comparison Framework/Scene2DViewport/MeasureCommands.h @ 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 8b6adfb62a2f
children 28b9e3a54200
comparison
equal deleted inserted replaced
699:5c551f078c18 700:059e1fd05fd6
32 namespace OrthancStone 32 namespace OrthancStone
33 { 33 {
34 class TrackerCommand : public boost::noncopyable 34 class TrackerCommand : public boost::noncopyable
35 { 35 {
36 public: 36 public:
37 TrackerCommand(Scene2DWPtr sceneW) : scene_(sceneW) 37 TrackerCommand(ViewportControllerWPtr controllerW)
38 : controllerW_(controllerW)
38 { 39 {
39 40
40 } 41 }
41 virtual void Undo() = 0; 42 virtual void Undo() = 0;
42 virtual void Redo() = 0; 43 virtual void Redo() = 0;
43 Scene2DPtr GetScene()
44 {
45 return scene_.lock();
46 }
47 44
48 protected: 45 protected:
49 Scene2DWPtr scene_; 46 ViewportControllerWPtr controllerW_;
50 }; 47 };
51 48
52 class CreateMeasureCommand : public TrackerCommand 49 class CreateMeasureCommand : public TrackerCommand
53 { 50 {
54 public: 51 public:
55 CreateMeasureCommand(Scene2DWPtr sceneW, MeasureToolList& measureTools); 52 CreateMeasureCommand(
53 ViewportControllerWPtr controllerW, MeasureToolList& measureTools);
56 ~CreateMeasureCommand(); 54 ~CreateMeasureCommand();
57 virtual void Undo() ORTHANC_OVERRIDE; 55 virtual void Undo() ORTHANC_OVERRIDE;
58 virtual void Redo() ORTHANC_OVERRIDE; 56 virtual void Redo() ORTHANC_OVERRIDE;
59 protected: 57 protected:
60 MeasureToolList& measureTools_; 58 MeasureToolList& measureTools_;
61 private: 59 private:
62 /** Must be implemented by the subclasses that create the actual tool */ 60 /** Must be implemented by the subclasses that create the actual tool */
63 virtual MeasureToolPtr GetMeasureTool() = 0; 61 virtual MeasureToolPtr GetMeasureTool() = 0;
64 }; 62 };
65 63
66
67 class CreateLineMeasureCommand : public CreateMeasureCommand 64 class CreateLineMeasureCommand : public CreateMeasureCommand
68 { 65 {
69 public: 66 public:
70 CreateLineMeasureCommand( 67 CreateLineMeasureCommand(
71 MessageBroker& broker, 68 MessageBroker& broker,
72 Scene2DWPtr scene, 69 ViewportControllerWPtr controllerW,
73 MeasureToolList& measureTools, 70 MeasureToolList& measureTools,
74 ScenePoint2D point); 71 ScenePoint2D point);
75 72
76 // the starting position is set in the ctor 73 // the starting position is set in the ctor
77 void SetEnd(ScenePoint2D scenePos); 74 void SetEnd(ScenePoint2D scenePos);
78 75
79 private: 76 private:
88 class CreateAngleMeasureCommand : public CreateMeasureCommand 85 class CreateAngleMeasureCommand : public CreateMeasureCommand
89 { 86 {
90 public: 87 public:
91 /** Ctor sets end of side 1*/ 88 /** Ctor sets end of side 1*/
92 CreateAngleMeasureCommand( 89 CreateAngleMeasureCommand(
93 MessageBroker& broker, 90 MessageBroker& broker,
94 Scene2DWPtr scene, 91 ViewportControllerWPtr controllerW,
95 MeasureToolList& measureTools, 92 MeasureToolList& measureTools,
96 ScenePoint2D point); 93 ScenePoint2D point);
97 94
98 /** This method sets center*/ 95 /** This method sets center*/
99 void SetCenter(ScenePoint2D scenePos); 96 void SetCenter(ScenePoint2D scenePos);
100 97
101 /** This method sets end of side 2*/ 98 /** This method sets end of side 2*/