Polyhedron demo object generator tetrahedron -added UI and half logic part

This commit is contained in:
Priyansh Jalan 2023-03-24 11:07:18 +00:00
parent 04b5104b5b
commit 455f625e8a
2 changed files with 198 additions and 135 deletions

View File

@ -590,46 +590,77 @@ template<class Facegraph_item>
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());

View File

@ -18,7 +18,7 @@
<item>
<widget class="QTabWidget" name="selector_tabWidget">
<property name="currentIndex">
<number>0</number>
<number>4</number>
</property>
<widget class="QWidget" name="prismTab">
<attribute name="title">
@ -755,24 +755,27 @@ QGroupBox::title {
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_12" stretch="1,0,1">
<layout class="QVBoxLayout" name="verticalLayout_12" stretch="0">
<item>
<spacer name="verticalSpacer_8">
<property name="orientation">
<enum>Qt::Vertical</enum>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>1</number>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="styleSheet">
<string notr="true">QGroupBox {
<widget class="QWidget" name="tetraTab">
<attribute name="title">
<string>Tetrahedron</string>
</attribute>
<widget class="QGroupBox" name="groupBox_3">
<property name="geometry">
<rect>
<x>0</x>
<y>30</y>
<width>477</width>
<height>144</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">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;
}</string>
</property>
<property name="title">
<string/>
</property>
<layout class="QVBoxLayout" name="verticalLayout_13">
<item>
<layout class="QGridLayout" name="gridLayout_3" columnstretch="0,1">
<item row="1" column="0">
<widget class="QLabel" name="label_22">
<property name="text">
<string>P1</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="tetP1">
<property name="text">
<string>1.0 0.0 0.0</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="tetP2">
<property name="text">
<string>0.0 1.0 0.0</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="tetP0">
<property name="text">
<string>0.0 0.0 0.0</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>P0</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_23">
<property name="text">
<string>P2</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_24">
<property name="text">
<string>P3</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="tetP3">
<property name="text">
<string>0.0 0.0 1.0</string>
</property>
</widget>
</property>
<property name="title">
<string/>
</property>
<layout class="QVBoxLayout" name="verticalLayout_13">
<item>
<layout class="QGridLayout" name="gridLayout_3" columnstretch="0,0">
<item row="3" column="1">
<widget class="QLineEdit" name="tetP3">
<property name="text">
<string>0.0 0.0 1.0</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_22">
<property name="text">
<string>P1</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>P0</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_23">
<property name="text">
<string>P2</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="tetP0">
<property name="text">
<string>0.0 0.0 0.0</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="tetP1">
<property name="text">
<string>1.0 0.0 0.0</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_24">
<property name="text">
<string>P3</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="tetP2">
<property name="text">
<string>0.0 1.0 0.0</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
<widget class="QWidget" name="tetraTab">
<attribute name="title">
<string>Bbox</string>
</attribute>
<widget class="QLabel" name="label_33">
<property name="geometry">
<rect>
<x>8</x>
<y>9</y>
<width>46</width>
<height>207</height>
</rect>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Coordinates of the minimum and the maximum of the Bbox.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Extrema:</string>
</property>
</widget>
<widget class="QLineEdit" name="extremaEdit_2">
<property name="geometry">
<rect>
<x>60</x>
<y>100</y>
<width>401</width>
<height>24</height>
</rect>
</property>
<property name="text">
<string>1.0 1.0 1.0</string>
</property>
</widget>
</widget>
</widget>
</item>
<item>
<spacer name="verticalSpacer_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>110</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
@ -1046,11 +1072,14 @@ QGroupBox::title {
</sizepolicy>
</property>
<property name="html">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;https://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;meta charset=&quot;utf-8&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans Serif'; font-size:9pt; 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-size:10pt;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
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;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">
<bool>false</bool>
@ -1094,11 +1123,14 @@ p, li { white-space: pre-wrap; }
</sizepolicy>
</property>
<property name="html">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;https://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;meta charset=&quot;utf-8&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans Serif'; font-size:9pt; 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-size:10pt;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
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;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">
<bool>false</bool>