comparison Applications/Generic/BasicNativeApplication.cpp @ 276:5de5699ad570 am-2

first display in QCairoWidget; no mouse interaction yet
author am@osimis.io
date Mon, 27 Aug 2018 12:21:52 +0200
parents dc1beee33134
children
comparison
equal deleted inserted replaced
275:58e23e0dd86a 276:5de5699ad570
72 /****************************************************************** 72 /******************************************************************
73 * Declare and parse the command-line options of the application 73 * Declare and parse the command-line options of the application
74 ******************************************************************/ 74 ******************************************************************/
75 75
76 boost::program_options::options_description options; 76 boost::program_options::options_description options;
77
78 { // generic options
79 boost::program_options::options_description generic("Generic options");
80 generic.add_options()
81 ("help", "Display this help and exit")
82 ("verbose", "Be verbose in logs")
83 ("orthanc", boost::program_options::value<std::string>()->default_value("http://localhost:8042/"),
84 "URL to the Orthanc server")
85 ("username", "Username for the Orthanc server")
86 ("password", "Password for the Orthanc server")
87 ("https-verify", boost::program_options::value<bool>()->default_value(true), "Check HTTPS certificates")
88 ;
89
90 options.add(generic);
91 }
92
93 // platform specific options
77 DeclareCommandLineOptions(options); 94 DeclareCommandLineOptions(options);
95
96 // application specific options
78 application.DeclareStartupOptions(options); 97 application.DeclareStartupOptions(options);
79 98
80 boost::program_options::variables_map parameters; 99 boost::program_options::variables_map parameters;
81 bool error = false; 100 bool error = false;
82 101
121 if (parameters.count("verbose")) 140 if (parameters.count("verbose"))
122 { 141 {
123 Orthanc::Logging::EnableInfoLevel(true); 142 Orthanc::Logging::EnableInfoLevel(true);
124 } 143 }
125 144
126 if (!parameters.count("width") || 145 ParseCommandLineOptions(parameters);
127 !parameters.count("height") || 146
128 !parameters.count("opengl"))
129 {
130 LOG(ERROR) << "Parameter \"width\", \"height\" or \"opengl\" is missing";
131 return -1;
132 }
133
134 int w = parameters["width"].as<int>();
135 int h = parameters["height"].as<int>();
136 if (w <= 0 || h <= 0)
137 {
138 LOG(ERROR) << "Parameters \"width\" and \"height\" must be positive";
139 return -1;
140 }
141
142 unsigned int width = static_cast<unsigned int>(w);
143 unsigned int height = static_cast<unsigned int>(h);
144 LOG(WARNING) << "Initial display size: " << width << "x" << height;
145
146 bool opengl = parameters["opengl"].as<bool>();
147 if (opengl)
148 {
149 LOG(WARNING) << "OpenGL is enabled, disable it with option \"--opengl=off\" if the application crashes";
150 }
151 else
152 {
153 LOG(WARNING) << "OpenGL is disabled, enable it with option \"--opengl=on\" for best performance";
154 }
155 147
156 bool success = true; 148 bool success = true;
157 try 149 try
158 { 150 {
159 /**************************************************************** 151 /****************************************************************
218 210
219 /**************************************************************** 211 /****************************************************************
220 * Run the application 212 * Run the application
221 ****************************************************************/ 213 ****************************************************************/
222 214
223 Run(context, title, width, height, opengl); 215 Run(context, title, argc, argv);
224
225 216
226 /**************************************************************** 217 /****************************************************************
227 * Finalize the application 218 * Finalize the application
228 ****************************************************************/ 219 ****************************************************************/
229 220