Mercurial > hg > orthanc-stone
comparison Samples/Sdl/TrackerSampleApp.h @ 656:002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
might also be needed on macos and GNU/Linux ?) + fixed text info overlay pos
for angle measure (this requires the app to be aware of the compositor)
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Tue, 14 May 2019 16:54:13 +0200 |
parents | 462a5074f914 |
children | cb3b76d16234 |
comparison
equal
deleted
inserted
replaced
655:1e26bb5f2a02 | 656:002d9562c8f5 |
---|---|
46 GuiTool_LAST | 46 GuiTool_LAST |
47 }; | 47 }; |
48 | 48 |
49 const char* MeasureToolToString(size_t i); | 49 const char* MeasureToolToString(size_t i); |
50 | 50 |
51 static const unsigned int FONT_SIZE = 32; | 51 static const unsigned int FONT_SIZE_0 = 32; |
52 static const unsigned int FONT_SIZE_1 = 24; | |
52 | 53 |
53 class Scene2D; | 54 class Scene2D; |
54 | 55 |
55 class TrackerSampleApp : public IObserver | 56 class TrackerSampleApp : public IObserver |
56 { | 57 { |
59 TrackerSampleApp(MessageBroker& broker) | 60 TrackerSampleApp(MessageBroker& broker) |
60 : IObserver(broker) | 61 : IObserver(broker) |
61 , currentTool_(GuiTool_Rotate) | 62 , currentTool_(GuiTool_Rotate) |
62 , scene_(broker) | 63 , scene_(broker) |
63 { | 64 { |
65 scene_.RegisterObserverCallback( | |
66 new Callable<TrackerSampleApp, Scene2D::SceneTransformChanged> | |
67 (*this, &TrackerSampleApp::OnSceneTransformChanged)); | |
68 | |
64 TEXTURE_2x2_1_ZINDEX = 1; | 69 TEXTURE_2x2_1_ZINDEX = 1; |
65 TEXTURE_1x1_ZINDEX = 2; | 70 TEXTURE_1x1_ZINDEX = 2; |
66 TEXTURE_2x2_2_ZINDEX = 3; | 71 TEXTURE_2x2_2_ZINDEX = 3; |
67 LINESET_1_ZINDEX = 4; | 72 LINESET_1_ZINDEX = 4; |
68 LINESET_2_ZINDEX = 5; | 73 LINESET_2_ZINDEX = 5; |
69 INFOTEXT_LAYER_ZINDEX = 6; | 74 FLOATING_INFOTEXT_LAYER_ZINDEX = 6; |
75 FIXED_INFOTEXT_LAYER_ZINDEX = 7; | |
70 } | 76 } |
71 void PrepareScene(); | 77 void PrepareScene(); |
78 void Run(); | |
72 | 79 |
73 void DisableTracker(); | 80 void DisableTracker(); |
74 | 81 |
75 Scene2D& GetScene(); | 82 Scene2D& GetScene(); |
76 | 83 |
77 void HandleApplicationEvent( | 84 void HandleApplicationEvent(const SDL_Event& event); |
78 const OpenGLCompositor& compositor, | 85 |
79 const SDL_Event& event); | 86 /** |
87 This method is called when the scene transform changes. It allows to | |
88 recompute the visual elements whose content depend upon the scene transform | |
89 */ | |
90 void OnSceneTransformChanged(const Scene2D::SceneTransformChanged& message); | |
80 | 91 |
81 private: | 92 private: |
82 void SelectNextTool(); | 93 void SelectNextTool(); |
83 | 94 |
84 | 95 |
85 FlexiblePointerTrackerPtr TrackerHitTest(const PointerEvent& e); | 96 FlexiblePointerTrackerPtr TrackerHitTest(const PointerEvent& e); |
86 | 97 |
87 FlexiblePointerTrackerPtr CreateSuitableTracker( | 98 FlexiblePointerTrackerPtr CreateSuitableTracker( |
88 const SDL_Event& event, | 99 const SDL_Event& event, |
89 const PointerEvent& e, | 100 const PointerEvent& e); |
90 const OpenGLCompositor& compositor); | |
91 | 101 |
92 void TakeScreenshot( | 102 void TakeScreenshot( |
93 const std::string& target, | 103 const std::string& target, |
94 unsigned int canvasWidth, | 104 unsigned int canvasWidth, |
95 unsigned int canvasHeight); | 105 unsigned int canvasHeight); |
100 void Commit(TrackerCommandPtr cmd); | 110 void Commit(TrackerCommandPtr cmd); |
101 void Undo(); | 111 void Undo(); |
102 void Redo(); | 112 void Redo(); |
103 | 113 |
104 private: | 114 private: |
105 void DisplayInfoText(const PointerEvent& e); | 115 void DisplayFloatingCtrlInfoText(const PointerEvent& e); |
116 void DisplayInfoText(); | |
106 void HideInfoText(); | 117 void HideInfoText(); |
107 | 118 |
108 private: | 119 private: |
120 std::auto_ptr<OpenGLCompositor> compositor_; | |
109 /** | 121 /** |
110 WARNING: the measuring tools do store a reference to the scene, and it | 122 WARNING: the measuring tools do store a reference to the scene, and it |
111 paramount that the scene gets destroyed AFTER the measurement tools. | 123 paramount that the scene gets destroyed AFTER the measurement tools. |
112 */ | 124 */ |
113 Scene2D scene_; | 125 Scene2D scene_; |
117 | 129 |
118 // we store the measure tools here so that they don't get deleted | 130 // we store the measure tools here so that they don't get deleted |
119 std::vector<MeasureToolPtr> measureTools_; | 131 std::vector<MeasureToolPtr> measureTools_; |
120 | 132 |
121 //static const int LAYER_POSITION = 150; | 133 //static const int LAYER_POSITION = 150; |
122 #if 0 | 134 |
123 int TEXTURE_2x2_1_ZINDEX = 12; | 135 |
124 int TEXTURE_1x1_ZINDEX = 13; | |
125 int TEXTURE_2x2_2_ZINDEX = 14; | |
126 int LINESET_1_ZINDEX = 50; | |
127 int LINESET_2_ZINDEX = 100; | |
128 int INFOTEXT_LAYER_ZINDEX = 150; | |
129 #else | |
130 int TEXTURE_2x2_1_ZINDEX; | 136 int TEXTURE_2x2_1_ZINDEX; |
131 int TEXTURE_1x1_ZINDEX; | 137 int TEXTURE_1x1_ZINDEX; |
132 int TEXTURE_2x2_2_ZINDEX; | 138 int TEXTURE_2x2_2_ZINDEX; |
133 int LINESET_1_ZINDEX; | 139 int LINESET_1_ZINDEX; |
134 int LINESET_2_ZINDEX; | 140 int LINESET_2_ZINDEX; |
135 int INFOTEXT_LAYER_ZINDEX; | 141 int FLOATING_INFOTEXT_LAYER_ZINDEX; |
136 #endif | 142 int FIXED_INFOTEXT_LAYER_ZINDEX; |
143 | |
137 GuiTool currentTool_; | 144 GuiTool currentTool_; |
138 }; | 145 }; |
139 | 146 |
140 } | 147 } |