Version: 9.15.0
gui.GraphViewer.GraphViewer Class Reference
Inheritance diagram for gui.GraphViewer.GraphViewer:
Collaboration diagram for gui.GraphViewer.GraphViewer:

Public Member Functions

def __init__ (self, c, parent, name, f)
 
def contentsMouseDoubleClickEvent (self, e)
 
def contentsMousePressEvent (self, e)
 
def selectItem (self, item)
 
def selectObj (self, obj)
 
def deselectObj (self, obj)
 
def popup (self)
 
def updateCanvas (self)
 
def addNode (self)
 
def zoomIn (self)
 
def zoomOut (self)
 
def clear (self)
 
def connecting (self, obj)
 
def contentsMouseMoveEvent (self, e)
 

Public Attributes

 selectPen
 
 selectBrush
 
 selectStyle
 
 selected
 
 tooltip
 

Private Attributes

 __moving
 
 __connecting
 
 __moving_start
 

Detailed Description

Definition at line 41 of file GraphViewer.py.

Constructor & Destructor Documentation

◆ __init__()

def gui.GraphViewer.GraphViewer.__init__ (   self,
  c,
  parent,
  name,
  f 
)

Definition at line 42 of file GraphViewer.py.

42  def __init__(self,c,parent,name,f):
43  QCanvasView.__init__(self,c,parent,name,f)
44  self.__moving=0
45  self.__connecting=0
46  self.__moving_start= 0
47  # for highlighting selections
48  self.selectPen=QPen(QColor(255,255,0),2,Qt.DashLine)
49  self.selectBrush=QBrush(Qt.red)
50  self.selectStyle = Qt.Dense5Pattern
51  self.selected=None
52  self.tooltip = DynamicTip( self )
53 

Member Function Documentation

◆ addNode()

def gui.GraphViewer.GraphViewer.addNode (   self)

Definition at line 164 of file GraphViewer.py.

164  def addNode(self):
165  print("addNode")
166 

Referenced by gui.GraphViewer.GraphViewer.popup().

◆ clear()

def gui.GraphViewer.GraphViewer.clear (   self)

Definition at line 177 of file GraphViewer.py.

177  def clear(self):
178  ilist = self.canvas().allItems()
179  for each_item in ilist:
180  if each_item:
181  each_item.setCanvas(None)
182  del each_item
183  self.canvas().update()
184 

References gui.CItems.LinkItem.canvas, and gui.graph.Graph.canvas.

◆ connecting()

def gui.GraphViewer.GraphViewer.connecting (   self,
  obj 
)
Method called by an item to notify canvasView a connection has begun

Definition at line 185 of file GraphViewer.py.

185  def connecting(self,obj):
186  """Method called by an item to notify canvasView a connection has begun"""
187  print("connecting",obj)
188  self.__connecting=obj
189 

References gui.GraphViewer.GraphViewer.__connecting.

◆ contentsMouseDoubleClickEvent()

def gui.GraphViewer.GraphViewer.contentsMouseDoubleClickEvent (   self,
  e 
)

Definition at line 54 of file GraphViewer.py.

54  def contentsMouseDoubleClickEvent(self,e): # QMouseEvent e
55  point = self.inverseWorldMatrix().map(e.pos())
56  ilist = self.canvas().collisions(point) #QCanvasItemList ilist
57  for each_item in ilist:
58  if each_item.rtti()==984376:
59  if not each_item.hit(point):
60  continue
61  if e.button()== Qt.LeftButton:
62  if hasattr(each_item,"handleDoubleClick"):
63  each_item.handleDoubleClick(point)
64  self.canvas().update()
65  return
66 
67 

References gui.CItems.LinkItem.canvas, and gui.graph.Graph.canvas.

◆ contentsMouseMoveEvent()

def gui.GraphViewer.GraphViewer.contentsMouseMoveEvent (   self,
  e 
)

Definition at line 190 of file GraphViewer.py.

190  def contentsMouseMoveEvent(self,e):
191  if self.__moving :
192  point = self.inverseWorldMatrix().map(e.pos())
193  self.__moving.moveBy(point.x()-self.__moving_start.x(),point.y()-self.__moving_start.y())
194  self.__moving_start = point
195  self.canvas().update()
196  else:
197  #self.tooltip.maybeTip(point)
198  QCanvasView.contentsMouseMoveEvent(self,e)
199 

References gui.GraphViewer.GraphViewer.__moving, gui.GraphViewer.GraphViewer.__moving_start, gui.CItems.LinkItem.canvas, and gui.graph.Graph.canvas.

◆ contentsMousePressEvent()

def gui.GraphViewer.GraphViewer.contentsMousePressEvent (   self,
  e 
)

Definition at line 68 of file GraphViewer.py.

