File: asimpledisplay.h

package info (click to toggle)
aeskulap 0.2.2b1%2Bgit20161206-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 3,840 kB
  • ctags: 1,302
  • sloc: cpp: 8,894; sh: 5,551; ansic: 685; makefile: 317; xml: 25
file content (205 lines) | stat: -rw-r--r-- 5,281 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
/*
    Aeskulap - DICOM image viewer and network client
    Copyright (C) 2005  Alexander Pipelka

    This file is part of Aeskulap.

    Aeskulap is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    Aeskulap is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Aeskulap; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

    Alexander Pipelka
    pipelka@teleweb.at

    Last Update:      $Author: braindead $
    Update Date:      $Date: 2007/04/24 10:49:37 $
    Source File:      $Source: /cvsroot/aeskulap/aeskulap/widgets/asimpledisplay.h,v $
    CVS/RCS Revision: $Revision: 1.17 $
    Status:           $State: Exp $
*/

#ifndef AESKULAP_SIMPLEDISPLAY_H
#define AESKULAP_SIMPLEDISPLAY_H

#include <gtkmm.h>
#include <gdkmm/pixbuf.h>
#include <gdkmm/event.h>
#include <glibmm/refptr.h>
#include <glibmm/object.h>

#include "poolinstance.h"
#include "displayparameters.h"

namespace Aeskulap {

class SimpleDisplay : public Gtk::EventBox {
public:

	SimpleDisplay();

	SimpleDisplay(const Glib::RefPtr<DisplayParameters>& params);

	virtual ~SimpleDisplay();

	bool set_image(const Glib::RefPtr<ImagePool::Instance>& image, bool smooth = true);

	bool set_image(const Glib::RefPtr<ImagePool::Instance>& image, const Glib::RefPtr<DisplayParameters>& params, bool smooth);

	void set_windowlevels(int c, int w);

	void update();

	void refresh(bool smooth = true);

	void set_id(int id);
	
	int get_id();
	
	void render(Glib::RefPtr<Gdk::Pixbuf>& pixbuf, bool smooth);

	bool point_to_screen(const ImagePool::Instance::Point& p, int& x, int& y);

	bool point_to_screen(const ImagePool::Instance::Point& p, int& x, int& y, const Glib::RefPtr<ImagePool::Instance>& image);

	bool screen_to_image(int x, int y, ImagePool::Instance::Point& p);

	bool screen_to_point(int x, int y, ImagePool::Instance::Point& p);

	bool screen_to_point(int x, int y, ImagePool::Instance::Point& p, const Glib::RefPtr<ImagePool::Instance>& image);

	void set_current_frame(int frame);
	
	int get_current_frame();

	int get_framecount();

	const Aeskulap::WindowLevel& get_windowlevel();

	const Aeskulap::WindowLevel& get_default_windowlevel();

	void set_inverted(bool inverted);

	bool get_inverted();

	void play();
	
	void stop();

	bool get_playing();

	const Glib::RefPtr<ImagePool::Instance>& get_image();

	sigc::signal<void> signal_play;
	
	sigc::signal<void> signal_stop;
	
	sigc::signal<void, int> signal_next_frame;

protected:

	bool get_blit_rectangles(const Glib::RefPtr<Gdk::Pixbuf>& pixbuf, int& sx0, int& sy0, int& sx1, int& sy1, int& dx0, int& dy0, int& dx1, int& dy1);

	void on_realize();

	void on_unrealize();

	void on_check_resize();

	void on_size_request(Gtk::Requisition* requisition);
	
	void on_size_allocate(Gtk::Allocation& allocation);

	bool on_expose_event(GdkEventExpose* event);

	bool on_next_frame();

	virtual void bitstretch(bool smooth = false);

	void get_zoom_wh(int& w, int& h);

private:

	virtual void init_display();

	void linestretch_24to24(int x1, int x2, int y1, int y2, int yr, int yw, guint8* src_pixels, guint8* dst_pixels, guint8* lut);

	void rectstretch_24to24(guint8* src, int xs1, int ys1, int xs2, int ys2, const Glib::RefPtr<Gdk::Pixbuf>& pixbuf, int xd1, int yd1, int xd2, int yd2);

	template < class ST >
	void linestretch_24(int x1, int x2, int y1, int y2, int yr, int yw, ST src_pixels, guint8* dst_pixels, guint8* lut);

	template < class ST >
	void rectstretch_24(ST src, int xs1, int ys1, int xs2, int ys2, const Glib::RefPtr<Gdk::Pixbuf>& pixbuf, int xd1, int yd1, int xd2, int yd2);

	void rect_stretch8(int xs1, int ys1, int xs2, int ys2, int xd1, int yd1, int xd2, int yd2, const Glib::RefPtr<Gdk::Pixbuf>& pixbuf);

	void rect_stretch16(int xs1, int ys1, int xs2, int ys2, int xd1, int yd1, int xd2, int yd2, const Glib::RefPtr<Gdk::Pixbuf>& pixbuf);

	void rect_stretch24(int xs1, int ys1, int xs2, int ys2, int xd1, int yd1, int xd2, int yd2, const Glib::RefPtr<Gdk::Pixbuf>& pixbuf);

	void create_windowmap();

protected:

	// window(levels) map

	int m_windowmap_depth;

	guint8* m_windowmap;

	int m_windowmap_size;

	double m_magnifier;

	int m_id;
	
	int m_offset_left;

	int m_offset_right;
	
	// external references

	Glib::RefPtr<ImagePool::Instance> m_image;

	Glib::RefPtr<DisplayParameters> m_disp_params;

	Glib::RefPtr<Gdk::GC> m_GC;

	Glib::RefPtr<Gdk::Pixbuf> m_pixbuf;
	
	Glib::RefPtr<Pango::Context> m_pangoctx;

	Glib::RefPtr<Gdk::Window> m_window;

	Glib::RefPtr<Gdk::Colormap> m_colormap;

	Gdk::Color m_colorBackground;
	
	// multiframe

	bool m_playing;
	
	int m_current_frame;

	Glib::RefPtr<Gdk::Pixbuf> m_filmholes_left;

	Glib::RefPtr<Gdk::Pixbuf> m_filmholes_right;

	sigc::connection m_animation_source;

};

} // namespace Aeskulap

#endif // AESKULAP_SIMPLEDISPLAY_H