]> SALOME platform Git repositories - modules/gui.git/blob - src/SALOME_PYQT/SalomePyQt/SalomePyQt.h
Salome HOME
f413631ccfb8bde7897a68c08caac17663fb7813
[modules/gui.git] / src / SALOME_PYQT / SalomePyQt / SalomePyQt.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   : SalomePyQt.h
24 // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
25 //
26 #ifndef SALOME_PYQT_H
27 #define SALOME_PYQT_H
28
29 #include <Python.h>
30
31 #include <QObject>
32 #include <QString>
33 #include <QColor>
34
35 #include <LightApp_Application.h>
36 #include <LightApp_Preferences.h>
37
38 class LightApp_SelectionMgr;
39 class QMenuBar;
40 class QMenu;
41 class QWidget;
42 class QAction;
43 class QTreeView;
44 class QtxActionGroup;
45
46 class SALOME_Selection : public QObject
47 {
48   Q_OBJECT
49
50 public:
51   ~SALOME_Selection();
52   static SALOME_Selection* GetSelection( LightApp_Application* );
53
54   void Clear();
55   void ClearIObjects();
56   void ClearFilters();
57
58 signals:
59   void currentSelectionChanged();
60
61 private slots:
62   void onSelMgrDestroyed();
63
64 private:
65   LightApp_SelectionMgr* mySelMgr;
66   SALOME_Selection( QObject* );
67 };
68
69 enum MenuName {
70   File        = 1,
71   View        = 2,
72   Edit        = 3,
73   Preferences = 4,
74   Tools       = 5,
75   Window      = 6,
76   Help        = 7  
77 };
78
79 enum {
80   WT_ObjectBrowser = LightApp_Application::WT_ObjectBrowser,
81   WT_PyConsole     = LightApp_Application::WT_PyConsole,
82   WT_LogWindow     = LightApp_Application::WT_LogWindow,
83   WT_User          = LightApp_Application::WT_User
84 };
85
86 enum { 
87   PT_Auto     = LightApp_Preferences::Auto,
88   PT_Space    = LightApp_Preferences::Space,
89   PT_Bool     = LightApp_Preferences::Bool, 
90   PT_Color    = LightApp_Preferences::Color,
91   PT_String   = LightApp_Preferences::String, 
92   PT_Selector = LightApp_Preferences::Selector, 
93   PT_DblSpin  = LightApp_Preferences::DblSpin, 
94   PT_IntSpin  = LightApp_Preferences::IntSpin, 
95   PT_Double   = LightApp_Preferences::Double, 
96   PT_Integer  = LightApp_Preferences::Integer, 
97   PT_GroupBox = LightApp_Preferences::GroupBox, 
98   PT_Tab      = LightApp_Preferences::Tab, 
99   PT_Frame    = LightApp_Preferences::Frame, 
100   PT_Font     = LightApp_Preferences::Font, 
101   PT_DirList  = LightApp_Preferences::DirList, 
102   PT_File     = LightApp_Preferences::File, 
103 };
104
105 //! Orientation
106 enum Orientation {
107   Horizontal = 0, //!< Horizontal orientation 
108   Vertical   = 1  //!< Vertical orientation
109 };
110
111 //! Action of splitting corresponding to QtxWorkstack::SplitType enumeration
112 enum Action {
113   MoveWidget   = 0, //!< move specified widget to the new area, other views stay in the previous area
114   LeaveWidget  = 1, //!< specified widget stays in the old area, all other views are moved to the new area
115   SplitAt      = 2  //!< the view area is splitted in such a way, that specified view and all views which follow it, are moved to the new area
116 };
117
118 class SalomePyQt
119 {
120 public:
121   static QWidget*          getDesktop();
122   static QWidget*          getMainFrame();
123   static QMenuBar*         getMainMenuBar();
124   static QMenu*            getPopupMenu( const MenuName );
125   static QMenu*            getPopupMenu( const QString& );
126   static QTreeView*        getObjectBrowser();
127   static SALOME_Selection* getSelection();
128   static int               getStudyId();
129   static void              putInfo( const QString&, const int = 0 );
130   static const QString     getActiveComponent();
131   static PyObject*         getActivePythonModule();
132   static bool              activateModule( const QString& );
133   static void              updateObjBrowser( const int = 0, bool = true );
134
135   static bool              isModified();
136   static void              setModified( bool );
137
138   static QString           getFileName         ( QWidget*, const QString&, const QStringList&, const QString&, bool );
139   static QStringList       getOpenFileNames    ( QWidget*, const QString&, const QStringList&, const QString& );
140   static QString           getExistingDirectory( QWidget*, const QString&, const QString& );
141
142   static QString           createObject( const QString& parent = QString() );
143   static QString           createObject( const QString&, const QString&, const QString&, const QString& = QString() );
144
145   static void              removeObject( const QString&);
146   static void              removeChildren( const QString& = QString() );
147   static QStringList       getChildren( const QString& = QString(), const bool = false );
148   static void              setName( const QString&, const QString& );
149   static void              setIcon( const QString&, const QString& );
150   static void              setToolTip( const QString&, const QString& );
151   static QString           getName( const QString& );
152   static QString           getToolTip( const QString& );
153
154   static void              setColor( const QString&, const QColor& );
155   static QColor            getColor( const QString& );
156
157   static void              setReference( const QString&, const QString& ); 
158   static QString           getReference( const QString& );
159
160   static QIcon             loadIcon( const QString&, const QString& );
161
162   static void              helpContext( const QString&, const QString& );
163
164   static bool              dumpView( const QString& );
165
166   static int               defaultMenuGroup();
167
168   static int               createTool( const QString& );
169   static int               createTool( const int,  const int,      const int = -1 );
170   static int               createTool( const int,  const QString&, const int = -1 );
171   static int               createTool( QAction*, const int,      const int = -1, const int = -1 );
172   static int               createTool( QAction*, const QString&, const int = -1, const int = -1 );
173
174   static int               createMenu( const QString&, const int = -1,
175                                        const int = -1, const int = -1, const int = -1 );
176   static int               createMenu( const QString&, const QString& = QString(), 
177                                        const int = -1, const int = -1, const int = -1 );
178   static int               createMenu( const int,      const int = -1,
179                                        const int = -1, const int = -1 );
180   static int               createMenu( const int,      const QString& = QString(), 
181                                        const int = -1, const int = -1 );
182   static int               createMenu( QAction*,     const int,      const int = -1, 
183                                        const int = -1, const int = -1 );
184   static int               createMenu( QAction*,     const QString&, const int = -1, 
185                                        const int = -1, const int = -1 );
186
187   static QAction*          createSeparator();
188
189   static QAction*          createAction( const int, const QString&,
190                                          const QString& = QString(), const QString& = QString(), 
191                                          const QString& = QString(), const int = 0, const bool = false );
192   
193   static QtxActionGroup*   createActionGroup( const int, const bool = true );
194
195   static QAction*          action( const int );
196   static int               actionId( const QAction* );
197
198   static void              addSetting    ( const QString&, const QString&, const double );
199   static void              addSetting    ( const QString&, const QString&, const int );
200   static void              addSetting    ( const QString&, const QString&, const bool, const int );
201   static void              addSetting    ( const QString&, const QString&, const QString& );
202   static void              addSetting    ( const QString&, const QString&, const QColor& );
203   static int               integerSetting( const QString&, const QString&, const int = 0 );
204   static double            doubleSetting ( const QString&, const QString&, const double = 0 );
205   static bool              boolSetting   ( const QString&, const QString&, const bool = 0 );
206   static QString           stringSetting ( const QString&, const QString&, const QString& = QString("") );
207   static QColor            colorSetting  ( const QString&, const QString&, const QColor& = QColor() );
208   static void              removeSetting ( const QString&, const QString& );
209   static bool              hasSetting    ( const QString&, const QString& );
210
211   static int               addGlobalPreference( const QString& );
212   static int               addPreference( const QString& );
213   static int               addPreference( const QString&,
214                                           const int, const int = PT_Auto,
215                                           const QString& = QString(),
216                                           const QString& = QString() );
217   static QVariant          preferenceProperty( const int, const QString& );
218   static void              setPreferenceProperty( const int, const QString&, const QVariant& );
219   static void              addPreferenceProperty( const int, const QString&, const int, const QVariant& );
220
221   static void              message( const QString&, bool = true );
222   static void              clearMessages();
223   
224   static QList<int>        getViews();
225   static int               getActiveView();
226   static QString           getViewType( const int );
227   static bool              setViewTitle( const int, const QString& );
228   static QString           getViewTitle( const int );
229   static QList<int>        findViews( const QString& );
230   static bool              activateView( const int );
231   static int               createView( const QString& );
232   static int               createView( const QString&, QWidget* );
233   static bool              closeView( const int );
234   static int               cloneView( const int );
235   static bool              isViewVisible( const int );
236   static void              setViewClosable( const int, const bool );
237   static bool              isViewClosable( const int );
238
239   static bool              groupAllViews();
240   static bool              splitView( const int, const Orientation, const Action );
241   static bool              moveView( const int, const int, const bool );
242   static QList<int>        neighbourViews( const int );
243
244   // the following methods are obsolete
245   static void              addStringSetting( const QString&, const QString&, bool = true );
246   static void              addIntSetting   ( const QString&, const int,      bool = true );
247   static void              addBoolSetting  ( const QString&, const bool,     bool = true );
248   static void              addDoubleSetting( const QString&, const double,   bool = true );
249   static void              removeSettings  ( const QString& );
250   static QString           getSetting      ( const QString& );
251
252   static void              removeChild( const QString& = QString() );
253 };
254
255 #endif // SALOME_PYQT_H