From 455f625e8a3a399a94f72b5be9bc02507996ae22 Mon Sep 17 00:00:00 2001 From: Priyansh Jalan <28981026+PriyanshJalan@users.noreply.github.com> Date: Fri, 24 Mar 2023 11:07:18 +0000 Subject: [PATCH] Polyhedron demo object generator tetrahedron -added UI and half logic part --- .../Plugins/PCA/Basic_generator_plugin.cpp | 97 ++++--- .../Plugins/PCA/Basic_generator_widget.ui | 236 ++++++++++-------- 2 files changed, 198 insertions(+), 135 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/Plugins/PCA/Basic_generator_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PCA/Basic_generator_plugin.cpp index 8bf98735fc4..2561811eaf7 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PCA/Basic_generator_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PCA/Basic_generator_plugin.cpp @@ -590,46 +590,77 @@ template void Basic_generator_plugin::generateTetrahedron() { typename Facegraph_item::Face_graph tetrahedron; - - QString point_texts[4]; - Point points[4]; - point_texts[0] = dock_widget->tetP0->text(); - point_texts[1] = dock_widget->tetP1->text(); - point_texts[2] = dock_widget->tetP2->text(); - point_texts[3] = dock_widget->tetP3->text(); - - for(int i=0; i<4; ++i) + if (dock_widget->tabWidget->currentIndex() == 0) { - QStringList list = point_texts[i].split(QRegExp("\\s+"), CGAL_QT_SKIP_EMPTY_PARTS); - if (list.isEmpty()) return; - if (list.size()!=3){ - QMessageBox *msgBox = new QMessageBox; - msgBox->setWindowTitle("Error"); - msgBox->setText("ERROR : Input should consists of 3 doubles."); - msgBox->exec(); - return; - } - double coords[3]; - for(int j=0; j<3; ++j) - { - bool ok; - coords[j] = list.at(j).toDouble(&ok); - if(!ok) + QString point_texts[4]; + Point points[4]; + point_texts[0] = dock_widget->tetP0->text(); + point_texts[1] = dock_widget->tetP1->text(); + point_texts[2] = dock_widget->tetP2->text(); + point_texts[3] = dock_widget->tetP3->text(); + + for (int i = 0; i < 4; ++i) { - QMessageBox *msgBox = new QMessageBox; + QStringList list = point_texts[i].split(QRegExp("\\s+"), CGAL_QT_SKIP_EMPTY_PARTS); + if (list.isEmpty()) return; + if (list.size() != 3) { + QMessageBox* msgBox = new QMessageBox; + msgBox->setWindowTitle("Error"); + msgBox->setText("ERROR : Input should consists of 3 doubles."); + msgBox->exec(); + return; + } + double coords[3]; + for (int j = 0; j < 3; ++j) + { + bool ok; + coords[j] = list.at(j).toDouble(&ok); + if (!ok) + { + QMessageBox* msgBox = new QMessageBox; + msgBox->setWindowTitle("Error"); + msgBox->setText("ERROR : Coordinates are invalid."); + msgBox->exec(); + return; + } + } + points[i] = Point(coords[0], coords[1], coords[2]); + } + CGAL::make_tetrahedron(points[0], + points[1], + points[2], + points[3], + tetrahedron); + } + else + { + QString text = dock_widget->extremaEdit_2->text(); + QStringList list = text.split(QRegExp("\\s+"), CGAL_QT_SKIP_EMPTY_PARTS); + if (list.isEmpty()) return; + if (list.size() != 3) { + QMessageBox* msgBox = new QMessageBox; msgBox->setWindowTitle("Error"); - msgBox->setText("ERROR : Coordinates are invalid."); + msgBox->setText("ERROR : Input should consists of 3 doubles."); msgBox->exec(); return; } - } - points[i] = Point(coords[0], coords[1], coords[2]); + + for (int i = 0; i < 3; ++i) + { + bool ok; + list.at(i).toDouble(&ok); + if (!ok) + { + QMessageBox* msgBox = new QMessageBox; + msgBox->setWindowTitle("Error"); + msgBox->setText("ERROR : Coordinates are invalid."); + msgBox->exec(); + return; + } + } + + } - CGAL::make_tetrahedron(points[0], - points[1], - points[2], - points[3], - tetrahedron); Facegraph_item* tet_item = new Facegraph_item(tetrahedron); tet_item->setName(dock_widget->name_lineEdit->text()); diff --git a/Polyhedron/demo/Polyhedron/Plugins/PCA/Basic_generator_widget.ui b/Polyhedron/demo/Polyhedron/Plugins/PCA/Basic_generator_widget.ui index f2839e20f06..2ee7ceac420 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PCA/Basic_generator_widget.ui +++ b/Polyhedron/demo/Polyhedron/Plugins/PCA/Basic_generator_widget.ui @@ -18,7 +18,7 @@ - 0 + 4 @@ -755,24 +755,27 @@ QGroupBox::title { - + - - - Qt::Vertical + + + 1 - - - 20 - 40 - - - - - - - - QGroupBox { + + + Tetrahedron + + + + + 0 + 30 + 477 + 144 + + + + QGroupBox { border: 1px solid gray; border-radius: 9px; margin-top: 0.5em; @@ -783,87 +786,110 @@ QGroupBox::title { left: 10px; padding: 0 3px 0 3px; } - - - - - - - - - - - P1 - - - - - - - 1.0 0.0 0.0 - - - - - - - 0.0 1.0 0.0 - - - - - - - 0.0 0.0 0.0 - - - - - - - P0 - - - - - - - P2 - - - - - - - P3 - - - - - - - 0.0 0.0 1.0 - - + + + + + + + + + + + 0.0 0.0 1.0 + + + + + + + P1 + + + + + + + P0 + + + + + + + P2 + + + + + + + 0.0 0.0 0.0 + + + + + + + 1.0 0.0 0.0 + + + + + + + P3 + + + + + + + 0.0 1.0 0.0 + + + + - - + + + + + Bbox + + + + + 8 + 9 + 46 + 207 + + + + <html><head/><body><p>Coordinates of the minimum and the maximum of the Bbox.</p></body></html> + + + Extrema: + + + + + + 60 + 100 + 401 + 24 + + + + 1.0 1.0 1.0 + + + - - - - Qt::Vertical - - - - 20 - 110 - - - - @@ -1046,11 +1072,14 @@ QGroupBox::title { - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "https://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><meta charset="utf-8" /><style type="text/css"> p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; 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-size:10pt;"><br /></p></body></html> +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;"> +<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> false @@ -1094,11 +1123,14 @@ p, li { white-space: pre-wrap; } - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "https://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><meta charset="utf-8" /><style type="text/css"> p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; 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-size:10pt;"><br /></p></body></html> +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;"> +<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> false