X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FOBJECT%2FSMESH_PreviewActorsCollection.cxx;h=8cdc0091298da5ed4af08ae48b5c67a3d83773fe;hp=493c1605b4b30ba8e4a3a366d8c2fac7c56874d7;hb=f4dd52ae3de915020ae02284b8458628a961cc29;hpb=6bac08c1a81f34d3f21c550bd92f83654b2546a5 diff --git a/src/OBJECT/SMESH_PreviewActorsCollection.cxx b/src/OBJECT/SMESH_PreviewActorsCollection.cxx index 493c1605b..8cdc00912 100644 --- a/src/OBJECT/SMESH_PreviewActorsCollection.cxx +++ b/src/OBJECT/SMESH_PreviewActorsCollection.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2015 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 @@ -65,8 +65,9 @@ SMESH_PreviewActorsCollection::~SMESH_PreviewActorsCollection() } 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(); @@ -82,17 +83,17 @@ bool SMESH_PreviewActorsCollection::Init( const TopoDS_Shape& theShape, if ( theShape.IsNull() ) return false; - Handle( SALOME_InteractiveObject ) anIO = new SALOME_InteractiveObject(); - anIO->setEntry( theEntry.toLatin1().constData() ); - - // get indexes of seleted elements - TopExp::MapShapes( theShape, myMapOfShapes ); + // Handle( SALOME_InteractiveObject ) anIO = new SALOME_InteractiveObject(); + // anIO->setEntry( theEntry.toUtf8().constData() ); + + // get indexes of selected elements + TopExp::MapShapes( theMainShape, myMapOfShapes ); TopExp_Explorer exp( theShape, theType ); QSet indices; for ( ; exp.More(); exp.Next() ) indices << myMapOfShapes.FindIndex( exp.Current() ); myIndices = indices.toList(); - qSort(myIndices); + //qSort(myIndices); // show current chunk showCurrentChunk(); @@ -112,11 +113,41 @@ GEOM_Actor* SMESH_PreviewActorsCollection::GetActorByIndex(int index) 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& indices) +{ + if ( myIndices != indices ) + { + myIndices = indices; + showCurrentChunk(); + } +} + void SMESH_PreviewActorsCollection::AddToRender(vtkRenderer* theRenderer) { myRenderer = theRenderer; @@ -217,7 +248,7 @@ void SMESH_PreviewActorsCollection::showCurrentChunk() QString entry = QString( "%1_%2" ).arg( myEntry ).arg( index ); // Create interactive object Handle( SALOME_InteractiveObject ) anIO = new SALOME_InteractiveObject(); - anIO->setEntry( entry.toLatin1().constData() ); + anIO->setEntry( entry.toUtf8().constData() ); // Init Actor anActor->SetVectorMode( myType==TopAbs_EDGE ); anActor->setIO( anIO ); @@ -229,7 +260,8 @@ void SMESH_PreviewActorsCollection::showCurrentChunk() myMapOfActors.insert(index, anActor); } } - mySelector->ClearIObjects(); + if ( mySelector ) + mySelector->ClearIObjects(); if ( myRenderer ) AddToRender( myRenderer ); }