The GeomSelectionTools class gives high level tools to select Geom (and other objects) A specific attention has been given to analyze selected GEOM objects. More...
#include <GeomSelectionTools.h>
Public Member Functions | |
| GeomSelectionTools (_PTR(Study)) | |
| Constructor. | |
| SALOME_ListIO * | getSelectedSalomeObjects () |
| Return the list of the selected Salome Interactive Object (SALOME_ListIO*) | |
| Handle (SALOME_InteractiveObject) getFirstSelectedSalomeObject() | |
| std::string | getFirstSelectedEntry () |
| Return the entry of the first selected Object. | |
| std::string | getEntryOfObject (Handle(SALOME_InteractiveObject)) |
| Return the entry of a Salome Interactive Object. | |
| std::string | getNameFromEntry (std::string) |
| Retrieve the name from the entry of the object. | |
| std::string | getFirstSelectedComponentDataType () |
| Retrieve the component type of the first selected object, it manages successfully references. | |
| TopAbs_ShapeEnum | getFirstSelectedShapeType () |
| Gives the ShapeType of the first Selected Object, return TopAbs_SHAPE if the first selected object does not define a shape. | |
| TopAbs_ShapeEnum | entryToShapeType (std::string) |
| Retrieve the shape type from the entry. | |
| GeomAbs_SurfaceType | getFaceInformation (TopoDS_Shape) |
| Print information to std output of the face and return the OCC type of face: Plane, Cylinder,Cone, Sphere, Torus, BezierSurface,BSplineSurface, SurfaceOfRevolution,SurfaceOfExtrusion, OtherSurface. | |
| _PTR (Study) getMyStudy() | |
Static Public Member Functions | |
| static SalomeApp_Application * | GetSalomeApplication () |
| Allows to get the Salome Application. | |
| static LightApp_SelectionMgr * | selectionMgr () |
| Allows to get the selection manager from LightApp. | |
Private Member Functions | |
| _PTR (Study) myStudy | |
The GeomSelectionTools class gives high level tools to select Geom (and other objects) A specific attention has been given to analyze selected GEOM objects.
| myStudy | This class is specific to the study ! |
Definition at line 57 of file GeomSelectionTools.h.
| GeomSelectionTools::GeomSelectionTools | ( | _PTR(Study) | aStudy | ) |
Constructor.
| aStudy | pointer to the Study |
Definition at line 52 of file GeomSelectionTools.cxx.
{
myStudy = aStudy;
}
| GeomSelectionTools._PTR | ( | Study | ) | [private] |
Referenced by entryToShapeType(), getEntryOfObject(), getFirstSelectedComponentDataType(), and getNameFromEntry().
| GeomSelectionTools._PTR | ( | Study | ) |
| TopAbs_ShapeEnum GeomSelectionTools::entryToShapeType | ( | std::string | entry | ) |
Retrieve the shape type from the entry.
Definition at line 201 of file GeomSelectionTools.cxx.
References _PTR(), SMESH_fixation.aShape, and GetSalomeApplication().
Referenced by getFirstSelectedShapeType().
{
// MESSAGE("GeomSelectionTools::entryToShapeType"<<entry );
TopoDS_Shape S = TopoDS_Shape();
TopAbs_ShapeEnum ShapeType = TopAbs_SHAPE;
_PTR(SObject) aSO = myStudy->FindObjectID(entry);
if (aSO){
_PTR(SObject) aRefSObj;
GEOM::GEOM_Object_var aShape;
// MESSAGE("Got a SO");
// If selected object is a reference
if ( aSO->ReferencedObject( aRefSObj ))
aSO = aRefSObj;
// MESSAGE("aSO->GetFatherComponent()->ComponentDataType(): " << aSO->GetFatherComponent()->ComponentDataType());
if ( strcmp(aSO->GetFatherComponent()->ComponentDataType().c_str(),"GEOM") == 0)
aShape = SMESH::SObjectToInterface<GEOM::GEOM_Object>(aSO);
if ( !aShape->_is_nil() ){
// MESSAGE("Got the Geom Object ");
// MESSAGE("Geom Object Type "<< aShape->GetType());
SalomeApp_Application* anApp = GetSalomeApplication();
if (anApp) {
// MESSAGE("Got Application");
Engines::EngineComponent_var component = anApp->lcc()->FindOrLoad_Component( "FactoryServer","GEOM" );
GEOM::GEOM_Gen_var _geomEngine = GEOM::GEOM_Gen::_narrow(component);
// MESSAGE("Got GEOM engine");
// if the Geom Object is a group
if (aShape->GetType() == GEOM_GROUP){
// MESSAGE("It's a group");
GEOM::GEOM_IGroupOperations_var aGroupOp = _geomEngine->GetIGroupOperations(myStudy->StudyId());
ShapeType= (TopAbs_ShapeEnum)aGroupOp->GetType(aShape);
}
// if not
else {
GEOM_Client* aClient = new GEOM_Client();
if ( aClient && !_geomEngine->_is_nil() ) {
// MESSAGE("GEOM client is OK and GEOM engine is not null");
S = aClient->GetShape( _geomEngine, aShape );
ShapeType=S.ShapeType();
}
}
}
}
}
// MESSAGE("ShapeType returned is " << ShapeType);
return ShapeType;
}
| std::string GeomSelectionTools::getEntryOfObject | ( | Handle(SALOME_InteractiveObject) | anIO | ) |
Return the entry of a Salome Interactive Object.
| anIO | the Handle of the Salome Interactive Object |
Definition at line 139 of file GeomSelectionTools.cxx.
References _PTR().
Referenced by getFirstSelectedEntry().
{
std::string entry="";
_PTR(SObject) aSO = myStudy->FindObjectID(anIO->getEntry());
if (aSO){
_PTR(SObject) aRefSObj;
// If selected object is a reference
if ( aSO->ReferencedObject( aRefSObj ))
entry = aRefSObj->GetID();
// If selected object is a reference is not a reference
else
entry= anIO->getEntry();
}
return entry;
}
| GeomAbs_SurfaceType GeomSelectionTools::getFaceInformation | ( | TopoDS_Shape | S | ) |
Print information to std output of the face and return the OCC type of face: Plane, Cylinder,Cone, Sphere, Torus, BezierSurface,BSplineSurface, SurfaceOfRevolution,SurfaceOfExtrusion, OtherSurface.
| TopoDS_Shape | S Face we want information about. |
Definition at line 271 of file GeomSelectionTools.cxx.
References Handle().
{
GeomAbs_SurfaceType surf_type=GeomAbs_OtherSurface ;
if (!S.IsNull() && S.ShapeType()==TopAbs_FACE){
TopoDS_Face f=TopoDS::Face(S);
Handle(Geom_Surface) surf = BRep_Tool::Surface(f);
BRepAdaptor_Surface surf_adap(f);
/* Global Information */
std::cout << "GLOBAL INFORMATION" << std::endl;
std::cout << "******************" << std::endl;
std::stringstream buffer;
buffer << "Degre U : " << surf_adap.UDegree();
//conversion nécessaire pour affichage
std::cout << buffer.str() << std::endl;
std::cout << " Degre V : " << surf_adap.VDegree() << std::endl;
std::cout << " Nb Poles U : " << surf_adap.NbUPoles() << std::endl;
std::cout << " Nb Poles V : " << surf_adap.NbVPoles() << std::endl;
std::cout << " Nb Noeuds U : " << surf_adap.NbUKnots() << std::endl;
std::cout << " Nb Noeuds V : " << surf_adap.NbVKnots() << std::endl;
std::cout << " U Rationnel ? " << surf_adap.IsURational() << std::endl;
std::cout << " V Rationnel ? " << surf_adap.IsVRational() << std::endl;
surf_type=surf_adap.GetType();
}
return surf_type;
}
| std::string GeomSelectionTools::getFirstSelectedComponentDataType | ( | ) |
Retrieve the component type of the first selected object, it manages successfully references.
Definition at line 179 of file GeomSelectionTools.cxx.
References _PTR(), and Handle().
{
Handle(SALOME_InteractiveObject) anIO;
std::string DataType="";
anIO=GeomSelectionTools::getFirstSelectedSalomeObject();
_PTR(SObject) aSO = myStudy->FindObjectID(anIO->getEntry());
if (aSO){
_PTR(SObject) aRefSObj;
// If selected object is a reference
if ( aSO->ReferencedObject( aRefSObj ))
DataType= aRefSObj->GetFatherComponent()->ComponentDataType();
// If selected object is a reference is not a reference
else
DataType=anIO->getComponentDataType();
}
return DataType;
}
| std::string GeomSelectionTools::getFirstSelectedEntry | ( | ) |
Return the entry of the first selected Object.
Definition at line 126 of file GeomSelectionTools.cxx.
References getEntryOfObject(), and Handle().
{
Handle(SALOME_InteractiveObject) anIO;
std::string entry="";
anIO=GeomSelectionTools::getFirstSelectedSalomeObject();
return GeomSelectionTools::getEntryOfObject(anIO);
}
| TopAbs_ShapeEnum GeomSelectionTools::getFirstSelectedShapeType | ( | ) |
Gives the ShapeType of the first Selected Object, return TopAbs_SHAPE if the first selected object does not define a shape.
Definition at line 251 of file GeomSelectionTools.cxx.
References entryToShapeType(), and Handle().
{
Handle(SALOME_InteractiveObject) anIO;
anIO=GeomSelectionTools::getFirstSelectedSalomeObject();
return entryToShapeType(anIO->getEntry());
}
| std::string GeomSelectionTools::getNameFromEntry | ( | std::string | entry | ) |
Retrieve the name from the entry of the object.
| entry | the entry of the object |
Definition at line 159 of file GeomSelectionTools.cxx.
References _PTR(), and ex21_lamp.name.
{
std::string name = "";
_PTR(SObject) aSO = myStudy->FindObjectID(entry);
if (aSO){
_PTR(SObject) aRefSObj;
// If selected object is a reference
if ( aSO->ReferencedObject( aRefSObj ))
name = aRefSObj->GetName();
// If selected object is a reference is not a reference
else
name = aSO->GetName();
}
return name;
}
| SalomeApp_Application * GeomSelectionTools::GetSalomeApplication | ( | ) | [static] |
Allows to get the Salome Application.
Definition at line 70 of file GeomSelectionTools.cxx.
Referenced by entryToShapeType(), and selectionMgr().
{
SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
if (anApp)
return anApp;
else
return 0;
}
| SALOME_ListIO * GeomSelectionTools::getSelectedSalomeObjects | ( | ) |
Return the list of the selected Salome Interactive Object (SALOME_ListIO*)
Definition at line 96 of file GeomSelectionTools.cxx.
References selectionMgr().
{
SALOME_ListIO* selected;
LightApp_SelectionMgr* aSel = selectionMgr();
aSel->selectedObjects( *selected, NULL, false );
return selected;
}
| GeomSelectionTools.Handle | ( | SALOME_InteractiveObject | ) |
| LightApp_SelectionMgr * GeomSelectionTools::selectionMgr | ( | ) | [static] |
Allows to get the selection manager from LightApp.
Definition at line 83 of file GeomSelectionTools.cxx.
References GetSalomeApplication().
Referenced by getSelectedSalomeObjects().
{
SalomeApp_Application* anApp = GetSalomeApplication();
if (anApp)
return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
else
return 0;
}