// Function : GEOMBase_Helper
// Purpose :
//================================================================
-GEOMBase_Helper::GEOMBase_Helper( SUIT_Desktop* desktop )
- : myDisplayer( 0 ), myCommand( 0 ), myViewWindow( 0 ), isPreview( false ), myDesktop( desktop ),
+GEOMBase_Helper::GEOMBase_Helper( SUIT_Desktop* desktop, SUIT_ViewWindow* aVW )
+ : myDisplayer( 0 ), myCommand( 0 ), myViewWindow( aVW ), isPreview( false ), myDesktop( desktop ),
myIsApplyAndClose( false ), myIsOptimizedBrowsing( false ), myIsWaitCursorEnabled( true ),
myIsDisableBrowsing(false), myIsDisplayResult(true)
{
QString anEntry = getEntry( anObj );
if ( anEntry != "" )
{
+ //MESSAGE("anEntry: "<< anEntry.toStdString().c_str());
QString aName = GEOMBase::GetName( anObj );
aListOfIO.Append( new SALOME_InteractiveObject( anEntry.toUtf8().constData(),
"GEOM", aName.toUtf8().constData() ));
localSelection( obj, modes );
}
+//================================================================
+// Function : localSelection
+// Purpose : Activate selection of sub-shapes in accordance with mode
+// mode is from TopAbs_ShapeEnum
+//================================================================
+void GEOMBase_Helper::localSelection( const std::string& entry, const std::string& name, const std::list<int> modes)
+{
+ SALOME_ListIO aListOfIO;
+ QString aName = name.c_str();
+ aListOfIO.Append( new SALOME_InteractiveObject( entry.c_str(),
+ "GEOM", aName.toUtf8().constData() ));
+ getDisplayer()->LocalSelection( aListOfIO, modes );
+}
+
//================================================================
// Function : localSelection
// Purpose : Activate selection of sub-shapes in accordance with mode
#include <QMap>
#include <list>
+#include <string>
typedef std::list<GEOM::GEOM_Object_ptr> ObjectList;
class GEOMBASE_EXPORT GEOMBase_Helper
{
public:
- GEOMBase_Helper( SUIT_Desktop* );
+ GEOMBase_Helper( SUIT_Desktop*, SUIT_ViewWindow* aVW = 0);
virtual ~GEOMBase_Helper();
static SUIT_ViewWindow* getActiveView();
void localSelection( const ObjectList&, const int );
void localSelection( GEOM::GEOM_Object_ptr, const std::list<int> );
void localSelection( GEOM::GEOM_Object_ptr, const int );
+ void localSelection( const std::string&, const std::string&, const std::list<int> );
void localSelection( const std::list<int> );
void localSelection( const int );
void activate( const int );
${PROJECT_BINARY_DIR}/idl
${PROJECT_BINARY_DIR}
${PROJECT_SOURCE_DIR}/src/OBJECT
+ ${PROJECT_SOURCE_DIR}/src/GEOMBase
${PROJECT_SOURCE_DIR}/src/GEOMClient
${PROJECT_SOURCE_DIR}/src/GEOMGUI
${PROJECT_SOURCE_DIR}/src/Material
# --- rules ---
IF(${CMAKE_VERSION} VERSION_LESS "3.8.0")
- SWIG_ADD_MODULE(libGEOM_Swig python libGEOM_Swig.i libGEOM_Swig.cxx)
+ SWIG_ADD_MODULE(libGEOM_Swig python libGEOM_Swig.i libGEOM_Swig.cxx GEOM_Swig_LocalSelector.cxx)
ELSE()
- SWIG_ADD_LIBRARY(libGEOM_Swig LANGUAGE python SOURCES libGEOM_Swig.i libGEOM_Swig.cxx)
+ SWIG_ADD_LIBRARY(libGEOM_Swig LANGUAGE python SOURCES libGEOM_Swig.i libGEOM_Swig.cxx GEOM_Swig_LocalSelector.cxx)
ENDIF()
SWIG_LINK_LIBRARIES(libGEOM_Swig "${_link_LIBRARIES}")
--- /dev/null
+// Copyright (C) 2007-2019 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
+//
+
+#include "GEOM_Swig_LocalSelector.h"
+#include <SalomeApp_Study.h>
+#include <SUIT_Desktop.h>
+#include <SUIT_Session.h>
+#include <GeometryGUI.h>
+#include <SalomeApp_Application.h>
+#include <LightApp_SelectionMgr.h>
+#include <SALOMEDSClient_definitions.hxx>
+#include <vector>
+#include <utilities.h>
+
+GEOM_Swig_LocalSelector::GEOM_Swig_LocalSelector(QWidget* parent, SUIT_ViewWindow* wnd, const std::string& shapeEntry, int mode) :
+ GEOMBase_Helper(dynamic_cast<SUIT_Desktop*>(parent), wnd )
+{
+ MESSAGE("GEOM_Swig_LocalSelector " << shapeEntry << " " << mode);
+ myObject = GEOM::GEOM_Object::_nil();
+ mySubShapesInd = new GEOM::short_array();
+ std::string shapeName = "aShape";
+
+ SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(SUIT_Session::session()->activeApplication()->activeStudy());
+ if (study)
+ {
+ _PTR(Study) studyDS = study->studyDS();
+ _PTR(SObject) obj( studyDS->FindObjectID( shapeEntry ) );
+ if (obj)
+ {
+ CORBA::Object_var corbaObj = GeometryGUI::ClientSObjectToObject(obj);
+ if (!CORBA::is_nil(corbaObj))
+ {
+ myObject = GEOM::GEOM_Object::_narrow(corbaObj);
+ shapeName = myObject->GetName();
+ MESSAGE("shapeName: " << shapeName);
+ }
+ }
+ }
+
+ std::list<int> modes;
+ modes.push_back(mode);
+ localSelection(shapeEntry, shapeName, modes);
+}
+
+GEOM_Swig_LocalSelector::~GEOM_Swig_LocalSelector()
+{
+ MESSAGE("~GEOM_Swig_LocalSelector");
+}
+
+std::vector<int> GEOM_Swig_LocalSelector::getSelection()
+{
+ MESSAGE("getSelection");
+ SalomeApp_Application* app = (SalomeApp_Application*)SUIT_Session::session()->activeApplication();
+ LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
+ SALOME_ListIO aSelList;
+ aSelMgr->selectedObjects(aSelList);
+
+ TColStd_IndexedMapOfInteger aMap;
+ MESSAGE("aSelList.Extent(): " << aSelList.Extent());
+ if (aSelList.Extent() > 0)
+ {
+ Handle(SALOME_InteractiveObject) anIO = aSelList.First();
+ aSelMgr->GetIndexes(anIO, aMap);
+ }
+
+ const int n = aMap.Extent();
+ std::vector<int> ids;
+ for (int i = 1; i <= n; i++)
+ ids.push_back(aMap(i));
+ for (int i =0; i < ids.size(); i++)
+ {
+ MESSAGE("ids[" << i << "] = " << ids[i]);
+ }
+
+ return ids;
+}
+
--- /dev/null
+// Copyright (C) 2007-2019 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
+//
+
+#ifndef _GEOM_SWIG_LOCALSELECTOR_H_
+#define _GEOM_SWIG_LOCALSELECTOR_H_
+
+#include <string>
+#include <vector>
+
+#include <QObject>
+
+#include "GEOMBase_Helper.h"
+
+class GEOM_Swig_LocalSelector : public GEOMBase_Helper
+{
+public:
+ GEOM_Swig_LocalSelector(QWidget* parent, SUIT_ViewWindow* wnd, const std::string& shapeEntry, int mode);
+ ~GEOM_Swig_LocalSelector();
+
+ std::vector<int> getSelection();
+
+protected:
+ GEOM::GEOM_Object_var myObject;
+ GEOM::short_array_var mySubShapesInd;
+
+};
+
+#endif /* _GEOM_SWIG_LOCALSELECTOR_H_ */
#include "GEOM_Displayer.h"
#include "GEOM_Constants.h"
#include "Material_Model.h"
+#include "GEOM_Swig_LocalSelector.h"
+#include "GEOMGUI_OCCSelector.h"
+#include "OCCViewer_ViewManager.h"
#include <SUIT_Desktop.h>
#include <SUIT_Session.h>
#include <SUIT_ViewManager.h>
#include <SUIT_ViewModel.h>
+#include <SUIT_SelectionMgr.h>
+#include <LightApp_SelectionMgr.h>
#include <SalomeApp_Application.h>
#include <SalomeApp_Study.h>
#include <OCCViewer_ViewFrame.h>
#include <SVTK_ViewWindow.h>
#include <SALOME_Event.h>
+#include <utilities.h>
// IDL Headers
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(GEOM_Gen)
+GEOM_Swig_LocalSelector* GEOM_Swig::myLocalSelector = 0;
+GEOMGUI_OCCSelector* GEOM_Swig::myOCCSelector =0;
+
/*!
\brief Constructor
*/
-GEOM_Swig::GEOM_Swig()
+GEOM_Swig::GEOM_Swig( bool updateOB )
{
- init();
+ init(updateOB);
}
/*!
/*!
\brief Internal initialization
*/
-void GEOM_Swig::init()
+void GEOM_Swig::init( bool updateOB )
{
class TEvent: public SALOME_Event
{
+ bool myUpdateOB;
public:
- TEvent()
+ TEvent( bool _updateOB ):
+ myUpdateOB(_updateOB)
{}
virtual void Execute()
{
}
// update Object browser
- if ( dynamic_cast<SalomeApp_Application*>( app ) )
+ if (myUpdateOB && dynamic_cast<SalomeApp_Application*>( app ) )
dynamic_cast<SalomeApp_Application*>( app )->updateObjectBrowser( true );
+
+ //myLocalSelector = 0;
}
};
- ProcessVoidEvent( new TEvent() );
+ ProcessVoidEvent( new TEvent(updateOB) );
}
/*!
theMaterial, theUpdateViewer ) );
}
+/*!
+ \brief initialize local subShapes selection on a given shape
+ \param theEntry geometry object's entry
+ \param theMode from enum TopAbs_ShapeEnum
+ */
+void GEOM_Swig::initLocalSelection( const char* theEntry, int theMode)
+{
+ class TEventInitLocalSelection: public SALOME_Event
+ {
+ std::string myEntry;
+ int myMode;
+ public:
+ TEventInitLocalSelection(const char* _entry, int _mode)
+ : myEntry(_entry), myMode(_mode)
+ {}
+ virtual void Execute()
+ {
+ if (myLocalSelector)
+ return;
+ SUIT_Application* app = SUIT_Session::session()->activeApplication();
+ if ( app )
+ {
+ SUIT_ViewWindow* window = app->desktop()->activeWindow();
+ SUIT_ViewWindow* wnd = 0;
+ LightApp_Application* lapp = dynamic_cast<LightApp_Application*>(app);
+ if ( lapp )
+ {
+ SUIT_ViewManager* viewMgr = lapp->activeViewManager();
+ if ( viewMgr )
+ {
+ wnd = viewMgr->getActiveView();
+ }
+ LightApp_SelectionMgr* mgr = lapp->selectionMgr();
+ if (!myOCCSelector)
+ {
+ myOCCSelector = new GEOMGUI_OCCSelector( ((OCCViewer_ViewManager*)viewMgr)->getOCCViewer(), mgr );
+ }
+
+ QList<SUIT_Selector*> aSelectorList;
+ mgr->selectors( "OCCViewer", aSelectorList );
+ for (int i=0; i< aSelectorList.size(); ++i)
+ {
+ if ( LightApp_OCCSelector* aSelector = dynamic_cast<LightApp_OCCSelector*>( aSelectorList.at(i) ) )
+ {
+ aSelector->setEnabled(false);
+ }
+ if ( GEOMGUI_OCCSelector* aSelector = dynamic_cast<GEOMGUI_OCCSelector*>( aSelectorList.at(i) ) )
+ {
+ aSelector->setEnabled(true);
+ }
+ }
+ myOCCSelector->setEnabled(true);
+ }
+
+ myLocalSelector = new GEOM_Swig_LocalSelector(app->desktop(), wnd, myEntry, myMode);
+ MESSAGE("TEventInitLocalSelection myLocalSelector: " << myLocalSelector);
+ }
+ }
+ };
+
+ ProcessVoidEvent(new TEventInitLocalSelection(theEntry, theMode));
+}
+
+/*!
+ \brief get local subShapes selection on a given shape
+ \return a list of selected subShapes indexes
+ */
+std::vector<int> GEOM_Swig::getLocalSelection()
+{
+ class TEventGetLocalSelection: public SALOME_Event
+ {
+ public:
+ typedef std::vector<int> TResult;
+ TResult myResult;
+
+ TEventGetLocalSelection(){}
+
+ virtual void Execute()
+ {
+ MESSAGE("TEventGetLocalSelection myLocalSelector: " << myLocalSelector);
+ if (myLocalSelector)
+ myResult = myLocalSelector->getSelection();
+ }
+ };
+
+ std::vector<int> result = ProcessEvent(new TEventGetLocalSelection());
+ return result;
+}
+
+/*!
+ \brief close local subShapes selection on a given shape
+ */
+void GEOM_Swig::closeLocalSelection()
+{
+ class TEventCloseLocalSelection: public SALOME_Event
+ {
+ public:
+ TEventCloseLocalSelection()
+ {}
+ virtual void Execute()
+ {
+ MESSAGE("TEventCloseLocalSelection myLocalSelector: " << myLocalSelector);
+ if (myLocalSelector)
+ {
+ delete myLocalSelector;
+ myLocalSelector = 0;
+ }
+ }
+ };
+
+ ProcessVoidEvent(new TEventCloseLocalSelection());
+}
+
class TInitGeomGenEvent: public SALOME_Event
{
public:
#define LIBGEOM_SWIG_H
#include "GEOM_GEOMGUI.hxx"
+#include <vector>
+
+class GEOM_Swig_LocalSelector;
+class GEOMGUI_OCCSelector;
class GEOMGUI_EXPORT GEOM_Swig
{
public:
- GEOM_Swig();
+ GEOM_Swig( bool updateOB = true );
~GEOM_Swig();
void createAndDisplayGO( const char* theEntry, bool theUpdateViewer = true );
void setMaterial( const char* theEntry, const char* theMaterial, bool theUpdateViewer = true );
void setMaterialProperty( const char* theEntry, const char* theMaterial, bool theUpdateViewer = true );
+ void initLocalSelection( const char* theEntry, int theMode);
+ std::vector<int> getLocalSelection();
+ void closeLocalSelection();
+
int getIndexTopology( const char* theSubIOR, const char* theMainIOR );
const char* getShapeTypeString( const char* theIOR );
const char* getShapeTypeIcon( const char* theIOR );
bool initGeomGen();
-private:
- void init();
+ static GEOM_Swig_LocalSelector* myLocalSelector;
+ static GEOMGUI_OCCSelector* myOCCSelector;
+
+private:
+ void init( bool updateOB );
};
#endif // LIBGEOM_SWIG_H
// Project : SALOME
// Module : GEOM
//
+
+
%module libGEOM_Swig
%{
#include "libGEOM_Swig.h"
%}
+%include "std_vector.i"
+namespace std {
+ %template(IntVector) vector<int>;
+}
+
+#include <vector>
+
/*
managing C++ exception in the Python API
*/
class GEOM_Swig
{
public:
- GEOM_Swig();
+ GEOM_Swig( bool updateOB = true );
~GEOM_Swig();
void createAndDisplayGO( const char* theEntry, bool theUpdateViewer = true );
void setMaterial( const char* theEntry, const char* theMaterial, bool theUpdateViewer = true );
void setMaterialProperty( const char* theEntry, const char* theMaterial, bool theUpdateViewer = true );
+ void initLocalSelection( const char* theEntry, int theMode);
+ std::vector<int> getLocalSelection();
+ void closeLocalSelection();
+
int getIndexTopology( const char* theSubIOR, const char* theMainIOR );
const char* getShapeTypeString( const char* theIOR );
const char* getShapeTypeIcon( const char* theIOR );