Version: 8.3.0
cataitems.py
Go to the documentation of this file.
1 # Copyright (C) 2006-2016 CEA/DEN, EDF R&D
2 #
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
7 #
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
12 #
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 #
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 #
19 
20 from qt import *
21 
22 import Item
23 import CONNECTOR
24 import Items
25 
26 class Obj(Item.Item):
27  def __init__(self,root=None):
28  Item.Item.__init__(self)
29  if root:
30  self.root=root
31  else:
32  self.root=self
33 
34  def selected(self):
35  if not self.emitting:
36  self.emitting=1
37  CONNECTOR.Emit(self.root,"selected",self)
38  self.emitting=0
39 
40  def panel(self,parent):
41  """Retourne un tab widget pour browser/editer la proc"""
42  tabWidget = QTabWidget( parent )
43  for name,method in self.panels:
44  tabWidget.addTab( method(self,tabWidget), name )
45  return tabWidget
46 
47  box=panel
48 
49  def panel1(self,parent):
50  qvbox=QVBox(parent)
51  self.text=QTextEdit(qvbox,"log")
52  self.text.setFrameShape(QTextEdit.NoFrame)
53  self.text.setTextFormat(QTextEdit.PlainText)
54  self.text.setWordWrap(QTextEdit.FixedColumnWidth)
55  #self.text.setWrapColumnOrWidth(120)
56  self.text.setReadOnly(1)
57  return qvbox
58 
59  panels=[("Panel1",panel1)]
60 
62  def __init__(self,service,root):
63  Item.Item.__init__(self)
64  self.root=root
65  self.service=service
66  self.label=service.getName()
67 
68  def isExpandable(self):
69  return True
70 
71  def addNode(self,appli):
72  appli.addNode(self.service)
73 
74  def getChildren(self):
75  sublist=[]
76  for port in self.service.getSetOfInputPort():
77  sublist.append(Items.ItemInPort(port,self.root))
78  for port in self.service.getSetOfOutputPort():
79  sublist.append(Items.ItemOutPort(port,self.root))
80  for port in self.service.getSetOfInputDataStreamPort():
81  sublist.append(Items.ItemInStream(port,self.root))
82  for port in self.service.getSetOfOutputDataStreamPort():
83  sublist.append(Items.ItemOutStream(port,self.root))
84  return sublist
85 
86  def selected(self):
87  if not self.emitting:
88  self.emitting=1
89  CONNECTOR.Emit(self.root,"selected",self)
90  self.emitting=0
91 
93  def __init__(self,typ,root,name=""):
94  Item.Item.__init__(self)
95  self.typ=typ
96  self.root=root
97  if name:
98  self.label=name
99  else:
100  self.label=typ.name()
101 
102  def isExpandable(self):
103  return True
104 
105  def getChildren(self):
106  sublist=[]
107  return sublist
108 
109  def selected(self):
110  if not self.emitting:
111  self.emitting=1
112  CONNECTOR.Emit(self.root,"selected",self)
113  self.emitting=0
114 
116  def __init__(self,compo,root):
117  Item.Item.__init__(self)
118  self.compo=compo
119  self.root=root
120  self.label=compo.getName()
121 
122  def isExpandable(self):
123  return True
124 
125  def getChildren(self):
126  sublist=[]
127  for service in self.compo._serviceMap.values():
128  itemservice=ItemService(service,self.root)
129  sublist.append(itemservice)
130  return sublist
131 
132  def selected(self):
133  if not self.emitting:
134  self.emitting=1
135  CONNECTOR.Emit(self.root,"selected",self)
136  self.emitting=0
137 
139  def __init__(self,node,root):
140  Item.Item.__init__(self)
141  self.node=node
142  self.root=root
143  self.label=node.getName()
144 
145  def isExpandable(self):
146  return True
147 
148  def addNode(self,appli):
149  appli.addNode(self.node)
150 
151  def getChildren(self):
152  sublist=[]
153  return sublist
154 
155  def selected(self):
156  if not self.emitting:
157  self.emitting=1
158  CONNECTOR.Emit(self.root,"selected",self)
159  self.emitting=0
160 
162  def __init__(self,node,root):
163  Item.Item.__init__(self)
164  self.node=node
165  self.root=root
166  self.label=node.getName()
167 
168  def addNode(self,appli):
169  appli.addNode(self.node)
170 
171  def isExpandable(self):
172  return True
173 
174  def getChildren(self):
175  sublist=[]
176  return sublist
177 
178  def selected(self):
179  if not self.emitting:
180  self.emitting=1
181  CONNECTOR.Emit(self.root,"selected",self)
182  self.emitting=0
183 
185  """Item for types folder"""
186  def __init__(self,typeMap,root):
187  Item.Item.__init__(self)
188  self.typeMap=typeMap
189  self.label="Types"
190  self.root=root
191 
192  def getIconName(self):
193  return "folder"
194 
195  def isExpandable(self):
196  return True
197 
198  def getChildren(self):
199  sublist=[]
200  for name,typ in self.typeMap.items():
201  itemtype=ItemType(typ,self.root,name)
202  sublist.append(itemtype)
203  return sublist
204 
206  """Item for components folder"""
207  def __init__(self,compoMap,root):
208  Item.Item.__init__(self)
209  self.compoMap=compoMap
210  self.label="Components"
211  self.root=root
212 
213  def getIconName(self):
214  return "folder"
215 
216  def isExpandable(self):
217  return True
218 
219  def getChildren(self):
220  sublist=[]
221  for compo in self.compoMap.values():
222  itemcompo=ItemCompo(compo,self.root)
223  sublist.append(itemcompo)
224  return sublist
225 
227  """Item for nodes folder"""
228  def __init__(self,nodesMap,root):
229  Item.Item.__init__(self)
230  self.nodesMap=nodesMap
231  self.label="Nodes"
232  self.root=root
233 
234  def getIconName(self):
235  return "folder"
236 
237  def isExpandable(self):
238  return True
239 
240  def getChildren(self):
241  sublist=[]
242  for node in self.nodesMap.values():
243  itemnode=ItemNode(node,self.root)
244  sublist.append(itemnode)
245  return sublist
246 
248  """Item for composed nodes folder"""
249  def __init__(self,composedMap,root):
250  Item.Item.__init__(self)
251  self.composedMap=composedMap
252  self.label="ComposedNodes"
253  self.root=root
254 
255  def getIconName(self):
256  return "folder"
257 
258  def isExpandable(self):
259  return True
260 
261  def getChildren(self):
262  sublist=[]
263  for node in self.composedMap.values():
264  itemnode=ItemComposedNode(node,self.root)
265  sublist.append(itemnode)
266  return sublist
267 
268 class Cata(Obj):
269  def __init__(self,cata):
270  Obj.__init__(self)
271  self.cata=cata
272  self.label=cata.getName()
273 
274  def isExpandable(self):
275  return True
276 
277  def getChildren(self):
278  sublist=[]
279  sublist.append(TypesItem(self.cata._typeMap,self))
280  sublist.append(NodesItem(self.cata._nodeMap,self))
281  sublist.append(ComposedNodesItem(self.cata._composednodeMap,self))
282  sublist.append(ComponentsItem(self.cata._componentMap,self))
283  return sublist
284 
285  def dblselected(self):
286  if not self.emitting:
287  self.emitting=1
288  CONNECTOR.Emit(self,"dblselected",self)
289  self.emitting=0
290