Mercurial > hg > orthanc-stone
diff Framework/Scene2D/Internals/FixedPointAligner.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 | 7efa2543699d |
children | c0fcb2757b0a |
line wrap: on
line diff
--- a/Framework/Scene2D/Internals/FixedPointAligner.cpp Fri May 17 09:20:46 2019 +0200 +++ b/Framework/Scene2D/Internals/FixedPointAligner.cpp Sun May 19 16:26:17 2019 +0200 @@ -18,29 +18,31 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. **/ - +#include <Framework/Scene2DViewport/ViewportController.h> #include "FixedPointAligner.h" namespace OrthancStone { namespace Internals { - FixedPointAligner::FixedPointAligner(Scene2D& scene, - const ScenePoint2D& p) : - scene_(scene), - canvas_(p) + FixedPointAligner::FixedPointAligner(ViewportControllerWPtr controllerW, + const ScenePoint2D& p) + : controllerW_(controllerW) + , canvas_(p) { - pivot_ = canvas_.Apply(scene_.GetCanvasToSceneTransform()); + ViewportControllerPtr controller = controllerW_.lock(); + pivot_ = canvas_.Apply(controller->GetCanvasToSceneTransform()); } void FixedPointAligner::Apply() { - ScenePoint2D p = canvas_.Apply(scene_.GetCanvasToSceneTransform()); + ViewportControllerPtr controller = controllerW_.lock(); + ScenePoint2D p = canvas_.Apply(controller->GetCanvasToSceneTransform()); - scene_.SetSceneToCanvasTransform( + controller->SetSceneToCanvasTransform( AffineTransform2D::Combine( - scene_.GetSceneToCanvasTransform(), + controller->GetSceneToCanvasTransform(), AffineTransform2D::CreateOffset(p.GetX() - pivot_.GetX(), p.GetY() - pivot_.GetY()))); }