Mercurial > hg > orthanc-stone
annotate Framework/Widgets/WorldSceneWidget.h @ 160:e9dae7e7bffc wasm
fix
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 14 Feb 2018 09:18:06 +0100 |
parents | e2fe9352f240 |
children | fccffbf99ba1 |
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 | |
135
e2fe9352f240
upgrade to year 2018
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
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: | |
78 WorldSceneWidget() : | |
79 interactor_(NULL) | |
80 { | |
81 } | |
82 | |
83 void Register(IWorldObserver& observer) | |
84 { | |
85 observers_.Register(observer); | |
86 } | |
87 | |
88 void Unregister(IWorldObserver& observer) | |
89 { | |
90 observers_.Unregister(observer); | |
91 } | |
92 | |
93 virtual void SetSize(unsigned int width, | |
94 unsigned int height); | |
95 | |
96 void SetInteractor(IWorldSceneInteractor& interactor); | |
97 | |
61
ca644004d2ee
MAJOR - removal of Start/Stop and observers in IWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
59
diff
changeset
|
98 virtual void SetDefaultView(); |
0 | 99 |
100 void SetView(const ViewportGeometry& view); | |
101 | |
102 ViewportGeometry GetView(); | |
103 | |
104 virtual IMouseTracker* CreateMouseTracker(MouseButton button, | |
105 int x, | |
106 int y, | |
107 KeyboardModifiers modifiers); | |
108 | |
109 virtual void RenderSceneMouseOver(CairoContext& context, | |
110 const ViewportGeometry& view, | |
111 double x, | |
112 double y); | |
113 | |
114 virtual IWorldSceneMouseTracker* CreateMouseSceneTracker(const ViewportGeometry& view, | |
115 MouseButton button, | |
116 double x, | |
117 double y, | |
118 KeyboardModifiers modifiers); | |
119 | |
120 virtual void MouseWheel(MouseWheelDirection direction, | |
121 int x, | |
122 int y, | |
123 KeyboardModifiers modifiers); | |
124 | |
125 virtual void KeyPressed(char key, | |
126 KeyboardModifiers modifiers); | |
127 }; | |
128 } |