X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESH_SWIG_WITHIHM%2FlibSMESH_Swig.cxx;h=f356bd9ba0666a8df044fe52c23bde4ba552f706;hp=c97dd01fd81ea7212aa43a09d6f12b3a8278f45a;hb=41b3e4433388f439856c3b0bb3725e9c81179c24;hpb=bd8f1aee7c78f7d2eb82bd4fec5e08c9e3d280ce diff --git a/src/SMESH_SWIG_WITHIHM/libSMESH_Swig.cxx b/src/SMESH_SWIG_WITHIHM/libSMESH_Swig.cxx index c97dd01fd..f356bd9ba 100644 --- a/src/SMESH_SWIG_WITHIHM/libSMESH_Swig.cxx +++ b/src/SMESH_SWIG_WITHIHM/libSMESH_Swig.cxx @@ -1,9 +1,9 @@ -// 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 @@ -24,9 +24,12 @@ // #include "libSMESH_Swig.h" + #include #include #include +#include +#include // SALOME KERNEL includes #include @@ -40,12 +43,16 @@ #include #include #include +#include #include #include #include +#include +#include // OCCT includes #include +#include // Qt includes #include @@ -295,7 +302,7 @@ SMESH_Swig::SMESH_Swig() } }; - MESSAGE("Constructeur"); + //MESSAGE("Constructeur"); if(CORBA::is_nil(anORB)) ProcessVoidEvent(new TEvent(anORB)); @@ -380,6 +387,10 @@ SMESH_Swig::Init(int theStudyID) aPixmap->SetPixMap( "ICON_OBJBROWSER_SMESH" ); aPixmap->UnRegister(); + SALOMEDS::UseCaseBuilder_var useCaseBuilder = myStudy->GetUseCaseBuilder(); + useCaseBuilder->SetRootCurrent(); + useCaseBuilder->Append( aSComponent.in() ); + myStudyBuilder->DefineComponentInstance(aSComponent,aSMESHGen); if (aLocked) myStudy->GetProperties()->SetLocked(true); @@ -391,7 +402,7 @@ SMESH_Swig::Init(int theStudyID) } }; - MESSAGE("Init"); + //MESSAGE("Init"); ProcessVoidEvent(new TEvent(theStudyID, myStudy, @@ -403,14 +414,13 @@ SMESH_Swig::Init(int theStudyID) //=============================================================== SMESH_Swig::~SMESH_Swig() { - MESSAGE("Destructeur"); + //MESSAGE("Destructeur"); } //=============================================================== const char* SMESH_Swig::AddNewMesh(const char* theIOR) { - MESSAGE("AddNewMesh"); // VSR: added temporarily - to be removed - objects are published automatically by engine SALOMEDS::SObject_var aSObject = myStudy->FindObjectIOR(theIOR); @@ -445,8 +455,6 @@ const char* SMESH_Swig::AddNewMesh(const char* theIOR) //=============================================================== const char* SMESH_Swig::AddNewHypothesis(const char* theIOR) { - MESSAGE("AddNewHypothesis"); - SALOMEDS::SObject_var aSObject = ::AddHypothesis(theIOR, mySComponentMesh, myStudyBuilder); @@ -460,8 +468,6 @@ const char* SMESH_Swig::AddNewHypothesis(const char* theIOR) //=============================================================== const char* SMESH_Swig::AddNewAlgorithms(const char* theIOR) { - MESSAGE("AddNewAlgorithms"); - SALOMEDS::SObject_var aSObject = ::AddAlgorithms(theIOR, mySComponentMesh, myStudyBuilder); @@ -726,3 +732,112 @@ void SMESH_Swig::SetMeshIcon(const char* theMeshEntry, theIsComputed, isEmpty)); } + +/*! + \brief Helper class for selection event. +*/ +class TSelectListEvent: public SALOME_Event +{ + const char* myId; + std::vector myIdsList; + bool myIsAppend; + +public: + TSelectListEvent(const char* id, std::vector ids, bool append) : + myId(id), + myIdsList(ids), + myIsAppend(append) + {} + virtual void Execute() + { + SMESHGUI* aSMESHGUI = SMESHGUI::GetSMESHGUI(); + if( !aSMESHGUI ) + return; + + LightApp_SelectionMgr* selMgr = SMESH::GetSelectionMgr( aSMESHGUI ); + if( !selMgr ) + return; + + selMgr->clearFilters(); + + SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( aSMESHGUI ); + if(!aViewWindow) + return; + + SMESH_Actor* anActor = SMESH::FindActorByEntry( myId ); + + if (!anActor || !anActor->hasIO()) + return; + + Handle(SALOME_InteractiveObject) anIO = anActor->getIO(); + SALOME_ListIO aList; + aList.Append(anIO); + selMgr->setSelectedObjects(aList, false); + + if ( aViewWindow->SelectionMode() == ActorSelection ) { + return; + } + + TColStd_MapOfInteger aMap; + std::vector::const_iterator anIter; + for (anIter = myIdsList.begin(); anIter != myIdsList.end(); ++anIter) { + aMap.Add(*anIter); + } + + // Set new selection + SVTK_Selector* aSelector = aViewWindow->GetSelector(); + aSelector->AddOrRemoveIndex(anIO, aMap, myIsAppend); + aViewWindow->highlight( anIO, true, true ); + aViewWindow->GetInteractor()->onEmitSelectionChanged(); + } +}; + +/*! + \brief Select the elements on the mesh, sub-mesh or group. + \param id object entry + \param ids list of the element ids + \param mode selection mode +*/ +void SMESH_Swig::select( const char* id, std::vector ids, bool append ) { + ProcessVoidEvent( new TSelectListEvent( id, ids, append ) ); +} + +/*! + \brief Select the elements on the mesh, sub-mesh or group. + \param id object entry + \param id id of the element + \param mode selection mode +*/ +void SMESH_Swig::select( const char* id, int id1, bool append ) { + std::vector ids; + ids.push_back( id1 ); + ProcessVoidEvent( new TSelectListEvent( id, ids, append ) ); +} + + +class TGetSelectionModeEvent : public SALOME_Event +{ +public: + typedef int TResult; + TResult myResult; + TGetSelectionModeEvent() : myResult( -1 ) {} + virtual void Execute() + { + SMESHGUI* aSMESHGUI = SMESHGUI::GetSMESHGUI(); + if( !aSMESHGUI ) + return; + + SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( aSMESHGUI ); + if(!aViewWindow) + return; + + myResult = aViewWindow->SelectionMode(); + } +}; + +/*! + \brief Get selection mode of the active VTK View window. +*/ +int SMESH_Swig::getSelectionMode() { + return ProcessEvent( new TGetSelectionModeEvent() ); +}