Mercurial > hg > orthanc-stone
comparison Samples/SampleInteractor.h @ 0:351ab0da0150
initial commit
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 14 Oct 2016 15:34:11 +0200 |
parents | |
children | 7207a407bcd8 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:351ab0da0150 |
---|---|
1 /** | |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
5 * | |
6 * This program is free software: you can redistribute it and/or | |
7 * modify it under the terms of the GNU General Public License as | |
8 * published by the Free Software Foundation, either version 3 of the | |
9 * License, or (at your option) any later version. | |
10 * | |
11 * In addition, as a special exception, the copyright holders of this | |
12 * program give permission to link the code of its release with the | |
13 * OpenSSL project's "OpenSSL" library (or with modified versions of it | |
14 * that use the same license as the "OpenSSL" library), and distribute | |
15 * the linked executables. You must obey the GNU General Public License | |
16 * in all respects for all of the code used other than "OpenSSL". If you | |
17 * modify file(s) with this exception, you may extend this exception to | |
18 * your version of the file(s), but you are not obligated to do so. If | |
19 * you do not wish to do so, delete this exception statement from your | |
20 * version. If you delete this exception statement from all source files | |
21 * in the program, then also delete it here. | |
22 * | |
23 * This program is distributed in the hope that it will be useful, but | |
24 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
26 * General Public License for more details. | |
27 * | |
28 * You should have received a copy of the GNU General Public License | |
29 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
30 **/ | |
31 | |
32 | |
33 #pragma once | |
34 | |
35 #include "SampleApplicationBase.h" | |
36 | |
37 #include "../Framework/Widgets/LayeredSceneWidget.h" | |
38 #include "../Framework/Widgets/IWorldSceneInteractor.h" | |
39 #include "../Framework/Toolbox/ParallelSlicesCursor.h" | |
40 | |
41 namespace OrthancStone | |
42 { | |
43 namespace Samples | |
44 { | |
45 /** | |
46 * This is a basic mouse interactor for sample applications. It | |
47 * contains a set of parallel slices in the 3D space. The mouse | |
48 * wheel events make the widget change the slice that is | |
49 * displayed. | |
50 **/ | |
51 class SampleInteractor : public IWorldSceneInteractor | |
52 { | |
53 private: | |
54 ParallelSlicesCursor cursor_; | |
55 | |
56 public: | |
57 SampleInteractor(VolumeImage& volume, | |
58 VolumeProjection projection, | |
59 bool reverse) | |
60 { | |
61 std::auto_ptr<ParallelSlices> slices(volume.GetGeometry(projection, reverse)); | |
62 cursor_.SetGeometry(*slices); | |
63 } | |
64 | |
65 SampleInteractor(ISeriesLoader& series, | |
66 bool reverse) | |
67 { | |
68 if (reverse) | |
69 { | |
70 std::auto_ptr<ParallelSlices> slices(series.GetGeometry().Reverse()); | |
71 cursor_.SetGeometry(*slices); | |
72 } | |
73 else | |
74 { | |
75 cursor_.SetGeometry(series.GetGeometry()); | |
76 } | |
77 } | |
78 | |
79 SampleInteractor(const ParallelSlices& slices) | |
80 { | |
81 cursor_.SetGeometry(slices); | |
82 } | |
83 | |
84 ParallelSlicesCursor& GetCursor() | |
85 { | |
86 return cursor_; | |
87 } | |
88 | |
89 void AddWidget(LayeredSceneWidget& widget) | |
90 { | |
91 widget.SetInteractor(*this); | |
92 widget.SetSlice(cursor_.GetCurrentSlice()); | |
93 } | |
94 | |
95 virtual IWorldSceneMouseTracker* CreateMouseTracker(WorldSceneWidget& widget, | |
96 const SliceGeometry& slice, | |
97 const ViewportGeometry& view, | |
98 MouseButton button, | |
99 double x, | |
100 double y, | |
101 IStatusBar* statusBar) | |
102 { | |
103 return NULL; | |
104 } | |
105 | |
106 virtual void MouseOver(CairoContext& context, | |
107 WorldSceneWidget& widget, | |
108 const SliceGeometry& slice, | |
109 const ViewportGeometry& view, | |
110 double x, | |
111 double y, | |
112 IStatusBar* statusBar) | |
113 { | |
114 } | |
115 | |
116 virtual void MouseWheel(WorldSceneWidget& widget, | |
117 MouseWheelDirection direction, | |
118 KeyboardModifiers modifiers, | |
119 IStatusBar* statusBar) | |
120 { | |
121 if (cursor_.ApplyWheelEvent(direction, modifiers)) | |
122 { | |
123 dynamic_cast<LayeredSceneWidget&>(widget).SetSlice(cursor_.GetCurrentSlice()); | |
124 } | |
125 } | |
126 | |
127 virtual void KeyPressed(WorldSceneWidget& widget, | |
128 char key, | |
129 KeyboardModifiers modifiers, | |
130 IStatusBar* statusBar) | |
131 { | |
132 } | |
133 | |
134 void LookupSliceContainingPoint(LayeredSceneWidget& widget, | |
135 const Vector& p) | |
136 { | |
137 if (cursor_.LookupSliceContainingPoint(p)) | |
138 { | |
139 widget.SetSlice(cursor_.GetCurrentSlice()); | |
140 } | |
141 } | |
142 }; | |
143 } | |
144 } |