- Basic oop sketch widget implement

This commit is contained in:
bklronin
2024-10-26 18:02:06 +02:00
parent 79c1aa106f
commit a5202e1630
4 changed files with 941 additions and 31 deletions

View File

@@ -383,8 +383,6 @@ class SketchWidget(QWidget):
# Track Relationship
# Points
# CONSTRAINTS
if event.button() == Qt.LeftButton and self.mouse_mode == "pt_pt":
if self.hovered_point and not self.main_buffer[0]:
self.main_buffer[0] = self.get_handle_from_ui_point(self.hovered_point)
@@ -773,7 +771,7 @@ class SketchWidget(QWidget):
return self.width() / self.height() * (1.0 / abs(self.zoom))
class Point2D_ALT:
class Point2D:
"""Improved oop aaproach?"""
def __init__(self):
self.ui_point = None
@@ -901,35 +899,11 @@ class Point2D_ALT:
return QPoint(self.to_quadrant_coords(qt_pos))
class Point2D:
ui_x: int = None
ui_y: int = None
handle = None
class Line2D:
crd1: Point2D = None
crd2: Point2D = None
handle = None
pass
class Sketch2d(SolverSystem):
def __init__(self):
self.wp = self.create_2d_base()
self.points = []
self.lines = []
def add_point(self, point: Point2D):
point.handle = self.add_point_2d(point.ui_x, point.ui_y, self.wo)
self.points.append(point)
def add_line(self, line: Line2D):
line.handle = self.add_line_2d(line.crd1, line.crd2, self.wp)
self.lines.append(line)
if __name__ == "__main__":
import sys