Mercurial > hg > orthanc-stone
annotate Applications/Samples/CtPetDoseStructFusion/MainWidgetInteractor.cpp @ 540:7428c5dfa5df ct-pet-dose-struct
Initial commit non working app
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Tue, 19 Mar 2019 16:29:07 +0100 |
parents | |
children |
rev | line source |
---|---|
540
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
1 /** |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
2 * Stone of Orthanc |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
5 * Copyright (C) 2017-2019 Osimis S.A., Belgium |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
6 * |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
7 * This program is free software: you can redistribute it and/or |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
8 * modify it under the terms of the GNU Affero General Public License |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
9 * as published by the Free Software Foundation, either version 3 of |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
10 * the License, or (at your option) any later version. |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
11 * |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
12 * This program is distributed in the hope that it will be useful, but |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
13 * WITHOUT ANY WARRANTY; without even the implied warranty of |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
15 * Affero General Public License for more details. |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
16 * |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
17 * You should have received a copy of the GNU Affero General Public License |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
19 **/ |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
20 |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
21 #include "MainWidgetInteractor.h" |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
22 |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
23 #include "CtPetDoseStructFusionApplication.h" |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
24 |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
25 namespace CtPetDoseStructFusion { |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
26 |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
27 IWorldSceneMouseTracker* MainWidgetInteractor::CreateMouseTracker(WorldSceneWidget& widget, |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
28 const ViewportGeometry& view, |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
29 MouseButton button, |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
30 KeyboardModifiers modifiers, |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
31 int viewportX, |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
32 int viewportY, |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
33 double x, |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
34 double y, |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
35 IStatusBar* statusBar, |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
36 const std::vector<Touch>& displayTouches) |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
37 { |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
38 if (button == MouseButton_Left) |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
39 { |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
40 if (application_.GetCurrentTool() == Tool_LineMeasure) |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
41 { |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
42 return new LineMeasureTracker(statusBar, dynamic_cast<SliceViewerWidget&>(widget).GetSlice(), |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
43 x, y, 255, 0, 0, application_.GetFont()); |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
44 } |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
45 else if (application_.GetCurrentTool() == Tool_CircleMeasure) |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
46 { |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
47 return new CircleMeasureTracker(statusBar, dynamic_cast<SliceViewerWidget&>(widget).GetSlice(), |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
48 x, y, 255, 0, 0, application_.GetFont()); |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
49 } |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
50 else if (application_.GetCurrentTool() == Tool_Crop) |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
51 { |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
52 // TODO |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
53 } |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
54 else if (application_.GetCurrentTool() == Tool_Windowing) |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
55 { |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
56 // TODO |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
57 } |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
58 else if (application_.GetCurrentTool() == Tool_Zoom) |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
59 { |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
60 // TODO |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
61 } |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
62 else if (application_.GetCurrentTool() == Tool_Pan) |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
63 { |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
64 // TODO |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
65 } |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
66 } |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
67 return NULL; |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
68 } |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
69 |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
70 void MainWidgetInteractor::MouseOver(CairoContext& context, |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
71 WorldSceneWidget& widget, |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
72 const ViewportGeometry& view, |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
73 double x, |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
74 double y, |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
75 IStatusBar* statusBar) |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
76 { |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
77 if (statusBar != NULL) |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
78 { |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
79 Vector p = dynamic_cast<SliceViewerWidget&>(widget).GetSlice().MapSliceToWorldCoordinates(x, y); |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
80 |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
81 char buf[64]; |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
82 sprintf(buf, "X = %.02f Y = %.02f Z = %.02f (in cm)", |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
83 p[0] / 10.0, p[1] / 10.0, p[2] / 10.0); |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
84 statusBar->SetMessage(buf); |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
85 } |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
86 } |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
87 |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
88 void MainWidgetInteractor::MouseWheel(WorldSceneWidget& widget, |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
89 MouseWheelDirection direction, |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
90 KeyboardModifiers modifiers, |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
91 IStatusBar* statusBar) |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
92 { |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
93 } |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
94 |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
95 void MainWidgetInteractor::KeyPressed(WorldSceneWidget& widget, |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
96 KeyboardKeys key, |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
97 char keyChar, |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
98 KeyboardModifiers modifiers, |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
99 IStatusBar* statusBar) |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
100 { |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
101 switch (keyChar) |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
102 { |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
103 case 's': |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
104 widget.FitContent(); |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
105 break; |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
106 |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
107 default: |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
108 break; |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
109 } |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
110 } |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
111 } |