]> SALOME platform Git repositories - modules/kernel.git/blob - src/SALOMEGUI/QAD_Desktop.h
Salome HOME
83bc083c972ceb6c8f30bb1c09f3831fae75a4d8
[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 //NRI#include "QAD_HelpWindow.h"
38 #include "QAD_Action.h"
39
40 #include "SALOME_NamingService.hxx"
41 #include "SALOME_LifeCycleCORBA.hxx"
42 #include "SALOME_Selection.h"
43
44 // IDL Headers 
45 #include <SALOMEconfig.h>
46 #include CORBA_CLIENT_HEADER(SALOME_ModuleCatalog)
47 #include CORBA_CLIENT_HEADER(SALOME_Component)
48 #include CORBA_SERVER_HEADER(SALOMEDS)
49
50 // QT Includes
51 #include <qlist.h>
52 #include <qmap.h>
53 #include <qmenubar.h>
54 #include <qtoolbar.h>
55 #include <qcombobox.h>
56 #include <qstatusbar.h>
57 #include <qpopupmenu.h>
58 #include "qworkspaceP.h"
59 #include <qmainwindow.h>
60 #include <qfiledialog.h>
61 #include <qtoolbutton.h>
62
63 class QAD_XmlHandler;
64 class SALOMEGUI;
65 class SALOME_Event;
66
67 class QAD_EXPORT QAD_Desktop : public QMainWindow
68 {
69   Q_OBJECT
70
71 protected:
72   //NRI - unused - :  enum ComponentType {GEOM, MESH, SOLVER, DATA, VISU, OTHER} ;
73
74   enum {  FileNewId = -1000, 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,PrefObjectBrowserShowUseCaseId, 
83           PrefObjectBrowserNoAutoSizeColumnsId,  
84           PrefDirsId, PrefMultiFileSave, PrefASCIISave, PrefUndoLevelId, PrefExternalBrowserId, PrefSaveId,
85           //NRI : SAL2214
86           WindowNew3dId, ViewOCCId, ViewVTKId, ViewPlot2dId,
87           //NRI : SAL2214
88           WindowCascadeId, WindowTileId, 
89           HelpContentsId, HelpContentsModuleId,
90           HelpSearchId, HelpWhatsThisId, HelpAboutId };
91   enum UpdateCommand { ActivateApp, DeactivateApp };
92
93     /* Desktop can be created only by application */
94     friend  bool QAD_Application::createDesktop( SALOME_NamingService* name_service );
95     QAD_Desktop( SALOME_NamingService* name_service );
96
97 public:
98     ~QAD_Desktop();
99
100     /* global event filter for qapplication */
101     bool eventFilter( QObject* o, QEvent* e );
102
103     /* resources */
104     static QAD_ResourceMgr* getResourceManager();
105     static QAD_ResourceMgr* createResourceManager();
106
107     /* palette */
108     static QPalette* getPalette();
109     static QPalette* createPalette();
110
111     /* activeStudyChanged */
112     void onActiveStudyChanged();
113
114     /* popup */
115     void     definePopup(QString & theContext,
116                          QString & theParent, 
117                          QString & theObject );
118     void     createPopup(QPopupMenu* popup, const QString & theContext,
119                          const QString & theParent, const QString & theObject );
120     void     customPopup(QPopupMenu* popup, const QString & theContext,
121                          const QString & theParent, const QString & theObject);
122
123     /* selection mode */
124     void SetSelectionMode(Selection_Mode mode, bool activeCompOnly = false);
125
126     /* desktop */
127     void              showDesktop();
128     void              closeDesktop( bool forceClose = false );
129     void              putInfo ( const QString& );
130     void              putInfo ( const QString&, int );
131     QToolBar*         getStdToolBar() const;
132     QMenuBar*         getMainMenuBar() const;
133
134     /* application */
135     void              addApplication(QAD_Application* app);
136
137     /* studies */
138     const QString&    getDefaultTitle() const;
139     const QPixmap&    getDefaultIcon() const;
140     const QString&    getDefaultStudyName() const;
141     QAD_Application*  getActiveApp() const;
142     QAD_Study*        getActiveStudy() const;
143     QWorkspaceP*      getMainFrame() const;
144     QString           getNewStudyName();
145     QAD_Study*        findStudy( SALOMEDS::Study_ptr theStudy );
146     static int        getUndoLevel();
147     /* help actions */
148     virtual void      helpAbout();    
149 /*    virtual void      helpSearch();
150     virtual void      helpContents();
151     virtual void      helpContext(const QString& path, const QString& dir = QString::null);
152 */
153     bool              loadComponent(QString);
154     bool              loadComponentData( const QString& );
155     QString           changeXmlInputSourceData(QString theData, QString theComponent);
156     void              activateComponent(const QString& theName, bool isLoadData = true);
157     void              deactivateComponent();
158     void              createStudy();
159
160     void              setSettings();
161
162     SALOME_ModuleCatalog::ModuleCatalog_var getCatalogue();
163
164     QAD_Menus*            getActiveMenus()      {return myActiveMenus;}
165     QAD_OperatorMenus*    getOperatorMenus()    {return myOperatorMenus;}
166     const QString&        getActiveComponent() const;
167     SALOMEGUI*            getActiveGUI();
168     SALOMEGUI*            getComponentGUI( const QString& );  // accepts component`s user name
169     QString               getComponentDataType() const;
170     SALOME_NamingService* getNameService()      {return myNameService;}
171
172     Engines::Component_var getEngine(const char *containerName,
173                                      const char *componentName);
174
175     QString getComponentName(const char *componentUserName);
176     QString getComponentUserName(const char *componentName);
177     
178     //NRI    QAD_HelpWindow*   getHelpWindow();
179
180     void              onMouseMove(QMouseEvent*);
181     bool              onMousePress(QMouseEvent*);
182     void              onKeyPress(QKeyEvent*);
183
184     virtual QAD_Study* loadStudy(QString theStudyName);
185
186 protected:
187     bool              closeAllStudies( QAD_Application* );
188     void              closeEvent( QCloseEvent* );
189     void              resizeEvent( QResizeEvent* );
190
191     virtual  QString  selectFileName ( bool open );
192
193     virtual   void    updateDesktop( UpdateCommand  );
194     virtual   void    updateStatusBar( UpdateCommand );
195     virtual   void    updateToolBars( UpdateCommand );
196     virtual   void    updateCaption( UpdateCommand );
197     virtual   void    updateMenu( UpdateCommand );
198
199 protected slots:
200     virtual void      onNewStudy();
201     virtual void      onNewStudy(QAD_Application* app);
202     virtual void      onLoadStudy();
203     virtual void      onOpenStudy();
204     virtual bool      onSaveStudy();
205     virtual bool      onSaveStudy(QAD_Study* doc);
206     virtual bool      onSaveAsStudy();
207     virtual bool      onSaveAsStudy(QAD_Study* doc);
208     virtual bool      onCloseStudy();
209     virtual bool      onCloseStudy(QAD_Study* doc);
210     //ask user to remove study from study manager permanently
211     virtual bool      onCloseStudy(QAD_Study* doc, bool ask);
212
213     virtual void      onStudyProperties();
214
215     virtual void      onViewStatusBar();
216     virtual void      onToolBarPopupAboutToShow();
217
218     virtual void      onExit();
219
220     virtual void      onWindowPopupAboutToShow();
221     void              onWindowsPopupActivated( int id );
222     void              onWindowsPopupStatusText( int id );
223     void              onHelpModulePopupStatusText(int id);
224     
225     void              onFilePopupStatusText( int id );
226     void              onEditPopupStatusText( int id );
227     void              onViewPopupStatusText( int id );
228
229     void              onSelectionMode();
230
231     void              onDirList();
232     void              onSavePref();
233     void              onViewerOCC();
234     void              onViewerVTK();
235     void              onGraphSupervisor();
236     void              onPlot2d();
237     void              onConsoleFontAction();
238   //VRV: T2.5 - add default viewer
239     void              onDefaultViewer( QActionP * theAction);
240   //VRV: T2.5 - add default viewer
241
242     void              onViewerTrihedron();
243     void              onObjectBrowser();
244     void              onMultiFileSave();
245     void              onASCIISave();
246     void              onUndoLevel();
247     void              onExternalBrowser();      
248
249     void              onActivateApp(QAD_Application* app);
250     void              onDeactivateApp(QAD_Application* app);
251
252     void              onHelpContents();
253     void              onHelpContentsModule();
254     /*    void        onHelpContentsTUI(); */
255 /*    void            onHelpSearch(); */
256     void              onHelpAbout();
257
258     void              onNewWindow3d();
259
260     void              onOpenWith();
261
262     void              onDispatchTools(int id);
263     void              onDispatch(int id);
264     void              onDispatch();
265     void              clearMenus();
266     void              onButtonActiveComponent();
267     void              onComboActiveComponent( const QString & );
268     void              onComboActiveComponent( const QString & , bool isLoadData);
269     void              onCascade(); 
270
271 /* NRI   void              onHelpWindowClosed(); */
272
273 protected:
274     QMenuBar*         myMainMenu;           /* the main menu bar */
275     int               myMainMenuPos;        /* index after which application inserts its items */
276     QPopupMenu        myFilePopup;
277     int               myFilePos;
278     QPopupMenu        myEditPopup;
279     int               myEditPos;
280     QPopupMenu        myViewPopup;
281     int               myViewPos;
282     QPopupMenu        myHelpPopup;
283     int               myHelpPos;
284
285   //VRV: T2.5 - add default viewer
286     QPopupMenu        myDefaultViewer;
287   //VRV: T2.5 - add default viewer
288     QPopupMenu        myObjBrowserPopup;
289     QPopupMenu        myViewerPopup;
290   //NRI : SAL2214
291     QPopupMenu        myNewViewPopup;
292   //NRI : SAL2214
293     QPopupMenu        myHelpContentsModulePopup;
294
295     QPopupMenu        myToolsPopup;
296     QPopupMenu        myPrefPopup;
297     QPopupMenu        mySelectionModePopup;
298     QPopupMenu        myWindowPopup;        /* not customized by an application */
299     
300     ActionMap         myStdActions;         /* default actions */
301     QToolBar*         myStdToolBar;         /* standard toolbar */
302     QStatusBar*       myStatusBar;          /* the only status bar */
303
304     QList<ToggleAction> myToolBarAction;
305     QPopupMenu          myToolBarsPopup;
306
307     QList<QAD_Application> myApps;          /* running applications */
308     QAD_Application*  myActiveApp;          /* the active application */
309     QAD_Study*        myActiveStudy;        /* the active document */
310
311     int               myCntUntitled;        /* number of untitled docs */
312     QWorkspaceP*      myWorkspace;          /* workspace */
313
314     QPixmap           myDefaultIcon;        /* if no application is active */
315     QString           myDefaultTitle;       /* desktop will use them */
316
317     QAD_OperatorMenus* myOperatorMenus;
318     QList<QAD_Menus>   myMenusList;
319     QAD_Menus*         myActiveMenus;
320
321     //NRI QAD_HelpWindow*    myHelpWindow;
322
323     QList<QToolButton> myComponentButton;
324
325     QMap<QString,QString> mapComponentName;
326
327 private:
328     void processEvent( SALOME_Event* );
329
330 private:
331     typedef QMap<QString, SALOMEGUI*> ComponentMap;
332
333 private:
334     static QAD_ResourceMgr*                 resourceMgr;
335     static QPalette*                        palette;
336     void                                    createActions();
337     void                                    updateActions();
338     QAD_XmlHandler*                         myXmlHandler;
339     QString                                 myActiveComp;
340     SALOME_NamingService*                   myNameService;
341     SALOME_ModuleCatalog::ModuleCatalog_var myCatalogue;
342     SALOME_LifeCycleCORBA *                 myEnginesLifeCycle;
343     QComboBox *                             myCombo;
344     bool                                    myQueryClose;
345     bool                                    myAboutToClose;
346     bool                                    _islibso;
347
348     ComponentMap                            myComponents;
349 };
350
351 /********************************************************************
352 ** Class: AppSelectionDlg
353 ** Descr: Dialog for the selection of the application when several
354 **        applications exist in the desktop and new document creation
355 **        is activated by user.
356 ** Level: Internal
357 *********************************************************************/
358 class Desktop_AppSelectionDlg : public QDialog
359 {
360    Q_OBJECT
361
362 public:
363    Desktop_AppSelectionDlg( QAD_Desktop*, QList<QAD_Application>& );
364    ~Desktop_AppSelectionDlg();
365
366 public:
367     QAD_Application* selectedApp()  const;
368
369 protected:
370     void             resizeEvent( QResizeEvent* );
371
372 protected slots:
373     void             onAppSelected(int);
374     void             onHelp();
375
376 protected:
377     int                                     myAppId;
378     QList<QAD_Application>&                 myApps;
379 };
380
381 #endif
382