]> SALOME platform Git repositories - modules/kernel.git/blob - src/SALOMEGUI/QAD_Desktop.h
Salome HOME
import SalomePro v1.2c
[modules/kernel.git] / src / SALOMEGUI / QAD_Desktop.h
1 //  SALOME SALOMEGUI : implementation of desktop and GUI kernel
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
6 //  This library is free software; you can redistribute it and/or 
7 //  modify it under the terms of the GNU Lesser General Public 
8 //  License as published by the Free Software Foundation; either 
9 //  version 2.1 of the License. 
10 // 
11 //  This library is distributed in the hope that it will be useful, 
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of 
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
14 //  Lesser General Public License for more details. 
15 // 
16 //  You should have received a copy of the GNU Lesser General Public 
17 //  License along with this library; if not, write to the Free Software 
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
19 // 
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : QAD_Desktop.h
25 //  Author : Nicolas REJNERI
26 //  Module : SALOME
27 //  $Header$
28
29 #ifndef QAD_DESKTOP_H
30 #define QAD_DESKTOP_H
31
32 #include "QAD.h"
33 #include "QAD_ResourceMgr.h"
34 #include "QAD_Application.h"
35 #include "QAD_OperatorMenus.h"
36 #include "QAD_Menus.h"
37 #include "QAD_HelpWindow.h"
38 #include "QAD_Action.h"
39
40 #include "SALOME_NamingService.hxx"
41 #include "SALOME_LifeCycleCORBA.hxx"
42
43 // IDL Headers 
44 #include <SALOMEconfig.h>
45 #include CORBA_CLIENT_HEADER(SALOME_ModuleCatalog)
46 #include CORBA_CLIENT_HEADER(SALOME_Component)
47 #include CORBA_SERVER_HEADER(SALOMEDS)
48
49 // QT Includes
50 #include <qlist.h>
51 #include <qmap.h>
52 #include <qmenubar.h>
53 #include <qtoolbar.h>
54 #include <qcombobox.h>
55 #include <qstatusbar.h>
56 #include <qpopupmenu.h>
57 #include "qworkspaceP.h"
58 #include <qmainwindow.h>
59 #include <qfiledialog.h>
60 #include <qtoolbutton.h>
61
62 // Open CASCADE Includes
63 #include <OSD_SharedLibrary.hxx>
64
65 class QAD_XmlHandler;
66
67 class QAD_EXPORT QAD_Desktop : public QMainWindow
68 {
69   Q_OBJECT
70
71 protected:
72   enum ComponentType {GEOM, MESH, SOLVER, DATA, VISU, OTHER} ;
73
74   enum {  FileNewId = 0, FileOpenId, FileLoadId, FileCloseId, FileSaveId, FileSaveAsId, FilePropsId, FileExitId,
75           ViewStatusBarId,
76           SelectionPointId, SelectionEdgeId, SelectionCellId, SelectionActorId,
77           PrefViewerOCCId, PrefViewerVTKId, PrefGraphSupervisorId, PrefViewerPlot2dId,
78           //VRV: T2.5 - add default viewer
79           DefaultViewerOCCId, DefaultViewerVTKId, DefaultGraphSupervisorId, DefaultPlot2dId,
80           //VRV: T2.5 - add default viewer
81           PrefViewerTrihedronId, PrefConsoleFontId, PrefObjectBrowserEntryId, 
82           PrefObjectBrowserIAPPId, PrefObjectBrowserValueId, PrefObjectBrowserCHRONO_SORTId, 
83           PrefDirsId, PrefMultiFileSave, PrefASCIISave, PrefExternalBrowserId, PrefSaveId,
84           //NRI : SAL2214
85           WindowNew3dId, ViewOCCId, ViewVTKId, ViewPlot2dId,
86           //NRI : SAL2214
87           WindowCascadeId, WindowTileId, 
88           HelpContentsId, HelpSearchId, HelpWhatsThisId, HelpAboutId };
89   enum UpdateCommand { ActivateApp, DeactivateApp };
90
91     /* Desktop can be created only by application */
92     friend  bool QAD_Application::createDesktop( SALOME_NamingService* name_service );
93     QAD_Desktop( SALOME_NamingService* name_service );
94
95 public:
96     ~QAD_Desktop();
97
98     /* global event filter for qapplication */
99     bool eventFilter( QObject* o, QEvent* e );
100
101     /* resources */
102     static QAD_ResourceMgr* getResourceManager();
103     static QAD_ResourceMgr* createResourceManager();
104
105     /* palette */
106     static QPalette* getPalette();
107     static QPalette* createPalette();
108
109     /* activeStudyChanged */
110     void onActiveStudyChanged();
111
112     /* popup */
113     void     definePopup(QString & theContext,
114                          QString & theParent, 
115                          QString & theObject );
116
117     void     createPopup(QPopupMenu* popupFather, QPopupMenu* popup,
118                          QString text, int popupID, bool separator = false);
119     void     createPopup(QPopupMenu* popup, const QString & theContext,
120                          const QString & theParent, const QString & theObject );
121     void     customPopup(QPopupMenu* popup, const QString & theContext,
122                          const QString & theParent, const QString & theObject);
123
124     /* selection mode */
125     void SetSelectionMode(int mode, bool activeCompOnly = false);
126
127     /* desktop */
128     void              showDesktop();
129     void              closeDesktop( bool forceClose = false );
130     void              putInfo ( const QString& );
131     void              putInfo ( const QString&, int );
132     QToolBar*         getStdToolBar() const;
133     QMenuBar*         getMainMenuBar() const;
134
135     /* application */
136     void              addApplication(QAD_Application* app);
137
138     /* studies */
139     const QString&    getDefaultTitle() const;
140     const QPixmap&    getDefaultIcon() const;
141     const QString&    getDefaultStudyName() const;
142     QAD_Application*  getActiveApp() const;
143     QAD_Study*        getActiveStudy() const;
144     QWorkspaceP*      getMainFrame() const;
145     QString           getNewStudyName();
146     QAD_Study*        findStudy( SALOMEDS::Study_ptr theStudy );
147
148     /* help actions */
149     virtual void      helpAbout();    
150     virtual void      helpSearch();
151     virtual void      helpContents();
152     virtual void      helpContext(const QString& path, const QString& dir = QString::null);
153
154     bool              loadComponent(QString);
155     void              activateComponent(const QString& theName, bool isLoadData = true);
156     void              createStudy();
157
158     void              setSettings();
159
160     SALOME_ModuleCatalog::ModuleCatalog_var getCatalogue();
161
162     QAD_Menus*            getActiveMenus()      {return myActiveMenus;}
163     QAD_OperatorMenus*    getOperatorMenus()    {return myOperatorMenus;}
164     const OSD_SharedLibrary&  getHandle() const {return mySharedLibrary;}// never return sych objects "by value"
165     const QString&        getActiveComponent() const;
166     SALOME_NamingService* getNameService()      {return myNameService;}
167
168     Engines::Component_var getEngine(const char *containerName,
169                                      const char *componentName);
170
171     QAD_HelpWindow*   getHelpWindow();
172
173     void              onMouseMove(QMouseEvent*);
174     bool              onMousePress(QMouseEvent*);
175     void              onKeyPress(QKeyEvent*);
176
177     virtual QAD_Study* loadStudy(QString theStudyName);
178
179 protected:
180     bool              closeAllStudies( QAD_Application* );
181     void              closeEvent( QCloseEvent* );
182     void              resizeEvent( QResizeEvent* );
183
184     virtual  QString  selectFileName ( bool open );
185
186     virtual   void    updateDesktop( UpdateCommand  );
187     virtual   void    updateStatusBar( UpdateCommand );
188     virtual   void    updateToolBars( UpdateCommand );
189     virtual   void    updateCaption( UpdateCommand );
190     virtual   void    updateMenu( UpdateCommand );
191
192     bool              loadComponentData( const QString& );
193
194 protected slots:
195     virtual void      onNewStudy();
196     virtual void      onNewStudy(QAD_Application* app);
197     virtual void      onLoadStudy();
198     virtual void      onOpenStudy();
199     virtual bool      onSaveStudy();
200     virtual bool      onSaveStudy(QAD_Study* doc);
201     virtual bool      onSaveAsStudy();
202     virtual bool      onSaveAsStudy(QAD_Study* doc);
203     virtual bool      onCloseStudy();
204     virtual bool      onCloseStudy(QAD_Study* doc);
205     //ask user to remove study from study manager permanently
206     virtual bool      onCloseStudy(QAD_Study* doc, bool ask);
207
208     virtual void      onStudyProperties();
209
210     virtual void      onViewStatusBar();
211     virtual void      onToolBarPopupAboutToShow();
212
213     virtual void      onExit();
214
215     virtual void      onWindowPopupAboutToShow();
216     void              onWindowsPopupActivated( int id );
217     void              onWindowsPopupStatusText( int id );
218
219     void              onSelectionMode();
220
221     void              onDirList();
222     void              onSavePref();
223     void              onViewerOCC();
224     void              onViewerVTK();
225     void              onGraphSupervisor();
226     void              onPlot2d();
227     void              onConsoleFontAction();
228   //VRV: T2.5 - add default viewer
229     void              onDefaultViewer( QActionP * theAction);
230   //VRV: T2.5 - add default viewer
231
232     void              onViewerTrihedron();
233     void              onObjectBrowser();
234     void              onMultiFileSave();
235     void              onASCIISave();
236     void              onExternalBrowser();      
237
238     void              onActivateApp(QAD_Application* app);
239     void              onDeactivateApp(QAD_Application* app);
240
241     void              onHelpContents();
242     void              onHelpContentsGUI();
243     void              onHelpContentsTUI();
244     void              onHelpSearch();
245     void              onHelpAbout();
246
247     void              onNewWindow3d();
248
249     void              onOpenWith();
250
251     void              onDispatchTools(int id);
252     void              onDispatch(int id);
253     void              onDispatch();
254     void              clearMenus();
255     void              onButtonActiveComponent();
256     void              onComboActiveComponent( const QString & );
257     void              onComboActiveComponent( const QString & , bool isLoadData);
258     void              onCascade(); 
259
260     void              onHelpWindowClosed();
261
262 protected:
263     QMenuBar*         myMainMenu;           /* the main menu bar */
264     int               myMainMenuPos;        /* index after which application inserts its items */
265     QPopupMenu        myFilePopup;
266     int               myFilePos;
267     QPopupMenu        myEditPopup;
268     int               myEditPos;
269     QPopupMenu        myViewPopup;
270     int               myViewPos;
271     QPopupMenu        myHelpPopup;
272     int               myHelpPos;
273
274   //VRV: T2.5 - add default viewer
275     QPopupMenu        myDefaultViewer;
276   //VRV: T2.5 - add default viewer
277     QPopupMenu        myObjBrowserPopup;
278     QPopupMenu        myViewerPopup;
279   //NRI : SAL2214
280     QPopupMenu        myNewViewPopup;
281   //NRI : SAL2214
282     QPopupMenu        myToolsPopup;
283     QPopupMenu        myPrefPopup;
284     QPopupMenu        mySelectionModePopup;
285     QPopupMenu        myWindowPopup;        /* not customized by an application */
286
287     ActionMap         myStdActions;         /* default actions */
288     QToolBar*         myStdToolBar;         /* standard toolbar */
289     QStatusBar*       myStatusBar;          /* the only status bar */
290
291     QList<ToggleAction> myToolBarAction;
292     QPopupMenu          myToolBarsPopup;
293
294     QList<QAD_Application> myApps;          /* running applications */
295     QAD_Application*  myActiveApp;          /* the active application */
296     QAD_Study*        myActiveStudy;        /* the active document */
297
298     int               myCntUntitled;        /* number of untitled docs */
299     QWorkspaceP*      myWorkspace;          /* workspace */
300
301     QPixmap           myDefaultIcon;        /* if no application is active */
302     QString           myDefaultTitle;       /* desktop will use them */
303
304     QAD_OperatorMenus* myOperatorMenus;
305     QList<QAD_Menus>   myMenusList;
306     QAD_Menus*         myActiveMenus;
307
308     QAD_HelpWindow*    myHelpWindow;
309
310     QList<QToolButton> myComponentButton;
311
312 private:
313     static QAD_ResourceMgr*                 resourceMgr;
314     static QPalette*                        palette;
315     void                                    createActions();
316     void                                    updateActions();
317     OSD_SharedLibrary                       mySharedLibrary;
318     QAD_XmlHandler*                         myXmlHandler;
319     QString                                 myActiveComp;
320     SALOME_NamingService*                   myNameService;
321     SALOME_ModuleCatalog::ModuleCatalog_var myCatalogue;
322     SALOME_LifeCycleCORBA *                 myEnginesLifeCycle;
323     QComboBox *                             myCombo;
324     bool                                    myQueryClose;
325 };
326
327 /********************************************************************
328 ** Class: AppSelectionDlg
329 ** Descr: Dialog for the selection of the application when several
330 **        applications exist in the desktop and new document creation
331 **        is activated by user.
332 ** Level: Internal
333 *********************************************************************/
334 class Desktop_AppSelectionDlg : public QDialog
335 {
336    Q_OBJECT
337
338 public:
339    Desktop_AppSelectionDlg( QAD_Desktop*, QList<QAD_Application>& );
340    ~Desktop_AppSelectionDlg();
341
342 public:
343     QAD_Application* selectedApp()  const;
344
345 protected:
346     void             resizeEvent( QResizeEvent* );
347
348 protected slots:
349     void             onAppSelected(int);
350     void             onHelp();
351
352 protected:
353     int                                     myAppId;
354     QList<QAD_Application>&                 myApps;
355 };
356
357 #endif
358