Salome HOME
1) Fix problem that new node does not have the usual ports ("nbBranches", evalSample...
[modules/yacs.git] / src / genericgui / GenericGui.hxx
1 // Copyright (C) 2006-2013  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #ifndef _GENERICGUI_HXX_
21 #define _GENERICGUI_HXX_
22
23 #include "GenericGuiExport.hxx"
24
25 #include <QAction>
26 #include <QActionGroup>
27 #include <QObject>
28 #include <QMainWindow>
29 #include <QDockWidget>
30 #include <QString>
31
32 #include "SuitWrapper.hxx"
33
34 #include <map>
35 #include <list>
36 #include <string>
37
38 namespace YACS
39 {
40
41   namespace ENGINE
42   {
43     class Proc;
44     class Catalog;
45   }
46   namespace HMI
47   {
48     class QtGuiContext;
49     class GuiEditor;
50     class SuitWrapper;
51     class CatalogWidget;
52     class YACSGuiLoader;
53     class SubjectDataPort;
54     class BatchJobsListDialog;
55
56     class GENERICGUI_EXPORT GenericGui: public QObject
57     {
58       Q_OBJECT
59
60     public:
61       GenericGui(YACS::HMI::SuitWrapper* wrapper, QMainWindow *parent = 0);
62       virtual ~GenericGui();
63
64       void createActions();
65       void createMenus();
66       void createTools();
67       void initialMenus();
68       void showBaseMenus(bool show);
69       void showEditionMenus(bool show);
70       void showExecMenus(bool show);
71       void showCommonMenus(bool show);
72       void switchContext(QWidget *view);
73       bool closeContext(QWidget *view, bool onExit = false);
74       void showDockWidgets(bool isVisible);
75       void raiseStacked();
76       CatalogWidget* getCatalogWidget() { return _catalogsWidget; };
77       std::list<std::string> getMachineList();
78       void createForEachLoop(std::string type="double");
79       void putGraphInForeachLoop(std::string type);
80       virtual void loadSchema(const std::string& filename,bool edit=true, bool arrangeLocalNodes=false);
81       virtual void onHelpContextModule( const QString&, const QString&, const QString& = QString() );
82       void createContext(YACS::ENGINE::Proc* proc,
83                          const QString& schemaName,
84                          const QString& runName,
85                          bool forEdition);
86       YACSGuiLoader *getLoader() { return _loader; };
87
88       QAction *_newSchemaAct;
89       QAction *_importSchemaAct;
90       QAction *_chooseBatchJobAct;
91       QAction *_importSupervSchemaAct;
92       QAction *_exportSchemaAct;
93       QAction *_exportSchemaAsAct;
94       QAction *_importCatalogAct;
95
96       QAction *_runLoadedSchemaAct;
97       QAction *_loadRunStateSchemaAct;
98       QAction *_loadAndRunSchemaAct;
99
100       QAction *_startResumeAct;
101       QAction *_abortAct;
102       QAction *_pauseAct;
103       QAction *_resetAct;
104
105       QAction *_saveRunStateAct;
106       QAction *_newEditionAct;
107
108       QActionGroup *_execModeGroup;
109       QAction *_withoutStopModeAct;
110       QAction *_breakpointsModeAct;
111       QAction *_stepByStepModeAct;
112
113       QAction *_toggleStopOnErrorAct;
114
115       QAction *_getYacsContainerLogAct;
116       QAction *_getErrorReportAct;
117       QAction *_getErrorDetailsAct;
118       QAction *_getContainerLogAct;
119       QAction *_shutdownProcAct;
120
121       QAction *_editDataTypesAct;
122       QAction *_createDataTypeAct;
123       QAction *_importDataTypeAct;
124       QAction *_newContainerAct;
125       QAction *_selectComponentInstanceAct;
126       QAction *_newSalomeComponentAct;
127       QAction *_newSalomePythonComponentAct;
128       QAction *_newCorbaComponentAct;
129       QAction *_salomeServiceNodeAct;
130       QAction *_serviceInlineNodeAct;
131       QAction *_CORBAServiceNodeAct;
132       QAction *_nodeNodeServiceNodeAct;
133       QAction *_cppNodeAct;
134       QAction *_XMLNodeAct;
135       QAction *_inDataNodeAct;
136       QAction *_outDataNodeAct;
137       QAction *_inStudyNodeAct;
138       QAction *_outStudyNodeAct;
139       QAction *_inlineScriptNodeAct;
140       QAction *_inlineFunctionNodeAct;
141       QAction *_blockNodeAct;
142       QAction *_FORNodeAct;
143       QAction *_FOREACHNodeAct;
144       QAction *_WHILENodeAct;
145       QAction *_SWITCHNodeAct;
146       QAction *_OptimizerLoopAct;
147       QAction *_nodeFromCatalogAct;
148       QAction *_deleteItemAct;
149       QAction *_cutItemAct;
150       QAction *_copyItemAct;
151       QAction *_pasteItemAct;
152       QAction *_putInBlocAct;
153       QAction *_putGraphInBlocAct;
154       QAction *_putGraphInForLoopAct;
155       QAction *_putGraphInWhileLoopAct;
156       QAction *_putGraphInOptimizerLoopAct;
157       QAction *_arrangeLocalNodesAct;
158       QAction *_arrangeRecurseNodesAct;
159       QAction *_computeLinkAct;
160       QAction *_zoomToBlocAct;
161       QAction *_centerOnNodeAct;
162       QAction *_shrinkExpand;
163
164       QAction *_toggleStraightLinksAct;
165       QAction *_toggleAutomaticComputeLinkAct;
166       QAction *_toggleSimplifyLinkAct;
167       QAction *_toggleForce2NodesLinkAct;
168       QAction *_toggleAddRowColsAct;
169       QAction *_toggleSceneItemVisibleAct;
170       QAction *_selectReferenceAct;
171       QAction *_whatsThisAct;
172
173       QAction *_showAllLinksAct;
174       QAction *_hideAllLinksAct;
175
176       QAction *_showOnlyPortLinksAct;
177       QAction *_showPortLinksAct;
178       QAction *_hidePortLinksAct;
179       QAction *_emphasisPortLinksAct;
180
181       QAction *_showOnlyCtrlLinksAct;
182       QAction *_showCtrlLinksAct;
183       QAction *_hideCtrlLinksAct;
184       QAction *_emphasisCtrlLinksAct;
185
186       QAction *_showOnlyLinkAct;
187       QAction *_showLinkAct;
188       QAction *_hideLinkAct;
189       QAction *_emphasisLinkAct;
190       QAction *_deEmphasizeAllAct;
191
192       QAction *_undoAct;
193       QAction *_redoAct;
194       QAction *_showUndoAct;
195       QAction *_showRedoAct;
196
197       YACS::HMI::GuiEditor *_guiEditor;
198       void setLoadedPresentation(YACS::ENGINE::Proc* proc);
199
200     public slots:
201       void onCleanOnExit();
202
203     protected:
204       int getMenuId() { return _menuId++; }
205       QString getSaveFileName(const QString& fileName = QString());
206
207       YACSGuiLoader *_loader;
208       SuitWrapper* _wrapper;
209       QMainWindow* _parent;
210       QDockWidget* _dwTree;
211       QDockWidget* _dwStacked;
212       QDockWidget* _dwCatalogs;
213       BatchJobsListDialog* _BJLdialog;
214       YACS::ENGINE::Catalog* _builtinCatalog;
215       YACS::ENGINE::Catalog* _sessionCatalog;
216       CatalogWidget* _catalogsWidget;
217       std::map<QWidget*, YACS::HMI::QtGuiContext*> _mapViewContext;
218       int _menuId;
219       int _toolId;
220       int _schemaCnt;
221       bool _isSaved;
222       std::list<std::string> _machineList;
223
224     private slots:
225
226       void onNewSchema();
227       void onImportSchema();
228       void onChooseBatchJob();
229       void onImportSupervSchema();
230       void onExportSchema();
231       void onExportSchemaAs();
232       void onImportCatalog();
233
234       void onRunLoadedSchema(bool withState = false);
235       void onLoadRunStateSchema();
236       void onLoadAndRunSchema();
237
238       void onStartResume();
239       void onAbort();
240       void onPause();
241       void onReset();
242       void onSaveRunState();
243       void onNewEdition();
244
245       void onWithoutStopMode(bool checked);
246       void onBreakpointsMode(bool checked);
247       void onStepByStepMode(bool checked);
248
249       void onToggleStopOnError(bool checked);
250
251       void onGetYacsContainerLog();
252       void onGetErrorReport();
253       void onGetErrorDetails();
254       void onGetContainerLog();
255       void onShutdownProc();
256
257       void onEditDataTypes();
258       void onCreateDataType();
259       void onImportDataType();
260
261       void onNewContainer();
262       void onSelectComponentInstance();
263       void onNewSalomeComponent();
264       void onNewSalomePythonComponent();
265       void onNewCorbaComponent();
266
267       void onSalomeServiceNode();
268       void onServiceInlineNode();
269       void onCORBAServiceNode();
270       void onNodeNodeServiceNode();
271       void onCppNode();
272       void onXMLNode();
273       void onInDataNode();
274       void onOutDataNode();
275       void onInStudyNode();
276       void onOutStudyNode();
277       void onInlineScriptNode();
278       void onInlineFunctionNode();
279       void onBlockNode();
280       void onFORNode();
281       void onFOREACHNode();
282       void onWHILENode();
283       void onSWITCHNode();
284       void onOptimizerLoop();
285       void onNodeFromCatalog();
286
287       void onDeleteItem();
288       void onCutItem();
289       void onCopyItem();
290       void onPasteItem();
291       void onPutInBloc();
292       void onPutGraphInBloc();
293       void onPutGraphInForLoop();
294       void onPutGraphInWhileLoop();
295       void onPutGraphInOptimizerLoop();
296       void onArrangeLocalNodes();
297       void onArrangeRecurseNodes();
298       void onRebuildLinks();
299       void onZoomToBloc();
300       void onCenterOnNode();
301       void onShrinkExpand();
302       void onToggleStraightLinks(bool checked);
303       void onToggleAutomaticComputeLinks(bool checked);
304       void onToggleSimplifyLinks(bool checked);
305       void onToggleForce2NodesLinks(bool checked);
306       void onToggleAddRowCols(bool checked);
307
308       void onToggleSceneItemVisible(bool checked);
309
310       void onShowAllLinks();
311       void onHideAllLinks();
312
313       void onShowOnlyPortLinks();
314       void onShowPortLinks();
315       void onHidePortLinks();
316       void onEmphasisPortLinks();
317
318       void onShowOnlyCtrlLinks();
319       void onShowCtrlLinks();
320       void onHideCtrlLinks();
321       void onEmphasisCtrlLinks();
322
323       void onShowOnlyLink();
324       void onShowLink();
325       void onHideLink();
326       void onEmphasisLink();
327       void onDeEmphasizeAll();
328
329       void onSelectReference();
330       void onWhatsThis();
331
332       void onUndo();
333       void onRedo();
334       void onShowUndo();
335       void onShowRedo();
336
337     private:
338       void displayLinks(bool isShown);
339       void displayControlLinks(bool isShown);
340       void displayPortLinks(bool isShown);
341       void displayALink(bool isShown);
342       void emphasizePortLink(YACS::HMI::SubjectDataPort* sub, bool emphasize);
343     };
344
345   }
346 }
347
348 #endif