-// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
#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
#include <Container_init_python.hxx>
#endif
+#include <QCoreApplication>
+
// Py_ssize_t for old Pythons
// This code is as recommended by"
// http://www.python.org/dev/peps/pep-0353/#conversion-guidelines
-#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN)
-typedef int Py_ssize_t;
-# define PY_SSIZE_T_MAX INT_MAX
-# define PY_SSIZE_T_MIN INT_MIN
-#endif
+//#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN)
+//typedef int Py_ssize_t;
+//# define PY_SSIZE_T_MAX INT_MAX
+//# define PY_SSIZE_T_MIN INT_MIN
+//#endif
//
// NB: Python requests.
{
SALOME_PYQT_LIGHT_EXPORT CAM_Module* createModule()
{
- static bool alreadyInitialized = false;
+ QCoreApplication* app = QCoreApplication::instance();
+ bool alreadyInitialized = app && app->property( "salome_pyqt_gui_light_initialized" ).toBool();
// make initialization only once (see comment above) !
if ( !alreadyInitialized ) {
- static PyThreadState* gtstate = 0;
-#ifndef GUI_DISABLE_CORBA
- if ( SUIT_PYTHON::initialized )
- gtstate = SUIT_PYTHON::_gtstate;
- else
- gtstate = KERNEL_PYTHON::_gtstate;
-#else
- gtstate = SUIT_PYTHON::_gtstate;
-#endif
- PyEval_RestoreThread( gtstate );
-
+ PyLockWrapper lck; // GIL acquisition
INIT_FUNCTION();
-
- PyEval_ReleaseThread( gtstate );
-
- alreadyInitialized = !alreadyInitialized;
+ if ( app ) app->setProperty( "salome_pyqt_gui_light_initialized", true );
}
return new SALOME_PYQT_ModuleLight();
// ... 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 );
+ }
}
/*!
/*!
\brief Save module data. Called when user saves study.
\param files output list of files where module stores data
+ \param url study URL
\sa PyModuleHelper::save()
*/
-void SALOME_PYQT_ModuleLight::save( QStringList& files )
+void SALOME_PYQT_ModuleLight::save( QStringList& files, const QString& url )
{
// call helper
- myHelper->save( files );
+ myHelper->save( files, url );
}
/*
- \brief Load module data. Called when user opens study
- and activates module.
- \param files list of files where module data is stored
- \sa PyModuleHelper::load()
+ \brief Load module data. Called when user opens study
+ and activates module.
+ \param files list of files where module data is stored
+ \param url study URL
+ \return \c true if loading has been finished successfully or \c false otherwise
+ \sa PyModuleHelper::load()
*/
-bool SALOME_PYQT_ModuleLight::load( const QStringList& files )
+bool SALOME_PYQT_ModuleLight::load( const QStringList& files, const QString& url )
{
// call helper
- return myHelper->load( files );
+ return myHelper->load( files, url );
}
/*!
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