Mercurial > hg > orthanc-stone
annotate Framework/Scene2DViewport/ViewportController.cpp @ 1397:1c2d065ba372
cleanup
author | Alain Mazy <alain@mazy.be> |
---|---|
date | Wed, 29 Apr 2020 20:41:36 +0200 |
parents | ab81ee8fce1f |
children |
rev | line source |
---|---|
698
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
1 /** |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
2 * Stone of Orthanc |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
1270
2d8ab34c8c91
upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1053
diff
changeset
|
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium |
698
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
6 * |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
7 * This program is free software: you can redistribute it and/or |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
8 * modify it under the terms of the GNU Affero General Public License |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
9 * as published by the Free Software Foundation, either version 3 of |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
10 * the License, or (at your option) any later version. |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
11 * |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
12 * This program is distributed in the hope that it will be useful, but |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
13 * WITHOUT ANY WARRANTY; without even the implied warranty of |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
15 * Affero General Public License for more details. |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
16 * |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
17 * You should have received a copy of the GNU Affero General Public License |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
19 **/ |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
20 |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
21 #include "ViewportController.h" |
858
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
842
diff
changeset
|
22 |
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
842
diff
changeset
|
23 #include "UndoStack.h" |
722
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
721
diff
changeset
|
24 #include "MeasureCommands.h" |
698
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
25 |
736
c0fcb2757b0a
enforce relative includes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
26 #include "../StoneException.h" |
1208
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
27 #include "../Scene2D/PanSceneTracker.h" |
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
28 #include "../Scene2D/RotateSceneTracker.h" |
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
29 #include "../Scene2D/ZoomSceneTracker.h" |
698
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
30 |
700
059e1fd05fd6
Introduced the ViewportController that sits between the application and the
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
31 #include <boost/make_shared.hpp> |
059e1fd05fd6
Introduced the ViewportController that sits between the application and the
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
32 |
698
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
33 namespace OrthancStone |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
34 { |
1214
741201eab130
removing pointer to viewport from ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1213
diff
changeset
|
35 IFlexiblePointerTracker* DefaultViewportInteractor::CreateTracker( |
1331
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1309
diff
changeset
|
36 boost::shared_ptr<IViewport> viewport, |
1215
9efa66d8d3f8
removed ViewportBase, and removed dependency of ViewportController on IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1214
diff
changeset
|
37 const PointerEvent& event, |
1307
8a28a9bf8876
ViewportController now gets a ref to its parent viewport for proper lock usage
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
38 unsigned int viewportWidth, |
8a28a9bf8876
ViewportController now gets a ref to its parent viewport for proper lock usage
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
39 unsigned int viewportHeight) |
1208
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
40 { |
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
41 switch (event.GetMouseButton()) |
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
42 { |
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
43 case MouseButton_Left: |
1307
8a28a9bf8876
ViewportController now gets a ref to its parent viewport for proper lock usage
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
44 return new RotateSceneTracker(viewport, event); |
1208
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
45 |
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
46 case MouseButton_Middle: |
1307
8a28a9bf8876
ViewportController now gets a ref to its parent viewport for proper lock usage
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
47 return new PanSceneTracker(viewport, event); |
1208
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
48 |
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
49 case MouseButton_Right: |
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
50 { |
1215
9efa66d8d3f8
removed ViewportBase, and removed dependency of ViewportController on IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1214
diff
changeset
|
51 if (viewportWidth != 0) |
1208
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
52 { |
1307
8a28a9bf8876
ViewportController now gets a ref to its parent viewport for proper lock usage
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
53 return new ZoomSceneTracker(viewport, event, viewportWidth); |
1208
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
54 } |
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
55 else |
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
56 { |
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
57 return NULL; |
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
58 } |
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
59 } |
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
60 |
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
61 default: |
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
62 return NULL; |
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
63 } |
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
64 } |
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
65 |
1331
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1309
diff
changeset
|
66 ViewportController::ViewportController(boost::shared_ptr<IViewport> viewport) |
1307
8a28a9bf8876
ViewportController now gets a ref to its parent viewport for proper lock usage
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
67 : viewport_(viewport) |
8a28a9bf8876
ViewportController now gets a ref to its parent viewport for proper lock usage
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
68 , scene_(new Scene2D) |
8a28a9bf8876
ViewportController now gets a ref to its parent viewport for proper lock usage
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
69 , canvasToSceneFactor_(1) |
1216
5147277850cf
better abstraction for IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1215
diff
changeset
|
70 { |
1331
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1309
diff
changeset
|
71 // undoStack_ is not default-initialized, which basically means empty. |
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1309
diff
changeset
|
72 // The controller must be able to cope with this. |
1216
5147277850cf
better abstraction for IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1215
diff
changeset
|
73 } |
5147277850cf
better abstraction for IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1215
diff
changeset
|
74 |
1020
ac88989817e3
TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents:
916
diff
changeset
|
75 ViewportController::~ViewportController() |
ac88989817e3
TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents:
916
diff
changeset
|
76 { |
858
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
842
diff
changeset
|
77 } |
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
842
diff
changeset
|
78 |
1331
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1309
diff
changeset
|
79 void ViewportController::PushCommand( |
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1309
diff
changeset
|
80 boost::shared_ptr<MeasureCommand> command) |
858
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
842
diff
changeset
|
81 { |
906
52b1c6ff10c5
Disabled OpenGL in GuiAdapter to allow for Cairo-only workflows (THIS IS A TEMP CHANGE!!!) + disabled outlined text by default (build macro)
Benjamin Golinvaux <bgo@osimis.io>
parents:
893
diff
changeset
|
82 boost::shared_ptr<UndoStack> undoStack = undoStackW_.lock(); |
1208
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
83 if (undoStack.get() != NULL) |
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
84 { |
906
52b1c6ff10c5
Disabled OpenGL in GuiAdapter to allow for Cairo-only workflows (THIS IS A TEMP CHANGE!!!) + disabled outlined text by default (build macro)
Benjamin Golinvaux <bgo@osimis.io>
parents:
893
diff
changeset
|
85 undoStack->PushCommand(command); |
1208
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
86 } |
906
52b1c6ff10c5
Disabled OpenGL in GuiAdapter to allow for Cairo-only workflows (THIS IS A TEMP CHANGE!!!) + disabled outlined text by default (build macro)
Benjamin Golinvaux <bgo@osimis.io>
parents:
893
diff
changeset
|
87 else |
52b1c6ff10c5
Disabled OpenGL in GuiAdapter to allow for Cairo-only workflows (THIS IS A TEMP CHANGE!!!) + disabled outlined text by default (build macro)
Benjamin Golinvaux <bgo@osimis.io>
parents:
893
diff
changeset
|
88 { |
1331
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1309
diff
changeset
|
89 LOG(ERROR) << "Internal error: no undo stack!"; |
906
52b1c6ff10c5
Disabled OpenGL in GuiAdapter to allow for Cairo-only workflows (THIS IS A TEMP CHANGE!!!) + disabled outlined text by default (build macro)
Benjamin Golinvaux <bgo@osimis.io>
parents:
893
diff
changeset
|
90 } |
858
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
842
diff
changeset
|
91 } |
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
842
diff
changeset
|
92 |
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
842
diff
changeset
|
93 void ViewportController::Undo() |
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
842
diff
changeset
|
94 { |
906
52b1c6ff10c5
Disabled OpenGL in GuiAdapter to allow for Cairo-only workflows (THIS IS A TEMP CHANGE!!!) + disabled outlined text by default (build macro)
Benjamin Golinvaux <bgo@osimis.io>
parents:
893
diff
changeset
|
95 boost::shared_ptr<UndoStack> undoStack = undoStackW_.lock(); |
52b1c6ff10c5
Disabled OpenGL in GuiAdapter to allow for Cairo-only workflows (THIS IS A TEMP CHANGE!!!) + disabled outlined text by default (build macro)
Benjamin Golinvaux <bgo@osimis.io>
parents:
893
diff
changeset
|
96 if (undoStack.get() != NULL) |
1208
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
97 { |
906
52b1c6ff10c5
Disabled OpenGL in GuiAdapter to allow for Cairo-only workflows (THIS IS A TEMP CHANGE!!!) + disabled outlined text by default (build macro)
Benjamin Golinvaux <bgo@osimis.io>
parents:
893
diff
changeset
|
98 undoStack->Undo(); |
1208
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
99 } |
906
52b1c6ff10c5
Disabled OpenGL in GuiAdapter to allow for Cairo-only workflows (THIS IS A TEMP CHANGE!!!) + disabled outlined text by default (build macro)
Benjamin Golinvaux <bgo@osimis.io>
parents:
893
diff
changeset
|
100 else |
52b1c6ff10c5
Disabled OpenGL in GuiAdapter to allow for Cairo-only workflows (THIS IS A TEMP CHANGE!!!) + disabled outlined text by default (build macro)
Benjamin Golinvaux <bgo@osimis.io>
parents:
893
diff
changeset
|
101 { |
1331
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1309
diff
changeset
|
102 LOG(ERROR) << "Internal error: no undo stack!"; |
906
52b1c6ff10c5
Disabled OpenGL in GuiAdapter to allow for Cairo-only workflows (THIS IS A TEMP CHANGE!!!) + disabled outlined text by default (build macro)
Benjamin Golinvaux <bgo@osimis.io>
parents:
893
diff
changeset
|
103 } |
858
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
842
diff
changeset
|
104 } |
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
842
diff
changeset
|
105 |
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
842
diff
changeset
|
106 void ViewportController::Redo() |
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
842
diff
changeset
|
107 { |
906
52b1c6ff10c5
Disabled OpenGL in GuiAdapter to allow for Cairo-only workflows (THIS IS A TEMP CHANGE!!!) + disabled outlined text by default (build macro)
Benjamin Golinvaux <bgo@osimis.io>
parents:
893
diff
changeset
|
108 boost::shared_ptr<UndoStack> undoStack = undoStackW_.lock(); |
52b1c6ff10c5
Disabled OpenGL in GuiAdapter to allow for Cairo-only workflows (THIS IS A TEMP CHANGE!!!) + disabled outlined text by default (build macro)
Benjamin Golinvaux <bgo@osimis.io>
parents:
893
diff
changeset
|
109 if (undoStack.get() != NULL) |
1208
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
110 { |
906
52b1c6ff10c5
Disabled OpenGL in GuiAdapter to allow for Cairo-only workflows (THIS IS A TEMP CHANGE!!!) + disabled outlined text by default (build macro)
Benjamin Golinvaux <bgo@osimis.io>
parents:
893
diff
changeset
|
111 undoStack->Redo(); |
1208
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
112 } |
906
52b1c6ff10c5
Disabled OpenGL in GuiAdapter to allow for Cairo-only workflows (THIS IS A TEMP CHANGE!!!) + disabled outlined text by default (build macro)
Benjamin Golinvaux <bgo@osimis.io>
parents:
893
diff
changeset
|
113 else |
52b1c6ff10c5
Disabled OpenGL in GuiAdapter to allow for Cairo-only workflows (THIS IS A TEMP CHANGE!!!) + disabled outlined text by default (build macro)
Benjamin Golinvaux <bgo@osimis.io>
parents:
893
diff
changeset
|
114 { |
1331
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1309
diff
changeset
|
115 LOG(ERROR) << "Internal error: no undo stack!"; |
906
52b1c6ff10c5
Disabled OpenGL in GuiAdapter to allow for Cairo-only workflows (THIS IS A TEMP CHANGE!!!) + disabled outlined text by default (build macro)
Benjamin Golinvaux <bgo@osimis.io>
parents:
893
diff
changeset
|
116 } |
858
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
842
diff
changeset
|
117 } |
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
842
diff
changeset
|
118 |
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
842
diff
changeset
|
119 bool ViewportController::CanUndo() const |
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
842
diff
changeset
|
120 { |
906
52b1c6ff10c5
Disabled OpenGL in GuiAdapter to allow for Cairo-only workflows (THIS IS A TEMP CHANGE!!!) + disabled outlined text by default (build macro)
Benjamin Golinvaux <bgo@osimis.io>
parents:
893
diff
changeset
|
121 boost::shared_ptr<UndoStack> undoStack = undoStackW_.lock(); |
52b1c6ff10c5
Disabled OpenGL in GuiAdapter to allow for Cairo-only workflows (THIS IS A TEMP CHANGE!!!) + disabled outlined text by default (build macro)
Benjamin Golinvaux <bgo@osimis.io>
parents:
893
diff
changeset
|
122 if (undoStack.get() != NULL) |
1208
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
123 { |
906
52b1c6ff10c5
Disabled OpenGL in GuiAdapter to allow for Cairo-only workflows (THIS IS A TEMP CHANGE!!!) + disabled outlined text by default (build macro)
Benjamin Golinvaux <bgo@osimis.io>
parents:
893
diff
changeset
|
124 return undoStack->CanUndo(); |
1208
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
125 } |
906
52b1c6ff10c5
Disabled OpenGL in GuiAdapter to allow for Cairo-only workflows (THIS IS A TEMP CHANGE!!!) + disabled outlined text by default (build macro)
Benjamin Golinvaux <bgo@osimis.io>
parents:
893
diff
changeset
|
126 else |
52b1c6ff10c5
Disabled OpenGL in GuiAdapter to allow for Cairo-only workflows (THIS IS A TEMP CHANGE!!!) + disabled outlined text by default (build macro)
Benjamin Golinvaux <bgo@osimis.io>
parents:
893
diff
changeset
|
127 { |
1331
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1309
diff
changeset
|
128 LOG(ERROR) << "Internal error: no undo stack!"; |
906
52b1c6ff10c5
Disabled OpenGL in GuiAdapter to allow for Cairo-only workflows (THIS IS A TEMP CHANGE!!!) + disabled outlined text by default (build macro)
Benjamin Golinvaux <bgo@osimis.io>
parents:
893
diff
changeset
|
129 return false; |
52b1c6ff10c5
Disabled OpenGL in GuiAdapter to allow for Cairo-only workflows (THIS IS A TEMP CHANGE!!!) + disabled outlined text by default (build macro)
Benjamin Golinvaux <bgo@osimis.io>
parents:
893
diff
changeset
|
130 } |
858
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
842
diff
changeset
|
131 } |
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
842
diff
changeset
|
132 |
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
842
diff
changeset
|
133 bool ViewportController::CanRedo() const |
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
842
diff
changeset
|
134 { |
906
52b1c6ff10c5
Disabled OpenGL in GuiAdapter to allow for Cairo-only workflows (THIS IS A TEMP CHANGE!!!) + disabled outlined text by default (build macro)
Benjamin Golinvaux <bgo@osimis.io>
parents:
893
diff
changeset
|
135 boost::shared_ptr<UndoStack> undoStack = undoStackW_.lock(); |
52b1c6ff10c5
Disabled OpenGL in GuiAdapter to allow for Cairo-only workflows (THIS IS A TEMP CHANGE!!!) + disabled outlined text by default (build macro)
Benjamin Golinvaux <bgo@osimis.io>
parents:
893
diff
changeset
|
136 if (undoStack.get() != NULL) |
1208
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
137 { |
906
52b1c6ff10c5
Disabled OpenGL in GuiAdapter to allow for Cairo-only workflows (THIS IS A TEMP CHANGE!!!) + disabled outlined text by default (build macro)
Benjamin Golinvaux <bgo@osimis.io>
parents:
893
diff
changeset
|
138 return undoStack->CanRedo(); |
1208
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
139 } |
906
52b1c6ff10c5
Disabled OpenGL in GuiAdapter to allow for Cairo-only workflows (THIS IS A TEMP CHANGE!!!) + disabled outlined text by default (build macro)
Benjamin Golinvaux <bgo@osimis.io>
parents:
893
diff
changeset
|
140 else |
52b1c6ff10c5
Disabled OpenGL in GuiAdapter to allow for Cairo-only workflows (THIS IS A TEMP CHANGE!!!) + disabled outlined text by default (build macro)
Benjamin Golinvaux <bgo@osimis.io>
parents:
893
diff
changeset
|
141 { |
1331
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1309
diff
changeset
|
142 LOG(ERROR) << "Internal error: no undo stack!"; |
906
52b1c6ff10c5
Disabled OpenGL in GuiAdapter to allow for Cairo-only workflows (THIS IS A TEMP CHANGE!!!) + disabled outlined text by default (build macro)
Benjamin Golinvaux <bgo@osimis.io>
parents:
893
diff
changeset
|
143 return false; |
52b1c6ff10c5
Disabled OpenGL in GuiAdapter to allow for Cairo-only workflows (THIS IS A TEMP CHANGE!!!) + disabled outlined text by default (build macro)
Benjamin Golinvaux <bgo@osimis.io>
parents:
893
diff
changeset
|
144 } |
858
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
842
diff
changeset
|
145 } |
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
842
diff
changeset
|
146 |
1331
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1309
diff
changeset
|
147 std::vector<boost::shared_ptr<MeasureTool> > |
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1309
diff
changeset
|
148 ViewportController::HitTestMeasureTools(ScenePoint2D p) |
721
af0aa0c149fa
FitContent is now wrapped by the controller (for observability)
Benjamin Golinvaux <bgo@osimis.io>
parents:
700
diff
changeset
|
149 { |
842
2b245953b44b
removed some c++11 for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
818
diff
changeset
|
150 std::vector<boost::shared_ptr<MeasureTool> > ret; |
721
af0aa0c149fa
FitContent is now wrapped by the controller (for observability)
Benjamin Golinvaux <bgo@osimis.io>
parents:
700
diff
changeset
|
151 |
774
66ac7a2d1e3a
A few renames and cleanups + moved GUI constants to controller + start work on
Benjamin Golinvaux <bgo@osimis.io>
parents:
761
diff
changeset
|
152 for (size_t i = 0; i < measureTools_.size(); ++i) |
66ac7a2d1e3a
A few renames and cleanups + moved GUI constants to controller + start work on
Benjamin Golinvaux <bgo@osimis.io>
parents:
761
diff
changeset
|
153 { |
66ac7a2d1e3a
A few renames and cleanups + moved GUI constants to controller + start work on
Benjamin Golinvaux <bgo@osimis.io>
parents:
761
diff
changeset
|
154 if (measureTools_[i]->HitTest(p)) |
66ac7a2d1e3a
A few renames and cleanups + moved GUI constants to controller + start work on
Benjamin Golinvaux <bgo@osimis.io>
parents:
761
diff
changeset
|
155 ret.push_back(measureTools_[i]); |
66ac7a2d1e3a
A few renames and cleanups + moved GUI constants to controller + start work on
Benjamin Golinvaux <bgo@osimis.io>
parents:
761
diff
changeset
|
156 } |
721
af0aa0c149fa
FitContent is now wrapped by the controller (for observability)
Benjamin Golinvaux <bgo@osimis.io>
parents:
700
diff
changeset
|
157 return ret; |
af0aa0c149fa
FitContent is now wrapped by the controller (for observability)
Benjamin Golinvaux <bgo@osimis.io>
parents:
700
diff
changeset
|
158 } |
1331
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1309
diff
changeset
|
159 |
865
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
160 void ViewportController::ResetMeasuringToolsHighlight() |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
161 { |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
162 for (size_t i = 0; i < measureTools_.size(); ++i) |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
163 { |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
164 measureTools_[i]->ResetHighlightState(); |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
165 } |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
166 } |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
858
diff
changeset
|
167 |
1331
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1309
diff
changeset
|
168 OrthancStone::AffineTransform2D |
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1309
diff
changeset
|
169 ViewportController::GetCanvasToSceneTransform() const |
700
059e1fd05fd6
Introduced the ViewportController that sits between the application and the
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
170 { |
1232
a28861abf888
viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1216
diff
changeset
|
171 return scene_->GetCanvasToSceneTransform(); |
700
059e1fd05fd6
Introduced the ViewportController that sits between the application and the
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
172 } |
059e1fd05fd6
Introduced the ViewportController that sits between the application and the
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
173 |
1331
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1309
diff
changeset
|
174 OrthancStone::AffineTransform2D |
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1309
diff
changeset
|
175 ViewportController::GetSceneToCanvasTransform() const |
700
059e1fd05fd6
Introduced the ViewportController that sits between the application and the
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
176 { |
1232
a28861abf888
viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1216
diff
changeset
|
177 return scene_->GetSceneToCanvasTransform(); |
700
059e1fd05fd6
Introduced the ViewportController that sits between the application and the
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
178 } |
059e1fd05fd6
Introduced the ViewportController that sits between the application and the
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
179 |
1331
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1309
diff
changeset
|
180 void ViewportController::SetSceneToCanvasTransform( |
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1309
diff
changeset
|
181 const AffineTransform2D& transform) |
721
af0aa0c149fa
FitContent is now wrapped by the controller (for observability)
Benjamin Golinvaux <bgo@osimis.io>
parents:
700
diff
changeset
|
182 { |
1232
a28861abf888
viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1216
diff
changeset
|
183 scene_->SetSceneToCanvasTransform(transform); |
1213
86a8266b8888
moving the scene from IViewport to ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1210
diff
changeset
|
184 |
1232
a28861abf888
viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1216
diff
changeset
|
185 canvasToSceneFactor_ = scene_->GetCanvasToSceneTransform().ComputeZoom(); |
721
af0aa0c149fa
FitContent is now wrapped by the controller (for observability)
Benjamin Golinvaux <bgo@osimis.io>
parents:
700
diff
changeset
|
186 BroadcastMessage(SceneTransformChanged(*this)); |
af0aa0c149fa
FitContent is now wrapped by the controller (for observability)
Benjamin Golinvaux <bgo@osimis.io>
parents:
700
diff
changeset
|
187 } |
af0aa0c149fa
FitContent is now wrapped by the controller (for observability)
Benjamin Golinvaux <bgo@osimis.io>
parents:
700
diff
changeset
|
188 |
1215
9efa66d8d3f8
removed ViewportBase, and removed dependency of ViewportController on IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1214
diff
changeset
|
189 void ViewportController::FitContent(unsigned int viewportWidth, |
9efa66d8d3f8
removed ViewportBase, and removed dependency of ViewportController on IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1214
diff
changeset
|
190 unsigned int viewportHeight) |
916
a911f5bb48da
MultiPlatform Basic Scene sample (so far: SDL + Qt)
Alain Mazy <alain@mazy.be>
parents:
906
diff
changeset
|
191 { |
1232
a28861abf888
viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1216
diff
changeset
|
192 scene_->FitContent(viewportWidth, viewportHeight); |
a28861abf888
viewports for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1216
diff
changeset
|
193 canvasToSceneFactor_ = scene_->GetCanvasToSceneTransform().ComputeZoom(); |
1208
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
194 BroadcastMessage(SceneTransformChanged(*this)); |
916
a911f5bb48da
MultiPlatform Basic Scene sample (so far: SDL + Qt)
Alain Mazy <alain@mazy.be>
parents:
906
diff
changeset
|
195 } |
a911f5bb48da
MultiPlatform Basic Scene sample (so far: SDL + Qt)
Alain Mazy <alain@mazy.be>
parents:
906
diff
changeset
|
196 |
1331
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1309
diff
changeset
|
197 void ViewportController::AddMeasureTool( |
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1309
diff
changeset
|
198 boost::shared_ptr<MeasureTool> measureTool) |
722
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
721
diff
changeset
|
199 { |
1331
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1309
diff
changeset
|
200 ORTHANC_ASSERT(std::find(measureTools_.begin(), |
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1309
diff
changeset
|
201 measureTools_.end(), |
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1309
diff
changeset
|
202 measureTool) == measureTools_.end(), |
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1309
diff
changeset
|
203 "Duplicate measure tool"); |
722
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
721
diff
changeset
|
204 measureTools_.push_back(measureTool); |
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
721
diff
changeset
|
205 } |
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
721
diff
changeset
|
206 |
1331
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1309
diff
changeset
|
207 void ViewportController::RemoveMeasureTool( |
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1309
diff
changeset
|
208 boost::shared_ptr<MeasureTool> measureTool) |
722
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
721
diff
changeset
|
209 { |
1331
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1309
diff
changeset
|
210 ORTHANC_ASSERT(std::find(measureTools_.begin(), |
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1309
diff
changeset
|
211 measureTools_.end(), |
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1309
diff
changeset
|
212 measureTool) != measureTools_.end(), |
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1309
diff
changeset
|
213 "Measure tool not found"); |
761
07adcffba38c
truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents:
754
diff
changeset
|
214 measureTools_.erase( |
07adcffba38c
truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents:
754
diff
changeset
|
215 std::remove(measureTools_.begin(), measureTools_.end(), measureTool), |
07adcffba38c
truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents:
754
diff
changeset
|
216 measureTools_.end()); |
722
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
721
diff
changeset
|
217 } |
774
66ac7a2d1e3a
A few renames and cleanups + moved GUI constants to controller + start work on
Benjamin Golinvaux <bgo@osimis.io>
parents:
761
diff
changeset
|
218 |
66ac7a2d1e3a
A few renames and cleanups + moved GUI constants to controller + start work on
Benjamin Golinvaux <bgo@osimis.io>
parents:
761
diff
changeset
|
219 double ViewportController::GetCanvasToSceneFactor() const |
66ac7a2d1e3a
A few renames and cleanups + moved GUI constants to controller + start work on
Benjamin Golinvaux <bgo@osimis.io>
parents:
761
diff
changeset
|
220 { |
66ac7a2d1e3a
A few renames and cleanups + moved GUI constants to controller + start work on
Benjamin Golinvaux <bgo@osimis.io>
parents:
761
diff
changeset
|
221 return canvasToSceneFactor_; |
66ac7a2d1e3a
A few renames and cleanups + moved GUI constants to controller + start work on
Benjamin Golinvaux <bgo@osimis.io>
parents:
761
diff
changeset
|
222 } |
66ac7a2d1e3a
A few renames and cleanups + moved GUI constants to controller + start work on
Benjamin Golinvaux <bgo@osimis.io>
parents:
761
diff
changeset
|
223 |
66ac7a2d1e3a
A few renames and cleanups + moved GUI constants to controller + start work on
Benjamin Golinvaux <bgo@osimis.io>
parents:
761
diff
changeset
|
224 double ViewportController::GetHandleSideLengthS() const |
66ac7a2d1e3a
A few renames and cleanups + moved GUI constants to controller + start work on
Benjamin Golinvaux <bgo@osimis.io>
parents:
761
diff
changeset
|
225 { |
66ac7a2d1e3a
A few renames and cleanups + moved GUI constants to controller + start work on
Benjamin Golinvaux <bgo@osimis.io>
parents:
761
diff
changeset
|
226 return HANDLE_SIDE_LENGTH_CANVAS_COORD * GetCanvasToSceneFactor(); |
66ac7a2d1e3a
A few renames and cleanups + moved GUI constants to controller + start work on
Benjamin Golinvaux <bgo@osimis.io>
parents:
761
diff
changeset
|
227 } |
66ac7a2d1e3a
A few renames and cleanups + moved GUI constants to controller + start work on
Benjamin Golinvaux <bgo@osimis.io>
parents:
761
diff
changeset
|
228 |
66ac7a2d1e3a
A few renames and cleanups + moved GUI constants to controller + start work on
Benjamin Golinvaux <bgo@osimis.io>
parents:
761
diff
changeset
|
229 double ViewportController::GetAngleToolArcRadiusS() const |
66ac7a2d1e3a
A few renames and cleanups + moved GUI constants to controller + start work on
Benjamin Golinvaux <bgo@osimis.io>
parents:
761
diff
changeset
|
230 { |
66ac7a2d1e3a
A few renames and cleanups + moved GUI constants to controller + start work on
Benjamin Golinvaux <bgo@osimis.io>
parents:
761
diff
changeset
|
231 return ARC_RADIUS_CANVAS_COORD * GetCanvasToSceneFactor(); |
66ac7a2d1e3a
A few renames and cleanups + moved GUI constants to controller + start work on
Benjamin Golinvaux <bgo@osimis.io>
parents:
761
diff
changeset
|
232 } |
66ac7a2d1e3a
A few renames and cleanups + moved GUI constants to controller + start work on
Benjamin Golinvaux <bgo@osimis.io>
parents:
761
diff
changeset
|
233 |
66ac7a2d1e3a
A few renames and cleanups + moved GUI constants to controller + start work on
Benjamin Golinvaux <bgo@osimis.io>
parents:
761
diff
changeset
|
234 double ViewportController::GetHitTestMaximumDistanceS() const |
66ac7a2d1e3a
A few renames and cleanups + moved GUI constants to controller + start work on
Benjamin Golinvaux <bgo@osimis.io>
parents:
761
diff
changeset
|
235 { |
66ac7a2d1e3a
A few renames and cleanups + moved GUI constants to controller + start work on
Benjamin Golinvaux <bgo@osimis.io>
parents:
761
diff
changeset
|
236 return HIT_TEST_MAX_DISTANCE_CANVAS_COORD * GetCanvasToSceneFactor(); |
66ac7a2d1e3a
A few renames and cleanups + moved GUI constants to controller + start work on
Benjamin Golinvaux <bgo@osimis.io>
parents:
761
diff
changeset
|
237 } |
66ac7a2d1e3a
A few renames and cleanups + moved GUI constants to controller + start work on
Benjamin Golinvaux <bgo@osimis.io>
parents:
761
diff
changeset
|
238 |
66ac7a2d1e3a
A few renames and cleanups + moved GUI constants to controller + start work on
Benjamin Golinvaux <bgo@osimis.io>
parents:
761
diff
changeset
|
239 double ViewportController::GetAngleTopTextLabelDistanceS() const |
66ac7a2d1e3a
A few renames and cleanups + moved GUI constants to controller + start work on
Benjamin Golinvaux <bgo@osimis.io>
parents:
761
diff
changeset
|
240 { |
66ac7a2d1e3a
A few renames and cleanups + moved GUI constants to controller + start work on
Benjamin Golinvaux <bgo@osimis.io>
parents:
761
diff
changeset
|
241 return TEXT_CENTER_DISTANCE_CANVAS_COORD * GetCanvasToSceneFactor(); |
66ac7a2d1e3a
A few renames and cleanups + moved GUI constants to controller + start work on
Benjamin Golinvaux <bgo@osimis.io>
parents:
761
diff
changeset
|
242 } |
1208
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
243 |
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
244 |
1331
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1309
diff
changeset
|
245 void ViewportController::HandleMousePress( |
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1309
diff
changeset
|
246 OrthancStone::IViewportInteractor& interactor, |
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1309
diff
changeset
|
247 const PointerEvent& event, |
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1309
diff
changeset
|
248 unsigned int viewportWidth, |
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1309
diff
changeset
|
249 unsigned int viewportHeight) |
1208
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
250 { |
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
251 if (activeTracker_) |
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
252 { |
1331
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1309
diff
changeset
|
253 // We are dealing with a multi-stage tracker (that is made of several |
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1309
diff
changeset
|
254 // interactions) |
1208
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
255 activeTracker_->PointerDown(event); |
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
256 |
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
257 if (!activeTracker_->IsAlive()) |
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
258 { |
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
259 activeTracker_.reset(); |
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
260 } |
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
261 } |
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
262 else |
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
263 { |
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
264 // Check whether there is already a measure tool at that position |
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
265 for (size_t i = 0; i < measureTools_.size(); ++i) |
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
266 { |
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
267 if (measureTools_[i]->HitTest(event.GetMainPosition())) |
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
268 { |
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
269 activeTracker_ = measureTools_[i]->CreateEditionTracker(event); |
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
270 return; |
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
271 } |
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
272 } |
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
273 |
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
274 // No measure tool, create new tracker from the interactor |
1331
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1309
diff
changeset
|
275 activeTracker_.reset(interactor.CreateTracker(viewport_, |
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1309
diff
changeset
|
276 event, |
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1309
diff
changeset
|
277 viewportWidth, |
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1309
diff
changeset
|
278 viewportHeight)); |
1208
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
279 } |
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
280 } |
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
281 |
1249
964c89e15e7e
ViewportController::HandleMouseMove() returning a Boolean for invalidation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1233
diff
changeset
|
282 bool ViewportController::HandleMouseMove(const PointerEvent& event) |
1208
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
283 { |
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
284 if (activeTracker_) |
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
285 { |
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
286 activeTracker_->PointerMove(event); |
1249
964c89e15e7e
ViewportController::HandleMouseMove() returning a Boolean for invalidation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1233
diff
changeset
|
287 return true; |
964c89e15e7e
ViewportController::HandleMouseMove() returning a Boolean for invalidation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1233
diff
changeset
|
288 } |
964c89e15e7e
ViewportController::HandleMouseMove() returning a Boolean for invalidation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1233
diff
changeset
|
289 else |
964c89e15e7e
ViewportController::HandleMouseMove() returning a Boolean for invalidation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1233
diff
changeset
|
290 { |
964c89e15e7e
ViewportController::HandleMouseMove() returning a Boolean for invalidation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1233
diff
changeset
|
291 return false; |
1208
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
292 } |
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
293 } |
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
294 |
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
295 void ViewportController::HandleMouseRelease(const PointerEvent& event) |
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
296 { |
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
297 if (activeTracker_) |
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
298 { |
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
299 activeTracker_->PointerUp(event); |
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
300 |
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
301 if (!activeTracker_->IsAlive()) |
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
302 { |
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
303 activeTracker_.reset(); |
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
304 } |
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
305 } |
00e6bff9ea39
handling of mouse interactions in ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1203
diff
changeset
|
306 } |
698
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
307 } |