comparison Framework/Scene2DViewport/ViewportController.h @ 1214:741201eab130 broker

removing pointer to viewport from ViewportController
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 04 Dec 2019 19:12:08 +0100
parents 86a8266b8888
children 9efa66d8d3f8
comparison
equal deleted inserted replaced
1213:86a8266b8888 1214:741201eab130
37 virtual ~IViewportInteractor() 37 virtual ~IViewportInteractor()
38 { 38 {
39 } 39 }
40 40
41 virtual IFlexiblePointerTracker* CreateTracker(boost::shared_ptr<ViewportController> controller, 41 virtual IFlexiblePointerTracker* CreateTracker(boost::shared_ptr<ViewportController> controller,
42 IViewport& viewport,
42 const PointerEvent& event) = 0; 43 const PointerEvent& event) = 0;
43 }; 44 };
44 45
45 46
46 // TODO - Move this to another file 47 // TODO - Move this to another file
47 class DefaultViewportInteractor : public IViewportInteractor 48 class DefaultViewportInteractor : public IViewportInteractor
48 { 49 {
49 public: 50 public:
50 virtual IFlexiblePointerTracker* CreateTracker(boost::shared_ptr<ViewportController> controller, 51 virtual IFlexiblePointerTracker* CreateTracker(boost::shared_ptr<ViewportController> controller,
52 IViewport& viewport,
51 const PointerEvent& event) ORTHANC_OVERRIDE; 53 const PointerEvent& event) ORTHANC_OVERRIDE;
52 }; 54 };
53 55
54 56
55 class UndoStack; 57 class UndoStack;
102 { 104 {
103 public: 105 public:
104 ORTHANC_STONE_DEFINE_ORIGIN_MESSAGE(__FILE__, __LINE__, \ 106 ORTHANC_STONE_DEFINE_ORIGIN_MESSAGE(__FILE__, __LINE__, \
105 SceneTransformChanged, ViewportController); 107 SceneTransformChanged, ViewportController);
106 108
107 ViewportController(boost::weak_ptr<UndoStack> undoStackW, 109 ViewportController(boost::weak_ptr<UndoStack> undoStackW);
108 boost::shared_ptr<IViewport> viewport);
109 110
110 ~ViewportController(); 111 ~ViewportController();
111 112
112 /** 113 /**
113 This method returns the list of measure tools containing the supplied point 114 This method returns the list of measure tools containing the supplied point
136 137
137 /** Forwarded to the underlying scene, and broadcasted to the observers */ 138 /** Forwarded to the underlying scene, and broadcasted to the observers */
138 void SetSceneToCanvasTransform(const AffineTransform2D& transform); 139 void SetSceneToCanvasTransform(const AffineTransform2D& transform);
139 140
140 /** Forwarded to the underlying scene, and broadcasted to the observers */ 141 /** Forwarded to the underlying scene, and broadcasted to the observers */
141 void FitContent(); 142 void FitContent(IViewport& viewport);
142 143
143 /** Adds a new measure tool */ 144 /** Adds a new measure tool */
144 void AddMeasureTool(boost::shared_ptr<MeasureTool> measureTool); 145 void AddMeasureTool(boost::shared_ptr<MeasureTool> measureTool);
145 146
146 /** Removes a measure tool or throws if it cannot be found */ 147 /** Removes a measure tool or throws if it cannot be found */
186 bool CanUndo() const; 187 bool CanUndo() const;
187 188
188 /** forwarded to the UndoStack */ 189 /** forwarded to the UndoStack */
189 bool CanRedo() const; 190 bool CanRedo() const;
190 191
191 IViewport& GetViewport() const
192 {
193 return *viewport_;
194 }
195
196 192
197 // Must be expressed in canvas coordinates 193 // Must be expressed in canvas coordinates
198 void HandleMousePress(IViewportInteractor& interactor, 194 void HandleMousePress(IViewport& viewport,
195 IViewportInteractor& interactor,
199 const PointerEvent& event); 196 const PointerEvent& event);
200 197
201 // Must be expressed in canvas coordinates 198 // Must be expressed in canvas coordinates
202 void HandleMouseMove(const PointerEvent& event); 199 void HandleMouseMove(const PointerEvent& event);
203 200
216 213
217 private: 214 private:
218 double GetCanvasToSceneFactor() const; 215 double GetCanvasToSceneFactor() const;
219 216
220 boost::weak_ptr<UndoStack> undoStackW_; // Global stack, possibly shared by all viewports 217 boost::weak_ptr<UndoStack> undoStackW_; // Global stack, possibly shared by all viewports
221 boost::shared_ptr<IViewport> viewport_;
222 std::vector<boost::shared_ptr<MeasureTool> > measureTools_; 218 std::vector<boost::shared_ptr<MeasureTool> > measureTools_;
223 boost::shared_ptr<IFlexiblePointerTracker> activeTracker_; // TODO - Can't this be a "std::auto_ptr"? 219 boost::shared_ptr<IFlexiblePointerTracker> activeTracker_; // TODO - Couldn't this be a "std::auto_ptr"?
224 220
225 Scene2D scene_; 221 Scene2D scene_;
226 222
227 // this is cached 223 // this is cached
228 double canvasToSceneFactor_; 224 double canvasToSceneFactor_;