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"
42 #include "SALOME_Selection.h"
45 #include <SALOMEconfig.h>
46 #include CORBA_CLIENT_HEADER(SALOME_ModuleCatalog)
47 #include CORBA_CLIENT_HEADER(SALOME_Component)
48 #include CORBA_SERVER_HEADER(SALOMEDS)
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>
67 class QAD_EXPORT QAD_Desktop : public QMainWindow
72 //NRI - unused - : enum ComponentType {GEOM, MESH, SOLVER, DATA, VISU, OTHER} ;
74 enum { FileNewId = -1000, 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, HelpContentsModuleId,
90 HelpSearchId, HelpWhatsThisId, HelpAboutId };
91 enum UpdateCommand { ActivateApp, DeactivateApp };
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 );
100 /* global event filter for qapplication */
101 bool eventFilter( QObject* o, QEvent* e );
104 static QAD_ResourceMgr* getResourceManager();
105 static QAD_ResourceMgr* createResourceManager();
108 static QPalette* getPalette();
109 static QPalette* createPalette();
111 /* activeStudyChanged */
112 void onActiveStudyChanged();
115 void definePopup(QString & theContext,
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);
124 void SetSelectionMode(Selection_Mode mode, bool activeCompOnly = false);
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;
135 void addApplication(QAD_Application* app);
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();
148 virtual void helpAbout();
149 /* virtual void helpSearch();
150 virtual void helpContents();
151 virtual void helpContext(const QString& path, const QString& dir = QString::null);
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();
162 SALOME_ModuleCatalog::ModuleCatalog_var getCatalogue();
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;}
172 Engines::Component_var getEngine(const char *containerName,
173 const char *componentName);
175 QString getComponentName(const char *componentUserName);
176 QString getComponentUserName(const char *componentName);
178 //NRI QAD_HelpWindow* getHelpWindow();
180 void onMouseMove(QMouseEvent*);
181 bool onMousePress(QMouseEvent*);
182 void onKeyPress(QKeyEvent*);
184 virtual QAD_Study* loadStudy(QString theStudyName);
187 bool closeAllStudies( QAD_Application* );
188 void closeEvent( QCloseEvent* );
189 void resizeEvent( QResizeEvent* );
191 virtual QString selectFileName ( bool open );
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 );
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 );
223 void onHelpModulePopupStatusText(int id);
225 void onFilePopupStatusText( int id );
226 void onEditPopupStatusText( int id );
227 void onViewPopupStatusText( int id );
229 void onSelectionMode();
235 void onGraphSupervisor();
237 void onConsoleFontAction();
238 //VRV: T2.5 - add default viewer
239 void onDefaultViewer( QActionP * theAction);
240 //VRV: T2.5 - add default viewer
242 void onViewerTrihedron();
243 void onObjectBrowser();
244 void onMultiFileSave();
247 void onExternalBrowser();
249 void onActivateApp(QAD_Application* app);
250 void onDeactivateApp(QAD_Application* app);
252 void onHelpContents();
253 void onHelpContentsModule();
254 /* void onHelpContentsTUI(); */
255 /* void onHelpSearch(); */
258 void onNewWindow3d();
262 void onDispatchTools(int id);
263 void onDispatch(int id);
266 void onButtonActiveComponent();
267 void onComboActiveComponent( const QString & );
268 void onComboActiveComponent( const QString & , bool isLoadData);
271 void onKeyAccel( int id );
272 /* NRI void onHelpWindowClosed(); */
275 QMenuBar* myMainMenu; /* the main menu bar */
276 int myMainMenuPos; /* index after which application inserts its items */
277 QPopupMenu myFilePopup;
279 QPopupMenu myEditPopup;
281 QPopupMenu myViewPopup;
283 QPopupMenu myHelpPopup;
286 //VRV: T2.5 - add default viewer
287 QPopupMenu myDefaultViewer;
288 //VRV: T2.5 - add default viewer
289 QPopupMenu myObjBrowserPopup;
290 QPopupMenu myViewerPopup;
292 QPopupMenu myNewViewPopup;
294 QPopupMenu myHelpContentsModulePopup;
296 QPopupMenu myToolsPopup;
297 QPopupMenu myPrefPopup;
298 QPopupMenu mySelectionModePopup;
299 QPopupMenu myWindowPopup; /* not customized by an application */
301 ActionMap myStdActions; /* default actions */
302 QToolBar* myStdToolBar; /* standard toolbar */
303 QStatusBar* myStatusBar; /* the only status bar */
305 QList<ToggleAction> myToolBarAction;
306 QPopupMenu myToolBarsPopup;
308 QList<QAD_Application> myApps; /* running applications */
309 QAD_Application* myActiveApp; /* the active application */
310 QAD_Study* myActiveStudy; /* the active document */
312 int myCntUntitled; /* number of untitled docs */
313 QWorkspaceP* myWorkspace; /* workspace */
315 QPixmap myDefaultIcon; /* if no application is active */
316 QString myDefaultTitle; /* desktop will use them */
318 QAD_OperatorMenus* myOperatorMenus;
319 QList<QAD_Menus> myMenusList;
320 QAD_Menus* myActiveMenus;
322 //NRI QAD_HelpWindow* myHelpWindow;
324 QList<QToolButton> myComponentButton;
326 QMap<QString,QString> mapComponentName;
329 void processEvent( SALOME_Event* );
332 typedef QMap<QString, SALOMEGUI*> ComponentMap;
335 static QAD_ResourceMgr* resourceMgr;
336 static QPalette* palette;
337 void createActions();
338 void updateActions();
339 QAD_XmlHandler* myXmlHandler;
340 QString myActiveComp;
341 SALOME_NamingService* myNameService;
342 SALOME_ModuleCatalog::ModuleCatalog_var myCatalogue;
343 SALOME_LifeCycleCORBA * myEnginesLifeCycle;
349 ComponentMap myComponents;
350 QMap<int, int> myAccelMap;
353 /********************************************************************
354 ** Class: AppSelectionDlg
355 ** Descr: Dialog for the selection of the application when several
356 ** applications exist in the desktop and new document creation
357 ** is activated by user.
359 *********************************************************************/
360 class Desktop_AppSelectionDlg : public QDialog
365 Desktop_AppSelectionDlg( QAD_Desktop*, QList<QAD_Application>& );
366 ~Desktop_AppSelectionDlg();
369 QAD_Application* selectedApp() const;
372 void resizeEvent( QResizeEvent* );
375 void onAppSelected(int);
380 QList<QAD_Application>& myApps;