-// 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
StdMeshersGUI_PropagationHelperWdg::
StdMeshersGUI_PropagationHelperWdg( StdMeshersGUI_SubShapeSelectorWdg* subSelectWdg,
- QWidget* parent ):
+ QWidget* parent,
+ bool show ):
QWidget( parent ), mySubSelectWdg( subSelectWdg ), myActor( 0 ), myModelActor( 0 )
{
- QGroupBox* helperBox = new QGroupBox( tr("HELPER"), this );
- QCheckBox* showGeomChkBox = new QCheckBox( tr("SHOW_GEOMETRY"), helperBox );
- QGroupBox* chainBox = new QGroupBox( tr("PROPAGATION_CHAINS"), helperBox );
- chainBox->setCheckable( true );
- chainBox->setChecked( false );
- myListWidget = new QListWidget( helperBox );
+ QGroupBox* helperBox = new QGroupBox( tr("HELPER"), this );
+ myShowGeomChkBox = new QCheckBox( tr("SHOW_GEOMETRY"), helperBox );
+ myChainBox = new QGroupBox( tr("PROPAGATION_CHAINS"), helperBox );
+ myChainBox->setCheckable( true );
+ myChainBox->setChecked( false );
+ myListWidget = new QListWidget( helperBox );
myListWidget->setSelectionMode( QAbstractItemView::SingleSelection );
- myAddButton = new QPushButton( tr("ADD"), helperBox );
- myReverseButton = new QPushButton( tr("REVERSE"), helperBox );
+ myAddButton = new QPushButton( tr("ADD"), helperBox );
+ myReverseButton = new QPushButton( tr("REVERSE"), helperBox );
- QGridLayout* chainsLayout = new QGridLayout( chainBox );
+ QGridLayout* chainsLayout = new QGridLayout( myChainBox );
chainsLayout->setMargin( MARGIN );
chainsLayout->setSpacing( SPACING );
chainsLayout->addWidget(myListWidget, 0, 0, 3, 3);
QVBoxLayout* helperLayout = new QVBoxLayout( helperBox );
helperLayout->setMargin( MARGIN );
helperLayout->setSpacing( SPACING );
- helperLayout->addWidget( showGeomChkBox );
- helperLayout->addWidget( chainBox );
+ helperLayout->addWidget( myShowGeomChkBox );
+ helperLayout->addWidget( myChainBox );
QVBoxLayout* lay = new QVBoxLayout( this );
lay->setMargin( 0 );
lay->setSpacing( SPACING );
lay->addWidget( helperBox );
- connect( showGeomChkBox, SIGNAL( toggled(bool)), SLOT( onShowGeometry(bool)));
- connect( chainBox, SIGNAL( toggled(bool)), SLOT( updateList(bool)));
+ connect( myShowGeomChkBox,SIGNAL( toggled(bool)), SLOT( onShowGeometry(bool)));
+ connect( myChainBox, SIGNAL( toggled(bool)), SLOT( updateList(bool)));
connect( myListWidget, SIGNAL( itemSelectionChanged()), SLOT( onListSelectionChanged() ));
connect( myAddButton, SIGNAL( clicked(bool)), SLOT( onAdd() ));
connect( myReverseButton, SIGNAL( clicked(bool)), SLOT( onReverse() ));
- onListSelectionChanged();
+ if ( show )
+ onListSelectionChanged();
}
//================================================================================
}
}
+//================================================================================
+/*!
+ * \brief Switch off all buttons and previews
+ */
+//================================================================================
+
+void StdMeshersGUI_PropagationHelperWdg::Clear()
+{
+ myShowGeomChkBox->setChecked( false );
+
+ myListWidget->blockSignals( true );
+ myListWidget->clear();
+ myListWidget->blockSignals( false );
+
+ myChainBox->blockSignals( true );
+ myChainBox->setChecked( false );
+ myChainBox->blockSignals( false );
+
+ if ( myActor )
+ myActor->SetVisibility( false );
+
+ if ( myModelActor )
+ myModelActor->SetVisibility( false );
+}
+
//================================================================================
/*!
* \brief SLOT called when 'Show Geometry' is checked
BRep_Builder aBuilder;
aBuilder.MakeCompound( aCompound );
- SMESH_PreviewActorsCollection* previewActor = mySubSelectWdg->GetActorCollection();
- if ( !previewActor ) return;
- const QList<int>& egdeIDs = previewActor->GetIndices();
- for ( QList<int>::const_iterator ieIt = egdeIDs.begin(); ieIt != egdeIDs.end(); ++ieIt )
- {
- TopoDS_Shape E = previewActor->GetShapeByIndex( *ieIt );
- if ( !E.IsNull() && E.ShapeType() == TopAbs_EDGE )
- aBuilder.Add( aCompound, E );
- }
+ TopTools_MapOfShape edgesMap;
+ TopExp_Explorer edge( mainShape, TopAbs_EDGE );
+ for ( ; edge.More(); edge.Next() )
+ if ( edgesMap.Add( edge.Current() ))
+ aBuilder.Add( aCompound, edge.Current() );
myModelActor = GEOM_Actor::New();
myModelActor->SetShape( aCompound, 0, 0 );
// aPreviewActor holds a map od all sub-shapes of mainShape
SMESH_PreviewActorsCollection* previewActor = mySubSelectWdg->GetActorCollection();
if ( !previewActor ) return false;
- const QList<int>& egdeIDs = previewActor->GetIndices();
+ const QList<int>& edgeIDs = previewActor->GetIndices();
// Make a 'map' of WIREs of EDGE with quadrilateral WIREs only
typedef std::vector< TEdgeInWire > TWiresOfEdge;// WIREs including an EDGE
std::vector< TWire > quadWires;
- quadWires.reserve( egdeIDs.count() );
- NCollection_DataMap< TGeomID, TWiresOfEdge > wiresOfEdge( egdeIDs.count() );
+ quadWires.reserve( previewActor->NbShapesOfType( TopAbs_FACE ));
+ NCollection_DataMap< TGeomID, TWiresOfEdge >
+ wiresOfEdge( previewActor->NbShapesOfType( TopAbs_EDGE ));
TopExp_Explorer wire;
- for ( TopExp_Explorer face( shape, TopAbs_FACE ); face.More(); face.Next() )
+ TopTools_MapOfShape faceMap;
+ for ( TopExp_Explorer face( mainShape, TopAbs_FACE ); face.More(); face.Next() )
{
+ if ( !faceMap.Add( face.Current() )) continue;
+
wire.Init( face.Current(), TopAbs_WIRE );
TopoDS_Shape W = wire.Current().Oriented( TopAbs_FORWARD );
TColStd_IndexedMapOfInteger chain, chainedEdges;
+ TColStd_MapOfInteger shapeEdges;
+ if ( !shape.IsSame( mainShape ))
+ for ( QList<TGeomID>::const_iterator ieIt = edgeIDs.begin(); ieIt != edgeIDs.end(); ++ieIt )
+ shapeEdges.Add( *ieIt );
+
// loop on all EDGEs in mainShape
- for ( QList<TGeomID>::const_iterator ieIt = egdeIDs.begin(); ieIt != egdeIDs.end(); ++ieIt )
+ for ( QList<TGeomID>::const_iterator ieIt = edgeIDs.begin(); ieIt != edgeIDs.end(); ++ieIt )
{
if ( chainedEdges.Contains( *ieIt ))
continue;
myChains.push_back( std::vector< TGeomID >() );
std::vector< TGeomID > & ch = myChains.back();
for ( int iC = 1; iC <= chain.Extent(); ++iC )
- ch.push_back( chain( iC ) );
+ {
+ TGeomID iE = chain( iC );
+ if ( shapeEdges.IsEmpty() || shapeEdges.Contains( Abs( iE )))
+ ch.push_back( iE );
+ }
+ if ( ch.size() < 2 )
+ myChains.pop_back();
}
- }
+ } // loop on edgeIDs
+
return !myChains.empty();
}
std::vector< int > * chain = 0;
if ( QListWidgetItem * item = myListWidget->currentItem() )
{
- int i = item->data( Qt::UserRole ).toInt();
+ size_t i = (size_t) item->data( Qt::UserRole ).toInt();
if ( 0 <= i && i < myChains.size() )
chain = & myChains[i];
}