annotate Framework/Deprecated/Widgets/WorldSceneWidget.cpp @ 1414:4f2e14275b09

Merge from loader-cache-refactoring
author Benjamin Golinvaux <bgo@osimis.io>
date Mon, 04 May 2020 18:27:44 +0200
parents 8a0a62189f46
children 30deba7bc8e2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Stone of Orthanc
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
1270
2d8ab34c8c91 upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1219
diff changeset
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
47
28956ed68280 agpl license
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 40
diff changeset
8 * modify it under the terms of the GNU Affero General Public License
28956ed68280 agpl license
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 40
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
28956ed68280 agpl license
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 40
diff changeset
10 * the License, or (at your option) any later version.
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
47
28956ed68280 agpl license
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 40
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
28956ed68280 agpl license
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 40
diff changeset
15 * Affero General Public License for more details.
281
300d8b8c48b3 mouse tracker tuning
am@osimis.io
parents: 278
diff changeset
16 *
47
28956ed68280 agpl license
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 40
diff changeset
17 * You should have received a copy of the GNU Affero General Public License
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 **/
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 #include "WorldSceneWidget.h"
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
332
50e5ec1bdd46 separating ZoomMouseTracker and PanMouseTracker from WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 331
diff changeset
24 #include "PanMouseTracker.h"
50e5ec1bdd46 separating ZoomMouseTracker and PanMouseTracker from WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 331
diff changeset
25 #include "ZoomMouseTracker.h"
457
3b4df9925db6 added support for 'touch' in mouse trackers. This is still a bit hacky and we need to refactor it to make it clean. Thanks to that, Pan and zoom are available together with 2 touches
Alain Mazy <alain@mazy.be>
parents: 439
diff changeset
26 #include "PanZoomMouseTracker.h"
332
50e5ec1bdd46 separating ZoomMouseTracker and PanMouseTracker from WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 331
diff changeset
27
50e5ec1bdd46 separating ZoomMouseTracker and PanMouseTracker from WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 331
diff changeset
28 #include <Core/Logging.h>
403
99e31898910e IObservable.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
29 #include <Core/OrthancException.h>
332
50e5ec1bdd46 separating ZoomMouseTracker and PanMouseTracker from WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 331
diff changeset
30
110
53025eecbc95 renamed SliceGeometry as CoordinateSystem3D
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 109
diff changeset
31 #include <math.h>
53025eecbc95 renamed SliceGeometry as CoordinateSystem3D
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 109
diff changeset
32 #include <memory>
53025eecbc95 renamed SliceGeometry as CoordinateSystem3D
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 109
diff changeset
33 #include <cassert>
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 693
diff changeset
35 namespace Deprecated
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 {
281
300d8b8c48b3 mouse tracker tuning
am@osimis.io
parents: 278
diff changeset
37 // this is an adapter between a IWorldSceneMouseTracker
300d8b8c48b3 mouse tracker tuning
am@osimis.io
parents: 278
diff changeset
38 // that is tracking a mouse in scene coordinates/mm and
300d8b8c48b3 mouse tracker tuning
am@osimis.io
parents: 278
diff changeset
39 // an IMouseTracker that is tracking a mouse
300d8b8c48b3 mouse tracker tuning
am@osimis.io
parents: 278
diff changeset
40 // in screen coordinates/pixels.
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 class WorldSceneWidget::SceneMouseTracker : public IMouseTracker
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 {
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 private:
332
50e5ec1bdd46 separating ZoomMouseTracker and PanMouseTracker from WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 331
diff changeset
44 ViewportGeometry view_;
1298
8a0a62189f46 replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1270
diff changeset
45 std::unique_ptr<IWorldSceneMouseTracker> tracker_;
281
300d8b8c48b3 mouse tracker tuning
am@osimis.io
parents: 278
diff changeset
46
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 public:
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 SceneMouseTracker(const ViewportGeometry& view,
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 IWorldSceneMouseTracker* tracker) :
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 view_(view),
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 tracker_(tracker)
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 {
332
50e5ec1bdd46 separating ZoomMouseTracker and PanMouseTracker from WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 331
diff changeset
53 if (tracker == NULL)
50e5ec1bdd46 separating ZoomMouseTracker and PanMouseTracker from WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 331
diff changeset
54 {
50e5ec1bdd46 separating ZoomMouseTracker and PanMouseTracker from WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 331
diff changeset
55 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer);
50e5ec1bdd46 separating ZoomMouseTracker and PanMouseTracker from WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 331
diff changeset
56 }
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 }
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 virtual void Render(Orthanc::ImageAccessor& target)
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 {
332
50e5ec1bdd46 separating ZoomMouseTracker and PanMouseTracker from WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 331
diff changeset
61 if (tracker_->HasRender())
50e5ec1bdd46 separating ZoomMouseTracker and PanMouseTracker from WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 331
diff changeset
62 {
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 693
diff changeset
63 OrthancStone::CairoSurface surface(target, false /* no alpha */);
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 693
diff changeset
64 OrthancStone::CairoContext context(surface);
332
50e5ec1bdd46 separating ZoomMouseTracker and PanMouseTracker from WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 331
diff changeset
65 view_.ApplyTransform(context);
50e5ec1bdd46 separating ZoomMouseTracker and PanMouseTracker from WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 331
diff changeset
66 tracker_->Render(context, view_.GetZoom());
50e5ec1bdd46 separating ZoomMouseTracker and PanMouseTracker from WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 331
diff changeset
67 }
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 }
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69
281
300d8b8c48b3 mouse tracker tuning
am@osimis.io
parents: 278
diff changeset
70 virtual void MouseUp()
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 {
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 tracker_->MouseUp();
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 }
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74
281
300d8b8c48b3 mouse tracker tuning
am@osimis.io
parents: 278
diff changeset
75 virtual void MouseMove(int x,
457
3b4df9925db6 added support for 'touch' in mouse trackers. This is still a bit hacky and we need to refactor it to make it clean. Thanks to that, Pan and zoom are available together with 2 touches
Alain Mazy <alain@mazy.be>
parents: 439
diff changeset
76 int y,
3b4df9925db6 added support for 'touch' in mouse trackers. This is still a bit hacky and we need to refactor it to make it clean. Thanks to that, Pan and zoom are available together with 2 touches
Alain Mazy <alain@mazy.be>
parents: 439
diff changeset
77 const std::vector<Touch>& displayTouches)
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 {
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 double sceneX, sceneY;
332
50e5ec1bdd46 separating ZoomMouseTracker and PanMouseTracker from WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 331
diff changeset
80 view_.MapPixelCenterToScene(sceneX, sceneY, x, y);
457
3b4df9925db6 added support for 'touch' in mouse trackers. This is still a bit hacky and we need to refactor it to make it clean. Thanks to that, Pan and zoom are available together with 2 touches
Alain Mazy <alain@mazy.be>
parents: 439
diff changeset
81
3b4df9925db6 added support for 'touch' in mouse trackers. This is still a bit hacky and we need to refactor it to make it clean. Thanks to that, Pan and zoom are available together with 2 touches
Alain Mazy <alain@mazy.be>
parents: 439
diff changeset
82 std::vector<Touch> sceneTouches;
3b4df9925db6 added support for 'touch' in mouse trackers. This is still a bit hacky and we need to refactor it to make it clean. Thanks to that, Pan and zoom are available together with 2 touches
Alain Mazy <alain@mazy.be>
parents: 439
diff changeset
83 for (size_t t = 0; t < displayTouches.size(); t++)
3b4df9925db6 added support for 'touch' in mouse trackers. This is still a bit hacky and we need to refactor it to make it clean. Thanks to that, Pan and zoom are available together with 2 touches
Alain Mazy <alain@mazy.be>
parents: 439
diff changeset
84 {
3b4df9925db6 added support for 'touch' in mouse trackers. This is still a bit hacky and we need to refactor it to make it clean. Thanks to that, Pan and zoom are available together with 2 touches
Alain Mazy <alain@mazy.be>
parents: 439
diff changeset
85 double sx, sy;
693
9a474e90e832 Fixed a bunch of truncation warnings in various parts of the library
Benjamin Golinvaux <bgo@osimis.io>
parents: 561
diff changeset
86
9a474e90e832 Fixed a bunch of truncation warnings in various parts of the library
Benjamin Golinvaux <bgo@osimis.io>
parents: 561
diff changeset
87 view_.MapPixelCenterToScene(
9a474e90e832 Fixed a bunch of truncation warnings in various parts of the library
Benjamin Golinvaux <bgo@osimis.io>
parents: 561
diff changeset
88 sx, sy, (int)displayTouches[t].x, (int)displayTouches[t].y);
9a474e90e832 Fixed a bunch of truncation warnings in various parts of the library
Benjamin Golinvaux <bgo@osimis.io>
parents: 561
diff changeset
89
9a474e90e832 Fixed a bunch of truncation warnings in various parts of the library
Benjamin Golinvaux <bgo@osimis.io>
parents: 561
diff changeset
90 sceneTouches.push_back(
9a474e90e832 Fixed a bunch of truncation warnings in various parts of the library
Benjamin Golinvaux <bgo@osimis.io>
parents: 561
diff changeset
91 Touch(static_cast<float>(sx), static_cast<float>(sy)));
457
3b4df9925db6 added support for 'touch' in mouse trackers. This is still a bit hacky and we need to refactor it to make it clean. Thanks to that, Pan and zoom are available together with 2 touches
Alain Mazy <alain@mazy.be>
parents: 439
diff changeset
92 }
3b4df9925db6 added support for 'touch' in mouse trackers. This is still a bit hacky and we need to refactor it to make it clean. Thanks to that, Pan and zoom are available together with 2 touches
Alain Mazy <alain@mazy.be>
parents: 439
diff changeset
93 tracker_->MouseMove(x, y, sceneX, sceneY, displayTouches, sceneTouches);
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 }
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95 };
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 693
diff changeset
98 bool WorldSceneWidget::RenderCairo(OrthancStone::CairoContext& context)
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99 {
53
c2dc924f1a63 removing threading out of the framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 48
diff changeset
100 view_.ApplyTransform(context);
c2dc924f1a63 removing threading out of the framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 48
diff changeset
101 return RenderScene(context, view_);
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102 }
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 693
diff changeset
105 void WorldSceneWidget::RenderMouseOverCairo(OrthancStone::CairoContext& context,
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106 int x,
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107 int y)
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108 {
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109 ViewportGeometry view = GetView();
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110 view.ApplyTransform(context);
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112 double sceneX, sceneY;
332
50e5ec1bdd46 separating ZoomMouseTracker and PanMouseTracker from WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 331
diff changeset
113 view.MapPixelCenterToScene(sceneX, sceneY, x, y);
331
7ccf919faff0 simplify WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 330
diff changeset
114
7ccf919faff0 simplify WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 330
diff changeset
115 if (interactor_)
7ccf919faff0 simplify WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 330
diff changeset
116 {
7ccf919faff0 simplify WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 330
diff changeset
117 interactor_->MouseOver(context, *this, view, sceneX, sceneY, GetStatusBar());
7ccf919faff0 simplify WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 330
diff changeset
118 }
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119 }
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121
53
c2dc924f1a63 removing threading out of the framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 48
diff changeset
122 void WorldSceneWidget::SetSceneExtent(ViewportGeometry& view)
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
123 {
109
53bd9277b025 using the Extent class
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 91
diff changeset
124 view.SetSceneExtent(GetSceneExtent());
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
125 }
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
126
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
127
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
128 void WorldSceneWidget::SetSize(unsigned int width,
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
129 unsigned int height)
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
130 {
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
131 CairoWidget::SetSize(width, height);
53
c2dc924f1a63 removing threading out of the framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 48
diff changeset
132 view_.SetDisplaySize(width, height);
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
133 }
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
134
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
135
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
136 void WorldSceneWidget::SetInteractor(IWorldSceneInteractor& interactor)
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
137 {
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
138 interactor_ = &interactor;
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
139 }
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
140
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
141
330
7a364e44fbb4 renamed SetDefaultView in FitContent
am@osimis.io
parents: 329
diff changeset
142 void WorldSceneWidget::FitContent()
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
143 {
53
c2dc924f1a63 removing threading out of the framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 48
diff changeset
144 SetSceneExtent(view_);
330
7a364e44fbb4 renamed SetDefaultView in FitContent
am@osimis.io
parents: 329
diff changeset
145 view_.FitContent();
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
146
278
8a86695fcbc3 renamings
am@osimis.io
parents: 196
diff changeset
147 NotifyContentChanged();
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
148 }
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
149
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
150
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
151 void WorldSceneWidget::SetView(const ViewportGeometry& view)
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
152 {
53
c2dc924f1a63 removing threading out of the framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 48
diff changeset
153 view_ = view;
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
154
278
8a86695fcbc3 renamings
am@osimis.io
parents: 196
diff changeset
155 NotifyContentChanged();
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
156 }
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
157
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
158
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 693
diff changeset
159 IMouseTracker* WorldSceneWidget::CreateMouseTracker(OrthancStone::MouseButton button,
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
160 int x,
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
161 int y,
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 693
diff changeset
162 OrthancStone::KeyboardModifiers modifiers,
457
3b4df9925db6 added support for 'touch' in mouse trackers. This is still a bit hacky and we need to refactor it to make it clean. Thanks to that, Pan and zoom are available together with 2 touches
Alain Mazy <alain@mazy.be>
parents: 439
diff changeset
163 const std::vector<Touch>& touches)
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
164 {
53
c2dc924f1a63 removing threading out of the framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 48
diff changeset
165 double sceneX, sceneY;
332
50e5ec1bdd46 separating ZoomMouseTracker and PanMouseTracker from WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 331
diff changeset
166 view_.MapPixelCenterToScene(sceneX, sceneY, x, y);
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
167
281
300d8b8c48b3 mouse tracker tuning
am@osimis.io
parents: 278
diff changeset
168 // asks the Widget Interactor to provide a mouse tracker
1298
8a0a62189f46 replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1270
diff changeset
169 std::unique_ptr<IWorldSceneMouseTracker> tracker;
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
170
331
7ccf919faff0 simplify WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 330
diff changeset
171 if (interactor_)
7ccf919faff0 simplify WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 330
diff changeset
172 {
457
3b4df9925db6 added support for 'touch' in mouse trackers. This is still a bit hacky and we need to refactor it to make it clean. Thanks to that, Pan and zoom are available together with 2 touches
Alain Mazy <alain@mazy.be>
parents: 439
diff changeset
173 tracker.reset(interactor_->CreateMouseTracker(*this, view_, button, modifiers, x, y, sceneX, sceneY, GetStatusBar(), touches));
331
7ccf919faff0 simplify WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 330
diff changeset
174 }
7ccf919faff0 simplify WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 330
diff changeset
175
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
176 if (tracker.get() != NULL)
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
177 {
53
c2dc924f1a63 removing threading out of the framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 48
diff changeset
178 return new SceneMouseTracker(view_, tracker.release());
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
179 }
333
08683537a227 possibility to turn off default mouse events in WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 332
diff changeset
180 else if (hasDefaultMouseEvents_)
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
181 {
457
3b4df9925db6 added support for 'touch' in mouse trackers. This is still a bit hacky and we need to refactor it to make it clean. Thanks to that, Pan and zoom are available together with 2 touches
Alain Mazy <alain@mazy.be>
parents: 439
diff changeset
182 if (touches.size() == 2)
333
08683537a227 possibility to turn off default mouse events in WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 332
diff changeset
183 {
457
3b4df9925db6 added support for 'touch' in mouse trackers. This is still a bit hacky and we need to refactor it to make it clean. Thanks to that, Pan and zoom are available together with 2 touches
Alain Mazy <alain@mazy.be>
parents: 439
diff changeset
184 return new SceneMouseTracker(view_, new PanZoomMouseTracker(*this, touches));
3b4df9925db6 added support for 'touch' in mouse trackers. This is still a bit hacky and we need to refactor it to make it clean. Thanks to that, Pan and zoom are available together with 2 touches
Alain Mazy <alain@mazy.be>
parents: 439
diff changeset
185 }
3b4df9925db6 added support for 'touch' in mouse trackers. This is still a bit hacky and we need to refactor it to make it clean. Thanks to that, Pan and zoom are available together with 2 touches
Alain Mazy <alain@mazy.be>
parents: 439
diff changeset
186 else
3b4df9925db6 added support for 'touch' in mouse trackers. This is still a bit hacky and we need to refactor it to make it clean. Thanks to that, Pan and zoom are available together with 2 touches
Alain Mazy <alain@mazy.be>
parents: 439
diff changeset
187 {
3b4df9925db6 added support for 'touch' in mouse trackers. This is still a bit hacky and we need to refactor it to make it clean. Thanks to that, Pan and zoom are available together with 2 touches
Alain Mazy <alain@mazy.be>
parents: 439
diff changeset
188 switch (button)
3b4df9925db6 added support for 'touch' in mouse trackers. This is still a bit hacky and we need to refactor it to make it clean. Thanks to that, Pan and zoom are available together with 2 touches
Alain Mazy <alain@mazy.be>
parents: 439
diff changeset
189 {
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 693
diff changeset
190 case OrthancStone::MouseButton_Middle:
457
3b4df9925db6 added support for 'touch' in mouse trackers. This is still a bit hacky and we need to refactor it to make it clean. Thanks to that, Pan and zoom are available together with 2 touches
Alain Mazy <alain@mazy.be>
parents: 439
diff changeset
191 return new SceneMouseTracker(view_, new PanMouseTracker(*this, x, y));
333
08683537a227 possibility to turn off default mouse events in WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 332
diff changeset
192
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 693
diff changeset
193 case OrthancStone::MouseButton_Right:
457
3b4df9925db6 added support for 'touch' in mouse trackers. This is still a bit hacky and we need to refactor it to make it clean. Thanks to that, Pan and zoom are available together with 2 touches
Alain Mazy <alain@mazy.be>
parents: 439
diff changeset
194 return new SceneMouseTracker(view_, new ZoomMouseTracker(*this, x, y));
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
195
457
3b4df9925db6 added support for 'touch' in mouse trackers. This is still a bit hacky and we need to refactor it to make it clean. Thanks to that, Pan and zoom are available together with 2 touches
Alain Mazy <alain@mazy.be>
parents: 439
diff changeset
196 default:
3b4df9925db6 added support for 'touch' in mouse trackers. This is still a bit hacky and we need to refactor it to make it clean. Thanks to that, Pan and zoom are available together with 2 touches
Alain Mazy <alain@mazy.be>
parents: 439
diff changeset
197 return NULL;
3b4df9925db6 added support for 'touch' in mouse trackers. This is still a bit hacky and we need to refactor it to make it clean. Thanks to that, Pan and zoom are available together with 2 touches
Alain Mazy <alain@mazy.be>
parents: 439
diff changeset
198 }
3b4df9925db6 added support for 'touch' in mouse trackers. This is still a bit hacky and we need to refactor it to make it clean. Thanks to that, Pan and zoom are available together with 2 touches
Alain Mazy <alain@mazy.be>
parents: 439
diff changeset
199 }
333
08683537a227 possibility to turn off default mouse events in WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 332
diff changeset
200 }
08683537a227 possibility to turn off default mouse events in WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 332
diff changeset
201 else
08683537a227 possibility to turn off default mouse events in WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 332
diff changeset
202 {
08683537a227 possibility to turn off default mouse events in WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 332
diff changeset
203 return NULL;
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
204 }
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
205 }
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
206
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
207
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 693
diff changeset
208 void WorldSceneWidget::MouseWheel(OrthancStone::MouseWheelDirection direction,
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
209 int x,
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
210 int y,
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 693
diff changeset
211 OrthancStone::KeyboardModifiers modifiers)
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
212 {
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
213 if (interactor_)
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
214 {
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
215 interactor_->MouseWheel(*this, direction, modifiers, GetStatusBar());
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
216 }
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
217 }
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
218
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
219
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 693
diff changeset
220 void WorldSceneWidget::KeyPressed(OrthancStone::KeyboardKeys key,
327
8716176ff7f0 added support for arrow keys
am@osimis.io
parents: 313
diff changeset
221 char keyChar,
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 693
diff changeset
222 OrthancStone::KeyboardModifiers modifiers)
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
223 {
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
224 if (interactor_)
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
225 {
327
8716176ff7f0 added support for arrow keys
am@osimis.io
parents: 313
diff changeset
226 interactor_->KeyPressed(*this, key, keyChar, modifiers, GetStatusBar());
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
227 }
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
228 }
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
229 }