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