Mercurial > lcfOS
comparison applications/lab/diagrameditor.py @ 57:143ab220aa27
Cleanup
author | windel |
---|---|
date | Sun, 22 Apr 2012 23:10:38 +0200 |
parents | 7a82f0d52e85 |
children | 65acf6874a8d |
comparison
equal
deleted
inserted
replaced
56:7a82f0d52e85 | 57:143ab220aa27 |
---|---|
452 if port.name == portname: | 452 if port.name == portname: |
453 return port | 453 return port |
454 def mouseMoveEvent(self, event): | 454 def mouseMoveEvent(self, event): |
455 if self.startedConnection: | 455 if self.startedConnection: |
456 pos = event.scenePos() | 456 pos = event.scenePos() |
457 items = self.items(pos) | |
458 for item in items: | |
459 if type(item) is PortItem: | |
460 pen = item.pen() | |
461 pen.setColor(Qt.red) | |
462 item.setPen(pen) | |
463 self.startedConnection.setEndPos(pos) | 457 self.startedConnection.setEndPos(pos) |
464 super(DiagramScene, self).mouseMoveEvent(event) | 458 super(DiagramScene, self).mouseMoveEvent(event) |
465 def mouseReleaseEvent(self, event): | 459 def mouseReleaseEvent(self, event): |
466 if self.startedConnection: | 460 if self.startedConnection: |
467 items = self.items(event.scenePos()) | 461 items = self.items(event.scenePos()) |
486 hits = [hit for hit in hits if type(hit) is BlockItem] | 480 hits = [hit for hit in hits if type(hit) is BlockItem] |
487 return hits | 481 return hits |
488 | 482 |
489 def viaPoints(pA, pB): | 483 def viaPoints(pA, pB): |
490 # Construct intermediate points: | 484 # Construct intermediate points: |
491 | |
492 pAB1 = QPointF(pA.x(), pB.y()) | 485 pAB1 = QPointF(pA.x(), pB.y()) |
493 pAB2 = QPointF(pB.x(), pA.y()) | 486 pAB2 = QPointF(pB.x(), pA.y()) |
494 path1 = QPainterPath(pA) | 487 path1 = QPainterPath(pA) |
495 path1.lineTo(pAB1) | 488 path1.lineTo(pAB1) |
496 path2 = QPainterPath(pA) | 489 path2 = QPainterPath(pA) |
513 else: | 506 else: |
514 p3 = P2 + dx | 507 p3 = P2 + dx |
515 | 508 |
516 # If pathitem: | 509 # If pathitem: |
517 pts = [P1, p2] + viaPoints(p2, p3) + [p3, P2] | 510 pts = [P1, p2] + viaPoints(p2, p3) + [p3, P2] |
511 print('line') | |
512 for pt in pts: | |
513 print(pt) | |
518 return pts | 514 return pts |
519 def deleteItem(self, item=None): | 515 def deleteItem(self, item=None): |
520 if item: | 516 if item: |
521 if type(item) is BlockItem: | 517 if type(item) is BlockItem: |
522 for p in item.inputs + item.outputs: | 518 for p in item.inputs + item.outputs: |