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