comparison Framework/Scene2DViewport/MeasureTools.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
19 **/ 19 **/
20 20
21 #pragma once 21 #pragma once
22 22
23 #include <Framework/Scene2DViewport/PointerTypes.h> 23 #include <Framework/Scene2DViewport/PointerTypes.h>
24 #include <Framework/Scene2DViewport/ViewportController.h>
24 25
25 #include <Framework/Scene2D/Scene2D.h> 26 #include <Framework/Scene2D/Scene2D.h>
26 #include <Framework/Scene2D/ScenePoint2D.h> 27 #include <Framework/Scene2D/ScenePoint2D.h>
27 #include <Framework/Scene2D/PolylineSceneLayer.h> 28 #include <Framework/Scene2D/PolylineSceneLayer.h>
28 #include <Framework/Scene2D/TextSceneLayer.h> 29 #include <Framework/Scene2D/TextSceneLayer.h>
55 56
56 /** 57 /**
57 This method is called when the scene transform changes. It allows to 58 This method is called when the scene transform changes. It allows to
58 recompute the visual elements whose content depend upon the scene transform 59 recompute the visual elements whose content depend upon the scene transform
59 */ 60 */
60 void OnSceneTransformChanged(const Scene2D::SceneTransformChanged& message); 61 void OnSceneTransformChanged(
62 const ViewportController::SceneTransformChanged& message);
61 63
62 protected: 64 protected:
63 MeasureTool(MessageBroker& broker, Scene2DWPtr sceneW); 65 MeasureTool(MessageBroker& broker, ViewportControllerWPtr controllerW);
64 66
65 /** 67 /**
66 This is the meat of the tool: this method must [create (if needed) and] 68 This is the meat of the tool: this method must [create (if needed) and]
67 update the layers and their data according to the measure tool kind and 69 update the layers and their data according to the measure tool kind and
68 current state. This is repeatedly called during user interaction 70 current state. This is repeatedly called during user interaction
69 */ 71 */
70 virtual void RefreshScene() = 0; 72 virtual void RefreshScene() = 0;
71 73
74 ViewportControllerPtr GetController();
72 Scene2DPtr GetScene(); 75 Scene2DPtr GetScene();
73 76
74 /** 77 /**
75 enabled_ is not accessible by subclasses because there is a state machine 78 enabled_ is not accessible by subclasses because there is a state machine
76 that we do not wanna mess with 79 that we do not wanna mess with
77 */ 80 */
78 bool IsEnabled() const; 81 bool IsEnabled() const;
79 82
80 private: 83 private:
81 Scene2DWPtr scene_; 84 ViewportControllerWPtr controllerW_;
82 bool enabled_; 85 bool enabled_;
83 }; 86 };
84 } 87 }
85 88
86 89