ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
gui.cc
Go to the documentation of this file.
1 // Copyright (c) 2018, ETH Zurich and UNC Chapel Hill.
2 // All rights reserved.
3 //
4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are met:
6 //
7 // * Redistributions of source code must retain the above copyright
8 // notice, this list of conditions and the following disclaimer.
9 //
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 //
14 // * Neither the name of ETH Zurich and UNC Chapel Hill nor the names of
15 // its contributors may be used to endorse or promote products derived
16 // from this software without specific prior written permission.
17 //
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
22 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 // POSSIBILITY OF SUCH DAMAGE.
29 //
30 // Author: Johannes L. Schoenberger (jsch-at-demuc-dot-de)
31 
32 #include "exe/gui.h"
33 
34 #include "util/opengl_utils.h"
35 #include "util/option_manager.h"
36 
37 namespace colmap {
38 
39 int RunGraphicalUserInterface(int argc, char** argv) {
40 #ifndef GUI_ENABLED
41  std::cerr << "ERROR: Cannot start colmap GUI; colmap was built without GUI "
42  "support or QT dependency is missing."
43  << std::endl;
44  return EXIT_FAILURE;
45 #else
46  using namespace colmap;
47 
48  OptionManager options;
49 
50  std::string import_path;
51 
52  if (argc > 1) {
53  options.AddDefaultOption("import_path", &import_path);
54  options.AddAllOptions();
55  options.Parse(argc, argv);
56  }
57 
58 #if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
59  QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
60  QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
61 #endif
62 
63  QApplication app(argc, argv);
64 
65  MainWindow main_window(options);
66  main_window.show();
67 
68  if (!import_path.empty()) {
69  main_window.ImportReconstruction(import_path);
70  }
71 
72  return app.exec();
73 #endif
74 }
75 
76 int RunProjectGenerator(int argc, char** argv) {
77  std::string output_path;
78  std::string quality = "high";
79 
80  OptionManager options;
81  options.AddRequiredOption("output_path", &output_path);
82  options.AddDefaultOption("quality", &quality, "{low, medium, high, extreme}");
83  options.Parse(argc, argv);
84 
85  OptionManager output_options;
86  output_options.AddAllOptions();
87 
88  StringToLower(&quality);
89  if (quality == "low") {
90  output_options.ModifyForLowQuality();
91  } else if (quality == "medium") {
92  output_options.ModifyForMediumQuality();
93  } else if (quality == "high") {
94  output_options.ModifyForHighQuality();
95  } else if (quality == "extreme") {
96  output_options.ModifyForExtremeQuality();
97  } else {
98  LOG(FATAL) << "Invalid quality provided";
99  }
100 
101  output_options.Write(output_path);
102 
103  return EXIT_SUCCESS;
104 }
105 
106 } // namespace colmap
void ImportReconstruction(const std::string &path)
Definition: main_window.cc:60
void AddRequiredOption(const std::string &name, T *option, const std::string &help_text="")
void AddDefaultOption(const std::string &name, T *option, const std::string &help_text="")
void Write(const std::string &path) const
void Parse(const int argc, char **argv)
QTextStream & endl(QTextStream &stream)
Definition: QtCompat.h:718
void StringToLower(std::string *str)
Definition: string.cc:193
int RunGraphicalUserInterface(int argc, char **argv)
Definition: gui.cc:39
int RunProjectGenerator(int argc, char **argv)
Definition: gui.cc:76