Mercurial > hg > orthanc-stone
annotate Framework/Widgets/WorldSceneWidget.h @ 331:7ccf919faff0 am-2
simplify WorldSceneWidget
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 17 Oct 2018 15:18:48 +0200 |
parents | 7a364e44fbb4 |
children | 50e5ec1bdd46 |
rev | line source |
---|---|
0 | 1 /** |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
134
4cff7b1ed31d
upgrade to year 2018
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
5 * Copyright (C) 2017-2018 Osimis S.A., Belgium |
0 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
47 | 8 * modify it under the terms of the GNU Affero General Public License |
9 * as published by the Free Software Foundation, either version 3 of | |
10 * the License, or (at your option) any later version. | |
0 | 11 * |
12 * This program is distributed in the hope that it will be useful, but | |
13 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
47 | 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 * Affero General Public License for more details. | |
281 | 16 * |
47 | 17 * You should have received a copy of the GNU Affero General Public License |
0 | 18 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 **/ | |
20 | |
21 | |
22 #pragma once | |
23 | |
24 #include "CairoWidget.h" | |
25 #include "IWorldSceneInteractor.h" | |
26 | |
61
ca644004d2ee
MAJOR - removal of Start/Stop and observers in IWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
59
diff
changeset
|
27 #include "../Toolbox/ObserversRegistry.h" |
0 | 28 #include "../Toolbox/ViewportGeometry.h" |
29 | |
30 namespace OrthancStone | |
31 { | |
32 class WorldSceneWidget : public CairoWidget | |
33 { | |
34 public: | |
281 | 35 class PanMouseTracker : public IMouseTracker |
36 { | |
37 private: | |
38 WorldSceneWidget& that_; | |
39 double previousPanX_; | |
40 double previousPanY_; | |
41 double downX_; | |
42 double downY_; | |
43 | |
44 public: | |
45 PanMouseTracker(WorldSceneWidget& that, int x, int y); | |
46 | |
47 virtual void Render(Orthanc::ImageAccessor& surface) {} | |
48 | |
49 virtual void MouseUp() {} | |
50 | |
51 virtual void MouseMove(int x, int y); | |
52 }; | |
53 | |
54 class ZoomMouseTracker : public IMouseTracker | |
55 { | |
56 private: | |
57 WorldSceneWidget& that_; | |
58 int downX_; | |
59 int downY_; | |
60 double centerX_; | |
61 double centerY_; | |
62 double oldZoom_; | |
63 | |
64 public: | |
65 ZoomMouseTracker(WorldSceneWidget& that, int x, int y); | |
66 | |
67 void Render(Orthanc::ImageAccessor& surface) {} | |
68 | |
69 virtual void MouseUp() {} | |
70 | |
71 virtual void MouseMove(int x, int y); | |
72 }; | |
73 | |
0 | 74 private: |
75 class SceneMouseTracker; | |
76 | |
53
c2dc924f1a63
removing threading out of the framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
77 ViewportGeometry view_; |
c2dc924f1a63
removing threading out of the framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
78 IWorldSceneInteractor* interactor_; |
0 | 79 |
331
7ccf919faff0
simplify WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
330
diff
changeset
|
80 protected: |
112
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
111
diff
changeset
|
81 virtual Extent2D GetSceneExtent() = 0; |
0 | 82 |
83 virtual bool RenderScene(CairoContext& context, | |
84 const ViewportGeometry& view) = 0; | |
85 | |
331
7ccf919faff0
simplify WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
330
diff
changeset
|
86 // From CairoWidget |
0 | 87 virtual bool RenderCairo(CairoContext& context); |
88 | |
331
7ccf919faff0
simplify WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
330
diff
changeset
|
89 // From CairoWidget |
0 | 90 virtual void RenderMouseOverCairo(CairoContext& context, |
91 int x, | |
92 int y); | |
93 | |
53
c2dc924f1a63
removing threading out of the framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
94 void SetSceneExtent(ViewportGeometry& geometry); |
0 | 95 |
96 public: | |
273
f21ba2468570
force all Widgets to have a name to ease debugging
am@osimis.io
parents:
196
diff
changeset
|
97 WorldSceneWidget(const std::string& name) : |
f21ba2468570
force all Widgets to have a name to ease debugging
am@osimis.io
parents:
196
diff
changeset
|
98 CairoWidget(name), |
0 | 99 interactor_(NULL) |
100 { | |
101 } | |
102 | |
103 void SetInteractor(IWorldSceneInteractor& interactor); | |
104 | |
105 void SetView(const ViewportGeometry& view); | |
106 | |
107 ViewportGeometry GetView(); | |
108 | |
331
7ccf919faff0
simplify WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
330
diff
changeset
|
109 virtual void SetSize(unsigned int width, |
7ccf919faff0
simplify WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
330
diff
changeset
|
110 unsigned int height); |
7ccf919faff0
simplify WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
330
diff
changeset
|
111 |
7ccf919faff0
simplify WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
330
diff
changeset
|
112 virtual void FitContent(); |
7ccf919faff0
simplify WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
330
diff
changeset
|
113 |
0 | 114 virtual IMouseTracker* CreateMouseTracker(MouseButton button, |
115 int x, | |
116 int y, | |
117 KeyboardModifiers modifiers); | |
118 | |
119 virtual void MouseWheel(MouseWheelDirection direction, | |
120 int x, | |
121 int y, | |
122 KeyboardModifiers modifiers); | |
123 | |
327 | 124 virtual void KeyPressed(KeyboardKeys key, |
125 char keyChar, | |
0 | 126 KeyboardModifiers modifiers); |
127 }; | |
128 } |