1 // SALOME SALOMEGUI : implementation of desktop and GUI kernel
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : QAD_Desktop.h
25 // Author : Nicolas REJNERI
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"
40 #include "SALOME_NamingService.hxx"
41 #include "SALOME_LifeCycleCORBA.hxx"
44 #include <SALOMEconfig.h>
45 #include CORBA_CLIENT_HEADER(SALOME_ModuleCatalog)
46 #include CORBA_CLIENT_HEADER(SALOME_Component)
47 #include CORBA_SERVER_HEADER(SALOMEDS)
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>
62 // Open CASCADE Includes
63 #include <OSD_SharedLibrary.hxx>
67 class QAD_EXPORT QAD_Desktop : public QMainWindow
72 //NRI - unused - : enum ComponentType {GEOM, MESH, SOLVER, DATA, VISU, OTHER} ;
74 enum { FileNewId = 0, FileOpenId, FileLoadId, FileCloseId, FileSaveId, FileSaveAsId, FilePropsId, FileExitId,
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, PrefSaveId,
85 WindowNew3dId, ViewOCCId, ViewVTKId, ViewPlot2dId,
87 WindowCascadeId, WindowTileId,
88 HelpContentsId, HelpSearchId, HelpWhatsThisId, HelpAboutId };
89 enum UpdateCommand { ActivateApp, DeactivateApp };
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 );
98 /* global event filter for qapplication */
99 bool eventFilter( QObject* o, QEvent* e );
102 static QAD_ResourceMgr* getResourceManager();
103 static QAD_ResourceMgr* createResourceManager();
106 static QPalette* getPalette();
107 static QPalette* createPalette();
109 /* activeStudyChanged */
110 void onActiveStudyChanged();
113 void definePopup(QString & theContext,
115 QString & theObject );
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);
125 void SetSelectionMode(int mode, bool activeCompOnly = false);
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;
136 void addApplication(QAD_Application* app);
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 );
149 virtual void helpAbout();
150 virtual void helpSearch();
151 virtual void helpContents();
152 virtual void helpContext(const QString& path, const QString& dir = QString::null);
154 bool loadComponent(QString);
155 void activateComponent(const QString& theName, bool isLoadData = true);
160 SALOME_ModuleCatalog::ModuleCatalog_var getCatalogue();
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;}
168 Engines::Component_var getEngine(const char *containerName,
169 const char *componentName);
171 QString getComponentName(const char *componentUserName);
172 QString getComponentUserName(const char *componentName);
174 QAD_HelpWindow* getHelpWindow();
176 void onMouseMove(QMouseEvent*);
177 bool onMousePress(QMouseEvent*);
178 void onKeyPress(QKeyEvent*);
180 virtual QAD_Study* loadStudy(QString theStudyName);
183 bool closeAllStudies( QAD_Application* );
184 void closeEvent( QCloseEvent* );
185 void resizeEvent( QResizeEvent* );
187 virtual QString selectFileName ( bool open );
189 virtual void updateDesktop( UpdateCommand );
190 virtual void updateStatusBar( UpdateCommand );
191 virtual void updateToolBars( UpdateCommand );
192 virtual void updateCaption( UpdateCommand );
193 virtual void updateMenu( UpdateCommand );
195 bool loadComponentData( const QString& );
198 virtual void onNewStudy();
199 virtual void onNewStudy(QAD_Application* app);
200 virtual void onLoadStudy();
201 virtual void onOpenStudy();
202 virtual bool onSaveStudy();
203 virtual bool onSaveStudy(QAD_Study* doc);
204 virtual bool onSaveAsStudy();
205 virtual bool onSaveAsStudy(QAD_Study* doc);
206 virtual bool onCloseStudy();
207 virtual bool onCloseStudy(QAD_Study* doc);
208 //ask user to remove study from study manager permanently
209 virtual bool onCloseStudy(QAD_Study* doc, bool ask);
211 virtual void onStudyProperties();
213 virtual void onViewStatusBar();
214 virtual void onToolBarPopupAboutToShow();
216 virtual void onExit();
218 virtual void onWindowPopupAboutToShow();
219 void onWindowsPopupActivated( int id );
220 void onWindowsPopupStatusText( int id );
222 void onSelectionMode();
228 void onGraphSupervisor();
230 void onConsoleFontAction();
231 //VRV: T2.5 - add default viewer
232 void onDefaultViewer( QActionP * theAction);
233 //VRV: T2.5 - add default viewer
235 void onViewerTrihedron();
236 void onObjectBrowser();
237 void onMultiFileSave();
240 void onActivateApp(QAD_Application* app);
241 void onDeactivateApp(QAD_Application* app);
243 void onHelpContents();
247 void onNewWindow3d();
251 void onDispatchTools(int id);
252 void onDispatch(int id);
255 void onButtonActiveComponent();
256 void onComboActiveComponent( const QString & );
257 void onComboActiveComponent( const QString & , bool isLoadData);
260 void onHelpWindowClosed();
263 QMenuBar* myMainMenu; /* the main menu bar */
264 int myMainMenuPos; /* index after which application inserts its items */
265 QPopupMenu myFilePopup;
267 QPopupMenu myEditPopup;
269 QPopupMenu myViewPopup;
271 QPopupMenu myHelpPopup;
274 //VRV: T2.5 - add default viewer
275 QPopupMenu myDefaultViewer;
276 //VRV: T2.5 - add default viewer
277 QPopupMenu myObjBrowserPopup;
278 QPopupMenu myViewerPopup;
280 QPopupMenu myNewViewPopup;
282 QPopupMenu myToolsPopup;
283 QPopupMenu myPrefPopup;
284 QPopupMenu mySelectionModePopup;
285 QPopupMenu myWindowPopup; /* not customized by an application */
287 ActionMap myStdActions; /* default actions */
288 QToolBar* myStdToolBar; /* standard toolbar */
289 QStatusBar* myStatusBar; /* the only status bar */
291 QList<ToggleAction> myToolBarAction;
292 QPopupMenu myToolBarsPopup;
294 QList<QAD_Application> myApps; /* running applications */
295 QAD_Application* myActiveApp; /* the active application */
296 QAD_Study* myActiveStudy; /* the active document */
298 int myCntUntitled; /* number of untitled docs */
299 QWorkspaceP* myWorkspace; /* workspace */
301 QPixmap myDefaultIcon; /* if no application is active */
302 QString myDefaultTitle; /* desktop will use them */
304 QAD_OperatorMenus* myOperatorMenus;
305 QList<QAD_Menus> myMenusList;
306 QAD_Menus* myActiveMenus;
308 QAD_HelpWindow* myHelpWindow;
310 QList<QToolButton> myComponentButton;
312 QMap<QString,QString> mapComponentName;
315 static QAD_ResourceMgr* resourceMgr;
316 static QPalette* palette;
317 void createActions();
318 void updateActions();
319 OSD_SharedLibrary mySharedLibrary;
320 QAD_XmlHandler* myXmlHandler;
321 QString myActiveComp;
322 SALOME_NamingService* myNameService;
323 SALOME_ModuleCatalog::ModuleCatalog_var myCatalogue;
324 SALOME_LifeCycleCORBA * myEnginesLifeCycle;
330 /********************************************************************
331 ** Class: AppSelectionDlg
332 ** Descr: Dialog for the selection of the application when several
333 ** applications exist in the desktop and new document creation
334 ** is activated by user.
336 *********************************************************************/
337 class Desktop_AppSelectionDlg : public QDialog
342 Desktop_AppSelectionDlg( QAD_Desktop*, QList<QAD_Application>& );
343 ~Desktop_AppSelectionDlg();
346 QAD_Application* selectedApp() const;
349 void resizeEvent( QResizeEvent* );
352 void onAppSelected(int);
357 QList<QAD_Application>& myApps;