1 // Copyright (C) 2006-2013 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.
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 _parent->addDockWidget(Qt::LeftDockWidgetArea, _dwTree);
157 _dwStacked = new QDockWidget(_parent);
158 _dwStacked->setVisible(false);
159 _dwStacked->setWindowTitle("Input Panel");
160 _dwStacked->setMinimumWidth(270); // --- force a minimum until display
161 _parent->addDockWidget(Qt::RightDockWidgetArea, _dwStacked);
162 _dwCatalogs = new QDockWidget(_parent);
163 _dwCatalogs->setVisible(false);
164 _dwCatalogs->setWindowTitle("Catalogs");
165 _parent->addDockWidget(Qt::RightDockWidgetArea, _dwCatalogs);
166 _catalogsWidget = new CatalogWidget(_dwCatalogs,
169 _dwCatalogs->setWidget(_catalogsWidget);
171 _parent->tabifyDockWidget(_dwStacked, _dwCatalogs);
172 _parent->tabifyDockWidget(_dwTree, _wrapper->objectBrowser());
173 #if QT_VERSION >= 0x040500
174 _parent->setTabPosition(Qt::AllDockWidgetAreas, Resource::tabPanelsUp? QTabWidget::North: QTabWidget::South);
176 //Import user catalog
177 std::string usercata=Resource::userCatalog.toStdString();
178 _catalogsWidget->addCatalogFromFile(usercata);
181 GenericGui::~GenericGui()
183 if(_BJLdialog) delete _BJLdialog;
186 void GenericGui::createActions()
188 // QAction* createAction(const int id,
189 // const QString& toolTip,
190 // const QIcon& icon,
191 // const QString& menu,
192 // const QString& status,
193 // const int shortCut,
194 // QObject* parent =0,
195 // bool checkable = false,
196 // QObject* receiver =0,
197 // const char* member =0);
199 _newSchemaAct = _wrapper->createAction(getMenuId(), tr("Create a new YACS Schema"), QIcon("icons:schema.png"),
200 tr("New Schema"), tr("Create a new YACS Schema"),
201 0, _parent, false, this, SLOT(onNewSchema()));
202 _newSchemaAct->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_N); // --- QKeySequence::New ambiguous in SALOME
204 _importSchemaAct = _wrapper->createAction(getMenuId(), tr("Import a YACS Schema for edition"), QIcon("icons:import_dataflow.png"),
205 tr("Import Schema"), tr("Import a YACS Schema for edition"),
206 0, _parent, false, this, SLOT(onImportSchema()));
207 _importSchemaAct->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_O); // --- QKeySequence::Open ambiguous in SALOME
209 _importSupervSchemaAct = _wrapper->createAction(getMenuId(), tr("Import a SUPERV Schema for edition"), QIcon("icons:import_superv_dataflow.png"),
210 tr("Import SUPERV Schema"), tr("Import a SUPERV Schema for edition"),
211 0, _parent, false, this, SLOT(onImportSupervSchema()));
213 _exportSchemaAct = _wrapper->createAction(getMenuId(), tr("Save the current YACS Schema"), QIcon("icons:save_dataflow.png"),
214 tr("Save Schema"), tr("Save the current YACS Schema"),
215 0, _parent, false, this, SLOT(onExportSchema()));
216 _exportSchemaAct->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_S); // --- QKeySequence::Save ambiguous in SALOME
218 _exportSchemaAsAct = _wrapper->createAction(getMenuId(), tr("Save the current YACS Schema As..."), QIcon("icons:export_dataflow.png"),
219 tr("Save Schema As"), tr("Save the current YACS Schema As..."),
220 0, _parent, false, this, SLOT(onExportSchemaAs()));
221 //_exportSchemaAsAct->setShortcut(QKeySequence::SaveAs); // --- ambiguous in SALOME
223 _importCatalogAct = _wrapper->createAction(getMenuId(), tr("Import a Schema as a Catalog"), QIcon("icons:insert_file.png"),
224 tr("Import Catalog"), tr("Import a Schema as a Catalog"),
225 0, _parent, false, this, SLOT(onImportCatalog()));
228 _runLoadedSchemaAct = _wrapper->createAction(getMenuId(), tr("Prepare the current edited schema for run"), QIcon("icons:run_active.png"),
229 tr("Run Current Schema"), tr("Prepare the current edited schema for run"),
230 0, _parent, false, this, SLOT(onRunLoadedSchema()));
232 _loadRunStateSchemaAct = _wrapper->createAction(getMenuId(), tr("Load a previous run state for this schema, prepare to run"), QIcon("icons:load_execution_state.png"),
233 tr("Load Run State"), tr("Load a previous run state for this schema, prepare to run"),
234 0, _parent, false, this, SLOT(onLoadRunStateSchema()));
236 _loadAndRunSchemaAct = _wrapper->createAction(getMenuId(), tr("Load a schema for run"), QIcon("icons:run.png"),
237 tr("Load Schema to run"), tr("Load a schema for run"),
238 0, _parent, false, this, SLOT(onLoadAndRunSchema()));
240 _chooseBatchJobAct = _wrapper->createAction(getMenuId(), tr("Choose Batch Job for watch"), QIcon("icons:batch.png"),
241 tr("Choose Batch Job for watch"), tr("Choose Batch Job for watch"),
242 0, _parent, false, this, SLOT(onChooseBatchJob()));
244 _startResumeAct = _wrapper->createAction(getMenuId(), tr("Start or Resume Schema execution"), QIcon("icons:suspend_resume.png"),
245 tr("Start/Resume execution"), tr("Start or Resume Schema execution"),
246 0, _parent, false, this, SLOT(onStartResume()));
248 _abortAct = _wrapper->createAction(getMenuId(), tr("Abort the current execution"), QIcon("icons:kill.png"),
249 tr("Abort execution"), tr("Abort the current execution"),
250 0, _parent, false, this, SLOT(onAbort()));
252 _pauseAct = _wrapper->createAction(getMenuId(), tr("Suspend the current execution"), QIcon("icons:pause.png"),
253 tr("Suspend execution"), tr("Suspend the current execution"),
254 0, _parent, false, this, SLOT(onPause()));
256 _resetAct = _wrapper->createAction(getMenuId(), tr("Reset error nodes and restart the current execution"), QIcon("icons:reset.png"),
257 tr("Restart execution"), tr("Restart the current execution with reset of error nodes"),
258 0, _parent, false, this, SLOT(onReset()));
261 _saveRunStateAct = _wrapper->createAction(getMenuId(), tr("Save the current run state"), QIcon("icons:save_dataflow_state.png"),
262 tr("Save State"), tr("Save the current run state"),
263 0, _parent, false, this, SLOT(onSaveRunState()));
265 _newEditionAct = _wrapper->createAction(getMenuId(), tr("Edit again the current schema in a new context"), QIcon("icons:new_edition.png"),
266 tr("Edit Again"), tr("Edit again the current schema in a new context"),
267 0, _parent, false, this, SLOT(onNewEdition()));
270 _getYacsContainerLogAct = _wrapper->createAction(getMenuId(), tr("get YACS container log"), QIcon("icons:change_informations.png"),
271 tr("YACS Container Log"), tr("get YACS container log"),
272 0, _parent, false, this, SLOT(onGetYacsContainerLog()));
274 _getErrorReportAct = _wrapper->createAction(getMenuId(), tr("get Node Error Report"), QIcon("icons:filter_notification.png"),
275 tr("Node Error Report"), tr("get Node Error Report"),
276 0, _parent, false, this, SLOT(onGetErrorReport()));
278 _getErrorDetailsAct = _wrapper->createAction(getMenuId(), tr("get Node Error Details"), QIcon("icons:icon_text.png"),
279 tr("Node Error Details"), tr("get Node Error Details"),
280 0, _parent, false, this, SLOT(onGetErrorDetails()));
282 _getContainerLogAct = _wrapper->createAction(getMenuId(), tr("get Node Container Log"), QIcon("icons:change_informations.png"),
283 tr("Node Container Log"), tr("get Node Container Log"),
284 0, _parent, false, this, SLOT(onGetContainerLog()));
286 _shutdownProcAct = _wrapper->createAction(getMenuId(), tr("Shutdown Proc"), QIcon("icons:kill.png"),
287 tr("Shutdown Proc"), tr("Shutdown Proc"),
288 0, _parent, false, this, SLOT(onShutdownProc()));
291 _editDataTypesAct = _wrapper->createAction(getMenuId(), tr("Edit Data Types"), QIcon("icons:kill.png"),
292 tr("Edit Data Types"), tr("Edit Data Types"),
293 0, _parent, false, this, SLOT(onEditDataTypes()));
295 _createDataTypeAct = _wrapper->createAction(getMenuId(), tr("Create Data Types"), QIcon("icons:kill.png"),
296 tr("Create Data Types"), tr("Create Data Types"),
297 0, _parent, false, this, SLOT(onCreateDataType()));
299 _importDataTypeAct = _wrapper->createAction(getMenuId(), tr("Import Data Types, use drag and drop from catalog"), QIcon("icons:folder_cyan.png"),
300 tr("Import Data Types"), tr("Import Data Types, use drag and drop from catalog"),
301 0, _parent, false, this, SLOT(onImportDataType()));
303 _newContainerAct = _wrapper->createAction(getMenuId(), tr("Create a New Container"), QIcon("icons:container.png"),
304 tr("Create Container"), tr("Create a New Container"),
305 0, _parent, false, this, SLOT(onNewContainer()));
307 _selectComponentInstanceAct = _wrapper->createAction(getMenuId(), tr("Select a Component Instance"), QIcon("icons:icon_select.png"),
308 tr("Select a Component Instance"), tr("Select a Component Instance"),
309 0, _parent, false, this, SLOT(onSelectComponentInstance()));
311 _newSalomeComponentAct = _wrapper->createAction(getMenuId(), tr("Create a New SALOME Component Instance"), QIcon("icons:new_salome_component.png"),
312 tr("Create Component Instance"), tr("Create a New SALOME Component Instance"),
313 0, _parent, false, this, SLOT(onNewSalomeComponent()));
315 _newSalomePythonComponentAct = _wrapper->createAction(getMenuId(), tr("Create a New SALOME Python Component"), QIcon("icons:new_salomepy_component.png"),
316 tr("SALOME Python Component"), tr("Create a New SALOME Python Component"),
317 0, _parent, false, this, SLOT(onNewSalomePythonComponent()));
319 _newCorbaComponentAct = _wrapper->createAction(getMenuId(), tr("Create a New CORBA Component"), QIcon("icons:new_corba_component.png"),
320 tr("CORBA Component"), tr("Create a New CORBA Component"),
321 0, _parent, false, this, SLOT(onNewCorbaComponent()));
323 _salomeServiceNodeAct = _wrapper->createAction(getMenuId(), tr("Create a New SALOME Service Node"), QIcon("icons:new_salome_service_node.png"),
324 tr("SALOME Service Node"), tr("Create a New SALOME Service Node"),
325 0, _parent, false, this, SLOT(onSalomeServiceNode()));
327 _serviceInlineNodeAct = _wrapper->createAction(getMenuId(), tr("Create a New Inline Service Node"), QIcon("icons:new_service_inline_node.png"),
328 tr("Inline Service Node"), tr("Create a New Inline Service Node"),
329 0, _parent, false, this, SLOT(onServiceInlineNode()));
331 _CORBAServiceNodeAct = _wrapper->createAction(getMenuId(), tr("Create a New CORBA Service Node"), QIcon("icons:new_corba_service_node.png"),
332 tr("CORBA Node"), tr("Create a New CORBA Service Node"),
333 0, _parent, false, this, SLOT(onCORBAServiceNode()));
335 _nodeNodeServiceNodeAct = _wrapper->createAction(getMenuId(), tr("Create a New Node referencing a Node"), QIcon("icons:new_nodenode_service_node.png"),
336 tr("Ref on Node"), tr("Create a New Node referencing a Node"),
337 0, _parent, false, this, SLOT(onNodeNodeServiceNode()));
339 _cppNodeAct = _wrapper->createAction(getMenuId(), tr("Create a New C++ Node"), QIcon("icons:new_cpp_node.png"),
340 tr("Cpp Node"), tr("Create a New C++ Node"),
341 0, _parent, false, this, SLOT(onCppNode()));
343 _inDataNodeAct = _wrapper->createAction(getMenuId(), tr("Create a New Input data Node"), QIcon("icons:node.png"),
344 tr("Input Data Node"), tr("Create a New Input data Node"),
345 0, _parent, false, this, SLOT(onInDataNode()));
347 _outDataNodeAct = _wrapper->createAction(getMenuId(), tr("Create a New Output data Node"), QIcon("icons:node.png"),
348 tr("Output Data Node"), tr("Create a New Output data Node"),
349 0, _parent, false, this, SLOT(onOutDataNode()));
351 _inStudyNodeAct = _wrapper->createAction(getMenuId(), tr("Create a New Input Study Node"), QIcon("icons:node.png"),
352 tr("Input Study Node"), tr("Create a New Input Study Node"),
353 0, _parent, false, this, SLOT(onInStudyNode()));
355 _outStudyNodeAct = _wrapper->createAction(getMenuId(), tr("Create a New Output Study Node"), QIcon("icons:node.png"),
356 tr("Output Study Node"), tr("Create a New Output Study Node"),
357 0, _parent, false, this, SLOT(onOutStudyNode()));
359 _inlineScriptNodeAct = _wrapper->createAction(getMenuId(), tr("Create a New Inline Python Script Node"), QIcon("icons:new_inline_script_node.png"),
360 tr("Inline Script Node"), tr("Create a New Inline Python Script Node"),
361 0, _parent, false, this, SLOT(onInlineScriptNode()));
363 _inlineFunctionNodeAct = _wrapper->createAction(getMenuId(), tr("Create a New Inline Python Function Node"), QIcon("icons:new_inline_function_node.png"),
364 tr("Inline Function Node"), tr("Create a New Inline Python Function Node"),
365 0, _parent, false, this, SLOT(onInlineFunctionNode()));
367 _blockNodeAct = _wrapper->createAction(getMenuId(), tr("Create a New Bloc Node"), QIcon("icons:new_block_node.png"),
368 tr("bloc Node"), tr("Create a New Bloc Node"),
369 0, _parent, false, this, SLOT(onBlockNode()));
371 _FORNodeAct = _wrapper->createAction(getMenuId(), tr("Create a New For Loop Node"), QIcon("icons:new_for_loop_node.png"),
372 tr("For Loop Node"), tr("Create a New For Loop Node"),
373 0, _parent, false, this, SLOT(onFORNode()));
375 _FOREACHNodeAct = _wrapper->createAction(getMenuId(), tr("Create a New For Each Loop Node"), QIcon("icons:new_foreach_loop_node.png"),
376 tr("For Each Loop Node"), tr("Create a New For Each Loop Node"),
377 0, _parent, false, this, SLOT(onFOREACHNode()));
379 _WHILENodeAct = _wrapper->createAction(getMenuId(), tr("Create a New While Loop Node"), QIcon("icons:new_while_loop_node.png"),
380 tr("While Loop Node"), tr("Create a New While Loop Node"),
381 0, _parent, false, this, SLOT(onWHILENode()));
383 _SWITCHNodeAct = _wrapper->createAction(getMenuId(), tr("Create a New Switch Node"), QIcon("icons:new_switch_loop_node.png"),
384 tr("Switch Node"), tr("Create a New Switch Node"),
385 0, _parent, false, this, SLOT(onSWITCHNode()));
387 _OptimizerLoopAct = _wrapper->createAction(getMenuId(), tr("Create a New Optimizer Loop Node"), QIcon("icons:new_for_loop_node.png"),
388 tr("Optimizer Loop"), tr("Create a New Optimizer Loop"),
389 0, _parent, false, this, SLOT(onOptimizerLoop()));
391 _nodeFromCatalogAct = _wrapper->createAction(getMenuId(), tr("Create a New Node from Catalog, use drag and drop from catalog"), QIcon("icons:new_from_library_node.png"),
392 tr("Node from Catalog"), tr("Create a New Node from Catalog, use drag and drop from catalog"),
393 0, _parent, false, this, SLOT(onNodeFromCatalog()));
395 _deleteItemAct = _wrapper->createAction(getMenuId(), tr("Delete a Schema Item"), QIcon("icons:delete.png"),
396 tr("Delete Item"), tr("Delete a Schema Item"),
397 0, _parent, false, this, SLOT(onDeleteItem()));
398 _deleteItemAct->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_D); // --- QKeySequence::Delete dangerous...
400 _cutItemAct = _wrapper->createAction(getMenuId(), tr("Cut a Schema Item"), QIcon("icons:cut.png"),
401 tr("Cut Item"), tr("Cut a Schema Item"),
402 0, _parent, false, this, SLOT(onCutItem()));
403 _cutItemAct->setShortcut(QKeySequence::Cut);
405 _copyItemAct = _wrapper->createAction(getMenuId(), tr("Copy a Schema Item"), QIcon("icons:copy.png"),
406 tr("Copy Item"), tr("Copy a Schema Item"),
407 0, _parent, false, this, SLOT(onCopyItem()));
408 _copyItemAct->setShortcut(QKeySequence::Copy);
410 _pasteItemAct = _wrapper->createAction(getMenuId(), tr("Paste a Schema Item"), QIcon("icons:paste.png"),
411 tr("Paste Item"), tr("Paste a Schema Item"),
412 0, _parent, false, this, SLOT(onPasteItem()));
413 _pasteItemAct->setShortcut(QKeySequence::Paste);
415 _putInBlocAct = _wrapper->createAction(getMenuId(), tr("Put node in block"), QIcon("icons:paste.png"),
416 tr("Put node in block"), tr("Put node in block"),
417 0, _parent, false, this, SLOT(onPutInBloc()));
419 _putGraphInBlocAct = _wrapper->createAction(getMenuId(), tr("Bloc"), QIcon("icons:new_block_node.png"),
420 tr("Bloc"), tr("Bloc"),
421 0, _parent, false, this, SLOT(onPutGraphInBloc()));
423 _putGraphInForLoopAct = _wrapper->createAction(getMenuId(), tr("For Loop"), QIcon("icons:new_for_loop_node.png"),
424 tr("For Loop"), tr("For Loop"),
425 0, _parent, false, this, SLOT(onPutGraphInForLoop()));
427 _putGraphInWhileLoopAct = _wrapper->createAction(getMenuId(), tr("While Loop"), QIcon("icons:new_while_loop_node.png"),
428 tr("While Loop"), tr("While Loop"),
429 0, _parent, false, this, SLOT(onPutGraphInWhileLoop()));
431 _putGraphInOptimizerLoopAct = _wrapper->createAction(getMenuId(), tr("Optimizer Loop"), QIcon("icons:new_for_loop_node.png"),
432 tr("Optimizer Loop"), tr("Optimizer Loop"),
433 0, _parent, false, this, SLOT(onPutGraphInOptimizerLoop()));
435 _arrangeLocalNodesAct = _wrapper->createAction(getMenuId(), tr("arrange nodes on that bloc level, without recursion"), QIcon("icons:arrange_nodes.png"),
436 tr("arrange local nodes"), tr("arrange nodes on that bloc level, without recursion"),
437 0, _parent, false, this, SLOT(onArrangeLocalNodes()));
439 _arrangeRecurseNodesAct = _wrapper->createAction(getMenuId(), tr("arrange nodes on that bloc level, with recursion"), QIcon("icons:sample.png"),
440 tr("arrange nodes recursion"), tr("arrange nodes on that bloc level, with recursion"),
441 0, _parent, false, this, SLOT(onArrangeRecurseNodes()));
443 _computeLinkAct = _wrapper->createAction(getMenuId(), tr("compute orthogonal links"), QIcon("icons:rebuild_links.png"),
444 tr("compute links"), tr("compute orthogonal links"),
445 0, _parent, false, this, SLOT(onRebuildLinks()));
447 _zoomToBlocAct = _wrapper->createAction(getMenuId(), tr("zoom 2D view to selected bloc"), QIcon("icons:zoomToBloc.png"),
448 tr("zoom to bloc"), tr("zoom 2D view to the selected composed node"),
449 0, _parent, false, this, SLOT(onZoomToBloc()));
451 _centerOnNodeAct = _wrapper->createAction(getMenuId(), tr("center 2D view on selected node"), QIcon("icons:centerOnNode.png"),
452 tr("center on node"), tr("center 2D view on selected node"),
453 0, _parent, false, this, SLOT(onCenterOnNode()));
454 _centerOnNodeAct->setShortcut(QKeySequence::Find);
456 _shrinkExpand = _wrapper->createAction(getMenuId(), tr("shrink or expand the selected node"), QIcon("icons:shrinkExpand.png"),
457 tr("shrink/expand"), tr("shrink or expand the selected node"),
458 0, _parent, false, this, SLOT(onShrinkExpand()));
460 _toggleStraightLinksAct = _wrapper->createAction(getMenuId(), tr("draw straight or orthogonal links"), QIcon("icons:straightLink.png"),
461 tr("straight/orthogonal"), tr("draw straight or orthogonal links"),
462 0, _parent, true, this, SLOT(onToggleStraightLinks(bool)));
464 _toggleStraightLinksAct->setChecked(Resource::straightLinks);
465 onToggleStraightLinks(Resource::straightLinks);
467 _toggleAutomaticComputeLinkAct = _wrapper->createAction(getMenuId(), tr("compute othogonal links automatically when nodes move"), QIcon("icons:autoComputeLink.png"),
468 tr("automatic link"), tr("compute othogonal links automatically when nodes move"),
469 0, _parent, true, this, SLOT(onToggleAutomaticComputeLinks(bool)));
471 _toggleAutomaticComputeLinkAct->setChecked(Resource::autoComputeLinks);
472 onToggleAutomaticComputeLinks(Resource::autoComputeLinks); // Why is this needed ?
474 _toggleSimplifyLinkAct = _wrapper->createAction(getMenuId(), tr("simplify links by removing unnecessary direction changes"), QIcon("icons:simplifyLink.png"),
475 tr("simplify links"), tr("simplify links by removing unnecessary direction changes"),
476 0, _parent, true, this, SLOT(onToggleSimplifyLinks(bool)));
477 _toggleSimplifyLinkAct->setChecked(Resource::simplifyLink);
478 onToggleSimplifyLinks(Resource::simplifyLink);
480 _toggleForce2NodesLinkAct = _wrapper->createAction(getMenuId(), tr("force orthogonal links by adding an edge on simples links"), QIcon("icons:force2nodeLink.png"),
481 tr("force ortho links"), tr("force orthogonal links by adding an edge on simples links"),
482 0, _parent, true, this, SLOT(onToggleForce2NodesLinks(bool)));
483 _toggleForce2NodesLinkAct->setChecked(true);
485 _toggleAddRowColsAct = _wrapper->createAction(getMenuId(), tr("allow more path for the links, for a better separation"), QIcon("icons:addRowCols.png"),
486 tr("separate links"), tr("allow more path for the links, for a better separation"),
487 0, _parent, true, this, SLOT(onToggleAddRowCols(bool)));
488 _toggleAddRowColsAct->setChecked(Resource::addRowCols);
489 onToggleAddRowCols(Resource::addRowCols);
491 _selectReferenceAct = _wrapper->createAction(getMenuId(), tr("select reference"), QIcon("icons:ob_service_node.png"),
492 tr("select reference"), tr("select reference"),
493 0, _parent, false, this, SLOT(onSelectReference()));
495 _whatsThisAct = _wrapper->createAction(getMenuId(), tr("active whatsThis Mode to get help on widgets"), QIcon("icons:whatsThis.png"),
496 tr("whatsThis Mode"), tr("active whatsThis Mode to get help on widgets"),
497 0, _parent, false, this, SLOT(onWhatsThis()));
498 _whatsThisAct->setShortcut(QKeySequence::WhatsThis);
500 _withoutStopModeAct = _wrapper->createAction(getMenuId(), tr("set execution mode without stop"), QIcon("icons:run_active.png"),
501 tr("mode without stop"), tr("set execution mode without stop"),
502 0, _parent, true, this, SLOT(onWithoutStopMode(bool)));
504 _breakpointsModeAct = _wrapper->createAction(getMenuId(), tr("set execution mode with stop on breakpoints"), QIcon("icons:breakpoints_active.png"),
505 tr("mode breakpoints"), tr("set execution mode with stop on breakpoints"),
506 0, _parent, true, this, SLOT(onBreakpointsMode(bool)));
508 _stepByStepModeAct = _wrapper->createAction(getMenuId(), tr("set execution mode step by step"), QIcon("icons:step_by_step_active.png"),
509 tr("mode step by step"), tr("set execution mode step by step"),
510 0, _parent, true, this, SLOT(onStepByStepMode(bool)));
512 _toggleStopOnErrorAct = _wrapper->createAction(getMenuId(), tr("Force stop on first error during execution"), QIcon("icons:toggle_stop_on_error.png"),
513 tr("stop on error"), tr("Force stop on first error during execution"),
514 0, _parent, true, this, SLOT(onToggleStopOnError(bool)));
516 _toggleSceneItemVisibleAct = _wrapper->createAction(getMenuId(), tr("toggle 2D scene item visibility"), QIcon("icons:toggleVisibility.png"),
517 tr("visible/hidden"), tr("toggle 2D scene item visibility"),
518 0, _parent, true, this, SLOT(onToggleSceneItemVisible(bool)));
522 _showAllLinksAct = _wrapper->createAction(getMenuId(), tr("Show all the links"), QIcon("icons:showLink.png"),
523 tr("show all links"), tr("Show all the links"),
524 0, _parent, false, this, SLOT(onShowAllLinks()));
526 _hideAllLinksAct = _wrapper->createAction(getMenuId(), tr("Hide all the links"), QIcon("icons:hideLink.png"),
527 tr("hide all links"), tr("Hide all the links"),
528 0, _parent, false, this, SLOT(onHideAllLinks()));
531 _showOnlyPortLinksAct = _wrapper->createAction(getMenuId(), tr("Show only links from/to this port"), QIcon("icons:showLink.png"),
532 tr("show only links"), tr("Show only links from/to this port"),
533 0, _parent, false, this, SLOT(onShowOnlyPortLinks()));
535 _showPortLinksAct = _wrapper->createAction(getMenuId(), tr("Show links from/to this port"), QIcon("icons:showLink.png"),
536 tr("show links"), tr("Show links from/to this port"),
537 0, _parent, false, this, SLOT(onShowPortLinks()));
539 _hidePortLinksAct = _wrapper->createAction(getMenuId(), tr("Hide links from/to this port"), QIcon("icons:hideLink.png"),
540 tr("hide links"), tr("Hide links from/to this port"),
541 0, _parent, false, this, SLOT(onHidePortLinks()));
544 _showOnlyCtrlLinksAct = _wrapper->createAction(getMenuId(), tr("Show only control links from/to this node"), QIcon("icons:showLink.png"),
545 tr("show only Control links"), tr("Show only control links from/to this node"),
546 0, _parent, false, this, SLOT(onShowOnlyCtrlLinks()));
548 _showCtrlLinksAct = _wrapper->createAction(getMenuId(), tr("Show control links from/to this node"), QIcon("icons:showLink.png"),
549 tr("show control links"), tr("Show control links from/to this node"),
550 0, _parent, false, this, SLOT(onShowCtrlLinks()));
552 _hideCtrlLinksAct = _wrapper->createAction(getMenuId(), tr("Hide control links from/to this node"), QIcon("icons:hideLink.png"),
553 tr("hide control links"), tr("Hide control links from/to this node"),
554 0, _parent, false, this, SLOT(onHideCtrlLinks()));
557 _showOnlyLinkAct = _wrapper->createAction(getMenuId(), tr("Show only this link"), QIcon("icons:showLink.png"),
558 tr("show only"), tr("Show only this link"),
559 0, _parent, false, this, SLOT(onShowOnlyLink()));
561 _showLinkAct = _wrapper->createAction(getMenuId(), tr("Show this link"), QIcon("icons:showLink.png"),
562 tr("show"), tr("Show this link"),
563 0, _parent, false, this, SLOT(onShowLink()));
565 _hideLinkAct = _wrapper->createAction(getMenuId(), tr("Hide this link"), QIcon("icons:hideLink.png"),
566 tr("hide"), tr("Hide this link"),
567 0, _parent, false, this, SLOT(onHideLink()));
570 _emphasisPortLinksAct = _wrapper->createAction(getMenuId(), tr("emphasis on links from/to this port"), QIcon("icons:emphasisLink.png"),
571 tr("emphasize links"), tr("emphasis on links from/to this port"),
572 0, _parent, false, this, SLOT(onEmphasisPortLinks()));
574 _emphasisCtrlLinksAct = _wrapper->createAction(getMenuId(), tr("emphasis on control links from/to this node"), QIcon("icons:emphasisLink.png"),
575 tr("emphasize control links"), tr("emphasis on control links from/to this node"),
576 0, _parent, false, this, SLOT(onEmphasisCtrlLinks()));
578 _emphasisLinkAct = _wrapper->createAction(getMenuId(), tr("emphasis on this link"), QIcon("icons:emphasisLink.png"),
579 tr("emphasize"), tr("emphasis on this link"),
580 0, _parent, false, this, SLOT(onEmphasisLink()));
582 _deEmphasizeAllAct = _wrapper->createAction(getMenuId(), tr("remove all emphasis"), QIcon("icons:deEmphasisLink.png"),
583 tr("remove all emphasis"), tr("remove all emphasis"),
584 0, _parent, false, this, SLOT(onDeEmphasizeAll()));
587 _undoAct = _wrapper->createAction(getMenuId(), tr("undo last action"), QIcon("icons:undo.png"),
588 tr("undo"), tr("undo last action"),
589 0, _parent, false, this, SLOT(onUndo()));
590 _undoAct->setShortcut(QKeySequence::Undo);
592 _redoAct = _wrapper->createAction(getMenuId(), tr("redo last action"), QIcon("icons:redo.png"),
593 tr("redo"), tr("redo last action"),
594 0, _parent, false, this, SLOT(onRedo()));
595 _redoAct->setShortcut(QKeySequence::Redo);
597 _showUndoAct = _wrapper->createAction(getMenuId(), tr("show undo commands"), QIcon("icons:undo.png"),
598 tr("show undo"), tr("show undo commands"),
599 0, _parent, false, this, SLOT(onShowUndo()));
601 _showRedoAct = _wrapper->createAction(getMenuId(), tr("show redo commands"), QIcon("icons:redo.png"),
602 tr("show redo"), tr("show redo commands"),
603 0, _parent, false, this, SLOT(onShowRedo()));
606 _execModeGroup = new QActionGroup(this);
607 _execModeGroup->addAction(_withoutStopModeAct);
608 _execModeGroup->addAction(_breakpointsModeAct);
609 _execModeGroup->addAction(_stepByStepModeAct);
610 _withoutStopModeAct->setChecked(true);
613 void GenericGui::createMenus()
616 aMenuId = _wrapper->createMenu( tr( "File" ), -1, -1 );
617 _wrapper->createMenu( _wrapper->separator(), aMenuId, -1, 10 );
618 aMenuId = _wrapper->createMenu( "YACS", aMenuId, -1, 10 );
619 _wrapper->createMenu( _newSchemaAct, aMenuId );
620 _wrapper->createMenu( _importSchemaAct, aMenuId );
622 aMenuId = _wrapper->createMenu( "YACS", -1, -1, 30 );
623 _wrapper->createMenu( _newSchemaAct, aMenuId );//, 10
624 _wrapper->createMenu( _importSchemaAct, aMenuId );
625 _wrapper->createMenu( _importSupervSchemaAct, aMenuId );
626 _wrapper->createMenu( _wrapper->separator(), aMenuId);
627 _wrapper->createMenu( _exportSchemaAct, aMenuId );
628 _wrapper->createMenu( _exportSchemaAsAct, aMenuId );
629 _wrapper->createMenu( _wrapper->separator(), aMenuId);
630 _wrapper->createMenu( _runLoadedSchemaAct, aMenuId );
631 _wrapper->createMenu( _loadRunStateSchemaAct, aMenuId );
632 _wrapper->createMenu( _loadAndRunSchemaAct, aMenuId );
633 _wrapper->createMenu( _chooseBatchJobAct, aMenuId );
634 _wrapper->createMenu( _wrapper->separator(), aMenuId);
635 _wrapper->createMenu( _undoAct, aMenuId );
636 _wrapper->createMenu( _redoAct, aMenuId );
637 _wrapper->createMenu( _showUndoAct, aMenuId );
638 _wrapper->createMenu( _showRedoAct, aMenuId );
639 _wrapper->createMenu( _wrapper->separator(), aMenuId);
640 _wrapper->createMenu( _startResumeAct, aMenuId );
641 _wrapper->createMenu( _abortAct, aMenuId );
642 _wrapper->createMenu( _pauseAct, aMenuId );
643 _wrapper->createMenu( _resetAct, aMenuId );
644 _wrapper->createMenu( _wrapper->separator(), aMenuId);
645 _wrapper->createMenu( _saveRunStateAct, aMenuId );
646 //_wrapper->createMenu( _newEditionAct, aMenuId );
647 _wrapper->createMenu( _wrapper->separator(), aMenuId);
648 _wrapper->createMenu( _withoutStopModeAct, aMenuId );
649 _wrapper->createMenu( _breakpointsModeAct, aMenuId );
650 _wrapper->createMenu( _stepByStepModeAct, aMenuId );
651 _wrapper->createMenu( _wrapper->separator(), aMenuId);
652 _wrapper->createMenu( _toggleStopOnErrorAct, aMenuId );
653 _wrapper->createMenu( _wrapper->separator(), aMenuId);
654 _wrapper->createMenu( _importCatalogAct, aMenuId );
655 _wrapper->createMenu( _wrapper->separator(), aMenuId);
656 _wrapper->createMenu( _toggleStraightLinksAct, aMenuId );
657 _wrapper->createMenu( _toggleAutomaticComputeLinkAct, aMenuId );
658 _wrapper->createMenu( _toggleSimplifyLinkAct, aMenuId );
659 _wrapper->createMenu( _toggleForce2NodesLinkAct, aMenuId );
660 _wrapper->createMenu( _toggleAddRowColsAct, aMenuId );
661 _wrapper->createMenu( _wrapper->separator(), aMenuId);
662 _wrapper->createMenu( _showAllLinksAct, aMenuId );
663 _wrapper->createMenu( _hideAllLinksAct, aMenuId );
664 _wrapper->createMenu( _wrapper->separator(), aMenuId);
665 _wrapper->createMenu( _whatsThisAct, aMenuId );
668 void GenericGui::createTools()
670 int aToolId = _wrapper->createTool ( tr( "YACS Toolbar" ) );
671 _wrapper->createTool( _newSchemaAct, aToolId );
672 _wrapper->createTool( _importSchemaAct, aToolId );
673 _wrapper->createTool( _wrapper->separator(), aToolId );
674 _wrapper->createTool( _exportSchemaAct, aToolId );
675 _wrapper->createTool( _exportSchemaAsAct, aToolId );
676 _wrapper->createTool( _wrapper->separator(), aToolId);
677 _wrapper->createTool( _runLoadedSchemaAct, aToolId );
678 _wrapper->createTool( _loadRunStateSchemaAct, aToolId );
679 _wrapper->createTool( _loadAndRunSchemaAct, aToolId );
680 _wrapper->createTool( _chooseBatchJobAct, aToolId );
681 _wrapper->createTool( _wrapper->separator(), aToolId );
682 _wrapper->createTool( _undoAct, aToolId );
683 _wrapper->createTool( _redoAct, aToolId );
684 _wrapper->createTool( _wrapper->separator(), aToolId );
685 _wrapper->createTool( _startResumeAct, aToolId );
686 _wrapper->createTool( _abortAct, aToolId );
687 _wrapper->createTool( _pauseAct, aToolId );
688 _wrapper->createTool( _resetAct, aToolId );
689 _wrapper->createTool( _wrapper->separator(), aToolId );
690 _wrapper->createTool( _saveRunStateAct, aToolId );
691 //_wrapper->createTool( _newEditionAct, aToolId );
692 _wrapper->createTool( _withoutStopModeAct, aToolId );
693 _wrapper->createTool( _breakpointsModeAct, aToolId );
694 _wrapper->createTool( _stepByStepModeAct, aToolId );
695 _wrapper->createTool( _wrapper->separator(), aToolId );
696 _wrapper->createTool( _toggleStopOnErrorAct, aToolId );
697 _wrapper->createTool( _wrapper->separator(), aToolId );
698 _wrapper->createTool( _importCatalogAct, aToolId );
699 _wrapper->createTool( _wrapper->separator(), aToolId );
700 _wrapper->createTool( _toggleStraightLinksAct, aToolId );
701 _wrapper->createTool( _toggleAutomaticComputeLinkAct, aToolId );
702 _wrapper->createTool( _toggleSimplifyLinkAct, aToolId );
703 //_wrapper->createTool( _toggleForce2NodesLinkAct, aToolId );
704 _wrapper->createTool( _toggleAddRowColsAct, aToolId );
705 _wrapper->createTool( _wrapper->separator(), aToolId );
706 _wrapper->createTool( _showAllLinksAct, aToolId );
707 _wrapper->createTool( _hideAllLinksAct, aToolId );
708 _wrapper->createTool( _wrapper->separator(), aToolId );
709 _wrapper->createTool( _whatsThisAct, aToolId );
712 void GenericGui::initialMenus()
714 showEditionMenus(false);
715 showExecMenus(false);
716 showCommonMenus(false);
720 void GenericGui::showBaseMenus(bool show)
722 DEBTRACE("GenericGui::showBaseMenus " << show);
723 _wrapper->setMenuShown(_newSchemaAct, show);
724 _wrapper->setToolShown(_newSchemaAct, show);
725 _wrapper->setMenuShown(_importSchemaAct, show);
726 _wrapper->setToolShown(_importSchemaAct, show);
727 _wrapper->setMenuShown(_importSupervSchemaAct, show);
728 _wrapper->setMenuShown(_loadAndRunSchemaAct, show);
729 _wrapper->setToolShown(_loadAndRunSchemaAct, show);
730 _wrapper->setMenuShown(_chooseBatchJobAct, show);
731 _wrapper->setToolShown(_chooseBatchJobAct, show);
732 _wrapper->setMenuShown(_whatsThisAct, show);
733 _wrapper->setToolShown(_whatsThisAct, show);
736 void GenericGui::showEditionMenus(bool show)
738 DEBTRACE("GenericGui::showEditionMenus " << show);
739 _wrapper->setMenuShown(_exportSchemaAct, show);
740 _wrapper->setToolShown(_exportSchemaAct, show);
741 _wrapper->setMenuShown(_exportSchemaAsAct, show);
742 _wrapper->setToolShown(_exportSchemaAsAct, show);
743 _wrapper->setMenuShown(_runLoadedSchemaAct, show);
744 _wrapper->setToolShown(_loadRunStateSchemaAct, show);
745 _wrapper->setMenuShown(_loadRunStateSchemaAct, show);
746 _wrapper->setToolShown(_runLoadedSchemaAct, show);
747 _wrapper->setMenuShown(_undoAct, show);
748 _wrapper->setToolShown(_undoAct, show);
749 _wrapper->setMenuShown(_redoAct, show);
750 _wrapper->setToolShown(_redoAct, show);
751 _wrapper->setMenuShown(_showUndoAct, show);
752 _wrapper->setMenuShown(_showRedoAct, show);
753 _wrapper->setMenuShown(_importCatalogAct, show);
754 _wrapper->setToolShown(_importCatalogAct, show);
757 void GenericGui::showExecMenus(bool show)
759 DEBTRACE("GenericGui::showExecMenus " << show);
760 _wrapper->setMenuShown(_startResumeAct, show);
761 _wrapper->setToolShown(_startResumeAct, show);
762 _wrapper->setMenuShown(_abortAct, show);
763 _wrapper->setToolShown(_abortAct, show);
764 _wrapper->setMenuShown(_pauseAct, show);
765 _wrapper->setToolShown(_pauseAct, show);
766 _wrapper->setMenuShown(_resetAct, show);
767 _wrapper->setToolShown(_resetAct, show);
768 _wrapper->setMenuShown(_saveRunStateAct, show);
769 _wrapper->setToolShown(_saveRunStateAct, show);
770 //_wrapper->setMenuShown(_newEditionAct, show);
771 //_wrapper->setToolShown(_newEditionAct, show);
772 _wrapper->setMenuShown(_withoutStopModeAct, show);
773 _wrapper->setToolShown(_withoutStopModeAct, show);
774 _wrapper->setMenuShown(_breakpointsModeAct, show);
775 _wrapper->setToolShown(_breakpointsModeAct, show);
776 _wrapper->setMenuShown(_stepByStepModeAct, show);
777 _wrapper->setToolShown(_stepByStepModeAct, show);
778 _wrapper->setMenuShown(_toggleStopOnErrorAct, show);
779 _wrapper->setToolShown(_toggleStopOnErrorAct, show);
782 void GenericGui::showCommonMenus(bool show)
784 DEBTRACE("GenericGui::showCommonMenus " << show);
785 _wrapper->setMenuShown(_toggleStraightLinksAct, show);
786 _wrapper->setToolShown(_toggleStraightLinksAct, show);
787 _wrapper->setMenuShown(_toggleAutomaticComputeLinkAct, show);
788 _wrapper->setToolShown(_toggleAutomaticComputeLinkAct, show);
789 _wrapper->setMenuShown(_toggleSimplifyLinkAct, show);
790 _wrapper->setToolShown(_toggleSimplifyLinkAct, show);
791 _wrapper->setMenuShown(_toggleForce2NodesLinkAct, show);
792 //_wrapper->setToolShown(_toggleForce2NodesLinkAct, show);
793 _wrapper->setMenuShown(_toggleAddRowColsAct, show);
794 _wrapper->setToolShown(_toggleAddRowColsAct, show);
795 _wrapper->setMenuShown(_showAllLinksAct, show);
796 _wrapper->setToolShown(_showAllLinksAct, show);
797 _wrapper->setMenuShown(_hideAllLinksAct, show);
798 _wrapper->setToolShown(_hideAllLinksAct, show);
801 void GenericGui::switchContext(QWidget *view)
803 DEBTRACE("GenericGui::switchContext " << view);
804 if (! _mapViewContext.count(view))
807 _dwTree->setWidget(0);
808 _dwStacked->setWidget(0);
811 QtGuiContext* newContext = _mapViewContext[view];
813 _dwTree->setWidget(newContext->getEditTree());
814 _dwTree->widget()->show();
816 _dwStacked->setWidget(newContext->getStackedWidget());
818 QtGuiContext::setQtCurrent(newContext);
820 if (newContext->isEdition())
822 showExecMenus(false);
824 showEditionMenus(true);
825 showCommonMenus(true);
826 if (_dwTree) _dwTree->setWindowTitle("Tree View: edition mode");
830 showEditionMenus(false);
833 showCommonMenus(true);
834 _withoutStopModeAct->setChecked(true);
835 if (_dwTree) _dwTree->setWindowTitle("Tree View: execution mode");
837 _dwStacked->setMinimumWidth(10);
840 bool GenericGui::closeContext(QWidget *view, bool onExit)
842 DEBTRACE("GenericGui::closeContext " << onExit);
843 if (! _mapViewContext.count(view))
845 QtGuiContext* context = _mapViewContext[view];
848 bool tryToSave = false;
850 if (QtGuiContext::getQtCurrent()->isEdition())
852 if (!QtGuiContext::getQtCurrent()->_setOfModifiedSubjects.empty())
855 msgBox.setText("Some elements are modified and not taken into account.");
856 string info = "do you want to apply your changes ?\n";
857 info += " - Save : do not take into account edition in progress,\n";
858 info += " but if there are other modifications, select a file name for save\n";
859 info += " - Discard : discard all modifications and close the schema";
861 info += "\n - Cancel : do not close the schema, return to edition";
862 msgBox.setInformativeText(info.c_str());
865 msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
866 msgBox.setDefaultButton(QMessageBox::Cancel);
870 msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Discard);
871 msgBox.setDefaultButton(QMessageBox::Save);
873 int ret = msgBox.exec();
876 case QMessageBox::Save:
879 case QMessageBox::Discard:
882 case QMessageBox::Cancel:
884 DEBTRACE("Cancel or default");
890 if (QtGuiContext::getQtCurrent()->isNotSaved())
893 msgBox.setWindowTitle("Close the active schema");
894 msgBox.setText("The schema has been modified");
895 string info = "do you want to save the schema ?\n";
896 info += " - Save : select a file name for save\n";
897 info += " - Discard : discard all modifications and close the schema";
899 info += "\n - Cancel : do not close the schema, return to edition";
900 msgBox.setInformativeText(info.c_str());
903 msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
904 msgBox.setDefaultButton(QMessageBox::Cancel);
908 msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Discard);
909 msgBox.setDefaultButton(QMessageBox::Save);
911 int ret = msgBox.exec();
914 case QMessageBox::Save:
917 case QMessageBox::Discard:
920 case QMessageBox::Cancel:
921 DEBTRACE("Cancel or default");
931 if ((!onExit) && (!_isSaved)) // --- probably, user has cancelled the save dialog. Do not close
936 map<QWidget*, YACS::HMI::QtGuiContext*>::iterator it = _mapViewContext.begin();
937 QtGuiContext* newContext = 0;
938 QWidget* newView = 0;
939 for (; it != _mapViewContext.end(); ++it)
941 if ((*it).second != context)
943 newView = (*it).first;
944 newContext = (*it).second;
948 int studyId = _wrapper->activeStudyId();
949 if (context->getStudyId() == studyId)
951 _wrapper->deleteSchema(view);
952 DEBTRACE("delete context");
953 if (GuiExecutor* exec = context->getGuiExecutor())
955 exec->closeContext();
958 _mapViewContext.erase(view);
959 switchContext(newView);
964 void GenericGui::showDockWidgets(bool isVisible)
966 DEBTRACE("GenericGui::showDockWidgets " << isVisible);
967 if (_dwTree) _dwTree->setVisible(isVisible);
968 if (_dwTree) _dwTree->toggleViewAction()->setVisible(isVisible);
969 if (_dwStacked) _dwStacked->setVisible(isVisible);
970 if (_dwStacked) _dwStacked->toggleViewAction()->setVisible(isVisible);
971 if (_dwCatalogs) _dwCatalogs->setVisible(isVisible);
972 if (_dwCatalogs) _dwCatalogs->toggleViewAction()->setVisible(isVisible);
975 void GenericGui::raiseStacked()
977 if (_dwStacked) _dwStacked->raise();
980 std::list<std::string> GenericGui::getMachineList()
982 if (!_machineList.empty()) return _machineList;
984 YACS::ENGINE::RuntimeSALOME* runTime = YACS::ENGINE::getSALOMERuntime();
985 CORBA::ORB_ptr orb = runTime->getOrb();
986 if (!orb) return _machineList;
988 SALOME_NamingService namingService(orb);
989 SALOME_LifeCycleCORBA lcc(&namingService);
991 CORBA::Object_var obj =
992 namingService.Resolve(SALOME_ResourcesManager::_ResourcesManagerNameInNS);
993 if (CORBA::is_nil(obj)) return _machineList;
995 Engines::ResourcesManager_var resManager = Engines::ResourcesManager::_narrow(obj);
996 if(!resManager) return _machineList;
998 Engines::ResourceParameters params;
1001 Engines::ResourceList* resourceList =
1002 resManager->GetFittingResources(params);
1004 for (int i = 0; i < resourceList->length(); i++)
1006 const char* aResource = (*resourceList)[i];
1007 _machineList.push_back(aResource);
1010 return _machineList;
1013 // -----------------------------------------------------------------------------
1015 /*! a QtGuiContext instance is created for each schema in edition or each execution or run
1016 * of a schema. The context stores references of a lot of objects related to the edition
1018 * \param proc the schema to run or edit, loaded from file or just created empty.
1019 * \param schemaName filename of the schema in edition, also used in execution to publish
1020 * a run under the edition name in Salome object browser.
1021 * \param runName filename of the schema in execution, not used in edition.
1022 * \param forEdition if true, edition mode, if false, execution mode.
1024 void GenericGui::createContext(YACS::ENGINE::Proc* proc,
1025 const QString& schemaName,
1026 const QString& runName,
1029 DEBTRACE("GenericGui::createContext");
1035 QWidget* central = _parent->centralWidget();
1037 central->setFocus();
1039 DEBTRACE("No Central Widget");
1042 QWidget* refWindow = 0; // --- used only on run to refer to the schema in edition
1045 fileName = schemaName;
1050 if (QtGuiContext::getQtCurrent())
1051 refWindow = QtGuiContext::getQtCurrent()->getWindow();
1054 QtGuiContext* context = new QtGuiContext(this);
1055 QtGuiContext::setQtCurrent(context);
1059 context->setEdition(forEdition);
1060 context->setSessionCatalog(_sessionCatalog);
1061 context->setFileName(fileName);
1062 context->setCurrentCatalog(_builtinCatalog);
1064 // --- scene, viewWindow & GraphicsView
1066 Scene *scene = new Scene();
1067 QWidget *viewWindow = _wrapper->getNewWindow(scene);
1068 _mapViewContext[viewWindow] = context;
1069 GraphicsView* gView = new GraphicsView(viewWindow);
1070 gView->setScene(scene);
1071 gView->setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
1072 int studyId = _wrapper->AssociateViewToWindow(gView, viewWindow);
1073 context->setStudyId(studyId);
1074 std::ostringstream value;
1076 proc->setProperty("DefaultStudyID",value.str());
1077 context->setScene(scene);
1078 context->setView(gView);
1079 context->setWindow(viewWindow);
1084 SchemaModel *schemaModel = new SchemaModel(context, viewWindow);
1085 schemaModel->setEdition(forEdition);
1086 context->setSchemaModel(schemaModel);
1087 RootSceneItem *rootSceneItem = new RootSceneItem(context);
1089 // --- tree associated to model
1091 FormEditTree *editTree = new FormEditTree(_dwTree);
1092 editTree->setMinimumHeight(400);
1093 _dwTree->setWidget(editTree);
1095 context->setEditTree(editTree);
1096 editTree->tv_schema->setModel(schemaModel);
1097 context->setSelectionModel(editTree->tv_schema->selectionModel());
1100 QObject::connect(editTree->tv_schema->selectionModel(),
1101 SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)),
1103 SLOT(updateSelection(const QItemSelection &, const QItemSelection &)));
1105 // --- stacked widget
1107 QStackedWidget *stacked = new QStackedWidget(_dwStacked);
1108 _dwStacked->setWidget(stacked);
1109 context->setStackedWidget(stacked);
1110 YACS::HMI::ItemEditionRoot* rootEdit = new YACS::HMI::ItemEditionRoot(context,
1112 context->getName().c_str());
1113 context->setEditionRoot(rootEdit);
1115 QObject::connect(schemaModel,
1116 SIGNAL(signalSelection(const QModelIndex &)),
1117 editTree->tv_schema,
1118 SLOT(viewSelection(const QModelIndex &)));
1122 proc->setEdition(forEdition);
1126 double passe = (end_t -start_t);
1127 passe = passe/CLOCKS_PER_SEC;
1128 DEBTRACE("create context -1- : " << passe);
1132 context->setLoading(true);
1134 context->setProc(proc);
1135 setLoadedPresentation(proc);
1139 double passe = (end_t -start_t);
1140 passe = passe/CLOCKS_PER_SEC;
1141 DEBTRACE("create context - load proc- : " << passe);
1145 context->setLoading(false);
1147 if (forEdition && _wrapper) // --- Edition mode
1149 _wrapper->createNewSchema(fileName, viewWindow);
1151 else if (_wrapper) // --- Execution Mode
1153 GuiExecutor *guiExec = new GuiExecutor(proc);
1154 context->setGuiExecutor(guiExec);
1155 _wrapper->createNewRun(schemaName, fileName, refWindow, viewWindow);
1159 QtGuiContext::getQtCurrent()->getSubjectProc()->update(UPDATE,
1160 ProcInvoc::getTypeOfNode(proc),
1161 0); // --- force validity check
1163 // --- adjust widgets
1165 TreeView *vtree = dynamic_cast<TreeView*>(editTree->tv_schema);
1167 vtree->resizeColumns();
1168 _catalogsWidget->setMinimumWidth(10); // --- reset the constraint on width
1169 editTree->setMinimumHeight(40);
1170 _dwStacked->setMinimumWidth(10);
1175 showExecMenus(false);
1176 showEditionMenus(true);
1177 showCommonMenus(true);
1178 if (_dwTree) _dwTree->setWindowTitle("Tree View: edition mode");
1182 showEditionMenus(false);
1183 showExecMenus(true);
1184 showCommonMenus(true);
1185 _withoutStopModeAct->setChecked(true);
1186 if (_dwTree) _dwTree->setWindowTitle("Tree View: execution mode");
1189 QtGuiContext::getQtCurrent()->setNotSaved(false);
1192 double passe = (end_t -start_t);
1193 passe = passe/CLOCKS_PER_SEC;
1194 DEBTRACE("create context - end - : " << passe);
1199 // -----------------------------------------------------------------------------
1201 void GenericGui::setLoadedPresentation(YACS::ENGINE::Proc* proc)
1203 DEBTRACE("GenericGui::setLoadedPresentation");
1204 QtGuiContext::getQtCurrent()->setLoadingPresentation(true);
1205 map<YACS::ENGINE::Node*, PrsData> presNodes = _loader->getPrsData(proc);
1206 if (!presNodes.empty())
1208 map<YACS::ENGINE::Node*, PrsData>::iterator it = presNodes.begin();
1209 for (; it!= presNodes.end(); ++it)
1211 YACS::ENGINE::Node* node = (*it).first;
1212 PrsData pres = (*it).second;
1213 SubjectNode *snode = QtGuiContext::getQtCurrent()->_mapOfSubjectNode[node];
1214 SceneItem *item = QtGuiContext::getQtCurrent()->_mapOfSceneItem[snode];
1216 SceneNodeItem *inode = dynamic_cast<SceneNodeItem*>(item);
1218 inode->setPos(QPointF(pres._x, pres._y));
1219 inode->setWidth(pres._width);
1220 inode->setHeight(pres._height);
1221 inode->setExpanded(pres._expanded);
1222 inode->setExpandedPos(QPointF(pres._expx, pres._expy));
1223 inode->setExpandedWH(pres._expWidth, pres._expHeight);
1224 inode->setShownState(shownState(pres._shownState));
1227 if (Scene::_autoComputeLinks)
1228 _guiEditor->rebuildLinks();
1231 YACS::HMI::SubjectProc* subproc = QtGuiContext::getQtCurrent()->getSubjectProc();
1232 SceneItem *item = QtGuiContext::getQtCurrent()->_mapOfSceneItem[subproc];
1233 SceneComposedNodeItem *proc = dynamic_cast<SceneComposedNodeItem*>(item);
1234 proc->updateLinks();
1237 QtGuiContext::getQtCurrent()->setLoadingPresentation(false);
1240 // -----------------------------------------------------------------------------
1242 void GenericGui::onNewSchema()
1244 DEBTRACE("GenericGui::onNewSchema");
1246 std::stringstream name;
1247 name << "newSchema_" << ++_schemaCnt;
1249 YACS::ENGINE::RuntimeSALOME* runTime = YACS::ENGINE::getSALOMERuntime();
1250 YACS::ENGINE::Proc *proc = runTime->createProc(name.str());
1254 QString fileName = name.str().c_str();
1255 createContext(proc, fileName, "", true);
1258 void GenericGui::loadSchema(const std::string& filename,bool edit, bool arrangeLocalNodes)
1260 YACS::ENGINE::Proc *proc = _loader->load(filename.c_str());
1263 YACS::ENGINE::Logger* logger= proc->getLogger("parser");
1264 if(!logger->isEmpty())
1266 DEBTRACE(logger->getStr());
1268 QString fn=QString::fromStdString(filename);
1270 createContext(proc, fn, "", true);
1272 createContext(proc, fn, fn, false);
1273 if (arrangeLocalNodes)
1275 _guiEditor->arrangeProc();
1279 void GenericGui::onImportSchema()
1284 DEBTRACE("GenericGui::onImportSchema");
1285 QFileDialog dialog(_parent,
1286 "Choose a filename to load" ,
1288 tr( "XML-Files (*.xml);;All Files (*)" ));
1290 dialog.setHistory(_wrapper->getQuickDirList());
1293 QStringList fileNames;
1296 fileNames = dialog.selectedFiles();
1297 if (!fileNames.isEmpty())
1298 fn = fileNames.first();
1301 if ( !fn.isEmpty() )
1303 // add ".xml" suffix
1305 if (!fi.exists() && fi.suffix() != "xml")
1308 DEBTRACE("file loaded : " <<fn.toStdString());
1309 YACS::ENGINE::Proc *proc = 0;
1312 proc = _loader->load(fn.toLatin1());
1319 double passe = (end_t -start_t);
1320 passe = passe/CLOCKS_PER_SEC;
1321 DEBTRACE("load xml file : " << passe);
1327 QMessageBox msgBox(QMessageBox::Critical,
1328 "Import YACS Schema, native YACS XML format",
1329 "The file has not the native YACS XML format or is not readable.");
1333 YACS::ENGINE::Logger* logger= proc->getLogger("parser");
1334 if(!logger->isEmpty())
1336 DEBTRACE(logger->getStr());
1338 createContext(proc, fn, "", true);
1342 void GenericGui::onImportSupervSchema()
1344 DEBTRACE("GenericGui::onImportSupervSchema");
1345 QFileDialog dialog(_parent,
1346 "Choose a SUPERV filename to load" ,
1348 tr( "XML-Files (*.xml);;All Files (*)" ));
1350 dialog.setHistory(_wrapper->getQuickDirList());
1353 QStringList fileNames;
1356 fileNames = dialog.selectedFiles();
1357 if (!fileNames.isEmpty())
1358 fn = fileNames.first();
1361 if (fn.isEmpty()) return;
1363 // add ".xml" suffix
1365 if (!fi.exists() && fi.suffix() != "xml")
1368 DEBTRACE("file loaded : " <<fn.toStdString());
1369 QString tmpFileName;
1373 QString tmpDir = getenv("TEMP");
1374 QString fileExt = "bat";
1376 QString tmpDir = "/tmp";
1377 QString fileExt = "sh";
1379 QDir aTmpDir(tmpDir);
1380 aTmpDir.mkdir(QString("YACS_") + getenv("USER"));
1381 YASSERT(aTmpDir.cd(QString("YACS_") + getenv("USER")));
1382 QDateTime curTime = QDateTime::currentDateTime();
1383 tmpFileName = "SUPERV_import_" + curTime.toString("yyyyMMdd_hhmmss") + ".xml";
1384 QString tmpOutput = "salomeloader_output";
1385 tmpFileName = aTmpDir.absoluteFilePath(tmpFileName);
1386 DEBTRACE(tmpFileName.toStdString());
1388 QString aCall = "salomeloader."+ fileExt+ " "+ fn + " " + tmpFileName + " > " + tmpOutput;
1389 DEBTRACE(aCall.toStdString());
1391 int ret = system(aCall.toAscii());
1394 // --- read file with logs
1395 fstream f(tmpOutput.toAscii());
1400 // --- Problem in execution
1401 int status=WEXITSTATUS(ret);
1404 QString mes = "Problems in conversion: some errors but an incomplete proc has nevertheless been created.\n\n";
1405 mes += QString(hfile.str().c_str());
1406 QMessageBox msgBox(QMessageBox::Warning,
1407 "Import YACS Schema, SUPERV XML format",
1411 else if(status == 2)
1413 QString mes = "Problems in conversion: a fatal error has been encountered. The proc can't be created.\n\n";
1414 mes += QString(hfile.str().c_str());
1415 QMessageBox msgBox(QMessageBox::Critical,
1416 "Import YACS Schema, SUPERV XML format",
1423 DEBTRACE("Unknown problem: " << ret );
1424 QMessageBox msgBox(QMessageBox::Critical,
1425 "Import YACS Schema, SUPERV XML format",
1426 "Unexpected exception in salomeloader.");
1434 QMessageBox msgBox(QMessageBox::Critical,
1435 "Import YACS Schema, SUPERV XML format",
1436 "Unexpected exception in convertSupervFile");
1442 if (fn.isEmpty()) return; // must not happen
1444 DEBTRACE("file loaded : " <<fn.toStdString());
1445 YACS::ENGINE::Proc *proc = _loader->load(fn.toLatin1());
1448 QMessageBox msgBox(QMessageBox::Critical,
1449 "Import YACS Schema, SUPERV file converted in native YACS XML format",
1450 "The file has not the native YACS XML format or is not readable.");
1454 YACS::ENGINE::Logger* logger= proc->getLogger("parser");
1455 if(!logger->isEmpty())
1457 DEBTRACE(logger->getStr());
1459 createContext(proc, fn, "", true);
1462 //! bug confirmOverwrite : correction Qt 4.3.5
1463 QString GenericGui::getSaveFileName(const QString& fileName)
1465 QFileDialog dialog(_parent, "Save schema", fileName);
1466 QStringList filters;
1467 filters << "XML files (*.xml)"
1469 dialog.setFileMode(QFileDialog::AnyFile);
1470 dialog.setFilters(filters);
1471 dialog.selectFilter("(*.xml)");
1472 dialog.setDefaultSuffix("xml");
1473 dialog.setConfirmOverwrite(true);
1474 //dialog.setConfirmOverwrite(false); // bug Qt4.3.3
1475 dialog.setAcceptMode(QFileDialog::AcceptSave);
1476 QString selectedFile;
1477 QStringList fileNames;
1479 if (bool ret = dialog.exec())
1481 DEBTRACE(ret << " " << dialog.confirmOverwrite());
1482 fileNames = dialog.selectedFiles();
1483 if (!fileNames.isEmpty())
1484 selectedFile = fileNames.first();
1486 QString filteredName = _guiEditor->asciiFilter(selectedFile);
1487 DEBTRACE(filteredName.toStdString());
1488 return filteredName;
1491 void GenericGui::onExportSchema()
1493 DEBTRACE("GenericGui::onExportSchema");
1494 if (!QtGuiContext::getQtCurrent()) return;
1495 YACS::ENGINE::Proc* proc = QtGuiContext::getQtCurrent()->getProc();
1496 QString fo = QtGuiContext::getQtCurrent()->getFileName();
1499 if (fo.startsWith("newSchema_"))
1502 fn = getSaveFileName(fo);
1504 if (fn.isEmpty()) return;
1506 DEBTRACE("GenericGui::onExportSchema: " << fn.toStdString());
1507 //to be sure that all pending changes are effective
1508 _parent->setFocus();
1509 QtGuiContext::getQtCurrent()->setFileName(fn);
1510 VisitorSaveGuiSchema aWriter(proc);
1511 aWriter.openFileSchema( fn.toStdString() );
1512 aWriter.visitProc();
1513 aWriter.closeFileSchema();
1514 QtGuiContext::getQtCurrent()->setNotSaved(false);
1516 if (fn.compare(foo) && _wrapper)
1517 _wrapper->renameSchema(foo, fn, QtGuiContext::getQtCurrent()->getWindow());
1520 void GenericGui::onExportSchemaAs()
1522 DEBTRACE("GenericGui::onExportSchemaAs");
1524 if (!QtGuiContext::getQtCurrent()) return;
1525 YACS::ENGINE::Proc* proc = QtGuiContext::getQtCurrent()->getProc();
1526 QString fo = QtGuiContext::getQtCurrent()->getFileName();
1528 if (fo.startsWith("newSchema_")) fo.clear();
1529 QString fn = getSaveFileName(fo);
1530 if (fn.isEmpty()) return;
1532 DEBTRACE("GenericGui::onExportSchemaAs: " << fn.toStdString());
1533 QtGuiContext::getQtCurrent()->setFileName(fn);
1534 VisitorSaveGuiSchema aWriter(proc);
1535 aWriter.openFileSchema(fn.toStdString());
1536 aWriter.visitProc();
1537 aWriter.closeFileSchema();
1539 QtGuiContext::getQtCurrent()->setNotSaved(false);
1541 if (fn.compare(foo) && _wrapper)
1542 _wrapper->renameSchema(foo, fn, QtGuiContext::getQtCurrent()->getWindow());
1545 void GenericGui::onImportCatalog()
1547 DEBTRACE("GenericGui::onImportCatalog");
1548 QFileDialog dialog(_parent,
1549 "Choose a YACS Schema to load as a Catalog" ,
1551 tr( "XML-Files (*.xml);;All Files (*)" ));
1553 dialog.setHistory(_wrapper->getQuickDirList());
1556 QStringList fileNames;
1559 fileNames = dialog.selectedFiles();
1560 if (!fileNames.isEmpty())
1561 fn = fileNames.first();
1564 if ( !fn.isEmpty() )
1565 _catalogsWidget->addCatalogFromFile(fn.toStdString());
1568 void GenericGui::onRunLoadedSchema(bool withState)
1570 DEBTRACE("GenericGui::onRunLoadedSchema");
1571 if (!QtGuiContext::getQtCurrent()) return;
1577 // --- check proc state (cf. editionProc)
1579 if (!QtGuiContext::getQtCurrent()->_setOfModifiedSubjects.empty())
1581 set<Subject*>::iterator it = QtGuiContext::getQtCurrent()->_setOfModifiedSubjects.begin();
1582 (*it)->select(true);
1586 YACS::ENGINE::Proc* proc = QtGuiContext::getQtCurrent()->getProc();
1587 if (!proc->isValid())
1589 QtGuiContext::getQtCurrent()->getSubjectProc()->select(true);
1593 YACS::ENGINE::LinkInfo info(YACS::ENGINE::LinkInfo::ALL_STOP_ASAP);
1596 proc->checkConsistency(info);
1598 catch (Exception &ex)
1600 DEBTRACE(ex.what());
1601 QtGuiContext::getQtCurrent()->getSubjectProc()->select(true);
1604 if (info.areWarningsOrErrors()) return;
1608 double passe = (end_t -start_t);
1609 passe = passe/CLOCKS_PER_SEC;
1610 cerr <<"run schema -1- : " << passe << endl;
1613 // --- save proc under a run name
1615 QFileInfo fo = QtGuiContext::getQtCurrent()->getFileName();
1616 QString procName = fo.baseName();
1617 //QString tmpDir = SALOMEDS_Tool::GetTmpDir().c_str();
1619 QString tmpDir = getenv("TEMP");
1621 QString tmpDir = "/tmp";
1623 QDir aTmpDir(tmpDir);
1624 aTmpDir.mkdir(QString("YACS_") + getenv("USER"));
1625 YASSERT(aTmpDir.cd(QString("YACS_") + getenv("USER")));
1626 QDateTime curTime = QDateTime::currentDateTime();
1627 QString aRunName = procName + "_" + curTime.toString("yyyyMMdd_hhmmss") + ".xml";
1628 aRunName = aTmpDir.absoluteFilePath(aRunName);
1629 DEBTRACE(aRunName.toStdString());
1631 VisitorSaveGuiSchema aWriter(proc);
1632 aWriter.openFileSchema(aRunName.toStdString());
1633 aWriter.visitProc();
1634 aWriter.closeFileSchema();
1636 // --- create a run context
1638 YACS::ENGINE::Proc *procrun = _loader->load(aRunName.toLatin1());
1641 double passe = (end_t -start_t);
1642 passe = passe/CLOCKS_PER_SEC;
1643 cerr <<"run schema -2- : " << passe << endl;
1646 createContext(procrun, QtGuiContext::getQtCurrent()->getFileName(), aRunName, false);
1648 // load state if required
1650 GuiExecutor *executor = QtGuiContext::getQtCurrent()->getGuiExecutor();
1651 if (!executor) return;
1654 QString fn = QFileDialog::getOpenFileName( _parent,
1655 "Choose a previous run state to load" ,
1657 tr( "XML-Files (*.xml);;All Files (*)" ));
1660 DEBTRACE("run state to load: " <<fn.toStdString());
1661 executor->setLoadStateFile(fn.toStdString());
1664 executor->startResumeDataflow(true); // --- initialise gui state
1665 if(_toggleStopOnErrorAct->isChecked())
1666 executor->setStopOnError(false);
1669 void GenericGui::onLoadRunStateSchema()
1671 DEBTRACE("GenericGui::onLoadRunStateSchema");
1672 onRunLoadedSchema(true);
1675 void GenericGui::onLoadAndRunSchema()
1677 DEBTRACE("GenericGui::onLoadAndRunSchema");
1678 QString fn = QFileDialog::getOpenFileName( _parent,
1679 "Choose a filename to load" ,
1681 tr( "XML-Files (*.xml);;All Files (*)" ));
1682 if ( !fn.isEmpty() )
1684 // add ".xml" suffix
1686 if (!fi.exists() && fi.suffix() != "xml")
1689 DEBTRACE("file loaded : " <<fn.toStdString());
1690 YACS::ENGINE::Proc *proc =0;
1693 proc = _loader->load(fn.toLatin1());
1700 QMessageBox msgBox(QMessageBox::Critical,
1701 "Import YACS Schema, native YACS XML format",
1702 "The file has not the native YACS XML format or is not readable.");
1706 YACS::ENGINE::Logger* logger= proc->getLogger("parser");
1707 if(!logger->isEmpty())
1709 DEBTRACE(logger->getStr());
1711 createContext(proc, fn, "", true);
1712 onRunLoadedSchema();
1716 void GenericGui::onChooseBatchJob() {
1717 DEBTRACE("GenericGui::onChooseBatchJob");
1719 // Show the Batch Jobs list
1720 if(_BJLdialog) delete _BJLdialog;
1721 _BJLdialog = new BatchJobsListDialog(tr("Select one Batch Job to watch"),this);
1723 _BJLdialog->move(300,200);
1724 _BJLdialog->resize(450,200);
1728 void GenericGui::onStartResume()
1730 DEBTRACE("GenericGui::onStartResume");
1731 if (!QtGuiContext::getQtCurrent()) return;
1732 if (!QtGuiContext::getQtCurrent()->getGuiExecutor()) return;
1733 QtGuiContext::getQtCurrent()->getGuiExecutor()->startResumeDataflow();
1736 void GenericGui::onAbort()
1738 DEBTRACE("GenericGui::onAbort");
1739 if (!QtGuiContext::getQtCurrent()) return;
1740 if (!QtGuiContext::getQtCurrent()->getGuiExecutor()) return;
1741 QtGuiContext::getQtCurrent()->getGuiExecutor()->killDataflow();
1744 void GenericGui::onPause()
1746 DEBTRACE("GenericGui::onPause");
1747 if (!QtGuiContext::getQtCurrent()) return;
1748 if (!QtGuiContext::getQtCurrent()->getGuiExecutor()) return;
1749 QtGuiContext::getQtCurrent()->getGuiExecutor()->suspendDataflow();
1752 void GenericGui::onReset()
1754 DEBTRACE("GenericGui::onReset");
1755 if (!QtGuiContext::getQtCurrent()) return;
1756 if (!QtGuiContext::getQtCurrent()->getGuiExecutor()) return;
1757 QtGuiContext::getQtCurrent()->getGuiExecutor()->resetDataflow();
1760 void GenericGui::onSaveRunState()
1762 DEBTRACE("GenericGui::onSaveRunState");
1763 if (!QtGuiContext::getQtCurrent()) return;
1764 if (!QtGuiContext::getQtCurrent()->getGuiExecutor()) return;
1765 QDateTime curTime = QDateTime::currentDateTime();
1766 QFileInfo procName = QtGuiContext::getQtCurrent()->getFileName();
1767 QString stateName = procName.baseName();
1768 DEBTRACE(stateName.toStdString());
1769 stateName += "_state_" + curTime.toString("yyyyMMdd_hhmmss") + ".xml";
1770 DEBTRACE(stateName.toStdString());
1771 stateName = getSaveFileName(stateName);
1772 DEBTRACE(stateName.toStdString());
1773 if (!stateName.isEmpty())
1774 QtGuiContext::getQtCurrent()->getGuiExecutor()->saveState(stateName.toStdString());
1777 void GenericGui::onNewEdition()
1779 DEBTRACE("GenericGui::onNewEdition");
1780 // if (!QtGuiContext::getQtCurrent()) return;
1781 // if (!QtGuiContext::getQtCurrent()->getGuiExecutor()) return;
1782 // QtGuiContext::getQtCurrent()->getGuiExecutor()->resetDataflow();
1785 void GenericGui::onGetYacsContainerLog()
1787 DEBTRACE("GenericGui::onGetYacsContainerLog");
1788 if (!QtGuiContext::getQtCurrent()) return;
1789 if (!QtGuiContext::getQtCurrent()->getGuiExecutor()) return;
1790 string log = QtGuiContext::getQtCurrent()->getGuiExecutor()->getContainerLog();
1791 ContainerLogViewer *lv = new ContainerLogViewer("YACS Container Log", _parent);
1796 void GenericGui::onGetErrorReport()
1798 DEBTRACE("GenericGui::onGetErrorReport");
1799 if (!QtGuiContext::getQtCurrent()) return;
1800 Subject *sub = QtGuiContext::getQtCurrent()->getSelectedSubject();
1801 SubjectNode *snode = dynamic_cast<SubjectNode*>(sub);
1804 if (QtGuiContext::getQtCurrent()->getGuiExecutor())
1806 log = QtGuiContext::getQtCurrent()->getGuiExecutor()->getErrorReport(snode->getNode());
1810 log = snode->getNode()->getErrorReport();
1813 LogViewer *lv = new LogViewer("Node error report", _parent);
1818 void GenericGui::onGetErrorDetails()
1820 DEBTRACE("GenericGui::onGetErrorDetails");
1821 if (!QtGuiContext::getQtCurrent()) return;
1822 Subject *sub = QtGuiContext::getQtCurrent()->getSelectedSubject();
1823 SubjectNode *snode = dynamic_cast<SubjectNode*>(sub);
1826 if (QtGuiContext::getQtCurrent()->getGuiExecutor())
1828 log = QtGuiContext::getQtCurrent()->getGuiExecutor()->getErrorDetails(snode->getNode());
1832 log = snode->getNode()->getErrorDetails();
1835 LogViewer *lv = new LogViewer("Node Error Details", _parent);
1840 void GenericGui::onGetContainerLog()
1842 DEBTRACE("GenericGui::onGetContainerLog");
1843 if (!QtGuiContext::getQtCurrent()) return;
1844 if (!QtGuiContext::getQtCurrent()->getGuiExecutor()) return;
1845 Subject *sub = QtGuiContext::getQtCurrent()->getSelectedSubject();
1846 SubjectElementaryNode *snode = dynamic_cast<SubjectElementaryNode*>(sub);
1848 string log = QtGuiContext::getQtCurrent()->getGuiExecutor()->getContainerLog(snode->getNode());
1850 LogViewer *lv = new LogViewer("Node Container Log", _parent);
1854 if (dynamic_cast<YACS::ENGINE::ServiceNode*>(snode->getNode()))
1856 info +="The container log of this node\n";
1857 info += "is not stored in a file and \n";
1858 info += "can't be displayed here, \n";
1859 info += "but you can have a look at \n";
1860 info += "the SALOME standard output,\n";
1861 info += "on your terminal...";
1865 info += "See YACS Container log \n";
1866 info += "(on main proc menu) \n";
1867 info += "for all inline nodes";
1876 void GenericGui::onShutdownProc()
1878 DEBTRACE("GenericGui::onShutdownProc");
1879 if (!QtGuiContext::getQtCurrent()) return;
1880 if (!QtGuiContext::getQtCurrent()->getGuiExecutor()) return;
1881 QtGuiContext::getQtCurrent()->getGuiExecutor()->shutdownProc();
1884 void GenericGui::onEditDataTypes()
1886 DEBTRACE("GenericGui::onEditDataTypes");
1889 void GenericGui::onCreateDataType()
1891 DEBTRACE("GenericGui::onCreateDataType");
1894 void GenericGui::onImportDataType()
1896 DEBTRACE("GenericGui::onImportDataType");
1897 if (_dwCatalogs) _dwCatalogs->raise();
1900 void GenericGui::onSelectComponentInstance()
1902 DEBTRACE("GenericGui::onSelectComponentInstance");
1903 Subject *sub = QtGuiContext::getQtCurrent()->getSelectedSubject();
1905 SubjectComponent *ref = dynamic_cast<SubjectComponent*>(sub);
1907 YACS::ENGINE::ComponentInstance* compo=ref->getComponent();
1908 QtGuiContext::getQtCurrent()->_mapOfLastComponentInstance[compo->getCompoName()]=compo;
1911 void GenericGui::onNewContainer()
1913 DEBTRACE("GenericGui::onNewContainer");
1914 _guiEditor->CreateContainer();
1917 void GenericGui::onNewSalomeComponent()
1919 DEBTRACE("GenericGui::onNewSalomeComponent");
1920 _guiEditor->CreateComponentInstance();
1923 void GenericGui::onNewSalomePythonComponent()
1925 DEBTRACE("GenericGui::onNewSalomePythonComponent");
1928 void GenericGui::onNewCorbaComponent()
1930 DEBTRACE("GenericGui::onNewCorbaComponent");
1934 void GenericGui::onSalomeServiceNode()
1936 DEBTRACE("GenericGui::onSalomeServiceNode");
1937 _guiEditor->CreateNode("SalomeNode");
1940 void GenericGui::onServiceInlineNode()
1942 DEBTRACE("GenericGui::onServiceInlineNode");
1943 _guiEditor->CreateNode("SalomePythonNode");
1946 void GenericGui::onCORBAServiceNode()
1948 DEBTRACE("GenericGui::onCORBAServiceNode");
1949 _guiEditor->CreateNode("CORBANode");
1952 void GenericGui::onNodeNodeServiceNode()
1954 DEBTRACE("GenericGui::onNodeNodeServiceNode");
1957 void GenericGui::onCppNode()
1959 DEBTRACE("GenericGui::onCppNode");
1960 _guiEditor->CreateNode("CppNode");
1963 void GenericGui::onXMLNode()
1965 DEBTRACE("GenericGui::onXMLNode");
1966 _guiEditor->CreateNode("XmlNode");
1969 void GenericGui::onInDataNode()
1971 DEBTRACE("GenericGui::onInDataNode");
1972 _guiEditor->CreateNode("PresetNode");
1975 void GenericGui::onOutDataNode()
1977 DEBTRACE("GenericGui::onOutDataNode");
1978 _guiEditor->CreateNode("OutNode");
1981 void GenericGui::onInStudyNode()
1983 DEBTRACE("GenericGui::onInStudyNode");
1984 _guiEditor->CreateNode("StudyInNode");
1987 void GenericGui::onOutStudyNode()
1989 DEBTRACE("GenericGui::onOutStudyNode");
1990 _guiEditor->CreateNode("StudyOutNode");
1993 void GenericGui::onInlineScriptNode()
1995 DEBTRACE("GenericGui::onInlineScriptNode");
1996 _guiEditor->CreateNode("PyScript");
1999 void GenericGui::onInlineFunctionNode()
2001 DEBTRACE("GenericGui::onInlineFunctionNode");
2002 _guiEditor->CreateNode("PyFunction");
2005 void GenericGui::onBlockNode()
2007 DEBTRACE("GenericGui::onBlockNode");
2008 _guiEditor->CreateBloc();
2011 void GenericGui::onFORNode()
2013 DEBTRACE("GenericGui::onFORNode");
2014 _guiEditor->CreateForLoop();
2017 void GenericGui::onFOREACHNode()
2019 DEBTRACE("GenericGui::onFOREACHNode");
2020 createForEachLoop("double");
2023 void GenericGui::createForEachLoop(std::string type)
2025 DEBTRACE("GenericGui::createForEachLoop");
2026 _guiEditor->CreateForEachLoop(type);
2029 void GenericGui::onWHILENode()
2031 DEBTRACE("GenericGui::onWHILENode");
2032 _guiEditor->CreateWhileLoop();
2035 void GenericGui::onSWITCHNode()
2037 DEBTRACE("GenericGui::onSWITCHNode");
2038 _guiEditor->CreateSwitch();
2041 void GenericGui::onOptimizerLoop()
2043 DEBTRACE("GenericGui::onOptimizerLoop");
2044 _guiEditor->CreateOptimizerLoop();
2047 void GenericGui::onNodeFromCatalog()
2049 DEBTRACE("GenericGui::onNodeFromCatalog");
2050 if (_dwCatalogs) _dwCatalogs->raise();
2053 void GenericGui::onDeleteItem()
2055 DEBTRACE("GenericGui::onDeleteItem");
2056 _guiEditor->DeleteSubject();
2059 void GenericGui::onCutItem()
2061 DEBTRACE("GenericGui::onCutItem");
2062 _guiEditor->CutSubject();
2065 void GenericGui::onCopyItem()
2067 DEBTRACE("GenericGui::onCopyItem");
2068 _guiEditor->CopySubject();
2071 void GenericGui::onPasteItem()
2073 DEBTRACE("GenericGui::onPasteItem");
2074 _guiEditor->PasteSubject();
2077 void GenericGui::onPutInBloc()
2079 _guiEditor->PutSubjectInBloc();
2082 void GenericGui::onPutGraphInBloc()
2084 DEBTRACE("GenericGui::onPutGraphInBloc");
2085 _guiEditor->PutGraphInBloc();
2086 _guiEditor->arrangeNodes(false);
2089 void GenericGui::onPutGraphInForLoop()
2091 DEBTRACE("GenericGui::onPutGraphInForLoop");
2092 _guiEditor->PutGraphInNode("ForLoop");
2095 void GenericGui::putGraphInForeachLoop(std::string type)
2097 DEBTRACE("GenericGui::PutGraphInForeachLoop");
2098 _guiEditor->PutGraphInNode("ForEachLoop_"+type);
2101 void GenericGui::onPutGraphInWhileLoop()
2103 DEBTRACE("GenericGui::onPutGraphInWhileLoop");
2104 _guiEditor->PutGraphInNode("WhileLoop");
2107 void GenericGui::onPutGraphInOptimizerLoop()
2109 DEBTRACE("GenericGui::onPutGraphInOptimizerLoop");
2110 _guiEditor->PutGraphInNode("OptimizerLoop");
2113 void GenericGui::onArrangeLocalNodes()
2115 DEBTRACE("GenericGui::onArrangeLocalNodes");
2116 _guiEditor->arrangeNodes(false);
2119 void GenericGui::onArrangeRecurseNodes()
2121 DEBTRACE("GenericGui::onArrangeRecurseNodes");
2122 _guiEditor->arrangeNodes(true);
2125 void GenericGui::onRebuildLinks()
2127 DEBTRACE("GenericGui::onRebuildLinks");
2128 _guiEditor->rebuildLinks();
2131 void GenericGui::onZoomToBloc()
2133 DEBTRACE("GenericGui::onZoomToBloc");
2134 QtGuiContext::getQtCurrent()->getView()->onZoomToBloc();
2137 void GenericGui::onCenterOnNode()
2139 DEBTRACE("GenericGui::onCenterOnNode");
2140 QtGuiContext::getQtCurrent()->getView()->onCenterOnNode();
2143 void GenericGui::onShrinkExpand() {
2144 DEBTRACE("GenericGui::onShrinkExpand");
2145 _guiEditor->shrinkExpand();
2148 void GenericGui::onToggleStraightLinks(bool checked)
2150 Scene::_straightLinks = checked;
2151 DEBTRACE("Scene::_straightLinks=" << checked);
2152 if (!QtGuiContext::getQtCurrent())
2154 map<Subject*, SchemaItem*>::const_iterator it = QtGuiContext::getQtCurrent()->_mapOfSchemaItem.begin();
2155 for( ; it != QtGuiContext::getQtCurrent()->_mapOfSchemaItem.end(); ++it)
2157 Subject* sub = (*it).first;
2158 sub->update(SWITCHSHAPE, 0, 0);
2162 void GenericGui::onToggleAutomaticComputeLinks(bool checked)
2164 Scene::_autoComputeLinks = checked;
2165 DEBTRACE("Scene::_autoComputeLinks=" << checked);
2168 void GenericGui::onToggleSimplifyLinks(bool checked)
2170 Scene::_simplifyLinks = checked;
2171 DEBTRACE("Scene::_simplifyLinks=" << checked);
2174 void GenericGui::onToggleForce2NodesLinks(bool checked)
2176 Scene::_force2NodesLink = checked;
2177 DEBTRACE("Scene::_force2NodesLink=" << checked);
2180 void GenericGui::onToggleAddRowCols(bool checked)
2182 Scene::_addRowCols = checked;
2183 DEBTRACE("Scene::_addRowCols=" << checked);
2186 void GenericGui::onSelectReference()
2188 Subject *sub = QtGuiContext::getQtCurrent()->getSelectedSubject();
2190 SubjectReference *ref = dynamic_cast<SubjectReference*>(sub);
2192 SubjectServiceNode *snode = dynamic_cast<SubjectServiceNode*>(ref->getReference());
2193 snode->select(true);
2196 void GenericGui::onWhatsThis()
2198 DEBTRACE("GenericGui::onWhatsThis");
2199 QWhatsThis::enterWhatsThisMode();
2202 void GenericGui::onWithoutStopMode(bool checked)
2204 DEBTRACE("GenericGui::onWithoutStopMode " << checked);
2205 if (!QtGuiContext::getQtCurrent()) return;
2206 if (!QtGuiContext::getQtCurrent()->getGuiExecutor()) return;
2207 if (checked) QtGuiContext::getQtCurrent()->getGuiExecutor()->setContinueMode();
2210 void GenericGui::onBreakpointsMode(bool checked)
2212 DEBTRACE("GenericGui::onWithoutStopMode " << checked);
2213 if (!QtGuiContext::getQtCurrent()) return;
2214 if (!QtGuiContext::getQtCurrent()->getGuiExecutor()) return;
2215 if (checked) QtGuiContext::getQtCurrent()->getGuiExecutor()->setBreakpointMode();
2218 void GenericGui::onStepByStepMode(bool checked)
2220 DEBTRACE("GenericGui::onWithoutStopMode " << checked);
2221 if (!QtGuiContext::getQtCurrent()) return;
2222 if (!QtGuiContext::getQtCurrent()->getGuiExecutor()) return;
2223 if (checked) QtGuiContext::getQtCurrent()->getGuiExecutor()->setStepByStepMode();
2226 void GenericGui::onToggleStopOnError(bool checked)
2228 DEBTRACE("GenericGui::onToggleStopOnError " << checked);
2229 if (!QtGuiContext::getQtCurrent()) return;
2230 if (!QtGuiContext::getQtCurrent()->getGuiExecutor()) return;
2232 QtGuiContext::getQtCurrent()->getGuiExecutor()->setStopOnError(false);
2234 QtGuiContext::getQtCurrent()->getGuiExecutor()->unsetStopOnError();
2237 void GenericGui::onToggleSceneItemVisible(bool checked)
2239 DEBTRACE("GenericGui::onToggleSceneItemVisible " << checked);
2240 if (!QtGuiContext::getQtCurrent()) return;
2241 Subject *sub = QtGuiContext::getQtCurrent()->getSelectedSubject();
2242 SubjectNode *snode = dynamic_cast<SubjectNode*>(sub);
2245 if (!QtGuiContext::getQtCurrent()->_mapOfSceneItem.count(sub)) return;
2247 SceneItem *item = QtGuiContext::getQtCurrent()->_mapOfSceneItem[sub];
2248 item->setVisible(checked);
2251 void GenericGui::displayLinks(bool isShown)
2253 if (!QtGuiContext::getQtCurrent()) return;
2254 map<pair<YACS::ENGINE::OutPort*, YACS::ENGINE::InPort*>,YACS::HMI::SubjectLink*>::const_iterator it;
2255 for (it = QtGuiContext::getQtCurrent()->_mapOfSubjectLink.begin();
2256 it != QtGuiContext::getQtCurrent()->_mapOfSubjectLink.end();
2259 YACS::HMI::SubjectLink* sub = (*it).second;
2261 SceneItem *item = QtGuiContext::getQtCurrent()->_mapOfSceneItem[sub];
2262 item->setVisible(isShown);
2266 void GenericGui::displayControlLinks(bool isShown)
2268 if (!QtGuiContext::getQtCurrent()) return;
2269 map<pair<YACS::ENGINE::Node*, YACS::ENGINE::Node*>,YACS::HMI::SubjectControlLink*>::const_iterator it;
2270 for (it = QtGuiContext::getQtCurrent()->_mapOfSubjectControlLink.begin();
2271 it != QtGuiContext::getQtCurrent()->_mapOfSubjectControlLink.end();
2274 YACS::HMI::SubjectControlLink* sub = (*it).second;
2276 SceneItem *item = QtGuiContext::getQtCurrent()->_mapOfSceneItem[sub];
2277 item->setVisible(isShown);
2281 void GenericGui::displayPortLinks(bool isShown)
2283 Subject *sub = QtGuiContext::getQtCurrent()->getSelectedSubject();
2284 DEBTRACE("displayPortLinks, subject : " << sub->getName());
2285 SubjectDataPort *sport = dynamic_cast<SubjectDataPort*>(sub);
2288 DEBTRACE("dataPort : " << sport->getName());
2289 list<SubjectLink*> linkList = sport->getListOfSubjectLink();
2290 list<SubjectLink*>::const_iterator it = linkList.begin();
2291 for( ; it != linkList.end(); ++it)
2293 YACS::HMI::SubjectLink* sub = (*it);
2295 SceneItem *item = QtGuiContext::getQtCurrent()->_mapOfSceneItem[sub];
2296 item->setVisible(isShown);
2300 SubjectNode *snode = dynamic_cast<SubjectNode*>(sub);
2303 DEBTRACE("Node : " << snode->getName());
2304 list<SubjectControlLink*> linkList = snode->getSubjectControlLinks();
2305 list<SubjectControlLink*>::const_iterator it = linkList.begin();
2306 for( ; it != linkList.end(); ++it)
2308 YACS::HMI::SubjectControlLink* sub = (*it);
2310 SceneItem *item = QtGuiContext::getQtCurrent()->_mapOfSceneItem[sub];
2311 item->setVisible(isShown);
2317 void GenericGui::displayALink(bool isShown)
2319 Subject *sub = QtGuiContext::getQtCurrent()->getSelectedSubject();
2320 if (! QtGuiContext::getQtCurrent()->_mapOfSceneItem.count(sub)) return;
2321 SceneItem *item = QtGuiContext::getQtCurrent()->_mapOfSceneItem[sub];
2322 item->setVisible(isShown);
2325 void GenericGui::onShowAllLinks()
2327 DEBTRACE("GenericGui::onShowAllLinks");
2329 displayControlLinks(true);
2332 void GenericGui::onHideAllLinks()
2334 DEBTRACE("GenericGui::onHideAllLinks");
2335 displayLinks(false);
2336 displayControlLinks(false);
2339 void GenericGui::onShowOnlyPortLinks()
2341 DEBTRACE("GenericGui::onShowOnlyPortLinks");
2343 displayPortLinks(true);
2346 void GenericGui::onShowPortLinks()
2348 DEBTRACE("GenericGui::onShowPortLinks");
2349 displayPortLinks(true);
2352 void GenericGui::onHidePortLinks()
2354 DEBTRACE("GenericGui::onHidePortLinks");
2355 displayPortLinks(false);
2358 void GenericGui::onEmphasisPortLinks()
2360 DEBTRACE("GenericGui::onEmphasisPortLinks");
2361 if (!QtGuiContext::getQtCurrent()) return;
2362 Subject *sub = QtGuiContext::getQtCurrent()->getSelectedSubject();
2363 DEBTRACE("EmphasizePortLinks, subject : " << sub->getName());
2367 SubjectDataPort *sport = dynamic_cast<SubjectDataPort*>(sub);
2370 emphasizePortLink(sport, true);
2374 // --- if a Node, explore all data ports
2376 SubjectNode *snode = dynamic_cast<SubjectNode*>(sub);
2379 DEBTRACE("Node : " << snode->getName());
2381 list<SubjectInputPort*> linkList = snode->getSubjectInputPorts();
2382 list<SubjectInputPort*>::const_iterator it = linkList.begin();
2383 for( ; it != linkList.end(); ++it)
2385 YACS::HMI::SubjectInputPort* sub = (*it);
2387 emphasizePortLink(sub, true);
2391 list<SubjectOutputPort*> linkList = snode->getSubjectOutputPorts();
2392 list<SubjectOutputPort*>::const_iterator it = linkList.begin();
2393 for( ; it != linkList.end(); ++it)
2395 YACS::HMI::SubjectOutputPort* sub = (*it);
2397 emphasizePortLink(sub, true);
2404 void GenericGui::onShowOnlyCtrlLinks()
2406 DEBTRACE("GenericGui::onShowOnlyCtrlLinks");
2408 displayPortLinks(true);
2411 void GenericGui::onShowCtrlLinks()
2413 DEBTRACE("GenericGui::onShowCtrlLinks");
2414 displayPortLinks(true);
2417 void GenericGui::onHideCtrlLinks()
2419 DEBTRACE("GenericGui::onHideCtrlLinks");
2420 displayPortLinks(false);
2423 void GenericGui::onEmphasisCtrlLinks()
2425 DEBTRACE("GenericGui::onEmphasisCtrlLinks");
2426 Subject *sub = QtGuiContext::getQtCurrent()->getSelectedSubject();
2427 DEBTRACE("Emphasize Ctrl Links, subject : " << sub->getName());
2430 SubjectNode *snode = dynamic_cast<SubjectNode*>(sub);
2433 DEBTRACE("Node : " << snode->getName());
2434 list<SubjectControlLink*> linkList = snode->getSubjectControlLinks();
2435 list<SubjectControlLink*>::const_iterator it = linkList.begin();
2436 for( ; it != linkList.end(); ++it)
2438 YACS::HMI::SubjectControlLink* sub = (*it);
2440 sub->update(EMPHASIZE, true, sub);
2441 Subject *sin = sub->getSubjectInNode();
2442 Subject *sout = sub->getSubjectOutNode();
2443 sin->update(EMPHASIZE, true, sub);
2444 sout->update(EMPHASIZE, true, sub);
2450 void GenericGui::onShowOnlyLink()
2452 DEBTRACE("GenericGui::onShowOnlyLink");
2457 void GenericGui::onShowLink()
2459 DEBTRACE("GenericGui::onShowLink");
2463 void GenericGui::onHideLink()
2465 DEBTRACE("GenericGui::onHideLink");
2466 displayALink(false);
2469 void GenericGui::onEmphasisLink()
2471 DEBTRACE("GenericGui::onEmphasisLink");
2472 Subject *sub = QtGuiContext::getQtCurrent()->getSelectedSubject();
2475 sub->update(EMPHASIZE, true, sub);
2478 void GenericGui::onDeEmphasizeAll()
2480 DEBTRACE("GenericGui::onDeEmphasizeAll");
2481 map<Subject*, SchemaItem*>::const_iterator it = QtGuiContext::getQtCurrent()->_mapOfSchemaItem.begin();
2482 for( ; it != QtGuiContext::getQtCurrent()->_mapOfSchemaItem.end(); ++it)
2484 Subject* sub = (*it).first;
2485 sub->update(EMPHASIZE, false, sub);
2489 void GenericGui::onUndo()
2491 DEBTRACE("GenericGui::onUndo");
2492 if (QtGuiContext::getQtCurrent()->_setOfModifiedSubjects.empty())
2493 QtGuiContext::getQtCurrent()->getInvoc()->undo();
2494 else Message("undo not possible when there are local modifications not confirmed");
2497 void GenericGui::onRedo()
2499 DEBTRACE("GenericGui::onRedo");
2500 if (QtGuiContext::getQtCurrent()->_setOfModifiedSubjects.empty())
2501 QtGuiContext::getQtCurrent()->getInvoc()->redo();
2502 else Message("redo not possible when there are local modifications not confirmed");
2505 void GenericGui::onShowUndo()
2507 _guiEditor->showUndo(_parent);
2510 void GenericGui::onShowRedo()
2512 _guiEditor->showRedo(_parent);
2515 void GenericGui::onCleanOnExit()
2517 DEBTRACE("GenericGui::onCleanOnExit");
2518 int studyId = _wrapper->activeStudyId();
2519 map<QWidget*, YACS::HMI::QtGuiContext*> mapViewContextCopy = _mapViewContext;
2520 map<QWidget*, YACS::HMI::QtGuiContext*>::iterator it = mapViewContextCopy.begin();
2521 for (; it != mapViewContextCopy.end(); ++it)
2523 closeContext((*it).first, true);
2527 void GenericGui::emphasizePortLink(YACS::HMI::SubjectDataPort* sub, bool emphasize)
2529 DEBTRACE("dataPort : " << sub->getName());
2530 list<SubjectLink*> linkList = sub->getListOfSubjectLink();
2531 list<SubjectLink*>::const_iterator it = linkList.begin();
2532 for( ; it != linkList.end(); ++it)
2534 YACS::HMI::SubjectLink* subli = (*it);
2535 if (!subli) continue;
2536 subli->update(EMPHASIZE, emphasize, sub);
2537 Subject *sin = subli->getSubjectInPort();
2538 Subject *sout = subli->getSubjectOutPort();
2539 sin->update(EMPHASIZE, emphasize, sub);
2540 sout->update(EMPHASIZE, emphasize, sub);
2544 void GenericGui::onHelpContextModule( const QString& theComponentName, const QString& theFileName, const QString& theContext)
2546 _wrapper->onHelpContextModule(theComponentName,theFileName,theContext);