1 // Copyright (C) 2006-2008 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
20 #include "SALOME_ResourcesManager.hxx"
21 #include "SALOME_LifeCycleCORBA.hxx"
23 #include "RuntimeSALOME.hxx"
25 #include "parsers.hxx"
27 #include "YACSGuiLoader.hxx"
29 #include "SALOME_NamingService.hxx"
30 #include "SALOME_ModuleCatalog.hxx"
31 #include "SALOME_ModuleCatalog.hh"
32 #include "SALOMEDS_Tool.hxx"
34 #include "QtGuiContext.hxx"
36 #include "GuiEditor.hxx"
37 #include "GraphicsView.hxx"
39 #include "GenericGui.hxx"
40 #include "SceneItem.hxx"
41 #include "ItemEdition.hxx"
42 #include "CatalogWidget.hxx"
43 #include "TreeView.hxx"
44 #include "VisitorSaveGuiSchema.hxx"
45 #include "TypeCode.hxx"
46 #include "LinkInfo.hxx"
47 #include "LogViewer.hxx"
49 #include <QFileDialog>
53 #include <QMessageBox>
61 #include "YacsTrace.hxx"
64 using namespace YACS::HMI;
66 GenericGui::GenericGui(YACS::HMI::SuitWrapper* wrapper, QMainWindow *parent)
76 _mapViewContext.clear();
80 GuiObserver::setEventMap();
82 string iconPath = getenv("YACS_ROOT_DIR");
83 iconPath += "/share/salome/resources/yacs";
85 QDir::addSearchPath("icons", iconPath.c_str());
87 YACS::ENGINE::RuntimeSALOME::setRuntime();
88 _loader = new YACSGuiLoader();
89 _loader->registerProcCataLoader();
90 _builtinCatalog = YACS::ENGINE::getSALOMERuntime()->getBuiltinCatalog();
94 YACS::ENGINE::RuntimeSALOME* runTime = YACS::ENGINE::getSALOMERuntime();
95 CORBA::ORB_ptr orb = runTime->getOrb();
98 SALOME_NamingService namingService(orb);
99 CORBA::Object_ptr obj = namingService.Resolve("/Kernel/ModulCatalog");
100 SALOME_ModuleCatalog::ModuleCatalog_var aModuleCatalog =
101 SALOME_ModuleCatalog::ModuleCatalog::_narrow(obj);
102 if (! CORBA::is_nil(aModuleCatalog))
104 DEBTRACE("SALOME_ModuleCatalog::ModuleCatalog found");
105 std::string anIOR = orb->object_to_string( aModuleCatalog );
106 _sessionCatalog = runTime->loadCatalog( "session", anIOR );
108 std::map< std::string, YACS::ENGINE::ComponentDefinition * >::iterator it;
109 for (it = _sessionCatalog->_componentMap.begin();
110 it != _sessionCatalog->_componentMap.end(); ++it)
111 DEBTRACE("Component: " <<(*it).first);
114 std::map< std::string, YACS::ENGINE::TypeCode*>::iterator it;
115 for (it = _sessionCatalog->_typeMap.begin();
116 it != _sessionCatalog->_typeMap.end(); ++it)
117 DEBTRACE("Type : " <<(*it).first
118 << " " << (*it).second->getKindRepr()
119 << " " << (*it).second->name()
120 << " " << (*it).second->shortName()
121 << " " << (*it).second->id() );
123 DEBTRACE("_sessionCatalog " << _sessionCatalog);
127 catch(ServiceUnreachable& e)
129 DEBTRACE("Caught Exception. "<<e);
132 _dwTree = new QDockWidget(_parent);
133 _dwTree->setWindowTitle("Tree View: edition mode");
134 _parent->addDockWidget(Qt::LeftDockWidgetArea, _dwTree);
135 _dwStacked = new QDockWidget(_parent);
136 _dwStacked->setWindowTitle("Input Panel");
137 _parent->addDockWidget(Qt::RightDockWidgetArea, _dwStacked);
138 _dwCatalogs = new QDockWidget(_parent);
139 _dwCatalogs->setWindowTitle("Catalogs");
140 _parent->addDockWidget(Qt::RightDockWidgetArea, _dwCatalogs);
141 _catalogsWidget = new CatalogWidget(_dwCatalogs,
144 _catalogsWidget->setMinimumWidth(350); // --- force a minimum until display
145 _dwCatalogs->setWidget(_catalogsWidget);
146 _parent->tabifyDockWidget(_dwStacked, _dwCatalogs);
149 GenericGui::~GenericGui()
153 void GenericGui::createActions()
155 // QAction* createAction(const int id,
156 // const QString& toolTip,
157 // const QIcon& icon,
158 // const QString& menu,
159 // const QString& status,
160 // const int shortCut,
161 // QObject* parent =0,
162 // bool checkable = false,
163 // QObject* receiver =0,
164 // const char* member =0);
168 pixmap.load("icons:new_dataflow.png");
169 _newSchemaAct = _wrapper->createAction(getMenuId(), tr("Create a new YACS Schema"), QIcon(pixmap),
170 tr("New Schema"), tr("Create a new YACS Schema"),
171 0, _parent, false, this, SLOT(onNewSchema()));
173 pixmap.load("icons:import_dataflow.png");
174 _importSchemaAct = _wrapper->createAction(getMenuId(), tr("Import a YACS Schema for edition"), QIcon(pixmap),
175 tr("Import Schema"), tr("Import a YACS Schema for edition"),
176 0, _parent, false, this, SLOT(onImportSchema()));
178 pixmap.load("icons:import_superv_dataflow.png");
179 _importSupervSchemaAct = _wrapper->createAction(getMenuId(), tr("Import a SUPERV Schema for edition"), QIcon(pixmap),
180 tr("Import SUPERV Schema"), tr("Import a SUPERV Schema for edition"),
181 0, _parent, false, this, SLOT(onImportSupervSchema()));
183 pixmap.load("icons:save_dataflow.png");
184 _exportSchemaAct = _wrapper->createAction(getMenuId(), tr("Save the current YACS Schema"), QIcon(pixmap),
185 tr("Save Schema"), tr("Save the current YACS Schema"),
186 0, _parent, false, this, SLOT(onExportSchema()));
188 pixmap.load("icons:export_dataflow.png");
189 _exportSchemaAsAct = _wrapper->createAction(getMenuId(), tr("Save the current YACS Schema As..."), QIcon(pixmap),
190 tr("Save Schema As"), tr("Save the current YACS Schema As..."),
191 0, _parent, false, this, SLOT(onExportSchemaAs()));
193 pixmap.load("icons:insert_file.png");
194 _importCatalogAct = _wrapper->createAction(getMenuId(), tr("Import a Schema as a Catalog"), QIcon(pixmap),
195 tr("Import Catalog"), tr("Import a Schema as a Catalog"),
196 0, _parent, false, this, SLOT(onImportCatalog()));
199 pixmap.load("icons:run_active.png");
200 _runLoadedSchemaAct = _wrapper->createAction(getMenuId(), tr("Prepare the current edited schema for run"), QIcon(pixmap),
201 tr("Run Current Schema"), tr("Prepare the current edited schema for run"),
202 0, _parent, false, this, SLOT(onRunLoadedSchema()));
204 pixmap.load("icons:load_execution_state.png");
205 _loadRunStateSchemaAct = _wrapper->createAction(getMenuId(), tr("Load a previous run state for this schema, prepare to run"), QIcon(pixmap),
206 tr("Load Run State"), tr("Load a previous run state for this schema, prepare to run"),
207 0, _parent, false, this, SLOT(onLoadRunStateSchema()));
209 pixmap.load("icons:run.png");
210 _loadAndRunSchemaAct = _wrapper->createAction(getMenuId(), tr("Load a schema for run"), QIcon(pixmap),
211 tr("Load Schema to run"), tr("Load a schema for run"),
212 0, _parent, false, this, SLOT(onLoadAndRunSchema()));
215 pixmap.load("icons:suspend_resume.png");
216 _startResumeAct = _wrapper->createAction(getMenuId(), tr("Start or Resume Schema execution"), QIcon(pixmap),
217 tr("Start/Resume execution"), tr("Start or Resume Schema execution"),
218 0, _parent, false, this, SLOT(onStartResume()));
220 pixmap.load("icons:kill.png");
221 _abortAct = _wrapper->createAction(getMenuId(), tr("Abort the current execution"), QIcon(pixmap),
222 tr("Abort execution"), tr("Abort the current execution"),
223 0, _parent, false, this, SLOT(onAbort()));
225 pixmap.load("icons:pause.png");
226 _pauseAct = _wrapper->createAction(getMenuId(), tr("Suspend the current execution"), QIcon(pixmap),
227 tr("Suspend execution"), tr("Suspend the current execution"),
228 0, _parent, false, this, SLOT(onPause()));
230 pixmap.load("icons:reset.png");
231 _resetAct = _wrapper->createAction(getMenuId(), tr("Reset the current execution"), QIcon(pixmap),
232 tr("Reset execution"), tr("Reset the current execution"),
233 0, _parent, false, this, SLOT(onReset()));
236 pixmap.load("icons:save_dataflow_state.png");
237 _saveRunStateAct = _wrapper->createAction(getMenuId(), tr("Save the current run state"), QIcon(pixmap),
238 tr("Save State"), tr("Save the current run state"),
239 0, _parent, false, this, SLOT(onSaveRunState()));
241 pixmap.load("icons:new_edition.png");
242 _newEditionAct = _wrapper->createAction(getMenuId(), tr("Edit again the current schema in a new context"), QIcon(pixmap),
243 tr("Edit Again"), tr("Edit again the current schema in a new context"),
244 0, _parent, false, this, SLOT(onNewEdition()));
247 pixmap.load("icons:change_informations.png");
248 _getYacsContainerLogAct = _wrapper->createAction(getMenuId(), tr("get YACS container log"), QIcon(pixmap),
249 tr("YACS Container Log"), tr("get YACS container log"),
250 0, _parent, false, this, SLOT(onGetYacsContainerLog()));
252 pixmap.load("icons:filter_notification.png");
253 _getErrorReportAct = _wrapper->createAction(getMenuId(), tr("get Node Error Report"), QIcon(pixmap),
254 tr("Node Error Report"), tr("get Node Error Report"),
255 0, _parent, false, this, SLOT(onGetErrorReport()));
257 pixmap.load("icons:icon_text.png");
258 _getErrorDetailsAct = _wrapper->createAction(getMenuId(), tr("get Node Error Details"), QIcon(pixmap),
259 tr("Node Error Details"), tr("get Node Error Details"),
260 0, _parent, false, this, SLOT(onGetErrorDetails()));
262 pixmap.load("icons:change_informations.png");
263 _getContainerLogAct = _wrapper->createAction(getMenuId(), tr("get Node Container Log"), QIcon(pixmap),
264 tr("Node Container Log"), tr("get Node Container Log"),
265 0, _parent, false, this, SLOT(onGetContainerLog()));
269 pixmap.load("icons:kill.png");
270 _editDataTypesAct = _wrapper->createAction(getMenuId(), tr("Edit Data Types"), QIcon(pixmap),
271 tr("Edit Data Types"), tr("Edit Data Types"),
272 0, _parent, false, this, SLOT(onEditDataTypes()));
274 pixmap.load("icons:kill.png");
275 _createDataTypeAct = _wrapper->createAction(getMenuId(), tr("Create Data Types"), QIcon(pixmap),
276 tr("Create Data Types"), tr("Create Data Types"),
277 0, _parent, false, this, SLOT(onCreateDataType()));
279 pixmap.load("icons:folder_cyan.png");
280 _importDataTypeAct = _wrapper->createAction(getMenuId(), tr("Import Data Types, use drag and drop from catalog"), QIcon(pixmap),
281 tr("Import Data Types"), tr("Import Data Types, use drag and drop from catalog"),
282 0, _parent, false, this, SLOT(onImportDataType()));
284 pixmap.load("icons:container.png");
285 _newContainerAct = _wrapper->createAction(getMenuId(), tr("Create a New Container"), QIcon(pixmap),
286 tr("Create Container"), tr("Create a New Container"),
287 0, _parent, false, this, SLOT(onNewContainer()));
289 pixmap.load("icons:new_salome_component.png");
290 _newSalomeComponentAct = _wrapper->createAction(getMenuId(), tr("Create a New SALOME Component"), QIcon(pixmap),
291 tr("SALOME Component"), tr("Create a New SALOME Component"),
292 0, _parent, false, this, SLOT(onNewSalomeComponent()));
294 pixmap.load("icons:new_salomepy_component.png");
295 _newSalomePythonComponentAct = _wrapper->createAction(getMenuId(), tr("Create a New SALOME Python Component"), QIcon(pixmap),
296 tr("SALOME Python Component"), tr("Create a New SALOME Python Component"),
297 0, _parent, false, this, SLOT(onNewSalomePythonComponent()));
299 pixmap.load("icons:new_corba_component.png");
300 _newCorbaComponentAct = _wrapper->createAction(getMenuId(), tr("Create a New CORBA Component"), QIcon(pixmap),
301 tr("CORBA Component"), tr("Create a New CORBA Component"),
302 0, _parent, false, this, SLOT(onNewCorbaComponent()));
304 pixmap.load("icons:schema.png");
305 _newSchemaAct = _wrapper->createAction(getMenuId(), tr("New Schema"), QIcon(pixmap),
306 tr("New Schema"), tr("New Schema"),
307 0, _parent, false, this, SLOT(onNewSchema()));
309 pixmap.load("icons:new_salome_service_node.png");
310 _salomeServiceNodeAct = _wrapper->createAction(getMenuId(), tr("Create a New SALOME Service Node"), QIcon(pixmap),
311 tr("SALOME Service Node"), tr("Create a New SALOME Service Node"),
312 0, _parent, false, this, SLOT(onSalomeServiceNode()));
314 pixmap.load("icons:new_service_inline_node.png");
315 _serviceInlineNodeAct = _wrapper->createAction(getMenuId(), tr("Create a New Inline Service Node"), QIcon(pixmap),
316 tr("Inline Service Node"), tr("Create a New Inline Service Node"),
317 0, _parent, false, this, SLOT(onServiceInlineNode()));
319 pixmap.load("icons:new_corba_service_node.png");
320 _CORBAServiceNodeAct = _wrapper->createAction(getMenuId(), tr("Create a New CORBA Service Node"), QIcon(pixmap),
321 tr("CORBA Node"), tr("Create a New CORBA Service Node"),
322 0, _parent, false, this, SLOT(onCORBAServiceNode()));
324 pixmap.load("icons:new_nodenode_service_node.png");
325 _nodeNodeServiceNodeAct = _wrapper->createAction(getMenuId(), tr("Create a New Node referencing a Node"), QIcon(pixmap),
326 tr("Ref on Node"), tr("Create a New Node referencing a Node"),
327 0, _parent, false, this, SLOT(onNodeNodeServiceNode()));
329 pixmap.load("icons:new_cpp_node.png");
330 _cppNodeAct = _wrapper->createAction(getMenuId(), tr("Create a New C++ Node"), QIcon(pixmap),
331 tr("Cpp Node"), tr("Create a New C++ Node"),
332 0, _parent, false, this, SLOT(onCppNode()));
334 pixmap.load("icons:kill.png");
335 _inDataNodeAct = _wrapper->createAction(getMenuId(), tr("Create a New Input data Node"), QIcon(pixmap),
336 tr("Input Data Node"), tr("Create a New Input data Node"),
337 0, _parent, false, this, SLOT(onInDataNode()));
339 pixmap.load("icons:kill.png");
340 _outDataNodeAct = _wrapper->createAction(getMenuId(), tr("Create a New Output data Node"), QIcon(pixmap),
341 tr("Output Data Node"), tr("Create a New Output data Node"),
342 0, _parent, false, this, SLOT(onOutDataNode()));
344 pixmap.load("icons:kill.png");
345 _inStudyNodeAct = _wrapper->createAction(getMenuId(), tr("Create a New Input Study Node"), QIcon(pixmap),
346 tr("Input Study Node"), tr("Create a New Input Study Node"),
347 0, _parent, false, this, SLOT(onInStudyNode()));
349 pixmap.load("icons:kill.png");
350 _outStudyNodeAct = _wrapper->createAction(getMenuId(), tr("Create a New Output Study Node"), QIcon(pixmap),
351 tr("Output Study Node"), tr("Create a New Output Study Node"),
352 0, _parent, false, this, SLOT(onOutStudyNode()));
354 pixmap.load("icons:new_inline_script_node.png");
355 _inlineScriptNodeAct = _wrapper->createAction(getMenuId(), tr("Create a New Inline Python Script Node"), QIcon(pixmap),
356 tr("Inline Script Node"), tr("Create a New Inline Python Script Node"),
357 0, _parent, false, this, SLOT(onInlineScriptNode()));
359 pixmap.load("icons:new_inline_function_node.png");
360 _inlineFunctionNodeAct = _wrapper->createAction(getMenuId(), tr("Create a New Inline Python Function Node"), QIcon(pixmap),
361 tr("Inline Function Node"), tr("Create a New Inline Python Function Node"),
362 0, _parent, false, this, SLOT(onInlineFunctionNode()));
364 pixmap.load("icons:new_block_node.png");
365 _blockNodeAct = _wrapper->createAction(getMenuId(), tr("Create a New Bloc Node"), QIcon(pixmap),
366 tr("bloc Node"), tr("Create a New Bloc Node"),
367 0, _parent, false, this, SLOT(onBlockNode()));
369 pixmap.load("icons:new_for_loop_node.png");
370 _FORNodeAct = _wrapper->createAction(getMenuId(), tr("Create a New For Loop Node"), QIcon(pixmap),
371 tr("For Loop Node"), tr("Create a New For Loop Node"),
372 0, _parent, false, this, SLOT(onFORNode()));
374 pixmap.load("icons:new_foreach_loop_node.png");
375 _FOREACHNodeAct = _wrapper->createAction(getMenuId(), tr("Create a New For Each Loop Node"), QIcon(pixmap),
376 tr("For Each Loop Node"), tr("Create a New For Each Loop Node"),
377 0, _parent, false, this, SLOT(onFOREACHNode()));
379 pixmap.load("icons:new_while_loop_node.png");
380 _WHILENodeAct = _wrapper->createAction(getMenuId(), tr("Create a New While Loop Node"), QIcon(pixmap),
381 tr("While Loop Node"), tr("Create a New While Loop Node"),
382 0, _parent, false, this, SLOT(onWHILENode()));
384 pixmap.load("icons:new_switch_loop_node.png");
385 _SWITCHNodeAct = _wrapper->createAction(getMenuId(), tr("Create a New Switch Node"), QIcon(pixmap),
386 tr("Switch Node"), tr("Create a New Switch Node"),
387 0, _parent, false, this, SLOT(onSWITCHNode()));
389 pixmap.load("icons:new_from_library_node.png");
390 _nodeFromCatalogAct = _wrapper->createAction(getMenuId(), tr("Create a New Node from Catalog, use drag and drop from catalog"), QIcon(pixmap),
391 tr("Node from Catalog"), tr("Create a New Node from Catalog, use drag and drop from catalog"),
392 0, _parent, false, this, SLOT(onNodeFromCatalog()));
394 pixmap.load("icons:delete.png");
395 _deleteItemAct = _wrapper->createAction(getMenuId(), tr("Delete a Schema Item"), QIcon(pixmap),
396 tr("Delete Item"), tr("Delete a Schema Item"),
397 0, _parent, false, this, SLOT(onDeleteItem()));
399 pixmap.load("icons:cut.png");
400 _cutItemAct = _wrapper->createAction(getMenuId(), tr("Cut a Schema Item"), QIcon(pixmap),
401 tr("Cut Item"), tr("Cut a Schema Item"),
402 0, _parent, false, this, SLOT(onCutItem()));
404 pixmap.load("icons:copy.png");
405 _copyItemAct = _wrapper->createAction(getMenuId(), tr("Copy a Schema Item"), QIcon(pixmap),
406 tr("Copy Item"), tr("Copy a Schema Item"),
407 0, _parent, false, this, SLOT(onCopyItem()));
409 pixmap.load("icons:paste.png");
410 _pasteItemAct = _wrapper->createAction(getMenuId(), tr("Paste a Schema Item"), QIcon(pixmap),
411 tr("Paste Item"), tr("Paste a Schema Item"),
412 0, _parent, false, this, SLOT(onPasteItem()));
414 pixmap.load("icons:arrange_nodes.png");
415 _arrangeLocalNodesAct = _wrapper->createAction(getMenuId(), tr("arrange nodes on that bloc level, without recursion"), QIcon(pixmap),
416 tr("arrange local nodes"), tr("arrange nodes on that bloc level, without recursion"),
417 0, _parent, false, this, SLOT(onArrangeLocalNodes()));
419 pixmap.load("icons:sample.png");
420 _arrangeRecurseNodesAct = _wrapper->createAction(getMenuId(), tr("arrange nodes on that bloc level, with recursion"), QIcon(pixmap),
421 tr("arrange nodes recursion"), tr("arrange nodes on that bloc level, with recursion"),
422 0, _parent, false, this, SLOT(onArrangeRecurseNodes()));
424 pixmap.load("icons:rebuild_links.png");
425 _computeLinkAct = _wrapper->createAction(getMenuId(), tr("compute orthogonal links"), QIcon(pixmap),
426 tr("compute links"), tr("compute orthogonal links"),
427 0, _parent, false, this, SLOT(onRebuildLinks()));
429 pixmap.load("icons:autoComputeLink.png");
430 _toggleAutomaticComputeLinkAct = _wrapper->createAction(getMenuId(), tr("compute othogonal links autoamtically when nodes move"), QIcon(pixmap),
431 tr("automatic link"), tr("compute othogonal links autoamtically when nodes move"),
432 0, _parent, true, this, SLOT(onToggleAutomaticComputeLinks(bool)));
434 _toggleAutomaticComputeLinkAct->setChecked(true);
436 pixmap.load("icons:simplifyLink.png");
437 _toggleSimplifyLinkAct = _wrapper->createAction(getMenuId(), tr("simplify links by removing unnecessary direction changes"), QIcon(pixmap),
438 tr("simplify links"), tr("simplify links by removing unnecessary direction changes"),
439 0, _parent, true, this, SLOT(onToggleSimplifyLinks(bool)));
440 _toggleSimplifyLinkAct->setChecked(true);
442 pixmap.load("icons:force2nodeLink.png");
443 _toggleForce2NodesLinkAct = _wrapper->createAction(getMenuId(), tr("force orthogonal links by adding an edge on simples links"), QIcon(pixmap),
444 tr("force ortho links"), tr("force orthogonal links by adding an edge on simples links"),
445 0, _parent, true, this, SLOT(onToggleForce2NodesLinks(bool)));
446 _toggleForce2NodesLinkAct->setChecked(true);
448 pixmap.load("icons:ob_service_node.png");
449 _selectReferenceAct = _wrapper->createAction(getMenuId(), tr("select reference"), QIcon(pixmap),
450 tr("select reference"), tr("select reference"),
451 0, _parent, false, this, SLOT(onSelectReference()));
453 pixmap.load("icons:whatsThis.png");
454 _whatsThisAct = _wrapper->createAction(getMenuId(), tr("active whatsThis Mode to get help on widgets"), QIcon(pixmap),
455 tr("whatsThis Mode"), tr("active whatsThis Mode to get help on widgets"),
456 0, _parent, false, this, SLOT(onWhatsThis()));
458 pixmap.load("icons:run_active.png");
459 _withoutStopModeAct = _wrapper->createAction(getMenuId(), tr("set execution mode without stop"), QIcon(pixmap),
460 tr("mode without stop"), tr("set execution mode without stop"),
461 0, _parent, true, this, SLOT(onWithoutStopMode(bool)));
463 pixmap.load("icons:breakpoints_active.png");
464 _breakpointsModeAct = _wrapper->createAction(getMenuId(), tr("set execution mode with stop on breakpoints"), QIcon(pixmap),
465 tr("mode breakpoints"), tr("set execution mode with stop on breakpoints"),
466 0, _parent, true, this, SLOT(onBreakpointsMode(bool)));
468 pixmap.load("icons:step_by_step_active.png");
469 _stepByStepModeAct = _wrapper->createAction(getMenuId(), tr("set execution mode step by step"), QIcon(pixmap),
470 tr("mode step by step"), tr("set execution mode step by step"),
471 0, _parent, true, this, SLOT(onStepByStepMode(bool)));
473 pixmap.load("icons:toggle_stop_on_error.png");
474 _toggleStopOnErrorAct = _wrapper->createAction(getMenuId(), tr("Force stop on first error during execution"), QIcon(pixmap),
475 tr("stop on error"), tr("Force stop on first error during execution"),
476 0, _parent, true, this, SLOT(onToggleStopOnError(bool)));
478 pixmap.load("icons:toggleVisibility.png");
479 _toggleSceneItemVisibleAct = _wrapper->createAction(getMenuId(), tr("toggle 2D scene item visibility"), QIcon(pixmap),
480 tr("visible/hidden"), tr("toggle 2D scene item visibility"),
481 0, _parent, true, this, SLOT(onToggleSceneItemVisible(bool)));
484 _execModeGroup = new QActionGroup(this);
485 _execModeGroup->addAction(_withoutStopModeAct);
486 _execModeGroup->addAction(_breakpointsModeAct);
487 _execModeGroup->addAction(_stepByStepModeAct);
488 _withoutStopModeAct->setChecked(true);
491 pixmap.load("icons:.png");
492 _ = _wrapper->createAction(getMenuId(), tr(""), QIcon(pixmap),
494 0, _parent, false, this, SLOT());
501 void GenericGui::createMenus()
504 aMenuId = _wrapper->createMenu( "File", -1, -1 );
505 _wrapper->createMenu( _wrapper->separator(), aMenuId, -1, 10 );
506 aMenuId = _wrapper->createMenu( "YACS" , aMenuId, -1, 10 );
507 _wrapper->createMenu( _newSchemaAct, aMenuId );
508 _wrapper->createMenu( _importSchemaAct, aMenuId );
510 aMenuId = _wrapper->createMenu( tr( "YACS" ), -1, -1, 30 );
511 _wrapper->createMenu( _newSchemaAct, aMenuId );//, 10
512 _wrapper->createMenu( _importSchemaAct, aMenuId );
513 _wrapper->createMenu( _importSupervSchemaAct, aMenuId );
514 _wrapper->createMenu( _wrapper->separator(), aMenuId);
515 _wrapper->createMenu( _exportSchemaAct, aMenuId );
516 _wrapper->createMenu( _exportSchemaAsAct, aMenuId );
517 _wrapper->createMenu( _wrapper->separator(), aMenuId);
518 _wrapper->createMenu( _runLoadedSchemaAct, aMenuId );
519 _wrapper->createMenu( _loadRunStateSchemaAct, aMenuId );
520 _wrapper->createMenu( _loadAndRunSchemaAct, aMenuId );
521 _wrapper->createMenu( _wrapper->separator(), aMenuId);
522 _wrapper->createMenu( _startResumeAct, aMenuId );
523 _wrapper->createMenu( _abortAct, aMenuId );
524 _wrapper->createMenu( _pauseAct, aMenuId );
525 _wrapper->createMenu( _resetAct, aMenuId );
526 _wrapper->createMenu( _wrapper->separator(), aMenuId);
527 _wrapper->createMenu( _saveRunStateAct, aMenuId );
528 _wrapper->createMenu( _newEditionAct, aMenuId );
529 _wrapper->createMenu( _wrapper->separator(), aMenuId);
530 _wrapper->createMenu( _withoutStopModeAct, aMenuId );
531 _wrapper->createMenu( _breakpointsModeAct, aMenuId );
532 _wrapper->createMenu( _stepByStepModeAct, aMenuId );
533 _wrapper->createMenu( _wrapper->separator(), aMenuId);
534 _wrapper->createMenu( _toggleStopOnErrorAct, aMenuId );
535 _wrapper->createMenu( _wrapper->separator(), aMenuId);
536 _wrapper->createMenu( _importCatalogAct, aMenuId );
537 _wrapper->createMenu( _wrapper->separator(), aMenuId);
538 _wrapper->createMenu( _whatsThisAct, aMenuId );
541 void GenericGui::createTools()
543 int aToolId = _wrapper->createTool ( tr( "TOOL_YACS" ) );
544 _wrapper->createTool( _newSchemaAct, aToolId );
545 _wrapper->createTool( _importSchemaAct, aToolId );
546 _wrapper->createTool( _importSupervSchemaAct, aToolId );
547 _wrapper->createTool( _wrapper->separator(), aToolId );
548 _wrapper->createTool( _exportSchemaAct, aToolId );
549 _wrapper->createTool( _exportSchemaAsAct, aToolId );
550 _wrapper->createTool( _wrapper->separator(), aToolId);
551 _wrapper->createTool( _runLoadedSchemaAct, aToolId );
552 _wrapper->createTool( _loadRunStateSchemaAct, aToolId );
553 _wrapper->createTool( _loadAndRunSchemaAct, aToolId );
554 _wrapper->createTool( _wrapper->separator(), aToolId );
555 _wrapper->createTool( _startResumeAct, aToolId );
556 _wrapper->createTool( _abortAct, aToolId );
557 _wrapper->createTool( _pauseAct, aToolId );
558 _wrapper->createTool( _resetAct, aToolId );
559 _wrapper->createTool( _wrapper->separator(), aToolId );
560 _wrapper->createTool( _wrapper->separator(), aToolId );
561 _wrapper->createTool( _saveRunStateAct, aToolId );
562 _wrapper->createTool( _newEditionAct, aToolId );
563 _wrapper->createTool( _withoutStopModeAct, aToolId );
564 _wrapper->createTool( _breakpointsModeAct, aToolId );
565 _wrapper->createTool( _stepByStepModeAct, aToolId );
566 _wrapper->createTool( _wrapper->separator(), aToolId );
567 _wrapper->createTool( _toggleStopOnErrorAct, aToolId );
568 _wrapper->createTool( _wrapper->separator(), aToolId );
569 _wrapper->createTool( _importCatalogAct, aToolId );
570 _wrapper->createTool( _wrapper->separator(), aToolId );
571 _wrapper->createTool( _whatsThisAct, aToolId );
574 void GenericGui::initialMenus()
577 showEditionMenus(false);
578 showExecMenus(false);
581 void GenericGui::showBaseMenus(bool show)
583 DEBTRACE("GenericGui::showBaseMenus " << show);
584 _wrapper->setMenuShown(_newSchemaAct, show);
585 _wrapper->setToolShown(_newSchemaAct, show);
586 _wrapper->setMenuShown(_importSchemaAct, show);
587 _wrapper->setToolShown(_importSchemaAct, show);
588 _wrapper->setMenuShown(_importSupervSchemaAct, show);
589 _wrapper->setToolShown(_importSupervSchemaAct, show);
590 _wrapper->setMenuShown(_loadAndRunSchemaAct, show);
591 _wrapper->setToolShown(_loadAndRunSchemaAct, show);
592 _wrapper->setMenuShown(_whatsThisAct, show);
593 _wrapper->setToolShown(_whatsThisAct, show);
596 void GenericGui::showEditionMenus(bool show)
598 DEBTRACE("GenericGui::showEditionMenus " << show);
599 _wrapper->setMenuShown(_exportSchemaAct, show);
600 _wrapper->setToolShown(_exportSchemaAct, show);
601 _wrapper->setMenuShown(_exportSchemaAsAct, show);
602 _wrapper->setToolShown(_exportSchemaAsAct, show);
603 _wrapper->setMenuShown(_runLoadedSchemaAct, show);
604 _wrapper->setToolShown(_loadRunStateSchemaAct, show);
605 _wrapper->setMenuShown(_loadRunStateSchemaAct, show);
606 _wrapper->setToolShown(_runLoadedSchemaAct, show);
607 _wrapper->setMenuShown(_importCatalogAct, show);
608 _wrapper->setToolShown(_importCatalogAct, show);
611 void GenericGui::showExecMenus(bool show)
613 DEBTRACE("GenericGui::showExecMenus " << show);
614 _wrapper->setMenuShown(_startResumeAct, show);
615 _wrapper->setToolShown(_startResumeAct, show);
616 _wrapper->setMenuShown(_abortAct, show);
617 _wrapper->setToolShown(_abortAct, show);
618 _wrapper->setMenuShown(_pauseAct, show);
619 _wrapper->setToolShown(_pauseAct, show);
620 _wrapper->setMenuShown(_resetAct, show);
621 _wrapper->setToolShown(_resetAct, show);
622 _wrapper->setMenuShown(_saveRunStateAct, show);
623 _wrapper->setToolShown(_saveRunStateAct, show);
624 _wrapper->setMenuShown(_newEditionAct, show);
625 _wrapper->setToolShown(_newEditionAct, show);
626 _wrapper->setMenuShown(_withoutStopModeAct, show);
627 _wrapper->setToolShown(_withoutStopModeAct, show);
628 _wrapper->setMenuShown(_breakpointsModeAct, show);
629 _wrapper->setToolShown(_breakpointsModeAct, show);
630 _wrapper->setMenuShown(_stepByStepModeAct, show);
631 _wrapper->setToolShown(_stepByStepModeAct, show);
632 _wrapper->setMenuShown(_toggleStopOnErrorAct, show);
633 _wrapper->setToolShown(_toggleStopOnErrorAct, show);
636 void GenericGui::switchContext(QWidget *view)
638 DEBTRACE("GenericGui::switchContext");
639 if (! _mapViewContext.count(view))
644 QtGuiContext* newContext = _mapViewContext[view];
645 QtGuiContext* oldContext = QtGuiContext::getQtCurrent();
647 _dwTree->setWidget(newContext->getEditTree());
648 _dwTree->widget()->show();
649 _dwStacked->setWidget(newContext->getStackedWidget());
651 QtGuiContext::setQtCurrent(newContext);
653 if (newContext->isEdition())
656 showEditionMenus(true);
657 showExecMenus(false);
658 if (_dwTree) _dwTree->setWindowTitle("Tree View: edition mode");
663 showEditionMenus(false);
665 _withoutStopModeAct->setChecked(true);
666 if (_dwTree) _dwTree->setWindowTitle("Tree View: execution mode");
670 void GenericGui::showDockWidgets(bool isVisible)
672 DEBTRACE("GenericGui::showDockWidgets " << isVisible);
673 if (_dwTree) _dwTree->setVisible(isVisible);
674 if (_dwStacked) _dwStacked->setVisible(isVisible);
675 if (_dwCatalogs) _dwCatalogs->setVisible(isVisible);
678 void GenericGui::raiseStacked()
680 if (_dwStacked) _dwStacked->raise();
683 std::list<std::string> GenericGui::getMachineList()
685 if (!_machineList.empty()) return _machineList;
687 YACS::ENGINE::RuntimeSALOME* runTime = YACS::ENGINE::getSALOMERuntime();
688 CORBA::ORB_ptr orb = runTime->getOrb();
689 if (!orb) return _machineList;
691 SALOME_NamingService namingService(orb);
692 SALOME_LifeCycleCORBA lcc(&namingService);
694 CORBA::Object_var obj =
695 namingService.Resolve(SALOME_ResourcesManager::_ResourcesManagerNameInNS);
696 if (CORBA::is_nil(obj)) return _machineList;
698 Engines::ResourcesManager_var resManager = Engines::ResourcesManager::_narrow(obj);
699 if(!resManager) return _machineList;
701 Engines::CompoList compoList ;
702 Engines::MachineParameters params;
705 Engines::MachineList* machineList =
706 resManager->GetFittingResources(params, compoList);
708 for (int i = 0; i < machineList->length(); i++)
710 const char* aMachine = (*machineList)[i];
711 _machineList.push_back(aMachine);
717 // -----------------------------------------------------------------------------
719 /*! a QtGuiContext instance is created for each schema in edition or each execution or run
720 * of a schema. The context stores references of a lot of objects related to the edition
722 * \param proc the schema to run or edit, loaded from file or just created empty.
723 * \param schemaName filename of the schema in edition, also used in execution to publish
724 * a run under the edition name in Salome object browser.
725 * \param runName filename of the schema in execution, not used in edition.
726 * \param forEdition if true, edition mode, if false, execution mode.
728 void GenericGui::createContext(YACS::ENGINE::Proc* proc,
729 const QString& schemaName,
730 const QString& runName,
733 DEBTRACE("GenericGui::createContext");
739 QWidget* refWindow = 0; // --- used only on run to refer to the schema in edition
742 fileName = schemaName;
747 if (QtGuiContext::getQtCurrent())
748 refWindow = QtGuiContext::getQtCurrent()->getWindow();
751 QtGuiContext* context = new QtGuiContext(this);
752 QtGuiContext::setQtCurrent(context);
756 context->setEdition(forEdition);
757 context->setSessionCatalog(_sessionCatalog);
758 context->setFileName(fileName);
759 context->setCurrentCatalog(YACS::ENGINE::getSALOMERuntime()->loadCatalog("proc", fileName.toStdString()));
761 // --- scene, viewWindow & GraphicsView
763 Scene *scene = new Scene();
764 QWidget *viewWindow = _wrapper->getNewWindow(scene);
765 _mapViewContext[viewWindow] = context;
766 GraphicsView* gView = new GraphicsView(viewWindow);
767 gView->setScene(scene);
768 gView->setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
769 int studyId = _wrapper->AssociateViewToWindow(gView, viewWindow);
770 context->setStudyId(studyId);
771 context->setScene(scene);
772 context->setView(gView);
773 context->setWindow(viewWindow);
778 SchemaModel *schemaModel = new SchemaModel(context, viewWindow);
779 schemaModel->setEdition(forEdition);
780 context->setSchemaModel(schemaModel);
781 RootSceneItem *rootSceneItem = new RootSceneItem(context);
783 // --- tree associated to model
785 FormEditTree *editTree = new FormEditTree(_dwTree);
786 editTree->setMinimumHeight(400);
787 _dwTree->setWidget(editTree);
789 context->setEditTree(editTree);
790 editTree->tv_schema->setModel(schemaModel);
791 context->setSelectionModel(editTree->tv_schema->selectionModel());
793 QObject::connect(editTree->tv_schema->selectionModel(),
794 SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)),
796 SLOT(updateSelection(const QItemSelection &, const QItemSelection &)));
798 // --- stacked widget
800 QStackedWidget *stacked = new QStackedWidget(_dwStacked);
801 _dwStacked->setWidget(stacked);
802 context->setStackedWidget(stacked);
803 YACS::HMI::ItemEditionRoot* rootEdit = new YACS::HMI::ItemEditionRoot(context,
805 context->getName().c_str());
806 context->setEditionRoot(rootEdit);
808 QObject::connect(schemaModel,
809 SIGNAL(signalSelection(const QModelIndex &)),
811 SLOT(viewSelection(const QModelIndex &)));
815 proc->setEdition(forEdition);
819 double passe = (end_t -start_t);
820 passe = passe/CLOCKS_PER_SEC;
821 cerr <<"create context -1- : " << passe << endl;
825 context->setLoading(true);
827 context->setProc(proc);
828 setLoadedPresentation(proc);
832 double passe = (end_t -start_t);
833 passe = passe/CLOCKS_PER_SEC;
834 cerr <<"create context - load proc- : " << passe << endl;
838 context->setLoading(false);
840 if (forEdition && _wrapper) // --- Edition mode
842 _wrapper->createNewSchema(fileName, viewWindow);
844 else if (_wrapper) // --- Execution Mode
846 GuiExecutor *guiExec = new GuiExecutor(proc);
847 context->setGuiExecutor(guiExec);
848 _wrapper->createNewRun(schemaName, fileName, refWindow, viewWindow);
852 QtGuiContext::getQtCurrent()->getSubjectProc()->update(UPDATE,
853 ProcInvoc::getTypeOfNode(proc),
854 0); // --- force validity check
856 // --- adjust widgets
858 TreeView *vtree = dynamic_cast<TreeView*>(editTree->tv_schema);
860 vtree->resizeColumns();
861 _catalogsWidget->setMinimumWidth(40); // --- reset the constraint on width
862 editTree->setMinimumHeight(40);
867 showEditionMenus(true);
868 showExecMenus(false);
869 if (_dwTree) _dwTree->setWindowTitle("Tree View: edition mode");
873 showEditionMenus(false);
875 _withoutStopModeAct->setChecked(true);
876 if (_dwTree) _dwTree->setWindowTitle("Tree View: execution mode");
880 // -----------------------------------------------------------------------------
882 void GenericGui::setLoadedPresentation(YACS::ENGINE::Proc* proc)
884 map<YACS::ENGINE::Node*, PrsData> presNodes = _loader->getPrsData(proc);
885 if (!presNodes.empty())
887 map<YACS::ENGINE::Node*, PrsData>::iterator it = presNodes.begin();
888 for (; it!= presNodes.end(); ++it)
890 YACS::ENGINE::Node* node = (*it).first;
891 PrsData pres = (*it).second;
892 SubjectNode *snode = QtGuiContext::getQtCurrent()->_mapOfSubjectNode[node];
893 SceneItem *item = QtGuiContext::getQtCurrent()->_mapOfSceneItem[snode];
895 item->setPos(QPointF(pres._x, pres._y));
896 item->setWidth(pres._width);
897 item->setHeight(pres._height);
899 _guiEditor->rebuildLinks();
903 // -----------------------------------------------------------------------------
905 void GenericGui::onNewSchema()
907 DEBTRACE("GenericGui::onNewSchema");
909 std::stringstream name;
910 name << "newSchema_" << ++_schemaCnt;
912 YACS::ENGINE::RuntimeSALOME* runTime = YACS::ENGINE::getSALOMERuntime();
913 YACS::ENGINE::Proc *proc = runTime->createProc(name.str());
915 QString fileName = name.str().c_str();
916 createContext(proc, fileName, "", true);
919 void GenericGui::onImportSchema()
921 DEBTRACE("GenericGui::onImportSchema");
922 QString fn = QFileDialog::getOpenFileName( _parent,
923 "Choose a filename to load" ,
925 tr( "XML-Files (*.xml);;All Files (*)" ));
928 DEBTRACE("file loaded : " <<fn.toStdString());
929 YACS::ENGINE::Proc *proc = _loader->load(fn.toLatin1());
932 QMessageBox msgBox(QMessageBox::Critical,
933 "Import YACS Schema, native YACS XML format",
934 "The file has not the native YACS XML format or is not readable.");
938 YACS::ENGINE::Logger* logger= proc->getLogger("parser");
939 if(!logger->isEmpty())
941 DEBTRACE(logger->getStr());
943 createContext(proc, fn, "", true);
947 void GenericGui::onImportSupervSchema()
949 DEBTRACE("GenericGui::onImportSupervSchema");
950 QString fn = QFileDialog::getOpenFileName( _parent,
951 "Choose a SUPERV filename to load" ,
953 tr( "XML-Files (*.xml);;All Files (*)" ));
954 if (fn.isEmpty()) return;
956 DEBTRACE("file loaded : " <<fn.toStdString());
960 QString tmpDir = "/tmp";
961 QDir aTmpDir(tmpDir);
962 aTmpDir.mkdir(QString("YACS_") + getenv("USER"));
963 assert(aTmpDir.cd(QString("YACS_") + getenv("USER")));
964 QDateTime curTime = QDateTime::currentDateTime();
965 tmpFileName = "SUPERV_import_" + curTime.toString("yyyyMMdd_hhmmss") + ".xml";
966 QString tmpOutput = "salomeloader_output";
967 tmpFileName = aTmpDir.absoluteFilePath(tmpFileName);
968 DEBTRACE(tmpFileName.toStdString());
970 QString aCall = "salomeloader.sh " + fn + " " + tmpFileName + " > " + tmpOutput;
971 DEBTRACE(aCall.toStdString());
973 int ret = system(aCall.toAscii());
976 // --- read file with logs
977 fstream f(tmpOutput.toAscii());
982 // --- Problem in execution
983 int status=WEXITSTATUS(ret);
986 QString mes = "Problems in conversion: some errors but an incomplete proc has nevertheless been created.\n\n";
987 mes += QString(hfile.str().c_str());
988 QMessageBox msgBox(QMessageBox::Warning,
989 "Import YACS Schema, SUPERV XML format",
995 QString mes = "Problems in conversion: a fatal error has been encountered. The proc can't be created.\n\n";
996 mes += QString(hfile.str().c_str());
997 QMessageBox msgBox(QMessageBox::Critical,
998 "Import YACS Schema, SUPERV XML format",
1005 DEBTRACE("Unknown problem: " << ret );
1006 QMessageBox msgBox(QMessageBox::Critical,
1007 "Import YACS Schema, SUPERV XML format",
1008 "Unexpected exception in salomeloader.");
1016 QMessageBox msgBox(QMessageBox::Critical,
1017 "Import YACS Schema, SUPERV XML format",
1018 "Unexpected exception in convertSupervFile");
1024 if (fn.isEmpty()) return; // must not happen
1026 DEBTRACE("file loaded : " <<fn.toStdString());
1027 YACS::ENGINE::Proc *proc = _loader->load(fn.toLatin1());
1030 QMessageBox msgBox(QMessageBox::Critical,
1031 "Import YACS Schema, SUPERV file converted in native YACS XML format",
1032 "The file has not the native YACS XML format or is not readable.");
1036 YACS::ENGINE::Logger* logger= proc->getLogger("parser");
1037 if(!logger->isEmpty())
1039 DEBTRACE(logger->getStr());
1041 createContext(proc, fn, "", true);
1044 //! bug confirmOverwrite : correction Qt 4.3.5
1045 QString GenericGui::getSaveFileName(const QString& fileName)
1047 QFileDialog dialog(_parent, "Save schema", fileName);
1048 QStringList filters;
1049 filters << "XML files (*.xml)"
1051 dialog.setFileMode(QFileDialog::AnyFile);
1052 dialog.setFilters(filters);
1053 dialog.selectFilter("(*.xml)");
1054 dialog.setDefaultSuffix("xml");
1055 dialog.setConfirmOverwrite(true);
1056 //dialog.setConfirmOverwrite(false); // bug Qt4.3.3
1057 dialog.setAcceptMode(QFileDialog::AcceptSave);
1058 QString selectedFile;
1059 QStringList fileNames;
1061 if (bool ret = dialog.exec())
1063 DEBTRACE(ret << " " << dialog.confirmOverwrite());
1064 fileNames = dialog.selectedFiles();
1065 if (!fileNames.isEmpty())
1066 selectedFile = fileNames.first();
1068 return selectedFile;
1071 void GenericGui::onExportSchema()
1073 DEBTRACE("GenericGui::onExportSchema");
1074 if (!QtGuiContext::getQtCurrent()) return;
1075 YACS::ENGINE::Proc* proc = QtGuiContext::getQtCurrent()->getProc();
1076 QString fo = QtGuiContext::getQtCurrent()->getFileName();
1079 if (fo.startsWith("newSchema_"))
1082 fn = getSaveFileName(fo);
1084 if (fn.isEmpty()) return;
1086 DEBTRACE("GenericGui::onExportSchema: " << fn.toStdString());
1087 QtGuiContext::getQtCurrent()->setFileName(fn);
1088 VisitorSaveGuiSchema aWriter(proc);
1089 aWriter.openFileSchema( fn.toStdString() );
1090 aWriter.visitProc();
1091 aWriter.closeFileSchema();
1093 if (fn.compare(foo) && _wrapper)
1094 _wrapper->renameSchema(foo, fn, QtGuiContext::getQtCurrent()->getWindow());
1097 void GenericGui::onExportSchemaAs()
1099 DEBTRACE("GenericGui::onExportSchemaAs");
1100 if (!QtGuiContext::getQtCurrent()) return;
1101 YACS::ENGINE::Proc* proc = QtGuiContext::getQtCurrent()->getProc();
1102 QString fo = QtGuiContext::getQtCurrent()->getFileName();
1104 if (fo.startsWith("newShema_")) fo.clear();
1105 QString fn = getSaveFileName(fo);
1106 if (fn.isEmpty()) return;
1108 DEBTRACE("GenericGui::onExportSchemaAs: " << fn.toStdString());
1109 QtGuiContext::getQtCurrent()->setFileName(fn);
1110 VisitorSaveGuiSchema aWriter(proc);
1111 aWriter.openFileSchema(fn.toStdString());
1112 aWriter.visitProc();
1113 aWriter.closeFileSchema();
1115 if (fn.compare(foo) && _wrapper)
1116 _wrapper->renameSchema(foo, fn, QtGuiContext::getQtCurrent()->getWindow());
1119 void GenericGui::onImportCatalog()
1121 DEBTRACE("GenericGui::onImportCatalog");
1122 QString fn = QFileDialog::getOpenFileName( _parent,
1123 "Choose a YACS Schema to load as a Catalog" ,
1125 tr( "XML-Files (*.xml);;All Files (*)" ));
1126 if ( !fn.isEmpty() )
1127 _catalogsWidget->addCatalogFromFile(fn.toStdString());
1130 void GenericGui::onRunLoadedSchema(bool withState)
1132 DEBTRACE("GenericGui::onRunLoadedSchema");
1133 if (!QtGuiContext::getQtCurrent()) return;
1139 // --- check proc state (cf. editionProc)
1141 if (!QtGuiContext::getQtCurrent()->_setOfModifiedSubjects.empty())
1143 set<Subject*>::iterator it = QtGuiContext::getQtCurrent()->_setOfModifiedSubjects.begin();
1144 (*it)->select(true);
1148 YACS::ENGINE::Proc* proc = QtGuiContext::getQtCurrent()->getProc();
1149 if (!proc->isValid())
1151 QtGuiContext::getQtCurrent()->getSubjectProc()->select(true);
1155 YACS::ENGINE::LinkInfo info(YACS::ENGINE::LinkInfo::ALL_STOP_ASAP);
1158 proc->checkConsistency(info);
1160 catch (Exception &ex)
1162 DEBTRACE(ex.what());
1163 QtGuiContext::getQtCurrent()->getSubjectProc()->select(true);
1165 if (info.areWarningsOrErrors()) return;
1169 double passe = (end_t -start_t);
1170 passe = passe/CLOCKS_PER_SEC;
1171 cerr <<"run schema -1- : " << passe << endl;
1174 // --- save proc under a run name
1176 QFileInfo fo = QtGuiContext::getQtCurrent()->getFileName();
1177 QString procName = fo.baseName();
1178 //QString tmpDir = SALOMEDS_Tool::GetTmpDir().c_str();
1179 QString tmpDir = "/tmp";
1180 QDir aTmpDir(tmpDir);
1181 aTmpDir.mkdir(QString("YACS_") + getenv("USER"));
1182 assert(aTmpDir.cd(QString("YACS_") + getenv("USER")));
1183 QDateTime curTime = QDateTime::currentDateTime();
1184 QString aRunName = procName + "_" + curTime.toString("yyyyMMdd_hhmmss") + ".xml";
1185 aRunName = aTmpDir.absoluteFilePath(aRunName);
1186 DEBTRACE(aRunName.toStdString());
1188 VisitorSaveGuiSchema aWriter(proc);
1189 aWriter.openFileSchema(aRunName.toStdString());
1190 aWriter.visitProc();
1191 aWriter.closeFileSchema();
1193 // --- create a run context
1195 YACS::ENGINE::Proc *procrun = _loader->load(aRunName.toLatin1());
1198 double passe = (end_t -start_t);
1199 passe = passe/CLOCKS_PER_SEC;
1200 cerr <<"run schema -2- : " << passe << endl;
1203 createContext(procrun, QtGuiContext::getQtCurrent()->getFileName(), aRunName, false);
1205 // load state if required
1207 GuiExecutor *executor = QtGuiContext::getQtCurrent()->getGuiExecutor();
1208 if (!executor) return;
1211 QString fn = QFileDialog::getOpenFileName( _parent,
1212 "Choose a previous run state to load" ,
1214 tr( "XML-Files (*.xml);;All Files (*)" ));
1217 DEBTRACE("run state to load: " <<fn.toStdString());
1218 executor->setLoadStateFile(fn.toStdString());
1221 executor->startResumeDataflow(true); // --- initialise gui state
1224 void GenericGui::onLoadRunStateSchema()
1226 DEBTRACE("GenericGui::onLoadRunStateSchema");
1227 onRunLoadedSchema(true);
1230 void GenericGui::onLoadAndRunSchema()
1232 DEBTRACE("GenericGui::onLoadAndRunSchema");
1233 QString fn = QFileDialog::getOpenFileName( _parent,
1234 "Choose a filename to load" ,
1236 tr( "XML-Files (*.xml);;All Files (*)" ));
1237 if ( !fn.isEmpty() )
1239 DEBTRACE("***************************************************************************");
1240 DEBTRACE("file loaded : " <<fn.toStdString());
1241 DEBTRACE("***************************************************************************");
1242 YACS::ENGINE::Proc *proc = _loader->load(fn.toLatin1());
1243 YACS::ENGINE::Logger* logger= proc->getLogger("parser");
1244 if(!logger->isEmpty())
1246 DEBTRACE(logger->getStr());
1248 createContext(proc, fn, fn, false);
1253 void GenericGui::onStartResume()
1255 DEBTRACE("GenericGui::onStartResume");
1256 if (!QtGuiContext::getQtCurrent()) return;
1257 if (!QtGuiContext::getQtCurrent()->getGuiExecutor()) return;
1258 QtGuiContext::getQtCurrent()->getGuiExecutor()->startResumeDataflow();
1261 void GenericGui::onAbort()
1263 DEBTRACE("GenericGui::onAbort");
1264 if (!QtGuiContext::getQtCurrent()) return;
1265 if (!QtGuiContext::getQtCurrent()->getGuiExecutor()) return;
1266 QtGuiContext::getQtCurrent()->getGuiExecutor()->killDataflow();
1269 void GenericGui::onPause()
1271 DEBTRACE("GenericGui::onPause");
1272 if (!QtGuiContext::getQtCurrent()) return;
1273 if (!QtGuiContext::getQtCurrent()->getGuiExecutor()) return;
1274 QtGuiContext::getQtCurrent()->getGuiExecutor()->suspendDataflow();
1277 void GenericGui::onReset()
1279 DEBTRACE("GenericGui::onReset");
1280 if (!QtGuiContext::getQtCurrent()) return;
1281 if (!QtGuiContext::getQtCurrent()->getGuiExecutor()) return;
1282 QtGuiContext::getQtCurrent()->getGuiExecutor()->resetDataflow();
1285 void GenericGui::onSaveRunState()
1287 DEBTRACE("GenericGui::onSaveRunState");
1288 if (!QtGuiContext::getQtCurrent()) return;
1289 if (!QtGuiContext::getQtCurrent()->getGuiExecutor()) return;
1290 QDateTime curTime = QDateTime::currentDateTime();
1291 QFileInfo procName = QtGuiContext::getQtCurrent()->getFileName();
1292 QString stateName = procName.baseName();
1293 DEBTRACE(stateName.toStdString());
1294 stateName += "_state_" + curTime.toString("yyyyMMdd_hhmmss") + ".xml";
1295 DEBTRACE(stateName.toStdString());
1296 stateName = getSaveFileName(stateName);
1297 DEBTRACE(stateName.toStdString());
1298 if (!stateName.isEmpty())
1299 QtGuiContext::getQtCurrent()->getGuiExecutor()->saveState(stateName.toStdString());
1302 void GenericGui::onNewEdition()
1304 DEBTRACE("GenericGui::onNewEdition");
1305 // if (!QtGuiContext::getQtCurrent()) return;
1306 // if (!QtGuiContext::getQtCurrent()->getGuiExecutor()) return;
1307 // QtGuiContext::getQtCurrent()->getGuiExecutor()->resetDataflow();
1310 void GenericGui::onGetYacsContainerLog()
1312 DEBTRACE("GenericGui::onGetYacsContainerLog");
1313 if (!QtGuiContext::getQtCurrent()) return;
1314 if (!QtGuiContext::getQtCurrent()->getGuiExecutor()) return;
1315 string log = QtGuiContext::getQtCurrent()->getGuiExecutor()->getContainerLog();
1316 LogViewer *lv = new LogViewer("YACS Container Log", _parent);
1321 void GenericGui::onGetErrorReport()
1323 DEBTRACE("GenericGui::onGetErrorReport");
1324 if (!QtGuiContext::getQtCurrent()) return;
1325 if (!QtGuiContext::getQtCurrent()->getGuiExecutor()) return;
1326 Subject *sub = QtGuiContext::getQtCurrent()->getSelectedSubject();
1327 SubjectElementaryNode *snode = dynamic_cast<SubjectElementaryNode*>(sub);
1329 string log = QtGuiContext::getQtCurrent()->getGuiExecutor()->getErrorReport(snode->getNode());
1330 LogViewer *lv = new LogViewer("Node error report", _parent);
1335 void GenericGui::onGetErrorDetails()
1337 DEBTRACE("GenericGui::onGetErrorDetails");
1338 if (!QtGuiContext::getQtCurrent()) return;
1339 if (!QtGuiContext::getQtCurrent()->getGuiExecutor()) return;
1340 Subject *sub = QtGuiContext::getQtCurrent()->getSelectedSubject();
1341 SubjectElementaryNode *snode = dynamic_cast<SubjectElementaryNode*>(sub);
1343 string log = QtGuiContext::getQtCurrent()->getGuiExecutor()->getErrorDetails(snode->getNode());
1344 LogViewer *lv = new LogViewer("Node Error Details", _parent);
1349 void GenericGui::onGetContainerLog()
1351 DEBTRACE("GenericGui::onGetContainerLog");
1352 if (!QtGuiContext::getQtCurrent()) return;
1353 if (!QtGuiContext::getQtCurrent()->getGuiExecutor()) return;
1354 Subject *sub = QtGuiContext::getQtCurrent()->getSelectedSubject();
1355 SubjectElementaryNode *snode = dynamic_cast<SubjectElementaryNode*>(sub);
1357 string log = QtGuiContext::getQtCurrent()->getGuiExecutor()->getContainerLog(snode->getNode());
1358 LogViewer *lv = new LogViewer("Node Container Log", _parent);
1365 void GenericGui::onEditDataTypes()
1367 DEBTRACE("GenericGui::onEditDataTypes");
1370 void GenericGui::onCreateDataType()
1372 DEBTRACE("GenericGui::onCreateDataType");
1375 void GenericGui::onImportDataType()
1377 DEBTRACE("GenericGui::onImportDataType");
1378 if (_dwCatalogs) _dwCatalogs->raise();
1382 void GenericGui::onNewContainer()
1384 DEBTRACE("GenericGui::onNewContainer");
1385 _guiEditor->CreateContainer();
1388 void GenericGui::onNewSalomeComponent()
1390 DEBTRACE("GenericGui::onNewSalomeComponent");
1393 void GenericGui::onNewSalomePythonComponent()
1395 DEBTRACE("GenericGui::onNewSalomePythonComponent");
1398 void GenericGui::onNewCorbaComponent()
1400 DEBTRACE("GenericGui::onNewCorbaComponent");
1404 void GenericGui::onSalomeServiceNode()
1406 DEBTRACE("GenericGui::onSalomeServiceNode");
1407 _guiEditor->CreateNode("SalomeNode");
1410 void GenericGui::onServiceInlineNode()
1412 DEBTRACE("GenericGui::onServiceInlineNode");
1413 _guiEditor->CreateNode("SalomePythonNode");
1416 void GenericGui::onCORBAServiceNode()
1418 DEBTRACE("GenericGui::onCORBAServiceNode");
1419 _guiEditor->CreateNode("CORBANode");
1422 void GenericGui::onNodeNodeServiceNode()
1424 DEBTRACE("GenericGui::onNodeNodeServiceNode");
1427 void GenericGui::onCppNode()
1429 DEBTRACE("GenericGui::onCppNode");
1430 _guiEditor->CreateNode("CppNode");
1433 void GenericGui::onXMLNode()
1435 DEBTRACE("GenericGui::onXMLNode");
1436 _guiEditor->CreateNode("XmlNode");
1439 void GenericGui::onInDataNode()
1441 DEBTRACE("GenericGui::onInDataNode");
1442 _guiEditor->CreateNode("PresetNode");
1445 void GenericGui::onOutDataNode()
1447 DEBTRACE("GenericGui::onOutDataNode");
1448 _guiEditor->CreateNode("OutNode");
1451 void GenericGui::onInStudyNode()
1453 DEBTRACE("GenericGui::onInStudyNode");
1454 _guiEditor->CreateNode("StudyInNode");
1457 void GenericGui::onOutStudyNode()
1459 DEBTRACE("GenericGui::onOutStudyNode");
1460 _guiEditor->CreateNode("StudyOutNode");
1463 void GenericGui::onInlineScriptNode()
1465 DEBTRACE("GenericGui::onInlineScriptNode");
1466 _guiEditor->CreateNode("PyScript");
1469 void GenericGui::onInlineFunctionNode()
1471 DEBTRACE("GenericGui::onInlineFunctionNode");
1472 _guiEditor->CreateNode("PyFunction");
1475 void GenericGui::onBlockNode()
1477 DEBTRACE("GenericGui::onBlockNode");
1478 _guiEditor->CreateBloc();
1481 void GenericGui::onFORNode()
1483 DEBTRACE("GenericGui::onFORNode");
1484 _guiEditor->CreateForLoop();
1487 void GenericGui::onFOREACHNode()
1489 DEBTRACE("GenericGui::onFOREACHNode");
1490 _guiEditor->CreateForEachLoop();
1493 void GenericGui::onWHILENode()
1495 DEBTRACE("GenericGui::onWHILENode");
1496 _guiEditor->CreateWhileLoop();
1499 void GenericGui::onSWITCHNode()
1501 DEBTRACE("GenericGui::onSWITCHNode");
1502 _guiEditor->CreateSwitch();
1505 void GenericGui::onNodeFromCatalog()
1507 DEBTRACE("GenericGui::onNodeFromCatalog");
1508 if (_dwCatalogs) _dwCatalogs->raise();
1511 void GenericGui::onDeleteItem()
1513 DEBTRACE("GenericGui::onDeleteItem");
1514 _guiEditor->DeleteSubject();
1517 void GenericGui::onCutItem()
1519 DEBTRACE("GenericGui::onCutItem");
1520 _guiEditor->CutSubject();
1523 void GenericGui::onCopyItem()
1525 DEBTRACE("GenericGui::onCopyItem");
1526 _guiEditor->CopySubject();
1529 void GenericGui::onPasteItem()
1531 DEBTRACE("GenericGui::onPasteItem");
1532 _guiEditor->PasteSubject();
1535 void GenericGui::onArrangeLocalNodes()
1537 DEBTRACE("GenericGui::onArrangeLocalNodes");
1538 _guiEditor->arrangeNodes(false);
1541 void GenericGui::onArrangeRecurseNodes()
1543 DEBTRACE("GenericGui::onArrangeRecurseNodes");
1544 _guiEditor->arrangeNodes(true);
1547 void GenericGui::onRebuildLinks()
1549 DEBTRACE("GenericGui::onRebuildLinks");
1550 _guiEditor->rebuildLinks();
1553 void GenericGui::onToggleAutomaticComputeLinks(bool checked)
1555 Scene::_autoComputeLinks = checked;
1556 DEBTRACE("Scene::_autoComputeLinks=" << checked);
1559 void GenericGui::onToggleSimplifyLinks(bool checked)
1561 Scene::_simplifyLinks = checked;
1562 DEBTRACE("Scene::_simplifyLinks=" << checked);
1565 void GenericGui::onToggleForce2NodesLinks(bool checked)
1567 Scene::_force2NodesLink = checked;
1568 DEBTRACE("Scene::_force2NodesLink=" << checked);
1571 void GenericGui::onSelectReference()
1573 Subject *sub = QtGuiContext::getQtCurrent()->getSelectedSubject();
1575 SubjectReference *ref = dynamic_cast<SubjectReference*>(sub);
1577 SubjectServiceNode *snode = dynamic_cast<SubjectServiceNode*>(ref->getReference());
1578 snode->select(true);
1581 void GenericGui::onWhatsThis()
1583 DEBTRACE("GenericGui::onWhatsThis");
1584 QWhatsThis::enterWhatsThisMode();
1587 void GenericGui::onWithoutStopMode(bool checked)
1589 DEBTRACE("GenericGui::onWithoutStopMode " << checked);
1590 if (!QtGuiContext::getQtCurrent()) return;
1591 if (!QtGuiContext::getQtCurrent()->getGuiExecutor()) return;
1592 if (checked) QtGuiContext::getQtCurrent()->getGuiExecutor()->setContinueMode();
1595 void GenericGui::onBreakpointsMode(bool checked)
1597 DEBTRACE("GenericGui::onWithoutStopMode " << checked);
1598 if (!QtGuiContext::getQtCurrent()) return;
1599 if (!QtGuiContext::getQtCurrent()->getGuiExecutor()) return;
1600 if (checked) QtGuiContext::getQtCurrent()->getGuiExecutor()->setBreakpointMode();
1603 void GenericGui::onStepByStepMode(bool checked)
1605 DEBTRACE("GenericGui::onWithoutStopMode " << checked);
1606 if (!QtGuiContext::getQtCurrent()) return;
1607 if (!QtGuiContext::getQtCurrent()->getGuiExecutor()) return;
1608 if (checked) QtGuiContext::getQtCurrent()->getGuiExecutor()->setStepByStepMode();
1611 void GenericGui::onToggleStopOnError(bool checked)
1613 DEBTRACE("GenericGui::onToggleStopOnError " << checked);
1614 if (!QtGuiContext::getQtCurrent()) return;
1615 if (!QtGuiContext::getQtCurrent()->getGuiExecutor()) return;
1618 void GenericGui::onToggleSceneItemVisible(bool checked)
1620 DEBTRACE("GenericGui::onToggleSceneItemVisible " << checked);
1621 if (!QtGuiContext::getQtCurrent()) return;
1622 Subject *sub = QtGuiContext::getQtCurrent()->getSelectedSubject();
1623 SubjectNode *snode = dynamic_cast<SubjectNode*>(sub);
1626 if (!QtGuiContext::getQtCurrent()->_mapOfSceneItem.count(sub)) return;
1628 SceneItem *item = QtGuiContext::getQtCurrent()->_mapOfSceneItem[sub];
1629 item->setVisible(checked);
1632 void GenericGui::onCleanOnExit()
1634 DEBTRACE("GenericGui::onCleanOnExit");
1635 int studyId = _wrapper->activeStudyId();
1636 set<QtGuiContext*> setcpy = QtGuiContext::_setOfContext;
1637 set<QtGuiContext*>::iterator it = setcpy.begin();
1638 for ( ; it != setcpy.end(); ++it)
1639 if ((*it)->getStudyId() == studyId)
1641 QtGuiContext::setQtCurrent(*it);