Salome HOME
Added slots for Copy and Paste operations
[modules/gui.git] / src / SalomeApp / SalomeApp_Application.h
1 // File:      SalomeApp_Application.h
2 // Created:   10/22/2004 3:37:25 PM
3 // Author:    Sergey LITONIN
4 // Copyright (C) CEA 2004
5
6 #ifndef SALOMEAPP_APPLICATION_H
7 #define SALOMEAPP_APPLICATION_H
8
9 #if _MSC_VER > 1000
10 #pragma once
11 #endif // _MSC_VER > 1000
12
13 #include "SalomeApp.h"
14 #include <CAM_Application.h>
15
16 #include <CORBA.h>
17
18 #include <SALOMEconfig.h>
19 //#include CORBA_CLIENT_HEADER(SALOMEDS)
20 #include <SALOME_NamingService.hxx>
21
22 #include "SALOMEDSClient.hxx"
23
24 class QAction;
25 class QComboBox;
26 class QDockWindow;
27
28 class LogWindow;
29 class OB_Browser;
30 class PythonConsole;
31 class SalomeApp_Module;
32 class SalomeApp_Preferences;
33 class SalomeApp_SelectionMgr;
34 class SalomeApp_WidgetContainer;
35
36 class SALOME_LifeCycleCORBA;
37
38 #ifdef WIN32
39 #pragma warning( disable:4251 )
40 #endif
41
42 /*
43   Class       : SalomeApp_Application
44   Description : Application containing SalomeApp module
45 */
46
47 class SALOMEAPP_EXPORT SalomeApp_Application : public CAM_Application
48 {
49   Q_OBJECT
50
51 public:
52   typedef enum { WT_ObjectBrowser, WT_PyConsole, WT_LogWindow, WT_User } WindowTypes;
53
54   enum { ModulesListId = STD_Application::UserID, NewGLViewId,
55          NewPlot2dId, NewOCCViewId, NewVTKViewId, DumpStudyId,
56          LoadScriptId,PropertiesId, PreferencesId, MRUId, UserID };
57
58 public:
59   SalomeApp_Application();
60   virtual ~SalomeApp_Application();
61   
62   virtual QString                     applicationName() const;
63   virtual QString                     applicationVersion() const;
64
65   virtual CAM_Module*                 loadModule( const QString& );
66   virtual bool                        activateModule( const QString& );
67   
68   SalomeApp_SelectionMgr*             selectionMgr() const;
69
70   LogWindow*                          logWindow();
71   OB_Browser*                         objectBrowser();
72   PythonConsole*                      pythonConsole();   
73
74   virtual void                        updateObjectBrowser( const bool = true );
75
76   SalomeApp_Preferences*              preferences() const;
77
78   virtual QString                     getFileFilter() const;
79   virtual QString                     getFileName( bool open, const QString& initial, const QString& filters, 
80                                                    const QString& caption, QWidget* parent );
81   virtual QString                     getDirectory( const QString& initial, const QString& caption, QWidget* parent );
82   virtual QStringList                 getOpenFileNames( const QString& initial, const QString& filters, 
83                                                         const QString& caption, QWidget* parent );
84
85   SUIT_ViewManager*                   getViewManager( const QString&, const bool );
86
87   void                                updateActions();
88
89   QWidget*                            getWindow( const int, const int = -1 );
90
91   QWidget*                            window( const int, const int = -1 ) const;
92   void                                addWindow( QWidget*, const int, const int = -1 );
93   void                                removeWindow( const int, const int = -1 );
94
95   bool                                isWindowVisible( const int ) const;
96   void                                setWindowShown( const int, const bool );
97
98   virtual void                        start();
99
100   virtual void                        contextMenuPopup( const QString&, QPopupMenu*, QString& );
101
102   static CORBA::ORB_var               orb();
103   static SALOMEDSClient_StudyManager* studyMgr();
104   static SALOME_NamingService*        namingService();
105   static SALOME_LifeCycleCORBA*       lcc();
106   static QString                      defaultEngineIOR();
107
108 signals:
109   void                                studyOpened();
110   void                                studySaved();
111   void                                studyClosed();
112
113 public slots:
114   virtual void                        onNewDoc();
115   virtual void                        onOpenDoc();
116   virtual void                        onHelpAbout();
117   virtual bool                        onOpenDoc( const QString& );
118   virtual void                        onCopy();
119   virtual void                        onPaste();  
120
121 private slots:
122   void                                onSelection();
123   void                                onRefresh();
124
125 protected:
126   virtual void                        createActions();
127   virtual SUIT_Study*                 createNewStudy();
128   virtual QWidget*                    createWindow( const int );
129   virtual void                        defaultWindows( QMap<int, int>& ) const;
130   virtual void                        defaultViewManagers( QStringList& ) const;
131
132   virtual void                        setActiveStudy( SUIT_Study* );
133
134   virtual void                        updateCommandsStatus();
135
136   virtual void                        onSelectionChanged();
137
138   virtual void                        beforeCloseDoc( SUIT_Study* );
139   virtual void                        afterCloseDoc();
140
141   virtual void                        moduleAdded( CAM_Module* );
142
143   SalomeApp_Preferences*              preferences( const bool ) const;
144
145   virtual void                        createPreferences( SalomeApp_Preferences* );
146   virtual void                        preferencesChanged( const QString&, const QString& );
147
148 private slots:
149   void                                onNewWindow();
150   void                                onModuleActivation( QAction* );
151   void                                onCloseView( SUIT_ViewManager* );
152
153   void                                onStudyCreated( SUIT_Study* );
154   void                                onStudyOpened( SUIT_Study* );
155   void                                onStudySaved( SUIT_Study* );
156   void                                onStudyClosed( SUIT_Study* );
157   
158   void                                onProperties();
159   void                                onDumpStudy();
160   void                                onLoadScript(); 
161
162   void                                onPreferences();
163   void                                onMRUActivated( QString );
164
165   void                                onPreferenceChanged( QString&, QString&, QString& );
166   void                                onOpenWith();
167
168 private:
169   void                                updateWindows();
170   void                                updateViewManagers();
171   void                                updateModuleActions();
172
173   void                                loadWindowsGeometry();
174   void                                saveWindowsGeometry();
175
176   void                                updatePreference( const QString&, const QString&, const QString& );
177
178   QString                             defaultModule() const;
179   void                                currentWindows( QMap<int, int>& ) const;
180   void                                currentViewManagers( QStringList& ) const;
181   SUIT_ViewManager*                   createViewManager( const QString& vmType );
182   void                                moduleIconNames( QMap<QString, QString>& ) const;
183
184   void                                activateWindows();
185
186 private:
187   typedef QMap<QString, QAction*>               ActionMap;
188   typedef QMap<int, SalomeApp_WidgetContainer*> WindowMap;
189
190 private:
191   SalomeApp_Preferences*              myPrefs;
192   SalomeApp_SelectionMgr*             mySelMgr;
193   ActionMap                           myActions;
194   WindowMap                           myWindows;
195
196   static SalomeApp_Preferences*       _prefs_;
197 };
198
199 #ifdef WIN32
200 #pragma warning( default:4251 )
201 #endif
202
203 #endif