|
@@ -333,13 +333,11 @@ class SketchScene(QGraphicsScene):
|
|
|
self._parent.plainTextEdit.appendPlainText("Error: Concrete syntax for type {} already exists".format(node_type))
|
|
|
return
|
|
|
|
|
|
- # check if we need to scale the group items down to 100x100 first
|
|
|
+ # scale group to fit 100x100
|
|
|
group_brect = group.boundingRect()
|
|
|
- need_scale = False
|
|
|
scale_factor = 1.0
|
|
|
- if group_brect.width() > 100 or group_brect.height() > 100:
|
|
|
- need_scale = True
|
|
|
- scale_factor = 100.0 / max(group_brect.width(), group_brect.height())
|
|
|
+ scale_factor = 100.0 / max(group_brect.width(), group_brect.height())
|
|
|
+ print("Scaling group by {}".format(scale_factor))
|
|
|
|
|
|
# populate CSM with sketched elements
|
|
|
for item in group.childItems():
|
|
@@ -348,29 +346,26 @@ class SketchScene(QGraphicsScene):
|
|
|
continue
|
|
|
if isinstance(item, QGraphicsRectItem):
|
|
|
rect = group.get_item_coord_relative(item)
|
|
|
- if need_scale:
|
|
|
- new_top_left = rect.topLeft() * scale_factor
|
|
|
- new_width = rect.width() * scale_factor
|
|
|
- new_height = rect.height() * scale_factor
|
|
|
- rect.setTopLeft(new_top_left)
|
|
|
- rect.setWidth(new_width)
|
|
|
- rect.setHeight(new_height)
|
|
|
+ new_top_left = rect.topLeft() * scale_factor
|
|
|
+ new_width = rect.width() * scale_factor
|
|
|
+ new_height = rect.height() * scale_factor
|
|
|
+ rect.setTopLeft(new_top_left)
|
|
|
+ rect.setWidth(new_width)
|
|
|
+ rect.setHeight(new_height)
|
|
|
mvops.add_rect_to_cs(csm, rect)
|
|
|
elif isinstance(item, QGraphicsEllipseItem):
|
|
|
rect = group.get_item_coord_relative(item)
|
|
|
- if need_scale:
|
|
|
- new_top_left = rect.topLeft() * scale_factor
|
|
|
- new_width = rect.width() * scale_factor
|
|
|
- new_height = rect.height() * scale_factor
|
|
|
- rect.setTopLeft(new_top_left)
|
|
|
- rect.setWidth(new_width)
|
|
|
- rect.setHeight(new_height)
|
|
|
+ new_top_left = rect.topLeft() * scale_factor
|
|
|
+ new_width = rect.width() * scale_factor
|
|
|
+ new_height = rect.height() * scale_factor
|
|
|
+ rect.setTopLeft(new_top_left)
|
|
|
+ rect.setWidth(new_width)
|
|
|
+ rect.setHeight(new_height)
|
|
|
mvops.add_ellipse_to_cs(csm, rect)
|
|
|
elif isinstance(item, SketchedLineItem):
|
|
|
p1, p2 = group.get_item_coord_relative(item)
|
|
|
- if need_scale:
|
|
|
- p1 *= scale_factor
|
|
|
- p2 *= scale_factor
|
|
|
+ p1 *= scale_factor
|
|
|
+ p2 *= scale_factor
|
|
|
mvops.add_line_to_cs(csm, p1, p2)
|
|
|
else:
|
|
|
print("Dont know how to capture CS of item {}".format(item))
|