From ab082b29f1180c227a1922f6a852f81f3345f523 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 26 Feb 2025 00:11:08 +0100 Subject: [PATCH] Make it possible to enter target coordinates in Selection item's "Move Point" --- .../Plugins/PCA/Basic_generator_plugin.cpp | 22 ++--- .../Lab/Plugins/PCA/Basic_generator_widget.ui | 32 +++---- Lab/demo/Lab/Plugins/PMP/Selection_plugin.cpp | 72 +++++++++++++++ Lab/demo/Lab/Plugins/PMP/Selection_widget.ui | 87 ++++++++++++------- .../Lab/Scene_polyhedron_selection_item.cpp | 19 +++- .../Lab/Scene_polyhedron_selection_item.h | 1 + Lab/demo/Lab/Viewer.cpp | 2 +- .../demo/Triangulation_on_sphere_2/main.cpp | 2 +- 8 files changed, 175 insertions(+), 62 deletions(-) diff --git a/Lab/demo/Lab/Plugins/PCA/Basic_generator_plugin.cpp b/Lab/demo/Lab/Plugins/PCA/Basic_generator_plugin.cpp index 15883fa976a..46539303a43 100644 --- a/Lab/demo/Lab/Plugins/PCA/Basic_generator_plugin.cpp +++ b/Lab/demo/Lab/Plugins/PCA/Basic_generator_plugin.cpp @@ -375,7 +375,7 @@ void Basic_generator_plugin::generateCube() if (list.size()!=3){ QMessageBox *msgBox = new QMessageBox; msgBox->setWindowTitle("Error"); - msgBox->setText("ERROR : Input should consists of 3 doubles."); + msgBox->setText("ERROR : Input should consist of 3 doubles."); msgBox->exec(); return; } @@ -416,7 +416,7 @@ void Basic_generator_plugin::generateCube() if (list.size()!=6){ QMessageBox *msgBox = new QMessageBox; msgBox->setWindowTitle("Error"); - msgBox->setText("ERROR : Input should consists of 6 doubles."); + msgBox->setText("ERROR : Input should consist of 6 doubles."); msgBox->exec(); return; } @@ -467,7 +467,7 @@ void Basic_generator_plugin::generatePrism() if (list.size()!=3){ QMessageBox *msgBox = new QMessageBox; msgBox->setWindowTitle("Error"); - msgBox->setText("ERROR : Input should consists of 3 doubles."); + msgBox->setText("ERROR : Input should consist of 3 doubles."); msgBox->exec(); return; } @@ -514,7 +514,7 @@ void Basic_generator_plugin::generatePyramid() if (list.size()!=3){ QMessageBox *msgBox = new QMessageBox; msgBox->setWindowTitle("Error"); - msgBox->setText("ERROR : Input should consists of 3 doubles."); + msgBox->setText("ERROR : Input should consist of 3 doubles."); msgBox->exec(); return; } @@ -557,7 +557,7 @@ void Basic_generator_plugin::generateSphere() if (list.size()!=4){ QMessageBox *msgBox = new QMessageBox; msgBox->setWindowTitle("Error"); - msgBox->setText("ERROR : Input should consists of four doubles."); + msgBox->setText("ERROR : Input should consist of four doubles."); msgBox->exec(); return; } @@ -607,7 +607,7 @@ void Basic_generator_plugin::generateTetrahedron() if (list.size() != 3) { QMessageBox* msgBox = new QMessageBox; msgBox->setWindowTitle("Error"); - msgBox->setText("ERROR : Input should consists of 3 doubles."); + msgBox->setText("ERROR : Input should consist of 3 doubles."); msgBox->exec(); return; } @@ -641,7 +641,7 @@ void Basic_generator_plugin::generateTetrahedron() if (list.size() != 12) { QMessageBox* msgBox = new QMessageBox; msgBox->setWindowTitle("Error"); - msgBox->setText("ERROR : Input should consists of 12 doubles."); + msgBox->setText("ERROR : Input should consist of 12 doubles."); msgBox->exec(); return; } @@ -685,7 +685,7 @@ void Basic_generator_plugin::generatePoints() if (list.size()%3!=0){ QMessageBox *msgBox = new QMessageBox; msgBox->setWindowTitle("Error"); - msgBox->setText("ERROR : Input should consists of triplets."); + msgBox->setText("ERROR : Input should consist of triplets."); msgBox->exec(); return; } @@ -742,14 +742,14 @@ void Basic_generator_plugin::generateLines() if(!is_2d && list.size()%3!=0){ QMessageBox *msgBox = new QMessageBox; msgBox->setWindowTitle("Error"); - msgBox->setText("ERROR : Input should consists of triplets."); + msgBox->setText("ERROR : Input should consist of triplets."); msgBox->exec(); return false; } else if(is_2d && list.size()%2!=0){ QMessageBox *msgBox = new QMessageBox; msgBox->setWindowTitle("Error"); - msgBox->setText("ERROR : Input should consists of pairs."); + msgBox->setText("ERROR : Input should consist of pairs."); msgBox->exec(); return false; } @@ -912,7 +912,7 @@ void Basic_generator_plugin::generateGrid() if (list.size()!=6){ QMessageBox *msgBox = new QMessageBox; msgBox->setWindowTitle("Error"); - msgBox->setText("ERROR : Input should consists of 6 doubles."); + msgBox->setText("ERROR : Input should consist of 6 doubles."); msgBox->exec(); return; } diff --git a/Lab/demo/Lab/Plugins/PCA/Basic_generator_widget.ui b/Lab/demo/Lab/Plugins/PCA/Basic_generator_widget.ui index eed6885a04c..f749ca97ab7 100644 --- a/Lab/demo/Lab/Plugins/PCA/Basic_generator_widget.ui +++ b/Lab/demo/Lab/Plugins/PCA/Basic_generator_widget.ui @@ -18,7 +18,7 @@ - 4 + 6 @@ -43,7 +43,7 @@ - Qt::Vertical + Qt::Orientation::Vertical @@ -180,7 +180,7 @@ QGroupBox::title { - Qt::RightToLeft + Qt::LayoutDirection::RightToLeft @@ -198,7 +198,7 @@ QGroupBox::title { - Qt::Vertical + Qt::Orientation::Vertical @@ -232,7 +232,7 @@ QGroupBox::title { - Qt::Vertical + Qt::Orientation::Vertical @@ -315,7 +315,7 @@ QGroupBox::title { - Qt::Vertical + Qt::Orientation::Vertical @@ -349,7 +349,7 @@ QGroupBox::title { - Qt::Vertical + Qt::Orientation::Vertical @@ -495,7 +495,7 @@ QGroupBox::title { - Qt::RightToLeft + Qt::LayoutDirection::RightToLeft @@ -513,7 +513,7 @@ QGroupBox::title { - Qt::Vertical + Qt::Orientation::Vertical @@ -880,7 +880,7 @@ p, li { white-space: pre-wrap; } hr { height: 1px; border-width: 0; } li.unchecked::marker { content: "\2610"; } li.checked::marker { content: "\2612"; } -</style></head><body style=" font-family:'Segoe UI'; font-size:9pt; font-weight:400; font-style:normal;"> +</style></head><body style=" font-family:'Cantarell'; font-size:11pt; font-weight:400; font-style:normal;"> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif'; font-size:10pt;"><br /></p></body></html> @@ -919,7 +919,7 @@ li.checked::marker { content: "\2612"; } - Qt::Vertical + Qt::Orientation::Vertical @@ -1045,7 +1045,7 @@ QGroupBox::title { - Qt::Vertical + Qt::Orientation::Vertical @@ -1081,7 +1081,7 @@ p, li { white-space: pre-wrap; } hr { height: 1px; border-width: 0; } li.unchecked::marker { content: "\2610"; } li.checked::marker { content: "\2612"; } -</style></head><body style=" font-family:'Segoe UI'; font-size:9pt; font-weight:400; font-style:normal;"> +</style></head><body style=" font-family:'Cantarell'; font-size:11pt; font-weight:400; font-style:normal;"> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif'; font-size:10pt;"><br /></p></body></html> @@ -1149,7 +1149,7 @@ p, li { white-space: pre-wrap; } hr { height: 1px; border-width: 0; } li.unchecked::marker { content: "\2610"; } li.checked::marker { content: "\2612"; } -</style></head><body style=" font-family:'Segoe UI'; font-size:9pt; font-weight:400; font-style:normal;"> +</style></head><body style=" font-family:'Cantarell'; font-size:11pt; font-weight:400; font-style:normal;"> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif'; font-size:10pt;"><br /></p></body></html> @@ -1167,7 +1167,7 @@ li.checked::marker { content: "\2612"; } - Qt::Vertical + Qt::Orientation::Vertical @@ -1206,7 +1206,7 @@ li.checked::marker { content: "\2612"; } - Qt::Horizontal + Qt::Orientation::Horizontal diff --git a/Lab/demo/Lab/Plugins/PMP/Selection_plugin.cpp b/Lab/demo/Lab/Plugins/PMP/Selection_plugin.cpp index 864c5dc1eed..6daad328b43 100644 --- a/Lab/demo/Lab/Plugins/PMP/Selection_plugin.cpp +++ b/Lab/demo/Lab/Plugins/PMP/Selection_plugin.cpp @@ -210,6 +210,7 @@ public: connect(ui_widget.Select_sharp_edges_button, SIGNAL(clicked()), this, SLOT(on_Select_sharp_edges_button_clicked())); connect(ui_widget.selectionOrEuler, SIGNAL(currentChanged(int)), this, SLOT(on_SelectionOrEuler_changed(int))); connect(ui_widget.editionBox, SIGNAL(currentIndexChanged(int)), this, SLOT(on_editionBox_changed(int))); + connect(ui_widget.movePoint_pushButton, SIGNAL(clicked()), this, SLOT(on_movePoint_pushButton_clicked())); ui_widget.Sharp_edges_label->hide(); ui_widget.Sharp_angle_spinbox->hide(); @@ -987,6 +988,10 @@ public Q_SLOTS: { Q_EMIT set_operation_mode(mode); } + + ui_widget.movePointCoordinates_textEdit->setVisible(false); + ui_widget.movePoint_pushButton->setVisible(false); + switch(mode) { //Join vertex @@ -1043,12 +1048,79 @@ public Q_SLOTS: ui_widget.docImage_Label->setPixmap(pm); break; } + // Move point + case 12: + { + ui_widget.docImage_Label->clear(); + ui_widget.movePointCoordinates_textEdit->setVisible(true); + ui_widget.movePoint_pushButton->setVisible(true); + ui_widget.movePoint_pushButton->setEnabled(true); + break; + } default: ui_widget.docImage_Label->clear(); break; } on_LassoCheckBox_changed(ui_widget.lassoCheckBox->isChecked()); } + + void on_movePoint_pushButton_clicked() + { + QString text = ui_widget.movePointCoordinates_textEdit->toPlainText(); + Scene_points_with_normal_item* item = new Scene_points_with_normal_item(); + QStringList list = text.split(QRegularExpression("\\s+"), CGAL_QT_SKIP_EMPTY_PARTS); + int counter = 0; + double coord[3]; + bool ok = true; + if (list.isEmpty()) return; + if (list.size() != 3){ + QMessageBox *msgBox = new QMessageBox; + msgBox->setWindowTitle("Error"); + msgBox->setText("ERROR : Input should consist of a triplet."); + msgBox->exec(); + return; + } + + for(QString s : list) + { + if(!s.isEmpty()) + { + double res = s.toDouble(&ok); + if(!ok) + { + QMessageBox *msgBox = new QMessageBox; + msgBox->setWindowTitle("Error"); + msgBox->setText("ERROR : Coordinates are invalid."); + msgBox->exec(); + break; + } + else + { + coord[counter++] = res; + } + } + } + + if(counter == 3) + { + const Kernel::Point_3 p(coord[0], coord[1], coord[2]); + item->point_set()->insert(p); + counter = 0; + + ui_widget.movePointCoordinates_textEdit->clear(); + + Scene_polyhedron_selection_item* selection_item = getSelectedItem(); + if(!selection_item) + selection_item = onTheFlyItem(); + if (!selection_item) { + print_message("Error: there is no selected polyhedron selection item!"); + return; + } + + selection_item->moveVertex(p); + } + } + void on_Select_sharp_edges_button_clicked() { Scene_polyhedron_selection_item* selection_item = getSelectedItem(); if(!selection_item) diff --git a/Lab/demo/Lab/Plugins/PMP/Selection_widget.ui b/Lab/demo/Lab/Plugins/PMP/Selection_widget.ui index f7cf53070eb..5a9dce0a662 100644 --- a/Lab/demo/Lab/Plugins/PMP/Selection_widget.ui +++ b/Lab/demo/Lab/Plugins/PMP/Selection_widget.ui @@ -7,7 +7,7 @@ 0 0 630 - 532 + 579 @@ -46,7 +46,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal @@ -176,7 +176,7 @@ - Qt::Vertical + Qt::Orientation::Vertical @@ -200,7 +200,7 @@ - Qt::Vertical + Qt::Orientation::Vertical @@ -218,7 +218,7 @@ Sharp edges angle: - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter @@ -274,7 +274,7 @@ - Qt::Vertical + Qt::Orientation::Vertical @@ -294,7 +294,7 @@ - Qt::Vertical + Qt::Orientation::Vertical @@ -367,7 +367,7 @@ - Qt::Vertical + Qt::Orientation::Vertical @@ -386,7 +386,7 @@ - Qt::Vertical + Qt::Orientation::Vertical @@ -479,7 +479,7 @@ - Qt::Vertical + Qt::Orientation::Vertical @@ -572,20 +572,7 @@ - - - Qt::Vertical - - - - 20 - 40 - - - - - - + @@ -664,6 +651,29 @@ + + + + true + + + + 0 + 0 + + + + New Coordinates: X Y Z + + + + + + + Apply move + + + @@ -671,15 +681,28 @@ - - - - Ctrl+Z to cancel the temporary selection. Ctrl+U to undo last operation (if applicable). - - - + + + + Ctrl+Z to cancel the temporary selection. Ctrl+U to undo last operation (if applicable). + + + + + + + Qt::Orientation::Vertical + + + + 20 + 40 + + + + @@ -690,7 +713,7 @@ - Qt::Vertical + Qt::Orientation::Vertical diff --git a/Lab/demo/Lab/Scene_polyhedron_selection_item.cpp b/Lab/demo/Lab/Scene_polyhedron_selection_item.cpp index 29769c95ae4..a00454c375b 100644 --- a/Lab/demo/Lab/Scene_polyhedron_selection_item.cpp +++ b/Lab/demo/Lab/Scene_polyhedron_selection_item.cpp @@ -1056,7 +1056,7 @@ bool Scene_polyhedron_selection_item::treat_selection(const std::setoffset(); + fg_vertex_descriptor vh = *temp_selected_vertices.begin(); + + VPmap vpm = get(CGAL::vertex_point,*polyhedron()); + put(vpm, vh, Point_3(new_position.x() - offset.x, + new_position.y() - offset.y, + new_position.z() - offset.z)); + const Point_3& p = get(vpm,vh); + d->manipulated_frame->setPosition(p.x()+offset.x, p.y()+offset.y, p.z()+offset.z); + setProperty("need_invalidate_aabb_tree", true); + invalidateOpenGLBuffers(); + poly_item->updateVertex(vh); + // poly_item->invalidateOpenGLBuffers(); +} + void Scene_polyhedron_selection_item::validateMoveVertex() { temp_selected_vertices.clear(); diff --git a/Lab/demo/Lab/Scene_polyhedron_selection_item.h b/Lab/demo/Lab/Scene_polyhedron_selection_item.h index 9467e26b782..23af5a1cfee 100644 --- a/Lab/demo/Lab/Scene_polyhedron_selection_item.h +++ b/Lab/demo/Lab/Scene_polyhedron_selection_item.h @@ -917,6 +917,7 @@ public Q_SLOTS: void updateTick(); void moveVertex(); + void moveVertex(const Point_3&); protected: bool eventFilter(QObject* /*target*/, QEvent * gen_event) { diff --git a/Lab/demo/Lab/Viewer.cpp b/Lab/demo/Lab/Viewer.cpp index b93cb2cb7b1..00e98fa2b88 100644 --- a/Lab/demo/Lab/Viewer.cpp +++ b/Lab/demo/Lab/Viewer.cpp @@ -1838,7 +1838,7 @@ void Viewer::setLighting() if (list.size()!=3){ QMessageBox *msgBox = new QMessageBox; msgBox->setWindowTitle("Error"); - msgBox->setText("ERROR : Input should consists of 3 floats."); + msgBox->setText("ERROR : Input should consist of 3 floats."); msgBox->exec(); return; } diff --git a/Triangulation_on_sphere_2/demo/Triangulation_on_sphere_2/main.cpp b/Triangulation_on_sphere_2/demo/Triangulation_on_sphere_2/main.cpp index 71cae05953d..1579f45389a 100644 --- a/Triangulation_on_sphere_2/demo/Triangulation_on_sphere_2/main.cpp +++ b/Triangulation_on_sphere_2/demo/Triangulation_on_sphere_2/main.cpp @@ -69,7 +69,7 @@ public slots: if (list.size()!=4){ QMessageBox *msgBox = new QMessageBox; msgBox->setWindowTitle("Error"); - msgBox->setText("ERROR : Input should consists of 4 doubles: The radius first, then the coordinates of the center."); + msgBox->setText("ERROR : Input should consist of 4 doubles: The radius first, then the coordinates of the center."); msgBox->exec(); return; }