Mercurial > lcfOS
comparison applications/lab/diagrameditor.py @ 59:f6ea630c4057
Cleanup
author | windel |
---|---|
date | Tue, 24 Apr 2012 08:01:55 +0200 |
parents | 65acf6874a8d |
children | b976546f5a60 |
comparison
equal
deleted
inserted
replaced
58:65acf6874a8d | 59:f6ea630c4057 |
---|---|
54 for p1, p2 in zip(pts[0:-1], pts[1:]): | 54 for p1, p2 in zip(pts[0:-1], pts[1:]): |
55 l1 = QLineF(p1, p2) | 55 l1 = QLineF(p1, p2) |
56 l2 = QLineF(p1, pos) | 56 l2 = QLineF(p1, pos) |
57 l3 = QLineF(pos, p2) | 57 l3 = QLineF(pos, p2) |
58 d = l1.length() - l2.length() - l3.length() | 58 d = l1.length() - l2.length() - l3.length() |
59 print(idx, d) | 59 if d > -3: |
60 if d > -1: | |
61 tidx = idx | 60 tidx = idx |
62 print('got:', tidx) | |
63 idx += 1 | 61 idx += 1 |
64 hi = HandleItem(self) | 62 hi = HandleItem(self) |
65 self.vias.insert(tidx, hi) | 63 self.vias.insert(tidx, hi) |
66 def callback(pos): | 64 def callback(pos): |
67 self.updateLineStukken() | 65 self.updateLineStukken() |
107 This algorithm determines the optimal routing of all signals. | 105 This algorithm determines the optimal routing of all signals. |
108 TODO: implement nice automatic line router | 106 TODO: implement nice automatic line router |
109 """ | 107 """ |
110 if self.pos1 is None or self.pos2 is None: | 108 if self.pos1 is None or self.pos2 is None: |
111 return | 109 return |
112 | |
113 pts = [self.pos1] + [v.pos() for v in self.vias] + [self.pos2] | 110 pts = [self.pos1] + [v.pos() for v in self.vias] + [self.pos2] |
114 | |
115 self.arrowhead.setPos(self.pos2) | 111 self.arrowhead.setPos(self.pos2) |
116 if pts[-1].x() < pts[-2].x(): | 112 if pts[-1].x() < pts[-2].x(): |
117 self.arrowhead.setRotation(-90) | 113 self.arrowhead.setRotation(-90) |
118 else: | 114 else: |
119 self.arrowhead.setRotation(90) | 115 self.arrowhead.setRotation(90) |
120 | |
121 path = QPainterPath(pts[0]) | 116 path = QPainterPath(pts[0]) |
122 for pt in pts[1:]: | 117 for pt in pts[1:]: |
123 path.lineTo(pt) | 118 path.lineTo(pt) |
124 self.setPath(path) | 119 self.setPath(path) |
125 """ Create a shape outline using the path stroker """ | 120 """ Create a shape outline using the path stroker """ |
275 self.sizer.setPos(60, 40) # This is a better resize function | 270 self.sizer.setPos(60, 40) # This is a better resize function |
276 #self.changeSize(60, 40) # TODO: create a wrapper function | 271 #self.changeSize(60, 40) # TODO: create a wrapper function |
277 def editParameters(self): | 272 def editParameters(self): |
278 pd = ParameterDialog(self, self.window()) | 273 pd = ParameterDialog(self, self.window()) |
279 pd.exec_() | 274 pd.exec_() |
275 def mouseDoubleClickEvent(self, event): | |
276 self.editParameters() | |
280 def newInputPort(self): | 277 def newInputPort(self): |
281 names = [i.name for i in self.inputs + self.outputs] | 278 names = [i.name for i in self.inputs + self.outputs] |
282 self.addInput(PortItem(uniqify('in', names), self, 'input')) | 279 self.addInput(PortItem(uniqify('in', names), self, 'input')) |
283 def newOutputPort(self): | 280 def newOutputPort(self): |
284 names = [i.name for i in self.inputs + self.outputs] | 281 names = [i.name for i in self.inputs + self.outputs] |