Mercurial > hg > orthanc-stone
diff Framework/Scene2DViewport/LineMeasureTool.cpp @ 866:c71ef52602a0 toa2019062501
Added the ability to edit existing measuring tools (demo not updated yet)
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Tue, 25 Jun 2019 17:54:46 +0200 |
parents | a29c13497557 |
children | 0aff28f15ea2 |
line wrap: on
line diff
--- a/Framework/Scene2DViewport/LineMeasureTool.cpp Tue Jun 25 15:24:13 2019 +0200 +++ b/Framework/Scene2DViewport/LineMeasureTool.cpp Tue Jun 25 17:54:46 2019 +0200 @@ -20,6 +20,7 @@ #include "LineMeasureTool.h" #include "MeasureToolsToolbox.h" +#include "EditLineMeasureTracker.h" #include "LayerHolder.h" #include <Core/Logging.h> @@ -119,6 +120,44 @@ return LineHitTest(p) != LineHighlightArea_None; } + boost::shared_ptr<IFlexiblePointerTracker> LineMeasureTool::CreateEditionTracker(const PointerEvent& e) + { + ScenePoint2D scenePos = e.GetMainPosition().Apply( + GetScene()->GetCanvasToSceneTransform()); + + if (!HitTest(scenePos)) + return boost::shared_ptr<IFlexiblePointerTracker>(); + + /** + new EditLineMeasureTracker( + boost::shared_ptr<LineMeasureTool> measureTool; + MessageBroker & broker, + boost::weak_ptr<ViewportController> controllerW, + const PointerEvent & e); + */ + boost::shared_ptr<EditLineMeasureTracker> editLineMeasureTracker( + new EditLineMeasureTracker(shared_from_this(), GetBroker(), GetController(), e)); + return editLineMeasureTracker; + } + + + boost::shared_ptr<MeasureToolMemento> LineMeasureTool::GetMemento() const + { + boost::shared_ptr<LineMeasureToolMemento> memento(new LineMeasureToolMemento()); + memento->start_ = start_; + memento->end_ = end_; + return memento; + } + + void LineMeasureTool::SetMemento(boost::shared_ptr<MeasureToolMemento> mementoBase) + { + boost::shared_ptr<LineMeasureToolMemento> memento = boost::dynamic_pointer_cast<LineMeasureToolMemento>(mementoBase); + ORTHANC_ASSERT(memento.get() != NULL, "Internal error: wrong (or bad) memento"); + start_ = memento->start_; + end_ = memento->end_; + RefreshScene(); + } + void LineMeasureTool::RefreshScene() { if (IsSceneAlive())