Mercurial > hg > orthanc-stone
comparison Samples/Sdl/SingleFrameViewer/SdlSimpleViewer.cpp @ 1387:4ebf246f3919
Fixed big mistake (factoring the option parsing, which only adds noise to the people reading the code)
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Mon, 27 Apr 2020 16:49:03 +0200 |
parents | ab871499ed30 |
children | ffdb82850e98 |
comparison
equal
deleted
inserted
replaced
1386:dfb48f0794b1 | 1387:4ebf246f3919 |
---|---|
1 | 1 |
2 #include "SdlSimpleViewerApplication.h" | 2 #include "SdlSimpleViewerApplication.h" |
3 | 3 #include "../SdlHelpers.h" |
4 #include <string> | 4 #include "../../Common/SampleHelpers.h" |
5 | |
6 #include <boost/program_options.hpp> | |
7 | |
8 #include <SDL.h> | |
9 | |
10 #include <Core/OrthancException.h> | |
11 | 5 |
12 #include <Framework/Loaders/GenericLoadersContext.h> | 6 #include <Framework/Loaders/GenericLoadersContext.h> |
13 #include <Framework/StoneException.h> | 7 #include <Framework/StoneException.h> |
14 #include <Framework/StoneEnumerations.h> | 8 #include <Framework/StoneEnumerations.h> |
15 #include <Framework/StoneInitialization.h> | 9 #include <Framework/StoneInitialization.h> |
16 #include <Framework/Viewport/SdlViewport.h> | 10 #include <Framework/Viewport/SdlViewport.h> |
17 | 11 |
18 #include "../SdlHelpers.h" | 12 #include <Core/OrthancException.h> |
19 #include "../../Common/SampleHelpers.h" | 13 |
14 #include <boost/program_options.hpp> | |
15 #include <SDL.h> | |
16 | |
17 #include <string> | |
18 | |
20 | 19 |
21 std::string orthancUrl; | 20 std::string orthancUrl; |
22 std::string instanceId; | 21 std::string instanceId; |
23 int frameIndex = 0; | 22 int frameIndex = 0; |
23 | |
24 | 24 |
25 static void ProcessOptions(int argc, char* argv[]) | 25 static void ProcessOptions(int argc, char* argv[]) |
26 { | 26 { |
27 namespace po = boost::program_options; | 27 namespace po = boost::program_options; |
28 po::options_description desc("Usage:"); | 28 po::options_description desc("Usage:"); |
29 | 29 |
30 desc.add_options() | 30 desc.add_options() |
31 ("log_level", po::value<std::string>()->default_value("WARNING"), | 31 ("loglevel", po::value<std::string>()->default_value("WARNING"), |
32 "You can choose WARNING, INFO or TRACE for the logging level: Errors and warnings will always be displayed. (default: WARNING)") | 32 "You can choose WARNING, INFO or TRACE for the logging level: Errors and warnings will always be displayed. (default: WARNING)") |
33 | 33 |
34 ("orthanc", po::value<std::string>()->default_value("http://localhost:8042"), | 34 ("orthanc", po::value<std::string>()->default_value("http://localhost:8042"), |
35 "Base URL of the Orthanc instance") | 35 "Base URL of the Orthanc instance") |
36 | 36 |
50 catch (std::exception& e) | 50 catch (std::exception& e) |
51 { | 51 { |
52 std::cerr << "Please check your command line options! (\"" << e.what() << "\")" << std::endl; | 52 std::cerr << "Please check your command line options! (\"" << e.what() << "\")" << std::endl; |
53 } | 53 } |
54 | 54 |
55 if (vm.count("log_level") > 0) | 55 if (vm.count("loglevel") > 0) |
56 { | 56 { |
57 std::string logLevel = vm["log_level"].as<std::string>(); | 57 std::string logLevel = vm["loglevel"].as<std::string>(); |
58 OrthancStoneHelpers::SetLogLevel(logLevel); | 58 OrthancStoneHelpers::SetLogLevel(logLevel); |
59 } | 59 } |
60 | 60 |
61 if (vm.count("orthanc") > 0) | 61 if (vm.count("orthanc") > 0) |
62 { | 62 { |
72 if (vm.count("frame_index") > 0) | 72 if (vm.count("frame_index") > 0) |
73 { | 73 { |
74 frameIndex = vm["frame_index"].as<int>(); | 74 frameIndex = vm["frame_index"].as<int>(); |
75 } | 75 } |
76 | 76 |
77 } | |
78 | |
79 extern void f() | |
80 { | |
81 std::cout << "f()" << std::endl; | |
82 } | 77 } |
83 | 78 |
84 /** | 79 /** |
85 * IMPORTANT: The full arguments to "main()" are needed for SDL on | 80 * IMPORTANT: The full arguments to "main()" are needed for SDL on |
86 * Windows. Otherwise, one gets the linking error "undefined reference | 81 * Windows. Otherwise, one gets the linking error "undefined reference |
87 * to `SDL_main'". https://wiki.libsdl.org/FAQWindows | 82 * to `SDL_main'". https://wiki.libsdl.org/FAQWindows |
88 **/ | 83 **/ |
89 int main(int argc, char* argv[]) | 84 int main(int argc, char* argv[]) |
90 { | 85 { |
91 f(); | |
92 | |
93 try | 86 try |
94 { | 87 { |
95 OrthancStone::StoneInitialize(); | 88 OrthancStone::StoneInitialize(); |
96 | 89 |
97 ProcessOptions(argc, argv); | 90 ProcessOptions(argc, argv); |