Mercurial > hg > orthanc-stone
annotate Framework/Widgets/WorldSceneWidget.h @ 274:dc1beee33134 am-2
split SdlApplication into NativeApplication and SdlApplication
author | am@osimis.io |
---|---|
date | Fri, 24 Aug 2018 13:52:55 +0200 |
parents | f21ba2468570 |
children | 300d8b8c48b3 |
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. | |
16 * | |
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: | |
35 class IWorldObserver : public boost::noncopyable | |
36 { | |
37 public: | |
38 virtual ~IWorldObserver() | |
39 { | |
40 } | |
41 | |
42 virtual void NotifySizeChange(const WorldSceneWidget& source, | |
43 ViewportGeometry& view) = 0; // Can be tuned by the observer | |
44 | |
45 virtual void NotifyViewChange(const WorldSceneWidget& source, | |
46 const ViewportGeometry& view) = 0; | |
47 }; | |
48 | |
49 private: | |
50 struct SizeChangeFunctor; | |
51 | |
52 class SceneMouseTracker; | |
53 class PanMouseTracker; | |
54 class ZoomMouseTracker; | |
55 | |
56 typedef ObserversRegistry<WorldSceneWidget, IWorldObserver> Observers; | |
57 | |
53
c2dc924f1a63
removing threading out of the framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
58 ViewportGeometry view_; |
c2dc924f1a63
removing threading out of the framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
59 Observers observers_; |
c2dc924f1a63
removing threading out of the framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
60 IWorldSceneInteractor* interactor_; |
0 | 61 |
112
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
111
diff
changeset
|
62 public: |
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
111
diff
changeset
|
63 virtual Extent2D GetSceneExtent() = 0; |
0 | 64 |
65 protected: | |
66 virtual bool RenderScene(CairoContext& context, | |
67 const ViewportGeometry& view) = 0; | |
68 | |
69 virtual bool RenderCairo(CairoContext& context); | |
70 | |
71 virtual void RenderMouseOverCairo(CairoContext& context, | |
72 int x, | |
73 int y); | |
74 | |
53
c2dc924f1a63
removing threading out of the framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
75 void SetSceneExtent(ViewportGeometry& geometry); |
0 | 76 |
77 public: | |
273
f21ba2468570
force all Widgets to have a name to ease debugging
am@osimis.io
parents:
196
diff
changeset
|
78 WorldSceneWidget(const std::string& name) : |
f21ba2468570
force all Widgets to have a name to ease debugging
am@osimis.io
parents:
196
diff
changeset
|
79 CairoWidget(name), |
0 | 80 interactor_(NULL) |
81 { | |
82 } | |
83 | |
84 void Register(IWorldObserver& observer) | |
85 { | |
86 observers_.Register(observer); | |
87 } | |
88 | |
89 void Unregister(IWorldObserver& observer) | |
90 { | |
91 observers_.Unregister(observer); | |
92 } | |
93 | |
94 virtual void SetSize(unsigned int width, | |
95 unsigned int height); | |
96 | |
97 void SetInteractor(IWorldSceneInteractor& interactor); | |
98 | |
61
ca644004d2ee
MAJOR - removal of Start/Stop and observers in IWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
59
diff
changeset
|
99 virtual void SetDefaultView(); |
0 | 100 |
101 void SetView(const ViewportGeometry& view); | |
102 | |
103 ViewportGeometry GetView(); | |
104 | |
105 virtual IMouseTracker* CreateMouseTracker(MouseButton button, | |
106 int x, | |
107 int y, | |
108 KeyboardModifiers modifiers); | |
109 | |
110 virtual void RenderSceneMouseOver(CairoContext& context, | |
111 const ViewportGeometry& view, | |
112 double x, | |
113 double y); | |
114 | |
115 virtual IWorldSceneMouseTracker* CreateMouseSceneTracker(const ViewportGeometry& view, | |
116 MouseButton button, | |
117 double x, | |
118 double y, | |
119 KeyboardModifiers modifiers); | |
120 | |
121 virtual void MouseWheel(MouseWheelDirection direction, | |
122 int x, | |
123 int y, | |
124 KeyboardModifiers modifiers); | |
125 | |
126 virtual void KeyPressed(char key, | |
127 KeyboardModifiers modifiers); | |
128 }; | |
129 } |