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