43 automatic_update(true),
45 model_viewer_widget_(model_viewer_widget),
46 background_color_(1.0f, 1.0f, 1.0f, 1.0f),
47 point3D_colormap_scale_(1),
48 point3D_colormap_min_q_(0.02),
49 point3D_colormap_max_q_(0.98),
52 setWindowFlags(Qt::Widget | Qt::WindowStaysOnTopHint | Qt::Tool);
53 setWindowModality(Qt::NonModal);
54 setWindowTitle(
"Render options");
56 QHBoxLayout* point_size_layout =
new QHBoxLayout();
57 QPushButton* decrease_point_size =
new QPushButton(
"-",
this);
58 connect(decrease_point_size, &QPushButton::released,
this,
59 &RenderOptionsWidget::DecreasePointSize);
60 QPushButton* increase_point_size =
new QPushButton(
"+",
this);
61 connect(increase_point_size, &QPushButton::released,
this,
62 &RenderOptionsWidget::IncreasePointSize);
63 point_size_layout->addWidget(decrease_point_size);
64 point_size_layout->addWidget(increase_point_size);
67 QHBoxLayout* camera_size_layout =
new QHBoxLayout();
68 QPushButton* decrease_camera_size =
new QPushButton(
"-",
this);
69 connect(decrease_camera_size, &QPushButton::released,
this,
70 &RenderOptionsWidget::DecreaseCameraSize);
71 QPushButton* increase_camera_size =
new QPushButton(
"+",
this);
72 connect(increase_camera_size, &QPushButton::released,
this,
73 &RenderOptionsWidget::IncreaseCameraSize);
74 camera_size_layout->addWidget(decrease_camera_size);
75 camera_size_layout->addWidget(increase_camera_size);
80 projection_cb_ =
new QComboBox(
this);
81 projection_cb_->addItem(
"Perspective");
82 projection_cb_->addItem(
"Orthographic");
87 QPushButton* select_background_color =
88 new QPushButton(tr(
"Select color"),
this);
91 connect(select_background_color, &QPushButton::released,
this,
92 [&]() { SelectColor(
"Background color", &background_color_); });
102 point3D_colormap_cb_ =
new QComboBox(
this);
103 point3D_colormap_cb_->addItem(
"Photometric");
104 point3D_colormap_cb_->addItem(
"Error");
105 point3D_colormap_cb_->addItem(
"Track-Length");
106 point3D_colormap_cb_->addItem(
"Ground-Resolution");
109 AddOptionDouble(&point3D_colormap_min_q_,
"Point colormap minq", 0, 1, 0.001,
111 AddOptionDouble(&point3D_colormap_max_q_,
"Point colormap maxq", 0, 1, 0.001,
113 AddOptionDouble(&point3D_colormap_scale_,
"Point colormap scale", -1e7, 1e7);
119 connect(point3D_colormap_cb_,
120 (
void (QComboBox::*)(
int)) & QComboBox::currentIndexChanged,
this,
121 &RenderOptionsWidget::SelectPointColormap);
125 image_colormap_cb_ =
new QComboBox(
this);
126 image_colormap_cb_->addItem(
"Uniform color");
127 image_colormap_cb_->addItem(
"Images with words in name");
130 select_image_plane_color_ =
new QPushButton(tr(
"Select color"),
this);
131 connect(select_image_plane_color_, &QPushButton::released,
this,
132 [&]() { SelectColor(
"Image plane color", &image_plane_color_); });
135 select_image_frame_color_ =
new QPushButton(tr(
"Select color"),
this);
136 connect(select_image_frame_color_, &QPushButton::released,
this,
137 [&]() { SelectColor(
"Image frame color", &image_frame_color_); });
140 image_colormap_name_filter_layout_ =
new QHBoxLayout();
141 QPushButton* image_colormap_add_word =
new QPushButton(
"Add",
this);
142 connect(image_colormap_add_word, &QPushButton::released,
this,
143 &RenderOptionsWidget::ImageColormapNameFilterAddWord);
144 QPushButton* image_colormap_clear_words =
new QPushButton(
"Clear",
this);
145 connect(image_colormap_clear_words, &QPushButton::released,
this,
146 &RenderOptionsWidget::ImageColormapNameFilterClearWords);
147 image_colormap_name_filter_layout_->addWidget(image_colormap_add_word);
148 image_colormap_name_filter_layout_->addWidget(image_colormap_clear_words);
149 AddLayoutRow(
"Words", image_colormap_name_filter_layout_);
151 HideLayout(image_colormap_name_filter_layout_);
152 connect(image_colormap_cb_,
153 (
void (QComboBox::*)(
int)) & QComboBox::currentIndexChanged,
this,
154 &RenderOptionsWidget::SelectImageColormap);
167 QPushButton* apply =
new QPushButton(tr(
"Apply"),
this);
169 connect(apply, &QPushButton::released,
this, &RenderOptionsWidget::Apply);
172 void RenderOptionsWidget::closeEvent(QCloseEvent*
event) {
176 void RenderOptionsWidget::Apply() {
182 ApplyPointColormap();
183 ApplyImageColormap();
184 ApplyBackgroundColor();
189 void RenderOptionsWidget::ApplyProjection() {
190 switch (projection_cb_->currentIndex()) {
192 options_->
render->projection_type =
193 RenderOptions::ProjectionType::PERSPECTIVE;
196 options_->
render->projection_type =
197 RenderOptions::ProjectionType::ORTHOGRAPHIC;
200 options_->
render->projection_type =
201 RenderOptions::ProjectionType::PERSPECTIVE;
206 void RenderOptionsWidget::ApplyPointColormap() {
209 switch (point3D_colormap_cb_->currentIndex()) {
211 point3D_color_map =
new PointColormapPhotometric();
214 point3D_color_map =
new PointColormapError();
217 point3D_color_map =
new PointColormapTrackLen();
220 point3D_color_map =
new PointColormapGroundResolution();
223 point3D_color_map =
new PointColormapPhotometric();
227 point3D_color_map->scale =
static_cast<float>(point3D_colormap_scale_);
228 point3D_color_map->min_q =
static_cast<float>(point3D_colormap_min_q_);
229 point3D_color_map->max_q =
static_cast<float>(point3D_colormap_max_q_);
234 void RenderOptionsWidget::ApplyImageColormap() {
237 switch (image_colormap_cb_->currentIndex()) {
239 image_color_map =
new ImageColormapUniform();
240 reinterpret_cast<ImageColormapUniform*
>(image_color_map)
241 ->uniform_plane_color = image_plane_color_;
242 reinterpret_cast<ImageColormapUniform*
>(image_color_map)
243 ->uniform_frame_color = image_frame_color_;
250 image_color_map =
new ImageColormapUniform();
257 void RenderOptionsWidget::ApplyBackgroundColor() {
259 background_color_(0), background_color_(1), background_color_(2));
262 void RenderOptionsWidget::SelectColor(
const std::string& title,
263 Eigen::Vector4f*
color) {
264 const QColor initial_color(
265 static_cast<int>(255 * (*
color)(0)),
static_cast<int>(255 * (*
color)(1)),
266 static_cast<int>(255 * (*
color)(2)),
static_cast<int>(255 * (*
color)(3)));
267 const QColor selected_color =
268 QColorDialog::getColor(initial_color,
this, title.c_str());
269 (*color)(0) = selected_color.red() / 255.0;
270 (*color)(1) = selected_color.green() / 255.0;
271 (*color)(2) = selected_color.blue() / 255.0;
272 (*color)(3) = selected_color.alpha() / 255.0;
275 void RenderOptionsWidget::SelectPointColormap(
const int idx) {
287 void RenderOptionsWidget::SelectImageColormap(
const int idx) {
291 HideLayout(image_colormap_name_filter_layout_);
295 ShowLayout(image_colormap_name_filter_layout_);
299 void RenderOptionsWidget::IncreasePointSize() {
300 const float kDelta = 100;
304 void RenderOptionsWidget::DecreasePointSize() {
305 const float kDelta = -100;
309 void RenderOptionsWidget::IncreaseCameraSize() {
310 const float kDelta = 100;
314 void RenderOptionsWidget::DecreaseCameraSize() {
315 const float kDelta = -100;
319 void RenderOptionsWidget::ImageColormapNameFilterAddWord() {
322 QInputDialog::getText(
this,
"",
"Word:", QLineEdit::Normal,
"", &word_ok);
323 if (!word_ok || word ==
"") {
328 SelectColor(
"Image plane color", &plane_color);
331 SelectColor(
"Image frame color", &frame_color);
334 plane_color, frame_color);
337 void RenderOptionsWidget::ImageColormapNameFilterClearWords() {
static const Eigen::Vector4f kDefaultPlaneColor
static const Eigen::Vector4f kDefaultFrameColor
void AddColorForWord(const std::string &word, const Eigen::Vector4f &plane_color, const Eigen::Vector4f &frame_color)
std::shared_ptr< RenderOptions > render
colmap::ImageColormapNameFilter ImageColormapNameFilter
colmap::ImageColormapBase ImageColormapBase
colmap::PointColormapBase PointColormapBase