Mercurial > hg > orthanc-stone
diff Framework/Scene2DViewport/MeasureCommands.h @ 1020:ac88989817e3 toa2019093001
TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
+ added DeleteMeasureCommand + moved the various concrete measuring tool-related
classes to their pre-assigned file locations (everything was crammed into
MeasureCommands.* files up to this commit) + added double-click handler to
GuiAdapter (for TOA implementation of "delete measuring tool on double-click")
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Mon, 30 Sep 2019 10:41:06 +0200 |
parents | c71ef52602a0 |
children | 5147277850cf 2d8ab34c8c91 |
line wrap: on
line diff
--- a/Framework/Scene2DViewport/MeasureCommands.h Fri Sep 27 13:32:05 2019 +0200 +++ b/Framework/Scene2DViewport/MeasureCommands.h Mon Sep 30 10:41:06 2019 +0200 @@ -32,10 +32,10 @@ namespace OrthancStone { - class TrackerCommand : public boost::noncopyable + class MeasureCommand : public boost::noncopyable { public: - TrackerCommand(boost::weak_ptr<ViewportController> controllerW) + MeasureCommand(boost::weak_ptr<ViewportController> controllerW) : controllerW_(controllerW) { @@ -43,14 +43,14 @@ virtual void Undo() = 0; virtual void Redo() = 0; - virtual ~TrackerCommand() {}; + virtual ~MeasureCommand() {}; protected: boost::shared_ptr<ViewportController> GetController(); boost::weak_ptr<ViewportController> controllerW_; }; - class CreateMeasureCommand : public TrackerCommand + class CreateMeasureCommand : public MeasureCommand { public: CreateMeasureCommand(boost::weak_ptr<ViewportController> controllerW); @@ -62,7 +62,7 @@ virtual boost::shared_ptr<MeasureTool> GetMeasureTool() = 0; }; - class EditMeasureCommand : public TrackerCommand + class EditMeasureCommand : public MeasureCommand { public: EditMeasureCommand(boost::shared_ptr<MeasureTool> measureTool, boost::weak_ptr<ViewportController> controllerW); @@ -83,94 +83,30 @@ boost::shared_ptr<MeasureToolMemento> mementoModified_; }; - class CreateLineMeasureCommand : public CreateMeasureCommand + class DeleteMeasureCommand : public MeasureCommand { public: - CreateLineMeasureCommand( - MessageBroker& broker, - boost::weak_ptr<ViewportController> controllerW, - ScenePoint2D point); - - // the starting position is set in the ctor - void SetEnd(ScenePoint2D scenePos); + DeleteMeasureCommand(boost::shared_ptr<MeasureTool> measureTool, boost::weak_ptr<ViewportController> controllerW); + virtual ~DeleteMeasureCommand(); + virtual void Undo() ORTHANC_OVERRIDE; + virtual void Redo() ORTHANC_OVERRIDE; + + /** This memento is the original object state */ + boost::shared_ptr<MeasureToolMemento> mementoOriginal_; private: - virtual boost::shared_ptr<MeasureTool> GetMeasureTool() ORTHANC_OVERRIDE - { - return measureTool_; - } - boost::shared_ptr<LineMeasureTool> measureTool_; - }; - - - class EditLineMeasureCommand : public EditMeasureCommand - { - public: - EditLineMeasureCommand( - boost::shared_ptr<LineMeasureTool> measureTool, - MessageBroker& broker, - boost::weak_ptr<ViewportController> controllerW); - - void SetStart(ScenePoint2D scenePos); - void SetEnd(ScenePoint2D scenePos); - - private: - virtual boost::shared_ptr<MeasureTool> GetMeasureTool() ORTHANC_OVERRIDE + /** Must be implemented by the subclasses that edit the actual tool */ + virtual boost::shared_ptr<MeasureTool> GetMeasureTool() { return measureTool_; } - boost::shared_ptr<LineMeasureTool> measureTool_; - }; - - class CreateAngleMeasureCommand : public CreateMeasureCommand - { - public: - /** Ctor sets end of side 1*/ - CreateAngleMeasureCommand( - MessageBroker& broker, - boost::weak_ptr<ViewportController> controllerW, - ScenePoint2D point); - - /** This method sets center*/ - void SetCenter(ScenePoint2D scenePos); - - /** This method sets end of side 2*/ - void SetSide2End(ScenePoint2D scenePos); - - private: - virtual boost::shared_ptr<MeasureTool> GetMeasureTool() ORTHANC_OVERRIDE - { - return measureTool_; - } - boost::shared_ptr<AngleMeasureTool> measureTool_; - }; + boost::shared_ptr<MeasureTool> measureTool_; - class EditAngleMeasureCommand : public EditMeasureCommand - { - public: - /** Ctor sets end of side 1*/ - EditAngleMeasureCommand( - boost::shared_ptr<AngleMeasureTool> measureTool, - MessageBroker& broker, - boost::weak_ptr<ViewportController> controllerW); - - /** This method sets center*/ - void SetCenter(ScenePoint2D scenePos); + protected: - /** This method sets end of side 1*/ - void SetSide1End(ScenePoint2D scenePos); - - /** This method sets end of side 2*/ - void SetSide2End(ScenePoint2D scenePos); - - private: - virtual boost::shared_ptr<MeasureTool> GetMeasureTool() ORTHANC_OVERRIDE - { - return measureTool_; - } - boost::shared_ptr<AngleMeasureTool> measureTool_; + /** This memento is updated by the subclasses upon modifications */ + boost::shared_ptr<MeasureToolMemento> mementoModified_; }; - }