개정판 576a96b2
add line split funct
Change-Id: Ia6705c9b1f8f8ce4afb5f969065159d656b453d6
DTI_PID/DTI_PID/Shapes/EngineeringLineItem.py | ||
---|---|---|
2175 | 2175 |
showAction.triggered.connect(self.contextShow) |
2176 | 2176 |
menu.addAction(showAction) |
2177 | 2177 |
|
2178 |
splitAction = QAction('Split', None) |
|
2179 |
splitAction.triggered.connect(lambda: self.contextSplit(event.pos())) |
|
2180 |
menu.addAction(splitAction) |
|
2181 |
|
|
2178 | 2182 |
freezeAction = QAction('Set Freeze', None) if not self.prop('Freeze') else QAction('Unset Freeze', None) |
2179 | 2183 |
freezeAction.triggered.connect(self.contextFreeze) |
2180 | 2184 |
menu.addAction(freezeAction) |
... | ... | |
2267 | 2271 |
if type(self.owner) is QEngineeringLineNoTextItem: |
2268 | 2272 |
self.owner.contextHighlight(self.owner) |
2269 | 2273 |
|
2274 |
def contextSplit(self, pos): |
|
2275 |
from App import App |
|
2276 |
|
|
2277 |
_pos = [round(pos.x()), round(pos.y())] |
|
2278 |
if abs(_pos[0] - self.start_point()[0]) > abs(_pos[1] - self.start_point()[1]): |
|
2279 |
_pos[1] = self.start_point()[1] |
|
2280 |
else: |
|
2281 |
_pos[0] = self.start_point()[0] |
|
2282 |
|
|
2283 |
savedConnectors = [] |
|
2284 |
for _connector in self.connectors: |
|
2285 |
if _connector.connectedItem and _connector._connected_at == QEngineeringAbstractItem.CONNECTED_AT_PT: |
|
2286 |
_connectors2 = [_connector2 for _connector2 in _connector.connectedItem.connectors if _connector2.connectedItem is self and _connector2._connected_at == QEngineeringAbstractItem.CONNECTED_AT_PT] |
|
2287 |
if _connectors2: |
|
2288 |
savedConnectors.append(_connectors2[0]) |
|
2289 |
continue |
|
2290 |
savedConnectors.append(None) |
|
2291 |
|
|
2292 |
inLine = QEngineeringLineItem(vertices=[self.start_point(), _pos]) |
|
2293 |
inLine.transfer.onRemoved.connect(App.mainWnd().itemRemoved) |
|
2294 |
inLine.lineType = self.lineType |
|
2295 |
|
|
2296 |
outLine = QEngineeringLineItem(vertices=[_pos, self.end_point()]) |
|
2297 |
outLine.transfer.onRemoved.connect(App.mainWnd().itemRemoved) |
|
2298 |
outLine.lineType = self.lineType |
|
2299 |
|
|
2300 |
inLine.connectors[0].connect(self.connectors[0].connectedItem, self.connectors[0]._connected_at) |
|
2301 |
inLine.connectors[1].connect(outLine) |
|
2302 |
outLine.connectors[0].connect(inLine) |
|
2303 |
outLine.connectors[1].connect(self.connectors[1].connectedItem, self.connectors[1]._connected_at) |
|
2304 |
|
|
2305 |
if savedConnectors[0]: |
|
2306 |
savedConnectors[0].connect(inLine) |
|
2307 |
if savedConnectors[1]: |
|
2308 |
savedConnectors[1].connect(outLine) |
|
2309 |
|
|
2310 |
self.scene().addItem(inLine) |
|
2311 |
self.scene().addItem(outLine) |
|
2312 |
self.transfer.onRemoved.emit(self) |
|
2313 |
|
|
2270 | 2314 |
def contextFreeze(self): |
2271 | 2315 |
from App import App |
2272 | 2316 |
|
내보내기 Unified diff