Make it possible to enter target coordinates in Selection item's "Move Point"

This commit is contained in:
Mael Rouxel-Labbé 2025-02-26 00:11:08 +01:00
parent 299a89f212
commit ab082b29f1
8 changed files with 175 additions and 62 deletions

View File

@ -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;
}

View File

@ -18,7 +18,7 @@
<item>
<widget class="QTabWidget" name="selector_tabWidget">
<property name="currentIndex">
<number>4</number>
<number>6</number>
</property>
<widget class="QWidget" name="prismTab">
<attribute name="title">
@ -43,7 +43,7 @@
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -180,7 +180,7 @@ QGroupBox::title {
<item>
<widget class="QCheckBox" name="prismCheckBox">
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
<enum>Qt::LayoutDirection::RightToLeft</enum>
</property>
<property name="text">
<string/>
@ -198,7 +198,7 @@ QGroupBox::title {
<item>
<spacer name="verticalSpacer_7">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -232,7 +232,7 @@ QGroupBox::title {
<item>
<spacer name="verticalSpacer_9">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -315,7 +315,7 @@ QGroupBox::title {
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -349,7 +349,7 @@ QGroupBox::title {
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -495,7 +495,7 @@ QGroupBox::title {
<item>
<widget class="QCheckBox" name="pyramidCheckBox">
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
<enum>Qt::LayoutDirection::RightToLeft</enum>
</property>
<property name="text">
<string/>
@ -513,7 +513,7 @@ QGroupBox::title {
<item>
<spacer name="verticalSpacer_6">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -880,7 +880,7 @@ p, li { white-space: pre-wrap; }
hr { height: 1px; border-width: 0; }
li.unchecked::marker { content: &quot;\2610&quot;; }
li.checked::marker { content: &quot;\2612&quot;; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Segoe UI'; font-size:9pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Cantarell'; font-size:11pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot;-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;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="overwriteMode">
@ -919,7 +919,7 @@ li.checked::marker { content: &quot;\2612&quot;; }
<item>
<spacer name="verticalSpacer_10">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -1045,7 +1045,7 @@ QGroupBox::title {
<item>
<spacer name="verticalSpacer_11">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -1081,7 +1081,7 @@ p, li { white-space: pre-wrap; }
hr { height: 1px; border-width: 0; }
li.unchecked::marker { content: &quot;\2610&quot;; }
li.checked::marker { content: &quot;\2612&quot;; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Segoe UI'; font-size:9pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Cantarell'; font-size:11pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot;-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;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="overwriteMode">
@ -1149,7 +1149,7 @@ p, li { white-space: pre-wrap; }
hr { height: 1px; border-width: 0; }
li.unchecked::marker { content: &quot;\2610&quot;; }
li.checked::marker { content: &quot;\2612&quot;; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Segoe UI'; font-size:9pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Cantarell'; font-size:11pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot;-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;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="overwriteMode">
@ -1167,7 +1167,7 @@ li.checked::marker { content: &quot;\2612&quot;; }
<item>
<spacer name="verticalSpacer_5">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -1206,7 +1206,7 @@ li.checked::marker { content: &quot;\2612&quot;; }
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>

View File

@ -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<Scene_polyhedron_selection_item>();
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<Scene_polyhedron_selection_item>();
if(!selection_item)

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>630</width>
<height>532</height>
<height>579</height>
</rect>
</property>
<property name="windowTitle">
@ -46,7 +46,7 @@
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -176,7 +176,7 @@
<item>
<spacer name="verticalSpacer_5">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -200,7 +200,7 @@
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -218,7 +218,7 @@
<string>Sharp edges angle:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
</property>
</widget>
</item>
@ -274,7 +274,7 @@
<item>
<spacer name="verticalSpacer_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -294,7 +294,7 @@
<item>
<spacer name="verticalSpacer_7">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -367,7 +367,7 @@
<item>
<spacer name="verticalSpacer_6">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -386,7 +386,7 @@
<item>
<spacer name="verticalSpacer_10">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -479,7 +479,7 @@
<item>
<spacer name="verticalSpacer_8">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -572,20 +572,7 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout_8">
<item>
<spacer name="verticalSpacer_9">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_9" stretch="0,1,0,0">
<layout class="QVBoxLayout" name="verticalLayout_9" stretch="0,1,0,0,0">
<item>
<widget class="QComboBox" name="editionBox">
<item>
@ -664,6 +651,29 @@
</property>
</widget>
</item>
<item>
<widget class="QTextEdit" name="movePointCoordinates_textEdit">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="placeholderText">
<string>New Coordinates: X Y Z</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="movePoint_pushButton">
<property name="text">
<string>Apply move</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="docImage_Label">
<property name="text">
@ -671,6 +681,8 @@
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="label_4">
<property name="text">
@ -678,7 +690,18 @@
</property>
</widget>
</item>
</layout>
<item>
<spacer name="verticalSpacer_9">
<property name="orientation">
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
@ -690,7 +713,7 @@
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>

View File

@ -1056,7 +1056,7 @@ bool Scene_polyhedron_selection_item::treat_selection(const std::set<fg_vertex_d
setProperty("need_invalidate_aabb_tree", false);
}
invalidateOpenGLBuffers();
Q_EMIT updateInstructions("Ctrl+Right-click to move the point. \nHit Ctrl+Z to leave the selection. (2/2)");
Q_EMIT updateInstructions("Hold Ctrl+Right-click to move the vertex, or enter new coordinates below.\nHit Ctrl+Z to deselect the vertex. (2/2)");
}
else
{
@ -1980,6 +1980,23 @@ void Scene_polyhedron_selection_item::moveVertex()
}
}
void Scene_polyhedron_selection_item::moveVertex(const Point_3& new_position)
{
const CGAL::qglviewer::Vec offset = Three::mainViewer()->offset();
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();

View File

@ -917,6 +917,7 @@ public Q_SLOTS:
void updateTick();
void moveVertex();
void moveVertex(const Point_3&);
protected:
bool eventFilter(QObject* /*target*/, QEvent * gen_event)
{

View File

@ -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;
}

View File

@ -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;
}