Add a PoC of moving vertices in the visualisation
This implementation is really barebones, mostly-broken (each vertex can only remember one line), but demonstrates that implementing moving is going to be quite simple.moving_topology
parent
ac3508727d
commit
21dbc83ff5
@ -0,0 +1,23 @@
|
|||||||
|
from PySide6.QtWidgets import QGraphicsRectItem
|
||||||
|
from PySide6.QtCore import QLineF
|
||||||
|
|
||||||
|
class MyGraphicsRectItem(QGraphicsRectItem):
|
||||||
|
#def __init__(self, *a, **kwa):
|
||||||
|
# return super().__init__(*a, **kwa)
|
||||||
|
#def itemChange(self, change, val):
|
||||||
|
# return super().itemChange(change, val)
|
||||||
|
def mouseMoveEvent(self, evt):
|
||||||
|
print(f'Moving: {self}')
|
||||||
|
line = self.data(0)
|
||||||
|
other_end = line.data(0)
|
||||||
|
if other_end == self:
|
||||||
|
other_end = line.data(1)
|
||||||
|
new_qlinef = QLineF(
|
||||||
|
self.x(),
|
||||||
|
self.y(),
|
||||||
|
other_end.x(),
|
||||||
|
other_end.y(),
|
||||||
|
)
|
||||||
|
line.setLine(new_qlinef)
|
||||||
|
return super().mouseMoveEvent(evt)
|
||||||
|
|
Loading…
Reference in New Issue