From ce3690ad8d754c53900ccb9a30bd637737bd65e5 Mon Sep 17 00:00:00 2001 From: Felipe CorrĂȘa da Silva Sanches Date: Mon, 28 Sep 2015 14:40:01 -0300 Subject: work in progress: ComponentItem class --- Lib/defconQt/glyphView.py | 15 ++++++++++++--- Lib/defconQt/representationFactories/glyphViewFactory.py | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) (limited to 'Lib/defconQt') diff --git a/Lib/defconQt/glyphView.py b/Lib/defconQt/glyphView.py index 88073ae..840b317 100644 --- a/Lib/defconQt/glyphView.py +++ b/Lib/defconQt/glyphView.py @@ -305,6 +305,13 @@ class OffCurvePointItem(QGraphicsEllipseItem): self.setRect(-offHalf/scale, -offHalf/scale, offWidth/scale, offHeight/scale) self.setPen(QPen(offCurvePointStrokeColor, offCurvePenWidth/scale)) +class ComponentItem(QGraphicsPathItem): + def __init__(self, path, component): + super(ComponentItem, self).__init__() + self._component = component + self.setFlag(QGraphicsItem.ItemIsMovable) + self.setFlag(QGraphicsItem.ItemIsSelectable) + class OnCurvePointItem(QGraphicsPathItem): def __init__(self, x, y, isSmooth, contour, point, scale=1, parent=None): super(OnCurvePointItem, self).__init__(parent) @@ -1284,9 +1291,11 @@ class GlyphView(QGraphicsView): scene._outlineItem.setZValue(-995) scene._glyphObject = self._glyph # components - paths = self._glyph.getRepresentation("defconQt.OnlyComponentsQPainterPath") - for path in paths: - scene.addPath(path, brush=QBrush(componentFillColor)) + components = self._glyph.getRepresentation("defconQt.OnlyComponentsQPainterPath") + scene._componentItems = [] + for path, component in components: + component_path = scene.addPath(path, brush=QBrush(componentFillColor)) + scene._componentItems.append(ComponentItem(component_path, component)) def addPoints(self): scene = self.scene() diff --git a/Lib/defconQt/representationFactories/glyphViewFactory.py b/Lib/defconQt/representationFactories/glyphViewFactory.py index 1b96cdc..c98c9ae 100644 --- a/Lib/defconQt/representationFactories/glyphViewFactory.py +++ b/Lib/defconQt/representationFactories/glyphViewFactory.py @@ -63,7 +63,7 @@ class OnlyComponentsQtPen(BasePen): pen.path.setFillRule(Qt.WindingFill) tPen = TransformPen(pen, transformation) glyph.draw(tPen) - self.paths.append(pen.path) + self.paths.append([pen.path, glyph]) # ---------- # point data -- cgit v1.2.3