comparison Framework/Scene2DViewport/ViewportController.h @ 891:0aff28f15ea2

new abstraction: IViewport
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 10 Jul 2019 18:18:42 +0200
parents a29c13497557
children 0c5201499af8
comparison
equal deleted inserted replaced
890:77c96ba899f9 891:0aff28f15ea2
20 20
21 #pragma once 21 #pragma once
22 22
23 #include "PredeclaredTypes.h" 23 #include "PredeclaredTypes.h"
24 24
25 #include "../Scene2D/Scene2D.h" 25 #include "../Viewport/IViewport.h"
26 #include "../Scene2D/PointerEvent.h" 26 #include "../Scene2D/PointerEvent.h"
27 #include "../Scene2DViewport/IFlexiblePointerTracker.h" 27 #include "../Scene2DViewport/IFlexiblePointerTracker.h"
28 28
29 #include <stack> 29 #include <stack>
30 30
78 { 78 {
79 public: 79 public:
80 ORTHANC_STONE_DEFINE_ORIGIN_MESSAGE(__FILE__, __LINE__, \ 80 ORTHANC_STONE_DEFINE_ORIGIN_MESSAGE(__FILE__, __LINE__, \
81 SceneTransformChanged, ViewportController); 81 SceneTransformChanged, ViewportController);
82 82
83 ViewportController(boost::weak_ptr<UndoStack> undoStackW, MessageBroker& broker); 83 ViewportController(boost::weak_ptr<UndoStack> undoStackW,
84 84 MessageBroker& broker,
85 boost::shared_ptr<const Scene2D> GetScene() const; 85 IViewport& viewport);
86 boost::shared_ptr<Scene2D> GetScene();
87 86
88 /** 87 /**
89 This method is called by the GUI system and should update/delete the 88 This method is called by the GUI system and should update/delete the
90 current tracker 89 current tracker
91 */ 90 */
168 bool CanUndo() const; 167 bool CanUndo() const;
169 168
170 /** forwarded to the UndoStack */ 169 /** forwarded to the UndoStack */
171 bool CanRedo() const; 170 bool CanRedo() const;
172 171
172 IViewport& GetViewport()
173 {
174 return viewport_;
175 }
176
177 Scene2D& GetScene()
178 {
179 return viewport_.GetScene();
180 }
181
182 const Scene2D& GetScene() const
183 {
184 return scene_;
185 }
173 186
174 private: 187 private:
175 double GetCanvasToSceneFactor() const; 188 double GetCanvasToSceneFactor() const;
176 189
177 boost::weak_ptr<UndoStack> undoStackW_; 190 boost::weak_ptr<UndoStack> undoStackW_;
178 191
179 boost::shared_ptr<UndoStack> GetUndoStack(); 192 boost::shared_ptr<UndoStack> GetUndoStack();
180 boost::shared_ptr<const UndoStack> GetUndoStack() const; 193 boost::shared_ptr<const UndoStack> GetUndoStack() const;
181 194
182 std::vector<boost::shared_ptr<MeasureTool> > measureTools_; 195 std::vector<boost::shared_ptr<MeasureTool> > measureTools_;
183 boost::shared_ptr<Scene2D> scene_;
184 boost::shared_ptr<IFlexiblePointerTracker> tracker_; 196 boost::shared_ptr<IFlexiblePointerTracker> tracker_;
185 197
186 // this is cached 198 // this is cached
187 mutable double canvasToSceneFactor_; 199 mutable double canvasToSceneFactor_;
200
201
202 // Refactoring on 2019-07-10: Removing shared_ptr from scene
203 IViewport& viewport_;
204 const Scene2D& scene_; // As long as the viewport exists, its associated scene too
188 }; 205 };
189 } 206 }