comparison Applications/Samples/Deprecated/SampleInteractor.h @ 1347:bfd77672d825 broker

Moved Application/Samples/* to Application/Samples/Deprecated/*
author Benjamin Golinvaux <bgo@osimis.io>
date Tue, 07 Apr 2020 14:29:01 +0200
parents Applications/Samples/SampleInteractor.h@8a0a62189f46
children c53a4667f895
comparison
equal deleted inserted replaced
1346:df8bf351c23f 1347:bfd77672d825
1 /**
2 * Stone of Orthanc
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
4 * Department, University Hospital of Liege, Belgium
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium
6 *
7 * This program is free software: you can redistribute it and/or
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.
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
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
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 **/
20
21
22 #pragma once
23
24 #include "SampleApplicationBase.h"
25
26 #include "../../Framework/Widgets/LayeredSceneWidget.h"
27 #include "../../Framework/Widgets/IWorldSceneInteractor.h"
28 #include "../../Framework/Toolbox/ParallelSlicesCursor.h"
29
30 namespace OrthancStone
31 {
32 namespace Samples
33 {
34 /**
35 * This is a basic mouse interactor for sample applications. It
36 * contains a set of parallel slices in the 3D space. The mouse
37 * wheel events make the widget change the slice that is
38 * displayed.
39 **/
40 class SampleInteractor : public IWorldSceneInteractor
41 {
42 private:
43 ParallelSlicesCursor cursor_;
44
45 public:
46 SampleInteractor(VolumeImage& volume,
47 VolumeProjection projection,
48 bool reverse)
49 {
50 std::unique_ptr<ParallelSlices> slices(volume.GetGeometry(projection, reverse));
51 cursor_.SetGeometry(*slices);
52 }
53
54 SampleInteractor(ISeriesLoader& series,
55 bool reverse)
56 {
57 if (reverse)
58 {
59 std::unique_ptr<ParallelSlices> slices(series.GetGeometry().Reverse());
60 cursor_.SetGeometry(*slices);
61 }
62 else
63 {
64 cursor_.SetGeometry(series.GetGeometry());
65 }
66 }
67
68 SampleInteractor(const ParallelSlices& slices)
69 {
70 cursor_.SetGeometry(slices);
71 }
72
73 ParallelSlicesCursor& GetCursor()
74 {
75 return cursor_;
76 }
77
78 void AddWidget(LayeredSceneWidget& widget)
79 {
80 widget.SetInteractor(*this);
81 widget.SetSlice(cursor_.GetCurrentSlice());
82 }
83
84 virtual IWorldSceneMouseTracker* CreateMouseTracker(WorldSceneWidget& widget,
85 const ViewportGeometry& view,
86 MouseButton button,
87 double x,
88 double y,
89 IStatusBar* statusBar)
90 {
91 return NULL;
92 }
93
94 virtual void MouseOver(CairoContext& context,
95 WorldSceneWidget& widget,
96 const ViewportGeometry& view,
97 double x,
98 double y,
99 IStatusBar* statusBar)
100 {
101 }
102
103 virtual void MouseWheel(WorldSceneWidget& widget,
104 MouseWheelDirection direction,
105 KeyboardModifiers modifiers,
106 IStatusBar* statusBar)
107 {
108 if (cursor_.ApplyWheelEvent(direction, modifiers))
109 {
110 dynamic_cast<LayeredSceneWidget&>(widget).SetSlice(cursor_.GetCurrentSlice());
111 }
112 }
113
114 virtual void KeyPressed(WorldSceneWidget& widget,
115 char key,
116 KeyboardModifiers modifiers,
117 IStatusBar* statusBar)
118 {
119 }
120
121 void LookupSliceContainingPoint(LayeredSceneWidget& widget,
122 const Vector& p)
123 {
124 if (cursor_.LookupSliceContainingPoint(p))
125 {
126 widget.SetSlice(cursor_.GetCurrentSlice());
127 }
128 }
129 };
130 }
131 }