68  def contentsMousePressEvent(self,e): # QMouseEvent e
69  p=e.globalPos()
70  point = self.inverseWorldMatrix().map(e.pos())
71  ilist = self.canvas().collisions(point) #QCanvasItemList ilist
72  for each_item in ilist:
73  if each_item.rtti()==984376:
74  if not each_item.hit(point):
75  continue
76  if e.button()== Qt.RightButton:
77  #Right button click
78  self.__moving=0
79  self.__connecting=0
80  if hasattr(each_item,"popup"):
81  menu=each_item.popup(self)
82  if menu:
83  menu.exec_loop( QCursor.pos() )
84  self.canvas().update()
85  elif hasattr(each_item,"getObj"):
86  menu=each_item.getObj().popup(self)
87  if menu:
88  menu.exec_loop( QCursor.pos() )
89  self.canvas().update()
90 
91  elif e.button()== Qt.LeftButton:
92  #Left button click
93  if self.__connecting:
94  #We are linking objects
95  if hasattr(each_item,"getObj"):
96  #a connection is ending
97  self.__connecting.link(each_item.getObj().item)
98  #self.__connecting.link(each_item.getObj())
99  self.canvas().update()
100  self.__connecting=0
101  else:
102  #We are moving or selecting a composite object
103  each_item.selected()
104  self.__moving=each_item
105  self.__moving_start=point
106  self.canvas().update()
107  return
108  if e.button()== Qt.RightButton:
109  menu=self.popup()
110  if menu:
111  menu.exec_loop( QCursor.pos() )
112  self.canvas().update()
113  self.__moving=0
114  self.__connecting=0
115  QCanvasView.contentsMousePressEvent(self,e)
116 

References gui.GraphViewer.GraphViewer.__connecting, gui.GraphViewer.GraphViewer.__moving, gui.GraphViewer.GraphViewer.__moving_start, gui.CItems.LinkItem.canvas, gui.graph.Graph.canvas, gui.GraphViewer.GraphViewer.popup(), gui.CItems.LinkItem.popup(), gui.CItems.ControlItem.popup(), gui.CItems.PortItem.popup(), gui.CItems.Cell.popup(), gui.GraphViewer.LinkItem.popup(), gui.GraphViewer.PortItem.popup(), and gui.GraphViewer.Cell.popup().

◆ deselectObj()

def gui.GraphViewer.GraphViewer.deselectObj (   self,
  obj 
)

Definition at line 141 of file GraphViewer.py.

141  def deselectObj(self,obj):
142  if obj:
143  obj.setPen(obj._origPen)
144  #obj.setBrush(obj._origBrush)
145 

Referenced by gui.GraphViewer.GraphViewer.selectItem().

◆ popup()

def gui.GraphViewer.GraphViewer.popup (   self)

◆ selectItem()

def gui.GraphViewer.GraphViewer.selectItem (   self,
  item 
)

◆ selectObj()

def gui.GraphViewer.GraphViewer.selectObj (   self,
  obj 
)

Definition at line 133 of file GraphViewer.py.

133  def selectObj(self,obj):
134  if obj:
135  obj._origPen = obj.pen()
136  obj._origBrush = obj.brush()
137  obj._origStyle = obj.brush().style()
138  obj.setPen(self.selectPen)
139  #obj.setBrush(self.selectBrush)
140 

References gui.GraphViewer.GraphViewer.selectPen.

Referenced by gui.GraphViewer.GraphViewer.selectItem().

◆ updateCanvas()

def gui.GraphViewer.GraphViewer.updateCanvas (   self)

Definition at line 157 of file GraphViewer.py.

157  def updateCanvas(self):
158  #Par defaut, Qt n'efface pas le background. Seul repaintContents
159  #semble le faire. Utile apres un popup ou un resize avec scrollbars
160  #Peut-on l'utiliser partout ? Pb de performance ?
161  self.repaintContents(True)
162  #self.canvas().update()
163 

◆ zoomIn()

def gui.GraphViewer.GraphViewer.zoomIn (   self)

Definition at line 167 of file GraphViewer.py.

167  def zoomIn(self):
168  m = self.worldMatrix()
169  m.scale( 2.0, 2.0 )
170  self.setWorldMatrix( m )
171 

◆ zoomOut()

def gui.GraphViewer.GraphViewer.zoomOut (   self)

Definition at line 172 of file GraphViewer.py.

172  def zoomOut(self):
173  m = self.worldMatrix()
174  m.scale( 0.5, 0.5 )
175  self.setWorldMatrix( m )
176 

Member Data Documentation

◆ __connecting

gui.GraphViewer.GraphViewer.__connecting
private

◆ __moving

gui.GraphViewer.GraphViewer.__moving
private

◆ __moving_start

gui.GraphViewer.GraphViewer.__moving_start
private

◆ selectBrush

gui.GraphViewer.GraphViewer.selectBrush

Definition at line 49 of file GraphViewer.py.

◆ selected

gui.GraphViewer.GraphViewer.selected

◆ selectPen

gui.GraphViewer.GraphViewer.selectPen

Definition at line 48 of file GraphViewer.py.

Referenced by gui.GraphViewer.GraphViewer.selectObj().

◆ selectStyle

gui.GraphViewer.GraphViewer.selectStyle

Definition at line 50 of file GraphViewer.py.

◆ tooltip

gui.GraphViewer.GraphViewer.tooltip

Definition at line 52 of file GraphViewer.py.


The documentation for this class was generated from the following file: