Mercurial > hg > orthanc-stone
changeset 2379:badae7b22831 refactoring
cont
| author | Sebastien Jodogne <s.jodogne@gmail.com> |
|---|---|
| date | Fri, 09 Oct 2026 16:12:21 +0200 |
| parents | 29020ee1e020 |
| children | 6a631b1d18ae |
| files | OrthancStone/Sources/Scene2DViewport/AngleMeasureTool.cpp |
| diffstat | 1 files changed, 13 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- a/OrthancStone/Sources/Scene2DViewport/AngleMeasureTool.cpp Fri Oct 09 16:09:48 2026 +0200 +++ b/OrthancStone/Sources/Scene2DViewport/AngleMeasureTool.cpp Fri Oct 09 16:12:21 2026 +0200 @@ -48,19 +48,16 @@ ScenePoint2D originalClickPosition_; AngleMeasureTool::AngleHighlightArea modifiedZone_; bool alive_; - boost::weak_ptr<IViewport>& viewport_; // TODO Refactoring boost::shared_ptr<EditMeasureCommand> editCommand_; public: Tracker(const boost::shared_ptr<AngleMeasureTool>& tool, bool isCreation, const Scene2D& scene, - const PointerEvent& e, - boost::weak_ptr<IViewport>& viewport) : + const PointerEvent& e) : tool_(tool), originalClickPosition_(e.GetMainPosition().Apply(scene.GetCanvasToSceneTransform())), - alive_(true), - viewport_(viewport) + alive_(true) { if (!tool) { @@ -70,20 +67,15 @@ modifiedZone_ = tool_->AngleHitTest(scene, originalClickPosition_); originalMemento_.reset(dynamic_cast<AngleMeasureTool::Memento*>(tool->CreateMemento())); - boost::shared_ptr<IViewport> sharedViewport = viewport.lock(); - if (sharedViewport) + if (isCreation) { - std::unique_ptr<IViewport::ILock> lock(sharedViewport->Lock()); - if (isCreation) - { - boost::shared_ptr<MeasureCommand> command(new CreateMeasureCommand(tool_)); - lock->GetController().PushCommand(command); - } - else - { - boost::shared_ptr<EditMeasureCommand> command(new EditMeasureCommand(tool_)); - editCommand_ = command; - } + boost::shared_ptr<MeasureCommand> command(new CreateMeasureCommand(tool_)); + tool->GetController().PushCommand(command); + } + else + { + boost::shared_ptr<EditMeasureCommand> command(new EditMeasureCommand(tool_)); + editCommand_ = command; } } @@ -143,13 +135,8 @@ if (alive_ && editCommand_) { editCommand_->SetMementoModified(tool_->CreateMemento()); - - boost::shared_ptr<IViewport> sharedViewport = viewport_.lock(); - if (sharedViewport) - { - std::unique_ptr<IViewport::ILock> lock(sharedViewport->Lock()); - lock->GetController().PushCommand(editCommand_); - } + tool_->GetController().PushCommand(editCommand_); + editCommand_.reset(); } alive_ = false; @@ -354,7 +341,7 @@ } else { - return new Tracker(boost::dynamic_pointer_cast<AngleMeasureTool>(shared_from_this()), isCreation, scene, e, viewport_); + return new Tracker(boost::dynamic_pointer_cast<AngleMeasureTool>(shared_from_this()), isCreation, scene, e); } }
