Salome HOME
Merge from V6_main 01/04/2013
[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 *_putGraphInOptimizerLoopAct;
154       QAction *_arrangeLocalNodesAct;
155       QAction *_arrangeRecurseNodesAct;
156       QAction *_computeLinkAct;
157       QAction *_zoomToBlocAct;
158       QAction *_centerOnNodeAct;
159       QAction *_shrinkExpand;
160
161       QAction *_toggleStraightLinksAct;
162       QAction *_toggleAutomaticComputeLinkAct;
163       QAction *_toggleSimplifyLinkAct;
164       QAction *_toggleForce2NodesLinkAct;
165       QAction *_toggleAddRowColsAct;
166       QAction *_toggleSceneItemVisibleAct;
167       QAction *_selectReferenceAct;
168       QAction *_whatsThisAct;
169
170       QAction *_showAllLinksAct;
171       QAction *_hideAllLinksAct;
172
173       QAction *_showOnlyPortLinksAct;
174       QAction *_showPortLinksAct;
175       QAction *_hidePortLinksAct;
176       QAction *_emphasisPortLinksAct;
177
178       QAction *_showOnlyCtrlLinksAct;
179       QAction *_showCtrlLinksAct;
180       QAction *_hideCtrlLinksAct;
181       QAction *_emphasisCtrlLinksAct;
182
183       QAction *_showOnlyLinkAct;
184       QAction *_showLinkAct;
185       QAction *_hideLinkAct;
186       QAction *_emphasisLinkAct;
187       QAction *_deEmphasizeAllAct;
188
189       QAction *_undoAct;
190       QAction *_redoAct;
191       QAction *_showUndoAct;
192       QAction *_showRedoAct;
193
194       YACS::HMI::GuiEditor *_guiEditor;
195       void setLoadedPresentation(YACS::ENGINE::Proc* proc);
196
197     public slots:
198       void onCleanOnExit();
199
200     protected:
201       int getMenuId() { return _menuId++; }
202       QString getSaveFileName(const QString& fileName = QString());
203
204       YACSGuiLoader *_loader;
205       SuitWrapper* _wrapper;
206       QMainWindow* _parent;
207       QDockWidget* _dwTree;
208       QDockWidget* _dwStacked;
209       QDockWidget* _dwCatalogs;
210       BatchJobsListDialog* _BJLdialog;
211       YACS::ENGINE::Catalog* _builtinCatalog;
212       YACS::ENGINE::Catalog* _sessionCatalog;
213       CatalogWidget* _catalogsWidget;
214       std::map<QWidget*, YACS::HMI::QtGuiContext*> _mapViewContext;
215       int _menuId;
216       int _toolId;
217       int _schemaCnt;
218       bool _isSaved;
219       std::list<std::string> _machineList;
220
221     private slots:
222
223       void onNewSchema();
224       void onImportSchema();
225       void onChooseBatchJob();
226       void onImportSupervSchema();
227       void onExportSchema();
228       void onExportSchemaAs();
229       void onImportCatalog();
230
231       void onRunLoadedSchema(bool withState = false);
232       void onLoadRunStateSchema();
233       void onLoadAndRunSchema();
234
235       void onStartResume();
236       void onAbort();
237       void onPause();
238       void onReset();
239       void onSaveRunState();
240       void onNewEdition();
241
242       void onWithoutStopMode(bool checked);
243       void onBreakpointsMode(bool checked);
244       void onStepByStepMode(bool checked);
245
246       void onToggleStopOnError(bool checked);
247
248       void onGetYacsContainerLog();
249       void onGetErrorReport();
250       void onGetErrorDetails();
251       void onGetContainerLog();
252       void onShutdownProc();
253
254       void onEditDataTypes();
255       void onCreateDataType();
256       void onImportDataType();
257
258       void onNewContainer();
259       void onSelectComponentInstance();
260       void onNewSalomeComponent();
261       void onNewSalomePythonComponent();
262       void onNewCorbaComponent();
263
264       void onSalomeServiceNode();
265       void onServiceInlineNode();
266       void onCORBAServiceNode();
267       void onNodeNodeServiceNode();
268       void onCppNode();
269       void onXMLNode();
270       void onInDataNode();
271       void onOutDataNode();
272       void onInStudyNode();
273       void onOutStudyNode();
274       void onInlineScriptNode();
275       void onInlineFunctionNode();
276       void onBlockNode();
277       void onFORNode();
278       void onFOREACHNode();
279       void onWHILENode();
280       void onSWITCHNode();
281       void onOptimizerLoop();
282       void onNodeFromCatalog();
283
284       void onDeleteItem();
285       void onCutItem();
286       void onCopyItem();
287       void onPasteItem();
288       void onPutInBloc();
289       void onPutGraphInOptimizerLoop();
290       void onArrangeLocalNodes();
291       void onArrangeRecurseNodes();
292       void onRebuildLinks();
293       void onZoomToBloc();
294       void onCenterOnNode();
295       void onShrinkExpand();
296       void onToggleStraightLinks(bool checked);
297       void onToggleAutomaticComputeLinks(bool checked);
298       void onToggleSimplifyLinks(bool checked);
299       void onToggleForce2NodesLinks(bool checked);
300       void onToggleAddRowCols(bool checked);
301
302       void onToggleSceneItemVisible(bool checked);
303
304       void onShowAllLinks();
305       void onHideAllLinks();
306
307       void onShowOnlyPortLinks();
308       void onShowPortLinks();
309       void onHidePortLinks();
310       void onEmphasisPortLinks();
311
312       void onShowOnlyCtrlLinks();
313       void onShowCtrlLinks();
314       void onHideCtrlLinks();
315       void onEmphasisCtrlLinks();
316
317       void onShowOnlyLink();
318       void onShowLink();
319       void onHideLink();
320       void onEmphasisLink();
321       void onDeEmphasizeAll();
322
323       void onSelectReference();
324       void onWhatsThis();
325
326       void onUndo();
327       void onRedo();
328       void onShowUndo();
329       void onShowRedo();
330
331     private:
332       void displayLinks(bool isShown);
333       void displayControlLinks(bool isShown);
334       void displayPortLinks(bool isShown);
335       void displayALink(bool isShown);
336       void emphasizePortLink(YACS::HMI::SubjectDataPort* sub, bool emphasize);
337     };
338
339   }
340 }
341
342 #endif