SALOME_Selection* Sel = SALOME_Selection::Selection( QString(myTitle + "_" + aSelection) );
mySelection = aSelection;
+
+ emit selectionModified( this );
}
/*!
void docOperationTerminated( bool );
void closed();
void supervStudyFrameClosing( QAD_ViewFrame* );
+ void selectionModified( QAD_Study* );
public slots:
void onStudyFrameActivated( QAD_StudyFrame* );
SIP_FLAGS = -t WS_X11 -t $(QT_VERS) $(PYQT_SIPFLAGS) -s ".cc" -c . -I $(PYQT_SIPS)
# Sip common sources
SIP_SRC = sipSalomePyQtSalomePyQt.cc \
- sipSalomePyQtSALOME_Selection.cc
+ sipSalomePyQtSalomePyQt_Selection.cc
# Sip version-specific sources
ifeq ($(SIP_VERS),v4_old)
$(MOC_SRC)
# Library moc sources
-LIB_MOC = SALOME_PYQT_GUI.h
+LIB_MOC = SALOME_PYQT_GUI.h \
+ SalomePyQt.h
# Client IDL
LIB_CLIENT_IDL = SALOME_Exception.idl SALOME_GenericObj.idl
// File : SalomePyQt.cxx
// Module : SALOME
-#include "SalomePyQt.hxx"
+#include "SalomePyQt.h"
#include <qapplication.h>
#include <qmenubar.h>
#include "QAD_Config.h"
#include "QAD_Settings.h"
+//====================================================================================
+// SalomePyQt_Selection class.
+//====================================================================================
+static QMap<QAD_Study*, SalomePyQt_Selection*> SelMap;
+
+/*!
+ SalomePyQt_Selection::GetSelection
+ Creates or finds the selection object (one per study).
+*/
+SalomePyQt_Selection* SalomePyQt_Selection::GetSelection( QAD_Study* study )
+{
+ SalomePyQt_Selection* sel = 0;
+ if ( study && SelMap.find( study ) != SelMap.end() )
+ sel = SelMap[ study ];
+ else
+ sel = SelMap[ study ] = new SalomePyQt_Selection( study );
+ return sel;
+}
+
+/*!
+ SalomePyQt_Selection::SalomePyQt_Selection
+ Selection constructor.
+*/
+SalomePyQt_Selection::SalomePyQt_Selection( QObject* p ) :
+ QObject( p ), myStudy( 0 ), mySelection( 0 )
+{
+ myStudy = dynamic_cast<QAD_Study*>( p );
+ if ( myStudy ) {
+ mySelection = SALOME_Selection::Selection( myStudy->getSelection() );
+ if ( mySelection ) {
+ connect( mySelection, SIGNAL( currentSelectionChanged() ),
+ this, SIGNAL( currentSelectionChanged() ) );
+ connect( mySelection, SIGNAL( destroyed() ),
+ this, SLOT ( onSelectionDestroyed() ) );
+ connect( myStudy, SIGNAL( selectionModified( QAD_Study* ) ),
+ this, SLOT ( onSelectionModified() ) );
+ }
+ }
+}
+/*!
+ SalomePyQt_Selection::~SalomePyQt_Selection
+ Selection destructor. Removes selection object from the map.
+*/
+SalomePyQt_Selection::~SalomePyQt_Selection()
+{
+ if ( myStudy && SelMap.find( myStudy ) != SelMap.end() )
+ SelMap.remove( myStudy );
+}
+
+/*!
+ SalomePyQt_Selection::onSelectionDestroyed
+ Watches for the selection destroying (e.g. when study is closed).
+*/
+void SalomePyQt_Selection::onSelectionDestroyed()
+{
+ mySelection = 0;
+}
+
+/*!
+ SalomePyQt_Selection::onSelectionModified
+ Updates and reconnect selection when it is changed (e.g. when study is saved).
+*/
+void SalomePyQt_Selection::onSelectionModified()
+{
+ if ( mySelection ) {
+ disconnect( mySelection, SIGNAL( currentSelectionChanged() ),
+ this, SIGNAL( currentSelectionChanged() ) );
+ disconnect( mySelection, SIGNAL( destroyed() ),
+ this, SLOT ( onSelectionDestroyed() ) );
+ }
+
+ mySelection = myStudy ? SALOME_Selection::Selection( myStudy->getSelection() ) : 0;
+
+ if ( mySelection ) {
+ connect( mySelection, SIGNAL( currentSelectionChanged() ),
+ this, SIGNAL( currentSelectionChanged() ) );
+ connect( mySelection, SIGNAL( destroyed() ),
+ this, SLOT ( onSelectionDestroyed() ) );
+ }
+}
+
+/*!
+ SalomePyQt_Selection::Clear
+ Clears the selection.
+*/
+void SalomePyQt_Selection::Clear()
+{
+ if ( mySelection ) mySelection->Clear();
+}
+
+/*!
+ SalomePyQt_Selection::ClearIObjects
+ Clears the selection and emits the signal.
+*/
+void SalomePyQt_Selection::ClearIObjects()
+{
+ if ( mySelection ) mySelection->ClearIObjects();
+}
+
+/*!
+ SalomePyQt_Selection::ClearFilters
+ Removes all selection filters.
+*/
+void SalomePyQt_Selection::ClearFilters()
+{
+ if ( mySelection ) mySelection->ClearFilters();
+}
+
+//====================================================================================
+// SalomePyQt class
+//====================================================================================
+
using namespace std;
QWidget* SalomePyQt::getDesktop()
return QAD_Application::getDesktop()->getActiveApp()->getActiveStudy()->getStudyId();
}
-SALOME_Selection* SalomePyQt::getSelection()
+SalomePyQt_Selection* SalomePyQt::getSelection()
{
- return SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveApp()->getActiveStudy()->getSelection());
+ return SalomePyQt_Selection::GetSelection(QAD_Application::getDesktop()->getActiveApp()->getActiveStudy());
}
void SalomePyQt::putInfo( const QString& msg )
--- /dev/null
+// Copyright (C) 2003 CEA/DEN, EDF R&D
+//
+//
+//
+// File : SalomePyQt.h
+// Module : SALOME
+
+#ifndef _SALOME_PYQT_H
+#define _SALOME_PYQT_H
+
+#include <qwidget.h>
+#include <qworkspace.h>
+#include <qstring.h>
+#include <qmenubar.h>
+
+class QAD_Study;
+class SALOME_Selection;
+class SalomePyQt_Selection : public QObject
+{
+ Q_OBJECT
+
+public:
+ ~SalomePyQt_Selection();
+ static SalomePyQt_Selection* GetSelection( QAD_Study* );
+
+ void Clear();
+ void ClearIObjects();
+ void ClearFilters();
+
+signals:
+ void currentSelectionChanged();
+
+private slots:
+ void onSelectionDestroyed();
+ void onSelectionModified();
+
+private:
+ QAD_Study* myStudy;
+ SALOME_Selection* mySelection;
+
+ SalomePyQt_Selection( QObject* );
+};
+
+enum MenuName {
+ File = 1,
+ View = 2,
+ Edit = 3,
+ Preferences = 4,
+ Tools = 5,
+ Window = 6,
+ Help = 7
+};
+
+class SalomePyQt
+{
+public:
+ static QWidget* getDesktop();
+ static QWorkspace* getMainFrame();
+ static QMenuBar* getMainMenuBar();
+ static QPopupMenu* getPopupMenu( const MenuName menu );
+ static SalomePyQt_Selection* getSelection();
+ static int getStudyId();
+ static void putInfo( const QString& );
+ static void putInfo( const QString&, int );
+
+ static const QString& getActiveComponent();
+
+ static void updateObjBrowser( int studyId, bool updateSelection);
+
+ static void addStringSetting(QString _name, QString _value, bool _autoValue);
+ static void addIntSetting(QString _name, int _value, bool _autoValue);
+ static void addDoubleSetting(QString _name, double _value, bool _autoValue);
+ static bool removeSettings(QString name);
+ static QString getSetting(QString name);
+
+ static QString getFileName(QWidget* parent,
+ const QString& initial,
+ const QStringList& filters,
+ const QString& caption,
+ bool open);
+ static QStringList getOpenFileNames(QWidget* parent,
+ const QString& initial,
+ const QStringList& filters,
+ const QString& caption);
+ static QString getExistingDirectory(QWidget* parent,
+ const QString& initial,
+ const QString& caption);
+ static void helpContext(const QString& source, const QString& context);
+ static bool dumpView(const QString& filename);
+};
+
+#endif
+++ /dev/null
-// Copyright (C) 2003 CEA/DEN, EDF R&D
-//
-//
-//
-// File : SalomePyQt.hxx
-// Module : SALOME
-
-#ifndef _SALOME_PYQT_H
-#define _SALOME_PYQT_H
-
-#include <SALOME_Selection.h>
-
-#include <qwidget.h>
-#include <qworkspace.h>
-#include <qstring.h>
-#include <qmenubar.h>
-
-enum MenuName {
- File = 1,
- View = 2,
- Edit = 3,
- Preferences = 4,
- Tools = 5,
- Window = 6,
- Help = 7
-};
-
-class SalomePyQt
-{
-public:
- static QWidget* getDesktop();
- static QWorkspace* getMainFrame();
- static QMenuBar* getMainMenuBar();
- static QPopupMenu* getPopupMenu( const MenuName menu );
- static SALOME_Selection* getSelection();
- static int getStudyId();
- static void putInfo( const QString& );
- static void putInfo( const QString&, int );
-
- static const QString& getActiveComponent();
-
- static void updateObjBrowser( int studyId, bool updateSelection);
-
- static void addStringSetting(QString _name, QString _value, bool _autoValue);
- static void addIntSetting(QString _name, int _value, bool _autoValue);
- static void addDoubleSetting(QString _name, double _value, bool _autoValue);
- static bool removeSettings(QString name);
- static QString getSetting(QString name);
-
- static QString getFileName(QWidget* parent,
- const QString& initial,
- const QStringList& filters,
- const QString& caption,
- bool open);
- static QStringList getOpenFileNames(QWidget* parent,
- const QString& initial,
- const QStringList& filters,
- const QString& caption);
- static QString getExistingDirectory(QWidget* parent,
- const QString& initial,
- const QString& caption);
- static void helpContext(const QString& source, const QString& context);
- static bool dumpView(const QString& filename);
-};
-
-#endif
%Import qtmod.sip
-class SALOME_Selection : QObject
+class SalomePyQt_Selection : QObject
{
%HeaderCode
-#include <SALOME_Selection.h>
+#include <SalomePyQt.h>
%End
-
public:
- SALOME_Selection(const QString &);
void Clear();
void ClearIObjects();
+ void ClearFilters();
+
+private:
+ SalomePyQt_Selection( QObject* /TransferThis/ );
signals:
void currentSelectionChanged();
{
%HeaderCode
-#include <SalomePyQt.hxx>
+#include <SalomePyQt.h>
%End
public:
- static QWidget* getDesktop();
- static QWorkspace* getMainFrame();
- static QMenuBar* getMainMenuBar();
- static QPopupMenu* getPopupMenu( const MenuName );
- static SALOME_Selection* getSelection();
- static int getStudyId();
- static void putInfo( const QString& );
- static void putInfo( const QString&, int );
-
- static const QString& getActiveComponent();
-
- static void updateObjBrowser( int, bool );
-
-
- static bool removeSettings(QString);
- static QString getSetting(QString);
- static void addStringSetting(QString, QString, bool);
- static void addIntSetting(QString, int, bool);
- static void addDoubleSetting(QString, double, bool);
-
- static QString getFileName(QWidget*, const QString&, const QStringList&, const QString&, bool);
- static QStringList getOpenFileNames(QWidget*, const QString&, const QStringList&, const QString&);
- static QString getExistingDirectory(QWidget*, const QString&, const QString&);
- static void helpContext(const QString&, const QString&);
- static bool dumpView(const QString&);
+ static QWidget* getDesktop();
+ static QWorkspace* getMainFrame();
+ static QMenuBar* getMainMenuBar();
+ static QPopupMenu* getPopupMenu( const MenuName );
+ static SalomePyQt_Selection* getSelection() /Factory/;
+ static int getStudyId();
+ static void putInfo( const QString& );
+ static void putInfo( const QString&, int );
+
+ static const QString& getActiveComponent();
+
+ static void updateObjBrowser( int, bool );
+
+
+ static bool removeSettings(QString);
+ static QString getSetting(QString);
+ static void addStringSetting(QString, QString, bool);
+ static void addIntSetting(QString, int, bool);
+ static void addDoubleSetting(QString, double, bool);
+
+ static QString getFileName(QWidget*,
+ const QString&,
+ const QStringList&,
+ const QString&, bool) /ReleaseGIL/;
+ static QStringList getOpenFileNames(QWidget*,
+ const QString&,
+ const QStringList&,
+ const QString&) /ReleaseGIL/;
+ static QString getExistingDirectory(QWidget*,
+ const QString&,
+ const QString&) /ReleaseGIL/;
+ static void helpContext(const QString&, const QString&);
+ static bool dumpView(const QString&);
};
%Import qtmod.sip
-class SALOME_Selection : QObject
+
+class SalomePyQt_Selection : QObject
{
%TypeHeaderCode
-#include <SALOME_Selection.h>
+#include <SalomePyQt.h>
%End
public:
- SALOME_Selection(const QString &);
void Clear();
void ClearIObjects();
+ void ClearFilters();
+
+private:
+ SalomePyQt_Selection( QObject* /TransferThis/ );
signals:
void currentSelectionChanged();
class SalomePyQt
{
%TypeHeaderCode
-#include <SalomePyQt.hxx>
+#include <SalomePyQt.h>
%End
public:
- static QWidget* getDesktop();
- static QWorkspace* getMainFrame();
- static QMenuBar* getMainMenuBar();
- static QPopupMenu* getPopupMenu( const MenuName );
- static SALOME_Selection* getSelection();
- static int getStudyId();
- static void putInfo( const QString& );
- static void putInfo( const QString&, int );
-
- static const QString& getActiveComponent();
-
- static void updateObjBrowser( int, bool );
-
-
- static bool removeSettings(QString);
- static QString getSetting(QString);
- static void addStringSetting(QString, QString, bool);
- static void addIntSetting(QString, int, bool);
- static void addDoubleSetting(QString, double, bool);
-
- static QString getFileName(QWidget*, const QString&, const QStringList&, const QString&, bool);
- static QStringList getOpenFileNames(QWidget*, const QString&, const QStringList&, const QString&);
- static QString getExistingDirectory(QWidget*, const QString&, const QString&);
- static void helpContext(const QString&, const QString&);
- static bool dumpView(const QString&);
+ static QWidget* getDesktop();
+ static QWorkspace* getMainFrame();
+ static QMenuBar* getMainMenuBar();
+ static QPopupMenu* getPopupMenu( const MenuName );
+ static SalomePyQt_Selection* getSelection() /Factory/;
+ static int getStudyId();
+ static void putInfo( const QString& );
+ static void putInfo( const QString&, int );
+
+ static const QString& getActiveComponent();
+
+ static void updateObjBrowser( int, bool );
+
+
+ static bool removeSettings(QString);
+ static QString getSetting(QString);
+ static void addStringSetting(QString, QString, bool);
+ static void addIntSetting(QString, int, bool);
+ static void addDoubleSetting(QString, double, bool);
+
+ static QString getFileName(QWidget*,
+ const QString&,
+ const QStringList&,
+ const QString&, bool) /ReleaseGIL/;
+ static QStringList getOpenFileNames(QWidget*,
+ const QString&,
+ const QStringList&,
+ const QString&) /ReleaseGIL/;
+ static QString getExistingDirectory(QWidget*,
+ const QString&,
+ const QString&) /ReleaseGIL/;
+ static void helpContext(const QString&, const QString&);
+ static bool dumpView(const QString&);
};