1 // Copyright (C) 2006-2019 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 #if QT_VERSION >= 0x040500
178 _parent->setTabPosition(Qt::AllDockWidgetAreas, Resource::tabPanelsUp? QTabWidget::North: QTabWidget::South);
180 //Import user catalog
181 std::string usercata=Resource::userCatalog.toStdString();
182 _catalogsWidget->addCatalogFromFile(usercata);
185 GenericGui::~GenericGui()
187 if(_BJLdialog) delete _BJLdialog;
190 void GenericGui::createActions()
192 // QAction* createAction(const int id,
193 // const QString& toolTip,
194 // const QIcon& icon,
195 // const QString& menu,
196 // const QString& status,
197 // const int shortCut,
198 // QObject* parent =0,
199 // bool checkable = false,
200 // QObject* receiver =0,
201 // const char* member =0);
203 _newSchemaAct = _wrapper->createAction(getMenuId(), tr("Create a new YACS Schema"), QIcon("icons:schema.png"),
204 tr("New Schema"), tr("Create a new YACS Schema"),
205 0, _parent, false, this, SLOT(onNewSchema()));
206 _newSchemaAct->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_N); // --- QKeySequence::New ambiguous in SALOME
208 _importSchemaAct = _wrapper->createAction(getMenuId(), tr("Import a YACS Schema for edition"), QIcon("icons:import_dataflow.png"),
209 tr("Import Schema"), tr("Import a YACS Schema for edition"),
210 0, _parent, false, this, SLOT(onImportSchema()));
211 _importSchemaAct->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_O); // --- QKeySequence::Open ambiguous in SALOME
213 _importSupervSchemaAct = _wrapper->createAction(getMenuId(), tr("Import a SUPERV Schema for edition"), QIcon("icons:import_superv_dataflow.png"),
214 tr("Import SUPERV Schema"), tr("Import a SUPERV Schema for edition"),
215 0, _parent, false, this, SLOT(onImportSupervSchema()));
217 _exportSchemaAct = _wrapper->createAction(getMenuId(), tr("Save the current YACS Schema"), QIcon("icons:save_dataflow.png"),
218 tr("Save Schema"), tr("Save the current YACS Schema"),
219 0, _parent, false, this, SLOT(onExportSchema()));
220 _exportSchemaAct->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_S); // --- QKeySequence::Save ambiguous in SALOME
222 _exportSchemaAsAct = _wrapper->createAction(getMenuId(), tr("Save the current YACS Schema As..."), QIcon("icons:export_dataflow.png"),
223 tr("Save Schema As"), tr("Save the current YACS Schema As..."),
224 0, _parent, false, this, SLOT(onExportSchemaAs()));
225 //_exportSchemaAsAct->setShortcut(QKeySequence::SaveAs); // --- ambiguous in SALOME
227 _importCatalogAct = _wrapper->createAction(getMenuId(), tr("Import a Schema as a Catalog"), QIcon("icons:insert_file.png"),
228 tr("Import Catalog"), tr("Import a Schema as a Catalog"),
229 0, _parent, false, this, SLOT(onImportCatalog()));
232 _runLoadedSchemaAct = _wrapper->createAction(getMenuId(), tr("Prepare the current edited schema for run"), QIcon("icons:run_active.png"),
233 tr("Run Current Schema"), tr("Prepare the current edited schema for run"),
234 0, _parent, false, this, SLOT(onRunLoadedSchema()));
236 _loadRunStateSchemaAct = _wrapper->createAction(getMenuId(), tr("Load a previous run state for this schema, prepare to run"), QIcon("icons:load_execution_state.png"),
237 tr("Load Run State"), tr("Load a previous run state for this schema, prepare to run"),
238 0, _parent, false, this, SLOT(onLoadRunStateSchema()));
240 _loadAndRunSchemaAct = _wrapper->createAction(getMenuId(), tr("Load a schema for run"), QIcon("icons:run.png"),
241 tr("Load Schema to run"), tr("Load a schema for run"),
242 0, _parent, false, this, SLOT(onLoadAndRunSchema()));
244 _chooseBatchJobAct = _wrapper->createAction(getMenuId(), tr("Choose Batch Job to watch"), QIcon("icons:batch.png"),
245 tr("Choose Batch Job to watch"), tr("Choose Batch Job to watch"),
246 0, _parent, false, this, SLOT(onChooseBatchJob()));
248 _startResumeAct = _wrapper->createAction(getMenuId(), tr("Start or Resume Schema execution"), QIcon("icons:suspend_resume.png"),
249 tr("Start/Resume execution"), tr("Start or Resume Schema execution"),
250 0, _parent, false, this, SLOT(onStartResume()));
252 _abortAct = _wrapper->createAction(getMenuId(), tr("Abort the current execution"), QIcon("icons:kill.png"),
253 tr("Abort execution"), tr("Abort the current execution"),
254 0, _parent, false, this, SLOT(onAbort()));
256 _pauseAct = _wrapper->createAction(getMenuId(), tr("Suspend the current execution"), QIcon("icons:pause.png"),
257 tr("Suspend execution"), tr("Suspend the current execution"),
258 0, _parent, false, this, SLOT(onPause()));
260 _resetAct = _wrapper->createAction(getMenuId(), tr("Reset error nodes and restart the current execution"), QIcon("icons:reset.png"),
261 tr("Restart execution"), tr("Restart the current execution with reset of error nodes"),
262 0, _parent, false, this, SLOT(onReset()));
265 _saveRunStateAct = _wrapper->createAction(getMenuId(), tr("Save the current run state"), QIcon("icons:save_dataflow_state.png"),
266 tr("Save State"), tr("Save the current run state"),
267 0, _parent, false, this, SLOT(onSaveRunState()));
269 _newEditionAct = _wrapper->createAction(getMenuId(), tr("Edit again the current schema in a new context"), QIcon("icons:new_edition.png"),
270 tr("Edit Again"), tr("Edit again the current schema in a new context"),
271 0, _parent, false, this, SLOT(onNewEdition()));
274 _getYacsContainerLogAct = _wrapper->createAction(getMenuId(), tr("get YACS container log"), QIcon("icons:change_informations.png"),
275 tr("YACS Container Log"), tr("get YACS container log"),
276 0, _parent, false, this, SLOT(onGetYacsContainerLog()));
278 _getErrorReportAct = _wrapper->createAction(getMenuId(), tr("get Node Error Report"), QIcon("icons:filter_notification.png"),
279 tr("Node Error Report"), tr("get Node Error Report"),
280 0, _parent, false, this, SLOT(onGetErrorReport()));
282 _getErrorDetailsAct = _wrapper->createAction(getMenuId(), tr("get Node Error Details"), QIcon("icons:icon_text.png"),
283 tr("Node Error Details"), tr("get Node Error Details"),
284 0, _parent, false, this, SLOT(onGetErrorDetails()));
286 _getContainerLogAct = _wrapper->createAction(getMenuId(), tr("get Node Container Log"), QIcon("icons:change_informations.png"),
287 tr("Node Container Log"), tr("get Node Container Log"),
288 0, _parent, false, this, SLOT(onGetContainerLog()));
290 _shutdownProcAct = _wrapper->createAction(getMenuId(), tr("Shutdown Proc"), QIcon("icons:kill.png"),
291 tr("Shutdown Proc"), tr("Shutdown Proc"),
292 0, _parent, false, this, SLOT(onShutdownProc()));
295 _editDataTypesAct = _wrapper->createAction(getMenuId(), tr("Edit Data Types"), QIcon("icons:kill.png"),
296 tr("Edit Data Types"), tr("Edit Data Types"),
297 0, _parent, false, this, SLOT(onEditDataTypes()));
299 _createDataTypeAct = _wrapper->createAction(getMenuId(), tr("Create Data Types"), QIcon("icons:kill.png"),
300 tr("Create Data Types"), tr("Create Data Types"),
301 0, _parent, false, this, SLOT(onCreateDataType()));
303 _importDataTypeAct = _wrapper->createAction(getMenuId(), tr("Import Data Types, use drag and drop from catalog"), QIcon("icons:folder_cyan.png"),
304 tr("Import Data Types"), tr("Import Data Types, use drag and drop from catalog"),
305 0, _parent, false, this, SLOT(onImportDataType()));
307 _newContainerAct = _wrapper->createAction(getMenuId(), tr("Create a New Container"), QIcon("icons:container.png"),
308 tr("Create Container"), tr("Create a New Container"),
309 0, _parent, false, this, SLOT(onNewContainer()));
311 _newHPContainerAct = _wrapper->createAction(getMenuId(), tr("Create a New HP Container"), QIcon("icons:container.png"),
312 tr("Create HP Container"), tr("Create a New Homogeneous Pool Container."),
313 0, _parent, false, this, SLOT(onNewHPContainer()));
315 _selectComponentInstanceAct = _wrapper->createAction(getMenuId(), tr("Select a Component Instance"), QIcon("icons:icon_select.png"),
316 tr("Select a Component Instance"), tr("Select a Component Instance"),
317 0, _parent, false, this, SLOT(onSelectComponentInstance()));
319 _newSalomeComponentAct = _wrapper->createAction(getMenuId(), tr("Create a New SALOME Component Instance"), QIcon("icons:new_salome_component.png"),
320 tr("Create Component Instance"), tr("Create a New SALOME Component Instance"),
321 0, _parent, false, this, SLOT(onNewSalomeComponent()));
323 _newSalomePythonComponentAct = _wrapper->createAction(getMenuId(), tr("Create a New SALOME Python Component"), QIcon("icons:new_salomepy_component.png"),
324 tr("SALOME Python Component"), tr("Create a New SALOME Python Component"),
325 0, _parent, false, this, SLOT(onNewSalomePythonComponent()));
327 _newCorbaComponentAct = _wrapper->createAction(getMenuId(), tr("Create a New CORBA Component"), QIcon("icons:new_corba_component.png"),
328 tr("CORBA Component"), tr("Create a New CORBA Component"),
329 0, _parent, false, this, SLOT(onNewCorbaComponent()));
331 _salomeServiceNodeAct = _wrapper->createAction(getMenuId(), tr("Create a New SALOME Service Node"), QIcon("icons:new_salome_service_node.png"),
332 tr("SALOME Service Node"), tr("Create a New SALOME Service Node"),
333 0, _parent, false, this, SLOT(onSalomeServiceNode()));
335 _serviceInlineNodeAct = _wrapper->createAction(getMenuId(), tr("Create a New Inline Service Node"), QIcon("icons:new_service_inline_node.png"),
336 tr("Inline Service Node"), tr("Create a New Inline Service Node"),
337 0, _parent, false, this, SLOT(onServiceInlineNode()));
339 _CORBAServiceNodeAct = _wrapper->createAction(getMenuId(), tr("Create a New CORBA Service Node"), QIcon("icons:new_corba_service_node.png"),
340 tr("CORBA Node"), tr("Create a New CORBA Service Node"),
341 0, _parent, false, this, SLOT(onCORBAServiceNode()));
343 _nodeNodeServiceNodeAct = _wrapper->createAction(getMenuId(), tr("Create a New Node referencing a Node"), QIcon("icons:new_nodenode_service_node.png"),
344 tr("Ref on Node"), tr("Create a New Node referencing a Node"),
345 0, _parent, false, this, SLOT(onNodeNodeServiceNode()));
347 _cppNodeAct = _wrapper->createAction(getMenuId(), tr("Create a New C++ Node"), QIcon("icons:new_cpp_node.png"),
348 tr("Cpp Node"), tr("Create a New C++ Node"),
349 0, _parent, false, this, SLOT(onCppNode()));
351 _inDataNodeAct = _wrapper->createAction(getMenuId(), tr("Create a New Input data Node"), QIcon("icons:node.png"),
352 tr("Input Data Node"), tr("Create a New Input data Node"),
353 0, _parent, false, this, SLOT(onInDataNode()));
355 _outDataNodeAct = _wrapper->createAction(getMenuId(), tr("Create a New Output data Node"), QIcon("icons:node.png"),
356 tr("Output Data Node"), tr("Create a New Output data Node"),
357 0, _parent, false, this, SLOT(onOutDataNode()));
359 _inStudyNodeAct = _wrapper->createAction(getMenuId(), tr("Create a New Input Study Node"), QIcon("icons:node.png"),
360 tr("Input Study Node"), tr("Create a New Input Study Node"),
361 0, _parent, false, this, SLOT(onInStudyNode()));
363 _outStudyNodeAct = _wrapper->createAction(getMenuId(), tr("Create a New Output Study Node"), QIcon("icons:node.png"),
364 tr("Output Study Node"), tr("Create a New Output Study Node"),
365 0, _parent, false, this, SLOT(onOutStudyNode()));
367 _inlineScriptNodeAct = _wrapper->createAction(getMenuId(), tr("Create a New Inline Python Script Node"), QIcon("icons:new_inline_script_node.png"),
368 tr("Inline Script Node"), tr("Create a New Inline Python Script Node"),
369 0, _parent, false, this, SLOT(onInlineScriptNode()));
371 _inlineFunctionNodeAct = _wrapper->createAction(getMenuId(), tr("Create a New Inline Python Function Node"), QIcon("icons:new_inline_function_node.png"),
372 tr("Inline Function Node"), tr("Create a New Inline Python Function Node"),
373 0, _parent, false, this, SLOT(onInlineFunctionNode()));
375 _blockNodeAct = _wrapper->createAction(getMenuId(), tr("Create a New Bloc Node"), QIcon("icons:new_block_node.png"),
376 tr("bloc Node"), tr("Create a New Bloc Node"),
377 0, _parent, false, this, SLOT(onBlockNode()));
379 _FORNodeAct = _wrapper->createAction(getMenuId(), tr("Create a New For Loop Node"), QIcon("icons:new_for_loop_node.png"),
380 tr("For Loop Node"), tr("Create a New For Loop Node"),
381 0, _parent, false, this, SLOT(onFORNode()));
383 _FOREACHNodeAct = _wrapper->createAction(getMenuId(), tr("Create a New For Each Loop Node"), QIcon("icons:new_foreach_loop_node.png"),
384 tr("For Each Loop Node"), tr("Create a New For Each Loop Node"),
385 0, _parent, false, this, SLOT(onFOREACHNode()));
387 _WHILENodeAct = _wrapper->createAction(getMenuId(), tr("Create a New While Loop Node"), QIcon("icons:new_while_loop_node.png"),
388 tr("While Loop Node"), tr("Create a New While Loop Node"),
389 0, _parent, false, this, SLOT(onWHILENode()));
391 _SWITCHNodeAct = _wrapper->createAction(getMenuId(), tr("Create a New Switch Node"), QIcon("icons:new_switch_loop_node.png"),
392 tr("Switch Node"), tr("Create a New Switch Node"),
393 0, _parent, false, this, SLOT(onSWITCHNode()));
395 _OptimizerLoopAct = _wrapper->createAction(getMenuId(), tr("Create a New Optimizer Loop Node"), QIcon("icons:new_for_loop_node.png"),
396 tr("Optimizer Loop"), tr("Create a New Optimizer Loop"),
397 0, _parent, false, this, SLOT(onOptimizerLoop()));
399 _nodeFromCatalogAct = _wrapper->createAction(getMenuId(), tr("Create a New Node from Catalog, use drag and drop from catalog"), QIcon("icons:new_from_library_node.png"),
400 tr("Node from Catalog"), tr("Create a New Node from Catalog, use drag and drop from catalog"),
401 0, _parent, false, this, SLOT(onNodeFromCatalog()));
403 _deleteItemAct = _wrapper->createAction(getMenuId(), tr("Delete a Schema Item"), QIcon("icons:delete.png"),
404 tr("Delete Item"), tr("Delete a Schema Item"),
405 0, _parent, false, this, SLOT(onDeleteItem()));
406 _deleteItemAct->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_D); // --- QKeySequence::Delete dangerous...
408 _cutItemAct = _wrapper->createAction(getMenuId(), tr("Cut a Schema Item"), QIcon("icons:cut.png"),
409 tr("Cut Item"), tr("Cut a Schema Item"),
410 0, _parent, false, this, SLOT(onCutItem()));
411 _cutItemAct->setShortcut(QKeySequence::Cut);
413 _copyItemAct = _wrapper->createAction(getMenuId(), tr("Copy a Schema Item"), QIcon("icons:copy.png"),
414 tr("Copy Item"), tr("Copy a Schema Item"),
415 0, _parent, false, this, SLOT(onCopyItem()));
416 _copyItemAct->setShortcut(QKeySequence::Copy);
418 _pasteItemAct = _wrapper->createAction(getMenuId(), tr("Paste a Schema Item"), QIcon("icons:paste.png"),
419 tr("Paste Item"), tr("Paste a Schema Item"),
420 0, _parent, false, this, SLOT(onPasteItem()));
421 _pasteItemAct->setShortcut(QKeySequence::Paste);
423 _putInBlocAct = _wrapper->createAction(getMenuId(), tr("Put node in block"), QIcon("icons:paste.png"),
424 tr("Put node in block"), tr("Put node in block"),
425 0, _parent, false, this, SLOT(onPutInBloc()));
427 _putGraphInBlocAct = _wrapper->createAction(getMenuId(), tr("Bloc"), QIcon("icons:new_block_node.png"),
428 tr("Bloc"), tr("Bloc"),
429 0, _parent, false, this, SLOT(onPutGraphInBloc()));
431 _putGraphInForLoopAct = _wrapper->createAction(getMenuId(), tr("For Loop"), QIcon("icons:new_for_loop_node.png"),
432 tr("For Loop"), tr("For Loop"),
433 0, _parent, false, this, SLOT(onPutGraphInForLoop()));
435 _putGraphInWhileLoopAct = _wrapper->createAction(getMenuId(), tr("While Loop"), QIcon("icons:new_while_loop_node.png"),
436 tr("While Loop"), tr("While Loop"),
437 0, _parent, false, this, SLOT(onPutGraphInWhileLoop()));
439 _putGraphInOptimizerLoopAct = _wrapper->createAction(getMenuId(), tr("Optimizer Loop"), QIcon("icons:new_for_loop_node.png"),
440 tr("Optimizer Loop"), tr("Optimizer Loop"),
441 0, _parent, false, this, SLOT(onPutGraphInOptimizerLoop()));
443 _arrangeLocalNodesAct = _wrapper->createAction(getMenuId(), tr("arrange nodes on that bloc level, without recursion"), QIcon("icons:arrange_nodes.png"),
444 tr("arrange local nodes"), tr("arrange nodes on that bloc level, without recursion"),
445 0, _parent, false, this, SLOT(onArrangeLocalNodes()));
447 _arrangeRecurseNodesAct = _wrapper->createAction(getMenuId(), tr("arrange nodes on that bloc level, with recursion"), QIcon("icons:sample.png"),
448 tr("arrange nodes recursion"), tr("arrange nodes on that bloc level, with recursion"),
449 0, _parent, false, this, SLOT(onArrangeRecurseNodes()));
451 _computeLinkAct = _wrapper->createAction(getMenuId(), tr("compute orthogonal links"), QIcon("icons:rebuild_links.png"),
452 tr("compute links"), tr("compute orthogonal links"),
453 0, _parent, false, this, SLOT(onRebuildLinks()));
455 _zoomToBlocAct = _wrapper->createAction(getMenuId(), tr("zoom 2D view to selected bloc"), QIcon("icons:zoomToBloc.png"),
456 tr("zoom to bloc"), tr("zoom 2D view to the selected composed node"),
457 0, _parent, false, this, SLOT(onZoomToBloc()));
459 _centerOnNodeAct = _wrapper->createAction(getMenuId(), tr("center 2D view on selected node"), QIcon("icons:centerOnNode.png"),
460 tr("center on node"), tr("center 2D view on selected node"),
461 0, _parent, false, this, SLOT(onCenterOnNode()));
462 _centerOnNodeAct->setShortcut(QKeySequence::Find);
464 _shrinkExpand = _wrapper->createAction(getMenuId(), tr("shrink or expand the selected node"), QIcon("icons:shrinkExpand.png"),
465 tr("shrink/expand"), tr("shrink or expand the selected node"),
466 0, _parent, false, this, SLOT(onShrinkExpand()));
468 _shrinkExpandChildren = _wrapper->createAction(getMenuId(), tr("shrink or expand direct children of the selected node"), QIcon("icons:shrinkExpand.png"),
469 tr("shrink/expand children"), tr("shrink or expand direct children of the selected node"),
470 0, _parent, false, this, SLOT(onShrinkExpandChildren()));
472 _shrinkExpandElementaryRecursively = _wrapper->createAction(getMenuId(), tr("shrink or expand elementary nodes of the selected node recursively"), QIcon("icons:shrinkExpand.png"),
473 tr("shrink/expand elementary"), tr("shrink or expand elementary nodes of the selected node recursively"),
474 0, _parent, false, this, SLOT(onShrinkExpandElementaryRecursively()));
476 _toggleStraightLinksAct = _wrapper->createAction(getMenuId(), tr("draw straight or orthogonal links"), QIcon("icons:straightLink.png"),
477 tr("straight/orthogonal"), tr("draw straight or orthogonal links"),
478 0, _parent, true, this, SLOT(onToggleStraightLinks(bool)));
480 _toggleStraightLinksAct->setChecked(Resource::straightLinks);
481 onToggleStraightLinks(Resource::straightLinks);
483 _toggleAutomaticComputeLinkAct = _wrapper->createAction(getMenuId(), tr("compute othogonal links automatically when nodes move"), QIcon("icons:autoComputeLink.png"),
484 tr("automatic link"), tr("compute othogonal links automatically when nodes move"),
485 0, _parent, true, this, SLOT(onToggleAutomaticComputeLinks(bool)));
487 _toggleAutomaticComputeLinkAct->setChecked(Resource::autoComputeLinks);
488 onToggleAutomaticComputeLinks(Resource::autoComputeLinks); // Why is this needed ?
490 _toggleSimplifyLinkAct = _wrapper->createAction(getMenuId(), tr("simplify links by removing unnecessary direction changes"), QIcon("icons:simplifyLink.png"),
491 tr("simplify links"), tr("simplify links by removing unnecessary direction changes"),
492 0, _parent, true, this, SLOT(onToggleSimplifyLinks(bool)));
493 _toggleSimplifyLinkAct->setChecked(Resource::simplifyLink);
494 onToggleSimplifyLinks(Resource::simplifyLink);
496 _toggleForce2NodesLinkAct = _wrapper->createAction(getMenuId(), tr("force orthogonal links by adding an edge on simples links"), QIcon("icons:force2nodeLink.png"),
497 tr("force ortho links"), tr("force orthogonal links by adding an edge on simples links"),
498 0, _parent, true, this, SLOT(onToggleForce2NodesLinks(bool)));
499 _toggleForce2NodesLinkAct->setChecked(true);
501 _toggleAddRowColsAct = _wrapper->createAction(getMenuId(), tr("allow more path for the links, for a better separation"), QIcon("icons:addRowCols.png"),
502 tr("separate links"), tr("allow more path for the links, for a better separation"),
503 0, _parent, true, this, SLOT(onToggleAddRowCols(bool)));
504 _toggleAddRowColsAct->setChecked(Resource::addRowCols);
505 onToggleAddRowCols(Resource::addRowCols);
507 _selectReferenceAct = _wrapper->createAction(getMenuId(), tr("select reference"), QIcon("icons:ob_service_node.png"),
508 tr("select reference"), tr("select reference"),
509 0, _parent, false, this, SLOT(onSelectReference()));
511 _whatsThisAct = _wrapper->createAction(getMenuId(), tr("active whatsThis Mode to get help on widgets"), QIcon("icons:whatsThis.png"),
512 tr("whatsThis Mode"), tr("active whatsThis Mode to get help on widgets"),
513 0, _parent, false, this, SLOT(onWhatsThis()));
514 _whatsThisAct->setShortcut(QKeySequence::WhatsThis);
516 _withoutStopModeAct = _wrapper->createAction(getMenuId(), tr("set execution mode without stop"), QIcon("icons:run_active.png"),
517 tr("mode without stop"), tr("set execution mode without stop"),
518 0, _parent, true, this, SLOT(onWithoutStopMode(bool)));
520 _breakpointsModeAct = _wrapper->createAction(getMenuId(), tr("set execution mode with stop on breakpoints"), QIcon("icons:breakpoints_active.png"),
521 tr("mode breakpoints"), tr("set execution mode with stop on breakpoints"),
522 0, _parent, true, this, SLOT(onBreakpointsMode(bool)));
524 _stepByStepModeAct = _wrapper->createAction(getMenuId(), tr("set execution mode step by step"), QIcon("icons:step_by_step_active.png"),
525 tr("mode step by step"), tr("set execution mode step by step"),
526 0, _parent, true, this, SLOT(onStepByStepMode(bool)));
528 _toggleStopOnErrorAct = _wrapper->createAction(getMenuId(), tr("Force stop on first error during execution"), QIcon("icons:toggle_stop_on_error.png"),
529 tr("stop on error"), tr("Force stop on first error during execution"),
530 0, _parent, true, this, SLOT(onToggleStopOnError(bool)));
532 _toggleSceneItemVisibleAct = _wrapper->createAction(getMenuId(), tr("toggle 2D scene item visibility"), QIcon("icons:toggleVisibility.png"),
533 tr("visible/hidden"), tr("toggle 2D scene item visibility"),
534 0, _parent, true, this, SLOT(onToggleSceneItemVisible(bool)));
538 _showAllLinksAct = _wrapper->createAction(getMenuId(), tr("Show all the links"), QIcon("icons:showLink.png"),
539 tr("show all links"), tr("Show all the links"),
540 0, _parent, false, this, SLOT(onShowAllLinks()));
542 _hideAllLinksAct = _wrapper->createAction(getMenuId(), tr("Hide all the links"), QIcon("icons:hideLink.png"),
543 tr("hide all links"), tr("Hide all the links"),
544 0, _parent, false, this, SLOT(onHideAllLinks()));
547 _showOnlyPortLinksAct = _wrapper->createAction(getMenuId(), tr("Show only links from/to this port"), QIcon("icons:showLink.png"),
548 tr("show only links"), tr("Show only links from/to this port"),
549 0, _parent, false, this, SLOT(onShowOnlyPortLinks()));
551 _showPortLinksAct = _wrapper->createAction(getMenuId(), tr("Show links from/to this port"), QIcon("icons:showLink.png"),
552 tr("show links"), tr("Show links from/to this port"),
553 0, _parent, false, this, SLOT(onShowPortLinks()));
555 _hidePortLinksAct = _wrapper->createAction(getMenuId(), tr("Hide links from/to this port"), QIcon("icons:hideLink.png"),
556 tr("hide links"), tr("Hide links from/to this port"),
557 0, _parent, false, this, SLOT(onHidePortLinks()));
560 _showOnlyCtrlLinksAct = _wrapper->createAction(getMenuId(), tr("Show only control links from/to this node"), QIcon("icons:showLink.png"),
561 tr("show only Control links"), tr("Show only control links from/to this node"),
562 0, _parent, false, this, SLOT(onShowOnlyCtrlLinks()));
564 _showCtrlLinksAct = _wrapper->createAction(getMenuId(), tr("Show control links from/to this node"), QIcon("icons:showLink.png"),
565 tr("show control links"), tr("Show control links from/to this node"),
566 0, _parent, false, this, SLOT(onShowCtrlLinks()));
568 _hideCtrlLinksAct = _wrapper->createAction(getMenuId(), tr("Hide control links from/to this node"), QIcon("icons:hideLink.png"),
569 tr("hide control links"), tr("Hide control links from/to this node"),
570 0, _parent, false, this, SLOT(onHideCtrlLinks()));
573 _showOnlyLinkAct = _wrapper->createAction(getMenuId(), tr("Show only this link"), QIcon("icons:showLink.png"),
574 tr("show only"), tr("Show only this link"),
575 0, _parent, false, this, SLOT(onShowOnlyLink()));
577 _showLinkAct = _wrapper->createAction(getMenuId(), tr("Show this link"), QIcon("icons:showLink.png"),
578 tr("show"), tr("Show this link"),
579 0, _parent, false, this, SLOT(onShowLink()));
581 _hideLinkAct = _wrapper->createAction(getMenuId(), tr("Hide this link"), QIcon("icons:hideLink.png"),
582 tr("hide"), tr("Hide this link"),
583 0, _parent, false, this, SLOT(onHideLink()));
586 _emphasisPortLinksAct = _wrapper->createAction(getMenuId(), tr("emphasis on links from/to this port"), QIcon("icons:emphasisLink.png"),
587 tr("emphasize links"), tr("emphasis on links from/to this port"),
588 0, _parent, false, this, SLOT(onEmphasisPortLinks()));
590 _emphasisCtrlLinksAct = _wrapper->createAction(getMenuId(), tr("emphasis on control links from/to this node"), QIcon("icons:emphasisLink.png"),
591 tr("emphasize control links"), tr("emphasis on control links from/to this node"),
592 0, _parent, false, this, SLOT(onEmphasisCtrlLinks()));
594 _emphasisLinkAct = _wrapper->createAction(getMenuId(), tr("emphasis on this link"), QIcon("icons:emphasisLink.png"),
595 tr("emphasize"), tr("emphasis on this link"),
596 0, _parent, false, this, SLOT(onEmphasisLink()));
598 _deEmphasizeAllAct = _wrapper->createAction(getMenuId(), tr("remove all emphasis"), QIcon("icons:deEmphasisLink.png"),
599 tr("remove all emphasis"), tr("remove all emphasis"),
600 0, _parent, false, this, SLOT(onDeEmphasizeAll()));
603 _undoAct = _wrapper->createAction(getMenuId(), tr("undo last action"), QIcon("icons:undo.png"),
604 tr("undo"), tr("undo last action"),
605 0, _parent, false, this, SLOT(onUndo()));
606 _undoAct->setShortcut(QKeySequence::Undo);
608 _redoAct = _wrapper->createAction(getMenuId(), tr("redo last action"), QIcon("icons:redo.png"),
609 tr("redo"), tr("redo last action"),
610 0, _parent, false, this, SLOT(onRedo()));
611 _redoAct->setShortcut(QKeySequence::Redo);
613 _showUndoAct = _wrapper->createAction(getMenuId(), tr("show undo commands"), QIcon("icons:undo.png"),
614 tr("show undo"), tr("show undo commands"),
615 0, _parent, false, this, SLOT(onShowUndo()));
617 _showRedoAct = _wrapper->createAction(getMenuId(), tr("show redo commands"), QIcon("icons:redo.png"),
618 tr("show redo"), tr("show redo commands"),
619 0, _parent, false, this, SLOT(onShowRedo()));
622 _execModeGroup = new QActionGroup(this);
623 _execModeGroup->addAction(_withoutStopModeAct);
624 _execModeGroup->addAction(_breakpointsModeAct);
625 _execModeGroup->addAction(_stepByStepModeAct);
626 _withoutStopModeAct->setChecked(true);
629 void GenericGui::createMenus()
632 aMenuId = _wrapper->createMenu( tr( "File" ), -1, -1 );
633 _wrapper->createMenu( _wrapper->separator(), aMenuId, -1, 10 );
634 aMenuId = _wrapper->createMenu( "YACS", aMenuId, -1, 10 );
635 _wrapper->createMenu( _newSchemaAct, aMenuId );
636 _wrapper->createMenu( _importSchemaAct, aMenuId );
638 aMenuId = _wrapper->createMenu( "YACS", -1, -1, 30 );
639 _wrapper->createMenu( _newSchemaAct, aMenuId );//, 10
640 _wrapper->createMenu( _importSchemaAct, aMenuId );
641 _wrapper->createMenu( _importSupervSchemaAct, aMenuId );
642 _wrapper->createMenu( _wrapper->separator(), aMenuId);
643 _wrapper->createMenu( _exportSchemaAct, aMenuId );
644 _wrapper->createMenu( _exportSchemaAsAct, aMenuId );
645 _wrapper->createMenu( _wrapper->separator(), aMenuId);
646 _wrapper->createMenu( _runLoadedSchemaAct, aMenuId );
647 _wrapper->createMenu( _loadRunStateSchemaAct, aMenuId );
648 _wrapper->createMenu( _loadAndRunSchemaAct, aMenuId );
649 _wrapper->createMenu( _chooseBatchJobAct, aMenuId );
650 _wrapper->createMenu( _wrapper->separator(), aMenuId);
651 _wrapper->createMenu( _undoAct, aMenuId );
652 _wrapper->createMenu( _redoAct, aMenuId );
653 _wrapper->createMenu( _showUndoAct, aMenuId );
654 _wrapper->createMenu( _showRedoAct, aMenuId );
655 _wrapper->createMenu( _wrapper->separator(), aMenuId);
656 _wrapper->createMenu( _startResumeAct, aMenuId );
657 _wrapper->createMenu( _abortAct, aMenuId );
658 _wrapper->createMenu( _pauseAct, aMenuId );
659 _wrapper->createMenu( _resetAct, aMenuId );
660 _wrapper->createMenu( _wrapper->separator(), aMenuId);
661 _wrapper->createMenu( _saveRunStateAct, aMenuId );
662 //_wrapper->createMenu( _newEditionAct, aMenuId );
663 _wrapper->createMenu( _wrapper->separator(), aMenuId);
664 _wrapper->createMenu( _withoutStopModeAct, aMenuId );
665 _wrapper->createMenu( _breakpointsModeAct, aMenuId );
666 _wrapper->createMenu( _stepByStepModeAct, aMenuId );
667 _wrapper->createMenu( _wrapper->separator(), aMenuId);
668 _wrapper->createMenu( _toggleStopOnErrorAct, aMenuId );
669 _wrapper->createMenu( _wrapper->separator(), aMenuId);
670 _wrapper->createMenu( _importCatalogAct, aMenuId );
671 _wrapper->createMenu( _wrapper->separator(), aMenuId);
672 _wrapper->createMenu( _toggleStraightLinksAct, aMenuId );
673 _wrapper->createMenu( _toggleAutomaticComputeLinkAct, aMenuId );
674 _wrapper->createMenu( _toggleSimplifyLinkAct, aMenuId );
675 _wrapper->createMenu( _toggleForce2NodesLinkAct, aMenuId );
676 _wrapper->createMenu( _toggleAddRowColsAct, aMenuId );
677 _wrapper->createMenu( _wrapper->separator(), aMenuId);
678 _wrapper->createMenu( _showAllLinksAct, aMenuId );
679 _wrapper->createMenu( _hideAllLinksAct, aMenuId );
680 _wrapper->createMenu( _wrapper->separator(), aMenuId);
681 _wrapper->createMenu( _whatsThisAct, aMenuId );
684 void GenericGui::createTools()
686 int aToolId = _wrapper->createTool ( tr( "YACS Toolbar" ), QString( "YACSToolbar" ) );
687 _wrapper->createTool( _newSchemaAct, aToolId );
688 _wrapper->createTool( _importSchemaAct, aToolId );
689 _wrapper->createTool( _wrapper->separator(), aToolId );
690 _wrapper->createTool( _exportSchemaAct, aToolId );
691 _wrapper->createTool( _exportSchemaAsAct, aToolId );
692 _wrapper->createTool( _wrapper->separator(), aToolId);
693 _wrapper->createTool( _runLoadedSchemaAct, aToolId );
694 _wrapper->createTool( _loadRunStateSchemaAct, aToolId );
695 _wrapper->createTool( _loadAndRunSchemaAct, aToolId );
696 _wrapper->createTool( _chooseBatchJobAct, aToolId );
697 _wrapper->createTool( _wrapper->separator(), aToolId );
698 _wrapper->createTool( _undoAct, aToolId );
699 _wrapper->createTool( _redoAct, aToolId );
700 _wrapper->createTool( _wrapper->separator(), aToolId );
701 _wrapper->createTool( _startResumeAct, aToolId );
702 _wrapper->createTool( _abortAct, aToolId );
703 _wrapper->createTool( _pauseAct, aToolId );
704 _wrapper->createTool( _resetAct, aToolId );
705 _wrapper->createTool( _wrapper->separator(), aToolId );
706 _wrapper->createTool( _saveRunStateAct, aToolId );
707 //_wrapper->createTool( _newEditionAct, aToolId );
708 _wrapper->createTool( _withoutStopModeAct, aToolId );
709 _wrapper->createTool( _breakpointsModeAct, aToolId );
710 _wrapper->createTool( _stepByStepModeAct, aToolId );
711 _wrapper->createTool( _wrapper->separator(), aToolId );
712 _wrapper->createTool( _toggleStopOnErrorAct, aToolId );
713 _wrapper->createTool( _wrapper->separator(), aToolId );
714 _wrapper->createTool( _importCatalogAct, aToolId );
715 _wrapper->createTool( _wrapper->separator(), aToolId );
716 _wrapper->createTool( _toggleStraightLinksAct, aToolId );
717 _wrapper->createTool( _toggleAutomaticComputeLinkAct, aToolId );
718 _wrapper->createTool( _toggleSimplifyLinkAct, aToolId );
719 //_wrapper->createTool( _toggleForce2NodesLinkAct, aToolId );
720 _wrapper->createTool( _toggleAddRowColsAct, aToolId );
721 _wrapper->createTool( _wrapper->separator(), aToolId );
722 _wrapper->createTool( _showAllLinksAct, aToolId );
723 _wrapper->createTool( _hideAllLinksAct, aToolId );
724 _wrapper->createTool( _wrapper->separator(), aToolId );
725 _wrapper->createTool( _whatsThisAct, aToolId );
728 void GenericGui::initialMenus()
730 showEditionMenus(false);
731 showExecMenus(false);
732 showCommonMenus(false);
736 void GenericGui::hideAllMenus()
738 showBaseMenus (false);
739 showCommonMenus (false);
740 showEditionMenus(false);
741 showExecMenus (false);
744 void GenericGui::showBaseMenus(bool show)
746 DEBTRACE("GenericGui::showBaseMenus " << show);
747 _wrapper->setMenuShown(_newSchemaAct, show);
748 _wrapper->setToolShown(_newSchemaAct, show);
749 _wrapper->setMenuShown(_importSchemaAct, show);
750 _wrapper->setToolShown(_importSchemaAct, show);
751 _wrapper->setMenuShown(_importSupervSchemaAct, show);
752 _wrapper->setMenuShown(_loadAndRunSchemaAct, show);
753 _wrapper->setToolShown(_loadAndRunSchemaAct, show);
754 _wrapper->setMenuShown(_chooseBatchJobAct, show);
755 _wrapper->setToolShown(_chooseBatchJobAct, show);
756 _wrapper->setMenuShown(_whatsThisAct, show);
757 _wrapper->setToolShown(_whatsThisAct, show);
760 void GenericGui::showEditionMenus(bool show)
762 DEBTRACE("GenericGui::showEditionMenus " << show);
763 _wrapper->setMenuShown(_exportSchemaAct, show);
764 _wrapper->setToolShown(_exportSchemaAct, show);
765 _wrapper->setMenuShown(_exportSchemaAsAct, show);
766 _wrapper->setToolShown(_exportSchemaAsAct, show);
767 _wrapper->setMenuShown(_runLoadedSchemaAct, show);
768 _wrapper->setToolShown(_loadRunStateSchemaAct, show);
769 _wrapper->setMenuShown(_loadRunStateSchemaAct, show);
770 _wrapper->setToolShown(_runLoadedSchemaAct, show);
771 _wrapper->setMenuShown(_undoAct, show);
772 _wrapper->setToolShown(_undoAct, show);
773 _wrapper->setMenuShown(_redoAct, show);
774 _wrapper->setToolShown(_redoAct, show);
775 _wrapper->setMenuShown(_showUndoAct, show);
776 _wrapper->setMenuShown(_showRedoAct, show);
777 _wrapper->setMenuShown(_importCatalogAct, show);
778 _wrapper->setToolShown(_importCatalogAct, show);
781 void GenericGui::showExecMenus(bool show)
783 DEBTRACE("GenericGui::showExecMenus " << show);
784 _wrapper->setMenuShown(_startResumeAct, show);
785 _wrapper->setToolShown(_startResumeAct, show);
786 _wrapper->setMenuShown(_abortAct, show);
787 _wrapper->setToolShown(_abortAct, show);
788 _wrapper->setMenuShown(_pauseAct, show);
789 _wrapper->setToolShown(_pauseAct, show);
790 _wrapper->setMenuShown(_resetAct, show);
791 _wrapper->setToolShown(_resetAct, show);
792 _wrapper->setMenuShown(_saveRunStateAct, show);
793 _wrapper->setToolShown(_saveRunStateAct, show);
794 //_wrapper->setMenuShown(_newEditionAct, show);
795 //_wrapper->setToolShown(_newEditionAct, show);
796 _wrapper->setMenuShown(_withoutStopModeAct, show);
797 _wrapper->setToolShown(_withoutStopModeAct, show);
798 _wrapper->setMenuShown(_breakpointsModeAct, show);
799 _wrapper->setToolShown(_breakpointsModeAct, show);
800 _wrapper->setMenuShown(_stepByStepModeAct, show);
801 _wrapper->setToolShown(_stepByStepModeAct, show);
802 _wrapper->setMenuShown(_toggleStopOnErrorAct, show);
803 _wrapper->setToolShown(_toggleStopOnErrorAct, show);
806 void GenericGui::showCommonMenus(bool show)
808 DEBTRACE("GenericGui::showCommonMenus " << show);
809 _wrapper->setMenuShown(_toggleStraightLinksAct, show);
810 _wrapper->setToolShown(_toggleStraightLinksAct, show);
811 _wrapper->setMenuShown(_toggleAutomaticComputeLinkAct, show);
812 _wrapper->setToolShown(_toggleAutomaticComputeLinkAct, show);
813 _wrapper->setMenuShown(_toggleSimplifyLinkAct, show);
814 _wrapper->setToolShown(_toggleSimplifyLinkAct, show);
815 _wrapper->setMenuShown(_toggleForce2NodesLinkAct, show);
816 //_wrapper->setToolShown(_toggleForce2NodesLinkAct, show);
817 _wrapper->setMenuShown(_toggleAddRowColsAct, show);
818 _wrapper->setToolShown(_toggleAddRowColsAct, show);
819 _wrapper->setMenuShown(_showAllLinksAct, show);
820 _wrapper->setToolShown(_showAllLinksAct, show);
821 _wrapper->setMenuShown(_hideAllLinksAct, show);
822 _wrapper->setToolShown(_hideAllLinksAct, show);
825 void GenericGui::switchContext(QWidget *view, bool onExit)
827 DEBTRACE("GenericGui::switchContext " << view);
828 if (! _mapViewContext.count(view))
830 onExit ? hideAllMenus() : initialMenus();
831 _dwTree->setWidget(0);
832 _dwStacked->setWidget(0);
835 QtGuiContext* newContext = _mapViewContext[view];
837 _dwTree->setWidget(newContext->getEditTree());
838 _dwTree->widget()->show();
840 _dwStacked->setWidget(newContext->getStackedWidget());
842 QtGuiContext::setQtCurrent(newContext);
844 if (newContext->isEdition())
846 showExecMenus(false);
848 showEditionMenus(true);
849 showCommonMenus(true);
850 if (_dwTree) _dwTree->setWindowTitle("Tree View: edition mode");
854 showEditionMenus(false);
857 showCommonMenus(true);
858 _withoutStopModeAct->setChecked(true);
859 if (_dwTree) _dwTree->setWindowTitle("Tree View: execution mode");
861 _dwStacked->setMinimumWidth(10);
864 bool GenericGui::closeContext(QWidget *view, bool onExit)
866 DEBTRACE("GenericGui::closeContext " << onExit);
867 if (! _mapViewContext.count(view))
869 QtGuiContext* context = _mapViewContext[view];
872 bool tryToSave = false;
874 if (QtGuiContext::getQtCurrent()->isEdition())
876 if (!QtGuiContext::getQtCurrent()->_setOfModifiedSubjects.empty())
879 msgBox.setText("Some elements are modified and not taken into account.");
880 string info = "do you want to apply your changes ?\n";
881 info += " - Save : do not take into account edition in progress,\n";
882 info += " but if there are other modifications, select a file name for save\n";
883 info += " - Discard : discard all modifications and close the schema";
885 info += "\n - Cancel : do not close the schema, return to edition";
886 msgBox.setInformativeText(info.c_str());
889 msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
890 msgBox.setDefaultButton(QMessageBox::Cancel);
894 msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Discard);
895 msgBox.setDefaultButton(QMessageBox::Save);
897 int ret = msgBox.exec();
900 case QMessageBox::Save:
903 case QMessageBox::Discard:
906 case QMessageBox::Cancel:
908 DEBTRACE("Cancel or default");
914 if (QtGuiContext::getQtCurrent()->isNotSaved())
917 msgBox.setWindowTitle("Close the active schema");
918 msgBox.setText("The schema has been modified");
919 string info = "do you want to save the schema ?\n";
920 info += " - Save : select a file name for save\n";
921 info += " - Discard : discard all modifications and close the schema";
923 info += "\n - Cancel : do not close the schema, return to edition";
924 msgBox.setInformativeText(info.c_str());
927 msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
928 msgBox.setDefaultButton(QMessageBox::Cancel);
932 msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Discard);
933 msgBox.setDefaultButton(QMessageBox::Save);
935 int ret = msgBox.exec();
938 case QMessageBox::Save:
941 case QMessageBox::Discard:
944 case QMessageBox::Cancel:
945 DEBTRACE("Cancel or default");
955 if ((!onExit) && (!_isSaved)) // --- probably, user has cancelled the save dialog. Do not close
960 map<QWidget*, YACS::HMI::QtGuiContext*>::iterator it = _mapViewContext.begin();
961 QtGuiContext* newContext = 0;
962 QWidget* newView = 0;
963 for (; it != _mapViewContext.end(); ++it)
965 if ((*it).second != context)
967 newView = (*it).first;
968 newContext = (*it).second;
972 _wrapper->deleteSchema(view);
973 DEBTRACE("delete context");
974 if (GuiExecutor* exec = context->getGuiExecutor())
976 exec->closeContext();
979 _mapViewContext.erase(view);
980 switchContext(newView, onExit);
984 void GenericGui::showDockWidgets(bool isVisible)
986 DEBTRACE("GenericGui::showDockWidgets " << isVisible);
987 if (_dwTree) _dwTree->setVisible(isVisible);
988 if (_dwTree) _dwTree->toggleViewAction()->setVisible(isVisible);
989 if (_dwStacked) _dwStacked->setVisible(isVisible);
990 if (_dwStacked) _dwStacked->toggleViewAction()->setVisible(isVisible);
991 if (_dwCatalogs) _dwCatalogs->setVisible(isVisible);
992 if (_dwCatalogs) _dwCatalogs->toggleViewAction()->setVisible(isVisible);
995 void GenericGui::raiseStacked()
997 if (_dwStacked) _dwStacked->raise();
1000 std::list<std::string> GenericGui::getMachineList()
1002 if (!_machineList.empty()) return _machineList;
1004 YACS::ENGINE::RuntimeSALOME* runTime = YACS::ENGINE::getSALOMERuntime();
1005 CORBA::ORB_ptr orb = runTime->getOrb();
1006 if (!orb) return _machineList;
1008 SALOME_NamingService namingService(orb);
1009 SALOME_LifeCycleCORBA lcc(&namingService);
1011 CORBA::Object_var obj =
1012 namingService.Resolve(SALOME_ResourcesManager::_ResourcesManagerNameInNS);
1013 if (CORBA::is_nil(obj)) return _machineList;
1015 Engines::ResourcesManager_var resManager = Engines::ResourcesManager::_narrow(obj);
1016 if(!resManager) return _machineList;
1018 Engines::ResourceParameters params;
1021 Engines::ResourceList* resourceList =
1022 resManager->GetFittingResources(params);
1024 for (int i = 0; i < resourceList->length(); i++)
1026 const char* aResource = (*resourceList)[i];
1027 _machineList.push_back(aResource);
1030 return _machineList;
1033 // -----------------------------------------------------------------------------
1035 /*! a QtGuiContext instance is created for each schema in edition or each execution or run
1036 * of a schema. The context stores references of a lot of objects related to the edition
1038 * \param proc the schema to run or edit, loaded from file or just created empty.
1039 * \param schemaName filename of the schema in edition, also used in execution to publish
1040 * a run under the edition name in Salome object browser.
1041 * \param runName filename of the schema in execution, not used in edition.
1042 * \param forEdition if true, edition mode, if false, execution mode.
1044 void GenericGui::createContext(YACS::ENGINE::Proc* proc,
1045 const QString& schemaName,
1046 const QString& runName,
1049 DEBTRACE("GenericGui::createContext");
1055 QWidget* central = _parent->centralWidget();
1057 central->setFocus();
1059 DEBTRACE("No Central Widget");
1062 QWidget* refWindow = 0; // --- used only on run to refer to the schema in edition
1065 fileName = schemaName;
1070 if (QtGuiContext::getQtCurrent())
1071 refWindow = QtGuiContext::getQtCurrent()->getWindow();
1074 QtGuiContext* context = new QtGuiContext(this);
1075 QtGuiContext::setQtCurrent(context);
1079 context->setEdition(forEdition);
1080 context->setSessionCatalog(_sessionCatalog);
1081 context->setFileName(fileName);
1082 context->setCurrentCatalog(_builtinCatalog);
1084 // --- scene, viewWindow & GraphicsView
1086 Scene *scene = new Scene();
1087 QWidget *viewWindow = _wrapper->getNewWindow(scene);
1088 _mapViewContext[viewWindow] = context;
1089 GraphicsView* gView = new GraphicsView(viewWindow);
1090 gView->setScene(scene);
1091 gView->setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
1092 _wrapper->AssociateViewToWindow(gView, viewWindow);
1093 context->setScene(scene);
1094 context->setView(gView);
1095 context->setWindow(viewWindow);
1100 SchemaModel *schemaModel = new SchemaModel(context, viewWindow);
1101 schemaModel->setEdition(forEdition);
1102 context->setSchemaModel(schemaModel);
1103 RootSceneItem *rootSceneItem = new RootSceneItem(context);
1105 // --- tree associated to model
1107 FormEditTree *editTree = new FormEditTree(_dwTree);
1108 editTree->setMinimumHeight(400);
1109 _dwTree->setWidget(editTree);
1111 context->setEditTree(editTree);
1112 editTree->tv_schema->setModel(schemaModel);
1113 context->setSelectionModel(editTree->tv_schema->selectionModel());
1116 QObject::connect(editTree->tv_schema->selectionModel(),
1117 SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)),
1119 SLOT(updateSelection(const QItemSelection &, const QItemSelection &)));
1121 // --- stacked widget
1123 QStackedWidget *stacked = new QStackedWidget(_dwStacked);
1124 _dwStacked->setWidget(stacked);
1125 context->setStackedWidget(stacked);
1126 YACS::HMI::ItemEditionRoot* rootEdit = new YACS::HMI::ItemEditionRoot(context,
1128 context->getName().c_str());
1129 context->setEditionRoot(rootEdit);
1131 QObject::connect(schemaModel,
1132 SIGNAL(signalSelection(const QModelIndex &)),
1133 editTree->tv_schema,
1134 SLOT(viewSelection(const QModelIndex &)));
1138 proc->setEdition(forEdition);
1142 double passe = (end_t -start_t);
1143 passe = passe/CLOCKS_PER_SEC;
1144 DEBTRACE("create context -1- : " << passe);
1148 context->setLoading(true);
1150 context->setProc(proc);
1151 setLoadedPresentation(proc);
1155 double passe = (end_t -start_t);
1156 passe = passe/CLOCKS_PER_SEC;
1157 DEBTRACE("create context - load proc- : " << passe);
1161 context->setLoading(false);
1163 if (forEdition && _wrapper) // --- Edition mode
1165 _wrapper->createNewSchema(fileName, viewWindow);
1167 else if (_wrapper) // --- Execution Mode
1169 GuiExecutor *guiExec = new GuiExecutor(proc);
1170 context->setGuiExecutor(guiExec);
1171 _wrapper->createNewRun(schemaName, fileName, refWindow, viewWindow);
1175 QtGuiContext::getQtCurrent()->getSubjectProc()->update(UPDATE,
1176 ProcInvoc::getTypeOfNode(proc),
1177 0); // --- force validity check
1179 // --- adjust widgets
1181 TreeView *vtree = dynamic_cast<TreeView*>(editTree->tv_schema);
1183 vtree->resizeColumns();
1184 _catalogsWidget->setMinimumWidth(10); // --- reset the constraint on width
1185 editTree->setMinimumHeight(40);
1186 _dwStacked->setMinimumWidth(10);
1191 showExecMenus(false);
1192 showEditionMenus(true);
1193 showCommonMenus(true);
1194 if (_dwTree) _dwTree->setWindowTitle("Tree View: edition mode");
1198 showEditionMenus(false);
1199 showExecMenus(true);
1200 showCommonMenus(true);
1201 _withoutStopModeAct->setChecked(true);
1202 if (_dwTree) _dwTree->setWindowTitle("Tree View: execution mode");
1205 QtGuiContext::getQtCurrent()->setNotSaved(false);
1208 double passe = (end_t -start_t);
1209 passe = passe/CLOCKS_PER_SEC;
1210 DEBTRACE("create context - end - : " << passe);
1215 // -----------------------------------------------------------------------------
1217 void GenericGui::setLoadedPresentation(YACS::ENGINE::Proc* proc)
1219 DEBTRACE("GenericGui::setLoadedPresentation");
1220 QtGuiContext::getQtCurrent()->setLoadingPresentation(true);
1221 map<SceneNodeItem*, QPointF> nodesToMove;
1222 map<YACS::ENGINE::Node*, PrsData> presNodes = _loader->getPrsData(proc);
1223 if (!presNodes.empty())
1225 map<YACS::ENGINE::Node*, PrsData>::iterator it = presNodes.begin();
1226 for (; it!= presNodes.end(); ++it)
1228 YACS::ENGINE::Node* node = (*it).first;
1229 PrsData pres = (*it).second;
1230 SubjectNode *snode = QtGuiContext::getQtCurrent()->_mapOfSubjectNode[node];
1231 SceneItem *item = QtGuiContext::getQtCurrent()->_mapOfSceneItem[snode];
1233 SceneNodeItem *inode = dynamic_cast<SceneNodeItem*>(item);
1235 inode->setPos(QPointF(pres._x, pres._y));
1236 inode->setWidth(pres._width);
1237 inode->setHeight(pres._height);
1238 inode->setExpanded(pres._expanded);
1239 QPointF anExpandedPos = QPointF(pres._expx, pres._expy);
1240 if (anExpandedPos.isNull())
1241 anExpandedPos = inode->pos();
1242 inode->setExpandedPos(anExpandedPos);
1243 inode->setExpandedWH(pres._expWidth, pres._expHeight);
1244 inode->setShownState(shownState(pres._shownState));
1246 // collect nodes to correct it's Y-position if this collides with parent's header
1247 if (inode->getParent() ) {
1248 qreal anX = inode->x();
1249 qreal anY = inode->y();
1250 if (inode->getShownState() == shrinkHidden) {
1251 anX = inode->getExpandedX();
1252 anY = inode->getExpandedY();
1254 if (anY < inode->getParent()->getHeaderBottom())
1255 nodesToMove[inode] = QPointF(anX, inode->getParent()->getHeaderBottom()+1);
1259 QtGuiContext::getQtCurrent()->setLoadingPresentation(false);
1261 //after loading of presentation:
1263 //move nodes because of progress bar, if any was added
1264 map<SceneNodeItem*, QPointF>::iterator it = nodesToMove.begin();
1265 for (; it!= nodesToMove.end(); ++it)
1267 (*it).first->setTopLeft((*it).second);
1271 if (Scene::_autoComputeLinks)
1272 _guiEditor->rebuildLinks();
1275 YACS::HMI::SubjectProc* subproc = QtGuiContext::getQtCurrent()->getSubjectProc();
1276 SceneItem *item = QtGuiContext::getQtCurrent()->_mapOfSceneItem[subproc];
1277 SceneComposedNodeItem *proc = dynamic_cast<SceneComposedNodeItem*>(item);
1278 proc->updateLinks();
1282 // -----------------------------------------------------------------------------
1284 void GenericGui::onNewSchema()
1286 DEBTRACE("GenericGui::onNewSchema");
1288 std::stringstream name;
1289 name << "newSchema_" << ++_schemaCnt;
1291 YACS::ENGINE::RuntimeSALOME* runTime = YACS::ENGINE::getSALOMERuntime();
1292 YACS::ENGINE::Proc *proc = runTime->createProc(name.str());
1296 QString fileName = name.str().c_str();
1297 createContext(proc, fileName, "", true);
1300 void GenericGui::loadSchema(const std::string& filename,bool edit, bool arrangeLocalNodes)
1302 YACS::ENGINE::Proc *proc = _loader->load(filename.c_str());
1305 YACS::ENGINE::Logger* logger= proc->getLogger("parser");
1306 if(!logger->isEmpty())
1308 DEBTRACE(logger->getStr());
1310 QString fn=QString::fromUtf8(filename.c_str());
1312 createContext(proc, fn, "", true);
1314 createContext(proc, fn, fn, false);
1315 if (arrangeLocalNodes)
1317 _guiEditor->arrangeProc();
1321 void GenericGui::onImportSchema()
1326 DEBTRACE("GenericGui::onImportSchema");
1327 QFileDialog dialog(_parent,
1328 "Choose a filename to load" ,
1330 tr( "XML-Files (*.xml);;All Files (*)" ));
1332 dialog.setHistory(_wrapper->getQuickDirList());
1335 QStringList fileNames;
1338 fileNames = dialog.selectedFiles();
1339 if (!fileNames.isEmpty())
1340 fn = fileNames.first();
1343 if ( !fn.isEmpty() )
1345 // add ".xml" suffix
1347 if (!fi.exists() && fi.suffix() != "xml")
1350 DEBTRACE("file loaded : " <<fn.toUtf8().constData());
1351 YACS::ENGINE::Proc *proc = 0;
1354 proc = _loader->load(fn.toUtf8().constData());
1361 double passe = (end_t -start_t);
1362 passe = passe/CLOCKS_PER_SEC;
1363 DEBTRACE("load xml file : " << passe);
1369 QMessageBox msgBox(QMessageBox::Critical,
1370 "Import YACS Schema, native YACS XML format",
1371 "The file has not the native YACS XML format or is not readable.");
1375 YACS::ENGINE::Logger* logger= proc->getLogger("parser");
1376 if(!logger->isEmpty())
1378 DEBTRACE(logger->getStr());
1380 createContext(proc, fn, "", true);
1384 void GenericGui::onImportSupervSchema()
1386 DEBTRACE("GenericGui::onImportSupervSchema");
1387 QFileDialog dialog(_parent,
1388 "Choose a SUPERV filename to load" ,
1390 tr( "XML-Files (*.xml);;All Files (*)" ));
1392 dialog.setHistory(_wrapper->getQuickDirList());
1395 QStringList fileNames;
1398 fileNames = dialog.selectedFiles();
1399 if (!fileNames.isEmpty())
1400 fn = fileNames.first();
1403 if (fn.isEmpty()) return;
1405 // add ".xml" suffix
1407 if (!fi.exists() && fi.suffix() != "xml")
1410 DEBTRACE("file loaded : " <<fn.toStdString());
1411 QString tmpFileName;
1415 QString tmpDir = getenv("TEMP");
1416 QString fileExt = "bat";
1418 QString tmpDir = "/tmp";
1419 QString fileExt = "sh";
1421 QDir aTmpDir(tmpDir);
1422 aTmpDir.mkdir(QString("YACS_") + getenv("USER"));
1423 YASSERT(aTmpDir.cd(QString("YACS_") + getenv("USER")));
1424 QDateTime curTime = QDateTime::currentDateTime();
1425 tmpFileName = "SUPERV_import_" + curTime.toString("yyyyMMdd_hhmmss") + ".xml";
1426 QString tmpOutput = "salomeloader_output";
1427 tmpFileName = aTmpDir.absoluteFilePath(tmpFileName);
1428 DEBTRACE(tmpFileName.toStdString());
1430 QString aCall = "salomeloader."+ fileExt+ " "+ fn + " " + tmpFileName + " > " + tmpOutput;
1431 DEBTRACE(aCall.toStdString());
1433 int ret = system(aCall.toLatin1());
1436 // --- read file with logs
1437 fstream f(tmpOutput.toLatin1());
1442 // --- Problem in execution
1443 int status=WEXITSTATUS(ret);
1446 QString mes = "Problems in conversion: some errors but an incomplete proc has nevertheless been created.\n\n";
1447 mes += QString(hfile.str().c_str());
1448 QMessageBox msgBox(QMessageBox::Warning,
1449 "Import YACS Schema, SUPERV XML format",
1453 else if(status == 2)
1455 QString mes = "Problems in conversion: a fatal error has been encountered. The proc can't be created.\n\n";
1456 mes += QString(hfile.str().c_str());
1457 QMessageBox msgBox(QMessageBox::Critical,
1458 "Import YACS Schema, SUPERV XML format",
1465 DEBTRACE("Unknown problem: " << ret );
1466 QMessageBox msgBox(QMessageBox::Critical,
1467 "Import YACS Schema, SUPERV XML format",
1468 "Unexpected exception in salomeloader.");
1476 QMessageBox msgBox(QMessageBox::Critical,
1477 "Import YACS Schema, SUPERV XML format",
1478 "Unexpected exception in convertSupervFile");
1484 if (fn.isEmpty()) return; // must not happen
1486 DEBTRACE("file loaded : " <<fn.toStdString());
1487 YACS::ENGINE::Proc *proc = _loader->load(fn.toLatin1());
1490 QMessageBox msgBox(QMessageBox::Critical,
1491 "Import YACS Schema, SUPERV file converted in native YACS XML format",
1492 "The file has not the native YACS XML format or is not readable.");
1496 YACS::ENGINE::Logger* logger= proc->getLogger("parser");
1497 if(!logger->isEmpty())
1499 DEBTRACE(logger->getStr());
1501 createContext(proc, fn, "", true);
1504 //! bug confirmOverwrite : correction Qt 4.3.5
1505 QString GenericGui::getSaveFileName(const QString& fileName)
1507 QFileDialog dialog(_parent, "Save schema", fileName);
1508 QStringList filters;
1509 filters << "XML files (*.xml)"
1511 dialog.setFileMode(QFileDialog::AnyFile);
1512 dialog.setNameFilters(filters);
1513 dialog.selectNameFilter("(*.xml)");
1514 dialog.setDefaultSuffix("xml");
1515 dialog.setConfirmOverwrite(true);
1516 //dialog.setConfirmOverwrite(false); // bug Qt4.3.3
1517 dialog.setAcceptMode(QFileDialog::AcceptSave);
1518 QString selectedFile;
1519 QStringList fileNames;
1521 if (bool ret = dialog.exec())
1523 DEBTRACE(ret << " " << dialog.confirmOverwrite());
1524 fileNames = dialog.selectedFiles();
1525 if (!fileNames.isEmpty())
1526 selectedFile = fileNames.first();
1528 QString filteredName = _guiEditor->asciiFilter(selectedFile);
1529 DEBTRACE(filteredName.toStdString());
1530 return filteredName;
1533 void GenericGui::onExportSchema()
1535 DEBTRACE("GenericGui::onExportSchema");
1536 if (!QtGuiContext::getQtCurrent()) return;
1537 YACS::ENGINE::Proc* proc = QtGuiContext::getQtCurrent()->getProc();
1538 QString fo = QtGuiContext::getQtCurrent()->getFileName();
1541 if (fo.startsWith("newSchema_"))
1544 fn = getSaveFileName(fo);
1546 if (fn.isEmpty()) return;
1548 DEBTRACE("GenericGui::onExportSchema: " << fn.toUtf8().constData());
1549 //to be sure that all pending changes are effective
1550 _parent->setFocus();
1551 QtGuiContext::getQtCurrent()->setFileName(fn);
1552 VisitorSaveGuiSchema aWriter(proc);
1553 aWriter.openFileSchema( fn.toUtf8().constData() );
1554 aWriter.visitProc();
1555 aWriter.closeFileSchema();
1556 QtGuiContext::getQtCurrent()->setNotSaved(false);
1558 if (fn.compare(foo) && _wrapper)
1559 _wrapper->renameSchema(foo, fn, QtGuiContext::getQtCurrent()->getWindow());
1562 void GenericGui::onExportSchemaAs()
1564 DEBTRACE("GenericGui::onExportSchemaAs");
1566 if (!QtGuiContext::getQtCurrent()) return;
1567 YACS::ENGINE::Proc* proc = QtGuiContext::getQtCurrent()->getProc();
1568 QString fo = QtGuiContext::getQtCurrent()->getFileName();
1570 if (fo.startsWith("newSchema_")) fo.clear();
1571 QString fn = getSaveFileName(fo);
1572 if (fn.isEmpty()) return;
1574 DEBTRACE("GenericGui::onExportSchemaAs: " << fn.toUtf8().constData());
1575 QtGuiContext::getQtCurrent()->setFileName(fn);
1576 VisitorSaveGuiSchema aWriter(proc);
1577 aWriter.openFileSchema(fn.toUtf8().constData());
1578 aWriter.visitProc();
1579 aWriter.closeFileSchema();
1581 QtGuiContext::getQtCurrent()->setNotSaved(false);
1583 if (fn.compare(foo) && _wrapper)
1584 _wrapper->renameSchema(foo, fn, QtGuiContext::getQtCurrent()->getWindow());
1587 void GenericGui::onImportCatalog()
1589 DEBTRACE("GenericGui::onImportCatalog");
1590 QFileDialog dialog(_parent,
1591 "Choose a YACS Schema to load as a Catalog" ,
1593 tr( "XML-Files (*.xml);;All Files (*)" ));
1595 dialog.setHistory(_wrapper->getQuickDirList());
1598 QStringList fileNames;
1601 fileNames = dialog.selectedFiles();
1602 if (!fileNames.isEmpty())
1603 fn = fileNames.first();
1606 if ( !fn.isEmpty() )
1607 _catalogsWidget->addCatalogFromFile(fn.toStdString());
1610 void GenericGui::onRunLoadedSchema(bool withState)
1612 DEBTRACE("GenericGui::onRunLoadedSchema");
1613 if (!QtGuiContext::getQtCurrent()) return;
1619 // --- check proc state (cf. editionProc)
1621 if (!QtGuiContext::getQtCurrent()->_setOfModifiedSubjects.empty())
1623 set<Subject*>::iterator it = QtGuiContext::getQtCurrent()->_setOfModifiedSubjects.begin();
1624 (*it)->select(true);
1628 YACS::ENGINE::Proc* proc = QtGuiContext::getQtCurrent()->getProc();
1629 if (!proc->isValid())
1631 QtGuiContext::getQtCurrent()->getSubjectProc()->select(true);
1635 YACS::ENGINE::LinkInfo info(YACS::ENGINE::LinkInfo::ALL_STOP_ASAP);
1638 proc->checkConsistency(info);
1640 catch (Exception &ex)
1642 DEBTRACE(ex.what());
1643 QtGuiContext::getQtCurrent()->getSubjectProc()->select(true);
1646 if (info.areWarningsOrErrors()) return;
1650 double passe = (end_t -start_t);
1651 passe = passe/CLOCKS_PER_SEC;
1652 cerr <<"run schema -1- : " << passe << endl;
1655 // --- save proc under a run name
1657 QFileInfo fo = QtGuiContext::getQtCurrent()->getFileName();
1658 QString procName = fo.baseName();
1659 //QString tmpDir = SALOMEDS_Tool::GetTmpDir().c_str();
1661 QString tmpDir = getenv("TEMP");
1663 QString tmpDir = "/tmp";
1665 QDir aTmpDir(tmpDir);
1666 aTmpDir.mkdir(QString("YACS_") + getenv("USER"));
1667 YASSERT(aTmpDir.cd(QString("YACS_") + getenv("USER")));
1668 QDateTime curTime = QDateTime::currentDateTime();
1669 QString aRunName = procName + "_" + curTime.toString("yyyyMMdd_hhmmss") + ".xml";
1670 aRunName = aTmpDir.absoluteFilePath(aRunName);
1671 DEBTRACE(aRunName.toStdString());
1673 VisitorSaveGuiSchema aWriter(proc);
1674 aWriter.openFileSchema(aRunName.toStdString());
1675 aWriter.visitProc();
1676 aWriter.closeFileSchema();
1678 // --- create a run context
1680 YACS::ENGINE::Proc *procrun = _loader->load(aRunName.toLatin1());
1683 double passe = (end_t -start_t);
1684 passe = passe/CLOCKS_PER_SEC;
1685 cerr <<"run schema -2- : " << passe << endl;
1688 createContext(procrun, QtGuiContext::getQtCurrent()->getFileName(), aRunName, false);
1690 // load state if required
1692 GuiExecutor *executor = QtGuiContext::getQtCurrent()->getGuiExecutor();
1693 if (!executor) return;
1696 QString fn = QFileDialog::getOpenFileName( _parent,
1697 "Choose a previous run state to load" ,
1699 tr( "XML-Files (*.xml);;All Files (*)" ));
1702 DEBTRACE("run state to load: " <<fn.toStdString());
1703 executor->setLoadStateFile(fn.toStdString());
1706 executor->startResumeDataflow(true); // --- initialise gui state
1707 if(_toggleStopOnErrorAct->isChecked())
1708 executor->setStopOnError(false);
1711 void GenericGui::onLoadRunStateSchema()
1713 DEBTRACE("GenericGui::onLoadRunStateSchema");
1714 onRunLoadedSchema(true);
1717 void GenericGui::onLoadAndRunSchema()
1719 DEBTRACE("GenericGui::onLoadAndRunSchema");
1720 QString fn = QFileDialog::getOpenFileName( _parent,
1721 "Choose a filename to load" ,
1723 tr( "XML-Files (*.xml);;All Files (*)" ));
1724 if ( !fn.isEmpty() )
1726 // add ".xml" suffix
1728 if (!fi.exists() && fi.suffix() != "xml")
1731 DEBTRACE("file loaded : " <<fn.toStdString());
1732 YACS::ENGINE::Proc *proc =0;
1735 proc = _loader->load(fn.toLatin1());
1742 QMessageBox msgBox(QMessageBox::Critical,
1743 "Import YACS Schema, native YACS XML format",
1744 "The file has not the native YACS XML format or is not readable.");
1748 YACS::ENGINE::Logger* logger= proc->getLogger("parser");
1749 if(!logger->isEmpty())
1751 DEBTRACE(logger->getStr());
1753 createContext(proc, fn, "", true);
1754 onRunLoadedSchema();
1758 void GenericGui::onChooseBatchJob() {
1759 DEBTRACE("GenericGui::onChooseBatchJob");
1761 // Show the Batch Jobs list
1762 if(_BJLdialog) delete _BJLdialog;
1763 _BJLdialog = new BatchJobsListDialog(tr("Select one Batch Job to watch"),this);
1765 _BJLdialog->move(300,200);
1766 _BJLdialog->resize(450,200);
1770 void GenericGui::onStartResume()
1772 DEBTRACE("GenericGui::onStartResume");
1773 if (!QtGuiContext::getQtCurrent()) return;
1774 if (!QtGuiContext::getQtCurrent()->getGuiExecutor()) return;
1775 QtGuiContext::getQtCurrent()->getGuiExecutor()->startResumeDataflow();
1778 void GenericGui::onAbort()
1780 DEBTRACE("GenericGui::onAbort");
1781 if (!QtGuiContext::getQtCurrent()) return;
1782 if (!QtGuiContext::getQtCurrent()->getGuiExecutor()) return;
1783 QtGuiContext::getQtCurrent()->getGuiExecutor()->killDataflow();
1786 void GenericGui::onPause()
1788 DEBTRACE("GenericGui::onPause");
1789 if (!QtGuiContext::getQtCurrent()) return;
1790 if (!QtGuiContext::getQtCurrent()->getGuiExecutor()) return;
1791 QtGuiContext::getQtCurrent()->getGuiExecutor()->suspendDataflow();
1794 void GenericGui::onReset()
1796 DEBTRACE("GenericGui::onReset");
1797 if (!QtGuiContext::getQtCurrent()) return;
1798 if (!QtGuiContext::getQtCurrent()->getGuiExecutor()) return;
1799 QtGuiContext::getQtCurrent()->getGuiExecutor()->resetDataflow();
1802 void GenericGui::onSaveRunState()
1804 DEBTRACE("GenericGui::onSaveRunState");
1805 if (!QtGuiContext::getQtCurrent()) return;
1806 if (!QtGuiContext::getQtCurrent()->getGuiExecutor()) return;
1807 QDateTime curTime = QDateTime::currentDateTime();
1808 QFileInfo procName = QtGuiContext::getQtCurrent()->getFileName();
1809 QString stateName = procName.baseName();
1810 DEBTRACE(stateName.toStdString());
1811 stateName += "_state_" + curTime.toString("yyyyMMdd_hhmmss") + ".xml";
1812 DEBTRACE(stateName.toStdString());
1813 stateName = getSaveFileName(stateName);
1814 DEBTRACE(stateName.toStdString());
1815 if (!stateName.isEmpty())
1816 QtGuiContext::getQtCurrent()->getGuiExecutor()->saveState(stateName.toStdString());
1819 void GenericGui::onNewEdition()
1821 DEBTRACE("GenericGui::onNewEdition");
1822 // if (!QtGuiContext::getQtCurrent()) return;
1823 // if (!QtGuiContext::getQtCurrent()->getGuiExecutor()) return;
1824 // QtGuiContext::getQtCurrent()->getGuiExecutor()->resetDataflow();
1827 void GenericGui::onGetYacsContainerLog()
1829 DEBTRACE("GenericGui::onGetYacsContainerLog");
1830 if (!QtGuiContext::getQtCurrent()) return;
1831 if (!QtGuiContext::getQtCurrent()->getGuiExecutor()) return;
1832 string log = QtGuiContext::getQtCurrent()->getGuiExecutor()->getContainerLog();
1833 ContainerLogViewer *lv = new ContainerLogViewer("YACS Container Log", _parent);
1838 void GenericGui::onGetErrorReport()
1840 DEBTRACE("GenericGui::onGetErrorReport");
1841 if (!QtGuiContext::getQtCurrent()) return;
1842 Subject *sub = QtGuiContext::getQtCurrent()->getSelectedSubject();
1843 SubjectNode *snode = dynamic_cast<SubjectNode*>(sub);
1846 if (QtGuiContext::getQtCurrent()->getGuiExecutor())
1848 log = QtGuiContext::getQtCurrent()->getGuiExecutor()->getErrorReport(snode->getNode());
1852 log = snode->getNode()->getErrorReport();
1855 LogViewer *lv = new LogViewer("Node error report", _parent);
1860 void GenericGui::onGetErrorDetails()
1862 DEBTRACE("GenericGui::onGetErrorDetails");
1863 if (!QtGuiContext::getQtCurrent()) return;
1864 Subject *sub = QtGuiContext::getQtCurrent()->getSelectedSubject();
1865 SubjectNode *snode = dynamic_cast<SubjectNode*>(sub);
1868 if (QtGuiContext::getQtCurrent()->getGuiExecutor())
1870 log = QtGuiContext::getQtCurrent()->getGuiExecutor()->getErrorDetails(snode->getNode());
1874 log = snode->getNode()->getErrorDetails();
1877 LogViewer *lv = new LogViewer("Node Error Details", _parent);
1882 void GenericGui::onGetContainerLog()
1884 DEBTRACE("GenericGui::onGetContainerLog");
1885 if (!QtGuiContext::getQtCurrent()) return;
1886 if (!QtGuiContext::getQtCurrent()->getGuiExecutor()) return;
1887 Subject *sub = QtGuiContext::getQtCurrent()->getSelectedSubject();
1888 SubjectElementaryNode *snode = dynamic_cast<SubjectElementaryNode*>(sub);
1890 string log = QtGuiContext::getQtCurrent()->getGuiExecutor()->getContainerLog(snode->getNode());
1892 LogViewer *lv = new LogViewer("Node Container Log", _parent);
1896 if (dynamic_cast<YACS::ENGINE::ServiceNode*>(snode->getNode()))
1898 info +="The container log of this node\n";
1899 info += "is not stored in a file and \n";
1900 info += "can't be displayed here, \n";
1901 info += "but you can have a look at \n";
1902 info += "the SALOME standard output,\n";
1903 info += "on your terminal...";
1907 info += "See YACS Container log \n";
1908 info += "(on main proc menu) \n";
1909 info += "for all inline nodes";
1918 void GenericGui::onShutdownProc()
1920 DEBTRACE("GenericGui::onShutdownProc");
1921 if (!QtGuiContext::getQtCurrent()) return;
1922 if (!QtGuiContext::getQtCurrent()->getGuiExecutor()) return;
1923 QtGuiContext::getQtCurrent()->getGuiExecutor()->shutdownProc();
1926 void GenericGui::onEditDataTypes()
1928 DEBTRACE("GenericGui::onEditDataTypes");
1931 void GenericGui::onCreateDataType()
1933 DEBTRACE("GenericGui::onCreateDataType");
1936 void GenericGui::onImportDataType()
1938 DEBTRACE("GenericGui::onImportDataType");
1939 if (_dwCatalogs) _dwCatalogs->raise();
1942 void GenericGui::onSelectComponentInstance()
1944 DEBTRACE("GenericGui::onSelectComponentInstance");
1945 Subject *sub = QtGuiContext::getQtCurrent()->getSelectedSubject();
1947 SubjectComponent *ref = dynamic_cast<SubjectComponent*>(sub);
1949 YACS::ENGINE::ComponentInstance* compo=ref->getComponent();
1950 QtGuiContext::getQtCurrent()->_mapOfLastComponentInstance[compo->getCompoName()]=compo;
1953 void GenericGui::onNewContainer()
1955 DEBTRACE("GenericGui::onNewContainer");
1956 _guiEditor->CreateContainer();
1959 void GenericGui::onNewHPContainer()
1961 DEBTRACE("GenericGui::onNewHPContainer");
1962 _guiEditor->CreateHPContainer();
1965 void GenericGui::onNewSalomeComponent()
1967 DEBTRACE("GenericGui::onNewSalomeComponent");
1968 _guiEditor->CreateComponentInstance();
1971 void GenericGui::onNewSalomePythonComponent()
1973 DEBTRACE("GenericGui::onNewSalomePythonComponent");
1976 void GenericGui::onNewCorbaComponent()
1978 DEBTRACE("GenericGui::onNewCorbaComponent");
1982 void GenericGui::onSalomeServiceNode()
1984 DEBTRACE("GenericGui::onSalomeServiceNode");
1985 _guiEditor->CreateNode("SalomeNode");
1988 void GenericGui::onServiceInlineNode()
1990 DEBTRACE("GenericGui::onServiceInlineNode");
1991 _guiEditor->CreateNode("SalomePythonNode");
1994 void GenericGui::onCORBAServiceNode()
1996 DEBTRACE("GenericGui::onCORBAServiceNode");
1997 _guiEditor->CreateNode("CORBANode");
2000 void GenericGui::onNodeNodeServiceNode()
2002 DEBTRACE("GenericGui::onNodeNodeServiceNode");
2005 void GenericGui::onCppNode()
2007 DEBTRACE("GenericGui::onCppNode");
2008 _guiEditor->CreateNode("CppNode");
2011 void GenericGui::onXMLNode()
2013 DEBTRACE("GenericGui::onXMLNode");
2014 _guiEditor->CreateNode("XmlNode");
2017 void GenericGui::onInDataNode()
2019 DEBTRACE("GenericGui::onInDataNode");
2020 _guiEditor->CreateNode("PresetNode");
2023 void GenericGui::onOutDataNode()
2025 DEBTRACE("GenericGui::onOutDataNode");
2026 _guiEditor->CreateNode("OutNode");
2029 void GenericGui::onInStudyNode()
2031 DEBTRACE("GenericGui::onInStudyNode");
2032 _guiEditor->CreateNode("StudyInNode");
2035 void GenericGui::onOutStudyNode()
2037 DEBTRACE("GenericGui::onOutStudyNode");
2038 _guiEditor->CreateNode("StudyOutNode");
2041 void GenericGui::onInlineScriptNode()
2043 DEBTRACE("GenericGui::onInlineScriptNode");
2044 _guiEditor->CreateNode("PyScript");
2047 void GenericGui::onInlineFunctionNode()
2049 DEBTRACE("GenericGui::onInlineFunctionNode");
2050 _guiEditor->CreateNode("PyFunction");
2053 void GenericGui::onBlockNode()
2055 DEBTRACE("GenericGui::onBlockNode");
2056 _guiEditor->CreateBloc();
2059 void GenericGui::onFORNode()
2061 DEBTRACE("GenericGui::onFORNode");
2062 _guiEditor->CreateForLoop();
2065 void GenericGui::onFOREACHNode()
2067 DEBTRACE("GenericGui::onFOREACHNode");
2068 createForEachLoop("double");
2071 void GenericGui::createForEachLoop(std::string type)
2073 DEBTRACE("GenericGui::createForEachLoop");
2074 _guiEditor->CreateForEachLoop(type);
2077 void GenericGui::onWHILENode()
2079 DEBTRACE("GenericGui::onWHILENode");
2080 _guiEditor->CreateWhileLoop();
2083 void GenericGui::onSWITCHNode()
2085 DEBTRACE("GenericGui::onSWITCHNode");
2086 _guiEditor->CreateSwitch();
2089 void GenericGui::onOptimizerLoop()
2091 DEBTRACE("GenericGui::onOptimizerLoop");
2092 _guiEditor->CreateOptimizerLoop();
2095 void GenericGui::onNodeFromCatalog()
2097 DEBTRACE("GenericGui::onNodeFromCatalog");
2098 if (_dwCatalogs) _dwCatalogs->raise();
2101 void GenericGui::onDeleteItem()
2103 DEBTRACE("GenericGui::onDeleteItem");
2104 _guiEditor->DeleteSubject();
2107 void GenericGui::onCutItem()
2109 DEBTRACE("GenericGui::onCutItem");
2110 _guiEditor->CutSubject();
2113 void GenericGui::onCopyItem()
2115 DEBTRACE("GenericGui::onCopyItem");
2116 _guiEditor->CopySubject();
2119 void GenericGui::onPasteItem()
2121 DEBTRACE("GenericGui::onPasteItem");
2122 _guiEditor->PasteSubject();
2125 void GenericGui::onPutInBloc()
2127 _guiEditor->PutSubjectInBloc();
2130 void GenericGui::onPutGraphInBloc()
2132 DEBTRACE("GenericGui::onPutGraphInBloc");
2133 _guiEditor->PutGraphInBloc();
2134 _guiEditor->arrangeNodes(false);
2137 void GenericGui::onPutGraphInForLoop()
2139 DEBTRACE("GenericGui::onPutGraphInForLoop");
2140 _guiEditor->PutGraphInNode("ForLoop");
2143 void GenericGui::putGraphInForeachLoop(std::string type)
2145 DEBTRACE("GenericGui::PutGraphInForeachLoop");
2146 _guiEditor->PutGraphInNode("ForEachLoop_"+type);
2149 void GenericGui::onPutGraphInWhileLoop()
2151 DEBTRACE("GenericGui::onPutGraphInWhileLoop");
2152 _guiEditor->PutGraphInNode("WhileLoop");
2155 void GenericGui::onPutGraphInOptimizerLoop()
2157 DEBTRACE("GenericGui::onPutGraphInOptimizerLoop");
2158 _guiEditor->PutGraphInNode("OptimizerLoop");
2161 void GenericGui::onArrangeLocalNodes()
2163 DEBTRACE("GenericGui::onArrangeLocalNodes");
2164 _guiEditor->arrangeNodes(false);
2167 void GenericGui::onArrangeRecurseNodes()
2169 DEBTRACE("GenericGui::onArrangeRecurseNodes");
2170 _guiEditor->arrangeNodes(true);
2173 void GenericGui::onRebuildLinks()
2175 DEBTRACE("GenericGui::onRebuildLinks");
2176 _guiEditor->rebuildLinks();
2179 void GenericGui::onZoomToBloc()
2181 DEBTRACE("GenericGui::onZoomToBloc");
2182 QtGuiContext::getQtCurrent()->getView()->onZoomToBloc();
2185 void GenericGui::onCenterOnNode()
2187 DEBTRACE("GenericGui::onCenterOnNode");
2188 QtGuiContext::getQtCurrent()->getView()->onCenterOnNode();
2191 void GenericGui::onShrinkExpand() {
2192 DEBTRACE("GenericGui::onShrinkExpand");
2193 _guiEditor->shrinkExpand();
2196 void GenericGui::onShrinkExpandChildren() {
2197 DEBTRACE("GenericGui::onShrinkExpandChildren");
2198 _guiEditor->shrinkExpand(Qt::ControlModifier|Qt::ShiftModifier);
2201 void GenericGui::onShrinkExpandElementaryRecursively() {
2202 DEBTRACE("GenericGui::onShrinkExpandElementaryRecursively");
2203 _guiEditor->shrinkExpand(Qt::ControlModifier);
2206 void GenericGui::onToggleStraightLinks(bool checked)
2208 Scene::_straightLinks = checked;
2209 DEBTRACE("Scene::_straightLinks=" << checked);
2210 if (!QtGuiContext::getQtCurrent())
2212 map<Subject*, SchemaItem*>::const_iterator it = QtGuiContext::getQtCurrent()->_mapOfSchemaItem.begin();
2213 for( ; it != QtGuiContext::getQtCurrent()->_mapOfSchemaItem.end(); ++it)
2215 Subject* sub = (*it).first;
2216 sub->update(SWITCHSHAPE, 0, 0);
2220 void GenericGui::onToggleAutomaticComputeLinks(bool checked)
2222 Scene::_autoComputeLinks = checked;
2223 DEBTRACE("Scene::_autoComputeLinks=" << checked);
2226 void GenericGui::onToggleSimplifyLinks(bool checked)
2228 Scene::_simplifyLinks = checked;
2229 DEBTRACE("Scene::_simplifyLinks=" << checked);
2232 void GenericGui::onToggleForce2NodesLinks(bool checked)
2234 Scene::_force2NodesLink = checked;
2235 DEBTRACE("Scene::_force2NodesLink=" << checked);
2238 void GenericGui::onToggleAddRowCols(bool checked)
2240 Scene::_addRowCols = checked;
2241 DEBTRACE("Scene::_addRowCols=" << checked);
2244 void GenericGui::onSelectReference()
2246 Subject *sub = QtGuiContext::getQtCurrent()->getSelectedSubject();
2248 SubjectReference *ref = dynamic_cast<SubjectReference*>(sub);
2250 SubjectServiceNode *snode = dynamic_cast<SubjectServiceNode*>(ref->getReference());
2251 snode->select(true);
2254 void GenericGui::onWhatsThis()
2256 DEBTRACE("GenericGui::onWhatsThis");
2257 QWhatsThis::enterWhatsThisMode();
2260 void GenericGui::onWithoutStopMode(bool checked)
2262 DEBTRACE("GenericGui::onWithoutStopMode " << checked);
2263 if (!QtGuiContext::getQtCurrent()) return;
2264 if (!QtGuiContext::getQtCurrent()->getGuiExecutor()) return;
2265 if (checked) QtGuiContext::getQtCurrent()->getGuiExecutor()->setContinueMode();
2268 void GenericGui::onBreakpointsMode(bool checked)
2270 DEBTRACE("GenericGui::onWithoutStopMode " << checked);
2271 if (!QtGuiContext::getQtCurrent()) return;
2272 if (!QtGuiContext::getQtCurrent()->getGuiExecutor()) return;
2273 if (checked) QtGuiContext::getQtCurrent()->getGuiExecutor()->setBreakpointMode();
2276 void GenericGui::onStepByStepMode(bool checked)
2278 DEBTRACE("GenericGui::onWithoutStopMode " << checked);
2279 if (!QtGuiContext::getQtCurrent()) return;
2280 if (!QtGuiContext::getQtCurrent()->getGuiExecutor()) return;
2281 if (checked) QtGuiContext::getQtCurrent()->getGuiExecutor()->setStepByStepMode();
2284 void GenericGui::onToggleStopOnError(bool checked)
2286 DEBTRACE("GenericGui::onToggleStopOnError " << checked);
2287 if (!QtGuiContext::getQtCurrent()) return;
2288 if (!QtGuiContext::getQtCurrent()->getGuiExecutor()) return;
2290 QtGuiContext::getQtCurrent()->getGuiExecutor()->setStopOnError(false);
2292 QtGuiContext::getQtCurrent()->getGuiExecutor()->unsetStopOnError();
2295 void GenericGui::onToggleSceneItemVisible(bool checked)
2297 DEBTRACE("GenericGui::onToggleSceneItemVisible " << checked);
2298 if (!QtGuiContext::getQtCurrent()) return;
2299 Subject *sub = QtGuiContext::getQtCurrent()->getSelectedSubject();
2300 SubjectNode *snode = dynamic_cast<SubjectNode*>(sub);
2303 if (!QtGuiContext::getQtCurrent()->_mapOfSceneItem.count(sub)) return;
2305 SceneItem *item = QtGuiContext::getQtCurrent()->_mapOfSceneItem[sub];
2306 item->setVisible(checked);
2309 void GenericGui::displayLinks(bool isShown)
2311 if (!QtGuiContext::getQtCurrent()) return;
2312 map<pair<YACS::ENGINE::OutPort*, YACS::ENGINE::InPort*>,YACS::HMI::SubjectLink*>::const_iterator it;
2313 for (it = QtGuiContext::getQtCurrent()->_mapOfSubjectLink.begin();
2314 it != QtGuiContext::getQtCurrent()->_mapOfSubjectLink.end();
2317 YACS::HMI::SubjectLink* sub = (*it).second;
2319 SceneItem *item = QtGuiContext::getQtCurrent()->_mapOfSceneItem[sub];
2320 item->setVisible(isShown);
2324 void GenericGui::displayControlLinks(bool isShown)
2326 if (!QtGuiContext::getQtCurrent()) return;
2327 map<pair<YACS::ENGINE::Node*, YACS::ENGINE::Node*>,YACS::HMI::SubjectControlLink*>::const_iterator it;
2328 for (it = QtGuiContext::getQtCurrent()->_mapOfSubjectControlLink.begin();
2329 it != QtGuiContext::getQtCurrent()->_mapOfSubjectControlLink.end();
2332 YACS::HMI::SubjectControlLink* sub = (*it).second;
2334 SceneItem *item = QtGuiContext::getQtCurrent()->_mapOfSceneItem[sub];
2335 item->setVisible(isShown);
2339 void GenericGui::displayPortLinks(bool isShown)
2341 Subject *sub = QtGuiContext::getQtCurrent()->getSelectedSubject();
2342 DEBTRACE("displayPortLinks, subject : " << sub->getName());
2343 SubjectDataPort *sport = dynamic_cast<SubjectDataPort*>(sub);
2346 DEBTRACE("dataPort : " << sport->getName());
2347 list<SubjectLink*> linkList = sport->getListOfSubjectLink();
2348 list<SubjectLink*>::const_iterator it = linkList.begin();
2349 for( ; it != linkList.end(); ++it)
2351 YACS::HMI::SubjectLink* sub = (*it);
2353 SceneItem *item = QtGuiContext::getQtCurrent()->_mapOfSceneItem[sub];
2354 item->setVisible(isShown);
2358 SubjectNode *snode = dynamic_cast<SubjectNode*>(sub);
2361 DEBTRACE("Node : " << snode->getName());
2362 list<SubjectControlLink*> linkList = snode->getSubjectControlLinks();
2363 list<SubjectControlLink*>::const_iterator it = linkList.begin();
2364 for( ; it != linkList.end(); ++it)
2366 YACS::HMI::SubjectControlLink* sub = (*it);
2368 SceneItem *item = QtGuiContext::getQtCurrent()->_mapOfSceneItem[sub];
2369 item->setVisible(isShown);
2375 void GenericGui::displayALink(bool isShown)
2377 Subject *sub = QtGuiContext::getQtCurrent()->getSelectedSubject();
2378 if (! QtGuiContext::getQtCurrent()->_mapOfSceneItem.count(sub)) return;
2379 SceneItem *item = QtGuiContext::getQtCurrent()->_mapOfSceneItem[sub];
2380 item->setVisible(isShown);
2383 void GenericGui::onShowAllLinks()
2385 DEBTRACE("GenericGui::onShowAllLinks");
2387 displayControlLinks(true);
2390 void GenericGui::onHideAllLinks()
2392 DEBTRACE("GenericGui::onHideAllLinks");
2393 displayLinks(false);
2394 displayControlLinks(false);
2397 void GenericGui::onShowOnlyPortLinks()
2399 DEBTRACE("GenericGui::onShowOnlyPortLinks");
2401 displayPortLinks(true);
2404 void GenericGui::onShowPortLinks()
2406 DEBTRACE("GenericGui::onShowPortLinks");
2407 displayPortLinks(true);
2410 void GenericGui::onHidePortLinks()
2412 DEBTRACE("GenericGui::onHidePortLinks");
2413 displayPortLinks(false);
2416 void GenericGui::onEmphasisPortLinks()
2418 DEBTRACE("GenericGui::onEmphasisPortLinks");
2419 if (!QtGuiContext::getQtCurrent()) return;
2420 Subject *sub = QtGuiContext::getQtCurrent()->getSelectedSubject();
2421 DEBTRACE("EmphasizePortLinks, subject : " << sub->getName());
2425 SubjectDataPort *sport = dynamic_cast<SubjectDataPort*>(sub);
2428 emphasizePortLink(sport, true);
2432 // --- if a Node, explore all data ports
2434 SubjectNode *snode = dynamic_cast<SubjectNode*>(sub);
2437 DEBTRACE("Node : " << snode->getName());
2439 list<SubjectInputPort*> linkList = snode->getSubjectInputPorts();
2440 list<SubjectInputPort*>::const_iterator it = linkList.begin();
2441 for( ; it != linkList.end(); ++it)
2443 YACS::HMI::SubjectInputPort* sub = (*it);
2445 emphasizePortLink(sub, true);
2449 list<SubjectOutputPort*> linkList = snode->getSubjectOutputPorts();
2450 list<SubjectOutputPort*>::const_iterator it = linkList.begin();
2451 for( ; it != linkList.end(); ++it)
2453 YACS::HMI::SubjectOutputPort* sub = (*it);
2455 emphasizePortLink(sub, true);
2462 void GenericGui::onShowOnlyCtrlLinks()
2464 DEBTRACE("GenericGui::onShowOnlyCtrlLinks");
2466 displayPortLinks(true);
2469 void GenericGui::onShowCtrlLinks()
2471 DEBTRACE("GenericGui::onShowCtrlLinks");
2472 displayPortLinks(true);
2475 void GenericGui::onHideCtrlLinks()
2477 DEBTRACE("GenericGui::onHideCtrlLinks");
2478 displayPortLinks(false);
2481 void GenericGui::onEmphasisCtrlLinks()
2483 DEBTRACE("GenericGui::onEmphasisCtrlLinks");
2484 Subject *sub = QtGuiContext::getQtCurrent()->getSelectedSubject();
2485 DEBTRACE("Emphasize Ctrl Links, subject : " << sub->getName());
2488 SubjectNode *snode = dynamic_cast<SubjectNode*>(sub);
2491 DEBTRACE("Node : " << snode->getName());
2492 list<SubjectControlLink*> linkList = snode->getSubjectControlLinks();
2493 list<SubjectControlLink*>::const_iterator it = linkList.begin();
2494 for( ; it != linkList.end(); ++it)
2496 YACS::HMI::SubjectControlLink* sub = (*it);
2498 sub->update(EMPHASIZE, true, sub);
2499 Subject *sin = sub->getSubjectInNode();
2500 Subject *sout = sub->getSubjectOutNode();
2501 sin->update(EMPHASIZE, true, sub);
2502 sout->update(EMPHASIZE, true, sub);
2508 void GenericGui::onShowOnlyLink()
2510 DEBTRACE("GenericGui::onShowOnlyLink");
2515 void GenericGui::onShowLink()
2517 DEBTRACE("GenericGui::onShowLink");
2521 void GenericGui::onHideLink()
2523 DEBTRACE("GenericGui::onHideLink");
2524 displayALink(false);
2527 void GenericGui::onEmphasisLink()
2529 DEBTRACE("GenericGui::onEmphasisLink");
2530 Subject *sub = QtGuiContext::getQtCurrent()->getSelectedSubject();
2533 sub->update(EMPHASIZE, true, sub);
2536 void GenericGui::onDeEmphasizeAll()
2538 DEBTRACE("GenericGui::onDeEmphasizeAll");
2539 map<Subject*, SchemaItem*>::const_iterator it = QtGuiContext::getQtCurrent()->_mapOfSchemaItem.begin();
2540 for( ; it != QtGuiContext::getQtCurrent()->_mapOfSchemaItem.end(); ++it)
2542 Subject* sub = (*it).first;
2543 sub->update(EMPHASIZE, false, sub);
2547 void GenericGui::onUndo()
2549 DEBTRACE("GenericGui::onUndo");
2550 if (QtGuiContext::getQtCurrent()->_setOfModifiedSubjects.empty())
2552 QtGuiContext::getQtCurrent()->getInvoc()->undo();
2553 // Empty the clipboard in order to avoid the copy of a destroyed object.
2554 QtGuiContext::getQtCurrent()->setSubjectToCopy(NULL);
2556 else Message("undo not possible when there are local modifications not confirmed");
2559 void GenericGui::onRedo()
2561 DEBTRACE("GenericGui::onRedo");
2562 if (QtGuiContext::getQtCurrent()->_setOfModifiedSubjects.empty())
2564 QtGuiContext::getQtCurrent()->getInvoc()->redo();
2565 // Empty the clipboard in order to avoid the copy of a destroyed object.
2566 QtGuiContext::getQtCurrent()->setSubjectToCopy(NULL);
2568 else Message("redo not possible when there are local modifications not confirmed");
2571 void GenericGui::onShowUndo()
2573 _guiEditor->showUndo(_parent);
2576 void GenericGui::onShowRedo()
2578 _guiEditor->showRedo(_parent);
2581 void GenericGui::onCleanOnExit()
2583 DEBTRACE("GenericGui::onCleanOnExit");
2584 map<QWidget*, YACS::HMI::QtGuiContext*> mapViewContextCopy = _mapViewContext;
2585 map<QWidget*, YACS::HMI::QtGuiContext*>::iterator it = mapViewContextCopy.begin();
2586 for (; it != mapViewContextCopy.end(); ++it)
2588 closeContext((*it).first, true);
2592 void GenericGui::emphasizePortLink(YACS::HMI::SubjectDataPort* sub, bool emphasize)
2594 DEBTRACE("dataPort : " << sub->getName());
2595 list<SubjectLink*> linkList = sub->getListOfSubjectLink();
2596 list<SubjectLink*>::const_iterator it = linkList.begin();
2597 for( ; it != linkList.end(); ++it)
2599 YACS::HMI::SubjectLink* subli = (*it);
2600 if (!subli) continue;
2601 subli->update(EMPHASIZE, emphasize, sub);
2602 Subject *sin = subli->getSubjectInPort();
2603 Subject *sout = subli->getSubjectOutPort();
2604 sin->update(EMPHASIZE, emphasize, sub);
2605 sout->update(EMPHASIZE, emphasize, sub);
2609 void GenericGui::onHelpContextModule( const QString& theComponentName, const QString& theFileName, const QString& theContext)
2611 _wrapper->onHelpContextModule(theComponentName,theFileName,theContext);