-// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2015 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
}
bool SMESH_PreviewActorsCollection::Init( const TopoDS_Shape& theShape,
- TopAbs_ShapeEnum theType,
- const QString& theEntry )
+ const TopoDS_Shape& theMainShape,
+ TopAbs_ShapeEnum theType,
+ const QString& theEntry )
{
SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
if ( theShape.IsNull() )
return false;
- Handle( SALOME_InteractiveObject ) anIO = new SALOME_InteractiveObject();
- anIO->setEntry( theEntry.toLatin1().constData() );
+ // Handle( SALOME_InteractiveObject ) anIO = new SALOME_InteractiveObject();
+ // anIO->setEntry( theEntry.toLatin1().constData() );
// get indexes of seleted elements
- TopExp::MapShapes( theShape, myMapOfShapes );
+ TopExp::MapShapes( theMainShape, myMapOfShapes );
TopExp_Explorer exp( theShape, theType );
QSet<int> indices;
for ( ; exp.More(); exp.Next() )
indices << myMapOfShapes.FindIndex( exp.Current() );
myIndices = indices.toList();
- qSort(myIndices);
+ //qSort(myIndices);
// show current chunk
showCurrentChunk();
return myMapOfActors.value( index );
}
+bool SMESH_PreviewActorsCollection::IsValidIndex( int index )
+{
+ return 0 < index && index <= myMapOfShapes.Extent();
+}
+
int SMESH_PreviewActorsCollection::GetIndexByShape( const TopoDS_Shape& theShape )
{
return myMapOfShapes.FindIndex( theShape );
}
+TopoDS_Shape SMESH_PreviewActorsCollection::GetShapeByIndex( int index )
+{
+ return IsValidIndex( index ) ? myMapOfShapes.FindKey( index ) : TopoDS_Shape();
+}
+
+int SMESH_PreviewActorsCollection::NbShapesOfType( TopAbs_ShapeEnum type )
+{
+ if ( type == TopAbs_SHAPE ) return myMapOfShapes.Extent();
+
+ int nb = 0;
+ for ( int i = 1; i <= myMapOfShapes.Extent(); ++i )
+ nb += ( myMapOfShapes(i).ShapeType() == type );
+
+ return nb;
+}
+
+void SMESH_PreviewActorsCollection::SetIndices( const QList<int>& indices)
+{
+ if ( myIndices != indices )
+ {
+ myIndices = indices;
+ showCurrentChunk();
+ }
+}
+
void SMESH_PreviewActorsCollection::AddToRender(vtkRenderer* theRenderer)
{
myRenderer = theRenderer;
myMapOfActors.insert(index, anActor);
}
}
- mySelector->ClearIObjects();
+ if ( mySelector )
+ mySelector->ClearIObjects();
if ( myRenderer )
AddToRender( myRenderer );
}