CMS 3D CMS Logo

ConfigEditorBoxView.py
Go to the documentation of this file.
1 import logging
2 
3 from PyQt4.QtCore import Qt,QCoreApplication,SIGNAL
4 
5 from Vispa.Main.Application import Application
6 from Vispa.Views.BoxDecayView import BoxDecayView
7 from Vispa.Gui.PortConnection import PortConnection,PointToPointConnection
8 from Vispa.Gui.ConnectableWidget import ConnectableWidget
9 from Vispa.Gui.WidgetContainer import WidgetContainer
10 
12  """
13  """
14 
15  LABEL="ConfigEditor BoxView"
16 
17  def __init__(self, parent=None,label=""):
18  logging.debug(__name__ + ": __init__")
19  BoxDecayView.__init__(self, parent)
20  self._connections = {}
21  self._colors = [Qt.red, Qt.green, Qt.blue, Qt.cyan, Qt.magenta]
22  self._colorIndex = 0
23  PointToPointConnection.CONNECTION_THICKNESS=2
24  self.setSortBeforeArranging(False)
27 
28  def connections(self):
29  return self._connections
30 
31  def setConnections(self, connections):
32  """ Sets the connections between the objects.
33 
34  You need to call updateContent() in order to make the changes visible.
35  """
36  self._colorIndex = 0
37  self._connections = connections
38 
39  def createBox(self, widgetParent, container, title, text):
40  widget=BoxDecayView.createBox(self, widgetParent, container, title, text)
41  widget.setToolTip("Double click to display this module with its dependencies")
42  return widget
43 
44  def createConnections(self, operationId, widgetParent):
45  for connection,values in self._connections.items():
46  # Process application event loop in order to accept user input during time consuming drawing operation
47  self._updateCounter+=1
48  if self._updateCounter>=self.UPDATE_EVERY:
50  if not Application.NO_PROCESS_EVENTS:
51  QCoreApplication.instance().processEvents()
52  # Abort drawing if operationId out of date
53  if operationId != self._operationId:
54  return None
55  w1 = self.widgetByObject(connection[0])
56  w2 = self.widgetByObject(connection[1])
57  if w1 and w2:
58  if hasattr(w1,"colorIndex"):
59  col = w1.colorIndex
60  else:
61  self._colorIndex += 1
62  if self._colorIndex >= len(self._colors):
63  self._colorIndex = 0
64  col = self._colorIndex
65  w1.colorIndex=col
66  w2.colorIndex=col
67  connectionWidget = self.createConnection(w1, values[0], w2, values[1], self._colors[col])
68  connectionWidget.show()
69  return True
70 
71  def highlight(self, objects=None):
72  """ Mark objects.
73  """
74  if objects!=None:
75  self._highlightedObjects=objects
76  for widget in self._highlightedWidgets:
77  if isinstance(widget,ConnectableWidget):
78  widget.setColors(ConnectableWidget.PEN_COLOR,
79  ConnectableWidget.FILL_COLOR1,
80  ConnectableWidget.FILL_COLOR2)
81  elif isinstance(widget,WidgetContainer):
82  widget.setColors(WidgetContainer.PEN_COLOR,
83  WidgetContainer.FILL_COLOR1,
84  WidgetContainer.FILL_COLOR2)
85  widget.update()
86  self._highlightedWidgets=[]
87  for object in self._highlightedObjects:
88  widget = self.widgetByObject(object)
89  if widget==None:
90  continue
91  if isinstance(widget,ConnectableWidget):
92  widget.setColors(ConnectableWidget.PEN_COLOR.darker(),
93  ConnectableWidget.FILL_COLOR1,
94  ConnectableWidget.FILL_COLOR2)
95  elif isinstance(widget,WidgetContainer):
96  widget.setColors(WidgetContainer.PEN_COLOR.darker(),
97  WidgetContainer.FILL_COLOR1,
98  WidgetContainer.FILL_COLOR2)
99  widget.update()
100  self._highlightedWidgets+=[widget]
101 
102  def updateContent(self,overrideCheck=False):
103  self._highlightedWidgets=[]
104  ok=BoxDecayView.updateContent(self,overrideCheck)
105  self.highlight()
106  return ok
107 
109  LABEL="Connection structure"
110 
112  LABEL="Sequence structure"
113 
def createBox(self, widgetParent, container, title, text)
def widgetByObject(self, object)
Definition: WidgetView.py:52
def createConnection(self, w1, name1, w2, name2, color=None, portsVisible=True)