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

Public Member Functions

def __init__
 
def contentsMouseDoubleClickEvent
 
def contentsMousePressEvent
 
def selectItem
 
def selectObj
 
def deselectObj
 
def popup
 
def updateCanvas
 
def addNode
 
def zoomIn
 
def zoomOut
 
def clear
 
def connecting
 
def contentsMouseMoveEvent
 

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

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

Definition at line 42 of file GraphViewer.py.

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

Member Function Documentation

def gui.GraphViewer.GraphViewer.addNode (   self)

Definition at line 164 of file GraphViewer.py.

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

165  def addNode(self):
166  print "addNode"
def gui.GraphViewer.GraphViewer.clear (   self)

Definition at line 177 of file GraphViewer.py.

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

178  def clear(self):
179  ilist = self.canvas().allItems()
180  for each_item in ilist:
181  if each_item:
182  each_item.setCanvas(None)
183  del each_item
184  self.canvas().update()
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.

References gui.GraphViewer.GraphViewer.__connecting.

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

Definition at line 54 of file GraphViewer.py.

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

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

Definition at line 190 of file GraphViewer.py.

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

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

Definition at line 68 of file GraphViewer.py.

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

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

Definition at line 141 of file GraphViewer.py.

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

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

Definition at line 146 of file GraphViewer.py.

References gui.cataitems.ItemService.addNode(), gui.cataitems.ItemNode.addNode(), gui.GraphViewer.GraphViewer.addNode(), gui.cataitems.ItemComposedNode.addNode(), YACS::HMI::SubjectComposedNode.addNode(), gui.Appli.Appli.addNode(), YACS::HMI::SubjectBloc.addNode(), YACS::HMI::SubjectForLoop.addNode(), YACS::HMI::SubjectWhileLoop.addNode(), YACS::HMI::SubjectSwitch.addNode(), and YACS::HMI::SubjectDynParaLoop.addNode().

Referenced by gui.GraphViewer.GraphViewer.contentsMousePressEvent().

147  def popup(self):
148  menu=QPopupMenu()
149  caption = QLabel( "<font color=darkblue><u><b>View Menu</b></u></font>", self )
150  caption.setAlignment( Qt.AlignCenter )
151  menu.insertItem( caption )
152  menu.insertItem("add Node", self.addNode)
153  return menu
def gui.GraphViewer.GraphViewer.selectItem (   self,
  item 
)

Definition at line 117 of file GraphViewer.py.

References gui.graph.Graph.canvas, gui.CItems.LinkItem.canvas, gui.GraphViewer.GraphViewer.deselectObj(), gui.browser.Browser.selected, gui.GraphViewer.GraphViewer.selected, gui.Appli.Browser.selected, and gui.GraphViewer.GraphViewer.selectObj().

Referenced by gui.Tree.Tree.additem().

118  def selectItem(self,item):
119  #print "selectItem",item
120  if self.selected:
121  try:
122  self.deselectObj(self.selected)
123  except:
124  pass
125  self.selected=None
126  #need to find equivalent canvas item
127  for citem in self.canvas().allItems():
128  if hasattr(citem,"item") and citem.item is item:
129  self.selected=citem
130  self.selectObj(self.selected)
131  break
132  self.canvas().update()
def gui.GraphViewer.GraphViewer.selectObj (   self,
  obj 
)

Definition at line 133 of file GraphViewer.py.

References gui.GraphViewer.GraphViewer.selectPen.

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

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

Definition at line 157 of file GraphViewer.py.

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

Definition at line 167 of file GraphViewer.py.

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

Definition at line 172 of file GraphViewer.py.

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

Member Data Documentation

gui.GraphViewer.GraphViewer.__connecting
private

Definition at line 45 of file GraphViewer.py.

Referenced by gui.GraphViewer.GraphViewer.connecting(), and gui.GraphViewer.GraphViewer.contentsMousePressEvent().

gui.GraphViewer.GraphViewer.__moving
private

Definition at line 44 of file GraphViewer.py.

Referenced by gui.GraphViewer.GraphViewer.contentsMouseMoveEvent(), and gui.GraphViewer.GraphViewer.contentsMousePressEvent().

gui.GraphViewer.GraphViewer.__moving_start
private

Definition at line 46 of file GraphViewer.py.

Referenced by gui.GraphViewer.GraphViewer.contentsMouseMoveEvent(), and gui.GraphViewer.GraphViewer.contentsMousePressEvent().

gui.GraphViewer.GraphViewer.selectBrush

Definition at line 49 of file GraphViewer.py.

gui.GraphViewer.GraphViewer.selected

Definition at line 51 of file GraphViewer.py.

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

gui.GraphViewer.GraphViewer.selectPen

Definition at line 48 of file GraphViewer.py.

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

gui.GraphViewer.GraphViewer.selectStyle

Definition at line 50 of file GraphViewer.py.

gui.GraphViewer.GraphViewer.tooltip

Definition at line 52 of file GraphViewer.py.


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