annotate Samples/Sdl/RtViewer/RtViewerSdl.cpp @ 1392:ffdb82850e98

Sdl run loop in /Common (might revert if need to customize) Segregation ongoing between sdl wasm Both samples ok SDL msvc v141 x64
author Benjamin Golinvaux <bgo@osimis.io>
date Tue, 28 Apr 2020 13:52:21 +0200
parents 5c83be3a6be5
children 27e0a00bd3e8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1386
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
1 /**
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
2 * Stone of Orthanc
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
4 * Department, University Hospital of Liege, Belgium
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
6 *
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
7 * This program is free software: you can redistribute it and/or
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
8 * modify it under the terms of the GNU Affero General Public License
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
10 * the License, or (at your option) any later version.
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
11 *
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
12 * This program is distributed in the hope that it will be useful, but
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
15 * Affero General Public License for more details.
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
16 *
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
17 * You should have received a copy of the GNU Affero General Public License
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
19 **/
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
20
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
21 #include "RtViewer.h"
1392
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
22 #include "../SdlHelpers.h"
1386
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
23 #include "SampleHelpers.h"
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
24
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
25 #include <Framework/StoneException.h>
1392
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
26 #include <Framework/StoneInitialization.h>
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
27
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
28 #include <Framework/OpenGL/SdlOpenGLContext.h>
1386
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
29
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
30 #include <boost/program_options.hpp>
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
31 #include <SDL.h>
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
32
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
33 #include <string>
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
34
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
35 static void GLAPIENTRY
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
36 OpenGLMessageCallback(GLenum source,
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
37 GLenum type,
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
38 GLuint id,
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
39 GLenum severity,
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
40 GLsizei length,
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
41 const GLchar* message,
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
42 const void* userParam)
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
43 {
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
44 if (severity != GL_DEBUG_SEVERITY_NOTIFICATION)
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
45 {
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
46 fprintf(stderr, "GL CALLBACK: %s type = 0x%x, severity = 0x%x, message = %s\n",
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
47 (type == GL_DEBUG_TYPE_ERROR ? "** GL ERROR **" : ""),
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
48 type, severity, message);
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
49 }
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
50 }
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
51
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
52 namespace OrthancStone
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
53 {
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
54 void RtViewerApp::ProcessOptions(int argc, char* argv[])
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
55 {
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
56 namespace po = boost::program_options;
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
57 po::options_description desc("Usage:");
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
58
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
59 desc.add_options()
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
60 ("loglevel", po::value<std::string>()->default_value("WARNING"),
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
61 "You can choose WARNING, INFO or TRACE for the logging level: Errors and warnings will always be displayed. (default: WARNING)")
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
62
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
63 ("orthanc", po::value<std::string>()->default_value("http://localhost:8042"),
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
64 "Base URL of the Orthanc instance")
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
65
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
66 ("ctseries", po::value<std::string>()->default_value("a04ecf01-79b2fc33-58239f7e-ad9db983-28e81afa"),
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
67 "Orthanc ID of the CT series to load")
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
68
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
69 ("rtdose", po::value<std::string>()->default_value("830a69ff-8e4b5ee3-b7f966c8-bccc20fb-d322dceb"),
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
70 "Orthanc ID of the RTDOSE instance to load")
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
71
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
72 ("rtstruct", po::value<std::string>()->default_value("54460695-ba3885ee-ddf61ac0-f028e31d-a6e474d9"),
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
73 "Orthanc ID of the RTSTRUCT instance to load")
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
74 ;
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
75
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
76 po::variables_map vm;
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
77 try
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
78 {
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
79 po::store(po::parse_command_line(argc, argv, desc), vm);
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
80 po::notify(vm);
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
81 }
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
82 catch (std::exception& e)
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
83 {
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
84 std::cerr << "Please check your command line options! (\"" << e.what() << "\")" << std::endl;
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
85 }
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
86
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
87 if (vm.count("loglevel") > 0)
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
88 {
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
89 std::string logLevel = vm["loglevel"].as<std::string>();
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
90 OrthancStoneHelpers::SetLogLevel(logLevel);
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
91 }
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
92
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
93 if (vm.count("orthanc") > 0)
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
94 {
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
95 // maybe check URL validity here
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
96 orthancUrl_ = vm["orthanc"].as<std::string>();
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
97 }
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
98
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
99 if (vm.count("ctseries") > 0)
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
100 {
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
101 ctSeriesId_ = vm["ctseries"].as<std::string>();
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
102 }
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
103
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
104 if (vm.count("rtdose") > 0)
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
105 {
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
106 doseInstanceId_ = vm["rtdose"].as<std::string>();
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
107 }
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
108
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
109 if (vm.count("rtstruct") > 0)
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
110 {
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
111 rtStructInstanceId_ = vm["rtstruct"].as<std::string>();
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
112 }
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
113 }
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
114
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
115 void RtViewerApp::RunSdl(int argc, char* argv[])
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
116 {
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
117 ProcessOptions(argc, argv);
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
118
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
119 {
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
120 std::unique_ptr<IViewport::ILock> lock(viewport_->Lock());
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
121 ViewportController& controller = lock->GetController();
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
122 Scene2D& scene = controller.GetScene();
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
123 ICompositor& compositor = lock->GetCompositor();
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
124
1389
5c83be3a6be5 split SDL / common + RtViewer rename + html test file
Benjamin Golinvaux <bgo@osimis.io>
parents: 1386
diff changeset
125 // False means we do NOT let a hi-DPI aware desktop managedr treat this as a legacy application that requires
5c83be3a6be5 split SDL / common + RtViewer rename + html test file
Benjamin Golinvaux <bgo@osimis.io>
parents: 1386
diff changeset
126 // scaling.
1386
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
127 controller.FitContent(compositor.GetCanvasWidth(), compositor.GetCanvasHeight());
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
128
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
129 glEnable(GL_DEBUG_OUTPUT);
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
130 glDebugMessageCallback(OpenGLMessageCallback, 0);
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
131
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
132 compositor.SetFont(0, Orthanc::EmbeddedResources::UBUNTU_FONT,
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
133 FONT_SIZE_0, Orthanc::Encoding_Latin1);
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
134 compositor.SetFont(1, Orthanc::EmbeddedResources::UBUNTU_FONT,
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
135 FONT_SIZE_1, Orthanc::Encoding_Latin1);
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
136 }
1392
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
137
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
138 /**
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
139 Create the shared loaders context
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
140 */
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
141 loadersContext_.reset(new GenericLoadersContext(1, 4, 1));
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
142 loadersContext_->StartOracle();
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
143
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
144 /**
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
145 It is very important that the Oracle (responsible for network I/O) be started before creating and firing the
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
146 loaders, for any command scheduled by the loader before the oracle is started will be lost.
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
147 */
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
148 PrepareLoadersAndSlicers();
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
149
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
150 OrthancStone::DefaultViewportInteractor interactor;
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
151
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
152 OrthancStoneHelpers::SdlRunLoop(viewport_, interactor);
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
153
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
154 loadersContext_->StopOracle();
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
155 }
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
156
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
157 #if 0
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
158 void RtViewerApp::HandleApplicationEvent(
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
159 const SDL_Event& event)
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
160 {
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
161 //DisplayInfoText();
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
162
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
163 std::unique_ptr<IViewport::ILock> lock(viewport_->Lock());
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
164 ViewportController& controller = lock->GetController();
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
165 Scene2D& scene = controller.GetScene();
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
166 ICompositor& compositor = lock->GetCompositor();
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
167
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
168 if (event.type == SDL_MOUSEMOTION)
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
169 {
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
170 int scancodeCount = 0;
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
171 const uint8_t* keyboardState = SDL_GetKeyboardState(&scancodeCount);
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
172
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
173 if (activeTracker_.get() == NULL &&
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
174 SDL_SCANCODE_LALT < scancodeCount &&
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
175 keyboardState[SDL_SCANCODE_LALT])
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
176 {
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
177 // The "left-ctrl" key is down, while no tracker is present
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
178 // Let's display the info text
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
179 PointerEvent e;
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
180 e.AddPosition(compositor.GetPixelCenterCoordinates(
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
181 event.button.x, event.button.y));
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
182
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
183 DisplayFloatingCtrlInfoText(e);
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
184 }
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
185 else
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
186 {
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
187 HideInfoText();
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
188 //LOG(TRACE) << "(event.type == SDL_MOUSEMOTION)";
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
189 if (activeTracker_.get() != NULL)
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
190 {
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
191 //LOG(TRACE) << "(activeTracker_.get() != NULL)";
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
192 PointerEvent e;
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
193 e.AddPosition(compositor.GetPixelCenterCoordinates(
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
194 event.button.x, event.button.y));
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
195
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
196 //LOG(TRACE) << "event.button.x = " << event.button.x << " " <<
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
197 // "event.button.y = " << event.button.y;
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
198 LOG(TRACE) << "activeTracker_->PointerMove(e); " <<
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
199 e.GetMainPosition().GetX() << " " << e.GetMainPosition().GetY();
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
200
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
201 activeTracker_->PointerMove(e);
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
202 if (!activeTracker_->IsAlive())
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
203 activeTracker_.reset();
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
204 }
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
205 }
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
206 }
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
207 else if (event.type == SDL_MOUSEBUTTONUP)
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
208 {
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
209 if (activeTracker_)
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
210 {
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
211 PointerEvent e;
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
212 e.AddPosition(compositor.GetPixelCenterCoordinates(event.button.x, event.button.y));
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
213 activeTracker_->PointerUp(e);
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
214 if (!activeTracker_->IsAlive())
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
215 activeTracker_.reset();
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
216 }
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
217 }
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
218 else if (event.type == SDL_MOUSEBUTTONDOWN)
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
219 {
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
220 PointerEvent e;
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
221 e.AddPosition(compositor.GetPixelCenterCoordinates(
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
222 event.button.x, event.button.y));
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
223 if (activeTracker_)
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
224 {
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
225 activeTracker_->PointerDown(e);
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
226 if (!activeTracker_->IsAlive())
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
227 activeTracker_.reset();
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
228 }
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
229 else
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
230 {
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
231 // we ATTEMPT to create a tracker if need be
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
232 activeTracker_ = CreateSuitableTracker(event, e);
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
233 }
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
234 }
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
235 else if (event.type == SDL_KEYDOWN &&
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
236 event.key.repeat == 0 /* Ignore key bounce */)
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
237 {
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
238 switch (event.key.keysym.sym)
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
239 {
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
240 case SDLK_ESCAPE:
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
241 if (activeTracker_)
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
242 {
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
243 activeTracker_->Cancel();
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
244 if (!activeTracker_->IsAlive())
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
245 activeTracker_.reset();
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
246 }
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
247 break;
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
248
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
249 case SDLK_r:
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
250 UpdateLayers();
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
251 {
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
252 std::unique_ptr<IViewport::ILock> lock(viewport_->Lock());
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
253 lock->Invalidate();
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
254 }
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
255 break;
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
256
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
257 case SDLK_s:
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
258 compositor.FitContent(scene);
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
259 break;
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
260
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
261 case SDLK_t:
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
262 if (!activeTracker_)
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
263 SelectNextTool();
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
264 else
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
265 {
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
266 LOG(WARNING) << "You cannot change the active tool when an interaction"
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
267 " is taking place";
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
268 }
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
269 break;
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
270
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
271 case SDLK_z:
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
272 LOG(TRACE) << "SDLK_z has been pressed. event.key.keysym.mod == " << event.key.keysym.mod;
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
273 if (event.key.keysym.mod & KMOD_CTRL)
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
274 {
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
275 if (controller.CanUndo())
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
276 {
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
277 LOG(TRACE) << "Undoing...";
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
278 controller.Undo();
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
279 }
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
280 else
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
281 {
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
282 LOG(WARNING) << "Nothing to undo!!!";
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
283 }
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
284 }
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
285 break;
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
286
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
287 case SDLK_y:
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
288 LOG(TRACE) << "SDLK_y has been pressed. event.key.keysym.mod == " << event.key.keysym.mod;
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
289 if (event.key.keysym.mod & KMOD_CTRL)
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
290 {
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
291 if (controller.CanRedo())
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
292 {
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
293 LOG(TRACE) << "Redoing...";
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
294 controller.Redo();
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
295 }
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
296 else
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
297 {
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
298 LOG(WARNING) << "Nothing to redo!!!";
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
299 }
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
300 }
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
301 break;
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
302
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
303 case SDLK_c:
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
304 TakeScreenshot(
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
305 "screenshot.png",
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
306 compositor.GetCanvasWidth(),
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
307 compositor.GetCanvasHeight());
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
308 break;
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
309
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
310 default:
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
311 break;
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
312 }
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
313 }
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
314 else if (viewport_->IsRefreshEvent(event))
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
315 {
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
316 // the viewport has been invalidated and requires repaint
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
317 viewport_->Paint();
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
318 }
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
319 }
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
320 #endif
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
321
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
322 #if 0
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
323 void RtViewerApp::RunSdl(int argc, char* argv[])
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
324 {
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
325 ProcessOptions(argc, argv);
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
326
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
327 {
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
328 std::unique_ptr<IViewport::ILock> lock(viewport_->Lock());
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
329 ViewportController& controller = lock->GetController();
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
330 Scene2D& scene = controller.GetScene();
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
331 ICompositor& compositor = lock->GetCompositor();
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
332
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
333 // False means we do NOT let a hi-DPI aware desktop managedr treat this as a legacy application that requires
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
334 // scaling.
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
335 controller.FitContent(compositor.GetCanvasWidth(), compositor.GetCanvasHeight());
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
336
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
337 glEnable(GL_DEBUG_OUTPUT);
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
338 glDebugMessageCallback(OpenGLMessageCallback, 0);
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
339
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
340 compositor.SetFont(0, Orthanc::EmbeddedResources::UBUNTU_FONT,
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
341 FONT_SIZE_0, Orthanc::Encoding_Latin1);
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
342 compositor.SetFont(1, Orthanc::EmbeddedResources::UBUNTU_FONT,
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
343 FONT_SIZE_1, Orthanc::Encoding_Latin1);
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
344 }
1386
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
345 //////// from loader
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
346
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
347 loadersContext_.reset(new GenericLoadersContext(1, 4, 1));
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
348 loadersContext_->StartOracle();
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
349
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
350 /**
1389
5c83be3a6be5 split SDL / common + RtViewer rename + html test file
Benjamin Golinvaux <bgo@osimis.io>
parents: 1386
diff changeset
351 It is very important that the Oracle (responsible for network I/O) be started before creating and firing the
1386
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
352 loaders, for any command scheduled by the loader before the oracle is started will be lost.
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
353 */
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
354 PrepareLoadersAndSlicers();
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
355
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
356 bool stopApplication = false;
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
357
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
358 while (!stopApplication)
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
359 {
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
360 SDL_Event event;
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
361 while (!stopApplication && SDL_PollEvent(&event))
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
362 {
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
363 if (event.type == SDL_QUIT)
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
364 {
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
365 stopApplication = true;
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
366 break;
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
367 }
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
368 else if (event.type == SDL_WINDOWEVENT &&
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
369 event.window.event == SDL_WINDOWEVENT_SIZE_CHANGED)
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
370 {
1389
5c83be3a6be5 split SDL / common + RtViewer rename + html test file
Benjamin Golinvaux <bgo@osimis.io>
parents: 1386
diff changeset
371 DisableTracker();
1386
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
372 }
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
373 else if (event.type == SDL_KEYDOWN &&
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
374 event.key.repeat == 0 /* Ignore key bounce */)
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
375 {
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
376 switch (event.key.keysym.sym)
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
377 {
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
378 case SDLK_f:
1389
5c83be3a6be5 split SDL / common + RtViewer rename + html test file
Benjamin Golinvaux <bgo@osimis.io>
parents: 1386
diff changeset
379 // TODO: implement GetWindow to be able to do:
5c83be3a6be5 split SDL / common + RtViewer rename + html test file
Benjamin Golinvaux <bgo@osimis.io>
parents: 1386
diff changeset
380 // viewport_->GetWindow().ToggleMaximize();
1386
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
381 ORTHANC_ASSERT(false, "Please implement GetWindow()");
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
382 break;
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
383 case SDLK_q:
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
384 stopApplication = true;
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
385 break;
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
386 default:
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
387 break;
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
388 }
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
389 }
1389
5c83be3a6be5 split SDL / common + RtViewer rename + html test file
Benjamin Golinvaux <bgo@osimis.io>
parents: 1386
diff changeset
390 // the code above is rather application-neutral.
5c83be3a6be5 split SDL / common + RtViewer rename + html test file
Benjamin Golinvaux <bgo@osimis.io>
parents: 1386
diff changeset
391 // the following call handles events specific to the application
1386
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
392 HandleApplicationEvent(event);
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
393 }
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
394 SDL_Delay(1);
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
395 }
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
396 loadersContext_->StopOracle();
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
397 }
1392
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
398 #endif
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
399
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
400 #if 0
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
401 boost::shared_ptr<IFlexiblePointerTracker> RtViewerApp::CreateSuitableTracker(
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
402 const SDL_Event& event,
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
403 const PointerEvent& e)
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
404 {
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
405 std::unique_ptr<IViewport::ILock> lock(viewport_->Lock());
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
406 ViewportController& controller = lock->GetController();
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
407 Scene2D& scene = controller.GetScene();
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
408 ICompositor& compositor = lock->GetCompositor();
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
409
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
410 using namespace Orthanc;
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
411
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
412 switch (event.button.button)
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
413 {
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
414 case SDL_BUTTON_MIDDLE:
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
415 return boost::shared_ptr<IFlexiblePointerTracker>(new PanSceneTracker
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
416 (viewport_, e));
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
417
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
418 case SDL_BUTTON_RIGHT:
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
419 return boost::shared_ptr<IFlexiblePointerTracker>(new ZoomSceneTracker
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
420 (viewport_, e, compositor.GetCanvasHeight()));
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
421
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
422 case SDL_BUTTON_LEFT:
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
423 {
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
424 //LOG(TRACE) << "CreateSuitableTracker: case SDL_BUTTON_LEFT:";
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
425 // TODO: we need to iterate on the set of measuring tool and perform
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
426 // a hit test to check if a tracker needs to be created for edition.
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
427 // Otherwise, depending upon the active tool, we might want to create
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
428 // a "measuring tool creation" tracker
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
429
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
430 // TODO: if there are conflicts, we should prefer a tracker that
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
431 // pertains to the type of measuring tool currently selected (TBD?)
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
432 boost::shared_ptr<IFlexiblePointerTracker> hitTestTracker = TrackerHitTest(e);
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
433
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
434 if (hitTestTracker != NULL)
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
435 {
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
436 //LOG(TRACE) << "hitTestTracker != NULL";
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
437 return hitTestTracker;
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
438 }
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
439 else
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
440 {
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
441 switch (currentTool_)
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
442 {
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
443 case RtViewerGuiTool_Rotate:
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
444 //LOG(TRACE) << "Creating RotateSceneTracker";
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
445 return boost::shared_ptr<IFlexiblePointerTracker>(new RotateSceneTracker(viewport_, e));
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
446 case RtViewerGuiTool_Pan:
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
447 return boost::shared_ptr<IFlexiblePointerTracker>(new PanSceneTracker(viewport_, e));
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
448 case RtViewerGuiTool_Zoom:
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
449 return boost::shared_ptr<IFlexiblePointerTracker>(new ZoomSceneTracker(viewport_, e, compositor.GetCanvasHeight()));
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
450 //case GuiTool_AngleMeasure:
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
451 // return new AngleMeasureTracker(GetScene(), e);
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
452 //case GuiTool_CircleMeasure:
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
453 // return new CircleMeasureTracker(GetScene(), e);
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
454 //case GuiTool_EllipseMeasure:
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
455 // return new EllipseMeasureTracker(GetScene(), e);
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
456 case RtViewerGuiTool_LineMeasure:
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
457 return boost::shared_ptr<IFlexiblePointerTracker>(new CreateLineMeasureTracker(viewport_, e));
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
458 case RtViewerGuiTool_AngleMeasure:
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
459 return boost::shared_ptr<IFlexiblePointerTracker>(new CreateAngleMeasureTracker(viewport_, e));
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
460 case RtViewerGuiTool_CircleMeasure:
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
461 LOG(ERROR) << "Not implemented yet!";
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
462 return boost::shared_ptr<IFlexiblePointerTracker>();
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
463 case RtViewerGuiTool_EllipseMeasure:
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
464 LOG(ERROR) << "Not implemented yet!";
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
465 return boost::shared_ptr<IFlexiblePointerTracker>();
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
466 default:
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
467 throw OrthancException(ErrorCode_InternalError, "Wrong tool!");
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
468 }
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
469 }
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
470 }
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
471 default:
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
472 return boost::shared_ptr<IFlexiblePointerTracker>();
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
473 }
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
474 }
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
475 #endif
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
476
1386
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
477 }
1392
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
478
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
479 boost::weak_ptr<OrthancStone::RtViewerApp> g_app;
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
480
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
481 /**
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
482 * IMPORTANT: The full arguments to "main()" are needed for SDL on
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
483 * Windows. Otherwise, one gets the linking error "undefined reference
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
484 * to `SDL_main'". https://wiki.libsdl.org/FAQWindows
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
485 **/
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
486 int main(int argc, char* argv[])
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
487 {
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
488 using namespace OrthancStone;
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
489
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
490 StoneInitialize();
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
491
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
492 try
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
493 {
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
494 boost::shared_ptr<RtViewerApp> app = RtViewerApp::Create();
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
495 g_app = app;
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
496 app->RunSdl(argc,argv);
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
497 }
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
498 catch (Orthanc::OrthancException& e)
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
499 {
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
500 LOG(ERROR) << "EXCEPTION: " << e.What();
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
501 }
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
502
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
503 StoneFinalize();
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
504
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
505 return 0;
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
506 }
ffdb82850e98 Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
507