1 // Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // File : SalomePyQt.h
24 // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
35 #include <LightApp_Application.h>
36 #include <LightApp_Preferences.h>
38 class LightApp_SelectionMgr;
46 class SALOME_Selection : public QObject
52 static SALOME_Selection* GetSelection( LightApp_Application* );
59 void currentSelectionChanged();
62 void onSelMgrDestroyed();
65 LightApp_SelectionMgr* mySelMgr;
66 SALOME_Selection( QObject* );
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
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,
107 Horizontal = 0, //!< Horizontal orientation
108 Vertical = 1 //!< Vertical orientation
111 //! Action of splitting corresponding to QtxWorkstack::SplitType enumeration
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
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 );
135 static bool isModified();
136 static void setModified( bool );
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& );
142 static QString createObject( const QString& parent = QString() );
143 static QString createObject( const QString&, const QString&, const QString&, const QString& = QString() );
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& );
154 static void setColor( const QString&, const QColor& );
155 static QColor getColor( const QString& );
157 static void setReference( const QString&, const QString& );
158 static QString getReference( const QString& );
160 static QIcon loadIcon( const QString&, const QString& );
162 static void helpContext( const QString&, const QString& );
164 static bool dumpView( const QString& );
166 static int defaultMenuGroup();
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 );
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 );
187 static QAction* createSeparator();
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 );
193 static QtxActionGroup* createActionGroup( const int, const bool = true );
195 static QAction* action( const int );
196 static int actionId( const QAction* );
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& );
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& );
221 static void message( const QString&, bool = true );
222 static void clearMessages();
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 );
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 );
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& );
252 static void removeChild( const QString& = QString() );
255 #endif // SALOME_PYQT_H