annotate Applications/Samples/SingleFrameEditorApplication.h @ 325:37ab9d83dc9b am-2

reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
author am@osimis.io
date Tue, 16 Oct 2018 11:30:00 +0200
parents
children 612238b3f3e8
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 :
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
36 public SampleApplicationBase,
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_) {
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
75 case Tools_Crop:
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
76 case Tools_Windowing:
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
77 case Tools_Zoom:
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
78 case Tools_Pan:
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
79 // TODO return the right mouse tracker
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
80 return NULL;
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
81 }
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
82
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
83 return NULL;
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
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
86 virtual void MouseOver(CairoContext& context,
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
87 WorldSceneWidget& widget,
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
88 const ViewportGeometry& view,
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
89 double x,
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
90 double y,
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
91 IStatusBar* statusBar)
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
92 {
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
93 if (statusBar != NULL)
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 Vector p = dynamic_cast<LayerWidget&>(widget).GetSlice().MapSliceToWorldCoordinates(x, y);
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 char buf[64];
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
98 sprintf(buf, "X = %.02f Y = %.02f Z = %.02f (in cm)",
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
99 p[0] / 10.0, p[1] / 10.0, p[2] / 10.0);
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
100 statusBar->SetMessage(buf);
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
101 }
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
102 }
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 virtual void MouseWheel(WorldSceneWidget& widget,
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
105 MouseWheelDirection direction,
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
106 KeyboardModifiers modifiers,
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
107 IStatusBar* statusBar)
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
108 {
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
109 }
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 virtual void KeyPressed(WorldSceneWidget& widget,
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
112 char key,
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
113 KeyboardModifiers modifiers,
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
114 IStatusBar* statusBar)
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
115 {
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
116 switch (key)
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
117 {
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
118 case 's':
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
119 widget.SetDefaultView();
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
120 break;
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
121 case 'p':
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
122 application_.currentTool_ = Tools_Pan;
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 'z':
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
125 application_.currentTool_ = Tools_Zoom;
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 'c':
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
128 application_.currentTool_ = Tools_Crop;
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 'w':
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
131 application_.currentTool_ = Tools_Windowing;
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 'i':
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
134 application_.Invert();
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 'r':
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
137 if (modifiers == KeyboardModifiers_None)
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
138 application_.Rotate(90);
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
139 else
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
140 application_.Rotate(-90);
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
141 break;
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
142 case 'e':
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
143 application_.Export();
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 default:
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
146 break;
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
147 }
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
148 }
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
149 };
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 void OnMainWidgetGeometryReady(const ILayerSource::GeometryReadyMessage& message)
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 mainWidget_->SetDefaultView();
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
154 }
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
155
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
156 LayerWidget* mainWidget_; // ownership is transfered to the application context
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
157 std::unique_ptr<Interactor> mainWidgetInteractor_;
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
158 std::unique_ptr<OrthancApiClient> orthancApiClient_;
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
159 Tools currentTool_;
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
160
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
161 const OrthancFrameLayerSource* source_;
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
162 unsigned int slice_;
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 public:
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
165 SingleFrameEditorApplication(MessageBroker& broker) :
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
166 IObserver(broker),
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
167 currentTool_(Tools_Zoom),
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
168 source_(NULL),
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
169 slice_(0)
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
170 {
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
171 }
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
172
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
173 virtual void DeclareStartupOptions(boost::program_options::options_description& options)
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 boost::program_options::options_description generic("Sample options");
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
176 generic.add_options()
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
177 ("instance", boost::program_options::value<std::string>(),
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
178 "Orthanc ID of the instance")
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
179 ("frame", boost::program_options::value<unsigned int>()->default_value(0),
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
180 "Number of the frame, for multi-frame DICOM instances")
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
181 ;
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
182
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
183 options.add(generic);
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 virtual void Initialize(StoneApplicationContext* context,
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
187 IStatusBar& statusBar,
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
188 const boost::program_options::variables_map& parameters)
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
189 {
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
190 using namespace OrthancStone;
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
191
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
192 context_ = context;
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
193
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
194 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
195
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
196 if (parameters.count("instance") != 1)
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
197 {
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
198 LOG(ERROR) << "The instance ID is missing";
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
199 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
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
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
202 std::string instance = parameters["instance"].as<std::string>();
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
203 int frame = parameters["frame"].as<unsigned int>();
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 orthancApiClient_.reset(new OrthancApiClient(IObserver::broker_, context_->GetWebService()));
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
206 mainWidget_ = new LayerWidget(broker_, "main-widget");
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 std::auto_ptr<OrthancFrameLayerSource> layer(new OrthancFrameLayerSource(broker_, *orthancApiClient_));
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
209 source_ = layer.get();
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
210 layer->LoadFrame(instance, frame);
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
211 layer->RegisterObserverCallback(new Callable<SingleFrameEditorApplication, ILayerSource::GeometryReadyMessage>(*this, &SingleFrameEditorApplication::OnMainWidgetGeometryReady));
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
212 mainWidget_->AddLayer(layer.release());
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
213
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
214 mainWidget_->SetTransmitMouseOver(true);
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
215
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
216 mainWidgetInteractor_.reset(new Interactor(*this));
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
217 mainWidget_->SetInteractor(*mainWidgetInteractor_);
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
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
220 virtual void Finalize() {}
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
221 virtual IWidget* GetCentralWidget() {return mainWidget_;}
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 void Invert()
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
224 {
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
225 // TODO
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
226 }
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 void Rotate(int degrees)
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
229 {
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
230 // TODO
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
231 }
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 void Export()
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
234 {
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
235 // TODO: export dicom file to a temporary file
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
236 }
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 }