]> SALOME platform Git repositories - modules/gui.git/blob - src/SalomeApp/SalomeApp_Application.h
Salome HOME
updated copyright message
[modules/gui.git] / src / SalomeApp / SalomeApp_Application.h
1 // Copyright (C) 2007-2023  CEA, EDF, 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 <omniORB4/CORBA.h>
38
39 //#include <SALOMEconfig.h>
40 //#include CORBA_CLIENT_HEADER(SALOMEDS)
41 #include <SALOME_NamingService.hxx>
42
43 #include "SALOMEDSClient.hxx"
44
45 #include <QPointer>
46
47 #include <memory>
48
49 class LightApp_Preferences;
50 class SalomeApp_Study;
51 #ifndef DISABLE_PYCONSOLE
52 class SalomeApp_NoteBook;
53 #endif
54 class SUIT_Desktop;
55 class SALOME_LifeCycleCORBA;
56
57
58 #ifdef WIN32
59 #pragma warning( disable:4251 )
60 #endif
61
62 /*!
63   \class SalomeApp_Application
64   \brief Application containing SalomeApp module or LightApp module
65 */
66
67 class SALOMEAPPIMPL_EXPORT SalomeApp_Application : public LightApp_Application
68 {
69   Q_OBJECT
70
71 public:
72   enum { MenuToolsId = 5 };
73   enum { DumpStudyId = LightApp_Application::UserID, LoadScriptId, PropertiesId,
74          CatalogGenId, RegDisplayId, SaveGUIStateId, ConnectId, DisconnectId,
75          UserID };
76
77   typedef enum { WT_NoteBook = LightApp_Application::WT_User,
78                  WT_User
79                } WindowTypes;
80
81 protected:
82   enum { OpenRefresh = LightApp_Application::OpenReload + 1 };
83   enum { CloseDisconnectSave = LightApp_Application::CloseDiscard + 1, CloseDisconnect };
84   enum { LoadStudyId = LightApp_Application::OpenStudyId + 1, NewAndScriptId };
85
86 public:
87   SalomeApp_Application(SALOME_NamingService_Abstract *ns = nullptr);
88   virtual ~SalomeApp_Application();
89
90   virtual void                        updateObjectBrowser( const bool = true );
91
92   virtual void                        start();
93
94   virtual void                        contextMenuPopup( const QString&, QMenu*, QString& );
95
96   virtual bool                        checkDataObject(LightApp_DataObject* theObj);
97
98   virtual bool                        checkExistingDoc();
99
100   static CORBA::ORB_var               orb();
101   static _PTR(Study)                  getStudy();
102   static SALOME_NamingService_Abstract* namingService();
103   static SALOME_LifeCycleCORBA*       lcc();
104
105   SUIT_ViewManager*                   newViewManager(const QString&);
106   void                                updateSavePointDataObjects( SalomeApp_Study* );
107
108   virtual bool                        isPossibleToClose( bool& );
109
110   virtual bool                        useStudy( const QString& );
111   virtual void                        updateDesktopTitle();
112
113 #ifndef DISABLE_PYCONSOLE
114   virtual void                        setNoteBook(SalomeApp_NoteBook* theNoteBook);
115   virtual SalomeApp_NoteBook*         getNoteBook() const;
116 #endif
117
118   virtual bool                        renameAllowed( const QString& ) const;
119   virtual bool                        renameObject( const QString&, const QString& );
120
121 public slots:
122   virtual void                        onNewDoc();
123   virtual void                        onLoadDoc();
124   virtual void                        onNewWithScript();
125   virtual bool                        onLoadDoc( const QString& );
126   virtual void                        onUnloadDoc( bool ask = true);
127   virtual void                        onCloseDoc( bool ask = true);
128   virtual void                        onOpenDoc();
129   virtual bool                        onOpenDoc( const QString& );
130   virtual bool                        onReopenDoc();
131
132   virtual void                        onExit();
133   virtual void                        onCopy();
134   virtual void                        onPaste();
135   void                                onSaveGUIState();// called from VISU
136 #ifndef DISABLE_PYCONSOLE
137   void                                onUpdateStudy(); // called from NoteBook
138 #endif
139   bool                                onRestoreStudy( const QString& theDumpScript,
140                                                       const QString& theStudyName,
141                                                       bool theIsStudySaved );
142
143   virtual void                        onDockWindowVisibilityChanged( bool );
144
145 protected slots:
146   void                                onStudyCreated( SUIT_Study* );
147   void                                onStudyOpened( SUIT_Study* );
148   void                                onDesktopMessage( const QString& );
149
150   virtual void                        onModuleActivation( const QString& );
151
152 protected:
153   virtual void                        createActions();
154   virtual SUIT_Study*                 createNewStudy();
155   virtual QWidget*                    createWindow( const int );
156
157   virtual void                        updateCommandsStatus();
158   virtual void                        onSelectionChanged();
159
160   virtual void                        createPreferences( LightApp_Preferences* );
161
162   virtual bool                        closeAction( const int, bool& );
163   virtual int                         closeChoice( const QString& );
164
165   virtual int                         openChoice( const QString& );
166   virtual bool                        openAction( const int, const QString& );
167
168   virtual QMap<int, QString>          activateModuleActions() const;
169   virtual void                        moduleActionSelected( const int );
170
171   void                                objectBrowserColumnsVisibility();
172
173 #ifndef DISABLE_PYCONSOLE
174   bool                                updateStudy();
175   virtual PyConsole_Interp*           createPyInterp();
176 #endif
177
178   virtual bool                        canOpenDoc( const QString& );
179   virtual void                        afterCloseDoc();
180
181   virtual void                        addCatalogue( const QString&, const QString& );
182
183 private slots:
184   void                                onDeleteInvalidReferences();
185   void                                onDblClick( SUIT_DataObject* );
186   void                                onProperties();
187   void                                onDumpStudy();
188   void                                onLoadScript();
189
190   void                                onDeleteGUIState();
191   void                                onRestoreGUIState();
192
193   void                                onCatalogGen();
194   void                                onRegDisplay();
195   void                                onOpenWith();
196   void                                onExtAction();
197
198 private:
199   void                                createExtraActions();
200   void                                ensureShaperIsActivated();
201
202 private:
203 #ifndef DISABLE_PYCONSOLE
204   QPointer<SalomeApp_NoteBook>        myNoteBook;        // Notebook instance
205 #endif
206   QMap<QString, QAction*>             myExtActions;      // Map <AttributeUserID, QAction>
207   bool                                myIsCloseFromExit; // "Close from Exit" flag
208
209   bool                                myToIgnoreMessages;// to ignore messages from SALOMEDS
210
211 signals:
212   void                                dumpedStudyClosed( const QString& theDumpScript,
213                                                          const QString& theStudyName,
214                                                          bool theIsStudySaved );
215   void                                notebookVarUpdated( QString theVarName );
216   void                                objectDoubleClicked( SUIT_DataObject* );
217 protected:
218   static std::unique_ptr<SALOME_NamingService_Abstract> _ns;
219 };
220
221 #ifdef WIN32
222 #pragma warning( default:4251 )
223 #endif
224
225 #endif