Mercurial > hg > orthanc-stone
comparison OrthancStone/Sources/Scene2DViewport/MeasureCommands.h @ 1606:874e178f34e9
- ViewportController now has weak ptr to Viewport
- Measuring tools + related commands and all trackers now store only a weak_ptr to the Viewport and lock() on demand for usage
- LayerHolder and FixedPoint aligner store only a weak_ptr to the Viewport, too
- Fixed float/double warning in GrayscaleWindowingSceneTracker
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Wed, 28 Oct 2020 20:14:34 +0100 |
parents | 8563ea5d8ae4 |
children | 9ac2a65d4172 |
comparison
equal
deleted
inserted
replaced
1605:b3c439d96d3e | 1606:874e178f34e9 |
---|---|
27 #include "MeasureTool.h" | 27 #include "MeasureTool.h" |
28 #include "LineMeasureTool.h" | 28 #include "LineMeasureTool.h" |
29 #include "AngleMeasureTool.h" | 29 #include "AngleMeasureTool.h" |
30 | 30 |
31 #include <boost/shared_ptr.hpp> | 31 #include <boost/shared_ptr.hpp> |
32 #include <boost/weak_ptr.hpp> | |
32 #include <boost/noncopyable.hpp> | 33 #include <boost/noncopyable.hpp> |
33 | 34 |
34 namespace OrthancStone | 35 namespace OrthancStone |
35 { | 36 { |
36 class MeasureCommand : public boost::noncopyable | 37 class MeasureCommand : public boost::noncopyable |
37 { | 38 { |
38 protected: | 39 protected: |
39 boost::shared_ptr<IViewport> viewport_; | 40 boost::weak_ptr<IViewport> viewport_; |
41 | |
42 /** | |
43 This will return a scoped lock to the viewport. | |
44 If the viewport does not exist anymore, then nullptr is returned. | |
45 */ | |
46 IViewport::ILock* GetViewportLock(); | |
40 | 47 |
41 public: | 48 public: |
42 explicit MeasureCommand(boost::shared_ptr<IViewport> viewport) : | 49 explicit MeasureCommand(boost::weak_ptr<IViewport> viewport) : |
43 viewport_(viewport) | 50 viewport_(viewport) |
44 { | 51 { |
45 } | 52 } |
46 | 53 |
47 virtual ~MeasureCommand() | 54 virtual ~MeasureCommand() |
59 private: | 66 private: |
60 /** Must be implemented by the subclasses that create the actual tool */ | 67 /** Must be implemented by the subclasses that create the actual tool */ |
61 virtual boost::shared_ptr<MeasureTool> GetMeasureTool() = 0; | 68 virtual boost::shared_ptr<MeasureTool> GetMeasureTool() = 0; |
62 | 69 |
63 public: | 70 public: |
64 explicit CreateMeasureCommand(boost::shared_ptr<IViewport> viewport); | 71 explicit CreateMeasureCommand(boost::weak_ptr<IViewport> viewport); |
65 | 72 |
66 virtual ~CreateMeasureCommand(); | 73 virtual ~CreateMeasureCommand(); |
67 | 74 |
68 virtual void Undo() ORTHANC_OVERRIDE; | 75 virtual void Undo() ORTHANC_OVERRIDE; |
69 | 76 |
81 /** This memento is updated by the subclasses upon modifications */ | 88 /** This memento is updated by the subclasses upon modifications */ |
82 boost::shared_ptr<MeasureToolMemento> mementoModified_; | 89 boost::shared_ptr<MeasureToolMemento> mementoModified_; |
83 | 90 |
84 public: | 91 public: |
85 EditMeasureCommand(boost::shared_ptr<MeasureTool> measureTool, | 92 EditMeasureCommand(boost::shared_ptr<MeasureTool> measureTool, |
86 boost::shared_ptr<IViewport> viewport); | 93 boost::weak_ptr<IViewport> viewport); |
87 | 94 |
88 virtual ~EditMeasureCommand(); | 95 virtual ~EditMeasureCommand(); |
89 | 96 |
90 virtual void Undo() ORTHANC_OVERRIDE; | 97 virtual void Undo() ORTHANC_OVERRIDE; |
91 | 98 |
111 /** This memento is updated by the subclasses upon modifications */ | 118 /** This memento is updated by the subclasses upon modifications */ |
112 boost::shared_ptr<MeasureToolMemento> mementoModified_; | 119 boost::shared_ptr<MeasureToolMemento> mementoModified_; |
113 | 120 |
114 public: | 121 public: |
115 DeleteMeasureCommand(boost::shared_ptr<MeasureTool> measureTool, | 122 DeleteMeasureCommand(boost::shared_ptr<MeasureTool> measureTool, |
116 boost::shared_ptr<IViewport> viewport); | 123 boost::weak_ptr<IViewport> viewport); |
117 | 124 |
118 virtual ~DeleteMeasureCommand(); | 125 virtual ~DeleteMeasureCommand(); |
119 | 126 |
120 virtual void Undo() ORTHANC_OVERRIDE; | 127 virtual void Undo() ORTHANC_OVERRIDE; |
121 | 128 |