- Added distance and quadrant

- added line distance to drawn lines
This commit is contained in:
bklronin 2024-06-26 17:42:13 +02:00
parent ac9176fbd3
commit 3e85a11787
4 changed files with 251 additions and 197 deletions

183
Gui.py
View File

@ -24,14 +24,14 @@ class Ui_fluencyCAD(object):
def setupUi(self, fluencyCAD):
if not fluencyCAD.objectName():
fluencyCAD.setObjectName(u"fluencyCAD")
fluencyCAD.resize(1755, 685)
fluencyCAD.resize(2214, 803)
self.centralwidget = QWidget(fluencyCAD)
self.centralwidget.setObjectName(u"centralwidget")
self.gridLayout = QGridLayout(self.centralwidget)
self.gridLayout.setObjectName(u"gridLayout")
self.InputTab = QTabWidget(self.centralwidget)
self.InputTab.setObjectName(u"InputTab")
sizePolicy = QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Preferred)
sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.InputTab.sizePolicy().hasHeightForWidth())
@ -79,61 +79,15 @@ class Ui_fluencyCAD(object):
self.InputTab.addTab(self.code_tab, "")
self.gridLayout.addWidget(self.InputTab, 0, 2, 8, 1)
self.groupBox = QGroupBox(self.centralwidget)
self.groupBox.setObjectName(u"groupBox")
self.gridLayout_3 = QGridLayout(self.groupBox)
self.gridLayout_3.setObjectName(u"gridLayout_3")
self.pb_extrdop = QPushButton(self.groupBox)
self.pb_extrdop.setObjectName(u"pb_extrdop")
self.gridLayout_3.addWidget(self.pb_extrdop, 0, 0, 1, 1)
self.pb_cutop = QPushButton(self.groupBox)
self.pb_cutop.setObjectName(u"pb_cutop")
self.gridLayout_3.addWidget(self.pb_cutop, 0, 1, 1, 1)
self.pb_arrayop = QPushButton(self.groupBox)
self.pb_arrayop.setObjectName(u"pb_arrayop")
self.gridLayout_3.addWidget(self.pb_arrayop, 1, 0, 1, 1)
self.pb_revop = QPushButton(self.groupBox)
self.pb_revop.setObjectName(u"pb_revop")
self.gridLayout_3.addWidget(self.pb_revop, 1, 1, 1, 1)
self.gridLayout.addWidget(self.groupBox, 0, 5, 7, 1, Qt.AlignTop)
self.gl_box = QGroupBox(self.centralwidget)
self.gl_box.setObjectName(u"gl_box")
sizePolicy1 = QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding)
sizePolicy1.setHorizontalStretch(0)
sizePolicy1.setVerticalStretch(4)
sizePolicy1.setHeightForWidth(self.gl_box.sizePolicy().hasHeightForWidth())
self.gl_box.setSizePolicy(sizePolicy1)
font = QFont()
font.setPointSize(12)
self.gl_box.setFont(font)
self.horizontalLayout_4 = QHBoxLayout(self.gl_box)
#ifndef Q_OS_MAC
self.horizontalLayout_4.setSpacing(-1)
#endif
self.horizontalLayout_4.setObjectName(u"horizontalLayout_4")
self.horizontalLayout_4.setContentsMargins(12, -1, -1, -1)
self.gridLayout.addWidget(self.gl_box, 0, 4, 8, 1)
self.gridLayout.addWidget(self.InputTab, 0, 2, 11, 1)
self.groupBox_5 = QGroupBox(self.centralwidget)
self.groupBox_5.setObjectName(u"groupBox_5")
sizePolicy2 = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
sizePolicy2.setHorizontalStretch(0)
sizePolicy2.setVerticalStretch(0)
sizePolicy2.setHeightForWidth(self.groupBox_5.sizePolicy().hasHeightForWidth())
self.groupBox_5.setSizePolicy(sizePolicy2)
sizePolicy1 = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
sizePolicy1.setHorizontalStretch(0)
sizePolicy1.setVerticalStretch(0)
sizePolicy1.setHeightForWidth(self.groupBox_5.sizePolicy().hasHeightForWidth())
self.groupBox_5.setSizePolicy(sizePolicy1)
self.groupBox_5.setMaximumSize(QSize(300, 16777215))
self.verticalLayout_3 = QVBoxLayout(self.groupBox_5)
self.verticalLayout_3.setObjectName(u"verticalLayout_3")
@ -145,11 +99,11 @@ class Ui_fluencyCAD(object):
self.groupBox_6 = QGroupBox(self.groupBox_5)
self.groupBox_6.setObjectName(u"groupBox_6")
sizePolicy3 = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
sizePolicy3.setHorizontalStretch(0)
sizePolicy3.setVerticalStretch(0)
sizePolicy3.setHeightForWidth(self.groupBox_6.sizePolicy().hasHeightForWidth())
self.groupBox_6.setSizePolicy(sizePolicy3)
sizePolicy2 = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
sizePolicy2.setHorizontalStretch(0)
sizePolicy2.setVerticalStretch(0)
sizePolicy2.setHeightForWidth(self.groupBox_6.sizePolicy().hasHeightForWidth())
self.groupBox_6.setSizePolicy(sizePolicy2)
self.gridLayout_6 = QGridLayout(self.groupBox_6)
self.gridLayout_6.setObjectName(u"gridLayout_6")
self.gridLayout_6.setContentsMargins(2, 2, 2, 2)
@ -179,8 +133,8 @@ class Ui_fluencyCAD(object):
self.groupBox_8 = QGroupBox(self.groupBox_5)
self.groupBox_8.setObjectName(u"groupBox_8")
sizePolicy3.setHeightForWidth(self.groupBox_8.sizePolicy().hasHeightForWidth())
self.groupBox_8.setSizePolicy(sizePolicy3)
sizePolicy2.setHeightForWidth(self.groupBox_8.sizePolicy().hasHeightForWidth())
self.groupBox_8.setSizePolicy(sizePolicy2)
self.gridLayout_8 = QGridLayout(self.groupBox_8)
self.gridLayout_8.setObjectName(u"gridLayout_8")
self.gridLayout_8.setContentsMargins(2, 2, 2, 2)
@ -203,7 +157,7 @@ class Ui_fluencyCAD(object):
self.verticalLayout_3.addWidget(self.groupBox_8)
self.gridLayout.addWidget(self.groupBox_5, 0, 3, 8, 1)
self.gridLayout.addWidget(self.groupBox_5, 0, 3, 11, 1)
self.groupBox_4 = QGroupBox(self.centralwidget)
self.groupBox_4.setObjectName(u"groupBox_4")
@ -215,7 +169,53 @@ class Ui_fluencyCAD(object):
self.verticalLayout_2.addWidget(self.pushButton_2)
self.gridLayout.addWidget(self.groupBox_4, 7, 5, 1, 1)
self.gridLayout.addWidget(self.groupBox_4, 10, 5, 1, 1)
self.gl_box = QGroupBox(self.centralwidget)
self.gl_box.setObjectName(u"gl_box")
sizePolicy3 = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
sizePolicy3.setHorizontalStretch(0)
sizePolicy3.setVerticalStretch(4)
sizePolicy3.setHeightForWidth(self.gl_box.sizePolicy().hasHeightForWidth())
self.gl_box.setSizePolicy(sizePolicy3)
font = QFont()
font.setPointSize(12)
self.gl_box.setFont(font)
self.horizontalLayout_4 = QHBoxLayout(self.gl_box)
#ifndef Q_OS_MAC
self.horizontalLayout_4.setSpacing(-1)
#endif
self.horizontalLayout_4.setObjectName(u"horizontalLayout_4")
self.horizontalLayout_4.setContentsMargins(12, -1, -1, -1)
self.gridLayout.addWidget(self.gl_box, 0, 4, 11, 1)
self.groupBox = QGroupBox(self.centralwidget)
self.groupBox.setObjectName(u"groupBox")
self.gridLayout_3 = QGridLayout(self.groupBox)
self.gridLayout_3.setObjectName(u"gridLayout_3")
self.pb_extrdop = QPushButton(self.groupBox)
self.pb_extrdop.setObjectName(u"pb_extrdop")
self.gridLayout_3.addWidget(self.pb_extrdop, 0, 0, 1, 1)
self.pb_cutop = QPushButton(self.groupBox)
self.pb_cutop.setObjectName(u"pb_cutop")
self.gridLayout_3.addWidget(self.pb_cutop, 0, 1, 1, 1)
self.pb_arrayop = QPushButton(self.groupBox)
self.pb_arrayop.setObjectName(u"pb_arrayop")
self.gridLayout_3.addWidget(self.pb_arrayop, 1, 0, 1, 1)
self.pb_revop = QPushButton(self.groupBox)
self.pb_revop.setObjectName(u"pb_revop")
self.gridLayout_3.addWidget(self.pb_revop, 1, 1, 1, 1)
self.gridLayout.addWidget(self.groupBox, 0, 5, 10, 1, Qt.AlignTop)
self.groupBox_9 = QGroupBox(self.centralwidget)
self.groupBox_9.setObjectName(u"groupBox_9")
@ -236,8 +236,8 @@ class Ui_fluencyCAD(object):
self.groupBox_2 = QGroupBox(self.centralwidget)
self.groupBox_2.setObjectName(u"groupBox_2")
sizePolicy3.setHeightForWidth(self.groupBox_2.sizePolicy().hasHeightForWidth())
self.groupBox_2.setSizePolicy(sizePolicy3)
sizePolicy2.setHeightForWidth(self.groupBox_2.sizePolicy().hasHeightForWidth())
self.groupBox_2.setSizePolicy(sizePolicy2)
self.gridLayout_2 = QGridLayout(self.groupBox_2)
self.gridLayout_2.setObjectName(u"gridLayout_2")
self.pb_rectool = QPushButton(self.groupBox_2)
@ -273,8 +273,9 @@ class Ui_fluencyCAD(object):
self.groupBox_3 = QGroupBox(self.centralwidget)
self.groupBox_3.setObjectName(u"groupBox_3")
sizePolicy3.setHeightForWidth(self.groupBox_3.sizePolicy().hasHeightForWidth())
self.groupBox_3.setSizePolicy(sizePolicy3)
sizePolicy2.setHeightForWidth(self.groupBox_3.sizePolicy().hasHeightForWidth())
self.groupBox_3.setSizePolicy(sizePolicy2)
self.groupBox_3.setMaximumSize(QSize(16777214, 16777213))
self.gridLayout_4 = QGridLayout(self.groupBox_3)
self.gridLayout_4.setObjectName(u"gridLayout_4")
self.pb_con_line = QPushButton(self.groupBox_3)
@ -296,14 +297,21 @@ class Ui_fluencyCAD(object):
self.pb_con_horiz.setCheckable(True)
self.pb_con_horiz.setAutoExclusive(False)
self.gridLayout_4.addWidget(self.pb_con_horiz, 1, 0, 1, 1)
self.gridLayout_4.addWidget(self.pb_con_horiz, 2, 0, 1, 1)
self.pb_con_vert = QPushButton(self.groupBox_3)
self.pb_con_vert.setObjectName(u"pb_con_vert")
self.pb_con_vert.setCheckable(True)
self.pb_con_vert.setAutoExclusive(False)
self.gridLayout_4.addWidget(self.pb_con_vert, 1, 1, 1, 1)
self.gridLayout_4.addWidget(self.pb_con_vert, 2, 1, 1, 1)
self.pb_con_sym = QPushButton(self.groupBox_3)
self.pb_con_sym.setObjectName(u"pb_con_sym")
self.pb_con_sym.setCheckable(True)
self.pb_con_sym.setAutoExclusive(False)
self.gridLayout_4.addWidget(self.pb_con_sym, 3, 1, 1, 1)
self.pb_con_dist = QPushButton(self.groupBox_3)
self.pb_con_dist.setObjectName(u"pb_con_dist")
@ -311,14 +319,19 @@ class Ui_fluencyCAD(object):
self.pb_con_dist.setAutoExclusive(False)
self.pb_con_dist.setAutoRepeatDelay(297)
self.gridLayout_4.addWidget(self.pb_con_dist, 2, 0, 1, 1)
self.gridLayout_4.addWidget(self.pb_con_dist, 3, 0, 1, 1)
self.pb_con_sym = QPushButton(self.groupBox_3)
self.pb_con_sym.setObjectName(u"pb_con_sym")
self.pb_con_sym.setCheckable(True)
self.pb_con_sym.setAutoExclusive(False)
self.pb_con_mid = QPushButton(self.groupBox_3)
self.pb_con_mid.setObjectName(u"pb_con_mid")
self.pb_con_mid.setCheckable(True)
self.gridLayout_4.addWidget(self.pb_con_sym, 2, 1, 1, 1)
self.gridLayout_4.addWidget(self.pb_con_mid, 1, 0, 1, 1)
self.pb_con_perp = QPushButton(self.groupBox_3)
self.pb_con_perp.setObjectName(u"pb_con_perp")
self.pb_con_perp.setCheckable(True)
self.gridLayout_4.addWidget(self.pb_con_perp, 1, 1, 1, 1)
self.gridLayout.addWidget(self.groupBox_3, 2, 0, 1, 1)
@ -326,7 +339,7 @@ class Ui_fluencyCAD(object):
fluencyCAD.setCentralWidget(self.centralwidget)
self.menubar = QMenuBar(fluencyCAD)
self.menubar.setObjectName(u"menubar")
self.menubar.setGeometry(QRect(0, 0, 1755, 24))
self.menubar.setGeometry(QRect(0, 0, 2214, 24))
fluencyCAD.setMenuBar(self.menubar)
self.statusbar = QStatusBar(fluencyCAD)
self.statusbar.setObjectName(u"statusbar")
@ -349,12 +362,6 @@ class Ui_fluencyCAD(object):
self.pb_apply_code.setText(QCoreApplication.translate("fluencyCAD", u"Apply Code", None))
self.pushButton.setText(QCoreApplication.translate("fluencyCAD", u"Delete Code", None))
self.InputTab.setTabText(self.InputTab.indexOf(self.code_tab), QCoreApplication.translate("fluencyCAD", u"Code", None))
self.groupBox.setTitle(QCoreApplication.translate("fluencyCAD", u"Modify", None))
self.pb_extrdop.setText(QCoreApplication.translate("fluencyCAD", u"Extrd", None))
self.pb_cutop.setText(QCoreApplication.translate("fluencyCAD", u"Cut", None))
self.pb_arrayop.setText(QCoreApplication.translate("fluencyCAD", u"Arry", None))
self.pb_revop.setText(QCoreApplication.translate("fluencyCAD", u"Rev", None))
self.gl_box.setTitle(QCoreApplication.translate("fluencyCAD", u"Model Viewer", None))
self.groupBox_5.setTitle(QCoreApplication.translate("fluencyCAD", u"Sketch", None))
self.groupBox_6.setTitle(QCoreApplication.translate("fluencyCAD", u"Tools", None))
self.pb_del_sketch.setText(QCoreApplication.translate("fluencyCAD", u"Del sketch", None))
@ -366,6 +373,12 @@ class Ui_fluencyCAD(object):
self.pb_edt_sktch_3.setText(QCoreApplication.translate("fluencyCAD", u"Nothing", None))
self.groupBox_4.setTitle(QCoreApplication.translate("fluencyCAD", u"Export", None))
self.pushButton_2.setText(QCoreApplication.translate("fluencyCAD", u"STL", None))
self.gl_box.setTitle(QCoreApplication.translate("fluencyCAD", u"Model Viewer", None))
self.groupBox.setTitle(QCoreApplication.translate("fluencyCAD", u"Modify", None))
self.pb_extrdop.setText(QCoreApplication.translate("fluencyCAD", u"Extrd", None))
self.pb_cutop.setText(QCoreApplication.translate("fluencyCAD", u"Cut", None))
self.pb_arrayop.setText(QCoreApplication.translate("fluencyCAD", u"Arry", None))
self.pb_revop.setText(QCoreApplication.translate("fluencyCAD", u"Rev", None))
self.groupBox_9.setTitle(QCoreApplication.translate("fluencyCAD", u"Workplanes", None))
self.pb_origin_wp.setText(QCoreApplication.translate("fluencyCAD", u"WP Origin", None))
self.pb_origin_face.setText(QCoreApplication.translate("fluencyCAD", u" WP Face", None))
@ -375,11 +388,13 @@ class Ui_fluencyCAD(object):
self.pb_slotool.setText(QCoreApplication.translate("fluencyCAD", u"Slot", None))
self.pb_linetool.setText(QCoreApplication.translate("fluencyCAD", u"Line", None))
self.groupBox_3.setTitle(QCoreApplication.translate("fluencyCAD", u"Constrain", None))
self.pb_con_line.setText(QCoreApplication.translate("fluencyCAD", u"Pt_Line", None))
self.pb_con_line.setText(QCoreApplication.translate("fluencyCAD", u"Pt_Lne", None))
self.pb_con_ptpt.setText(QCoreApplication.translate("fluencyCAD", u"Pt_Pt", None))
self.pb_con_horiz.setText(QCoreApplication.translate("fluencyCAD", u"Horiz", None))
self.pb_con_vert.setText(QCoreApplication.translate("fluencyCAD", u"Vert", None))
self.pb_con_dist.setText(QCoreApplication.translate("fluencyCAD", u"Distnce", None))
self.pb_con_sym.setText(QCoreApplication.translate("fluencyCAD", u"Symetrc", None))
self.pb_con_dist.setText(QCoreApplication.translate("fluencyCAD", u"Distnce", None))
self.pb_con_mid.setText(QCoreApplication.translate("fluencyCAD", u"Pt_Mid_L", None))
self.pb_con_perp.setText(QCoreApplication.translate("fluencyCAD", u"Perp_Lne", None))
# retranslateUi

