1 // Copyright (C) 2006-2020 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 #include "SALOME_ResourcesManager.hxx"
22 #include "SALOME_LifeCycleCORBA.hxx"
24 #include "RuntimeSALOME.hxx"
26 #include "InputPort.hxx"
27 #include "ServiceNode.hxx"
28 #include "parsers.hxx"
30 #include "YACSGuiLoader.hxx"
31 #include "ComponentInstance.hxx"
33 #include "SALOME_NamingService.hxx"
34 #include "SALOME_ModuleCatalog.hxx"
35 #include "SALOME_ModuleCatalog.hh"
36 #include "SALOMEDS_Tool.hxx"
38 #include "QtGuiContext.hxx"
40 #include "GuiEditor.hxx"
41 #include "GraphicsView.hxx"
43 #include "GenericGui.hxx"
44 #include "SceneItem.hxx"
45 #include "SceneNodeItem.hxx"
46 #include "SceneComposedNodeItem.hxx"
47 #include "ItemEdition.hxx"
48 #include "CatalogWidget.hxx"
49 #include "TreeView.hxx"
50 #include "VisitorSaveGuiSchema.hxx"
51 #include "TypeCode.hxx"
52 #include "LinkInfo.hxx"
53 #include "LogViewer.hxx"
55 #include "Resource.hxx"
56 #include "Message.hxx"
57 #include "ListJobs_GUI.hxx"
59 #include <QFileDialog>
63 #include <QMessageBox>
71 #define WEXITSTATUS(w) ((int) ((w) & 0x40000000))
75 #include "YacsTrace.hxx"
78 using namespace YACS::HMI;
80 GenericGui::GenericGui(YACS::HMI::SuitWrapper* wrapper, QMainWindow *parent)
91 _mapViewContext.clear();
95 QtGuiContext::_counters = new counters(100);
96 srand((unsigned)time(0));
98 GuiObserver::setEventMap();
100 string iconPath = getenv("YACS_ROOT_DIR");
101 iconPath += "/share/salome/resources/yacs";
103 QDir::addSearchPath("icons", iconPath.c_str());
105 _guiEditor = new GuiEditor();
107 YACS::ENGINE::RuntimeSALOME::setRuntime();
108 _loader = new YACSGuiLoader();
109 _loader->registerProcCataLoader();
110 _builtinCatalog = YACS::ENGINE::getSALOMERuntime()->getBuiltinCatalog();
114 YACS::ENGINE::RuntimeSALOME* runTime = YACS::ENGINE::getSALOMERuntime();
115 CORBA::ORB_ptr orb = runTime->getOrb();
118 SALOME_NamingService namingService(orb);
119 CORBA::Object_ptr obj = namingService.Resolve("/Kernel/ModulCatalog");
120 SALOME_ModuleCatalog::ModuleCatalog_var aModuleCatalog =
121 SALOME_ModuleCatalog::ModuleCatalog::_narrow(obj);
122 if (! CORBA::is_nil(aModuleCatalog))
124 DEBTRACE("SALOME_ModuleCatalog::ModuleCatalog found");
125 std::string anIOR = orb->object_to_string( aModuleCatalog );
126 _sessionCatalog = runTime->loadCatalog( "session", anIOR );
127 runTime->addCatalog(_sessionCatalog);
129 std::map< std::string, YACS::ENGINE::ComponentDefinition * >::iterator it;
130 for (it = _sessionCatalog->_componentMap.begin();
131 it != _sessionCatalog->_componentMap.end(); ++it)
132 DEBTRACE("Component: " <<(*it).first);
135 std::map< std::string, YACS::ENGINE::TypeCode*>::iterator it;
136 for (it = _sessionCatalog->_typeMap.begin();
137 it != _sessionCatalog->_typeMap.end(); ++it)
138 DEBTRACE("Type : " <<(*it).first
139 << " " << (*it).second->getKindRepr()
140 << " " << (*it).second->name()
141 << " " << (*it).second->shortName()
142 << " " << (*it).second->id() );
144 DEBTRACE("_sessionCatalog " << _sessionCatalog);
148 catch(ServiceUnreachable& e)
150 DEBTRACE("Caught Exception. "<<e);
153 _dwTree = new QDockWidget(_parent);
154 _dwTree->setVisible(false);
155 _dwTree->setWindowTitle("Tree View: edition mode");
156 _dwTree->setObjectName("yacsTreeViewDock");
157 _parent->addDockWidget(Qt::LeftDockWidgetArea, _dwTree);
158 _dwStacked = new QDockWidget(_parent);
159 _dwStacked->setVisible(false);
160 _dwStacked->setWindowTitle("Input Panel");
161 _dwStacked->setObjectName("yacsInputPanelDock");
162 _dwStacked->setMinimumWidth(270); // --- force a minimum until display
163 _parent->addDockWidget(Qt::RightDockWidgetArea, _dwStacked);
164 _dwCatalogs = new QDockWidget(_parent);
165 _dwCatalogs->setVisible(false);
166 _dwCatalogs->setWindowTitle("Catalogs");
167 _dwCatalogs->setObjectName("yacsCatalogsDock");
168 _parent->addDockWidget(Qt::RightDockWidgetArea, _dwCatalogs);
169 _catalogsWidget = new CatalogWidget(_dwCatalogs,
172 _dwCatalogs->setWidget(_catalogsWidget);
174 _parent->tabifyDockWidget(_dwStacked, _dwCatalogs);
175 if (_wrapper->objectBrowser())
176 _parent->tabifyDockWidget(_dwTree, _wrapper->objectBrowser());
177 _parent->setTabPosition(Qt::AllDockWidgetAreas, Resource::tabPanelsUp? QTabWidget::North: QTabWidget::South);
178 //Import user catalog
179 std::string usercata=Resource::userCatalog.toStdString();
180 _catalogsWidget->addCatalogFromFile(usercata);
183 GenericGui::~GenericGui()
185 if(_BJLdialog) delete _BJLdialog;
188 void GenericGui::createActions()
190 // QAction* createAction(const int id,
191 // const QString& toolTip,
192 // const QIcon& icon,
193 // const QString& menu,
194 // const QString& status,
195 // const int shortCut,
196 // QObject* parent =0,
197 // bool checkable = false,
198 // QObject* receiver =0,
199 // const char* member =0);
201 _newSchemaAct = _wrapper->createAction(getMenuId(), tr("Create a new YACS Schema"), QIcon("icons:schema.png"),
202 tr("New Schema"), tr("Create a new YACS Schema"),
203 0, _parent, false, this, SLOT(onNewSchema()));
204 _newSchemaAct->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_N); // --- QKeySequence::New ambiguous in SALOME
206 _importSchemaAct = _wrapper->createAction(getMenuId(), tr("Import a YACS Schema for edition"), QIcon("icons:import_dataflow.png"),
207 tr("Import Schema"), tr("Import a YACS Schema for edition"),
208 0, _parent, false, this, SLOT(onImportSchema()));
209 _importSchemaAct->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_O); // --- QKeySequence::Open ambiguous in SALOME
211 _importSupervSchemaAct = _wrapper->createAction(getMenuId(), tr("Import a SUPERV Schema for edition"), QIcon("icons:import_superv_dataflow.png"),
212 tr("Import SUPERV Schema"), tr("Import a SUPERV Schema for edition"),
213 0, _parent, false, this, SLOT(onImportSupervSchema()));
215 _exportSchemaAct = _wrapper->createAction(getMenuId(), tr("Save the current YACS Schema"), QIcon("icons:save_dataflow.png"),
216 tr("Save Schema"), tr("Save the current YACS Schema"),
217 0, _parent, false, this, SLOT(onExportSchema()));
218 _exportSchemaAct->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_S); // --- QKeySequence::Save ambiguous in SALOME
220 _exportSchemaAsAct = _wrapper->createAction(getMenuId(), tr("Save the current YACS Schema As..."), QIcon("icons:export_dataflow.png"),
221 tr("Save Schema As"), tr("Save the current YACS Schema As..."),
222 0, _parent, false, this, SLOT(onExportSchemaAs()));
223 //_exportSchemaAsAct->setShortcut(QKeySequence::SaveAs); // --- ambiguous in SALOME
225 _importCatalogAct = _wrapper->createAction(getMenuId(), tr("Import a Schema as a Catalog"), QIcon("icons:insert_file.png"),
226 tr("Import Catalog"), tr("Import a Schema as a Catalog"),
227 0, _parent, false, this, SLOT(onImportCatalog()));
230 _runLoadedSchemaAct = _wrapper->createAction(getMenuId(), tr("Prepare the current edited schema for run"), QIcon("icons:run_active.png"),
231 tr("Run Current Schema"), tr("Prepare the current edited schema for run"),
232 0, _parent, false, this, SLOT(onRunLoadedSchema()));
234 _loadRunStateSchemaAct = _wrapper->createAction(getMenuId(), tr("Load a previous run state for this schema, prepare to run"), QIcon("icons:load_execution_state.png"),
235 tr("Load Run State"), tr("Load a previous run state for this schema, prepare to run"),
236 0, _parent, false, this, SLOT(onLoadRunStateSchema()));
238 _loadAndRunSchemaAct = _wrapper->createAction(getMenuId(), tr("Load a schema for run"), QIcon("icons:run.png"),
239 tr("Load Schema to run"), tr("Load a schema for run"),
240 0, _parent, false, this, SLOT(onLoadAndRunSchema()));
242 _chooseBatchJobAct = _wrapper->createAction(getMenuId(), tr("Choose Batch Job to watch"), QIcon("icons:batch.png"),
243 tr("Choose Batch Job to watch"), tr("Choose Batch Job to watch"),
244 0, _parent, false, this, SLOT(onChooseBatchJob()));
246 _startResumeAct = _wrapper->createAction(getMenuId(), tr("Start or Resume Schema execution"), QIcon("icons:suspend_resume.png"),
247 tr("Start/Resume execution"), tr("Start or Resume Schema execution"),
248 0, _parent, false, this, SLOT(onStartResume()));
250 _abortAct = _wrapper->createAction(getMenuId(), tr("Abort the current execution"), QIcon("icons:kill.png"),
251 tr("Abort execution"), tr("Abort the current execution"),
252 0, _parent, false, this, SLOT(onAbort()));
254 _pauseAct = _wrapper->createAction(getMenuId(), tr("Suspend the current execution"), QIcon("icons:pause.png"),
255 tr("Suspend execution"), tr("Suspend the current execution"),
256 0, _parent, false, this, SLOT(onPause()));
258 _resetAct = _wrapper->createAction(getMenuId(), tr("Reset error nodes and restart the current execution"), QIcon("icons:reset.png"),
259 tr("Restart execution"), tr("Restart the current execution with reset of error nodes"),
260 0, _parent, false, this, SLOT(onReset()));
263 _saveRunStateAct = _wrapper->createAction(getMenuId(), tr("Save the current run state"), QIcon("icons:save_dataflow_state.png"),
264 tr("Save State"), tr("Save the current run state"),
265 0, _parent, false, this, SLOT(onSaveRunState()));
267 _newEditionAct = _wrapper->createAction(getMenuId(), tr("Edit again the current schema in a new context"), QIcon("icons:new_edition.png"),
268 tr("Edit Again"), tr("Edit again the current schema in a new context"),
269 0, _parent, false, this, SLOT(onNewEdition()));
272 _getYacsContainerLogAct = _wrapper->createAction(getMenuId(), tr("get YACS container log"), QIcon("icons:change_informations.png"),
273 tr("YACS Container Log"), tr("get YACS container log"),
274 0, _parent, false, this, SLOT(onGetYacsContainerLog()));
276 _getErrorReportAct = _wrapper->createAction(getMenuId(), tr("get Node Error Report"), QIcon("icons:filter_notification.png"),
277 tr("Node Error Report"), tr("get Node Error Report"),
278 0, _parent, false, this, SLOT(onGetErrorReport()));
280 _getErrorDetailsAct = _wrapper->createAction(getMenuId(), tr("get Node Error Details"), QIcon("icons:icon_text.png"),
281 tr("Node Error Details"), tr("get Node Error Details"),
282 0, _parent, false, this, SLOT(onGetErrorDetails()));
284 _getContainerLogAct = _wrapper->createAction(getMenuId(), tr("get Node Container Log"), QIcon("icons:change_informations.png"),
285 tr("Node Container Log"), tr("get Node Container Log"),
286 0, _parent, false, this, SLOT(onGetContainerLog()));
288 _shutdownProcAct = _wrapper->createAction(getMenuId(), tr("Shutdown Proc"), QIcon("icons:kill.png"),
289 tr("Shutdown Proc"), tr("Shutdown Proc"),
290 0, _parent, false, this, SLOT(onShutdownProc()));
293 _editDataTypesAct = _wrapper->createAction(getMenuId(), tr("Edit Data Types"), QIcon("icons:kill.png"),
294 tr("Edit Data Types"), tr("Edit Data Types"),
295 0, _parent, false, this, SLOT(onEditDataTypes()));
297 _createDataTypeAct = _wrapper->createAction(getMenuId(), tr("Create Data Types"), QIcon("icons:kill.png"),
298 tr("Create Data Types"), tr("Create Data Types"),
299 0, _parent, false, this, SLOT(onCreateDataType()));
301 _importDataTypeAct = _wrapper->createAction(getMenuId(), tr("Import Data Types, use drag and drop from catalog"), QIcon("icons:folder_cyan.png"),
302 tr("Import Data Types"), tr("Import Data Types, use drag and drop from catalog"),
303 0, _parent, false, this, SLOT(onImportDataType()));
305 _newContainerAct = _wrapper->createAction(getMenuId(), tr("Create a New Container"), QIcon("icons:container.png"),
306 tr("Create Container"), tr("Create a New Container"),
307 0, _parent, false, this, SLOT(onNewContainer()));
309 _newHPContainerAct = _wrapper->createAction(getMenuId(), tr("Create a New HP Container"), QIcon("icons:container.png"),
310 tr("Create HP Container"), tr("Create a New Homogeneous Pool Container."),
311 0, _parent, false, this, SLOT(onNewHPContainer()));
313 _selectComponentInstanceAct = _wrapper->createAction(getMenuId(), tr("Select a Component Instance"), QIcon("icons:icon_select.png"),
314 tr("Select a Component Instance"), tr("Select a Component Instance"),
315 0, _parent, false, this, SLOT(onSelectComponentInstance()));
317 _newSalomeComponentAct = _wrapper->createAction(getMenuId(), tr("Create a New SALOME Component Instance"), QIcon("icons:new_salome_component.png"),
318 tr("Create Component Instance"), tr("Create a New SALOME Component Instance"),
319 0, _parent, false, this, SLOT(onNewSalomeComponent()));
321 _newSalomePythonComponentAct = _wrapper->createAction(getMenuId(), tr("Create a New SALOME Python Component"), QIcon("icons:new_salomepy_component.png"),
322 tr("SALOME Python Component"), tr("Create a New SALOME Python Component"),
323 0, _parent, false, this, SLOT(onNewSalomePythonComponent()));
325 _newCorbaComponentAct = _wrapper->createAction(getMenuId(), tr("Create a New CORBA Component"), QIcon("icons:new_corba_component.png"),
326 tr("CORBA Component"), tr("Create a New CORBA Component"),
327 0, _parent, false, this, SLOT(onNewCorbaComponent()));
329 _salomeServiceNodeAct = _wrapper->createAction(getMenuId(), tr("Create a New SALOME Service Node"), QIcon("icons:new_salome_service_node.png"),
330 tr("SALOME Service Node"), tr("Create a New SALOME Service Node"),
331 0, _parent, false, this, SLOT(onSalomeServiceNode()));
333 _serviceInlineNodeAct = _wrapper->createAction(getMenuId(), tr("Create a New Inline Service Node"), QIcon("icons:new_service_inline_node.png"),
334 tr("Inline Service Node"), tr("Create a New Inline Service Node"),
335 0, _parent, false, this, SLOT(onServiceInlineNode()));
337 _CORBAServiceNodeAct = _wrapper->createAction(getMenuId(), tr("Create a New CORBA Service Node"), QIcon("icons:new_corba_service_node.png"),
338 tr("CORBA Node"), tr("Create a New CORBA Service Node"),
339 0, _parent, false, this, SLOT(onCORBAServiceNode()));
341 _nodeNodeServiceNodeAct = _wrapper->createAction(getMenuId(), tr("Create a New Node referencing a Node"), QIcon("icons:new_nodenode_service_node.png"),
342 tr("Ref on Node"), tr("Create a New Node referencing a Node"),
343 0, _parent, false, this, SLOT(onNodeNodeServiceNode()));
345 _cppNodeAct = _wrapper->createAction(getMenuId(), tr("Create a New C++ Node"), QIcon("icons:new_cpp_node.png"),
346 tr("Cpp Node"), tr("Create a New C++ Node"),
347 0, _parent, false, this, SLOT(onCppNode()));
349 _inDataNodeAct = _wrapper->createAction(getMenuId(), tr("Create a New Input data Node"), QIcon("icons:node.png"),
350 tr("Input Data Node"), tr("Create a New Input data Node"),
351 0, _parent, false, this, SLOT(onInDataNode()));
353 _outDataNodeAct = _wrapper->createAction(getMenuId(), tr("Create a New Output data Node"), QIcon("icons:node.png"),
354 tr("Output Data Node"), tr("Create a New Output data Node"),
355 0, _parent, false, this, SLOT(onOutDataNode()));
357 _inStudyNodeAct = _wrapper->createAction(getMenuId(), tr("Create a New Input Study Node"), QIcon("icons:node.png"),
358 tr("Input Study Node"), tr("Create a New Input Study Node"),
359 0, _parent, false, this, SLOT(onInStudyNode()));
361 _outStudyNodeAct = _wrapper->createAction(getMenuId(), tr("Create a New Output Study Node"), QIcon("icons:node.png"),
362 tr("Output Study Node"), tr("Create a New Output Study Node"),
363 0, _parent, false, this, SLOT(onOutStudyNode()));
365 _inlineScriptNodeAct = _wrapper->createAction(getMenuId(), tr("Create a New Inline Python Script Node"), QIcon("icons:new_inline_script_node.png"),
366 tr("Inline Script Node"), tr("Create a New Inline Python Script Node"),
367 0, _parent, false, this, SLOT(onInlineScriptNode()));
369 _inlineFunctionNodeAct = _wrapper->createAction(getMenuId(), tr("Create a New Inline Python Function Node"), QIcon("icons:new_inline_function_node.png"),
370 tr("Inline Function Node"), tr("Create a New Inline Python Function Node"),
371 0, _parent, false, this, SLOT(onInlineFunctionNode()));
373 _blockNodeAct = _wrapper->createAction(getMenuId(), tr("Create a New Bloc Node"), QIcon("icons:new_block_node.png"),
374 tr("bloc Node"), tr("Create a New Bloc Node"),
375 0, _parent, false, this, SLOT(onBlockNode()));
377 _FORNodeAct = _wrapper->createAction(getMenuId(), tr("Create a New For Loop Node"), QIcon("icons:new_for_loop_node.png"),
378 tr("For Loop Node"), tr("Create a New For Loop Node"),
379 0, _parent, false, this, SLOT(onFORNode()));
381 _FOREACHNodeAct = _wrapper->createAction(getMenuId(), tr("Create a New For Each Loop Node"), QIcon("icons:new_foreach_loop_node.png"),
382 tr("For Each Loop Node"), tr("Create a New For Each Loop Node"),
383 0, _parent, false, this, SLOT(onFOREACHNode()));
385 _WHILENodeAct = _wrapper->createAction(getMenuId(), tr("Create a New While Loop Node"), QIcon("icons:new_while_loop_node.png"),
386 tr("While Loop Node"), tr("Create a New While Loop Node"),
387 0, _parent, false, this, SLOT(onWHILENode()));
389 _SWITCHNodeAct = _wrapper->createAction(getMenuId(), tr("Create a New Switch Node"), QIcon("icons:new_switch_loop_node.png"),
390 tr("Switch Node"), tr("Create a New Switch Node"),
391 0, _parent, false, this, SLOT(onSWITCHNode()));
393 _OptimizerLoopAct = _wrapper->createAction(getMenuId(), tr("Create a New Optimizer Loop Node"), QIcon("icons:new_for_loop_node.png"),
394 tr("Optimizer Loop"), tr("Create a New Optimizer Loop"),
395 0, _parent, false, this, SLOT(onOptimizerLoop()));
397 _nodeFromCatalogAct = _wrapper->createAction(getMenuId(), tr("Create a New Node from Catalog, use drag and drop from catalog"), QIcon("icons:new_from_library_node.png"),
398 tr("Node from Catalog"), tr("Create a New Node from Catalog, use drag and drop from catalog"),
399 0, _parent, false, this, SLOT(onNodeFromCatalog()));
401 _deleteItemAct = _wrapper->createAction(getMenuId(), tr("Delete a Schema Item"), QIcon("icons:delete.png"),
402 tr("Delete Item"), tr("Delete a Schema Item"),
403 0, _parent, false, this, SLOT(onDeleteItem()));
404 _deleteItemAct->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_D); // --- QKeySequence::Delete dangerous...
406 _cutItemAct = _wrapper->createAction(getMenuId(), tr("Cut a Schema Item"), QIcon("icons:cut.png"),
407 tr("Cut Item"), tr("Cut a Schema Item"),
408 0, _parent, false, this, SLOT(onCutItem()));
409 _cutItemAct->setShortcut(QKeySequence::Cut);
411 _copyItemAct = _wrapper->createAction(getMenuId(), tr("Copy a Schema Item"), QIcon("icons:copy.png"),
412 tr("Copy Item"), tr("Copy a Schema Item"),
413 0, _parent, false, this, SLOT(onCopyItem()));
414 _copyItemAct->setShortcut(QKeySequence::Copy);
416 _pasteItemAct = _wrapper->createAction(getMenuId(), tr("Paste a Schema Item"), QIcon("icons:paste.png"),
417 tr("Paste Item"), tr("Paste a Schema Item"),
418 0, _parent, false, this, SLOT(onPasteItem()));
419 _pasteItemAct->setShortcut(QKeySequence::Paste);
421 _putInBlocAct = _wrapper->createAction(getMenuId(), tr("Put node in block"), QIcon("icons:paste.png"),
422 tr("Put node in block"), tr("Put node in block"),
423 0, _parent, false, this, SLOT(onPutInBloc()));
425 _putGraphInBlocAct = _wrapper->createAction(getMenuId(), tr("Bloc"), QIcon("icons:new_block_node.png"),
426 tr("Bloc"), tr("Bloc"),
427 0, _parent, false, this, SLOT(onPutGraphInBloc()));
429 _putGraphInForLoopAct = _wrapper->createAction(getMenuId(), tr("For Loop"), QIcon("icons:new_for_loop_node.png"),
430 tr("For Loop"), tr("For Loop"),
431 0, _parent, false, this, SLOT(onPutGraphInForLoop()));
433 _putGraphInWhileLoopAct = _wrapper->createAction(getMenuId(), tr("While Loop"), QIcon("icons:new_while_loop_node.png"),
434 tr("While Loop"), tr("While Loop"),
435 0, _parent, false, this, SLOT(onPutGraphInWhileLoop()));
437 _putGraphInOptimizerLoopAct = _wrapper->createAction(getMenuId(), tr("Optimizer Loop"), QIcon("icons:new_for_loop_node.png"),
438 tr("Optimizer Loop"), tr("Optimizer Loop"),
439 0, _parent, false, this, SLOT(onPutGraphInOptimizerLoop()));
441 _arrangeLocalNodesAct = _wrapper->createAction(getMenuId(), tr("arrange nodes on that bloc level, without recursion"), QIcon("icons:arrange_nodes.png"),
442 tr("arrange local nodes"), tr("arrange nodes on that bloc level, without recursion"),
443 0, _parent, false, this, SLOT(onArrangeLocalNodes()));
445 _arrangeRecurseNodesAct = _wrapper->createAction(getMenuId(), tr("arrange nodes on that bloc level, with recursion"), QIcon("icons:sample.png"),
446 tr("arrange nodes recursion"), tr("arrange nodes on that bloc level, with recursion"),
447 0, _parent, false, this, SLOT(onArrangeRecurseNodes()));
449 _computeLinkAct = _wrapper->createAction(getMenuId(), tr("compute orthogonal links"), QIcon("icons:rebuild_links.png"),
450 tr("compute links"), tr("compute orthogonal links"),
451 0, _parent, false, this, SLOT(onRebuildLinks()));
453 _zoomToBlocAct = _wrapper->createAction(getMenuId(), tr("zoom 2D view to selected bloc"), QIcon("icons:zoomToBloc.png"),
454 tr("zoom to bloc"), tr("zoom 2D view to the selected composed node"),
455 0, _parent, false, this, SLOT(onZoomToBloc()));
457 _centerOnNodeAct = _wrapper->createAction(getMenuId(), tr("center 2D view on selected node"), QIcon("icons:centerOnNode.png"),
458 tr("center on node"), tr("center 2D view on selected node"),
459 0, _parent, false, this, SLOT(onCenterOnNode()));
460 _centerOnNodeAct->setShortcut(QKeySequence::Find);
462 _shrinkExpand = _wrapper->createAction(getMenuId(), tr("shrink or expand the selected node"), QIcon("icons:shrinkExpand.png"),
463 tr("shrink/expand"), tr("shrink or expand the selected node"),
464 0, _parent, false, this, SLOT(onShrinkExpand()));
466 _shrinkExpandChildren = _wrapper->createAction(getMenuId(), tr("shrink or expand direct children of the selected node"), QIcon("icons:shrinkExpand.png"),
467 tr("shrink/expand children"), tr("shrink or expand direct children of the selected node"),
468 0, _parent, false, this, SLOT(onShrinkExpandChildren()));
470 _shrinkExpandElementaryRecursively = _wrapper->createAction(getMenuId(), tr("shrink or expand elementary nodes of the selected node recursively"), QIcon("icons:shrinkExpand.png"),
471 tr("shrink/expand elementary"), tr("shrink or expand elementary nodes of the selected node recursively"),
472 0, _parent, false, this, SLOT(onShrinkExpandElementaryRecursively()));
474 _toggleStraightLinksAct = _wrapper->createAction(getMenuId(), tr("draw straight or orthogonal links"), QIcon("icons:straightLink.png"),
475 tr("straight/orthogonal"), tr("draw straight or orthogonal links"),
476 0, _parent, true, this, SLOT(onToggleStraightLinks(bool)));
478 _toggleStraightLinksAct->setChecked(Resource::straightLinks);
479 onToggleStraightLinks(Resource::straightLinks);
481 _toggleAutomaticComputeLinkAct = _wrapper->createAction(getMenuId(), tr("compute othogonal links automatically when nodes move"), QIcon("icons:autoComputeLink.png"),
482 tr("automatic link"), tr("compute othogonal links automatically when nodes move"),
483 0, _parent, true, this, SLOT(onToggleAutomaticComputeLinks(bool)));
485 _toggleAutomaticComputeLinkAct->setChecked(Resource::autoComputeLinks);
486 onToggleAutomaticComputeLinks(Resource::autoComputeLinks); // Why is this needed ?
488 _toggleSimplifyLinkAct = _wrapper->createAction(getMenuId(), tr("simplify links by removing unnecessary direction changes"), QIcon("icons:simplifyLink.png"),
489 tr("simplify links"), tr("simplify links by removing unnecessary direction changes"),
490 0, _parent, true, this, SLOT(onToggleSimplifyLinks(bool)));
491 _toggleSimplifyLinkAct->setChecked(Resource::simplifyLink);
492 onToggleSimplifyLinks(Resource::simplifyLink);
494 _toggleForce2NodesLinkAct = _wrapper->createAction(getMenuId(), tr("force orthogonal links by adding an edge on simples links"), QIcon("icons:force2nodeLink.png"),
495 tr("force ortho links"), tr("force orthogonal links by adding an edge on simples links"),
496 0, _parent, true, this, SLOT(onToggleForce2NodesLinks(bool)));
497 _toggleForce2NodesLinkAct->setChecked(true);
499 _toggleAddRowColsAct = _wrapper->createAction(getMenuId(), tr("allow more path for the links, for a better separation"), QIcon("icons:addRowCols.png"),
500 tr("separate links"), tr("allow more path for the links, for a better separation"),
501 0, _parent, true, this, SLOT(onToggleAddRowCols(bool)));
502 _toggleAddRowColsAct->setChecked(Resource::addRowCols);
503 onToggleAddRowCols(Resource::addRowCols);
505 _selectReferenceAct = _wrapper->createAction(getMenuId(), tr("select reference"), QIcon("icons:ob_service_node.png"),
506 tr("select reference"), tr("select reference"),
507 0, _parent, false, this, SLOT(onSelectReference()));
509 _whatsThisAct = _wrapper->createAction(getMenuId(), tr("active whatsThis Mode to get help on widgets"), QIcon("icons:whatsThis.png"),
510 tr("whatsThis Mode"), tr("active whatsThis Mode to get help on widgets"),
511 0, _parent, false, this, SLOT(onWhatsThis()));
512 _whatsThisAct->setShortcut(QKeySequence::WhatsThis);
514 _withoutStopModeAct = _wrapper->createAction(getMenuId(), tr("set execution mode without stop"), QIcon("icons:run_active.png"),
515 tr("mode without stop"), tr("set execution mode without stop"),
516 0, _parent, true, this, SLOT(onWithoutStopMode(bool)));
518 _breakpointsModeAct = _wrapper->createAction(getMenuId(), tr("set execution mode with stop on breakpoints"), QIcon("icons:breakpoints_active.png"),
519 tr("mode breakpoints"), tr("set execution mode with stop on breakpoints"),
520 0, _parent, true, this, SLOT(onBreakpointsMode(bool)));
522 _stepByStepModeAct = _wrapper->createAction(getMenuId(), tr("set execution mode step by step"), QIcon("icons:step_by_step_active.png"),
523 tr("mode step by step"), tr("set execution mode step by step"),
524 0, _parent, true, this, SLOT(onStepByStepMode(bool)));
526 _toggleStopOnErrorAct = _wrapper->createAction(getMenuId(), tr("Force stop on first error during execution"), QIcon("icons:toggle_stop_on_error.png"),
527 tr("stop on error"), tr("Force stop on first error during execution"),
528 0, _parent, true, this, SLOT(onToggleStopOnError(bool)));
530 _toggleSceneItemVisibleAct = _wrapper->createAction(getMenuId(), tr("toggle 2D scene item visibility"), QIcon("icons:toggleVisibility.png"),
531 tr("visible/hidden"), tr("toggle 2D scene item visibility"),
532 0, _parent, true, this, SLOT(onToggleSceneItemVisible(bool)));
536 _showAllLinksAct = _wrapper->createAction(getMenuId(), tr("Show all the links"), QIcon("icons:showLink.png"),
537 tr("show all links"), tr("Show all the links"),
538 0, _parent, false, this, SLOT(onShowAllLinks()));
540 _hideAllLinksAct = _wrapper->createAction(getMenuId(), tr("Hide all the links"), QIcon("icons:hideLink.png"),
541 tr("hide all links"), tr("Hide all the links"),
542 0, _parent, false, this, SLOT(onHideAllLinks()));
545 _showOnlyPortLinksAct = _wrapper->createAction(getMenuId(), tr("Show only links from/to this port"), QIcon("icons:showLink.png"),
546 tr("show only links"), tr("Show only links from/to this port"),
547 0, _parent, false, this, SLOT(onShowOnlyPortLinks()));
549 _showPortLinksAct = _wrapper->createAction(getMenuId(), tr("Show links from/to this port"), QIcon("icons:showLink.png"),
550 tr("show links"), tr("Show links from/to this port"),
551 0, _parent, false, this, SLOT(onShowPortLinks()));
553 _hidePortLinksAct = _wrapper->createAction(getMenuId(), tr("Hide links from/to this port"), QIcon("icons:hideLink.png"),
554 tr("hide links"), tr("Hide links from/to this port"),
555 0, _parent, false, this, SLOT(onHidePortLinks()));
558 _showOnlyCtrlLinksAct = _wrapper->createAction(getMenuId(), tr("Show only control links from/to this node"), QIcon("icons:showLink.png"),
559 tr("show only Control links"), tr("Show only control links from/to this node"),
560 0, _parent, false, this, SLOT(onShowOnlyCtrlLinks()));
562 _showCtrlLinksAct = _wrapper->createAction(getMenuId(), tr("Show control links from/to this node"), QIcon("icons:showLink.png"),
563 tr("show control links"), tr("Show control links from/to this node"),
564 0, _parent, false, this, SLOT(onShowCtrlLinks()));
566 _hideCtrlLinksAct = _wrapper->createAction(getMenuId(), tr("Hide control links from/to this node"), QIcon("icons:hideLink.png"),
567 tr("hide control links"), tr("Hide control links from/to this node"),
568 0, _parent, false, this, SLOT(onHideCtrlLinks()));
571 _showOnlyLinkAct = _wrapper->createAction(getMenuId(), tr("Show only this link"), QIcon("icons:showLink.png"),
572 tr("show only"), tr("Show only this link"),
573 0, _parent, false, this, SLOT(onShowOnlyLink()));
575 _showLinkAct = _wrapper->createAction(getMenuId(), tr("Show this link"), QIcon("icons:showLink.png"),
576 tr("show"), tr("Show this link"),
577 0, _parent, false, this, SLOT(onShowLink()));
579 _hideLinkAct = _wrapper->createAction(getMenuId(), tr("Hide this link"), QIcon("icons:hideLink.png"),
580 tr("hide"), tr("Hide this link"),
581 0, _parent, false, this, SLOT(onHideLink()));
584 _emphasisPortLinksAct = _wrapper->createAction(getMenuId(), tr("emphasis on links from/to this port"), QIcon("icons:emphasisLink.png"),
585 tr("emphasize links"), tr("emphasis on links from/to this port"),
586 0, _parent, false, this, SLOT(onEmphasisPortLinks()));
588 _emphasisCtrlLinksAct = _wrapper->createAction(getMenuId(), tr("emphasis on control links from/to this node"), QIcon("icons:emphasisLink.png"),
589 tr("emphasize control links"), tr("emphasis on control links from/to this node"),
590 0, _parent, false, this, SLOT(onEmphasisCtrlLinks()));
592 _emphasisLinkAct = _wrapper->createAction(getMenuId(), tr("emphasis on this link"), QIcon("icons:emphasisLink.png"),
593 tr("emphasize"), tr("emphasis on this link"),
594 0, _parent, false, this, SLOT(onEmphasisLink()));
596 _deEmphasizeAllAct = _wrapper->createAction(getMenuId(), tr("remove all emphasis"), QIcon("icons:deEmphasisLink.png"),
597 tr("remove all emphasis"), tr("remove all emphasis"),
598 0, _parent, false, this, SLOT(onDeEmphasizeAll()));
601 _undoAct = _wrapper->createAction(getMenuId(), tr("undo last action"), QIcon("icons:undo.png"),
602 tr("undo"), tr("undo last action"),
603 0, _parent, false, this, SLOT(onUndo()));
604 _undoAct->setShortcut(QKeySequence::Undo);
606 _redoAct = _wrapper->createAction(getMenuId(), tr("redo last action"), QIcon("icons:redo.png"),
607 tr("redo"), tr("redo last action"),
608 0, _parent, false, this, SLOT(onRedo()));
609 _redoAct->setShortcut(QKeySequence::Redo);
611 _showUndoAct = _wrapper->createAction(getMenuId(), tr("show undo commands"), QIcon("icons:undo.png"),
612 tr("show undo"), tr("show undo commands"),
613 0, _parent, false, this, SLOT(onShowUndo()));
615 _showRedoAct = _wrapper->createAction(getMenuId(), tr("show redo commands"), QIcon("icons:redo.png"),
616 tr("show redo"), tr("show redo commands"),
617 0, _parent, false, this, SLOT(onShowRedo()));
620 _execModeGroup = new QActionGroup(this);
621 _execModeGroup->addAction(_withoutStopModeAct);
622 _execModeGroup->addAction(_breakpointsModeAct);
623 _execModeGroup->addAction(_stepByStepModeAct);
624 _withoutStopModeAct->setChecked(true);
627 void GenericGui::createMenus()
630 aMenuId = _wrapper->createMenu( tr( "File" ), -1, -1 );
631 _wrapper->createMenu( _wrapper->separator(), aMenuId, -1, 10 );
632 aMenuId = _wrapper->createMenu( "YACS", aMenuId, -1, 10 );
633 _wrapper->createMenu( _newSchemaAct, aMenuId );
634 _wrapper->createMenu( _importSchemaAct, aMenuId );
636 aMenuId = _wrapper->createMenu( "YACS", -1, -1, 30 );
637 _wrapper->createMenu( _newSchemaAct, aMenuId );//, 10
638 _wrapper->createMenu( _importSchemaAct, aMenuId );
639 _wrapper->createMenu( _importSupervSchemaAct, aMenuId );
640 _wrapper->createMenu( _wrapper->separator(), aMenuId);
641 _wrapper->createMenu( _exportSchemaAct, aMenuId );
642 _wrapper->createMenu( _exportSchemaAsAct, aMenuId );
643 _wrapper->createMenu( _wrapper->separator(), aMenuId);
644 _wrapper->createMenu( _runLoadedSchemaAct, aMenuId );
645 _wrapper->createMenu( _loadRunStateSchemaAct, aMenuId );
646 _wrapper->createMenu( _loadAndRunSchemaAct, aMenuId );
647 _wrapper->createMenu( _chooseBatchJobAct, aMenuId );
648 _wrapper->createMenu( _wrapper->separator(), aMenuId);
649 _wrapper->createMenu( _undoAct, aMenuId );
650 _wrapper->createMenu( _redoAct, aMenuId );
651 _wrapper->createMenu( _showUndoAct, aMenuId );
652 _wrapper->createMenu( _showRedoAct, aMenuId );
653 _wrapper->createMenu( _wrapper->separator(), aMenuId);
654 _wrapper->createMenu( _startResumeAct, aMenuId );
655 _wrapper->createMenu( _abortAct, aMenuId );
656 _wrapper->createMenu( _pauseAct, aMenuId );
657 _wrapper->createMenu( _resetAct, aMenuId );
658 _wrapper->createMenu( _wrapper->separator(), aMenuId);
659 _wrapper->createMenu( _saveRunStateAct, aMenuId );
660 //_wrapper->createMenu( _newEditionAct, aMenuId );
661 _wrapper->createMenu( _wrapper->separator(), aMenuId);
662 _wrapper->createMenu( _withoutStopModeAct, aMenuId );
663 _wrapper->createMenu( _breakpointsModeAct, aMenuId );
664 _wrapper->createMenu( _stepByStepModeAct, aMenuId );
665 _wrapper->createMenu( _wrapper->separator(), aMenuId);
666 _wrapper->createMenu( _toggleStopOnErrorAct, aMenuId );
667 _wrapper->createMenu( _wrapper->separator(), aMenuId);
668 _wrapper->createMenu( _importCatalogAct, aMenuId );
669 _wrapper->createMenu( _wrapper->separator(), aMenuId);
670 _wrapper->createMenu( _toggleStraightLinksAct, aMenuId );
671 _wrapper->createMenu( _toggleAutomaticComputeLinkAct, aMenuId );
672 _wrapper->createMenu( _toggleSimplifyLinkAct, aMenuId );
673 _wrapper->createMenu( _toggleForce2NodesLinkAct, aMenuId );
674 _wrapper->createMenu( _toggleAddRowColsAct, aMenuId );
675 _wrapper->createMenu( _wrapper->separator(), aMenuId);
676 _wrapper->createMenu( _showAllLinksAct, aMenuId );
677 _wrapper->createMenu( _hideAllLinksAct, aMenuId );
678 _wrapper->createMenu( _wrapper->separator(), aMenuId);
679 _wrapper->createMenu( _whatsThisAct, aMenuId );
682 void GenericGui::createTools()
684 int aToolId = _wrapper->createTool ( tr( "YACS Toolbar" ), QString( "YACSToolbar" ) );
685 _wrapper->createTool( _newSchemaAct, aToolId );
686 _wrapper->createTool( _importSchemaAct, aToolId );
687 _wrapper->createTool( _wrapper->separator(), aToolId );
688 _wrapper->createTool( _exportSchemaAct, aToolId );
689 _wrapper->createTool( _exportSchemaAsAct, aToolId );
690 _wrapper->createTool( _wrapper->separator(), aToolId);
691 _wrapper->createTool( _runLoadedSchemaAct, aToolId );
692 _wrapper->createTool( _loadRunStateSchemaAct, aToolId );
693 _wrapper->createTool( _loadAndRunSchemaAct, aToolId );
694 _wrapper->createTool( _chooseBatchJobAct, aToolId );
695 _wrapper->createTool( _wrapper->separator(), aToolId );
696 _wrapper->createTool( _undoAct, aToolId );
697 _wrapper->createTool( _redoAct, aToolId );
698 _wrapper->createTool( _wrapper->separator(), aToolId );
699 _wrapper->createTool( _startResumeAct, aToolId );
700 _wrapper->createTool( _abortAct, aToolId );
701 _wrapper->createTool( _pauseAct, aToolId );
702 _wrapper->createTool( _resetAct, aToolId );
703 _wrapper->createTool( _wrapper->separator(), aToolId );
704 _wrapper->createTool( _saveRunStateAct, aToolId );
705 //_wrapper->createTool( _newEditionAct, aToolId );
706 _wrapper->createTool( _withoutStopModeAct, aToolId );
707 _wrapper->createTool( _breakpointsModeAct, aToolId );
708 _wrapper->createTool( _stepByStepModeAct, aToolId );
709 _wrapper->createTool( _wrapper->separator(), aToolId );
710 _wrapper->createTool( _toggleStopOnErrorAct, aToolId );
711 _wrapper->createTool( _wrapper->separator(), aToolId );
712 _wrapper->createTool( _importCatalogAct, aToolId );
713 _wrapper->createTool( _wrapper->separator(), aToolId );
714 _wrapper->createTool( _toggleStraightLinksAct, aToolId );
715 _wrapper->createTool( _toggleAutomaticComputeLinkAct, aToolId );
716 _wrapper->createTool( _toggleSimplifyLinkAct, aToolId );
717 //_wrapper->createTool( _toggleForce2NodesLinkAct, aToolId );
718 _wrapper->createTool( _toggleAddRowColsAct, aToolId );
719 _wrapper->createTool( _wrapper->separator(), aToolId );
720 _wrapper->createTool( _showAllLinksAct, aToolId );
721 _wrapper->createTool( _hideAllLinksAct, aToolId );
722 _wrapper->createTool( _wrapper->separator(), aToolId );
723 _wrapper->createTool( _whatsThisAct, aToolId );
726 void GenericGui::initialMenus()
728 showEditionMenus(false);
729 showExecMenus(false);
730 showCommonMenus(false);
734 void GenericGui::hideAllMenus()
736 showBaseMenus (false);
737 showCommonMenus (false);
738 showEditionMenus(false);
739 showExecMenus (false);
742 void GenericGui::showBaseMenus(bool show)
744 DEBTRACE("GenericGui::showBaseMenus " << show);
745 _wrapper->setMenuShown(_newSchemaAct, show);
746 _wrapper->setToolShown(_newSchemaAct, show);
747 _wrapper->setMenuShown(_importSchemaAct, show);
748 _wrapper->setToolShown(_importSchemaAct, show);
749 _wrapper->setMenuShown(_importSupervSchemaAct, show);
750 _wrapper->setMenuShown(_loadAndRunSchemaAct, show);
751 _wrapper->setToolShown(_loadAndRunSchemaAct, show);
752 _wrapper->setMenuShown(_chooseBatchJobAct, show);
753 _wrapper->setToolShown(_chooseBatchJobAct, show);
754 _wrapper->setMenuShown(_whatsThisAct, show);
755 _wrapper->setToolShown(_whatsThisAct, show);
758 void GenericGui::showEditionMenus(bool show)
760 DEBTRACE("GenericGui::showEditionMenus " << show);
761 _wrapper->setMenuShown(_exportSchemaAct, show);
762 _wrapper->setToolShown(_exportSchemaAct, show);
763 _wrapper->setMenuShown(_exportSchemaAsAct, show);
764 _wrapper->setToolShown(_exportSchemaAsAct, show);
765 _wrapper->setMenuShown(_runLoadedSchemaAct, show);
766 _wrapper->setToolShown(_loadRunStateSchemaAct, show);
767 _wrapper->setMenuShown(_loadRunStateSchemaAct, show);
768 _wrapper->setToolShown(_runLoadedSchemaAct, show);
769 _wrapper->setMenuShown(_undoAct, show);
770 _wrapper->setToolShown(_undoAct, show);
771 _wrapper->setMenuShown(_redoAct, show);
772 _wrapper->setToolShown(_redoAct, show);
773 _wrapper->setMenuShown(_showUndoAct, show);
774 _wrapper->setMenuShown(_showRedoAct, show);
775 _wrapper->setMenuShown(_importCatalogAct, show);
776 _wrapper->setToolShown(_importCatalogAct, show);
779 void GenericGui::showExecMenus(bool show)
781 DEBTRACE("GenericGui::showExecMenus " << show);
782 _wrapper->setMenuShown(_startResumeAct, show);
783 _wrapper->setToolShown(_startResumeAct, show);
784 _wrapper->setMenuShown(_abortAct, show);
785 _wrapper->setToolShown(_abortAct, show);
786 _wrapper->setMenuShown(_pauseAct, show);
787 _wrapper->setToolShown(_pauseAct, show);
788 _wrapper->setMenuShown(_resetAct, show);
789 _wrapper->setToolShown(_resetAct, show);
790 _wrapper->setMenuShown(_saveRunStateAct, show);
791 _wrapper->setToolShown(_saveRunStateAct, show);
792 //_wrapper->setMenuShown(_newEditionAct, show);
793 //_wrapper->setToolShown(_newEditionAct, show);
794 _wrapper->setMenuShown(_withoutStopModeAct, show);
795 _wrapper->setToolShown(_withoutStopModeAct, show);
796 _wrapper->setMenuShown(_breakpointsModeAct, show);
797 _wrapper->setToolShown(_breakpointsModeAct, show);
798 _wrapper->setMenuShown(_stepByStepModeAct, show);
799 _wrapper->setToolShown(_stepByStepModeAct, show);
800 _wrapper->setMenuShown(_toggleStopOnErrorAct, show);
801 _wrapper->setToolShown(_toggleStopOnErrorAct, show);
804 void GenericGui::showCommonMenus(bool show)
806 DEBTRACE("GenericGui::showCommonMenus " << show);
807 _wrapper->setMenuShown(_toggleStraightLinksAct, show);
808 _wrapper->setToolShown(_toggleStraightLinksAct, show);
809 _wrapper->setMenuShown(_toggleAutomaticComputeLinkAct, show);
810 _wrapper->setToolShown(_toggleAutomaticComputeLinkAct, show);
811 _wrapper->setMenuShown(_toggleSimplifyLinkAct, show);
812 _wrapper->setToolShown(_toggleSimplifyLinkAct, show);
813 _wrapper->setMenuShown(_toggleForce2NodesLinkAct, show);
814 //_wrapper->setToolShown(_toggleForce2NodesLinkAct, show);
815 _wrapper->setMenuShown(_toggleAddRowColsAct, show);
816 _wrapper->setToolShown(_toggleAddRowColsAct, show);
817 _wrapper->setMenuShown(_showAllLinksAct, show);
818 _wrapper->setToolShown(_showAllLinksAct, show);
819 _wrapper->setMenuShown(_hideAllLinksAct, show);
820 _wrapper->setToolShown(_hideAllLinksAct, show);
823 void GenericGui::switchContext(QWidget *view, bool onExit)
825 DEBTRACE("GenericGui::switchContext " << view);
826 if (! _mapViewContext.count(view))
828 onExit ? hideAllMenus() : initialMenus();
829 _dwTree->setWidget(0);
830 _dwStacked->setWidget(0);
833 QtGuiContext* newContext = _mapViewContext[view];
835 _dwTree->setWidget(newContext->getEditTree());
836 _dwTree->widget()->show();
838 _dwStacked->setWidget(newContext->getStackedWidget());
840 QtGuiContext::setQtCurrent(newContext);
842 if (newContext->isEdition())
844 showExecMenus(false);
846 showEditionMenus(true);
847 showCommonMenus(true);
848 if (_dwTree) _dwTree->setWindowTitle("Tree View: edition mode");
852 showEditionMenus(false);
855 showCommonMenus(true);
856 _withoutStopModeAct->setChecked(true);
857 if (_dwTree) _dwTree->setWindowTitle("Tree View: execution mode");
859 _dwStacked->setMinimumWidth(10);
862 bool GenericGui::closeContext(QWidget *view, bool onExit)
864 DEBTRACE("GenericGui::closeContext " << onExit);
865 if (! _mapViewContext.count(view))
867 QtGuiContext* context = _mapViewContext[view];
870 bool tryToSave = false;
872 if (QtGuiContext::getQtCurrent()->isEdition())
874 if (!QtGuiContext::getQtCurrent()->_setOfModifiedSubjects.empty())
877 msgBox.setText("Some elements are modified and not taken into account.");
878 string info = "do you want to apply your changes ?\n";
879 info += " - Save : do not take into account edition in progress,\n";
880 info += " but if there are other modifications, select a file name for save\n";
881 info += " - Discard : discard all modifications and close the schema";
883 info += "\n - Cancel : do not close the schema, return to edition";
884 msgBox.setInformativeText(info.c_str());
887 msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
888 msgBox.setDefaultButton(QMessageBox::Cancel);
892 msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Discard);
893 msgBox.setDefaultButton(QMessageBox::Save);
895 int ret = msgBox.exec();
898 case QMessageBox::Save:
901 case QMessageBox::Discard:
904 case QMessageBox::Cancel:
906 DEBTRACE("Cancel or default");
912 if (QtGuiContext::getQtCurrent()->isNotSaved())
915 msgBox.setWindowTitle("Close the active schema");
916 msgBox.setText("The schema has been modified");
917 string info = "do you want to save the schema ?\n";
918 info += " - Save : select a file name for save\n";
919 info += " - Discard : discard all modifications and close the schema";
921 info += "\n - Cancel : do not close the schema, return to edition";
922 msgBox.setInformativeText(info.c_str());
925 msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
926 msgBox.setDefaultButton(QMessageBox::Cancel);
930 msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Discard);
931 msgBox.setDefaultButton(QMessageBox::Save);
933 int ret = msgBox.exec();
936 case QMessageBox::Save:
939 case QMessageBox::Discard:
942 case QMessageBox::Cancel:
943 DEBTRACE("Cancel or default");
953 if ((!onExit) && (!_isSaved)) // --- probably, user has cancelled the save dialog. Do not close
958 map<QWidget*, YACS::HMI::QtGuiContext*>::iterator it = _mapViewContext.begin();
959 QtGuiContext* newContext = 0;
960 QWidget* newView = 0;
961 for (; it != _mapViewContext.end(); ++it)
963 if ((*it).second != context)
965 newView = (*it).first;
966 newContext = (*it).second;
970 _wrapper->deleteSchema(view);
971 DEBTRACE("delete context");
972 if (GuiExecutor* exec = context->getGuiExecutor())
974 exec->closeContext();
977 _mapViewContext.erase(view);
978 switchContext(newView, onExit);
982 void GenericGui::showDockWidgets(bool isVisible)
984 DEBTRACE("GenericGui::showDockWidgets " << isVisible);
985 if (_dwTree) _dwTree->setVisible(isVisible);
986 if (_dwTree) _dwTree->toggleViewAction()->setVisible(isVisible);
987 if (_dwStacked) _dwStacked->setVisible(isVisible);
988 if (_dwStacked) _dwStacked->toggleViewAction()->setVisible(isVisible);
989 if (_dwCatalogs) _dwCatalogs->setVisible(isVisible);
990 if (_dwCatalogs) _dwCatalogs->toggleViewAction()->setVisible(isVisible);
993 void GenericGui::raiseStacked()
995 if (_dwStacked) _dwStacked->raise();
998 std::list<std::string> GenericGui::getMachineList()
1000 if (!_machineList.empty()) return _machineList;
1002 YACS::ENGINE::RuntimeSALOME* runTime = YACS::ENGINE::getSALOMERuntime();
1003 CORBA::ORB_ptr orb = runTime->getOrb();
1004 if (!orb) return _machineList;
1006 SALOME_NamingService namingService(orb);
1007 SALOME_LifeCycleCORBA lcc(&namingService);
1009 CORBA::Object_var obj =
1010 namingService.Resolve(SALOME_ResourcesManager::_ResourcesManagerNameInNS);
1011 if (CORBA::is_nil(obj)) return _machineList;
1013 Engines::ResourcesManager_var resManager = Engines::ResourcesManager::_narrow(obj);
1014 if(!resManager) return _machineList;
1016 Engines::ResourceParameters params;
1019 Engines::ResourceList* resourceList =
1020 resManager->GetFittingResources(params);
1022 for (int i = 0; i < resourceList->length(); i++)
1024 const char* aResource = (*resourceList)[i];
1025 _machineList.push_back(aResource);
1028 return _machineList;
1031 // -----------------------------------------------------------------------------
1033 /*! a QtGuiContext instance is created for each schema in edition or each execution or run
1034 * of a schema. The context stores references of a lot of objects related to the edition
1036 * \param proc the schema to run or edit, loaded from file or just created empty.
1037 * \param schemaName filename of the schema in edition, also used in execution to publish
1038 * a run under the edition name in Salome object browser.
1039 * \param runName filename of the schema in execution, not used in edition.
1040 * \param forEdition if true, edition mode, if false, execution mode.
1042 void GenericGui::createContext(YACS::ENGINE::Proc* proc,
1043 const QString& schemaName,
1044 const QString& runName,
1047 DEBTRACE("GenericGui::createContext");
1053 QWidget* central = _parent->centralWidget();
1055 central->setFocus();
1057 DEBTRACE("No Central Widget");
1060 QWidget* refWindow = 0; // --- used only on run to refer to the schema in edition
1063 fileName = schemaName;
1068 if (QtGuiContext::getQtCurrent())
1069 refWindow = QtGuiContext::getQtCurrent()->getWindow();
1072 QtGuiContext* context = new QtGuiContext(this);
1073 QtGuiContext::setQtCurrent(context);
1077 context->setEdition(forEdition);
1078 context->setSessionCatalog(_sessionCatalog);
1079 context->setFileName(fileName);
1080 context->setCurrentCatalog(_builtinCatalog);
1082 // --- scene, viewWindow & GraphicsView
1084 Scene *scene = new Scene();
1085 QWidget *viewWindow = _wrapper->getNewWindow(scene);
1086 _mapViewContext[viewWindow] = context;
1087 GraphicsView* gView = new GraphicsView(viewWindow);
1088 gView->setScene(scene);
1089 gView->setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
1090 _wrapper->AssociateViewToWindow(gView, viewWindow);
1091 context->setScene(scene);
1092 context->setView(gView);
1093 context->setWindow(viewWindow);
1098 SchemaModel *schemaModel = new SchemaModel(context, viewWindow);
1099 schemaModel->setEdition(forEdition);
1100 context->setSchemaModel(schemaModel);
1101 RootSceneItem *rootSceneItem = new RootSceneItem(context);
1103 // --- tree associated to model
1105 FormEditTree *editTree = new FormEditTree(_dwTree);
1106 editTree->setMinimumHeight(400);
1107 _dwTree->setWidget(editTree);
1109 context->setEditTree(editTree);
1110 editTree->tv_schema->setModel(schemaModel);
1111 context->setSelectionModel(editTree->tv_schema->selectionModel());
1114 QObject::connect(editTree->tv_schema->selectionModel(),
1115 SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)),
1117 SLOT(updateSelection(const QItemSelection &, const QItemSelection &)));
1119 // --- stacked widget
1121 QStackedWidget *stacked = new QStackedWidget(_dwStacked);
1122 _dwStacked->setWidget(stacked);
1123 context->setStackedWidget(stacked);
1124 YACS::HMI::ItemEditionRoot* rootEdit = new YACS::HMI::ItemEditionRoot(context,
1126 context->getName().c_str());
1127 context->setEditionRoot(rootEdit);
1129 QObject::connect(schemaModel,
1130 SIGNAL(signalSelection(const QModelIndex &)),
1131 editTree->tv_schema,
1132 SLOT(viewSelection(const QModelIndex &)));
1136 proc->setEdition(forEdition);
1140 double passe = (end_t -start_t);
1141 passe = passe/CLOCKS_PER_SEC;
1142 DEBTRACE("create context -1- : " << passe);
1146 context->setLoading(true);
1148 context->setProc(proc);
1149 setLoadedPresentation(proc);
1153 double passe = (end_t -start_t);
1154 passe = passe/CLOCKS_PER_SEC;
1155 DEBTRACE("create context - load proc- : " << passe);
1159 context->setLoading(false);
1161 if (forEdition && _wrapper) // --- Edition mode
1163 _wrapper->createNewSchema(fileName, viewWindow);
1165 else if (_wrapper) // --- Execution Mode
1167 GuiExecutor *guiExec = new GuiExecutor(proc);
1168 context->setGuiExecutor(guiExec);
1169 _wrapper->createNewRun(schemaName, fileName, refWindow, viewWindow);
1173 QtGuiContext::getQtCurrent()->getSubjectProc()->update(UPDATE,
1174 ProcInvoc::getTypeOfNode(proc),
1175 0); // --- force validity check
1177 // --- adjust widgets
1179 TreeView *vtree = dynamic_cast<TreeView*>(editTree->tv_schema);
1181 vtree->resizeColumns();
1182 _catalogsWidget->setMinimumWidth(10); // --- reset the constraint on width
1183 editTree->setMinimumHeight(40);
1184 _dwStacked->setMinimumWidth(10);
1189 showExecMenus(false);
1190 showEditionMenus(true);
1191 showCommonMenus(true);
1192 if (_dwTree) _dwTree->setWindowTitle("Tree View: edition mode");
1196 showEditionMenus(false);
1197 showExecMenus(true);
1198 showCommonMenus(true);
1199 _withoutStopModeAct->setChecked(true);
1200 if (_dwTree) _dwTree->setWindowTitle("Tree View: execution mode");
1203 QtGuiContext::getQtCurrent()->setNotSaved(false);
1206 double passe = (end_t -start_t);
1207 passe = passe/CLOCKS_PER_SEC;
1208 DEBTRACE("create context - end - : " << passe);
1213 // -----------------------------------------------------------------------------
1215 void GenericGui::setLoadedPresentation(YACS::ENGINE::Proc* proc)
1217 DEBTRACE("GenericGui::setLoadedPresentation");
1218 QtGuiContext::getQtCurrent()->setLoadingPresentation(true);
1219 map<SceneNodeItem*, QPointF> nodesToMove;
1220 map<YACS::ENGINE::Node*, PrsData> presNodes = _loader->getPrsData(proc);
1221 if (!presNodes.empty())
1223 map<YACS::ENGINE::Node*, PrsData>::iterator it = presNodes.begin();
1224 for (; it!= presNodes.end(); ++it)
1226 YACS::ENGINE::Node* node = (*it).first;
1227 PrsData pres = (*it).second;
1228 SubjectNode *snode = QtGuiContext::getQtCurrent()->_mapOfSubjectNode[node];
1229 SceneItem *item = QtGuiContext::getQtCurrent()->_mapOfSceneItem[snode];
1231 SceneNodeItem *inode = dynamic_cast<SceneNodeItem*>(item);
1233 inode->setPos(QPointF(pres._x, pres._y));
1234 inode->setWidth(pres._width);
1235 inode->setHeight(pres._height);
1236 inode->setExpanded(pres._expanded);
1237 QPointF anExpandedPos = QPointF(pres._expx, pres._expy);
1238 if (anExpandedPos.isNull())
1239 anExpandedPos = inode->pos();
1240 inode->setExpandedPos(anExpandedPos);
1241 inode->setExpandedWH(pres._expWidth, pres._expHeight);
1242 inode->setShownState(shownState(pres._shownState));
1244 // collect nodes to correct it's Y-position if this collides with parent's header
1245 if (inode->getParent() ) {
1246 qreal anX = inode->x();
1247 qreal anY = inode->y();
1248 if (inode->getShownState() == shrinkHidden) {
1249 anX = inode->getExpandedX();
1250 anY = inode->getExpandedY();
1252 if (anY < inode->getParent()->getHeaderBottom())
1253 nodesToMove[inode] = QPointF(anX, inode->getParent()->getHeaderBottom()+1);
1257 QtGuiContext::getQtCurrent()->setLoadingPresentation(false);
1259 //after loading of presentation:
1261 //move nodes because of progress bar, if any was added
1262 map<SceneNodeItem*, QPointF>::iterator it = nodesToMove.begin();
1263 for (; it!= nodesToMove.end(); ++it)
1265 (*it).first->setTopLeft((*it).second);
1269 if (Scene::_autoComputeLinks)
1270 _guiEditor->rebuildLinks();
1273 YACS::HMI::SubjectProc* subproc = QtGuiContext::getQtCurrent()->getSubjectProc();
1274 SceneItem *item = QtGuiContext::getQtCurrent()->_mapOfSceneItem[subproc];
1275 SceneComposedNodeItem *proc = dynamic_cast<SceneComposedNodeItem*>(item);
1276 proc->updateLinks();
1280 // -----------------------------------------------------------------------------
1282 void GenericGui::onNewSchema()
1284 DEBTRACE("GenericGui::onNewSchema");
1286 std::stringstream name;
1287 name << "newSchema_" << ++_schemaCnt;
1289 YACS::ENGINE::RuntimeSALOME* runTime = YACS::ENGINE::getSALOMERuntime();
1290 YACS::ENGINE::Proc *proc = runTime->createProc(name.str());
1294 QString fileName = name.str().c_str();
1295 createContext(proc, fileName, "", true);
1298 void GenericGui::loadSchema(const std::string& filename,bool edit, bool arrangeLocalNodes)
1300 YACS::ENGINE::Proc *proc = _loader->load(filename.c_str());
1303 YACS::ENGINE::Logger* logger= proc->getLogger("parser");
1304 if(!logger->isEmpty())
1306 DEBTRACE(logger->getStr());
1308 QString fn=QString::fromUtf8(filename.c_str());
1310 createContext(proc, fn, "", true);
1312 createContext(proc, fn, fn, false);
1313 if (arrangeLocalNodes)
1315 _guiEditor->arrangeProc();
1319 void GenericGui::onImportSchema()
1324 DEBTRACE("GenericGui::onImportSchema");
1325 QFileDialog dialog(_parent,
1326 "Choose a filename to load" ,
1328 tr( "XML-Files (*.xml);;All Files (*)" ));
1330 dialog.setHistory(_wrapper->getQuickDirList());
1333 QStringList fileNames;
1336 fileNames = dialog.selectedFiles();
1337 if (!fileNames.isEmpty())
1338 fn = fileNames.first();
1341 if ( !fn.isEmpty() )
1343 // add ".xml" suffix
1345 if (!fi.exists() && fi.suffix() != "xml")
1348 DEBTRACE("file loaded : " <<fn.toUtf8().constData());
1349 YACS::ENGINE::Proc *proc = 0;
1352 proc = _loader->load(fn.toUtf8().constData());
1359 double passe = (end_t -start_t);
1360 passe = passe/CLOCKS_PER_SEC;
1361 DEBTRACE("load xml file : " << passe);
1367 QMessageBox msgBox(QMessageBox::Critical,
1368 "Import YACS Schema, native YACS XML format",
1369 "The file has not the native YACS XML format or is not readable.");
1373 YACS::ENGINE::Logger* logger= proc->getLogger("parser");
1374 if(!logger->isEmpty())
1376 DEBTRACE(logger->getStr());
1378 createContext(proc, fn, "", true);
1382 void GenericGui::onImportSupervSchema()
1384 DEBTRACE("GenericGui::onImportSupervSchema");
1385 QFileDialog dialog(_parent,
1386 "Choose a SUPERV filename to load" ,
1388 tr( "XML-Files (*.xml);;All Files (*)" ));
1390 dialog.setHistory(_wrapper->getQuickDirList());
1393 QStringList fileNames;
1396 fileNames = dialog.selectedFiles();
1397 if (!fileNames.isEmpty())
1398 fn = fileNames.first();
1401 if (fn.isEmpty()) return;
1403 // add ".xml" suffix
1405 if (!fi.exists() && fi.suffix() != "xml")
1408 DEBTRACE("file loaded : " <<fn.toStdString());
1409 QString tmpFileName;
1413 QString tmpDir = getenv("TEMP");
1414 QString fileExt = "bat";
1416 QString tmpDir = "/tmp";
1417 QString fileExt = "sh";
1419 QDir aTmpDir(tmpDir);
1420 aTmpDir.mkdir(QString("YACS_") + getenv("USER"));
1421 YASSERT(aTmpDir.cd(QString("YACS_") + getenv("USER")));
1422 QDateTime curTime = QDateTime::currentDateTime();
1423 tmpFileName = "SUPERV_import_" + curTime.toString("yyyyMMdd_hhmmss") + ".xml";
1424 QString tmpOutput = "salomeloader_output";
1425 tmpFileName = aTmpDir.absoluteFilePath(tmpFileName);
1426 DEBTRACE(tmpFileName.toStdString());
1428 QString aCall = "salomeloader."+ fileExt+ " "+ fn + " " + tmpFileName + " > " + tmpOutput;
1429 DEBTRACE(aCall.toStdString());
1431 int ret = system(aCall.toLatin1());
1434 // --- read file with logs
1435 fstream f(tmpOutput.toLatin1());
1440 // --- Problem in execution
1441 int status=WEXITSTATUS(ret);
1444 QString mes = "Problems in conversion: some errors but an incomplete proc has nevertheless been created.\n\n";
1445 mes += QString(hfile.str().c_str());
1446 QMessageBox msgBox(QMessageBox::Warning,
1447 "Import YACS Schema, SUPERV XML format",
1451 else if(status == 2)
1453 QString mes = "Problems in conversion: a fatal error has been encountered. The proc can't be created.\n\n";
1454 mes += QString(hfile.str().c_str());
1455 QMessageBox msgBox(QMessageBox::Critical,
1456 "Import YACS Schema, SUPERV XML format",
1463 DEBTRACE("Unknown problem: " << ret );
1464 QMessageBox msgBox(QMessageBox::Critical,
1465 "Import YACS Schema, SUPERV XML format",
1466 "Unexpected exception in salomeloader.");
1474 QMessageBox msgBox(QMessageBox::Critical,
1475 "Import YACS Schema, SUPERV XML format",
1476 "Unexpected exception in convertSupervFile");
1482 if (fn.isEmpty()) return; // must not happen
1484 DEBTRACE("file loaded : " <<fn.toStdString());
1485 YACS::ENGINE::Proc *proc = _loader->load(fn.toLatin1());
1488 QMessageBox msgBox(QMessageBox::Critical,
1489 "Import YACS Schema, SUPERV file converted in native YACS XML format",
1490 "The file has not the native YACS XML format or is not readable.");
1494 YACS::ENGINE::Logger* logger= proc->getLogger("parser");
1495 if(!logger->isEmpty())
1497 DEBTRACE(logger->getStr());
1499 createContext(proc, fn, "", true);
1502 //! bug confirmOverwrite : correction Qt 4.3.5
1503 QString GenericGui::getSaveFileName(const QString& fileName)
1505 QFileDialog dialog(_parent, "Save schema", fileName);
1506 QStringList filters;
1507 filters << "XML files (*.xml)"
1509 dialog.setFileMode(QFileDialog::AnyFile);
1510 dialog.setNameFilters(filters);
1511 dialog.selectNameFilter("(*.xml)");
1512 dialog.setDefaultSuffix("xml");
1513 dialog.setConfirmOverwrite(true);
1514 //dialog.setConfirmOverwrite(false); // bug Qt4.3.3
1515 dialog.setAcceptMode(QFileDialog::AcceptSave);
1516 QString selectedFile;
1517 QStringList fileNames;
1519 if (bool ret = dialog.exec())
1521 DEBTRACE(ret << " " << dialog.confirmOverwrite());
1522 fileNames = dialog.selectedFiles();
1523 if (!fileNames.isEmpty())
1524 selectedFile = fileNames.first();
1526 QString filteredName = _guiEditor->asciiFilter(selectedFile);
1527 DEBTRACE(filteredName.toStdString());
1528 return filteredName;
1531 void GenericGui::onExportSchema()
1533 DEBTRACE("GenericGui::onExportSchema");
1534 if (!QtGuiContext::getQtCurrent()) return;
1535 YACS::ENGINE::Proc* proc = QtGuiContext::getQtCurrent()->getProc();
1536 QString fo = QtGuiContext::getQtCurrent()->getFileName();
1539 if (fo.startsWith("newSchema_"))
1542 fn = getSaveFileName(fo);
1544 if (fn.isEmpty()) return;
1546 DEBTRACE("GenericGui::onExportSchema: " << fn.toUtf8().constData());
1547 //to be sure that all pending changes are effective
1548 _parent->setFocus();
1549 QtGuiContext::getQtCurrent()->setFileName(fn);
1550 VisitorSaveGuiSchema aWriter(proc);
1551 aWriter.openFileSchema( fn.toUtf8().constData() );
1552 aWriter.visitProc();
1553 aWriter.closeFileSchema();
1554 QtGuiContext::getQtCurrent()->setNotSaved(false);
1556 if (fn.compare(foo) && _wrapper)
1557 _wrapper->renameSchema(foo, fn, QtGuiContext::getQtCurrent()->getWindow());
1560 void GenericGui::onExportSchemaAs()
1562 DEBTRACE("GenericGui::onExportSchemaAs");
1564 if (!QtGuiContext::getQtCurrent()) return;
1565 YACS::ENGINE::Proc* proc = QtGuiContext::getQtCurrent()->getProc();
1566 QString fo = QtGuiContext::getQtCurrent()->getFileName();
1568 if (fo.startsWith("newSchema_")) fo.clear();
1569 QString fn = getSaveFileName(fo);
1570 if (fn.isEmpty()) return;
1572 DEBTRACE("GenericGui::onExportSchemaAs: " << fn.toUtf8().constData());
1573 QtGuiContext::getQtCurrent()->setFileName(fn);
1574 VisitorSaveGuiSchema aWriter(proc);
1575 aWriter.openFileSchema(fn.toUtf8().constData());
1576 aWriter.visitProc();
1577 aWriter.closeFileSchema();
1579 QtGuiContext::getQtCurrent()->setNotSaved(false);
1581 if (fn.compare(foo) && _wrapper)
1582 _wrapper->renameSchema(foo, fn, QtGuiContext::getQtCurrent()->getWindow());
1585 void GenericGui::onImportCatalog()
1587 DEBTRACE("GenericGui::onImportCatalog");
1588 QFileDialog dialog(_parent,
1589 "Choose a YACS Schema to load as a Catalog" ,
1591 tr( "XML-Files (*.xml);;All Files (*)" ));
1593 dialog.setHistory(_wrapper->getQuickDirList());
1596 QStringList fileNames;
1599 fileNames = dialog.selectedFiles();
1600 if (!fileNames.isEmpty())
1601 fn = fileNames.first();
1604 if ( !fn.isEmpty() )
1605 _catalogsWidget->addCatalogFromFile(fn.toStdString());
1608 void GenericGui::onRunLoadedSchema(bool withState)
1610 DEBTRACE("GenericGui::onRunLoadedSchema");
1611 if (!QtGuiContext::getQtCurrent()) return;
1617 // --- check proc state (cf. editionProc)
1619 if (!QtGuiContext::getQtCurrent()->_setOfModifiedSubjects.empty())
1621 set<Subject*>::iterator it = QtGuiContext::getQtCurrent()->_setOfModifiedSubjects.begin();
1622 (*it)->select(true);
1626 YACS::ENGINE::Proc* proc = QtGuiContext::getQtCurrent()->getProc();
1627 if (!proc->isValid())
1629 QtGuiContext::getQtCurrent()->getSubjectProc()->select(true);
1633 YACS::ENGINE::LinkInfo info(YACS::ENGINE::LinkInfo::ALL_STOP_ASAP);
1636 proc->checkConsistency(info);
1638 catch (Exception &ex)
1640 DEBTRACE(ex.what());
1641 QtGuiContext::getQtCurrent()->getSubjectProc()->select(true);
1644 if (info.areWarningsOrErrors()) return;
1648 double passe = (end_t -start_t);
1649 passe = passe/CLOCKS_PER_SEC;
1650 cerr <<"run schema -1- : " << passe << endl;
1653 // --- save proc under a run name
1655 QFileInfo fo = QtGuiContext::getQtCurrent()->getFileName();
1656 QString procName = fo.baseName();
1657 //QString tmpDir = SALOMEDS_Tool::GetTmpDir().c_str();
1659 QString tmpDir = getenv("TEMP");
1661 QString tmpDir = "/tmp";
1663 QDir aTmpDir(tmpDir);
1664 aTmpDir.mkdir(QString("YACS_") + getenv("USER"));
1665 YASSERT(aTmpDir.cd(QString("YACS_") + getenv("USER")));
1666 QDateTime curTime = QDateTime::currentDateTime();
1667 QString aRunName = procName + "_" + curTime.toString("yyyyMMdd_hhmmss") + ".xml";
1668 aRunName = aTmpDir.absoluteFilePath(aRunName);
1669 DEBTRACE(aRunName.toStdString());
1671 VisitorSaveGuiSchema aWriter(proc);
1672 aWriter.openFileSchema(aRunName.toStdString());
1673 aWriter.visitProc();
1674 aWriter.closeFileSchema();
1676 // --- create a run context
1678 YACS::ENGINE::Proc *procrun = _loader->load(aRunName.toLatin1());
1681 double passe = (end_t -start_t);
1682 passe = passe/CLOCKS_PER_SEC;
1683 cerr <<"run schema -2- : " << passe << endl;
1686 createContext(procrun, QtGuiContext::getQtCurrent()->getFileName(), aRunName, false);
1688 // load state if required
1690 GuiExecutor *executor = QtGuiContext::getQtCurrent()->getGuiExecutor();
1691 if (!executor) return;
1694 QString fn = QFileDialog::getOpenFileName( _parent,
1695 "Choose a previous run state to load" ,
1697 tr( "XML-Files (*.xml);;All Files (*)" ));
1700 DEBTRACE("run state to load: " <<fn.toStdString());
1701 executor->setLoadStateFile(fn.toStdString());
1704 executor->startResumeDataflow(true); // --- initialise gui state
1705 if(_toggleStopOnErrorAct->isChecked())
1706 executor->setStopOnError(false);
1709 void GenericGui::onLoadRunStateSchema()
1711 DEBTRACE("GenericGui::onLoadRunStateSchema");
1712 onRunLoadedSchema(true);
1715 void GenericGui::onLoadAndRunSchema()
1717 DEBTRACE("GenericGui::onLoadAndRunSchema");
1718 QString fn = QFileDialog::getOpenFileName( _parent,
1719 "Choose a filename to load" ,
1721 tr( "XML-Files (*.xml);;All Files (*)" ));
1722 if ( !fn.isEmpty() )
1724 // add ".xml" suffix
1726 if (!fi.exists() && fi.suffix() != "xml")
1729 DEBTRACE("file loaded : " <<fn.toStdString());
1730 YACS::ENGINE::Proc *proc =0;
1733 proc = _loader->load(fn.toLatin1());
1740 QMessageBox msgBox(QMessageBox::Critical,
1741 "Import YACS Schema, native YACS XML format",
1742 "The file has not the native YACS XML format or is not readable.");
1746 YACS::ENGINE::Logger* logger= proc->getLogger("parser");
1747 if(!logger->isEmpty())
1749 DEBTRACE(logger->getStr());
1751 createContext(proc, fn, "", true);
1752 onRunLoadedSchema();
1756 void GenericGui::onChooseBatchJob() {
1757 DEBTRACE("GenericGui::onChooseBatchJob");
1759 // Show the Batch Jobs list
1760 if(_BJLdialog) delete _BJLdialog;
1761 _BJLdialog = new BatchJobsListDialog(tr("Select one Batch Job to watch"),this);
1763 _BJLdialog->move(300,200);
1764 _BJLdialog->resize(450,200);
1768 void GenericGui::onStartResume()
1770 DEBTRACE("GenericGui::onStartResume");
1771 if (!QtGuiContext::getQtCurrent()) return;
1772 if (!QtGuiContext::getQtCurrent()->getGuiExecutor()) return;
1773 QtGuiContext::getQtCurrent()->getGuiExecutor()->startResumeDataflow();
1776 void GenericGui::onAbort()
1778 DEBTRACE("GenericGui::onAbort");
1779 if (!QtGuiContext::getQtCurrent()) return;
1780 if (!QtGuiContext::getQtCurrent()->getGuiExecutor()) return;
1781 QtGuiContext::getQtCurrent()->getGuiExecutor()->killDataflow();
1784 void GenericGui::onPause()
1786 DEBTRACE("GenericGui::onPause");
1787 if (!QtGuiContext::getQtCurrent()) return;
1788 if (!QtGuiContext::getQtCurrent()->getGuiExecutor()) return;
1789 QtGuiContext::getQtCurrent()->getGuiExecutor()->suspendDataflow();
1792 void GenericGui::onReset()
1794 DEBTRACE("GenericGui::onReset");
1795 if (!QtGuiContext::getQtCurrent()) return;
1796 if (!QtGuiContext::getQtCurrent()->getGuiExecutor()) return;
1797 QtGuiContext::getQtCurrent()->getGuiExecutor()->resetDataflow();
1800 void GenericGui::onSaveRunState()
1802 DEBTRACE("GenericGui::onSaveRunState");
1803 if (!QtGuiContext::getQtCurrent()) return;
1804 if (!QtGuiContext::getQtCurrent()->getGuiExecutor()) return;
1805 QDateTime curTime = QDateTime::currentDateTime();
1806 QFileInfo procName = QtGuiContext::getQtCurrent()->getFileName();
1807 QString stateName = procName.baseName();
1808 DEBTRACE(stateName.toStdString());
1809 stateName += "_state_" + curTime.toString("yyyyMMdd_hhmmss") + ".xml";
1810 DEBTRACE(stateName.toStdString());
1811 stateName = getSaveFileName(stateName);
1812 DEBTRACE(stateName.toStdString());
1813 if (!stateName.isEmpty())
1814 QtGuiContext::getQtCurrent()->getGuiExecutor()->saveState(stateName.toStdString());
1817 void GenericGui::onNewEdition()
1819 DEBTRACE("GenericGui::onNewEdition");
1820 // if (!QtGuiContext::getQtCurrent()) return;
1821 // if (!QtGuiContext::getQtCurrent()->getGuiExecutor()) return;
1822 // QtGuiContext::getQtCurrent()->getGuiExecutor()->resetDataflow();
1825 void GenericGui::onGetYacsContainerLog()
1827 DEBTRACE("GenericGui::onGetYacsContainerLog");
1828 if (!QtGuiContext::getQtCurrent()) return;
1829 if (!QtGuiContext::getQtCurrent()->getGuiExecutor()) return;
1830 string log = QtGuiContext::getQtCurrent()->getGuiExecutor()->getContainerLog();
1831 ContainerLogViewer *lv = new ContainerLogViewer("YACS Container Log", _parent);
1836 void GenericGui::onGetErrorReport()
1838 DEBTRACE("GenericGui::onGetErrorReport");
1839 if (!QtGuiContext::getQtCurrent()) return;
1840 Subject *sub = QtGuiContext::getQtCurrent()->getSelectedSubject();
1841 SubjectNode *snode = dynamic_cast<SubjectNode*>(sub);
1844 if (QtGuiContext::getQtCurrent()->getGuiExecutor())
1846 log = QtGuiContext::getQtCurrent()->getGuiExecutor()->getErrorReport(snode->getNode());
1850 log = snode->getNode()->getErrorReport();
1853 LogViewer *lv = new LogViewer("Node error report", _parent);
1858 void GenericGui::onGetErrorDetails()
1860 DEBTRACE("GenericGui::onGetErrorDetails");
1861 if (!QtGuiContext::getQtCurrent()) return;
1862 Subject *sub = QtGuiContext::getQtCurrent()->getSelectedSubject();
1863 SubjectNode *snode = dynamic_cast<SubjectNode*>(sub);
1866 if (QtGuiContext::getQtCurrent()->getGuiExecutor())
1868 log = QtGuiContext::getQtCurrent()->getGuiExecutor()->getErrorDetails(snode->getNode());
1872 log = snode->getNode()->getErrorDetails();
1875 LogViewer *lv = new LogViewer("Node Error Details", _parent);
1880 void GenericGui::onGetContainerLog()
1882 DEBTRACE("GenericGui::onGetContainerLog");
1883 if (!QtGuiContext::getQtCurrent()) return;
1884 if (!QtGuiContext::getQtCurrent()->getGuiExecutor()) return;
1885 Subject *sub = QtGuiContext::getQtCurrent()->getSelectedSubject();
1886 SubjectElementaryNode *snode = dynamic_cast<SubjectElementaryNode*>(sub);
1888 string log = QtGuiContext::getQtCurrent()->getGuiExecutor()->getContainerLog(snode->getNode());
1890 LogViewer *lv = new LogViewer("Node Container Log", _parent);
1894 if (dynamic_cast<YACS::ENGINE::ServiceNode*>(snode->getNode()))
1896 info +="The container log of this node\n";
1897 info += "is not stored in a file and \n";
1898 info += "can't be displayed here, \n";
1899 info += "but you can have a look at \n";
1900 info += "the SALOME standard output,\n";
1901 info += "on your terminal...";
1905 info += "See YACS Container log \n";
1906 info += "(on main proc menu) \n";
1907 info += "for all inline nodes";
1916 void GenericGui::onShutdownProc()
1918 DEBTRACE("GenericGui::onShutdownProc");
1919 if (!QtGuiContext::getQtCurrent()) return;
1920 if (!QtGuiContext::getQtCurrent()->getGuiExecutor()) return;
1921 QtGuiContext::getQtCurrent()->getGuiExecutor()->shutdownProc();
1924 void GenericGui::onEditDataTypes()
1926 DEBTRACE("GenericGui::onEditDataTypes");
1929 void GenericGui::onCreateDataType()
1931 DEBTRACE("GenericGui::onCreateDataType");
1934 void GenericGui::onImportDataType()
1936 DEBTRACE("GenericGui::onImportDataType");
1937 if (_dwCatalogs) _dwCatalogs->raise();
1940 void GenericGui::onSelectComponentInstance()
1942 DEBTRACE("GenericGui::onSelectComponentInstance");
1943 Subject *sub = QtGuiContext::getQtCurrent()->getSelectedSubject();
1945 SubjectComponent *ref = dynamic_cast<SubjectComponent*>(sub);
1947 YACS::ENGINE::ComponentInstance* compo=ref->getComponent();
1948 QtGuiContext::getQtCurrent()->_mapOfLastComponentInstance[compo->getCompoName()]=compo;
1951 void GenericGui::onNewContainer()
1953 DEBTRACE("GenericGui::onNewContainer");
1954 _guiEditor->CreateContainer();
1957 void GenericGui::onNewHPContainer()
1959 DEBTRACE("GenericGui::onNewHPContainer");
1960 _guiEditor->CreateHPContainer();
1963 void GenericGui::onNewSalomeComponent()
1965 DEBTRACE("GenericGui::onNewSalomeComponent");
1966 _guiEditor->CreateComponentInstance();
1969 void GenericGui::onNewSalomePythonComponent()
1971 DEBTRACE("GenericGui::onNewSalomePythonComponent");
1974 void GenericGui::onNewCorbaComponent()
1976 DEBTRACE("GenericGui::onNewCorbaComponent");
1980 void GenericGui::onSalomeServiceNode()
1982 DEBTRACE("GenericGui::onSalomeServiceNode");
1983 _guiEditor->CreateNode("SalomeNode");
1986 void GenericGui::onServiceInlineNode()
1988 DEBTRACE("GenericGui::onServiceInlineNode");
1989 _guiEditor->CreateNode("SalomePythonNode");
1992 void GenericGui::onCORBAServiceNode()
1994 DEBTRACE("GenericGui::onCORBAServiceNode");
1995 _guiEditor->CreateNode("CORBANode");
1998 void GenericGui::onNodeNodeServiceNode()
2000 DEBTRACE("GenericGui::onNodeNodeServiceNode");
2003 void GenericGui::onCppNode()
2005 DEBTRACE("GenericGui::onCppNode");
2006 _guiEditor->CreateNode("CppNode");
2009 void GenericGui::onXMLNode()
2011 DEBTRACE("GenericGui::onXMLNode");
2012 _guiEditor->CreateNode("XmlNode");
2015 void GenericGui::onInDataNode()
2017 DEBTRACE("GenericGui::onInDataNode");
2018 _guiEditor->CreateNode("PresetNode");
2021 void GenericGui::onOutDataNode()
2023 DEBTRACE("GenericGui::onOutDataNode");
2024 _guiEditor->CreateNode("OutNode");
2027 void GenericGui::onInStudyNode()
2029 DEBTRACE("GenericGui::onInStudyNode");
2030 _guiEditor->CreateNode("StudyInNode");
2033 void GenericGui::onOutStudyNode()
2035 DEBTRACE("GenericGui::onOutStudyNode");
2036 _guiEditor->CreateNode("StudyOutNode");
2039 void GenericGui::onInlineScriptNode()
2041 DEBTRACE("GenericGui::onInlineScriptNode");
2042 _guiEditor->CreateNode("PyScript");
2045 void GenericGui::onInlineFunctionNode()
2047 DEBTRACE("GenericGui::onInlineFunctionNode");
2048 _guiEditor->CreateNode("PyFunction");
2051 void GenericGui::onBlockNode()
2053 DEBTRACE("GenericGui::onBlockNode");
2054 _guiEditor->CreateBloc();
2057 void GenericGui::onFORNode()
2059 DEBTRACE("GenericGui::onFORNode");
2060 _guiEditor->CreateForLoop();
2063 void GenericGui::onFOREACHNode()
2065 DEBTRACE("GenericGui::onFOREACHNode");
2066 createForEachLoop("double");
2069 void GenericGui::createForEachLoop(std::string type)
2071 DEBTRACE("GenericGui::createForEachLoop");
2072 _guiEditor->CreateForEachLoop(type);
2075 void GenericGui::onWHILENode()
2077 DEBTRACE("GenericGui::onWHILENode");
2078 _guiEditor->CreateWhileLoop();
2081 void GenericGui::onSWITCHNode()
2083 DEBTRACE("GenericGui::onSWITCHNode");
2084 _guiEditor->CreateSwitch();
2087 void GenericGui::onOptimizerLoop()
2089 DEBTRACE("GenericGui::onOptimizerLoop");
2090 _guiEditor->CreateOptimizerLoop();
2093 void GenericGui::onNodeFromCatalog()
2095 DEBTRACE("GenericGui::onNodeFromCatalog");
2096 if (_dwCatalogs) _dwCatalogs->raise();
2099 void GenericGui::onDeleteItem()
2101 DEBTRACE("GenericGui::onDeleteItem");
2102 _guiEditor->DeleteSubject();
2105 void GenericGui::onCutItem()
2107 DEBTRACE("GenericGui::onCutItem");
2108 _guiEditor->CutSubject();
2111 void GenericGui::onCopyItem()
2113 DEBTRACE("GenericGui::onCopyItem");
2114 _guiEditor->CopySubject();
2117 void GenericGui::onPasteItem()
2119 DEBTRACE("GenericGui::onPasteItem");
2120 _guiEditor->PasteSubject();
2123 void GenericGui::onPutInBloc()
2125 _guiEditor->PutSubjectInBloc();
2128 void GenericGui::onPutGraphInBloc()
2130 DEBTRACE("GenericGui::onPutGraphInBloc");
2131 _guiEditor->PutGraphInBloc();
2132 _guiEditor->arrangeNodes(false);
2135 void GenericGui::onPutGraphInForLoop()
2137 DEBTRACE("GenericGui::onPutGraphInForLoop");
2138 _guiEditor->PutGraphInNode("ForLoop");
2141 void GenericGui::putGraphInForeachLoop(std::string type)
2143 DEBTRACE("GenericGui::PutGraphInForeachLoop");
2144 _guiEditor->PutGraphInNode("ForEachLoop_"+type);
2147 void GenericGui::onPutGraphInWhileLoop()
2149 DEBTRACE("GenericGui::onPutGraphInWhileLoop");
2150 _guiEditor->PutGraphInNode("WhileLoop");
2153 void GenericGui::onPutGraphInOptimizerLoop()
2155 DEBTRACE("GenericGui::onPutGraphInOptimizerLoop");
2156 _guiEditor->PutGraphInNode("OptimizerLoop");
2159 void GenericGui::onArrangeLocalNodes()
2161 DEBTRACE("GenericGui::onArrangeLocalNodes");
2162 _guiEditor->arrangeNodes(false);
2165 void GenericGui::onArrangeRecurseNodes()
2167 DEBTRACE("GenericGui::onArrangeRecurseNodes");
2168 _guiEditor->arrangeNodes(true);
2171 void GenericGui::onRebuildLinks()
2173 DEBTRACE("GenericGui::onRebuildLinks");
2174 _guiEditor->rebuildLinks();
2177 void GenericGui::onZoomToBloc()
2179 DEBTRACE("GenericGui::onZoomToBloc");
2180 QtGuiContext::getQtCurrent()->getView()->onZoomToBloc();
2183 void GenericGui::onCenterOnNode()
2185 DEBTRACE("GenericGui::onCenterOnNode");
2186 QtGuiContext::getQtCurrent()->getView()->onCenterOnNode();
2189 void GenericGui::onShrinkExpand() {
2190 DEBTRACE("GenericGui::onShrinkExpand");
2191 _guiEditor->shrinkExpand();
2194 void GenericGui::onShrinkExpandChildren() {
2195 DEBTRACE("GenericGui::onShrinkExpandChildren");
2196 _guiEditor->shrinkExpand(Qt::ControlModifier|Qt::ShiftModifier);
2199 void GenericGui::onShrinkExpandElementaryRecursively() {
2200 DEBTRACE("GenericGui::onShrinkExpandElementaryRecursively");
2201 _guiEditor->shrinkExpand(Qt::ControlModifier);
2204 void GenericGui::onToggleStraightLinks(bool checked)
2206 Scene::_straightLinks = checked;
2207 DEBTRACE("Scene::_straightLinks=" << checked);
2208 if (!QtGuiContext::getQtCurrent())
2210 map<Subject*, SchemaItem*>::const_iterator it = QtGuiContext::getQtCurrent()->_mapOfSchemaItem.begin();
2211 for( ; it != QtGuiContext::getQtCurrent()->_mapOfSchemaItem.end(); ++it)
2213 Subject* sub = (*it).first;
2214 sub->update(SWITCHSHAPE, 0, 0);
2218 void GenericGui::onToggleAutomaticComputeLinks(bool checked)
2220 Scene::_autoComputeLinks = checked;
2221 DEBTRACE("Scene::_autoComputeLinks=" << checked);
2224 void GenericGui::onToggleSimplifyLinks(bool checked)
2226 Scene::_simplifyLinks = checked;
2227 DEBTRACE("Scene::_simplifyLinks=" << checked);
2230 void GenericGui::onToggleForce2NodesLinks(bool checked)
2232 Scene::_force2NodesLink = checked;
2233 DEBTRACE("Scene::_force2NodesLink=" << checked);
2236 void GenericGui::onToggleAddRowCols(bool checked)
2238 Scene::_addRowCols = checked;
2239 DEBTRACE("Scene::_addRowCols=" << checked);
2242 void GenericGui::onSelectReference()
2244 Subject *sub = QtGuiContext::getQtCurrent()->getSelectedSubject();
2246 SubjectReference *ref = dynamic_cast<SubjectReference*>(sub);
2248 SubjectServiceNode *snode = dynamic_cast<SubjectServiceNode*>(ref->getReference());
2249 snode->select(true);
2252 void GenericGui::onWhatsThis()
2254 DEBTRACE("GenericGui::onWhatsThis");
2255 QWhatsThis::enterWhatsThisMode();
2258 void GenericGui::onWithoutStopMode(bool checked)
2260 DEBTRACE("GenericGui::onWithoutStopMode " << checked);
2261 if (!QtGuiContext::getQtCurrent()) return;
2262 if (!QtGuiContext::getQtCurrent()->getGuiExecutor()) return;
2263 if (checked) QtGuiContext::getQtCurrent()->getGuiExecutor()->setContinueMode();
2266 void GenericGui::onBreakpointsMode(bool checked)
2268 DEBTRACE("GenericGui::onWithoutStopMode " << checked);
2269 if (!QtGuiContext::getQtCurrent()) return;
2270 if (!QtGuiContext::getQtCurrent()->getGuiExecutor()) return;
2271 if (checked) QtGuiContext::getQtCurrent()->getGuiExecutor()->setBreakpointMode();
2274 void GenericGui::onStepByStepMode(bool checked)
2276 DEBTRACE("GenericGui::onWithoutStopMode " << checked);
2277 if (!QtGuiContext::getQtCurrent()) return;
2278 if (!QtGuiContext::getQtCurrent()->getGuiExecutor()) return;
2279 if (checked) QtGuiContext::getQtCurrent()->getGuiExecutor()->setStepByStepMode();
2282 void GenericGui::onToggleStopOnError(bool checked)
2284 DEBTRACE("GenericGui::onToggleStopOnError " << checked);
2285 if (!QtGuiContext::getQtCurrent()) return;
2286 if (!QtGuiContext::getQtCurrent()->getGuiExecutor()) return;
2288 QtGuiContext::getQtCurrent()->getGuiExecutor()->setStopOnError(false);
2290 QtGuiContext::getQtCurrent()->getGuiExecutor()->unsetStopOnError();
2293 void GenericGui::onToggleSceneItemVisible(bool checked)
2295 DEBTRACE("GenericGui::onToggleSceneItemVisible " << checked);
2296 if (!QtGuiContext::getQtCurrent()) return;
2297 Subject *sub = QtGuiContext::getQtCurrent()->getSelectedSubject();
2298 SubjectNode *snode = dynamic_cast<SubjectNode*>(sub);
2301 if (!QtGuiContext::getQtCurrent()->_mapOfSceneItem.count(sub)) return;
2303 SceneItem *item = QtGuiContext::getQtCurrent()->_mapOfSceneItem[sub];
2304 item->setVisible(checked);
2307 void GenericGui::displayLinks(bool isShown)
2309 if (!QtGuiContext::getQtCurrent()) return;
2310 map<pair<YACS::ENGINE::OutPort*, YACS::ENGINE::InPort*>,YACS::HMI::SubjectLink*>::const_iterator it;
2311 for (it = QtGuiContext::getQtCurrent()->_mapOfSubjectLink.begin();
2312 it != QtGuiContext::getQtCurrent()->_mapOfSubjectLink.end();
2315 YACS::HMI::SubjectLink* sub = (*it).second;
2317 SceneItem *item = QtGuiContext::getQtCurrent()->_mapOfSceneItem[sub];
2318 item->setVisible(isShown);
2322 void GenericGui::displayControlLinks(bool isShown)
2324 if (!QtGuiContext::getQtCurrent()) return;
2325 map<pair<YACS::ENGINE::Node*, YACS::ENGINE::Node*>,YACS::HMI::SubjectControlLink*>::const_iterator it;
2326 for (it = QtGuiContext::getQtCurrent()->_mapOfSubjectControlLink.begin();
2327 it != QtGuiContext::getQtCurrent()->_mapOfSubjectControlLink.end();
2330 YACS::HMI::SubjectControlLink* sub = (*it).second;
2332 SceneItem *item = QtGuiContext::getQtCurrent()->_mapOfSceneItem[sub];
2333 item->setVisible(isShown);
2337 void GenericGui::displayPortLinks(bool isShown)
2339 Subject *sub = QtGuiContext::getQtCurrent()->getSelectedSubject();
2340 DEBTRACE("displayPortLinks, subject : " << sub->getName());
2341 SubjectDataPort *sport = dynamic_cast<SubjectDataPort*>(sub);
2344 DEBTRACE("dataPort : " << sport->getName());
2345 list<SubjectLink*> linkList = sport->getListOfSubjectLink();
2346 list<SubjectLink*>::const_iterator it = linkList.begin();
2347 for( ; it != linkList.end(); ++it)
2349 YACS::HMI::SubjectLink* sub = (*it);
2351 SceneItem *item = QtGuiContext::getQtCurrent()->_mapOfSceneItem[sub];
2352 item->setVisible(isShown);
2356 SubjectNode *snode = dynamic_cast<SubjectNode*>(sub);
2359 DEBTRACE("Node : " << snode->getName());
2360 list<SubjectControlLink*> linkList = snode->getSubjectControlLinks();
2361 list<SubjectControlLink*>::const_iterator it = linkList.begin();
2362 for( ; it != linkList.end(); ++it)
2364 YACS::HMI::SubjectControlLink* sub = (*it);
2366 SceneItem *item = QtGuiContext::getQtCurrent()->_mapOfSceneItem[sub];
2367 item->setVisible(isShown);
2373 void GenericGui::displayALink(bool isShown)
2375 Subject *sub = QtGuiContext::getQtCurrent()->getSelectedSubject();
2376 if (! QtGuiContext::getQtCurrent()->_mapOfSceneItem.count(sub)) return;
2377 SceneItem *item = QtGuiContext::getQtCurrent()->_mapOfSceneItem[sub];
2378 item->setVisible(isShown);
2381 void GenericGui::onShowAllLinks()
2383 DEBTRACE("GenericGui::onShowAllLinks");
2385 displayControlLinks(true);
2388 void GenericGui::onHideAllLinks()
2390 DEBTRACE("GenericGui::onHideAllLinks");
2391 displayLinks(false);
2392 displayControlLinks(false);
2395 void GenericGui::onShowOnlyPortLinks()
2397 DEBTRACE("GenericGui::onShowOnlyPortLinks");
2399 displayPortLinks(true);
2402 void GenericGui::onShowPortLinks()
2404 DEBTRACE("GenericGui::onShowPortLinks");
2405 displayPortLinks(true);
2408 void GenericGui::onHidePortLinks()
2410 DEBTRACE("GenericGui::onHidePortLinks");
2411 displayPortLinks(false);
2414 void GenericGui::onEmphasisPortLinks()
2416 DEBTRACE("GenericGui::onEmphasisPortLinks");
2417 if (!QtGuiContext::getQtCurrent()) return;
2418 Subject *sub = QtGuiContext::getQtCurrent()->getSelectedSubject();
2419 DEBTRACE("EmphasizePortLinks, subject : " << sub->getName());
2423 SubjectDataPort *sport = dynamic_cast<SubjectDataPort*>(sub);
2426 emphasizePortLink(sport, true);
2430 // --- if a Node, explore all data ports
2432 SubjectNode *snode = dynamic_cast<SubjectNode*>(sub);
2435 DEBTRACE("Node : " << snode->getName());
2437 list<SubjectInputPort*> linkList = snode->getSubjectInputPorts();
2438 list<SubjectInputPort*>::const_iterator it = linkList.begin();
2439 for( ; it != linkList.end(); ++it)
2441 YACS::HMI::SubjectInputPort* sub = (*it);
2443 emphasizePortLink(sub, true);
2447 list<SubjectOutputPort*> linkList = snode->getSubjectOutputPorts();
2448 list<SubjectOutputPort*>::const_iterator it = linkList.begin();
2449 for( ; it != linkList.end(); ++it)
2451 YACS::HMI::SubjectOutputPort* sub = (*it);
2453 emphasizePortLink(sub, true);
2460 void GenericGui::onShowOnlyCtrlLinks()
2462 DEBTRACE("GenericGui::onShowOnlyCtrlLinks");
2464 displayPortLinks(true);
2467 void GenericGui::onShowCtrlLinks()
2469 DEBTRACE("GenericGui::onShowCtrlLinks");
2470 displayPortLinks(true);
2473 void GenericGui::onHideCtrlLinks()
2475 DEBTRACE("GenericGui::onHideCtrlLinks");
2476 displayPortLinks(false);
2479 void GenericGui::onEmphasisCtrlLinks()
2481 DEBTRACE("GenericGui::onEmphasisCtrlLinks");
2482 Subject *sub = QtGuiContext::getQtCurrent()->getSelectedSubject();
2483 DEBTRACE("Emphasize Ctrl Links, subject : " << sub->getName());
2486 SubjectNode *snode = dynamic_cast<SubjectNode*>(sub);
2489 DEBTRACE("Node : " << snode->getName());
2490 list<SubjectControlLink*> linkList = snode->getSubjectControlLinks();
2491 list<SubjectControlLink*>::const_iterator it = linkList.begin();
2492 for( ; it != linkList.end(); ++it)
2494 YACS::HMI::SubjectControlLink* sub = (*it);
2496 sub->update(EMPHASIZE, true, sub);
2497 Subject *sin = sub->getSubjectInNode();
2498 Subject *sout = sub->getSubjectOutNode();
2499 sin->update(EMPHASIZE, true, sub);
2500 sout->update(EMPHASIZE, true, sub);
2506 void GenericGui::onShowOnlyLink()
2508 DEBTRACE("GenericGui::onShowOnlyLink");
2513 void GenericGui::onShowLink()
2515 DEBTRACE("GenericGui::onShowLink");
2519 void GenericGui::onHideLink()
2521 DEBTRACE("GenericGui::onHideLink");
2522 displayALink(false);
2525 void GenericGui::onEmphasisLink()
2527 DEBTRACE("GenericGui::onEmphasisLink");
2528 Subject *sub = QtGuiContext::getQtCurrent()->getSelectedSubject();
2531 sub->update(EMPHASIZE, true, sub);
2534 void GenericGui::onDeEmphasizeAll()
2536 DEBTRACE("GenericGui::onDeEmphasizeAll");
2537 map<Subject*, SchemaItem*>::const_iterator it = QtGuiContext::getQtCurrent()->_mapOfSchemaItem.begin();
2538 for( ; it != QtGuiContext::getQtCurrent()->_mapOfSchemaItem.end(); ++it)
2540 Subject* sub = (*it).first;
2541 sub->update(EMPHASIZE, false, sub);
2545 void GenericGui::onUndo()
2547 DEBTRACE("GenericGui::onUndo");
2548 if (QtGuiContext::getQtCurrent()->_setOfModifiedSubjects.empty())
2550 QtGuiContext::getQtCurrent()->getInvoc()->undo();
2551 // Empty the clipboard in order to avoid the copy of a destroyed object.
2552 QtGuiContext::getQtCurrent()->setSubjectToCopy(NULL);
2554 else Message("undo not possible when there are local modifications not confirmed");
2557 void GenericGui::onRedo()
2559 DEBTRACE("GenericGui::onRedo");
2560 if (QtGuiContext::getQtCurrent()->_setOfModifiedSubjects.empty())
2562 QtGuiContext::getQtCurrent()->getInvoc()->redo();
2563 // Empty the clipboard in order to avoid the copy of a destroyed object.
2564 QtGuiContext::getQtCurrent()->setSubjectToCopy(NULL);
2566 else Message("redo not possible when there are local modifications not confirmed");
2569 void GenericGui::onShowUndo()
2571 _guiEditor->showUndo(_parent);
2574 void GenericGui::onShowRedo()
2576 _guiEditor->showRedo(_parent);
2579 void GenericGui::onCleanOnExit()
2581 DEBTRACE("GenericGui::onCleanOnExit");
2582 map<QWidget*, YACS::HMI::QtGuiContext*> mapViewContextCopy = _mapViewContext;
2583 map<QWidget*, YACS::HMI::QtGuiContext*>::iterator it = mapViewContextCopy.begin();
2584 for (; it != mapViewContextCopy.end(); ++it)
2586 closeContext((*it).first, true);
2590 void GenericGui::emphasizePortLink(YACS::HMI::SubjectDataPort* sub, bool emphasize)
2592 DEBTRACE("dataPort : " << sub->getName());
2593 list<SubjectLink*> linkList = sub->getListOfSubjectLink();
2594 list<SubjectLink*>::const_iterator it = linkList.begin();
2595 for( ; it != linkList.end(); ++it)
2597 YACS::HMI::SubjectLink* subli = (*it);
2598 if (!subli) continue;
2599 subli->update(EMPHASIZE, emphasize, sub);
2600 Subject *sin = subli->getSubjectInPort();
2601 Subject *sout = subli->getSubjectOutPort();
2602 sin->update(EMPHASIZE, emphasize, sub);
2603 sout->update(EMPHASIZE, emphasize, sub);
2607 void GenericGui::onHelpContextModule( const QString& theComponentName, const QString& theFileName, const QString& theContext)
2609 _wrapper->onHelpContextModule(theComponentName,theFileName,theContext);