Salome HOME
c72468cfee188eb7932b69c2992322d3c33c790b
[modules/gui.git] / src / SalomeApp / SalomeApp_Application.h
1 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  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.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 // File:      SalomeApp_Application.h
24 // Created:   10/22/2004 3:37:25 PM
25 // Author:    Sergey LITONIN
26 //
27 #ifndef SALOMEAPP_APPLICATION_H
28 #define SALOMEAPP_APPLICATION_H
29
30 #if _MSC_VER > 1000
31 #pragma once
32 #endif // _MSC_VER > 1000
33
34 #include "SalomeApp.h"
35 #include <LightApp_Application.h>
36
37 #include <SUIT_DataObject.h>
38
39 #include <CORBA.h>
40
41 //#include <SALOMEconfig.h>
42 //#include CORBA_CLIENT_HEADER(SALOMEDS)
43 #include <SALOME_NamingService.hxx>
44
45 #include "SALOMEDSClient.hxx"
46
47 class LightApp_Preferences;
48 class SalomeApp_Study;
49 class SalomeApp_NoteBookDlg;
50 class SUIT_Desktop;
51
52 class SUIT_ViewModel;
53 class SALOME_LifeCycleCORBA;
54
55
56 #ifdef WIN32
57 #pragma warning( disable:4251 )
58 #endif
59
60 /*!
61   \class SalomeApp_Application
62   \brief Application containing SalomeApp module or LightApp module
63 */
64
65 class SALOMEAPP_EXPORT SalomeApp_Application : public LightApp_Application
66 {
67   Q_OBJECT
68
69 public:
70   enum { MenuToolsId = 5 };
71   enum { DumpStudyId = LightApp_Application::UserID, LoadScriptId, PropertiesId,
72          CatalogGenId, RegDisplayId, SaveGUIStateId, FileLoadId, NoteBookId, UserID };
73
74 protected:
75   enum { OpenRefresh = LightApp_Application::OpenReload + 1 };
76   enum { CloseUnload = LightApp_Application::CloseDiscard + 1 };
77   enum { LoadStudyId = LightApp_Application::OpenStudyId + 1, NewAndScriptId };
78
79 public:
80   SalomeApp_Application();
81   virtual ~SalomeApp_Application();
82
83   virtual void                        updateObjectBrowser( const bool = true );
84
85   virtual QString                     getFileFilter() const;
86
87   virtual void                        start();
88
89   virtual void                        contextMenuPopup( const QString&, QMenu*, QString& );
90
91   virtual bool                        checkDataObject(LightApp_DataObject* theObj);
92
93   virtual void                        setDesktop( SUIT_Desktop* );
94
95   static CORBA::ORB_var               orb();
96   static SALOMEDSClient_StudyManager* studyMgr();
97   static SALOME_NamingService*        namingService();
98   static SALOME_LifeCycleCORBA*       lcc();
99
100   SUIT_ViewManager*                   newViewManager(const QString&);
101   void                                updateSavePointDataObjects( SalomeApp_Study* );
102
103   virtual bool                        isPossibleToClose( bool& );
104
105   virtual bool                        useStudy( const QString& );
106   virtual void                        updateDesktopTitle();
107   
108   virtual void                        setNoteBook(SalomeApp_NoteBookDlg* theNoteBook);
109   virtual SalomeApp_NoteBookDlg*      getNoteBook() const;
110
111  //! update visibility state of objects
112   void                                updateVisibilityState( DataObjectList& theList,
113                                                              SUIT_ViewModel* theViewModel );  
114
115   virtual bool                        renameAllowed( const QString& ) const;
116   virtual bool                        renameObject( const QString&, const QString& );
117   
118 public slots:
119   virtual void                        onLoadDoc();
120   virtual void                        onNewWithScript();
121   virtual bool                        onLoadDoc( const QString& );
122   virtual void                        onCloseDoc( bool ask = true);
123
124   virtual void                        onExit();
125   virtual void                        onCopy();
126   virtual void                        onPaste();
127   void                                onSaveGUIState();// called from VISU
128
129 protected slots:
130   void                                onStudyCreated( SUIT_Study* );
131   void                                onStudySaved( SUIT_Study* );
132   void                                onStudyOpened( SUIT_Study* );
133   void                                onStudyClosed( SUIT_Study* );
134   
135   void                                onViewManagerRemoved( SUIT_ViewManager* );
136
137 protected:
138   virtual void                        createActions();
139   virtual SUIT_Study*                 createNewStudy();
140   virtual QWidget*                    createWindow( const int );
141
142   virtual void                        updateCommandsStatus();
143   virtual void                        onSelectionChanged();
144
145   virtual void                        createPreferences( LightApp_Preferences* );
146
147   virtual bool                        closeAction( const int, bool& );
148   virtual int                         closeChoice( const QString& );
149
150   virtual int                         openChoice( const QString& );
151   virtual bool                        openAction( const int, const QString& );
152
153   virtual QMap<int, QString>          activateModuleActions() const;
154   virtual void                        moduleActionSelected( const int );
155
156   void                                objectBrowserColumnsVisibility();
157
158 private slots:
159   void                                onDeleteInvalidReferences();
160   void                                onDblClick( SUIT_DataObject* );
161   void                                onProperties();
162   void                                onDumpStudy();
163   void                                onNoteBook();
164   void                                onLoadScript();
165
166   void                                onDeleteGUIState();
167   void                                onRestoreGUIState();
168
169   void                                onCatalogGen();
170   void                                onRegDisplay();
171   void                                onOpenWith();
172   void                                onExtAction();
173
174   void                                onWindowActivated( SUIT_ViewWindow* theViewWindow );
175
176 private:
177   void                                createExtraActions();
178
179 private:
180   SalomeApp_NoteBookDlg*              myNoteBook;
181   QMap<QString, QAction*>             myExtActions; // Map <AttributeUserID, QAction>
182 };
183
184 #ifdef WIN32
185 #pragma warning( default:4251 )
186 #endif
187
188 #endif