summaryrefslogtreecommitdiff
path: root/src/main/python
diff options
context:
space:
mode:
authorsumit2020-05-31 21:31:43 +0530
committersumit2020-05-31 21:31:43 +0530
commit3d48ad1d1884aacb74e569f60b213aa2be64d539 (patch)
tree391c431bc5755e6adc83fa4c66c7e2e54343c2f7 /src/main/python
parent25341b4f0c95f404b2acbeb4d23c3decb2a8f346 (diff)
downloadChemical-PFD-3d48ad1d1884aacb74e569f60b213aa2be64d539.tar.gz
Chemical-PFD-3d48ad1d1884aacb74e569f60b213aa2be64d539.tar.bz2
Chemical-PFD-3d48ad1d1884aacb74e569f60b213aa2be64d539.zip
common path of lines
Diffstat (limited to 'src/main/python')
-rw-r--r--src/main/python/shapes/line.py58
1 files changed, 42 insertions, 16 deletions
diff --git a/src/main/python/shapes/line.py b/src/main/python/shapes/line.py
index 8bba5be..2c5a527 100644
--- a/src/main/python/shapes/line.py
+++ b/src/main/python/shapes/line.py
@@ -126,6 +126,46 @@ class Line(QGraphicsPathItem):
# initiates path
self.createPath()
+ def advance(self, phase):
+ # items = self.collidingItems(Qt.IntersectsItemShape)
+ items = self.scene().items(self.shape(),Qt.IntersectsItemShape,Qt.DescendingOrder)
+ self.commonPaths = []
+ for item in items:
+ if type(item) in [type(self)]:
+ if item == self:
+ break
+ # origin = self.mapFromItem(item, 0, 0)
+ shape = item.shape()
+ shape = self.mapFromItem(item, item.shape())
+ commonPath = self.shape().intersected(shape)
+ self.commonPaths.append(commonPath)
+
+ def paint(self, painter, option, widget):
+ color = Qt.red if self.isSelected() else Qt.black
+ painter.setPen(QPen(color, 2, self.penStyle))
+ path = self.path()
+ painter.drawPath(path)
+ for p in self.commonPaths:
+ print("length = ",p.length(),"element = ",p.elementCount())
+ for i in range(p.elementCount()):
+ print(p.elementAt(i).x,p.elementAt(i).y)
+ # if p.elementAt(0).x == p.elementAt(1).x:
+ # pass
+ painter.save()
+ painter.setPen(Qt.darkYellow)
+ painter.setBrush(Qt.darkYellow)
+ painter.drawPath(p)
+ painter.restore()
+ # painter.setPen(QPen(QBrush(Qt.black),-1))
+ # painter.setBrush(QBrush(Qt.red))
+ # print(painter.pen().width())
+ # painter.drawPath(path)
+
+ # To paint path of shape
+ # painter.setPen(QPen(Qt.blue, 1, Qt.SolidLine))
+ # painter.drawPath(self.shape())
+
+
def createPath(self):
"""
creates initial path and stores it's points
@@ -412,7 +452,7 @@ class Line(QGraphicsPathItem):
self.points = [start, ns, QPointF(ns.x() - swidth - offset, ns.y()),
QPointF(ns.x() - swidth - offset, pe.y()), end]
- # draw line
+ # path of line
path = QPainterPath(self.startPoint)
for i in range(1, len(self.points)):
path.lineTo(self.points[i])
@@ -464,21 +504,6 @@ class Line(QGraphicsPathItem):
path = qp.createStroke(self.path())
return path
- def paint(self, painter, option, widget):
- color = Qt.red if self.isSelected() else Qt.black
- painter.setPen(QPen(color, 2, self.penStyle))
- painter.drawPath(self.path())
-
- # To paint path of shape
- # painter.setPen(QPen(Qt.blue, 1, Qt.SolidLine))
- # painter.drawPath(self.shape())
- # if self.isSelected():
- # self.showGripItem()
- # self._selected = True
- # elif self._selected:
- # self.hideGripItem()
- # self._selected = False
-
def movePoints(self, index, movement):
"""move points of line
"""
@@ -543,6 +568,7 @@ class Line(QGraphicsPathItem):
self.endPoint = endPoint
self.createPath()
self.updateGrabber()
+ self.scene().update()
return
if self.startGripItem and self.endGripItem: