Salome HOME
Merge branch V7_3_1_BR
[modules/gui.git] / src / SalomeApp / SalomeApp_Application.h
1 // Copyright (C) 2007-2014  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, or (at your option) any later version.
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 <omniORB4/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 #include <QPointer>
48
49 class LightApp_Preferences;
50 class SalomeApp_Study;
51 #ifndef DISABLE_PYCONSOLE
52   class SalomeApp_NoteBook;
53 #endif
54 class SUIT_Desktop;
55
56 class SUIT_ViewModel;
57 class SALOME_LifeCycleCORBA;
58
59
60 #ifdef WIN32
61 #pragma warning( disable:4251 )
62 #endif
63
64 /*!
65   \class SalomeApp_Application
66   \brief Application containing SalomeApp module or LightApp module
67 */
68
69 class SALOMEAPP_EXPORT SalomeApp_Application : public LightApp_Application
70 {
71   Q_OBJECT
72
73 public:
74   enum { MenuToolsId = 5 };
75   enum { DumpStudyId = LightApp_Application::UserID, LoadScriptId, PropertiesId,
76          CatalogGenId, RegDisplayId, SaveGUIStateId, FileLoadId, UserID,
77          SimanCheckInId, SimanLocalCheckInId };
78
79   typedef enum { WT_NoteBook = LightApp_Application::WT_User } WindowTypes;
80
81 protected:
82   enum { OpenRefresh = LightApp_Application::OpenReload + 1 };
83   enum { CloseUnload = LightApp_Application::CloseDiscard + 1 };
84   enum { LoadStudyId = LightApp_Application::OpenStudyId + 1, NewAndScriptId };
85
86 public:
87   SalomeApp_Application();
88   virtual ~SalomeApp_Application();
89
90   virtual void                        updateObjectBrowser( const bool = true );
91
92   virtual QString                     getFileFilter() const;
93
94   virtual void                        start();
95
96   virtual void                        contextMenuPopup( const QString&, QMenu*, QString& );
97
98   virtual bool                        checkDataObject(LightApp_DataObject* theObj);
99
100   virtual void                        setDesktop( SUIT_Desktop* );
101
102   static CORBA::ORB_var               orb();
103   static SALOMEDSClient_StudyManager* studyMgr();
104   static SALOME_NamingService*        namingService();
105   static SALOME_LifeCycleCORBA*       lcc();
106
107   SUIT_ViewManager*                   newViewManager(const QString&);
108   void                                updateSavePointDataObjects( SalomeApp_Study* );
109
110   virtual bool                        isPossibleToClose( bool& );
111
112   virtual bool                        useStudy( const QString& );
113   virtual void                        updateDesktopTitle();
114   virtual void                        currentWindows( QMap<int, int>& ) const;
115
116 #ifndef DISABLE_PYCONSOLE
117   virtual void                        setNoteBook(SalomeApp_NoteBook* theNoteBook);
118   virtual SalomeApp_NoteBook*         getNoteBook() const;
119 #endif
120
121  //! update visibility state of objects
122   void                                updateVisibilityState( DataObjectList& theList,
123                                                              SUIT_ViewModel* theViewModel );  
124
125   virtual bool                        renameAllowed( const QString& ) const;
126   virtual bool                        renameObject( const QString&, const QString& );
127   
128 public slots:
129   virtual void                        onLoadDoc();
130   virtual void                        onNewWithScript();
131   virtual bool                        onLoadDoc( const QString& );
132   virtual void                        onCloseDoc( bool ask = true);
133   virtual void                        onLoadDocMessage(const QString&);
134
135   virtual void                        onExit();
136   virtual void                        onCopy();
137   virtual void                        onPaste();
138   void                                onSaveGUIState();// called from VISU
139 #ifndef DISABLE_PYCONSOLE
140   void                                onUpdateStudy(); // called from NoteBook
141 #endif
142   bool                                onRestoreStudy( const QString& theDumpScript,
143                                                       const QString& theStudyName,
144                                                       bool theIsStudySaved );
145
146   virtual void                        onCheckIn();
147   virtual void                        onLocalCheckIn();
148
149 protected slots:
150   void                                onStudyCreated( SUIT_Study* );
151   void                                onStudySaved( SUIT_Study* );
152   void                                onStudyOpened( SUIT_Study* );
153   void                                onStudyClosed( SUIT_Study* );
154   
155   void                                onViewManagerRemoved( SUIT_ViewManager* );
156
157 protected:
158   virtual void                        createActions();
159   virtual SUIT_Study*                 createNewStudy();
160   virtual QWidget*                    createWindow( const int );
161
162   virtual void                        updateCommandsStatus();
163   virtual void                        onSelectionChanged();
164
165   virtual void                        createPreferences( LightApp_Preferences* );
166
167   virtual bool                        closeAction( const int, bool& );
168   virtual int                         closeChoice( const QString& );
169
170   virtual int                         openChoice( const QString& );
171   virtual bool                        openAction( const int, const QString& );
172
173   virtual QMap<int, QString>          activateModuleActions() const;
174   virtual void                        moduleActionSelected( const int );
175
176   virtual void                        defaultWindows( QMap<int, int>& ) const;
177
178   void                                objectBrowserColumnsVisibility();
179
180 #ifndef DISABLE_PYCONSOLE
181   bool                                updateStudy();
182 #endif
183
184   virtual void                        afterCloseDoc();
185
186 private slots:
187   void                                onDeleteInvalidReferences();
188   void                                onDblClick( SUIT_DataObject* );
189   void                                onProperties();
190   void                                onDumpStudy();
191   void                                onLoadScript();
192
193   void                                onDeleteGUIState();
194   void                                onRestoreGUIState();
195
196   void                                onCatalogGen();
197   void                                onRegDisplay();
198   void                                onOpenWith();
199   void                                onExtAction();
200
201   void                                onWindowActivated( SUIT_ViewWindow* theViewWindow );
202
203 private:
204   void                                createExtraActions();
205
206 private:
207 #ifndef DISABLE_PYCONSOLE
208   QPointer<SalomeApp_NoteBook>        myNoteBook;
209 #endif
210   QMap<QString, QAction*>             myExtActions; // Map <AttributeUserID, QAction>
211   bool                                myIsSiman; // application corresponds to the siman study flag
212
213 signals:
214   void                                dumpedStudyClosed( const QString& theDumpScript, 
215                                                          const QString& theStudyName, 
216                                                          bool theIsStudySaved );
217   void                                notebookVarUpdated( QString theVarName );
218
219 };
220
221 #ifdef WIN32
222 #pragma warning( default:4251 )
223 #endif
224
225 #endif