${PROJECT_SOURCE_DIR}/src/STD
${PROJECT_SOURCE_DIR}/src/SUIT
${PROJECT_SOURCE_DIR}/src/SUITApp
+ ${PROJECT_SOURCE_DIR}/src/ObjBrowser
)
# additional preprocessor / compiler flags
#include "CAM_Application.h"
#include "SUITApp_init_python.hxx"
#include "SUIT_DataObjectIterator.h"
-
+#include "LightApp_Application.h"
+#include "SUIT_DataBrowser.h"
#include "sipAPISalomePyQtGUILight.h"
#ifndef GUI_DISABLE_CORBA
// ... then call helper
myHelper->initialize( app );
+ SUIT_DataBrowser* ob = getApp()->objectBrowser();
+ if (ob && ob->model()) {
+ connect( ob->model(), SIGNAL( clicked( SUIT_DataObject*, int ) ),
+ myHelper, SLOT( onObjectBrowserClicked( SUIT_DataObject*, int ) ), Qt::UniqueConnection );
+ }
}
/*!
return color;
}
+void SALOME_PYQT_ModuleLight::setObjectPosition( const QString& theEntry, int thePos )
+{
+ SALOME_PYQT_DataObjectLight* dataObj = findObject( theEntry );
+ if ( dataObj )
+ dataObj->setPosition(thePos);
+}
+
+int SALOME_PYQT_ModuleLight::getObjectPosition( const QString& theEntry )
+{
+ SALOME_PYQT_DataObjectLight* dataObj = findObject( theEntry );
+ if ( dataObj )
+ return dataObj->position();
+ return -1;
+}
+
+
/*!
\brief Set reference to another data object
\param entry data object entry
void removeObject( const QString& );
void removeChildren( const QString& );
+ void setObjectPosition( const QString&, int );
+ int getObjectPosition( const QString& );
+
QStringList getChildren( const QString&, const bool = false ) const;
protected:
Qt::UniqueConnection );
}
}
+
+
+
+void PyModuleHelper::internalOBClickedPython( const QString& theObj, int theColumn)
+{
+ FuncMsg fmsg( "--- PyModuleHelper::internalOBClickedPython()" );
+
+ // Python interpreter should be initialized and Python module should be
+ // import first
+ if ( !myInterp || !myPyModule )
+ return; // Error
+
+ if ( PyObject_HasAttrString( myPyModule, (char*)"onObjectBrowserClicked" ) ) {
+ PyObjWrapper res( PyObject_CallMethod( myPyModule, (char*)"onObjectBrowserClicked", (char*)"si", theObj.toLatin1().constData(), theColumn ) );
+ if( !res ) {
+ PyErr_Print();
+ }
+ }
+}
+
+
+
+void PyModuleHelper::onObjectBrowserClicked(SUIT_DataObject* theObj, int theColumn)
+{
+ FuncMsg fmsg( "PyModuleHelper::onObjectBrowserClicked()" );
+
+ // temporary set myInitModule because dumpPython() method
+ // might be called by the framework when this module is inactive,
+ // but still it should be possible to access this module's data
+ // from Python
+ InitLocker lock( myModule );
+
+ class PythonReq: public PyInterp_LockRequest
+ {
+ public:
+ PythonReq( PyInterp_Interp* _py_interp,
+ PyModuleHelper* _helper,
+ const QString& _entry,
+ int _column )
+ : PyInterp_LockRequest( _py_interp, 0, true ), // this request should be processed synchronously (sync == true)
+ myHelper( _helper ) ,
+ myEntry( _entry ),
+ myColumn( _column )
+ {}
+ protected:
+ virtual void execute()
+ {
+ myHelper->internalOBClickedPython( myEntry, myColumn );
+ }
+ private:
+ PyModuleHelper* myHelper;
+ int myColumn;
+ QString myEntry;
+ };
+
+ // Posting the request only if dispatcher is not busy!
+ // Executing the request synchronously
+ const LightApp_DataObject* data_object = dynamic_cast<const LightApp_DataObject*>( theObj );
+ if ( (!PyInterp_Dispatcher::Get()->IsBusy()) && data_object )
+ PyInterp_Dispatcher::Get()->Exec( new PythonReq( myInterp, this, data_object->entry(), theColumn ) );
+}
+
const int, Qt::DropAction );
QString engineIOR() const;
+ void onObjectBrowserClicked(SUIT_DataObject*, int);
+
private:
void initInterp( int );
void importModule();
void internalDropObjects( const DataObjectList&, SUIT_DataObject*,
const int, Qt::DropAction );
QString internalEngineIOR() const;
+ void internalOBClickedPython( const QString&, int );
void connectView( SUIT_ViewWindow* );
};
{
ProcessVoidEvent( new TPlot2dFitRange(id, XMin, XMax, YMin, YMax) );
}
+
+
+void SalomePyQt::setVisibilityState( const QString& theEntry, VisibilityState theState)
+{
+ class TEvent: public SALOME_Event
+ {
+ QString myEntry;
+ int myState;
+ public:
+ TEvent( const QString& theEntry, int theState):
+ myEntry(theEntry), myState(theState) {}
+ virtual void Execute()
+ {
+ LightApp_Study* aStudy = getActiveStudy();
+ if ( !aStudy )
+ return;
+ aStudy->setVisibilityState(myEntry, (Qtx::VisibilityState)myState);
+ }
+ };
+ ProcessVoidEvent( new TEvent(theEntry, theState ) );
+}
+
+class TGetVisibilityStateEvent: public SALOME_Event
+{
+public:
+ typedef int TResult;
+ TResult myResult;
+ QString myEntry;
+ TGetVisibilityStateEvent(const QString& theEntry) : myResult( 0 ), myEntry(theEntry) {}
+ virtual void Execute()
+ {
+ LightApp_Study* aStudy = getActiveStudy();
+ if ( aStudy )
+ myResult = aStudy->visibilityState(myEntry);
+ }
+};
+
+VisibilityState SalomePyQt::getVisibilityState( const QString& theEntry )
+{
+ return (VisibilityState) ProcessEvent( new TGetVisibilityStateEvent(theEntry) );
+}
+
+
+void SalomePyQt::setObjectPosition( const QString& theEntry, int thePos )
+{
+ class TEvent: public SALOME_Event
+ {
+ QString myEntry;
+ int myPos;
+ public:
+ TEvent( const QString& theEntry, int thePos):
+ myEntry(theEntry), myPos(thePos) {}
+ virtual void Execute()
+ {
+ SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
+ if ( module )
+ module->setObjectPosition(myEntry, myPos );
+ }
+ };
+ ProcessVoidEvent( new TEvent(theEntry, thePos ) );
+}
+
+
+
+class TGetObjectPositionEvent: public SALOME_Event
+{
+public:
+ typedef int TResult;
+ TResult myResult;
+ QString myEntry;
+ TGetObjectPositionEvent(const QString& theEntry) : myResult( 0 ), myEntry(theEntry) {}
+ virtual void Execute()
+ {
+ SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
+ if ( module )
+ myResult = module->getObjectPosition(myEntry);
+ }
+};
+
+int SalomePyQt::getObjectPosition( const QString& theEntry )
+{
+ return ProcessEvent( new TGetObjectPositionEvent(theEntry) );
+}
Y2Axis = Plot2d_ViewFrame::Y2Axis
};
+enum VisibilityState
+{
+ ShownState, //!< Object is shown in viewer
+ HiddenState, //!< Object is hidden in viewer
+ UnpresentableState //!< Unpresentable object
+};
+
+
class SalomePyQt
{
public:
static QString getName( const QString& );
static QString getToolTip( const QString& );
+ static void setVisibilityState( const QString&, VisibilityState );
+ static VisibilityState getVisibilityState( const QString& );
+
+ static void setObjectPosition( const QString&, int );
+ static int getObjectPosition( const QString& );
+
+
static void setColor( const QString&, const QColor& );
static QColor getColor( const QString& );
void clearAllPoints();
};
+enum VisibilityState
+{
+ ShownState,
+ HiddenState,
+ UnpresentableState
+};
+
+
class SalomePyQt
{
%TypeHeaderCode
static QString getName(const QString& ) /ReleaseGIL/ ;
static QString getToolTip(const QString& ) /ReleaseGIL/ ;
+ static void setVisibilityState( const QString&, VisibilityState );
+ static VisibilityState getVisibilityState( const QString& );
+
+ static void setObjectPosition( const QString&, int );
+ static int getObjectPosition( const QString& );
+
static void setColor( const QString&, const QColor& ) /ReleaseGIL/ ;
static QColor getColor( const QString& ) /ReleaseGIL/ ;