Mercurial > hg > orthanc-stone
comparison Framework/Widgets/WorldSceneWidget.cpp @ 91:81f73efd81a1 wasm
cleaning up
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 29 May 2017 11:18:35 +0200 |
parents | bd48431ac285 |
children | 53bd9277b025 |
comparison
equal
deleted
inserted
replaced
90:64e60018943f | 91:81f73efd81a1 |
---|---|
36 | 36 |
37 view.MapDisplayToScene(sceneX, sceneY, x, y); | 37 view.MapDisplayToScene(sceneX, sceneY, x, y); |
38 } | 38 } |
39 | 39 |
40 | 40 |
41 struct WorldSceneWidget::ViewChangeFunctor | |
42 { | |
43 const ViewportGeometry& view_; | |
44 | |
45 ViewChangeFunctor(const ViewportGeometry& view) : | |
46 view_(view) | |
47 { | |
48 } | |
49 | |
50 void operator() (IWorldObserver& observer, | |
51 const WorldSceneWidget& source) | |
52 { | |
53 observer.NotifyViewChange(source, view_); | |
54 } | |
55 }; | |
56 | |
57 | |
58 struct WorldSceneWidget::SizeChangeFunctor | 41 struct WorldSceneWidget::SizeChangeFunctor |
59 { | 42 { |
60 ViewportGeometry& view_; | 43 ViewportGeometry& view_; |
61 | 44 |
62 SizeChangeFunctor(ViewportGeometry& view) : | 45 SizeChangeFunctor(ViewportGeometry& view) : |
142 int y) | 125 int y) |
143 { | 126 { |
144 that_.view_.SetPan(previousPanX_ + x - downX_, | 127 that_.view_.SetPan(previousPanX_ + x - downX_, |
145 previousPanY_ + y - downY_); | 128 previousPanY_ + y - downY_); |
146 | 129 |
147 ViewChangeFunctor functor(that_.view_); | 130 that_.observers_.Apply(that_, &IWorldObserver::NotifyViewChange, that_.view_); |
148 that_.observers_.Notify(&that_, functor); | |
149 } | 131 } |
150 }; | 132 }; |
151 | 133 |
152 | 134 |
153 class WorldSceneWidget::ZoomMouseTracker : public IMouseTracker | 135 class WorldSceneWidget::ZoomMouseTracker : public IMouseTracker |
221 int tx, ty; | 203 int tx, ty; |
222 that_.view_.MapSceneToDisplay(tx, ty, centerX_, centerY_); | 204 that_.view_.MapSceneToDisplay(tx, ty, centerX_, centerY_); |
223 that_.view_.SetPan(panX + static_cast<double>(downX_ - tx), | 205 that_.view_.SetPan(panX + static_cast<double>(downX_ - tx), |
224 panY + static_cast<double>(downY_ - ty)); | 206 panY + static_cast<double>(downY_ - ty)); |
225 | 207 |
226 ViewChangeFunctor functor(that_.view_); | 208 that_.observers_.Apply(that_, &IWorldObserver::NotifyViewChange, that_.view_); |
227 that_.observers_.Notify(&that_, functor); | |
228 } | 209 } |
229 }; | 210 }; |
230 | 211 |
231 | 212 |
232 bool WorldSceneWidget::RenderCairo(CairoContext& context) | 213 bool WorldSceneWidget::RenderCairo(CairoContext& context) |
271 } | 252 } |
272 else | 253 else |
273 { | 254 { |
274 // With a size observer, let it decide which view to use | 255 // With a size observer, let it decide which view to use |
275 SizeChangeFunctor functor(view_); | 256 SizeChangeFunctor functor(view_); |
276 observers_.Notify(this, functor); | 257 observers_.Notify(*this, functor); |
277 } | 258 } |
278 } | 259 } |
279 | 260 |
280 | 261 |
281 void WorldSceneWidget::SetInteractor(IWorldSceneInteractor& interactor) | 262 void WorldSceneWidget::SetInteractor(IWorldSceneInteractor& interactor) |
289 SetSceneExtent(view_); | 270 SetSceneExtent(view_); |
290 view_.SetDefaultView(); | 271 view_.SetDefaultView(); |
291 | 272 |
292 NotifyChange(); | 273 NotifyChange(); |
293 | 274 |
294 ViewChangeFunctor functor(view_); | 275 observers_.Apply(*this, &IWorldObserver::NotifyViewChange, view_); |
295 observers_.Notify(this, functor); | |
296 } | 276 } |
297 | 277 |
298 | 278 |
299 void WorldSceneWidget::SetView(const ViewportGeometry& view) | 279 void WorldSceneWidget::SetView(const ViewportGeometry& view) |
300 { | 280 { |
301 view_ = view; | 281 view_ = view; |
302 | 282 |
303 NotifyChange(); | 283 NotifyChange(); |
304 | 284 |
305 ViewChangeFunctor functor(view_); | 285 observers_.Apply(*this, &IWorldObserver::NotifyViewChange, view_); |
306 observers_.Notify(this, functor); | |
307 } | 286 } |
308 | 287 |
309 | 288 |
310 ViewportGeometry WorldSceneWidget::GetView() | 289 ViewportGeometry WorldSceneWidget::GetView() |
311 { | 290 { |