View File

@ -72,6 +72,11 @@ class SketchWidget(QWidget):
def distance(self, p1, p2):
return math.sqrt((p1.x() - p2.x())**2 + (p1.y() - p2.y())**2)
def calculate_midpoint(self, point1, point2):
mx = (point1.x() + point2.x()) // 2
my = (point1.y() + point2.y()) // 2
return QPoint(mx, my)
def is_point_on_line(self, p, p1, p2, tolerance=5):
# Calculate the lengths of the sides of the triangle
a = self.distance(p, p1)
@ -137,6 +142,7 @@ class SketchWidget(QWidget):
"""print("Initial slv_points_main:", self.slv_points_main)
print("Change list:", point_list)"""
if len(point_list) > 0:
for tbu_points_idx in point_list:
# Each tbu_points_idx is a tuple: (index, old_point, new_point)
index, old_point, new_point = tbu_points_idx
@ -436,6 +442,9 @@ class SketchWidget(QWidget):
elif self.solv.solve() == ResultFlag.INCONSISTENT:
print("Solve_failed - Incons")
if event.button() == Qt.LeftButton and self.mouse_mode == "pb_con_mid":
points_need_update = check_all_points()
print("This", points_need_update)
@ -514,19 +523,21 @@ class SketchWidget(QWidget):
painter.drawLine(middle_x, 0, middle_x, self.height())
# Draw tick marks
tick_length = 10
tick_spacing = 50
tick_length = int(10 * self.zoom)
tick_spacing = int(50 * self.zoom)
pen = QPen(Qt.gray, 1, Qt.SolidLine)
painter.setPen(pen)
# Draw tick marks on the X axis
for x in range(0, self.width(), tick_spacing):
painter.drawLine(x, middle_y - tick_length // 2, x, middle_y + tick_length // 2)
# Draw tick marks on the X axis to the right and left from the middle point
for x in range(0, self.width() // 2, tick_spacing):
painter.drawLine(middle_x + x, middle_y - tick_length // 2, middle_x + x, middle_y + tick_length // 2)
painter.drawLine(middle_x - x, middle_y - tick_length // 2, middle_x - x, middle_y + tick_length // 2)
# Draw tick marks on the Y axis
for y in range(0, self.height(), tick_spacing):
painter.drawLine(middle_x - tick_length // 2, y, middle_x + tick_length // 2, y)
# Draw tick marks on the Y axis upwards and downwards from the middle point
for y in range(0, self.height() // 2, tick_spacing):
painter.drawLine(middle_x - tick_length // 2, middle_y + y, middle_x + tick_length // 2, middle_y + y)
painter.drawLine(middle_x - tick_length // 2, middle_y - y, middle_x + tick_length // 2, middle_y - y)
# Draw the origin point in red
painter.setPen(QPen(Qt.red, 4))
@ -553,11 +564,6 @@ class SketchWidget(QWidget):
# Apply the zoom factor
painter.scale(self.zoom, self.zoom)
# Set the background color
#painter.fillRect(0, self.width(), 0, self.height(), QColor('black'))
# Draw axes
pen = QPen(Qt.gray)
pen.setWidth(2 / self.zoom)
painter.setPen(pen)
@ -567,7 +573,14 @@ class SketchWidget(QWidget):
painter.drawEllipse(point['ui_point'], 3 / self.zoom, 3 / self.zoom)
for dic in self.slv_lines_main:
painter.drawLine(dic['ui_points'][0] , dic['ui_points'][1])
p1 = dic['ui_points'][0]
p2 = dic['ui_points'][1]
painter.drawLine(p1, p2)
dis = self.distance(p1, p2)
mid = self.calculate_midpoint(p1, p2)
painter.drawText(mid, str(round(dis, 2)))
pen = QPen(Qt.green)
pen.setWidth(2)
@ -587,7 +600,7 @@ class SketchWidget(QWidget):
painter.setPen(highlight_pen)
painter.drawEllipse(self.hovered_point, 5 / self.zoom, 5 / self.zoom)
if self.selected_line:
if self.selected_line and not self.hovered_point:
p1, p2 = self.selected_line
painter.setPen(QPen(Qt.red, 2))
painter.drawLine(p1, p2)

184
gui.ui
View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>1755</width>
<height>685</height>
<width>2214</width>
<height>803</height>
</rect>
</property>
<property name="windowTitle">
@ -15,10 +15,10 @@
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="2" rowspan="8">
<item row="0" column="2" rowspan="11">
<widget class="QTabWidget" name="InputTab">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -81,70 +81,7 @@
</widget>
</widget>
</item>
<item row="0" column="5" rowspan="7" alignment="Qt::AlignTop">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Modify</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QPushButton" name="pb_extrdop">
<property name="text">
<string>Extrd</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="pb_cutop">
<property name="text">
<string extracomment="1. Bigger obj 2. smaller object">Cut</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="pb_arrayop">
<property name="text">
<string>Arry</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="pb_revop">
<property name="text">
<string>Rev</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="4" rowspan="8">
<widget class="QGroupBox" name="gl_box">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>4</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="title">
<string>Model Viewer</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<property name="spacing">
<number>-1</number>
</property>
<property name="leftMargin">
<number>12</number>
</property>
</layout>
</widget>
</item>
<item row="0" column="3" rowspan="8">
<item row="0" column="3" rowspan="11">
<widget class="QGroupBox" name="groupBox_5">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
@ -275,7 +212,7 @@
</layout>
</widget>
</item>
<item row="7" column="5">
<item row="10" column="5">
<widget class="QGroupBox" name="groupBox_4">
<property name="title">
<string>Export</string>
@ -291,6 +228,69 @@
</layout>
</widget>
</item>
<item row="0" column="4" rowspan="11">
<widget class="QGroupBox" name="gl_box">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>4</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="title">
<string>Model Viewer</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<property name="spacing">
<number>-1</number>
</property>
<property name="leftMargin">
<number>12</number>
</property>
</layout>
</widget>
</item>
<item row="0" column="5" rowspan="10" alignment="Qt::AlignTop">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Modify</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QPushButton" name="pb_extrdop">
<property name="text">
<string>Extrd</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="pb_cutop">
<property name="text">
<string extracomment="1. Bigger obj 2. smaller object">Cut</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="pb_arrayop">
<property name="text">
<string>Arry</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="pb_revop">
<property name="text">
<string>Rev</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="0">
<widget class="QGroupBox" name="groupBox_9">
<property name="title">
@ -389,6 +389,12 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777214</width>
<height>16777213</height>
</size>
</property>
<property name="title">
<string>Constrain</string>
</property>
@ -396,7 +402,7 @@
<item row="0" column="1">
<widget class="QPushButton" name="pb_con_line">
<property name="text">
<string>Pt_Line</string>
<string>Pt_Lne</string>
</property>
<property name="checkable">
<bool>true</bool>
@ -419,7 +425,7 @@
</property>
</widget>
</item>
<item row="1" column="0">
<item row="2" column="0">
<widget class="QPushButton" name="pb_con_horiz">
<property name="text">
<string>Horiz</string>
@ -432,7 +438,7 @@
</property>
</widget>
</item>
<item row="1" column="1">
<item row="2" column="1">
<widget class="QPushButton" name="pb_con_vert">
<property name="text">
<string>Vert</string>
@ -445,7 +451,20 @@
</property>
</widget>
</item>
<item row="2" column="0">
<item row="3" column="1">
<widget class="QPushButton" name="pb_con_sym">
<property name="text">
<string>Symetrc</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoExclusive">
<bool>false</bool>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QPushButton" name="pb_con_dist">
<property name="text">
<string>Distnce</string>
@ -461,16 +480,23 @@
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QPushButton" name="pb_con_sym">
<item row="1" column="0">
<widget class="QPushButton" name="pb_con_mid">
<property name="text">
<string>Symetrc</string>
<string>Pt_Mid_L</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoExclusive">
<bool>false</bool>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="pb_con_perp">
<property name="text">
<string>Perp_Lne</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
@ -484,7 +510,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>1755</width>
<width>2214</width>
<height>24</height>
</rect>
</property>

18
main.py
View File

@ -12,7 +12,6 @@ from python_solvespace import SolverSystem, ResultFlag
# main, draw_widget, gl_widget
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
@ -65,7 +64,6 @@ class MainWindow(QMainWindow):
self.sketchWidget.constrain_done.connect(self.constrain_finished)
def add_wp_origin(self):
#Select orientation
#orientation, ok = Q .getDouble(self, 'Extrude Length', 'Enter a mm value:', decimals=2)
@ -88,7 +86,7 @@ class MainWindow(QMainWindow):
self.sketchWidget.line_buffer = None
def act_constrain_pt_line_mode(self):
if not self.ui.pb_linetool.isChecked():
if not self.ui.pb_con_line.isChecked():
self.sketchWidget.mouse_mode = 'pt_line'
else:
self.sketchWidget.mouse_mode = None
@ -109,12 +107,19 @@ class MainWindow(QMainWindow):
self.sketchWidget.line_buffer = None
def act_constrain_distance_mode(self):
if not self.ui.pb_con_vert.isChecked():
if not self.ui.pb_con_dist.isChecked():
self.sketchWidget.mouse_mode = 'distance'
else:
self.sketchWidget.mouse_mode = None
self.sketchWidget.line_buffer = None
def act_constrain_mid_point_mode(self):
if not self.ui.pb_con_mid.isChecked():
self.sketchWidget.mouse_mode = 'pb_con_mid'
else:
self.sketchWidget.mouse_mode = None
self.sketchWidget.line_buffer = None
def constrain_finished(self):
self.ui.pb_con_ptpt.setChecked(False)
self.ui.pb_con_line.setChecked(False)
@ -225,7 +230,6 @@ class MainWindow(QMainWindow):
return p_list
def send_extrude(self):
selected = self.ui.sketch_list.currentItem()
name = selected.text()
@ -289,10 +293,6 @@ class MainWindow(QMainWindow):
self.openGLWidget.load_stl(file)
self.openGLWidget.update()
""" def check_current_tab(self):
if self.ui.InputTab.currentIndex() == 0:
geo = Geometry()