-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
lnetd_l1scene.py
90 lines (77 loc) · 2.84 KB
/
lnetd_l1scene.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtCore import Qt, QSize, QTimer, QPointF, QRectF, QMetaObject, QRect , QCoreApplication, QPoint, QLineF , pyqtSlot
from PyQt5.QtGui import QPainter, QBrush, QPen, QFont, QIcon, QTransform, QPalette, QColor
from PyQt5.QtWidgets import (
QApplication,
QWidget,
QVBoxLayout,
QFrame,
QCheckBox,
QHBoxLayout,
QLineEdit,
QPushButton,
QMessageBox,
QFileDialog,
QSizePolicy,
QMenu,
QSlider,
QDialog,
QComboBox,
QLabel,
QSpacerItem,
QMainWindow,
QMenuBar,
QOpenGLWidget
)
class L1Scene(QtWidgets.QGraphicsScene):
#nodeDown = QtCore.Signal(object)
l1nodeDown = QtCore.pyqtSignal(object,object)
l1nodeUp = QtCore.pyqtSignal(object,object)
circuitUp = QtCore.pyqtSignal(object,object)
circuitDown = QtCore.pyqtSignal(object,object)
load_l1_topology = QtCore.pyqtSignal(object)
load_l1_dummy_topology = QtCore.pyqtSignal(object)
def __init__(self, parent=None):
super(L1Scene, self).__init__(parent)
self.setItemIndexMethod(QtWidgets.QGraphicsScene.NoIndex)
def mousePressEvent(self, event):
self.update()
super(L1Scene, self).mousePressEvent(event)
def mouseMoveEvent(self, event):
self.update()
super(L1Scene, self).mouseMoveEvent(event)
def mouseReleaseEvent(self, event):
self.update()
super(L1Scene, self).mouseReleaseEvent(event)
#--->Handle Item actions, links them to signal for mainwindow
def handleNodeActionDown(self, nodeItem, message):
"""to handle node changes"""
self.l1nodeDown.emit(self,nodeItem)
def handleNodeActionUp(self, nodeItem, message):
"""to handle node changes"""
self.l1nodeUp.emit(self,nodeItem)
def handleInterfaceActionDown(self, interfaceItem, message):
"""to handle node changes"""
self.circuitDown.emit(self,interfaceItem)
def handleInterfaceActionUp(self, interfaceItem, message):
"""to handle node changes"""
self.circuitUp.emit(self,interfaceItem)
def contextMenuEvent(self,event):
item = self.itemAt(event.scenePos().x(),event.scenePos().y(),QtGui.QTransform())
if item:
try:
item.contextMenuEvent(event)
return
except:
pass
else:
cmenu = QMenu()
load_l1_topology = cmenu.addAction("Load L1 Topology")
load_l1_dummy_topology = cmenu.addAction("Load Dummy L1 Topology")
action = cmenu.exec_(event.screenPos())
if action == load_l1_dummy_topology:
self.load_l1_dummy_topology.emit(self)
elif action == load_l1_topology:
self.load_l1_topology.emit(self)
#dont propagate event
#super(GraphicsScene, self).contextMenuEvent(event)