- More projection and extrusion in place

This commit is contained in:
bklronin
2024-07-10 23:19:43 +02:00
parent b5c965bf2e
commit cb471b4108
4 changed files with 185 additions and 90 deletions

View File

@@ -22,6 +22,8 @@ class SketchWidget(QWidget):
self.drag_buffer = [None, None]
self.main_buffer = [None, None]
self.proj_snap_points = []
self.hovered_point = None
self.selected_line = None
@@ -54,23 +56,20 @@ class SketchWidget(QWidget):
def create_proj_lines(self, lines):
"""Lines as orientation projected from the sketch"""
for line in lines:
for point in line:
x, y, z = point
for point in lines:
print(point)
x, y = point
self.proj_snap_points = lines
point = self.solv.add_point_2d(x, y, self.wp)
#point = self.solv.add_point_2d(x, y, self.wp)
relation_point = {} # Reinitialize the dictionary
handle_nr = self.get_handle_nr(str(point))
relation_point['handle_nr'] = handle_nr
relation_point['solv_handle'] = point
relation_point['ui_point'] = QPoint(x, y)
"""relation_point = {} # Reinitialize the dictionary
#handle_nr = self.get_handle_nr(str(point))
#relation_point['handle_nr'] = handle_nr
#relation_point['solv_handle'] = point
relation_point['ui_point'] = QPoint(x, y)
self.slv_points_main.append(relation_point)
print("points", self.slv_points_main)
print("lines", self.slv_lines_main)
print("lines", lines)
self.slv_points_main.append(relation_point)"""
def find_duplicate_points_2d(self, edges):
points = []
@@ -635,6 +634,21 @@ class SketchWidget(QWidget):
painter.setPen(QPen(Qt.red, 4))
painter.drawPoint(middle_x, middle_y)
def draw_cross(self, painter, x, y, size=10):
# Set up the pen
pen = QPen(QColor('red')) # You can change the color as needed
pen.setWidth(2) # Set the line width
painter.setPen(pen)
# Calculate the endpoints of the cross
half_size = size // 2
# Draw the horizontal line
painter.drawLine(x - half_size, y, x + half_size, y)
# Draw the vertical line
painter.drawLine(x, y - half_size, x, y + half_size)
def to_quadrant_coords(self, point):
"""Translate linear coordinates to quadrant coordinates."""
center_x = self.width() // 2
@@ -663,6 +677,10 @@ class SketchWidget(QWidget):
for point in self.slv_points_main:
painter.drawEllipse(point['ui_point'], 3 / self.zoom, 3 / self.zoom)
for cross in self.proj_snap_points:
# Calculate the endpoints of the cross
self.draw_cross(painter, cross[0], cross[1], 10)
for dic in self.slv_lines_main:
p1 = dic['ui_points'][0]
p2 = dic['ui_points'][1]