# HG changeset patch # User Sebastien Jodogne # Date 1539772232 -7200 # Node ID b10dfdb96866d004031bf3bd9e6e0f9ce2e42e0a # Parent c80b5bddf86bdff5a1f1b84bbebec64a7c2fcad6 removing WorldSceneWidget::IWorldObserver diff -r c80b5bddf86b -r b10dfdb96866 Applications/Samples/SingleFrameEditorApplication.h --- a/Applications/Samples/SingleFrameEditorApplication.h Wed Oct 17 10:26:33 2018 +0200 +++ b/Applications/Samples/SingleFrameEditorApplication.h Wed Oct 17 12:30:32 2018 +0200 @@ -72,9 +72,11 @@ IStatusBar* statusBar) { switch (application_.currentTool_) { - case Tools_Crop: + case Tools_Zoom: + printf("ZOOM\n"); + + case Tools_Crop: case Tools_Windowing: - case Tools_Zoom: case Tools_Pan: // TODO return the right mouse tracker return NULL; @@ -97,7 +99,7 @@ char buf[64]; sprintf(buf, "X = %.02f Y = %.02f Z = %.02f (in cm)", p[0] / 10.0, p[1] / 10.0, p[2] / 10.0); - statusBar->SetMessage(buf); + //statusBar->SetMessage(buf); } } @@ -149,8 +151,9 @@ } }; - void OnMainWidgetGeometryReady(const ILayerSource::GeometryReadyMessage& message) + void OnGeometryChanged(const LayerWidget::GeometryChangedMessage& message) { + mainWidget_->SetSlice(source_->GetSlice(slice_).GetGeometry()); mainWidget_->SetDefaultView(); } @@ -208,7 +211,7 @@ std::auto_ptr layer(new OrthancFrameLayerSource(broker_, *orthancApiClient_)); source_ = layer.get(); layer->LoadFrame(instance, frame); - layer->RegisterObserverCallback(new Callable(*this, &SingleFrameEditorApplication::OnMainWidgetGeometryReady)); + mainWidget_->RegisterObserverCallback(new Callable(*this, &SingleFrameEditorApplication::OnGeometryChanged)); mainWidget_->AddLayer(layer.release()); mainWidget_->SetTransmitMouseOver(true); diff -r c80b5bddf86b -r b10dfdb96866 Framework/Layers/OrthancFrameLayerSource.cpp --- a/Framework/Layers/OrthancFrameLayerSource.cpp Wed Oct 17 10:26:33 2018 +0200 +++ b/Framework/Layers/OrthancFrameLayerSource.cpp Wed Oct 17 12:30:32 2018 +0200 @@ -105,6 +105,7 @@ const CoordinateSystem3D& viewportSlice) { size_t index; + if (loader_.IsGeometryReady() && loader_.LookupSlice(index, viewportSlice)) { @@ -122,17 +123,10 @@ { size_t index; - if (loader_.IsGeometryReady()) + if (loader_.IsGeometryReady() && + loader_.LookupSlice(index, viewportSlice)) { - if (loader_.LookupSlice(index, viewportSlice)) - { - loader_.ScheduleLoadSliceImage(index, quality_); - } - else - { - Slice slice; - LayerSourceBase::NotifyLayerReady(NULL, slice.GetGeometry(), true); - } + loader_.ScheduleLoadSliceImage(index, quality_); } } } diff -r c80b5bddf86b -r b10dfdb96866 Framework/Widgets/LayerWidget.cpp --- a/Framework/Widgets/LayerWidget.cpp Wed Oct 17 10:26:33 2018 +0200 +++ b/Framework/Widgets/LayerWidget.cpp Wed Oct 17 12:30:32 2018 +0200 @@ -255,7 +255,7 @@ ILayerSource& source) const { extent.Reset(); - + std::vector points; if (source.GetExtent(points, slice_)) { diff -r c80b5bddf86b -r b10dfdb96866 Framework/Widgets/WorldSceneWidget.cpp --- a/Framework/Widgets/WorldSceneWidget.cpp Wed Oct 17 10:26:33 2018 +0200 +++ b/Framework/Widgets/WorldSceneWidget.cpp Wed Oct 17 12:30:32 2018 +0200 @@ -43,23 +43,6 @@ } - struct WorldSceneWidget::SizeChangeFunctor - { - ViewportGeometry& view_; - - SizeChangeFunctor(ViewportGeometry& view) : - view_(view) - { - } - - void operator() (IWorldObserver& observer, - const WorldSceneWidget& source) - { - observer.NotifySizeChange(source, view_); - } - }; - - // this is an adapter between a IWorldSceneMouseTracker // that is tracking a mouse in scene coordinates/mm and // an IMouseTracker that is tracking a mouse @@ -112,14 +95,14 @@ that_.view_.GetPan(previousPanX_, previousPanY_); } + void WorldSceneWidget::PanMouseTracker::MouseMove(int x, int y) { that_.view_.SetPan(previousPanX_ + x - downX_, previousPanY_ + y - downY_); - - that_.observers_.Apply(that_, &IWorldObserver::NotifyViewChange, that_.view_); } + WorldSceneWidget::ZoomMouseTracker::ZoomMouseTracker(WorldSceneWidget& that, int x, int y) : @@ -174,8 +157,6 @@ that_.view_.MapSceneToDisplay(tx, ty, centerX_, centerY_); that_.view_.SetPan(panX + static_cast(downX_ - tx), panY + static_cast(downY_ - ty)); - - that_.observers_.Apply(that_, &IWorldObserver::NotifyViewChange, that_.view_); } @@ -209,20 +190,7 @@ unsigned int height) { CairoWidget::SetSize(width, height); - view_.SetDisplaySize(width, height); - - if (observers_.IsEmpty()) - { - // Without a size observer, reset to the default view - // view_.SetDefaultView(); - } - else - { - // With a size observer, let it decide which view to use - SizeChangeFunctor functor(view_); - observers_.Notify(*this, functor); - } } @@ -238,8 +206,6 @@ view_.SetDefaultView(); NotifyContentChanged(); - - observers_.Apply(*this, &IWorldObserver::NotifyViewChange, view_); } @@ -248,8 +214,6 @@ view_ = view; NotifyContentChanged(); - - observers_.Apply(*this, &IWorldObserver::NotifyViewChange, view_); } diff -r c80b5bddf86b -r b10dfdb96866 Framework/Widgets/WorldSceneWidget.h --- a/Framework/Widgets/WorldSceneWidget.h Wed Oct 17 10:26:33 2018 +0200 +++ b/Framework/Widgets/WorldSceneWidget.h Wed Oct 17 12:30:32 2018 +0200 @@ -32,20 +32,6 @@ class WorldSceneWidget : public CairoWidget { public: - class IWorldObserver : public boost::noncopyable - { - public: - virtual ~IWorldObserver() - { - } - - virtual void NotifySizeChange(const WorldSceneWidget& source, - ViewportGeometry& view) = 0; // Can be tuned by the observer - - virtual void NotifyViewChange(const WorldSceneWidget& source, - const ViewportGeometry& view) = 0; - }; - class PanMouseTracker : public IMouseTracker { private: @@ -90,10 +76,7 @@ class SceneMouseTracker; - typedef ObserversRegistry Observers; - ViewportGeometry view_; - Observers observers_; IWorldSceneInteractor* interactor_; public: @@ -118,16 +101,6 @@ { } - void Register(IWorldObserver& observer) - { - observers_.Register(observer); - } - - void Unregister(IWorldObserver& observer) - { - observers_.Unregister(observer); - } - virtual void SetSize(unsigned int width, unsigned int height);