10 #include "ui/colormaps.h"
19 : OptionsWidget(parent),
21 automatic_update(true),
23 model_viewer_widget_(model_viewer_widget),
24 background_color_(1.0f, 1.0f, 1.0f, 1.0f),
25 point3D_colormap_scale_(1),
26 point3D_colormap_min_q_(0.02),
27 point3D_colormap_max_q_(0.98),
28 image_plane_color_(ImageColormapUniform::kDefaultPlaneColor),
29 image_frame_color_(ImageColormapUniform::kDefaultFrameColor) {
30 setWindowFlags(Qt::Widget | Qt::WindowStaysOnTopHint | Qt::Tool);
31 setWindowModality(Qt::NonModal);
32 setWindowTitle(
"Render options");
34 QHBoxLayout* point_size_layout =
new QHBoxLayout();
35 QPushButton* decrease_point_size =
new QPushButton(
"-",
this);
36 connect(decrease_point_size, &QPushButton::released,
this,
37 &RenderOptionsWidget::DecreasePointSize);
38 QPushButton* increase_point_size =
new QPushButton(
"+",
this);
39 connect(increase_point_size, &QPushButton::released,
this,
40 &RenderOptionsWidget::IncreasePointSize);
41 point_size_layout->addWidget(decrease_point_size);
42 point_size_layout->addWidget(increase_point_size);
43 AddLayoutRow(
"Point size", point_size_layout);
45 QHBoxLayout* camera_size_layout =
new QHBoxLayout();
46 QPushButton* decrease_camera_size =
new QPushButton(
"-",
this);
47 connect(decrease_camera_size, &QPushButton::released,
this,
48 &RenderOptionsWidget::DecreaseCameraSize);
49 QPushButton* increase_camera_size =
new QPushButton(
"+",
this);
50 connect(increase_camera_size, &QPushButton::released,
this,
51 &RenderOptionsWidget::IncreaseCameraSize);
52 camera_size_layout->addWidget(decrease_camera_size);
53 camera_size_layout->addWidget(increase_camera_size);
54 AddLayoutRow(
"Camera size", camera_size_layout);
58 projection_cb_ =
new QComboBox(
this);
59 projection_cb_->addItem(
"Perspective");
60 projection_cb_->addItem(
"Orthographic");
61 AddWidgetRow(
"Projection", projection_cb_);
65 QPushButton* select_background_color =
66 new QPushButton(tr(
"Select color"),
this);
67 grid_layout_->addWidget(select_background_color,
68 grid_layout_->rowCount() - 1, 1);
69 connect(select_background_color, &QPushButton::released,
this,
70 [&]() { SelectColor(
"Background color", &background_color_); });
71 AddWidgetRow(
"Background", select_background_color);
75 AddOptionDouble(&options->render->max_error,
"Point max. error [px]");
76 AddOptionInt(&options->render->min_track_len,
"Point min. track length", 0);
80 point3D_colormap_cb_ =
new QComboBox(
this);
81 point3D_colormap_cb_->addItem(
"Photometric");
82 point3D_colormap_cb_->addItem(
"Error");
83 point3D_colormap_cb_->addItem(
"Track-Length");
84 point3D_colormap_cb_->addItem(
"Ground-Resolution");
85 AddWidgetRow(
"Point colormap", point3D_colormap_cb_);
87 AddOptionDouble(&point3D_colormap_min_q_,
"Point colormap minq", 0, 1,
89 AddOptionDouble(&point3D_colormap_max_q_,
"Point colormap maxq", 0, 1,
91 AddOptionDouble(&point3D_colormap_scale_,
"Point colormap scale", -1e7,
95 HideOption(&point3D_colormap_min_q_);
96 HideOption(&point3D_colormap_max_q_);
97 HideOption(&point3D_colormap_scale_);
98 connect(point3D_colormap_cb_,
99 (
void(QComboBox::*)(
int)) & QComboBox::currentIndexChanged,
this,
100 &RenderOptionsWidget::SelectPointColormap);
104 image_colormap_cb_ =
new QComboBox(
this);
105 image_colormap_cb_->addItem(
"Uniform color");
106 image_colormap_cb_->addItem(
"Images with words in name");
107 AddWidgetRow(
"Image colormap", image_colormap_cb_);
109 select_image_plane_color_ =
new QPushButton(tr(
"Select color"),
this);
110 connect(select_image_plane_color_, &QPushButton::released,
this,
111 [&]() { SelectColor(
"Image plane color", &image_plane_color_); });
112 AddWidgetRow(
"Image plane", select_image_plane_color_);
114 select_image_frame_color_ =
new QPushButton(tr(
"Select color"),
this);
115 connect(select_image_frame_color_, &QPushButton::released,
this,
116 [&]() { SelectColor(
"Image frame color", &image_frame_color_); });
117 AddWidgetRow(
"Image frame", select_image_frame_color_);
119 image_colormap_name_filter_layout_ =
new QHBoxLayout();
120 QPushButton* image_colormap_add_word =
new QPushButton(
"Add",
this);
121 connect(image_colormap_add_word, &QPushButton::released,
this,
122 &RenderOptionsWidget::ImageColormapNameFilterAddWord);
123 QPushButton* image_colormap_clear_words =
new QPushButton(
"Clear",
this);
124 connect(image_colormap_clear_words, &QPushButton::released,
this,
125 &RenderOptionsWidget::ImageColormapNameFilterClearWords);
126 image_colormap_name_filter_layout_->addWidget(image_colormap_add_word);
127 image_colormap_name_filter_layout_->addWidget(image_colormap_clear_words);
128 AddLayoutRow(
"Words", image_colormap_name_filter_layout_);
130 HideLayout(image_colormap_name_filter_layout_);
131 connect(image_colormap_cb_,
132 (
void(QComboBox::*)(
int)) & QComboBox::currentIndexChanged,
this,
133 &RenderOptionsWidget::SelectImageColormap);
137 AddOptionBool(&options->render->adapt_refresh_rate,
138 "Adaptive refresh rate");
139 AddOptionInt(&options->render->refresh_rate,
"Refresh rate [frames]", 1);
143 AddOptionBool(&options->render->image_connections,
"Image connections");
147 QPushButton* apply =
new QPushButton(tr(
"Apply"),
this);
148 grid_layout_->addWidget(apply, grid_layout_->rowCount(), 1);
149 connect(apply, &QPushButton::released,
this, &RenderOptionsWidget::Apply);
152 void RenderOptionsWidget::closeEvent(QCloseEvent*
event) {
156 void RenderOptionsWidget::Apply() {
162 ApplyPointColormap();
163 ApplyImageColormap();
164 ApplyBackgroundColor();
169 void RenderOptionsWidget::ApplyProjection() {
170 switch (projection_cb_->currentIndex()) {
172 options_->render->projection_type =
173 colmap::RenderOptions::ProjectionType::PERSPECTIVE;
176 options_->render->projection_type =
177 colmap::RenderOptions::ProjectionType::ORTHOGRAPHIC;
180 options_->render->projection_type =
181 colmap::RenderOptions::ProjectionType::PERSPECTIVE;
184 if (options_->render->projection_type ==
185 colmap::RenderOptions::ProjectionType::PERSPECTIVE) {
188 if (options_->render->projection_type ==
189 colmap::RenderOptions::ProjectionType::ORTHOGRAPHIC) {
194 void RenderOptionsWidget::ApplyPointColormap() {
197 switch (point3D_colormap_cb_->currentIndex()) {
199 point3D_color_map =
new PointColormapPhotometric();
202 point3D_color_map =
new PointColormapError();
205 point3D_color_map =
new PointColormapTrackLen();
208 point3D_color_map =
new PointColormapGroundResolution();
211 point3D_color_map =
new PointColormapPhotometric();
215 point3D_color_map->scale =
static_cast<float>(point3D_colormap_scale_);
216 point3D_color_map->min_q =
static_cast<float>(point3D_colormap_min_q_);
217 point3D_color_map->max_q =
static_cast<float>(point3D_colormap_max_q_);
222 void RenderOptionsWidget::ApplyImageColormap() {
225 switch (image_colormap_cb_->currentIndex()) {
227 image_color_map =
new ImageColormapUniform();
228 reinterpret_cast<ImageColormapUniform*
>(image_color_map)
229 ->uniform_plane_color = image_plane_color_;
230 reinterpret_cast<ImageColormapUniform*
>(image_color_map)
231 ->uniform_frame_color = image_frame_color_;
238 image_color_map =
new ImageColormapUniform();
245 void RenderOptionsWidget::ApplyBackgroundColor() {
247 background_color_(0), background_color_(1), background_color_(2));
250 void RenderOptionsWidget::SelectColor(
const std::string& title,
251 Eigen::Vector4f*
color) {
252 const QColor initial_color(
static_cast<int>(255 * (*
color)(0)),
253 static_cast<int>(255 * (*
color)(1)),
254 static_cast<int>(255 * (*
color)(2)),
255 static_cast<int>(255 * (*
color)(3)));
256 const QColor selected_color =
257 QColorDialog::getColor(initial_color,
this, title.c_str());
258 (*color)(0) = selected_color.red() / 255.0;
259 (*color)(1) = selected_color.green() / 255.0;
260 (*color)(2) = selected_color.blue() / 255.0;
261 (*color)(3) = selected_color.alpha() / 255.0;
264 void RenderOptionsWidget::SelectPointColormap(
const int idx) {
266 HideOption(&point3D_colormap_scale_);
267 HideOption(&point3D_colormap_min_q_);
268 HideOption(&point3D_colormap_max_q_);
270 ShowOption(&point3D_colormap_scale_);
271 ShowOption(&point3D_colormap_min_q_);
272 ShowOption(&point3D_colormap_max_q_);
276 void RenderOptionsWidget::SelectImageColormap(
const int idx) {
278 ShowWidget(select_image_plane_color_);
279 ShowWidget(select_image_frame_color_);
280 HideLayout(image_colormap_name_filter_layout_);
282 HideWidget(select_image_plane_color_);
283 HideWidget(select_image_frame_color_);
284 ShowLayout(image_colormap_name_filter_layout_);
288 void RenderOptionsWidget::IncreasePointSize() {
289 const float kDelta = 100;
293 void RenderOptionsWidget::DecreasePointSize() {
294 const float kDelta = -100;
298 void RenderOptionsWidget::IncreaseCameraSize() {
299 const float kDelta = 100;
303 void RenderOptionsWidget::DecreaseCameraSize() {
304 const float kDelta = -100;
308 void RenderOptionsWidget::ImageColormapNameFilterAddWord() {
310 const QString word = QInputDialog::getText(
311 this,
"",
"Word:", QLineEdit::Normal,
"", &word_ok);
312 if (!word_ok || word ==
"") {
316 Eigen::Vector4f plane_color(ImageColormapBase::kDefaultPlaneColor);
317 SelectColor(
"Image plane color", &plane_color);
319 Eigen::Vector4f frame_color(ImageColormapBase::kDefaultFrameColor);
320 SelectColor(
"Image frame color", &frame_color);
322 image_colormap_name_filter_.AddColorForWord(word.toUtf8().constData(),
323 plane_color, frame_color);
326 void RenderOptionsWidget::ImageColormapNameFilterClearWords() {
Generic file read and write utility for python interface.
colmap::ImageColormapNameFilter ImageColormapNameFilter
colmap::ImageColormapBase ImageColormapBase
colmap::OptionManager OptionManager
colmap::PointColormapBase PointColormapBase