Salome HOME
Merge branch V7_3_1_BR
[modules/yacs.git] / src / genericgui / GenericGui.hxx
1 // Copyright (C) 2006-2014  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, or (at your option) any later version.
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 hideAllMenus();
69       void showBaseMenus(bool show);
70       void showEditionMenus(bool show);
71       void showExecMenus(bool show);
72       void showCommonMenus(bool show);
73       void switchContext(QWidget *view, bool onExit = false);
74       bool closeContext(QWidget *view, bool onExit = false);
75       void showDockWidgets(bool isVisible);
76       void raiseStacked();
77       CatalogWidget* getCatalogWidget() { return _catalogsWidget; };
78       std::list<std::string> getMachineList();
79       void createForEachLoop(std::string type="double");
80       void putGraphInForeachLoop(std::string type);
81       virtual void loadSchema(const std::string& filename,bool edit=true, bool arrangeLocalNodes=false);
82       virtual void onHelpContextModule( const QString&, const QString&, const QString& = QString() );
83       void createContext(YACS::ENGINE::Proc* proc,
84                          const QString& schemaName,
85                          const QString& runName,
86                          bool forEdition);
87       YACSGuiLoader *getLoader() { return _loader; };
88
89       QAction *_newSchemaAct;
90       QAction *_importSchemaAct;
91       QAction *_chooseBatchJobAct;
92       QAction *_importSupervSchemaAct;
93       QAction *_exportSchemaAct;
94       QAction *_exportSchemaAsAct;
95       QAction *_importCatalogAct;
96
97       QAction *_runLoadedSchemaAct;
98       QAction *_loadRunStateSchemaAct;
99       QAction *_loadAndRunSchemaAct;
100
101       QAction *_startResumeAct;
102       QAction *_abortAct;
103       QAction *_pauseAct;
104       QAction *_resetAct;
105
106       QAction *_saveRunStateAct;
107       QAction *_newEditionAct;
108
109       QActionGroup *_execModeGroup;
110       QAction *_withoutStopModeAct;
111       QAction *_breakpointsModeAct;
112       QAction *_stepByStepModeAct;
113
114       QAction *_toggleStopOnErrorAct;
115
116       QAction *_getYacsContainerLogAct;
117       QAction *_getErrorReportAct;
118       QAction *_getErrorDetailsAct;
119       QAction *_getContainerLogAct;
120       QAction *_shutdownProcAct;
121
122       QAction *_editDataTypesAct;
123       QAction *_createDataTypeAct;
124       QAction *_importDataTypeAct;
125       QAction *_newContainerAct;
126       QAction *_selectComponentInstanceAct;
127       QAction *_newSalomeComponentAct;
128       QAction *_newSalomePythonComponentAct;
129       QAction *_newCorbaComponentAct;
130       QAction *_salomeServiceNodeAct;
131       QAction *_serviceInlineNodeAct;
132       QAction *_CORBAServiceNodeAct;
133       QAction *_nodeNodeServiceNodeAct;
134       QAction *_cppNodeAct;
135       QAction *_XMLNodeAct;
136       QAction *_inDataNodeAct;
137       QAction *_outDataNodeAct;
138       QAction *_inStudyNodeAct;
139       QAction *_outStudyNodeAct;
140       QAction *_inlineScriptNodeAct;
141       QAction *_inlineFunctionNodeAct;
142       QAction *_blockNodeAct;
143       QAction *_FORNodeAct;
144       QAction *_FOREACHNodeAct;
145       QAction *_WHILENodeAct;
146       QAction *_SWITCHNodeAct;
147       QAction *_OptimizerLoopAct;
148       QAction *_nodeFromCatalogAct;
149       QAction *_deleteItemAct;
150       QAction *_cutItemAct;
151       QAction *_copyItemAct;
152       QAction *_pasteItemAct;
153       QAction *_putInBlocAct;
154       QAction *_putGraphInBlocAct;
155       QAction *_putGraphInForLoopAct;
156       QAction *_putGraphInWhileLoopAct;
157       QAction *_putGraphInOptimizerLoopAct;
158       QAction *_arrangeLocalNodesAct;
159       QAction *_arrangeRecurseNodesAct;
160       QAction *_computeLinkAct;
161       QAction *_zoomToBlocAct;
162       QAction *_centerOnNodeAct;
163       QAction *_shrinkExpand;
164
165       QAction *_toggleStraightLinksAct;
166       QAction *_toggleAutomaticComputeLinkAct;
167       QAction *_toggleSimplifyLinkAct;
168       QAction *_toggleForce2NodesLinkAct;
169       QAction *_toggleAddRowColsAct;
170       QAction *_toggleSceneItemVisibleAct;
171       QAction *_selectReferenceAct;
172       QAction *_whatsThisAct;
173
174       QAction *_showAllLinksAct;
175       QAction *_hideAllLinksAct;
176
177       QAction *_showOnlyPortLinksAct;
178       QAction *_showPortLinksAct;
179       QAction *_hidePortLinksAct;
180       QAction *_emphasisPortLinksAct;
181
182       QAction *_showOnlyCtrlLinksAct;
183       QAction *_showCtrlLinksAct;
184       QAction *_hideCtrlLinksAct;
185       QAction *_emphasisCtrlLinksAct;
186
187       QAction *_showOnlyLinkAct;
188       QAction *_showLinkAct;
189       QAction *_hideLinkAct;
190       QAction *_emphasisLinkAct;
191       QAction *_deEmphasizeAllAct;
192
193       QAction *_undoAct;
194       QAction *_redoAct;
195       QAction *_showUndoAct;
196       QAction *_showRedoAct;
197
198       YACS::HMI::GuiEditor *_guiEditor;
199       void setLoadedPresentation(YACS::ENGINE::Proc* proc);
200
201     public slots:
202       void onCleanOnExit();
203
204     protected:
205       int getMenuId() { return _menuId++; }
206       QString getSaveFileName(const QString& fileName = QString());
207
208       YACSGuiLoader *_loader;
209       SuitWrapper* _wrapper;
210       QMainWindow* _parent;
211       QDockWidget* _dwTree;
212       QDockWidget* _dwStacked;
213       QDockWidget* _dwCatalogs;
214       BatchJobsListDialog* _BJLdialog;
215       YACS::ENGINE::Catalog* _builtinCatalog;
216       YACS::ENGINE::Catalog* _sessionCatalog;
217       CatalogWidget* _catalogsWidget;
218       std::map<QWidget*, YACS::HMI::QtGuiContext*> _mapViewContext;
219       int _menuId;
220       int _toolId;
221       int _schemaCnt;
222       bool _isSaved;
223       std::list<std::string> _machineList;
224
225     private slots:
226
227       void onNewSchema();
228       void onImportSchema();
229       void onChooseBatchJob();
230       void onImportSupervSchema();
231       void onExportSchema();
232       void onExportSchemaAs();
233       void onImportCatalog();
234
235       void onRunLoadedSchema(bool withState = false);
236       void onLoadRunStateSchema();
237       void onLoadAndRunSchema();
238
239       void onStartResume();
240       void onAbort();
241       void onPause();
242       void onReset();
243       void onSaveRunState();
244       void onNewEdition();
245
246       void onWithoutStopMode(bool checked);
247       void onBreakpointsMode(bool checked);
248       void onStepByStepMode(bool checked);
249
250       void onToggleStopOnError(bool checked);
251
252       void onGetYacsContainerLog();
253       void onGetErrorReport();
254       void onGetErrorDetails();
255       void onGetContainerLog();
256       void onShutdownProc();
257
258       void onEditDataTypes();
259       void onCreateDataType();
260       void onImportDataType();
261
262       void onNewContainer();
263       void onSelectComponentInstance();
264       void onNewSalomeComponent();
265       void onNewSalomePythonComponent();
266       void onNewCorbaComponent();
267
268       void onSalomeServiceNode();
269       void onServiceInlineNode();
270       void onCORBAServiceNode();
271       void onNodeNodeServiceNode();
272       void onCppNode();
273       void onXMLNode();
274       void onInDataNode();
275       void onOutDataNode();
276       void onInStudyNode();
277       void onOutStudyNode();
278       void onInlineScriptNode();
279       void onInlineFunctionNode();
280       void onBlockNode();
281       void onFORNode();
282       void onFOREACHNode();
283       void onWHILENode();
284       void onSWITCHNode();
285       void onOptimizerLoop();
286       void onNodeFromCatalog();
287
288       void onDeleteItem();
289       void onCutItem();
290       void onCopyItem();
291       void onPasteItem();
292       void onPutInBloc();
293       void onPutGraphInBloc();
294       void onPutGraphInForLoop();
295       void onPutGraphInWhileLoop();
296       void onPutGraphInOptimizerLoop();
297       void onArrangeLocalNodes();
298       void onArrangeRecurseNodes();
299       void onRebuildLinks();
300       void onZoomToBloc();
301       void onCenterOnNode();
302       void onShrinkExpand();
303       void onToggleStraightLinks(bool checked);
304       void onToggleAutomaticComputeLinks(bool checked);
305       void onToggleSimplifyLinks(bool checked);
306       void onToggleForce2NodesLinks(bool checked);
307       void onToggleAddRowCols(bool checked);
308
309       void onToggleSceneItemVisible(bool checked);
310
311       void onShowAllLinks();
312       void onHideAllLinks();
313
314       void onShowOnlyPortLinks();
315       void onShowPortLinks();
316       void onHidePortLinks();
317       void onEmphasisPortLinks();
318
319       void onShowOnlyCtrlLinks();
320       void onShowCtrlLinks();
321       void onHideCtrlLinks();
322       void onEmphasisCtrlLinks();
323
324       void onShowOnlyLink();
325       void onShowLink();
326       void onHideLink();
327       void onEmphasisLink();
328       void onDeEmphasizeAll();
329
330       void onSelectReference();
331       void onWhatsThis();
332
333       void onUndo();
334       void onRedo();
335       void onShowUndo();
336       void onShowRedo();
337
338     private:
339       void displayLinks(bool isShown);
340       void displayControlLinks(bool isShown);
341       void displayPortLinks(bool isShown);
342       void displayALink(bool isShown);
343       void emphasizePortLink(YACS::HMI::SubjectDataPort* sub, bool emphasize);
344     };
345
346   }
347 }
348
349 #endif