Mercurial > hg > orthanc-stone
annotate Framework/Widgets/WorldSceneWidget.h @ 46:766d31dc5716 wasm
removing threads for wasm
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 19 Apr 2017 14:33:06 +0200 |
parents | 7207a407bcd8 |
children | 25befef48c35 |
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 | |
40
7207a407bcd8
shared copyright with osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
5 * Copyright (C) 2017 Osimis, Belgium |
0 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
8 * modify it under the terms of the GNU General Public License as | |
9 * published by the Free Software Foundation, either version 3 of the | |
10 * License, or (at your option) any later version. | |
11 * | |
12 * In addition, as a special exception, the copyright holders of this | |
13 * program give permission to link the code of its release with the | |
14 * OpenSSL project's "OpenSSL" library (or with modified versions of it | |
15 * that use the same license as the "OpenSSL" library), and distribute | |
16 * the linked executables. You must obey the GNU General Public License | |
17 * in all respects for all of the code used other than "OpenSSL". If you | |
18 * modify file(s) with this exception, you may extend this exception to | |
19 * your version of the file(s), but you are not obligated to do so. If | |
20 * you do not wish to do so, delete this exception statement from your | |
21 * version. If you delete this exception statement from all source files | |
22 * in the program, then also delete it here. | |
23 * | |
24 * This program is distributed in the hope that it will be useful, but | |
25 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
27 * General Public License for more details. | |
28 * | |
29 * You should have received a copy of the GNU General Public License | |
30 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
31 **/ | |
32 | |
33 | |
34 #pragma once | |
35 | |
36 #include "CairoWidget.h" | |
37 #include "IWorldSceneInteractor.h" | |
38 | |
39 #include "../Toolbox/SharedValue.h" | |
40 #include "../Toolbox/ViewportGeometry.h" | |
41 | |
42 namespace OrthancStone | |
43 { | |
44 class WorldSceneWidget : public CairoWidget | |
45 { | |
46 public: | |
47 // Must be thread-safe | |
48 class IWorldObserver : public boost::noncopyable | |
49 { | |
50 public: | |
51 virtual ~IWorldObserver() | |
52 { | |
53 } | |
54 | |
55 virtual void NotifySizeChange(const WorldSceneWidget& source, | |
56 ViewportGeometry& view) = 0; // Can be tuned by the observer | |
57 | |
58 virtual void NotifyViewChange(const WorldSceneWidget& source, | |
59 const ViewportGeometry& view) = 0; | |
60 }; | |
61 | |
62 private: | |
63 struct ViewChangeFunctor; | |
64 struct SizeChangeFunctor; | |
65 | |
66 class SceneMouseTracker; | |
67 class PanMouseTracker; | |
68 class ZoomMouseTracker; | |
69 | |
70 typedef ObserversRegistry<WorldSceneWidget, IWorldObserver> Observers; | |
71 | |
72 SharedValue<ViewportGeometry> view_; | |
73 Observers observers_; | |
74 IWorldSceneInteractor* interactor_; | |
75 | |
76 | |
77 protected: | |
78 virtual bool RenderScene(CairoContext& context, | |
79 const ViewportGeometry& view) = 0; | |
80 | |
81 virtual bool RenderCairo(CairoContext& context); | |
82 | |
83 virtual void RenderMouseOverCairo(CairoContext& context, | |
84 int x, | |
85 int y); | |
86 | |
87 void SetSceneExtent(SharedValue<ViewportGeometry>::Locker& locker); | |
88 | |
89 public: | |
90 WorldSceneWidget() : | |
91 interactor_(NULL) | |
92 { | |
93 } | |
94 | |
95 using WidgetBase::Register; | |
96 using WidgetBase::Unregister; | |
97 | |
98 void Register(IWorldObserver& observer) | |
99 { | |
100 observers_.Register(observer); | |
101 } | |
102 | |
103 void Unregister(IWorldObserver& observer) | |
104 { | |
105 observers_.Unregister(observer); | |
106 } | |
107 | |
46
766d31dc5716
removing threads for wasm
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
40
diff
changeset
|
108 virtual SliceGeometry GetSlice() |
766d31dc5716
removing threads for wasm
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
40
diff
changeset
|
109 { |
766d31dc5716
removing threads for wasm
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
40
diff
changeset
|
110 return SliceGeometry(); |
766d31dc5716
removing threads for wasm
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
40
diff
changeset
|
111 } |
0 | 112 |
113 virtual void GetSceneExtent(double& x1, | |
114 double& y1, | |
115 double& x2, | |
116 double& y2) = 0; | |
117 | |
118 virtual void SetSize(unsigned int width, | |
119 unsigned int height); | |
120 | |
121 void SetInteractor(IWorldSceneInteractor& interactor); | |
122 | |
123 virtual void Start(); | |
124 | |
125 void SetDefaultView(); | |
126 | |
127 void SetView(const ViewportGeometry& view); | |
128 | |
129 ViewportGeometry GetView(); | |
130 | |
131 virtual IMouseTracker* CreateMouseTracker(MouseButton button, | |
132 int x, | |
133 int y, | |
134 KeyboardModifiers modifiers); | |
135 | |
136 virtual void RenderSceneMouseOver(CairoContext& context, | |
137 const ViewportGeometry& view, | |
138 double x, | |
139 double y); | |
140 | |
141 virtual IWorldSceneMouseTracker* CreateMouseSceneTracker(const ViewportGeometry& view, | |
142 MouseButton button, | |
143 double x, | |
144 double y, | |
145 KeyboardModifiers modifiers); | |
146 | |
147 virtual void MouseWheel(MouseWheelDirection direction, | |
148 int x, | |
149 int y, | |
150 KeyboardModifiers modifiers); | |
151 | |
152 virtual void KeyPressed(char key, | |
153 KeyboardModifiers modifiers); | |
154 }; | |
155 } |