Mercurial > hg > orthanc-stone
comparison Applications/Samples/SimpleViewer/MainWidgetInteractor.cpp @ 319:daa04d15192c am-2
new SimpleViewer sample that has been split in multiple files to be able to scale it
author | am@osimis.io |
---|---|
date | Thu, 11 Oct 2018 13:16:54 +0200 |
parents | |
children | 8716176ff7f0 |
comparison
equal
deleted
inserted
replaced
318:3a4ca166fafa | 319:daa04d15192c |
---|---|
1 /** | |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
5 * Copyright (C) 2017-2018 Osimis S.A., Belgium | |
6 * | |
7 * This program is free software: you can redistribute it and/or | |
8 * modify it under the terms of the GNU Affero General Public License | |
9 * as published by the Free Software Foundation, either version 3 of | |
10 * the License, or (at your option) any later version. | |
11 * | |
12 * This program is distributed in the hope that it will be useful, but | |
13 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 * Affero General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU Affero General Public License | |
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 **/ | |
20 | |
21 #include "MainWidgetInteractor.h" | |
22 | |
23 #include "SimpleViewerApplication.h" | |
24 | |
25 namespace SimpleViewer { | |
26 | |
27 IWorldSceneMouseTracker* MainWidgetInteractor::CreateMouseTracker(WorldSceneWidget& widget, | |
28 const ViewportGeometry& view, | |
29 MouseButton button, | |
30 KeyboardModifiers modifiers, | |
31 double x, | |
32 double y, | |
33 IStatusBar* statusBar) | |
34 { | |
35 if (button == MouseButton_Left) | |
36 { | |
37 if (application_.GetCurrentTool() == SimpleViewerApplication::Tools_LineMeasure) | |
38 { | |
39 return new LineMeasureTracker(statusBar, dynamic_cast<LayerWidget&>(widget).GetSlice(), x, y, 255, 0, 0, 10); | |
40 } | |
41 else if (application_.GetCurrentTool() == SimpleViewerApplication::Tools_CircleMeasure) | |
42 { | |
43 return new CircleMeasureTracker(statusBar, dynamic_cast<LayerWidget&>(widget).GetSlice(), x, y, 255, 0, 0, 10); | |
44 } | |
45 else if (application_.GetCurrentTool() == SimpleViewerApplication::Tools_Crop) | |
46 { | |
47 // TODO | |
48 } | |
49 else if (application_.GetCurrentTool() == SimpleViewerApplication::Tools_Windowing) | |
50 { | |
51 // TODO | |
52 } | |
53 else if (application_.GetCurrentTool() == SimpleViewerApplication::Tools_Zoom) | |
54 { | |
55 // TODO | |
56 } | |
57 else if (application_.GetCurrentTool() == SimpleViewerApplication::Tools_Pan) | |
58 { | |
59 // TODO | |
60 } | |
61 | |
62 } | |
63 return NULL; | |
64 } | |
65 | |
66 void MainWidgetInteractor::MouseOver(CairoContext& context, | |
67 WorldSceneWidget& widget, | |
68 const ViewportGeometry& view, | |
69 double x, | |
70 double y, | |
71 IStatusBar* statusBar) | |
72 { | |
73 if (statusBar != NULL) | |
74 { | |
75 Vector p = dynamic_cast<LayerWidget&>(widget).GetSlice().MapSliceToWorldCoordinates(x, y); | |
76 | |
77 char buf[64]; | |
78 sprintf(buf, "X = %.02f Y = %.02f Z = %.02f (in cm)", | |
79 p[0] / 10.0, p[1] / 10.0, p[2] / 10.0); | |
80 statusBar->SetMessage(buf); | |
81 } | |
82 } | |
83 | |
84 void MainWidgetInteractor::MouseWheel(WorldSceneWidget& widget, | |
85 MouseWheelDirection direction, | |
86 KeyboardModifiers modifiers, | |
87 IStatusBar* statusBar) | |
88 { | |
89 } | |
90 | |
91 void MainWidgetInteractor::KeyPressed(WorldSceneWidget& widget, | |
92 char key, | |
93 KeyboardModifiers modifiers, | |
94 IStatusBar* statusBar) | |
95 { | |
96 switch (key) | |
97 { | |
98 case 's': | |
99 widget.SetDefaultView(); | |
100 break; | |
101 | |
102 default: | |
103 break; | |
104 } | |
105 } | |
106 } |