From: ptv Date: Fri, 16 Jan 2009 13:52:54 +0000 (+0000) Subject: IMP19938 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=0dd6c95e106fbe2cf9cfd409a056e1c8339c333c;p=modules%2Fsmesh.git IMP19938 --- diff --git a/idl/SMESH_Filter.idl b/idl/SMESH_Filter.idl index c25b76fc6..e0aea39aa 100644 --- a/idl/SMESH_Filter.idl +++ b/idl/SMESH_Filter.idl @@ -49,6 +49,7 @@ module SMESH FT_FreeBorders, FT_FreeEdges, FT_FreeNodes, + FT_FreeFaces, FT_MultiConnection, FT_MultiConnection2D, FT_Length, @@ -60,6 +61,9 @@ module SMESH FT_LyingOnGeom, FT_RangeOfIds, FT_BadOrientedVolume, + FT_LinearOrQuadratic, + FT_GroupColor, + FT_ElemGeomType, FT_LessThan, FT_MoreThan, FT_EqualTo, @@ -126,7 +130,7 @@ module SMESH typedef sequence Values; Values GetValues(); }; - + /*! * Predicates are intended for verification of criteria, * must return bool value by mesh id @@ -258,6 +262,12 @@ module SMESH */ interface FreeNodes: Predicate{}; + /*! + * Logical functor (predicate) "Free faces". + * Verify whether 2D mesh element is free ( i.e. connected to one volume only ) + */ + interface FreeFaces: Predicate{}; + /*! * Abstract logical functor (predicate) "RangeOfIds". * Verify whether an Entity Id belongs to defined sequence of id's @@ -308,6 +318,33 @@ module SMESH interface LogicalAND: LogicalBinary{}; interface LogicalOR : LogicalBinary{}; + /*! + * Logical functor (predicate) "Is element Linear or Quadratic". + * Verify whether a mesh element is linear + */ + interface LinearOrQuadratic: Predicate { + void SetElementType( in ElementType theType ); + }; + + /*! + * Functor "Group Color" + * Returns color of group to which mesh element belongs to + */ + interface GroupColor : Predicate{ + void SetElementType( in ElementType theType ); + void SetColorStr( in string theColor ); + string GetColorStr(); + }; + + /*! + * Functor "Element geometry type" + * Returns is element has indicated geometry type + */ + interface ElemGeomType : Predicate{ + void SetElementType ( in ElementType theType ); + void SetGeometryType( in GeometryType theType ); + }; + /*! * Filter */ @@ -324,6 +361,7 @@ module SMESH * ThresholdStr - Threshold value defined as string. Used for: * 1. Diaposon of identifiers. Example: "1,2,3,5-10,12,27-29" * 2. BelongToGeom predicate for storing name of shape + * 3. GroupColor predicate for storing group color "0.2;0;0.5" * ThresholdID - One more threshold value defined as string. Used for: * 1. BelongToGeom predicate for storing id of shape * Tolerance - Tolerance is used for comparators (EqualTo comparision) and for @@ -429,10 +467,15 @@ module SMESH FreeBorders CreateFreeBorders(); FreeEdges CreateFreeEdges(); FreeNodes CreateFreeNodes(); + FreeFaces CreateFreeFaces(); RangeOfIds CreateRangeOfIds(); BadOrientedVolume CreateBadOrientedVolume(); + LinearOrQuadratic CreateLinearOrQuadratic(); + + GroupColor CreateGroupColor(); + ElemGeomType CreateElemGeomType(); /*! * Create comparators ( predicates ) diff --git a/idl/SMESH_Mesh.idl b/idl/SMESH_Mesh.idl index d55204ef4..c5f8b14eb 100644 --- a/idl/SMESH_Mesh.idl +++ b/idl/SMESH_Mesh.idl @@ -114,6 +114,23 @@ module SMESH FACE, VOLUME }; + + /*! + * Enumeration for element geometry type, like in SMDS + */ + enum GeometryType + { + Geom_POINT, + Geom_EDGE, + Geom_TRIANGLE, + Geom_QUADRANGLE, + Geom_POLYGON, + Geom_TETRA, + Geom_PYRAMID, + Geom_HEXA, + Geom_PENTA, + Geom_POLYHEDRA + }; /*! * ElementOrder points out entities of what order are requested diff --git a/resources/Makefile.am b/resources/Makefile.am index 5484c04d5..075657e1a 100644 --- a/resources/Makefile.am +++ b/resources/Makefile.am @@ -165,7 +165,8 @@ dist_salomeres_DATA = \ mesh_node_to_point.png \ mesh_tree_mesh_partial.png \ mesh_extractGroup.png \ - mesh_precompute.png + mesh_precompute.png \ + mesh_free_faces.png # VSR: little trick to avoid putting if SMESHCatalog.xml to the distribution archive nodist_salomeres_SCRIPTS = SMESHCatalog.xml diff --git a/src/Controls/Makefile.am b/src/Controls/Makefile.am index 41e95b0df..56ac46b52 100644 --- a/src/Controls/Makefile.am +++ b/src/Controls/Makefile.am @@ -45,10 +45,12 @@ libSMESHControls_la_CPPFLAGS = \ $(CAS_CPPFLAGS) \ $(BOOST_CPPFLAGS) \ $(KERNEL_CXXFLAGS) \ - -I$(srcdir)/../SMDS + -I$(srcdir)/../SMDS \ + -I$(srcdir)/../SMESHDS libSMESHControls_la_LDFLAGS = \ ../SMDS/libSMDS.la \ + ../SMESHDS/libSMESHDS.la \ $(CAS_LDPATH) -lTKernel -lTKBRep -lTKG3d SMESHControls_CPPFLAGS = \ @@ -57,6 +59,7 @@ SMESHControls_CPPFLAGS = \ SMESHControls_LDADD = \ ../SMDS/libSMDS.la \ + ../SMESHDS/libSMESHDS.la \ libSMESHControls.la \ $(KERNEL_LDFLAGS) -lOpUtil -lSALOMELocalTrace -lSALOMEBasics \ $(GEOM_LDFLAGS) -lGEOMAlgo \ diff --git a/src/Controls/SMESH_Controls.cxx b/src/Controls/SMESH_Controls.cxx index 38c8396bc..fc57ada19 100644 --- a/src/Controls/SMESH_Controls.cxx +++ b/src/Controls/SMESH_Controls.cxx @@ -59,6 +59,9 @@ #include "SMDS_QuadraticFaceOfNodes.hxx" #include "SMDS_QuadraticEdge.hxx" +#include "SMESHDS_Mesh.hxx" +#include "SMESHDS_GroupBase.hxx" + /* AUXILIARY METHODS */ @@ -1722,6 +1725,275 @@ SMDSAbs_ElementType FreeNodes::GetType() const } +/* + Class : FreeFaces + Description : Predicate for free faces +*/ + +FreeFaces::FreeFaces() +{ + myMesh = 0; +} + +void FreeFaces::SetMesh( const SMDS_Mesh* theMesh ) +{ + myMesh = theMesh; +} + +bool FreeFaces::IsSatisfy( long theId ) +{ + if (!myMesh) return false; + // check that faces nodes refers to less than two common volumes + const SMDS_MeshElement* aFace = myMesh->FindElement( theId ); + if ( !aFace || aFace->GetType() != SMDSAbs_Face ) + return false; + + int nbNode = aFace->NbNodes(); + + // collect volumes check that number of volumss with count equal nbNode not less than 2 + typedef map< SMDS_MeshElement*, int > TMapOfVolume; // map of volume counters + typedef map< SMDS_MeshElement*, int >::iterator TItrMapOfVolume; // iterator + TMapOfVolume mapOfVol; + + SMDS_ElemIteratorPtr nodeItr = aFace->nodesIterator(); + while ( nodeItr->more() ) { + const SMDS_MeshNode* aNode = static_cast(nodeItr->next()); + if ( !aNode ) continue; + SMDS_ElemIteratorPtr volItr = aNode->GetInverseElementIterator(SMDSAbs_Volume); + while ( volItr->more() ) { + SMDS_MeshElement* aVol = (SMDS_MeshElement*)volItr->next(); + TItrMapOfVolume itr = mapOfVol.insert(make_pair(aVol, 0)).first; + (*itr).second++; + } + } + int nbVol = 0; + TItrMapOfVolume volItr = mapOfVol.begin(); + TItrMapOfVolume volEnd = mapOfVol.end(); + for ( ; volItr != volEnd; ++volItr ) + if ( (*volItr).second >= nbNode ) + nbVol++; + // face is not free if number of volumes constructed on thier nodes more than one + return (nbVol < 2); +} + +SMDSAbs_ElementType FreeFaces::GetType() const +{ + return SMDSAbs_Face; +} + +/* + Class : LinearOrQuadratic + Description : Predicate to verify whether a mesh element is linear +*/ + +LinearOrQuadratic::LinearOrQuadratic() +{ + myMesh = 0; +} + +void LinearOrQuadratic::SetMesh( const SMDS_Mesh* theMesh ) +{ + myMesh = theMesh; +} + +bool LinearOrQuadratic::IsSatisfy( long theId ) +{ + if (!myMesh) return false; + const SMDS_MeshElement* anElem = myMesh->FindElement( theId ); + if ( !anElem || (myType != SMDSAbs_All && anElem->GetType() != myType) ) + return false; + return (!anElem->IsQuadratic()); +} + +void LinearOrQuadratic::SetType( SMDSAbs_ElementType theType ) +{ + myType = theType; +} + +SMDSAbs_ElementType LinearOrQuadratic::GetType() const +{ + return myType; +} + +/* + Class : GroupColor + Description : Functor for check color of group to whic mesh element belongs to +*/ + +GroupColor::GroupColor() +{ +} + +bool GroupColor::IsSatisfy( long theId ) +{ + return (myIDs.find( theId ) != myIDs.end()); +} + +void GroupColor::SetType( SMDSAbs_ElementType theType ) +{ + myType = theType; +} + +SMDSAbs_ElementType GroupColor::GetType() const +{ + return myType; +} + +static bool isEqual( const Quantity_Color& theColor1, + const Quantity_Color& theColor2 ) +{ + // tolerance to compare colors + const double tol = 5*1e-3; + return ( fabs( theColor1.Red() - theColor2.Red() ) < tol && + fabs( theColor1.Green() - theColor2.Green() ) < tol && + fabs( theColor1.Blue() - theColor2.Blue() ) < tol ); +} + + +void GroupColor::SetMesh( const SMDS_Mesh* theMesh ) +{ + myIDs.clear(); + + const SMESHDS_Mesh* aMesh = dynamic_cast(theMesh); + if ( !aMesh ) + return; + + int nbGrp = aMesh->GetNbGroups(); + if ( !nbGrp ) + return; + + // iterates on groups and find necessary elements ids + const std::set& aGroups = aMesh->GetGroups(); + set::const_iterator GrIt = aGroups.begin(); + for (; GrIt != aGroups.end(); GrIt++) { + SMESHDS_GroupBase* aGrp = (*GrIt); + if ( !aGrp ) + continue; + // check type and color of group + if ( !isEqual( myColor, aGrp->GetColor() ) ) + continue; + if ( myType != SMDSAbs_All && myType != (SMDSAbs_ElementType)aGrp->GetType() ) + continue; + + // add elements IDS into control + int aSize = aGrp->Extent(); + for (int i = 0; i < aSize; i++) + myIDs.insert( aGrp->GetID(i+1) ); + } +} + +void GroupColor::SetColorStr( const TCollection_AsciiString& theStr ) +{ + TCollection_AsciiString aStr = theStr; + aStr.RemoveAll( ' ' ); + aStr.RemoveAll( '\t' ); + for ( int aPos = aStr.Search( ";;" ); aPos != -1; aPos = aStr.Search( ";;" ) ) + aStr.Remove( aPos, 2 ); + Standard_Real clr[3]; + clr[0] = clr[1] = clr[2] = 0.; + for ( int i = 0; i < 3; i++ ) { + TCollection_AsciiString tmpStr = aStr.Token( ";", i+1 ); + if ( !tmpStr.IsEmpty() && tmpStr.IsRealValue() ) + clr[i] = tmpStr.RealValue(); + } + myColor = Quantity_Color( clr[0], clr[1], clr[2], Quantity_TOC_RGB ); +} + +//======================================================================= +// name : GetRangeStr +// Purpose : Get range as a string. +// Example: "1,2,3,50-60,63,67,70-" +//======================================================================= +void GroupColor::GetColorStr( TCollection_AsciiString& theResStr ) const +{ + theResStr.Clear(); + theResStr += TCollection_AsciiString( myColor.Red() ); + theResStr += TCollection_AsciiString( ";" ) + TCollection_AsciiString( myColor.Green() ); + theResStr += TCollection_AsciiString( ";" ) + TCollection_AsciiString( myColor.Blue() ); +} + +/* + Class : ElemGeomType + Description : Predicate to check element geometry type +*/ + +ElemGeomType::ElemGeomType() +{ + myMesh = 0; + myType = SMDSAbs_All; + myGeomType = SMDSGeom_TRIANGLE; +} + +void ElemGeomType::SetMesh( const SMDS_Mesh* theMesh ) +{ + myMesh = theMesh; +} + +bool ElemGeomType::IsSatisfy( long theId ) +{ + if (!myMesh) return false; + const SMDS_MeshElement* anElem = myMesh->FindElement( theId ); + const SMDSAbs_ElementType anElemType = anElem->GetType(); + if ( !anElem || (myType != SMDSAbs_All && anElemType != myType) ) + return false; + const int aNbNode = anElem->NbNodes(); + bool isOk = false; + switch( anElemType ) + { + case SMDSAbs_Node: + isOk = (myGeomType == SMDSGeom_POINT); + break; + + case SMDSAbs_Edge: + isOk = (myGeomType == SMDSGeom_EDGE); + break; + + case SMDSAbs_Face: + if ( myGeomType == SMDSGeom_TRIANGLE ) + isOk = (!anElem->IsPoly() && aNbNode == 3); + else if ( myGeomType == SMDSGeom_QUADRANGLE ) + isOk = (!anElem->IsPoly() && aNbNode == 4); + else if ( myGeomType == SMDSGeom_POLYGON ) + isOk = anElem->IsPoly(); + break; + + case SMDSAbs_Volume: + if ( myGeomType == SMDSGeom_TETRA ) + isOk = (!anElem->IsPoly() && aNbNode == 4); + else if ( myGeomType == SMDSGeom_PYRAMID ) + isOk = (!anElem->IsPoly() && aNbNode == 5); + else if ( myGeomType == SMDSGeom_PENTA ) + isOk = (!anElem->IsPoly() && aNbNode == 6); + else if ( myGeomType == SMDSGeom_HEXA ) + isOk = (!anElem->IsPoly() && aNbNode == 8); + else if ( myGeomType == SMDSGeom_POLYHEDRA ) + isOk = anElem->IsPoly(); + break; + default: break; + } + return isOk; +} + +void ElemGeomType::SetType( SMDSAbs_ElementType theType ) +{ + myType = theType; +} + +SMDSAbs_ElementType ElemGeomType::GetType() const +{ + return myType; +} + +void ElemGeomType::SetGeomType( SMDSAbs_GeometryType theType ) +{ + myGeomType = theType; +} + +SMDSAbs_GeometryType ElemGeomType::GetGeomType() const +{ + return myGeomType; +} + /* Class : RangeOfIds Description : Predicate for Range of Ids. diff --git a/src/Controls/SMESH_ControlsDef.hxx b/src/Controls/SMESH_ControlsDef.hxx index e400e16d4..082a08fed 100644 --- a/src/Controls/SMESH_ControlsDef.hxx +++ b/src/Controls/SMESH_ControlsDef.hxx @@ -36,6 +36,7 @@ #include #include #include +#include #include "SMDSAbs_ElementType.hxx" #include "SMDS_MeshNode.hxx" @@ -710,6 +711,83 @@ namespace SMESH{ typedef boost::shared_ptr ElementsOnShapePtr; + /* + Class : FreeFaces + Description : Predicate for free faces + */ + class SMESHCONTROLS_EXPORT FreeFaces: public virtual Predicate{ + public: + FreeFaces(); + virtual void SetMesh( const SMDS_Mesh* theMesh ); + virtual bool IsSatisfy( long theElementId ); + virtual SMDSAbs_ElementType GetType() const; + + private: + const SMDS_Mesh* myMesh; + }; + + /* + Class : LinearOrQuadratic + Description : Predicate for free faces + */ + class SMESHCONTROLS_EXPORT LinearOrQuadratic: public virtual Predicate{ + public: + LinearOrQuadratic(); + virtual void SetMesh( const SMDS_Mesh* theMesh ); + virtual bool IsSatisfy( long theElementId ); + void SetType( SMDSAbs_ElementType theType ); + virtual SMDSAbs_ElementType GetType() const; + + private: + const SMDS_Mesh* myMesh; + SMDSAbs_ElementType myType; + }; + typedef boost::shared_ptr LinearOrQuadraticPtr; + + /* + Class : GroupColor + Description : Functor for check color of group to whic mesh element belongs to + */ + class SMESHCONTROLS_EXPORT GroupColor: public virtual Predicate{ + public: + GroupColor(); + virtual void SetMesh( const SMDS_Mesh* theMesh ); + virtual bool IsSatisfy( long theElementId ); + void SetType( SMDSAbs_ElementType theType ); + virtual SMDSAbs_ElementType GetType() const; + void SetColorStr( const TCollection_AsciiString& ); + void GetColorStr( TCollection_AsciiString& ) const; + + private: + typedef std::set< long > TIDs; + + Quantity_Color myColor; + SMDSAbs_ElementType myType; + TIDs myIDs; + }; + typedef boost::shared_ptr GroupColorPtr; + + /* + Class : ElemGeomType + Description : Predicate to check element geometry type + */ + class SMESHCONTROLS_EXPORT ElemGeomType: public virtual Predicate{ + public: + ElemGeomType(); + virtual void SetMesh( const SMDS_Mesh* theMesh ); + virtual bool IsSatisfy( long theElementId ); + void SetType( SMDSAbs_ElementType theType ); + virtual SMDSAbs_ElementType GetType() const; + void SetGeomType( SMDSAbs_GeometryType theType ); + virtual SMDSAbs_GeometryType GetGeomType() const; + + private: + const SMDS_Mesh* myMesh; + SMDSAbs_ElementType myType; + SMDSAbs_GeometryType myGeomType; + }; + typedef boost::shared_ptr ElemGeomTypePtr; + /* FILTER */ diff --git a/src/OBJECT/SMESH_Actor.cxx b/src/OBJECT/SMESH_Actor.cxx index 9d78a4067..4737f9776 100644 --- a/src/OBJECT/SMESH_Actor.cxx +++ b/src/OBJECT/SMESH_Actor.cxx @@ -154,6 +154,27 @@ SMESH_ActorDef::SMESH_ActorDef() aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE); aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD); + my2DExtProp = vtkProperty::New(); + my2DExtProp->DeepCopy(mySurfaceProp); + SMESH::GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) ); + anRGB[0] = 1 - anRGB[0]; + anRGB[1] = 1 - anRGB[1]; + anRGB[2] = 1 - anRGB[2]; + my2DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]); + + my2DExtActor = SMESH_DeviceActor::New(); + my2DExtActor->SetUserMatrix(aMatrix); + my2DExtActor->PickableOff(); + my2DExtActor->SetProperty(my2DExtProp); + my2DExtActor->SetBackfaceProperty(my2DExtProp); + my2DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe); + aFilter = my2DExtActor->GetExtractUnstructuredGrid(); + aFilter->RegisterCellsWithType(VTK_TRIANGLE); + aFilter->RegisterCellsWithType(VTK_POLYGON); + aFilter->RegisterCellsWithType(VTK_QUAD); + aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE); + aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD); + my3DActor = SMESH_DeviceActor::New(); my3DActor->SetUserMatrix(aMatrix); my3DActor->PickableOff(); @@ -422,6 +443,8 @@ SMESH_ActorDef::~SMESH_ActorDef() my1DExtActor->Delete(); my2DActor->Delete(); + my2DExtProp->Delete(); + my2DExtActor->Delete(); my3DActor->Delete(); myNodeActor->Delete(); @@ -608,6 +631,10 @@ SetControlMode(eControl theMode, aFunctor.reset(new SMESH::Controls::FreeNodes()); myControlActor = myNodeActor; break; + case eFreeFaces: + aFunctor.reset(new SMESH::Controls::FreeFaces()); + myControlActor = my2DActor; + break; case eMultiConnection: aFunctor.reset(new SMESH::Controls::MultiConnection()); myControlActor = my1DActor; @@ -696,6 +723,9 @@ SetControlMode(eControl theMode, case eFreeBorders: my1DExtActor->SetExtControlMode(aFunctor); break; + case eFreeFaces: + my2DExtActor->SetExtControlMode(aFunctor); + break; case eLength2D: case eMultiConnection2D: my1DExtActor->SetExtControlMode(aFunctor,myScalarBarActor,myLookupTable); @@ -712,6 +742,7 @@ SetControlMode(eControl theMode, switch(myControlMode){ case eLength2D: case eFreeEdges: + case eFreeFaces: case eMultiConnection2D: //SetEntityMode(eEdges); SetEntityMode(eFaces); @@ -744,6 +775,7 @@ void SMESH_ActorDef::AddToRender(vtkRenderer* theRenderer){ my3DActor->AddToRender(theRenderer); my2DActor->AddToRender(theRenderer); + my2DExtActor->AddToRender(theRenderer); theRenderer->AddActor(my1DActor); theRenderer->AddActor(my1DExtActor); @@ -773,6 +805,7 @@ void SMESH_ActorDef::RemoveFromRender(vtkRenderer* theRenderer){ theRenderer->RemoveActor(my1DExtActor); my2DActor->RemoveFromRender(theRenderer); + my2DExtActor->RemoveFromRender(theRenderer); my3DActor->RemoveFromRender(theRenderer); theRenderer->RemoveActor(myScalarBarActor); @@ -804,17 +837,20 @@ bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj, my1DExtActor->Init(myVisualObj,myImplicitBoolean); my2DActor->Init(myVisualObj,myImplicitBoolean); + my2DExtActor->Init(myVisualObj,myImplicitBoolean); my3DActor->Init(myVisualObj,myImplicitBoolean); my1DActor->GetMapper()->SetLookupTable(myLookupTable); my1DExtActor->GetMapper()->SetLookupTable(myLookupTable); my2DActor->GetMapper()->SetLookupTable(myLookupTable); + my2DExtActor->GetMapper()->SetLookupTable(myLookupTable); my3DActor->GetMapper()->SetLookupTable(myLookupTable); vtkFloatingPointType aFactor, aUnits; my2DActor->GetPolygonOffsetParameters(aFactor,aUnits); my2DActor->SetPolygonOffsetParameters(aFactor,aUnits*0.75); + my2DExtActor->SetPolygonOffsetParameters(aFactor,aUnits*0.5); SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr(); if( !mgr ) @@ -870,6 +906,7 @@ void SMESH_ActorDef::SetTransform(VTKViewer_Transform* theTransform){ my1DExtActor->SetTransform(theTransform); my2DActor->SetTransform(theTransform); + my2DExtActor->SetTransform(theTransform); my3DActor->SetTransform(theTransform); Modified(); @@ -924,6 +961,7 @@ void SMESH_ActorDef::SetShrinkFactor(vtkFloatingPointType theValue){ my1DExtActor->SetShrinkFactor(theValue); my2DActor->SetShrinkFactor(theValue); + my2DExtActor->SetShrinkFactor(theValue); my3DActor->SetShrinkFactor(theValue); Modified(); @@ -938,6 +976,7 @@ void SMESH_ActorDef::SetShrink(){ my1DExtActor->SetShrink(); my2DActor->SetShrink(); + my2DExtActor->SetShrink(); my3DActor->SetShrink(); myIsShrunk = true; @@ -953,6 +992,7 @@ void SMESH_ActorDef::UnShrink(){ my1DExtActor->UnShrink(); my2DActor->UnShrink(); + my2DExtActor->UnShrink(); my3DActor->UnShrink(); myIsShrunk = false; @@ -995,6 +1035,7 @@ void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation){ my1DExtActor->VisibilityOff(); my2DActor->VisibilityOff(); + my2DExtActor->VisibilityOff(); my3DActor->VisibilityOff(); myScalarBarActor->VisibilityOff(); @@ -1014,6 +1055,9 @@ void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation){ case eFreeBorders: my1DExtActor->VisibilityOn(); break; + case eFreeFaces: + my2DExtActor->VisibilityOn(); + break; case eLength2D: case eMultiConnection2D: my1DExtActor->VisibilityOn(); @@ -1185,12 +1229,15 @@ void SMESH_ActorDef::SetRepresentation(int theMode){ my2DActor->SetProperty(aProp); my2DActor->SetBackfaceProperty(aBackProp); my2DActor->SetRepresentation(aReperesent); + + my2DExtActor->SetRepresentation(aReperesent); my3DActor->SetProperty(aProp); my3DActor->SetBackfaceProperty(aBackProp); my3DActor->SetRepresentation(aReperesent); my1DExtActor->SetVisibility(false); + my2DExtActor->SetVisibility(false); switch(myControlMode){ case eLength: @@ -1375,6 +1422,7 @@ void SMESH_ActorDef::SetSufaceColor(vtkFloatingPointType r,vtkFloatingPointType void SMESH_ActorDef::GetSufaceColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){ ::GetColor(mySurfaceProp,r,g,b); + my2DExtProp->SetColor(1.0-r,1.0-g,1.0-b); } void SMESH_ActorDef::SetBackSufaceColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){ @@ -1484,6 +1532,7 @@ SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed) my1DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed); my2DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed); + my2DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed); my3DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed); } diff --git a/src/OBJECT/SMESH_Actor.h b/src/OBJECT/SMESH_Actor.h index acabe3eb2..00e7cc87c 100644 --- a/src/OBJECT/SMESH_Actor.h +++ b/src/OBJECT/SMESH_Actor.h @@ -97,8 +97,8 @@ class SMESHOBJECT_EXPORT SMESH_Actor: public SALOME_Actor virtual bool GetFacesOriented() = 0; enum eControl{eNone, eLength, eLength2D, eFreeBorders, eFreeEdges, eFreeNodes, - eMultiConnection, eArea, eTaper, eAspectRatio, eMinimumAngle, eWarping, - eSkew, eAspectRatio3D, eMultiConnection2D, eVolume3D}; + eFreeFaces, eMultiConnection, eArea, eTaper, eAspectRatio, + eMinimumAngle, eWarping, eSkew, eAspectRatio3D, eMultiConnection2D, eVolume3D}; virtual void SetControlMode(eControl theMode) = 0; virtual eControl GetControlMode() = 0; diff --git a/src/OBJECT/SMESH_ActorDef.h b/src/OBJECT/SMESH_ActorDef.h index 6fc67894a..471d4099d 100644 --- a/src/OBJECT/SMESH_ActorDef.h +++ b/src/OBJECT/SMESH_ActorDef.h @@ -216,7 +216,9 @@ class SMESH_ActorDef : public SMESH_Actor SMESH_DeviceActor* myHighlitableActor; eControl myControlMode; + vtkProperty* my2DExtProp; SMESH_DeviceActor* my2DActor; + SMESH_DeviceActor* my2DExtActor; SMESH_DeviceActor* my3DActor; SMESH_DeviceActor* myControlActor; diff --git a/src/OBJECT/SMESH_DeviceActor.cxx b/src/OBJECT/SMESH_DeviceActor.cxx index cc0ca91dc..a268b6afb 100644 --- a/src/OBJECT/SMESH_DeviceActor.cxx +++ b/src/OBJECT/SMESH_DeviceActor.cxx @@ -485,13 +485,15 @@ SMESH_DeviceActor myVisualObj->UpdateFunctor(theFunctor); using namespace SMESH::Controls; - if(FreeBorders* aFreeBorders = dynamic_cast(theFunctor.get())){ + if ( dynamic_cast(theFunctor.get()) || + dynamic_cast(theFunctor.get()) ) { + Predicate* aFreePredicate = dynamic_cast(theFunctor.get()); myExtractUnstructuredGrid->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding); vtkUnstructuredGrid* aGrid = myVisualObj->GetUnstructuredGrid(); vtkIdType aNbCells = aGrid->GetNumberOfCells(); for( vtkIdType i = 0; i < aNbCells; i++ ){ vtkIdType anObjId = myVisualObj->GetElemObjId(i); - if(aFreeBorders->IsSatisfy(anObjId)) + if(aFreePredicate->IsSatisfy(anObjId)) myExtractUnstructuredGrid->RegisterCell(i); } if(!myExtractUnstructuredGrid->IsCellsRegistered()) @@ -544,8 +546,7 @@ SMESH_DeviceActor SetUnstructuredGrid(aDataSet); aDataSet->Delete(); - } - else if(FreeNodes* aFreeNodes = dynamic_cast(theFunctor.get())){ + }else if(FreeNodes* aFreeNodes = dynamic_cast(theFunctor.get())){ myExtractUnstructuredGrid->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding); vtkUnstructuredGrid* aGrid = myVisualObj->GetUnstructuredGrid(); vtkIdType aNbCells = aGrid->GetNumberOfCells(); diff --git a/src/SMDS/SMDSAbs_ElementType.hxx b/src/SMDS/SMDSAbs_ElementType.hxx index 0ce02cd9a..962100685 100644 --- a/src/SMDS/SMDSAbs_ElementType.hxx +++ b/src/SMDS/SMDSAbs_ElementType.hxx @@ -39,6 +39,26 @@ enum SMDSAbs_ElementType SMDSAbs_NbElementTypes }; +/*! enumeration for element geometry type */ +enum SMDSAbs_GeometryType +{ + // 0D element + SMDSGeom_POINT, + // 1D element + SMDSGeom_EDGE, + // 2D element + SMDSGeom_TRIANGLE, + SMDSGeom_QUADRANGLE, + SMDSGeom_POLYGON, + // 3D element + SMDSGeom_TETRA, + SMDSGeom_PYRAMID, + SMDSGeom_PENTA, + SMDSGeom_HEXA, + SMDSGeom_POLYHEDRA, +}; + + enum SMDSAbs_ElementOrder { ORDER_ANY, /*! entities of any order */ ORDER_LINEAR, /*! entities of 1st order */ diff --git a/src/SMESHGUI/SMESHGUI.cxx b/src/SMESHGUI/SMESHGUI.cxx index df1f47522..88042cf96 100644 --- a/src/SMESHGUI/SMESHGUI.cxx +++ b/src/SMESHGUI/SMESHGUI.cxx @@ -811,6 +811,10 @@ aTitle = QObject::tr( "SMESH_VOLUME" ); aControl = SMESH_Actor::eVolume3D; break; + case 6021: + aTitle = QObject::tr( "FREE_FACES" ); + aControl = SMESH_Actor::eFreeFaces; + break; } anActor->SetControlMode(aControl); anActor->GetScalarBarActor()->SetTitle(aTitle.toLatin1().data()); @@ -2431,6 +2435,7 @@ bool SMESHGUI::OnGUIEvent( int theCommandID ) case 6004: case 6005: case 6009: + case 6021: if ( vtkwnd ) { LightApp_SelectionMgr* mgr = selectionMgr(); @@ -2654,6 +2659,7 @@ void SMESHGUI::initialize( CAM_Application* app ) createSMESHAction( 903, "WHAT_IS", "ICON_WHAT_IS" ); createSMESHAction( 6001, "LENGTH", "ICON_LENGTH", 0, true ); createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE", 0, true ); + createSMESHAction( 6021, "FREE_FACES", "ICON_FREE_FACES", 0, true ); createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D", 0, true ); createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION", 0, true ); createSMESHAction( 6005, "FREE_NODE", "ICON_FREE_NODE", 0, true ); @@ -2813,6 +2819,7 @@ void SMESHGUI::initialize( CAM_Application* app ) createMenu( separator(), ctrlId, -1 ); createMenu( 6017, ctrlId, -1 ); createMenu( 6009, ctrlId, -1 ); + createMenu( 6021, ctrlId, -1 ); createMenu( separator(), ctrlId, -1 ); createMenu( 400, addId, -1 ); @@ -2905,6 +2912,7 @@ void SMESHGUI::initialize( CAM_Application* app ) createTool( separator(), ctrlTb ); createTool( 6017, ctrlTb ); createTool( 6009, ctrlTb ); + createTool( 6021, ctrlTb ); createTool( separator(), ctrlTb ); createTool( 400, addRemTb ); @@ -3223,6 +3231,11 @@ void SMESHGUI::initialize( CAM_Application* app ) popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule ); popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", QtxPopupMgr::ToggleRule ); + popupMgr()->insert( action( 6021 ), anId, -1 ); // FREE_FACE + popupMgr()->setRule( action( 6021 ), aMeshInVtkHasFaces /*aMeshInVtkHasVolumes*/, + QtxPopupMgr::VisibleRule ); + popupMgr()->setRule( action( 6021 ), "controlMode = 'eFreeFaces'", QtxPopupMgr::ToggleRule ); + popupMgr()->insert( separator(), anId, -1 ); popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP diff --git a/src/SMESHGUI/SMESHGUI_ExtrusionAlongPathDlg.cxx b/src/SMESHGUI/SMESHGUI_ExtrusionAlongPathDlg.cxx index 80298f7c8..7be8b336c 100644 --- a/src/SMESHGUI/SMESHGUI_ExtrusionAlongPathDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_ExtrusionAlongPathDlg.cxx @@ -32,6 +32,7 @@ #include "SMESHGUI_MeshUtils.h" #include "SMESHGUI_SpinBox.h" #include "SMESHGUI_IdValidator.h" +#include "SMESHGUI_FilterDlg.h" #include #include @@ -109,7 +110,8 @@ private: SMESHGUI_ExtrusionAlongPathDlg::SMESHGUI_ExtrusionAlongPathDlg( SMESHGUI* theModule ) : QDialog( SMESH::GetDesktop( theModule ) ), mySMESHGUI( theModule ), - mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ) + mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ), + myFilterDlg( 0 ) { SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( mySMESHGUI ); QPixmap edgeImage ( mgr->loadPixmap("SMESH", tr("ICON_DLG_EDGE"))); @@ -164,6 +166,8 @@ SMESHGUI_ExtrusionAlongPathDlg::SMESHGUI_ExtrusionAlongPathDlg( SMESHGUI* theMod ElementsLineEdit = new QLineEdit(GroupArguments); ElementsLineEdit->setValidator(myIdValidator); + QPushButton* filterBtn = new QPushButton( tr( "SMESH_BUT_FILTER" ), GroupArguments ); + connect(filterBtn, SIGNAL(clicked()), this, SLOT(setFilters())); // Controls for the whole mesh selection MeshCheck = new QCheckBox(tr("SMESH_SELECT_WHOLE_MESH"), GroupArguments); @@ -272,11 +276,12 @@ SMESHGUI_ExtrusionAlongPathDlg::SMESHGUI_ExtrusionAlongPathDlg( SMESHGUI* theMod GroupArgumentsLayout->addWidget(ElementsLab, 0, 0); GroupArgumentsLayout->addWidget(SelectElementsButton, 0, 1); GroupArgumentsLayout->addWidget(ElementsLineEdit, 0, 2); - GroupArgumentsLayout->addWidget(MeshCheck, 1, 0, 1, 3); - GroupArgumentsLayout->addWidget(PathGrp, 2, 0, 1, 3); - GroupArgumentsLayout->addWidget(BasePointGrp, 3, 0, 1, 3); - GroupArgumentsLayout->addWidget(AnglesGrp, 4, 0, 1, 3); - GroupArgumentsLayout->addWidget(MakeGroupsCheck, 5, 0, 1, 3); + GroupArgumentsLayout->addWidget(filterBtn, 0, 3); + GroupArgumentsLayout->addWidget(MeshCheck, 1, 0, 1, 4); + GroupArgumentsLayout->addWidget(PathGrp, 2, 0, 1, 4); + GroupArgumentsLayout->addWidget(BasePointGrp, 3, 0, 1, 4); + GroupArgumentsLayout->addWidget(AnglesGrp, 4, 0, 1, 4); + GroupArgumentsLayout->addWidget(MakeGroupsCheck, 5, 0, 1, 4); /***************************************************************/ // common buttons group box @@ -382,6 +387,10 @@ SMESHGUI_ExtrusionAlongPathDlg::SMESHGUI_ExtrusionAlongPathDlg( SMESHGUI* theMod SMESHGUI_ExtrusionAlongPathDlg::~SMESHGUI_ExtrusionAlongPathDlg() { // no need to delete child widgets, Qt does it all for us + if ( myFilterDlg != 0 ) { + myFilterDlg->setParent( 0 ); + delete myFilterDlg; + } } //================================================================================= @@ -693,8 +702,11 @@ void SMESHGUI_ExtrusionAlongPathDlg::reject() disconnect(mySelectionMgr, 0, this, 0); mySelectionMgr->clearFilters(); //mySelectionMgr->clearSelected(); - SMESH::SetPickable(); // ??? - SMESH::SetPointRepresentation(false); + if (SMESH::GetCurrentVtkView()) { + SMESH::RemoveFilters(); // PAL6938 -- clean all mesh entity filters + SMESH::SetPointRepresentation(false); + SMESH::SetPickable(); + } if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) aViewWindow->SetSelectionMode(ActorSelection); mySMESHGUI->ResetState(); @@ -1199,3 +1211,25 @@ void SMESHGUI_ExtrusionAlongPathDlg::keyPressEvent( QKeyEvent* e ) ClickOnHelp(); } } + +//================================================================================= +// function : setFilters() +// purpose : SLOT. Called when "Filter" button pressed. +//================================================================================= +void SMESHGUI_ExtrusionAlongPathDlg::setFilters() +{ + if ( !myFilterDlg ) + { + QList types; + types.append( SMESH::EDGE ); + types.append( SMESH::FACE ); + myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, types ); + } + myFilterDlg->Init( Elements1dRB->isChecked() ? SMESH::EDGE : SMESH::FACE ); + + myFilterDlg->SetSelection(); + myFilterDlg->SetMesh( myMesh ); + myFilterDlg->SetSourceWg( ElementsLineEdit ); + + myFilterDlg->show(); +} diff --git a/src/SMESHGUI/SMESHGUI_ExtrusionAlongPathDlg.h b/src/SMESHGUI/SMESHGUI_ExtrusionAlongPathDlg.h index 6885b738e..48abcd7b3 100644 --- a/src/SMESHGUI/SMESHGUI_ExtrusionAlongPathDlg.h +++ b/src/SMESHGUI/SMESHGUI_ExtrusionAlongPathDlg.h @@ -50,6 +50,7 @@ class SMESHGUI; class SMESH_Actor; class SMESHGUI_IdValidator; class SMESHGUI_SpinBox; +class SMESHGUI_FilterDlg; class SVTK_Selector; class LightApp_SelectionMgr; class SUIT_SelectionFilter; @@ -134,6 +135,8 @@ private: QString myHelpFileName; + SMESHGUI_FilterDlg* myFilterDlg; + protected slots: void reject(); @@ -150,6 +153,7 @@ private slots: void onSelectMesh(); void OnAngleAdded(); void OnAngleRemoved(); + void setFilters(); }; #endif // SMESHGUI_EXTRUSIONALONGPATHDLG_H diff --git a/src/SMESHGUI/SMESHGUI_ExtrusionDlg.cxx b/src/SMESHGUI/SMESHGUI_ExtrusionDlg.cxx index 196720eb2..9efeb3dc1 100644 --- a/src/SMESHGUI/SMESHGUI_ExtrusionDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_ExtrusionDlg.cxx @@ -32,6 +32,7 @@ #include "SMESHGUI_MeshUtils.h" #include "SMESHGUI_SpinBox.h" #include "SMESHGUI_IdValidator.h" +#include "SMESHGUI_FilterDlg.h" #include #include @@ -87,7 +88,8 @@ SMESHGUI_ExtrusionDlg::SMESHGUI_ExtrusionDlg (SMESHGUI* theModule) : QDialog( SMESH::GetDesktop( theModule ) ), mySMESHGUI( theModule ), - mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ) + mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ), + myFilterDlg( 0 ) { QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_DLG_EDGE"))); QPixmap image1 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_DLG_TRIANGLE"))); @@ -160,6 +162,8 @@ SMESHGUI_ExtrusionDlg::SMESHGUI_ExtrusionDlg (SMESHGUI* theModule) LineEditElements = new QLineEdit(GroupArguments); LineEditElements->setValidator(myIdValidator); + QPushButton* filterBtn = new QPushButton( tr( "SMESH_BUT_FILTER" ), GroupArguments ); + connect(filterBtn, SIGNAL(clicked()), this, SLOT(setFilters())); // Control for the whole mesh selection CheckBoxMesh = new QCheckBox(tr("SMESH_SELECT_WHOLE_MESH"), GroupArguments); @@ -200,7 +204,8 @@ SMESHGUI_ExtrusionDlg::SMESHGUI_ExtrusionDlg (SMESHGUI* theModule) GroupArgumentsLayout->addWidget(TextLabelElements, 0, 0); GroupArgumentsLayout->addWidget(SelectElementsButton, 0, 1); - GroupArgumentsLayout->addWidget(LineEditElements, 0, 2, 1, 6); + GroupArgumentsLayout->addWidget(LineEditElements, 0, 2, 1, 5); + GroupArgumentsLayout->addWidget(filterBtn, 0, 7); GroupArgumentsLayout->addWidget(CheckBoxMesh, 1, 0, 1, 8); GroupArgumentsLayout->addWidget(TextLabelDistance, 2, 0); GroupArgumentsLayout->addWidget(TextLabelDx, 2, 2); @@ -296,6 +301,10 @@ SMESHGUI_ExtrusionDlg::SMESHGUI_ExtrusionDlg (SMESHGUI* theModule) //================================================================================= SMESHGUI_ExtrusionDlg::~SMESHGUI_ExtrusionDlg() { + if ( myFilterDlg != 0 ) { + myFilterDlg->setParent( 0 ); + delete myFilterDlg; + } } //================================================================================= @@ -452,8 +461,11 @@ void SMESHGUI_ExtrusionDlg::ClickOnCancel() disconnect(mySelectionMgr, 0, this, 0); mySelectionMgr->clearFilters(); //mySelectionMgr->clearSelected(); - SMESH::SetPickable(); // ??? - SMESH::SetPointRepresentation(false); + if (SMESH::GetCurrentVtkView()) { + SMESH::RemoveFilters(); // PAL6938 -- clean all mesh entity filters + SMESH::SetPointRepresentation(false); + SMESH::SetPickable(); + } if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) aViewWindow->SetSelectionMode(ActorSelection); mySMESHGUI->ResetState(); @@ -822,3 +834,25 @@ void SMESHGUI_ExtrusionDlg::keyPressEvent( QKeyEvent* e ) ClickOnHelp(); } } + +//================================================================================= +// function : setFilters() +// purpose : SLOT. Called when "Filter" button pressed. +//================================================================================= +void SMESHGUI_ExtrusionDlg::setFilters() +{ + if ( !myFilterDlg ) + { + QList types; + types.append( SMESH::EDGE ); + types.append( SMESH::FACE ); + myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, types ); + } + myFilterDlg->Init( GetConstructorId() ? SMESH::FACE : SMESH::EDGE ); + + myFilterDlg->SetSelection(); + myFilterDlg->SetMesh( myMesh ); + myFilterDlg->SetSourceWg( LineEditElements ); + + myFilterDlg->show(); +} diff --git a/src/SMESHGUI/SMESHGUI_ExtrusionDlg.h b/src/SMESHGUI/SMESHGUI_ExtrusionDlg.h index 252ac0274..cf8eefd87 100644 --- a/src/SMESHGUI/SMESHGUI_ExtrusionDlg.h +++ b/src/SMESHGUI/SMESHGUI_ExtrusionDlg.h @@ -52,6 +52,7 @@ class SMESHGUI; class SMESH_Actor; class SMESHGUI_IdValidator; class SMESHGUI_SpinBox; +class SMESHGUI_FilterDlg; class SVTK_Selector; class LightApp_SelectionMgr; class SUIT_SelectionFilter; @@ -126,6 +127,8 @@ private: QString myHelpFileName; + SMESHGUI_FilterDlg* myFilterDlg; + private slots: void ConstructorsClicked( int ); void CheckIsEnable(); @@ -139,6 +142,7 @@ private slots: void ActivateThisDialog(); void onTextChange( const QString& ); void onSelectMesh( bool ); + void setFilters(); }; #endif // SMESHGUI_EXTRUSIONDLG_H diff --git a/src/SMESHGUI/SMESHGUI_Filter.cxx b/src/SMESHGUI/SMESHGUI_Filter.cxx index de8af3acd..83ba736a8 100755 --- a/src/SMESHGUI/SMESHGUI_Filter.cxx +++ b/src/SMESHGUI/SMESHGUI_Filter.cxx @@ -82,17 +82,18 @@ bool SMESHGUI_PredicateFilter::IsValid( const int theCellId ) const return false; SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh(); - SMESH::ElementType anElemType = myPred->GetElementType(); - int aMeshId = anElemType == SMESH::NODE ? anActor->GetNodeObjId( theCellId ) - : anActor->GetElemObjId( theCellId ); + SMDSAbs_ElementType anElemType = (SMDSAbs_ElementType)myPred->GetElementType(); + int aMeshId = anElemType == SMDSAbs_Node ? anActor->GetNodeObjId( theCellId ) + : anActor->GetElemObjId( theCellId ); // if type of element != type of predicate return true because // this predicate is not intended for filtering sush elements - const SMDS_MeshElement* anElem = anElemType == SMESH::NODE ? aMesh->FindNode( aMeshId ) - : aMesh->FindElement( aMeshId ); - if ( anElem != 0 && anElem->GetType() != (SMDSAbs_ElementType)myPred->GetElementType() ) - return true; - + const SMDS_MeshElement* anElem = anElemType == SMDSAbs_Node ? aMesh->FindNode( aMeshId ) + : aMesh->FindElement( aMeshId ); + // here we guess that predicate element type can not be All in case of node selection + if ( !anElem || (anElemType != SMDSAbs_All && anElem->GetType() != anElemType) ) + return false; + return myPred->IsSatisfy( aMeshId ); } @@ -110,14 +111,15 @@ bool SMESHGUI_PredicateFilter::IsObjValid( const int theObjId ) const return false; SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh(); - SMESH::ElementType anElemType = myPred->GetElementType(); + SMDSAbs_ElementType anElemType = (SMDSAbs_ElementType)myPred->GetElementType(); // if type of element != type of predicate return true because // this predicate is not intended for filtering sush elements - const SMDS_MeshElement* anElem = anElemType == SMESH::NODE ? aMesh->FindNode( theObjId ) - : aMesh->FindElement( theObjId ); - if ( anElem != 0 && anElem->GetType() != (SMDSAbs_ElementType)myPred->GetElementType() ) - return true; + const SMDS_MeshElement* anElem = anElemType == SMDSAbs_Node ? aMesh->FindNode( theObjId ) + : aMesh->FindElement( theObjId ); + // here we guess that predicate element type can not be All in case of node selection + if ( !anElem || (anElemType != SMDSAbs_All && anElem->GetType() != anElemType) ) + return false; return myPred->IsSatisfy( theObjId ); } diff --git a/src/SMESHGUI/SMESHGUI_FilterDlg.cxx b/src/SMESHGUI/SMESHGUI_FilterDlg.cxx index c1d720283..6cee1b45d 100755 --- a/src/SMESHGUI/SMESHGUI_FilterDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_FilterDlg.cxx @@ -47,6 +47,8 @@ #include #include #include +#include +#include #include #include @@ -699,8 +701,6 @@ void SMESHGUI_FilterTable::Init (const QList& theTypes) if (myTables.isEmpty()) { - int aType = theTypes.first(); - // create main layout QVBoxLayout* aMainLay = new QVBoxLayout(this); aMainLay->setMargin( 0 ); @@ -730,8 +730,14 @@ void SMESHGUI_FilterTable::Init (const QList& theTypes) mySwitchTableGrpLayout->setMargin(0); mySwitchTableGrpLayout->setSpacing(0); - myTables[ aType ] = createTable(mySwitchTableGrp, aType); - mySwitchTableGrpLayout->addWidget(myTables[ aType ]); + QList::const_iterator typeIt = theTypes.begin(); + for ( ; typeIt != theTypes.end(); ++typeIt ) { + Table* aTable = createTable(mySwitchTableGrp, *typeIt); + myTables[ *typeIt ] = aTable; + mySwitchTableGrpLayout->addWidget(aTable); + if ( typeIt != theTypes.begin() ) + aTable->hide(); + } // create buttons myAddBtn = new QPushButton(tr("ADD"), myTableGrp); @@ -899,41 +905,43 @@ bool SMESHGUI_FilterTable::IsValid (const bool theMess, const int theEntityType) for (int i = 0, n = aTable->rowCount(); i < n; i++) { int aCriterion = GetCriterionType(i, aType); - - if (aCriterion == SMESH::FT_RangeOfIds || + QString errMsg; + if (aCriterion == SMESH::FT_GroupColor ) { + QtxColorButton* clrBtn = qobject_cast(aTable->cellWidget(i, 2)); + if (clrBtn && !clrBtn->color().isValid()) + errMsg = tr( "GROUPCOLOR_ERROR" ); + } else if (aCriterion == SMESH::FT_ElemGeomType ) { + QtxComboBox* typeBox = qobject_cast(aTable->cellWidget(i, 2)); + if (typeBox && typeBox->currentId() == -1) + errMsg = tr( "ERROR" ); + } else if (aCriterion == SMESH::FT_RangeOfIds || aCriterion == SMESH::FT_BelongToGeom || aCriterion == SMESH::FT_BelongToPlane || aCriterion == SMESH::FT_BelongToCylinder || aCriterion == SMESH::FT_BelongToGenSurface || aCriterion == SMESH::FT_LyingOnGeom) { - if (aTable->text(i, 2).isEmpty()) { - if (theMess) - SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"), - tr("ERROR")); - return false; - } - } else { + if (aTable->text(i, 2).isEmpty()); + errMsg = tr( "ERROR" ); + } + else { bool aRes = false; bool isSignalsBlocked = aTable->signalsBlocked(); aTable->blockSignals(true); double aThreshold = (int)aTable->text(i, 2).toDouble(&aRes); aTable->blockSignals(isSignalsBlocked); - if (!aRes && aTable->isEditable(i, 2)) { - if (theMess) - SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"), - tr("ERROR")); - return false; - } + if (!aRes && aTable->isEditable(i, 2)) + errMsg = tr( "ERROR" ); else if (aType == SMESH::EDGE && GetCriterionType(i, aType) == SMESH::FT_MultiConnection && aThreshold == 1) - { - if (theMess) - SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"), - tr("MULTIEDGES_ERROR")); - return false; - } + errMsg = tr( "MULTIEDGES_ERROR" ); + } + + if (!errMsg.isEmpty()) { + if (theMess) + SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"), errMsg ); + return false; } QTableWidgetItem* anItem = aTable->item(i, 0); @@ -1012,12 +1020,28 @@ void SMESHGUI_FilterTable::GetCriterion (const int theRow, int aCriterionType = GetCriterionType(theRow, aType); - if ( aCriterionType != SMESH::FT_RangeOfIds && - aCriterionType != SMESH::FT_BelongToGeom && - aCriterionType != SMESH::FT_BelongToPlane && - aCriterionType != SMESH::FT_BelongToCylinder && - aCriterionType != SMESH::FT_BelongToGenSurface && - aCriterionType != SMESH::FT_LyingOnGeom) + if ( aCriterionType == SMESH::FT_GroupColor ) + { + QtxColorButton* clrBtn = qobject_cast(aTable->cellWidget(theRow, 2)); + if ( clrBtn ) + { + const QColor qClr = clrBtn->color(); + QString clrStr = QString( "%1;%2;%3" ). + arg( qClr.red()/256. ).arg( qClr.green()/256. ).arg( qClr.blue()/256. ); + theCriterion.ThresholdStr = clrStr.toLatin1().constData(); + } + } + else if ( aCriterionType == SMESH::FT_ElemGeomType ) { + QtxComboBox* typeBox = qobject_cast(aTable->cellWidget(theRow, 2)); + if ( typeBox ) + theCriterion.Threshold = (double)typeBox->currentId(); + } + else if ( aCriterionType != SMESH::FT_RangeOfIds && + aCriterionType != SMESH::FT_BelongToGeom && + aCriterionType != SMESH::FT_BelongToPlane && + aCriterionType != SMESH::FT_BelongToCylinder && + aCriterionType != SMESH::FT_BelongToGenSurface && + aCriterionType != SMESH::FT_LyingOnGeom) { theCriterion.Compare = ((ComboItem*)aTable->item(theRow, 1))->value(); theCriterion.Threshold = aTable->item(theRow, 2)->text().toDouble(); @@ -1063,7 +1087,28 @@ void SMESHGUI_FilterTable::SetCriterion (const int theRow, else aTable->setEditable(false, theRow, 4); - if (theCriterion.Type != SMESH::FT_RangeOfIds && + if (theCriterion.Type == SMESH::FT_GroupColor ) + { + QtxColorButton* clrBtn = qobject_cast(aTable->cellWidget(theRow, 2)); + if ( clrBtn ) + { + QColor qClr; + QString clrStr( theCriterion.ThresholdStr ); + QStringList clrVals = clrStr.split( ";" ); + if ( clrVals.count() > 2 ) + qClr.setRgb( (int)256*clrVals[0].toDouble(), + (int)256*clrVals[1].toDouble(), + (int)256*clrVals[2].toDouble() ); + clrBtn->setColor( qClr ); + } + } + else if (theCriterion.Type == SMESH::FT_ElemGeomType ) + { + QtxComboBox* typeBox = qobject_cast(aTable->cellWidget(theRow, 2)); + if ( typeBox ) + typeBox->setCurrentId( (int)(theCriterion.Threshold + 0.5) ); + } + else if (theCriterion.Type != SMESH::FT_RangeOfIds && theCriterion.Type != SMESH::FT_BelongToGeom && theCriterion.Type != SMESH::FT_BelongToPlane && theCriterion.Type != SMESH::FT_BelongToCylinder && @@ -1072,7 +1117,9 @@ void SMESHGUI_FilterTable::SetCriterion (const int theRow, theCriterion.Type != SMESH::FT_FreeBorders && theCriterion.Type != SMESH::FT_FreeEdges && theCriterion.Type != SMESH::FT_FreeNodes && - theCriterion.Type != SMESH::FT_BadOrientedVolume) + theCriterion.Type != SMESH::FT_FreeFaces && + theCriterion.Type != SMESH::FT_BadOrientedVolume && + theCriterion.Type != SMESH::FT_LinearOrQuadratic) aTable->item( theRow, 2 )->setText(QString("%1").arg(theCriterion.Threshold, 0, 'g', 15)); else { @@ -1223,12 +1270,15 @@ void SMESHGUI_FilterTable::updateAdditionalWidget() } ComboItem* anItem = ((ComboItem*)aTable->item(aRow, 0)); + int aCriterion = GetCriterionType(aRow); bool toEnable = ((ComboItem*)aTable->item(aRow, 1))->value() == SMESH::FT_EqualTo && - GetCriterionType(aRow) != SMESH::FT_BelongToGeom && - GetCriterionType(aRow) != SMESH::FT_LyingOnGeom && - GetCriterionType(aRow) != SMESH::FT_RangeOfIds && - GetCriterionType(aRow) != SMESH::FT_FreeEdges && - GetCriterionType(aRow) != SMESH::FT_BadOrientedVolume; + aCriterion != SMESH::FT_BelongToGeom && + aCriterion != SMESH::FT_LyingOnGeom && + aCriterion != SMESH::FT_RangeOfIds && + aCriterion != SMESH::FT_FreeEdges && + aCriterion != SMESH::FT_FreeFaces && + aCriterion != SMESH::FT_BadOrientedVolume; + if (!myAddWidgets.contains(anItem)) { myAddWidgets[ anItem ] = new AdditionalWidget(myWgStack); @@ -1288,6 +1338,34 @@ void SMESHGUI_FilterTable::onCurrentChanged (int theRow, int theCol) emit CurrentChanged(theRow, theCol); } +//======================================================================= +// name : geomTypes +// Purpose : returns available geometry types of elements +//======================================================================= +static QList geomTypes( const int theType ) +{ + QList typeIds; + if ( theType == SMESH::NODE ) + typeIds.append( SMESH::Geom_POINT ); + if ( theType == SMESH::ALL || theType == SMESH::EDGE ) + typeIds.append( SMESH::Geom_EDGE ); + if ( theType == SMESH::ALL || theType == SMESH::FACE ) + { + typeIds.append( SMESH::Geom_TRIANGLE ); + typeIds.append( SMESH::Geom_QUADRANGLE ); + typeIds.append( SMESH::Geom_POLYGON ); + } + if ( theType == SMESH::ALL || theType == SMESH::VOLUME ) + { + typeIds.append( SMESH::Geom_TETRA ); + typeIds.append( SMESH::Geom_PYRAMID ); + typeIds.append( SMESH::Geom_HEXA ); + typeIds.append( SMESH::Geom_PENTA ); + typeIds.append( SMESH::Geom_POLYHEDRA ); + } + return typeIds; +} + //======================================================================= // name : SMESHGUI_FilterTable::onCriterionChanged() // Purpose : Provides reaction on change of criterion @@ -1299,11 +1377,47 @@ void SMESHGUI_FilterTable::onCriterionChanged (const int row, const int col, con ComboItem* aCompareItem = (ComboItem*)aTable->item(row, 1); int aCriterionType = GetCriterionType(row); + QtxColorButton* clrBtn = qobject_cast(aTable->cellWidget(row, 2)); + QtxComboBox* typeBox = qobject_cast(aTable->cellWidget(row, 2)); + + if ( (aCriterionType == SMESH::FT_GroupColor && !clrBtn) || + (aCriterionType == SMESH::FT_ElemGeomType && !typeBox) ) + { + bool isSignalsBlocked = aTable->signalsBlocked(); + aTable->blockSignals( true ); + if ( aCriterionType == SMESH::FT_GroupColor ) + aTable->setCellWidget( row, 2, new QtxColorButton( aTable ) ); + else { + QtxComboBox* typeBox = new QtxComboBox( aTable ); + aTable->setCellWidget( row, 2, typeBox ); + QList typeIds = geomTypes( aType ); + QList::const_iterator anIter = typeIds.begin(); + for ( int i = 0; anIter != typeIds.end(); ++anIter, ++i) { + QString typeKey = QString( "GEOM_TYPE_%1" ).arg( *anIter ); + typeBox->addItem( tr( typeKey.toLatin1().data() ) ); + typeBox->setId( i, *anIter ); + } + } + aTable->blockSignals( isSignalsBlocked ); + } + else if ( (aCriterionType != SMESH::FT_GroupColor && clrBtn) || + (aCriterionType != SMESH::FT_ElemGeomType && typeBox) ) + { + bool isSignalsBlocked = aTable->signalsBlocked(); + aTable->blockSignals( true ); + aTable->setCellWidget( row, 2, 0 ); + aTable->setItem( row, 2, new QTableWidgetItem() ); + aTable->blockSignals( isSignalsBlocked ); + } - if ( aType == SMESH::NODE && aCriterionType == SMESH::FT_FreeNodes || - aType == SMESH::EDGE && aCriterionType == SMESH::FT_FreeBorders || - aType == SMESH::FACE && aCriterionType == SMESH::FT_FreeEdges || - aType == SMESH::VOLUME && aCriterionType == SMESH::FT_BadOrientedVolume) + if (aType == SMESH::NODE && aCriterionType == SMESH::FT_FreeNodes || + aType == SMESH::EDGE && aCriterionType == SMESH::FT_FreeBorders || + aType == SMESH::FACE && (aCriterionType == SMESH::FT_FreeEdges || + aCriterionType == SMESH::FT_FreeFaces) || + aType == SMESH::VOLUME && aCriterionType == SMESH::FT_BadOrientedVolume || + aCriterionType == SMESH::FT_LinearOrQuadratic || + aCriterionType == SMESH::FT_GroupColor || + aCriterionType == SMESH::FT_ElemGeomType) { bool isSignalsBlocked = aTable->signalsBlocked(); aTable->blockSignals( true ); @@ -1311,8 +1425,8 @@ void SMESHGUI_FilterTable::onCriterionChanged (const int row, const int col, con if (aCompareItem->count() > 0) aCompareItem->clear(); aTable->setEditable(false, row, 1); - aTable->setEditable(false, row, 2); - + aTable->setEditable(aCriterionType == SMESH::FT_GroupColor || + aCriterionType == SMESH::FT_ElemGeomType, row, 2); aTable->blockSignals( isSignalsBlocked ); } else if (aCriterionType == SMESH::FT_RangeOfIds || @@ -1330,6 +1444,12 @@ void SMESHGUI_FilterTable::onCriterionChanged (const int row, const int col, con if (!aTable->isEditable(row, 2)) aTable->setEditable(true, row, 2); } + else if (aCriterionType == SMESH::FT_GroupColor || + aCriterionType == SMESH::FT_ElemGeomType) + { + if (!aTable->isEditable(row, 2)) + aTable->setEditable(true, row, 2); + } else { if (aCompareItem->count() != 3) @@ -1507,6 +1627,7 @@ const QMap& SMESHGUI_FilterTable::getSupportedTypes() const aTypes[ SMESH::EDGE ] = tr("EDGES"); aTypes[ SMESH::FACE ] = tr("FACES"); aTypes[ SMESH::VOLUME ] = tr("VOLUMES"); + aTypes[ SMESH::ALL ] = tr("ELEMENTS"); } return aTypes; @@ -1530,6 +1651,7 @@ const QMap& SMESHGUI_FilterTable::getCriteria (const int theType) aCriteria[ SMESH::FT_BelongToGenSurface ] = tr("BELONG_TO_GENSURFACE"); aCriteria[ SMESH::FT_LyingOnGeom ] = tr("LYING_ON_GEOM"); aCriteria[ SMESH::FT_FreeNodes ] = tr("FREE_NODES"); + aCriteria[ SMESH::FT_GroupColor ] = tr("GROUP_COLOR"); } return aCriteria; } @@ -1547,6 +1669,9 @@ const QMap& SMESHGUI_FilterTable::getCriteria (const int theType) aCriteria[ SMESH::FT_BelongToCylinder ] = tr("BELONG_TO_CYLINDER"); aCriteria[ SMESH::FT_BelongToGenSurface ] = tr("BELONG_TO_GENSURFACE"); aCriteria[ SMESH::FT_LyingOnGeom ] = tr("LYING_ON_GEOM"); + aCriteria[ SMESH::FT_LinearOrQuadratic ] = tr("LINEAR"); + aCriteria[ SMESH::FT_GroupColor ] = tr("GROUP_COLOR"); + aCriteria[ SMESH::FT_ElemGeomType ] = tr("GEOM_TYPE"); } return aCriteria; } @@ -1570,6 +1695,10 @@ const QMap& SMESHGUI_FilterTable::getCriteria (const int theType) aCriteria[ SMESH::FT_LyingOnGeom ] = tr("LYING_ON_GEOM"); aCriteria[ SMESH::FT_Length2D ] = tr("LENGTH2D"); aCriteria[ SMESH::FT_MultiConnection2D ] = tr("MULTI2D_BORDERS"); + aCriteria[ SMESH::FT_FreeFaces ] = tr("FREE_FACES"); + aCriteria[ SMESH::FT_LinearOrQuadratic ] = tr("LINEAR"); + aCriteria[ SMESH::FT_GroupColor ] = tr("GROUP_COLOR"); + aCriteria[ SMESH::FT_ElemGeomType ] = tr("GEOM_TYPE"); } return aCriteria; } @@ -1584,12 +1713,25 @@ const QMap& SMESHGUI_FilterTable::getCriteria (const int theType) aCriteria[ SMESH::FT_LyingOnGeom ] = tr("LYING_ON_GEOM"); aCriteria[ SMESH::FT_BadOrientedVolume ] = tr("BAD_ORIENTED_VOLUME"); aCriteria[ SMESH::FT_Volume3D ] = tr("VOLUME_3D"); + aCriteria[ SMESH::FT_LinearOrQuadratic ] = tr("LINEAR"); + aCriteria[ SMESH::FT_GroupColor ] = tr("GROUP_COLOR"); + aCriteria[ SMESH::FT_ElemGeomType ] = tr("GEOM_TYPE"); } return aCriteria; } - else + else // SMESH::ALL { static QMap aCriteria; + if (aCriteria.isEmpty()) + { + aCriteria[ SMESH::FT_RangeOfIds ] = tr("RANGE_OF_IDS"); + aCriteria[ SMESH::FT_BelongToGeom ] = tr("BELONG_TO_GEOM"); + aCriteria[ SMESH::FT_LyingOnGeom ] = tr("LYING_ON_GEOM"); + aCriteria[ SMESH::FT_LinearOrQuadratic ] = tr("LINEAR"); + aCriteria[ SMESH::FT_GroupColor ] = tr("GROUP_COLOR"); + aCriteria[ SMESH::FT_ElemGeomType ] = tr("GEOM_TYPE"); + } + return aCriteria; } } @@ -2037,15 +2179,15 @@ QWidget* SMESHGUI_FilterDlg::createSourceGroup (QWidget* theParent) QRadioButton* aMeshBtn = new QRadioButton(tr("MESH"), aBox); QRadioButton* aSelBtn = new QRadioButton(tr("SELECTION"), aBox); - QRadioButton* aGrpBtn = new QRadioButton(tr("CURRENT_GROUP"), aBox); + QRadioButton* aDlgBtn = new QRadioButton(tr("CURRENT_DIALOG"),aBox); aLay->addWidget(aMeshBtn); aLay->addWidget(aSelBtn); - aLay->addWidget(aGrpBtn); + aLay->addWidget(aDlgBtn); mySourceGrp->addButton(aMeshBtn, Mesh); mySourceGrp->addButton(aSelBtn, Selection); - mySourceGrp->addButton(aGrpBtn, Dialog); + mySourceGrp->addButton(aDlgBtn, Dialog); aSelBtn->setChecked(true); @@ -2357,6 +2499,7 @@ Selection_Mode SMESHGUI_FilterDlg::getSelMode (const int theType) const case SMESH::EDGE : return EdgeSelection; case SMESH::FACE : return FaceSelection; case SMESH::VOLUME : return VolumeSelection; + case SMESH::ALL : return CellSelection; default : return ActorSelection; } @@ -2486,10 +2629,9 @@ void SMESHGUI_FilterDlg::SetSourceWg (QWidget* theWg) void SMESHGUI_FilterDlg::SetMesh (SMESH::SMESH_Mesh_var theMesh) { myMesh = theMesh; - if ( myMesh->_is_nil() ) { - myButtons[BTN_OK]->setEnabled(false); - myButtons[BTN_Apply]->setEnabled(false); - } + const bool isEnable = !(myMesh->_is_nil()); + myButtons[BTN_OK]->setEnabled(isEnable); + myButtons[BTN_Apply]->setEnabled(isEnable); } //======================================================================= @@ -2832,13 +2974,14 @@ void SMESHGUI_FilterDlg::onSelectionDone() } } + int aCriterionType = myTable->GetCriterionType(aRow); if (aList.Extent() != 1 || !myTable->CurrentCell(aRow, aCol) || - myTable->GetCriterionType(aRow) != SMESH::FT_BelongToGeom && - myTable->GetCriterionType(aRow) != SMESH::FT_BelongToPlane && - myTable->GetCriterionType(aRow) != SMESH::FT_BelongToCylinder && - myTable->GetCriterionType(aRow) != SMESH::FT_BelongToGenSurface && - myTable->GetCriterionType(aRow) != SMESH::FT_LyingOnGeom) + aCriterionType != SMESH::FT_BelongToGeom && + aCriterionType != SMESH::FT_BelongToPlane && + aCriterionType != SMESH::FT_BelongToCylinder && + aCriterionType != SMESH::FT_BelongToGenSurface && + aCriterionType != SMESH::FT_LyingOnGeom) return; Handle(SALOME_InteractiveObject) anIO = aList.First(); @@ -2891,23 +3034,24 @@ void SMESHGUI_FilterDlg::updateSelection() int aRow, aCol; + int aCriterionType = myTable->GetCriterionType(aRow); if (myTable->CurrentCell(aRow, aCol) && - (myTable->GetCriterionType(aRow) == SMESH::FT_BelongToGeom || - myTable->GetCriterionType(aRow) == SMESH::FT_BelongToPlane || - myTable->GetCriterionType(aRow) == SMESH::FT_BelongToCylinder || - myTable->GetCriterionType(aRow) == SMESH::FT_BelongToGenSurface || - myTable->GetCriterionType(aRow) == SMESH::FT_LyingOnGeom)) { + (aCriterionType == SMESH::FT_BelongToGeom || + aCriterionType == SMESH::FT_BelongToPlane || + aCriterionType == SMESH::FT_BelongToCylinder || + aCriterionType == SMESH::FT_BelongToGenSurface || + aCriterionType == SMESH::FT_LyingOnGeom)) { - if (myTable->GetCriterionType(aRow) == SMESH::FT_BelongToGeom || - myTable->GetCriterionType(aRow) == SMESH::FT_BelongToGenSurface || - myTable->GetCriterionType(aRow) == SMESH::FT_LyingOnGeom) { + if (aCriterionType == SMESH::FT_BelongToGeom || + aCriterionType == SMESH::FT_BelongToGenSurface || + aCriterionType == SMESH::FT_LyingOnGeom) { mySelectionMgr->installFilter(new GEOM_SelectionFilter( aStudy, true )); - } else if (myTable->GetCriterionType(aRow) == SMESH::FT_BelongToPlane) { + } else if (aCriterionType == SMESH::FT_BelongToPlane) { mySelectionMgr->installFilter(new GEOM_FaceFilter( aStudy, StdSelect_Plane ) ); - } else if (myTable->GetCriterionType(aRow) == SMESH::FT_BelongToCylinder) { + } else if (aCriterionType == SMESH::FT_BelongToCylinder) { mySelectionMgr->installFilter(new GEOM_FaceFilter( aStudy, StdSelect_Cylinder ) ); } myIsSelectionChanged = true; diff --git a/src/SMESHGUI/SMESHGUI_GroupDlg.cxx b/src/SMESHGUI/SMESHGUI_GroupDlg.cxx index 74176f0bc..694e08074 100644 --- a/src/SMESHGUI/SMESHGUI_GroupDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_GroupDlg.cxx @@ -594,6 +594,7 @@ void SMESHGUI_GroupDlg::init (SMESH::SMESH_GroupBase_ptr theGroup, myName->setText( "Group On " + aShapeName); myName->blockSignals(false); } + updateButtons(); } //================================================================================= diff --git a/src/SMESHGUI/SMESHGUI_RemoveElementsDlg.cxx b/src/SMESHGUI/SMESHGUI_RemoveElementsDlg.cxx index f4aaf0737..67cd890f5 100644 --- a/src/SMESHGUI/SMESHGUI_RemoveElementsDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_RemoveElementsDlg.cxx @@ -31,6 +31,7 @@ #include "SMESHGUI_VTKUtils.h" #include "SMESHGUI_MeshUtils.h" #include "SMESHGUI_IdValidator.h" +#include "SMESHGUI_FilterDlg.h" #include #include @@ -81,7 +82,8 @@ SMESHGUI_RemoveElementsDlg mySelector(SMESH::GetViewWindow(theModule)->GetSelector()), mySelectionMgr(SMESH::GetSelectionMgr(theModule)), mySMESHGUI(theModule), - myBusy(false) + myBusy(false), + myFilterDlg(0) { setModal( false ); setAttribute( Qt::WA_DeleteOnClose, true ); @@ -120,10 +122,13 @@ SMESHGUI_RemoveElementsDlg SelectButtonC1A1->setIcon(image1); LineEditC1A1 = new QLineEdit(GroupC1); LineEditC1A1->setValidator(new SMESHGUI_IdValidator(this)); + QPushButton* filterBtn = new QPushButton( tr( "SMESH_BUT_FILTER" ), GroupC1 ); + connect(filterBtn, SIGNAL(clicked()), this, SLOT(setFilters())); GroupC1Layout->addWidget(TextLabelC1A1); GroupC1Layout->addWidget(SelectButtonC1A1); GroupC1Layout->addWidget(LineEditC1A1); + GroupC1Layout->addWidget(filterBtn ); /***************************************************************/ GroupButtons = new QGroupBox(this); @@ -165,6 +170,11 @@ SMESHGUI_RemoveElementsDlg //================================================================================= SMESHGUI_RemoveElementsDlg::~SMESHGUI_RemoveElementsDlg() { + if ( myFilterDlg ) { + myFilterDlg->setParent( 0 ); + delete myFilterDlg; + myFilterDlg = 0; + } } //================================================================================= @@ -253,10 +263,13 @@ void SMESHGUI_RemoveElementsDlg::ClickOnOk() //================================================================================= void SMESHGUI_RemoveElementsDlg::ClickOnCancel() { + if (SMESH::GetCurrentVtkView()) + SMESH::RemoveFilters(); // PAL6938 -- clean all mesh entity filters //mySelectionMgr->clearSelected(); if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) aViewWindow->SetSelectionMode(ActorSelection); disconnect(mySelectionMgr, 0, this, 0); + mySelectionMgr->clearFilters(); mySMESHGUI->ResetState(); reject(); } @@ -487,3 +500,19 @@ void SMESHGUI_RemoveElementsDlg::keyPressEvent( QKeyEvent* e ) ClickOnHelp(); } } + +//================================================================================= +// function : setFilters() +// purpose : SLOT. Called when "Filter" button pressed. +//================================================================================= +void SMESHGUI_RemoveElementsDlg::setFilters() +{ + if ( !myFilterDlg ) + myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, SMESH::ALL ); + + myFilterDlg->SetSelection(); + myFilterDlg->SetMesh( myMesh ); + myFilterDlg->SetSourceWg( LineEditC1A1 ); + + myFilterDlg->show(); +} diff --git a/src/SMESHGUI/SMESHGUI_RemoveElementsDlg.h b/src/SMESHGUI/SMESHGUI_RemoveElementsDlg.h index 3dfd477ea..d5da490c0 100644 --- a/src/SMESHGUI/SMESHGUI_RemoveElementsDlg.h +++ b/src/SMESHGUI/SMESHGUI_RemoveElementsDlg.h @@ -43,6 +43,7 @@ class QPushButton; class QRadioButton; class SMESHGUI; +class SMESHGUI_FilterDlg; class SMESH_Actor; class SVTK_Selector; class LightApp_SelectionMgr; @@ -92,6 +93,8 @@ private: QString myHelpFileName; + SMESHGUI_FilterDlg* myFilterDlg; + private slots: void ClickOnOk(); void ClickOnCancel(); @@ -102,6 +105,7 @@ private slots: void DeactivateActiveDialog(); void ActivateThisDialog(); void onTextChange( const QString& ); + void setFilters(); }; #endif // SMESHGUI_REMOVEELEMENTSDLG_H diff --git a/src/SMESHGUI/SMESHGUI_RemoveNodesDlg.cxx b/src/SMESHGUI/SMESHGUI_RemoveNodesDlg.cxx index 2f2a5e3f9..f48b34f8a 100644 --- a/src/SMESHGUI/SMESHGUI_RemoveNodesDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_RemoveNodesDlg.cxx @@ -31,6 +31,7 @@ #include "SMESHGUI_VTKUtils.h" #include "SMESHGUI_MeshUtils.h" #include "SMESHGUI_IdValidator.h" +#include "SMESHGUI_FilterDlg.h" #include #include @@ -81,7 +82,8 @@ SMESHGUI_RemoveNodesDlg mySelector(SMESH::GetViewWindow(theModule)->GetSelector()), mySelectionMgr(SMESH::GetSelectionMgr(theModule)), mySMESHGUI(theModule), - myBusy(false) + myBusy(false), + myFilterDlg(0) { setModal( false ); setAttribute( Qt::WA_DeleteOnClose, true ); @@ -120,10 +122,13 @@ SMESHGUI_RemoveNodesDlg SelectButtonC1A1->setIcon(image1); LineEditC1A1 = new QLineEdit(GroupC1); LineEditC1A1->setValidator(new SMESHGUI_IdValidator(this)); + QPushButton* filterBtn = new QPushButton( tr( "SMESH_BUT_FILTER" ), GroupC1 ); + connect(filterBtn, SIGNAL(clicked()), this, SLOT(setFilters())); GroupC1Layout->addWidget(TextLabelC1A1); GroupC1Layout->addWidget(SelectButtonC1A1); GroupC1Layout->addWidget(LineEditC1A1); + GroupC1Layout->addWidget(filterBtn ); /***************************************************************/ GroupButtons = new QGroupBox(this); @@ -165,6 +170,11 @@ SMESHGUI_RemoveNodesDlg //================================================================================= SMESHGUI_RemoveNodesDlg::~SMESHGUI_RemoveNodesDlg() { + if ( myFilterDlg ) { + myFilterDlg->setParent( 0 ); + delete myFilterDlg; + myFilterDlg = 0; + } } //================================================================================= @@ -258,10 +268,14 @@ void SMESHGUI_RemoveNodesDlg::ClickOnOk() void SMESHGUI_RemoveNodesDlg::ClickOnCancel() { //mySelectionMgr->clearSelected(); - SMESH::SetPointRepresentation(false); + if (SMESH::GetCurrentVtkView()) { + SMESH::RemoveFilters(); // PAL6938 -- clean all mesh entity filters + SMESH::SetPointRepresentation(false); + } if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) aViewWindow->SetSelectionMode(ActorSelection); disconnect(mySelectionMgr, 0, this, 0); + mySelectionMgr->clearFilters(); mySMESHGUI->ResetState(); reject(); } @@ -493,3 +507,19 @@ void SMESHGUI_RemoveNodesDlg::keyPressEvent( QKeyEvent* e ) ClickOnHelp(); } } + +//================================================================================= +// function : setFilters() +// purpose : SLOT. Called when "Filter" button pressed. +//================================================================================= +void SMESHGUI_RemoveNodesDlg::setFilters() +{ + if ( !myFilterDlg ) + myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, SMESH::NODE ); + + myFilterDlg->SetSelection(); + myFilterDlg->SetMesh( myMesh ); + myFilterDlg->SetSourceWg( LineEditC1A1 ); + + myFilterDlg->show(); +} diff --git a/src/SMESHGUI/SMESHGUI_RemoveNodesDlg.h b/src/SMESHGUI/SMESHGUI_RemoveNodesDlg.h index 9e4f2f2c6..6208ac651 100644 --- a/src/SMESHGUI/SMESHGUI_RemoveNodesDlg.h +++ b/src/SMESHGUI/SMESHGUI_RemoveNodesDlg.h @@ -43,6 +43,7 @@ class QPushButton; class QRadioButton; class SMESHGUI; +class SMESHGUI_FilterDlg; class SMESH_Actor; class SVTK_Selector; class LightApp_SelectionMgr; @@ -91,6 +92,8 @@ private: QLineEdit* LineEditC1A1; QString myHelpFileName; + + SMESHGUI_FilterDlg* myFilterDlg; private slots: void ClickOnOk(); @@ -102,6 +105,7 @@ private slots: void DeactivateActiveDialog(); void ActivateThisDialog(); void onTextChange( const QString& ); + void setFilters(); }; #endif // SMESHGUI_REMOVENODESDLG_H diff --git a/src/SMESHGUI/SMESHGUI_RevolutionDlg.cxx b/src/SMESHGUI/SMESHGUI_RevolutionDlg.cxx index a8a49d119..e2476920f 100644 --- a/src/SMESHGUI/SMESHGUI_RevolutionDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_RevolutionDlg.cxx @@ -33,6 +33,7 @@ #include "SMESHGUI_MeshUtils.h" #include "SMESHGUI_IdValidator.h" #include "SMESHGUI_MeshEditPreview.h" +#include "SMESHGUI_FilterDlg.h" #include #include @@ -90,7 +91,8 @@ SMESHGUI_RevolutionDlg::SMESHGUI_RevolutionDlg( SMESHGUI* theModule ) : QDialog( SMESH::GetDesktop( theModule ) ), mySMESHGUI( theModule ), mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ), - myVectorDefinition(NONE_SELECT) + myVectorDefinition(NONE_SELECT), + myFilterDlg( 0 ) { mySimulation = new SMESHGUI_MeshEditPreview(SMESH::GetViewWindow( mySMESHGUI )); @@ -141,6 +143,8 @@ SMESHGUI_RevolutionDlg::SMESHGUI_RevolutionDlg( SMESHGUI* theModule ) LineEditElements = new QLineEdit(GroupArguments); LineEditElements->setValidator(myIdValidator); + QPushButton* filterBtn = new QPushButton( tr( "SMESH_BUT_FILTER" ), GroupArguments ); + connect(filterBtn, SIGNAL(clicked()), this, SLOT(setFilters())); // Control for the whole mesh selection CheckBoxMesh = new QCheckBox(tr("SMESH_SELECT_WHOLE_MESH"), GroupArguments); @@ -233,13 +237,14 @@ SMESHGUI_RevolutionDlg::SMESHGUI_RevolutionDlg( SMESHGUI* theModule ) GroupArgumentsLayout->addWidget(TextLabelElements, 0, 0); GroupArgumentsLayout->addWidget(SelectElementsButton, 0, 1); GroupArgumentsLayout->addWidget(LineEditElements, 0, 2); - GroupArgumentsLayout->addWidget(CheckBoxMesh, 1, 0, 1, 3); - GroupArgumentsLayout->addWidget(GroupAxis, 2, 0, 1, 3); - GroupArgumentsLayout->addWidget(GroupAngleBox, 3, 0, 1, 3); + GroupArgumentsLayout->addWidget(filterBtn, 0, 3); + GroupArgumentsLayout->addWidget(CheckBoxMesh, 1, 0, 1, 4); + GroupArgumentsLayout->addWidget(GroupAxis, 2, 0, 1, 4); + GroupArgumentsLayout->addWidget(GroupAngleBox, 3, 0, 1, 4); GroupArgumentsLayout->addWidget(TextLabelTolerance, 4, 0, 1, 2); - GroupArgumentsLayout->addWidget(SpinBox_Tolerance, 4, 2); - GroupArgumentsLayout->addWidget(CheckBoxPreview, 5, 0, 1, 3); - GroupArgumentsLayout->addWidget(MakeGroupsCheck, 6, 0, 1, 3); + GroupArgumentsLayout->addWidget(SpinBox_Tolerance, 4, 2, 1, 2); + GroupArgumentsLayout->addWidget(CheckBoxPreview, 5, 0, 1, 4); + GroupArgumentsLayout->addWidget(MakeGroupsCheck, 6, 0, 1, 4); /***************************************************************/ GroupButtons = new QGroupBox(this); @@ -356,6 +361,11 @@ SMESHGUI_RevolutionDlg::SMESHGUI_RevolutionDlg( SMESHGUI* theModule ) SMESHGUI_RevolutionDlg::~SMESHGUI_RevolutionDlg() { delete mySimulation; + if ( myFilterDlg ) { + myFilterDlg->setParent( 0 ); + delete myFilterDlg; + myFilterDlg = 0; + } } //================================================================================= @@ -523,7 +533,10 @@ void SMESHGUI_RevolutionDlg::ClickOnCancel() disconnect(mySelectionMgr, 0, this, 0); mySelectionMgr->clearFilters(); //mySelectionMgr->clearSelected(); - SMESH::SetPointRepresentation(false); + if (SMESH::GetCurrentVtkView()) { + SMESH::RemoveFilters(); // PAL6938 -- clean all mesh entity filters + SMESH::SetPointRepresentation(false); + } if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) aViewWindow->SetSelectionMode(ActorSelection); mySMESHGUI->ResetState(); @@ -1119,3 +1132,25 @@ void SMESHGUI_RevolutionDlg::onSelectVectorMenu( QAction* action){ connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); SelectionIntoArgument(); } + +//================================================================================= +// function : setFilters() +// purpose : SLOT. Called when "Filter" button pressed. +//================================================================================= +void SMESHGUI_RevolutionDlg::setFilters() +{ + if ( !myFilterDlg ) + { + QList types; + types.append( SMESH::EDGE ); + types.append( SMESH::FACE ); + myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, types ); + } + myFilterDlg->Init( GetConstructorId() ? SMESH::FACE : SMESH::EDGE ); + + myFilterDlg->SetSelection(); + myFilterDlg->SetMesh( myMesh ); + myFilterDlg->SetSourceWg( LineEditElements ); + + myFilterDlg->show(); +} diff --git a/src/SMESHGUI/SMESHGUI_RevolutionDlg.h b/src/SMESHGUI/SMESHGUI_RevolutionDlg.h index 0395e21a0..4eb931d24 100644 --- a/src/SMESHGUI/SMESHGUI_RevolutionDlg.h +++ b/src/SMESHGUI/SMESHGUI_RevolutionDlg.h @@ -48,6 +48,7 @@ class QSpinBox; class SMESHGUI_IdValidator; class SMESHGUI_SpinBox; class SMESHGUI; +class SMESHGUI_FilterDlg; class SMESH_Actor; class SVTK_Selector; class LightApp_SelectionMgr; @@ -148,6 +149,8 @@ private: QString myHelpFileName; + SMESHGUI_FilterDlg* myFilterDlg; + private slots: void ConstructorsClicked( int ); void ClickOnOk(); @@ -165,6 +168,7 @@ private slots: void onDisplaySimulation( bool ); void onSelectVectorMenu( QAction* ); void onSelectVectorButton(); + void setFilters(); }; #endif // SMESHGUI_REVOLUTIONDLG_H diff --git a/src/SMESHGUI/SMESHGUI_RotationDlg.cxx b/src/SMESHGUI/SMESHGUI_RotationDlg.cxx index b76cfa308..217b97114 100644 --- a/src/SMESHGUI/SMESHGUI_RotationDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_RotationDlg.cxx @@ -32,6 +32,7 @@ #include "SMESHGUI_VTKUtils.h" #include "SMESHGUI_MeshUtils.h" #include "SMESHGUI_IdValidator.h" +#include "SMESHGUI_FilterDlg.h" #include #include @@ -89,7 +90,8 @@ enum { MOVE_ELEMS_BUTTON = 0, COPY_ELEMS_BUTTON, MAKE_MESH_BUTTON }; //!< action SMESHGUI_RotationDlg::SMESHGUI_RotationDlg( SMESHGUI* theModule ) : QDialog( SMESH::GetDesktop( theModule ) ), mySMESHGUI( theModule ), - mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ) + mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ), + myFilterDlg(0) { QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_DLG_MESH_ROTATION"))); QPixmap image1 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT"))); @@ -130,6 +132,8 @@ SMESHGUI_RotationDlg::SMESHGUI_RotationDlg( SMESHGUI* theModule ) SelectElementsButton->setIcon(image1); LineEditElements = new QLineEdit(GroupArguments); LineEditElements->setValidator(myIdValidator); + QPushButton* filterBtn = new QPushButton( tr( "SMESH_BUT_FILTER" ), GroupArguments ); + connect(filterBtn, SIGNAL(clicked()), this, SLOT(setFilters())); // Control for the whole mesh selection CheckBoxMesh = new QCheckBox(tr("SMESH_SELECT_WHOLE_MESH"), GroupArguments); @@ -209,7 +213,8 @@ SMESHGUI_RotationDlg::SMESHGUI_RotationDlg( SMESHGUI* theModule ) GroupArgumentsLayout->addWidget(TextLabelElements, 0, 0); GroupArgumentsLayout->addWidget(SelectElementsButton, 0, 1); - GroupArgumentsLayout->addWidget(LineEditElements, 0, 2, 1, 2); + GroupArgumentsLayout->addWidget(LineEditElements, 0, 2, 1, 1); + GroupArgumentsLayout->addWidget(filterBtn, 0, 3); GroupArgumentsLayout->addWidget(CheckBoxMesh, 1, 0, 1, 4); GroupArgumentsLayout->addWidget(GroupAxis, 2, 0, 1, 4); GroupArgumentsLayout->addWidget(TextLabelAngle, 3, 0, 1, 2); @@ -310,6 +315,11 @@ SMESHGUI_RotationDlg::SMESHGUI_RotationDlg( SMESHGUI* theModule ) //================================================================================= SMESHGUI_RotationDlg::~SMESHGUI_RotationDlg() { + if ( myFilterDlg ) { + myFilterDlg->setParent( 0 ); + delete myFilterDlg; + myFilterDlg = 0; + } } //================================================================================= @@ -431,7 +441,10 @@ void SMESHGUI_RotationDlg::ClickOnCancel() disconnect(mySelectionMgr, 0, this, 0); mySelectionMgr->clearFilters(); //mySelectionMgr->clearSelected(); - SMESH::SetPointRepresentation(false); + if (SMESH::GetCurrentVtkView()) { + SMESH::RemoveFilters(); // PAL6938 -- clean all mesh entity filters + SMESH::SetPointRepresentation(false); + } if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) aViewWindow->SetSelectionMode(ActorSelection); mySMESHGUI->ResetState(); @@ -909,3 +922,19 @@ void SMESHGUI_RotationDlg::keyPressEvent( QKeyEvent* e ) ClickOnHelp(); } } + +//================================================================================= +// function : setFilters() +// purpose : SLOT. Called when "Filter" button pressed. +//================================================================================= +void SMESHGUI_RotationDlg::setFilters() +{ + if ( !myFilterDlg ) + myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, SMESH::ALL ); + + myFilterDlg->SetSelection(); + myFilterDlg->SetMesh( myMesh ); + myFilterDlg->SetSourceWg( LineEditElements ); + + myFilterDlg->show(); +} diff --git a/src/SMESHGUI/SMESHGUI_RotationDlg.h b/src/SMESHGUI/SMESHGUI_RotationDlg.h index bee73659c..a92fc1d2a 100644 --- a/src/SMESHGUI/SMESHGUI_RotationDlg.h +++ b/src/SMESHGUI/SMESHGUI_RotationDlg.h @@ -47,6 +47,7 @@ class SMESHGUI; class SMESH_Actor; class SMESHGUI_IdValidator; class SMESHGUI_SpinBox; +class SMESHGUI_FilterDlg; class SVTK_Selector; class LightApp_SelectionMgr; class SMESH_LogicalFilter; @@ -127,6 +128,8 @@ private: QString myHelpFileName; + SMESHGUI_FilterDlg* myFilterDlg; + private slots: void ClickOnOk(); void ClickOnCancel(); @@ -140,6 +143,7 @@ private slots: void onSelectMesh( bool ); void onVectorChanged(); void onActionClicked( int ); + void setFilters(); }; #endif // SMESHGUI_ROTATIONDLG_H diff --git a/src/SMESHGUI/SMESHGUI_Selection.cxx b/src/SMESHGUI/SMESHGUI_Selection.cxx index 7fc015a75..f58ecdebd 100644 --- a/src/SMESHGUI/SMESHGUI_Selection.cxx +++ b/src/SMESHGUI/SMESHGUI_Selection.cxx @@ -240,6 +240,7 @@ QString SMESHGUI_Selection::controlMode( int ind ) const case SMESH_Actor::eLength2D: return "eLength2D"; case SMESH_Actor::eFreeEdges: return "eFreeEdges"; case SMESH_Actor::eFreeBorders: return "eFreeBorders"; + case SMESH_Actor::eFreeFaces: return "eFreeFaces"; case SMESH_Actor::eMultiConnection: return "eMultiConnection"; case SMESH_Actor::eMultiConnection2D: return "eMultiConnection2D"; case SMESH_Actor::eArea: return "eArea"; diff --git a/src/SMESHGUI/SMESHGUI_SmoothingDlg.cxx b/src/SMESHGUI/SMESHGUI_SmoothingDlg.cxx index 4f8711a04..e49ba9e47 100644 --- a/src/SMESHGUI/SMESHGUI_SmoothingDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_SmoothingDlg.cxx @@ -32,6 +32,7 @@ #include "SMESHGUI_MeshUtils.h" #include "SMESHGUI_SpinBox.h" #include "SMESHGUI_IdValidator.h" +#include "SMESHGUI_FilterDlg.h" #include #include @@ -89,7 +90,8 @@ SMESHGUI_SmoothingDlg::SMESHGUI_SmoothingDlg( SMESHGUI* theModule ) : QDialog( SMESH::GetDesktop( theModule ) ), mySMESHGUI( theModule ), - mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ) + mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ), + myFilterDlg(0) { QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_DLG_SMOOTHING"))); QPixmap image1 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT"))); @@ -133,6 +135,8 @@ SMESHGUI_SmoothingDlg::SMESHGUI_SmoothingDlg( SMESHGUI* theModule ) LineEditElements = new QLineEdit(GroupArguments); LineEditElements->setValidator(myIdValidator); + QPushButton* filterElemBtn = new QPushButton( tr( "SMESH_BUT_FILTER" ), GroupArguments ); + connect(filterElemBtn, SIGNAL(clicked()), this, SLOT(setElemFilters())); // Control for the whole mesh selection CheckBoxMesh = new QCheckBox(tr("SMESH_SELECT_WHOLE_MESH"), GroupArguments); @@ -145,6 +149,8 @@ SMESHGUI_SmoothingDlg::SMESHGUI_SmoothingDlg( SMESHGUI* theModule ) LineEditNodes = new QLineEdit(GroupArguments); LineEditNodes->setValidator(myIdValidator); + QPushButton* filterNodeBtn = new QPushButton( tr( "SMESH_BUT_FILTER" ), GroupArguments ); + connect(filterNodeBtn, SIGNAL(clicked()), this, SLOT(setNodeFilters())); // Controls for method selection TextLabelMethod = new QLabel(tr("METHOD"), GroupArguments); @@ -167,17 +173,19 @@ SMESHGUI_SmoothingDlg::SMESHGUI_SmoothingDlg( SMESHGUI* theModule ) GroupArgumentsLayout->addWidget(TextLabelElements, 0, 0); GroupArgumentsLayout->addWidget(SelectElementsButton, 0, 1); GroupArgumentsLayout->addWidget(LineEditElements, 0, 2); - GroupArgumentsLayout->addWidget(CheckBoxMesh, 1, 0, 1, 3); + GroupArgumentsLayout->addWidget(filterElemBtn, 0, 3); + GroupArgumentsLayout->addWidget(CheckBoxMesh, 1, 0, 1, 4); GroupArgumentsLayout->addWidget(TextLabelNodes, 2, 0); GroupArgumentsLayout->addWidget(SelectNodesButton, 2, 1); GroupArgumentsLayout->addWidget(LineEditNodes, 2, 2); + GroupArgumentsLayout->addWidget(filterNodeBtn, 2, 3); GroupArgumentsLayout->addWidget(TextLabelMethod, 3, 0); - GroupArgumentsLayout->addWidget(ComboBoxMethod, 3, 2); + GroupArgumentsLayout->addWidget(ComboBoxMethod, 3, 2, 1, 2); GroupArgumentsLayout->addWidget(TextLabelLimit, 4, 0); - GroupArgumentsLayout->addWidget(SpinBox_IterationLimit, 4, 2); + GroupArgumentsLayout->addWidget(SpinBox_IterationLimit, 4, 2, 1, 2); GroupArgumentsLayout->addWidget(TextLabelAspectRatio, 5, 0); - GroupArgumentsLayout->addWidget(SpinBox_AspectRatio, 5, 2); - GroupArgumentsLayout->addWidget(CheckBoxParametric, 6, 0, 1, 3); + GroupArgumentsLayout->addWidget(SpinBox_AspectRatio, 5, 2, 1, 2); + GroupArgumentsLayout->addWidget(CheckBoxParametric, 6, 0, 1, 4); /***************************************************************/ GroupButtons = new QGroupBox(this); @@ -273,6 +281,10 @@ SMESHGUI_SmoothingDlg::SMESHGUI_SmoothingDlg( SMESHGUI* theModule ) SMESHGUI_SmoothingDlg::~SMESHGUI_SmoothingDlg() { // no need to delete child widgets, Qt does it all for us + if ( myFilterDlg != 0 ) { + myFilterDlg->setParent( 0 ); + delete myFilterDlg; + } } //================================================================================= @@ -382,8 +394,11 @@ void SMESHGUI_SmoothingDlg::ClickOnCancel() disconnect(mySelectionMgr, 0, this, 0); mySelectionMgr->clearFilters(); //mySelectionMgr->clearSelected(); - SMESH::SetPickable(); // ??? - SMESH::SetPointRepresentation(false); + if (SMESH::GetCurrentVtkView()) { + SMESH::RemoveFilters(); // PAL6938 -- clean all mesh entity filters + SMESH::SetPointRepresentation(false); + SMESH::SetPickable(); + } if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) aViewWindow->SetSelectionMode(ActorSelection); mySMESHGUI->ResetState(); @@ -494,9 +509,13 @@ void SMESHGUI_SmoothingDlg::SelectionIntoArgument() QString aString = ""; myBusy = true; - if (myEditCurrentArgument == (QWidget*)LineEditElements) { - LineEditElements->setText(aString); - myNbOkElements = 0; + if (myEditCurrentArgument == LineEditElements || + myEditCurrentArgument == LineEditNodes) { + myEditCurrentArgument->setText(aString); + if (myEditCurrentArgument == LineEditElements) + myNbOkElements = 0; + else + myNbOkNodes = 0; buttonOk->setEnabled(false); buttonApply->setEnabled(false); myActor = 0; @@ -583,17 +602,17 @@ void SMESHGUI_SmoothingDlg::SelectionIntoArgument() return; myBusy = true; - LineEditElements->setEnabled(true); - LineEditElements->setText(aString); - LineEditElements->repaint(); - LineEditElements->setEnabled(false); + myEditCurrentArgument->setEnabled(true); + myEditCurrentArgument->setText(aString); + myEditCurrentArgument->repaint(); + myEditCurrentArgument->setEnabled(false); myBusy = false; // OK if (myEditCurrentArgument == LineEditElements) - myNbOkElements = true; + myNbOkElements = aNbUnits; else if (myEditCurrentArgument == LineEditNodes) - myNbOkNodes = true; + myNbOkNodes = aNbUnits; if (myNbOkElements && (myNbOkNodes || LineEditNodes->text().trimmed().isEmpty())) { buttonOk->setEnabled(true); @@ -719,8 +738,10 @@ void SMESHGUI_SmoothingDlg::onSelectMesh (bool toSelectMesh) else TextLabelElements->setText(tr("SMESH_ID_ELEMENTS")); - if (myEditCurrentArgument != LineEditElements) { + if (myEditCurrentArgument != LineEditElements && + myEditCurrentArgument != LineEditNodes) { LineEditElements->clear(); + LineEditNodes->clear(); return; } @@ -732,14 +753,15 @@ void SMESHGUI_SmoothingDlg::onSelectMesh (bool toSelectMesh) aViewWindow->SetSelectionMode(ActorSelection); // mySelectionMgr->setSelectionModes(ActorSelection); mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter); - LineEditElements->setReadOnly(true); - LineEditElements->setValidator(0); + myEditCurrentArgument->setReadOnly(true); + myEditCurrentArgument->setValidator(0); } else { if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) - aViewWindow->SetSelectionMode(FaceSelection); - LineEditElements->setReadOnly(false); + aViewWindow->SetSelectionMode(myEditCurrentArgument == LineEditElements ? FaceSelection + : NodeSelection ); + myEditCurrentArgument->setReadOnly(false); LineEditElements->setValidator(myIdValidator); - onTextChange(LineEditElements->text()); + onTextChange(myEditCurrentArgument->text()); } SelectionIntoArgument(); @@ -760,3 +782,43 @@ void SMESHGUI_SmoothingDlg::keyPressEvent( QKeyEvent* e ) ClickOnHelp(); } } + +//================================================================================= +// function : setFilters() +// purpose : activate filter dialog +//================================================================================= +void SMESHGUI_SmoothingDlg::setFilters( const bool theIsElem ) +{ + if ( !myFilterDlg ) + { + QList types; + types.append( SMESH::NODE ); + types.append( SMESH::ALL ); + myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, types ); + } + myFilterDlg->Init( theIsElem ? SMESH::ALL : SMESH::NODE ); + + myFilterDlg->SetSelection(); + myFilterDlg->SetMesh( myMesh ); + myFilterDlg->SetSourceWg( theIsElem ? LineEditElements : LineEditNodes ); + + myFilterDlg->show(); +} + +//================================================================================= +// function : setElemFilters() +// purpose : SLOT. Called when element "Filter" button pressed. +//================================================================================= +void SMESHGUI_SmoothingDlg::setElemFilters() +{ + setFilters( true ); +} + +//================================================================================= +// function : setNodeFilters() +// purpose : SLOT. Called when node "Filter" button pressed. +//================================================================================= +void SMESHGUI_SmoothingDlg::setNodeFilters() +{ + setFilters( false ); +} diff --git a/src/SMESHGUI/SMESHGUI_SmoothingDlg.h b/src/SMESHGUI/SMESHGUI_SmoothingDlg.h index cf9d195ff..6bbfdf49e 100644 --- a/src/SMESHGUI/SMESHGUI_SmoothingDlg.h +++ b/src/SMESHGUI/SMESHGUI_SmoothingDlg.h @@ -44,9 +44,10 @@ class QRadioButton; class QComboBox; class QCheckBox; class QSpinBox; +class SMESHGUI; class SMESHGUI_IdValidator; class SMESHGUI_SpinBox; -class SMESHGUI; +class SMESHGUI_FilterDlg; class SMESH_Actor; class SVTK_Selector; class LightApp_SelectionMgr; @@ -70,6 +71,7 @@ private: void enterEvent( QEvent* ); /* mouse enter the QWidget */ void hideEvent( QHideEvent* ); /* ESC key */ void keyPressEvent( QKeyEvent* ); + void setFilters( const bool theIsElem ); SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */ SMESHGUI_IdValidator* myIdValidator; @@ -111,6 +113,8 @@ private: QString myHelpFileName; + SMESHGUI_FilterDlg* myFilterDlg; + private slots: void ClickOnOk(); void ClickOnCancel(); @@ -122,6 +126,8 @@ private slots: void ActivateThisDialog(); void onTextChange( const QString& ); void onSelectMesh( bool ); + void setElemFilters(); + void setNodeFilters(); }; #endif // SMESHGUI_SMOOTHINGDLG_H diff --git a/src/SMESHGUI/SMESHGUI_SymmetryDlg.cxx b/src/SMESHGUI/SMESHGUI_SymmetryDlg.cxx index 932104d4d..3d0358388 100644 --- a/src/SMESHGUI/SMESHGUI_SymmetryDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_SymmetryDlg.cxx @@ -32,6 +32,7 @@ #include "SMESHGUI_VTKUtils.h" #include "SMESHGUI_MeshUtils.h" #include "SMESHGUI_IdValidator.h" +#include "SMESHGUI_FilterDlg.h" #include #include @@ -90,7 +91,8 @@ enum { MOVE_ELEMS_BUTTON = 0, COPY_ELEMS_BUTTON, MAKE_MESH_BUTTON }; //!< action SMESHGUI_SymmetryDlg::SMESHGUI_SymmetryDlg( SMESHGUI* theModule ) : QDialog( SMESH::GetDesktop( theModule ) ), mySMESHGUI( theModule ), - mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ) + mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ), + myFilterDlg(0) { QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SMESH_SYMMETRY_POINT"))); QPixmap image1 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SMESH_SYMMETRY_AXIS"))); @@ -141,6 +143,8 @@ SMESHGUI_SymmetryDlg::SMESHGUI_SymmetryDlg( SMESHGUI* theModule ) SelectElementsButton->setIcon(image3); LineEditElements = new QLineEdit(GroupArguments); LineEditElements->setValidator(myIdValidator); + QPushButton* filterBtn = new QPushButton( tr( "SMESH_BUT_FILTER" ), GroupArguments ); + connect(filterBtn, SIGNAL(clicked()), this, SLOT(setFilters())); // Control for the whole mesh selection CheckBoxMesh = new QCheckBox(tr("SMESH_SELECT_WHOLE_MESH"), GroupArguments); @@ -218,7 +222,8 @@ SMESHGUI_SymmetryDlg::SMESHGUI_SymmetryDlg( SMESHGUI* theModule ) // layout GroupArgumentsLayout->addWidget(TextLabelElements, 0, 0); GroupArgumentsLayout->addWidget(SelectElementsButton, 0, 1); - GroupArgumentsLayout->addWidget(LineEditElements, 0, 2, 1, 2); + GroupArgumentsLayout->addWidget(LineEditElements, 0, 2, 1, 1); + GroupArgumentsLayout->addWidget(filterBtn, 0, 3); GroupArgumentsLayout->addWidget(CheckBoxMesh, 1, 0, 1, 4); GroupArgumentsLayout->addWidget(GroupMirror, 2, 0, 1, 4); GroupArgumentsLayout->addWidget(ActionBox, 3, 0, 3, 3); @@ -317,6 +322,10 @@ SMESHGUI_SymmetryDlg::SMESHGUI_SymmetryDlg( SMESHGUI* theModule ) //================================================================================= SMESHGUI_SymmetryDlg::~SMESHGUI_SymmetryDlg() { + if ( myFilterDlg != 0 ) { + myFilterDlg->setParent( 0 ); + delete myFilterDlg; + } } //================================================================================= @@ -520,7 +529,10 @@ void SMESHGUI_SymmetryDlg::ClickOnCancel() disconnect(mySelectionMgr, 0, this, 0); mySelectionMgr->clearFilters(); //mySelectionMgr->clearSelected(); - SMESH::SetPointRepresentation(false); + if (SMESH::GetCurrentVtkView()) { + SMESH::RemoveFilters(); // PAL6938 -- clean all mesh entity filters + SMESH::SetPointRepresentation(false); + } if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) aViewWindow->SetSelectionMode(ActorSelection); mySMESHGUI->ResetState(); @@ -1007,3 +1019,19 @@ void SMESHGUI_SymmetryDlg::keyPressEvent( QKeyEvent* e ) ClickOnHelp(); } } + +//================================================================================= +// function : setFilters() +// purpose : SLOT. Called when "Filter" button pressed. +//================================================================================= +void SMESHGUI_SymmetryDlg::setFilters() +{ + if ( !myFilterDlg ) + myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, SMESH::ALL ); + + myFilterDlg->SetSelection(); + myFilterDlg->SetMesh( myMesh ); + myFilterDlg->SetSourceWg( LineEditElements ); + + myFilterDlg->show(); +} diff --git a/src/SMESHGUI/SMESHGUI_SymmetryDlg.h b/src/SMESHGUI/SMESHGUI_SymmetryDlg.h index faa9eebfa..755b551d4 100644 --- a/src/SMESHGUI/SMESHGUI_SymmetryDlg.h +++ b/src/SMESHGUI/SMESHGUI_SymmetryDlg.h @@ -43,9 +43,10 @@ class QLineEdit; class QPushButton; class QRadioButton; class QCheckBox; +class SMESHGUI; class SMESHGUI_IdValidator; class SMESHGUI_SpinBox; -class SMESHGUI; +class SMESHGUI_FilterDlg; class SMESH_Actor; class SVTK_Selector; class LightApp_SelectionMgr; @@ -128,6 +129,8 @@ private: QString myHelpFileName; + SMESHGUI_FilterDlg* myFilterDlg; + private slots: void ConstructorsClicked( int ); void ClickOnOk(); @@ -142,6 +145,7 @@ private slots: void onSelectMesh( bool ); void onVectorChanged(); void onActionClicked( int ); + void setFilters(); }; #endif // SMESHGUI_SYMMETRYDLG_H diff --git a/src/SMESHGUI/SMESHGUI_TranslationDlg.cxx b/src/SMESHGUI/SMESHGUI_TranslationDlg.cxx index a4859f5e4..e603401b7 100644 --- a/src/SMESHGUI/SMESHGUI_TranslationDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_TranslationDlg.cxx @@ -32,6 +32,7 @@ #include "SMESHGUI_VTKUtils.h" #include "SMESHGUI_MeshUtils.h" #include "SMESHGUI_IdValidator.h" +#include "SMESHGUI_FilterDlg.h" #include #include @@ -107,7 +108,8 @@ private: SMESHGUI_TranslationDlg::SMESHGUI_TranslationDlg( SMESHGUI* theModule ) : QDialog( SMESH::GetDesktop( theModule ) ), mySMESHGUI( theModule ), - mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ) + mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ), + myFilterDlg(0) { QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SMESH_TRANSLATION_POINTS"))); QPixmap image1 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SMESH_TRANSLATION_VECTOR"))); @@ -153,6 +155,8 @@ SMESHGUI_TranslationDlg::SMESHGUI_TranslationDlg( SMESHGUI* theModule ) SelectElementsButton->setIcon(image2); LineEditElements = new QLineEdit(GroupArguments); LineEditElements->setValidator(myIdValidator); + QPushButton* filterBtn = new QPushButton( tr( "SMESH_BUT_FILTER" ), GroupArguments ); + connect(filterBtn, SIGNAL(clicked()), this, SLOT(setFilters())); // Control for the whole mesh selection CheckBoxMesh = new QCheckBox(tr("SMESH_SELECT_WHOLE_MESH"), GroupArguments); @@ -208,7 +212,8 @@ SMESHGUI_TranslationDlg::SMESHGUI_TranslationDlg( SMESHGUI* theModule ) // layout GroupArgumentsLayout->addWidget(TextLabelElements, 0, 0); GroupArgumentsLayout->addWidget(SelectElementsButton, 0, 1); - GroupArgumentsLayout->addWidget(LineEditElements, 0, 2, 1, 6); + GroupArgumentsLayout->addWidget(LineEditElements, 0, 2, 1, 5); + GroupArgumentsLayout->addWidget(filterBtn, 0, 7); GroupArgumentsLayout->addWidget(CheckBoxMesh, 1, 0, 1, 8); GroupArgumentsLayout->addWidget(TextLabel1, 2, 0); GroupArgumentsLayout->addWidget(SelectButton1, 2, 1); @@ -318,6 +323,11 @@ SMESHGUI_TranslationDlg::SMESHGUI_TranslationDlg( SMESHGUI* theModule ) //================================================================================= SMESHGUI_TranslationDlg::~SMESHGUI_TranslationDlg() { + if ( myFilterDlg ) { + myFilterDlg->setParent( 0 ); + delete myFilterDlg; + myFilterDlg = 0; + } } //================================================================================= @@ -504,7 +514,10 @@ void SMESHGUI_TranslationDlg::ClickOnCancel() disconnect(mySelectionMgr, 0, this, 0); mySelectionMgr->clearFilters(); //mySelectionMgr->clearSelected(); - SMESH::SetPointRepresentation(false); + if (SMESH::GetCurrentVtkView()) { + SMESH::RemoveFilters(); // PAL6938 -- clean all mesh entity filters + SMESH::SetPointRepresentation(false); + } if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) aViewWindow->SetSelectionMode( ActorSelection ); mySMESHGUI->ResetState(); @@ -957,3 +970,19 @@ void SMESHGUI_TranslationDlg::keyPressEvent( QKeyEvent* e ) ClickOnHelp(); } } + +//================================================================================= +// function : setFilters() +// purpose : SLOT. Called when "Filter" button pressed. +//================================================================================= +void SMESHGUI_TranslationDlg::setFilters() +{ + if ( !myFilterDlg ) + myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, SMESH::ALL ); + + myFilterDlg->SetSelection(); + myFilterDlg->SetMesh( myMesh ); + myFilterDlg->SetSourceWg( LineEditElements ); + + myFilterDlg->show(); +} diff --git a/src/SMESHGUI/SMESHGUI_TranslationDlg.h b/src/SMESHGUI/SMESHGUI_TranslationDlg.h index 7fd24a930..3c3ae8987 100644 --- a/src/SMESHGUI/SMESHGUI_TranslationDlg.h +++ b/src/SMESHGUI/SMESHGUI_TranslationDlg.h @@ -46,6 +46,7 @@ class QCheckBox; class SMESHGUI; class SMESHGUI_IdValidator; class SMESHGUI_SpinBox; +class SMESHGUI_FilterDlg; class SMESH_Actor; class SVTK_Selector; class LightApp_SelectionMgr; @@ -124,6 +125,8 @@ private: QLineEdit* LineEditNewMesh; QString myHelpFileName; + + SMESHGUI_FilterDlg* myFilterDlg; private slots: void ConstructorsClicked( int ); @@ -138,6 +141,7 @@ private slots: void onTextChange( const QString& ); void onSelectMesh( bool ); void onActionClicked( int ); + void setFilters(); }; #endif // SMESHGUI_TRANSLATIONDLG_H diff --git a/src/SMESHGUI/SMESH_images.ts b/src/SMESHGUI/SMESH_images.ts index e17d097ce..57caf7ffb 100644 --- a/src/SMESHGUI/SMESH_images.ts +++ b/src/SMESHGUI/SMESH_images.ts @@ -226,6 +226,10 @@ ICON_FREE_NODE mesh_free_nodes.png + + ICON_FREE_FACES + mesh_free_faces.png + ICON_HYPO mesh_hypo_length.png diff --git a/src/SMESHGUI/SMESH_msg_en.ts b/src/SMESHGUI/SMESH_msg_en.ts index baa4a1232..a7a4f781f 100644 --- a/src/SMESHGUI/SMESH_msg_en.ts +++ b/src/SMESHGUI/SMESH_msg_en.ts @@ -310,6 +310,10 @@ MEN_FREE_NODE Free Nodes + + MEN_FREE_FACES + Free Faces + MEN_GLOBAL_HYPO Global Hypothesis @@ -2070,6 +2074,10 @@ Consider saving your work before application crash + + STB_FREE_FACES + Free Faces + STB_GLOBAL_HYPO Global Hypothesis @@ -2548,6 +2556,10 @@ Consider saving your work before application crash + + TOP_FREE_FACES + Free Faces + TOP_GLOBAL_HYPO Global Hypothesis @@ -3460,8 +3472,8 @@ Please select a groups and try again Please select valid object and try again - CURRENT_GROUP - Current Group + CURRENT_DIALOG + Current Dialog EDGES_TLT @@ -3756,6 +3768,10 @@ Please enter correct value and try again + + FREE_FACES + Free faces + ID ID @@ -3768,6 +3784,10 @@ Please enter correct value and try again LENGTH Length + + LENGTH2D + Length 2D + LESS_THAN Less than @@ -3787,6 +3807,11 @@ Please enter correct value and try again MULTIEDGES_ERROR Threshold value of borders at multi-connections can not be equal 1 +Please enter correct value and try again + + + GROUPCOLOR_ERROR + Color of group can not be undefied Please enter correct value and try again @@ -3841,6 +3866,66 @@ Please enter correct value and try again WARPING Warping + + LINEAR + Linear + + + GROUP_COLOR + Color of Group + + + ELEMENTS + Elements + + + GEOM_TYPE + Geomtry type + + + GEOM_TYPE_0 + + + + GEOM_TYPE_0 + Point + + + GEOM_TYPE_1 + Edge + + + GEOM_TYPE_2 + Triangle + + + GEOM_TYPE_3 + Quadrangle + + + GEOM_TYPE_4 + Polygon + + + GEOM_TYPE_5 + Tetrahedron + + + GEOM_TYPE_6 + Pyramid + + + GEOM_TYPE_7 + Hexahedron + + + GEOM_TYPE_8 + Pentahedron + + + GEOM_TYPE_9 + Polyhedra + SMESHGUI_GroupOpDlg diff --git a/src/SMESH_I/SMESH_Filter_i.cxx b/src/SMESH_I/SMESH_Filter_i.cxx index be7f625f7..7991ab1b2 100644 --- a/src/SMESH_I/SMESH_Filter_i.cxx +++ b/src/SMESH_I/SMESH_Filter_i.cxx @@ -1283,6 +1283,21 @@ FunctorType FreeEdges_i::GetFunctorType() return SMESH::FT_FreeEdges; } +/* + Class : FreeFaces_i + Description : Predicate for free faces +*/ +FreeFaces_i::FreeFaces_i() +{ + myPredicatePtr.reset(new Controls::FreeFaces()); + myFunctorPtr = myPredicatePtr; +} + +FunctorType FreeFaces_i::GetFunctorType() +{ + return SMESH::FT_FreeFaces; +} + /* Class : FreeNodes_i Description : Predicate for free nodes @@ -1346,6 +1361,94 @@ FunctorType RangeOfIds_i::GetFunctorType() return SMESH::FT_RangeOfIds; } +/* + Class : LinearOrQuadratic_i + Description : Predicate to verify whether a mesh element is linear +*/ +LinearOrQuadratic_i::LinearOrQuadratic_i() +{ + myLinearOrQuadraticPtr.reset(new Controls::LinearOrQuadratic()); + myFunctorPtr = myPredicatePtr = myLinearOrQuadraticPtr; +} + +void LinearOrQuadratic_i::SetElementType(ElementType theType) +{ + myLinearOrQuadraticPtr->SetType(SMDSAbs_ElementType(theType)); + TPythonDump()<SetColorStr( + TCollection_AsciiString( (Standard_CString)theColor ) ); + TPythonDump()<GetColorStr( aStr ); + return CORBA::string_dup( aStr.ToCString() ); +} + +void GroupColor_i::SetElementType(ElementType theType) +{ + myGroupColorPtr->SetType(SMDSAbs_ElementType(theType)); + TPythonDump()<SetType(SMDSAbs_ElementType(theType)); + TPythonDump()<SetGeomType(SMDSAbs_GeometryType(theType)); + TPythonDump()<GetGeomType();; +} + +FunctorType ElemGeomType_i::GetFunctorType() +{ + return SMESH::FT_ElemGeomType; +} + /* Class : Comparator_i Description : Base class for comparators @@ -1778,6 +1881,14 @@ FreeEdges_ptr FilterManager_i::CreateFreeEdges() return anObj._retn(); } +FreeFaces_ptr FilterManager_i::CreateFreeFaces() +{ + SMESH::FreeFaces_i* aServant = new SMESH::FreeFaces_i(); + SMESH::FreeFaces_var anObj = aServant->_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<length(); @@ -2167,6 +2300,33 @@ static inline bool getCriteria( Predicate_i* thePred, theCriteria[ theCriteria->length() - 1 ].BinaryOp = aFType; return getCriteria( aPred2, theCriteria ); } + case FT_GroupColor: + { + CORBA::ULong i = theCriteria->length(); + theCriteria->length( i + 1 ); + + theCriteria[ i ] = createCriterion(); + + GroupColor_i* aPred = dynamic_cast( thePred ); + theCriteria[ i ].Type = aFType; + theCriteria[ i ].TypeOfElement = aPred->GetElementType(); + theCriteria[ i ].ThresholdStr = aPred->GetColorStr(); + + return true; + } + case FT_ElemGeomType: + { + CORBA::ULong i = theCriteria->length(); + theCriteria->length( i + 1 ); + + theCriteria[ i ] = createCriterion(); + + ElemGeomType_i* aPred = dynamic_cast( thePred ); + theCriteria[ i ].Type = aFType; + theCriteria[ i ].TypeOfElement = aPred->GetElementType(); + theCriteria[ i ].Threshold = (double)aPred->GetGeometryType(); + return true; + } case FT_Undefined: return false; @@ -2281,6 +2441,9 @@ CORBA::Boolean Filter_i::SetCriteria( const SMESH::Filter::Criteria& theCriteria case SMESH::FT_FreeEdges: aPredicate = aFilterMgr->CreateFreeEdges(); break; + case SMESH::FT_FreeFaces: + aPredicate = aFilterMgr->CreateFreeFaces(); + break; case SMESH::FT_FreeNodes: aPredicate = aFilterMgr->CreateFreeNodes(); break; @@ -2331,6 +2494,29 @@ CORBA::Boolean Filter_i::SetCriteria( const SMESH::Filter::Criteria& theCriteria aPredicate = aFilterMgr->CreateBadOrientedVolume(); } break; + case SMESH::FT_LinearOrQuadratic: + { + SMESH::LinearOrQuadratic_ptr tmpPred = aFilterMgr->CreateLinearOrQuadratic(); + tmpPred->SetElementType( aTypeOfElem ); + aPredicate = tmpPred; + break; + } + case SMESH::FT_GroupColor: + { + SMESH::GroupColor_ptr tmpPred = aFilterMgr->CreateGroupColor(); + tmpPred->SetElementType( aTypeOfElem ); + tmpPred->SetColorStr( aThresholdStr ); + aPredicate = tmpPred; + break; + } + case SMESH::FT_ElemGeomType: + { + SMESH::ElemGeomType_ptr tmpPred = aFilterMgr->CreateElemGeomType(); + tmpPred->SetElementType( aTypeOfElem ); + tmpPred->SetGeometryType( (GeometryType)(aThreshold + 0.5) ); + aPredicate = tmpPred; + break; + } default: continue; @@ -2542,17 +2728,21 @@ static inline LDOMString toString( CORBA::Long theType ) case FT_RangeOfIds : return "Range of IDs"; case FT_FreeBorders : return "Free borders"; case FT_FreeEdges : return "Free edges"; + case FT_FreeFaces : return "Free faces"; case FT_FreeNodes : return "Free nodes"; case FT_MultiConnection : return "Borders at multi-connections"; case FT_MultiConnection2D: return "Borders at multi-connections 2D"; case FT_Length : return "Length"; - case FT_Length2D : return "Length2D"; + case FT_Length2D : return "Length 2D"; case FT_LessThan : return "Less than"; case FT_MoreThan : return "More than"; case FT_EqualTo : return "Equal to"; case FT_LogicalNOT : return "Not"; case FT_LogicalAND : return "And"; case FT_LogicalOR : return "Or"; + case FT_GroupColor : return "Color of Group"; + case FT_LinearOrQuadratic : return "Linear or Quadratic"; + case FT_ElemGeomType : return "Element geomtry type"; case FT_Undefined : return ""; default : return ""; } @@ -2578,6 +2768,7 @@ static inline SMESH::FunctorType toFunctorType( const LDOMString& theStr ) else if ( theStr.equals( "Lying on Geom" ) ) return FT_LyingOnGeom; else if ( theStr.equals( "Free borders" ) ) return FT_FreeBorders; else if ( theStr.equals( "Free edges" ) ) return FT_FreeEdges; + else if ( theStr.equals( "Free faces" ) ) return FT_FreeFaces; else if ( theStr.equals( "Free nodes" ) ) return FT_FreeNodes; else if ( theStr.equals( "Borders at multi-connections" ) ) return FT_MultiConnection; // else if ( theStr.equals( "Borders at multi-connections 2D" ) ) return FT_MultiConnection2D; @@ -2591,6 +2782,9 @@ static inline SMESH::FunctorType toFunctorType( const LDOMString& theStr ) else if ( theStr.equals( "Not" ) ) return FT_LogicalNOT; else if ( theStr.equals( "And" ) ) return FT_LogicalAND; else if ( theStr.equals( "Or" ) ) return FT_LogicalOR; + else if ( theStr.equals( "Color of Group" ) ) return FT_GroupColor; + else if ( theStr.equals( "Linear or Quadratic" ) ) return FT_LinearOrQuadratic; + else if ( theStr.equals( "Element geomtry type" ) ) return FT_ElemGeomType; else if ( theStr.equals( "" ) ) return FT_Undefined; else return FT_Undefined; } @@ -2863,7 +3057,7 @@ Filter_ptr FilterLibrary_i::Copy( const char* theFilterName ) } else aCriterion.ThresholdStr = str.GetString(); - + aCriteria.push_back( aCriterion ); } diff --git a/src/SMESH_I/SMESH_Filter_i.hxx b/src/SMESH_I/SMESH_Filter_i.hxx index c6971b0fd..f14fccdcb 100644 --- a/src/SMESH_I/SMESH_Filter_i.hxx +++ b/src/SMESH_I/SMESH_Filter_i.hxx @@ -522,6 +522,19 @@ namespace SMESH }; + /* + Class : FreeFaces_i + Description : Predicate for free faces + */ + class SMESH_I_EXPORT FreeFaces_i: public virtual POA_SMESH::FreeFaces, + public virtual Predicate_i + { + public: + FreeFaces_i(); + FunctorType GetFunctorType(); + }; + + /* Class : FreeNodes_i Description : Predicate for free nodes @@ -554,6 +567,60 @@ namespace SMESH protected: Controls::RangeOfIdsPtr myRangeOfIdsPtr; }; + + /* + Class : LinearOrQuadratic_i + Description : Verify whether a mesh element is linear + */ + class SMESH_I_EXPORT LinearOrQuadratic_i: public virtual POA_SMESH::LinearOrQuadratic, + public virtual Predicate_i + { + public: + LinearOrQuadratic_i(); + FunctorType GetFunctorType(); + void SetElementType( ElementType theType ); + + private: + Controls::LinearOrQuadraticPtr myLinearOrQuadraticPtr; + }; + + /* + Class : GroupColor_i + Description : Functor for check color of group to whic mesh element belongs to + */ + class SMESH_I_EXPORT GroupColor_i: public virtual POA_SMESH::GroupColor, + public virtual Predicate_i + { + public: + GroupColor_i(); + FunctorType GetFunctorType(); + + void SetElementType( ElementType theType ); + void SetColorStr( const char* theColor ); + char* GetColorStr(); + + private: + Controls::GroupColorPtr myGroupColorPtr; + }; + + /* + Class : ElemGeomType_i + Description : Functor for check element geometry type + */ + class SMESH_I_EXPORT ElemGeomType_i: public virtual POA_SMESH::ElemGeomType, + public virtual Predicate_i + { + public: + ElemGeomType_i(); + FunctorType GetFunctorType(); + + void SetElementType ( ElementType theType ); + void SetGeometryType( GeometryType theType ); + GeometryType GetGeometryType() const; + + private: + Controls::ElemGeomTypePtr myElemGeomTypePtr; + }; /* Class : Comparator_i @@ -830,11 +897,17 @@ namespace SMESH FreeBorders_ptr CreateFreeBorders(); FreeEdges_ptr CreateFreeEdges(); FreeNodes_ptr CreateFreeNodes(); + FreeFaces_ptr CreateFreeFaces(); RangeOfIds_ptr CreateRangeOfIds(); BadOrientedVolume_ptr CreateBadOrientedVolume(); + LinearOrQuadratic_ptr CreateLinearOrQuadratic(); + GroupColor_ptr CreateGroupColor(); + + ElemGeomType_ptr CreateElemGeomType(); + LessThan_ptr CreateLessThan(); MoreThan_ptr CreateMoreThan(); EqualTo_ptr CreateEqualTo(); diff --git a/src/SMESH_SWIG/smeshDC.py b/src/SMESH_SWIG/smeshDC.py index da15d1fa0..9530fe60e 100644 --- a/src/SMESH_SWIG/smeshDC.py +++ b/src/SMESH_SWIG/smeshDC.py @@ -475,7 +475,8 @@ class smeshDC(SMESH._objref_SMESH_Gen): else: print "Error: The treshold should be a string." return None - elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_BadOrientedVolume, FT_FreeNodes]: + elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_BadOrientedVolume, FT_FreeNodes, + FT_FreeFaces, FT_ElemGeomType, FT_GroupColor]: # At this point the treshold is unnecessary if aTreshold == FT_LogicalNOT: aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)