Mercurial > hg > orthanc-stone
annotate Applications/Samples/SingleFrameEditorApplication.h @ 457:3b4df9925db6 am-touch-events
added support for 'touch' in mouse trackers. This is still a bit hacky and we need to refactor it to make it clean. Thanks to that, Pan and zoom are available together with 2 touches
author | Alain Mazy <alain@mazy.be> |
---|---|
date | Thu, 24 Jan 2019 16:42:27 +0100 |
parents | a750f11892ec |
children | 3c28542229a3 |
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 |
439 | 5 * Copyright (C) 2017-2019 Osimis S.A., Belgium |
325
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 |
415
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
414
diff
changeset
|
26 #include "../../Framework/Radiography/RadiographyLayerCropTracker.h" |
414 | 27 #include "../../Framework/Radiography/RadiographyLayerMoveTracker.h" |
415
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
414
diff
changeset
|
28 #include "../../Framework/Radiography/RadiographyLayerResizeTracker.h" |
414 | 29 #include "../../Framework/Radiography/RadiographyLayerRotateTracker.h" |
408 | 30 #include "../../Framework/Radiography/RadiographyScene.h" |
414 | 31 #include "../../Framework/Radiography/RadiographySceneCommand.h" |
413 | 32 #include "../../Framework/Radiography/RadiographyWidget.h" |
415
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
414
diff
changeset
|
33 #include "../../Framework/Radiography/RadiographyWindowingTracker.h" |
430 | 34 #include "../../Framework/Radiography/RadiographySceneWriter.h" |
35 #include "../../Framework/Radiography/RadiographySceneReader.h" | |
359
100df90bf0ea
preparing to implement Export
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
358
diff
changeset
|
36 |
418 | 37 #include <Core/HttpClient.h> |
343 | 38 #include <Core/Images/FontRegistry.h> |
325
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
39 #include <Core/Logging.h> |
403 | 40 #include <Core/OrthancException.h> |
325
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
41 |
407 | 42 |
43 // Export using PAM is faster than using PNG, but requires Orthanc | |
44 // core >= 1.4.3 | |
362
12cec26d08ce
export of a valid DICOM CR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
361
diff
changeset
|
45 #define EXPORT_USING_PAM 1 |
12cec26d08ce
export of a valid DICOM CR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
361
diff
changeset
|
46 |
340
f5d5814a41a0
rendering BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
339
diff
changeset
|
47 |
325
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
48 namespace OrthancStone |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
49 { |
407 | 50 namespace Samples |
358 | 51 { |
408 | 52 class RadiographyEditorInteractor : |
430 | 53 public IWorldSceneInteractor, |
54 public IObserver | |
358 | 55 { |
407 | 56 private: |
57 enum Tool | |
58 { | |
59 Tool_Move, | |
60 Tool_Rotate, | |
61 Tool_Crop, | |
62 Tool_Resize, | |
63 Tool_Windowing | |
64 }; | |
430 | 65 |
358 | 66 |
417
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
415
diff
changeset
|
67 StoneApplicationContext* context_; |
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
415
diff
changeset
|
68 UndoRedoStack undoRedoStack_; |
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
415
diff
changeset
|
69 Tool tool_; |
407 | 70 |
71 | |
72 static double GetHandleSize() | |
73 { | |
74 return 10.0; | |
75 } | |
430 | 76 |
77 | |
407 | 78 public: |
408 | 79 RadiographyEditorInteractor(MessageBroker& broker) : |
407 | 80 IObserver(broker), |
417
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
415
diff
changeset
|
81 context_(NULL), |
407 | 82 tool_(Tool_Move) |
83 { | |
84 } | |
417
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
415
diff
changeset
|
85 |
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
415
diff
changeset
|
86 void SetContext(StoneApplicationContext& context) |
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
415
diff
changeset
|
87 { |
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
415
diff
changeset
|
88 context_ = &context; |
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
415
diff
changeset
|
89 } |
430 | 90 |
407 | 91 virtual IWorldSceneMouseTracker* CreateMouseTracker(WorldSceneWidget& worldWidget, |
92 const ViewportGeometry& view, | |
93 MouseButton button, | |
94 KeyboardModifiers modifiers, | |
95 int viewportX, | |
96 int viewportY, | |
97 double x, | |
98 double y, | |
457
3b4df9925db6
added support for 'touch' in mouse trackers. This is still a bit hacky and we need to refactor it to make it clean. Thanks to that, Pan and zoom are available together with 2 touches
Alain Mazy <alain@mazy.be>
parents:
440
diff
changeset
|
99 IStatusBar* statusBar, |
3b4df9925db6
added support for 'touch' in mouse trackers. This is still a bit hacky and we need to refactor it to make it clean. Thanks to that, Pan and zoom are available together with 2 touches
Alain Mazy <alain@mazy.be>
parents:
440
diff
changeset
|
100 const std::vector<Touch>& displayTouches) |
357
ec4ad6c5eb99
avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
356
diff
changeset
|
101 { |
408 | 102 RadiographyWidget& widget = dynamic_cast<RadiographyWidget&>(worldWidget); |
407 | 103 |
104 if (button == MouseButton_Left) | |
358 | 105 { |
407 | 106 size_t selected; |
430 | 107 |
407 | 108 if (tool_ == Tool_Windowing) |
358 | 109 { |
408 | 110 return new RadiographyWindowingTracker( |
430 | 111 undoRedoStack_, widget.GetScene(), |
112 viewportX, viewportY, | |
113 RadiographyWindowingTracker::Action_DecreaseWidth, | |
114 RadiographyWindowingTracker::Action_IncreaseWidth, | |
115 RadiographyWindowingTracker::Action_DecreaseCenter, | |
116 RadiographyWindowingTracker::Action_IncreaseCenter); | |
358 | 117 } |
407 | 118 else if (!widget.LookupSelectedLayer(selected)) |
358 | 119 { |
407 | 120 // No layer is currently selected |
121 size_t layer; | |
122 if (widget.GetScene().LookupLayer(layer, x, y)) | |
358 | 123 { |
407 | 124 widget.Select(layer); |
358 | 125 } |
407 | 126 |
127 return NULL; | |
358 | 128 } |
407 | 129 else if (tool_ == Tool_Crop || |
130 tool_ == Tool_Resize) | |
358 | 131 { |
408 | 132 RadiographyScene::LayerAccessor accessor(widget.GetScene(), selected); |
410
6decc0ba9da5
rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
408
diff
changeset
|
133 |
6decc0ba9da5
rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
408
diff
changeset
|
134 Corner corner; |
407 | 135 if (accessor.GetLayer().LookupCorner(corner, x, y, view.GetZoom(), GetHandleSize())) |
358 | 136 { |
407 | 137 switch (tool_) |
138 { | |
430 | 139 case Tool_Crop: |
140 return new RadiographyLayerCropTracker | |
408 | 141 (undoRedoStack_, widget.GetScene(), view, selected, x, y, corner); |
407 | 142 |
430 | 143 case Tool_Resize: |
144 return new RadiographyLayerResizeTracker | |
408 | 145 (undoRedoStack_, widget.GetScene(), selected, x, y, corner, |
146 (modifiers & KeyboardModifiers_Shift)); | |
407 | 147 |
430 | 148 default: |
149 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | |
407 | 150 } |
384
d20d75f20c5d
better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
377
diff
changeset
|
151 } |
d20d75f20c5d
better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
377
diff
changeset
|
152 else |
d20d75f20c5d
better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
377
diff
changeset
|
153 { |
407 | 154 size_t layer; |
430 | 155 |
407 | 156 if (widget.GetScene().LookupLayer(layer, x, y)) |
384
d20d75f20c5d
better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
377
diff
changeset
|
157 { |
407 | 158 widget.Select(layer); |
384
d20d75f20c5d
better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
377
diff
changeset
|
159 } |
407 | 160 else |
161 { | |
162 widget.Unselect(); | |
163 } | |
430 | 164 |
384
d20d75f20c5d
better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
377
diff
changeset
|
165 return NULL; |
d20d75f20c5d
better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
377
diff
changeset
|
166 } |
358 | 167 } |
168 else | |
169 { | |
407 | 170 size_t layer; |
171 | |
172 if (widget.GetScene().LookupLayer(layer, x, y)) | |
173 { | |
174 if (layer == selected) | |
175 { | |
176 switch (tool_) | |
177 { | |
430 | 178 case Tool_Move: |
179 return new RadiographyLayerMoveTracker | |
408 | 180 (undoRedoStack_, widget.GetScene(), layer, x, y, |
181 (modifiers & KeyboardModifiers_Shift)); | |
407 | 182 |
430 | 183 case Tool_Rotate: |
184 return new RadiographyLayerRotateTracker | |
408 | 185 (undoRedoStack_, widget.GetScene(), view, layer, x, y, |
186 (modifiers & KeyboardModifiers_Shift)); | |
430 | 187 |
188 default: | |
189 break; | |
407 | 190 } |
191 | |
192 return NULL; | |
193 } | |
194 else | |
195 { | |
196 widget.Select(layer); | |
197 return NULL; | |
198 } | |
199 } | |
200 else | |
201 { | |
202 widget.Unselect(); | |
203 return NULL; | |
204 } | |
205 } | |
206 } | |
207 else | |
208 { | |
209 return NULL; | |
210 } | |
211 } | |
212 | |
213 virtual void MouseOver(CairoContext& context, | |
214 WorldSceneWidget& worldWidget, | |
215 const ViewportGeometry& view, | |
216 double x, | |
217 double y, | |
218 IStatusBar* statusBar) | |
219 { | |
408 | 220 RadiographyWidget& widget = dynamic_cast<RadiographyWidget&>(worldWidget); |
407 | 221 |
222 #if 0 | |
223 if (statusBar != NULL) | |
224 { | |
225 char buf[64]; | |
226 sprintf(buf, "X = %.02f Y = %.02f (in cm)", x / 10.0, y / 10.0); | |
227 statusBar->SetMessage(buf); | |
228 } | |
229 #endif | |
230 | |
231 size_t selected; | |
232 | |
233 if (widget.LookupSelectedLayer(selected) && | |
234 (tool_ == Tool_Crop || | |
235 tool_ == Tool_Resize)) | |
236 { | |
408 | 237 RadiographyScene::LayerAccessor accessor(widget.GetScene(), selected); |
430 | 238 |
410
6decc0ba9da5
rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
408
diff
changeset
|
239 Corner corner; |
407 | 240 if (accessor.GetLayer().LookupCorner(corner, x, y, view.GetZoom(), GetHandleSize())) |
241 { | |
242 accessor.GetLayer().GetCorner(x, y, corner); | |
430 | 243 |
407 | 244 double z = 1.0 / view.GetZoom(); |
430 | 245 |
407 | 246 context.SetSourceColor(255, 0, 0); |
247 cairo_t* cr = context.GetObject(); | |
248 cairo_set_line_width(cr, 2.0 * z); | |
249 cairo_move_to(cr, x - GetHandleSize() * z, y - GetHandleSize() * z); | |
250 cairo_line_to(cr, x + GetHandleSize() * z, y - GetHandleSize() * z); | |
251 cairo_line_to(cr, x + GetHandleSize() * z, y + GetHandleSize() * z); | |
252 cairo_line_to(cr, x - GetHandleSize() * z, y + GetHandleSize() * z); | |
253 cairo_line_to(cr, x - GetHandleSize() * z, y - GetHandleSize() * z); | |
254 cairo_stroke(cr); | |
358 | 255 } |
256 } | |
339 | 257 } |
407 | 258 |
259 virtual void MouseWheel(WorldSceneWidget& widget, | |
260 MouseWheelDirection direction, | |
261 KeyboardModifiers modifiers, | |
262 IStatusBar* statusBar) | |
344
fdec8e6893cb
ordering of bitmap layers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
343
diff
changeset
|
263 { |
358 | 264 } |
407 | 265 |
266 virtual void KeyPressed(WorldSceneWidget& worldWidget, | |
267 KeyboardKeys key, | |
268 char keyChar, | |
269 KeyboardModifiers modifiers, | |
270 IStatusBar* statusBar) | |
345 | 271 { |
408 | 272 RadiographyWidget& widget = dynamic_cast<RadiographyWidget&>(worldWidget); |
407 | 273 |
274 switch (keyChar) | |
358 | 275 { |
430 | 276 case 'a': |
277 widget.FitContent(); | |
278 break; | |
279 | |
280 case 'c': | |
281 tool_ = Tool_Crop; | |
282 break; | |
407 | 283 |
430 | 284 case 'd': |
285 { | |
286 // dump to json and reload | |
287 Json::Value snapshot; | |
288 RadiographySceneWriter writer; | |
289 writer.Write(snapshot, widget.GetScene()); | |
407 | 290 |
430 | 291 LOG(INFO) << "JSON export was successful: " |
292 << snapshot.toStyledString(); | |
293 | |
294 boost::shared_ptr<RadiographyScene> scene(new RadiographyScene(GetBroker())); | |
295 RadiographySceneReader reader(*scene, context_->GetOrthancApiClient()); | |
296 | |
297 Orthanc::FontRegistry fontRegistry; | |
298 fontRegistry.AddFromResource(Orthanc::EmbeddedResources::FONT_UBUNTU_MONO_BOLD_16); | |
299 | |
300 reader.SetFontRegistry(fontRegistry); | |
301 reader.Read(snapshot); | |
407 | 302 |
430 | 303 widget.SetScene(scene); |
304 };break; | |
305 | |
306 case 'e': | |
307 { | |
308 Orthanc::DicomMap tags; | |
407 | 309 |
430 | 310 // Minimal set of tags to generate a valid CR image |
311 tags.SetValue(Orthanc::DICOM_TAG_ACCESSION_NUMBER, "NOPE", false); | |
312 tags.SetValue(Orthanc::DICOM_TAG_BODY_PART_EXAMINED, "PELVIS", false); | |
313 tags.SetValue(Orthanc::DICOM_TAG_INSTANCE_NUMBER, "1", false); | |
314 //tags.SetValue(Orthanc::DICOM_TAG_LATERALITY, "", false); | |
315 tags.SetValue(Orthanc::DICOM_TAG_MANUFACTURER, "OSIMIS", false); | |
316 tags.SetValue(Orthanc::DICOM_TAG_MODALITY, "CR", false); | |
317 tags.SetValue(Orthanc::DICOM_TAG_PATIENT_BIRTH_DATE, "20000101", false); | |
318 tags.SetValue(Orthanc::DICOM_TAG_PATIENT_ID, "hello", false); | |
319 tags.SetValue(Orthanc::DICOM_TAG_PATIENT_NAME, "HELLO^WORLD", false); | |
320 tags.SetValue(Orthanc::DICOM_TAG_PATIENT_ORIENTATION, "", false); | |
321 tags.SetValue(Orthanc::DICOM_TAG_PATIENT_SEX, "M", false); | |
322 tags.SetValue(Orthanc::DICOM_TAG_REFERRING_PHYSICIAN_NAME, "HOUSE^MD", false); | |
323 tags.SetValue(Orthanc::DICOM_TAG_SERIES_NUMBER, "1", false); | |
324 tags.SetValue(Orthanc::DICOM_TAG_SOP_CLASS_UID, "1.2.840.10008.5.1.4.1.1.1", false); | |
325 tags.SetValue(Orthanc::DICOM_TAG_STUDY_ID, "STUDY", false); | |
326 tags.SetValue(Orthanc::DICOM_TAG_VIEW_POSITION, "", false); | |
327 | |
328 if (context_ != NULL) | |
329 { | |
330 widget.GetScene().ExportDicom(context_->GetOrthancApiClient(), | |
331 tags, std::string(), 0.1, 0.1, widget.IsInverted(), | |
332 widget.GetInterpolation(), EXPORT_USING_PAM); | |
407 | 333 } |
334 | |
430 | 335 break; |
336 } | |
337 | |
338 case 'i': | |
339 widget.SwitchInvert(); | |
340 break; | |
341 | |
342 case 'm': | |
343 tool_ = Tool_Move; | |
344 break; | |
345 | |
346 case 'n': | |
347 { | |
348 switch (widget.GetInterpolation()) | |
349 { | |
350 case ImageInterpolation_Nearest: | |
351 LOG(INFO) << "Switching to bilinear interpolation"; | |
352 widget.SetInterpolation(ImageInterpolation_Bilinear); | |
407 | 353 break; |
354 | |
430 | 355 case ImageInterpolation_Bilinear: |
356 LOG(INFO) << "Switching to nearest neighbor interpolation"; | |
357 widget.SetInterpolation(ImageInterpolation_Nearest); | |
407 | 358 break; |
359 | |
430 | 360 default: |
361 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); | |
362 } | |
363 | |
364 break; | |
365 } | |
407 | 366 |
430 | 367 case 'r': |
368 tool_ = Tool_Rotate; | |
369 break; | |
370 | |
371 case 's': | |
372 tool_ = Tool_Resize; | |
373 break; | |
374 | |
375 case 'w': | |
376 tool_ = Tool_Windowing; | |
377 break; | |
407 | 378 |
430 | 379 case 'y': |
380 if (modifiers & KeyboardModifiers_Control) | |
381 { | |
382 undoRedoStack_.Redo(); | |
383 widget.NotifyContentChanged(); | |
384 } | |
385 break; | |
407 | 386 |
430 | 387 case 'z': |
388 if (modifiers & KeyboardModifiers_Control) | |
389 { | |
390 undoRedoStack_.Undo(); | |
391 widget.NotifyContentChanged(); | |
392 } | |
393 break; | |
394 | |
395 default: | |
396 break; | |
358 | 397 } |
345 | 398 } |
407 | 399 }; |
336
c7fdc8bac581
creating GrayscaleBitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
334
diff
changeset
|
400 |
430 | 401 |
402 | |
325
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
403 class SingleFrameEditorApplication : |
430 | 404 public SampleSingleCanvasApplicationBase, |
405 public IObserver | |
325
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
406 { |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
407 private: |
430 | 408 boost::shared_ptr<RadiographyScene> scene_; |
409 RadiographyEditorInteractor interactor_; | |
410 Orthanc::FontRegistry fontRegistry_; | |
325
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
411 |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
412 public: |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
413 SingleFrameEditorApplication(MessageBroker& broker) : |
362
12cec26d08ce
export of a valid DICOM CR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
361
diff
changeset
|
414 IObserver(broker), |
12cec26d08ce
export of a valid DICOM CR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
361
diff
changeset
|
415 interactor_(broker) |
325
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
416 { |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
417 } |
384
d20d75f20c5d
better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
377
diff
changeset
|
418 |
d20d75f20c5d
better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
377
diff
changeset
|
419 virtual ~SingleFrameEditorApplication() |
d20d75f20c5d
better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
377
diff
changeset
|
420 { |
d20d75f20c5d
better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
377
diff
changeset
|
421 LOG(WARNING) << "Destroying the application"; |
d20d75f20c5d
better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
377
diff
changeset
|
422 } |
325
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
423 |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
424 virtual void DeclareStartupOptions(boost::program_options::options_description& options) |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
425 { |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
426 boost::program_options::options_description generic("Sample options"); |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
427 generic.add_options() |
430 | 428 ("instance", boost::program_options::value<std::string>(), |
429 "Orthanc ID of the instance") | |
430 ("frame", boost::program_options::value<unsigned int>()->default_value(0), | |
431 "Number of the frame, for multi-frame DICOM instances") | |
432 ; | |
325
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
433 |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
434 options.add(generic); |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
435 } |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
436 |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
437 virtual void Initialize(StoneApplicationContext* context, |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
438 IStatusBar& statusBar, |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
439 const boost::program_options::variables_map& parameters) |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
440 { |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
441 using namespace OrthancStone; |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
442 |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
443 context_ = context; |
417
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
415
diff
changeset
|
444 interactor_.SetContext(*context); |
325
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
445 |
358 | 446 statusBar.SetMessage("Use the key \"a\" to reinitialize the layout"); |
447 statusBar.SetMessage("Use the key \"c\" to crop"); | |
359
100df90bf0ea
preparing to implement Export
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
358
diff
changeset
|
448 statusBar.SetMessage("Use the key \"e\" to export DICOM to the Orthanc server"); |
358 | 449 statusBar.SetMessage("Use the key \"f\" to switch full screen"); |
450 statusBar.SetMessage("Use the key \"i\" to invert contrast"); | |
451 statusBar.SetMessage("Use the key \"m\" to move objects"); | |
359
100df90bf0ea
preparing to implement Export
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
358
diff
changeset
|
452 statusBar.SetMessage("Use the key \"n\" to switch between nearest neighbor and bilinear interpolation"); |
358 | 453 statusBar.SetMessage("Use the key \"r\" to rotate objects"); |
407 | 454 statusBar.SetMessage("Use the key \"s\" to resize objects (not applicable to DICOM layers)"); |
358 | 455 statusBar.SetMessage("Use the key \"w\" to change windowing"); |
456 | |
457 statusBar.SetMessage("Use the key \"ctrl-z\" to undo action"); | |
458 statusBar.SetMessage("Use the key \"ctrl-y\" to redo action"); | |
325
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
459 |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
460 if (parameters.count("instance") != 1) |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
461 { |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
462 LOG(ERROR) << "The instance ID is missing"; |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
463 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
464 } |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
465 |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
466 std::string instance = parameters["instance"].as<std::string>(); |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
467 int frame = parameters["frame"].as<unsigned int>(); |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
468 |
430 | 469 fontRegistry_.AddFromResource(Orthanc::EmbeddedResources::FONT_UBUNTU_MONO_BOLD_16); |
343 | 470 |
417
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
415
diff
changeset
|
471 scene_.reset(new RadiographyScene(GetBroker())); |
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
415
diff
changeset
|
472 //scene_->LoadDicomFrame(instance, frame, false); //.SetPan(200, 0); |
430 | 473 scene_->LoadDicomFrame(context->GetOrthancApiClient(), "61f3143e-96f34791-ad6bbb8d-62559e75-45943e1b", 0, false, NULL); |
418 | 474 |
475 #if !defined(ORTHANC_ENABLE_WASM) || ORTHANC_ENABLE_WASM != 1 | |
476 Orthanc::HttpClient::ConfigureSsl(true, "/etc/ssl/certs/ca-certificates.crt"); | |
477 #endif | |
478 | |
417
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
415
diff
changeset
|
479 //scene_->LoadDicomWebFrame(context->GetWebService()); |
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
415
diff
changeset
|
480 |
354 | 481 { |
430 | 482 RadiographyLayer& layer = scene_->LoadText(fontRegistry_.GetFont(0), "Hello\nworld", NULL); |
410
6decc0ba9da5
rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
408
diff
changeset
|
483 layer.SetResizeable(true); |
354 | 484 } |
485 | |
486 { | |
430 | 487 RadiographyLayer& layer = scene_->LoadTestBlock(100, 50, NULL); |
410
6decc0ba9da5
rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
408
diff
changeset
|
488 layer.SetResizeable(true); |
6decc0ba9da5
rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
408
diff
changeset
|
489 layer.SetPan(0, 200); |
354 | 490 } |
491 | |
337 | 492 |
428
751fb354149e
ability to change the scene of the RadiographyWidget
am@osimis.io
parents:
418
diff
changeset
|
493 mainWidget_ = new RadiographyWidget(GetBroker(), scene_, "main-widget"); |
325
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
494 mainWidget_->SetTransmitMouseOver(true); |
358 | 495 mainWidget_->SetInteractor(interactor_); |
325
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
496 |
407 | 497 //scene_->SetWindowing(128, 256); |
325
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
498 } |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
499 }; |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
500 } |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
501 } |