Пример #1
0
 def loadConn(self, item):
     c = Connection(None, self)
     pt1 = QtCore.QPointF(float(item.findtext('pos1X')),
                          float(item.findtext('pos1Y')))
     pt2 = QtCore.QPointF(float(item.findtext('pos2X')),
                          float(item.findtext('pos2Y')))
     c.pos1 = pt1
     c.pos2 = pt2
     c.update_ports_from_pos()
Пример #2
0
 def bindNode(self):
     self.scene.DgmToUndo()
     item = self.scene.item
     if len(item.port_out.connections) == 1:
         c1 = item.port_in.connections[0]
         c2 = item.port_out.connections[0]
         c = Connection(None, self.scene)
         c.pos1 = c1.pos1
         c.pos2 = c2.pos2
         item.remove()
         c.update_ports_from_pos()
         if isinstance(c.port1, OutPort) and isinstance(c.port2, InPort):
             pos = QtCore.QPointF((c.pos2.x() + c.pos1.x()) / 2, c.pos1.y())
             self.newNode(c, pos)
     else:
         self.scene.clearLastUndo()
Пример #3
0
 def newNode(self, item, pos):
     port2 = item.port2
     pos2 = item.pos2
     c = Connection(None, self.scene)
     b = Node(None, self.scene)
     b.setPos(pos)
     self.lastNode = b
     item.port2.connections.remove(item)
     item.port2.connections.append(c)
     item.port2 = b.port_in
     item.port2.connections.append(item)
     item.pos2 = b.pos()
     c.port1 = b.port_out
     c.port2 = port2
     c.port1.connections.append(c)
     c.pos1 = b.pos()
     c.pos2 = pos2
     item.update_path()
     c.update_path()
     self.scene.isInsConn = False
     self.scene.isConnecting = True