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 //NRI#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,PrefObjectBrowserShowUseCaseId,
83 PrefObjectBrowserNoAutoSizeColumnsId,
84 PrefDirsId, PrefMultiFileSave, PrefASCIISave, PrefUndoLevelId, PrefExternalBrowserId, PrefSaveId,
86 WindowNew3dId, ViewOCCId, ViewVTKId, ViewPlot2dId,
88 WindowCascadeId, WindowTileId,
89 HelpContentsId, HelpSearchId, HelpWhatsThisId, HelpAboutId };
90 enum UpdateCommand { ActivateApp, DeactivateApp };
92 /* Desktop can be created only by application */
93 friend bool QAD_Application::createDesktop( SALOME_NamingService* name_service );
94 QAD_Desktop( SALOME_NamingService* name_service );
99 /* global event filter for qapplication */
100 bool eventFilter( QObject* o, QEvent* e );
103 static QAD_ResourceMgr* getResourceManager();
104 static QAD_ResourceMgr* createResourceManager();
107 static QPalette* getPalette();
108 static QPalette* createPalette();
110 /* activeStudyChanged */
111 void onActiveStudyChanged();
114 void definePopup(QString & theContext,
116 QString & theObject );
118 void createPopup(QPopupMenu* popupFather, QPopupMenu* popup,
119 QString text, int popupID, bool separator = false);
120 void createPopup(QPopupMenu* popup, const QString & theContext,
121 const QString & theParent, const QString & theObject );
122 void customPopup(QPopupMenu* popup, const QString & theContext,
123 const QString & theParent, const QString & theObject);
126 void SetSelectionMode(int mode, bool activeCompOnly = false);
130 void closeDesktop( bool forceClose = false );
131 void putInfo ( const QString& );
132 void putInfo ( const QString&, int );
133 QToolBar* getStdToolBar() const;
134 QMenuBar* getMainMenuBar() const;
137 void addApplication(QAD_Application* app);
140 const QString& getDefaultTitle() const;
141 const QPixmap& getDefaultIcon() const;
142 const QString& getDefaultStudyName() const;
143 QAD_Application* getActiveApp() const;
144 QAD_Study* getActiveStudy() const;
145 QWorkspaceP* getMainFrame() const;
146 QString getNewStudyName();
147 QAD_Study* findStudy( SALOMEDS::Study_ptr theStudy );
148 static int getUndoLevel();
150 virtual void helpAbout();
151 /* virtual void helpSearch();
152 virtual void helpContents();
153 virtual void helpContext(const QString& path, const QString& dir = QString::null);
155 bool loadComponent(QString);
156 QString changeXmlInputSourceData(QString theData, QString theComponent);
157 void activateComponent(const QString& theName, bool isLoadData = true);
162 SALOME_ModuleCatalog::ModuleCatalog_var getCatalogue();
164 QAD_Menus* getActiveMenus() {return myActiveMenus;}
165 QAD_OperatorMenus* getOperatorMenus() {return myOperatorMenus;}
166 const OSD_SharedLibrary& getHandle() const {return mySharedLibrary;}// never return sych objects "by value"
167 const QString& getActiveComponent() const;
168 SALOME_NamingService* getNameService() {return myNameService;}
170 Engines::Component_var getEngine(const char *containerName,
171 const char *componentName);
173 QString getComponentName(const char *componentUserName);
174 QString getComponentUserName(const char *componentName);
176 //NRI QAD_HelpWindow* getHelpWindow();
178 void onMouseMove(QMouseEvent*);
179 bool onMousePress(QMouseEvent*);
180 void onKeyPress(QKeyEvent*);
182 virtual QAD_Study* loadStudy(QString theStudyName);
185 bool closeAllStudies( QAD_Application* );
186 void closeEvent( QCloseEvent* );
187 void resizeEvent( QResizeEvent* );
189 virtual QString selectFileName ( bool open );
191 virtual void updateDesktop( UpdateCommand );
192 virtual void updateStatusBar( UpdateCommand );
193 virtual void updateToolBars( UpdateCommand );
194 virtual void updateCaption( UpdateCommand );
195 virtual void updateMenu( UpdateCommand );
197 bool loadComponentData( const QString& );
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);
213 virtual void onStudyProperties();
215 virtual void onViewStatusBar();
216 virtual void onToolBarPopupAboutToShow();
218 virtual void onExit();
220 virtual void onWindowPopupAboutToShow();
221 void onWindowsPopupActivated( int id );
222 void onWindowsPopupStatusText( int id );
224 void onSelectionMode();
230 void onGraphSupervisor();
232 void onConsoleFontAction();
233 //VRV: T2.5 - add default viewer
234 void onDefaultViewer( QActionP * theAction);
235 //VRV: T2.5 - add default viewer
237 void onViewerTrihedron();
238 void onObjectBrowser();
239 void onMultiFileSave();
242 void onExternalBrowser();
244 void onActivateApp(QAD_Application* app);
245 void onDeactivateApp(QAD_Application* app);
247 void onHelpContents();
248 void onHelpContentsGUI();
249 void onHelpContentsTUI();
250 /* void onHelpSearch(); */
253 void onNewWindow3d();
257 void onDispatchTools(int id);
258 void onDispatch(int id);
261 void onButtonActiveComponent();
262 void onComboActiveComponent( const QString & );
263 void onComboActiveComponent( const QString & , bool isLoadData);
266 /* NRI void onHelpWindowClosed(); */
269 QMenuBar* myMainMenu; /* the main menu bar */
270 int myMainMenuPos; /* index after which application inserts its items */
271 QPopupMenu myFilePopup;
273 QPopupMenu myEditPopup;
275 QPopupMenu myViewPopup;
277 QPopupMenu myHelpPopup;
280 //VRV: T2.5 - add default viewer
281 QPopupMenu myDefaultViewer;
282 //VRV: T2.5 - add default viewer
283 QPopupMenu myObjBrowserPopup;
284 QPopupMenu myViewerPopup;
286 QPopupMenu myNewViewPopup;
288 QPopupMenu myToolsPopup;
289 QPopupMenu myPrefPopup;
290 QPopupMenu mySelectionModePopup;
291 QPopupMenu myWindowPopup; /* not customized by an application */
293 ActionMap myStdActions; /* default actions */
294 QToolBar* myStdToolBar; /* standard toolbar */
295 QStatusBar* myStatusBar; /* the only status bar */
297 QList<ToggleAction> myToolBarAction;
298 QPopupMenu myToolBarsPopup;
300 QList<QAD_Application> myApps; /* running applications */
301 QAD_Application* myActiveApp; /* the active application */
302 QAD_Study* myActiveStudy; /* the active document */
304 int myCntUntitled; /* number of untitled docs */
305 QWorkspaceP* myWorkspace; /* workspace */
307 QPixmap myDefaultIcon; /* if no application is active */
308 QString myDefaultTitle; /* desktop will use them */
310 QAD_OperatorMenus* myOperatorMenus;
311 QList<QAD_Menus> myMenusList;
312 QAD_Menus* myActiveMenus;
314 //NRI QAD_HelpWindow* myHelpWindow;
316 QList<QToolButton> myComponentButton;
318 QMap<QString,QString> mapComponentName;
321 static QAD_ResourceMgr* resourceMgr;
322 static QPalette* palette;
323 void createActions();
324 void updateActions();
325 OSD_SharedLibrary mySharedLibrary;
326 QAD_XmlHandler* myXmlHandler;
327 QString myActiveComp;
328 SALOME_NamingService* myNameService;
329 SALOME_ModuleCatalog::ModuleCatalog_var myCatalogue;
330 SALOME_LifeCycleCORBA * myEnginesLifeCycle;
336 /********************************************************************
337 ** Class: AppSelectionDlg
338 ** Descr: Dialog for the selection of the application when several
339 ** applications exist in the desktop and new document creation
340 ** is activated by user.
342 *********************************************************************/
343 class Desktop_AppSelectionDlg : public QDialog
348 Desktop_AppSelectionDlg( QAD_Desktop*, QList<QAD_Application>& );
349 ~Desktop_AppSelectionDlg();
352 QAD_Application* selectedApp() const;
355 void resizeEvent( QResizeEvent* );
358 void onAppSelected(int);
363 QList<QAD_Application>& myApps;