annotate Applications/Samples/SingleFrameEditorApplication.h @ 330:7a364e44fbb4 am-2

renamed SetDefaultView in FitContent
author am@osimis.io
date Wed, 17 Oct 2018 12:45:52 +0200
parents b10dfdb96866
children c34784e5f299
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
325
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
1 /**
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
2 * Stone of Orthanc
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
5 * Copyright (C) 2017-2018 Osimis S.A., Belgium
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
6 *
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
8 * modify it under the terms of the GNU Affero General Public License
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
10 * the License, or (at your option) any later version.
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
11 *
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
15 * Affero General Public License for more details.
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
16 *
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
17 * You should have received a copy of the GNU Affero General Public License
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
19 **/
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
20
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
21
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
22 #pragma once
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
23
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
24 #include "SampleApplicationBase.h"
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
25
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
26 #include "../../Framework/Layers/OrthancFrameLayerSource.h"
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
27 #include "../../Framework/Widgets/LayerWidget.h"
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
28
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
29 #include <Core/Logging.h>
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
30
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
31 namespace OrthancStone
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
32 {
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
33 namespace Samples
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
34 {
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
35 class SingleFrameEditorApplication :
326
612238b3f3e8 all 4 samples now working in Qt, SDL and wasm
am@osimis.io
parents: 325
diff changeset
36 public SampleSingleCanvasApplicationBase,
325
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
37 public IObserver
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
38 {
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
39 enum Tools
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
40 {
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
41 Tools_Crop,
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
42 Tools_Windowing,
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
43 Tools_Zoom,
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
44 Tools_Pan
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
45 };
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
46
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
47 enum Actions
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
48 {
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
49 Actions_Invert,
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
50 Actions_RotateLeft,
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
51 Actions_RotateRight
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
52 };
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
53
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
54 private:
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
55 class Interactor : public IWorldSceneInteractor
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
56 {
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
57 private:
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
58 SingleFrameEditorApplication& application_;
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
59
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
60 public:
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
61 Interactor(SingleFrameEditorApplication& application) :
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
62 application_(application)
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
63 {
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
64 }
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
65
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
66 virtual IWorldSceneMouseTracker* CreateMouseTracker(WorldSceneWidget& widget,
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
67 const ViewportGeometry& view,
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
68 MouseButton button,
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
69 KeyboardModifiers modifiers,
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
70 double x,
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
71 double y,
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
72 IStatusBar* statusBar)
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
73 {
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
74 switch (application_.currentTool_) {
329
b10dfdb96866 removing WorldSceneWidget::IWorldObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 327
diff changeset
75 case Tools_Zoom:
b10dfdb96866 removing WorldSceneWidget::IWorldObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 327
diff changeset
76 printf("ZOOM\n");
b10dfdb96866 removing WorldSceneWidget::IWorldObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 327
diff changeset
77
b10dfdb96866 removing WorldSceneWidget::IWorldObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 327
diff changeset
78 case Tools_Crop:
325
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
79 case Tools_Windowing:
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
80 case Tools_Pan:
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
81 // TODO return the right mouse tracker
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
82 return NULL;
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
83 }
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
84
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
85 return NULL;
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
86 }
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
87
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
88 virtual void MouseOver(CairoContext& context,
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
89 WorldSceneWidget& widget,
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
90 const ViewportGeometry& view,
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
91 double x,
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
92 double y,
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
93 IStatusBar* statusBar)
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
94 {
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
95 if (statusBar != NULL)
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
96 {
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
97 Vector p = dynamic_cast<LayerWidget&>(widget).GetSlice().MapSliceToWorldCoordinates(x, y);
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
98
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
99 char buf[64];
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
100 sprintf(buf, "X = %.02f Y = %.02f Z = %.02f (in cm)",
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
101 p[0] / 10.0, p[1] / 10.0, p[2] / 10.0);
329
b10dfdb96866 removing WorldSceneWidget::IWorldObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 327
diff changeset
102 //statusBar->SetMessage(buf);
325
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
103 }
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
104 }
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
105
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
106 virtual void MouseWheel(WorldSceneWidget& widget,
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
107 MouseWheelDirection direction,
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
108 KeyboardModifiers modifiers,
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
109 IStatusBar* statusBar)
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
110 {
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
111 }
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
112
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
113 virtual void KeyPressed(WorldSceneWidget& widget,
327
8716176ff7f0 added support for arrow keys
am@osimis.io
parents: 326
diff changeset
114 KeyboardKeys key,
8716176ff7f0 added support for arrow keys
am@osimis.io
parents: 326
diff changeset
115 char keyChar,
325
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
116 KeyboardModifiers modifiers,
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
117 IStatusBar* statusBar)
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
118 {
327
8716176ff7f0 added support for arrow keys
am@osimis.io
parents: 326
diff changeset
119 switch (keyChar)
325
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
120 {
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
121 case 's':
330
7a364e44fbb4 renamed SetDefaultView in FitContent
am@osimis.io
parents: 329
diff changeset
122 widget.FitContent();
325
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
123 break;
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
124 case 'p':
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
125 application_.currentTool_ = Tools_Pan;
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
126 break;
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
127 case 'z':
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
128 application_.currentTool_ = Tools_Zoom;
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
129 break;
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
130 case 'c':
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
131 application_.currentTool_ = Tools_Crop;
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
132 break;
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
133 case 'w':
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
134 application_.currentTool_ = Tools_Windowing;
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
135 break;
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
136 case 'i':
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
137 application_.Invert();
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
138 break;
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
139 case 'r':
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
140 if (modifiers == KeyboardModifiers_None)
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
141 application_.Rotate(90);
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
142 else
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
143 application_.Rotate(-90);
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
144 break;
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
145 case 'e':
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
146 application_.Export();
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
147 break;
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
148 default:
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
149 break;
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
150 }
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
151 }
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
152 };
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
153
329
b10dfdb96866 removing WorldSceneWidget::IWorldObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 327
diff changeset
154 void OnGeometryChanged(const LayerWidget::GeometryChangedMessage& message)
325
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
155 {
329
b10dfdb96866 removing WorldSceneWidget::IWorldObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 327
diff changeset
156 mainWidget_->SetSlice(source_->GetSlice(slice_).GetGeometry());
330
7a364e44fbb4 renamed SetDefaultView in FitContent
am@osimis.io
parents: 329
diff changeset
157 mainWidget_->FitContent();
325
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
158 }
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
159
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
160 std::unique_ptr<Interactor> mainWidgetInteractor_;
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
161 std::unique_ptr<OrthancApiClient> orthancApiClient_;
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
162 Tools currentTool_;
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
163
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
164 const OrthancFrameLayerSource* source_;
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
165 unsigned int slice_;
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
166
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
167 public:
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
168 SingleFrameEditorApplication(MessageBroker& broker) :
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
169 IObserver(broker),
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
170 currentTool_(Tools_Zoom),
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
171 source_(NULL),
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
172 slice_(0)
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
173 {
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
174 }
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
175
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
176 virtual void DeclareStartupOptions(boost::program_options::options_description& options)
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
177 {
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
178 boost::program_options::options_description generic("Sample options");
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
179 generic.add_options()
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
180 ("instance", boost::program_options::value<std::string>(),
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
181 "Orthanc ID of the instance")
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
182 ("frame", boost::program_options::value<unsigned int>()->default_value(0),
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
183 "Number of the frame, for multi-frame DICOM instances")
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
184 ;
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
185
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
186 options.add(generic);
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
187 }
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
188
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
189 virtual void Initialize(StoneApplicationContext* context,
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
190 IStatusBar& statusBar,
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
191 const boost::program_options::variables_map& parameters)
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
192 {
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
193 using namespace OrthancStone;
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
194
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
195 context_ = context;
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
196
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
197 statusBar.SetMessage("Use the key \"s\" to reinitialize the layout, \"p\" to pan, \"z\" to zoom, \"c\" to crop, \"i\" to invert, \"w\" to change windowing, \"r\" to rotate cw, \"shift+r\" to rotate ccw");
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
198
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
199 if (parameters.count("instance") != 1)
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
200 {
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
201 LOG(ERROR) << "The instance ID is missing";
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
202 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
203 }
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
204
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
205 std::string instance = parameters["instance"].as<std::string>();
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
206 int frame = parameters["frame"].as<unsigned int>();
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
207
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
208 orthancApiClient_.reset(new OrthancApiClient(IObserver::broker_, context_->GetWebService()));
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
209 mainWidget_ = new LayerWidget(broker_, "main-widget");
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
210
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
211 std::auto_ptr<OrthancFrameLayerSource> layer(new OrthancFrameLayerSource(broker_, *orthancApiClient_));
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
212 source_ = layer.get();
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
213 layer->LoadFrame(instance, frame);
329
b10dfdb96866 removing WorldSceneWidget::IWorldObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 327
diff changeset
214 mainWidget_->RegisterObserverCallback(new Callable<SingleFrameEditorApplication, LayerWidget::GeometryChangedMessage>(*this, &SingleFrameEditorApplication::OnGeometryChanged));
325
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
215 mainWidget_->AddLayer(layer.release());
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
216
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
217 mainWidget_->SetTransmitMouseOver(true);
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
218
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
219 mainWidgetInteractor_.reset(new Interactor(*this));
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
220 mainWidget_->SetInteractor(*mainWidgetInteractor_);
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
221 }
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
222
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
223
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
224 void Invert()
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
225 {
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
226 // TODO
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
227 }
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
228
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
229 void Rotate(int degrees)
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
230 {
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
231 // TODO
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
232 }
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
233
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
234 void Export()
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
235 {
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
236 // TODO: export dicom file to a temporary file
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
237 }
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
238 };
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
239
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
240
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
241 }
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
242 }