*/
void LightApp_Application::onSelection()
{
+ //MESSAGE("onSelection")
onSelectionChanged();
if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
{
SUIT_ViewManager* aVM = viewManager( vmType );
SUIT_ViewManager* anActiveVM = CAM_Application::activeViewManager();
-
+ MESSAGE("vmType: " << vmType.toStdString() << " aVM: " << aVM << " anActiveVM: " << anActiveVM );
if ( anActiveVM && anActiveVM->getType() == vmType )
- aVM = anActiveVM;
+ {
+ MESSAGE("aVM = anActiveVM");
+ aVM = anActiveVM;
+ }
if ( aVM && create )
{
if ( !aVM->getActiveView() )
- aVM->createView();
+ {
+ MESSAGE("aVM->createView()");
+ aVM->createView();
+ }
else
- desktop()->setActiveWindow( aVM->getActiveView() );
+ {
+ MESSAGE("desktop()->setActiveWindow: " << aVM->getActiveView());
+ desktop()->setActiveWindow( aVM->getActiveView() );
+ }
}
else if ( create )
- aVM = createViewManager( vmType );
+ {
+ MESSAGE("aVM = createViewManager( vmType )");
+ aVM = createViewManager( vmType );
+ }
return aVM;
}
#include "SALOME_ListIO.hxx"
#endif
-
+#include <utilities.h>
#ifndef DISABLE_VTKVIEWER
#ifndef DISABLE_SALOMEOBJECT
}
}
- return -1;
+ return ActorSelection; // workaround for embedded VTK viewer in a module : is it safe ?
}
/*!
for(; anIter != theList.end(); ++anIter){
const SUIT_DataOwner* aDataOwner = (*anIter).get();
if(const LightApp_SVTKDataOwner* anOwner = dynamic_cast<const LightApp_SVTKDataOwner*>(aDataOwner)){
+ MESSAGE("aSelector->SetSelectionMode("<<anOwner->GetMode()<<");");
aSelector->SetSelectionMode(anOwner->GetMode());
Handle(SALOME_InteractiveObject) anIO = anOwner->IO();
#endif
}
-#if OCC_VERSION_LARGE > 0x07010000
+#if OCC_VERSION_LARGE > 0x07010001
return new V3d_Viewer( aGraphicDriver, name, domain, viewSize, viewProjection,
Quantity_NOC_GRAY30, V3d_ZBUFFER, V3d_GOURAUD,
computedMode, defaultComputedMode );
// init selector
myAISContext = new AIS_InteractiveContext( myV3dViewer );
-#if OCC_VERSION_LARGE > 0x07000000
-
+#if OCC_VERSION_LARGE > 0x07010100
+ myAISContext->HighlightStyle(Prs3d_TypeOfHighlight_LocalSelected)->SetColor( Quantity_NOC_WHITE );
+ myAISContext->HighlightStyle(Prs3d_TypeOfHighlight_Selected)->SetColor( Quantity_NOC_WHITE );
+#elif OCC_VERSION_LARGE > 0x07000000
const Handle(Graphic3d_HighlightStyle)& sStyle = myAISContext->SelectionStyle();
- sStyle->SetColor( Quantity_NOC_WHITE );
-#else
+ sStyle->SetColor( Quantity_NOC_WHITE );
+#else
myAISContext->SelectionColor( Quantity_NOC_WHITE );
-#endif
+#endif
// display isoline on planar faces (box for ex.)
myAISContext->IsoOnPlane( true );
${PROJECT_SOURCE_DIR}/tools/PyConsole/src
${PROJECT_SOURCE_DIR}/tools/PyInterp/src
)
+IF(SALOME_USE_SALOMEOBJECT)
+ INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src/OBJECT)
+ENDIF()
# additional preprocessor / compiler flags
ADD_DEFINITIONS(
SALOME_PYQT_DataModelLight.h
SALOME_PYQT_ModuleLight.h
SALOME_PYQT_PyModule.h
+ SALOME_PYQT_Selector.h
)
# header files / no moc processing
SET(_other_HEADERS
SALOME_PYQT_DataObjectLight.h
+ SALOME_PYQT_BorrowedDataObjectLight.h
SALOME_PYQT_GUILight.h
SALOME_PYQT_PyInterp.h
)
SET(_other_SOURCES
SALOME_PYQT_DataModelLight.cxx
SALOME_PYQT_DataObjectLight.cxx
+ SALOME_PYQT_BorrowedDataObjectLight.cxx
SALOME_PYQT_ModuleLight.cxx
SALOME_PYQT_PyInterp.cxx
SALOME_PYQT_PyModule.cxx
+ SALOME_PYQT_Selector.cxx
)
# sources / to compile
--- /dev/null
+// 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, 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
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+// Author : Roman NIKOLAEV, Open CASCADE S.A.S. (roman.nikolaev@opencascade.com)
+// Date : 22/06/2007
+//
+#include "SALOME_PYQT_BorrowedDataObjectLight.h"
+#include <LightApp_Application.h>
+#include <SUIT_Session.h>
+#include <utilities.h>
+#include <SUIT_ResourceMgr.h>
+
+
+#include <CAM_DataModel.h>
+#include <CAM_Module.h>
+
+
+/*!
+ * Class: SALOME_PYQT_BorrowedDataObjectLight
+ * Description: LIGHT PYTHON module's Borrowed data object: reference objects from other modules.
+ * Used to propagate selection in a light module client of other modules publishing objects in study.
+ * (copied from SALOME_PYQT_DataObjectLight)
+ */
+
+//=================================================================================
+// function : SALOME_PYQT_BorrowedDataObjectLight()
+// purpose : constructor
+//=================================================================================
+SALOME_PYQT_BorrowedDataObjectLight::SALOME_PYQT_BorrowedDataObjectLight ( QString entry )
+ : CAM_DataObject(0),
+ LightApp_DataObject( 0 )
+
+{
+ myEntry = entry;
+}
+
+//=================================================================================
+// function : SALOME_PYQT_BorrowedDataObjectLight()
+// purpose : destructor
+//=================================================================================
+SALOME_PYQT_BorrowedDataObjectLight::~SALOME_PYQT_BorrowedDataObjectLight()
+{
+
+}
+
+//=================================================================================
+// function : SALOME_PYQT_BorrowedDataObjectLight::entry()
+// purpose : return entry of object
+//=================================================================================
+QString SALOME_PYQT_BorrowedDataObjectLight::entry() const
+{
+ return myEntry;
+}
+
+//=================================================================================
+// function : SALOME_PYQT_BorrowedDataObjectLight::refEntry()
+// purpose : return entry of the data object referenced by this one (if any)
+//=================================================================================
+QString SALOME_PYQT_BorrowedDataObjectLight::refEntry() const
+{
+ return myRefEntry;
+}
+
+//=================================================================================
+// function : SALOME_PYQT_BorrowedDataObjectLight::setRefEntry()
+// purpose : sets entry of the data object referenced by this one
+//=================================================================================
+void SALOME_PYQT_BorrowedDataObjectLight::setRefEntry( const QString& refEntry )
+{
+ myRefEntry = refEntry;
+}
+
+//=================================================================================
+// function : SALOME_PYQT_BorrowedDataObjectLight::name()
+// purpose : return name of object
+//=================================================================================
+QString SALOME_PYQT_BorrowedDataObjectLight::name() const
+{
+ return myName;
+}
+
+//=================================================================================
+// function : SALOME_PYQT_BorrowedDataObjectLight::icon()
+// purpose : return icon of object
+//=================================================================================
+QPixmap SALOME_PYQT_BorrowedDataObjectLight::icon(const int index) const
+{
+ if(index == NameId)
+ return myIcon;
+ else
+ return LightApp_DataObject::icon( index );
+}
+
+
+//=================================================================================
+// function : SALOME_PYQT_BorrowedDataObjectLight::toolTip()
+// purpose : return toolTip of object
+//=================================================================================
+QString SALOME_PYQT_BorrowedDataObjectLight::toolTip(const int index) const
+{
+ return myToolTip;
+}
+
+//=================================================================================
+// function : SALOME_PYQT_BorrowedDataObjectLight::toolTip()
+// purpose : return toolTip of object
+//=================================================================================
+QColor SALOME_PYQT_BorrowedDataObjectLight::color( const ColorRole role, const int id ) const
+{
+ QColor c;
+
+ switch ( role )
+ {
+ case Text:
+ case Foreground:
+ if ( !isReference() )
+ c = myColor;
+ break;
+
+ default:
+ break;
+ }
+
+ // Issue 21379: LightApp_DataObject::color() defines colors for valid references
+ if ( !c.isValid() )
+ c = LightApp_DataObject::color( role, id );
+
+ return c;
+}
+
+bool SALOME_PYQT_BorrowedDataObjectLight::setName(const QString& name)
+{
+ myName = name;
+ return true;
+}
+
+void SALOME_PYQT_BorrowedDataObjectLight::setIcon(const QString& iconname)
+{
+ if(!iconname.isEmpty()) {
+ LightApp_Application* anApp = dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() );
+ if(anApp) {
+ QString modulename = anApp->activeModule()->name();
+ if(!modulename.isEmpty())
+ {
+ myIcon = SUIT_Session::session()->resourceMgr()->loadPixmap(modulename,
+ QObject::tr(iconname.toLatin1()));
+ }
+ }
+ }
+}
+
+void SALOME_PYQT_BorrowedDataObjectLight::setToolTip(const QString& tooltip)
+{
+ myToolTip = tooltip;
+}
+
+void SALOME_PYQT_BorrowedDataObjectLight::setColor(const QColor& color)
+{
+ myColor = color;
+}
--- /dev/null
+// 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, 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
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+// Author : Roman NIKOLAEV, Open CASCADE S.A.S. (roman.nikolaev@opencascade.com)
+// Date : 22/06/2007
+//
+#ifndef SALOME_PYQT_BORROWEDDATAOBJECTLIGHT_H
+#define SALOME_PYQT_BORROWEDDATAOBJECTLIGHT_H
+
+
+#include "SALOME_PYQT_GUILight.h"
+#include <LightApp_DataObject.h>
+#include <LightApp_Study.h>
+
+#include <qstring.h>
+
+/*!
+ * SALOME_PYQT_BorrowedDataObjectLight - PYTHON LIGHT module's data object class
+ * for objects created by other modules and referenced in a light module.
+ * Used to propagate selection in a light module client of other modules publishing objects in study.
+ * (copied from SALOME_PYQT_DataObjectLight)
+ */
+class SALOME_PYQT_LIGHT_EXPORT SALOME_PYQT_BorrowedDataObjectLight : public virtual LightApp_DataObject
+{
+
+ public:
+ SALOME_PYQT_BorrowedDataObjectLight( QString entry );
+
+ virtual ~SALOME_PYQT_BorrowedDataObjectLight();
+
+ virtual QString entry() const;
+
+ virtual QString refEntry() const;
+ void setRefEntry( const QString& refEntry );
+
+ virtual QString name() const;
+ virtual QPixmap icon(const int = NameId) const;
+ virtual QString toolTip(const int = NameId) const;
+
+ bool setName(const QString& name);
+ void setIcon(const QString& icon);
+ void setToolTip(const QString& tooltip);
+
+ virtual QColor color( const ColorRole, const int = NameId ) const;
+ void setColor(const QColor& color);
+
+ private:
+ QString myEntry;
+ QString myRefEntry;
+ QString myName;
+ QString myToolTip;
+ QPixmap myIcon;
+ QColor myColor;
+};
+
+#endif // SALOME_PYQT_BORROWEDDATAOBJECTLIGHT_H
#include "SALOME_PYQT_ModuleLight.h"
#include "SALOME_PYQT_DataModelLight.h"
#include "SALOME_PYQT_PyModule.h"
+#include "SALOME_PYQT_Selector.h"
#include "CAM_Application.h"
#include "SUITApp_init_python.hxx"
#include "SUIT_DataObjectIterator.h"
#include "LightApp_Application.h"
+#include "LightApp_SelectionMgr.h"
#include "SUIT_DataBrowser.h"
#include "sipAPISalomePyQtGUILight.h"
#endif
#include <QCoreApplication>
+#include <utilities.h>
// Py_ssize_t for old Pythons
// This code is as recommended by"
\brief Constructor
*/
SALOME_PYQT_ModuleLight::SALOME_PYQT_ModuleLight()
- : LightApp_Module( "noname" ) // name is set explicitly at the module initialization
+ : LightApp_Module( "noname" ), mySelector(0) // name is set explicitly at the module initialization
{
// initialize helper
myHelper = new PyModuleHelper( this );
{
// call helper
myHelper->modelClosed(application()->activeStudy());
+ if (mySelector)
+ mySelector->clear();
LightApp_Module::onModelClosed();
}
}
return obj;
}
+
+/*!
+ \brief not used yet
+*/
+void SALOME_PYQT_ModuleLight::getSelected( DataObjectList& ) const
+{
+ MESSAGE("getSelected");
+}
+
+/*!
+ \brief not used yet
+*/
+unsigned long SALOME_PYQT_ModuleLight::getModifiedTime() const
+{
+ MESSAGE("getModifiedTime");
+}
+
+/*!
+ \brief not used yet
+*/
+SUIT_DataObject* SALOME_PYQT_ModuleLight::root() const
+{
+ MESSAGE("root");
+}
+
+/*!
+ \brief Used to notify a Python light module of a modification of selection in study (propagation of a remote selection)
+ \param list of study entries
+*/
+void SALOME_PYQT_ModuleLight::setSelected( const QStringList& entries, const bool isUnused)
+{
+ MESSAGE("setSelected");
+ return myHelper->selectionUpdated(entries);
+}
+
+/*!
+ \brief called by Python module to notify a list of study entries locally selected (for selection propagation)
+ \param list of study entries
+*/
+void SALOME_PYQT_ModuleLight::setLocalSelected(const QStringList & entries)
+{
+ MESSAGE("setLocalSelected");
+ if (!mySelector)
+ {
+ mySelector = new SALOME_PYQT_Selector(this, this->getApp()->selectionMgr());
+ }
+ mySelector->setLocalEntries(entries);
+ emit localSelectionChanged();
+}
+
class QMenu;
class PyModuleHelper;
+class SALOME_PYQT_Selector;
class SALOME_PYQT_DataObjectLight;
class SALOME_PYQT_LIGHT_EXPORT SALOME_PYQT_ModuleLight: public LightApp_Module
QStringList getChildren( const QString&, const bool = false ) const;
+ void setLocalSelected(const QStringList &);
+ void getSelected( DataObjectList& ) const;
+ unsigned long getModifiedTime() const;
+ SUIT_DataObject* root() const;
+ void setSelected( const QStringList&, const bool = false );
+
protected:
CAM_DataModel* createDataModel();
SALOME_PYQT_DataObjectLight*
findObject( const QString& ) const;
+signals:
+ void selectionChanged();
+ void localSelectionChanged();
+
private:
PyModuleHelper* myHelper;
+ SALOME_PYQT_Selector* mySelector;
};
#endif // SALOME_PYQT_MODULELIGHT_H
PyInterp_Dispatcher::Get()->Exec( new ActionReq( myInterp, this, myModule->actionId( action ) ) );
}
+/*!
+ \brief update selection from other views or modules.
+
+ Called when selection is modified outside.
+*/
+void PyModuleHelper::selectionUpdated(const QStringList& entries)
+{
+ FuncMsg fmsg( "PyModuleHelper::selectionUpdated()" );
+ MESSAGE("selectionUpdated");
+
+ // perform synchronous request to Python event dispatcher
+ class SelectionReq : public PyInterp_LockRequest
+ {
+ public:
+ SelectionReq( PyInterp_Interp* _py_interp,
+ PyModuleHelper* _helper,
+ const QStringList& _entries )
+ : PyInterp_LockRequest( _py_interp, 0, true ), // this request should be processed synchronously (sync == true)
+ myHelper( _helper ),
+ myEntries( _entries )
+ {
+ MESSAGE("SelectionReq");
+ }
+ protected:
+ virtual void execute()
+ {
+ MESSAGE("execute");
+ myHelper->internalSelectionUpdated( myEntries );
+ }
+ private:
+ PyModuleHelper* myHelper;
+ const QStringList& myEntries;
+ };
+
+ // post request
+ PyInterp_Dispatcher::Get()->Exec( new SelectionReq( myInterp, this, entries ) );
+}
+
/*!
\brief Process context popup menu request.
}
}
+/*!
+ \brief update selection from other views or modules
+ \internal
+
+ Performs the following actions:
+ - calls Python module's onSelectionpdated(entries) method
+
+ \param list of entries
+*/
+void PyModuleHelper::internalSelectionUpdated(const QStringList& entries)
+{
+ FuncMsg fmsg("--- PyModuleHelper::internalSelectionUpdated()");
+ MESSAGE("internalSelectionUpdated");
+
+ // Python interpreter should be initialized and Python module should be imported first
+ if (!myInterp || !myPyModule)
+ return; // Error
+
+ QStringList* theList = new QStringList(entries);
+
+#if SIP_VERSION < 0x040800
+ PyObjWrapper sipList(sipBuildResult(0, "M", theList, sipClass_QStringList));
+#else
+ PyObjWrapper sipList( sipBuildResult( 0, "D", theList, sipType_QStringList, NULL ) );
+#endif
+ if (PyObject_HasAttrString(myPyModule, (char*) "onSelectionUpdated"))
+ {
+ MESSAGE("call onSelectionUpdated");
+ PyObjWrapper res(PyObject_CallMethod(myPyModule, (char*) "onSelectionUpdated", (char*) "O", sipList.get()));
+
+ if (!res)
+ {
+ PyErr_Print();
+ }
+ }
+}
+
/*!
\brief Context popup menu handling callback function
\internal
void preferenceChanged( const QString&, const QString&, const QString& setting );
void studyActivated( SUIT_Study* );
void actionActivated();
+ void selectionUpdated(const QStringList&);
void contextMenu( const QString&, QMenu* );
void createPreferences();
void activeViewChanged( SUIT_ViewWindow* );
void internalPreferencesChanged( const QString&, const QString& );
void internalStudyChanged( SUIT_Study* );
void internalActionActivated( int );
+ void internalSelectionUpdated(const QStringList&);
void internalContextMenu( const QString&, QMenu* );
void internalCreatePreferences();
void internalActiveViewChanged( SUIT_ViewWindow* );
--- /dev/null
+// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// 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, 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
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+// File : SALOME_PYQT_Selector.cxx
+// Author :
+//
+#include "SALOME_PYQT_Selector.h"
+
+#include "LightApp_DataOwner.h"
+#include "LightApp_DataObject.h"
+#include "LightApp_Application.h"
+#include "SALOME_PYQT_ModuleLight.h"
+#include "SALOME_PYQT_BorrowedDataObjectLight.h"
+#include <SUIT_Session.h>
+#include <SUIT_DataObjectIterator.h>
+#include <QTime>
+#include <time.h>
+
+#include <utilities.h>
+
+/*!
+ \class SALOME_PYQT_Selector
+ \brief Object browser selection handler class.
+ */
+
+/*!
+ \brief Constructor.
+ \param pymod Python module interface instance in charge of calling Python module methods from C++
+ \param mgr selection manager
+ */
+SALOME_PYQT_Selector::SALOME_PYQT_Selector(SALOME_PYQT_ModuleLight* pymod, SUIT_SelectionMgr* mgr) :
+ SUIT_Selector(mgr, pymod), myPyModule(pymod)
+{
+ MESSAGE("constructor");
+ myLocalEntries.clear();
+ mySelectedList.clear();
+ myEntries.clear();
+ myModifiedTime = 0;
+ if (myPyModule)
+ {
+ connect(myPyModule, SIGNAL(localSelectionChanged()), this, SLOT(onSelectionChanged()));
+ }
+ setModified();
+}
+
+/*!
+ \brief Destructor.
+ */
+SALOME_PYQT_Selector::~SALOME_PYQT_Selector()
+{
+ MESSAGE("destructor");
+}
+
+/*!
+ \brief Reset selection internally. Used on close study.
+ */
+void SALOME_PYQT_Selector::clear()
+{
+ MESSAGE("clear");
+ myLocalEntries.clear();
+ mySelectedList.clear();
+ myEntries.clear();
+}
+
+/*!
+ \brief Get Python module interface instance.
+ \return a pointer to the Python module interface instance.
+ */
+SALOME_PYQT_ModuleLight* SALOME_PYQT_Selector::pyModule() const
+{
+ MESSAGE("pyModule");
+ return myPyModule;
+}
+
+/*!
+ \brief Get selector type.
+ \return selector type
+ */
+QString SALOME_PYQT_Selector::type() const
+{
+ MESSAGE("type");
+ return "PYQT_Module";
+}
+
+/*!
+ \brief Get the time of the last selection changing.
+ \return latest selection changing time
+ */
+unsigned long SALOME_PYQT_Selector::getModifiedTime() const
+{
+ MESSAGE("getModifiedTime");
+ return myModifiedTime;
+}
+
+/*!
+ \brief Update the time of the latest selection changing.
+ */
+void SALOME_PYQT_Selector::setModified()
+{
+ MESSAGE("setModified");
+ myModifiedTime = clock();
+}
+
+/*!
+ \brief Called when the Object browser selection is changed.
+ */
+void SALOME_PYQT_Selector::onSelectionChanged()
+{
+ MESSAGE("onSelectionChanged");
+ QTime t1 = QTime::currentTime();
+ mySelectedList.clear();
+ selectionChanged();
+ QTime t2 = QTime::currentTime();
+ qDebug( QString( "selection time = %1 msecs" ).arg( t1.msecsTo( t2 ) ).toLatin1().constData());
+}
+
+/*!
+ \brief Get list of currently selected objects.
+ \param theList list to be filled with the selected objects owners
+ */
+void SALOME_PYQT_Selector::getSelection(SUIT_DataOwnerPtrList& theList) const
+{
+ MESSAGE("getSelection");
+ if (mySelectedList.count() == 0)
+ {
+ MESSAGE("mySelectedList.count(): " << mySelectedList.count() << " myLocalEntries.size(): "<< myLocalEntries.size());
+ SALOME_PYQT_Selector* that = (SALOME_PYQT_Selector*) this; // because of const...
+ for (int i = 0; i < myLocalEntries.size(); i++)
+ {
+ SALOME_PYQT_BorrowedDataObjectLight *obj = new SALOME_PYQT_BorrowedDataObjectLight(myLocalEntries[i]);
+#ifndef DISABLE_SALOMEOBJECT
+ Handle(SALOME_InteractiveObject)aSObj = new SALOME_InteractiveObject
+ ( obj->entry().toLatin1().constData(),
+ obj->componentDataType().toLatin1().constData(),
+ obj->name().toLatin1().constData() );
+ LightApp_DataOwner* owner = new LightApp_DataOwner(aSObj);
+#else
+ LightApp_DataOwner* owner = new LightApp_DataOwner( obj->entry() );
+#endif
+ that->mySelectedList.append(SUIT_DataOwnerPtr(owner));
+ }
+ }
+ theList = mySelectedList;
+}
+
+/*!
+ \brief Set selection.
+ \param theList list of the object owners to be set selected
+ */
+void SALOME_PYQT_Selector::setSelection(const SUIT_DataOwnerPtrList& theList)
+{
+ MESSAGE("setSelection");
+ if (!myPyModule)
+ return;
+
+ myEntries.clear();
+ for (SUIT_DataOwnerPtrList::const_iterator it = theList.begin(); it != theList.end(); ++it)
+ {
+ const LightApp_DataOwner* owner = dynamic_cast<const LightApp_DataOwner*>((*it).operator->());
+ if (owner)
+ {
+ QString entry = owner->entry();
+ myEntries.append(entry);
+ MESSAGE("Selected: "<< entry.toStdString());
+ }
+ }
+ fillEntries(myEntries);
+ mySelectedList.clear();
+}
+
+/*!
+ \brief Fill map of the data objects currently shown in the Object Browser.
+ \param entries map to be filled
+ */
+void SALOME_PYQT_Selector::fillEntries(QStringList& entries)
+{
+ MESSAGE("fillEntries");
+ if (!myPyModule)
+ return;
+ myPyModule->setSelected(entries);
+ setModified();
+}
+
--- /dev/null
+// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// 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, 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
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+// File : SALOME_PYQT_Selector.h
+// Author :
+//
+#ifndef SALOME_PYQT_SELECTOR_H
+#define SALOME_PYQT_SELECTOR_H
+
+#include "SALOME_PYQT_GUILight.h"
+#include "PyInterp_Interp.h" // !!! WARNING !!! THIS INCLUDE MUST BE THE VERY FIRST !!!
+
+#include "LightApp.h"
+
+#include <SUIT_Selector.h>
+#include <SUIT_DataOwner.h>
+
+#include <QObject>
+
+class SALOME_PYQT_ModuleLight;
+class LightApp_DataObject;
+
+class SALOME_PYQT_LIGHT_EXPORT SALOME_PYQT_Selector : public QObject, public SUIT_Selector
+{
+ Q_OBJECT
+
+public:
+ SALOME_PYQT_Selector( SALOME_PYQT_ModuleLight*, SUIT_SelectionMgr* );
+ virtual ~SALOME_PYQT_Selector();
+
+ SALOME_PYQT_ModuleLight* pyModule() const;
+
+ virtual QString type() const;
+
+ unsigned long getModifiedTime() const;
+ void setModified();
+ void setLocalEntries(const QStringList& entries) { myLocalEntries = entries; };
+ void clear();
+
+private slots:
+ void onSelectionChanged();
+
+protected:
+ virtual void getSelection( SUIT_DataOwnerPtrList& ) const;
+ virtual void setSelection( const SUIT_DataOwnerPtrList& );
+
+private:
+ void fillEntries( QStringList& );
+
+private:
+ QStringList myLocalEntries;
+ SALOME_PYQT_ModuleLight* myPyModule;
+ SUIT_DataOwnerPtrList mySelectedList;
+ QStringList myEntries;
+ unsigned long myModifiedTime;
+};
+
+#endif
#include <QPaintEvent>
#include <QCoreApplication>
+#include <utilities.h>
namespace
{
/*!
return sel;
}
+
/*!
\brief Constructor.
\param p parent object
return ProcessEvent( new TGetSelectionEvent() );
}
+/*!
+ \fn QStringList* SalomePyQt::setSelection(const QStringList& );
+ \brief Send local selection for notification.
+
+ The list of locally selected objects (study entries) is sent for notification of
+ other listening entities (modules, viewers...).
+*/
+
+class TSetSelectionEvent: public SALOME_Event
+{
+ QStringList myEntryList;
+public:
+ TSetSelectionEvent(const QStringList& entryList) : myEntryList(entryList) {}
+ virtual void Execute()
+ {
+ SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
+ if ( !module ) return;
+ module->setLocalSelected(myEntryList);
+ }
+};
+void SalomePyQt::setSelection( const QStringList& entryList)
+{
+ return ProcessVoidEvent( new TSetSelectionEvent(entryList) );
+}
+
/*!
\fn void SalomePyQt::putInfo( const QString& msg, const int sec );
\brief Put an information message to the current application's
for ( int i = 0, n = vec.size(); i < n; i++ ) {
SUIT_ViewWindow* wnd = vec[ i ];
if ( wnd )
- myResult.append( wnd->getId() );
+ {
+ MESSAGE("SUIT_ViewWindow*: "<< wnd << " id: " << wnd->getId());
+ myResult.append( wnd->getId() );
+ }
}
}
}
virtual void Execute()
{
SUIT_ViewWindow* wnd = getWnd( myWndId );
+ MESSAGE("window id:" << myWndId << " SUIT_ViewWindow*: " << wnd);
if ( wnd ) {
wnd->setFocus();
myResult = true;
return ProcessEvent( new TActivateView( id ) );
}
+/*!
+ \fn bool SalomePyQt::activateManagerAndView( const int id );
+ \brief Activate view manager and view: useful for a view embedded in a module main Window
+ \param id window identifier
+ \return \c true if operation is completed successfully and \c false otherwise
+ */
+
+class TActivateViewManagerAndView: public SALOME_Event
+{
+public:
+ typedef bool TResult;
+ TResult myResult;
+ int myWndId;
+ TActivateViewManagerAndView( const int id )
+ : myResult( false ),
+ myWndId( id ) {}
+ virtual void Execute()
+ {
+ SUIT_ViewWindow* wnd = getWnd( myWndId );
+ MESSAGE("window id:" << myWndId << " SUIT_ViewWindow*: " << wnd);
+ if ( wnd )
+ {
+ LightApp_Application* app = getApplication();
+ app->desktop()->windowActivated(wnd); // equivalent to app->setActiveViewManager(wnd->getViewManager())
+ wnd->setFocus();
+ myResult = true;
+ }
+ }
+};
+bool SalomePyQt::activateViewManagerAndView( const int id )
+{
+ return ProcessEvent( new TActivateViewManagerAndView( id ) );
+}
+
+/*!
+ *
+ */
+
+class TGetViewWidget: public SALOME_Event
+{
+public:
+ typedef QWidget* TResult;
+ TResult myResult;
+ int myWndId;
+ TGetViewWidget( const int id )
+ : myResult( 0 ),
+ myWndId( id ) {}
+ virtual void Execute()
+ {
+ SUIT_ViewWindow* wnd = getWnd( myWndId );
+ if ( wnd ) {
+ myResult = (QWidget*)wnd;
+ }
+ }
+};
+QWidget* SalomePyQt::getViewWidget( const int id)
+{
+ return ProcessEvent( new TGetViewWidget( id ) );
+}
+
+
/*!
\fn int SalomePyQt::createView( const QString& type, bool visible = true, const int width = 0, const int height = 0 );
\brief Create new view and activate it
static QMenu* getPopupMenu( const QString& );
static QTreeView* getObjectBrowser();
static SALOME_Selection* getSelection();
+ static void setSelection( const QStringList& );
static int getStudyId();
static void putInfo( const QString&, const int = 0 );
static const QString getActiveComponent();
static bool setViewSize( const int, const int, const int = 0 );
static QList<int> findViews( const QString& );
static bool activateView( const int );
+ static bool activateViewManagerAndView( const int );
+ static QWidget* getViewWidget( const int );
static int createView( const QString&, bool visible = true, const int width = 0, const int height = 0 );
static int createView( const QString&, QWidget* );
static bool closeView( const int );
static QMenu* getPopupMenu( const QString& ) /ReleaseGIL/ ;
static QTreeView* getObjectBrowser() /ReleaseGIL/ ;
static SALOME_Selection* getSelection() /Factory,ReleaseGIL/ ;
+ static void setSelection( const QStringList& ) /ReleaseGIL/ ;
static int getStudyId() /ReleaseGIL/ ;
static void putInfo( const QString&, const int = 0 ) /ReleaseGIL/ ;
static const QString getActiveComponent() /ReleaseGIL/ ;
static bool setViewSize( const int, const int, const int = 0 ) /ReleaseGIL/ ;
static QList<int> findViews( const QString& ) /ReleaseGIL/ ;
static bool activateView( const int ) /ReleaseGIL/ ;
+ static bool activateViewManagerAndView( const int ) /ReleaseGIL/ ;
+ static QWidget* getViewWidget( const int ) /ReleaseGIL/ ;
static int createView( const QString&, bool visible = true, const int width = 0, const int height = 0 ) /ReleaseGIL/ ;
static int createView( const QString&, QWidget* ) /ReleaseGIL/ ;
static bool closeView( const int ) /ReleaseGIL/ ;
#include <QRegExp>
#include <QString>
#include <QStringList>
+#if QT_VERSION > QT_VERSION_CHECK(5, 0, 0)
+#include <QSurfaceFormat>
+#endif
#include <stdlib.h>
}
}
+#if QT_VERSION > QT_VERSION_CHECK(5, 0, 0)
+ // initialization of the X11 visual on Linux
+ QSurfaceFormat format;
+ format.setDepthBufferSize(16);
+ format.setStencilBufferSize(1);
+ format.setProfile(QSurfaceFormat::CompatibilityProfile);
+ QSurfaceFormat::setDefaultFormat(format);
+#endif
+
// add <qtdir>/plugins directory to the pluins search path for image plugins
QString qtdir = Qtx::qtDir( "plugins" );
if ( !qtdir.isEmpty() )
if (oldFather) {
oldFather->removeChild(suit_obj, false);
SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( myStudy->application() );
+// MESSAGE("myStudy: " << myStudy->id() << " app " << app);
+// MESSAGE("objectBrowser: "<< app->objectBrowser());
+ if (!app->objectBrowser()) {
+ MESSAGE("Object Browser not found. Problem ??");
+ return;
+ }
SUIT_AbstractModel* model = dynamic_cast<SUIT_AbstractModel*>(app->objectBrowser()->model());
model->forgetObject( suit_obj );
#include <QWaitCondition>
#include <QRegExp>
#include <QTextStream>
+#if QT_VERSION > QT_VERSION_CHECK(5, 0, 0)
+#include <QSurfaceFormat>
+#endif
/*! - read arguments, define list of server to launch with their arguments.
* - wait for naming service
QLocale::setDefault( QLocale::system() );
}
}
+
+#if QT_VERSION > QT_VERSION_CHECK(5, 0, 0)
+ // initialization of the X11 visual on Linux
+ QSurfaceFormat format;
+ format.setDepthBufferSize(16);
+ format.setStencilBufferSize(1);
+ format.setProfile(QSurfaceFormat::CompatibilityProfile);
+ QSurfaceFormat::setDefaultFormat(format);
+#endif
// Create Qt application instance;
// this should be done the very first!