Salome HOME
Allow passing multiple scripts with arguments from command line
[modules/gui.git] / src / SalomeApp / SalomeApp_Application.h
1 // Copyright (C) 2007-2013  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 <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 class SalomeApp_NoteBook;
52 class SUIT_Desktop;
53
54 class SUIT_ViewModel;
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 SALOMEAPP_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, FileLoadId, UserID };
75
76   typedef enum { WT_NoteBook = LightApp_Application::WT_User } WindowTypes;
77
78 protected:
79   enum { OpenRefresh = LightApp_Application::OpenReload + 1 };
80   enum { CloseUnload = LightApp_Application::CloseDiscard + 1 };
81   enum { LoadStudyId = LightApp_Application::OpenStudyId + 1, NewAndScriptId };
82
83 public:
84   SalomeApp_Application();
85   virtual ~SalomeApp_Application();
86
87   virtual void                        updateObjectBrowser( const bool = true );
88
89   virtual QString                     getFileFilter() const;
90
91   virtual void                        start();
92
93   virtual void                        contextMenuPopup( const QString&, QMenu*, QString& );
94
95   virtual bool                        checkDataObject(LightApp_DataObject* theObj);
96
97   virtual void                        setDesktop( SUIT_Desktop* );
98
99   static CORBA::ORB_var               orb();
100   static SALOMEDSClient_StudyManager* studyMgr();
101   static SALOME_NamingService*        namingService();
102   static SALOME_LifeCycleCORBA*       lcc();
103
104   SUIT_ViewManager*                   newViewManager(const QString&);
105   void                                updateSavePointDataObjects( SalomeApp_Study* );
106
107   virtual bool                        isPossibleToClose( bool& );
108
109   virtual bool                        useStudy( const QString& );
110   virtual void                        updateDesktopTitle();
111   virtual void                        currentWindows( QMap<int, int>& ) const;
112   
113   virtual void                        setNoteBook(SalomeApp_NoteBook* theNoteBook);
114   virtual SalomeApp_NoteBook*         getNoteBook() const;
115
116  //! update visibility state of objects
117   void                                updateVisibilityState( DataObjectList& theList,
118                                                              SUIT_ViewModel* theViewModel );  
119
120   virtual bool                        renameAllowed( const QString& ) const;
121   virtual bool                        renameObject( const QString&, const QString& );
122   
123 public slots:
124   virtual void                        onLoadDoc();
125   virtual void                        onNewWithScript();
126   virtual bool                        onLoadDoc( const QString& );
127   virtual void                        onCloseDoc( bool ask = true);
128
129   virtual void                        onExit();
130   virtual void                        onCopy();
131   virtual void                        onPaste();
132   void                                onSaveGUIState();// called from VISU
133   void                                onUpdateStudy(); // called from NoteBook
134   bool                                onRestoreStudy( const QString& theDumpScript,
135                                                       const QString& theStudyName,
136                                                       bool theIsStudySaved );
137
138 protected slots:
139   void                                onStudyCreated( SUIT_Study* );
140   void                                onStudySaved( SUIT_Study* );
141   void                                onStudyOpened( SUIT_Study* );
142   void                                onStudyClosed( SUIT_Study* );
143   
144   void                                onViewManagerRemoved( SUIT_ViewManager* );
145
146 protected:
147   virtual void                        createActions();
148   virtual SUIT_Study*                 createNewStudy();
149   virtual QWidget*                    createWindow( const int );
150
151   virtual void                        updateCommandsStatus();
152   virtual void                        onSelectionChanged();
153
154   virtual void                        createPreferences( LightApp_Preferences* );
155
156   virtual bool                        closeAction( const int, bool& );
157   virtual int                         closeChoice( const QString& );
158
159   virtual int                         openChoice( const QString& );
160   virtual bool                        openAction( const int, const QString& );
161
162   virtual QMap<int, QString>          activateModuleActions() const;
163   virtual void                        moduleActionSelected( const int );
164
165   virtual void                        defaultWindows( QMap<int, int>& ) const;
166
167   void                                objectBrowserColumnsVisibility();
168
169   bool                                updateStudy();
170
171   virtual void                        afterCloseDoc();
172
173 private slots:
174   void                                onDeleteInvalidReferences();
175   void                                onDblClick( SUIT_DataObject* );
176   void                                onProperties();
177   void                                onDumpStudy();
178   void                                onLoadScript();
179
180   void                                onDeleteGUIState();
181   void                                onRestoreGUIState();
182
183   void                                onCatalogGen();
184   void                                onRegDisplay();
185   void                                onOpenWith();
186   void                                onExtAction();
187
188   void                                onWindowActivated( SUIT_ViewWindow* theViewWindow );
189
190 private:
191   void                                createExtraActions();
192
193 private:
194   QPointer<SalomeApp_NoteBook>        myNoteBook;
195   QMap<QString, QAction*>             myExtActions; // Map <AttributeUserID, QAction>
196
197 signals:
198   void                                dumpedStudyClosed( const QString& theDumpScript, 
199                                                          const QString& theStudyName, 
200                                                          bool theIsStudySaved );
201   void                                notebookVarUpdated( QString theVarName );
202
203 };
204
205 #ifdef WIN32
206 #pragma warning( default:4251 )
207 #endif
208
209 #endif