23368: [CEA 1865] Possibility to define faces to mesh as a single one: transpatch mesh

This commit is contained in:
eap 2016-10-31 16:00:19 +03:00
parent 189e207e89
commit 20d9e162bd
3 changed files with 133 additions and 89 deletions

View File

@ -56,11 +56,9 @@
StdMeshersGUI_ObjectReferenceParamWdg::StdMeshersGUI_ObjectReferenceParamWdg
( SUIT_SelectionFilter* f, QWidget* parent, bool multiSelection
/*, bool stretch */)
: QWidget( parent ), myMultiSelection( multiSelection )
{
myFilter = f;
// myStretchActivated = stretch;
init();
}
@ -78,6 +76,7 @@ StdMeshersGUI_ObjectReferenceParamWdg::StdMeshersGUI_ObjectReferenceParamWdg
myFilter = new SMESH_TypeFilter( objType );
init();
}
//================================================================================
/*!
* \brief Destructor
@ -93,7 +92,6 @@ StdMeshersGUI_ObjectReferenceParamWdg::~StdMeshersGUI_ObjectReferenceParamWdg()
}
}
//================================================================================
/*!
* \brief Create a leayout, initialize fields
@ -128,9 +126,6 @@ void StdMeshersGUI_ObjectReferenceParamWdg::init()
aHBox->addWidget( mySelButton );
aHBox->addWidget( myObjNameLineEdit );
//if (myStretchActivated){
// aHBox->addStretch();
//}
connect( mySelButton, SIGNAL(clicked()), SLOT(activateSelection()));
}

View File

@ -70,7 +70,9 @@
//================================================================================
StdMeshersGUI_SubShapeSelectorWdg
::StdMeshersGUI_SubShapeSelectorWdg( QWidget * parent, TopAbs_ShapeEnum aSubShType ):
::StdMeshersGUI_SubShapeSelectorWdg( QWidget * parent,
TopAbs_ShapeEnum subShType,
const bool toShowList ):
QWidget( parent ),
myMaxSize( -1 ),
myPreviewActor( 0 )
@ -81,14 +83,26 @@ StdMeshersGUI_SubShapeSelectorWdg
edgesLayout->setMargin( MARGIN );
edgesLayout->setSpacing( SPACING );
if ( toShowList )
{
myListWidget = new QListWidget( this );
myAddButton = new QPushButton( tr( "SMESH_BUT_ADD" ), this );
myRemoveButton = new QPushButton( tr( "SMESH_BUT_REMOVE" ), this );
myListWidget->setSelectionMode( QListWidget::ExtendedSelection );
myListWidget->setMinimumWidth(300);
}
else
{
myListWidget = 0;
myAddButton = 0;
myRemoveButton = 0;
}
myInfoLabel = new QLabel( this );
myPrevButton = new QPushButton( "<<", this );
myNextButton = new QPushButton( ">>", this );
myListWidget->setSelectionMode( QListWidget::ExtendedSelection );
if ( myListWidget )
{
edgesLayout->addWidget(myListWidget, 0, 0, 3, 3);
edgesLayout->addWidget(myAddButton, 0, 3);
edgesLayout->addWidget(myRemoveButton, 1, 3);
@ -98,13 +112,18 @@ StdMeshersGUI_SubShapeSelectorWdg
edgesLayout->setRowStretch(2, 5);
edgesLayout->setColumnStretch(1, 5);
myListWidget->setMinimumWidth(300);
myInfoLabel->setMinimumWidth(300);
myInfoLabel->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
}
else // show only Prev and Next buttons
{
edgesLayout->addWidget(myInfoLabel, 0, 0, 1, 2);
edgesLayout->addWidget(myPrevButton, 1, 0);
edgesLayout->addWidget(myNextButton, 1, 1);
}
//myInfoLabel->setMinimumWidth(300);
//myInfoLabel->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
myInfoLabel->setAlignment(Qt::AlignCenter);
mySubShType = aSubShType;
mySubShType = subShType;
init();
}
@ -150,13 +169,9 @@ StdMeshersGUI_SubShapeSelectorWdg::~StdMeshersGUI_SubShapeSelectorWdg()
void StdMeshersGUI_SubShapeSelectorWdg::init()
{
myParamValue = "";
myIsNotCorrected = true; // to dont call the GetCorrectedValue method twice
myListOfIDs.clear();
mySelectedIDs.clear();
myAddButton->setEnabled( false );
myRemoveButton->setEnabled( false );
mySMESHGUI = SMESHGUI::GetSMESHGUI();
mySelectionMgr = SMESH::GetSelectionMgr( mySMESHGUI );
mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
@ -165,15 +180,20 @@ void StdMeshersGUI_SubShapeSelectorWdg::init()
aViewWindow->SetSelectionMode( ActorSelection );
myFilter=0;
//setFilter();
if ( myListWidget )
{
myAddButton->setEnabled( false );
myRemoveButton->setEnabled( false );
connect( myListWidget, SIGNAL(itemSelectionChanged()), this, SLOT(onListSelectionChanged()));
connect( myAddButton, SIGNAL(clicked()), SLOT(onAdd()));
connect( myRemoveButton, SIGNAL(clicked()), SLOT(onRemove()));
}
connect( myPrevButton, SIGNAL(clicked()), SLOT(onPrevious()));
connect( myNextButton, SIGNAL(clicked()), SLOT(onNext()));
connect( mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(selectionIntoArgument()));
connect( myListWidget, SIGNAL(itemSelectionChanged()), this, SLOT(onListSelectionChanged()));
updateState();
}
@ -186,14 +206,17 @@ void StdMeshersGUI_SubShapeSelectorWdg::init()
void StdMeshersGUI_SubShapeSelectorWdg::setFilter()
{
SalomeApp_Study* study = mySMESHGUI->activeStudy();
GEOM_TypeFilter* typeFilter = new GEOM_TypeFilter(study, mySubShType, /*isShapeType=*/true );
GEOM_CompoundFilter* gpoupFilter = new GEOM_CompoundFilter(study);
gpoupFilter->addSubType( mySubShType );
myGeomFilters.append( typeFilter );
myGeomFilters.append( gpoupFilter );
myFilter = new SMESH_LogicalFilter( myGeomFilters, SMESH_LogicalFilter::LO_OR );
mySelectionMgr->installFilter( myFilter );
// if ( !myFilter )
// {
// SalomeApp_Study* study = mySMESHGUI->activeStudy();
// GEOM_TypeFilter* typeFilter = new GEOM_TypeFilter(study, mySubShType, /*isShapeType=*/true );
// GEOM_CompoundFilter* gpoupFilter = new GEOM_CompoundFilter(study);
// gpoupFilter->addSubType( mySubShType );
// myGeomFilters.append( typeFilter );
// myGeomFilters.append( gpoupFilter );
// myFilter = new SMESH_LogicalFilter( myGeomFilters, SMESH_LogicalFilter::LO_OR );
// }
// mySelectionMgr->installFilter( myFilter );
}
//================================================================================
@ -217,6 +240,26 @@ void StdMeshersGUI_SubShapeSelectorWdg::ShowPreview( bool visible)
}
}
//================================================================================
/*!
* \brief Connect/disconnect to change of selection
*/
//================================================================================
void StdMeshersGUI_SubShapeSelectorWdg::ActivateSelection( bool toActivate )
{
if ( !mySelectionMgr ) return;
if ( toActivate )
{
connect( mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(selectionIntoArgument()));
}
else
{
disconnect(mySelectionMgr, 0, this, 0 );
}
}
//================================================================================
/*!
* \brief Clears selected IDs. This is a workaround of a bug that
@ -232,7 +275,7 @@ void StdMeshersGUI_SubShapeSelectorWdg::ClearSelected()
//=================================================================================
// function : selectionIntoArgument()
// purpose : Called when selection as changed or other case
// purpose : Called when selection has changed or in other cases
//=================================================================================
void StdMeshersGUI_SubShapeSelectorWdg::selectionIntoArgument()
{
@ -313,8 +356,10 @@ void StdMeshersGUI_SubShapeSelectorWdg::selectionIntoArgument()
}
}
// update add button
if ( myListWidget )
{
myAddButton->setEnabled(( myListWidget->count() < myMaxSize || myMaxSize == -1 ) &&
mySelectedIDs.size() > 0 &&
( mySelectedIDs.size() > 0 ) &&
( mySelectedIDs.size() <= myMaxSize || myMaxSize == -1 ) );
//Connect Selected Ids in viewer and dialog's Ids list
@ -332,13 +377,16 @@ void StdMeshersGUI_SubShapeSelectorWdg::selectionIntoArgument()
myListWidget->blockSignals( signalsBlocked );
}
emit shapeSelected();
}
//=================================================================================
// function : onAdd()
// purpose : Called when Add Button Clicked
//=================================================================================
void StdMeshersGUI_SubShapeSelectorWdg::onAdd()
{
if ( mySelectedIDs.size() < 1 )
if ( mySelectedIDs.size() < 1 || !myListWidget )
return;
myListWidget->blockSignals( true );
@ -365,7 +413,7 @@ void StdMeshersGUI_SubShapeSelectorWdg::onAdd()
//=================================================================================
void StdMeshersGUI_SubShapeSelectorWdg::onRemove()
{
if ( myListWidget->count() < 1 )
if ( myListWidget->count() < 1 || !myListWidget )
return;
myListWidget->blockSignals( true );
@ -390,6 +438,7 @@ void StdMeshersGUI_SubShapeSelectorWdg::onPrevious()
{
if ( myPreviewActor ) {
myPreviewActor->previous();
if ( myListWidget )
myListWidget->clearSelection();
updateButtons();
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
@ -401,6 +450,7 @@ void StdMeshersGUI_SubShapeSelectorWdg::onNext()
{
if ( myPreviewActor ) {
myPreviewActor->next();
if ( myListWidget )
myListWidget->clearSelection();
updateButtons();
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
@ -417,7 +467,6 @@ void StdMeshersGUI_SubShapeSelectorWdg::onListSelectionChanged()
if ( !myPreviewActor )
return;
//mySelectionMgr->clearSelected();
myPreviewActor->HighlightAll( false );
QList<QListWidgetItem*> selItems = myListWidget->selectedItems();
QListWidgetItem* anItem;
@ -458,7 +507,6 @@ void StdMeshersGUI_SubShapeSelectorWdg::SetGeomShapeEntry( const QString& theEnt
else
myMainShape = GetTopoDSByEntry( myMainEntry.c_str() );
updateState();
myIsNotCorrected = true;
}
}
@ -468,18 +516,20 @@ void StdMeshersGUI_SubShapeSelectorWdg::SetGeomShapeEntry( const QString& theEnt
//=================================================================================
void StdMeshersGUI_SubShapeSelectorWdg::updateState()
{
bool state = false;
if ( !myGeomShape.IsNull() )
state = true;
bool state = ( !myGeomShape.IsNull() );
myInfoLabel ->setVisible( false );
myPrevButton->setVisible( false );
myNextButton->setVisible( false );
if ( myListWidget )
{
myListWidget->setEnabled( state );
myAddButton->setEnabled( mySelectedIDs.size() > 0 );
}
if ( state ) {
SUIT_OverrideCursor wc;
if ( !myPreviewActor )
myPreviewActor = new SMESH_PreviewActorsCollection();
myPreviewActor->SetSelector( mySelector );
myPreviewActor->Init( myGeomShape, myMainShape, mySubShType, myEntry.c_str() );
@ -555,9 +605,12 @@ bool StdMeshersGUI_SubShapeSelectorWdg::SetListOfIDs( SMESH::long_array_var theI
for ( int i = 0; i < size; i++ )
mySelectedIDs.append( theIds[ i ] );
if ( myListWidget )
{
myListWidget->blockSignals( true );
myListWidget->clear();
myListWidget->blockSignals( false );
}
bool isOk = true;
if ( myPreviewActor )
@ -572,7 +625,6 @@ bool StdMeshersGUI_SubShapeSelectorWdg::SetListOfIDs( SMESH::long_array_var theI
for ( int i = 0; i < size && isOk; i++ )
isOk = ( theIds[ i ] > 0 && theIds[ i ] <= aMainMap.Extent() );
}
// mySelectedIDs = GetCorrectedListOfIDs( false, &isOk );
onAdd();
return isOk;
}

View File

@ -51,25 +51,21 @@ class STDMESHERSGUI_EXPORT StdMeshersGUI_SubShapeSelectorWdg : public QWidget
public:
StdMeshersGUI_SubShapeSelectorWdg( QWidget* parent = 0,
TopAbs_ShapeEnum aSubShType = TopAbs_EDGE );
TopAbs_ShapeEnum subShType = TopAbs_EDGE,
const bool toShowList = true);
~StdMeshersGUI_SubShapeSelectorWdg();
SMESH::long_array_var GetListOfIDs();
bool SetListOfIDs( SMESH::long_array_var );
const QList<int>& GetSelectedIDs() const { return mySelectedIDs; }
void SetGeomShapeEntry( const QString& theEntry,
const QString& theMainShapeEntry);
//QString GetGeomShapeEntry() { return myEntry; }
// void SetMainShapeEntry( const QString& theEntry );
const char* GetMainShapeEntry();
TopoDS_Shape GetGeomShape() { return myGeomShape; }
TopoDS_Shape GetMainShape() { return myMainShape; }
// QList<int> GetCorrectedListOfIDs( bool fromSubshapeToMainshape,
// bool* isOK=0);
static GEOM::GEOM_Object_var GetGeomObjectByEntry( const QString& );
static TopoDS_Shape GetTopoDSByEntry( const QString& );
@ -84,9 +80,11 @@ public:
vtkRenderer* GetRenderer() { return myRenderer; }
SMESH_PreviewActorsCollection* GetActorCollection() { return myPreviewActor; }
void ClearSelected();
void ActivateSelection( bool );
signals:
void selectionChanged();
void selectionChanged(); // in the list
void shapeSelected(); // globally
private:
void updateState();
@ -126,7 +124,6 @@ private:
QString myParamValue;
bool myIsShown;
bool myIsNotCorrected;
// for manage possible size of myListOfIDs
int myMaxSize;