Salome HOME
00a9f95017d935341b9ed1ccb13a4445896a19ef
[modules/yacs.git] / src / genericgui / GenericGui.cxx
1 //  Copyright (C) 2006-2008  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.
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 #include <Python.h>
20 #include "SALOME_ResourcesManager.hxx"
21 #include "SALOME_LifeCycleCORBA.hxx"
22
23 #include "RuntimeSALOME.hxx"
24 #include "Proc.hxx"
25 #include "parsers.hxx"
26 #include "Logger.hxx"
27 #include "YACSGuiLoader.hxx"
28
29 #include "SALOME_NamingService.hxx"
30 #include "SALOME_ModuleCatalog.hxx"
31 #include "SALOME_ModuleCatalog.hh"
32 #include "SALOMEDS_Tool.hxx"
33
34 #include "QtGuiContext.hxx"
35
36 #include "GuiEditor.hxx"
37 #include "GraphicsView.hxx"
38 #include "Scene.hxx"
39 #include "GenericGui.hxx"
40 #include "SceneItem.hxx"
41 #include "ItemEdition.hxx"
42 #include "CatalogWidget.hxx"
43 #include "TreeView.hxx"
44 #include "VisitorSaveGuiSchema.hxx"
45 #include "TypeCode.hxx"
46 #include "LinkInfo.hxx"
47 #include "LogViewer.hxx"
48
49 #include <QFileDialog>
50 #include <sstream>
51 #include <QDir>
52 #include <QDateTime>
53 #include <QMessageBox>
54 #include <QWhatsThis>
55
56 #include <cstdlib>
57
58 #include <ctime>
59
60 //#define _DEVDEBUG_
61 #include "YacsTrace.hxx"
62
63 using namespace std;
64 using namespace YACS::HMI;
65
66 GenericGui::GenericGui(YACS::HMI::SuitWrapper* wrapper, QMainWindow *parent)
67 {
68   _wrapper = wrapper;
69   _parent = parent;
70   _dwTree = 0;
71   _dwStacked = 0;
72   _dwCatalogs = 0;
73   _catalogsWidget = 0;
74   _sessionCatalog = 0;
75   _schemaCnt = 0;
76   _mapViewContext.clear();
77   _machineList.clear();
78   _menuId = 190;
79
80   GuiObserver::setEventMap();
81
82   string iconPath = getenv("YACS_ROOT_DIR");
83   iconPath += "/share/salome/resources/yacs";
84   DEBTRACE(iconPath);
85   QDir::addSearchPath("icons", iconPath.c_str());
86
87   YACS::ENGINE::RuntimeSALOME::setRuntime();
88   _loader = new YACSGuiLoader();
89   _loader->registerProcCataLoader();
90   _builtinCatalog = YACS::ENGINE::getSALOMERuntime()->getBuiltinCatalog();
91
92   try
93     {
94       YACS::ENGINE::RuntimeSALOME* runTime = YACS::ENGINE::getSALOMERuntime();
95       CORBA::ORB_ptr orb = runTime->getOrb();
96       if (orb)
97         {
98           SALOME_NamingService namingService(orb);
99           CORBA::Object_ptr obj = namingService.Resolve("/Kernel/ModulCatalog");
100           SALOME_ModuleCatalog::ModuleCatalog_var aModuleCatalog =
101             SALOME_ModuleCatalog::ModuleCatalog::_narrow(obj);
102           if (! CORBA::is_nil(aModuleCatalog))
103             {
104               DEBTRACE("SALOME_ModuleCatalog::ModuleCatalog found");
105               std::string anIOR = orb->object_to_string( aModuleCatalog );
106               _sessionCatalog = runTime->loadCatalog( "session", anIOR );
107               {
108                 std::map< std::string, YACS::ENGINE::ComponentDefinition * >::iterator it;
109                 for (it = _sessionCatalog->_componentMap.begin();
110                      it != _sessionCatalog->_componentMap.end(); ++it)
111                   DEBTRACE("Component: " <<(*it).first);
112               }
113               {
114                 std::map< std::string, YACS::ENGINE::TypeCode*>::iterator it;
115                 for (it = _sessionCatalog->_typeMap.begin();
116                      it != _sessionCatalog->_typeMap.end(); ++it)
117                   DEBTRACE("Type : " <<(*it).first
118                            << " " << (*it).second->getKindRepr()
119                            << " " << (*it).second->name()
120                            << " " << (*it).second->shortName()
121                            << " " << (*it).second->id() );
122               }
123               DEBTRACE("_sessionCatalog " << _sessionCatalog);
124             }
125         }
126     }
127   catch(ServiceUnreachable& e)
128     {
129       DEBTRACE("Caught Exception. "<<e);
130     }
131
132   _dwTree = new QDockWidget(_parent);
133   _dwTree->setWindowTitle("Tree View: edition mode");
134   _parent->addDockWidget(Qt::LeftDockWidgetArea, _dwTree);
135   _dwStacked = new QDockWidget(_parent);
136   _dwStacked->setWindowTitle("Input Panel");
137   _parent->addDockWidget(Qt::RightDockWidgetArea, _dwStacked);
138   _dwCatalogs = new QDockWidget(_parent);
139   _dwCatalogs->setWindowTitle("Catalogs");
140   _parent->addDockWidget(Qt::RightDockWidgetArea, _dwCatalogs);
141   _catalogsWidget = new CatalogWidget(_dwCatalogs,
142                                       _builtinCatalog,
143                                       _sessionCatalog);
144   _catalogsWidget->setMinimumWidth(350); // --- force a minimum until display
145   _dwCatalogs->setWidget(_catalogsWidget);
146   _parent->tabifyDockWidget(_dwStacked, _dwCatalogs);
147 }
148
149 GenericGui::~GenericGui()
150 {
151 }
152
153 void GenericGui::createActions()
154 {
155 //       QAction* createAction(const int id,
156 //                             const QString& toolTip,
157 //                             const QIcon& icon,
158 //                             const QString& menu,
159 //                             const QString& status,
160 //                             const int shortCut,
161 //                             QObject* parent =0,
162 //                             bool checkable = false,
163 //                             QObject* receiver =0,
164 //                             const char* member =0);
165
166   QPixmap pixmap;
167
168   pixmap.load("icons:new_dataflow.png");
169   _newSchemaAct = _wrapper->createAction(getMenuId(), tr("Create a new YACS Schema"), QIcon(pixmap),
170                                          tr("New Schema"), tr("Create a new YACS Schema"),
171                                          0, _parent, false, this,  SLOT(onNewSchema()));
172   
173   pixmap.load("icons:import_dataflow.png");
174   _importSchemaAct = _wrapper->createAction(getMenuId(), tr("Import a YACS Schema for edition"), QIcon(pixmap),
175                                             tr("Import Schema"), tr("Import a YACS Schema for edition"),
176                                             0, _parent, false, this,  SLOT(onImportSchema()));
177   
178   pixmap.load("icons:import_superv_dataflow.png");
179   _importSupervSchemaAct = _wrapper->createAction(getMenuId(), tr("Import a SUPERV Schema for edition"), QIcon(pixmap),
180                                                   tr("Import SUPERV Schema"), tr("Import a SUPERV Schema for edition"),
181                                                   0, _parent, false, this,  SLOT(onImportSupervSchema()));
182   
183   pixmap.load("icons:save_dataflow.png");
184   _exportSchemaAct = _wrapper->createAction(getMenuId(), tr("Save the current YACS Schema"), QIcon(pixmap),
185                                             tr("Save Schema"), tr("Save the current YACS Schema"),
186                                             0, _parent, false, this,  SLOT(onExportSchema()));
187   
188   pixmap.load("icons:export_dataflow.png");
189   _exportSchemaAsAct = _wrapper->createAction(getMenuId(), tr("Save the current YACS Schema As..."), QIcon(pixmap),
190                                               tr("Save Schema As"), tr("Save the current YACS Schema As..."),
191                                               0, _parent, false, this,  SLOT(onExportSchemaAs()));
192
193   pixmap.load("icons:insert_file.png");
194   _importCatalogAct = _wrapper->createAction(getMenuId(), tr("Import a Schema as a Catalog"), QIcon(pixmap),
195                                               tr("Import Catalog"), tr("Import a Schema as a Catalog"),
196                                               0, _parent, false, this,  SLOT(onImportCatalog()));
197
198
199   pixmap.load("icons:run_active.png");
200   _runLoadedSchemaAct = _wrapper->createAction(getMenuId(), tr("Prepare the current edited schema for run"), QIcon(pixmap),
201                                               tr("Run Current Schema"), tr("Prepare the current edited schema for run"),
202                                               0, _parent, false, this,  SLOT(onRunLoadedSchema()));
203
204   pixmap.load("icons:load_execution_state.png");
205   _loadRunStateSchemaAct = _wrapper->createAction(getMenuId(), tr("Load a previous run state for this schema, prepare to run"), QIcon(pixmap),
206                                                   tr("Load Run State"), tr("Load a previous run state for this schema, prepare to run"),
207                                                   0, _parent, false, this,  SLOT(onLoadRunStateSchema()));
208
209   pixmap.load("icons:run.png");
210   _loadAndRunSchemaAct = _wrapper->createAction(getMenuId(), tr("Load a schema for run"), QIcon(pixmap),
211                                               tr("Load Schema to run"), tr("Load a schema for run"),
212                                               0, _parent, false, this,  SLOT(onLoadAndRunSchema()));
213
214
215   pixmap.load("icons:suspend_resume.png");
216   _startResumeAct = _wrapper->createAction(getMenuId(), tr("Start or Resume Schema execution"), QIcon(pixmap),
217                                        tr("Start/Resume execution"), tr("Start or Resume Schema execution"),
218                                        0, _parent, false, this,  SLOT(onStartResume()));
219
220   pixmap.load("icons:kill.png");
221   _abortAct = _wrapper->createAction(getMenuId(), tr("Abort the current execution"), QIcon(pixmap),
222                                      tr("Abort execution"), tr("Abort the current execution"),
223                                      0, _parent, false, this,  SLOT(onAbort()));
224
225   pixmap.load("icons:pause.png");
226   _pauseAct = _wrapper->createAction(getMenuId(), tr("Suspend the current execution"), QIcon(pixmap),
227                                      tr("Suspend execution"), tr("Suspend the current execution"),
228                                      0, _parent, false, this,  SLOT(onPause()));
229
230   pixmap.load("icons:reset.png");
231   _resetAct = _wrapper->createAction(getMenuId(), tr("Reset the current execution"), QIcon(pixmap),
232                                       tr("Reset execution"), tr("Reset the current execution"),
233                                       0, _parent, false, this,  SLOT(onReset()));
234
235
236   pixmap.load("icons:save_dataflow_state.png");
237   _saveRunStateAct = _wrapper->createAction(getMenuId(), tr("Save the current run state"), QIcon(pixmap),
238                                             tr("Save State"), tr("Save the current run state"),
239                                             0, _parent, false, this,  SLOT(onSaveRunState()));
240
241   pixmap.load("icons:new_edition.png");
242   _newEditionAct = _wrapper->createAction(getMenuId(), tr("Edit again the current schema in a new context"), QIcon(pixmap),
243                                           tr("Edit Again"), tr("Edit again the current schema in a new context"),
244                                           0, _parent, false, this,  SLOT(onNewEdition()));
245
246
247   pixmap.load("icons:change_informations.png");
248   _getYacsContainerLogAct = _wrapper->createAction(getMenuId(), tr("get YACS container log"), QIcon(pixmap),
249                                           tr("YACS Container Log"), tr("get YACS container log"),
250                                           0, _parent, false, this,  SLOT(onGetYacsContainerLog()));
251
252   pixmap.load("icons:filter_notification.png");
253   _getErrorReportAct = _wrapper->createAction(getMenuId(), tr("get Node Error Report"), QIcon(pixmap),
254                                           tr("Node Error Report"), tr("get Node Error Report"),
255                                           0, _parent, false, this,  SLOT(onGetErrorReport()));
256
257   pixmap.load("icons:icon_text.png");
258   _getErrorDetailsAct = _wrapper->createAction(getMenuId(), tr("get Node Error Details"), QIcon(pixmap),
259                                           tr("Node Error Details"), tr("get Node Error Details"),
260                                           0, _parent, false, this,  SLOT(onGetErrorDetails()));
261
262   pixmap.load("icons:change_informations.png");
263   _getContainerLogAct = _wrapper->createAction(getMenuId(), tr("get Node Container Log"), QIcon(pixmap),
264                                           tr("Node Container Log"), tr("get Node Container Log"),
265                                           0, _parent, false, this,  SLOT(onGetContainerLog()));
266
267
268
269   pixmap.load("icons:kill.png");
270   _editDataTypesAct = _wrapper->createAction(getMenuId(), tr("Edit Data Types"), QIcon(pixmap),
271                                               tr("Edit Data Types"), tr("Edit Data Types"),
272                                               0, _parent, false, this,  SLOT(onEditDataTypes()));
273
274   pixmap.load("icons:kill.png");
275   _createDataTypeAct = _wrapper->createAction(getMenuId(), tr("Create Data Types"), QIcon(pixmap),
276                                               tr("Create Data Types"), tr("Create Data Types"),
277                                               0, _parent, false, this,  SLOT(onCreateDataType()));
278
279   pixmap.load("icons:folder_cyan.png");
280   _importDataTypeAct = _wrapper->createAction(getMenuId(), tr("Import Data Types, use drag and drop from catalog"), QIcon(pixmap),
281                                               tr("Import Data Types"), tr("Import Data Types, use drag and drop from catalog"),
282                                               0, _parent, false, this,  SLOT(onImportDataType()));
283
284   pixmap.load("icons:container.png");
285   _newContainerAct = _wrapper->createAction(getMenuId(), tr("Create a New Container"), QIcon(pixmap),
286                                               tr("Create Container"), tr("Create a New Container"),
287                                               0, _parent, false, this,  SLOT(onNewContainer()));
288
289   pixmap.load("icons:new_salome_component.png");
290   _newSalomeComponentAct = _wrapper->createAction(getMenuId(), tr("Create a New SALOME Component"), QIcon(pixmap),
291                                               tr("SALOME Component"), tr("Create a New SALOME Component"),
292                                               0, _parent, false, this,  SLOT(onNewSalomeComponent()));
293
294   pixmap.load("icons:new_salomepy_component.png");
295   _newSalomePythonComponentAct = _wrapper->createAction(getMenuId(), tr("Create a New SALOME Python Component"), QIcon(pixmap),
296                                               tr("SALOME Python Component"), tr("Create a New SALOME Python Component"),
297                                               0, _parent, false, this,  SLOT(onNewSalomePythonComponent()));
298
299   pixmap.load("icons:new_corba_component.png");
300   _newCorbaComponentAct = _wrapper->createAction(getMenuId(), tr("Create a New CORBA Component"), QIcon(pixmap),
301                                               tr("CORBA Component"), tr("Create a New CORBA Component"),
302                                               0, _parent, false, this,  SLOT(onNewCorbaComponent()));
303
304   pixmap.load("icons:schema.png");
305   _newSchemaAct = _wrapper->createAction(getMenuId(), tr("New Schema"), QIcon(pixmap),
306                                               tr("New Schema"), tr("New Schema"),
307                                               0, _parent, false, this,  SLOT(onNewSchema()));
308
309   pixmap.load("icons:new_salome_service_node.png");
310   _salomeServiceNodeAct = _wrapper->createAction(getMenuId(), tr("Create a New SALOME Service Node"), QIcon(pixmap),
311                                               tr("SALOME Service Node"), tr("Create a New SALOME Service Node"),
312                                               0, _parent, false, this,  SLOT(onSalomeServiceNode()));
313
314   pixmap.load("icons:new_service_inline_node.png");
315   _serviceInlineNodeAct = _wrapper->createAction(getMenuId(), tr("Create a New Inline Service Node"), QIcon(pixmap),
316                                               tr("Inline Service Node"), tr("Create a New Inline Service Node"),
317                                               0, _parent, false, this,  SLOT(onServiceInlineNode()));
318
319   pixmap.load("icons:new_corba_service_node.png");
320   _CORBAServiceNodeAct = _wrapper->createAction(getMenuId(), tr("Create a New CORBA Service Node"), QIcon(pixmap),
321                                               tr("CORBA Node"), tr("Create a New CORBA Service Node"),
322                                               0, _parent, false, this,  SLOT(onCORBAServiceNode()));
323
324   pixmap.load("icons:new_nodenode_service_node.png");
325   _nodeNodeServiceNodeAct = _wrapper->createAction(getMenuId(), tr("Create a New Node referencing a Node"), QIcon(pixmap),
326                                               tr("Ref on Node"), tr("Create a New Node referencing a Node"),
327                                               0, _parent, false, this,  SLOT(onNodeNodeServiceNode()));
328
329   pixmap.load("icons:new_cpp_node.png");
330   _cppNodeAct = _wrapper->createAction(getMenuId(), tr("Create a New C++ Node"), QIcon(pixmap),
331                                               tr("Cpp Node"), tr("Create a New C++ Node"),
332                                               0, _parent, false, this,  SLOT(onCppNode()));
333
334   pixmap.load("icons:kill.png");
335   _inDataNodeAct = _wrapper->createAction(getMenuId(), tr("Create a New Input data Node"), QIcon(pixmap),
336                                               tr("Input Data Node"), tr("Create a New Input data Node"),
337                                               0, _parent, false, this,  SLOT(onInDataNode()));
338
339   pixmap.load("icons:kill.png");
340   _outDataNodeAct = _wrapper->createAction(getMenuId(), tr("Create a New Output data Node"), QIcon(pixmap),
341                                               tr("Output Data Node"), tr("Create a New Output data Node"),
342                                               0, _parent, false, this,  SLOT(onOutDataNode()));
343
344   pixmap.load("icons:kill.png");
345   _inStudyNodeAct = _wrapper->createAction(getMenuId(), tr("Create a New Input Study Node"), QIcon(pixmap),
346                                               tr("Input Study Node"), tr("Create a New Input Study Node"),
347                                               0, _parent, false, this,  SLOT(onInStudyNode()));
348
349   pixmap.load("icons:kill.png");
350   _outStudyNodeAct = _wrapper->createAction(getMenuId(), tr("Create a New Output Study Node"), QIcon(pixmap),
351                                               tr("Output Study Node"), tr("Create a New Output Study Node"),
352                                               0, _parent, false, this,  SLOT(onOutStudyNode()));
353
354   pixmap.load("icons:new_inline_script_node.png");
355   _inlineScriptNodeAct = _wrapper->createAction(getMenuId(), tr("Create a New Inline Python Script Node"), QIcon(pixmap),
356                                               tr("Inline Script Node"), tr("Create a New Inline Python Script Node"),
357                                               0, _parent, false, this,  SLOT(onInlineScriptNode()));
358
359   pixmap.load("icons:new_inline_function_node.png");
360   _inlineFunctionNodeAct = _wrapper->createAction(getMenuId(), tr("Create a New Inline Python Function Node"), QIcon(pixmap),
361                                               tr("Inline Function Node"), tr("Create a New Inline Python Function Node"),
362                                               0, _parent, false, this,  SLOT(onInlineFunctionNode()));
363
364   pixmap.load("icons:new_block_node.png");
365   _blockNodeAct = _wrapper->createAction(getMenuId(), tr("Create a New Bloc Node"), QIcon(pixmap),
366                                               tr("bloc Node"), tr("Create a New Bloc Node"),
367                                               0, _parent, false, this,  SLOT(onBlockNode()));
368
369   pixmap.load("icons:new_for_loop_node.png");
370   _FORNodeAct = _wrapper->createAction(getMenuId(), tr("Create a New For Loop Node"), QIcon(pixmap),
371                                               tr("For Loop Node"), tr("Create a New For Loop Node"),
372                                               0, _parent, false, this,  SLOT(onFORNode()));
373
374   pixmap.load("icons:new_foreach_loop_node.png");
375   _FOREACHNodeAct = _wrapper->createAction(getMenuId(), tr("Create a New For Each Loop Node"), QIcon(pixmap),
376                                               tr("For Each Loop Node"), tr("Create a New For Each Loop Node"),
377                                               0, _parent, false, this,  SLOT(onFOREACHNode()));
378
379   pixmap.load("icons:new_while_loop_node.png");
380   _WHILENodeAct = _wrapper->createAction(getMenuId(), tr("Create a New While Loop Node"), QIcon(pixmap),
381                                               tr("While Loop Node"), tr("Create a New While Loop Node"),
382                                               0, _parent, false, this,  SLOT(onWHILENode()));
383
384   pixmap.load("icons:new_switch_loop_node.png");
385   _SWITCHNodeAct = _wrapper->createAction(getMenuId(), tr("Create a New Switch Node"), QIcon(pixmap),
386                                               tr("Switch Node"), tr("Create a New Switch Node"),
387                                               0, _parent, false, this,  SLOT(onSWITCHNode()));
388
389   pixmap.load("icons:new_from_library_node.png");
390   _nodeFromCatalogAct = _wrapper->createAction(getMenuId(), tr("Create a New Node from Catalog, use drag and drop from catalog"), QIcon(pixmap),
391                                               tr("Node from Catalog"), tr("Create a New Node from Catalog, use drag and drop from catalog"),
392                                               0, _parent, false, this,  SLOT(onNodeFromCatalog()));
393
394   pixmap.load("icons:delete.png");
395   _deleteItemAct = _wrapper->createAction(getMenuId(), tr("Delete a Schema Item"), QIcon(pixmap),
396                                               tr("Delete Item"), tr("Delete a Schema Item"),
397                                               0, _parent, false, this,  SLOT(onDeleteItem()));
398
399   pixmap.load("icons:cut.png");
400   _cutItemAct = _wrapper->createAction(getMenuId(), tr("Cut a Schema Item"), QIcon(pixmap),
401                                        tr("Cut Item"), tr("Cut a Schema Item"),
402                                        0, _parent, false, this,  SLOT(onCutItem()));
403
404   pixmap.load("icons:copy.png");
405   _copyItemAct = _wrapper->createAction(getMenuId(), tr("Copy a Schema Item"), QIcon(pixmap),
406                                         tr("Copy Item"), tr("Copy a Schema Item"),
407                                         0, _parent, false, this,  SLOT(onCopyItem()));
408
409   pixmap.load("icons:paste.png");
410   _pasteItemAct = _wrapper->createAction(getMenuId(), tr("Paste a Schema Item"), QIcon(pixmap),
411                                          tr("Paste Item"), tr("Paste a Schema Item"),
412                                          0, _parent, false, this,  SLOT(onPasteItem()));
413
414   pixmap.load("icons:arrange_nodes.png");
415   _arrangeLocalNodesAct = _wrapper->createAction(getMenuId(), tr("arrange nodes on that bloc level, without recursion"), QIcon(pixmap),
416                                               tr("arrange local nodes"), tr("arrange nodes on that bloc level, without recursion"),
417                                               0, _parent, false, this,  SLOT(onArrangeLocalNodes()));
418
419   pixmap.load("icons:sample.png");
420   _arrangeRecurseNodesAct = _wrapper->createAction(getMenuId(), tr("arrange nodes on that bloc level, with recursion"), QIcon(pixmap),
421                                               tr("arrange nodes recursion"), tr("arrange nodes on that bloc level, with recursion"),
422                                               0, _parent, false, this,  SLOT(onArrangeRecurseNodes()));
423
424   pixmap.load("icons:rebuild_links.png");
425   _computeLinkAct = _wrapper->createAction(getMenuId(), tr("compute orthogonal links"), QIcon(pixmap),
426                                               tr("compute links"), tr("compute orthogonal links"),
427                                               0, _parent, false, this,  SLOT(onRebuildLinks()));
428
429   pixmap.load("icons:autoComputeLink.png");
430   _toggleAutomaticComputeLinkAct = _wrapper->createAction(getMenuId(), tr("compute othogonal links autoamtically when nodes move"), QIcon(pixmap),
431                                               tr("automatic link"), tr("compute othogonal links autoamtically when nodes move"),
432                                               0, _parent, true, this,  SLOT(onToggleAutomaticComputeLinks(bool)));
433
434   _toggleAutomaticComputeLinkAct->setChecked(true);
435
436   pixmap.load("icons:simplifyLink.png");
437   _toggleSimplifyLinkAct = _wrapper->createAction(getMenuId(), tr("simplify links by removing unnecessary direction changes"), QIcon(pixmap),
438                                               tr("simplify links"), tr("simplify links by removing unnecessary direction changes"),
439                                               0, _parent, true, this,  SLOT(onToggleSimplifyLinks(bool)));
440   _toggleSimplifyLinkAct->setChecked(true);
441
442   pixmap.load("icons:force2nodeLink.png");
443   _toggleForce2NodesLinkAct = _wrapper->createAction(getMenuId(), tr("force orthogonal links by adding an edge on simples links"), QIcon(pixmap),
444                                               tr("force ortho links"), tr("force orthogonal links by adding an edge on simples links"),
445                                               0, _parent, true, this,  SLOT(onToggleForce2NodesLinks(bool)));
446   _toggleForce2NodesLinkAct->setChecked(true);
447
448   pixmap.load("icons:ob_service_node.png");
449   _selectReferenceAct = _wrapper->createAction(getMenuId(), tr("select reference"), QIcon(pixmap),
450                                               tr("select reference"), tr("select reference"),
451                                               0, _parent, false, this,  SLOT(onSelectReference()));
452
453   pixmap.load("icons:whatsThis.png");
454   _whatsThisAct = _wrapper->createAction(getMenuId(), tr("active whatsThis Mode to get help on widgets"), QIcon(pixmap),
455                                               tr("whatsThis Mode"), tr("active whatsThis Mode to get help on widgets"),
456                                               0, _parent, false, this,  SLOT(onWhatsThis()));
457
458   pixmap.load("icons:run_active.png");
459   _withoutStopModeAct = _wrapper->createAction(getMenuId(), tr("set execution mode without stop"), QIcon(pixmap),
460                                               tr("mode without stop"), tr("set execution mode without stop"),
461                                                0, _parent, true, this,  SLOT(onWithoutStopMode(bool)));
462
463   pixmap.load("icons:breakpoints_active.png");
464   _breakpointsModeAct = _wrapper->createAction(getMenuId(), tr("set execution mode with stop on breakpoints"), QIcon(pixmap),
465                                               tr("mode breakpoints"), tr("set execution mode with stop on breakpoints"),
466                                                0, _parent, true, this,  SLOT(onBreakpointsMode(bool)));
467
468   pixmap.load("icons:step_by_step_active.png");
469   _stepByStepModeAct = _wrapper->createAction(getMenuId(), tr("set execution mode step by step"), QIcon(pixmap),
470                                               tr("mode step by step"), tr("set execution mode step by step"),
471                                               0, _parent, true, this,  SLOT(onStepByStepMode(bool)));
472
473   pixmap.load("icons:toggle_stop_on_error.png");
474   _toggleStopOnErrorAct = _wrapper->createAction(getMenuId(), tr("Force stop on first error during execution"), QIcon(pixmap),
475                                               tr("stop on error"), tr("Force stop on first error during execution"),
476                                               0, _parent, true, this,  SLOT(onToggleStopOnError(bool)));
477
478   pixmap.load("icons:toggleVisibility.png");
479   _toggleSceneItemVisibleAct = _wrapper->createAction(getMenuId(), tr("toggle 2D scene item visibility"), QIcon(pixmap),
480                                               tr("visible/hidden"), tr("toggle 2D scene item visibility"),
481                                               0, _parent, true, this,  SLOT(onToggleSceneItemVisible(bool)));
482
483
484   _execModeGroup = new QActionGroup(this);
485   _execModeGroup->addAction(_withoutStopModeAct);
486   _execModeGroup->addAction(_breakpointsModeAct);
487   _execModeGroup->addAction(_stepByStepModeAct);
488   _withoutStopModeAct->setChecked(true);
489
490   /*
491   pixmap.load("icons:.png");
492   _ = _wrapper->createAction(getMenuId(), tr(""), QIcon(pixmap),
493                                               tr(""), tr(""),
494                                               0, _parent, false, this,  SLOT());
495
496   */
497
498
499 }
500
501 void GenericGui::createMenus()
502 {
503   int aMenuId;
504   aMenuId = _wrapper->createMenu( "File", -1, -1 );
505   _wrapper->createMenu( _wrapper->separator(), aMenuId, -1, 10 );
506   aMenuId = _wrapper->createMenu( "YACS" , aMenuId, -1, 10 );
507   _wrapper->createMenu( _newSchemaAct, aMenuId );
508   _wrapper->createMenu( _importSchemaAct, aMenuId );
509
510   aMenuId = _wrapper->createMenu( tr( "YACS" ), -1, -1, 30 );
511   _wrapper->createMenu( _newSchemaAct, aMenuId );//, 10
512   _wrapper->createMenu( _importSchemaAct, aMenuId );
513   _wrapper->createMenu( _importSupervSchemaAct, aMenuId );
514   _wrapper->createMenu( _wrapper->separator(), aMenuId);
515   _wrapper->createMenu( _exportSchemaAct, aMenuId );
516   _wrapper->createMenu( _exportSchemaAsAct, aMenuId );
517   _wrapper->createMenu( _wrapper->separator(), aMenuId);
518   _wrapper->createMenu( _runLoadedSchemaAct, aMenuId );
519   _wrapper->createMenu( _loadRunStateSchemaAct, aMenuId );
520   _wrapper->createMenu( _loadAndRunSchemaAct, aMenuId );
521   _wrapper->createMenu( _wrapper->separator(), aMenuId);
522   _wrapper->createMenu( _startResumeAct, aMenuId );
523   _wrapper->createMenu( _abortAct, aMenuId );
524   _wrapper->createMenu( _pauseAct, aMenuId );
525   _wrapper->createMenu( _resetAct, aMenuId );
526   _wrapper->createMenu( _wrapper->separator(), aMenuId);
527   _wrapper->createMenu( _saveRunStateAct, aMenuId );
528   _wrapper->createMenu( _newEditionAct, aMenuId );
529   _wrapper->createMenu( _wrapper->separator(), aMenuId);
530   _wrapper->createMenu( _withoutStopModeAct, aMenuId );
531   _wrapper->createMenu( _breakpointsModeAct, aMenuId );
532   _wrapper->createMenu( _stepByStepModeAct, aMenuId );
533   _wrapper->createMenu( _wrapper->separator(), aMenuId);
534   _wrapper->createMenu( _toggleStopOnErrorAct, aMenuId );
535   _wrapper->createMenu( _wrapper->separator(), aMenuId);
536   _wrapper->createMenu( _importCatalogAct, aMenuId );
537   _wrapper->createMenu( _wrapper->separator(), aMenuId);
538   _wrapper->createMenu( _whatsThisAct, aMenuId );
539 }
540
541 void GenericGui::createTools()
542 {
543   int aToolId = _wrapper->createTool ( tr( "TOOL_YACS" ) );
544   _wrapper->createTool( _newSchemaAct, aToolId );
545   _wrapper->createTool( _importSchemaAct, aToolId );
546   _wrapper->createTool( _importSupervSchemaAct, aToolId );
547   _wrapper->createTool( _wrapper->separator(), aToolId );
548   _wrapper->createTool( _exportSchemaAct, aToolId );
549   _wrapper->createTool( _exportSchemaAsAct, aToolId );
550   _wrapper->createTool( _wrapper->separator(), aToolId);
551   _wrapper->createTool( _runLoadedSchemaAct, aToolId );
552   _wrapper->createTool( _loadRunStateSchemaAct, aToolId );
553   _wrapper->createTool( _loadAndRunSchemaAct, aToolId );
554   _wrapper->createTool( _wrapper->separator(), aToolId );
555   _wrapper->createTool( _startResumeAct, aToolId );
556   _wrapper->createTool( _abortAct, aToolId );
557   _wrapper->createTool( _pauseAct, aToolId );
558   _wrapper->createTool( _resetAct, aToolId );
559   _wrapper->createTool( _wrapper->separator(), aToolId );
560   _wrapper->createTool( _wrapper->separator(), aToolId );
561   _wrapper->createTool( _saveRunStateAct, aToolId );
562   _wrapper->createTool( _newEditionAct, aToolId );
563   _wrapper->createTool( _withoutStopModeAct, aToolId );
564   _wrapper->createTool( _breakpointsModeAct, aToolId );
565   _wrapper->createTool( _stepByStepModeAct, aToolId );
566   _wrapper->createTool( _wrapper->separator(), aToolId );
567   _wrapper->createTool( _toggleStopOnErrorAct, aToolId );
568   _wrapper->createTool( _wrapper->separator(), aToolId );
569   _wrapper->createTool( _importCatalogAct, aToolId );
570   _wrapper->createTool( _wrapper->separator(), aToolId );
571   _wrapper->createTool( _whatsThisAct, aToolId );
572 }
573
574 void GenericGui::initialMenus()
575 {
576   showBaseMenus(true);
577   showEditionMenus(false);
578   showExecMenus(false);
579 }
580
581 void GenericGui::showBaseMenus(bool show)
582 {
583   DEBTRACE("GenericGui::showBaseMenus " << show);
584   _wrapper->setMenuShown(_newSchemaAct, show);
585   _wrapper->setToolShown(_newSchemaAct, show);
586   _wrapper->setMenuShown(_importSchemaAct, show);
587   _wrapper->setToolShown(_importSchemaAct, show);
588   _wrapper->setMenuShown(_importSupervSchemaAct, show);
589   _wrapper->setToolShown(_importSupervSchemaAct, show);
590   _wrapper->setMenuShown(_loadAndRunSchemaAct, show);
591   _wrapper->setToolShown(_loadAndRunSchemaAct, show);
592   _wrapper->setMenuShown(_whatsThisAct, show);
593   _wrapper->setToolShown(_whatsThisAct, show);
594 }
595
596 void GenericGui::showEditionMenus(bool show)
597 {
598   DEBTRACE("GenericGui::showEditionMenus " << show);
599   _wrapper->setMenuShown(_exportSchemaAct, show);
600   _wrapper->setToolShown(_exportSchemaAct, show);
601   _wrapper->setMenuShown(_exportSchemaAsAct, show);
602   _wrapper->setToolShown(_exportSchemaAsAct, show);
603   _wrapper->setMenuShown(_runLoadedSchemaAct, show);
604   _wrapper->setToolShown(_loadRunStateSchemaAct, show);
605   _wrapper->setMenuShown(_loadRunStateSchemaAct, show);
606   _wrapper->setToolShown(_runLoadedSchemaAct, show);
607   _wrapper->setMenuShown(_importCatalogAct, show);
608   _wrapper->setToolShown(_importCatalogAct, show);
609 }
610
611 void GenericGui::showExecMenus(bool show)
612 {
613   DEBTRACE("GenericGui::showExecMenus " << show);
614   _wrapper->setMenuShown(_startResumeAct, show);
615   _wrapper->setToolShown(_startResumeAct, show);
616   _wrapper->setMenuShown(_abortAct, show);
617   _wrapper->setToolShown(_abortAct, show);
618   _wrapper->setMenuShown(_pauseAct, show);
619   _wrapper->setToolShown(_pauseAct, show);
620   _wrapper->setMenuShown(_resetAct, show);
621   _wrapper->setToolShown(_resetAct, show);
622   _wrapper->setMenuShown(_saveRunStateAct, show);
623   _wrapper->setToolShown(_saveRunStateAct, show);
624   _wrapper->setMenuShown(_newEditionAct, show);
625   _wrapper->setToolShown(_newEditionAct, show);
626   _wrapper->setMenuShown(_withoutStopModeAct, show);
627   _wrapper->setToolShown(_withoutStopModeAct, show);
628   _wrapper->setMenuShown(_breakpointsModeAct, show);
629   _wrapper->setToolShown(_breakpointsModeAct, show);
630   _wrapper->setMenuShown(_stepByStepModeAct, show);
631   _wrapper->setToolShown(_stepByStepModeAct, show);
632   _wrapper->setMenuShown(_toggleStopOnErrorAct, show);
633   _wrapper->setToolShown(_toggleStopOnErrorAct, show);
634 }
635
636 void GenericGui::switchContext(QWidget *view)
637 {
638   DEBTRACE("GenericGui::switchContext");
639   if (! _mapViewContext.count(view))
640     {
641       initialMenus();
642       return;
643     }
644   QtGuiContext* newContext = _mapViewContext[view];
645   QtGuiContext* oldContext = QtGuiContext::getQtCurrent();
646
647   _dwTree->setWidget(newContext->getEditTree());
648   _dwTree->widget()->show();
649   _dwStacked->setWidget(newContext->getStackedWidget());
650
651   QtGuiContext::setQtCurrent(newContext);
652
653   if (newContext->isEdition())
654     {
655       showBaseMenus(true);
656       showEditionMenus(true);
657       showExecMenus(false);
658       if (_dwTree) _dwTree->setWindowTitle("Tree View: edition mode");
659     }
660   else
661     {
662       showBaseMenus(true);
663       showEditionMenus(false);
664       showExecMenus(true);
665       _withoutStopModeAct->setChecked(true);
666       if (_dwTree) _dwTree->setWindowTitle("Tree View: execution mode");
667     }
668 }
669
670 void GenericGui::showDockWidgets(bool isVisible)
671 {
672   DEBTRACE("GenericGui::showDockWidgets " << isVisible);
673   if (_dwTree) _dwTree->setVisible(isVisible);
674   if (_dwStacked) _dwStacked->setVisible(isVisible);
675   if (_dwCatalogs) _dwCatalogs->setVisible(isVisible);
676 }
677
678 void GenericGui::raiseStacked()
679 {
680   if (_dwStacked) _dwStacked->raise();
681 }
682
683 std::list<std::string> GenericGui::getMachineList()
684 {
685   if (!_machineList.empty()) return _machineList;
686
687   YACS::ENGINE::RuntimeSALOME* runTime = YACS::ENGINE::getSALOMERuntime();
688   CORBA::ORB_ptr orb = runTime->getOrb();
689   if (!orb) return _machineList;
690
691   SALOME_NamingService namingService(orb);
692   SALOME_LifeCycleCORBA lcc(&namingService);
693
694   CORBA::Object_var obj =
695     namingService.Resolve(SALOME_ResourcesManager::_ResourcesManagerNameInNS);
696   if (CORBA::is_nil(obj)) return _machineList;
697
698   Engines::ResourcesManager_var resManager = Engines::ResourcesManager::_narrow(obj);
699   if(!resManager) return _machineList;
700
701   Engines::CompoList compoList ;
702   Engines::MachineParameters params;
703   lcc.preSet(params);
704
705   Engines::MachineList* machineList =
706     resManager->GetFittingResources(params, compoList);
707
708   for (int i = 0; i < machineList->length(); i++)
709     {
710       const char* aMachine = (*machineList)[i];
711       _machineList.push_back(aMachine);
712     }
713
714   return _machineList;
715 }
716
717 // -----------------------------------------------------------------------------
718
719 /*! a QtGuiContext instance is created for each schema in edition or each execution or run
720  *  of a schema. The context stores references of a lot of objects related to the edition
721  *  or execution.
722  *  \param proc       the schema to run or edit, loaded from file or just created empty.
723  *  \param schemaName filename of the schema in edition, also used in execution to publish
724  *                    a run under the edition name in Salome object browser.
725  *  \param runName    filename of the schema in execution, not used in edition.
726  *  \param forEdition if true, edition mode, if false, execution mode.
727  */
728 void GenericGui::createContext(YACS::ENGINE::Proc* proc,
729                                const QString& schemaName,
730                                const QString& runName,
731                                bool forEdition)
732 {
733   DEBTRACE("GenericGui::createContext");
734   clock_t  start_t;
735   clock_t  end_t;
736   start_t = clock();
737
738   QString fileName;
739   QWidget* refWindow = 0; // --- used only on run to refer to the schema in edition
740   if (forEdition)
741     {
742       fileName = schemaName;
743     }
744   else
745     {
746       fileName = runName;
747       if (QtGuiContext::getQtCurrent())
748         refWindow = QtGuiContext::getQtCurrent()->getWindow();
749     }
750
751   QtGuiContext* context = new QtGuiContext(this);
752   QtGuiContext::setQtCurrent(context);
753
754   // --- catalogs
755
756   context->setEdition(forEdition);
757   context->setSessionCatalog(_sessionCatalog);
758   context->setFileName(fileName);
759   context->setCurrentCatalog(YACS::ENGINE::getSALOMERuntime()->loadCatalog("proc", fileName.toStdString()));
760
761   // --- scene, viewWindow & GraphicsView
762
763   Scene *scene = new Scene();
764   QWidget *viewWindow = _wrapper->getNewWindow(scene);
765   _mapViewContext[viewWindow] = context;
766   GraphicsView* gView = new GraphicsView(viewWindow);
767   gView->setScene(scene);
768   gView->setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
769   int studyId = _wrapper->AssociateViewToWindow(gView, viewWindow);
770   context->setStudyId(studyId);
771   context->setScene(scene);
772   context->setView(gView);
773   context->setWindow(viewWindow);
774   gView->show();
775
776   // --- Schema Model
777
778   SchemaModel *schemaModel = new SchemaModel(context, viewWindow);
779   schemaModel->setEdition(forEdition);
780   context->setSchemaModel(schemaModel);
781   RootSceneItem *rootSceneItem = new RootSceneItem(context);
782
783   // --- tree associated to model
784
785   FormEditTree *editTree = new FormEditTree(_dwTree);
786   editTree->setMinimumHeight(400);
787   _dwTree->setWidget(editTree);
788   editTree->show();
789   context->setEditTree(editTree);
790   editTree->tv_schema->setModel(schemaModel);
791   context->setSelectionModel(editTree->tv_schema->selectionModel());
792
793   QObject::connect(editTree->tv_schema->selectionModel(),
794                    SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)),
795                    schemaModel,
796                    SLOT(updateSelection(const QItemSelection &, const QItemSelection &)));
797
798   // --- stacked widget
799
800   QStackedWidget *stacked = new QStackedWidget(_dwStacked);
801   _dwStacked->setWidget(stacked);
802   context->setStackedWidget(stacked);
803   YACS::HMI::ItemEditionRoot* rootEdit = new YACS::HMI::ItemEditionRoot(context,
804                                                                         0,
805                                                                         context->getName().c_str());
806   context->setEditionRoot(rootEdit);
807
808   QObject::connect(schemaModel,
809                    SIGNAL(signalSelection(const QModelIndex &)),
810                    editTree->tv_schema,
811                    SLOT(viewSelection(const QModelIndex &)));
812
813   // --- load schema
814
815   proc->setEdition(forEdition);
816
817   {
818     end_t = clock();
819     double passe =  (end_t -start_t);
820     passe = passe/CLOCKS_PER_SEC;
821     cerr <<"create context -1- : " << passe << endl;
822     start_t = end_t;
823   }
824
825   context->setLoading(true);
826
827   context->setProc(proc);
828   setLoadedPresentation(proc);
829
830   {
831     end_t = clock();
832     double passe =  (end_t -start_t);
833     passe = passe/CLOCKS_PER_SEC;
834     cerr <<"create context - load proc- : " << passe << endl;
835     start_t = end_t;
836   }
837
838   context->setLoading(false);
839
840   if (forEdition && _wrapper)  // --- Edition mode
841     {
842       _wrapper->createNewSchema(fileName, viewWindow);
843     }
844   else if (_wrapper)           // --- Execution Mode
845     {
846       GuiExecutor *guiExec = new GuiExecutor(proc);
847       context->setGuiExecutor(guiExec);
848       _wrapper->createNewRun(schemaName, fileName, refWindow, viewWindow);
849     }
850
851
852   QtGuiContext::getQtCurrent()->getSubjectProc()->update(UPDATE,
853                                                          ProcInvoc::getTypeOfNode(proc),
854                                                          0); // --- force validity check
855
856   // --- adjust widgets
857
858   TreeView *vtree = dynamic_cast<TreeView*>(editTree->tv_schema);
859   assert(vtree);
860   vtree->resizeColumns();
861   _catalogsWidget->setMinimumWidth(40); // --- reset the constraint on width
862   editTree->setMinimumHeight(40);
863   // --- show menus
864
865   if (forEdition)
866     {
867       showEditionMenus(true);
868       showExecMenus(false);
869       if (_dwTree) _dwTree->setWindowTitle("Tree View: edition mode");
870     }
871   else
872     {
873       showEditionMenus(false);
874       showExecMenus(true);
875       _withoutStopModeAct->setChecked(true);
876       if (_dwTree) _dwTree->setWindowTitle("Tree View: execution mode");
877     }
878 }
879
880 // -----------------------------------------------------------------------------
881
882 void GenericGui::setLoadedPresentation(YACS::ENGINE::Proc* proc)
883 {
884   map<YACS::ENGINE::Node*, PrsData> presNodes = _loader->getPrsData(proc);
885   if (!presNodes.empty())
886     {
887       map<YACS::ENGINE::Node*, PrsData>::iterator it = presNodes.begin();
888       for (; it!= presNodes.end(); ++it)
889         {
890           YACS::ENGINE::Node* node = (*it).first;
891           PrsData pres = (*it).second;
892           SubjectNode *snode = QtGuiContext::getQtCurrent()->_mapOfSubjectNode[node];
893           SceneItem *item = QtGuiContext::getQtCurrent()->_mapOfSceneItem[snode];
894           assert(item);
895           item->setPos(QPointF(pres._x, pres._y));
896           item->setWidth(pres._width);
897           item->setHeight(pres._height);
898         }
899       _guiEditor->rebuildLinks();
900     }
901 }
902
903 // -----------------------------------------------------------------------------
904
905 void GenericGui::onNewSchema()
906 {
907   DEBTRACE("GenericGui::onNewSchema");
908
909   std::stringstream name;
910   name << "newSchema_" << ++_schemaCnt;
911
912   YACS::ENGINE::RuntimeSALOME* runTime = YACS::ENGINE::getSALOMERuntime();
913   YACS::ENGINE::Proc *proc = runTime->createProc(name.str());
914
915   QString fileName = name.str().c_str();
916   createContext(proc, fileName, "", true);
917 }
918
919 void GenericGui::onImportSchema()
920 {
921   DEBTRACE("GenericGui::onImportSchema");
922   QString fn = QFileDialog::getOpenFileName( _parent,
923                                              "Choose a filename to load" ,
924                                              QString::null,
925                                              tr( "XML-Files (*.xml);;All Files (*)" ));
926   if ( !fn.isEmpty() )
927     {
928       DEBTRACE("file loaded : " <<fn.toStdString());
929       YACS::ENGINE::Proc *proc = _loader->load(fn.toLatin1());
930       if (!proc)
931         {
932           QMessageBox msgBox(QMessageBox::Critical,
933                              "Import YACS Schema, native YACS XML format",
934                              "The file has not the native YACS XML format or is not readable.");
935           msgBox.exec();
936           return;
937         }
938       YACS::ENGINE::Logger* logger= proc->getLogger("parser");
939       if(!logger->isEmpty())
940         {
941           DEBTRACE(logger->getStr());
942         }
943       createContext(proc, fn, "", true);
944     }
945 }
946
947 void GenericGui::onImportSupervSchema()
948 {
949   DEBTRACE("GenericGui::onImportSupervSchema");
950   QString fn = QFileDialog::getOpenFileName( _parent,
951                                              "Choose a  SUPERV filename to load" ,
952                                              QString::null,
953                                              tr( "XML-Files (*.xml);;All Files (*)" ));
954   if (fn.isEmpty()) return;
955
956   DEBTRACE("file loaded : " <<fn.toStdString());
957   QString tmpFileName;
958   try
959     {
960       QString tmpDir = "/tmp";
961       QDir aTmpDir(tmpDir);
962       aTmpDir.mkdir(QString("YACS_") + getenv("USER"));
963       assert(aTmpDir.cd(QString("YACS_") + getenv("USER")));
964       QDateTime curTime = QDateTime::currentDateTime();   
965       tmpFileName = "SUPERV_import_" + curTime.toString("yyyyMMdd_hhmmss") + ".xml";
966       QString tmpOutput = "salomeloader_output";
967       tmpFileName = aTmpDir.absoluteFilePath(tmpFileName);
968       DEBTRACE(tmpFileName.toStdString());
969       
970       QString aCall = "salomeloader.sh " + fn + " " + tmpFileName + " > " + tmpOutput;
971       DEBTRACE(aCall.toStdString());
972       
973       int ret = system(aCall.toAscii());
974       if(ret != 0)
975         {
976           // --- read file with logs
977           fstream f(tmpOutput.toAscii());
978           stringstream hfile;
979           hfile << f.rdbuf();
980           f.close();
981           
982           // --- Problem in execution
983           int status=WEXITSTATUS(ret);
984           if(status == 1)
985             {
986               QString mes = "Problems in conversion: some errors but an incomplete proc has nevertheless been created.\n\n";
987               mes += QString(hfile.str().c_str());
988               QMessageBox msgBox(QMessageBox::Warning,
989                                  "Import YACS Schema, SUPERV XML format",
990                                  mes);
991               msgBox.exec();
992             }
993           else if(status == 2)
994             {
995               QString mes = "Problems in conversion: a fatal error has been encountered. The proc can't be created.\n\n";
996               mes += QString(hfile.str().c_str());
997               QMessageBox msgBox(QMessageBox::Critical,
998                                  "Import YACS Schema, SUPERV XML format",
999                                  mes);
1000               msgBox.exec();
1001               return;
1002             }
1003           else
1004             {
1005               DEBTRACE("Unknown problem: " << ret );
1006               QMessageBox msgBox(QMessageBox::Critical,
1007                                  "Import YACS Schema, SUPERV XML format",
1008                                  "Unexpected exception in salomeloader.");
1009               msgBox.exec();
1010               return;
1011             }
1012         }
1013     }
1014   catch(...)
1015     {
1016       QMessageBox msgBox(QMessageBox::Critical,
1017                          "Import YACS Schema, SUPERV XML format",
1018                          "Unexpected exception in convertSupervFile");
1019       msgBox.exec();
1020       return;
1021     }
1022
1023   fn = tmpFileName;
1024   if (fn.isEmpty()) return; // must not happen
1025
1026   DEBTRACE("file loaded : " <<fn.toStdString());
1027   YACS::ENGINE::Proc *proc = _loader->load(fn.toLatin1());
1028   if (!proc)
1029     {
1030       QMessageBox msgBox(QMessageBox::Critical,
1031                          "Import YACS Schema, SUPERV file converted in native YACS XML format",
1032                          "The file has not the native YACS XML format or is not readable.");
1033       msgBox.exec();
1034       return;
1035     }
1036   YACS::ENGINE::Logger* logger= proc->getLogger("parser");
1037   if(!logger->isEmpty())
1038     {
1039       DEBTRACE(logger->getStr());
1040     }
1041   createContext(proc, fn, "", true);
1042 }
1043
1044 //! bug confirmOverwrite : correction Qt 4.3.5
1045 QString GenericGui::getSaveFileName(const QString& fileName)
1046 {
1047   QFileDialog dialog(_parent, "Save schema", fileName);
1048   QStringList filters;
1049   filters << "XML files (*.xml)"
1050           << "Any files (*)";
1051   dialog.setFileMode(QFileDialog::AnyFile);
1052   dialog.setFilters(filters);
1053   dialog.selectFilter("(*.xml)");
1054   dialog.setDefaultSuffix("xml");
1055   dialog.setConfirmOverwrite(true);
1056   //dialog.setConfirmOverwrite(false);  // bug Qt4.3.3
1057   dialog.setAcceptMode(QFileDialog::AcceptSave);
1058   QString selectedFile;
1059   QStringList fileNames;
1060   fileNames.clear();
1061   if (bool ret = dialog.exec())
1062     {
1063       DEBTRACE(ret << " " << dialog.confirmOverwrite());
1064       fileNames = dialog.selectedFiles();
1065       if (!fileNames.isEmpty())
1066         selectedFile = fileNames.first();
1067     }
1068   return selectedFile;
1069 }
1070
1071 void GenericGui::onExportSchema()
1072 {
1073   DEBTRACE("GenericGui::onExportSchema");
1074   if (!QtGuiContext::getQtCurrent()) return;
1075   YACS::ENGINE::Proc* proc = QtGuiContext::getQtCurrent()->getProc();
1076   QString fo = QtGuiContext::getQtCurrent()->getFileName();
1077   QString foo = fo;
1078   QString fn = fo;
1079   if (fo.startsWith("newSchema_"))
1080     {
1081       fo.clear();
1082       fn = getSaveFileName(fo);
1083     }
1084   if (fn.isEmpty()) return;
1085
1086   DEBTRACE("GenericGui::onExportSchema: " << fn.toStdString());
1087   QtGuiContext::getQtCurrent()->setFileName(fn);
1088   VisitorSaveGuiSchema aWriter(proc);
1089   aWriter.openFileSchema( fn.toStdString() );
1090   aWriter.visitProc();
1091   aWriter.closeFileSchema();
1092
1093   if (fn.compare(foo) && _wrapper)
1094     _wrapper->renameSchema(foo, fn, QtGuiContext::getQtCurrent()->getWindow());
1095 }
1096
1097 void GenericGui::onExportSchemaAs()
1098 {
1099   DEBTRACE("GenericGui::onExportSchemaAs");
1100   if (!QtGuiContext::getQtCurrent()) return;
1101   YACS::ENGINE::Proc* proc = QtGuiContext::getQtCurrent()->getProc();
1102   QString fo = QtGuiContext::getQtCurrent()->getFileName();
1103   QString foo = fo;
1104   if (fo.startsWith("newShema_")) fo.clear();
1105   QString fn = getSaveFileName(fo);
1106   if (fn.isEmpty()) return;
1107
1108   DEBTRACE("GenericGui::onExportSchemaAs: " << fn.toStdString());
1109   QtGuiContext::getQtCurrent()->setFileName(fn);
1110   VisitorSaveGuiSchema aWriter(proc);
1111   aWriter.openFileSchema(fn.toStdString());
1112   aWriter.visitProc();
1113   aWriter.closeFileSchema();
1114
1115   if (fn.compare(foo) && _wrapper)
1116     _wrapper->renameSchema(foo, fn, QtGuiContext::getQtCurrent()->getWindow());
1117 }
1118
1119 void GenericGui::onImportCatalog()
1120 {
1121   DEBTRACE("GenericGui::onImportCatalog");
1122   QString fn = QFileDialog::getOpenFileName( _parent,
1123                                              "Choose a YACS Schema to load as a Catalog" ,
1124                                              QString::null,
1125                                              tr( "XML-Files (*.xml);;All Files (*)" ));
1126   if ( !fn.isEmpty() )
1127     _catalogsWidget->addCatalogFromFile(fn.toStdString());
1128 }
1129   
1130 void GenericGui::onRunLoadedSchema(bool withState)
1131 {
1132   DEBTRACE("GenericGui::onRunLoadedSchema");
1133   if (!QtGuiContext::getQtCurrent()) return;
1134
1135   clock_t  start_t;
1136   clock_t  end_t;
1137   start_t = clock();
1138
1139   // --- check proc state (cf. editionProc)
1140
1141   if (!QtGuiContext::getQtCurrent()->_setOfModifiedSubjects.empty())
1142     {
1143       set<Subject*>::iterator it = QtGuiContext::getQtCurrent()->_setOfModifiedSubjects.begin();
1144       (*it)->select(true);
1145       return;
1146     }
1147
1148   YACS::ENGINE::Proc* proc = QtGuiContext::getQtCurrent()->getProc();
1149   if (!proc->isValid())
1150     {
1151       QtGuiContext::getQtCurrent()->getSubjectProc()->select(true);
1152       return;
1153     }
1154
1155   YACS::ENGINE::LinkInfo info(YACS::ENGINE::LinkInfo::ALL_STOP_ASAP);
1156   try
1157     {
1158       proc->checkConsistency(info);
1159     }
1160   catch (Exception &ex)
1161     {
1162       DEBTRACE(ex.what());
1163       QtGuiContext::getQtCurrent()->getSubjectProc()->select(true);
1164     }
1165   if (info.areWarningsOrErrors()) return;
1166  
1167   {
1168     end_t = clock();
1169     double passe =  (end_t -start_t);
1170     passe = passe/CLOCKS_PER_SEC;
1171     cerr <<"run schema -1- : " << passe << endl;
1172     start_t = end_t;
1173   }
1174   // --- save proc under a run name
1175
1176   QFileInfo fo = QtGuiContext::getQtCurrent()->getFileName();
1177   QString procName = fo.baseName();
1178   //QString tmpDir = SALOMEDS_Tool::GetTmpDir().c_str();
1179   QString tmpDir = "/tmp";
1180   QDir aTmpDir(tmpDir);
1181   aTmpDir.mkdir(QString("YACS_") + getenv("USER"));
1182   assert(aTmpDir.cd(QString("YACS_") + getenv("USER")));
1183   QDateTime curTime = QDateTime::currentDateTime();   
1184   QString aRunName = procName + "_" + curTime.toString("yyyyMMdd_hhmmss") + ".xml";
1185   aRunName = aTmpDir.absoluteFilePath(aRunName);
1186   DEBTRACE(aRunName.toStdString());
1187
1188   VisitorSaveGuiSchema aWriter(proc);
1189   aWriter.openFileSchema(aRunName.toStdString());
1190   aWriter.visitProc();
1191   aWriter.closeFileSchema();
1192
1193   // --- create a run context
1194
1195   YACS::ENGINE::Proc *procrun = _loader->load(aRunName.toLatin1());
1196   {
1197     end_t = clock();
1198     double passe =  (end_t -start_t);
1199     passe = passe/CLOCKS_PER_SEC;
1200     cerr <<"run schema -2- : " << passe << endl;
1201     start_t = end_t;
1202   }
1203   createContext(procrun, QtGuiContext::getQtCurrent()->getFileName(), aRunName, false);
1204
1205   // load state if required
1206
1207   GuiExecutor *executor = QtGuiContext::getQtCurrent()->getGuiExecutor();
1208   if (!executor) return;
1209   if (withState)
1210     {
1211       QString fn = QFileDialog::getOpenFileName( _parent,
1212                                                  "Choose a previous run state to load" ,
1213                                                  QString::null,
1214                                                  tr( "XML-Files (*.xml);;All Files (*)" ));
1215       if (!fn.isEmpty())
1216         {
1217           DEBTRACE("run state to load: " <<fn.toStdString());
1218           executor->setLoadStateFile(fn.toStdString());
1219         }
1220     }
1221   executor->startResumeDataflow(true); // --- initialise gui state
1222 }
1223
1224 void GenericGui::onLoadRunStateSchema()
1225 {
1226   DEBTRACE("GenericGui::onLoadRunStateSchema");
1227   onRunLoadedSchema(true);
1228 }
1229
1230 void GenericGui::onLoadAndRunSchema()
1231 {
1232   DEBTRACE("GenericGui::onLoadAndRunSchema");
1233   QString fn = QFileDialog::getOpenFileName( _parent,
1234                                              "Choose a filename to load" ,
1235                                              QString::null,
1236                                              tr( "XML-Files (*.xml);;All Files (*)" ));
1237   if ( !fn.isEmpty() )
1238     {
1239       DEBTRACE("***************************************************************************");
1240       DEBTRACE("file loaded : " <<fn.toStdString());
1241       DEBTRACE("***************************************************************************");
1242       YACS::ENGINE::Proc *proc = _loader->load(fn.toLatin1());
1243       YACS::ENGINE::Logger* logger= proc->getLogger("parser");
1244       if(!logger->isEmpty())
1245         {
1246           DEBTRACE(logger->getStr());
1247         }
1248       createContext(proc, fn, fn, false);
1249     }
1250
1251 }
1252
1253 void GenericGui::onStartResume()
1254 {
1255   DEBTRACE("GenericGui::onStartResume");
1256   if (!QtGuiContext::getQtCurrent()) return;
1257   if (!QtGuiContext::getQtCurrent()->getGuiExecutor()) return;
1258   QtGuiContext::getQtCurrent()->getGuiExecutor()->startResumeDataflow();
1259 }
1260
1261 void GenericGui::onAbort()
1262 {
1263   DEBTRACE("GenericGui::onAbort");
1264   if (!QtGuiContext::getQtCurrent()) return;
1265   if (!QtGuiContext::getQtCurrent()->getGuiExecutor()) return;
1266   QtGuiContext::getQtCurrent()->getGuiExecutor()->killDataflow();
1267 }
1268
1269 void GenericGui::onPause()
1270 {
1271   DEBTRACE("GenericGui::onPause");
1272   if (!QtGuiContext::getQtCurrent()) return;
1273   if (!QtGuiContext::getQtCurrent()->getGuiExecutor()) return;
1274   QtGuiContext::getQtCurrent()->getGuiExecutor()->suspendDataflow();
1275 }
1276
1277 void GenericGui::onReset()
1278 {
1279   DEBTRACE("GenericGui::onReset");
1280   if (!QtGuiContext::getQtCurrent()) return;
1281   if (!QtGuiContext::getQtCurrent()->getGuiExecutor()) return;
1282   QtGuiContext::getQtCurrent()->getGuiExecutor()->resetDataflow();
1283 }
1284
1285 void GenericGui::onSaveRunState()
1286 {
1287   DEBTRACE("GenericGui::onSaveRunState");
1288   if (!QtGuiContext::getQtCurrent()) return;
1289   if (!QtGuiContext::getQtCurrent()->getGuiExecutor()) return;
1290   QDateTime curTime = QDateTime::currentDateTime(); 
1291   QFileInfo procName = QtGuiContext::getQtCurrent()->getFileName();
1292   QString stateName = procName.baseName();
1293   DEBTRACE(stateName.toStdString());
1294   stateName += "_state_" + curTime.toString("yyyyMMdd_hhmmss") + ".xml";
1295   DEBTRACE(stateName.toStdString());
1296   stateName = getSaveFileName(stateName);
1297   DEBTRACE(stateName.toStdString());
1298   if (!stateName.isEmpty())
1299     QtGuiContext::getQtCurrent()->getGuiExecutor()->saveState(stateName.toStdString());
1300 }
1301
1302 void GenericGui::onNewEdition()
1303 {
1304   DEBTRACE("GenericGui::onNewEdition");
1305 //   if (!QtGuiContext::getQtCurrent()) return;
1306 //   if (!QtGuiContext::getQtCurrent()->getGuiExecutor()) return;
1307 //   QtGuiContext::getQtCurrent()->getGuiExecutor()->resetDataflow();
1308 }
1309
1310 void GenericGui::onGetYacsContainerLog()
1311 {
1312   DEBTRACE("GenericGui::onGetYacsContainerLog");
1313   if (!QtGuiContext::getQtCurrent()) return;
1314   if (!QtGuiContext::getQtCurrent()->getGuiExecutor()) return;
1315   string log = QtGuiContext::getQtCurrent()->getGuiExecutor()->getContainerLog();
1316   LogViewer *lv = new LogViewer("YACS Container Log", _parent);
1317   lv->readFile(log);
1318   lv->show();
1319 }
1320
1321 void GenericGui::onGetErrorReport()
1322 {
1323   DEBTRACE("GenericGui::onGetErrorReport");
1324   if (!QtGuiContext::getQtCurrent()) return;
1325   if (!QtGuiContext::getQtCurrent()->getGuiExecutor()) return;
1326   Subject *sub = QtGuiContext::getQtCurrent()->getSelectedSubject();
1327   SubjectElementaryNode *snode = dynamic_cast<SubjectElementaryNode*>(sub);
1328   if (!snode) return;
1329   string log = QtGuiContext::getQtCurrent()->getGuiExecutor()->getErrorReport(snode->getNode());
1330   LogViewer *lv = new LogViewer("Node error report", _parent);
1331   lv->setText(log);
1332   lv->show();
1333 }
1334
1335 void GenericGui::onGetErrorDetails()
1336 {
1337   DEBTRACE("GenericGui::onGetErrorDetails");
1338   if (!QtGuiContext::getQtCurrent()) return;
1339   if (!QtGuiContext::getQtCurrent()->getGuiExecutor()) return;
1340   Subject *sub = QtGuiContext::getQtCurrent()->getSelectedSubject();
1341   SubjectElementaryNode *snode = dynamic_cast<SubjectElementaryNode*>(sub);
1342   if (!snode) return;
1343   string log = QtGuiContext::getQtCurrent()->getGuiExecutor()->getErrorDetails(snode->getNode());
1344   LogViewer *lv = new LogViewer("Node Error Details", _parent);
1345   lv->setText(log);
1346   lv->show();
1347 }
1348
1349 void GenericGui::onGetContainerLog()
1350 {
1351   DEBTRACE("GenericGui::onGetContainerLog");
1352   if (!QtGuiContext::getQtCurrent()) return;
1353   if (!QtGuiContext::getQtCurrent()->getGuiExecutor()) return;
1354   Subject *sub = QtGuiContext::getQtCurrent()->getSelectedSubject();
1355   SubjectElementaryNode *snode = dynamic_cast<SubjectElementaryNode*>(sub);
1356   if (!snode) return;
1357   string log = QtGuiContext::getQtCurrent()->getGuiExecutor()->getContainerLog(snode->getNode());
1358   LogViewer *lv = new LogViewer("Node Container Log", _parent);
1359   lv->readFile(log);
1360   lv->show();
1361 }
1362
1363
1364
1365 void GenericGui::onEditDataTypes()
1366 {
1367   DEBTRACE("GenericGui::onEditDataTypes");
1368 }
1369
1370 void GenericGui::onCreateDataType()
1371 {
1372   DEBTRACE("GenericGui::onCreateDataType");
1373 }
1374
1375 void GenericGui::onImportDataType()
1376 {
1377   DEBTRACE("GenericGui::onImportDataType");
1378   if (_dwCatalogs) _dwCatalogs->raise();
1379 }
1380
1381
1382 void GenericGui::onNewContainer()
1383 {
1384   DEBTRACE("GenericGui::onNewContainer");
1385   _guiEditor->CreateContainer();
1386 }
1387
1388 void GenericGui::onNewSalomeComponent()
1389 {
1390   DEBTRACE("GenericGui::onNewSalomeComponent");
1391 }
1392
1393 void GenericGui::onNewSalomePythonComponent()
1394 {
1395   DEBTRACE("GenericGui::onNewSalomePythonComponent");
1396 }
1397
1398 void GenericGui::onNewCorbaComponent()
1399 {
1400   DEBTRACE("GenericGui::onNewCorbaComponent");
1401 }
1402
1403
1404 void GenericGui::onSalomeServiceNode()
1405 {
1406   DEBTRACE("GenericGui::onSalomeServiceNode");
1407   _guiEditor->CreateNode("SalomeNode");
1408 }
1409
1410 void GenericGui::onServiceInlineNode()
1411 {
1412   DEBTRACE("GenericGui::onServiceInlineNode");
1413   _guiEditor->CreateNode("SalomePythonNode");
1414 }
1415
1416 void GenericGui::onCORBAServiceNode()
1417 {
1418   DEBTRACE("GenericGui::onCORBAServiceNode");
1419   _guiEditor->CreateNode("CORBANode");
1420 }
1421
1422 void GenericGui::onNodeNodeServiceNode()
1423 {
1424   DEBTRACE("GenericGui::onNodeNodeServiceNode");
1425 }
1426
1427 void GenericGui::onCppNode()
1428 {
1429   DEBTRACE("GenericGui::onCppNode");
1430   _guiEditor->CreateNode("CppNode");
1431 }
1432
1433 void GenericGui::onXMLNode()
1434 {
1435   DEBTRACE("GenericGui::onXMLNode");
1436   _guiEditor->CreateNode("XmlNode");
1437 }
1438
1439 void GenericGui::onInDataNode()
1440 {
1441   DEBTRACE("GenericGui::onInDataNode");
1442   _guiEditor->CreateNode("PresetNode");
1443 }
1444
1445 void GenericGui::onOutDataNode()
1446 {
1447   DEBTRACE("GenericGui::onOutDataNode");
1448   _guiEditor->CreateNode("OutNode");
1449 }
1450
1451 void GenericGui::onInStudyNode()
1452 {
1453   DEBTRACE("GenericGui::onInStudyNode");
1454   _guiEditor->CreateNode("StudyInNode");
1455 }
1456
1457 void GenericGui::onOutStudyNode()
1458 {
1459   DEBTRACE("GenericGui::onOutStudyNode");
1460   _guiEditor->CreateNode("StudyOutNode");
1461 }
1462
1463 void GenericGui::onInlineScriptNode()
1464 {
1465   DEBTRACE("GenericGui::onInlineScriptNode");
1466   _guiEditor->CreateNode("PyScript");
1467 }
1468
1469 void GenericGui::onInlineFunctionNode()
1470 {
1471   DEBTRACE("GenericGui::onInlineFunctionNode");
1472   _guiEditor->CreateNode("PyFunction");
1473 }
1474
1475 void GenericGui::onBlockNode()
1476 {
1477   DEBTRACE("GenericGui::onBlockNode");
1478   _guiEditor->CreateBloc();
1479 }
1480
1481 void GenericGui::onFORNode()
1482 {
1483   DEBTRACE("GenericGui::onFORNode");
1484   _guiEditor->CreateForLoop();
1485 }
1486
1487 void GenericGui::onFOREACHNode()
1488 {
1489   DEBTRACE("GenericGui::onFOREACHNode");
1490   _guiEditor->CreateForEachLoop();
1491 }
1492
1493 void GenericGui::onWHILENode()
1494 {
1495   DEBTRACE("GenericGui::onWHILENode");
1496   _guiEditor->CreateWhileLoop();
1497 }
1498
1499 void GenericGui::onSWITCHNode()
1500 {
1501   DEBTRACE("GenericGui::onSWITCHNode");
1502   _guiEditor->CreateSwitch();
1503 }
1504
1505 void GenericGui::onNodeFromCatalog()
1506 {
1507   DEBTRACE("GenericGui::onNodeFromCatalog");
1508   if (_dwCatalogs) _dwCatalogs->raise();
1509 }
1510
1511 void GenericGui::onDeleteItem()
1512 {
1513   DEBTRACE("GenericGui::onDeleteItem");
1514   _guiEditor->DeleteSubject();
1515 }
1516
1517 void GenericGui::onCutItem()
1518 {
1519   DEBTRACE("GenericGui::onCutItem");
1520   _guiEditor->CutSubject();
1521 }
1522
1523 void GenericGui::onCopyItem()
1524 {
1525   DEBTRACE("GenericGui::onCopyItem");
1526   _guiEditor->CopySubject();
1527 }
1528
1529 void GenericGui::onPasteItem()
1530 {
1531   DEBTRACE("GenericGui::onPasteItem");
1532   _guiEditor->PasteSubject();
1533 }
1534
1535 void GenericGui::onArrangeLocalNodes()
1536 {
1537   DEBTRACE("GenericGui::onArrangeLocalNodes");
1538   _guiEditor->arrangeNodes(false);
1539 }
1540
1541 void GenericGui::onArrangeRecurseNodes()
1542 {
1543   DEBTRACE("GenericGui::onArrangeRecurseNodes");
1544   _guiEditor->arrangeNodes(true);
1545 }
1546
1547 void GenericGui::onRebuildLinks()
1548 {
1549   DEBTRACE("GenericGui::onRebuildLinks");
1550   _guiEditor->rebuildLinks();
1551 }
1552
1553 void GenericGui::onToggleAutomaticComputeLinks(bool checked)
1554 {
1555   Scene::_autoComputeLinks = checked;
1556   DEBTRACE("Scene::_autoComputeLinks=" << checked);
1557 }
1558
1559 void GenericGui::onToggleSimplifyLinks(bool checked)
1560 {
1561   Scene::_simplifyLinks = checked;
1562   DEBTRACE("Scene::_simplifyLinks=" << checked);
1563 }
1564
1565 void GenericGui::onToggleForce2NodesLinks(bool checked)
1566 {
1567   Scene::_force2NodesLink  = checked;
1568   DEBTRACE("Scene::_force2NodesLink=" << checked);
1569 }
1570
1571 void GenericGui::onSelectReference()
1572 {
1573   Subject *sub = QtGuiContext::getQtCurrent()->getSelectedSubject();
1574   if (!sub) return;
1575   SubjectReference *ref = dynamic_cast<SubjectReference*>(sub);
1576   assert(ref);
1577   SubjectServiceNode *snode = dynamic_cast<SubjectServiceNode*>(ref->getReference());
1578   snode->select(true);
1579 }
1580
1581 void GenericGui::onWhatsThis()
1582 {
1583   DEBTRACE("GenericGui::onWhatsThis");
1584   QWhatsThis::enterWhatsThisMode();
1585 }
1586
1587 void GenericGui::onWithoutStopMode(bool checked)
1588 {
1589   DEBTRACE("GenericGui::onWithoutStopMode " << checked);
1590   if (!QtGuiContext::getQtCurrent()) return;
1591   if (!QtGuiContext::getQtCurrent()->getGuiExecutor()) return;
1592   if (checked) QtGuiContext::getQtCurrent()->getGuiExecutor()->setContinueMode();
1593 }
1594
1595 void GenericGui::onBreakpointsMode(bool checked)
1596 {
1597   DEBTRACE("GenericGui::onWithoutStopMode " << checked);
1598   if (!QtGuiContext::getQtCurrent()) return;
1599   if (!QtGuiContext::getQtCurrent()->getGuiExecutor()) return;
1600   if (checked) QtGuiContext::getQtCurrent()->getGuiExecutor()->setBreakpointMode();
1601 }
1602
1603 void GenericGui::onStepByStepMode(bool checked)
1604 {
1605   DEBTRACE("GenericGui::onWithoutStopMode " << checked);
1606   if (!QtGuiContext::getQtCurrent()) return;
1607   if (!QtGuiContext::getQtCurrent()->getGuiExecutor()) return;
1608   if (checked) QtGuiContext::getQtCurrent()->getGuiExecutor()->setStepByStepMode();
1609 }
1610
1611 void GenericGui::onToggleStopOnError(bool checked)
1612 {
1613   DEBTRACE("GenericGui::onToggleStopOnError " << checked);
1614   if (!QtGuiContext::getQtCurrent()) return;
1615   if (!QtGuiContext::getQtCurrent()->getGuiExecutor()) return;
1616 }
1617
1618 void GenericGui::onToggleSceneItemVisible(bool checked)
1619 {
1620   DEBTRACE("GenericGui::onToggleSceneItemVisible " << checked);
1621   if (!QtGuiContext::getQtCurrent()) return;
1622   Subject *sub = QtGuiContext::getQtCurrent()->getSelectedSubject();
1623   SubjectNode *snode = dynamic_cast<SubjectNode*>(sub);
1624   if (!snode) return;
1625   DEBTRACE("---");
1626   if (!QtGuiContext::getQtCurrent()->_mapOfSceneItem.count(sub)) return;
1627   DEBTRACE("---");
1628   SceneItem *item = QtGuiContext::getQtCurrent()->_mapOfSceneItem[sub];
1629   item->setVisible(checked);
1630 }
1631
1632 void GenericGui::onCleanOnExit()
1633 {
1634   DEBTRACE("GenericGui::onCleanOnExit");
1635   int studyId = _wrapper->activeStudyId();
1636   set<QtGuiContext*> setcpy = QtGuiContext::_setOfContext;
1637   set<QtGuiContext*>::iterator it = setcpy.begin();
1638   for ( ; it != setcpy.end(); ++it)
1639     if ((*it)->getStudyId() == studyId)
1640       {
1641         QtGuiContext::setQtCurrent(*it);
1642         delete(*it);
1643       }
1644 }