ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
reconstruction_manager_widget.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 
33 
34 // Qt5/Qt6 Compatibility
35 #include <QtCompat.h>
36 
37 namespace colmap {
38 
40  std::numeric_limits<size_t>::max();
41 
43  QWidget* parent, const ReconstructionManager* reconstruction_manager)
44  : QComboBox(parent), reconstruction_manager_(reconstruction_manager) {
45  QFont font;
46  font.setPointSize(10);
47  setFont(font);
48 }
49 
51  if (view()->isVisible()) {
52  return;
53  }
54 
55  blockSignals(true);
56 
57  const int prev_idx = currentIndex() == -1 ? 0 : currentIndex();
58 
59  clear();
60 
61  addItem("Newest model");
62 
63  int max_width = 0;
64  for (size_t i = 0; i < reconstruction_manager_->Size(); ++i) {
65 #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
66  const QString item = QString::asprintf(
67  "Model %d (%d images, %d points)", static_cast<int>(i + 1),
68  static_cast<int>(reconstruction_manager_->Get(i).NumRegImages()),
69  static_cast<int>(reconstruction_manager_->Get(i).NumPoints3D()));
70 #else
71  const QString item = QString().sprintf(
72  "Model %d (%d images, %d points)", static_cast<int>(i + 1),
73  static_cast<int>(reconstruction_manager_->Get(i).NumRegImages()),
74  static_cast<int>(reconstruction_manager_->Get(i).NumPoints3D()));
75 #endif
76  QFontMetrics font_metrics(view()->font());
77  max_width = std::max(max_width, QTCOMPAT_FONTMETRICS_WIDTH(font_metrics, item));
78  addItem(item);
79  }
80 
81  view()->setMinimumWidth(max_width);
82 
83  if (reconstruction_manager_->Size() == 0) {
84  setCurrentIndex(0);
85  } else {
86  setCurrentIndex(prev_idx);
87  }
88 
89  blockSignals(false);
90 }
91 
93  if (reconstruction_manager_->Size() == 0) {
95  } else {
96  if (currentIndex() == 0) {
98  } else {
99  return currentIndex() - 1;
100  }
101  }
102 }
103 
105  if (reconstruction_manager_->Size() == 0) {
106  blockSignals(true);
107  setCurrentIndex(0);
108  blockSignals(false);
109  } else {
110  blockSignals(true);
111  setCurrentIndex(idx + 1);
112  blockSignals(false);
113  }
114 }
115 
116 } // namespace colmap
#define QTCOMPAT_FONTMETRICS_WIDTH(fm, text)
Definition: QtCompat.h:339
ReconstructionManagerWidget(QWidget *parent, const ReconstructionManager *reconstruction_manager)
const Reconstruction & Get(const size_t idx) const
size_t NumRegImages() const
size_t NumPoints3D() const