Mercurial > hg > orthanc-stone
annotate Samples/Sdl/TrackerSample.cpp @ 805:6a75f1c03c4e
merge
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 28 May 2019 15:59:06 +0200 |
parents | 07adcffba38c |
children | e42b491f1fb2 |
rev | line source |
---|---|
632
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
1 /** |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
2 * Stone of Orthanc |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
5 * Copyright (C) 2017-2019 Osimis S.A., Belgium |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
6 * |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
7 * This program is free software: you can redistribute it and/or |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
8 * modify it under the terms of the GNU Affero General Public License |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
9 * as published by the Free Software Foundation, either version 3 of |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
10 * the License, or (at your option) any later version. |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
11 * |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
12 * This program is distributed in the hope that it will be useful, but |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
13 * WITHOUT ANY WARRANTY; without even the implied warranty of |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
15 * Affero General Public License for more details. |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
16 * |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
17 * You should have received a copy of the GNU Affero General Public License |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
19 **/ |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
20 |
644 | 21 #include "TrackerSampleApp.h" |
632
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
22 |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
23 // From Stone |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
24 #include "../../Applications/Sdl/SdlOpenGLWindow.h" |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
25 #include "../../Framework/Scene2D/CairoCompositor.h" |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
26 #include "../../Framework/Scene2D/ColorTextureSceneLayer.h" |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
27 #include "../../Framework/Scene2D/OpenGLCompositor.h" |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
28 #include "../../Framework/StoneInitialization.h" |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
29 |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
30 #include <Core/Logging.h> |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
31 #include <Core/OrthancException.h> |
644 | 32 |
632
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
33 |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
34 #include <boost/shared_ptr.hpp> |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
35 #include <boost/weak_ptr.hpp> |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
36 |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
37 #include <SDL.h> |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
38 #include <stdio.h> |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
39 |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
40 /* |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
41 TODO: |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
42 |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
43 - to decouple the trackers from the sample, we need to supply them with |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
44 the scene rather than the app |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
45 |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
46 - in order to do that, we need a GetNextFreeZIndex function (or something |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
47 along those lines) in the scene object |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
48 |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
49 */ |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
50 |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
51 |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
52 using namespace Orthanc; |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
53 using namespace OrthancStone; |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
54 |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
55 |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
56 |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
57 |
660
cb3b76d16234
Added info display map to the app + global logging function + fixed bisecting
Benjamin Golinvaux <bgo@osimis.io>
parents:
656
diff
changeset
|
58 boost::weak_ptr<TrackerSampleApp> g_app; |
632
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
59 |
660
cb3b76d16234
Added info display map to the app + global logging function + fixed bisecting
Benjamin Golinvaux <bgo@osimis.io>
parents:
656
diff
changeset
|
60 void TrackerSample_SetInfoDisplayMessage(std::string key, std::string value) |
cb3b76d16234
Added info display map to the app + global logging function + fixed bisecting
Benjamin Golinvaux <bgo@osimis.io>
parents:
656
diff
changeset
|
61 { |
cb3b76d16234
Added info display map to the app + global logging function + fixed bisecting
Benjamin Golinvaux <bgo@osimis.io>
parents:
656
diff
changeset
|
62 boost::shared_ptr<TrackerSampleApp> app = g_app.lock(); |
cb3b76d16234
Added info display map to the app + global logging function + fixed bisecting
Benjamin Golinvaux <bgo@osimis.io>
parents:
656
diff
changeset
|
63 if (app) |
cb3b76d16234
Added info display map to the app + global logging function + fixed bisecting
Benjamin Golinvaux <bgo@osimis.io>
parents:
656
diff
changeset
|
64 { |
cb3b76d16234
Added info display map to the app + global logging function + fixed bisecting
Benjamin Golinvaux <bgo@osimis.io>
parents:
656
diff
changeset
|
65 app->SetInfoDisplayMessage(key, value); |
cb3b76d16234
Added info display map to the app + global logging function + fixed bisecting
Benjamin Golinvaux <bgo@osimis.io>
parents:
656
diff
changeset
|
66 } |
cb3b76d16234
Added info display map to the app + global logging function + fixed bisecting
Benjamin Golinvaux <bgo@osimis.io>
parents:
656
diff
changeset
|
67 } |
632
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
68 |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
69 /** |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
70 * IMPORTANT: The full arguments to "main()" are needed for SDL on |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
71 * Windows. Otherwise, one gets the linking error "undefined reference |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
72 * to `SDL_main'". https://wiki.libsdl.org/FAQWindows |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
73 **/ |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
74 int main(int argc, char* argv[]) |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
75 { |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
76 StoneInitialize(); |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
77 Orthanc::Logging::EnableInfoLevel(true); |
761
07adcffba38c
truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents:
660
diff
changeset
|
78 // Orthanc::Logging::EnableTraceLevel(true); |
644 | 79 |
632
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
80 try |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
81 { |
654
462a5074f914
Turned the scene into an observable to be able to dynamically react to
Benjamin Golinvaux <bgo@osimis.io>
parents:
645
diff
changeset
|
82 MessageBroker broker; |
660
cb3b76d16234
Added info display map to the app + global logging function + fixed bisecting
Benjamin Golinvaux <bgo@osimis.io>
parents:
656
diff
changeset
|
83 boost::shared_ptr<TrackerSampleApp> app(new TrackerSampleApp(broker)); |
cb3b76d16234
Added info display map to the app + global logging function + fixed bisecting
Benjamin Golinvaux <bgo@osimis.io>
parents:
656
diff
changeset
|
84 g_app = app; |
cb3b76d16234
Added info display map to the app + global logging function + fixed bisecting
Benjamin Golinvaux <bgo@osimis.io>
parents:
656
diff
changeset
|
85 app->PrepareScene(); |
cb3b76d16234
Added info display map to the app + global logging function + fixed bisecting
Benjamin Golinvaux <bgo@osimis.io>
parents:
656
diff
changeset
|
86 app->Run(); |
632
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
87 } |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
88 catch (Orthanc::OrthancException& e) |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
89 { |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
90 LOG(ERROR) << "EXCEPTION: " << e.What(); |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
91 } |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
92 |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
93 StoneFinalize(); |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
94 |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
95 return 0; |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
96 } |
660
cb3b76d16234
Added info display map to the app + global logging function + fixed bisecting
Benjamin Golinvaux <bgo@osimis.io>
parents:
656
diff
changeset
|
97 |
cb3b76d16234
Added info display map to the app + global logging function + fixed bisecting
Benjamin Golinvaux <bgo@osimis.io>
parents:
656
diff
changeset
|
98 |