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,7 +590,8 @@ template<class Facegraph_item>
void Basic_generator_plugin::generateTetrahedron() void Basic_generator_plugin::generateTetrahedron()
{ {
typename Facegraph_item::Face_graph tetrahedron; typename Facegraph_item::Face_graph tetrahedron;
if (dock_widget->tabWidget->currentIndex() == 0)
{
QString point_texts[4]; QString point_texts[4];
Point points[4]; Point points[4];
point_texts[0] = dock_widget->tetP0->text(); point_texts[0] = dock_widget->tetP0->text();
@ -598,25 +599,25 @@ void Basic_generator_plugin::generateTetrahedron()
point_texts[2] = dock_widget->tetP2->text(); point_texts[2] = dock_widget->tetP2->text();
point_texts[3] = dock_widget->tetP3->text(); point_texts[3] = dock_widget->tetP3->text();
for(int i=0; i<4; ++i) for (int i = 0; i < 4; ++i)
{ {
QStringList list = point_texts[i].split(QRegExp("\\s+"), CGAL_QT_SKIP_EMPTY_PARTS); QStringList list = point_texts[i].split(QRegExp("\\s+"), CGAL_QT_SKIP_EMPTY_PARTS);
if (list.isEmpty()) return; if (list.isEmpty()) return;
if (list.size()!=3){ if (list.size() != 3) {
QMessageBox *msgBox = new QMessageBox; QMessageBox* msgBox = new QMessageBox;
msgBox->setWindowTitle("Error"); msgBox->setWindowTitle("Error");
msgBox->setText("ERROR : Input should consists of 3 doubles."); msgBox->setText("ERROR : Input should consists of 3 doubles.");
msgBox->exec(); msgBox->exec();
return; return;
} }
double coords[3]; double coords[3];
for(int j=0; j<3; ++j) for (int j = 0; j < 3; ++j)
{ {
bool ok; bool ok;
coords[j] = list.at(j).toDouble(&ok); coords[j] = list.at(j).toDouble(&ok);
if(!ok) if (!ok)
{ {
QMessageBox *msgBox = new QMessageBox; QMessageBox* msgBox = new QMessageBox;
msgBox->setWindowTitle("Error"); msgBox->setWindowTitle("Error");
msgBox->setText("ERROR : Coordinates are invalid."); msgBox->setText("ERROR : Coordinates are invalid.");
msgBox->exec(); msgBox->exec();
@ -630,6 +631,36 @@ void Basic_generator_plugin::generateTetrahedron()
points[2], points[2],
points[3], points[3],
tetrahedron); 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 : Input should consists of 3 doubles.");
msgBox->exec();
return;
}
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;
}
}
}
Facegraph_item* tet_item = new Facegraph_item(tetrahedron); Facegraph_item* tet_item = new Facegraph_item(tetrahedron);
tet_item->setName(dock_widget->name_lineEdit->text()); tet_item->setName(dock_widget->name_lineEdit->text());

View File

@ -18,7 +18,7 @@
<item> <item>
<widget class="QTabWidget" name="selector_tabWidget"> <widget class="QTabWidget" name="selector_tabWidget">
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>4</number>
</property> </property>
<widget class="QWidget" name="prismTab"> <widget class="QWidget" name="prismTab">
<attribute name="title"> <attribute name="title">
@ -755,22 +755,25 @@ QGroupBox::title {
</widget> </widget>
</item> </item>
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout_12" stretch="1,0,1"> <layout class="QVBoxLayout" name="verticalLayout_12" stretch="0">
<item> <item>
<spacer name="verticalSpacer_8"> <widget class="QTabWidget" name="tabWidget">
<property name="orientation"> <property name="currentIndex">
<enum>Qt::Vertical</enum> <number>1</number>
</property> </property>
<property name="sizeHint" stdset="0"> <widget class="QWidget" name="tetraTab">
<size> <attribute name="title">
<width>20</width> <string>Tetrahedron</string>
<height>40</height> </attribute>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QGroupBox" name="groupBox_3"> <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"> <property name="styleSheet">
<string notr="true">QGroupBox { <string notr="true">QGroupBox {
border: 1px solid gray; border: 1px solid gray;
@ -789,7 +792,14 @@ QGroupBox::title {
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_13"> <layout class="QVBoxLayout" name="verticalLayout_13">
<item> <item>
<layout class="QGridLayout" name="gridLayout_3" columnstretch="0,1"> <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"> <item row="1" column="0">
<widget class="QLabel" name="label_22"> <widget class="QLabel" name="label_22">
<property name="text"> <property name="text">
@ -797,27 +807,6 @@ QGroupBox::title {
</property> </property>
</widget> </widget>
</item> </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"> <item row="0" column="0">
<widget class="QLabel" name="label_6"> <widget class="QLabel" name="label_6">
<property name="text"> <property name="text">
@ -832,6 +821,20 @@ QGroupBox::title {
</property> </property>
</widget> </widget>
</item> </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"> <item row="3" column="0">
<widget class="QLabel" name="label_24"> <widget class="QLabel" name="label_24">
<property name="text"> <property name="text">
@ -839,10 +842,10 @@ QGroupBox::title {
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="1"> <item row="2" column="1">
<widget class="QLineEdit" name="tetP3"> <widget class="QLineEdit" name="tetP2">
<property name="text"> <property name="text">
<string>0.0 0.0 1.0</string> <string>0.0 1.0 0.0</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -850,19 +853,42 @@ QGroupBox::title {
</item> </item>
</layout> </layout>
</widget> </widget>
</item> </widget>
<item> <widget class="QWidget" name="tetraTab">
<spacer name="verticalSpacer_4"> <attribute name="title">
<property name="orientation"> <string>Bbox</string>
<enum>Qt::Vertical</enum> </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>
<property name="sizeHint" stdset="0"> <property name="toolTip">
<size> <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>
<width>20</width>
<height>110</height>
</size>
</property> </property>
</spacer> <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>
</layout> </layout>
</item> </item>
@ -1046,11 +1072,14 @@ QGroupBox::title {
</sizepolicy> </sizepolicy>
</property> </property>
<property name="html"> <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; <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;style type=&quot;text/css&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; } 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; hr { height: 1px; border-width: 0; }
&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> 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>
<property name="overwriteMode"> <property name="overwriteMode">
<bool>false</bool> <bool>false</bool>
@ -1094,11 +1123,14 @@ p, li { white-space: pre-wrap; }
</sizepolicy> </sizepolicy>
</property> </property>
<property name="html"> <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; <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;style type=&quot;text/css&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; } 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; hr { height: 1px; border-width: 0; }
&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> 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>
<property name="overwriteMode"> <property name="overwriteMode">
<bool>false</bool> <bool>false</bool>