2016-03-18 22:10:20 +05:00
|
|
|
// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
|
2003-07-10 19:18:22 +06:00
|
|
|
//
|
2012-08-09 16:03:55 +06:00
|
|
|
// 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
|
2014-02-20 18:25:37 +06:00
|
|
|
// version 2.1 of the License, or (at your option) any later version.
|
2003-07-10 19:18:22 +06:00
|
|
|
//
|
2012-08-09 16:03:55 +06:00
|
|
|
// 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.
|
2003-07-10 19:18:22 +06:00
|
|
|
//
|
2012-08-09 16:03:55 +06:00
|
|
|
// 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
|
2003-07-10 19:18:22 +06:00
|
|
|
//
|
2012-08-09 16:03:55 +06:00
|
|
|
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
2009-02-17 10:27:49 +05:00
|
|
|
//
|
2012-08-09 16:03:55 +06:00
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
// SMESH SMESH : GUI for SMESH component
|
|
|
|
// File : libSMESH_Swig.cxx
|
|
|
|
// Author : Nicolas REJNERI, Open CASCADE S.A.S.
|
|
|
|
// SMESH includes
|
|
|
|
//
|
|
|
|
#include "libSMESH_Swig.h"
|
2003-05-19 20:07:00 +06:00
|
|
|
|
2015-07-22 20:13:50 +05:00
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
#include <SMESHGUI.h>
|
|
|
|
#include <SMESHGUI_Utils.h>
|
|
|
|
#include <SMESHGUI_Displayer.h>
|
2015-07-22 20:13:50 +05:00
|
|
|
#include <SMESHGUI_VTKUtils.h>
|
|
|
|
#include <SMESH_Actor.h>
|
2005-06-07 19:22:20 +06:00
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
// SALOME KERNEL includes
|
|
|
|
#include <Utils_ORB_INIT.hxx>
|
|
|
|
#include <Utils_SINGLETON.hxx>
|
|
|
|
#include <SALOMEDSClient_ClientFactory.hxx>
|
2005-06-07 19:22:20 +06:00
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
#include <utilities.h>
|
2003-05-19 20:07:00 +06:00
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
// SALOME GUI includes
|
|
|
|
#include <SUIT_Session.h>
|
2012-10-08 17:56:59 +06:00
|
|
|
#include <SUIT_ViewManager.h>
|
|
|
|
#include <SALOME_Prs.h>
|
|
|
|
#include <SUIT_ViewWindow.h>
|
2015-07-22 20:13:50 +05:00
|
|
|
#include <SVTK_ViewWindow.h>
|
2009-02-17 10:27:49 +05:00
|
|
|
#include <VTKViewer_ViewModel.h>
|
|
|
|
#include <SALOME_Event.h>
|
|
|
|
#include <SalomeApp_Application.h>
|
2015-07-22 20:13:50 +05:00
|
|
|
#include <LightApp_SelectionMgr.h>
|
|
|
|
#include <SVTK_RenderWindowInteractor.h>
|
2003-05-19 20:07:00 +06:00
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
// OCCT includes
|
|
|
|
#include <TopAbs.hxx>
|
2015-07-22 20:13:50 +05:00
|
|
|
#include <TColStd_MapOfInteger.hxx>
|
2003-05-19 20:07:00 +06:00
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
// Qt includes
|
|
|
|
#include <QApplication>
|
2008-03-07 12:47:05 +05:00
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
// IDL includes
|
2003-05-19 20:07:00 +06:00
|
|
|
#include <SALOMEconfig.h>
|
|
|
|
#include CORBA_SERVER_HEADER(SMESH_Gen)
|
|
|
|
#include CORBA_SERVER_HEADER(SMESH_Hypothesis)
|
|
|
|
|
2006-05-06 14:51:48 +06:00
|
|
|
static CORBA::ORB_var anORB;
|
2003-05-19 20:07:00 +06:00
|
|
|
|
2006-05-06 14:51:48 +06:00
|
|
|
namespace
|
2003-05-19 20:07:00 +06:00
|
|
|
{
|
2006-05-06 14:51:48 +06:00
|
|
|
//---------------------------------------------------------------
|
|
|
|
inline
|
|
|
|
CORBA::Object_var
|
|
|
|
StringToObject(const std::string& theIOR)
|
|
|
|
{
|
|
|
|
return anORB->string_to_object(theIOR.c_str());
|
2003-05-19 20:07:00 +06:00
|
|
|
}
|
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
|
2006-05-06 14:51:48 +06:00
|
|
|
//---------------------------------------------------------------
|
|
|
|
inline
|
|
|
|
SALOMEDS::SObject_var
|
|
|
|
GetDomainRoot(const SALOMEDS::SComponent_var& theSComponentMesh,
|
2012-08-09 16:03:55 +06:00
|
|
|
const SALOMEDS::StudyBuilder_var& theStudyBuilder,
|
|
|
|
CORBA::Long theDomainRootTag,
|
|
|
|
const QString& theName,
|
|
|
|
const QString& thePixmap)
|
2006-05-06 14:51:48 +06:00
|
|
|
{
|
|
|
|
SALOMEDS::SObject_var aDomainRoot;
|
|
|
|
if (!theSComponentMesh->FindSubObject(theDomainRootTag,aDomainRoot)) {
|
|
|
|
aDomainRoot = theStudyBuilder->NewObjectToTag(theSComponentMesh,theDomainRootTag);
|
|
|
|
SALOMEDS::GenericAttribute_var anAttr = theStudyBuilder->FindOrCreateAttribute(aDomainRoot,"AttributeName");
|
|
|
|
SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
|
2009-02-17 10:27:49 +05:00
|
|
|
aName->SetValue(theName.toLatin1().data());
|
2013-02-12 20:37:44 +06:00
|
|
|
aName->UnRegister();
|
2006-05-06 14:51:48 +06:00
|
|
|
anAttr = theStudyBuilder->FindOrCreateAttribute(aDomainRoot,"AttributePixMap");
|
|
|
|
SALOMEDS::AttributePixMap_var aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
|
2009-02-17 10:27:49 +05:00
|
|
|
aPixmap->SetPixMap(thePixmap.toLatin1().data());
|
2013-02-12 20:37:44 +06:00
|
|
|
aPixmap->UnRegister();
|
2006-05-06 14:51:48 +06:00
|
|
|
anAttr = theStudyBuilder->FindOrCreateAttribute(aDomainRoot,"AttributeSelectable");
|
|
|
|
SALOMEDS::AttributeSelectable_var aSelAttr = SALOMEDS::AttributeSelectable::_narrow(anAttr);
|
|
|
|
aSelAttr->SetSelectable(false);
|
2013-02-12 20:37:44 +06:00
|
|
|
aSelAttr->UnRegister();
|
2006-05-06 14:51:48 +06:00
|
|
|
}
|
2004-06-18 14:34:31 +06:00
|
|
|
|
2006-05-06 14:51:48 +06:00
|
|
|
return aDomainRoot;
|
|
|
|
}
|
2004-06-18 14:34:31 +06:00
|
|
|
|
2003-05-19 20:07:00 +06:00
|
|
|
|
2006-05-06 14:51:48 +06:00
|
|
|
//---------------------------------------------------------------
|
|
|
|
inline
|
|
|
|
SALOMEDS::SObject_var
|
|
|
|
GetHypothesisRoot(const SALOMEDS::SComponent_var& theSComponentMesh,
|
2012-08-09 16:03:55 +06:00
|
|
|
const SALOMEDS::StudyBuilder_var& theStudyBuilder)
|
2006-05-06 14:51:48 +06:00
|
|
|
{
|
|
|
|
return GetDomainRoot(theSComponentMesh,
|
2012-08-09 16:03:55 +06:00
|
|
|
theStudyBuilder,
|
|
|
|
SMESH::Tag_HypothesisRoot,
|
|
|
|
QObject::tr("SMESH_MEN_HYPOTHESIS"),
|
|
|
|
"ICON_SMESH_TREE_HYPO");
|
2006-05-06 14:51:48 +06:00
|
|
|
}
|
2008-03-07 12:47:05 +05:00
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
|
2006-05-06 14:51:48 +06:00
|
|
|
//---------------------------------------------------------------
|
|
|
|
inline
|
|
|
|
SALOMEDS::SObject_var
|
|
|
|
GetAlgorithmsRoot(const SALOMEDS::SComponent_var& theSComponentMesh,
|
2012-08-09 16:03:55 +06:00
|
|
|
const SALOMEDS::StudyBuilder_var& theStudyBuilder)
|
2006-05-06 14:51:48 +06:00
|
|
|
{
|
|
|
|
return GetDomainRoot(theSComponentMesh,
|
2012-08-09 16:03:55 +06:00
|
|
|
theStudyBuilder,
|
|
|
|
SMESH::Tag_AlgorithmsRoot,
|
|
|
|
QObject::tr("SMESH_MEN_ALGORITHMS"),
|
|
|
|
"ICON_SMESH_TREE_ALGO");
|
2006-05-06 14:51:48 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------
|
|
|
|
inline
|
|
|
|
SALOMEDS::SObject_var
|
2013-02-12 20:37:44 +06:00
|
|
|
AddToDomain(const std::string& theIOR,
|
|
|
|
const SALOMEDS::SComponent_var& theSComponentMesh,
|
2012-08-09 16:03:55 +06:00
|
|
|
const SALOMEDS::StudyBuilder_var& theStudyBuilder,
|
2013-02-12 20:37:44 +06:00
|
|
|
CORBA::Long theDomainRootTag,
|
|
|
|
const QString& theDomainName,
|
|
|
|
const QString& theDomainPixmap)
|
2006-05-06 14:51:48 +06:00
|
|
|
{
|
|
|
|
SALOMEDS::SObject_var aDomain = GetDomainRoot(theSComponentMesh,
|
2012-08-09 16:03:55 +06:00
|
|
|
theStudyBuilder,
|
|
|
|
SMESH::Tag_AlgorithmsRoot,
|
|
|
|
theDomainName,
|
|
|
|
theDomainPixmap);
|
2006-05-06 14:51:48 +06:00
|
|
|
// Add New Hypothesis
|
|
|
|
SALOMEDS::SObject_var aSObject = theStudyBuilder->NewObject(aDomain);
|
2013-02-12 20:37:44 +06:00
|
|
|
aDomain->UnRegister();
|
2006-05-06 14:51:48 +06:00
|
|
|
SALOMEDS::GenericAttribute_var anAttr = theStudyBuilder->FindOrCreateAttribute(aSObject,"AttributePixMap");
|
|
|
|
SALOMEDS::AttributePixMap_var aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
|
|
|
|
CORBA::Object_var anObject = StringToObject(theIOR);
|
|
|
|
SMESH::SMESH_Hypothesis_var aDomainItem = SMESH::SMESH_Hypothesis::_narrow(anObject.in());
|
|
|
|
CORBA::String_var aType = aDomainItem->GetName();
|
|
|
|
QString aPixmapName = theDomainPixmap + "_" + aType.in();
|
2009-02-17 10:27:49 +05:00
|
|
|
aPixmap->SetPixMap(aPixmapName.toLatin1().data());
|
2013-02-12 20:37:44 +06:00
|
|
|
aPixmap->UnRegister();
|
2006-05-06 14:51:48 +06:00
|
|
|
anAttr = theStudyBuilder->FindOrCreateAttribute(aSObject,"AttributeIOR");
|
|
|
|
SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
|
|
|
|
anIOR->SetValue(theIOR.c_str());
|
2013-02-12 20:37:44 +06:00
|
|
|
anIOR->UnRegister();
|
2008-03-07 12:47:05 +05:00
|
|
|
|
2006-05-06 14:51:48 +06:00
|
|
|
return aSObject;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------
|
|
|
|
SALOMEDS::SObject_var
|
|
|
|
AddHypothesis(const std::string& theIOR,
|
2012-08-09 16:03:55 +06:00
|
|
|
const SALOMEDS::SComponent_var& theSComponentMesh,
|
|
|
|
const SALOMEDS::StudyBuilder_var& theStudyBuilder)
|
2006-05-06 14:51:48 +06:00
|
|
|
{
|
|
|
|
return AddToDomain(theIOR,
|
2012-08-09 16:03:55 +06:00
|
|
|
theSComponentMesh,
|
|
|
|
theStudyBuilder,
|
|
|
|
SMESH::Tag_HypothesisRoot,
|
|
|
|
QObject::tr("SMESH_MEN_HYPOTHESIS"),
|
|
|
|
"ICON_SMESH_TREE_HYPO");
|
2006-05-06 14:51:48 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------
|
|
|
|
SALOMEDS::SObject_var
|
|
|
|
AddAlgorithms(const std::string& theIOR,
|
2012-08-09 16:03:55 +06:00
|
|
|
const SALOMEDS::SComponent_var& theSComponentMesh,
|
|
|
|
const SALOMEDS::StudyBuilder_var& theStudyBuilder)
|
2006-05-06 14:51:48 +06:00
|
|
|
{
|
|
|
|
return AddToDomain(theIOR,
|
2012-08-09 16:03:55 +06:00
|
|
|
theSComponentMesh,
|
|
|
|
theStudyBuilder,
|
|
|
|
SMESH::Tag_AlgorithmsRoot,
|
|
|
|
QObject::tr("SMESH_MEN_ALGORITHMS"),
|
|
|
|
"ICON_SMESH_TREE_ALGO");
|
2006-05-06 14:51:48 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------
|
|
|
|
void
|
2013-02-12 20:37:44 +06:00
|
|
|
SetDomain(const char* theMeshOrSubMeshEntry,
|
|
|
|
const char* theDomainEntry,
|
|
|
|
const SALOMEDS::Study_var& theStudy,
|
2012-08-09 16:03:55 +06:00
|
|
|
const SALOMEDS::StudyBuilder_var& theStudyBuilder,
|
2013-02-12 20:37:44 +06:00
|
|
|
long theRefOnAppliedDomainTag,
|
|
|
|
const QString& theAppliedDomainMEN,
|
|
|
|
const QString& theAppliedDomainICON)
|
2006-05-06 14:51:48 +06:00
|
|
|
{
|
|
|
|
SALOMEDS::SObject_var aMeshOrSubMeshSO = theStudy->FindObjectID(theMeshOrSubMeshEntry);
|
2013-02-12 20:37:44 +06:00
|
|
|
SALOMEDS::SObject_var aHypothesisSO = theStudy->FindObjectID(theDomainEntry);
|
2006-05-06 14:51:48 +06:00
|
|
|
|
|
|
|
if(!aMeshOrSubMeshSO->_is_nil() && !aHypothesisSO->_is_nil()){
|
|
|
|
//Find or Create Applied Hypothesis root
|
|
|
|
SALOMEDS::SObject_var anAppliedDomainSO;
|
2013-02-12 20:37:44 +06:00
|
|
|
if( !aMeshOrSubMeshSO->FindSubObject( theRefOnAppliedDomainTag, anAppliedDomainSO ))
|
|
|
|
{
|
2012-08-09 16:03:55 +06:00
|
|
|
anAppliedDomainSO = theStudyBuilder->NewObjectToTag(aMeshOrSubMeshSO,theRefOnAppliedDomainTag);
|
|
|
|
SALOMEDS::GenericAttribute_var anAttr =
|
|
|
|
theStudyBuilder->FindOrCreateAttribute(anAppliedDomainSO,"AttributeName");
|
|
|
|
SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
|
|
|
|
aName->SetValue(theAppliedDomainMEN.toLatin1().data());
|
2013-02-12 20:37:44 +06:00
|
|
|
aName->UnRegister();
|
2012-08-09 16:03:55 +06:00
|
|
|
anAttr = theStudyBuilder->FindOrCreateAttribute(anAppliedDomainSO,"AttributeSelectable");
|
|
|
|
SALOMEDS::AttributeSelectable_var aSelAttr = SALOMEDS::AttributeSelectable::_narrow(anAttr);
|
|
|
|
aSelAttr->SetSelectable(false);
|
2013-02-12 20:37:44 +06:00
|
|
|
aSelAttr->UnRegister();
|
2012-08-09 16:03:55 +06:00
|
|
|
anAttr = theStudyBuilder->FindOrCreateAttribute(anAppliedDomainSO,"AttributePixMap");
|
|
|
|
SALOMEDS::AttributePixMap_var aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
|
|
|
|
aPixmap->SetPixMap(theAppliedDomainICON.toLatin1().data());
|
2013-02-12 20:37:44 +06:00
|
|
|
aPixmap->UnRegister();
|
2005-06-22 17:27:49 +06:00
|
|
|
}
|
2006-05-06 14:51:48 +06:00
|
|
|
SALOMEDS::SObject_var aSObject = theStudyBuilder->NewObject(anAppliedDomainSO);
|
|
|
|
theStudyBuilder->Addreference(aSObject,aHypothesisSO);
|
2013-02-12 20:37:44 +06:00
|
|
|
aSObject->UnRegister();
|
|
|
|
anAppliedDomainSO->UnRegister();
|
2006-05-06 14:51:48 +06:00
|
|
|
}
|
2013-02-12 20:37:44 +06:00
|
|
|
if ( !aMeshOrSubMeshSO->_is_nil() ) aMeshOrSubMeshSO->UnRegister();
|
|
|
|
if ( !aHypothesisSO->_is_nil()) aHypothesisSO->UnRegister();
|
2003-05-19 20:07:00 +06:00
|
|
|
}
|
2004-03-16 17:51:43 +05:00
|
|
|
|
2006-05-06 14:51:48 +06:00
|
|
|
|
|
|
|
//---------------------------------------------------------------
|
|
|
|
void
|
2013-02-12 20:37:44 +06:00
|
|
|
SetHypothesis(const char* theMeshOrSubMeshEntry,
|
|
|
|
const char* theDomainEntry,
|
|
|
|
const SALOMEDS::Study_var& theStudy,
|
2012-08-09 16:03:55 +06:00
|
|
|
const SALOMEDS::StudyBuilder_var& theStudyBuilder)
|
2006-05-06 14:51:48 +06:00
|
|
|
{
|
|
|
|
SetDomain(theMeshOrSubMeshEntry,
|
2012-08-09 16:03:55 +06:00
|
|
|
theDomainEntry,
|
|
|
|
theStudy,
|
|
|
|
theStudyBuilder,
|
|
|
|
SMESH::Tag_RefOnAppliedHypothesis,
|
|
|
|
QObject::tr("SMESH_MEN_APPLIED_HYPOTHESIS"),
|
|
|
|
"ICON_SMESH_TREE_HYPO");
|
2006-05-06 14:51:48 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------
|
|
|
|
void
|
2013-02-12 20:37:44 +06:00
|
|
|
SetAlgorithms(const char* theMeshOrSubMeshEntry,
|
|
|
|
const char* theDomainEntry,
|
|
|
|
const SALOMEDS::Study_var& theStudy,
|
2012-08-09 16:03:55 +06:00
|
|
|
const SALOMEDS::StudyBuilder_var& theStudyBuilder)
|
2006-05-06 14:51:48 +06:00
|
|
|
{
|
|
|
|
SetDomain(theMeshOrSubMeshEntry,
|
2012-08-09 16:03:55 +06:00
|
|
|
theDomainEntry,
|
|
|
|
theStudy,
|
|
|
|
theStudyBuilder,
|
|
|
|
SMESH::Tag_RefOnAppliedAlgorithms,
|
|
|
|
QObject::tr("SMESH_MEN_APPLIED_ALGORIHTMS"),
|
|
|
|
"ICON_SMESH_TREE_ALGO");
|
2006-05-06 14:51:48 +06:00
|
|
|
}
|
2003-05-19 20:07:00 +06:00
|
|
|
}
|
|
|
|
|
2006-05-06 14:51:48 +06:00
|
|
|
|
|
|
|
//===============================================================
|
|
|
|
SMESH_Swig::SMESH_Swig()
|
|
|
|
{
|
|
|
|
class TEvent: public SALOME_Event
|
|
|
|
{
|
|
|
|
CORBA::ORB_var& myORB;
|
|
|
|
public:
|
|
|
|
|
|
|
|
TEvent(CORBA::ORB_var& theORB):
|
|
|
|
myORB(theORB)
|
|
|
|
{}
|
|
|
|
|
|
|
|
virtual
|
|
|
|
void
|
|
|
|
Execute()
|
|
|
|
{
|
|
|
|
try {
|
2012-08-09 16:03:55 +06:00
|
|
|
ORB_INIT &anORBInit = *SINGLETON_<ORB_INIT>::Instance();
|
|
|
|
ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting());
|
|
|
|
myORB = anORBInit( 0, 0 );
|
2006-05-06 14:51:48 +06:00
|
|
|
} catch (...) {
|
2012-08-09 16:03:55 +06:00
|
|
|
INFOS("internal error : orb not found");
|
2006-05-06 14:51:48 +06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-09-08 21:01:15 +05:00
|
|
|
//MESSAGE("Constructeur");
|
2006-05-06 14:51:48 +06:00
|
|
|
|
|
|
|
if(CORBA::is_nil(anORB))
|
|
|
|
ProcessVoidEvent(new TEvent(anORB));
|
|
|
|
|
|
|
|
ASSERT(!CORBA::is_nil(anORB));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//===============================================================
|
|
|
|
void
|
|
|
|
SMESH_Swig::Init(int theStudyID)
|
|
|
|
{
|
|
|
|
class TEvent: public SALOME_Event
|
|
|
|
{
|
2013-02-12 20:37:44 +06:00
|
|
|
int myStudyID;
|
|
|
|
SALOMEDS::Study_var& myStudy;
|
2006-05-06 14:51:48 +06:00
|
|
|
SALOMEDS::StudyBuilder_var& myStudyBuilder;
|
2013-02-12 20:37:44 +06:00
|
|
|
SALOMEDS::SComponent_var& mySComponentMesh;
|
2006-05-06 14:51:48 +06:00
|
|
|
public:
|
2013-02-12 20:37:44 +06:00
|
|
|
TEvent(int theStudyID,
|
|
|
|
SALOMEDS::Study_var& theStudy,
|
2012-08-09 16:03:55 +06:00
|
|
|
SALOMEDS::StudyBuilder_var& theStudyBuilder,
|
2013-02-12 20:37:44 +06:00
|
|
|
SALOMEDS::SComponent_var& theSComponentMesh):
|
|
|
|
myStudyID (theStudyID),
|
|
|
|
myStudy (theStudy),
|
|
|
|
myStudyBuilder (theStudyBuilder),
|
2006-05-06 14:51:48 +06:00
|
|
|
mySComponentMesh(theSComponentMesh)
|
|
|
|
{}
|
|
|
|
|
2013-02-12 20:37:44 +06:00
|
|
|
~TEvent()
|
|
|
|
{
|
|
|
|
if ( !mySComponentMesh->_is_nil() ) mySComponentMesh->UnRegister();
|
|
|
|
}
|
|
|
|
|
2006-05-06 14:51:48 +06:00
|
|
|
virtual
|
|
|
|
void
|
|
|
|
Execute()
|
|
|
|
{
|
2013-02-12 20:37:44 +06:00
|
|
|
SUIT_Session* aSession = SUIT_Session::session();
|
2006-05-06 14:51:48 +06:00
|
|
|
SUIT_Application* anApplication = aSession->activeApplication();
|
2013-02-12 20:37:44 +06:00
|
|
|
SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>(anApplication);
|
2006-05-06 14:51:48 +06:00
|
|
|
|
|
|
|
SALOME_NamingService* aNamingService = anApp->namingService();
|
2013-02-12 20:37:44 +06:00
|
|
|
CORBA::Object_var anObject = aNamingService->Resolve("/myStudyManager");
|
2006-05-06 14:51:48 +06:00
|
|
|
SALOMEDS::StudyManager_var aStudyMgr = SALOMEDS::StudyManager::_narrow(anObject);
|
|
|
|
myStudy = aStudyMgr->GetStudyByID(myStudyID);
|
|
|
|
|
|
|
|
SMESH::SMESH_Gen_var aSMESHGen = SMESHGUI::GetSMESHGen();
|
2008-03-07 12:47:05 +05:00
|
|
|
aSMESHGen->SetCurrentStudy( myStudy.in() );
|
2006-05-06 14:51:48 +06:00
|
|
|
|
|
|
|
myStudyBuilder = myStudy->NewBuilder();
|
|
|
|
|
|
|
|
SALOMEDS::GenericAttribute_var anAttr;
|
|
|
|
SALOMEDS::AttributeName_var aName;
|
|
|
|
SALOMEDS::AttributePixMap_var aPixmap;
|
|
|
|
|
|
|
|
SALOMEDS::SComponent_var aSComponent = myStudy->FindComponent("SMESH");
|
2013-02-12 20:37:44 +06:00
|
|
|
if ( aSComponent->_is_nil() )
|
|
|
|
{
|
2012-08-09 16:03:55 +06:00
|
|
|
bool aLocked = myStudy->GetProperties()->IsLocked();
|
|
|
|
if (aLocked)
|
|
|
|
myStudy->GetProperties()->SetLocked(false);
|
|
|
|
|
2013-02-12 20:37:44 +06:00
|
|
|
SMESHGUI* aSMESHGUI = SMESHGUI::GetSMESHGUI();
|
|
|
|
//SRN: BugID IPAL9186, load a SMESH gui if it hasn't been loaded
|
|
|
|
if (!aSMESHGUI) {
|
2012-08-09 16:03:55 +06:00
|
|
|
CAM_Module* aModule = anApp->module("Mesh");
|
|
|
|
if(!aModule)
|
2013-02-12 20:37:44 +06:00
|
|
|
aModule = anApp->loadModule("Mesh");
|
2012-08-09 16:03:55 +06:00
|
|
|
aSMESHGUI = dynamic_cast<SMESHGUI*>(aModule);
|
|
|
|
} //SRN: BugID IPAL9186: end of a fix
|
2013-02-12 20:37:44 +06:00
|
|
|
|
|
|
|
aSComponent = myStudyBuilder->NewComponent("SMESH");
|
|
|
|
|
|
|
|
anAttr = myStudyBuilder->FindOrCreateAttribute(aSComponent,"AttributeName");
|
|
|
|
aName = SALOMEDS::AttributeName::_narrow(anAttr);
|
2012-08-09 16:03:55 +06:00
|
|
|
aName->SetValue(aSMESHGUI->moduleName().toLatin1().data());
|
2013-02-12 20:37:44 +06:00
|
|
|
aName->UnRegister();
|
|
|
|
|
2012-08-09 16:03:55 +06:00
|
|
|
anAttr = myStudyBuilder->FindOrCreateAttribute(aSComponent,"AttributePixMap");
|
|
|
|
aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
|
|
|
|
aPixmap->SetPixMap( "ICON_OBJBROWSER_SMESH" );
|
2013-02-12 20:37:44 +06:00
|
|
|
aPixmap->UnRegister();
|
|
|
|
|
2013-09-26 14:44:08 +06:00
|
|
|
SALOMEDS::UseCaseBuilder_var useCaseBuilder = myStudy->GetUseCaseBuilder();
|
|
|
|
useCaseBuilder->SetRootCurrent();
|
|
|
|
useCaseBuilder->Append( aSComponent.in() );
|
2013-08-28 17:00:25 +06:00
|
|
|
|
2012-08-09 16:03:55 +06:00
|
|
|
myStudyBuilder->DefineComponentInstance(aSComponent,aSMESHGen);
|
|
|
|
if (aLocked)
|
|
|
|
myStudy->GetProperties()->SetLocked(true);
|
2006-05-06 14:51:48 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
mySComponentMesh = SALOMEDS::SComponent::_narrow(aSComponent);
|
2008-03-07 12:47:05 +05:00
|
|
|
|
|
|
|
qApp->processEvents(); // Workaround for bug 12662
|
2006-05-06 14:51:48 +06:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-09-08 21:01:15 +05:00
|
|
|
//MESSAGE("Init");
|
2006-05-06 14:51:48 +06:00
|
|
|
|
|
|
|
ProcessVoidEvent(new TEvent(theStudyID,
|
2012-08-09 16:03:55 +06:00
|
|
|
myStudy,
|
|
|
|
myStudyBuilder,
|
|
|
|
mySComponentMesh));
|
2006-05-06 14:51:48 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//===============================================================
|
2003-05-19 20:07:00 +06:00
|
|
|
SMESH_Swig::~SMESH_Swig()
|
|
|
|
{
|
2016-09-08 21:01:15 +05:00
|
|
|
//MESSAGE("Destructeur");
|
2003-05-19 20:07:00 +06:00
|
|
|
}
|
|
|
|
|
2006-05-06 14:51:48 +06:00
|
|
|
|
|
|
|
//===============================================================
|
2008-03-07 12:47:05 +05:00
|
|
|
const char* SMESH_Swig::AddNewMesh(const char* theIOR)
|
2003-05-19 20:07:00 +06:00
|
|
|
{
|
2004-06-18 14:34:31 +06:00
|
|
|
|
|
|
|
// VSR: added temporarily - to be removed - objects are published automatically by engine
|
2006-05-06 14:51:48 +06:00
|
|
|
SALOMEDS::SObject_var aSObject = myStudy->FindObjectIOR(theIOR);
|
2013-02-12 20:37:44 +06:00
|
|
|
if (aSObject->_is_nil())
|
|
|
|
{
|
2006-05-06 14:51:48 +06:00
|
|
|
//Find or Create Hypothesis root
|
2013-02-12 20:37:44 +06:00
|
|
|
SALOMEDS::SObject_var hroot = GetHypothesisRoot(mySComponentMesh,myStudyBuilder);
|
|
|
|
SALOMEDS::SObject_var aroot = GetAlgorithmsRoot(mySComponentMesh,myStudyBuilder);
|
|
|
|
hroot->UnRegister();
|
|
|
|
aroot->UnRegister();
|
2008-03-07 12:47:05 +05:00
|
|
|
|
2006-05-06 14:51:48 +06:00
|
|
|
// Add New Mesh
|
|
|
|
aSObject = myStudyBuilder->NewObject(mySComponentMesh);
|
|
|
|
SALOMEDS::GenericAttribute_var anAttr = myStudyBuilder->FindOrCreateAttribute(aSObject,"AttributePixMap");
|
|
|
|
SALOMEDS::AttributePixMap_var aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
|
|
|
|
aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH" );
|
2013-02-12 20:37:44 +06:00
|
|
|
aPixmap->UnRegister();
|
|
|
|
|
2006-05-06 14:51:48 +06:00
|
|
|
anAttr = myStudyBuilder->FindOrCreateAttribute(aSObject, "AttributeIOR");
|
|
|
|
SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
|
|
|
|
anIOR->SetValue(theIOR);
|
2013-02-12 20:37:44 +06:00
|
|
|
anIOR->UnRegister();
|
2003-05-19 20:07:00 +06:00
|
|
|
}
|
|
|
|
|
2006-05-06 14:51:48 +06:00
|
|
|
CORBA::String_var anEntry = aSObject->GetID();
|
2013-02-12 20:37:44 +06:00
|
|
|
aSObject->UnRegister();
|
2003-05-19 20:07:00 +06:00
|
|
|
|
2006-05-06 14:51:48 +06:00
|
|
|
return anEntry._retn();
|
2003-05-19 20:07:00 +06:00
|
|
|
}
|
|
|
|
|
2006-05-06 14:51:48 +06:00
|
|
|
|
|
|
|
//===============================================================
|
2008-03-07 12:47:05 +05:00
|
|
|
const char* SMESH_Swig::AddNewHypothesis(const char* theIOR)
|
2003-05-19 20:07:00 +06:00
|
|
|
{
|
2006-05-06 14:51:48 +06:00
|
|
|
SALOMEDS::SObject_var aSObject = ::AddHypothesis(theIOR,
|
2012-08-09 16:03:55 +06:00
|
|
|
mySComponentMesh,
|
|
|
|
myStudyBuilder);
|
2006-05-06 14:51:48 +06:00
|
|
|
CORBA::String_var anEntry = aSObject->GetID();
|
2013-02-12 20:37:44 +06:00
|
|
|
aSObject->UnRegister();
|
|
|
|
|
2006-05-06 14:51:48 +06:00
|
|
|
return anEntry._retn();
|
2003-05-19 20:07:00 +06:00
|
|
|
}
|
|
|
|
|
2006-05-06 14:51:48 +06:00
|
|
|
|
|
|
|
//===============================================================
|
2008-03-07 12:47:05 +05:00
|
|
|
const char* SMESH_Swig::AddNewAlgorithms(const char* theIOR)
|
2003-05-19 20:07:00 +06:00
|
|
|
{
|
2006-05-06 14:51:48 +06:00
|
|
|
SALOMEDS::SObject_var aSObject = ::AddAlgorithms(theIOR,
|
2012-08-09 16:03:55 +06:00
|
|
|
mySComponentMesh,
|
|
|
|
myStudyBuilder);
|
2006-05-06 14:51:48 +06:00
|
|
|
CORBA::String_var anEntry = aSObject->GetID();
|
2013-02-12 20:37:44 +06:00
|
|
|
aSObject->UnRegister();
|
|
|
|
|
2006-05-06 14:51:48 +06:00
|
|
|
return anEntry._retn();
|
2003-05-19 20:07:00 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-05-06 14:51:48 +06:00
|
|
|
//===============================================================
|
2008-03-07 12:47:05 +05:00
|
|
|
void SMESH_Swig::SetShape(const char* theShapeEntry,
|
|
|
|
const char* theMeshEntry)
|
2006-05-06 14:51:48 +06:00
|
|
|
{
|
|
|
|
SALOMEDS::SObject_var aGeomShapeSO = myStudy->FindObjectID( theShapeEntry );
|
2013-02-12 20:37:44 +06:00
|
|
|
SALOMEDS::SObject_var aMeshSO = myStudy->FindObjectID( theMeshEntry );
|
2008-03-07 12:47:05 +05:00
|
|
|
|
2006-05-06 14:51:48 +06:00
|
|
|
if(!aMeshSO->_is_nil() && !aGeomShapeSO->_is_nil()){
|
2008-03-07 12:47:05 +05:00
|
|
|
SALOMEDS::SObject_var aSObject = myStudyBuilder->NewObjectToTag(aMeshSO, SMESH::Tag_RefOnShape);
|
2006-05-06 14:51:48 +06:00
|
|
|
myStudyBuilder->Addreference(aSObject,aGeomShapeSO);
|
2013-02-12 20:37:44 +06:00
|
|
|
aSObject->UnRegister();
|
2003-05-19 20:07:00 +06:00
|
|
|
}
|
2013-02-12 20:37:44 +06:00
|
|
|
if ( !aMeshSO->_is_nil() ) aMeshSO->UnRegister();
|
|
|
|
if ( !aGeomShapeSO->_is_nil() ) aGeomShapeSO->UnRegister();
|
2003-05-19 20:07:00 +06:00
|
|
|
}
|
|
|
|
|
2006-05-06 14:51:48 +06:00
|
|
|
|
|
|
|
//===============================================================
|
2008-03-07 12:47:05 +05:00
|
|
|
void SMESH_Swig::SetHypothesis(const char* theMeshOrSubMeshEntry,
|
|
|
|
const char* theDomainEntry)
|
2003-05-19 20:07:00 +06:00
|
|
|
{
|
2006-05-06 14:51:48 +06:00
|
|
|
::SetHypothesis(theMeshOrSubMeshEntry,
|
2012-08-09 16:03:55 +06:00
|
|
|
theDomainEntry,
|
|
|
|
myStudy,
|
|
|
|
myStudyBuilder);
|
2003-05-19 20:07:00 +06:00
|
|
|
}
|
2005-07-07 13:28:57 +06:00
|
|
|
|
2006-05-06 14:51:48 +06:00
|
|
|
|
|
|
|
//===============================================================
|
2008-03-07 12:47:05 +05:00
|
|
|
void SMESH_Swig::SetAlgorithms(const char* theMeshOrSubMeshEntry,
|
|
|
|
const char* theDomainEntry)
|
2003-05-19 20:07:00 +06:00
|
|
|
{
|
2006-05-06 14:51:48 +06:00
|
|
|
::SetAlgorithms(theMeshOrSubMeshEntry,
|
2012-08-09 16:03:55 +06:00
|
|
|
theDomainEntry,
|
|
|
|
myStudy,
|
|
|
|
myStudyBuilder);
|
2003-05-19 20:07:00 +06:00
|
|
|
}
|
|
|
|
|
2006-05-06 14:51:48 +06:00
|
|
|
|
|
|
|
//===============================================================
|
|
|
|
void
|
|
|
|
SMESH_Swig::UnSetHypothesis(const char* theDomainEntry)
|
2003-05-19 20:07:00 +06:00
|
|
|
{
|
2006-05-06 14:51:48 +06:00
|
|
|
SALOMEDS::SObject_var aDomainSO = myStudy->FindObjectID(theDomainEntry);
|
|
|
|
if(!aDomainSO->_is_nil())
|
|
|
|
myStudyBuilder->RemoveObject(aDomainSO);
|
2003-05-19 20:07:00 +06:00
|
|
|
}
|
|
|
|
|
2008-03-07 12:47:05 +05:00
|
|
|
const char* SMESH_Swig::AddSubMesh(const char* theMeshEntry,
|
|
|
|
const char* theSubMeshIOR,
|
|
|
|
int theShapeType)
|
2003-05-19 20:07:00 +06:00
|
|
|
{
|
2006-05-06 14:51:48 +06:00
|
|
|
SALOMEDS::SObject_var aMeshSO = myStudy->FindObjectID(theMeshEntry);
|
2013-02-12 20:37:44 +06:00
|
|
|
if(!aMeshSO->_is_nil()) {
|
2006-05-06 14:51:48 +06:00
|
|
|
long aShapeTag;
|
|
|
|
QString aSubMeshName;
|
2013-02-12 20:37:44 +06:00
|
|
|
switch(theShapeType) {
|
2006-05-06 14:51:48 +06:00
|
|
|
case TopAbs_SOLID:
|
2013-02-12 20:37:44 +06:00
|
|
|
aShapeTag = SMESH::Tag_SubMeshOnSolid;
|
2006-05-06 14:51:48 +06:00
|
|
|
aSubMeshName = QObject::tr("SMESH_MEN_SubMeshesOnSolid");
|
|
|
|
break;
|
|
|
|
case TopAbs_FACE:
|
2013-02-12 20:37:44 +06:00
|
|
|
aShapeTag = SMESH::Tag_SubMeshOnFace;
|
2006-05-06 14:51:48 +06:00
|
|
|
aSubMeshName = QObject::tr("SMESH_MEN_SubMeshesOnFace");
|
|
|
|
break;
|
|
|
|
case TopAbs_EDGE:
|
2013-02-12 20:37:44 +06:00
|
|
|
aShapeTag = SMESH::Tag_SubMeshOnEdge;
|
2006-05-06 14:51:48 +06:00
|
|
|
aSubMeshName = QObject::tr("SMESH_MEN_SubMeshesOnEdge");
|
|
|
|
break;
|
|
|
|
case TopAbs_VERTEX:
|
2013-02-12 20:37:44 +06:00
|
|
|
aShapeTag = SMESH::Tag_SubMeshOnVertex;
|
2006-05-06 14:51:48 +06:00
|
|
|
aSubMeshName = QObject::tr("SMESH_MEN_SubMeshesOnVertex");
|
|
|
|
break;
|
|
|
|
default:
|
2013-02-12 20:37:44 +06:00
|
|
|
aShapeTag = SMESH::Tag_SubMeshOnCompound;
|
2008-03-07 12:47:05 +05:00
|
|
|
aSubMeshName = QObject::tr("SMESH_MEN_SubMeshesOnCompound");
|
2003-05-19 20:07:00 +06:00
|
|
|
}
|
2008-03-07 12:47:05 +05:00
|
|
|
|
2006-05-06 14:51:48 +06:00
|
|
|
SALOMEDS::GenericAttribute_var anAttr;
|
2013-02-12 20:37:44 +06:00
|
|
|
SALOMEDS::SObject_var aSubMeshesRoot;
|
|
|
|
if ( !aMeshSO->FindSubObject( aShapeTag, aSubMeshesRoot ) )
|
|
|
|
{
|
2006-05-06 14:51:48 +06:00
|
|
|
aSubMeshesRoot = myStudyBuilder->NewObjectToTag(aMeshSO,aShapeTag);
|
|
|
|
anAttr = myStudyBuilder->FindOrCreateAttribute(aSubMeshesRoot,"AttributeName");
|
|
|
|
SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
|
2009-02-17 10:27:49 +05:00
|
|
|
aName->SetValue(aSubMeshName.toLatin1().data());
|
2013-02-12 20:37:44 +06:00
|
|
|
aName->UnRegister();
|
2006-05-06 14:51:48 +06:00
|
|
|
anAttr = myStudyBuilder->FindOrCreateAttribute(aSubMeshesRoot,"AttributeSelectable");
|
|
|
|
SALOMEDS::AttributeSelectable_var aSelAttr = SALOMEDS::AttributeSelectable::_narrow(anAttr);
|
2003-05-19 20:07:00 +06:00
|
|
|
aSelAttr->SetSelectable(false);
|
2013-02-12 20:37:44 +06:00
|
|
|
aSelAttr->UnRegister();
|
2003-05-19 20:07:00 +06:00
|
|
|
}
|
2013-02-12 20:37:44 +06:00
|
|
|
aSubMeshesRoot->UnRegister();
|
|
|
|
aMeshSO->UnRegister();
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2006-05-06 14:51:48 +06:00
|
|
|
SALOMEDS::SObject_var aSObject = myStudyBuilder->NewObject(aSubMeshesRoot);
|
|
|
|
anAttr = myStudyBuilder->FindOrCreateAttribute(aSObject,"AttributeIOR");
|
|
|
|
SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
|
|
|
|
anIOR->SetValue(theSubMeshIOR);
|
2013-02-12 20:37:44 +06:00
|
|
|
anIOR->UnRegister();
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2006-05-06 14:51:48 +06:00
|
|
|
CORBA::String_var aString = aSObject->GetID();
|
2013-02-12 20:37:44 +06:00
|
|
|
aSObject->UnRegister();
|
|
|
|
|
2006-05-06 14:51:48 +06:00
|
|
|
return aString._retn();
|
2003-05-19 20:07:00 +06:00
|
|
|
}
|
2006-05-06 14:51:48 +06:00
|
|
|
|
2003-05-19 20:07:00 +06:00
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2008-03-07 12:47:05 +05:00
|
|
|
const char* SMESH_Swig::AddSubMeshOnShape(const char* theMeshEntry,
|
|
|
|
const char* theGeomShapeEntry,
|
|
|
|
const char* theSubMeshIOR,
|
2013-02-12 20:37:44 +06:00
|
|
|
int ShapeType)
|
2003-05-19 20:07:00 +06:00
|
|
|
{
|
2006-05-06 14:51:48 +06:00
|
|
|
SALOMEDS::SObject_var aGeomShapeSO = myStudy->FindObjectID(theGeomShapeEntry);
|
2013-02-12 20:37:44 +06:00
|
|
|
if(!aGeomShapeSO->_is_nil())
|
|
|
|
{
|
|
|
|
const char * aSubMeshEntry = AddSubMesh(theMeshEntry,theSubMeshIOR,ShapeType);
|
2006-05-06 14:51:48 +06:00
|
|
|
SALOMEDS::SObject_var aSubMeshSO = myStudy->FindObjectID(aSubMeshEntry);
|
2013-02-12 20:37:44 +06:00
|
|
|
if ( !aSubMeshSO->_is_nil()) {
|
|
|
|
SetShape( theGeomShapeEntry, aSubMeshEntry );
|
2006-05-06 14:51:48 +06:00
|
|
|
CORBA::String_var aString = aSubMeshSO->GetID();
|
2013-02-12 20:37:44 +06:00
|
|
|
aSubMeshSO->UnRegister();
|
2006-05-06 14:51:48 +06:00
|
|
|
return aString._retn();
|
2003-05-19 20:07:00 +06:00
|
|
|
}
|
2013-02-12 20:37:44 +06:00
|
|
|
aGeomShapeSO->UnRegister();
|
2003-05-19 20:07:00 +06:00
|
|
|
}
|
2006-05-06 14:51:48 +06:00
|
|
|
|
2003-05-19 20:07:00 +06:00
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
|
|
|
void SMESH_Swig::CreateAndDisplayActor( const char* Mesh_Entry )
|
|
|
|
{
|
|
|
|
// SMESH_Actor* Mesh = smeshGUI->ReadScript(aM);
|
2008-03-07 12:47:05 +05:00
|
|
|
class TEvent: public SALOME_Event
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
const char* _entry;
|
|
|
|
public:
|
|
|
|
TEvent(const char* Mesh_Entry) {
|
|
|
|
_entry = Mesh_Entry;
|
|
|
|
}
|
|
|
|
virtual void Execute() {
|
|
|
|
//SMESH::UpdateView(SMESH::eDisplay, _entry);
|
2013-02-12 20:37:44 +06:00
|
|
|
SUIT_Session* aSession = SUIT_Session::session();
|
2008-03-07 12:47:05 +05:00
|
|
|
SUIT_Application* anApplication = aSession->activeApplication();
|
2013-02-12 20:37:44 +06:00
|
|
|
SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>(anApplication);
|
|
|
|
/*SUIT_ViewManager* vman = */anApp->getViewManager(VTKViewer_Viewer::Type(),true);
|
|
|
|
SMESHGUI_Displayer* aDisp = new SMESHGUI_Displayer(anApp);
|
2008-03-07 12:47:05 +05:00
|
|
|
aDisp->Display(_entry,1);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
ProcessVoidEvent(new TEvent(Mesh_Entry));
|
2003-05-19 20:07:00 +06:00
|
|
|
}
|
|
|
|
|
2012-10-08 17:56:59 +06:00
|
|
|
void SMESH_Swig::EraseActor( const char* Mesh_Entry, const bool allViewers )
|
|
|
|
{
|
|
|
|
class TEvent: public SALOME_Event
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
const char* _entry;
|
2013-02-12 20:37:44 +06:00
|
|
|
bool _allViewers;
|
2012-10-08 17:56:59 +06:00
|
|
|
public:
|
|
|
|
TEvent(const char* Mesh_Entry, const bool allViewers ) {
|
|
|
|
_entry = Mesh_Entry;
|
|
|
|
_allViewers = allViewers;
|
|
|
|
}
|
|
|
|
virtual void Execute() {
|
2013-02-12 20:37:44 +06:00
|
|
|
SUIT_Session* aSession = SUIT_Session::session();
|
2012-10-08 17:56:59 +06:00
|
|
|
SUIT_Application* anApplication = aSession->activeApplication();
|
2013-02-12 20:37:44 +06:00
|
|
|
SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>(anApplication);
|
|
|
|
SMESHGUI_Displayer* aDisp = new SMESHGUI_Displayer(anApp);
|
2012-10-08 17:56:59 +06:00
|
|
|
ViewManagerList aManagers;
|
|
|
|
if ( !_allViewers ) {
|
2013-02-12 20:37:44 +06:00
|
|
|
aManagers << anApp->activeViewManager();
|
2012-10-08 17:56:59 +06:00
|
|
|
}
|
|
|
|
else {
|
2013-02-12 20:37:44 +06:00
|
|
|
aManagers = anApp->viewManagers();
|
2012-10-08 17:56:59 +06:00
|
|
|
}
|
|
|
|
foreach( SUIT_ViewManager* aMgr, aManagers ) {
|
2013-02-12 20:37:44 +06:00
|
|
|
if ( aMgr && aMgr->getType() == VTKViewer_Viewer::Type() ) {
|
|
|
|
SALOME_View* aSalomeView = dynamic_cast<SALOME_View*>(aMgr->getViewModel());
|
|
|
|
if (aSalomeView) {
|
|
|
|
aDisp->Erase(_entry,true, true, aSalomeView);
|
|
|
|
}
|
|
|
|
}
|
2012-10-08 17:56:59 +06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
ProcessVoidEvent(new TEvent(Mesh_Entry, allViewers));
|
|
|
|
}
|
|
|
|
|
2008-03-07 12:47:05 +05:00
|
|
|
void SMESH_Swig::SetName(const char* theEntry,
|
|
|
|
const char* theName)
|
2003-05-19 20:07:00 +06:00
|
|
|
{
|
2006-05-06 14:51:48 +06:00
|
|
|
SALOMEDS::SObject_var aSObject = myStudy->FindObjectID(theEntry);
|
2003-05-19 20:07:00 +06:00
|
|
|
SALOMEDS::GenericAttribute_var anAttr;
|
2006-05-06 14:51:48 +06:00
|
|
|
SALOMEDS::AttributeName_var aName;
|
|
|
|
if(!aSObject->_is_nil()){
|
|
|
|
anAttr = myStudyBuilder->FindOrCreateAttribute(aSObject,"AttributeName");
|
2003-05-19 20:07:00 +06:00
|
|
|
aName = SALOMEDS::AttributeName::_narrow(anAttr);
|
2006-05-06 14:51:48 +06:00
|
|
|
aName->SetValue(theName);
|
2013-02-12 20:37:44 +06:00
|
|
|
aName->UnRegister();
|
|
|
|
aSObject->UnRegister();
|
2003-05-19 20:07:00 +06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-07-07 13:28:57 +06:00
|
|
|
//================================================================================
|
|
|
|
/*!
|
|
|
|
* \brief Set mesh icon according to compute status
|
|
|
|
* \param Mesh_Entry - entry of a mesh
|
|
|
|
* \param isComputed - is mesh computed or not
|
|
|
|
*/
|
|
|
|
//================================================================================
|
|
|
|
|
2008-03-07 12:47:05 +05:00
|
|
|
void SMESH_Swig::SetMeshIcon(const char* theMeshEntry,
|
2013-02-12 20:37:44 +06:00
|
|
|
const bool theIsComputed,
|
|
|
|
const bool isEmpty)
|
2005-07-07 13:28:57 +06:00
|
|
|
{
|
2006-05-06 14:51:48 +06:00
|
|
|
class TEvent: public SALOME_Event
|
|
|
|
{
|
|
|
|
SALOMEDS::Study_var myStudy;
|
2013-02-12 20:37:44 +06:00
|
|
|
std::string myMeshEntry;
|
|
|
|
bool myIsComputed, myIsEmpty;
|
2006-05-06 14:51:48 +06:00
|
|
|
public:
|
|
|
|
TEvent(const SALOMEDS::Study_var& theStudy,
|
2013-02-12 20:37:44 +06:00
|
|
|
const std::string& theMeshEntry,
|
|
|
|
const bool theIsComputed,
|
|
|
|
const bool isEmpty):
|
|
|
|
myStudy (theStudy),
|
|
|
|
myMeshEntry (theMeshEntry),
|
2008-03-07 12:47:05 +05:00
|
|
|
myIsComputed(theIsComputed),
|
2013-02-12 20:37:44 +06:00
|
|
|
myIsEmpty (isEmpty)
|
2006-05-06 14:51:48 +06:00
|
|
|
{}
|
|
|
|
|
|
|
|
virtual
|
|
|
|
void
|
|
|
|
Execute()
|
|
|
|
{
|
2013-02-12 20:37:44 +06:00
|
|
|
SALOMEDS::SObject_ptr aMeshSO = myStudy->FindObjectID(myMeshEntry.c_str());
|
|
|
|
if(_PTR(SObject) aMesh = ClientFactory::SObject(aMeshSO))
|
|
|
|
SMESH::ModifiedMesh(aMesh,myIsComputed,myIsEmpty);
|
|
|
|
// aMeshSO->UnRegister(); ~aMesh() already called UnRegister()!
|
2006-05-06 14:51:48 +06:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
ProcessVoidEvent(new TEvent(myStudy,
|
2012-08-09 16:03:55 +06:00
|
|
|
theMeshEntry,
|
|
|
|
theIsComputed,
|
2008-03-07 12:47:05 +05:00
|
|
|
isEmpty));
|
2005-07-07 13:28:57 +06:00
|
|
|
}
|
2015-07-22 20:13:50 +05:00
|
|
|
|
|
|
|
/*!
|
|
|
|
\brief Helper class for selection event.
|
|
|
|
*/
|
|
|
|
class TSelectListEvent: public SALOME_Event
|
|
|
|
{
|
|
|
|
const char* myId;
|
|
|
|
std::vector<int> myIdsList;
|
|
|
|
bool myIsAppend;
|
|
|
|
|
|
|
|
public:
|
|
|
|
TSelectListEvent(const char* id, std::vector<int> 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<int>::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<int> 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<int> 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() );
|
|
|
|
}
|