IMPLEMENT_STANDARD_HANDLE(SMESHGUI_TriangleFilter, SMESHGUI_Filter)
IMPLEMENT_STANDARD_RTTIEXT(SMESHGUI_TriangleFilter, SMESHGUI_Filter)
+IMPLEMENT_STANDARD_HANDLE(SMESHGUI_FacesFilter, SMESHGUI_Filter)
+IMPLEMENT_STANDARD_RTTIEXT(SMESHGUI_FacesFilter, SMESHGUI_Filter)
+
+IMPLEMENT_STANDARD_HANDLE(SMESHGUI_VolumesFilter, SMESHGUI_Filter)
+IMPLEMENT_STANDARD_RTTIEXT(SMESHGUI_VolumesFilter, SMESHGUI_Filter)
+
/*
Class : SMESHGUI_PredicateFilter
Description : Selection filter for VTK viewer. This class aggregate object
SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh();
const SMDS_MeshElement* anElem = aMesh->FindElement( anActor->GetElemObjId( theCellId ) );
- return anElem != 0 ? anElem->GetType() != SMDSAbs_Face || anElem->NbNodes() == 4 : false;
+ return anElem && anElem->GetType() == SMDSAbs_Face && anElem->NbNodes() == 4;
}
//=======================================================================
SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh();
const SMDS_MeshElement* anElem = aMesh->FindElement( theObjId );
- return anElem != 0 ? anElem->GetType() != SMDSAbs_Face || anElem->NbNodes() == 4 : false;
+ return anElem && anElem->GetType() == SMDSAbs_Face && anElem->NbNodes() == 4;
}
//=======================================================================
SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh();
const SMDS_MeshElement* anElem = aMesh->FindElement( anActor->GetElemObjId( theCellId ) );
- return anElem != 0 ? anElem->GetType() != SMDSAbs_Face || anElem->NbNodes() == 3 : false;
+ return anElem && anElem->GetType() == SMDSAbs_Face && anElem->NbNodes() == 3;
}
//=======================================================================
SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh();
const SMDS_MeshElement* anElem = aMesh->FindElement( theObjId );
- return anElem != 0 ? anElem->GetType() != SMDSAbs_Face || anElem->NbNodes() == 3 : false;
+ return anElem && anElem->GetType() == SMDSAbs_Face && anElem->NbNodes() == 3;
}
//=======================================================================
return false;
}
+/*
+ Class : SMESHGUI_FacesFilter
+ Description : Verify whether selected cell is any face
+*/
+
+
+//=======================================================================
+// name : SMESHGUI_FacesFilter::SMESHGUI_FacesFilter
+// Purpose : Constructor
+//=======================================================================
+SMESHGUI_FacesFilter::SMESHGUI_FacesFilter()
+: SMESHGUI_Filter()
+{
+}
+
+SMESHGUI_FacesFilter::~SMESHGUI_FacesFilter()
+{
+}
+
+//=======================================================================
+// name : SMESHGUI_FacesFilter::IsValid
+// Purpose : Verify whether selected cell is face
+//=======================================================================
+bool SMESHGUI_FacesFilter::IsValid( const int theCellId ) const
+{
+ if ( myActor == 0 )
+ return false;
+
+ SMESH_Actor* anActor = ( SMESH_Actor* )myActor;
+ if ( anActor->GetObject() == 0 )
+ return false;
+
+ SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh();
+ const SMDS_MeshElement* anElem = aMesh->FindElement( anActor->GetElemObjId( theCellId ) );
+
+ return anElem && anElem->GetType() == SMDSAbs_Face;
+}
+
+//=======================================================================
+// name : SMESHGUI_FacesFilter::IsValid
+// Purpose : Verify whether selected cell is face
+//=======================================================================
+bool SMESHGUI_FacesFilter::IsObjValid( const int theObjId ) const
+{
+ if ( myActor == 0 )
+ return false;
+
+ SMESH_Actor* anActor = ( SMESH_Actor* )myActor;
+ if ( anActor->GetObject() == 0 )
+ return false;
+
+ SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh();
+ const SMDS_MeshElement* anElem = aMesh->FindElement( theObjId );
+
+ return anElem && anElem->GetType() == SMDSAbs_Face;
+}
+
+//=======================================================================
+// name : SMESHGUI_FacesFilter::GetId
+// Purpose : Get ID of the filter. Must return value from SMESHGUI_FilterType
+// enumeration. All filters must have different ids
+//=======================================================================
+int SMESHGUI_FacesFilter::GetId() const
+{
+ return SMESHGUI_FaceFilter;
+}
+
+//=======================================================================
+// name : SMESHGUI_FacesFilter::IsNodeFilter
+// Purpose : Returns true if filter is intended for nodes
+//=======================================================================
+bool SMESHGUI_FacesFilter::IsNodeFilter() const
+{
+ return false;
+}
+
+
+/*
+ Class : SMESHGUI_VolumesFilter
+ Description : Verify whether selected cell is any volume
+*/
+
+
+//=======================================================================
+// name : SMESHGUI_VolumesFilter::SMESHGUI_VolumesFilter
+// Purpose : Constructor
+//=======================================================================
+SMESHGUI_VolumesFilter::SMESHGUI_VolumesFilter()
+: SMESHGUI_Filter()
+{
+}
+
+SMESHGUI_VolumesFilter::~SMESHGUI_VolumesFilter()
+{
+}
+
+//=======================================================================
+// name : SMESHGUI_VolumesFilter::IsValid
+// Purpose : Verify whether selected cell is volume
+//=======================================================================
+bool SMESHGUI_VolumesFilter::IsValid( const int theCellId ) const
+{
+ if ( myActor == 0 )
+ return false;
+
+ SMESH_Actor* anActor = ( SMESH_Actor* )myActor;
+ if ( anActor->GetObject() == 0 )
+ return false;
+
+ SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh();
+ const SMDS_MeshElement* anElem = aMesh->FindElement( anActor->GetElemObjId( theCellId ) );
+
+ return anElem && anElem->GetType() == SMDSAbs_Volume;
+}
+
+//=======================================================================
+// name : SMESHGUI_VolumesFilter::IsValid
+// Purpose : Verify whether selected cell is volume
+//=======================================================================
+bool SMESHGUI_VolumesFilter::IsObjValid( const int theObjId ) const
+{
+ if ( myActor == 0 )
+ return false;
+
+ SMESH_Actor* anActor = ( SMESH_Actor* )myActor;
+ if ( anActor->GetObject() == 0 )
+ return false;
+
+ SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh();
+ const SMDS_MeshElement* anElem = aMesh->FindElement( theObjId );
+
+ return anElem && anElem->GetType() == SMDSAbs_Volume;
+}
+
+//=======================================================================
+// name : SMESHGUI_VolumesFilter::GetId
+// Purpose : Get ID of the filter. Must return value from SMESHGUI_FilterType
+// enumeration. All filters must have different ids
+//=======================================================================
+int SMESHGUI_VolumesFilter::GetId() const
+{
+ return SMESHGUI_VolumeFilter;
+}
+
+//=======================================================================
+// name : SMESHGUI_VolumesFilter::IsNodeFilter
+// Purpose : Returns true if filter is intended for nodes
+//=======================================================================
+bool SMESHGUI_VolumesFilter::IsNodeFilter() const
+{
+ return false;
+}
+
DEFINE_STANDARD_RTTI(SMESHGUI_TriangleFilter)
};
+/*
+ Class : SMESHGUI_FacesFilter
+ Description : Verify whether selected cell is any face
+*/
+
+DEFINE_STANDARD_HANDLE(SMESHGUI_FacesFilter, SMESHGUI_Filter)
+
+class SMESHGUI_FacesFilter : public SMESHGUI_Filter
+{
+
+public:
+ SMESHGUI_FacesFilter();
+ virtual ~SMESHGUI_FacesFilter();
+
+ virtual bool IsValid( const int theCellId ) const;
+ virtual bool IsObjValid( const int theObjId ) const;
+ virtual int GetId() const;
+ virtual bool IsNodeFilter() const;
+
+public:
+ DEFINE_STANDARD_RTTI(SMESHGUI_FacesFilter)
+};
+
+/*
+ Class : SMESHGUI_VolumesFilter
+ Description : Verify whether selected cell is any volume
+*/
+
+DEFINE_STANDARD_HANDLE(SMESHGUI_VolumesFilter, SMESHGUI_Filter)
+
+class SMESHGUI_VolumesFilter : public SMESHGUI_Filter
+{
+
+public:
+ SMESHGUI_VolumesFilter();
+ virtual ~SMESHGUI_VolumesFilter();
+
+ virtual bool IsValid( const int theCellId ) const;
+ virtual bool IsObjValid( const int theObjId ) const;
+ virtual int GetId() const;
+ virtual bool IsNodeFilter() const;
+
+public:
+ DEFINE_STANDARD_RTTI(SMESHGUI_VolumesFilter)
+};
+
#endif
if ( myBusy || !isEnabled() ) return;
myBusy = true;
+ myMesh = SMESH::SMESH_Mesh::_nil();
+ myActor = 0;
+
int nbSel = mySelection->IObjectCount();
myListBox->clearSelection();
if ( nbSel == 1 ) {
myActor = SMESH::FindActorByEntry(mySelection->firstIObject()->getEntry());
- if (!myActor)
+ if ( !myActor && !myMesh->_is_nil() )
myActor = SMESH::FindActorByObject( myMesh );
VTKViewer_InteractorStyleSALOME* aStyle = SMESH::GetInteractorStyle();
- Handle(VTKViewer_Filter) aFilter1 = aStyle->GetFilter( myFilterType );
- Handle(VTKViewer_Filter) aFilter2 = aStyle->GetFilter( SMESHGUI_FaceFilter );
- if ( !aFilter1.IsNull() )
- aFilter1->SetActor( myActor );
- if ( !aFilter2.IsNull() )
- aFilter2->SetActor( myActor );
- if ( myActor )
- SMESH::SetPickable(myActor);
+ Handle(VTKViewer_Filter) aFilter = aStyle->GetFilter( myFilterType );
+ if ( !aFilter.IsNull() && myActor ) {
+ aFilter->SetActor( myActor );
+ //SMESH::SetPickable( myActor );
+ }
}
myBusy = false;
}
//=======================================================================
-// name : SMESHGUI_MultiEditDlg::onAddBtn
+// name : SMESHGUI_MultiEditDlg::isIdValid
// Purpose : Verify whether Id of element satisfies to filters from viewer
//=======================================================================
bool SMESHGUI_MultiEditDlg::isIdValid( const int theId ) const
{
VTKViewer_InteractorStyleSALOME* aStyle = SMESH::GetInteractorStyle();
- Handle(SMESHGUI_Filter) aFilter1 =
+ Handle(SMESHGUI_Filter) aFilter =
Handle(SMESHGUI_Filter)::DownCast( aStyle->GetFilter( myFilterType ) );
- Handle(SMESHGUI_Filter) aFilter2 =
- Handle(SMESHGUI_Filter)::DownCast( aStyle->GetFilter( SMESHGUI_FaceFilter ) );
- return ( aFilter1.IsNull() || aFilter1->IsObjValid( theId ) ) &&
- ( aFilter2.IsNull() || aFilter2->IsObjValid( theId ) );
+ return ( !aFilter.IsNull() && aFilter->IsObjValid( theId ) );
}
//=======================================================================
SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>( anIter.Value() );
if ( !aSubMesh->_is_nil() )
{
- if ( aSubMesh->GetFather()->GetId() == myMesh->GetId() )
+ if ( !myMesh->_is_nil() && aSubMesh->GetFather()->GetId() == myMesh->GetId() )
{
SMESH::long_array_var anIds = aSubMesh->GetElementsId();
for ( int i = 0, n = anIds->length(); i < n; i++ )
{
SMESH::SMESH_GroupBase_var aGroup =
SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>( anIter.Value() );
- if ( !aGroup->_is_nil() && aGroup->GetType() == SMESH::FACE )
+ if ( !aGroup->_is_nil() && ( aGroup->GetType() == SMESH::FACE || aGroup->GetType() == SMESH::VOLUME ) )
{
- if ( aGroup->GetMesh()->GetId() == myMesh->GetId() )
+ if ( !myMesh->_is_nil() && aGroup->GetMesh()->GetId() == myMesh->GetId() )
{
SMESH::long_array_var anIds = aGroup->GetListOfID();
for ( int i = 0, n = anIds->length(); i < n; i++ )
QAD_Application::getDesktop()->SetSelectionMode( ActorSelection, true );
mySelection->AddFilter( myGroupFilter );
}
- else
- {
- if ( myFilterType == SMESHGUI_VolumeFilter ) {
- QAD_Application::getDesktop()->SetSelectionMode( VolumeSelection, true );
- }
- else {
- QAD_Application::getDesktop()->SetSelectionMode( FaceSelection, true );
- if ( myFilterType == SMESHGUI_TriaFilter )
- SMESH::SetFilter( new SMESHGUI_TriangleFilter() );
- else if ( myFilterType == SMESHGUI_QuadFilter )
- SMESH::SetFilter( new SMESHGUI_QuadrangleFilter() );
- }
+ if ( myFilterType == SMESHGUI_VolumeFilter ) {
+ QAD_Application::getDesktop()->SetSelectionMode( VolumeSelection, true );
+ SMESH::SetFilter( new SMESHGUI_VolumesFilter() );
+ }
+ else {
+ QAD_Application::getDesktop()->SetSelectionMode( FaceSelection, true );
+ if ( myFilterType == SMESHGUI_TriaFilter )
+ SMESH::SetFilter( new SMESHGUI_TriangleFilter() );
+ else if ( myFilterType == SMESHGUI_QuadFilter )
+ SMESH::SetFilter( new SMESHGUI_QuadrangleFilter() );
+ else
+ SMESH::SetFilter( new SMESHGUI_FacesFilter() );
}
}
if ( aMeshEditor->_is_nil() )
return false;
+ myBusy = true;
+
SMESH::long_array_var anIds = getIds();
bool aResult = process( aMeshEditor, anIds.inout() );
updateButtons();
}
+ myBusy = false;
return aResult;
}
myFilterType = SMESHGUI_FaceFilter;
setSelectionMode();
- if ( myActor )
- mySelection->AddIObject( myActor->getIO(), true );
+ myActor = 0;
}
}