comparison Framework/Scene2DViewport/MeasureCommands.h @ 880:9953f16c304d am-dev

Merge
author Alain Mazy <alain@mazy.be>
date Fri, 05 Jul 2019 15:33:02 +0200
parents c71ef52602a0
children ac88989817e3
comparison
equal deleted inserted replaced
879:12b591d5d63c 880:9953f16c304d
40 { 40 {
41 41
42 } 42 }
43 virtual void Undo() = 0; 43 virtual void Undo() = 0;
44 virtual void Redo() = 0; 44 virtual void Redo() = 0;
45
46 virtual ~TrackerCommand() {};
45 47
46 protected: 48 protected:
47 boost::shared_ptr<ViewportController> GetController(); 49 boost::shared_ptr<ViewportController> GetController();
48 boost::weak_ptr<ViewportController> controllerW_; 50 boost::weak_ptr<ViewportController> controllerW_;
49 }; 51 };
50 52
51 class CreateMeasureCommand : public TrackerCommand 53 class CreateMeasureCommand : public TrackerCommand
52 { 54 {
53 public: 55 public:
54 CreateMeasureCommand(boost::weak_ptr<ViewportController> controllerW); 56 CreateMeasureCommand(boost::weak_ptr<ViewportController> controllerW);
55 ~CreateMeasureCommand(); 57 virtual ~CreateMeasureCommand();
56 virtual void Undo() ORTHANC_OVERRIDE; 58 virtual void Undo() ORTHANC_OVERRIDE;
57 virtual void Redo() ORTHANC_OVERRIDE; 59 virtual void Redo() ORTHANC_OVERRIDE;
58 private: 60 private:
59 /** Must be implemented by the subclasses that create the actual tool */ 61 /** Must be implemented by the subclasses that create the actual tool */
60 virtual boost::shared_ptr<MeasureTool> GetMeasureTool() = 0; 62 virtual boost::shared_ptr<MeasureTool> GetMeasureTool() = 0;
61 }; 63 };
62 64
65 class EditMeasureCommand : public TrackerCommand
66 {
67 public:
68 EditMeasureCommand(boost::shared_ptr<MeasureTool> measureTool, boost::weak_ptr<ViewportController> controllerW);
69 virtual ~EditMeasureCommand();
70 virtual void Undo() ORTHANC_OVERRIDE;
71 virtual void Redo() ORTHANC_OVERRIDE;
72
73 /** This memento is the original object state */
74 boost::shared_ptr<MeasureToolMemento> mementoOriginal_;
75
76 private:
77 /** Must be implemented by the subclasses that edit the actual tool */
78 virtual boost::shared_ptr<MeasureTool> GetMeasureTool() = 0;
79
80 protected:
81
82 /** This memento is updated by the subclasses upon modifications */
83 boost::shared_ptr<MeasureToolMemento> mementoModified_;
84 };
85
63 class CreateLineMeasureCommand : public CreateMeasureCommand 86 class CreateLineMeasureCommand : public CreateMeasureCommand
64 { 87 {
65 public: 88 public:
66 CreateLineMeasureCommand( 89 CreateLineMeasureCommand(
67 MessageBroker& broker, 90 MessageBroker& broker,
68 boost::weak_ptr<ViewportController> controllerW, 91 boost::weak_ptr<ViewportController> controllerW,
69 ScenePoint2D point); 92 ScenePoint2D point);
70 93
71 // the starting position is set in the ctor 94 // the starting position is set in the ctor
95 void SetEnd(ScenePoint2D scenePos);
96
97 private:
98 virtual boost::shared_ptr<MeasureTool> GetMeasureTool() ORTHANC_OVERRIDE
99 {
100 return measureTool_;
101 }
102 boost::shared_ptr<LineMeasureTool> measureTool_;
103 };
104
105
106 class EditLineMeasureCommand : public EditMeasureCommand
107 {
108 public:
109 EditLineMeasureCommand(
110 boost::shared_ptr<LineMeasureTool> measureTool,
111 MessageBroker& broker,
112 boost::weak_ptr<ViewportController> controllerW);
113
114 void SetStart(ScenePoint2D scenePos);
72 void SetEnd(ScenePoint2D scenePos); 115 void SetEnd(ScenePoint2D scenePos);
73 116
74 private: 117 private:
75 virtual boost::shared_ptr<MeasureTool> GetMeasureTool() ORTHANC_OVERRIDE 118 virtual boost::shared_ptr<MeasureTool> GetMeasureTool() ORTHANC_OVERRIDE
76 { 119 {
101 return measureTool_; 144 return measureTool_;
102 } 145 }
103 boost::shared_ptr<AngleMeasureTool> measureTool_; 146 boost::shared_ptr<AngleMeasureTool> measureTool_;
104 }; 147 };
105 148
149 class EditAngleMeasureCommand : public EditMeasureCommand
150 {
151 public:
152 /** Ctor sets end of side 1*/
153 EditAngleMeasureCommand(
154 boost::shared_ptr<AngleMeasureTool> measureTool,
155 MessageBroker& broker,
156 boost::weak_ptr<ViewportController> controllerW);
157
158 /** This method sets center*/
159 void SetCenter(ScenePoint2D scenePos);
160
161 /** This method sets end of side 1*/
162 void SetSide1End(ScenePoint2D scenePos);
163
164 /** This method sets end of side 2*/
165 void SetSide2End(ScenePoint2D scenePos);
166
167 private:
168 virtual boost::shared_ptr<MeasureTool> GetMeasureTool() ORTHANC_OVERRIDE
169 {
170 return measureTool_;
171 }
172 boost::shared_ptr<AngleMeasureTool> measureTool_;
173 };
174
106 } 175 }
107 176