Mercurial > hg > orthanc-stone
annotate Deprecated/Samples/Sdl/TrackerSampleApp.h @ 1463:182bf3106ee2
dos2unix
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 12 Jun 2020 07:19:31 +0200 |
parents | 828a9b4ee1b7 |
children |
rev | line source |
---|---|
644 | 1 /** |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
1270
2d8ab34c8c91
upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
938
diff
changeset
|
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium |
644 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
8 * modify it under the terms of the GNU Affero General Public License | |
9 * as published by the Free Software Foundation, either version 3 of | |
10 * the License, or (at your option) any later version. | |
11 * | |
12 * This program is distributed in the hope that it will be useful, but | |
13 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 * Affero General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU Affero General Public License | |
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 **/ | |
20 | |
698
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
660
diff
changeset
|
21 |
1458
828a9b4ee1b7
added missing copyright
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1402
diff
changeset
|
22 #pragma once |
828a9b4ee1b7
added missing copyright
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1402
diff
changeset
|
23 |
737 | 24 #include "../../Framework/Messages/IObserver.h" |
25 #include "../../Framework/Scene2D/OpenGLCompositor.h" | |
26 #include "../../Framework/Scene2DViewport/IFlexiblePointerTracker.h" | |
774
66ac7a2d1e3a
A few renames and cleanups + moved GUI constants to controller + start work on
Benjamin Golinvaux <bgo@osimis.io>
parents:
761
diff
changeset
|
27 #include "../../Framework/Scene2DViewport/MeasureTool.h" |
818
e42b491f1fb2
Removed typedefs to shared_ptr by making them explicit. Removed using namespace
Benjamin Golinvaux <bgo@osimis.io>
parents:
774
diff
changeset
|
28 #include "../../Framework/Scene2DViewport/PredeclaredTypes.h" |
737 | 29 #include "../../Framework/Scene2DViewport/ViewportController.h" |
893
0c5201499af8
Fixes to TrackerSampleApp following IViewport refactoring (FusionMprSdl not working yet)
Benjamin Golinvaux <bgo@osimis.io>
parents:
891
diff
changeset
|
30 #include "../../Framework/Viewport/SdlViewport.h" |
644 | 31 |
32 #include <SDL.h> | |
33 | |
34 #include <boost/make_shared.hpp> | |
35 #include <boost/shared_ptr.hpp> | |
660
cb3b76d16234
Added info display map to the app + global logging function + fixed bisecting
Benjamin Golinvaux <bgo@osimis.io>
parents:
656
diff
changeset
|
36 #include <boost/enable_shared_from_this.hpp> |
644 | 37 |
38 namespace OrthancStone | |
39 { | |
40 enum GuiTool | |
41 { | |
42 GuiTool_Rotate = 0, | |
43 GuiTool_Pan, | |
44 GuiTool_Zoom, | |
45 GuiTool_LineMeasure, | |
46 GuiTool_CircleMeasure, | |
47 GuiTool_AngleMeasure, | |
48 GuiTool_EllipseMeasure, | |
49 GuiTool_LAST | |
50 }; | |
51 | |
52 const char* MeasureToolToString(size_t i); | |
53 | |
656
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
54 static const unsigned int FONT_SIZE_0 = 32; |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
55 static const unsigned int FONT_SIZE_1 = 24; |
644 | 56 |
57 class Scene2D; | |
858
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
818
diff
changeset
|
58 class UndoStack; |
644 | 59 |
654
462a5074f914
Turned the scene into an observable to be able to dynamically react to
Benjamin Golinvaux <bgo@osimis.io>
parents:
644
diff
changeset
|
60 class TrackerSampleApp : public IObserver |
660
cb3b76d16234
Added info display map to the app + global logging function + fixed bisecting
Benjamin Golinvaux <bgo@osimis.io>
parents:
656
diff
changeset
|
61 , public boost::enable_shared_from_this<TrackerSampleApp> |
644 | 62 { |
63 public: | |
64 // 12 because. | |
660
cb3b76d16234
Added info display map to the app + global logging function + fixed bisecting
Benjamin Golinvaux <bgo@osimis.io>
parents:
656
diff
changeset
|
65 TrackerSampleApp(MessageBroker& broker); |
644 | 66 void PrepareScene(); |
656
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
67 void Run(); |
660
cb3b76d16234
Added info display map to the app + global logging function + fixed bisecting
Benjamin Golinvaux <bgo@osimis.io>
parents:
656
diff
changeset
|
68 void SetInfoDisplayMessage(std::string key, std::string value); |
644 | 69 void DisableTracker(); |
70 | |
656
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
71 void HandleApplicationEvent(const SDL_Event& event); |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
72 |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
73 /** |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
74 This method is called when the scene transform changes. It allows to |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
75 recompute the visual elements whose content depend upon the scene transform |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
76 */ |
700
059e1fd05fd6
Introduced the ViewportController that sits between the application and the
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
77 void OnSceneTransformChanged( |
059e1fd05fd6
Introduced the ViewportController that sits between the application and the
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
78 const ViewportController::SceneTransformChanged& message); |
644 | 79 |
80 private: | |
81 void SelectNextTool(); | |
761
07adcffba38c
truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents:
737
diff
changeset
|
82 void CreateRandomMeasureTool(); |
644 | 83 |
893
0c5201499af8
Fixes to TrackerSampleApp following IViewport refactoring (FusionMprSdl not working yet)
Benjamin Golinvaux <bgo@osimis.io>
parents:
891
diff
changeset
|
84 |
0c5201499af8
Fixes to TrackerSampleApp following IViewport refactoring (FusionMprSdl not working yet)
Benjamin Golinvaux <bgo@osimis.io>
parents:
891
diff
changeset
|
85 /** |
0c5201499af8
Fixes to TrackerSampleApp following IViewport refactoring (FusionMprSdl not working yet)
Benjamin Golinvaux <bgo@osimis.io>
parents:
891
diff
changeset
|
86 In the case of this app, the viewport is an SDL viewport and it has |
0c5201499af8
Fixes to TrackerSampleApp following IViewport refactoring (FusionMprSdl not working yet)
Benjamin Golinvaux <bgo@osimis.io>
parents:
891
diff
changeset
|
87 a OpenGLCompositor& GetCompositor() method |
0c5201499af8
Fixes to TrackerSampleApp following IViewport refactoring (FusionMprSdl not working yet)
Benjamin Golinvaux <bgo@osimis.io>
parents:
891
diff
changeset
|
88 */ |
938
eaaa9b574e05
Fixed the Stone samples wrt the recent API changes (SdlOpenGLViewport, ICompositor...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
916
diff
changeset
|
89 ICompositor& GetCompositor(); |
893
0c5201499af8
Fixes to TrackerSampleApp following IViewport refactoring (FusionMprSdl not working yet)
Benjamin Golinvaux <bgo@osimis.io>
parents:
891
diff
changeset
|
90 |
0c5201499af8
Fixes to TrackerSampleApp following IViewport refactoring (FusionMprSdl not working yet)
Benjamin Golinvaux <bgo@osimis.io>
parents:
891
diff
changeset
|
91 /** |
0c5201499af8
Fixes to TrackerSampleApp following IViewport refactoring (FusionMprSdl not working yet)
Benjamin Golinvaux <bgo@osimis.io>
parents:
891
diff
changeset
|
92 See the other overload |
0c5201499af8
Fixes to TrackerSampleApp following IViewport refactoring (FusionMprSdl not working yet)
Benjamin Golinvaux <bgo@osimis.io>
parents:
891
diff
changeset
|
93 */ |
938
eaaa9b574e05
Fixed the Stone samples wrt the recent API changes (SdlOpenGLViewport, ICompositor...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
916
diff
changeset
|
94 const ICompositor& GetCompositor() const; |
893
0c5201499af8
Fixes to TrackerSampleApp following IViewport refactoring (FusionMprSdl not working yet)
Benjamin Golinvaux <bgo@osimis.io>
parents:
891
diff
changeset
|
95 |
761
07adcffba38c
truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents:
737
diff
changeset
|
96 /** |
07adcffba38c
truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents:
737
diff
changeset
|
97 This returns a random point in the canvas part of the scene, but in |
07adcffba38c
truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents:
737
diff
changeset
|
98 scene coordinates |
07adcffba38c
truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents:
737
diff
changeset
|
99 */ |
07adcffba38c
truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents:
737
diff
changeset
|
100 ScenePoint2D GetRandomPointInScene() const; |
644 | 101 |
818
e42b491f1fb2
Removed typedefs to shared_ptr by making them explicit. Removed using namespace
Benjamin Golinvaux <bgo@osimis.io>
parents:
774
diff
changeset
|
102 boost::shared_ptr<IFlexiblePointerTracker> TrackerHitTest(const PointerEvent& e); |
644 | 103 |
818
e42b491f1fb2
Removed typedefs to shared_ptr by making them explicit. Removed using namespace
Benjamin Golinvaux <bgo@osimis.io>
parents:
774
diff
changeset
|
104 boost::shared_ptr<IFlexiblePointerTracker> CreateSuitableTracker( |
644 | 105 const SDL_Event& event, |
656
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
106 const PointerEvent& e); |
644 | 107 |
108 void TakeScreenshot( | |
109 const std::string& target, | |
110 unsigned int canvasWidth, | |
111 unsigned int canvasHeight); | |
112 | |
113 /** | |
114 This adds the command at the top of the undo stack | |
115 */ | |
818
e42b491f1fb2
Removed typedefs to shared_ptr by making them explicit. Removed using namespace
Benjamin Golinvaux <bgo@osimis.io>
parents:
774
diff
changeset
|
116 void Commit(boost::shared_ptr<TrackerCommand> cmd); |
644 | 117 void Undo(); |
118 void Redo(); | |
119 | |
120 private: | |
656
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
121 void DisplayFloatingCtrlInfoText(const PointerEvent& e); |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
122 void DisplayInfoText(); |
644 | 123 void HideInfoText(); |
124 | |
125 private: | |
126 /** | |
127 WARNING: the measuring tools do store a reference to the scene, and it | |
128 paramount that the scene gets destroyed AFTER the measurement tools. | |
129 */ | |
818
e42b491f1fb2
Removed typedefs to shared_ptr by making them explicit. Removed using namespace
Benjamin Golinvaux <bgo@osimis.io>
parents:
774
diff
changeset
|
130 boost::shared_ptr<ViewportController> controller_; |
644 | 131 |
660
cb3b76d16234
Added info display map to the app + global logging function + fixed bisecting
Benjamin Golinvaux <bgo@osimis.io>
parents:
656
diff
changeset
|
132 std::map<std::string, std::string> infoTextMap_; |
818
e42b491f1fb2
Removed typedefs to shared_ptr by making them explicit. Removed using namespace
Benjamin Golinvaux <bgo@osimis.io>
parents:
774
diff
changeset
|
133 boost::shared_ptr<IFlexiblePointerTracker> activeTracker_; |
644 | 134 |
135 //static const int LAYER_POSITION = 150; | |
656
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
136 |
644 | 137 int TEXTURE_2x2_1_ZINDEX; |
138 int TEXTURE_1x1_ZINDEX; | |
139 int TEXTURE_2x2_2_ZINDEX; | |
140 int LINESET_1_ZINDEX; | |
141 int LINESET_2_ZINDEX; | |
656
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
142 int FLOATING_INFOTEXT_LAYER_ZINDEX; |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
143 int FIXED_INFOTEXT_LAYER_ZINDEX; |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
144 |
644 | 145 GuiTool currentTool_; |
858
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
818
diff
changeset
|
146 boost::shared_ptr<UndoStack> undoStack_; |
916
a911f5bb48da
MultiPlatform Basic Scene sample (so far: SDL + Qt)
Alain Mazy <alain@mazy.be>
parents:
893
diff
changeset
|
147 SdlOpenGLViewport viewport_; |
644 | 148 }; |
149 | |
150 } |