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()
{
typename Facegraph_item::Face_graph tetrahedron;
if (dock_widget->tabWidget->currentIndex() == 0)
{
QString point_texts[4];
Point points[4];
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[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);
if (list.isEmpty()) return;
if (list.size()!=3){
QMessageBox *msgBox = new QMessageBox;
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)
for (int j = 0; j < 3; ++j)
{
bool ok;
coords[j] = list.at(j).toDouble(&ok);
if(!ok)
if (!ok)
{
QMessageBox *msgBox = new QMessageBox;
QMessageBox* msgBox = new QMessageBox;
msgBox->setWindowTitle("Error");
msgBox->setText("ERROR : Coordinates are invalid.");
msgBox->exec();
@ -630,6 +631,36 @@ void Basic_generator_plugin::generateTetrahedron()
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 : 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);
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,22 +755,25 @@ 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="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;
@ -789,7 +792,14 @@ QGroupBox::title {
</property>
<layout class="QVBoxLayout" name="verticalLayout_13">
<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">
<widget class="QLabel" name="label_22">
<property name="text">
@ -797,27 +807,6 @@ QGroupBox::title {
</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">
@ -832,6 +821,20 @@ QGroupBox::title {
</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">
@ -839,10 +842,10 @@ QGroupBox::title {
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="tetP3">
<item row="2" column="1">
<widget class="QLineEdit" name="tetP2">
<property name="text">
<string>0.0 0.0 1.0</string>
<string>0.0 1.0 0.0</string>
</property>
</widget>
</item>
@ -850,19 +853,42 @@ QGroupBox::title {
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
</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="sizeHint" stdset="0">
<size>
<width>20</width>
<height>110</height>
</size>
<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>
</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>
</layout>
</item>
@ -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>