Mercurial > hg > orthanc-stone
diff Framework/Scene2DViewport/CreateLineMeasureTracker.cpp @ 700:059e1fd05fd6 refactor-viewport-controller
Introduced the ViewportController that sits between the application and the
Scene2D to handle the trackers and measuring tools. This is a work in progress.
The Scene2D is no longer an observable. Message sending is managed by the
ViewportController.
Move some refs to shared and weak to prevent lifetime issues.
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Sun, 19 May 2019 16:26:17 +0200 |
parents | 8b6adfb62a2f |
children | 28b9e3a54200 |
line wrap: on
line diff
--- a/Framework/Scene2DViewport/CreateLineMeasureTracker.cpp Fri May 17 09:20:46 2019 +0200 +++ b/Framework/Scene2DViewport/CreateLineMeasureTracker.cpp Sun May 19 16:26:17 2019 +0200 @@ -27,19 +27,18 @@ { CreateLineMeasureTracker::CreateLineMeasureTracker( MessageBroker& broker, - Scene2DWPtr sceneW, + ViewportControllerWPtr controllerW, std::vector<TrackerCommandPtr>& undoStack, MeasureToolList& measureTools, const PointerEvent& e) - : CreateMeasureTracker(sceneW, undoStack, measureTools) + : CreateMeasureTracker(controllerW, undoStack, measureTools) { - Scene2DPtr scene = sceneW.lock(); command_.reset( new CreateLineMeasureCommand( broker, - sceneW, + controllerW, measureTools, - e.GetMainPosition().Apply(scene->GetCanvasToSceneTransform()))); + e.GetMainPosition().Apply(GetScene()->GetCanvasToSceneTransform()))); } CreateLineMeasureTracker::~CreateLineMeasureTracker() @@ -49,10 +48,9 @@ void CreateLineMeasureTracker::PointerMove(const PointerEvent& event) { - Scene2DPtr scene = scene_.lock(); - assert(scene); + assert(GetScene()); - if (!active_) + if (!alive_) { throw OrthancException(ErrorCode_InternalError, "Internal error: wrong state in CreateLineMeasureTracker::" @@ -60,7 +58,7 @@ } ScenePoint2D scenePos = event.GetMainPosition().Apply( - scene->GetCanvasToSceneTransform()); + GetScene()->GetCanvasToSceneTransform()); //LOG(TRACE) << "scenePos.GetX() = " << scenePos.GetX() << " " << // "scenePos.GetY() = " << scenePos.GetY(); @@ -78,7 +76,7 @@ // Unless we augment the PointerEvent structure with the button index, // we cannot really tell if this pointer up event matches the initial // pointer down event. Let's make it simple for now. - active_ = false; + alive_ = false; } void CreateLineMeasureTracker::PointerDown(const PointerEvent& e)