ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
ReconstructionManagerWidget.cpp
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
9 
10 #include "base/reconstruction_manager.h"
11 
12 namespace cloudViewer {
13 
14 using namespace colmap;
15 
18 
20  QWidget* parent,
21  const colmap::ReconstructionManager* reconstruction_manager)
22  : QComboBox(parent), reconstruction_manager_(reconstruction_manager) {
23  QFont font;
24  font.setPointSize(10);
25  setFont(font);
26 }
27 
29  if (view()->isVisible()) {
30  return;
31  }
32 
33  blockSignals(true);
34 
35  const int prev_idx = currentIndex() == -1 ? 0 : currentIndex();
36 
37  clear();
38 
39  addItem("Newest model");
40 
41  int max_width = 0;
42  for (size_t i = 0; i < reconstruction_manager_->Size(); ++i) {
43  const QString item = QString().asprintf(
44  "Model %d (%d images, %d points)", static_cast<int>(i + 1),
45  static_cast<int>(
46  reconstruction_manager_->Get(i).NumRegImages()),
47  static_cast<int>(
48  reconstruction_manager_->Get(i).NumPoints3D()));
49  QFontMetrics font_metrics(view()->font());
50  max_width = std::max(max_width, font_metrics.horizontalAdvance(item));
51  addItem(item);
52  }
53 
54  view()->setMinimumWidth(max_width);
55 
56  if (reconstruction_manager_->Size() == 0) {
57  setCurrentIndex(0);
58  } else {
59  setCurrentIndex(prev_idx);
60  }
61 
62  blockSignals(false);
63 }
64 
66  if (reconstruction_manager_->Size() == 0) {
68  } else {
69  if (currentIndex() == 0) {
71  } else {
72  return currentIndex() - 1;
73  }
74  }
75 }
76 
78  if (reconstruction_manager_->Size() == 0) {
79  blockSignals(true);
80  setCurrentIndex(0);
81  blockSignals(false);
82  } else {
83  blockSignals(true);
84  setCurrentIndex(idx + 1);
85  blockSignals(false);
86  }
87 }
88 
89 } // namespace cloudViewer
ReconstructionManagerWidget(QWidget *parent, const colmap::ReconstructionManager *reconstruction_manager)
int max(int a, int b)
Definition: cutil_math.h:48
Generic file read and write utility for python interface.