diff --git a/INSTALL b/INSTALL index 72bd5f169..d9e6d956d 100644 --- a/INSTALL +++ b/INSTALL @@ -1,5 +1,6 @@ -This is the version 2.2.0 of SMESH +This is the version 3.0.0 of SMESH Compatible with : - - KERNEL 2.2.0 - - GEOM 2.2.0 - - MED 2.2.0 + - KERNEL 3.0.0 + - GUI 3.0.0 + - GEOM 3.0.0 + - MED 3.0.0 diff --git a/Makefile.in b/Makefile.in index dfbd2629a..c659cb280 100644 --- a/Makefile.in +++ b/Makefile.in @@ -53,6 +53,8 @@ mesh_line.png \ mesh_move_node.png \ mesh_orientation.png \ mesh.png \ +mesh_polygon.png \ +mesh_polyhedron.png \ mesh_pyramid_n.png \ mesh_pyramid.png \ mesh_quad_n.png \ diff --git a/adm_local/unix/make_commence.in b/adm_local/unix/make_commence.in index 5e2ad5bb8..e7e10c9a5 100644 --- a/adm_local/unix/make_commence.in +++ b/adm_local/unix/make_commence.in @@ -67,7 +67,7 @@ QT_MT_LIBS = @QT_MT_LIBS@ MOC = @MOC@ UIC = @UIC@ - +MSG2QM = @MSG2QM@ #QWT diff --git a/adm_local/unix/make_conclude.in b/adm_local/unix/make_conclude.in index 9eac1df82..f4827fd31 100644 --- a/adm_local/unix/make_conclude.in +++ b/adm_local/unix/make_conclude.in @@ -327,11 +327,7 @@ distclean: clean $(SWIG) $(SWIG_FLAGS) -o $@ $< $(top_builddir)/share/salome/resources/%.qm: %.po - if test -e ${KERNEL_ROOT_DIR}/bin/salome/msg2qm ; then \ - ${KERNEL_ROOT_DIR}/bin/salome/msg2qm $< $@ ; \ - else \ - $(top_builddir)/bin/salome/msg2qm $< $@ ; \ - fi + $(MSG2QM) $< $@ ; \ #------------------------------------------------------------------------------ # The following section of this makefile contains dependencies between the diff --git a/bin/VERSION b/bin/VERSION index 44f7b56ff..e0c447a4d 100755 --- a/bin/VERSION +++ b/bin/VERSION @@ -1,2 +1,2 @@ -THIS IS SALOME - SMESH VERSION: 2.2.0 +THIS IS SALOME - SMESH VERSION: 3.0.0 diff --git a/configure.in.base b/configure.in.base index 2e65ed140..71cdbb9d6 100644 --- a/configure.in.base +++ b/configure.in.base @@ -217,6 +217,14 @@ echo CHECK_QT +echo +echo --------------------------------------------- +echo testing MSG2QM +echo --------------------------------------------- +echo + +CHECK_MSG2QM + echo echo --------------------------------------------- echo testing VTK diff --git a/idl/SMESH_Filter.idl b/idl/SMESH_Filter.idl index 0644362d4..929afb67a 100644 --- a/idl/SMESH_Filter.idl +++ b/idl/SMESH_Filter.idl @@ -278,7 +278,7 @@ module SMESH /*! * Filter */ - interface Filter: SALOME::GenericObj + interface Filter: SALOME::GenericObj, SMESH_IDSource { /*! * Structure containing information about one criterion @@ -312,6 +312,8 @@ module SMESH typedef sequence Criteria; void SetPredicate( in Predicate thePredicate ); + void SetMesh( in SMESH_Mesh theMesh ); + long_array GetElementsId( in SMESH_Mesh theMesh ); ElementType GetElementType(); Predicate GetPredicate(); diff --git a/idl/SMESH_Group.idl b/idl/SMESH_Group.idl index a39c3445d..37657674b 100644 --- a/idl/SMESH_Group.idl +++ b/idl/SMESH_Group.idl @@ -33,6 +33,8 @@ module SMESH { + interface Predicate; + /*! * SMESH_Group: base interface of group object */ @@ -98,11 +100,13 @@ module SMESH * Adds elements to the group */ long Add( in long_array elem_ids ); + long AddByPredicate( in Predicate thePredicate ); /*! * Removes elements from the group */ long Remove( in long_array elem_ids ); + long RemoveByPredicate( in Predicate thePredicate ); }; /*! diff --git a/idl/SMESH_Mesh.idl b/idl/SMESH_Mesh.idl index e380a6a09..53579df6a 100644 --- a/idl/SMESH_Mesh.idl +++ b/idl/SMESH_Mesh.idl @@ -58,14 +58,17 @@ module SMESH ADD_EDGE, ADD_TRIANGLE, ADD_QUADRANGLE, + ADD_POLYGON, ADD_TETRAHEDRON, ADD_PYRAMID, ADD_PRISM, ADD_HEXAHEDRON, + ADD_POLYHEDRON, REMOVE_NODE, REMOVE_ELEMENT, MOVE_NODE, CHANGE_ELEMENT_NODES, + CHANGE_POLYHEDRON_NODES, RENUMBER }; @@ -375,6 +378,9 @@ module SMESH long NbQuadrangles() raises (SALOME::SALOME_Exception); + long NbPolygons() + raises (SALOME::SALOME_Exception); + long NbVolumes() raises (SALOME::SALOME_Exception); @@ -390,6 +396,9 @@ module SMESH long NbPrisms() raises (SALOME::SALOME_Exception); + long NbPolyhedrons() + raises (SALOME::SALOME_Exception); + long NbSubMesh() raises (SALOME::SALOME_Exception); @@ -461,7 +470,7 @@ module SMESH raises (SALOME::SALOME_Exception); }; - /* + /*! * This interface makes modifications on the Mesh - removing elements and nodes etc. */ interface NumericalFunctor; @@ -480,6 +489,25 @@ module SMESH boolean AddVolume(in long_array IDsOfNodes); + //boolean AddPolygonalFace (in long_array IdsOfNodes); + + /*! + * Create volume of many faces, giving nodes for each face. + * \param IdsOfNodes List of node IDs for volume creation face by face. + * \param Quantities List of integer values, Quantities[i] + * gives quantity of nodes in face number i. + */ + boolean AddPolyhedralVolume (in long_array IdsOfNodes, + in long_array Quantities); + + /*! + * Create volume of many faces, giving IDs of existing faces. + * \param IdsOfFaces List of face IDs for volume creation. + * \note The created volume will refer only to nodes + * of the given faces, not to the faces itself. + */ + boolean AddPolyhedralVolumeByFaces (in long_array IdsOfFaces); + boolean MoveNode(in long NodeID, in double x, in double y, in double z); boolean InverseDiag(in long NodeID1, in long NodeID2); @@ -521,6 +549,18 @@ module SMESH in double MaxAspectRatio, in Smooth_Method Method); + boolean SmoothParametric(in long_array IDsOfElements, + in long_array IDsOfFixedNodes, + in long MaxNbOfIterations, + in double MaxAspectRatio, + in Smooth_Method Method); + + boolean SmoothParametricObject(in SMESH_IDSource theObject, + in long_array IDsOfFixedNodes, + in long MaxNbOfIterations, + in double MaxAspectRatio, + in Smooth_Method Method); + void RenumberNodes(); void RenumberElements(); @@ -637,7 +677,9 @@ module SMESH in long LastNodeID1, in long FirstNodeID2, in long SecondNodeID2, - in long LastNodeID2); + in long LastNodeID2, + in boolean CreatePolygons, + in boolean CreatePolyedrs); Sew_Error SewConformFreeBorders (in long FirstNodeID1, in long SecondNodeID1, @@ -649,7 +691,9 @@ module SMESH in long SecondNodeIDOnFreeBorder, in long LastNodeIDOnFreeBorder, in long FirstNodeIDOnSide, - in long LastNodeIDOnSide); + in long LastNodeIDOnSide, + in boolean CreatePolygons, + in boolean CreatePolyedrs); Sew_Error SewSideElements (in long_array IDsOfSide1Elements, in long_array IDsOfSide2Elements, diff --git a/idl/SMESH_Pattern.idl b/idl/SMESH_Pattern.idl index fa1d7dd11..d2324a0b2 100644 --- a/idl/SMESH_Pattern.idl +++ b/idl/SMESH_Pattern.idl @@ -103,9 +103,15 @@ module SMESH /*! * Create nodes and elements in using nodes - * coordinates computed by either of Apply...() methods + * coordinates computed by either of Apply...() methods. + * If CreatePolygons is TRUE, replace adjacent faces by polygons + * to keep mesh conformity. + * If CreatePolyedrs is TRUE, replace adjacent volumes by polyedrs + * to keep mesh conformity. */ - boolean MakeMesh(in SMESH_Mesh theMesh); + boolean MakeMesh (in SMESH_Mesh theMesh, + in boolean CreatePolygons, + in boolean CreatePolyedrs); /*! * Return the loaded pattern in the string form to be saved in file diff --git a/resources/SMESHCatalog.xml b/resources/SMESHCatalog.xml index 76072ee74..e66eb085d 100644 --- a/resources/SMESHCatalog.xml +++ b/resources/SMESHCatalog.xml @@ -16,7 +16,7 @@ Mesh MESH NRI - 2.2.0 + 3.0.0 Mesh component 1 ModuleMesh.png diff --git a/resources/SMESH_en.xml b/resources/SMESH_en.xml index 0bbbc4597..7d314c75d 100644 --- a/resources/SMESH_en.xml +++ b/resources/SMESH_en.xml @@ -97,8 +97,10 @@ + + @@ -440,8 +442,10 @@ + + diff --git a/resources/mesh_polygon.png b/resources/mesh_polygon.png new file mode 100644 index 000000000..a1f671b1f Binary files /dev/null and b/resources/mesh_polygon.png differ diff --git a/resources/mesh_polyhedron.png b/resources/mesh_polyhedron.png new file mode 100644 index 000000000..f475dec62 Binary files /dev/null and b/resources/mesh_polyhedron.png differ diff --git a/src/Controls/SMESH_Controls.cxx b/src/Controls/SMESH_Controls.cxx index 4aa92f1d2..3dd59cf5d 100644 --- a/src/Controls/SMESH_Controls.cxx +++ b/src/Controls/SMESH_Controls.cxx @@ -81,7 +81,7 @@ namespace{ return aDist; } - int getNbMultiConnection( SMDS_Mesh* theMesh, const int theId ) + int getNbMultiConnection( const SMDS_Mesh* theMesh, const int theId ) { if ( theMesh == 0 ) return 0; @@ -137,7 +137,7 @@ NumericalFunctor::NumericalFunctor(): myPrecision = -1; } -void NumericalFunctor::SetMesh( SMDS_Mesh* theMesh ) +void NumericalFunctor::SetMesh( const SMDS_Mesh* theMesh ) { myMesh = theMesh; } @@ -213,26 +213,17 @@ double MinimumAngle::GetValue( const TSequenceOfXYZ& P ) { double aMin; - if ( P.size() == 3 ) - { - double A0 = getAngle( P( 3 ), P( 1 ), P( 2 ) ); - double A1 = getAngle( P( 1 ), P( 2 ), P( 3 ) ); - double A2 = getAngle( P( 2 ), P( 3 ), P( 1 ) ); - - aMin = Min( A0, Min( A1, A2 ) ); - } - else if ( P.size() == 4 ) - { - double A0 = getAngle( P( 4 ), P( 1 ), P( 2 ) ); - double A1 = getAngle( P( 1 ), P( 2 ), P( 3 ) ); - double A2 = getAngle( P( 2 ), P( 3 ), P( 4 ) ); - double A3 = getAngle( P( 3 ), P( 4 ), P( 1 ) ); - - aMin = Min( Min( A0, A1 ), Min( A2, A3 ) ); - } - else + if (P.size() <3) return 0.; + + aMin = getAngle(P( P.size() ), P( 1 ), P( 2 )); + aMin = Min(aMin,getAngle(P( P.size()-1 ), P( P.size() ), P( 1 ))); + for (int i=2; i 3) + aArea = getArea( P( 1 ), P( 2 ), P( 3 ) ); else return 0; + + for (int i=4; i<=P.size(); i++) + aArea += getArea(P(1),P(i-1),P(i)); + return aArea; } double Area::GetBadRate( double Value, int /*nbNodes*/ ) const @@ -1034,7 +1030,6 @@ double MultiConnection2D::GetValue( long theElementId ) int aResult = 0; if (GetPoints(theElementId,P)){ - double aVal; const SMDS_MeshElement* anFaceElem = myMesh->FindElement( theElementId ); SMDSAbs_ElementType aType = anFaceElem->GetType(); @@ -1116,7 +1111,6 @@ void MultiConnection2D::GetValues(MValues& theValues){ SMDS_FaceIteratorPtr anIter = myMesh->facesIterator(); for(; anIter->more(); ){ const SMDS_MeshFace* anElem = anIter->next(); - long anElemId = anElem->GetID(); SMDS_ElemIteratorPtr aNodesIter = anElem->nodesIterator(); long aNodeId[3]; @@ -1176,7 +1170,7 @@ BadOrientedVolume::BadOrientedVolume() myMesh = 0; } -void BadOrientedVolume::SetMesh( SMDS_Mesh* theMesh ) +void BadOrientedVolume::SetMesh( const SMDS_Mesh* theMesh ) { myMesh = theMesh; } @@ -1207,7 +1201,7 @@ FreeBorders::FreeBorders() myMesh = 0; } -void FreeBorders::SetMesh( SMDS_Mesh* theMesh ) +void FreeBorders::SetMesh( const SMDS_Mesh* theMesh ) { myMesh = theMesh; } @@ -1232,7 +1226,7 @@ FreeEdges::FreeEdges() myMesh = 0; } -void FreeEdges::SetMesh( SMDS_Mesh* theMesh ) +void FreeEdges::SetMesh( const SMDS_Mesh* theMesh ) { myMesh = theMesh; } @@ -1379,7 +1373,7 @@ RangeOfIds::RangeOfIds() // name : SetMesh // Purpose : Set mesh //======================================================================= -void RangeOfIds::SetMesh( SMDS_Mesh* theMesh ) +void RangeOfIds::SetMesh( const SMDS_Mesh* theMesh ) { myMesh = theMesh; } @@ -1581,7 +1575,7 @@ Comparator::Comparator(): Comparator::~Comparator() {} -void Comparator::SetMesh( SMDS_Mesh* theMesh ) +void Comparator::SetMesh( const SMDS_Mesh* theMesh ) { if ( myFunctor ) myFunctor->SetMesh( theMesh ); @@ -1666,7 +1660,7 @@ bool LogicalNOT::IsSatisfy( long theId ) return myPredicate && !myPredicate->IsSatisfy( theId ); } -void LogicalNOT::SetMesh( SMDS_Mesh* theMesh ) +void LogicalNOT::SetMesh( const SMDS_Mesh* theMesh ) { if ( myPredicate ) myPredicate->SetMesh( theMesh ); @@ -1693,7 +1687,7 @@ LogicalBinary::LogicalBinary() LogicalBinary::~LogicalBinary() {} -void LogicalBinary::SetMesh( SMDS_Mesh* theMesh ) +void LogicalBinary::SetMesh( const SMDS_Mesh* theMesh ) { if ( myPredicate1 ) myPredicate1->SetMesh( theMesh ); @@ -1767,11 +1761,10 @@ void Filter::SetPredicate( PredicatePtr thePredicate ) myPredicate = thePredicate; } - template -void FillSequence(const TIterator& theIterator, - TPredicate& thePredicate, - Filter::TIdSequence& theSequence) +inline void FillSequence(const TIterator& theIterator, + TPredicate& thePredicate, + Filter::TIdSequence& theSequence) { if ( theIterator ) { while( theIterator->more() ) { @@ -1783,40 +1776,46 @@ void FillSequence(const TIterator& theIterator, } } -Filter::TIdSequence -Filter::GetElementsId( SMDS_Mesh* theMesh ) +void +Filter:: +GetElementsId( const SMDS_Mesh* theMesh, + PredicatePtr thePredicate, + TIdSequence& theSequence ) { - TIdSequence aSequence; - if ( !theMesh || !myPredicate ) return aSequence; + theSequence.clear(); - myPredicate->SetMesh( theMesh ); + if ( !theMesh || !thePredicate ) + return; - SMDSAbs_ElementType aType = myPredicate->GetType(); + thePredicate->SetMesh( theMesh ); + + SMDSAbs_ElementType aType = thePredicate->GetType(); switch(aType){ - case SMDSAbs_Node:{ - FillSequence(theMesh->nodesIterator(),myPredicate,aSequence); + case SMDSAbs_Node: + FillSequence(theMesh->nodesIterator(),thePredicate,theSequence); + break; + case SMDSAbs_Edge: + FillSequence(theMesh->edgesIterator(),thePredicate,theSequence); + break; + case SMDSAbs_Face: + FillSequence(theMesh->facesIterator(),thePredicate,theSequence); + break; + case SMDSAbs_Volume: + FillSequence(theMesh->volumesIterator(),thePredicate,theSequence); + break; + case SMDSAbs_All: + FillSequence(theMesh->edgesIterator(),thePredicate,theSequence); + FillSequence(theMesh->facesIterator(),thePredicate,theSequence); + FillSequence(theMesh->volumesIterator(),thePredicate,theSequence); break; } - case SMDSAbs_Edge:{ - FillSequence(theMesh->edgesIterator(),myPredicate,aSequence); - break; - } - case SMDSAbs_Face:{ - FillSequence(theMesh->facesIterator(),myPredicate,aSequence); - break; - } - case SMDSAbs_Volume:{ - FillSequence(theMesh->volumesIterator(),myPredicate,aSequence); - break; - } - case SMDSAbs_All:{ - FillSequence(theMesh->edgesIterator(),myPredicate,aSequence); - FillSequence(theMesh->facesIterator(),myPredicate,aSequence); - FillSequence(theMesh->volumesIterator(),myPredicate,aSequence); - break; - } - } - return aSequence; +} + +void +Filter::GetElementsId( const SMDS_Mesh* theMesh, + Filter::TIdSequence& theSequence ) +{ + GetElementsId(theMesh,myPredicate,theSequence); } /* @@ -1880,7 +1879,7 @@ ManifoldPart::~ManifoldPart() myMesh = 0; } -void ManifoldPart::SetMesh( SMDS_Mesh* theMesh ) +void ManifoldPart::SetMesh( const SMDS_Mesh* theMesh ) { myMesh = theMesh; process(); @@ -2209,7 +2208,7 @@ ElementsOnSurface::~ElementsOnSurface() myMesh = 0; } -void ElementsOnSurface::SetMesh( SMDS_Mesh* theMesh ) +void ElementsOnSurface::SetMesh( const SMDS_Mesh* theMesh ) { if ( myMesh == theMesh ) return; diff --git a/src/Controls/SMESH_ControlsDef.hxx b/src/Controls/SMESH_ControlsDef.hxx index 339157e6c..02336ebbc 100644 --- a/src/Controls/SMESH_ControlsDef.hxx +++ b/src/Controls/SMESH_ControlsDef.hxx @@ -97,14 +97,14 @@ namespace SMESH{ { public: ~Functor(){} - virtual void SetMesh( SMDS_Mesh* theMesh ) = 0; + virtual void SetMesh( const SMDS_Mesh* theMesh ) = 0; virtual SMDSAbs_ElementType GetType() const = 0; }; class NumericalFunctor: public virtual Functor{ public: NumericalFunctor(); - virtual void SetMesh( SMDS_Mesh* theMesh ); + virtual void SetMesh( const SMDS_Mesh* theMesh ); virtual double GetValue( long theElementId ); virtual double GetValue(const TSequenceOfXYZ& thePoints) { return -1.0;}; virtual SMDSAbs_ElementType GetType() const = 0; @@ -117,7 +117,7 @@ namespace SMESH{ static bool GetPoints(const SMDS_MeshElement* theElem, TSequenceOfXYZ& theRes); protected: - SMDS_Mesh* myMesh; + const SMDS_Mesh* myMesh; long myPrecision; }; @@ -295,12 +295,12 @@ namespace SMESH{ class FreeBorders: public virtual Predicate{ public: FreeBorders(); - virtual void SetMesh( SMDS_Mesh* theMesh ); + virtual void SetMesh( const SMDS_Mesh* theMesh ); virtual bool IsSatisfy( long theElementId ); virtual SMDSAbs_ElementType GetType() const; protected: - SMDS_Mesh* myMesh; + const SMDS_Mesh* myMesh; }; @@ -311,12 +311,12 @@ namespace SMESH{ class BadOrientedVolume: public virtual Predicate{ public: BadOrientedVolume(); - virtual void SetMesh( SMDS_Mesh* theMesh ); + virtual void SetMesh( const SMDS_Mesh* theMesh ); virtual bool IsSatisfy( long theElementId ); virtual SMDSAbs_ElementType GetType() const; protected: - SMDS_Mesh* myMesh; + const SMDS_Mesh* myMesh; }; @@ -327,7 +327,7 @@ namespace SMESH{ class FreeEdges: public virtual Predicate{ public: FreeEdges(); - virtual void SetMesh( SMDS_Mesh* theMesh ); + virtual void SetMesh( const SMDS_Mesh* theMesh ); virtual bool IsSatisfy( long theElementId ); virtual SMDSAbs_ElementType GetType() const; static bool IsFreeEdge( const SMDS_MeshNode** theNodes, const int theFaceId ); @@ -342,7 +342,7 @@ namespace SMESH{ void GetBoreders(TBorders& theBorders); protected: - SMDS_Mesh* myMesh; + const SMDS_Mesh* myMesh; }; typedef boost::shared_ptr FreeEdgesPtr; @@ -359,7 +359,7 @@ namespace SMESH{ { public: RangeOfIds(); - virtual void SetMesh( SMDS_Mesh* theMesh ); + virtual void SetMesh( const SMDS_Mesh* theMesh ); virtual bool IsSatisfy( long theNodeId ); virtual SMDSAbs_ElementType GetType() const; virtual void SetType( SMDSAbs_ElementType theType ); @@ -369,7 +369,7 @@ namespace SMESH{ bool SetRangeStr( const TCollection_AsciiString& ); protected: - SMDS_Mesh* myMesh; + const SMDS_Mesh* myMesh; TColStd_SequenceOfInteger myMin; TColStd_SequenceOfInteger myMax; @@ -389,7 +389,7 @@ namespace SMESH{ public: Comparator(); virtual ~Comparator(); - virtual void SetMesh( SMDS_Mesh* theMesh ); + virtual void SetMesh( const SMDS_Mesh* theMesh ); virtual void SetMargin(double theValue); virtual void SetNumFunctor(NumericalFunctorPtr theFunct); virtual bool IsSatisfy( long theElementId ) = 0; @@ -449,7 +449,7 @@ namespace SMESH{ LogicalNOT(); virtual ~LogicalNOT(); virtual bool IsSatisfy( long theElementId ); - virtual void SetMesh( SMDS_Mesh* theMesh ); + virtual void SetMesh( const SMDS_Mesh* theMesh ); virtual void SetPredicate(PredicatePtr thePred); virtual SMDSAbs_ElementType GetType() const; @@ -467,7 +467,7 @@ namespace SMESH{ public: LogicalBinary(); virtual ~LogicalBinary(); - virtual void SetMesh( SMDS_Mesh* theMesh ); + virtual void SetMesh( const SMDS_Mesh* theMesh ); virtual void SetPredicate1(PredicatePtr thePred); virtual void SetPredicate2(PredicatePtr thePred); virtual SMDSAbs_ElementType GetType() const; @@ -532,7 +532,7 @@ namespace SMESH{ ManifoldPart(); ~ManifoldPart(); - virtual void SetMesh( SMDS_Mesh* theMesh ); + virtual void SetMesh( const SMDS_Mesh* theMesh ); // inoke when all parameters already set virtual bool IsSatisfy( long theElementId ); virtual SMDSAbs_ElementType GetType() const; @@ -560,7 +560,7 @@ namespace SMESH{ TVectorOfFacePtr& theFaces ) const; private: - SMDS_Mesh* myMesh; + const SMDS_Mesh* myMesh; TColStd_MapOfInteger myMapIds; TColStd_MapOfInteger myMapBadGeomIds; TVectorOfFacePtr myAllFacePtr; @@ -582,7 +582,7 @@ namespace SMESH{ public: ElementsOnSurface(); ~ElementsOnSurface(); - virtual void SetMesh( SMDS_Mesh* theMesh ); + virtual void SetMesh( const SMDS_Mesh* theMesh ); virtual bool IsSatisfy( long theElementId ); virtual SMDSAbs_ElementType GetType() const; @@ -597,7 +597,7 @@ namespace SMESH{ bool isOnSurface( const SMDS_MeshNode* theNode ) const; private: - SMDS_Mesh* myMesh; + const SMDS_Mesh* myMesh; TColStd_MapOfInteger myIds; SMDSAbs_ElementType myType; Handle(Geom_Surface) mySurf; @@ -615,9 +615,20 @@ namespace SMESH{ Filter(); virtual ~Filter(); virtual void SetPredicate(PredicatePtr thePred); + typedef std::vector TIdSequence; - virtual TIdSequence GetElementsId( SMDS_Mesh* theMesh ); - + + virtual + void + GetElementsId( const SMDS_Mesh* theMesh, + TIdSequence& theSequence ); + + static + void + GetElementsId( const SMDS_Mesh* theMesh, + PredicatePtr thePredicate, + TIdSequence& theSequence ); + protected: PredicatePtr myPredicate; }; diff --git a/src/DriverMED/DriverMED_R_SMESHDS_Mesh.cxx b/src/DriverMED/DriverMED_R_SMESHDS_Mesh.cxx index 1433e3208..1a0074604 100644 --- a/src/DriverMED/DriverMED_R_SMESHDS_Mesh.cxx +++ b/src/DriverMED/DriverMED_R_SMESHDS_Mesh.cxx @@ -268,7 +268,175 @@ Driver_Mesh::Status DriverMED_R_SMESHDS_Mesh::Perform() MED::TGeom::const_iterator anTGeomIter = aTGeom.begin(); for(; anTGeomIter != aTGeom.end(); anTGeomIter++){ const EGeometrieElement& aGeom = anTGeomIter->first; - if(aGeom == ePOINT1) continue; + + if (aGeom == ePOINT1) { + continue; + + } else if (aGeom == ePOLYGONE) { + PPolygoneInfo aPolygoneInfo = aMed->GetPPolygoneInfo(aMeshInfo,anEntity,aGeom); + EBooleen anIsElemNum = takeNumbers ? aPolygoneInfo->IsElemNum() : eFAUX; + + TElemNum aConn = aPolygoneInfo->GetConnectivite(); + TElemNum aIndex = aPolygoneInfo->GetIndex(); + + TInt nbPolygons = aPolygoneInfo->GetNbElem(); + + for (TInt iPG = 0; iPG < nbPolygons; iPG++) { + // get nodes + TInt aCurrPG_FirstNodeIndex = aIndex[iPG] - 1; + int nbNodes = aPolygoneInfo->GetNbConn(iPG); + std::vector nodes_ids (nbNodes); + //for (TInt inode = 0; inode < nbNodes; inode++) { + // nodes_ids[inode] = aConn[aCurrPG_FirstNodeIndex + inode]; + //} +#ifdef _EDF_NODE_IDS_ + if (anIsNodeNum) { + for (TInt inode = 0; inode < nbNodes; inode++) { + nodes_ids[inode] = aNodeInfo->GetElemNum(aConn[aCurrPG_FirstNodeIndex + inode] - 1); + } + } else { + for (TInt inode = 0; inode < nbNodes; inode++) { + nodes_ids[inode] = aConn[aCurrPG_FirstNodeIndex + inode]; + } + } +#else + for (TInt inode = 0; inode < nbNodes; inode++) { + nodes_ids[inode] = aConn[aCurrPG_FirstNodeIndex + inode]; + } +#endif + + bool isRenum = false; + SMDS_MeshElement* anElement = NULL; + TInt aFamNum = aPolygoneInfo->GetFamNum(iPG); + + try { + if (anIsElemNum) { + anElement = myMesh->AddPolygonalFaceWithID + (nodes_ids, aPolygoneInfo->GetElemNum(iPG)); + } + if (!anElement) { + std::vector nodes (nbNodes); + for (int inode = 0; inode < nbNodes; inode++) { + nodes[inode] = FindNode(myMesh, nodes_ids[inode]); + } + anElement = myMesh->AddPolygonalFace(nodes); + isRenum = anIsElemNum; + } + } catch (const std::exception& exc) { + aResult = DRS_FAIL; + } catch (...) { + aResult = DRS_FAIL; + } + + if (!anElement) { + aResult = DRS_WARN_SKIP_ELEM; + } else { + if (isRenum) { + anIsElemNum = eFAUX; + takeNumbers = false; + if (aResult < DRS_WARN_RENUMBER) + aResult = DRS_WARN_RENUMBER; + } + if (myFamilies.find(aFamNum) != myFamilies.end()) { + // Save reference to this element from its family + myFamilies[aFamNum]->AddElement(anElement); + myFamilies[aFamNum]->SetType(anElement->GetType()); + } + } + } // for (TInt iPG = 0; iPG < nbPolygons; iPG++) + continue; + + } else if (aGeom == ePOLYEDRE) { + PPolyedreInfo aPolyedreInfo = aMed->GetPPolyedreInfo(aMeshInfo,anEntity,aGeom); + EBooleen anIsElemNum = takeNumbers ? aPolyedreInfo->IsElemNum() : eFAUX; + + TElemNum aConn = aPolyedreInfo->GetConnectivite(); + TElemNum aFacesIndex = aPolyedreInfo->GetFacesIndex(); + TElemNum aIndex = aPolyedreInfo->GetIndex(); + + TInt nbPolyedres = aPolyedreInfo->GetNbElem(); + + for (int iPE = 0; iPE < nbPolyedres; iPE++) { + // get faces + int aCurrPE_FirstFaceIndex = aIndex[iPE] - 1; + int aNextPE_FirstFaceIndex = aIndex[iPE + 1] - 1; + int nbFaces = aNextPE_FirstFaceIndex - aCurrPE_FirstFaceIndex; + std::vector quantities (nbFaces); + for (int iFa = 0; iFa < nbFaces; iFa++) { + int aCurrFace_FirstNodeIndex = aFacesIndex[aCurrPE_FirstFaceIndex + iFa] - 1; + int aNextFace_FirstNodeIndex = aFacesIndex[aCurrPE_FirstFaceIndex + iFa + 1] - 1; + + int nbNodes = aNextFace_FirstNodeIndex - aCurrFace_FirstNodeIndex; + quantities[iFa] = nbNodes; + } + + // get nodes + int aCurrPE_FirstNodeIndex = aFacesIndex[aCurrPE_FirstFaceIndex] - 1; + int nbPENodes = aPolyedreInfo->GetNbConn(iPE); + std::vector nodes_ids (nbPENodes); + //for (int inode = 0; inode < nbPENodes; inode++) { + // nodes_ids[inode] = aConn[aCurrPE_FirstNodeIndex + inode]; + //} +#ifdef _EDF_NODE_IDS_ + if (anIsNodeNum) { + for (int inode = 0; inode < nbPENodes; inode++) { + nodes_ids[inode] = aNodeInfo->GetElemNum(aConn[aCurrPE_FirstNodeIndex + inode] - 1); + } + } else { + for (int inode = 0; inode < nbPENodes; inode++) { + nodes_ids[inode] = aConn[aCurrPE_FirstNodeIndex + inode]; + } + } +#else + for (int inode = 0; inode < nbPENodes; inode++) { + nodes_ids[inode] = aConn[aCurrPE_FirstNodeIndex + inode]; + } +#endif + + bool isRenum = false; + SMDS_MeshElement* anElement = NULL; + TInt aFamNum = aPolyedreInfo->GetFamNum(iPE); + + try { + if (anIsElemNum) { + anElement = myMesh->AddPolyhedralVolumeWithID + (nodes_ids, quantities, aPolyedreInfo->GetElemNum(iPE)); + } + if (!anElement) { + std::vector nodes (nbPENodes); + for (int inode = 0; inode < nbPENodes; inode++) { + nodes[inode] = FindNode(myMesh, nodes_ids[inode]); + } + anElement = myMesh->AddPolyhedralVolume(nodes, quantities); + isRenum = anIsElemNum; + } + } catch (const std::exception& exc) { + aResult = DRS_FAIL; + } catch (...) { + aResult = DRS_FAIL; + } + + if (!anElement) { + aResult = DRS_WARN_SKIP_ELEM; + } else { + if (isRenum) { + anIsElemNum = eFAUX; + takeNumbers = false; + if (aResult < DRS_WARN_RENUMBER) + aResult = DRS_WARN_RENUMBER; + } + if (myFamilies.find(aFamNum) != myFamilies.end()) { + // Save reference to this element from its family + myFamilies[aFamNum]->AddElement(anElement); + myFamilies[aFamNum]->SetType(anElement->GetType()); + } + } + } // for (int iPE = 0; iPE < nbPolyedres; iPE++) + continue; + + } else { + } + PCellInfo aCellInfo = aMed->GetPCellInfo(aMeshInfo,anEntity,aGeom); EBooleen anIsElemNum = takeNumbers ? aCellInfo->IsElemNum() : eFAUX; TInt aNbElems = aCellInfo->GetNbElem(); @@ -343,6 +511,8 @@ Driver_Mesh::Status DriverMED_R_SMESHDS_Mesh::Perform() SMDS_MeshElement* anElement = NULL; TInt aFamNum = aCellInfo->GetFamNum(iElem); try{ + //MESSAGE("Try to create element # " << iElem << " with id = " + // << aCellInfo->GetElemNum(iElem)); switch(aGeom){ case eSEG2: case eSEG3: @@ -586,7 +756,7 @@ void DriverMED_R_SMESHDS_Mesh::GetGroup(SMESHDS_Group* theGroup) for (; anElemsIter != anElements.end(); anElemsIter++) { element = *anElemsIter; - theGroup->SMDSGroup().Add(element); + theGroup->SMDSGroup().Add(element); } if ( element ) theGroup->SetType( element->GetType() ); diff --git a/src/DriverMED/DriverMED_W_SMESHDS_Mesh.cxx b/src/DriverMED/DriverMED_W_SMESHDS_Mesh.cxx index edd5418c4..82e134adf 100644 --- a/src/DriverMED/DriverMED_W_SMESHDS_Mesh.cxx +++ b/src/DriverMED/DriverMED_W_SMESHDS_Mesh.cxx @@ -33,6 +33,8 @@ #include "SMESHDS_Mesh.hxx" #include "SMDS_MeshElement.hxx" #include "SMDS_MeshNode.hxx" +#include "SMDS_PolyhedralVolumeOfNodes.hxx" + #include "utilities.h" #include "MED_Utilities.hxx" @@ -61,7 +63,7 @@ void DriverMED_W_SMESHDS_Mesh::SetFile(const std::string& theFileName, void DriverMED_W_SMESHDS_Mesh::SetFile(const std::string& theFileName) { - return SetFile(theFileName,MED::eV2_1); + return SetFile(theFileName,MED::eV2_2); } void DriverMED_W_SMESHDS_Mesh::SetMeshName(const std::string& theMeshName) @@ -440,6 +442,16 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform() MED::TIntVector aQuadConn; aQuadConn.reserve(aNbElems*aNbQuadConn); + MED::TIntVector aPolygoneElemNums; + aPolygoneElemNums.reserve(aNbElems); + MED::TIntVector aPolygoneInds; + aPolygoneInds.reserve(aNbElems + 1); + aPolygoneInds.push_back(1); // reference on the first element in the connectivities + MED::TIntVector aPolygoneFamilyNums; + aPolygoneFamilyNums.reserve(aNbElems); + MED::TIntVector aPolygoneConn; + aPolygoneConn.reserve(aNbElems*aNbQuadConn); + for(TInt iElem = 0; iElem < aNbElems && anIter->more(); iElem++){ const SMDS_MeshFace* anElem = anIter->next(); TInt aNbNodes = anElem->NbNodes(); @@ -448,41 +460,42 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform() MED::TIntVector* anElemNums; MED::TIntVector* aFamilyNums; MED::TIntVector* aConnectivity; - switch(aNbNodes){ - case 3: - aNbConnectivity = aNbTriaConn; - anElemNums = &anTriaElemNums; - aFamilyNums = &aTriaFamilyNums; - aConnectivity = &aTriaConn; - break; - case 4: - aNbConnectivity = aNbQuadConn; - anElemNums = &aQuadElemNums; - aFamilyNums = &aQuadFamilyNums; - aConnectivity = &aQuadConn; - break; - } + if (anElem->IsPoly()) { + aNbConnectivity = aNbNodes; + anElemNums = &aPolygoneElemNums; + aFamilyNums = &aPolygoneFamilyNums; + aConnectivity = &aPolygoneConn; + } else { + switch(aNbNodes){ + case 3: + aNbConnectivity = aNbTriaConn; + anElemNums = &anTriaElemNums; + aFamilyNums = &aTriaFamilyNums; + aConnectivity = &aTriaConn; + break; + case 4: + aNbConnectivity = aNbQuadConn; + anElemNums = &aQuadElemNums; + aFamilyNums = &aQuadFamilyNums; + aConnectivity = &aQuadConn; + break; + default: + break; + } + } MED::TIntVector aVector(aNbNodes); for(TInt iNode = 0; aNodesIter->more(); iNode++){ const SMDS_MeshElement* aNode = aNodesIter->next(); +#ifdef _EDF_NODE_IDS_ + aVector[iNode] = aNodeIdMap[aNode->GetID()]; +#else aVector[iNode] = aNode->GetID(); +#endif } TInt aSize = aConnectivity->size(); aConnectivity->resize(aSize+aNbConnectivity); - // There is some differnce between SMDS and MED in cells mapping -#ifdef _EDF_NODE_IDS_ - switch(aNbNodes){ - case 4: - (*aConnectivity)[aSize+0] = aNodeIdMap[aVector[0]]; - (*aConnectivity)[aSize+1] = aNodeIdMap[aVector[1]]; - (*aConnectivity)[aSize+2] = aNodeIdMap[aVector[3]]; - (*aConnectivity)[aSize+3] = aNodeIdMap[aVector[2]]; - default: - for(TInt iNode = 0; iNode < aNbNodes; iNode++) - (*aConnectivity)[aSize+iNode] = aNodeIdMap[aVector[iNode]]; - } -#else + // There is some differences between SMDS and MED in cells mapping switch(aNbNodes){ case 4: (*aConnectivity)[aSize+0] = aVector[0]; @@ -493,7 +506,13 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform() for(TInt iNode = 0; iNode < aNbNodes; iNode++) (*aConnectivity)[aSize+iNode] = aVector[iNode]; } -#endif + + if (anElem->IsPoly()) { + // fill indices for polygonal element + TInt aPrevPos = aPolygoneInds.back(); + aPolygoneInds.push_back(aPrevPos + aNbNodes); + } + anElemNums->push_back(anElem->GetID()); if (anElemFamMap.find(anElem) != anElemFamMap.end()) @@ -523,6 +542,22 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform() MESSAGE("Perform - anEntity = "<NbFaces(); + for (int iface = 1; iface <= aNbFaces; iface++) { + int aNbFaceNodes = aPolyedre->NbFaceNodes(iface); + for (int inode = 1; inode <= aNbFaceNodes; inode++) { + aNodeId = aPolyedre->GetFaceNode(iface, inode)->GetID(); #ifdef _EDF_NODE_IDS_ - switch(aNbNodes){ - case 5: - (*aConnectivity)[aSize+0] = aNodeIdMap[aVector[0]]; - (*aConnectivity)[aSize+1] = aNodeIdMap[aVector[3]]; - (*aConnectivity)[aSize+2] = aNodeIdMap[aVector[2]]; - (*aConnectivity)[aSize+3] = aNodeIdMap[aVector[1]]; - (*aConnectivity)[aSize+4] = aNodeIdMap[aVector[4]]; - default: - for(TInt iNode = 0; iNode < aNbNodes; iNode++) - (*aConnectivity)[aSize+iNode] = aNodeIdMap[aVector[iNode]]; - } + aPolyedreConn.push_back(aNodeIdMap[aNodeId]); #else - switch(aNbNodes){ - case 5: - (*aConnectivity)[aSize+0] = aVector[0]; - (*aConnectivity)[aSize+1] = aVector[3]; - (*aConnectivity)[aSize+2] = aVector[2]; - (*aConnectivity)[aSize+3] = aVector[1]; - (*aConnectivity)[aSize+4] = aVector[4]; - default: - for(TInt iNode = 0; iNode < aNbNodes; iNode++) - (*aConnectivity)[aSize+iNode] = aVector[iNode]; - } + aPolyedreConn.push_back(aNodeId); #endif - anElemNums->push_back(anElem->GetID()); + } + TInt aPrevPos = aPolyedreFaces.back(); + aPolyedreFaces.push_back(aPrevPos + aNbFaceNodes); + } + TInt aPrevPos = aPolyedreInds.back(); + aPolyedreInds.push_back(aPrevPos + aNbFaces); + + } else { + TInt aNbNodes = anElem->NbNodes(); + SMDS_ElemIteratorPtr aNodesIter = anElem->nodesIterator(); + TInt aNbConnectivity; + MED::TIntVector* aConnectivity; + switch(aNbNodes){ + case 4: + aNbConnectivity = aNbTetraConn; + anElemNums = &anTetraElemNums; + aFamilyNums = &aTetraFamilyNums; + aConnectivity = &aTetraConn; + break; + case 5: + aNbConnectivity = aNbPyraConn; + anElemNums = &anPyraElemNums; + aFamilyNums = &aPyraFamilyNums; + aConnectivity = &aPyraConn; + break; + case 6: + aNbConnectivity = aNbPentaConn; + anElemNums = &anPentaElemNums; + aFamilyNums = &aPentaFamilyNums; + aConnectivity = &aPentaConn; + break; + case 8: + aNbConnectivity = aNbHexaConn; + anElemNums = &aHexaElemNums; + aFamilyNums = &aHexaFamilyNums; + aConnectivity = &aHexaConn; + } + + TInt aSize = aConnectivity->size(); + aConnectivity->resize(aSize + aNbConnectivity); + + MED::TIntVector aVector(aNbNodes); + for(TInt iNode = 0; aNodesIter->more(); iNode++){ + const SMDS_MeshElement* aNode = aNodesIter->next(); +#ifdef _EDF_NODE_IDS_ + aVector[iNode] = aNodeIdMap[aNode->GetID()]; +#else + aVector[iNode] = aNode->GetID(); +#endif + } + // There is some difference between SMDS and MED in cells mapping + switch(aNbNodes){ + case 5: + (*aConnectivity)[aSize+0] = aVector[0]; + (*aConnectivity)[aSize+1] = aVector[3]; + (*aConnectivity)[aSize+2] = aVector[2]; + (*aConnectivity)[aSize+3] = aVector[1]; + (*aConnectivity)[aSize+4] = aVector[4]; + default: + for(TInt iNode = 0; iNode < aNbNodes; iNode++) + (*aConnectivity)[aSize+iNode] = aVector[iNode]; + } + } + + anElemNums->push_back(anElem->GetID()); if (anElemFamMap.find(anElem) != anElemFamMap.end()) aFamilyNums->push_back(anElemFamMap[anElem]); @@ -682,6 +754,23 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform() MESSAGE("Perform - anEntity = "< - -#include "DriverSTL_R_SMDS_Mesh.h" - -#include "SMDS_Mesh.hxx" -#include "SMDS_MeshElement.hxx" -#include "SMDS_MeshNode.hxx" #include -#include -#include -#include -#include -#include -#include -#include - -#include "utilities.h" - -static const int HEADER_SIZE = 84; -static const int SIZEOF_STL_FACET = 50; -//static const int STL_MIN_FILE_SIZE = 284; -static const int ASCII_LINES_PER_FACET = 7; - -static Standard_Real tab1[3]; -static Standard_Real tab2[3]; - -typedef NCollection_DataMap DriverSTL_DataMapOfPntNodePtr; -//typedef NCollection_BaseCollection DriverSTL_ColOfNodePtr; - //======================================================================= //function : HashCode //purpose : //======================================================================= inline Standard_Integer HashCode - (const gp_Pnt& point, const Standard_Integer Upper) + (const gp_Pnt& point, Standard_Integer Upper) { union { @@ -63,7 +36,8 @@ inline Standard_Integer HashCode return ::HashCode(U.I[0]/23+U.I[1]/19+U.I[2]/17+U.I[3]/13+U.I[4]/11+U.I[5]/7,Upper); } - +static Standard_Real tab1[3]; +static Standard_Real tab2[3]; //======================================================================= //function : IsEqual //purpose : @@ -75,7 +49,32 @@ inline Standard_Boolean IsEqual point2.Coord(tab2[0],tab2[1],tab2[2]); return (memcmp(tab1,tab2,sizeof(tab1)) == 0); } +#include "DriverSTL_R_SMDS_Mesh.h" +#include "SMDS_Mesh.hxx" +#include "SMDS_MeshElement.hxx" +#include "SMDS_MeshNode.hxx" + +#include +#include +#include +#include +#include +#include + +#include "utilities.h" + +static const int HEADER_SIZE = 84; +static const int SIZEOF_STL_FACET = 50; +//static const int STL_MIN_FILE_SIZE = 284; +static const int ASCII_LINES_PER_FACET = 7; + + +//typedef NCollection_BaseCollection DriverSTL_ColOfNodePtr; + + +#include +typedef NCollection_DataMap DriverSTL_DataMapOfPntNodePtr; //======================================================================= //function : DriverSTL_R_SMDS_Mesh //purpose : diff --git a/src/OBJECT/Makefile.in b/src/OBJECT/Makefile.in index bc91acb4a..8cf070ccf 100644 --- a/src/OBJECT/Makefile.in +++ b/src/OBJECT/Makefile.in @@ -50,9 +50,9 @@ LIB_CLIENT_IDL = SALOME_Exception.idl \ BIN = BIN_SRC = -CPPFLAGS+=$(OCC_INCLUDES) $(VTK_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome \ +CPPFLAGS+=$(OCC_INCLUDES) $(VTK_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome -I${GUI_ROOT_DIR}/include/salome \ $(BOOST_CPPFLAGS) $(QT_INCLUDES) -LDFLAGS+=$(OCC_KERNEL_LIBS) $(VTK_LIBS) -L${KERNEL_ROOT_DIR}/lib/salome -lSMDS \ - -lSalomeGUI -lSalomeObject -lSMESHControls +LDFLAGS+=$(OCC_KERNEL_LIBS) $(VTK_LIBS) -L${KERNEL_ROOT_DIR}/lib/salome -L${GUI_ROOT_DIR}/lib/salome -lSMDS \ + -lSalomeApp -lSalomeObject -lSMESHControls @CONCLUDE@ diff --git a/src/OBJECT/SMESH_Actor.cxx b/src/OBJECT/SMESH_Actor.cxx index 004399a7f..3db87dba4 100644 --- a/src/OBJECT/SMESH_Actor.cxx +++ b/src/OBJECT/SMESH_Actor.cxx @@ -31,9 +31,9 @@ #include "SMESH_ActorUtils.h" #include "SMESH_DeviceActor.h" #include "SMESH_ControlsDef.hxx" -#include "SALOME_ExtractUnstructuredGrid.h" +#include -#include "QAD_Config.h" +//#include "QAD_Config.h" #include #include @@ -73,7 +73,7 @@ #include "utilities.h" #ifdef _DEBUG_ -static int MYDEBUG = 0; +static int MYDEBUG = 1; #else static int MYDEBUG = 0; #endif @@ -118,7 +118,7 @@ SMESH_ActorDef::SMESH_ActorDef() float aLineWidth = SMESH::GetFloat("SMESH:SettingsWidth",1); vtkMatrix4x4 *aMatrix = vtkMatrix4x4::New(); - SALOME_ExtractUnstructuredGrid* aFilter = NULL; + VTKViewer_ExtractUnstructuredGrid* aFilter = NULL; //Definition 2D and 3D divices of the actor //----------------------------------------- @@ -142,7 +142,7 @@ SMESH_ActorDef::SMESH_ActorDef() my2DActor->SetBackfaceProperty(myBackSurfaceProp); my2DActor->SetRepresentation(SMESH_DeviceActor::eSurface); aFilter = my2DActor->GetExtractUnstructuredGrid(); - aFilter->SetModeOfChanging(SALOME_ExtractUnstructuredGrid::eAdding); + aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding); aFilter->RegisterCellsWithType(VTK_TRIANGLE); aFilter->RegisterCellsWithType(VTK_POLYGON); aFilter->RegisterCellsWithType(VTK_QUAD); @@ -154,13 +154,13 @@ SMESH_ActorDef::SMESH_ActorDef() my3DActor->SetBackfaceProperty(myBackSurfaceProp); my3DActor->SetRepresentation(SMESH_DeviceActor::eSurface); aFilter = my3DActor->GetExtractUnstructuredGrid(); - aFilter->SetModeOfChanging(SALOME_ExtractUnstructuredGrid::eAdding); + aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding); aFilter->RegisterCellsWithType(VTK_TETRA); aFilter->RegisterCellsWithType(VTK_VOXEL); aFilter->RegisterCellsWithType(VTK_HEXAHEDRON); aFilter->RegisterCellsWithType(VTK_WEDGE); aFilter->RegisterCellsWithType(VTK_PYRAMID); - + aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET); //Definition 1D divice of the actor //--------------------------------- @@ -181,7 +181,7 @@ SMESH_ActorDef::SMESH_ActorDef() my1DActor->SetProperty(myEdgeProp); my1DActor->SetRepresentation(SMESH_DeviceActor::eSurface); aFilter = my1DActor->GetExtractUnstructuredGrid(); - aFilter->SetModeOfChanging(SALOME_ExtractUnstructuredGrid::eAdding); + aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding); aFilter->RegisterCellsWithType(VTK_LINE); my1DProp = vtkProperty::New(); @@ -206,7 +206,7 @@ SMESH_ActorDef::SMESH_ActorDef() my1DExtActor->SetProperty(my1DExtProp); my1DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe); aFilter = my1DExtActor->GetExtractUnstructuredGrid(); - aFilter->SetModeOfChanging(SALOME_ExtractUnstructuredGrid::eAdding); + aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding); aFilter->RegisterCellsWithType(VTK_LINE); @@ -227,7 +227,7 @@ SMESH_ActorDef::SMESH_ActorDef() myNodeActor->SetProperty(myNodeProp); myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint); aFilter = myNodeActor->GetExtractUnstructuredGrid(); - aFilter->SetModeOfExtraction(SALOME_ExtractUnstructuredGrid::ePoints); + aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints); //Definition of Pickable and Highlitable engines @@ -288,38 +288,38 @@ SMESH_ActorDef::SMESH_ActorDef() vtkTextProperty* aScalarBarTitleProp = vtkTextProperty::New(); - if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarTitleColor" ) ) { +/* if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarTitleColor" ) ) { QStringList aTColor = QStringList::split( ":", QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleColor" ), false ); aScalarBarTitleProp->SetColor( ( aTColor.count() > 0 ? aTColor[0].toInt()/255. : 1.0 ), - ( aTColor.count() > 1 ? aTColor[1].toInt()/255. : 1.0 ), + ( aTColor.count() > 1 ? aTColor[1].toInt()/255. : 1.0 ), ( aTColor.count() > 2 ? aTColor[2].toInt()/255. : 1.0 ) ); } - else + else*/ aScalarBarTitleProp->SetColor( 1.0, 1.0, 1.0 ); aScalarBarTitleProp->SetFontFamilyToArial(); - if( QAD_CONFIG->hasSetting( "SMESH:ScalarBarTitleFont" ) ){ + /*if( QAD_CONFIG->hasSetting( "SMESH:ScalarBarTitleFont" ) ){ if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleFont" ) == "Arial" ) aScalarBarTitleProp->SetFontFamilyToArial(); else if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleFont" ) == "Courier" ) aScalarBarTitleProp->SetFontFamilyToCourier(); else if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleFont" ) == "Times" ) aScalarBarTitleProp->SetFontFamilyToTimes(); - } + }*/ - if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleBold" ) == "true" ) + /*if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleBold" ) == "true" ) aScalarBarTitleProp->BoldOn(); - else + else*/ aScalarBarTitleProp->BoldOff(); - if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleItalic" ) == "true" ) + /*if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleItalic" ) == "true" ) aScalarBarTitleProp->ItalicOn(); - else + else*/ aScalarBarTitleProp->ItalicOff(); - if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleShadow" ) == "true" ) + /*if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleShadow" ) == "true" ) aScalarBarTitleProp->ShadowOn(); - else + else*/ aScalarBarTitleProp->ShadowOff(); myScalarBarActor->SetTitleTextProperty( aScalarBarTitleProp ); @@ -327,74 +327,74 @@ SMESH_ActorDef::SMESH_ActorDef() vtkTextProperty* aScalarBarLabelProp = vtkTextProperty::New(); - if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarLabelColor" ) ) { + /*if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarLabelColor" ) ) { QStringList aTColor = QStringList::split( ":", QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelColor" ), false ); aScalarBarLabelProp->SetColor( ( aTColor.count() > 0 ? aTColor[0].toInt()/255. : 1.0 ), - ( aTColor.count() > 1 ? aTColor[1].toInt()/255. : 1.0 ), + ( aTColor.count() > 1 ? aTColor[1].toInt()/255. : 1.0 ), ( aTColor.count() > 2 ? aTColor[2].toInt()/255. : 1.0 ) ); } - else + else*/ aScalarBarLabelProp->SetColor( 1.0, 1.0, 1.0 ); aScalarBarLabelProp->SetFontFamilyToArial(); - if( QAD_CONFIG->hasSetting( "SMESH:ScalarBarLabelFont" ) ){ + /*if( QAD_CONFIG->hasSetting( "SMESH:ScalarBarLabelFont" ) ){ if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelFont" ) == "Arial" ) aScalarBarLabelProp->SetFontFamilyToArial(); else if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelFont" ) == "Courier" ) aScalarBarLabelProp->SetFontFamilyToCourier(); else if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelFont" ) == "Times" ) aScalarBarLabelProp->SetFontFamilyToTimes(); - } + }*/ - if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelBold" ) == "true" ) + /*if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelBold" ) == "true" ) aScalarBarLabelProp->BoldOn(); - else + else*/ aScalarBarLabelProp->BoldOff(); - if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelItalic" ) == "true" ) + /*if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelItalic" ) == "true" ) aScalarBarLabelProp->ItalicOn(); - else + else*/ aScalarBarLabelProp->ItalicOff(); - if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelShadow" ) == "true" ) + /*if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelShadow" ) == "true" ) aScalarBarLabelProp->ShadowOn(); - else + else*/ aScalarBarLabelProp->ShadowOff(); myScalarBarActor->SetLabelTextProperty( aScalarBarLabelProp ); aScalarBarLabelProp->Delete(); - if ( QAD_CONFIG->getSetting("SMESH:ScalarBarOrientation") == "Horizontal" ) + /*if ( QAD_CONFIG->getSetting("SMESH:ScalarBarOrientation") == "Horizontal" ) myScalarBarActor->SetOrientationToHorizontal(); - else + else*/ myScalarBarActor->SetOrientationToVertical(); - float aXVal = QAD_CONFIG->getSetting("SMESH:ScalarBarOrientation") == "Horizontal" ? 0.20 : 0.01; - if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarXPosition" ) ) - aXVal = QAD_CONFIG->getSetting( "SMESH:ScalarBarXPosition" ).toFloat(); - float aYVal = QAD_CONFIG->getSetting("SMESH:ScalarBarOrientation") == "Horizontal" ? 0.01 : 0.1; - if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarYPosition" ) ) - aYVal = QAD_CONFIG->getSetting( "SMESH:ScalarBarYPosition" ).toFloat(); + float aXVal = 0.01; //QAD_CONFIG->getSetting("SMESH:ScalarBarOrientation") == "Horizontal" ? 0.20 : 0.01; + //if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarXPosition" ) ) + // aXVal = QAD_CONFIG->getSetting( "SMESH:ScalarBarXPosition" ).toFloat(); + float aYVal = 0.1; //QAD_CONFIG->getSetting("SMESH:ScalarBarOrientation") == "Horizontal" ? 0.01 : 0.1; + //if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarYPosition" ) ) + // aYVal = QAD_CONFIG->getSetting( "SMESH:ScalarBarYPosition" ).toFloat(); myScalarBarActor->SetPosition( aXVal, aYVal ); - float aWVal = QAD_CONFIG->getSetting("SMESH:ScalarBarOrientation") == "Horizontal" ? 0.60 : 0.10; - if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarWidth" ) ) - aWVal = QAD_CONFIG->getSetting( "SMESH:ScalarBarWidth" ).toFloat(); + float aWVal = 0.1; //QAD_CONFIG->getSetting("SMESH:ScalarBarOrientation") == "Horizontal" ? 0.60 : 0.10; + //if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarWidth" ) ) + // aWVal = QAD_CONFIG->getSetting( "SMESH:ScalarBarWidth" ).toFloat(); myScalarBarActor->SetWidth( aWVal ); - float aHVal = QAD_CONFIG->getSetting("SMESH:ScalarBarOrientation") == "Horizontal" ? 0.12 : 0.80; - if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarHeight" ) ) - aHVal = QAD_CONFIG->getSetting( "SMESH:ScalarBarHeight" ).toFloat(); + float aHVal = 0.8; //QAD_CONFIG->getSetting("SMESH:ScalarBarOrientation") == "Horizontal" ? 0.12 : 0.80; + //if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarHeight" ) ) + // aHVal = QAD_CONFIG->getSetting( "SMESH:ScalarBarHeight" ).toFloat(); myScalarBarActor->SetHeight( aHVal ); int anIntVal = 5; - if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarNbOfLabels" ) ) - anIntVal = QAD_CONFIG->getSetting("SMESH:ScalarBarNbOfLabels").toInt(); + //if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarNbOfLabels" ) ) + // anIntVal = QAD_CONFIG->getSetting("SMESH:ScalarBarNbOfLabels").toInt(); myScalarBarActor->SetNumberOfLabels(anIntVal == 0? 5: anIntVal); anIntVal = 64; - if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarNbOfColors" ) ) - anIntVal = QAD_CONFIG->getSetting("SMESH:ScalarBarNbOfColors").toInt(); + //if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarNbOfColors" ) ) + // anIntVal = QAD_CONFIG->getSetting("SMESH:ScalarBarNbOfColors").toInt(); myScalarBarActor->SetMaximumNumberOfColors(anIntVal == 0? 64: anIntVal); @@ -405,7 +405,7 @@ SMESH_ActorDef::SMESH_ActorDef() myPtsMaskPoints = vtkMaskPoints::New(); myPtsMaskPoints->SetInput(myPointsNumDataSet); myPtsMaskPoints->SetOnRatio(1); - + myPtsSelectVisiblePoints = vtkSelectVisiblePoints::New(); myPtsSelectVisiblePoints->SetInput(myPtsMaskPoints->GetOutput()); myPtsSelectVisiblePoints->SelectInvisibleOff(); @@ -623,7 +623,7 @@ SetControlMode(eControl theMode, bool theCheckEntityMode) { myControlMode = eNone; - theCheckEntityMode &= QAD_CONFIG->getSetting("SMESH:DispayEntity") == "true"; + //theCheckEntityMode &= QAD_CONFIG->getSetting("SMESH:DispayEntity") == "true"; my1DActor->GetMapper()->SetScalarVisibility(false); my2DActor->GetMapper()->SetScalarVisibility(false); @@ -851,8 +851,9 @@ bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj, //SetIsShrunkable(theGrid->GetNumberOfCells() > 10); SetIsShrunkable(true); - QString aMode = QAD_CONFIG->getSetting("SMESH:DisplayMode"); + //QString aMode = QAD_CONFIG->getSetting("SMESH:DisplayMode"); SetRepresentation(-1); + /* if(aMode.compare("Wireframe") == 0){ SetRepresentation(eEdge); }else if(aMode.compare("Shading") == 0){ @@ -860,11 +861,11 @@ bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj, }else if(aMode.compare("Nodes") == 0){ SetRepresentation(ePoint); } - - aMode = QAD_CONFIG->getSetting("SMESH:Shrink"); + */ + /*aMode = QAD_CONFIG->getSetting("SMESH:Shrink"); if(aMode == "yes"){ SetShrink(); - } + }*/ myTimeStamp->Modified(); Modified(); @@ -882,7 +883,7 @@ vtkDataSet* SMESH_ActorDef::GetInput(){ } -void SMESH_ActorDef::SetTransform(SALOME_Transform* theTransform){ +void SMESH_ActorDef::SetTransform(VTKViewer_Transform* theTransform){ myNodeActor->SetTransform(theTransform); myBaseActor->SetTransform(theTransform); @@ -1101,10 +1102,10 @@ void SMESH_ActorDef::SetEntityMode(unsigned int theMode){ myBaseActor->myGeomFilter->SetInside(myEntityMode != myEntityState); myEntityMode = theMode; - SALOME_ExtractUnstructuredGrid* aFilter = NULL; + VTKViewer_ExtractUnstructuredGrid* aFilter = NULL; aFilter = myBaseActor->GetExtractUnstructuredGrid(); aFilter->ClearRegisteredCellsWithType(); - aFilter->SetModeOfChanging(SALOME_ExtractUnstructuredGrid::eAdding); + aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding); if(myEntityMode & eEdges){ if (MYDEBUG) MESSAGE("EDGES"); @@ -1255,13 +1256,13 @@ void SMESH_ActorDef::UpdateHighlight(){ myHighlitableActor->SetHighlited(anIsVisible); myHighlitableActor->SetVisibility(anIsVisible); myHighlitableActor->GetExtractUnstructuredGrid()-> - SetModeOfExtraction(SALOME_ExtractUnstructuredGrid::eCells); + SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::eCells); myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe); }else if(myRepresentation == ePoint || GetPointRepresentation()){ myHighlitableActor->SetHighlited(anIsVisible); myHighlitableActor->SetVisibility(anIsVisible); myHighlitableActor->GetExtractUnstructuredGrid()-> - SetModeOfExtraction(SALOME_ExtractUnstructuredGrid::ePoints); + SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints); myHighlitableActor->SetRepresentation(SMESH_DeviceActor::ePoint); } } diff --git a/src/OBJECT/SMESH_Actor.h b/src/OBJECT/SMESH_Actor.h index dcb8d11e8..cc4345e36 100644 --- a/src/OBJECT/SMESH_Actor.h +++ b/src/OBJECT/SMESH_Actor.h @@ -29,7 +29,7 @@ #ifndef SMESH_ACTOR_H #define SMESH_ACTOR_H -#include "SALOME_Actor.h" +#include #include "SMESH_Object.h" class vtkUnstructuredGrid; diff --git a/src/OBJECT/SMESH_ActorDef.h b/src/OBJECT/SMESH_ActorDef.h index e6925d30e..1928f6518 100644 --- a/src/OBJECT/SMESH_ActorDef.h +++ b/src/OBJECT/SMESH_ActorDef.h @@ -50,7 +50,7 @@ public: return *this; } TVTKSmartPtr& operator=(T* r){ vtkSmartPointer::operator=(r); return *this;} - T* Get() const { return GetPointer();} + T* Get() const { return this->GetPointer();} }; @@ -147,7 +147,7 @@ class SMESH_ActorDef : public SMESH_Actor{ virtual bool GetPointRepresentation(); virtual float* GetBounds(); - virtual void SetTransform(SALOME_Transform* theTransform); + virtual void SetTransform(VTKViewer_Transform* theTransform); virtual vtkUnstructuredGrid* GetUnstructuredGrid(); virtual vtkDataSet* GetInput(); diff --git a/src/OBJECT/SMESH_ActorUtils.cxx b/src/OBJECT/SMESH_ActorUtils.cxx index fdaa86c25..7e71257b2 100644 --- a/src/OBJECT/SMESH_ActorUtils.cxx +++ b/src/OBJECT/SMESH_ActorUtils.cxx @@ -20,7 +20,7 @@ #include "SMESH_ActorUtils.h" -#include "QAD_Config.h" +//#include "QAD_Config.h" #include "utilities.h" #include @@ -36,9 +36,10 @@ namespace SMESH{ float GetFloat(const QString& theValue, float theDefault){ if(theValue.isEmpty()) return theDefault; - QString aValue = QAD_CONFIG->getSetting(theValue); - if(aValue.isEmpty()) return theDefault; - return aValue.toFloat(); + //QString aValue = QAD_CONFIG->getSetting(theValue); + //if(aValue.isEmpty()) + return theDefault; + //return aValue.toFloat(); } void WriteUnstructuredGrid(vtkUnstructuredGrid* theGrid, const char* theFileName){ diff --git a/src/OBJECT/SMESH_DeviceActor.cxx b/src/OBJECT/SMESH_DeviceActor.cxx index 962ad1ed8..3548aaefe 100644 --- a/src/OBJECT/SMESH_DeviceActor.cxx +++ b/src/OBJECT/SMESH_DeviceActor.cxx @@ -32,10 +32,10 @@ #include "SMESH_ControlsDef.hxx" #include "SMESH_ActorUtils.h" -#include "SALOME_Transform.h" -#include "SALOME_TransformFilter.h" -#include "SALOME_PassThroughFilter.h" -#include "SALOME_ExtractUnstructuredGrid.h" +#include +#include +#include +#include // VTK Includes #include @@ -100,16 +100,16 @@ SMESH_DeviceActor::SMESH_DeviceActor() myExtractGeometry->SetReleaseDataFlag(true); myIsImplicitFunctionUsed = false; - myExtractUnstructuredGrid = SALOME_ExtractUnstructuredGrid::New(); + myExtractUnstructuredGrid = VTKViewer_ExtractUnstructuredGrid::New(); myMergeFilter = vtkMergeFilter::New(); - myGeomFilter = SALOME_GeometryFilter::New(); + myGeomFilter = VTKViewer_GeometryFilter::New(); - myTransformFilter = SALOME_TransformFilter::New(); + myTransformFilter = VTKViewer_TransformFilter::New(); for(int i = 0; i < 6; i++) - myPassFilter.push_back(SALOME_PassThroughFilter::New()); + myPassFilter.push_back(VTKViewer_PassThroughFilter::New()); } @@ -231,7 +231,7 @@ void SMESH_DeviceActor::SetUnstructuredGrid(vtkUnstructuredGrid* theGrid){ } -SALOME_ExtractUnstructuredGrid* SMESH_DeviceActor::GetExtractUnstructuredGrid(){ +VTKViewer_ExtractUnstructuredGrid* SMESH_DeviceActor::GetExtractUnstructuredGrid(){ return myExtractUnstructuredGrid; } @@ -300,7 +300,7 @@ void SMESH_DeviceActor::SetExtControlMode(SMESH::Controls::FunctorPtr theFunctor bool anIsInitialized = theFunctor; myExtractUnstructuredGrid->ClearRegisteredCells(); myExtractUnstructuredGrid->ClearRegisteredCellsWithType(); - myExtractUnstructuredGrid->SetModeOfChanging(SALOME_ExtractUnstructuredGrid::ePassAll); + myExtractUnstructuredGrid->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::ePassAll); myVisualObj->UpdateFunctor(theFunctor); using namespace SMESH::Controls; @@ -436,12 +436,12 @@ void SMESH_DeviceActor::SetExtControlMode(SMESH::Controls::FunctorPtr theFunctor { myExtractUnstructuredGrid->ClearRegisteredCells(); myExtractUnstructuredGrid->ClearRegisteredCellsWithType(); - myExtractUnstructuredGrid->SetModeOfChanging(SALOME_ExtractUnstructuredGrid::ePassAll); + myExtractUnstructuredGrid->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::ePassAll); myVisualObj->UpdateFunctor(theFunctor); using namespace SMESH::Controls; if(FreeBorders* aFreeBorders = dynamic_cast(theFunctor.get())){ - myExtractUnstructuredGrid->SetModeOfChanging(SALOME_ExtractUnstructuredGrid::eAdding); + myExtractUnstructuredGrid->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding); vtkUnstructuredGrid* aGrid = myVisualObj->GetUnstructuredGrid(); vtkIdType aNbCells = aGrid->GetNumberOfCells(); for( vtkIdType i = 0; i < aNbCells; i++ ){ @@ -516,7 +516,7 @@ unsigned long int SMESH_DeviceActor::GetMTime(){ } -void SMESH_DeviceActor::SetTransform(SALOME_Transform* theTransform){ +void SMESH_DeviceActor::SetTransform(VTKViewer_Transform* theTransform){ myTransformFilter->SetTransform(theTransform); } diff --git a/src/OBJECT/SMESH_DeviceActor.h b/src/OBJECT/SMESH_DeviceActor.h index 96dd92ce6..88da39f94 100644 --- a/src/OBJECT/SMESH_DeviceActor.h +++ b/src/OBJECT/SMESH_DeviceActor.h @@ -29,7 +29,7 @@ #ifndef SMESH_DEVICE_ACTOR_H #define SMESH_DEVICE_ACTOR_H -#include "SALOME_GeometryFilter.h" +#include #include "SMESH_Controls.hxx" #include "SMESH_Object.h" @@ -46,10 +46,10 @@ class vtkScalarBarActor; class vtkLookupTable; class vtkImplicitBoolean; -class SALOME_Transform; -class SALOME_TransformFilter; -class SALOME_PassThroughFilter; -class SALOME_ExtractUnstructuredGrid; +class VTKViewer_Transform; +class VTKViewer_TransformFilter; +class VTKViewer_PassThroughFilter; +class VTKViewer_ExtractUnstructuredGrid; class SMESH_ExtractGeometry; @@ -71,7 +71,7 @@ class SMESH_DeviceActor: public vtkLODActor{ virtual int GetElemObjId(int theVtkID); virtual vtkCell* GetElemCell(int theObjID); - virtual void SetTransform(SALOME_Transform* theTransform); + virtual void SetTransform(VTKViewer_Transform* theTransform); virtual unsigned long int GetMTime(); float GetShrinkFactor(); @@ -89,7 +89,7 @@ class SMESH_DeviceActor: public vtkLODActor{ virtual void SetVisibility(int theMode); virtual int GetVisibility(); - SALOME_ExtractUnstructuredGrid* GetExtractUnstructuredGrid(); + VTKViewer_ExtractUnstructuredGrid* GetExtractUnstructuredGrid(); vtkUnstructuredGrid* GetUnstructuredGrid(); void SetControlMode(SMESH::Controls::FunctorPtr theFunctor, @@ -122,12 +122,12 @@ class SMESH_DeviceActor: public vtkLODActor{ bool myIsImplicitFunctionUsed; vtkMergeFilter* myMergeFilter; - SALOME_ExtractUnstructuredGrid* myExtractUnstructuredGrid; + VTKViewer_ExtractUnstructuredGrid* myExtractUnstructuredGrid; bool myStoreClippingMapping; - SALOME_GeometryFilter *myGeomFilter; - SALOME_TransformFilter *myTransformFilter; - std::vector myPassFilter; + VTKViewer_GeometryFilter *myGeomFilter; + VTKViewer_TransformFilter *myTransformFilter; + std::vector myPassFilter; vtkShrinkFilter* myShrinkFilter; bool myIsShrinkable; diff --git a/src/OBJECT/SMESH_Object.cxx b/src/OBJECT/SMESH_Object.cxx index 24023bacf..885ee3de3 100644 --- a/src/OBJECT/SMESH_Object.cxx +++ b/src/OBJECT/SMESH_Object.cxx @@ -31,7 +31,7 @@ #include "SMDS_Mesh.hxx" #include "SMESH_Actor.h" #include "SMESH_ControlsDef.hxx" -#include "SALOME_ExtractUnstructuredGrid.h" +#include #include CORBA_SERVER_HEADER(SALOME_Exception) @@ -160,6 +160,30 @@ namespace{ } + inline void AddPolygonsWithID(SMDS_Mesh* theMesh, + SMESH::log_array_var& theSeq, + CORBA::Long theId) + { + const SMESH::long_array& anIndexes = theSeq[theId].indexes; + CORBA::Long anIndexId = 0, aNbElems = theSeq[theId].number; + + for (CORBA::Long anElemId = 0; anElemId < aNbElems; anElemId++) { + int aFaceId = anIndexes[anIndexId++]; + + int aNbNodes = anIndexes[anIndexId++]; + std::vector nodes_ids (aNbNodes); + for (int i = 0; i < aNbNodes; i++) { + nodes_ids[i] = anIndexes[anIndexId++]; + } + + SMDS_MeshElement* anElem = theMesh->AddPolygonalFaceWithID(nodes_ids, aFaceId); + if (!anElem) + EXCEPTION(runtime_error, "SMDS_Mesh::FindElement - cannot AddPolygonalFaceWithID for ID = " + << anElemId); + } + } + + inline void AddTetrasWithID(SMDS_Mesh* theMesh, SMESH::log_array_var& theSeq, CORBA::Long theId) @@ -175,7 +199,7 @@ namespace{ anIndexes[anIndexId+4], anIndexes[anIndexId]); if(!anElem) - EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddFaceWithID for ID = "<DebugOn(); - } + if ( MYDEBUG ) + MESSAGE( "~SMESH_MeshObj - myGrid->GetReferenceCount() = " << myGrid->GetReferenceCount() ); myGrid->Delete(); } @@ -545,35 +631,37 @@ void SMESH_VisualObjDef::buildElemPrs() SMDS_ElemIteratorPtr aNodesIter = anElem->nodesIterator(); switch(aType){ case SMDSAbs_Volume:{ - int* aConnectivities = NULL; + std::vector aConnectivities; GetConnect(aNodesIter,aConnect); // Convertions connectivities from SMDS to VTK - switch(aNbNodes){ - case 4:{ - static int anIds[] = {0,2,1,3}; - aConnectivities = anIds; - break; - } - case 5:{ - static int anIds[] = {0,3,2,1,4}; - aConnectivities = anIds; - break; - } - case 6:{ - static int anIds[] = {0,1,2,3,4,5}; - aConnectivities = anIds; - break; - } - case 8:{ - static int anIds[] = {0,3,2,1,4,7,6,5}; - aConnectivities = anIds; - break; - }} + if (anElem->IsPoly() && aNbNodes > 3) { // POLYEDRE + for (int k = 0; k < aNbNodes; k++) { + aConnectivities.push_back(k); + } - if(aConnectivities) - for( vtkIdType aNodeId = 0; aNodeId < aNbNodes; aNodeId++ ) + } else if (aNbNodes == 4) { + static int anIds[] = {0,2,1,3}; + for (int k = 0; k < aNbNodes; k++) aConnectivities.push_back(anIds[k]); + + } else if (aNbNodes == 5) { + static int anIds[] = {0,3,2,1,4}; + for (int k = 0; k < aNbNodes; k++) aConnectivities.push_back(anIds[k]); + + } else if (aNbNodes == 6) { + static int anIds[] = {0,1,2,3,4,5}; + for (int k = 0; k < aNbNodes; k++) aConnectivities.push_back(anIds[k]); + + } else if (aNbNodes == 8) { + static int anIds[] = {0,3,2,1,4,7,6,5}; + for (int k = 0; k < aNbNodes; k++) aConnectivities.push_back(anIds[k]); + + } else { + } + + if (aConnectivities.size() > 0) { + for (vtkIdType aNodeId = 0; aNodeId < aNbNodes; aNodeId++) SetId(anIdList,mySMDS2VTKNodes,aConnect,aNodeId,aConnectivities[aNodeId]); - + } break; } default: @@ -584,7 +672,7 @@ void SMESH_VisualObjDef::buildElemPrs() } aConnectivity->InsertNextCell( anIdList ); - aCellTypesArray->InsertNextValue( getCellType( aType, aNbNodes ) ); + aCellTypesArray->InsertNextValue( getCellType( aType, anElem->IsPoly(), aNbNodes ) ); iElem++; } @@ -628,7 +716,7 @@ bool SMESH_VisualObjDef::GetEdgeNodes( const int theElemId, int nbNodes = anElem->NbNodes(); - if ( theEdgeNum < 1 || theEdgeNum > 4 || nbNodes != 3 && nbNodes != 4 || theEdgeNum > nbNodes ) + if ( theEdgeNum < 0 || theEdgeNum > 3 || nbNodes != 3 && nbNodes != 4 || theEdgeNum > nbNodes ) return false; int anIds[ nbNodes ]; @@ -637,10 +725,10 @@ bool SMESH_VisualObjDef::GetEdgeNodes( const int theElemId, while( anIter->more() ) anIds[ i++ ] = anIter->next()->GetID(); - if ( nbNodes != theEdgeNum ) + if ( theEdgeNum < nbNodes - 1 ) { - theNodeId1 = anIds[ theEdgeNum - 1 ]; - theNodeId2 = anIds[ theEdgeNum ]; + theNodeId1 = anIds[ theEdgeNum ]; + theNodeId2 = anIds[ theEdgeNum + 1 ]; } else { @@ -697,25 +785,27 @@ void SMESH_MeshObj::Update( int theIsClear ) if( !aLength ) return; - + for ( CORBA::Long anId = 0; anId < aLength; anId++) { const SMESH::double_array& aCoords = aSeq[anId].coords; const SMESH::long_array& anIndexes = aSeq[anId].indexes; CORBA::Long anElemId = 0, aNbElems = aSeq[anId].number; CORBA::Long aCommand = aSeq[anId].commandType; - + switch(aCommand) { - case SMESH::ADD_NODE : AddNodesWithID ( myMesh, aSeq, anId ); break; - case SMESH::ADD_EDGE : AddEdgesWithID ( myMesh, aSeq, anId ); break; - case SMESH::ADD_TRIANGLE : AddTriasWithID ( myMesh, aSeq, anId ); break; - case SMESH::ADD_QUADRANGLE : AddQuadsWithID ( myMesh, aSeq, anId ); break; - case SMESH::ADD_TETRAHEDRON: AddTetrasWithID ( myMesh, aSeq, anId ); break; - case SMESH::ADD_PYRAMID : AddPiramidsWithID( myMesh, aSeq, anId ); break; - case SMESH::ADD_PRISM : AddPrismsWithID ( myMesh, aSeq, anId ); break; - case SMESH::ADD_HEXAHEDRON : AddHexasWithID ( myMesh, aSeq, anId ); break; - + case SMESH::ADD_NODE : AddNodesWithID ( myMesh, aSeq, anId ); break; + case SMESH::ADD_EDGE : AddEdgesWithID ( myMesh, aSeq, anId ); break; + case SMESH::ADD_TRIANGLE : AddTriasWithID ( myMesh, aSeq, anId ); break; + case SMESH::ADD_QUADRANGLE : AddQuadsWithID ( myMesh, aSeq, anId ); break; + case SMESH::ADD_POLYGON : AddPolygonsWithID ( myMesh, aSeq, anId ); break; + case SMESH::ADD_TETRAHEDRON: AddTetrasWithID ( myMesh, aSeq, anId ); break; + case SMESH::ADD_PYRAMID : AddPiramidsWithID ( myMesh, aSeq, anId ); break; + case SMESH::ADD_PRISM : AddPrismsWithID ( myMesh, aSeq, anId ); break; + case SMESH::ADD_HEXAHEDRON : AddHexasWithID ( myMesh, aSeq, anId ); break; + case SMESH::ADD_POLYHEDRON : AddPolyhedronsWithID( myMesh, aSeq, anId ); break; + case SMESH::REMOVE_NODE: for( ; anElemId < aNbElems; anElemId++ ) myMesh->RemoveNode( FindNode( myMesh, anIndexes[anElemId] ) ); @@ -743,8 +833,8 @@ void SMESH_MeshObj::Update( int theIsClear ) // nb nodes int nbNodes = anIndexes[i++]; // nodes - ASSERT( nbNodes < 9 ); - const SMDS_MeshNode* aNodes[ 8 ]; + //ASSERT( nbNodes < 9 ); + const SMDS_MeshNode* aNodes[ nbNodes ]; for ( int iNode = 0; iNode < nbNodes; iNode++ ) aNodes[ iNode ] = FindNode( myMesh, anIndexes[i++] ); // change @@ -752,6 +842,9 @@ void SMESH_MeshObj::Update( int theIsClear ) } break; + case SMESH::CHANGE_POLYHEDRON_NODES: + ChangePolyhedronNodes(myMesh, aSeq, anId); + break; case SMESH::RENUMBER: for(CORBA::Long i=0; anElemId < aNbElems; anElemId++, i+=3) { diff --git a/src/OBJECT/SMESH_ObjectDef.h b/src/OBJECT/SMESH_ObjectDef.h index 14df168d7..134b47b10 100644 --- a/src/OBJECT/SMESH_ObjectDef.h +++ b/src/OBJECT/SMESH_ObjectDef.h @@ -30,7 +30,7 @@ #define SMESH_OBJECTDEF_H // IDL Headers -#include "SALOMEconfig.h" +#include #include CORBA_SERVER_HEADER(SMESH_Mesh) #include CORBA_SERVER_HEADER(SMESH_Group) diff --git a/src/SMDS/Makefile.in b/src/SMDS/Makefile.in index d64abd6fe..e066e25e0 100644 --- a/src/SMDS/Makefile.in +++ b/src/SMDS/Makefile.in @@ -55,8 +55,10 @@ LIB_SRC = \ SMDS_IteratorOfElements.cxx \ SMDS_VolumeOfFaces.cxx \ SMDS_VolumeOfNodes.cxx \ + SMDS_PolyhedralVolumeOfNodes.cxx \ SMDS_FaceOfEdges.cxx \ SMDS_FaceOfNodes.cxx \ + SMDS_PolygonalFaceOfNodes.cxx \ SMDS_VolumeTool.cxx # SMDS_Tria3OfNodes.cxx \ # SMDS_HexahedronOfNodes.cxx @@ -107,8 +109,10 @@ EXPORT_HEADERS= \ SMDS_IteratorOfElements.hxx \ SMDS_VolumeOfFaces.hxx \ SMDS_VolumeOfNodes.hxx \ + SMDS_PolyhedralVolumeOfNodes.hxx \ SMDS_FaceOfEdges.hxx \ SMDS_FaceOfNodes.hxx \ + SMDS_PolygonalFaceOfNodes.hxx \ SMDS_VolumeTool.hxx # SMDS_Tria3OfNodes.hxx \ # SMDS_HexahedronOfNodes.hxx diff --git a/src/SMDS/SMDS_Mesh.cxx b/src/SMDS/SMDS_Mesh.cxx index 763d61c47..0058da878 100644 --- a/src/SMDS/SMDS_Mesh.cxx +++ b/src/SMDS/SMDS_Mesh.cxx @@ -29,6 +29,8 @@ #include "SMDS_VolumeOfFaces.hxx" #include "SMDS_FaceOfNodes.hxx" #include "SMDS_FaceOfEdges.hxx" +#include "SMDS_PolyhedralVolumeOfNodes.hxx" +#include "SMDS_PolygonalFaceOfNodes.hxx" #include #include @@ -786,6 +788,126 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshFace * f1, return volume; } +/////////////////////////////////////////////////////////////////////////////// +/// Add a polygon defined by its nodes IDs +/////////////////////////////////////////////////////////////////////////////// + +SMDS_MeshFace* SMDS_Mesh::AddPolygonalFaceWithID (std::vector nodes_ids, + const int ID) +{ + int nbNodes = nodes_ids.size(); + std::vector nodes (nbNodes); + for (int i = 0; i < nbNodes; i++) { + nodes[i] = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(nodes_ids[i]); + if (!nodes[i]) return NULL; + } + return SMDS_Mesh::AddPolygonalFaceWithID(nodes, ID); +} + +/////////////////////////////////////////////////////////////////////////////// +/// Add a polygon defined by its nodes +/////////////////////////////////////////////////////////////////////////////// + +SMDS_MeshFace* SMDS_Mesh::AddPolygonalFaceWithID + (std::vector nodes, + const int ID) +{ + SMDS_MeshFace * face; + + if (hasConstructionEdges()) + { + MESSAGE("Error : Not implemented"); + return NULL; + } + else + { + face = new SMDS_PolygonalFaceOfNodes(nodes); + myFaces.Add(face); + } + + if (!registerElement(ID, face)) { + RemoveElement(face, false); + face = NULL; + } + return face; +} + +/////////////////////////////////////////////////////////////////////////////// +/// Add a polygon defined by its nodes. +/// An ID is automatically affected to the created face. +/////////////////////////////////////////////////////////////////////////////// + +SMDS_MeshFace* SMDS_Mesh::AddPolygonalFace (std::vector nodes) +{ + return SMDS_Mesh::AddPolygonalFaceWithID(nodes, myElementIDFactory->GetFreeID()); +} + +/////////////////////////////////////////////////////////////////////////////// +/// Create a new polyhedral volume and add it to the mesh. +/// @param ID The ID of the new volume +/// @return The created volume or NULL if an element with this ID already exists +/// or if input nodes are not found. +/////////////////////////////////////////////////////////////////////////////// + +SMDS_MeshVolume * SMDS_Mesh::AddPolyhedralVolumeWithID + (std::vector nodes_ids, + std::vector quantities, + const int ID) +{ + int nbNodes = nodes_ids.size(); + std::vector nodes (nbNodes); + for (int i = 0; i < nbNodes; i++) { + nodes[i] = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(nodes_ids[i]); + if (!nodes[i]) return NULL; + } + return SMDS_Mesh::AddPolyhedralVolumeWithID(nodes, quantities, ID); +} + +/////////////////////////////////////////////////////////////////////////////// +/// Create a new polyhedral volume and add it to the mesh. +/// @param ID The ID of the new volume +/// @return The created volume +/////////////////////////////////////////////////////////////////////////////// + +SMDS_MeshVolume* SMDS_Mesh::AddPolyhedralVolumeWithID + (std::vector nodes, + std::vector quantities, + const int ID) +{ + SMDS_MeshVolume* volume; + if (hasConstructionFaces()) { + MESSAGE("Error : Not implemented"); + return NULL; + } else if (hasConstructionEdges()) { + MESSAGE("Error : Not implemented"); + return NULL; + } else { + volume = new SMDS_PolyhedralVolumeOfNodes(nodes, quantities); + myVolumes.Add(volume); + } + + if (!registerElement(ID, volume)) { + RemoveElement(volume, false); + volume = NULL; + } + return volume; +} + +/////////////////////////////////////////////////////////////////////////////// +/// Create a new polyhedral volume and add it to the mesh. +/// @return The created volume +/////////////////////////////////////////////////////////////////////////////// + +SMDS_MeshVolume* SMDS_Mesh::AddPolyhedralVolume + (std::vector nodes, + std::vector quantities) +{ + int ID = myElementIDFactory->GetFreeID(); + SMDS_MeshVolume * v = SMDS_Mesh::AddPolyhedralVolumeWithID(nodes, quantities, ID); + if (v == NULL) myElementIDFactory->ReleaseID(ID); + return v; +} + /////////////////////////////////////////////////////////////////////////////// /// Registers element with the given ID, maintains inverse connections /////////////////////////////////////////////////////////////////////////////// @@ -966,10 +1088,25 @@ bool SMDS_Mesh::ChangeElementNodes(const SMDS_MeshElement * elem, } case SMDSAbs_Face: { const SMDS_FaceOfNodes* face = dynamic_cast( elem ); - if ( face ) + if ( face ) { Ok = const_cast( face )->ChangeNodes( nodes, nbnodes ); + } else { + /// ??? begin + const SMDS_PolygonalFaceOfNodes* face = dynamic_cast(elem); + if (face) { + Ok = const_cast(face)->ChangeNodes(nodes, nbnodes); + } + /// ??? end + } break; } + //case SMDSAbs_PolygonalFace: { + // const SMDS_PolygonalFaceOfNodes* face = dynamic_cast(elem); + // if (face) { + // Ok = const_cast(face)->ChangeNodes(nodes, nbnodes); + // } + // break; + //} case SMDSAbs_Volume: { const SMDS_VolumeOfNodes* vol = dynamic_cast( elem ); if ( vol ) @@ -1007,6 +1144,62 @@ bool SMDS_Mesh::ChangeElementNodes(const SMDS_MeshElement * elem, return Ok; } +//======================================================================= +//function : ChangePolyhedronNodes +//purpose : to change nodes of polyhedral volume +//======================================================================= +bool SMDS_Mesh::ChangePolyhedronNodes (const SMDS_MeshElement * elem, + std::vector nodes, + std::vector quantities) +{ + if (elem->GetType() != SMDSAbs_Volume) { + MESSAGE("WRONG ELEM TYPE"); + return false; + } + + const SMDS_PolyhedralVolumeOfNodes* vol = dynamic_cast(elem); + if (!vol) { + return false; + } + + // keep current nodes of elem + set oldNodes; + SMDS_ElemIteratorPtr itn = elem->nodesIterator(); + while (itn->more()) { + oldNodes.insert(itn->next()); + } + + // change nodes + bool Ok = const_cast(vol)->ChangeNodes(nodes, quantities); + if (!Ok) { + return false; + } + + // update InverseElements + + // AddInverseElement to new nodes + int nbnodes = nodes.size(); + for (int i = 0; i < nbnodes; i++) { + if (oldNodes.find(nodes[i]) == oldNodes.end()) { + // new node + const_cast(nodes[i])->AddInverseElement(elem); + } else { + // remove from oldNodes a node that remains in elem + oldNodes.erase(nodes[i]); + } + } + + // RemoveInverseElement from the nodes removed from elem + set::iterator it; + for (it = oldNodes.begin(); it != oldNodes.end(); it++) { + SMDS_MeshNode * n = static_cast + (const_cast( *it )); + n->RemoveInverseElement(elem); + } + + return Ok; +} + //======================================================================= //function : FindEdge //purpose : @@ -1192,6 +1385,55 @@ const SMDS_MeshElement* SMDS_Mesh::FindElement(int IDelem) const return myElementIDFactory->MeshElement(IDelem); } +//======================================================================= +//function : FindFace +//purpose : find polygon +//======================================================================= + +const SMDS_MeshFace* SMDS_Mesh::FindFace (std::vector nodes_ids) const +{ + int nbnodes = nodes_ids.size(); + std::vector poly_nodes (nbnodes); + for (int inode = 0; inode < nbnodes; inode++) { + const SMDS_MeshNode * node = FindNode(nodes_ids[inode]); + if (node == NULL) return NULL; + } + return FindFace(poly_nodes); +} + +const SMDS_MeshFace* SMDS_Mesh::FindFace (std::vector nodes) +{ + int nbNodes = nodes.size(); + if (nbNodes < 1) return NULL; + + bool isFound = true; + const SMDS_MeshFace * face; + set faces; + + for (int inode = 0; inode < nbNodes && isFound; inode++) { + set new_faces; + + SMDS_ElemIteratorPtr itF = nodes[inode]->facesIterator(); + while (itF->more()) { + face = static_cast(itF->next()); + if (face->NbNodes() == nbNodes) { + if (inode == 0 || faces.find(face) != faces.end()) { + new_faces.insert(face); + } + } + } + faces = new_faces; + if (new_faces.size() == 0) { + isFound = false; + } + } + + if (isFound) + return face; + + return NULL; +} + //======================================================================= //function : DumpNodes //purpose : @@ -1743,7 +1985,8 @@ void SMDS_Mesh::RemoveElement(const SMDS_MeshElement * elem, // get finite elements built on elem set * s1; if (!hasConstructionEdges() && elem->GetType() == SMDSAbs_Edge || - !hasConstructionFaces() && elem->GetType() == SMDSAbs_Face) + !hasConstructionFaces() && elem->GetType() == SMDSAbs_Face || + elem->GetType() == SMDSAbs_Volume) { s1 = new set(); s1->insert(elem); @@ -1936,4 +2179,3 @@ void SMDS_Mesh::Renumber (const bool isNodes, const int startID, const int del ID += deltaID; } } - diff --git a/src/SMDS/SMDS_Mesh.hxx b/src/SMDS/SMDS_Mesh.hxx index 1aa9dda92..9d59a3ddf 100644 --- a/src/SMDS/SMDS_Mesh.hxx +++ b/src/SMDS/SMDS_Mesh.hxx @@ -201,6 +201,28 @@ public: const SMDS_MeshFace * f5, const SMDS_MeshFace * f6); + virtual SMDS_MeshFace* AddPolygonalFaceWithID (std::vector nodes_ids, + const int ID); + + virtual SMDS_MeshFace* AddPolygonalFaceWithID (std::vector nodes, + const int ID); + + virtual SMDS_MeshFace* AddPolygonalFace (std::vector nodes); + + virtual SMDS_MeshVolume* AddPolyhedralVolumeWithID + (std::vector nodes_ids, + std::vector quantities, + const int ID); + + virtual SMDS_MeshVolume* AddPolyhedralVolumeWithID + (std::vector nodes, + std::vector quantities, + const int ID); + + virtual SMDS_MeshVolume* AddPolyhedralVolume + (std::vector nodes, + std::vector quantities); + virtual void RemoveElement(const SMDS_MeshElement * elem, std::list& removedElems, std::list& removedNodes, @@ -217,6 +239,9 @@ public: static bool ChangeElementNodes(const SMDS_MeshElement * elem, const SMDS_MeshNode * nodes[], const int nbnodes); + static bool ChangePolyhedronNodes(const SMDS_MeshElement * elem, + std::vector nodes, + std::vector quantities); virtual void Renumber (const bool isNodes, const int startID = 1, const int deltaID = 1); // Renumber all nodes or elements. @@ -235,6 +260,10 @@ public: const SMDS_MeshNode *n2, const SMDS_MeshNode *n3, const SMDS_MeshNode *n4); + + const SMDS_MeshFace *FindFace(std::vector nodes_ids) const; + static const SMDS_MeshFace* FindFace(std::vector nodes); + int MaxNodeID() const; int MinNodeID() const; int MaxElementID() const; diff --git a/src/SMDS/SMDS_MeshElement.hxx b/src/SMDS/SMDS_MeshElement.hxx index 3d9d13afe..b9f61351b 100644 --- a/src/SMDS/SMDS_MeshElement.hxx +++ b/src/SMDS/SMDS_MeshElement.hxx @@ -59,6 +59,8 @@ class SMDS_MeshElement:public SMDS_MeshObject ///Return the type of the current element virtual SMDSAbs_ElementType GetType() const = 0; + virtual bool IsPoly() const { return false; }; + friend std::ostream & operator <<(std::ostream & OS, const SMDS_MeshElement *); friend bool SMDS_MeshElementIDFactory::BindID(int ID,SMDS_MeshElement*elem); diff --git a/src/SMDS/SMDS_MeshGroup.cxx b/src/SMDS/SMDS_MeshGroup.cxx index 0acb246a8..0cb481c50 100644 --- a/src/SMDS/SMDS_MeshGroup.cxx +++ b/src/SMDS/SMDS_MeshGroup.cxx @@ -125,7 +125,7 @@ void SMDS_MeshGroup::Add(const SMDS_MeshElement * theElem) // the type of the group is determined by the first element added if (myElements.empty()) myType = theElem->GetType(); else if (theElem->GetType() != myType) - MESSAGE("SMDS_MeshGroup::Add : Type Mismatch"); + MESSAGE("SMDS_MeshGroup::Add : Type Mismatch "<GetType()<<"!="<::iterator i = myPoolOfID.begin(); + int ID = *i;//myPoolOfID.top(); + myPoolOfID.erase( i );//myPoolOfID.pop(); return ID; } } @@ -56,5 +57,27 @@ int SMDS_MeshIDFactory::GetFreeID() //======================================================================= void SMDS_MeshIDFactory::ReleaseID(const int ID) { - if (ID > 0 && ID < myMaxID) myPoolOfID.push(ID); + if ( ID > 0 ) + { + if ( ID < myMaxID ) + { + myPoolOfID.insert(ID); + } + else if ( ID == myMaxID ) + { + --myMaxID; + if ( !myPoolOfID.empty() ) // assure that myMaxID is not in myPoolOfID + { + set::iterator i = --myPoolOfID.end(); + while ( i != myPoolOfID.begin() && myMaxID == *i ) { + --myMaxID; --i; + } + if ( myMaxID == *i ) + --myMaxID; // begin of myPoolOfID reached + else + ++i; + myPoolOfID.erase( i, myPoolOfID.end() ); + } + } + } } diff --git a/src/SMDS/SMDS_MeshIDFactory.hxx b/src/SMDS/SMDS_MeshIDFactory.hxx index 62b2d4c00..8a6425ac2 100644 --- a/src/SMDS/SMDS_MeshIDFactory.hxx +++ b/src/SMDS/SMDS_MeshIDFactory.hxx @@ -28,7 +28,7 @@ #define _SMDS_MeshIDFactory_HeaderFile #include "SMDS_MeshObject.hxx" -#include +#include class SMDS_MeshIDFactory:public SMDS_MeshObject @@ -40,7 +40,7 @@ class SMDS_MeshIDFactory:public SMDS_MeshObject protected: SMDS_MeshIDFactory(); int myMaxID; - std::stack myPoolOfID; + std::set myPoolOfID; }; #endif diff --git a/src/SMDS/SMDS_PolygonalFaceOfNodes.cxx b/src/SMDS/SMDS_PolygonalFaceOfNodes.cxx new file mode 100644 index 000000000..38abf18c2 --- /dev/null +++ b/src/SMDS/SMDS_PolygonalFaceOfNodes.cxx @@ -0,0 +1,174 @@ +// SMESH SMDS : implementaion of Salome mesh data structure +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org + +#ifdef _MSC_VER +#pragma warning(disable:4786) +#endif + +#include "SMDS_PolygonalFaceOfNodes.hxx" + +#include "SMDS_IteratorOfElements.hxx" +//#include "SMDS_MeshNode.hxx" +#include "utilities.h" + +using namespace std; + +//======================================================================= +//function : Constructor +//purpose : +//======================================================================= +SMDS_PolygonalFaceOfNodes::SMDS_PolygonalFaceOfNodes + (std::vector nodes) +{ + myNodes = nodes; +} + +//======================================================================= +//function : GetType +//purpose : +//======================================================================= +SMDSAbs_ElementType SMDS_PolygonalFaceOfNodes::GetType() const +{ + return SMDSAbs_Face; + //return SMDSAbs_PolygonalFace; +} + +//======================================================================= +//function : ChangeNodes +//purpose : +//======================================================================= +bool SMDS_PolygonalFaceOfNodes::ChangeNodes (std::vector nodes) +{ + if (nodes.size() < 3) + return false; + + myNodes = nodes; + + return true; +} + +//======================================================================= +//function : ChangeNodes +//purpose : to support the same interface, as SMDS_FaceOfNodes +//======================================================================= +bool SMDS_PolygonalFaceOfNodes::ChangeNodes (const SMDS_MeshNode* nodes[], + const int nbNodes) +{ + if (nbNodes < 3) + return false; + + myNodes.resize(nbNodes); + int i = 0; + for (; i < nbNodes; i++) { + myNodes[i] = nodes[i]; + } + + return true; +} + +//======================================================================= +//function : NbNodes +//purpose : +//======================================================================= +int SMDS_PolygonalFaceOfNodes::NbNodes() const +{ + return myNodes.size(); +} + +//======================================================================= +//function : NbEdges +//purpose : +//======================================================================= +int SMDS_PolygonalFaceOfNodes::NbEdges() const +{ + return NbNodes(); +} + +//======================================================================= +//function : NbFaces +//purpose : +//======================================================================= +int SMDS_PolygonalFaceOfNodes::NbFaces() const +{ + return 1; +} + +//======================================================================= +//function : Print +//purpose : +//======================================================================= +void SMDS_PolygonalFaceOfNodes::Print(ostream & OS) const +{ + OS << "polygonal face <" << GetID() << " > : "; + int i, nbNodes = myNodes.size(); + for (i = 0; i < nbNodes - 1; i++) + OS << myNodes[i] << ","; + OS << myNodes[i] << ") " << endl; +} + +//======================================================================= +//function : elementsIterator +//purpose : +//======================================================================= +class SMDS_PolygonalFaceOfNodes_MyIterator:public SMDS_ElemIterator +{ + //const SMDS_MeshNode* const *mySet; + const std::vector mySet; + //int myLength; + int index; + public: + //SMDS_PolygonalFaceOfNodes_MyIterator(const SMDS_MeshNode* const *s, int l): + // mySet(s),myLength(l),index(0) {} + SMDS_PolygonalFaceOfNodes_MyIterator(const std::vector s): + mySet(s),index(0) {} + + bool more() + { + return index < mySet.size(); + } + + const SMDS_MeshElement* next() + { + index++; + return mySet[index-1]; + } +}; + +SMDS_ElemIteratorPtr SMDS_PolygonalFaceOfNodes::elementsIterator + (SMDSAbs_ElementType type) const +{ + switch(type) + { + case SMDSAbs_Face: + return SMDS_MeshElement::elementsIterator(SMDSAbs_Face); + case SMDSAbs_Node: + return SMDS_ElemIteratorPtr(new SMDS_PolygonalFaceOfNodes_MyIterator(myNodes)); + case SMDSAbs_Edge: + MESSAGE("Error : edge iterator for SMDS_PolygonalFaceOfNodes not implemented"); + break; + default: + return SMDS_ElemIteratorPtr + (new SMDS_IteratorOfElements + (this,type,SMDS_ElemIteratorPtr + (new SMDS_PolygonalFaceOfNodes_MyIterator(myNodes)))); + } + return SMDS_ElemIteratorPtr(); +} diff --git a/src/SMDS/SMDS_PolygonalFaceOfNodes.hxx b/src/SMDS/SMDS_PolygonalFaceOfNodes.hxx new file mode 100644 index 000000000..567746259 --- /dev/null +++ b/src/SMDS/SMDS_PolygonalFaceOfNodes.hxx @@ -0,0 +1,60 @@ +// SMESH SMDS : implementaion of Salome mesh data structure +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org + +#ifndef _SMDS_PolygonalFaceOfNodes_HeaderFile +#define _SMDS_PolygonalFaceOfNodes_HeaderFile + +#include "SMDS_MeshFace.hxx" +//#include "SMDS_FaceOfNodes.hxx" +#include "SMDS_MeshNode.hxx" +#include "SMDS_Iterator.hxx" + +#include + +//class SMDS_PolygonalFaceOfNodes:public SMDS_FaceOfNodes +class SMDS_PolygonalFaceOfNodes:public SMDS_MeshFace +{ + public: + SMDS_PolygonalFaceOfNodes (std::vector nodes); + + virtual SMDSAbs_ElementType GetType() const; + virtual bool IsPoly() const { return true; }; + + bool ChangeNodes (std::vector nodes); + + bool ChangeNodes (const SMDS_MeshNode* nodes[], + const int nbNodes); + // to support the same interface, as SMDS_FaceOfNodes + + virtual int NbNodes() const; + virtual int NbEdges() const; + virtual int NbFaces() const; + + virtual void Print (std::ostream & OS) const; + + protected: + virtual SMDS_ElemIteratorPtr elementsIterator (SMDSAbs_ElementType type) const; + + private: + std::vector myNodes; +}; + +#endif diff --git a/src/SMDS/SMDS_PolyhedralVolumeOfNodes.cxx b/src/SMDS/SMDS_PolyhedralVolumeOfNodes.cxx new file mode 100644 index 000000000..8b2613474 --- /dev/null +++ b/src/SMDS/SMDS_PolyhedralVolumeOfNodes.cxx @@ -0,0 +1,182 @@ +// SMESH SMDS : implementaion of Salome mesh data structure +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org + +#ifdef _MSC_VER +#pragma warning(disable:4786) +#endif + +#include "SMDS_PolyhedralVolumeOfNodes.hxx" +#include "SMDS_MeshNode.hxx" +#include "utilities.h" + +#include + +using namespace std; + +//======================================================================= +//function : Constructor +//purpose : Create a volume of many faces +//======================================================================= +SMDS_PolyhedralVolumeOfNodes::SMDS_PolyhedralVolumeOfNodes + (std::vector nodes, + std::vector quantities) +: SMDS_VolumeOfNodes(NULL, NULL, NULL, NULL) +{ + ChangeNodes(nodes, quantities); +} + +//======================================================================= +//function : GetType +//purpose : +//======================================================================= +SMDSAbs_ElementType SMDS_PolyhedralVolumeOfNodes::GetType() const +{ +// return SMDSAbs_PolyhedralVolume; + return SMDSAbs_Volume; +} + +//======================================================================= +//function : ChangeNodes +//purpose : +//======================================================================= +bool SMDS_PolyhedralVolumeOfNodes::ChangeNodes (std::vector nodes, + std::vector quantities) +{ + myNodesByFaces = nodes; + myQuantities = quantities; + + // Init fields of parent class + int aNbNodes = 0; + std::set aSet; + int nodes_len = nodes.size(); + for (int j = 0; j < nodes_len; j++) { + if (aSet.find(nodes[j]) == aSet.end()) { + aSet.insert(nodes[j]); + aNbNodes++; + } + } + + int k = 0; + const SMDS_MeshNode* aNodes [aNbNodes]; + std::set::iterator anIter = aSet.begin(); + for (; anIter != aSet.end(); anIter++, k++) { + aNodes[k] = *anIter; + } + + //SMDS_VolumeOfNodes::ChangeNodes(aNodes, aNbNodes); + delete [] myNodes; + //myNbNodes = nodes.size(); + myNbNodes = aNbNodes; + myNodes = new const SMDS_MeshNode* [myNbNodes]; + for (int i = 0; i < myNbNodes; i++) { + //myNodes[i] = nodes[i]; + myNodes[i] = aNodes[i]; + } + + return true; +} + +//======================================================================= +//function : NbEdges +//purpose : +//======================================================================= +int SMDS_PolyhedralVolumeOfNodes::NbEdges() const +{ + int nbEdges = 0; + + for (int ifa = 0; ifa < myQuantities.size(); ifa++) { + nbEdges += myQuantities[ifa]; + } + nbEdges /= 2; + + return nbEdges; +} + +//======================================================================= +//function : NbFaces +//purpose : +//======================================================================= +int SMDS_PolyhedralVolumeOfNodes::NbFaces() const +{ + return myQuantities.size(); +} + +//======================================================================= +//function : NbFaceNodes +//purpose : +//======================================================================= +int SMDS_PolyhedralVolumeOfNodes::NbFaceNodes (const int face_ind) const +{ + if (face_ind < 1 || myQuantities.size() < face_ind) + return 0; + return myQuantities[face_ind - 1]; +} + +//======================================================================= +//function : GetFaceNode +//purpose : +//======================================================================= +const SMDS_MeshNode* SMDS_PolyhedralVolumeOfNodes::GetFaceNode (const int face_ind, + const int node_ind) const +{ + if (node_ind < 1 || NbFaceNodes(face_ind) < node_ind) + return NULL; + + int i, first_node = 0; + for (i = 0; i < face_ind - 1; i++) { + first_node += myQuantities[i]; + } + + return myNodesByFaces[first_node + node_ind - 1]; +} + +//======================================================================= +//function : Print +//purpose : +//======================================================================= +void SMDS_PolyhedralVolumeOfNodes::Print (ostream & OS) const +{ + OS << "polyhedral volume <" << GetID() << "> : "; + + int faces_len = myQuantities.size(); + //int nodes_len = myNodesByFaces.size(); + int cur_first_node = 0; + + int i, j; + for (i = 0; i < faces_len; i++) { + OS << "face_" << i << " ("; + for (j = 0; j < myQuantities[i] - 1; j++) { + OS << myNodesByFaces[cur_first_node + j] << ","; + } + OS << myNodesByFaces[cur_first_node + j] << ") "; + cur_first_node += myQuantities[i]; + } +} + +//======================================================================= +//function : ChangeNodes +//purpose : usage disabled +//======================================================================= +bool SMDS_PolyhedralVolumeOfNodes::ChangeNodes (const SMDS_MeshNode* nodes[], + const int nbNodes) +{ + return false; +} diff --git a/src/SMDS/SMDS_PolyhedralVolumeOfNodes.hxx b/src/SMDS/SMDS_PolyhedralVolumeOfNodes.hxx new file mode 100644 index 000000000..d7cfeeed5 --- /dev/null +++ b/src/SMDS/SMDS_PolyhedralVolumeOfNodes.hxx @@ -0,0 +1,72 @@ +// SMESH SMDS : implementaion of Salome mesh data structure +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMDS_PolyhedralVolumeOfNodes.hxx +// Module : SMESH + +#ifndef _SMDS_PolyhedralVolumeOfNodes_HeaderFile +#define _SMDS_PolyhedralVolumeOfNodes_HeaderFile + +#include "SMDS_VolumeOfNodes.hxx" + +class SMDS_PolyhedralVolumeOfNodes:public SMDS_VolumeOfNodes +{ + public: + SMDS_PolyhedralVolumeOfNodes (std::vector nodes, + std::vector quantities); + + //virtual ~SMDS_PolyhedralVolumeOfNodes(); + + virtual SMDSAbs_ElementType GetType() const; + virtual bool IsPoly() const { return true; }; + + bool ChangeNodes (std::vector nodes, + std::vector quantities); + + //virtual int NbNodes() const; + virtual int NbEdges() const; + virtual int NbFaces() const; + + int NbFaceNodes (const int face_ind) const; + // 1 <= face_ind <= NbFaces() + + const SMDS_MeshNode* GetFaceNode (const int face_ind, const int node_ind) const; + // 1 <= face_ind <= NbFaces() + // 1 <= node_ind <= NbFaceNodes() + + virtual void Print (std::ostream & OS) const; + + protected: + //virtual SMDS_ElemIteratorPtr elementsIterator (SMDSAbs_ElementType type) const; + + private: + // usage disabled + bool ChangeNodes (const SMDS_MeshNode* nodes[], + const int nbNodes); + + private: + std::vector myNodesByFaces; + std::vector myQuantities; +}; + +#endif diff --git a/src/SMDS/SMDS_VolumeTool.cxx b/src/SMDS/SMDS_VolumeTool.cxx index 034486801..dd98851eb 100644 --- a/src/SMDS/SMDS_VolumeTool.cxx +++ b/src/SMDS/SMDS_VolumeTool.cxx @@ -11,6 +11,10 @@ #include "SMDS_MeshElement.hxx" #include "SMDS_MeshNode.hxx" +#include "SMDS_PolyhedralVolumeOfNodes.hxx" + +#include "utilities.h" + #include #include #include @@ -200,19 +204,36 @@ double XYZ::Magnitude() { SMDS_VolumeTool::SMDS_VolumeTool () : myVolume( 0 ), + myPolyedre( 0 ), myVolForward( true ), myNbFaces( 0 ), myVolumeNbNodes( 0 ), - myExternalFaces( false ) + myVolumeNodes( NULL ), + myExternalFaces( false ), + myFaceNbNodes( 0 ), + myCurFace( -1 ), + myFaceNodeIndices( NULL ), + myFaceNodes( NULL ) { } + //======================================================================= //function : SMDS_VolumeTool //purpose : //======================================================================= SMDS_VolumeTool::SMDS_VolumeTool (const SMDS_MeshElement* theVolume) - : myExternalFaces( false ) + : myVolume( 0 ), + myPolyedre( 0 ), + myVolForward( true ), + myNbFaces( 0 ), + myVolumeNbNodes( 0 ), + myVolumeNodes( NULL ), + myExternalFaces( false ), + myFaceNbNodes( 0 ), + myCurFace( -1 ), + myFaceNodeIndices( NULL ), + myFaceNodes( NULL ) { Set( theVolume ); } @@ -224,6 +245,14 @@ SMDS_VolumeTool::SMDS_VolumeTool (const SMDS_MeshElement* theVolume) SMDS_VolumeTool::~SMDS_VolumeTool() { + if (myVolumeNodes != NULL) { + delete [] myVolumeNodes; + myVolumeNodes = NULL; + } + if (myFaceNodes != NULL) { + delete [] myFaceNodes; + myFaceNodes = NULL; + } } //======================================================================= @@ -234,58 +263,75 @@ SMDS_VolumeTool::~SMDS_VolumeTool() bool SMDS_VolumeTool::Set (const SMDS_MeshElement* theVolume) { myVolume = 0; + myPolyedre = 0; + myVolForward = true; - myCurFace = -1; - myVolumeNbNodes = 0; myNbFaces = 0; + myVolumeNbNodes = 0; + if (myVolumeNodes != NULL) { + delete [] myVolumeNodes; + myVolumeNodes = NULL; + } + + myExternalFaces = false; + myFaceNbNodes = 0; + + myCurFace = -1; + myFaceNodeIndices = NULL; + if (myFaceNodes != NULL) { + delete [] myFaceNodes; + myFaceNodes = NULL; + } + if ( theVolume && theVolume->GetType() == SMDSAbs_Volume ) { + myVolume = theVolume; + + myNbFaces = theVolume->NbFaces(); myVolumeNbNodes = theVolume->NbNodes(); - switch ( myVolumeNbNodes ) { - case 4: - case 5: - case 6: - case 8: - { - myVolume = theVolume; - myNbFaces = theVolume->NbFaces(); - // set volume nodes - int iNode = 0; - SMDS_ElemIteratorPtr nodeIt = myVolume->nodesIterator(); - while ( nodeIt->more() ) - myVolumeNodes[ iNode++ ] = static_cast( nodeIt->next() ); - - // nb nodes in each face - if ( myVolumeNbNodes == 4 ) - myFaceNbNodes = Tetra_nbN; - else if ( myVolumeNbNodes == 5 ) - myFaceNbNodes = Pyramid_nbN; - else if ( myVolumeNbNodes == 6 ) - myFaceNbNodes = Penta_nbN; - else - myFaceNbNodes = Hexa_nbN; - - // define volume orientation - XYZ botNormal; - GetFaceNormal( 0, botNormal.x, botNormal.y, botNormal.z ); - const SMDS_MeshNode* topNode = myVolumeNodes[ myVolumeNbNodes - 1 ]; - const SMDS_MeshNode* botNode = myVolumeNodes[ 0 ]; - XYZ upDir (topNode->X() - botNode->X(), - topNode->Y() - botNode->Y(), - topNode->Z() - botNode->Z() ); - myVolForward = ( botNormal.Dot( upDir ) < 0 ); - break; + // set volume nodes + int iNode = 0; + myVolumeNodes = new const SMDS_MeshNode* [myVolumeNbNodes]; + SMDS_ElemIteratorPtr nodeIt = myVolume->nodesIterator(); + while ( nodeIt->more() ) { + myVolumeNodes[ iNode++ ] = static_cast( nodeIt->next() ); } - default: myVolume = 0; + + if (myVolume->IsPoly()) { + myPolyedre = static_cast( myVolume ); + if (!myPolyedre) { + MESSAGE("Warning: bad volumic element"); + return false; + } + } else { + switch ( myVolumeNbNodes ) { + case 4: + case 5: + case 6: + case 8: { + // define volume orientation + XYZ botNormal; + GetFaceNormal( 0, botNormal.x, botNormal.y, botNormal.z ); + const SMDS_MeshNode* topNode = myVolumeNodes[ myVolumeNbNodes - 1 ]; + const SMDS_MeshNode* botNode = myVolumeNodes[ 0 ]; + XYZ upDir (topNode->X() - botNode->X(), + topNode->Y() - botNode->Y(), + topNode->Z() - botNode->Z() ); + myVolForward = ( botNormal.Dot( upDir ) < 0 ); + break; + } + default: + break; + } } } return ( myVolume != 0 ); } //======================================================================= -//function : GetInverseNodes -//purpose : Return nodes vector of an inverse volume +//function : Inverse +//purpose : Inverse volume //======================================================================= #define SWAP_NODES(nodes,i1,i2) \ @@ -298,6 +344,11 @@ void SMDS_VolumeTool::Inverse () { if ( !myVolume ) return; + if (myVolume->IsPoly()) { + MESSAGE("Warning: attempt to inverse polyhedral volume"); + return; + } + myVolForward = !myVolForward; myCurFace = -1; @@ -372,9 +423,9 @@ void SMDS_VolumeTool::SetExternalNormal () int SMDS_VolumeTool::NbFaceNodes( int faceIndex ) { - if ( !setFace( faceIndex )) - return 0; - return myFaceNbNodes[ faceIndex ]; + if ( !setFace( faceIndex )) + return 0; + return myFaceNbNodes; } //======================================================================= @@ -402,6 +453,10 @@ const SMDS_MeshNode** SMDS_VolumeTool::GetFaceNodes( int faceIndex ) const int* SMDS_VolumeTool::GetFaceNodesIndices( int faceIndex ) { + if (myVolume->IsPoly()) { + MESSAGE("Warning: attempt to obtain FaceNodesIndices of polyhedral volume"); + return NULL; + } if ( !setFace( faceIndex )) return 0; return myFaceNodeIndices; @@ -419,10 +474,10 @@ bool SMDS_VolumeTool::GetFaceNodes (int faceIndex, return false; theFaceNodes.clear(); - int iNode, nbNode = myFaceNbNodes[ faceIndex ]; + int iNode, nbNode = myFaceNbNodes; for ( iNode = 0; iNode < nbNode; iNode++ ) theFaceNodes.insert( myFaceNodes[ iNode ]); - + return true; } @@ -436,6 +491,16 @@ bool SMDS_VolumeTool::IsFaceExternal( int faceIndex ) if ( myExternalFaces || !myVolume ) return true; + if (myVolume->IsPoly()) { + XYZ aNormal, baryCenter, p0 (myPolyedre->GetFaceNode(faceIndex + 1, 1)); + GetFaceNormal(faceIndex, aNormal.x, aNormal.y, aNormal.z); + GetBaryCenter(baryCenter.x, baryCenter.y, baryCenter.z); + XYZ insideVec (baryCenter - p0); + if (insideVec.Dot(aNormal) > 0) + return false; + return true; + } + switch ( myVolumeNbNodes ) { case 4: case 5: @@ -482,7 +547,6 @@ bool SMDS_VolumeTool::GetFaceNormal (int faceIndex, double & X, double & Y, doub return true; } - //======================================================================= //function : GetFaceArea //purpose : Return face area @@ -490,6 +554,11 @@ bool SMDS_VolumeTool::GetFaceNormal (int faceIndex, double & X, double & Y, doub double SMDS_VolumeTool::GetFaceArea( int faceIndex ) { + if (myVolume->IsPoly()) { + MESSAGE("Warning: attempt to obtain area of a face of polyhedral volume"); + return 0; + } + if ( !setFace( faceIndex )) return 0; @@ -500,7 +569,7 @@ double SMDS_VolumeTool::GetFaceArea( int faceIndex ) XYZ aVec13( p3 - p1 ); double area = aVec12.Crossed( aVec13 ).Magnitude() * 0.5; - if ( myFaceNbNodes[ faceIndex ] == 4 ) { + if ( myFaceNbNodes == 4 ) { XYZ p4 ( myFaceNodes[3] ); XYZ aVec14( p4 - p1 ); area += aVec14.Crossed( aVec13 ).Magnitude() * 0.5; @@ -516,12 +585,17 @@ double SMDS_VolumeTool::GetFaceArea( int faceIndex ) int SMDS_VolumeTool::GetOppFaceIndex( int faceIndex ) const { int ind = -1; + if (myVolume->IsPoly()) { + MESSAGE("Warning: attempt to obtain opposite face on polyhedral volume"); + return ind; + } + if ( faceIndex >= 0 && faceIndex < NbFaces() ) { switch ( myVolumeNbNodes ) { case 6: if ( faceIndex == 0 || faceIndex == 1 ) ind = 1 - faceIndex; - break; + break; case 8: ind = faceIndex + ( faceIndex % 2 ? -1 : 1 ); break; @@ -542,6 +616,33 @@ bool SMDS_VolumeTool::IsLinked (const SMDS_MeshNode* theNode1, if ( !myVolume ) return false; + if (myVolume->IsPoly()) { + if (!myPolyedre) { + MESSAGE("Warning: bad volumic element"); + return false; + } + bool isLinked = false; + int iface; + for (iface = 1; iface <= myNbFaces && !isLinked; iface++) { + int inode, nbFaceNodes = myPolyedre->NbFaceNodes(iface); + + for (inode = 1; inode <= nbFaceNodes && !isLinked; inode++) { + const SMDS_MeshNode* curNode = myPolyedre->GetFaceNode(iface, inode); + + if (curNode == theNode1 || curNode == theNode2) { + int inextnode = (inode == nbFaceNodes) ? 1 : inode + 1; + const SMDS_MeshNode* nextNode = myPolyedre->GetFaceNode(iface, inextnode); + + if ((curNode == theNode1 && nextNode == theNode2) || + (curNode == theNode2 && nextNode == theNode1)) { + isLinked = true; + } + } + } + } + return isLinked; + } + // find nodes indices int i1 = -1, i2 = -1; for ( int i = 0; i < myVolumeNbNodes; i++ ) { @@ -562,6 +663,10 @@ bool SMDS_VolumeTool::IsLinked (const SMDS_MeshNode* theNode1, bool SMDS_VolumeTool::IsLinked (const int theNode1Index, const int theNode2Index) const { + if (myVolume->IsPoly()) { + return IsLinked(myVolumeNodes[theNode1Index], myVolumeNodes[theNode2Index]); + } + int minInd = theNode1Index < theNode2Index ? theNode1Index : theNode2Index; int maxInd = theNode1Index < theNode2Index ? theNode2Index : theNode1Index; @@ -617,7 +722,6 @@ int SMDS_VolumeTool::GetNodeIndex(const SMDS_MeshNode* theNode) const return -1; } - //======================================================================= //function : IsFreeFace //purpose : check that only one volume is build on the face nodes @@ -626,11 +730,12 @@ int SMDS_VolumeTool::GetNodeIndex(const SMDS_MeshNode* theNode) const bool SMDS_VolumeTool::IsFreeFace( int faceIndex ) { const int free = true; - if ( !setFace( faceIndex )) + + if (!setFace( faceIndex )) return !free; const SMDS_MeshNode** nodes = GetFaceNodes( faceIndex ); - int nbFaceNodes = NbFaceNodes( faceIndex ); + int nbFaceNodes = myFaceNbNodes; // evaluate nb of face nodes shared by other volume int maxNbShared = -1; @@ -706,7 +811,7 @@ bool SMDS_VolumeTool::IsFreeFace( int faceIndex ) // check traingle parts 1 & 3 if ( isShared[1] && isShared[3] ) return !free; // is not free - // check traingle parts 0 & 2; + // check triangle parts 0 & 2; // 0 part could not be checked in the loop; check it here if ( isShared[2] && prevLinkShared && volume.IsLinked( nodes[ 0 ], nodes[ 1 ] ) && @@ -741,7 +846,7 @@ int SMDS_VolumeTool::GetFaceIndex( const set& theFaceNodes //purpose : Return index of a face formed by theFaceNodes //======================================================================= -int SMDS_VolumeTool::GetFaceIndex( const set& theFaceNodesIndices ) +/*int SMDS_VolumeTool::GetFaceIndex( const set& theFaceNodesIndices ) { for ( int iFace = 0; iFace < myNbFaces; iFace++ ) { const int* nodes = GetFaceNodesIndices( iFace ); @@ -753,7 +858,7 @@ int SMDS_VolumeTool::GetFaceIndex( const set& theFaceNodesIndices ) return iFace; } return -1; -} +}*/ //======================================================================= //function : setFace @@ -768,44 +873,163 @@ bool SMDS_VolumeTool::setFace( int faceIndex ) if ( myCurFace == faceIndex ) return true; + myCurFace = -1; + if ( faceIndex < 0 || faceIndex >= NbFaces() ) return false; - // choose face node indices - switch ( myVolumeNbNodes ) { - case 4: - if ( myExternalFaces ) - myFaceNodeIndices = myVolForward ? Tetra_F[ faceIndex ] : Tetra_RE[ faceIndex ]; - else - myFaceNodeIndices = myVolForward ? Tetra_F[ faceIndex ] : Tetra_R[ faceIndex ]; - break; - case 5: - if ( myExternalFaces ) - myFaceNodeIndices = myVolForward ? Pyramid_F[ faceIndex ] : Pyramid_RE[ faceIndex ]; - else - myFaceNodeIndices = myVolForward ? Pyramid_F[ faceIndex ] : Pyramid_R[ faceIndex ]; - break; - case 6: - if ( myExternalFaces ) - myFaceNodeIndices = myVolForward ? Penta_FE[ faceIndex ] : Penta_RE[ faceIndex ]; - else - myFaceNodeIndices = myVolForward ? Penta_F[ faceIndex ] : Penta_R[ faceIndex ]; - break; - case 8: - if ( myExternalFaces ) - myFaceNodeIndices = myVolForward ? Hexa_FE[ faceIndex ] : Hexa_RE[ faceIndex ]; - else - myFaceNodeIndices = Hexa_F[ faceIndex ]; - break; - default: return false; + if (myFaceNodes != NULL) { + delete [] myFaceNodes; + myFaceNodes = NULL; } - // set face nodes - int iNode, nbNode = myFaceNbNodes[ faceIndex ]; - for ( iNode = 0; iNode <= nbNode; iNode++ ) - myFaceNodes[ iNode ] = myVolumeNodes[ myFaceNodeIndices[ iNode ]]; + if (myVolume->IsPoly()) { + if (!myPolyedre) { + MESSAGE("Warning: bad volumic element"); + return false; + } + + // check orientation + bool isGoodOri = true; + if (myExternalFaces) { + // get natural orientation + XYZ aNormal, baryCenter, p0 (myPolyedre->GetFaceNode(faceIndex + 1, 1)); + SMDS_VolumeTool vTool (myPolyedre); + vTool.GetFaceNormal(faceIndex, aNormal.x, aNormal.y, aNormal.z); + vTool.GetBaryCenter(baryCenter.x, baryCenter.y, baryCenter.z); + XYZ insideVec (baryCenter - p0); + if (insideVec.Dot(aNormal) > 0) + isGoodOri = false; + } + + // set face nodes + int iNode; + myFaceNbNodes = myPolyedre->NbFaceNodes(faceIndex + 1); + myFaceNodes = new const SMDS_MeshNode* [myFaceNbNodes + 1]; + if (isGoodOri) { + for ( iNode = 0; iNode < myFaceNbNodes; iNode++ ) + myFaceNodes[ iNode ] = myPolyedre->GetFaceNode(faceIndex + 1, iNode + 1); + } else { + for ( iNode = 0; iNode < myFaceNbNodes; iNode++ ) + myFaceNodes[ iNode ] = myPolyedre->GetFaceNode(faceIndex + 1, myFaceNbNodes - iNode); + } + myFaceNodes[ myFaceNbNodes ] = myFaceNodes[ 0 ]; // last = first + + } else { + // choose face node indices + switch ( myVolumeNbNodes ) { + case 4: + myFaceNbNodes = Tetra_nbN[ faceIndex ]; + if ( myExternalFaces ) + myFaceNodeIndices = myVolForward ? Tetra_F[ faceIndex ] : Tetra_RE[ faceIndex ]; + else + myFaceNodeIndices = myVolForward ? Tetra_F[ faceIndex ] : Tetra_R[ faceIndex ]; + break; + case 5: + myFaceNbNodes = Pyramid_nbN[ faceIndex ]; + if ( myExternalFaces ) + myFaceNodeIndices = myVolForward ? Pyramid_F[ faceIndex ] : Pyramid_RE[ faceIndex ]; + else + myFaceNodeIndices = myVolForward ? Pyramid_F[ faceIndex ] : Pyramid_R[ faceIndex ]; + break; + case 6: + myFaceNbNodes = Penta_nbN[ faceIndex ]; + if ( myExternalFaces ) + myFaceNodeIndices = myVolForward ? Penta_FE[ faceIndex ] : Penta_RE[ faceIndex ]; + else + myFaceNodeIndices = myVolForward ? Penta_F[ faceIndex ] : Penta_R[ faceIndex ]; + break; + case 8: + myFaceNbNodes = Hexa_nbN[ faceIndex ]; + if ( myExternalFaces ) + myFaceNodeIndices = myVolForward ? Hexa_FE[ faceIndex ] : Hexa_RE[ faceIndex ]; + else + myFaceNodeIndices = Hexa_F[ faceIndex ]; + break; + default: + return false; + } + + // set face nodes + myFaceNodes = new const SMDS_MeshNode* [myFaceNbNodes + 1]; + for ( int iNode = 0; iNode <= myFaceNbNodes; iNode++ ) + myFaceNodes[ iNode ] = myVolumeNodes[ myFaceNodeIndices[ iNode ]]; + } myCurFace = faceIndex; return true; } + +//======================================================================= +//function : GetType +//purpose : return VolumeType by nb of nodes in a volume +//======================================================================= + +SMDS_VolumeTool::VolumeType SMDS_VolumeTool::GetType(int nbNodes) +{ + switch ( nbNodes ) { + case 4: return TETRA; + case 5: return PYRAM; + case 6: return PENTA; + case 8: return HEXA; + default:return UNKNOWN; + } +} + +//======================================================================= +//function : NbFaces +//purpose : return nb of faces by volume type +//======================================================================= + +int SMDS_VolumeTool::NbFaces( VolumeType type ) +{ + switch ( type ) { + case TETRA: return 4; + case PYRAM: return 5; + case PENTA: return 5; + case HEXA : return 6; + default: return 0; + } +} + +//======================================================================= +//function : GetFaceNodesIndices +//purpose : Return the array of face nodes indices +// To comfort link iteration, the array +// length == NbFaceNodes( faceIndex ) + 1 and +// the last node index == the first one. +//======================================================================= + +const int* SMDS_VolumeTool::GetFaceNodesIndices(VolumeType type, + int faceIndex, + bool external) +{ + switch ( type ) { + case TETRA: return Tetra_F[ faceIndex ]; + case PYRAM: return Pyramid_F[ faceIndex ]; + case PENTA: return external ? Penta_FE[ faceIndex ] : Penta_F[ faceIndex ]; + case HEXA: return external ? Hexa_FE[ faceIndex ] : Hexa_F[ faceIndex ]; + default:; + } + return 0; +} + +//======================================================================= +//function : NbFaceNodes +//purpose : Return number of nodes in the array of face nodes +//======================================================================= + +int SMDS_VolumeTool::NbFaceNodes(VolumeType type, + int faceIndex ) +{ + switch ( type ) { + case TETRA: return Tetra_nbN[ faceIndex ]; + case PYRAM: return Pyramid_nbN[ faceIndex ]; + case PENTA: return Penta_nbN[ faceIndex ]; + case HEXA: return Hexa_nbN[ faceIndex ]; + default:; + } + return 0; +} + diff --git a/src/SMDS/SMDS_VolumeTool.hxx b/src/SMDS/SMDS_VolumeTool.hxx index 99e7dc176..89732b1da 100644 --- a/src/SMDS/SMDS_VolumeTool.hxx +++ b/src/SMDS/SMDS_VolumeTool.hxx @@ -32,6 +32,7 @@ class SMDS_MeshElement; class SMDS_MeshNode; +class SMDS_PolyhedralVolumeOfNodes; #include #include @@ -149,26 +150,52 @@ class SMDS_VolumeTool // Return index of a face formed by theFaceNodes. // Return -1 if a face not found - int GetFaceIndex( const std::set& theFaceNodesIndices ); + //int GetFaceIndex( const std::set& theFaceNodesIndices ); // Return index of a face formed by theFaceNodesIndices // Return -1 if a face not found + // ------------------------ + // static methods for faces + // ------------------------ + + enum VolumeType { UNKNOWN, TETRA, PYRAM, PENTA, HEXA }; + + static VolumeType GetType(int nbNodes); + // return VolumeType by nb of nodes in a volume + + static int NbFaces( VolumeType type ); + // return nb of faces by volume type + + static const int* GetFaceNodesIndices(VolumeType type, + int faceIndex, + bool external); + // Return the array of face nodes indices + // To comfort link iteration, the array + // length == NbFaceNodes( faceIndex ) + 1 and + // the last node index == the first one. + + static int NbFaceNodes(VolumeType type, + int faceIndex ); + // Return number of nodes in the array of face nodes private: bool setFace( int faceIndex ); const SMDS_MeshElement* myVolume; + const SMDS_PolyhedralVolumeOfNodes* myPolyedre; + bool myVolForward; int myNbFaces; int myVolumeNbNodes; - const SMDS_MeshNode* myVolumeNodes[ 8 ]; + const SMDS_MeshNode** myVolumeNodes; bool myExternalFaces; - int* myFaceNodeIndices; - int* myFaceNbNodes; - const SMDS_MeshNode* myFaceNodes[ 5 ]; + int myCurFace; + int myFaceNbNodes; + int* myFaceNodeIndices; + const SMDS_MeshNode** myFaceNodes; }; #endif diff --git a/src/SMESH/SMESH_Mesh.cxx b/src/SMESH/SMESH_Mesh.cxx index e3bf98a5d..308456021 100644 --- a/src/SMESH/SMESH_Mesh.cxx +++ b/src/SMESH/SMESH_Mesh.cxx @@ -79,7 +79,7 @@ static int MYDEBUG = 0; SMESH_Mesh::SMESH_Mesh(int localId, int studyId, SMESH_Gen * gen, SMESHDS_Document * myDocument) : _groupId( 0 ) { - INFOS("SMESH_Mesh::SMESH_Mesh; this = "<::iterator itg; @@ -660,6 +660,24 @@ throw(SALOME_Exception) return aSubMesh; } +//============================================================================= +/*! + * Get the SMESH_subMesh object implementation. Dont create it, return null + * if it does not exist. + */ +//============================================================================= + +SMESH_subMesh *SMESH_Mesh::GetSubMeshContaining(const int aShapeID) +throw(SALOME_Exception) +{ + Unexpect aCatch(SalomeException); + + map ::iterator i_sm = _mapSubMesh.find(aShapeID); + if (i_sm == _mapSubMesh.end()) + return NULL; + return i_sm->second; +} + //======================================================================= //function : IsUsedHypothesis //purpose : Return True if anHyp is used to mesh aSubShape @@ -833,7 +851,12 @@ int SMESH_Mesh::NbTriangles() throw(SALOME_Exception) int Nb = 0; SMDS_FaceIteratorPtr itFaces=_myMeshDS->facesIterator(); - while(itFaces->more()) if(itFaces->next()->NbNodes()==3) Nb++; + //while(itFaces->more()) if(itFaces->next()->NbNodes()==3) Nb++; + const SMDS_MeshFace * curFace; + while (itFaces->more()) { + curFace = itFaces->next(); + if (!curFace->IsPoly() && curFace->NbNodes() == 3) Nb++; + } return Nb; } @@ -846,7 +869,25 @@ int SMESH_Mesh::NbQuadrangles() throw(SALOME_Exception) int Nb = 0; SMDS_FaceIteratorPtr itFaces=_myMeshDS->facesIterator(); - while(itFaces->more()) if(itFaces->next()->NbNodes()==4) Nb++; + //while(itFaces->more()) if(itFaces->next()->NbNodes()==4) Nb++; + const SMDS_MeshFace * curFace; + while (itFaces->more()) { + curFace = itFaces->next(); + if (!curFace->IsPoly() && curFace->NbNodes() == 4) Nb++; + } + return Nb; +} + +/////////////////////////////////////////////////////////////////////////////// +/// Return the number of polygonal faces in the mesh. This method run in O(n) +/////////////////////////////////////////////////////////////////////////////// +int SMESH_Mesh::NbPolygons() throw(SALOME_Exception) +{ + Unexpect aCatch(SalomeException); + int Nb = 0; + SMDS_FaceIteratorPtr itFaces = _myMeshDS->facesIterator(); + while (itFaces->more()) + if (itFaces->next()->IsPoly()) Nb++; return Nb; } @@ -866,7 +907,12 @@ int SMESH_Mesh::NbTetras() throw(SALOME_Exception) Unexpect aCatch(SalomeException); int Nb = 0; SMDS_VolumeIteratorPtr itVolumes=_myMeshDS->volumesIterator(); - while(itVolumes->more()) if(itVolumes->next()->NbNodes()==4) Nb++; + //while(itVolumes->more()) if(itVolumes->next()->NbNodes()==4) Nb++; + const SMDS_MeshVolume * curVolume; + while (itVolumes->more()) { + curVolume = itVolumes->next(); + if (!curVolume->IsPoly() && curVolume->NbNodes() == 4) Nb++; + } return Nb; } @@ -875,7 +921,12 @@ int SMESH_Mesh::NbHexas() throw(SALOME_Exception) Unexpect aCatch(SalomeException); int Nb = 0; SMDS_VolumeIteratorPtr itVolumes=_myMeshDS->volumesIterator(); - while(itVolumes->more()) if(itVolumes->next()->NbNodes()==8) Nb++; + //while(itVolumes->more()) if(itVolumes->next()->NbNodes()==8) Nb++; + const SMDS_MeshVolume * curVolume; + while (itVolumes->more()) { + curVolume = itVolumes->next(); + if (!curVolume->IsPoly() && curVolume->NbNodes() == 8) Nb++; + } return Nb; } @@ -884,7 +935,12 @@ int SMESH_Mesh::NbPyramids() throw(SALOME_Exception) Unexpect aCatch(SalomeException); int Nb = 0; SMDS_VolumeIteratorPtr itVolumes=_myMeshDS->volumesIterator(); - while(itVolumes->more()) if(itVolumes->next()->NbNodes()==5) Nb++; + //while(itVolumes->more()) if(itVolumes->next()->NbNodes()==5) Nb++; + const SMDS_MeshVolume * curVolume; + while (itVolumes->more()) { + curVolume = itVolumes->next(); + if (!curVolume->IsPoly() && curVolume->NbNodes() == 5) Nb++; + } return Nb; } @@ -893,7 +949,22 @@ int SMESH_Mesh::NbPrisms() throw(SALOME_Exception) Unexpect aCatch(SalomeException); int Nb = 0; SMDS_VolumeIteratorPtr itVolumes=_myMeshDS->volumesIterator(); - while(itVolumes->more()) if(itVolumes->next()->NbNodes()==6) Nb++; + //while(itVolumes->more()) if(itVolumes->next()->NbNodes()==6) Nb++; + const SMDS_MeshVolume * curVolume; + while (itVolumes->more()) { + curVolume = itVolumes->next(); + if (!curVolume->IsPoly() && curVolume->NbNodes() == 6) Nb++; + } + return Nb; +} + +int SMESH_Mesh::NbPolyhedrons() throw(SALOME_Exception) +{ + Unexpect aCatch(SalomeException); + int Nb = 0; + SMDS_VolumeIteratorPtr itVolumes = _myMeshDS->volumesIterator(); + while (itVolumes->more()) + if (itVolumes->next()->IsPoly()) Nb++; return Nb; } @@ -992,8 +1063,8 @@ void SMESH_Mesh::RemoveGroup (const int theGroupID) if (_mapGroup.find(theGroupID) == _mapGroup.end()) return; GetMeshDS()->RemoveGroup( _mapGroup[theGroupID]->GetGroupDS() ); - delete _mapGroup[theGroupID]; _mapGroup.erase (theGroupID); + delete _mapGroup[theGroupID]; } //============================================================================= diff --git a/src/SMESH/SMESH_Mesh.hxx b/src/SMESH/SMESH_Mesh.hxx index 2864deade..a91a8861b 100644 --- a/src/SMESH/SMESH_Mesh.hxx +++ b/src/SMESH/SMESH_Mesh.hxx @@ -129,6 +129,9 @@ public: SMESH_subMesh *GetSubMeshContaining(const TopoDS_Shape & aSubShape) throw(SALOME_Exception); + SMESH_subMesh *GetSubMeshContaining(const int aShapeID) + throw(SALOME_Exception); + const list < SMESH_subMesh * >& GetSubMeshUsingHypothesis(SMESHDS_Hypothesis * anHyp) throw(SALOME_Exception); @@ -165,6 +168,8 @@ public: int NbTriangles() throw(SALOME_Exception); int NbQuadrangles() throw(SALOME_Exception); + + int NbPolygons() throw(SALOME_Exception); int NbVolumes() throw(SALOME_Exception); @@ -173,9 +178,11 @@ public: int NbHexas() throw(SALOME_Exception); int NbPyramids() throw(SALOME_Exception); - + int NbPrisms() throw(SALOME_Exception); + int NbPolyhedrons() throw(SALOME_Exception); + int NbSubMesh() throw(SALOME_Exception); int NbGroup() const { return _mapGroup.size(); } diff --git a/src/SMESH/SMESH_MeshEditor.cxx b/src/SMESH/SMESH_MeshEditor.cxx index dfc453b80..94b59dced 100644 --- a/src/SMESH/SMESH_MeshEditor.cxx +++ b/src/SMESH/SMESH_MeshEditor.cxx @@ -28,12 +28,16 @@ #include "SMESH_MeshEditor.hxx" -#include "SMESH_ControlsDef.hxx" - #include "SMDS_FaceOfNodes.hxx" #include "SMDS_VolumeTool.hxx" +#include "SMDS_EdgePosition.hxx" +#include "SMDS_PolyhedralVolumeOfNodes.hxx" +#include "SMDS_FacePosition.hxx" +#include "SMDS_SpacePosition.hxx" + #include "SMESHDS_Group.hxx" #include "SMESHDS_Mesh.hxx" + #include "SMESH_subMesh.hxx" #include "SMESH_ControlsDef.hxx" @@ -48,17 +52,20 @@ #include #include #include +#include #include #include #include -#include #include - +#include +#include +#include +#include +#include +#include #include -#include "utilities.h" - using namespace std; using namespace SMESH::Controls; @@ -494,11 +501,38 @@ bool SMESH_MeshEditor::Reorient (const SMDS_MeshElement * theElem) } case SMDSAbs_Volume: { - SMDS_VolumeTool vTool; - if ( !vTool.Set( theElem )) - return false; - vTool.Inverse(); - return GetMeshDS()->ChangeElementNodes( theElem, vTool.GetNodes(), vTool.NbNodes() ); + if (theElem->IsPoly()) { + const SMDS_PolyhedralVolumeOfNodes* aPolyedre = + static_cast( theElem ); + if (!aPolyedre) { + MESSAGE("Warning: bad volumic element"); + return false; + } + + int nbFaces = aPolyedre->NbFaces(); + vector poly_nodes; + vector quantities (nbFaces); + + // reverse each face of the polyedre + for (int iface = 1; iface <= nbFaces; iface++) { + int inode, nbFaceNodes = aPolyedre->NbFaceNodes(iface); + quantities[iface - 1] = nbFaceNodes; + + for (inode = nbFaceNodes; inode >= 1; inode--) { + const SMDS_MeshNode* curNode = aPolyedre->GetFaceNode(iface, inode); + poly_nodes.push_back(curNode); + } + } + + return GetMeshDS()->ChangePolyhedronNodes( theElem, poly_nodes, quantities ); + + } else { + SMDS_VolumeTool vTool; + if ( !vTool.Set( theElem )) + return false; + vTool.Inverse(); + return GetMeshDS()->ChangeElementNodes( theElem, vTool.GetNodes(), vTool.NbNodes() ); + } } default:; } @@ -977,12 +1011,12 @@ bool SMESH_MeshEditor::TriToQuad (set & theElems, } -#define DUMPSO(txt) \ +/*#define DUMPSO(txt) \ // cout << txt << endl; //============================================================================= -/*! - * - */ +// +// +// //============================================================================= static void swap( int i1, int i2, int idNodes[], gp_Pnt P[] ) { @@ -1254,7 +1288,7 @@ bool SMESH_MeshEditor::SortHexaNodes (const SMDS_Mesh * theMesh, // } return true; -} +}*/ //======================================================================= //function : laplacianSmooth @@ -1262,52 +1296,76 @@ bool SMESH_MeshEditor::SortHexaNodes (const SMDS_Mesh * theMesh, // connected to that node along an element edge //======================================================================= -void laplacianSmooth(SMESHDS_Mesh * theMesh, - const SMDS_MeshNode* theNode, - const set & theElems, - const set & theFixedNodes) +void laplacianSmooth(const SMDS_MeshNode* theNode, + const Handle(Geom_Surface)& theSurface, + map< const SMDS_MeshNode*, gp_XY* >& theUVMap) { // find surrounding nodes + set< const SMDS_MeshNode* > nodeSet; SMDS_ElemIteratorPtr elemIt = theNode->GetInverseElementIterator(); while ( elemIt->more() ) { const SMDS_MeshElement* elem = elemIt->next(); - if ( theElems.find( elem ) == theElems.end() ) + if ( elem->GetType() != SMDSAbs_Face ) continue; - int i = 0, iNode = 0; - const SMDS_MeshNode* aNodes [4]; + // put all nodes in array + int nbNodes = 0, iNode = 0; + vector< const SMDS_MeshNode*> aNodes( elem->NbNodes() ); SMDS_ElemIteratorPtr itN = elem->nodesIterator(); while ( itN->more() ) { - aNodes[ i ] = static_cast( itN->next() ); - if ( aNodes[ i ] == theNode ) - iNode = i; - else - nodeSet.insert( aNodes[ i ] ); - i++; - } - if ( elem->NbNodes() == 4 ) { // remove an opposite node - iNode += ( iNode < 2 ) ? 2 : -2; - nodeSet.erase( aNodes[ iNode ]); + aNodes[ nbNodes ] = static_cast( itN->next() ); + if ( aNodes[ nbNodes ] == theNode ) + iNode = nbNodes; // index of theNode within aNodes + nbNodes++; } + // add linked nodes + int iAfter = ( iNode + 1 == nbNodes ) ? 0 : iNode + 1; + nodeSet.insert( aNodes[ iAfter ]); + int iBefore = ( iNode == 0 ) ? nbNodes - 1 : iNode - 1; + nodeSet.insert( aNodes[ iBefore ]); } // compute new coodrs + double coord[] = { 0., 0., 0. }; set< const SMDS_MeshNode* >::iterator nodeSetIt = nodeSet.begin(); for ( ; nodeSetIt != nodeSet.end(); nodeSetIt++ ) { const SMDS_MeshNode* node = (*nodeSetIt); - coord[0] += node->X(); - coord[1] += node->Y(); - coord[2] += node->Z(); + if ( theSurface.IsNull() ) { // smooth in 3D + coord[0] += node->X(); + coord[1] += node->Y(); + coord[2] += node->Z(); + } + else { // smooth in 2D + ASSERT( theUVMap.find( node ) != theUVMap.end() ); + gp_XY* uv = theUVMap[ node ]; + coord[0] += uv->X(); + coord[1] += uv->Y(); + } } - double nbNodes = nodeSet.size(); - theMesh->MoveNode (theNode, - coord[0]/nbNodes, - coord[1]/nbNodes, - coord[2]/nbNodes); + int nbNodes = nodeSet.size(); + if ( !nbNodes ) + return; + coord[0] /= nbNodes; + coord[1] /= nbNodes; + + if ( !theSurface.IsNull() ) { + ASSERT( theUVMap.find( theNode ) != theUVMap.end() ); + theUVMap[ theNode ]->SetCoord( coord[0], coord[1] ); + gp_Pnt p3d = theSurface->Value( coord[0], coord[1] ); + coord[0] = p3d.X(); + coord[1] = p3d.Y(); + coord[2] = p3d.Z(); + } + else + coord[2] /= nbNodes; + + // move node + + const_cast< SMDS_MeshNode* >( theNode )->setXYZ(coord[0],coord[1],coord[2]); } //======================================================================= @@ -1316,23 +1374,23 @@ void laplacianSmooth(SMESHDS_Mesh * theMesh, // surrounding elements //======================================================================= -void centroidalSmooth(SMESHDS_Mesh * theMesh, - const SMDS_MeshNode* theNode, - const set & theElems, - const set & theFixedNodes) +void centroidalSmooth(const SMDS_MeshNode* theNode, + const Handle(Geom_Surface)& theSurface, + map< const SMDS_MeshNode*, gp_XY* >& theUVMap) { gp_XYZ aNewXYZ(0.,0.,0.); SMESH::Controls::Area anAreaFunc; double totalArea = 0.; int nbElems = 0; + // compute new XYZ + SMDS_ElemIteratorPtr elemIt = theNode->GetInverseElementIterator(); while ( elemIt->more() ) { const SMDS_MeshElement* elem = elemIt->next(); - if ( theElems.find( elem ) == theElems.end() ) + if ( elem->GetType() != SMDSAbs_Face ) continue; - nbElems++; gp_XYZ elemCenter(0.,0.,0.); @@ -1343,6 +1401,11 @@ void centroidalSmooth(SMESHDS_Mesh * theMesh, const SMDS_MeshNode* aNode = static_cast( itN->next() ); gp_XYZ aP( aNode->X(), aNode->Y(), aNode->Z() ); aNodePoints.push_back( aP ); + if ( !theSurface.IsNull() ) { // smooth in 2D + ASSERT( theUVMap.find( aNode ) != theUVMap.end() ); + gp_XY* uv = theUVMap[ aNode ]; + aP.SetCoord( uv->X(), uv->Y(), 0. ); + } elemCenter += aP; } double elemArea = anAreaFunc.GetValue( aNodePoints ); @@ -1351,10 +1414,38 @@ void centroidalSmooth(SMESHDS_Mesh * theMesh, aNewXYZ += elemCenter * elemArea; } aNewXYZ /= totalArea; - theMesh->MoveNode (theNode, - aNewXYZ.X(), - aNewXYZ.Y(), - aNewXYZ.Z()); + if ( !theSurface.IsNull() ) { + ASSERT( theUVMap.find( theNode ) != theUVMap.end() ); + theUVMap[ theNode ]->SetCoord( aNewXYZ.X(), aNewXYZ.Y() ); + aNewXYZ = theSurface->Value( aNewXYZ.X(), aNewXYZ.Y() ).XYZ(); + } + + // move node + + const_cast< SMDS_MeshNode* >( theNode )->setXYZ(aNewXYZ.X(),aNewXYZ.Y(),aNewXYZ.Z()); +} + +//======================================================================= +//function : getClosestUV +//purpose : return UV of closest projection +//======================================================================= + +static bool getClosestUV (Extrema_GenExtPS& projector, + const gp_Pnt& point, + gp_XY & result) +{ + projector.Perform( point ); + if ( projector.IsDone() ) { + double u, v, minVal = DBL_MAX; + for ( int i = projector.NbExt(); i > 0; i-- ) + if ( projector.Value( i ) < minVal ) { + minVal = projector.Value( i ); + projector.Point( i ).Parameter( u, v ); + } + result.SetCoord( u, v ); + return true; + } + return false; } //======================================================================= @@ -1371,124 +1462,465 @@ void SMESH_MeshEditor::Smooth (set & theElems, set & theFixedNodes, const SmoothMethod theSmoothMethod, const int theNbIterations, - double theTgtAspectRatio) + double theTgtAspectRatio, + const bool the2D) { MESSAGE((theSmoothMethod==LAPLACIAN ? "LAPLACIAN" : "CENTROIDAL") << "--::Smooth()"); - SMESHDS_Mesh* aMesh = GetMeshDS(); - if ( theElems.empty() ) { - // add all faces - SMDS_FaceIteratorPtr fIt = aMesh->facesIterator(); - while ( fIt->more() ) - theElems.insert( fIt->next() ); - } - - set setMovableNodes; - - // Fill setMovableNodes - - map< const SMDS_MeshNode*, int > mapNodeNbFaces; - set< const SMDS_MeshElement* >::iterator itElem; - for ( itElem = theElems.begin(); itElem != theElems.end(); itElem++ ) - { - const SMDS_MeshElement* elem = (*itElem); - if ( !elem || elem->GetType() != SMDSAbs_Face ) - continue; - - SMDS_ElemIteratorPtr itN = elem->nodesIterator(); - while ( itN->more() ) { - const SMDS_MeshNode* node = - static_cast( itN->next() ); - - if ( theFixedNodes.find( node ) != theFixedNodes.end() ) - continue; - - // if node is on edge => it is fixed - SMDS_PositionPtr aPositionPtr = node->GetPosition(); - if ( aPositionPtr.get() && - (aPositionPtr->GetTypeOfPosition() == SMDS_TOP_EDGE || - aPositionPtr->GetTypeOfPosition() == SMDS_TOP_VERTEX)) { - theFixedNodes.insert( node ); - continue; - } - // fill mapNodeNbFaces in order to detect fixed boundary nodes - map::iterator nodeNbFacesIt = - mapNodeNbFaces.find ( node ); - if ( nodeNbFacesIt == mapNodeNbFaces.end() ) - mapNodeNbFaces.insert( map::value_type( node, 1 )); - else - (*nodeNbFacesIt).second++; - } - } - // put not fixed nodes in setMovableNodes - map::iterator nodeNbFacesIt = - mapNodeNbFaces.begin(); - for ( ; nodeNbFacesIt != mapNodeNbFaces.end(); nodeNbFacesIt++ ) { - const SMDS_MeshNode* node = (*nodeNbFacesIt).first; - // a node is on free boundary if it is shared by 1-2 faces - if ( (*nodeNbFacesIt).second > 2 ) - setMovableNodes.insert( node ); - else - theFixedNodes.insert( node ); - } - - // SMOOTHING // - if ( theTgtAspectRatio < 1.0 ) theTgtAspectRatio = 1.0; SMESH::Controls::AspectRatio aQualityFunc; - for ( int it = 0; it < theNbIterations; it++ ) - { - Standard_Real maxDisplacement = 0.; - set::iterator movableNodesIt - = setMovableNodes.begin(); - for ( ; movableNodesIt != setMovableNodes.end(); movableNodesIt++ ) - { - const SMDS_MeshNode* node = (*movableNodesIt); - gp_XYZ aPrevPos ( node->X(), node->Y(), node->Z() ); - - // smooth - if ( theSmoothMethod == LAPLACIAN ) - laplacianSmooth( aMesh, node, theElems, theFixedNodes ); - else - centroidalSmooth( aMesh, node, theElems, theFixedNodes ); - - // displacement - gp_XYZ aNewPos ( node->X(), node->Y(), node->Z() ); - Standard_Real aDispl = (aPrevPos - aNewPos).SquareModulus(); - if ( aDispl > maxDisplacement ) - maxDisplacement = aDispl; - } - // no node movement => exit - if ( maxDisplacement < 1.e-16 ) { - MESSAGE("-- no node movement -- maxDisplacement: " << maxDisplacement << " it "<< it); - break; - } - - // check elements quality - double maxRatio = 0; - for ( itElem = theElems.begin(); itElem != theElems.end(); itElem++ ) - { - const SMDS_MeshElement* elem = (*itElem); - if ( !elem || elem->GetType() != SMDSAbs_Face ) - continue; - SMESH::Controls::TSequenceOfXYZ aPoints; - if ( aQualityFunc.GetPoints( elem, aPoints )) { - double aValue = aQualityFunc.GetValue( aPoints ); - if ( aValue > maxRatio ) - maxRatio = aValue; + SMESHDS_Mesh* aMesh = GetMeshDS(); + + if ( theElems.empty() ) { + // add all faces to theElems + SMDS_FaceIteratorPtr fIt = aMesh->facesIterator(); + while ( fIt->more() ) + theElems.insert( fIt->next() ); + } + // get all face ids theElems are on + set< int > faceIdSet; + set< const SMDS_MeshElement* >::iterator itElem; + if ( the2D ) + for ( itElem = theElems.begin(); itElem != theElems.end(); itElem++ ) { + int fId = FindShape( *itElem ); + // check that corresponding submesh exists and a shape is face + if (fId && + faceIdSet.find( fId ) == faceIdSet.end() && + aMesh->MeshElements( fId )) { + TopoDS_Shape F = aMesh->IndexToShape( fId ); + if ( !F.IsNull() && F.ShapeType() == TopAbs_FACE ) + faceIdSet.insert( fId ); } } - if ( maxRatio <= theTgtAspectRatio ) { - MESSAGE("-- quality achived -- maxRatio " << maxRatio << " it "<< it); - break; + faceIdSet.insert( 0 ); // to smooth elements that are not on any TopoDS_Face + + // =============================================== + // smooth elements on each TopoDS_Face separately + // =============================================== + + set< int >::reverse_iterator fId = faceIdSet.rbegin(); // treate 0 fId at the end + for ( ; fId != faceIdSet.rend(); ++fId ) + { + // get face surface and submesh + Handle(Geom_Surface) surface; + SMESHDS_SubMesh* faceSubMesh = 0; + TopoDS_Face face; + double fToler2 = 0, vPeriod = 0., uPeriod = 0., f,l; + double u1 = 0, u2 = 0, v1 = 0, v2 = 0; + bool isUPeriodic = false, isVPeriodic = false; + if ( *fId ) { + face = TopoDS::Face( aMesh->IndexToShape( *fId )); + surface = BRep_Tool::Surface( face ); + faceSubMesh = aMesh->MeshElements( *fId ); + fToler2 = BRep_Tool::Tolerance( face ); + fToler2 *= fToler2 * 10.; + isUPeriodic = surface->IsUPeriodic(); + if ( isUPeriodic ) + vPeriod = surface->UPeriod(); + isVPeriodic = surface->IsVPeriodic(); + if ( isVPeriodic ) + uPeriod = surface->VPeriod(); + surface->Bounds( u1, u2, v1, v2 ); } - if (it+1 == theNbIterations) { - MESSAGE("-- Iteration limit exceeded --"); + // --------------------------------------------------------- + // for elements on a face, find movable and fixed nodes and + // compute UV for them + // --------------------------------------------------------- + bool checkBoundaryNodes = false; + set setMovableNodes; + map< const SMDS_MeshNode*, gp_XY* > uvMap, uvMap2; + list< gp_XY > listUV; // uvs the 2 uvMaps refer to + list< const SMDS_MeshElement* > elemsOnFace; + + Extrema_GenExtPS projector; + GeomAdaptor_Surface surfAdaptor; + if ( !surface.IsNull() ) { + surfAdaptor.Load( surface ); + projector.Initialize( surfAdaptor, 20,20, 1e-5,1e-5 ); } - } + int nbElemOnFace = 0; + itElem = theElems.begin(); + // loop on not yet smoothed elements: look for elems on a face + while ( itElem != theElems.end() ) + { + if ( faceSubMesh && nbElemOnFace == faceSubMesh->NbElements() ) + break; // all elements found + + const SMDS_MeshElement* elem = (*itElem); + if ( !elem || elem->GetType() != SMDSAbs_Face || elem->NbNodes() < 3 || + ( faceSubMesh && !faceSubMesh->Contains( elem ))) { + ++itElem; + continue; + } + elemsOnFace.push_back( elem ); + theElems.erase( itElem++ ); + nbElemOnFace++; + + // get movable nodes of elem + const SMDS_MeshNode* node; + SMDS_TypeOfPosition posType; + SMDS_ElemIteratorPtr itN = elem->nodesIterator(); + while ( itN->more() ) { + node = static_cast( itN->next() ); + const SMDS_PositionPtr& pos = node->GetPosition(); + posType = pos.get() ? pos->GetTypeOfPosition() : SMDS_TOP_3DSPACE; + if (posType != SMDS_TOP_EDGE && + posType != SMDS_TOP_VERTEX && + theFixedNodes.find( node ) == theFixedNodes.end()) + { + // check if all faces around the node are on faceSubMesh + // because a node on edge may be bound to face + SMDS_ElemIteratorPtr eIt = node->GetInverseElementIterator(); + bool all = true; + if ( faceSubMesh ) { + while ( eIt->more() && all ) { + const SMDS_MeshElement* e = eIt->next(); + if ( e->GetType() == SMDSAbs_Face ) + all = faceSubMesh->Contains( e ); + } + } + if ( all ) + setMovableNodes.insert( node ); + else + checkBoundaryNodes = true; + } + if ( posType == SMDS_TOP_3DSPACE ) + checkBoundaryNodes = true; + } + + if ( surface.IsNull() ) + continue; + + // get nodes to check UV + list< const SMDS_MeshNode* > uvCheckNodes; + itN = elem->nodesIterator(); + while ( itN->more() ) { + node = static_cast( itN->next() ); + if ( uvMap.find( node ) == uvMap.end() ) + uvCheckNodes.push_back( node ); + // add nodes of elems sharing node +// SMDS_ElemIteratorPtr eIt = node->GetInverseElementIterator(); +// while ( eIt->more() ) { +// const SMDS_MeshElement* e = eIt->next(); +// if ( e != elem && e->GetType() == SMDSAbs_Face ) { +// SMDS_ElemIteratorPtr nIt = e->nodesIterator(); +// while ( nIt->more() ) { +// const SMDS_MeshNode* n = +// static_cast( nIt->next() ); +// if ( uvMap.find( n ) == uvMap.end() ) +// uvCheckNodes.push_back( n ); +// } +// } +// } + } + // check UV on face + list< const SMDS_MeshNode* >::iterator n = uvCheckNodes.begin(); + for ( ; n != uvCheckNodes.end(); ++n ) + { + node = *n; + gp_XY uv( 0, 0 ); + const SMDS_PositionPtr& pos = node->GetPosition(); + posType = pos.get() ? pos->GetTypeOfPosition() : SMDS_TOP_3DSPACE; + // get existing UV + switch ( posType ) { + case SMDS_TOP_FACE: { + SMDS_FacePosition* fPos = ( SMDS_FacePosition* ) pos.get(); + uv.SetCoord( fPos->GetUParameter(), fPos->GetVParameter() ); + break; + } + case SMDS_TOP_EDGE: { + TopoDS_Shape S = aMesh->IndexToShape( pos->GetShapeId() ); + Handle(Geom2d_Curve) pcurve; + if ( !S.IsNull() && S.ShapeType() == TopAbs_EDGE ) + pcurve = BRep_Tool::CurveOnSurface( TopoDS::Edge( S ), face, f,l ); + if ( !pcurve.IsNull() ) { + double u = (( SMDS_EdgePosition* ) pos.get() )->GetUParameter(); + uv = pcurve->Value( u ).XY(); + } + break; + } + case SMDS_TOP_VERTEX: { + TopoDS_Shape S = aMesh->IndexToShape( pos->GetShapeId() ); + if ( !S.IsNull() && S.ShapeType() == TopAbs_VERTEX ) + uv = BRep_Tool::Parameters( TopoDS::Vertex( S ), face ).XY(); + break; + } + default:; + } + // check existing UV + bool project = true; + gp_Pnt pNode ( node->X(), node->Y(), node->Z() ); + double dist1 = DBL_MAX, dist2 = 0; + if ( posType != SMDS_TOP_3DSPACE ) { + dist1 = pNode.SquareDistance( surface->Value( uv.X(), uv.Y() )); + project = dist1 > fToler2; + } + if ( project ) { // compute new UV + gp_XY newUV; + if ( !getClosestUV( projector, pNode, newUV )) { + MESSAGE("Node Projection Failed " << node); + } + else { + if ( isUPeriodic ) + newUV.SetX( ElCLib::InPeriod( newUV.X(), u1, u2 )); + if ( isVPeriodic ) + newUV.SetY( ElCLib::InPeriod( newUV.Y(), v1, v2 )); + // check new UV + if ( posType != SMDS_TOP_3DSPACE ) + dist2 = pNode.SquareDistance( surface->Value( newUV.X(), newUV.Y() )); + if ( dist2 < dist1 ) + uv = newUV; + } + } + // store UV in the map + listUV.push_back( uv ); + uvMap.insert( make_pair( node, &listUV.back() )); + } + } // loop on not yet smoothed elements + + if ( !faceSubMesh || nbElemOnFace != faceSubMesh->NbElements() ) + checkBoundaryNodes = true; + + // fix nodes on mesh boundary + + if ( checkBoundaryNodes ) + { + typedef pair TLink; + map< TLink, int > linkNbMap; // how many times a link encounters in elemsOnFace + map< TLink, int >::iterator link_nb; + // put all elements links to linkNbMap + list< const SMDS_MeshElement* >::iterator elemIt = elemsOnFace.begin(); + for ( ; elemIt != elemsOnFace.end(); ++elemIt ) + { + // put elem nodes in array + vector< const SMDS_MeshNode* > nodes; + nodes.reserve( (*elemIt)->NbNodes() + 1 ); + SMDS_ElemIteratorPtr itN = (*elemIt)->nodesIterator(); + while ( itN->more() ) + nodes.push_back( static_cast( itN->next() )); + nodes.push_back( nodes.front() ); + // loop on elem links: insert them in linkNbMap + for ( int iN = 1; iN < nodes.size(); ++iN ) { + TLink link; + if ( nodes[ iN-1 ]->GetID() < nodes[ iN ]->GetID() ) + link = make_pair( nodes[ iN-1 ], nodes[ iN ] ); + else + link = make_pair( nodes[ iN ], nodes[ iN-1 ] ); + link_nb = linkNbMap.find( link ); + if ( link_nb == linkNbMap.end() ) + linkNbMap.insert( make_pair ( link, 1 )); + else + link_nb->second++; + } + } + // remove nodes that are in links encountered only once from setMovableNodes + for ( link_nb = linkNbMap.begin(); link_nb != linkNbMap.end(); ++link_nb ) { + if ( link_nb->second == 1 ) { + setMovableNodes.erase( link_nb->first.first ); + setMovableNodes.erase( link_nb->first.second ); + } + } + } + + // ----------------------------------------------------- + // for nodes on seam edge, compute one more UV ( uvMap2 ); + // find movable nodes linked to nodes on seam and which + // are to be smoothed using the second UV ( uvMap2 ) + // ----------------------------------------------------- + + set nodesNearSeam; // to smooth using uvMap2 + if ( !surface.IsNull() ) + { + TopExp_Explorer eExp( face, TopAbs_EDGE ); + for ( ; eExp.More(); eExp.Next() ) + { + TopoDS_Edge edge = TopoDS::Edge( eExp.Current() ); + if ( !BRep_Tool::IsClosed( edge, face )) + continue; + SMESHDS_SubMesh* sm = aMesh->MeshElements( edge ); + if ( !sm ) continue; + // find out which parameter varies for a node on seam + double f,l; + gp_Pnt2d uv1, uv2; + Handle(Geom2d_Curve) pcurve = BRep_Tool::CurveOnSurface( edge, face, f, l ); + if ( pcurve.IsNull() ) continue; + uv1 = pcurve->Value( f ); + edge.Reverse(); + pcurve = BRep_Tool::CurveOnSurface( edge, face, f, l ); + if ( pcurve.IsNull() ) continue; + uv2 = pcurve->Value( f ); + int iPar = Abs( uv1.X() - uv2.X() ) > Abs( uv1.Y() - uv2.Y() ) ? 1 : 2; + // assure uv1 < uv2 + if ( uv1.Coord( iPar ) > uv2.Coord( iPar )) { + gp_Pnt2d tmp = uv1; uv1 = uv2; uv2 = tmp; + } + // get nodes on seam and its vertices + list< const SMDS_MeshNode* > seamNodes; + SMDS_NodeIteratorPtr nSeamIt = sm->GetNodes(); + while ( nSeamIt->more() ) + seamNodes.push_back( nSeamIt->next() ); + TopExp_Explorer vExp( edge, TopAbs_VERTEX ); + for ( ; vExp.More(); vExp.Next() ) { + sm = aMesh->MeshElements( vExp.Current() ); + if ( sm ) { + nSeamIt = sm->GetNodes(); + while ( nSeamIt->more() ) + seamNodes.push_back( nSeamIt->next() ); + } + } + // loop on nodes on seam + list< const SMDS_MeshNode* >::iterator noSeIt = seamNodes.begin(); + for ( ; noSeIt != seamNodes.end(); ++noSeIt ) + { + const SMDS_MeshNode* nSeam = *noSeIt; + map< const SMDS_MeshNode*, gp_XY* >::iterator n_uv = uvMap.find( nSeam ); + if ( n_uv == uvMap.end() ) + continue; + // set the first UV + n_uv->second->SetCoord( iPar, uv1.Coord( iPar )); + // set the second UV + listUV.push_back( *n_uv->second ); + listUV.back().SetCoord( iPar, uv2.Coord( iPar )); + if ( uvMap2.empty() ) + uvMap2 = uvMap; // copy the uvMap contents + uvMap2[ nSeam ] = &listUV.back(); + + // collect movable nodes linked to ones on seam in nodesNearSeam + SMDS_ElemIteratorPtr eIt = nSeam->GetInverseElementIterator(); + while ( eIt->more() ) + { + const SMDS_MeshElement* e = eIt->next(); + if ( e->GetType() != SMDSAbs_Face ) + continue; + int nbUseMap1 = 0, nbUseMap2 = 0; + SMDS_ElemIteratorPtr nIt = e->nodesIterator(); + while ( nIt->more() ) + { + const SMDS_MeshNode* n = + static_cast( nIt->next() ); + if (n == nSeam || + setMovableNodes.find( n ) == setMovableNodes.end() ) + continue; + // add only nodes being closer to uv2 than to uv1 + gp_Pnt pMid (0.5 * ( n->X() + nSeam->X() ), + 0.5 * ( n->Y() + nSeam->Y() ), + 0.5 * ( n->Z() + nSeam->Z() )); + gp_XY uv; + getClosestUV( projector, pMid, uv ); + if ( uv.Coord( iPar ) > uvMap[ n ]->Coord( iPar ) ) { + nodesNearSeam.insert( n ); + nbUseMap2++; + } + else + nbUseMap1++; + } + // for centroidalSmooth all element nodes must + // be on one side of a seam + if ( theSmoothMethod == CENTROIDAL && nbUseMap1 && nbUseMap2 ) + { + SMDS_ElemIteratorPtr nIt = e->nodesIterator(); + while ( nIt->more() ) { + const SMDS_MeshNode* n = + static_cast( nIt->next() ); + setMovableNodes.erase( n ); + } + } + } + } // loop on nodes on seam + } // loop on edge of a face + } // if ( !face.IsNull() ) + + if ( setMovableNodes.empty() ) { + MESSAGE( "Face id : " << *fId << " - NO SMOOTHING: no nodes to move!!!"); + continue; // goto next face + } + + // ------------- + // SMOOTHING // + // ------------- + + int it = -1; + double maxRatio = -1., maxDisplacement = -1.; + set::iterator nodeToMove; + for ( it = 0; it < theNbIterations; it++ ) + { + maxDisplacement = 0.; + nodeToMove = setMovableNodes.begin(); + for ( ; nodeToMove != setMovableNodes.end(); nodeToMove++ ) + { + const SMDS_MeshNode* node = (*nodeToMove); + gp_XYZ aPrevPos ( node->X(), node->Y(), node->Z() ); + + // smooth + bool map2 = ( nodesNearSeam.find( node ) != nodesNearSeam.end() ); + if ( theSmoothMethod == LAPLACIAN ) + laplacianSmooth( node, surface, map2 ? uvMap2 : uvMap ); + else + centroidalSmooth( node, surface, map2 ? uvMap2 : uvMap ); + + // node displacement + gp_XYZ aNewPos ( node->X(), node->Y(), node->Z() ); + Standard_Real aDispl = (aPrevPos - aNewPos).SquareModulus(); + if ( aDispl > maxDisplacement ) + maxDisplacement = aDispl; + } + // no node movement => exit + if ( maxDisplacement < 1.e-16 ) { + MESSAGE("-- no node movement --"); + break; + } + + // check elements quality + maxRatio = 0; + list< const SMDS_MeshElement* >::iterator elemIt = elemsOnFace.begin(); + for ( ; elemIt != elemsOnFace.end(); ++elemIt ) + { + const SMDS_MeshElement* elem = (*elemIt); + if ( !elem || elem->GetType() != SMDSAbs_Face ) + continue; + SMESH::Controls::TSequenceOfXYZ aPoints; + if ( aQualityFunc.GetPoints( elem, aPoints )) { + double aValue = aQualityFunc.GetValue( aPoints ); + if ( aValue > maxRatio ) + maxRatio = aValue; + } + } + if ( maxRatio <= theTgtAspectRatio ) { + MESSAGE("-- quality achived --"); + break; + } + if (it+1 == theNbIterations) { + MESSAGE("-- Iteration limit exceeded --"); + } + } // smoothing iterations + + MESSAGE(" Face id: " << *fId << + " Nb iterstions: " << it << + " Displacement: " << maxDisplacement << + " Aspect Ratio " << maxRatio); + + // --------------------------------------- + // new nodes positions are computed, + // record movement in DS and set new UV + // --------------------------------------- + + nodeToMove = setMovableNodes.begin(); + for ( ; nodeToMove != setMovableNodes.end(); nodeToMove++ ) + { + SMDS_MeshNode* node = const_cast< SMDS_MeshNode* > (*nodeToMove); + aMesh->MoveNode( node, node->X(), node->Y(), node->Z() ); + map< const SMDS_MeshNode*, gp_XY* >::iterator node_uv = uvMap.find( node ); + if ( node_uv != uvMap.end() ) { + gp_XY* uv = node_uv->second; + node->SetPosition + ( SMDS_PositionPtr( new SMDS_FacePosition( *fId, uv->X(), uv->Y() ))); + } + } + + } // loop on face ids } //======================================================================= @@ -1593,6 +2025,8 @@ static void sweepElement(SMESHDS_Mesh* aMesh, SMDS_MeshElement* aNewElem = 0; switch ( nbNodes ) { + case 0: + return; case 1: { // NODE if ( nbSame == 0 ) aNewElem = aMesh->AddEdge( prevNod[ 0 ], nextNod[ 0 ] ); @@ -1615,8 +2049,8 @@ static void sweepElement(SMESHDS_Mesh* aMesh, nextNod[ i0 ], nextNod[ 1 ], nextNod[ i2 ] ); else if ( nbSame == 1 ) // --- pyramid - aNewElem = aMesh->AddVolume (prevNod[ iBeforeSame ], prevNod[ iAfterSame ], - nextNod[ iAfterSame ], nextNod[ iBeforeSame ], + aNewElem = aMesh->AddVolume (prevNod[ iBeforeSame ], prevNod[ iAfterSame ], + nextNod[ iAfterSame ], nextNod[ iBeforeSame ], nextNod[ iSameNode ]); else // 2 same nodes: --- tetrahedron @@ -1632,12 +2066,12 @@ static void sweepElement(SMESHDS_Mesh* aMesh, else if ( nbSame == 1 ) // --- pyramid + pentahedron { - aNewElem = aMesh->AddVolume (prevNod[ iBeforeSame ], prevNod[ iAfterSame ], - nextNod[ iAfterSame ], nextNod[ iBeforeSame ], + aNewElem = aMesh->AddVolume (prevNod[ iBeforeSame ], prevNod[ iAfterSame ], + nextNod[ iAfterSame ], nextNod[ iBeforeSame ], nextNod[ iSameNode ]); newElems.push_back( aNewElem ); - aNewElem = aMesh->AddVolume (prevNod[ iAfterSame ], prevNod[ iOpposSame ], - prevNod[ iBeforeSame ], nextNod[ iAfterSame ], + aNewElem = aMesh->AddVolume (prevNod[ iAfterSame ], prevNod[ iOpposSame ], + prevNod[ iBeforeSame ], nextNod[ iAfterSame ], nextNod[ iOpposSame ], nextNod[ iBeforeSame ] ); } else if ( nbSame == 2 ) // pentahedron @@ -1645,18 +2079,41 @@ static void sweepElement(SMESHDS_Mesh* aMesh, if ( prevNod[ iBeforeSame ] == nextNod[ iBeforeSame ] ) // iBeforeSame is same too aNewElem = aMesh->AddVolume (prevNod[ iBeforeSame ], prevNod[ iOpposSame ], - nextNod[ iOpposSame ], prevNod[ iSameNode ], + nextNod[ iOpposSame ], prevNod[ iSameNode ], prevNod[ iAfterSame ], nextNod[ iAfterSame ]); else // iAfterSame is same too - aNewElem = aMesh->AddVolume (prevNod[ iSameNode ], prevNod[ iBeforeSame ], + aNewElem = aMesh->AddVolume (prevNod[ iSameNode ], prevNod[ iBeforeSame ], nextNod[ iBeforeSame ], prevNod[ iAfterSame ], prevNod[ iOpposSame ], nextNod[ iOpposSame ]); } break; } - default: - return; + default: { + // realized for extrusion only + vector polyedre_nodes (nbNodes*2 + 4*nbNodes); + vector quantities (nbNodes + 2); + + quantities[0] = nbNodes; // bottom of prism + for (int inode = 0; inode < nbNodes; inode++) { + polyedre_nodes[inode] = prevNod[inode]; + } + + quantities[1] = nbNodes; // top of prism + for (int inode = 0; inode < nbNodes; inode++) { + polyedre_nodes[nbNodes + inode] = nextNod[inode]; + } + + for (int iface = 0; iface < nbNodes; iface++) { + quantities[iface + 2] = 4; + int inextface = (iface == nbNodes - 1) ? 0 : iface + 1; + polyedre_nodes[2*nbNodes + 4*iface + 0] = prevNod[iface]; + polyedre_nodes[2*nbNodes + 4*iface + 1] = prevNod[inextface]; + polyedre_nodes[2*nbNodes + 4*iface + 2] = nextNod[inextface]; + polyedre_nodes[2*nbNodes + 4*iface + 3] = nextNod[iface]; + } + aNewElem = aMesh->AddPolyhedralVolume (polyedre_nodes, quantities); + } } if ( aNewElem ) newElems.push_back( aNewElem ); @@ -1790,6 +2247,16 @@ static void makeWalls (SMESHDS_Mesh* aMesh, aMesh->AddFace( nodes[ 0 ], nodes[ 1 ], nodes[ 2 ] ); break; case 4: aMesh->AddFace( nodes[ 0 ], nodes[ 1 ], nodes[ 2 ], nodes[ 3 ] ); break; + default: + { + int nbPolygonNodes = vTool.NbFaceNodes( *ind ); + vector polygon_nodes (nbPolygonNodes); + for (int inode = 0; inode < nbPolygonNodes; inode++) { + polygon_nodes[inode] = nodes[inode]; + } + aMesh->AddPolygonalFace(polygon_nodes); + break; + } } } // go to the next volume @@ -1818,6 +2285,17 @@ static void makeWalls (SMESHDS_Mesh* aMesh, !aMesh->FindFace( nodes[ 0 ], nodes[ 1 ], nodes[ 2 ], nodes[ 3 ])) aMesh->AddFace( nodes[ 0 ], nodes[ 1 ], nodes[ 2 ], nodes[ 3 ] ); break; + default: + { + int nbPolygonNodes = lastVol.NbFaceNodes( iF ); + vector polygon_nodes (nbPolygonNodes); + for (int inode = 0; inode < nbPolygonNodes; inode++) { + polygon_nodes[inode] = nodes[inode]; + } + if (!hasFreeLinks || !aMesh->FindFace(polygon_nodes)) + aMesh->AddPolygonalFace(polygon_nodes); + } + break; } } @@ -2320,7 +2798,7 @@ void SMESH_MeshEditor::Transform (set & theElems, SMDS_ElemIteratorPtr itN = elem->nodesIterator(); while ( itN->more() ) { - // check if a node has been already transormed + // check if a node has been already transformed const SMDS_MeshNode* node = static_cast( itN->next() ); if (nodeMap.find( node ) != nodeMap.end() ) @@ -2334,8 +2812,12 @@ void SMESH_MeshEditor::Transform (set & theElems, const SMDS_MeshNode * newNode = node; if ( theCopy ) newNode = aMesh->AddNode( coord[0], coord[1], coord[2] ); - else + else { aMesh->MoveNode( node, coord[0], coord[1], coord[2] ); + // node position on shape becomes invalid + const_cast< SMDS_MeshNode* > ( node )->SetPosition + ( SMDS_SpacePosition::originSpacePosition() ); + } nodeMap.insert( TNodeNodeMap::value_type( node, newNode )); // keep inverse elements @@ -2386,6 +2868,82 @@ void SMESH_MeshEditor::Transform (set & theElems, int nbNodes = elem->NbNodes(); int elemType = elem->GetType(); + if (elem->IsPoly()) { + // Polygon or Polyhedral Volume + switch ( elemType ) { + case SMDSAbs_Face: + { + vector poly_nodes (nbNodes); + int iNode = 0; + SMDS_ElemIteratorPtr itN = elem->nodesIterator(); + while (itN->more()) { + const SMDS_MeshNode* node = + static_cast(itN->next()); + TNodeNodeMap::iterator nodeMapIt = nodeMap.find(node); + if (nodeMapIt == nodeMap.end()) + break; // not all nodes transformed + if (needReverse) { + // reverse mirrored faces and volumes + poly_nodes[nbNodes - iNode - 1] = (*nodeMapIt).second; + } else { + poly_nodes[iNode] = (*nodeMapIt).second; + } + iNode++; + } + if ( iNode != nbNodes ) + continue; // not all nodes transformed + + if ( theCopy ) { + aMesh->AddPolygonalFace(poly_nodes); + } else { + aMesh->ChangePolygonNodes(elem, poly_nodes); + } + } + break; + case SMDSAbs_Volume: + { + // ATTENTION: Reversing is not yet done!!! + const SMDS_PolyhedralVolumeOfNodes* aPolyedre = + (const SMDS_PolyhedralVolumeOfNodes*) elem; + if (!aPolyedre) { + MESSAGE("Warning: bad volumic element"); + continue; + } + + vector poly_nodes; + vector quantities; + + bool allTransformed = true; + int nbFaces = aPolyedre->NbFaces(); + for (int iface = 1; iface <= nbFaces && allTransformed; iface++) { + int nbFaceNodes = aPolyedre->NbFaceNodes(iface); + for (int inode = 1; inode <= nbFaceNodes && allTransformed; inode++) { + const SMDS_MeshNode* node = aPolyedre->GetFaceNode(iface, inode); + TNodeNodeMap::iterator nodeMapIt = nodeMap.find(node); + if (nodeMapIt == nodeMap.end()) { + allTransformed = false; // not all nodes transformed + } else { + poly_nodes.push_back((*nodeMapIt).second); + } + } + quantities.push_back(nbFaceNodes); + } + if ( !allTransformed ) + continue; // not all nodes transformed + + if ( theCopy ) { + aMesh->AddPolyhedralVolume(poly_nodes, quantities); + } else { + aMesh->ChangePolyhedronNodes(elem, poly_nodes, quantities); + } + } + break; + default:; + } + continue; + } + + // Regular elements int* i = index[ FORWARD ]; if ( needReverse && nbNodes > 2) // reverse mirrored faces and volumes if ( elemType == SMDSAbs_Face ) @@ -2498,6 +3056,88 @@ void SMESH_MeshEditor::FindCoincidentNodes (set & theNodes } } +//======================================================================= +//function : SimplifyFace +//purpose : +//======================================================================= +int SMESH_MeshEditor::SimplifyFace (const vector faceNodes, + vector& poly_nodes, + vector& quantities) const +{ + int nbNodes = faceNodes.size(); + + if (nbNodes < 3) + return 0; + + set nodeSet; + + // get simple seq of nodes + const SMDS_MeshNode* simpleNodes[ nbNodes ]; + int iSimple = 0, nbUnique = 0; + + simpleNodes[iSimple++] = faceNodes[0]; + nbUnique++; + for (int iCur = 1; iCur < nbNodes; iCur++) { + if (faceNodes[iCur] != simpleNodes[iSimple - 1]) { + simpleNodes[iSimple++] = faceNodes[iCur]; + if (nodeSet.insert( faceNodes[iCur] ).second) + nbUnique++; + } + } + int nbSimple = iSimple; + if (simpleNodes[nbSimple - 1] == simpleNodes[0]) { + nbSimple--; + iSimple--; + } + + if (nbUnique < 3) + return 0; + + // separate loops + int nbNew = 0; + bool foundLoop = (nbSimple > nbUnique); + while (foundLoop) { + foundLoop = false; + set loopSet; + for (iSimple = 0; iSimple < nbSimple && !foundLoop; iSimple++) { + const SMDS_MeshNode* n = simpleNodes[iSimple]; + if (!loopSet.insert( n ).second) { + foundLoop = true; + + // separate loop + int iC = 0, curLast = iSimple; + for (; iC < curLast; iC++) { + if (simpleNodes[iC] == n) break; + } + int loopLen = curLast - iC; + if (loopLen > 2) { + // create sub-element + nbNew++; + quantities.push_back(loopLen); + for (; iC < curLast; iC++) { + poly_nodes.push_back(simpleNodes[iC]); + } + } + // shift the rest nodes (place from the first loop position) + for (iC = curLast + 1; iC < nbSimple; iC++) { + simpleNodes[iC - loopLen] = simpleNodes[iC]; + } + nbSimple -= loopLen; + iSimple -= loopLen; + } + } // for (iSimple = 0; iSimple < nbSimple; iSimple++) + } // while (foundLoop) + + if (iSimple > 2) { + nbNew++; + quantities.push_back(iSimple); + for (int i = 0; i < iSimple; i++) + poly_nodes.push_back(simpleNodes[i]); + } + + return nbNew; +} + //======================================================================= //function : MergeNodes //purpose : In each group, the cdr of nodes are substituted by the first one @@ -2572,6 +3212,88 @@ void SMESH_MeshEditor::MergeNodes (TListOfListOfNodes & theGroupsOfNodes) int nbUniqueNodes = nodeSet.size(); if ( nbNodes != nbUniqueNodes ) // some nodes stick { + // Polygons and Polyhedral volumes + if (elem->IsPoly()) { + + if (elem->GetType() == SMDSAbs_Face) { + // Polygon + vector face_nodes (nbNodes); + int inode = 0; + for (; inode < nbNodes; inode++) { + face_nodes[inode] = curNodes[inode]; + } + + vector polygons_nodes; + vector quantities; + int nbNew = SimplifyFace(face_nodes, polygons_nodes, quantities); + + if (nbNew > 0) { + inode = 0; + for (int iface = 0; iface < nbNew - 1; iface++) { + int nbNodes = quantities[iface]; + vector poly_nodes (nbNodes); + for (int ii = 0; ii < nbNodes; ii++, inode++) { + poly_nodes[ii] = polygons_nodes[inode]; + } + SMDS_MeshElement* newElem = aMesh->AddPolygonalFace(poly_nodes); + if (aShapeId) + aMesh->SetMeshElementOnShape(newElem, aShapeId); + } + aMesh->ChangeElementNodes(elem, &polygons_nodes[inode], quantities[nbNew - 1]); + } else { + rmElemIds.push_back(elem->GetID()); + } + + } else if (elem->GetType() == SMDSAbs_Volume) { + // Polyhedral volume + if (nbUniqueNodes < 4) { + rmElemIds.push_back(elem->GetID()); + } else { + // each face has to be analized in order to check volume validity + const SMDS_PolyhedralVolumeOfNodes* aPolyedre = + static_cast( elem ); + if (aPolyedre) { + int nbFaces = aPolyedre->NbFaces(); + + vector poly_nodes; + vector quantities; + + for (int iface = 1; iface <= nbFaces; iface++) { + int nbFaceNodes = aPolyedre->NbFaceNodes(iface); + vector faceNodes (nbFaceNodes); + + for (int inode = 1; inode <= nbFaceNodes; inode++) { + const SMDS_MeshNode * faceNode = aPolyedre->GetFaceNode(iface, inode); + TNodeNodeMap::iterator nnIt = nodeNodeMap.find(faceNode); + if (nnIt != nodeNodeMap.end()) { // faceNode sticks + faceNode = (*nnIt).second; + } + faceNodes[inode - 1] = faceNode; + } + + SimplifyFace(faceNodes, poly_nodes, quantities); + } + + if (quantities.size() > 3) { + // to be done: remove coincident faces + } + + if (quantities.size() > 3) + aMesh->ChangePolyhedronNodes(elem, poly_nodes, quantities); + else + rmElemIds.push_back(elem->GetID()); + + } else { + rmElemIds.push_back(elem->GetID()); + } + } + } else { + } + + continue; + } + + // Regular elements switch ( nbNodes ) { case 2: ///////////////////////////////////// EDGE isOk = false; break; @@ -2813,10 +3535,41 @@ void SMESH_MeshEditor::MergeNodes (TListOfListOfNodes & theGroupsOfNodes) } // if ( nbNodes != nbUniqueNodes ) // some nodes stick - if ( isOk ) - aMesh->ChangeElementNodes( elem, uniqueNodes, nbUniqueNodes ); - else + if ( isOk ) { + if (elem->IsPoly() && elem->GetType() == SMDSAbs_Volume) { + // Change nodes of polyedre + const SMDS_PolyhedralVolumeOfNodes* aPolyedre = + static_cast( elem ); + if (aPolyedre) { + int nbFaces = aPolyedre->NbFaces(); + + vector poly_nodes; + vector quantities (nbFaces); + + for (int iface = 1; iface <= nbFaces; iface++) { + int inode, nbFaceNodes = aPolyedre->NbFaceNodes(iface); + quantities[iface - 1] = nbFaceNodes; + + for (inode = 1; inode <= nbFaceNodes; inode++) { + const SMDS_MeshNode* curNode = aPolyedre->GetFaceNode(iface, inode); + + TNodeNodeMap::iterator nnIt = nodeNodeMap.find( curNode ); + if (nnIt != nodeNodeMap.end()) { // curNode sticks + curNode = (*nnIt).second; + } + poly_nodes.push_back(curNode); + } + } + aMesh->ChangePolyhedronNodes( elem, poly_nodes, quantities ); + } + } else { + // Change regular element or polygon + aMesh->ChangeElementNodes( elem, uniqueNodes, nbUniqueNodes ); + } + } else { + // Remove invalid regular element or invalid polygon rmElemIds.push_back( elem->GetID() ); + } } // loop on elements @@ -3091,7 +3844,9 @@ SMESH_MeshEditor::Sew_Error const SMDS_MeshNode* theSideFirstNode, const SMDS_MeshNode* theSideSecondNode, const SMDS_MeshNode* theSideThirdNode, - bool theSideIsFreeBorder) + const bool theSideIsFreeBorder, + const bool toCreatePolygons, + const bool toCreatePolyedrs) { MESSAGE("::SewFreeBorder()"); Sew_Error aResult = SEW_OK; @@ -3202,7 +3957,7 @@ SMESH_MeshEditor::Sew_Error LinkID_Gen aLinkID_Gen( GetMeshDS() ); set foundSideLinkIDs, checkedLinkIDs; SMDS_VolumeTool volume; - const SMDS_MeshNode* faceNodes[ 4 ]; + //const SMDS_MeshNode* faceNodes[ 4 ]; const SMDS_MeshNode* sideNode; const SMDS_MeshElement* sideElem; @@ -3230,6 +3985,7 @@ SMESH_MeshEditor::Sew_Error const SMDS_MeshElement* elem = invElemIt->next(); // prepare data for a loop on links, of a face or a volume int iPrevNode, iNode = 0, nbNodes = elem->NbNodes(); + const SMDS_MeshNode* faceNodes[ nbNodes ]; bool isVolume = volume.Set( elem ); const SMDS_MeshNode** nodes = isVolume ? volume.GetNodes() : faceNodes; if ( isVolume ) // --volume @@ -3313,7 +4069,7 @@ SMESH_MeshEditor::Sew_Error } while ( sideNode != theSideSecondNode ); - if ( hasVolumes && sideNodes.size () != bordNodes.size() ) { + if ( hasVolumes && sideNodes.size () != bordNodes.size() && !toCreatePolyedrs) { MESSAGE("VOLUME SPLITTING IS FORBIDDEN"); return SEW_VOLUMES_TO_SPLIT; // volume splitting is forbidden } @@ -3437,15 +4193,19 @@ SMESH_MeshEditor::Sew_Error list & nodeList = (*insertMapIt).second; const SMDS_MeshNode* n12 = nodeList.front(); nodeList.pop_front(); const SMDS_MeshNode* n22 = nodeList.front(); nodeList.pop_front(); - InsertNodesIntoLink( elem, n12, n22, nodeList ); + InsertNodesIntoLink( elem, n12, n22, nodeList, toCreatePolygons ); // 2. perform insertion into the link of adjacent faces while (true) { const SMDS_MeshElement* adjElem = findAdjacentFace( n12, n22, elem ); if ( adjElem ) - InsertNodesIntoLink( adjElem, n12, n22, nodeList ); + InsertNodesIntoLink( adjElem, n12, n22, nodeList, toCreatePolygons ); else break; } + if (toCreatePolyedrs) { + // perform insertion into the links of adjacent volumes + UpdateVolumes(n12, n22, nodeList); + } // 3. find an element appeared on n1 and n2 after the insertion insertMap.erase( elem ); elem = findAdjacentFace( n1, n2, 0 ); @@ -3485,18 +4245,22 @@ SMESH_MeshEditor::Sew_Error const SMDS_MeshNode* n1 = nodeList.front(); nodeList.pop_front(); const SMDS_MeshNode* n2 = nodeList.front(); nodeList.pop_front(); - InsertNodesIntoLink( elem, n1, n2, nodeList ); + InsertNodesIntoLink( elem, n1, n2, nodeList, toCreatePolygons ); if ( !theSideIsFreeBorder ) { // look for and insert nodes into the faces adjacent to elem while (true) { const SMDS_MeshElement* adjElem = findAdjacentFace( n1, n2, elem ); if ( adjElem ) - InsertNodesIntoLink( adjElem, n1, n2, nodeList ); + InsertNodesIntoLink( adjElem, n1, n2, nodeList, toCreatePolygons ); else break; } } + if (toCreatePolyedrs) { + // perform insertion into the links of adjacent volumes + UpdateVolumes(n1, n2, nodeList); + } } } // end: insert new nodes @@ -3515,14 +4279,15 @@ SMESH_MeshEditor::Sew_Error void SMESH_MeshEditor::InsertNodesIntoLink(const SMDS_MeshElement* theFace, const SMDS_MeshNode* theBetweenNode1, const SMDS_MeshNode* theBetweenNode2, - list& theNodesToInsert) + list& theNodesToInsert, + const bool toCreatePoly) { if ( theFace->GetType() != SMDSAbs_Face ) return; // find indices of 2 link nodes and of the rest nodes int iNode = 0, il1, il2, i3, i4; il1 = il2 = i3 = i4 = -1; - const SMDS_MeshNode* nodes[ 8 ]; + const SMDS_MeshNode* nodes[ theFace->NbNodes() ]; SMDS_ElemIteratorPtr nodeIt = theFace->nodesIterator(); while ( nodeIt->more() ) { const SMDS_MeshNode* n = static_cast( nodeIt->next() ); @@ -3541,11 +4306,12 @@ void SMESH_MeshEditor::InsertNodesIntoLink(const SMDS_MeshElement* theFace, // arrange link nodes to go one after another regarding the face orientation bool reverse = ( Abs( il2 - il1 ) == 1 ? il2 < il1 : il1 < il2 ); + list aNodesToInsert = theNodesToInsert; if ( reverse ) { iNode = il1; il1 = il2; il2 = iNode; - theNodesToInsert.reverse(); + aNodesToInsert.reverse(); } // check that not link nodes of a quadrangles are in good order int nbFaceNodes = theFace->NbNodes(); @@ -3555,13 +4321,59 @@ void SMESH_MeshEditor::InsertNodesIntoLink(const SMDS_MeshElement* theFace, i4 = iNode; } - // put theNodesToInsert between theBetweenNode1 and theBetweenNode2 - int nbLinkNodes = 2 + theNodesToInsert.size(); + if (toCreatePoly || theFace->IsPoly()) { + + iNode = 0; + vector poly_nodes (nbFaceNodes + aNodesToInsert.size()); + + // add nodes of face up to first node of link + bool isFLN = false; + nodeIt = theFace->nodesIterator(); + while ( nodeIt->more() && !isFLN ) { + const SMDS_MeshNode* n = static_cast( nodeIt->next() ); + poly_nodes[iNode++] = n; + if (n == nodes[il1]) { + isFLN = true; + } + } + + // add nodes to insert + list::iterator nIt = aNodesToInsert.begin(); + for (; nIt != aNodesToInsert.end(); nIt++) { + poly_nodes[iNode++] = *nIt; + } + + // add nodes of face starting from last node of link + while ( nodeIt->more() ) { + const SMDS_MeshNode* n = static_cast( nodeIt->next() ); + poly_nodes[iNode++] = n; + } + + // edit or replace the face + SMESHDS_Mesh *aMesh = GetMeshDS(); + + if (theFace->IsPoly()) { + aMesh->ChangePolygonNodes(theFace, poly_nodes); + + } else { + int aShapeId = FindShape( theFace ); + + SMDS_MeshElement* newElem = aMesh->AddPolygonalFace(poly_nodes); + if ( aShapeId && newElem ) + aMesh->SetMeshElementOnShape( newElem, aShapeId ); + + aMesh->RemoveElement(theFace); + } + return; + } + + // put aNodesToInsert between theBetweenNode1 and theBetweenNode2 + int nbLinkNodes = 2 + aNodesToInsert.size(); const SMDS_MeshNode* linkNodes[ nbLinkNodes ]; linkNodes[ 0 ] = nodes[ il1 ]; linkNodes[ nbLinkNodes - 1 ] = nodes[ il2 ]; - list::iterator nIt = theNodesToInsert.begin(); - for ( iNode = 1; nIt != theNodesToInsert.end(); nIt++ ) { + list::iterator nIt = aNodesToInsert.begin(); + for ( iNode = 1; nIt != aNodesToInsert.end(); nIt++ ) { linkNodes[ iNode++ ] = *nIt; } // decide how to split a quadrangle: compare possible variants @@ -3632,6 +4444,87 @@ void SMESH_MeshEditor::InsertNodesIntoLink(const SMDS_MeshElement* theFace, aMesh->ChangeElementNodes( theFace, newNodes, iSplit == iBestQuad ? 4 : 3 ); } +//======================================================================= +//function : UpdateVolumes +//purpose : +//======================================================================= +void SMESH_MeshEditor::UpdateVolumes (const SMDS_MeshNode* theBetweenNode1, + const SMDS_MeshNode* theBetweenNode2, + list& theNodesToInsert) +{ + SMDS_ElemIteratorPtr invElemIt = theBetweenNode1->GetInverseElementIterator(); + while (invElemIt->more()) { // loop on inverse elements of theBetweenNode1 + const SMDS_MeshElement* elem = invElemIt->next(); + if (elem->GetType() != SMDSAbs_Volume) + continue; + + // check, if current volume has link theBetweenNode1 - theBetweenNode2 + SMDS_VolumeTool aVolume (elem); + if (!aVolume.IsLinked(theBetweenNode1, theBetweenNode2)) + continue; + + // insert new nodes in all faces of the volume, sharing link theBetweenNode1 - theBetweenNode2 + int iface, nbFaces = aVolume.NbFaces(); + vector poly_nodes; + vector quantities (nbFaces); + + for (iface = 0; iface < nbFaces; iface++) { + int nbFaceNodes = aVolume.NbFaceNodes(iface), nbInserted = 0; + // faceNodes will contain (nbFaceNodes + 1) nodes, last = first + const SMDS_MeshNode** faceNodes = aVolume.GetFaceNodes(iface); + + for (int inode = 0; inode < nbFaceNodes; inode++) { + poly_nodes.push_back(faceNodes[inode]); + + if (nbInserted == 0) { + if (faceNodes[inode] == theBetweenNode1) { + if (faceNodes[inode + 1] == theBetweenNode2) { + nbInserted = theNodesToInsert.size(); + + // add nodes to insert + list::iterator nIt = theNodesToInsert.begin(); + for (; nIt != theNodesToInsert.end(); nIt++) { + poly_nodes.push_back(*nIt); + } + } + } else if (faceNodes[inode] == theBetweenNode2) { + if (faceNodes[inode + 1] == theBetweenNode1) { + nbInserted = theNodesToInsert.size(); + + // add nodes to insert in reversed order + list::iterator nIt = theNodesToInsert.end(); + nIt--; + for (; nIt != theNodesToInsert.begin(); nIt--) { + poly_nodes.push_back(*nIt); + } + poly_nodes.push_back(*nIt); + } + } else { + } + } + } + quantities[iface] = nbFaceNodes + nbInserted; + } + + // Replace or update the volume + SMESHDS_Mesh *aMesh = GetMeshDS(); + + if (elem->IsPoly()) { + aMesh->ChangePolyhedronNodes(elem, poly_nodes, quantities); + + } else { + int aShapeId = FindShape( elem ); + + SMDS_MeshElement* newElem = + aMesh->AddPolyhedralVolume(poly_nodes, quantities); + if (aShapeId && newElem) + aMesh->SetMeshElementOnShape(newElem, aShapeId); + + aMesh->RemoveElement(elem); + } + } +} + //======================================================================= //function : SewSideElements //purpose : @@ -3763,17 +4656,31 @@ SMESH_MeshEditor::Sew_Error bool isNewFace = setOfFaceNodeSet.insert( faceNodeSet ).second; if ( isNewFace ) { // no such a face is given but it still can exist, check it - if ( nbNodes == 3 ) + if ( nbNodes == 3 ) { aFreeFace = aMesh->FindFace( fNodes[0],fNodes[1],fNodes[2] ); - else + } else if ( nbNodes == 4 ) { aFreeFace = aMesh->FindFace( fNodes[0],fNodes[1],fNodes[2],fNodes[3] ); + } else { + vector poly_nodes (nbNodes); + for (int inode = 0; inode < nbNodes; inode++) { + poly_nodes[inode] = fNodes[inode]; + } + aFreeFace = aMesh->FindFace(poly_nodes); + } } if ( !aFreeFace ) { // create a temporary face - if ( nbNodes == 3 ) + if ( nbNodes == 3 ) { aFreeFace = aTmpFacesMesh.AddFace( fNodes[0],fNodes[1],fNodes[2] ); - else + } else if ( nbNodes == 4 ) { aFreeFace = aTmpFacesMesh.AddFace( fNodes[0],fNodes[1],fNodes[2],fNodes[3] ); + } else { + vector poly_nodes (nbNodes); + for (int inode = 0; inode < nbNodes; inode++) { + poly_nodes[inode] = fNodes[inode]; + } + aFreeFace = aTmpFacesMesh.AddPolygonalFace(poly_nodes); + } } if ( aFreeFace ) freeFaceList.push_back( aFreeFace ); diff --git a/src/SMESH/SMESH_MeshEditor.hxx b/src/SMESH/SMESH_MeshEditor.hxx index 677d9c033..0bb91f730 100644 --- a/src/SMESH/SMESH_MeshEditor.hxx +++ b/src/SMESH/SMESH_MeshEditor.hxx @@ -98,13 +98,16 @@ class SMESH_MeshEditor { std::set & theFixedNodes, const SmoothMethod theSmoothMethod, const int theNbIterations, - double theTgtAspectRatio = 1.0); + double theTgtAspectRatio = 1.0, + const bool the2D = true); // Smooth theElements using theSmoothMethod during theNbIterations // or until a worst element has aspect ratio <= theTgtAspectRatio. // Aspect Ratio varies in range [1.0, inf]. // If theElements is empty, the whole mesh is smoothed. // theFixedNodes contains additionally fixed nodes. Nodes built // on edges and boundary nodes are always fixed. + // If the2D, smoothing is performed using UV parameters of nodes + // on geometrical faces void RotationSweep (std::set & theElements, @@ -154,6 +157,12 @@ class SMESH_MeshEditor { // Return list of group of nodes close to each other within theTolerance. // Search among theNodes or in the whole mesh if theNodes is empty. + int SimplifyFace (const vector faceNodes, + vector& poly_nodes, + vector& quantities) const; + // Split face, defined by , into several faces by repeating nodes. + // Is used by MergeNodes() + void MergeNodes (TListOfListOfNodes & theNodeGroups); // In each group, the cdr of nodes are substituted by the first one // in all elements. @@ -189,7 +198,9 @@ class SMESH_MeshEditor { const SMDS_MeshNode* theSide2FirstNode, const SMDS_MeshNode* theSide2SecondNode, const SMDS_MeshNode* theSide2ThirdNode = 0, - bool theSide2IsFreeBorder = true); + const bool theSide2IsFreeBorder = true, + const bool toCreatePolygons = false, + const bool toCreatePolyedrs = false); // Sew the free border to the side2 by replacing nodes in // elements on the free border with nodes of the elements // of the side 2. If nb of links in the free border and @@ -226,20 +237,27 @@ class SMESH_MeshEditor { void InsertNodesIntoLink(const SMDS_MeshElement* theFace, const SMDS_MeshNode* theBetweenNode1, const SMDS_MeshNode* theBetweenNode2, - std::list& theNodesToInsert); - // insert theNodesToInsert into theFace between theBetweenNode1 - // and theBetweenNode2 and split theElement. + std::list& theNodesToInsert, + const bool toCreatePoly = false); + // insert theNodesToInsert into theFace between theBetweenNode1 and theBetweenNode2. + // If toCreatePoly is true, replace theFace by polygon, else split theFace. - static int SortQuadNodes (const SMDS_Mesh * theMesh, - int theNodeIds[] ); - // Set 4 nodes of a quadrangle face in a good order. - // Swap 1<->2 or 2<->3 nodes and correspondingly return - // 1 or 2 else 0. + void UpdateVolumes (const SMDS_MeshNode* theBetweenNode1, + const SMDS_MeshNode* theBetweenNode2, + std::list& theNodesToInsert); + // insert theNodesToInsert into all volumes, containing link + // theBetweenNode1 - theBetweenNode2, between theBetweenNode1 and theBetweenNode2. - static bool SortHexaNodes (const SMDS_Mesh * theMesh, - int theNodeIds[] ); - // Set 8 nodes of a hexahedron in a good order. - // Return success status +// static int SortQuadNodes (const SMDS_Mesh * theMesh, +// int theNodeIds[] ); +// // Set 4 nodes of a quadrangle face in a good order. +// // Swap 1<->2 or 2<->3 nodes and correspondingly return +// // 1 or 2 else 0. +// +// static bool SortHexaNodes (const SMDS_Mesh * theMesh, +// int theNodeIds[] ); +// // Set 8 nodes of a hexahedron in a good order. +// // Return success status static void AddToSameGroups (const SMDS_MeshElement* elemToAdd, const SMDS_MeshElement* elemInGroups, diff --git a/src/SMESH/SMESH_Pattern.cxx b/src/SMESH/SMESH_Pattern.cxx index 0aeffec35..fb9b5afc1 100644 --- a/src/SMESH/SMESH_Pattern.cxx +++ b/src/SMESH/SMESH_Pattern.cxx @@ -58,6 +58,7 @@ #include "SMDS_MeshElement.hxx" #include "SMDS_MeshFace.hxx" #include "SMDS_MeshNode.hxx" +#include "SMDS_VolumeTool.hxx" #include "SMESHDS_Group.hxx" #include "SMESHDS_Mesh.hxx" #include "SMESHDS_SubMesh.hxx" @@ -297,8 +298,8 @@ bool SMESH_Pattern::Load (const char* theFileContents) while ( readLine( fields, lineBeg, clearFields )) { - myElemPointIDs.push_back( list< int >() ); - list< int >& elemPoints = myElemPointIDs.back(); + myElemPointIDs.push_back( TElemDef() ); + TElemDef& elemPoints = myElemPointIDs.back(); for ( fIt = fields.begin(); fIt != fields.end(); fIt++ ) { int pointIndex = getInt( *fIt ); @@ -379,11 +380,11 @@ bool SMESH_Pattern::Save (ostream& theFile) } // elements theFile << "!!! Indices of points of " << myElemPointIDs.size() << " elements:" << endl; - list >::const_iterator epIt = myElemPointIDs.begin(); + list::const_iterator epIt = myElemPointIDs.begin(); for ( ; epIt != myElemPointIDs.end(); epIt++ ) { - const list< int > & elemPoints = *epIt; - list< int >::const_iterator iIt = elemPoints.begin(); + const TElemDef & elemPoints = *epIt; + TElemDef::const_iterator iIt = elemPoints.begin(); for ( ; iIt != elemPoints.end(); iIt++ ) theFile << " " << *iIt; theFile << endl; @@ -594,8 +595,8 @@ bool SMESH_Pattern::Load (SMESH_Mesh* theMesh, SMDS_FaceIteratorPtr fIt = aMeshDS->facesIterator(); while ( fIt->more() ) { - myElemPointIDs.push_back( list< int >() ); - list< int >& elemPoints = myElemPointIDs.back(); + myElemPointIDs.push_back( TElemDef() ); + TElemDef& elemPoints = myElemPointIDs.back(); SMDS_ElemIteratorPtr nIt = fIt->next()->nodesIterator(); while ( nIt->more() ) { @@ -814,8 +815,8 @@ bool SMESH_Pattern::Load (SMESH_Mesh* theMesh, SMDS_ElemIteratorPtr elemIt = fSubMesh->GetElements(); while ( elemIt->more() ) { SMDS_ElemIteratorPtr nIt = elemIt->next()->nodesIterator(); - myElemPointIDs.push_back( list< int >() ); - list< int >& elemPoints = myElemPointIDs.back(); + myElemPointIDs.push_back( TElemDef() ); + TElemDef& elemPoints = myElemPointIDs.back(); while ( nIt->more() ) elemPoints.push_back( nodePointIDMap[ nIt->next() ]); } @@ -2456,7 +2457,7 @@ bool SMESH_Pattern::Apply (const SMDS_MeshFace* theFace, const int theNodeIndexOnKeyPoint1, const bool theReverse) { - MESSAGE(" ::Apply(MeshFace) " ); +// MESSAGE(" ::Apply(MeshFace) " ); if ( !IsLoaded() ) { MESSAGE( "Pattern not loaded" ); @@ -2609,80 +2610,6 @@ inline static bool isDefined(const gp_XYZ& theXYZ) return theXYZ.X() < 1.e100; } -//======================================================================= -//function : mergePoints -//purpose : Look for coincident points between myXYZs indexed with -// list of each element of xyzIndGroups. Coincident indices -// are merged in myElemXYZIDs. -//======================================================================= - -void SMESH_Pattern::mergePoints (map > >& indGroups, - map< int, list< list< int >* > > & reverseConnectivity) -{ - map< TNodeSet, list< list< int > > >::iterator indListIt; - for ( indListIt = indGroups.begin(); indListIt != indGroups.end(); indListIt++ ) - { - list > groups = indListIt->second; - if ( groups.size() < 2 ) - continue; - -// const TNodeSet & nodes = indListIt->first; -// TNodeSet::const_iterator n = nodes.begin(); -// for ( ; n != nodes.end(); n++ ) -// cout << *n ; - - // find tolerance - Bnd_Box box; - list< int >& indices = groups.front(); - list< int >::iterator ind, ind1, ind2; - for ( ind = indices.begin(); ind != indices.end(); ind++ ) - box.Add( gp_Pnt( myXYZ[ *ind ])); - double x, y, z, X, Y, Z; - box.Get( x, y, z, X, Y, Z ); - gp_Pnt p( x, y, z ), P( X, Y, Z ); - double tol2 = 1.e-4 * p.SquareDistance( P ); - - // compare points, replace indices - - list< list< int > >::iterator grpIt1, grpIt2; - for ( grpIt1 = groups.begin(); grpIt1 != groups.end(); grpIt1++ ) - { - list< int >& indices1 = *grpIt1; - grpIt2 = grpIt1; - for ( grpIt2++; grpIt2 != groups.end(); grpIt2++ ) - { - list< int >& indices2 = *grpIt2; - for ( ind1 = indices1.begin(); ind1 != indices1.end(); ind1++ ) - { - gp_XYZ& p1 = myXYZ[ *ind1 ]; - ind2 = indices2.begin(); - while ( ind2 != indices2.end() ) - { - gp_XYZ& p2 = myXYZ[ *ind2 ]; - //MESSAGE("COMP: " << *ind1 << " " << *ind2 << " X: " << p2.X() << " tol2: " << tol2); - if ( ( p1 - p2 ).SquareModulus() <= tol2 ) - { - ASSERT( reverseConnectivity.find( *ind2 ) != reverseConnectivity.end() ); - list< list< int >* > & elemXYZIDsList = reverseConnectivity[ *ind2 ]; - list< list< int >* >::iterator elemXYZIDs = elemXYZIDsList.begin(); - for ( ; elemXYZIDs != elemXYZIDsList.end(); elemXYZIDs++ ) - { - ind = find( (*elemXYZIDs)->begin(), (*elemXYZIDs)->end(), *ind2 ); - //MESSAGE( " Replace " << *ind << " with " << *ind1 ); - myXYZ[ *ind ] = undefinedXYZ(); - *ind = *ind1; - } - ind2 = indices2.erase( ind2 ); - } - else - ind2++; - } - } - } - } - } -} - //======================================================================= //function : Apply //purpose : Compute nodes coordinates applying @@ -2690,9 +2617,9 @@ void SMESH_Pattern::mergePoints (map > >& indGroups, // will be mapped into -th node //======================================================================= -bool SMESH_Pattern::Apply (std::set theFaces, - const int theNodeIndexOnKeyPoint1, - const bool theReverse) +bool SMESH_Pattern::Apply (std::set& theFaces, + const int theNodeIndexOnKeyPoint1, + const bool theReverse) { MESSAGE(" ::Apply(set) " ); @@ -2710,10 +2637,13 @@ bool SMESH_Pattern::Apply (std::set theFaces, return setErrorCode( ERR_APPL_BAD_NB_VERTICES ); } + myShape.Nullify(); myXYZ.clear(); myElemXYZIDs.clear(); myXYZIdToNodeMap.clear(); myElements.clear(); + myIdsOnBoundary.clear(); + myReverseConnectivity.clear(); myXYZ.resize( myPoints.size() * theFaces.size(), undefinedXYZ() ); myElements.reserve( theFaces.size() ); @@ -2723,11 +2653,6 @@ bool SMESH_Pattern::Apply (std::set theFaces, for ( int i = 0; i < myPoints.size(); i++ ) pointIndex.insert( make_pair( & myPoints[ i ], i )); - // to merge nodes on edges of the elements being refined - typedef set TLink; - map< TLink, list< list< int > > > linkPointIndListMap; - map< int, list< list< int >* > > reverseConnectivity; - int ind1 = 0; // lowest point index for a face // apply to each face in theFaces set @@ -2741,37 +2666,45 @@ bool SMESH_Pattern::Apply (std::set theFaces, myElements.push_back( *face ); // store computed points belonging to elements - list< list< int > >::iterator ll = myElemPointIDs.begin(); + list< TElemDef >::iterator ll = myElemPointIDs.begin(); for ( ; ll != myElemPointIDs.end(); ++ll ) { - myElemXYZIDs.push_back(); - list< int >& xyzIds = myElemXYZIDs.back(); - list< int >& pIds = *ll; - for ( list::iterator id = pIds.begin(); id != pIds.end(); id++ ) { + myElemXYZIDs.push_back(TElemDef()); + TElemDef& xyzIds = myElemXYZIDs.back(); + TElemDef& pIds = *ll; + for ( TElemDef::iterator id = pIds.begin(); id != pIds.end(); id++ ) { int pIndex = *id + ind1; xyzIds.push_back( pIndex ); myXYZ[ pIndex ] = myPoints[ *id ].myXYZ.XYZ(); - reverseConnectivity[ pIndex ].push_back( & xyzIds ); + myReverseConnectivity[ pIndex ].push_back( & xyzIds ); } } - // put points on links to linkPointIndListMap + // put points on links to myIdsOnBoundary, + // they will be used to sew new elements on adjacent refined elements int nbNodes = (*face)->NbNodes(), eID = nbNodes + 1; for ( int i = 0; i < nbNodes; i++ ) { + list< TPoint* > & linkPoints = getShapePoints( eID++ ); const SMDS_MeshNode* n1 = myOrderedNodes[ i ]; const SMDS_MeshNode* n2 = myOrderedNodes[ i + 1 == nbNodes ? 0 : i + 1 ]; - // make a link of node pointers - TLink link; - link.insert( n1 ); - link.insert( n2 ); - // add the link to the map - list< list< int > >& groups = linkPointIndListMap[ link ]; - groups.push_back(); - list< int >& indList = groups.back(); - list< TPoint* > & linkPoints = getShapePoints( eID++ ); + // make a link and a node set + TNodeSet linkSet, node1Set; + linkSet.insert( n1 ); + linkSet.insert( n2 ); + node1Set.insert( n1 ); list< TPoint* >::iterator p = linkPoints.begin(); - // map the first link point to n1 - myXYZIdToNodeMap[ pointIndex[ *p ] + ind1 ] = n1; + { + // map the first link point to n1 + int nId = pointIndex[ *p ] + ind1; + myXYZIdToNodeMap[ nId ] = n1; + list< list< int > >& groups = myIdsOnBoundary[ node1Set ]; + groups.push_back(list< int > ()); + groups.back().push_back( nId ); + } + // add the linkSet to the map + list< list< int > >& groups = myIdsOnBoundary[ linkSet ]; + groups.push_back(list< int > ()); + list< int >& indList = groups.back(); // add points to the map excluding the end points for ( p++; *p != linkPoints.back(); p++ ) indList.push_back( pointIndex[ *p ] + ind1 ); @@ -2779,8 +2712,6 @@ bool SMESH_Pattern::Apply (std::set theFaces, ind1 += myPoints.size(); } - mergePoints( linkPointIndListMap, reverseConnectivity ); - return !myElemXYZIDs.empty(); } @@ -2793,9 +2724,9 @@ bool SMESH_Pattern::Apply (std::set theFaces, // node. //======================================================================= -bool SMESH_Pattern::Apply (std::set theVolumes, - const int theNode000Index, - const int theNode001Index) +bool SMESH_Pattern::Apply (std::set & theVolumes, + const int theNode000Index, + const int theNode001Index) { MESSAGE(" ::Apply(set) " ); @@ -2813,10 +2744,13 @@ bool SMESH_Pattern::Apply (std::set theVolumes, return setErrorCode( ERR_APPL_BAD_NB_VERTICES ); } + myShape.Nullify(); myXYZ.clear(); myElemXYZIDs.clear(); myXYZIdToNodeMap.clear(); myElements.clear(); + myIdsOnBoundary.clear(); + myReverseConnectivity.clear(); myXYZ.resize( myPoints.size() * theVolumes.size(), undefinedXYZ() ); myElements.reserve( theVolumes.size() ); @@ -2826,10 +2760,6 @@ bool SMESH_Pattern::Apply (std::set theVolumes, for ( int i = 0; i < myPoints.size(); i++ ) pointIndex.insert( make_pair( & myPoints[ i ], i )); - // to merge nodes on edges and faces of the elements being refined - map< TNodeSet, list< list< int > > > subPointIndListMap; - map< int, list< list< int >* > > reverseConnectivity; - int ind1 = 0; // lowest point index for an element // apply to each element in theVolumes set @@ -2843,27 +2773,28 @@ bool SMESH_Pattern::Apply (std::set theVolumes, myElements.push_back( *vol ); // store computed points belonging to elements - list< list< int > >::iterator ll = myElemPointIDs.begin(); + list< TElemDef >::iterator ll = myElemPointIDs.begin(); for ( ; ll != myElemPointIDs.end(); ++ll ) { - myElemXYZIDs.push_back(); - list< int >& xyzIds = myElemXYZIDs.back(); - list< int >& pIds = *ll; - for ( list::iterator id = pIds.begin(); id != pIds.end(); id++ ) { + myElemXYZIDs.push_back(TElemDef()); + TElemDef& xyzIds = myElemXYZIDs.back(); + TElemDef& pIds = *ll; + for ( TElemDef::iterator id = pIds.begin(); id != pIds.end(); id++ ) { int pIndex = *id + ind1; xyzIds.push_back( pIndex ); myXYZ[ pIndex ] = myPoints[ *id ].myXYZ.XYZ(); - reverseConnectivity[ pIndex ].push_back( & xyzIds ); + myReverseConnectivity[ pIndex ].push_back( & xyzIds ); } } - // put points on edges and faces to subPointIndListMap + // put points on edges and faces to myIdsOnBoundary, + // they will be used to sew new elements on adjacent refined elements for ( int Id = SMESH_Block::ID_V000; Id <= SMESH_Block::ID_F1yz; Id++ ) { // make a set of sub-points TNodeSet subNodes; vector< int > subIDs; if ( SMESH_Block::IsVertexID( Id )) { - // use nodes of refined volumes for merge + subNodes.insert( myOrderedNodes[ Id - 1 ]); } else if ( SMESH_Block::IsEdgeID( Id )) { SMESH_Block::GetEdgeVertexIDs( Id, subIDs ); @@ -2880,23 +2811,20 @@ bool SMESH_Pattern::Apply (std::set theVolumes, subNodes.insert( myOrderedNodes[ subIDs.front() - 1 ]); subNodes.insert( myOrderedNodes[ subIDs.back() - 1 ]); } - list< list< int > >& groups = subPointIndListMap[ subNodes ]; - groups.push_back(); - list< int >& indList = groups.back(); // add points list< TPoint* > & points = getShapePoints( Id ); list< TPoint* >::iterator p = points.begin(); - if ( subNodes.empty() ) // vertex case - myXYZIdToNodeMap[ pointIndex[ *p ] + ind1 ] = myOrderedNodes[ Id - 1 ]; - else - for ( ; p != points.end(); p++ ) - indList.push_back( pointIndex[ *p ] + ind1 ); + list< list< int > >& groups = myIdsOnBoundary[ subNodes ]; + groups.push_back(list< int > ()); + list< int >& indList = groups.back(); + for ( ; p != points.end(); p++ ) + indList.push_back( pointIndex[ *p ] + ind1 ); + if ( subNodes.size() == 1 ) // vertex case + myXYZIdToNodeMap[ indList.back() ] = myOrderedNodes[ Id - 1 ]; } ind1 += myPoints.size(); } - mergePoints( subPointIndListMap, reverseConnectivity ); - return !myElemXYZIDs.empty(); } @@ -3007,8 +2935,8 @@ bool SMESH_Pattern::Load (SMESH_Mesh* theMesh, SMDS_ElemIteratorPtr elemIt = aSubMesh->GetElements(); while ( elemIt->more() ) { SMDS_ElemIteratorPtr nIt = elemIt->next()->nodesIterator(); - myElemPointIDs.push_back( list< int >() ); - list< int >& elemPoints = myElemPointIDs.back(); + myElemPointIDs.push_back( TElemDef() ); + TElemDef& elemPoints = myElemPointIDs.back(); while ( nIt->more() ) elemPoints.push_back( nodePointIDMap[ nIt->next() ]); } @@ -3092,7 +3020,7 @@ bool SMESH_Pattern::Apply (const SMDS_MeshVolume* theVolume, const int theNode000Index, const int theNode001Index) { - MESSAGE(" ::Apply(MeshVolume) " ); + //MESSAGE(" ::Apply(MeshVolume) " ); if (!findBoundaryPoints()) // bind ID to points return false; @@ -3129,20 +3057,432 @@ bool SMESH_Pattern::Apply (const SMDS_MeshVolume* theVolume, return setErrorCode( ERR_OK ); } +//======================================================================= +//function : mergePoints +//purpose : Merge XYZ on edges and/or faces. +//======================================================================= + +void SMESH_Pattern::mergePoints (const bool uniteGroups) +{ + map< TNodeSet, list< list< int > > >::iterator idListIt = myIdsOnBoundary.begin(); + for ( ; idListIt != myIdsOnBoundary.end(); idListIt++ ) + { + list >& groups = idListIt->second; + if ( groups.size() < 2 ) + continue; + + // find tolerance + const TNodeSet& nodes = idListIt->first; + double tol2 = 1.e-10; + if ( nodes.size() > 1 ) { + Bnd_Box box; + TNodeSet::const_iterator n = nodes.begin(); + for ( ; n != nodes.end(); ++n ) + box.Add( gp_Pnt( (*n)->X(), (*n)->Y(), (*n)->Z() )); + double x, y, z, X, Y, Z; + box.Get( x, y, z, X, Y, Z ); + gp_Pnt p( x, y, z ), P( X, Y, Z ); + tol2 = 1.e-4 * p.SquareDistance( P ); + } + + // to unite groups on link + bool unite = ( uniteGroups && nodes.size() == 2 ); + map< double, int > distIndMap; + const SMDS_MeshNode* node = *nodes.begin(); + gp_Pnt P( node->X(), node->Y(), node->Z() ); + + // compare points, replace indices + + list< int >::iterator ind1, ind2; + list< list< int > >::iterator grpIt1, grpIt2; + for ( grpIt1 = groups.begin(); grpIt1 != groups.end(); grpIt1++ ) + { + list< int >& indices1 = *grpIt1; + grpIt2 = grpIt1; + for ( grpIt2++; grpIt2 != groups.end(); grpIt2++ ) + { + list< int >& indices2 = *grpIt2; + for ( ind1 = indices1.begin(); ind1 != indices1.end(); ind1++ ) + { + gp_XYZ& p1 = myXYZ[ *ind1 ]; + ind2 = indices2.begin(); + while ( ind2 != indices2.end() ) + { + gp_XYZ& p2 = myXYZ[ *ind2 ]; + //MESSAGE("COMP: " << *ind1 << " " << *ind2 << " X: " << p2.X() << " tol2: " << tol2); + if ( ( p1 - p2 ).SquareModulus() <= tol2 ) + { + ASSERT( myReverseConnectivity.find( *ind2 ) != myReverseConnectivity.end() ); + list< TElemDef* > & elemXYZIDsList = myReverseConnectivity[ *ind2 ]; + list< TElemDef* >::iterator elemXYZIDs = elemXYZIDsList.begin(); + for ( ; elemXYZIDs != elemXYZIDsList.end(); elemXYZIDs++ ) + { + //MESSAGE( " Replace " << *ind2 << " with " << *ind1 ); + myXYZ[ *ind2 ] = undefinedXYZ(); + replace( (*elemXYZIDs)->begin(), (*elemXYZIDs)->end(), *ind2, *ind1 ); + } + ind2 = indices2.erase( ind2 ); + } + else + ind2++; + } + } + } + if ( unite ) { // sort indices using distIndMap + for ( ind1 = indices1.begin(); ind1 != indices1.end(); ind1++ ) + { + ASSERT( isDefined( myXYZ[ *ind1 ] )); + double dist = P.SquareDistance( myXYZ[ *ind1 ]); + distIndMap.insert( make_pair( dist, *ind1 )); + } + } + } + if ( unite ) { // put all sorted indices into the first group + list< int >& g = groups.front(); + g.clear(); + map< double, int >::iterator dist_ind = distIndMap.begin(); + for ( ; dist_ind != distIndMap.end(); dist_ind++ ) + g.push_back( dist_ind->second ); + } + } // loop on myIdsOnBoundary +} + +//======================================================================= +//function : makePolyElements +//purpose : prepare intermediate data to create Polygons and Polyhedrons +//======================================================================= + +void SMESH_Pattern:: + makePolyElements(const vector< const SMDS_MeshNode* >& theNodes, + const bool toCreatePolygons, + const bool toCreatePolyedrs) +{ + myPolyElemXYZIDs.clear(); + myPolyElems.clear(); + myPolyElems.reserve( myIdsOnBoundary.size() ); + + // make a set of refined elements + set< const SMDS_MeshElement* > avoidSet, elemSet; + avoidSet.insert( myElements.begin(), myElements.end() ); + + map< TNodeSet, list< list< int > > >::iterator indListIt, nn_IdList; + + if ( toCreatePolygons ) + { + int lastFreeId = myXYZ.size(); + + // loop on links of refined elements + indListIt = myIdsOnBoundary.begin(); + for ( ; indListIt != myIdsOnBoundary.end(); indListIt++ ) + { + const TNodeSet & linkNodes = indListIt->first; + if ( linkNodes.size() != 2 ) + continue; // skip face + const SMDS_MeshNode* n1 = * linkNodes.begin(); + const SMDS_MeshNode* n2 = * linkNodes.rbegin(); + + list >& idGroups = indListIt->second; // ids of nodes to build + if ( idGroups.empty() || idGroups.front().empty() ) + continue; + + // find not refined face having n1-n2 link + + while (true) + { + const SMDS_MeshElement* face = + SMESH_MeshEditor::FindFaceInSet( n1, n2, elemSet, avoidSet ); + if ( face ) + { + avoidSet.insert ( face ); + myPolyElems.push_back( face ); + + // some links of are split; + // make list of xyz for + myPolyElemXYZIDs.push_back(TElemDef()); + TElemDef & faceNodeIds = myPolyElemXYZIDs.back(); + // loop on links of a + SMDS_ElemIteratorPtr nIt = face->nodesIterator(); + int i = 0, nbNodes = face->NbNodes(); + vector nodes( nbNodes + 1 ); + while ( nIt->more() ) + nodes[ i++ ] = static_cast( nIt->next() ); + nodes[ i ] = nodes[ 0 ]; + for ( i = 0; i < nbNodes; ++i ) + { + // look for point mapped on a link + TNodeSet faceLinkNodes; + faceLinkNodes.insert( nodes[ i ] ); + faceLinkNodes.insert( nodes[ i + 1 ] ); + if ( faceLinkNodes == linkNodes ) + nn_IdList = indListIt; + else + nn_IdList = myIdsOnBoundary.find( faceLinkNodes ); + // add face point ids + faceNodeIds.push_back( ++lastFreeId ); + myXYZIdToNodeMap.insert( make_pair( lastFreeId, nodes[ i ])); + if ( nn_IdList != myIdsOnBoundary.end() ) + { + // there are points mapped on a link + list< int >& mappedIds = nn_IdList->second.front(); + if ( isReversed( nodes[ i ], mappedIds )) + faceNodeIds.insert (faceNodeIds.end(),mappedIds.rbegin(), mappedIds.rend() ); + else + faceNodeIds.insert (faceNodeIds.end(),mappedIds.begin(), mappedIds.end() ); + } + } // loop on links of a + } // if ( face ) + else + break; + } // while (true) + + if ( myIs2D && idGroups.size() > 1 ) { + + // sew new elements on 2 refined elements sharing n1-n2 link + + list< int >& idsOnLink = idGroups.front(); + // temporarily add ids of link nodes to idsOnLink + bool rev = isReversed( n1, idsOnLink ); + for ( int i = 0; i < 2; ++i ) + { + TNodeSet nodeSet; + nodeSet.insert( i ? n2 : n1 ); + ASSERT( myIdsOnBoundary.find( nodeSet ) != myIdsOnBoundary.end() ); + list >& groups = myIdsOnBoundary[ nodeSet ]; + int nodeId = groups.front().front(); + bool append = i; + if ( rev ) append = !append; + if ( append ) + idsOnLink.push_back( nodeId ); + else + idsOnLink.push_front( nodeId ); + } + list< int >::iterator id = idsOnLink.begin(); + for ( ; id != idsOnLink.end(); ++id ) // loop on XYZ ids on a link + { + list< TElemDef* >& elemDefs = myReverseConnectivity[ *id ]; // elems sharing id + list< TElemDef* >::iterator pElemDef = elemDefs.begin(); + for ( ; pElemDef != elemDefs.end(); pElemDef++ ) // loop on elements sharing id + { + TElemDef* pIdList = *pElemDef; // ptr on list of ids making element up + // look for in element definition + TElemDef::iterator idDef = find( pIdList->begin(), pIdList->end(), *id ); + ASSERT ( idDef != pIdList->end() ); + // look for 2 neighbour ids of in element definition + for ( int prev = 0; prev < 2; ++prev ) { + TElemDef::iterator idDef2 = idDef; + if ( prev ) + idDef2 = ( idDef2 == pIdList->begin() ) ? --pIdList->end() : --idDef2; + else + idDef2 = ( ++idDef2 == pIdList->end() ) ? pIdList->begin() : idDef2; + // look for idDef2 on a link starting from id + list< int >::iterator id2 = find( id, idsOnLink.end(), *idDef2 ); + if ( id2 != idsOnLink.end() && id != --id2 ) { // found not next to id + // insert ids located on link between and + // into the element definition between idDef and idDef2 + if ( prev ) + for ( ; id2 != id; --id2 ) + pIdList->insert( idDef, *id2 ); + else { + list< int >::iterator id1 = id; + for ( ++id1, ++id2; id1 != id2; ++id1 ) + pIdList->insert( idDef2, *id1 ); + } + } + } + } + } + // remove ids of link nodes + idsOnLink.pop_front(); + idsOnLink.pop_back(); + } + } // loop on myIdsOnBoundary + } // if ( toCreatePolygons ) + + if ( toCreatePolyedrs ) + { + // check volumes adjacent to the refined elements + SMDS_VolumeTool volTool; + vector::iterator refinedElem = myElements.begin(); + for ( ; refinedElem != myElements.end(); ++refinedElem ) + { + // loop on nodes of refinedElem + SMDS_ElemIteratorPtr nIt = (*refinedElem)->nodesIterator(); + while ( nIt->more() ) { + const SMDS_MeshNode* node = static_cast( nIt->next() ); + // loop on inverse elements of node + SMDS_ElemIteratorPtr eIt = node->GetInverseElementIterator(); + while ( eIt->more() ) + { + const SMDS_MeshElement* elem = eIt->next(); + if ( !volTool.Set( elem ) || !avoidSet.insert( elem ).second ) + continue; // skip faces or refined elements + // add polyhedron definition + myPolyhedronQuantities.push_back(vector ()); + myPolyElemXYZIDs.push_back(TElemDef()); + vector& quantity = myPolyhedronQuantities.back(); + TElemDef & elemDef = myPolyElemXYZIDs.back(); + // get definitions of new elements on volume faces + bool makePoly = false; + for ( int iF = 0; iF < volTool.NbFaces(); ++iF ) + { + if ( getFacesDefinition(volTool.GetFaceNodes( iF ), + volTool.NbFaceNodes( iF ), + theNodes, elemDef, quantity)) + makePoly = true; + } + if ( makePoly ) + myPolyElems.push_back( elem ); + else { + myPolyhedronQuantities.pop_back(); + myPolyElemXYZIDs.pop_back(); + } + } + } + } + } +} + +//======================================================================= +//function : getFacesDefinition +//purpose : return faces definition for a volume face defined by theBndNodes +//======================================================================= + +bool SMESH_Pattern:: + getFacesDefinition(const SMDS_MeshNode** theBndNodes, + const int theNbBndNodes, + const vector< const SMDS_MeshNode* >& theNodes, + list< int >& theFaceDefs, + vector& theQuantity) +{ + bool makePoly = false; +// cout << "FROM FACE NODES: " < bndNodeSet; + for ( int i = 0; i < theNbBndNodes; ++i ) + bndNodeSet.insert( theBndNodes[ i ]); + + map< TNodeSet, list< list< int > > >::iterator nn_IdList; + + // make a set of all nodes on a face + set< int > ids; + if ( !myIs2D ) { // for 2D, merge only edges + nn_IdList = myIdsOnBoundary.find( bndNodeSet ); + if ( nn_IdList != myIdsOnBoundary.end() ) { + makePoly = true; + list< int > & faceIds = nn_IdList->second.front(); + ids.insert( faceIds.begin(), faceIds.end() ); + } + } + //bool hasIdsInFace = !ids.empty(); + + // add ids on links and bnd nodes + int lastFreeId = Max( myXYZIdToNodeMap.rbegin()->first, theNodes.size() ); + TElemDef faceDef; // definition for the case if there is no new adjacent volumes + for ( int iN = 0; iN < theNbBndNodes; ++iN ) + { + // add id of iN-th bnd node + TNodeSet nSet; + nSet.insert( theBndNodes[ iN ] ); + nn_IdList = myIdsOnBoundary.find( nSet ); + int bndId = ++lastFreeId; + if ( nn_IdList != myIdsOnBoundary.end() ) { + bndId = nn_IdList->second.front().front(); + ids.insert( bndId ); + } + else + myXYZIdToNodeMap.insert( make_pair( bndId, theBndNodes[ iN ] )); + faceDef.push_back( bndId ); + // add ids on a link + TNodeSet linkNodes; + linkNodes.insert( theBndNodes[ iN ]); + linkNodes.insert( theBndNodes[ iN + 1 == theNbBndNodes ? 0 : iN + 1 ]); + nn_IdList = myIdsOnBoundary.find( linkNodes ); + if ( nn_IdList != myIdsOnBoundary.end() ) { + makePoly = true; + list< int > & linkIds = nn_IdList->second.front(); + ids.insert( linkIds.begin(), linkIds.end() ); + if ( isReversed( theBndNodes[ iN ], linkIds )) + faceDef.insert( faceDef.end(), linkIds.begin(), linkIds.end() ); + else + faceDef.insert( faceDef.end(), linkIds.rbegin(), linkIds.rend() ); + } + } + + // find faces definition of new volumes + + bool defsAdded = false; + if ( !myIs2D ) { // for 2D, merge only edges + SMDS_VolumeTool vol; + set< TElemDef* > checkedVolDefs; + set< int >::iterator id = ids.begin(); + for ( ; id != ids.end(); ++id ) + { + // definitions of volumes sharing id + list< TElemDef* >& defList = myReverseConnectivity[ *id ]; + ASSERT( !defList.empty() ); + // loop on volume definitions + list< TElemDef* >::iterator pIdList = defList.begin(); + for ( ; pIdList != defList.end(); ++pIdList) + { + if ( !checkedVolDefs.insert( *pIdList ).second ) + continue; // skip already checked volume definition + vector< int > idVec; + idVec.reserve( (*pIdList)->size() ); + idVec.insert( idVec.begin(), (*pIdList)->begin(), (*pIdList)->end() ); + // loop on face defs of a volume + SMDS_VolumeTool::VolumeType volType = vol.GetType( idVec.size() ); + if ( volType == SMDS_VolumeTool::UNKNOWN ) + continue; + int nbFaces = vol.NbFaces( volType ); + for ( int iF = 0; iF < nbFaces; ++iF ) + { + const int* nodeInds = vol.GetFaceNodesIndices( volType, iF, true ); + int iN, nbN = vol.NbFaceNodes( volType, iF ); + // check if all nodes of a faces are in + bool all = true; + for ( iN = 0; iN < nbN && all; ++iN ) { + int nodeId = idVec[ nodeInds[ iN ]]; + all = ( ids.find( nodeId ) != ids.end() ); + } + if ( all ) { + // store a face definition + for ( iN = 0; iN < nbN; ++iN ) { + theFaceDefs.push_back( idVec[ nodeInds[ iN ]]); + } + theQuantity.push_back( nbN ); + defsAdded = true; + } + } + } + } + } + if ( !defsAdded ) { + theQuantity.push_back( faceDef.size() ); + theFaceDefs.splice( theFaceDefs.end(), faceDef, faceDef.begin(), faceDef.end() ); + } + + return makePoly; +} + //======================================================================= //function : MakeMesh //purpose : Create nodes and elements in using nodes // coordinates computed by either of Apply...() methods //======================================================================= -bool SMESH_Pattern::MakeMesh(SMESH_Mesh* theMesh) +bool SMESH_Pattern::MakeMesh(SMESH_Mesh* theMesh, + const bool toCreatePolygons, + const bool toCreatePolyedrs) { MESSAGE(" ::MakeMesh() " ); if ( !myIsComputed ) return setErrorCode( ERR_MAKEM_NOT_COMPUTED ); + mergePoints( toCreatePolygons ); + SMESHDS_Mesh* aMeshDS = theMesh->GetMeshDS(); - SMESH_MeshEditor editor( theMesh ); // clear elements and nodes existing on myShape @@ -3165,18 +3505,16 @@ bool SMESH_Pattern::MakeMesh(SMESH_Mesh* theMesh) bool onMeshElements = ( !myElements.empty() ); - // loop on sub-shapes of myShape: create nodes and build point-node map - - vector< const SMDS_MeshNode* > nodesVector; - map< TPoint*, const SMDS_MeshNode* > pointNodeMap; + vector< const SMDS_MeshNode* > nodesVector; // i-th point/xyz -> node if ( onMeshElements ) { - nodesVector.resize( myXYZ.size() ); + nodesVector.resize( Max( myXYZ.size(), myXYZIdToNodeMap.rbegin()->first ), 0 ); + map< int, const SMDS_MeshNode*>::iterator i_node = myXYZIdToNodeMap.begin(); + for ( ; i_node != myXYZIdToNodeMap.end(); i_node++ ) { + nodesVector[ i_node->first ] = i_node->second; + } for ( int i = 0; i < myXYZ.size(); ++i ) { - map< int, const SMDS_MeshNode*>::iterator idNode = myXYZIdToNodeMap.find( i ); - if ( idNode != myXYZIdToNodeMap.end() ) - nodesVector[ i ] = idNode->second; - else if ( isDefined( myXYZ[ i ] )) + if ( !nodesVector[ i ] && isDefined( myXYZ[ i ] ) ) nodesVector[ i ] = aMeshDS->AddNode (myXYZ[ i ].X(), myXYZ[ i ].Y(), myXYZ[ i ].Z()); @@ -3184,6 +3522,14 @@ bool SMESH_Pattern::MakeMesh(SMESH_Mesh* theMesh) } else { + nodesVector.resize( myPoints.size(), 0 ); + + // to find point index + map< TPoint*, int > pointIndex; + for ( int i = 0; i < myPoints.size(); i++ ) + pointIndex.insert( make_pair( & myPoints[ i ], i )); + + // loop on sub-shapes of myShape: create nodes map< int, list< TPoint* > >::iterator idPointIt = myShapeIDToPointsMap.begin(); for ( ; idPointIt != myShapeIDToPointsMap.end(); idPointIt++ ) { @@ -3198,12 +3544,14 @@ bool SMESH_Pattern::MakeMesh(SMESH_Mesh* theMesh) for ( ; pIt != points.end(); pIt++ ) { TPoint* point = *pIt; - if ( pointNodeMap.find( point ) != pointNodeMap.end() ) + int pIndex = pointIndex[ point ]; + if ( nodesVector [ pIndex ] ) continue; SMDS_MeshNode* node = aMeshDS->AddNode (point->myXYZ.X(), point->myXYZ.Y(), point->myXYZ.Z()); - pointNodeMap.insert( make_pair( point, node )); + nodesVector [ pIndex ] = node; + if ( subMeshDS ) { switch ( S.ShapeType() ) { case TopAbs_VERTEX: { @@ -3232,62 +3580,126 @@ bool SMESH_Pattern::MakeMesh(SMESH_Mesh* theMesh) } } } - + // create elements - // shapes and groups myElements are on - vector< int > shapeIDs; - vector< list< SMESHDS_Group* > > groups; if ( onMeshElements ) { - shapeIDs.resize( myElements.size() ); - groups.resize( myElements.size() ); + // prepare data to create poly elements + makePolyElements( nodesVector, toCreatePolygons, toCreatePolyedrs ); + + // refine elements + createElements( theMesh, nodesVector, myElemXYZIDs, myElements ); + // sew old and new elements + createElements( theMesh, nodesVector, myPolyElemXYZIDs, myPolyElems ); + } + else + { + createElements( theMesh, nodesVector, myElemPointIDs, myElements ); + } + +// const map& sm = aMeshDS->SubMeshes(); +// map::const_iterator i_sm = sm.begin(); +// for ( ; i_sm != sm.end(); i_sm++ ) +// { +// cout << " SM " << i_sm->first << " "; +// TopAbs::Print( aMeshDS->IndexToShape( i_sm->first ).ShapeType(), cout)<< " "; +// //SMDS_ElemIteratorPtr GetElements(); +// SMDS_NodeIteratorPtr nit = i_sm->second->GetNodes(); +// while ( nit->more() ) +// cout << nit->next()->GetID() << " "; +// cout << endl; +// } + return setErrorCode( ERR_OK ); +} + +//======================================================================= +//function : createElements +//purpose : add elements to the mesh +//======================================================================= + +void SMESH_Pattern::createElements(SMESH_Mesh* theMesh, + const vector& theNodesVector, + const list< TElemDef > & theElemNodeIDs, + const vector& theElements) +{ + SMESHDS_Mesh* aMeshDS = theMesh->GetMeshDS(); + SMESH_MeshEditor editor( theMesh ); + + bool onMeshElements = !theElements.empty(); + + // shapes and groups theElements are on + vector< int > shapeIDs; + vector< list< SMESHDS_Group* > > groups; + set< const SMDS_MeshNode* > shellNodes; + if ( onMeshElements ) + { + shapeIDs.resize( theElements.size() ); + groups.resize( theElements.size() ); const set& allGroups = aMeshDS->GetGroups(); set::const_iterator grIt; - for ( int i = 0; i < myElements.size(); i++ ) + for ( int i = 0; i < theElements.size(); i++ ) { - shapeIDs[ i ] = editor.FindShape( myElements[ i ] ); + shapeIDs[ i ] = editor.FindShape( theElements[ i ] ); for ( grIt = allGroups.begin(); grIt != allGroups.end(); grIt++ ) { SMESHDS_Group* group = dynamic_cast( *grIt ); - if ( group && group->SMDSGroup().Contains( myElements[ i ] )) + if ( group && group->SMDSGroup().Contains( theElements[ i ] )) groups[ i ].push_back( group ); } } + // get all nodes bound to shells because their SpacePosition is not set + // by SMESHDS_Mesh::SetNodeInVolume() + TopoDS_Shape aMainShape = aMeshDS->ShapeToMesh(); + if ( !aMainShape.IsNull() ) { + TopExp_Explorer shellExp( aMainShape, TopAbs_SHELL ); + for ( ; shellExp.More(); shellExp.Next() ) + { + SMESHDS_SubMesh * sm = aMeshDS->MeshElements( shellExp.Current() ); + if ( sm ) { + SMDS_NodeIteratorPtr nIt = sm->GetNodes(); + while ( nIt->more() ) + shellNodes.insert( nIt->next() ); + } + } + } } - int nbElems = myElemPointIDs.size(); // nb elements in a pattern + // nb new elements per a refined element + int nbNewElemsPerOld = 1; + if ( onMeshElements ) + nbNewElemsPerOld = theElemNodeIDs.size() / theElements.size(); - list >::iterator epIt, epEnd; - if ( onMeshElements ) { - epIt = myElemXYZIDs.begin(); - epEnd = myElemXYZIDs.end(); - } - else { - epIt = myElemPointIDs.begin(); - epEnd = myElemPointIDs.end(); - } - for ( int iElem = 0; epIt != epEnd; epIt++, iElem++ ) + bool is2d = myIs2D; + + list< TElemDef >::const_iterator enIt = theElemNodeIDs.begin(); + list< vector >::iterator quantity = myPolyhedronQuantities.begin(); + for ( int iElem = 0; enIt != theElemNodeIDs.end(); enIt++, iElem++ ) { - list< int > & elemPoints = *epIt; + const TElemDef & elemNodeInd = *enIt; // retrieve nodes - const SMDS_MeshNode* nodes[ 8 ]; - list< int >::iterator iIt = elemPoints.begin(); + vector< const SMDS_MeshNode* > nodes( elemNodeInd.size() ); + TElemDef::const_iterator id = elemNodeInd.begin(); int nbNodes; - for ( nbNodes = 0; iIt != elemPoints.end(); iIt++ ) { - if ( onMeshElements ) - nodes[ nbNodes++ ] = nodesVector[ *iIt ]; + for ( nbNodes = 0; id != elemNodeInd.end(); id++ ) { + if ( *id < theNodesVector.size() ) + nodes[ nbNodes++ ] = theNodesVector[ *id ]; else - nodes[ nbNodes++ ] = pointNodeMap[ & myPoints[ *iIt ]]; + nodes[ nbNodes++ ] = myXYZIdToNodeMap[ *id ]; + } + // dim of refined elem + int elemIndex = iElem / nbNewElemsPerOld; // refined element index + if ( onMeshElements ) { + is2d = ( theElements[ elemIndex ]->GetType() == SMDSAbs_Face ); } // add an element const SMDS_MeshElement* elem = 0; - if ( myIs2D ) { + if ( is2d ) { switch ( nbNodes ) { case 3: elem = aMeshDS->AddFace( nodes[0], nodes[1], nodes[2] ); break; case 4: elem = aMeshDS->AddFace( nodes[0], nodes[1], nodes[2], nodes[3] ); break; default: - ASSERT( nbNodes < 8 ); + elem = aMeshDS->AddPolygonalFace( nodes ); } } else { @@ -3304,13 +3716,12 @@ bool SMESH_Pattern::MakeMesh(SMESH_Mesh* theMesh) elem = aMeshDS->AddVolume (nodes[0], nodes[1], nodes[2], nodes[3], nodes[4], nodes[5], nodes[6], nodes[7] ); break; default: - ASSERT( nbNodes < 8 ); + elem = aMeshDS->AddPolyhedralVolume( nodes, *quantity++ ); } } // set element on a shape if ( elem && onMeshElements ) // applied to mesh elements { - int elemIndex = iElem / nbElems; int shapeID = shapeIDs[ elemIndex ]; if ( shapeID > 0 ) { aMeshDS->SetMeshElementOnShape( elem, shapeID ); @@ -3325,11 +3736,14 @@ bool SMESH_Pattern::MakeMesh(SMESH_Mesh* theMesh) while ( noIt->more() ) { SMDS_MeshNode* node = const_cast ( static_cast( noIt->next() )); - if ( !node->GetPosition() || !node->GetPosition()->GetShapeId() ) { + if (!node->GetPosition()->GetShapeId() && + shellNodes.find( node ) == shellNodes.end() ) { if ( S.ShapeType() == TopAbs_FACE ) aMeshDS->SetNodeOnFace( node, shapeID ); - else + else { aMeshDS->SetNodeInVolume( node, shapeID ); + shellNodes.insert( node ); + } } } } @@ -3342,7 +3756,7 @@ bool SMESH_Pattern::MakeMesh(SMESH_Mesh* theMesh) aMeshDS->SetMeshElementOnShape( elem, myShape ); } - // make that SMESH_subMesh::_computeState = COMPUTE_OK + // make that SMESH_subMesh::_computeState == COMPUTE_OK // so that operations with hypotheses will erase the mesh being built SMESH_subMesh * subMesh; @@ -3353,22 +3767,46 @@ bool SMESH_Pattern::MakeMesh(SMESH_Mesh* theMesh) } if ( onMeshElements ) { list< int > elemIDs; - for ( int i = 0; i < myElements.size(); i++ ) + for ( int i = 0; i < theElements.size(); i++ ) { - int shapeID = shapeIDs[ i ]; - if ( shapeID > 0 ) { - TopoDS_Shape S = aMeshDS->IndexToShape( shapeID ); - subMesh = theMesh->GetSubMeshContaining( S ); - if ( subMesh ) - subMesh->ComputeStateEngine( SMESH_subMesh::CHECK_COMPUTE_STATE ); - } - elemIDs.push_back( myElements[ i ]->GetID() ); + subMesh = theMesh->GetSubMeshContaining( shapeIDs[ i ] ); + if ( subMesh ) + subMesh->ComputeStateEngine( SMESH_subMesh::CHECK_COMPUTE_STATE ); + + elemIDs.push_back( theElements[ i ]->GetID() ); } // remove refined elements editor.Remove( elemIDs, false ); } +} - return setErrorCode( ERR_OK ); +//======================================================================= +//function : isReversed +//purpose : check xyz ids order in theIdsList taking into account +// theFirstNode on a link +//======================================================================= + +bool SMESH_Pattern::isReversed(const SMDS_MeshNode* theFirstNode, + const list< int >& theIdsList) const +{ + if ( theIdsList.size() < 2 ) + return false; + + gp_Pnt Pf ( theFirstNode->X(), theFirstNode->Y(), theFirstNode->Z() ); + gp_Pnt P[2]; + list::const_iterator id = theIdsList.begin(); + for ( int i = 0; i < 2; ++i, ++id ) { + if ( *id < myXYZ.size() ) + P[ i ] = myXYZ[ *id ]; + else { + map< int, const SMDS_MeshNode*>::const_iterator i_n; + i_n = myXYZIdToNodeMap.find( *id ); + ASSERT( i_n != myXYZIdToNodeMap.end() ); + const SMDS_MeshNode* n = i_n->second; + P[ i ].SetCoord( n->X(), n->Y(), n->Z() ); + } + } + return Pf.SquareDistance( P[ 1 ] ) < Pf.SquareDistance( P[ 0 ] ); } @@ -3539,11 +3977,11 @@ bool SMESH_Pattern::findBoundaryPoints() typedef pair< TPoint*, TPoint*> TLink; set< TLink > linkSet; - list >::iterator epIt = myElemPointIDs.begin(); + list::iterator epIt = myElemPointIDs.begin(); for ( ; epIt != myElemPointIDs.end(); epIt++ ) { - list< int > & elemPoints = *epIt; - list< int >::iterator pIt = elemPoints.begin(); + TElemDef & elemPoints = *epIt; + TElemDef::iterator pIt = elemPoints.begin(); int prevP = elemPoints.back(); for ( ; pIt != elemPoints.end(); pIt++ ) { TPoint* p1 = & myPoints[ prevP ]; @@ -3768,6 +4206,9 @@ bool SMESH_Pattern::setShapeToMesh(const TopoDS_Shape& theShape) return setErrorCode( ERR_APPL_BAD_NB_VERTICES ); } + myElements.clear(); // not refine elements + myElemXYZIDs.clear(); + myShapeIDMap.Clear(); myShape = theShape; return true; diff --git a/src/SMESH/SMESH_Pattern.hxx b/src/SMESH/SMESH_Pattern.hxx index 670578ce4..373d2ef25 100644 --- a/src/SMESH/SMESH_Pattern.hxx +++ b/src/SMESH/SMESH_Pattern.hxx @@ -100,9 +100,9 @@ class SMESH_Pattern { // the loaded pattern to . The first key-point // will be mapped into -th node - bool Apply (std::set theFaces, - const int theNodeIndexOnKeyPoint1, - const bool theReverse); + bool Apply (std::set& theFaces, + const int theNodeIndexOnKeyPoint1, + const bool theReverse); // Compute nodes coordinates applying // the loaded pattern to . The first key-point // will be mapped into -th node @@ -116,9 +116,9 @@ class SMESH_Pattern { // (0,0,1) key-point will be mapped into -th // node. - bool Apply (std::set theVolumes, - const int theNode000Index, - const int theNode001Index); + bool Apply (std::set& theVolumes, + const int theNode000Index, + const int theNode001Index); // Compute nodes coordinates applying // the loaded pattern to . The (0,0,0) key-point // will be mapped into -th node. The @@ -128,7 +128,9 @@ class SMESH_Pattern { bool GetMappedPoints ( std::list & thePoints ) const; // Return nodes coordinates computed by Apply() method - bool MakeMesh(SMESH_Mesh* theMesh); + bool MakeMesh(SMESH_Mesh* theMesh, + const bool toCreatePolygons = false, + const bool toCreatePolyedrs = false); // Create nodes and elements in using nodes // coordinates computed by either of Apply...() methods @@ -271,41 +273,80 @@ class SMESH_Pattern { // are appended to theEdgesPointsList typedef std::set TNodeSet; - void mergePoints (std::map > >& xyzIndGroups, - std::map< int, std::list< std::list< int >* > >& reverseConnectivity); - // Look for coincident points between myXYZs indexed with - // list of each element of xyzIndGroups. Coincident indices - // are merged in myElemXYZIDs using reverseConnectivity. + void mergePoints (const bool uniteGroups); + // Merge XYZ on edges and/or faces. + + void makePolyElements(const std::vector< const SMDS_MeshNode* >& theNodes, + const bool toCreatePolygons, + const bool toCreatePolyedrs); + // prepare intermediate data to create Polygons and Polyhedrons + + void createElements(SMESH_Mesh* theMesh, + const std::vector& theNodesVector, + const std::list< std::list< int > > & theElemNodeIDs, + const std::vector& theElements); + // add elements to the mesh + + bool getFacesDefinition(const SMDS_MeshNode** theBndNodes, + const int theNbBndNodes, + const std::vector< const SMDS_MeshNode* >& theNodes, + std::list< int >& theFaceDefs, + std::vector& theQuantity); + // fill faces definition for a volume face defined by theBndNodes + // return true if a face definition changes + + + bool isReversed(const SMDS_MeshNode* theFirstNode, + const std::list< int >& theIdsList) const; + // check xyz ids order in theIdsList taking into account + // theFirstNode on a link + private: // fields - bool myIs2D; - std::vector< TPoint > myPoints; - std::list< int > myKeyPointIDs; - std::list< std::list< int > > myElemPointIDs; + typedef std::list< int > TElemDef; // element definition is its nodes ids - ErrorCode myErrorCode; - bool myIsComputed; - bool myIsBoundaryPointsFound; + bool myIs2D; + std::vector< TPoint > myPoints; + std::list< int > myKeyPointIDs; + std::list< TElemDef > myElemPointIDs; - TopoDS_Shape myShape; + ErrorCode myErrorCode; + bool myIsComputed; + bool myIsBoundaryPointsFound; + + TopoDS_Shape myShape; // all functions assure that shapes are indexed so that first go // ordered vertices, then ordered edge, then faces and maybe a shell - TopTools_IndexedMapOfOrientedShape myShapeIDMap; - //TopTools_IndexedMapOfShape myShapeIDMap; - std::map< int, list< TPoint* > > myShapeIDToPointsMap; + TopTools_IndexedMapOfOrientedShape myShapeIDMap; + std::map< int, list< TPoint* > > myShapeIDToPointsMap; // for the 2d case: // nb of key-points in each of pattern boundaries - std::list< int > myNbKeyPntInBoundary; + std::list< int > myNbKeyPntInBoundary; + // to compute while applying to mesh elements, not to shapes - std::vector myXYZ; - std::list< std::list< int > > myElemXYZIDs; - std::map< int, const SMDS_MeshNode*> myXYZIdToNodeMap; // map id to node of a refined element - std::vector myElements; // refined elements - std::vector myOrderedNodes; + + std::vector myXYZ; // XYZ of nodes to create + std::list< TElemDef > myElemXYZIDs; // new elements definitions + std::map< int, const SMDS_MeshNode*> myXYZIdToNodeMap; // map XYZ id to node of a refined element + std::vector myElements; // refined elements + std::vector myOrderedNodes; + + // elements to replace with polygon or polyhedron + std::vector myPolyElems; + // definitions of new poly elements + std::list< TElemDef > myPolyElemXYZIDs; + std::list< std::vector > myPolyhedronQuantities; + + // map a boundary to XYZs on it; + // a boundary (edge or face) is defined as a set of its nodes, + // XYZs on a boundary are indices of myXYZ s + std::map > > myIdsOnBoundary; + // map XYZ id to element it is in + std::map< int, std::list< TElemDef* > > myReverseConnectivity; }; diff --git a/src/SMESH/SMESH_subMesh.cxx b/src/SMESH/SMESH_subMesh.cxx index dd93a999f..163a8a45f 100644 --- a/src/SMESH/SMESH_subMesh.cxx +++ b/src/SMESH/SMESH_subMesh.cxx @@ -792,18 +792,21 @@ SMESH_Hypothesis::Hypothesis_Status ASSERT(algo); if (!algo->CheckHypothesis((*_father),_subShape, ret )) { + //two applying algo on the same shape not allowed + _meshDS->RemoveHypothesis(_subShape, anHyp); if ( !SMESH_Hypothesis::IsStatusFatal( ret )) // ret should be fatal: anHyp was not added ret = SMESH_Hypothesis::HYP_INCOMPATIBLE; } - else if (!_father->IsUsedHypothesis( anHyp, _subShape )) - ret = SMESH_Hypothesis::HYP_INCOMPATIBLE; - - if (SMESH_Hypothesis::IsStatusFatal( ret )) + else if (SMESH_Hypothesis::IsStatusFatal( ret )) { - MESSAGE("do not add extra hypothesis"); _meshDS->RemoveHypothesis(_subShape, anHyp); } + else if (!_father->IsUsedHypothesis( anHyp, _subShape )) + { + _meshDS->RemoveHypothesis(_subShape, anHyp); + ret = SMESH_Hypothesis::HYP_INCOMPATIBLE; + } else { modifiedHyp = true; @@ -812,19 +815,11 @@ SMESH_Hypothesis::Hypothesis_Status } case ADD_ALGO: { //already existing algo : on father ? SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape); - if ( algo->CheckHypothesis((*_father),_subShape, aux_ret )) { - // check if algo changes - SMESH_HypoFilter f; - f.Init( SMESH_HypoFilter::IsAlgo() ); - f.And( SMESH_HypoFilter::IsApplicableTo( _subShape )); - f.AndNot( SMESH_HypoFilter::Is( algo )); - const SMESH_Hypothesis * prevAlgo = _father->GetHypothesis( _subShape, f, true ); - if (prevAlgo && - string(algo->GetName()) != string(prevAlgo->GetName()) ) - modifiedHyp = true; - } + if ( algo->CheckHypothesis((*_father),_subShape, aux_ret )) + SetAlgoState(HYP_OK); else SetAlgoState(MISSING_HYP); + modifiedHyp = true; break; } case REMOVE_HYP: { @@ -845,13 +840,13 @@ SMESH_Hypothesis::Hypothesis_Status } else { - if ( algo->CheckHypothesis((*_father),_subShape, aux_ret )) { - // check if algo remains - if ( anHyp != algo && strcmp( anHyp->GetName(), algo->GetName()) ) - modifiedHyp = true; - } + if ( algo->CheckHypothesis((*_father),_subShape, aux_ret )) + SetAlgoState(HYP_OK); else SetAlgoState(MISSING_HYP); + // check if same algo remains + if ( anHyp != algo && strcmp( anHyp->GetName(), algo->GetName()) ) + modifiedHyp = true; } break; } @@ -860,6 +855,7 @@ SMESH_Hypothesis::Hypothesis_Status ASSERT(algo); if ( algo->CheckHypothesis((*_father),_subShape, aux_ret )) { + SetAlgoState(HYP_OK); if (_father->IsUsedHypothesis( anHyp, _subShape )) // new Hyp modifiedHyp = true; } @@ -867,35 +863,27 @@ SMESH_Hypothesis::Hypothesis_Status SetAlgoState(MISSING_HYP); break; } - case ADD_FATHER_ALGO: { + case ADD_FATHER_ALGO: { // a new algo on father SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape); - if ( algo == anHyp ) { // a new algo on father - if ( algo->CheckHypothesis((*_father),_subShape, aux_ret )) { - // check if algo changes - SMESH_HypoFilter f; - f.Init( SMESH_HypoFilter::IsAlgo() ); - f.And( SMESH_HypoFilter::IsApplicableTo( _subShape )); - f.AndNot( SMESH_HypoFilter::Is( algo )); - const SMESH_Hypothesis* prevAlgo = _father->GetHypothesis( _subShape, f, true ); - if (prevAlgo && - string(algo->GetName()) != string(prevAlgo->GetName()) ) - modifiedHyp = true; - } + if ( algo == anHyp ) { + if ( algo->CheckHypothesis((*_father),_subShape, aux_ret )) + SetAlgoState(HYP_OK); else SetAlgoState(MISSING_HYP); + modifiedHyp = true; } break; } case REMOVE_FATHER_HYP: { SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape); ASSERT(algo); - if ( algo->CheckHypothesis((*_father),_subShape, aux_ret )) { - // is there the same local hyp or maybe a new father algo applied? - if ( !GetSimilarAttached( _subShape, anHyp ) ) - modifiedHyp = true; - } + if ( algo->CheckHypothesis((*_father),_subShape, aux_ret )) + SetAlgoState(HYP_OK); else SetAlgoState(MISSING_HYP); + // is there the same local hyp or maybe a new father algo applied? + if ( !GetSimilarAttached( _subShape, anHyp ) ) + modifiedHyp = true; break; } case REMOVE_FATHER_ALGO: { @@ -906,13 +894,13 @@ SMESH_Hypothesis::Hypothesis_Status } else { - if ( algo->CheckHypothesis((*_father),_subShape, aux_ret )) { - // check if algo changes - if ( string(algo->GetName()) != string( anHyp->GetName()) ) - modifiedHyp = true; - } + if ( algo->CheckHypothesis((*_father),_subShape, aux_ret )) + SetAlgoState(HYP_OK); else SetAlgoState(MISSING_HYP); + // is there the same local algo or maybe a new father algo applied? + if ( !GetSimilarAttached( _subShape, anHyp )) + modifiedHyp = true; } break; } @@ -1047,7 +1035,7 @@ void SMESH_subMesh::CleanDependsOn() for (its = dependson.begin(); its != dependson.end(); its++) { SMESH_subMesh *sm = (*its).second; - //SCRUTE((*its).first); + // SCRUTE((*its).first); sm->ComputeStateEngine(CLEAN); } } @@ -1497,21 +1485,21 @@ void SMESH_subMesh::UpdateDependantsState(const compute_event theEvent) void SMESH_subMesh::CleanDependants() { + //MESSAGE("SMESH_subMesh::CleanDependants: shape type " << _subShape.ShapeType() ); + TopTools_ListIteratorOfListOfShape it( _father->GetAncestors( _subShape )); for (; it.More(); it.Next()) { const TopoDS_Shape& ancestor = it.Value(); - // PAL8021. do not go upper than SOLID, else ComputeStateEngine(CLEANDEP) - // will erase mesh on other shapes in a compound - if ( ancestor.ShapeType() >= TopAbs_SOLID ) { - SMESH_subMesh *aSubMesh = _father->GetSubMeshContaining(ancestor); - if (aSubMesh) - aSubMesh->ComputeStateEngine(CLEANDEP); - } + //MESSAGE("ancestor shape type " << ancestor.ShapeType() ); + SMESH_subMesh *aSubMesh = _father->GetSubMeshContaining(ancestor); + if (aSubMesh) + aSubMesh->ComputeStateEngine(CLEANDEP); } ComputeStateEngine(CLEAN); } + //============================================================================= /*! * diff --git a/src/SMESHDS/SMESHDS_Command.cxx b/src/SMESHDS/SMESHDS_Command.cxx index 4e7dc3f3b..b55b5af1c 100644 --- a/src/SMESHDS/SMESHDS_Command.cxx +++ b/src/SMESHDS/SMESHDS_Command.cxx @@ -224,6 +224,57 @@ void SMESHDS_Command::AddVolume(int NewVolID, myNumber++; } +//======================================================================= +//function : AddPolygonalFace +//purpose : +//======================================================================= +void SMESHDS_Command::AddPolygonalFace (const int ElementID, + std::vector nodes_ids) +{ + if (!myType == SMESHDS_AddPolygon) { + MESSAGE("SMESHDS_Command::AddPolygonalFace : Bad Type"); + return; + } + myIntegers.push_back(ElementID); + + int i, nbNodes = nodes_ids.size(); + myIntegers.push_back(nbNodes); + for (i = 0; i < nbNodes; i++) { + myIntegers.push_back(nodes_ids[i]); + } + + myNumber++; +} + +//======================================================================= +//function : AddPolyhedralVolume +//purpose : +//======================================================================= +void SMESHDS_Command::AddPolyhedralVolume (const int ElementID, + std::vector nodes_ids, + std::vector quantities) +{ + if (!myType == SMESHDS_AddPolyhedron) { + MESSAGE("SMESHDS_Command::AddPolyhedralVolume : Bad Type"); + return; + } + myIntegers.push_back(ElementID); + + int i, nbNodes = nodes_ids.size(); + myIntegers.push_back(nbNodes); + for (i = 0; i < nbNodes; i++) { + myIntegers.push_back(nodes_ids[i]); + } + + int nbFaces = quantities.size(); + myIntegers.push_back(nbFaces); + for (i = 0; i < nbFaces; i++) { + myIntegers.push_back(quantities[i]); + } + + myNumber++; +} + //======================================================================= //function : //purpose : @@ -263,7 +314,7 @@ void SMESHDS_Command::ChangeElementNodes(int ElementID, int nodes[], int nbnodes { if (!myType == SMESHDS_ChangeElementNodes) { - MESSAGE("SMESHDS_Command::RemoveElement : Bad Type"); + MESSAGE("SMESHDS_Command::ChangeElementNodes : Bad Type"); return; } myIntegers.push_back(ElementID); @@ -274,6 +325,36 @@ void SMESHDS_Command::ChangeElementNodes(int ElementID, int nodes[], int nbnodes myNumber++; } +//======================================================================= +//function : ChangePolyhedronNodes +//purpose : +//======================================================================= +void SMESHDS_Command::ChangePolyhedronNodes (const int ElementID, + std::vector nodes_ids, + std::vector quantities) +{ + if (myType != SMESHDS_ChangePolyhedronNodes) + { + MESSAGE("SMESHDS_Command::ChangePolyhedronNodes : Bad Type"); + return; + } + myIntegers.push_back(ElementID); + + int i, nbNodes = nodes_ids.size(); + myIntegers.push_back(nbNodes); + for (i = 0; i < nbNodes; i++) { + myIntegers.push_back(nodes_ids[i]); + } + + int nbFaces = quantities.size(); + myIntegers.push_back(nbFaces); + for (i = 0; i < nbFaces; i++) { + myIntegers.push_back(quantities[i]); + } + + myNumber++; +} + //======================================================================= //function : Renumber //purpose : diff --git a/src/SMESHDS/SMESHDS_Command.hxx b/src/SMESHDS/SMESHDS_Command.hxx index b72b21b86..3ecd762f3 100644 --- a/src/SMESHDS/SMESHDS_Command.hxx +++ b/src/SMESHDS/SMESHDS_Command.hxx @@ -29,6 +29,7 @@ #include "SMESHDS_CommandType.hxx" #include +#include class SMESHDS_Command { @@ -48,10 +49,18 @@ class SMESHDS_Command int idnode4, int idnode5, int idnode6); void AddVolume(int NewVolID, int idnode1, int idnode2, int idnode3, int idnode4, int idnode5, int idnode6, int idnode7, int idnode8); + void AddPolygonalFace (const int ElementID, + std::vector nodes_ids); + void AddPolyhedralVolume (const int ElementID, + std::vector nodes_ids, + std::vector quantities); void MoveNode(int NewNodeID, double x, double y, double z); void RemoveNode(int NodeID); void RemoveElement(int ElementID); void ChangeElementNodes(int ElementID, int nodes[], int nbnodes); + void ChangePolyhedronNodes(const int ElementID, + std::vector nodes_ids, + std::vector quantities); void Renumber (const bool isNodes, const int startID, const int deltaID); SMESHDS_CommandType GetType(); int GetNumber(); diff --git a/src/SMESHDS/SMESHDS_CommandType.hxx b/src/SMESHDS/SMESHDS_CommandType.hxx index e906020cb..f2c505b1f 100644 --- a/src/SMESHDS/SMESHDS_CommandType.hxx +++ b/src/SMESHDS/SMESHDS_CommandType.hxx @@ -34,14 +34,17 @@ enum SMESHDS_CommandType { SMESHDS_AddEdge, SMESHDS_AddTriangle, SMESHDS_AddQuadrangle, + SMESHDS_AddPolygon, SMESHDS_AddTetrahedron, SMESHDS_AddPyramid, SMESHDS_AddPrism, SMESHDS_AddHexahedron, + SMESHDS_AddPolyhedron, SMESHDS_RemoveNode, SMESHDS_RemoveElement, SMESHDS_MoveNode, SMESHDS_ChangeElementNodes, + SMESHDS_ChangePolyhedronNodes, SMESHDS_Renumber }; diff --git a/src/SMESHDS/SMESHDS_Mesh.cxx b/src/SMESHDS/SMESHDS_Mesh.cxx index d3e5d6bb8..ded954d0c 100644 --- a/src/SMESHDS/SMESHDS_Mesh.cxx +++ b/src/SMESHDS/SMESHDS_Mesh.cxx @@ -171,8 +171,9 @@ bool SMESHDS_Mesh::ChangeElementNodes(const SMDS_MeshElement * elem, if ( ! SMDS_Mesh::ChangeElementNodes( elem, nodes, nbnodes )) return false; - ASSERT( nbnodes < 9 ); - int i, IDs[ 8 ]; + //ASSERT( nbnodes < 9 ); + //int i, IDs[ 8 ]; + int i, IDs[ nbnodes ]; for ( i = 0; i < nbnodes; i++ ) IDs [ i ] = nodes[ i ]->GetID(); myScript->ChangeElementNodes( elem->GetID(), IDs, nbnodes); @@ -180,6 +181,49 @@ bool SMESHDS_Mesh::ChangeElementNodes(const SMDS_MeshElement * elem, return true; } +//======================================================================= +//function : ChangePolygonNodes +//purpose : +//======================================================================= +bool SMESHDS_Mesh::ChangePolygonNodes + (const SMDS_MeshElement * elem, + std::vector nodes) +{ + ASSERT(nodes.size() > 3); + + int nb = nodes.size(); + const SMDS_MeshNode* nodes_array [nb]; + for (int inode = 0; inode < nb; inode++) { + nodes_array[inode] = nodes[inode]; + } + + return ChangeElementNodes(elem, nodes_array, nb); +} + +//======================================================================= +//function : ChangePolyhedronNodes +//purpose : +//======================================================================= +bool SMESHDS_Mesh::ChangePolyhedronNodes + (const SMDS_MeshElement * elem, + std::vector nodes, + std::vector quantities) +{ + ASSERT(nodes.size() > 3); + + if (!SMDS_Mesh::ChangePolyhedronNodes(elem, nodes, quantities)) + return false; + + int i, len = nodes.size(); + std::vector nodes_ids (len); + for (i = 0; i < len; i++) { + nodes_ids[i] = nodes[i]->GetID(); + } + myScript->ChangePolyhedronNodes(elem->GetID(), nodes_ids, quantities); + + return true; +} + //======================================================================= //function : Renumber //purpose : @@ -472,6 +516,100 @@ SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1, n8->GetID()); return anElem; } + +//======================================================================= +//function : AddPolygonalFace +//purpose : +//======================================================================= +SMDS_MeshFace* SMESHDS_Mesh::AddPolygonalFaceWithID (std::vector nodes_ids, + const int ID) +{ + SMDS_MeshFace *anElem = SMDS_Mesh::AddPolygonalFaceWithID(nodes_ids, ID); + if (anElem) { + myScript->AddPolygonalFace(ID, nodes_ids); + } + return anElem; +} + +SMDS_MeshFace* SMESHDS_Mesh::AddPolygonalFaceWithID + (std::vector nodes, + const int ID) +{ + SMDS_MeshFace *anElem = SMDS_Mesh::AddPolygonalFaceWithID(nodes, ID); + if (anElem) { + int i, len = nodes.size(); + std::vector nodes_ids (len); + for (i = 0; i < len; i++) { + nodes_ids[i] = nodes[i]->GetID(); + } + myScript->AddPolygonalFace(ID, nodes_ids); + } + return anElem; +} + +SMDS_MeshFace* SMESHDS_Mesh::AddPolygonalFace + (std::vector nodes) +{ + SMDS_MeshFace *anElem = SMDS_Mesh::AddPolygonalFace(nodes); + if (anElem) { + int i, len = nodes.size(); + std::vector nodes_ids (len); + for (i = 0; i < len; i++) { + nodes_ids[i] = nodes[i]->GetID(); + } + myScript->AddPolygonalFace(anElem->GetID(), nodes_ids); + } + return anElem; +} + +//======================================================================= +//function : AddPolyhedralVolume +//purpose : +//======================================================================= +SMDS_MeshVolume* SMESHDS_Mesh::AddPolyhedralVolumeWithID (std::vector nodes_ids, + std::vector quantities, + const int ID) +{ + SMDS_MeshVolume *anElem = SMDS_Mesh::AddPolyhedralVolumeWithID(nodes_ids, quantities, ID); + if (anElem) { + myScript->AddPolyhedralVolume(ID, nodes_ids, quantities); + } + return anElem; +} + +SMDS_MeshVolume* SMESHDS_Mesh::AddPolyhedralVolumeWithID + (std::vector nodes, + std::vector quantities, + const int ID) +{ + SMDS_MeshVolume *anElem = SMDS_Mesh::AddPolyhedralVolumeWithID(nodes, quantities, ID); + if (anElem) { + int i, len = nodes.size(); + std::vector nodes_ids (len); + for (i = 0; i < len; i++) { + nodes_ids[i] = nodes[i]->GetID(); + } + myScript->AddPolyhedralVolume(ID, nodes_ids, quantities); + } + return anElem; +} + +SMDS_MeshVolume* SMESHDS_Mesh::AddPolyhedralVolume + (std::vector nodes, + std::vector quantities) +{ + SMDS_MeshVolume *anElem = SMDS_Mesh::AddPolyhedralVolume(nodes, quantities); + if (anElem) { + int i, len = nodes.size(); + std::vector nodes_ids (len); + for (i = 0; i < len; i++) { + nodes_ids[i] = nodes[i]->GetID(); + } + myScript->AddPolyhedralVolume(anElem->GetID(), nodes_ids, quantities); + } + return anElem; +} + //======================================================================= //function : removeFromContainers //purpose : @@ -738,13 +876,14 @@ bool SMESHDS_Mesh::IsGroupOfSubShapes (const TopoDS_Shape& theShape) const /// Return the sub mesh linked to the a given TopoDS_Shape or NULL if the given /// TopoDS_Shape is unknown /////////////////////////////////////////////////////////////////////////////// -SMESHDS_SubMesh * SMESHDS_Mesh::MeshElements(const TopoDS_Shape & S) +SMESHDS_SubMesh * SMESHDS_Mesh::MeshElements(const TopoDS_Shape & S) const { if (myShape.IsNull()) MESSAGE("myShape is NULL"); int Index = ShapeToIndex(S); - if (myShapeIndexToSubMesh.find(Index)!=myShapeIndexToSubMesh.end()) - return myShapeIndexToSubMesh[Index]; + TShapeIndexToSubMesh::const_iterator anIter = myShapeIndexToSubMesh.find(Index); + if (anIter != myShapeIndexToSubMesh.end()) + return anIter->second; else return NULL; } @@ -895,7 +1034,7 @@ TopoDS_Shape SMESHDS_Mesh::IndexToShape(int ShapeIndex) //function : ShapeToIndex //purpose : //======================================================================= -int SMESHDS_Mesh::ShapeToIndex(const TopoDS_Shape & S) +int SMESHDS_Mesh::ShapeToIndex(const TopoDS_Shape & S) const { if (myShape.IsNull()) MESSAGE("myShape is NULL"); diff --git a/src/SMESHDS/SMESHDS_Mesh.hxx b/src/SMESHDS/SMESHDS_Mesh.hxx index 459d30848..86b9071c1 100644 --- a/src/SMESHDS/SMESHDS_Mesh.hxx +++ b/src/SMESHDS/SMESHDS_Mesh.hxx @@ -158,12 +158,39 @@ public: const SMDS_MeshNode * n7, const SMDS_MeshNode * n8); + virtual SMDS_MeshFace* AddPolygonalFaceWithID (std::vector nodes_ids, + const int ID); + + virtual SMDS_MeshFace* AddPolygonalFaceWithID (std::vector nodes, + const int ID); + + virtual SMDS_MeshFace* AddPolygonalFace (std::vector nodes); + + virtual SMDS_MeshVolume* AddPolyhedralVolumeWithID + (std::vector nodes_ids, + std::vector quantities, + const int ID); + + virtual SMDS_MeshVolume* AddPolyhedralVolumeWithID + (std::vector nodes, + std::vector quantities, + const int ID); + + virtual SMDS_MeshVolume* AddPolyhedralVolume + (std::vector nodes, + std::vector quantities); + void MoveNode(const SMDS_MeshNode *, double x, double y, double z); virtual void RemoveNode(const SMDS_MeshNode *); void RemoveElement(const SMDS_MeshElement *); bool ChangeElementNodes(const SMDS_MeshElement * elem, const SMDS_MeshNode * nodes[], const int nbnodes); + bool ChangePolygonNodes(const SMDS_MeshElement * elem, + std::vector nodes); + bool ChangePolyhedronNodes(const SMDS_MeshElement * elem, + std::vector nodes, + std::vector quantities); void Renumber (const bool isNodes, const int startID=1, const int deltaID=1); void SetNodeInVolume(SMDS_MeshNode * aNode, const TopoDS_Shell & S); @@ -177,7 +204,7 @@ public: const TopoDS_Shape & S); TopoDS_Shape ShapeToMesh() const; bool HasMeshElements(const TopoDS_Shape & S); - SMESHDS_SubMesh * MeshElements(const TopoDS_Shape & S); + SMESHDS_SubMesh * MeshElements(const TopoDS_Shape & S) const; SMESHDS_SubMesh * MeshElements(const int Index); std::list SubMeshIndices(); const std::map& SubMeshes() @@ -187,7 +214,7 @@ public: const std::list& GetHypothesis(const TopoDS_Shape & S) const; SMESHDS_Script * GetScript(); void ClearScript(); - int ShapeToIndex(const TopoDS_Shape & aShape); + int ShapeToIndex(const TopoDS_Shape & aShape) const; TopoDS_Shape IndexToShape(int ShapeIndex); SMESHDS_SubMesh * NewSubMesh(int Index); @@ -219,9 +246,15 @@ private: int myMeshID; TopoDS_Shape myShape; + + typedef std::map TShapeIndexToSubMesh; + TShapeIndexToSubMesh myShapeIndexToSubMesh; + TopTools_IndexedMapOfShape myIndexToShape; - std::map myShapeIndexToSubMesh; - std::set myGroups; + + typedef std::set TGroups; + TGroups myGroups; + SMESHDS_Script* myScript; }; diff --git a/src/SMESHDS/SMESHDS_Script.cxx b/src/SMESHDS/SMESHDS_Script.cxx index 97e158432..369ab4697 100644 --- a/src/SMESHDS/SMESHDS_Script.cxx +++ b/src/SMESHDS/SMESHDS_Script.cxx @@ -148,6 +148,27 @@ void SMESHDS_Script::AddVolume(int NewID, idnode5, idnode6, idnode7, idnode8); } +//======================================================================= +//function : AddPolygonalFace +//purpose : +//======================================================================= +void SMESHDS_Script::AddPolygonalFace (int NewFaceID, std::vector nodes_ids) +{ + getCommand(SMESHDS_AddPolygon)->AddPolygonalFace(NewFaceID, nodes_ids); +} + +//======================================================================= +//function : AddPolyhedralVolume +//purpose : +//======================================================================= +void SMESHDS_Script::AddPolyhedralVolume (int NewID, + std::vector nodes_ids, + std::vector quantities) +{ + getCommand(SMESHDS_AddPolyhedron)->AddPolyhedralVolume + (NewID, nodes_ids, quantities); +} + //======================================================================= //function : //purpose : @@ -185,6 +206,18 @@ void SMESHDS_Script::ChangeElementNodes(int ElementID, int nodes[], int nbnodes) getCommand(SMESHDS_ChangeElementNodes)->ChangeElementNodes( ElementID, nodes, nbnodes ); } +//======================================================================= +//function : ChangePolyhedronNodes +//purpose : +//======================================================================= +void SMESHDS_Script::ChangePolyhedronNodes (const int ElementID, + std::vector nodes_ids, + std::vector quantities) +{ + getCommand(SMESHDS_ChangePolyhedronNodes)->ChangePolyhedronNodes + (ElementID, nodes_ids, quantities); +} + //======================================================================= //function : Renumber //purpose : diff --git a/src/SMESHDS/SMESHDS_Script.hxx b/src/SMESHDS/SMESHDS_Script.hxx index e51d3ec98..3874facfc 100644 --- a/src/SMESHDS/SMESHDS_Script.hxx +++ b/src/SMESHDS/SMESHDS_Script.hxx @@ -30,6 +30,7 @@ #include "SMESHDS_Command.hxx" #include +#include class SMESHDS_Script @@ -48,10 +49,20 @@ class SMESHDS_Script int idnode4, int idnode5, int idnode6); void AddVolume(int NewVolID, int idnode1, int idnode2, int idnode3, int idnode4, int idnode5, int idnode6, int idnode7, int idnode8); - void MoveNode(int NewNodeID, double x, double y, double z); + + void AddPolygonalFace (const int NewFaceID, + std::vector nodes_ids); + void AddPolyhedralVolume (const int NewVolID, + std::vector nodes_ids, + std::vector quantities); + + void MoveNode(int NewNodeID, double x, double y, double z); void RemoveNode(int NodeID); void RemoveElement(int ElementID); void ChangeElementNodes(int ElementID, int nodes[], int nbnodes); + void ChangePolyhedronNodes(const int ElementID, + std::vector nodes_ids, + std::vector quantities); void Renumber (const bool isNodes, const int startID, const int deltaID); void Clear(); const std::list & GetCommands(); diff --git a/src/SMESHFiltersSelection/Makefile.in b/src/SMESHFiltersSelection/Makefile.in index fa9869176..e9c388166 100644 --- a/src/SMESHFiltersSelection/Makefile.in +++ b/src/SMESHFiltersSelection/Makefile.in @@ -58,14 +58,16 @@ LIB_CLIENT_IDL = SALOME_Exception.idl \ # header files EXPORT_HEADERS= SMESH_Type.h \ SMESH_TypeFilter.hxx \ - Handle_SMESH_TypeFilter.hxx \ SMESH_NumberFilter.hxx \ SMESH_LogicalFilter.hxx # additionnal information to compil and link file -CPPFLAGS += $(OCC_INCLUDES) $(QT_INCLUDES) $(PYTHON_INCLUDES) $(VTK_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome -I${GEOM_ROOT_DIR}/include/salome -CXXFLAGS += $(OCC_CXXFLAGS) -I${KERNEL_ROOT_DIR}/include/salome -I${GEOM_ROOT_DIR}/include/salome -LDFLAGS += $(OCC_KERNEL_LIBS) -L${GEOM_ROOT_DIR}/lib/salome +CPPFLAGS += $(OCC_INCLUDES) $(QT_INCLUDES) $(PYTHON_INCLUDES) $(VTK_INCLUDES) \ + -I${KERNEL_ROOT_DIR}/include/salome -I${GUI_ROOT_DIR}/include/salome \ + -I${GEOM_ROOT_DIR}/include/salome -I${BOOSTDIR} +CXXFLAGS += $(OCC_CXXFLAGS) -I${KERNEL_ROOT_DIR}/include/salome -I${GUI_ROOT_DIR}/include/salome \ + -I${GEOM_ROOT_DIR}/include/salome -I${BOOSTDIR} +LDFLAGS += $(OCC_KERNEL_LIBS) -L${GUI_ROOT_DIR}/lib/salome -L${GEOM_ROOT_DIR}/lib/salome -lSalomeApp -lsuit # additional file to be cleaned MOSTLYCLEAN = @@ -73,4 +75,3 @@ CLEAN = DISTCLEAN = @CONCLUDE@ - diff --git a/src/SMESHFiltersSelection/SMESH_LogicalFilter.cxx b/src/SMESHFiltersSelection/SMESH_LogicalFilter.cxx index 47b6356ae..18631a405 100644 --- a/src/SMESHFiltersSelection/SMESH_LogicalFilter.cxx +++ b/src/SMESHFiltersSelection/SMESH_LogicalFilter.cxx @@ -1,49 +1,17 @@ -// SALOME SALOMEGUI : implementation of desktop and GUI kernel -// -// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -// -// -// // File : SMESH_LogicalFilter.cxx -// Author : Sergey LITONIN // Module : SMESH #include "SMESH_LogicalFilter.hxx" -/* - Class : SMESH_LogicalFilter - Description : Filter for combaining several filters with logical operation (OR or AND) -*/ - -IMPLEMENT_STANDARD_HANDLE( SMESH_LogicalFilter, SALOME_Filter ) -IMPLEMENT_STANDARD_RTTIEXT( SMESH_LogicalFilter, SALOME_Filter ) - //======================================================================= // name : SMESH_LogicalFilter::SMESH_LogicalFilter // Purpose : Constructor //======================================================================= -SMESH_LogicalFilter::SMESH_LogicalFilter( const SMESH_ListOfFilter& theFilters, - const int theLogOp ) +SMESH_LogicalFilter::SMESH_LogicalFilter (const QPtrList& theFilters, + const int theLogOp) { - myFilters = theFilters; - myLogOp = theLogOp; + setFilters(theFilters); + setOperation(theLogOp); } //======================================================================= @@ -58,91 +26,56 @@ SMESH_LogicalFilter::~SMESH_LogicalFilter() // name : SMESH_LogicalFilter::IsOk // Purpose : Verify validity of entry object //======================================================================= -Standard_Boolean SMESH_LogicalFilter::IsOk( const Handle(SALOME_InteractiveObject)& theIO ) const +bool SMESH_LogicalFilter::isOk (const SUIT_DataOwner* owner) const { - SMESH_ListOfFilter::Iterator anIter( myFilters ); - for ( ; anIter.More(); anIter.Next() ) + bool res = true; + QPtrListIterator it (myFilters); + SUIT_SelectionFilter* filter; + for (; ((filter = it.current()) != 0) && res; ++it) { - Handle(SALOME_Filter) aFilter = anIter.Value(); - if ( !aFilter.IsNull() ) - { - if ( myLogOp == LO_OR && anIter.Value()->IsOk( theIO ) ) - return true; - if ( myLogOp == LO_AND && !anIter.Value()->IsOk( theIO ) ) - return false; - } + if (myOperation == LO_OR && filter->isOk(owner)) + return true; + if (myOperation == LO_AND && !filter->isOk(owner)) + return false; + if (myOperation == LO_NOT) + return !filter->isOk(owner); } - return myLogOp == LO_OR ? false : true; + return (myOperation != LO_OR); } //======================================================================= -// name : SMESH_LogicalFilter::SetFilters +// name : SMESH_LogicalFilter::setFilters // Purpose : Set new list of filters. Old wilters are removed //======================================================================= -void SMESH_LogicalFilter::SetFilters( const SMESH_ListOfFilter& theFilters ) +void SMESH_LogicalFilter::setFilters (const QPtrList& theFilters) { myFilters = theFilters; } //======================================================================= -// name : SMESH_LogicalFilter::SetLogOp +// name : SMESH_LogicalFilter::setOperation // Purpose : Set logical operation //======================================================================= -void SMESH_LogicalFilter::SetLogOp( const int theLogOp ) +void SMESH_LogicalFilter::setOperation (const int theLogOp) { - myLogOp = theLogOp; + myOperation = theLogOp; } //======================================================================= -// name : SMESH_LogicalFilter::GetFilters +// name : SMESH_LogicalFilter::getFilters // Purpose : Get list of filters //======================================================================= -const SMESH_ListOfFilter& SMESH_LogicalFilter::GetFilters() const +const QPtrList SMESH_LogicalFilter::getFilters() const { return myFilters; } //======================================================================= -// name : SMESH_LogicalFilter::GetLogOp +// name : SMESH_LogicalFilter::getOperation // Purpose : Get logical operation //======================================================================= -int SMESH_LogicalFilter::GetLogOp() const +int SMESH_LogicalFilter::getOperation() const { - return myLogOp; + return myOperation; } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/SMESHFiltersSelection/SMESH_LogicalFilter.hxx b/src/SMESHFiltersSelection/SMESH_LogicalFilter.hxx index ec10f865b..a453bb13d 100644 --- a/src/SMESHFiltersSelection/SMESH_LogicalFilter.hxx +++ b/src/SMESHFiltersSelection/SMESH_LogicalFilter.hxx @@ -1,102 +1,33 @@ -// SALOME SALOMEGUI : implementation of desktop and GUI kernel -// -// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -// -// -// // File : SMESH_LogicalFilter.hxx -// Author : Sergey LITONIN // Module : SMESH #ifndef _SMESH_LogicalFilter_HeaderFile #define _SMESH_LogicalFilter_HeaderFile -#include "SALOME_Filter.hxx" +#include -#include -#include -#include +#include -DEFINE_STANDARD_HANDLE( SMESH_LogicalFilter, SALOME_Filter ) - -DEFINE_BASECOLLECTION( SMESH_FilterColl, Handle(SALOME_Filter) ) -DEFINE_LIST( SMESH_ListOfFilter, SMESH_FilterColl, Handle(SALOME_Filter) ) - - -/* - Class : SMESH_LogicalFilter - Description : Filter for combaining several filters with logical operation (OR or AND) -*/ - -class SMESH_LogicalFilter : public SALOME_Filter +class SMESH_LogicalFilter : public SUIT_SelectionFilter { -public: + public: + enum { LO_OR, LO_AND, LO_NOT, LO_UNDEFINED }; - enum { LO_OR, LO_AND, LO_UNDEFINED }; + public: + SMESH_LogicalFilter (const QPtrList&, + const int); + virtual ~SMESH_LogicalFilter(); -public: + virtual bool isOk (const SUIT_DataOwner*) const; - SMESH_LogicalFilter( const SMESH_ListOfFilter&, const int ); - - - virtual ~SMESH_LogicalFilter(); - virtual Standard_Boolean IsOk( const Handle(SALOME_InteractiveObject)& ) const; - - void SetFilters( const SMESH_ListOfFilter& ); - void SetLogOp( const int ); - const SMESH_ListOfFilter& GetFilters() const; - int GetLogOp() const; + void setFilters (const QPtrList&); + void setOperation (const int); + const QPtrList getFilters() const; + int getOperation() const; private: - - SMESH_ListOfFilter myFilters; - int myLogOp; - -public: - DEFINE_STANDARD_RTTI( SMESH_LogicalFilter ) + QPtrList myFilters; + int myOperation; }; #endif - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/SMESHFiltersSelection/SMESH_NumberFilter.cxx b/src/SMESHFiltersSelection/SMESH_NumberFilter.cxx index 8a7c43a58..3f0cd8834 100644 --- a/src/SMESHFiltersSelection/SMESH_NumberFilter.cxx +++ b/src/SMESHFiltersSelection/SMESH_NumberFilter.cxx @@ -1,84 +1,65 @@ -// SALOME SALOMEGUI : implementation of desktop and GUI kernel -// -// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -// -// -// // File : SMESH_NumberFilter.cxx -// Author : Sergey LITONIN // Module : SMESH #include "SMESH_NumberFilter.hxx" + #include "GEOMBase.h" -#include "TopTools_MapOfShape.hxx" -#include "TopExp_Explorer.hxx" + +#include "SUIT_Application.h" +#include "SUIT_Session.h" + +#include "SalomeApp_Study.h" +#include "SalomeApp_DataOwner.h" + #include "SALOME_InteractiveObject.hxx" -#include "QAD_Application.h" -#include "QAD_Desktop.h" +#include "SALOMEDSClient_SObject.hxx" +#include "SALOMEDS_SObject.hxx" +#include +#include -/* - Class : SMESH_NumberFilter - Description : Filter for geom objects. - Filter geom objects by number of subshapes of the given type -*/ - -IMPLEMENT_STANDARD_HANDLE( SMESH_NumberFilter, SALOME_TypeFilter ) -IMPLEMENT_STANDARD_RTTIEXT( SMESH_NumberFilter, SALOME_TypeFilter ) +/*! + * Class : SMESH_NumberFilter + * Description : Filter for geom objects. + * Filter geom objects by number of subshapes of the given type + */ //======================================================================= // name : SMESH_NumberFilter::SMESH_NumberFilter // Purpose : Constructor //======================================================================= -SMESH_NumberFilter::SMESH_NumberFilter( const char* theKind, +SMESH_NumberFilter::SMESH_NumberFilter (const char* theKind, const TopAbs_ShapeEnum theSubShapeType, const int theNumber, const TopAbs_ShapeEnum theShapeType, GEOM::GEOM_Object_ptr theMainObj, - const bool theIsClosedOnly ) -: SALOME_TypeFilter( (char*)theKind ) + const bool theIsClosedOnly) { + myKind = (char*)theKind; mySubShapeType = theSubShapeType; myNumber = theNumber; myIsClosedOnly = theIsClosedOnly; - myShapeTypes.Add( theShapeType ); - myMainObj = GEOM::GEOM_Object::_duplicate( theMainObj ); + myShapeTypes.Add(theShapeType); + myMainObj = GEOM::GEOM_Object::_duplicate(theMainObj); } //======================================================================= // name : SMESH_NumberFilter::SMESH_NumberFilter // Purpose : Constructor //======================================================================= -SMESH_NumberFilter::SMESH_NumberFilter( const char* theKind, +SMESH_NumberFilter::SMESH_NumberFilter (const char* theKind, const TopAbs_ShapeEnum theSubShapeType, const int theNumber, const TColStd_MapOfInteger& theShapeTypes, GEOM::GEOM_Object_ptr theMainObj, const bool theIsClosedOnly ) -: SALOME_TypeFilter( (char*)theKind ) { + myKind = (char*)theKind; mySubShapeType = theSubShapeType; myNumber = theNumber; myIsClosedOnly = theIsClosedOnly; myShapeTypes = theShapeTypes; - myMainObj = GEOM::GEOM_Object::_duplicate( theMainObj ); + myMainObj = GEOM::GEOM_Object::_duplicate(theMainObj); } SMESH_NumberFilter::~SMESH_NumberFilter() @@ -89,52 +70,53 @@ SMESH_NumberFilter::~SMESH_NumberFilter() // name : SMESH_NumberFilter::SMESH_NumberFilter // Purpose : Verify validity of entry object //======================================================================= -Standard_Boolean SMESH_NumberFilter::IsOk( const Handle(SALOME_InteractiveObject)& theObj ) const +bool SMESH_NumberFilter::isOk (const SUIT_DataOwner* theDataOwner) const { - if ( theObj.IsNull() || !SALOME_TypeFilter::IsOk( theObj ) ) + if (!theDataOwner) return false; // Get geom object from IO - GEOM::GEOM_Object_var aGeomObj = getGeom( theObj ); - if ( aGeomObj->_is_nil() ) + GEOM::GEOM_Object_var aGeomObj = getGeom(theDataOwner); + if (aGeomObj->_is_nil()) return false; // Get shape from geom object and verify its parameters TopoDS_Shape aShape; - if ( !GEOMBase::GetShape( aGeomObj, aShape ) || - aShape.IsNull() || - !myShapeTypes.Contains( aShape.ShapeType() ) || - myIsClosedOnly && aShape.ShapeType() == TopAbs_SHELL && !aShape.Closed() ) + if (!GEOMBase::GetShape(aGeomObj, aShape) || + aShape.IsNull() || + !myShapeTypes.Contains(aShape.ShapeType())) return false; - + + if (myIsClosedOnly && aShape.ShapeType() == TopAbs_SHELL && !aShape.Closed()) + return false; + // Verify whether shape of entry object is sub-shape of myMainObj - if ( !myMainObj->_is_nil() ) - { + if (!myMainObj->_is_nil()) { TopoDS_Shape aMainShape; - if ( !GEOMBase::GetShape( myMainObj, aMainShape ) ) + if (!GEOMBase::GetShape(myMainObj, aMainShape)) return false; bool isFound = false; TopAbs_ShapeEnum aShapeType = aShape.ShapeType(); - TopExp_Explorer anExp( aMainShape, aShapeType ); - for ( ; anExp.More(); anExp.Next() ) - if ( anExp.Current() == aShape ) - { + TopExp_Explorer anExp (aMainShape, aShapeType); + for (; anExp.More(); anExp.Next()) { + if (anExp.Current() == aShape) { isFound = true; break; } - if ( !isFound ) + } + if (!isFound) return false; } + // Verify number of sub-shapes - if ( mySubShapeType == TopAbs_SHAPE ); + if (mySubShapeType == TopAbs_SHAPE); return true; - int nbShapes = 0; - TopExp_Explorer anExp2( aShape, mySubShapeType ); + TopExp_Explorer anExp2 (aShape, mySubShapeType); TopTools_MapOfShape aMap; - for ( ; anExp2.More(); anExp2.Next() ) - aMap.Add( anExp2.Current() ); + for (; anExp2.More(); anExp2.Next()) + aMap.Add(anExp2.Current()); return myNumber == aMap.Extent(); } @@ -143,83 +125,76 @@ Standard_Boolean SMESH_NumberFilter::IsOk( const Handle(SALOME_InteractiveObject // name : SMESH_NumberFilter::getGeom // Purpose : Retrieve geom object from SALOME_InteractiveObject //======================================================================= -GEOM::GEOM_Object_ptr SMESH_NumberFilter::getGeom( - const Handle(SALOME_InteractiveObject)& theObj ) const +GEOM::GEOM_Object_ptr SMESH_NumberFilter::getGeom + (const SUIT_DataOwner* theDataOwner) const { - if ( theObj->isComponentType( "GEOM" ) ) - { - Standard_Boolean aRes = Standard_False; - GEOM::GEOM_Object_var aGeomObj = GEOMBase::ConvertIOinGEOMObject( theObj, aRes ); - return aRes ? aGeomObj._retn() : GEOM::GEOM_Object::_nil(); - } - else - { - // Get geom object corresponding to the mesh - SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument(); - SALOMEDS::SObject_var aSO = aStudy->FindObjectID( theObj->getEntry() ); - if ( aSO->_is_nil() ) - return GEOM::GEOM_Object::_nil(); + const SalomeApp_DataOwner* owner = + dynamic_cast(theDataOwner); + SalomeApp_Study* appStudy = dynamic_cast + (SUIT_Session::session()->activeApplication()->activeStudy()); - SALOMEDS::ChildIterator_var anIter = aStudy->NewChildIterator( aSO ); - for( ; anIter->More(); anIter->Next() ) - { - SALOMEDS::SObject_var aSO = anIter->Value(); - SALOMEDS::SObject_var aRefSO; - - GEOM::GEOM_Object_var aMeshShape = GEOM::GEOM_Object::_narrow( - aSO->ReferencedObject( aRefSO )? aRefSO->GetObject() : aSO->GetObject() ); - - if ( !aMeshShape->_is_nil() ) - return aMeshShape._retn(); - } + GEOM::GEOM_Object_var anObj; + if (!owner || !appStudy) return GEOM::GEOM_Object::_nil(); + + _PTR(Study) study = appStudy->studyDS(); + QString entry = owner->entry(); + + _PTR(SObject) aSO(study->FindObjectID(entry.latin1())); + if (!aSO) + return GEOM::GEOM_Object::_nil(); + + CORBA::Object_var anObject = _CAST(SObject,aSO)->GetObject(); + anObj = GEOM::GEOM_Object::_narrow(anObject); + if (!CORBA::is_nil(anObj)) + return anObj._retn(); + + // Get geom object corresponding to the mesh + _PTR(ChildIterator) anIter = study->NewChildIterator(aSO); + for (; anIter->More(); anIter->Next()) { + _PTR(SObject) aSO = anIter->Value(); + if (!aSO) + continue; + _PTR(SObject) aRefSO; + _PTR(SObject) anObj; + if (aSO->ReferencedObject(aRefSO)) + anObj = aRefSO; + + if (!anObj) + anObj = aSO; + + anObject = _CAST(SObject,anObj)->GetObject(); + GEOM::GEOM_Object_var aMeshShape = GEOM::GEOM_Object::_narrow(anObject); + + if (!aMeshShape->_is_nil()) + return aMeshShape._retn(); } + + return GEOM::GEOM_Object::_nil(); } - -void SMESH_NumberFilter::SetSubShapeType( const TopAbs_ShapeEnum theSubShapeType ) +void SMESH_NumberFilter::SetSubShapeType (const TopAbs_ShapeEnum theSubShapeType) { mySubShapeType = theSubShapeType; } -void SMESH_NumberFilter::SetNumber( const int theNumber ) +void SMESH_NumberFilter::SetNumber (const int theNumber) { myNumber = theNumber; } -void SMESH_NumberFilter::SetClosedOnly( const bool theIsClosedOnly ) +void SMESH_NumberFilter::SetClosedOnly (const bool theIsClosedOnly) { myIsClosedOnly = theIsClosedOnly; } -void SMESH_NumberFilter::SetShapeType( const TopAbs_ShapeEnum theShapeType ) +void SMESH_NumberFilter::SetShapeType (const TopAbs_ShapeEnum theShapeType) { myShapeTypes.Add( theShapeType ); } -void SMESH_NumberFilter::SetMainShape( GEOM::GEOM_Object_ptr theMainObj ) +void SMESH_NumberFilter::SetMainShape (GEOM::GEOM_Object_ptr theMainObj) { - myMainObj = GEOM::GEOM_Object::_duplicate( theMainObj ); + myMainObj = GEOM::GEOM_Object::_duplicate(theMainObj); } - - - - - - - - - - - - - - - - - - - - - diff --git a/src/SMESHFiltersSelection/SMESH_NumberFilter.hxx b/src/SMESHFiltersSelection/SMESH_NumberFilter.hxx index a4fc8df16..6b3411293 100644 --- a/src/SMESHFiltersSelection/SMESH_NumberFilter.hxx +++ b/src/SMESHFiltersSelection/SMESH_NumberFilter.hxx @@ -1,124 +1,69 @@ -// SALOME SALOMEGUI : implementation of desktop and GUI kernel -// -// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -// -// -// // File : SMESH_NumberFilter.hxx -// Author : Sergey LITONIN // Module : SMESH #ifndef _SMESH_NumberFilter_HeaderFile #define _SMESH_NumberFilter_HeaderFile -#include -#include "SALOME_TypeFilter.hxx" +#include "SUIT_SelectionFilter.h" + #include #include #include -#include CORBA_SERVER_HEADER(SMESH_Mesh) #include CORBA_SERVER_HEADER(GEOM_Gen) -DEFINE_STANDARD_HANDLE( SMESH_NumberFilter, SALOME_TypeFilter ) +class SUIT_DataOwner; -/* - Class : SMESH_NumberFilter - Description : Filter for geom or smesh objects. - Filter geom objects by number of subshapes of the given type - Parameters of constructor: - * theSubShapeType - Type of subshape - * theNumber - Number of subshapes. Object is selected if it contains theNumber of - theSubShapeType sub-shapes - * theShapeType - This map specifies types of object to be selected - * theMainObject - Sub-shapes of this object is selected only - * theIsClosedOnly - Closed shapes is selected if this parameter is true -*/ -class SMESH_NumberFilter : public SALOME_TypeFilter +/*! + * Class : SMESH_NumberFilter + * Description : Filter for geom or smesh objects. + * Filter geom objects by number of subshapes of the given type + * Parameters of constructor: + * * theSubShapeType - Type of subshape + * * theNumber - Number of subshapes. Object is selected if it contains theNumber of + * theSubShapeType sub-shapes + * * theShapeType - This map specifies types of object to be selected + * * theMainObject - Sub-shapes of this object is selected only + * * theIsClosedOnly - Closed shapes is selected if this parameter is true + */ +class SMESH_NumberFilter : public SUIT_SelectionFilter { + public: + SMESH_NumberFilter (const char* theKind, + const TopAbs_ShapeEnum theSubShapeType, + const int theNumber, + const TopAbs_ShapeEnum theShapeType = TopAbs_SHAPE, + GEOM::GEOM_Object_ptr theMainObj = GEOM::GEOM_Object::_nil(), + const bool theIsClosedOnly = false ); -public: + SMESH_NumberFilter (const char* theKind, + const TopAbs_ShapeEnum theSubShapeType, + const int theNumber, + const TColStd_MapOfInteger& theShapeTypes, + GEOM::GEOM_Object_ptr theMainObj = GEOM::GEOM_Object::_nil(), + const bool theIsClosedOnly = false ); - SMESH_NumberFilter( const char* theKind, - const TopAbs_ShapeEnum theSubShapeType, - const int theNumber, - const TopAbs_ShapeEnum theShapeType = TopAbs_SHAPE, - GEOM::GEOM_Object_ptr theMainObj = GEOM::GEOM_Object::_nil(), - const bool theIsClosedOnly = false ); + virtual ~SMESH_NumberFilter(); - SMESH_NumberFilter( const char* theKind, - const TopAbs_ShapeEnum theSubShapeType, - const int theNumber, - const TColStd_MapOfInteger& theShapeTypes, - GEOM::GEOM_Object_ptr theMainObj = GEOM::GEOM_Object::_nil(), - const bool theIsClosedOnly = false ); - - virtual ~SMESH_NumberFilter(); - virtual Standard_Boolean IsOk( const Handle(SALOME_InteractiveObject)& ) const; - - void SetSubShapeType( const TopAbs_ShapeEnum ); - void SetNumber( const int ); - void SetClosedOnly( const bool ); - void SetShapeType( const TopAbs_ShapeEnum ); - void SetShapeTypes( const TColStd_MapOfInteger& ); - void SetMainShape( GEOM::GEOM_Object_ptr ); + virtual bool isOk (const SUIT_DataOwner*) const; -private: - GEOM::GEOM_Object_ptr getGeom( const Handle(SALOME_InteractiveObject)& theObj ) const; + void SetSubShapeType (const TopAbs_ShapeEnum); + void SetNumber (const int); + void SetClosedOnly (const bool); + void SetShapeType (const TopAbs_ShapeEnum); + void SetShapeTypes (const TColStd_MapOfInteger&); + void SetMainShape (GEOM::GEOM_Object_ptr); - -private: + private: + GEOM::GEOM_Object_ptr getGeom (const SUIT_DataOwner*) const; + + private: + char* myKind; TopAbs_ShapeEnum mySubShapeType; int myNumber; bool myIsClosedOnly; TColStd_MapOfInteger myShapeTypes; GEOM::GEOM_Object_var myMainObj; - -public: - DEFINE_STANDARD_RTTI( SMESH_NumberFilter ) }; #endif - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/SMESHFiltersSelection/SMESH_Type.h b/src/SMESHFiltersSelection/SMESH_Type.h index a3ba79fa0..f80b9cc28 100644 --- a/src/SMESHFiltersSelection/SMESH_Type.h +++ b/src/SMESHFiltersSelection/SMESH_Type.h @@ -7,6 +7,9 @@ // Copyright : Open CASCADE 2002 // $Header$ +#ifndef SMESH_TYPE_HEADER +#define SMESH_TYPE_HEADER + enum MeshObjectType { HYPOTHESIS, ALGORITHM, @@ -20,3 +23,5 @@ enum MeshObjectType { SUBMESH_COMPOUND, GROUP }; + +#endif diff --git a/src/SMESHFiltersSelection/SMESH_TypeFilter.cxx b/src/SMESHFiltersSelection/SMESH_TypeFilter.cxx index 9f17ae1b4..5e98287df 100644 --- a/src/SMESHFiltersSelection/SMESH_TypeFilter.cxx +++ b/src/SMESHFiltersSelection/SMESH_TypeFilter.cxx @@ -1,44 +1,38 @@ -// File : SMESH_TypeFilter.cxx -// Created : Fri Dec 07 09:57:24 2001 -// Author : Nicolas REJNERI -// Project : SALOME -// Module : SMESH -// Copyright : Open CASCADE -// $Header$ +#include "SMESH_TypeFilter.hxx" -#include "SMESH_TypeFilter.ixx" +#include -#include "SALOME_InteractiveObject.hxx" -#include "SALOME_TypeFilter.hxx" +#include +#include -#include "utilities.h" -#include "QAD_Application.h" -#include "QAD_Desktop.h" -#include "QAD_Study.h" - -using namespace std; - -SMESH_TypeFilter::SMESH_TypeFilter(MeshObjectType aType) +SMESH_TypeFilter::SMESH_TypeFilter (MeshObjectType theType) { - myKind = aType; + myType = theType; } -Standard_Boolean SMESH_TypeFilter::IsOk(const Handle(SALOME_InteractiveObject)& anObj) const +SMESH_TypeFilter::~SMESH_TypeFilter() { - Handle(SALOME_TypeFilter) meshFilter = new SALOME_TypeFilter( "SMESH" ); - if ( !meshFilter->IsOk(anObj) ) - return false; +} +bool SMESH_TypeFilter::isOk (const SUIT_DataOwner* theDataOwner) const +{ bool Ok = false; - if ( anObj->hasEntry() ) { - QAD_Study* ActiveStudy = QAD_Application::getDesktop()->getActiveStudy(); - SALOMEDS::Study_var aStudy = ActiveStudy->getStudyDocument(); - SALOMEDS::SObject_var obj = aStudy->FindObjectID( anObj->getEntry() ); + const SalomeApp_DataOwner* owner = + dynamic_cast(theDataOwner); + SalomeApp_Study* appStudy = dynamic_cast + (SUIT_Session::session()->activeApplication()->activeStudy()); + + if (owner && appStudy) { + _PTR(Study) study = appStudy->studyDS(); + QString entry = owner->entry(); + + _PTR(SObject) obj (study->FindObjectID(entry.latin1())); + if (!obj) return false; + + _PTR(SObject) objFather = obj->GetFather(); + _PTR(SComponent) objComponent = obj->GetFatherComponent(); - SALOMEDS::SObject_var objFather = obj->GetFather(); - SALOMEDS::SComponent_var objComponent = obj->GetFatherComponent(); - int aLevel = obj->Depth() - objComponent->Depth(); // Max level under the component is 4: @@ -55,10 +49,10 @@ Standard_Boolean SMESH_TypeFilter::IsOk(const Handle(SALOME_InteractiveObject)& // 4 | |- Applied algorithms ( selectable in Use Case Browser ) // |- Group Of Nodes - if ( aLevel <= 0 ) + if (aLevel <= 0) return false; - switch ( myKind ) + switch (myType) { case HYPOTHESIS: { @@ -133,3 +127,8 @@ Standard_Boolean SMESH_TypeFilter::IsOk(const Handle(SALOME_InteractiveObject)& } return Ok; } + +MeshObjectType SMESH_TypeFilter::type() const +{ + return myType; +} diff --git a/src/SMESHFiltersSelection/SMESH_TypeFilter.hxx b/src/SMESHFiltersSelection/SMESH_TypeFilter.hxx index 9e98ab8b8..442d72dad 100644 --- a/src/SMESHFiltersSelection/SMESH_TypeFilter.hxx +++ b/src/SMESHFiltersSelection/SMESH_TypeFilter.hxx @@ -1,95 +1,25 @@ -// File generated by CPPExt (Transient) -// -// Copyright (C) 1991,1995 by -// -// MATRA DATAVISION, FRANCE -// -// This software is furnished in accordance with the terms and conditions -// of the contract and with the inclusion of the above copyright notice. -// This software or any other copy thereof may not be provided or otherwise -// be made available to any other person. No title to an ownership of the -// software is hereby transferred. -// -// At the termination of the contract, the software and all copies of this -// software must be deleted. -// +// File : SMESH_TypeFilter.hxx +// Module : SMESH + #ifndef _SMESH_TypeFilter_HeaderFile #define _SMESH_TypeFilter_HeaderFile -#ifndef _Handle_SMESH_TypeFilter_HeaderFile -#include "Handle_SMESH_TypeFilter.hxx" -#endif - -#include "SALOME_InteractiveObject.hxx" -#include "SALOME_Filter.hxx" #include "SMESH_Type.h" +#include "SUIT_SelectionFilter.h" -// Open CASCADE Includes -#include - -class SMESH_TypeFilter : public SALOME_Filter { +class SUIT_DataOwner; +class SMESH_TypeFilter : public SUIT_SelectionFilter +{ public: + SMESH_TypeFilter (MeshObjectType theType); + ~SMESH_TypeFilter(); - inline void* operator new(size_t,void* anAddress) - { - return anAddress; - } - inline void* operator new(size_t size) - { - return Standard::Allocate(size); - } - inline void operator delete(void *anAddress) - { - if (anAddress) Standard::Free((Standard_Address&)anAddress); - } -// inline void operator delete(void *anAddress, size_t size) -// { -// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); -// } - // Methods PUBLIC - // -Standard_EXPORT SMESH_TypeFilter(MeshObjectType aType); -Standard_EXPORT virtual Standard_Boolean IsOk(const Handle(SALOME_InteractiveObject)& anobj) const; -Standard_EXPORT ~SMESH_TypeFilter(); - - - - - // Type management - // - Standard_EXPORT friend Handle_Standard_Type& SMESH_TypeFilter_Type_(); - Standard_EXPORT const Handle(Standard_Type)& DynamicType() const; - Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const; + virtual bool isOk (const SUIT_DataOwner*) const; + MeshObjectType type() const; protected: - - // Methods PROTECTED - // - - - // Fields PROTECTED - // -MeshObjectType myKind; - -private: - - // Methods PRIVATE - // - - - // Fields PRIVATE - // - - + MeshObjectType myType; }; - - - - -// other inline functions and methods (like "C++: function call" methods) -// - - #endif diff --git a/src/SMESHGUI/Makefile.in b/src/SMESHGUI/Makefile.in index bc02829e3..8c89e1772 100644 --- a/src/SMESHGUI/Makefile.in +++ b/src/SMESHGUI/Makefile.in @@ -43,15 +43,16 @@ EXPORT_HEADERS= SMESHGUI_Swig.hxx \ SMESHGUI_HypothesesUtils.h \ SMESHGUI_SpinBox.h \ SMESHGUI_aParameter.h \ - SMESHGUI_aParameterDlg.h + SMESHGUI_aParameterDlg.h \ + SMESHGUI_Selection.h # .po files to transform in .qm PO_FILES = \ - SMESH_icons.po \ + SMESH_images.po \ SMESH_msg_en.po # Libraries targets -LIB = libSMESHGUI.la +LIB = libSMESH.la LIB_SRC = SMESHGUI.cxx \ SMESHGUI_PatternWidget.cxx \ SMESHGUI_CreatePatternDlg.cxx \ @@ -96,7 +97,6 @@ LIB_SRC = SMESHGUI.cxx \ SMESHGUI_SewingDlg.cxx \ SMESHGUI_MergeNodesDlg.cxx \ SMESHGUI_Utils.cxx \ - SMESHGUI_SMESHGenUtils.cxx \ SMESHGUI_GEOMGenUtils.cxx \ SMESHGUI_MeshUtils.cxx \ SMESHGUI_GroupUtils.cxx \ @@ -104,7 +104,9 @@ LIB_SRC = SMESHGUI.cxx \ SMESHGUI_PatternUtils.cxx \ SMESHGUI_HypothesesUtils.cxx \ SMESHGUI_PrecisionDlg.cxx \ - SMESHGUI_VTKUtils.cxx + SMESHGUI_VTKUtils.cxx \ + SMESHGUI_Selection.cxx \ + SMESHGUI_CreatePolyhedralVolumeDlg.cxx LIB_MOC = \ SMESHGUI.h \ @@ -146,7 +148,8 @@ LIB_MOC = \ SMESHGUI_SymmetryDlg.h \ SMESHGUI_SewingDlg.h \ SMESHGUI_PrecisionDlg.h \ - SMESHGUI_MergeNodesDlg.h + SMESHGUI_MergeNodesDlg.h \ + SMESHGUI_CreatePolyhedralVolumeDlg.h LIB_CLIENT_IDL = SALOME_Exception.idl \ GEOM_Gen.idl \ @@ -171,13 +174,14 @@ LIB_SERVER_IDL = #BIN = SMESHBin CPPFLAGS += $(QT_INCLUDES) $(VTK_INCLUDES) $(OGL_INCLUDES) $(OCC_INCLUDES) $(PYTHON_INCLUDES) \ - -I${KERNEL_ROOT_DIR}/include/salome -I${GEOM_ROOT_DIR}/include/salome \ - $(BOOST_CPPFLAGS) + -I${KERNEL_ROOT_DIR}/include/salome -I${GUI_ROOT_DIR}/include/salome \ + -I${GEOM_ROOT_DIR}/include/salome $(BOOST_CPPFLAGS) -CXXFLAGS += -I${KERNEL_ROOT_DIR}/include/salome -I${GEOM_ROOT_DIR}/include/salome +CXXFLAGS += -I${KERNEL_ROOT_DIR}/include/salome -I${GUI_ROOT_DIR}/include/salome \ + -I${GEOM_ROOT_DIR}/include/salome -LDFLAGS += -lSMESHObject -lSMESHFiltersSelection -lSMDS -lSMESHControls -lDlgRef $(OCC_KERNEL_LIBS) -lTKBO -L${KERNEL_ROOT_DIR}/lib/salome -lVTKViewer -lSalomeGUI -lSalomePrs -lSalomeNS -lqsplitterP -lSalomeLifeCycleCORBA -lOpUtil -lSalomeObject -lEvent -lSALOMELocalTrace -lSalomeVTKFilter -lOCCViewer -L${GEOM_ROOT_DIR}/lib/salome -lGEOMGUI -lGEOMClient -lGEOMFiltersSelection -lGEOMBase -lGEOMObject +LDFLAGS += -lSMESHObject -lSMESHFiltersSelection -lSMDS -lSMESHControls -lDlgRef $(OCC_KERNEL_LIBS) -lTKBO -L${KERNEL_ROOT_DIR}/lib/salome -L${GUI_ROOT_DIR}/lib/salome -lVTKViewer -lSalomeApp -lSalomePrs -lSalomeNS -lSalomeLifeCycleCORBA -lOpUtil -lSalomeObject -lEvent -lSALOMELocalTrace -lSVTK -lOCCViewer -L${GEOM_ROOT_DIR}/lib/salome -lGEOM -lGEOMClient -lGEOMBase -lGEOMObject LDFLAGSFORBIN += $(LDFLAGS) diff --git a/src/SMESHGUI/SMESHGUI.cxx b/src/SMESHGUI/SMESHGUI.cxx index 34c82ee21..21faa6d72 100644 --- a/src/SMESHGUI/SMESHGUI.cxx +++ b/src/SMESHGUI/SMESHGUI.cxx @@ -3,11 +3,11 @@ // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License. -// +// // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU @@ -15,7 +15,7 @@ // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org // @@ -62,37 +62,48 @@ #include "SMESHGUI_MergeNodesDlg.h" #include "SMESHGUI_MeshPatternDlg.h" #include "SMESHGUI_PrecisionDlg.h" +#include "SMESHGUI_Selection.h" +#include "SMESHGUI_CreatePolyhedralVolumeDlg.h" -#include "VTKViewer_ViewFrame.h" -#include "VTKViewer_InteractorStyleSALOME.h" -#include "VTKViewer_RenderWindowInteractor.h" +#include +#include #include "SMESH_Actor.h" #include "SMESH_Object.h" +#include "SMESH_TypeFilter.hxx" -#include "QAD.h" -#include "QAD_Tools.h" -#include "QAD_Config.h" -#include "QAD_Settings.h" -#include "QAD_RightFrame.h" -#include "QAD_MessageBox.h" -#include "QAD_Resource.h" -#include "QAD_FileDlg.h" -#include "QAD_Desktop.h" -#include "QAD_ResourceMgr.h" -#include "QAD_WaitCursor.h" +#include "SUIT_Tools.h" +#include "SUIT_MessageBox.h" +#include "SUIT_ResourceMgr.h" +#include "SUIT_FileDlg.h" +#include "SUIT_Desktop.h" +#include "SUIT_ResourceMgr.h" +#include "SUIT_OverrideCursor.h" +#include "SUIT_Study.h" +#include "SUIT_Session.h" #include "SALOME_NamingService.hxx" #include "SALOME_ListIteratorOfListIO.hxx" #include "SALOME_InteractiveObject.hxx" +#include "SALOME_ListIO.hxx" +#include -#include "SALOMEGUI_Desktop.h" -#include "SALOMEGUI_NameDlg.h" -#include "SALOMEGUI_ImportOperation.h" -#include "SALOMEGUI_QtCatchCorbaException.hxx" +#include "OB_Browser.h" + +#include "QtxPopupMgr.h" + +#include "SalomeApp_Application.h" +#include "SalomeApp_NameDlg.h" +#include "SalomeApp_DataOwner.h" +#include "SalomeApp_ImportOperation.h" +#include "SalomeApp_Tools.h" +#include "SalomeApp_Study.h" +#include "SalomeApp_VTKSelector.h" + +#include +#include #include "SMESHGUI_Utils.h" -#include "SMESHGUI_SMESHGenUtils.h" #include "SMESHGUI_GEOMGenUtils.h" #include "SMESHGUI_MeshUtils.h" #include "SMESHGUI_GroupUtils.h" @@ -119,6 +130,7 @@ #include #include #include +#include #include #include @@ -131,16 +143,19 @@ #include "utilities.h" +#include "SALOMEDS_Study.hxx" +#include "SALOMEDSClient_StudyBuilder.hxx" +#include "SALOMEDSClient_SComponent.hxx" + using namespace std; namespace{ // Decalarations //============================================================= - void ImportMeshesFromFile(QAD_Desktop * parent, - SMESH::SMESH_Gen_ptr theComponentMesh, + void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh, int theCommandID); - void ExportMeshToFile(QAD_Desktop * parent, int theCommandID); + void ExportMeshToFile(int theCommandID); void SetDisplayMode(int theCommandID); @@ -153,8 +168,7 @@ namespace{ // Definitions //============================================================= - void ImportMeshesFromFile(QAD_Desktop * parent, - SMESH::SMESH_Gen_ptr theComponentMesh, + void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh, int theCommandID) { QStringList filter; @@ -168,14 +182,14 @@ namespace{ }else if (theCommandID == 111){ filter.append(QObject::tr("DAT files (*.dat)")); } - QString filename = QAD_FileDlg::getFileName(parent, + QString filename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), "", filter, QObject::tr("Import mesh"), true); if(!filename.isEmpty()) { - QAD_WaitCursor wc; - SALOMEDS::Study_var aStudy = SMESH::GetActiveStudyDocument(); + SUIT_OverrideCursor wc; + _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); try { SMESH::mesh_array_var aMeshes = new SMESH::mesh_array; @@ -191,13 +205,13 @@ namespace{ SMESH::DriverMED_ReadStatus res; aMeshes = theComponentMesh->CreateMeshesFromMED(filename.latin1(),res); if ( res != SMESH::DRS_OK ) { - wc.stop(); - QAD_MessageBox::warn1(QAD_Application::getDesktop(), + wc.suspend(); + SUIT_MessageBox::warn1(SMESHGUI::desktop(), QObject::tr("SMESH_WRN_WARNING"), QObject::tr(QString("SMESH_DRS_%1").arg(res)), QObject::tr("SMESH_BUT_OK")); aMeshes->length( 0 ); - wc.start(); + wc.resume(); } break; } @@ -205,10 +219,10 @@ namespace{ bool isEmpty = false; for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) { - SALOMEDS::SObject_var aMeshSO = SMESH::FindSObject( aMeshes[i] ); - if ( !aMeshSO->_is_nil() ) { - SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder(); - SALOMEDS::AttributePixMap_var aPixmap = SALOMEDS::AttributePixMap::_narrow( aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" ) ); + _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] ); + if ( aMeshSO ) { + _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder(); + _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" ); aPixmap->SetPixMap("ICON_SMESH_TREE_MESH_IMPORTED"); if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() ); @@ -217,43 +231,50 @@ namespace{ } if ( isEmpty ) { - wc.stop(); - QAD_MessageBox::warn1(QAD_Application::getDesktop(), + wc.suspend(); + SUIT_MessageBox::warn1(SMESHGUI::desktop(), QObject::tr("SMESH_WRN_WARNING"), QObject::tr("SMESH_DRS_EMPTY"), QObject::tr("SMESH_BUT_OK")); - wc.start(); + wc.resume(); } } catch (const SALOME::SALOME_Exception& S_ex){ - wc.stop(); - QtCatchCorbaException(S_ex); - wc.start(); + wc.suspend(); + SalomeApp_Tools::QtCatchCorbaException(S_ex); + wc.resume(); } } } - void ExportMeshToFile(QAD_Desktop * parent, int theCommandID) + void ExportMeshToFile( int theCommandID ) { - SALOME_Selection *aSel = SALOME_Selection::Selection(SMESH::GetActiveStudy()->getSelection()); - if(aSel->IObjectCount()){ - Handle(SALOME_InteractiveObject) anIObject = aSel->firstIObject(); + SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr(); + SALOME_ListIO selected; + if( aSel ) + aSel->selectedObjects( selected ); + + if(selected.Extent()){ + Handle(SALOME_InteractiveObject) anIObject = selected.First(); SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface(anIObject); if ( !aMesh->_is_nil() ) { QString aFilter, aTitle = QObject::tr("Export mesh"); QMap aFilterMap; switch ( theCommandID ) { + case 125: case 122: aFilterMap.insert( QObject::tr("MED 2.1 (*.med)"), SMESH::MED_V2_1 ); aFilterMap.insert( QObject::tr("MED 2.2 (*.med)"), SMESH::MED_V2_2 ); break; + case 124: case 121: aFilter = QObject::tr("DAT files (*.dat)"); break; + case 126: case 123: { if(aMesh->NbPyramids()){ - int aRet = QAD_MessageBox::warn2(QAD_Application::getDesktop(), + int aRet = SUIT_MessageBox::warn2(SMESHGUI::desktop(), QObject::tr("SMESH_WRN_WARNING"), QObject::tr("SMESH_EXPORT_UNV").arg(anIObject->getName()), QObject::tr("SMESH_BUT_YES"), @@ -267,39 +288,55 @@ namespace{ default: return; }} - + QString aFilename; SMESH::MED_VERSION aFormat; - - if ( theCommandID != 122) - aFilename = QAD_FileDlg::getFileName(parent, "", aFilter, aTitle, false); + + if ( theCommandID != 122 && theCommandID != 125 ) + aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), "", aFilter, aTitle, false); else { QStringList filters; for ( QMap::const_iterator it = aFilterMap.begin(); it != aFilterMap.end(); ++it ) filters.push_back( it.key() ); - QAD_FileDlg* fd = new QAD_FileDlg( parent, false, true, true ); + SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true ); fd->setCaption( aTitle ); fd->setFilters( filters ); fd->exec(); aFilename = fd->selectedFile(); aFormat = aFilterMap[fd->selectedFilter()]; delete fd; + if( !aFilename.isEmpty() + && (aMesh->NbPolygons()>0 or aMesh->NbPolyhedrons()>0) + && aFormat==SMESH::MED_V2_1){ + int aRet = SUIT_MessageBox::warn2(SMESHGUI::desktop(), + QObject::tr("SMESH_WRN_WARNING"), + QObject::tr("SMESH_EXPORT_MED_V2_1").arg(anIObject->getName()), + QObject::tr("SMESH_BUT_YES"), + QObject::tr("SMESH_BUT_NO"), + 0,1,0); + if(aRet){ + return; + } + } } if ( !aFilename.isEmpty() ) { // Check whether the file already exists and delete it if yes QFile aFile( aFilename ); if ( aFile.exists() ) aFile.remove(); - QAD_WaitCursor wc; + SUIT_OverrideCursor wc; switch ( theCommandID ) { + case 125: case 122: aMesh->ExportToMED( aFilename.latin1(), false, aFormat ); // currently, automatic groups are never created break; + case 124: case 121: aMesh->ExportDAT( aFilename.latin1() ); break; + case 126: case 123: aMesh->ExportUNV( aFilename.latin1() ); break; @@ -309,8 +346,8 @@ namespace{ } } } - } - + } + inline void InverseEntityMode(unsigned int& theOutputMode, unsigned int theMode) { @@ -322,9 +359,13 @@ namespace{ } void SetDisplayEntity(int theCommandID){ - SALOME_Selection *Sel = SALOME_Selection::Selection(SMESH::GetActiveStudy()->getSelection()); - if(Sel->IObjectCount() >= 1){ - SALOME_ListIteratorOfListIO It(Sel->StoredIObjects()); + SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr(); + SALOME_ListIO selected; + if( aSel ) + aSel->selectedObjects( selected ); + + if(selected.Extent() >= 1){ + SALOME_ListIteratorOfListIO It( selected ); for(; It.More(); It.Next()){ Handle(SALOME_InteractiveObject) IObject = It.Value(); if(IObject->hasEntry()){ @@ -353,20 +394,24 @@ namespace{ } void SetDisplayMode(int theCommandID){ - SALOME_Selection *Sel = SALOME_Selection::Selection(SMESH::GetActiveStudy()->getSelection()); - if(Sel->IObjectCount() >= 1){ + SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr(); + SALOME_ListIO selected; + if( aSel ) + aSel->selectedObjects( selected ); + + if(selected.Extent() >= 1){ switch(theCommandID){ case 1134:{ SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog(); - new SMESHGUI_ClippingDlg(QAD_Application::getDesktop(),"",false); + new SMESHGUI_ClippingDlg( SMESHGUI::GetSMESHGUI(), "", false ); return; } case 1133:{ SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog(); - new SMESHGUI_TransparencyDlg(QAD_Application::getDesktop(),"",false); + new SMESHGUI_TransparencyDlg( SMESHGUI::desktop(), "", false ); return; }} - SALOME_ListIteratorOfListIO It(Sel->StoredIObjects()); + SALOME_ListIteratorOfListIO It( selected ); for(; It.More(); It.Next()){ Handle(SALOME_InteractiveObject) IObject = It.Value(); if(IObject->hasEntry()){ @@ -379,7 +424,7 @@ namespace{ anActor->SetRepresentation(SMESH_Actor::eSurface); break; case 213: - if(anActor->IsShrunk()) + if(anActor->IsShrunk()) anActor->UnShrink(); else anActor->SetShrink(); @@ -394,36 +439,36 @@ namespace{ int c1 = int (color[1] * 255); int c2 = int (color[2] * 255); QColor c(c0, c1, c2); - + float edgecolor[3]; anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]); c0 = int (edgecolor[0] * 255); c1 = int (edgecolor[1] * 255); c2 = int (edgecolor[2] * 255); QColor e(c0, c1, c2); - + float backfacecolor[3]; anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]); c0 = int (backfacecolor[0] * 255); c1 = int (backfacecolor[1] * 255); c2 = int (backfacecolor[2] * 255); QColor b(c0, c1, c2); - + float nodecolor[3]; anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]); c0 = int (nodecolor[0] * 255); c1 = int (nodecolor[1] * 255); c2 = int (nodecolor[2] * 255); QColor n(c0, c1, c2); - + int Edgewidth = (int)anActor->GetLineWidth(); if(Edgewidth == 0) Edgewidth = 1; int intValue = int(anActor->GetNodeSize()); float Shrink = anActor->GetShrinkFactor(); - - SMESHGUI_Preferences_ColorDlg *aDlg = - new SMESHGUI_Preferences_ColorDlg(QAD_Application::getDesktop(),""); + + SMESHGUI_Preferences_ColorDlg *aDlg = + new SMESHGUI_Preferences_ColorDlg(SMESHGUI::desktop(),""); aDlg->SetColor(1, c); aDlg->SetColor(2, e); aDlg->SetColor(3, n); @@ -438,27 +483,27 @@ namespace{ QColor backfacecolor = aDlg->GetColor(4); /* actor color and backface color */ anActor->SetSufaceColor(float (color.red()) / 255., - float (color.green()) / 255., + float (color.green()) / 255., float (color.blue()) / 255.); - anActor->SetBackSufaceColor(float (backfacecolor.red()) / 255., + anActor->SetBackSufaceColor(float (backfacecolor.red()) / 255., float (backfacecolor.green()) / 255., float (backfacecolor.blue()) / 255.); - + /* edge color */ anActor->SetEdgeColor(float (edgecolor.red()) / 255., float (edgecolor.green()) / 255., float (edgecolor.blue()) / 255.); - + /* Shrink factor and size edges */ anActor->SetShrinkFactor(aDlg->GetIntValue(3) / 100.); anActor->SetLineWidth(aDlg->GetIntValue(1)); - + /* Nodes color and size */ anActor->SetNodeColor(float (nodecolor.red()) / 255., float (nodecolor.green()) / 255., float (nodecolor.blue()) / 255.); anActor->SetNodeSize(aDlg->GetIntValue(2)); - + delete aDlg; } break; @@ -473,94 +518,59 @@ namespace{ void SetDisplaySettings() { + SUIT_ResourceMgr* mgr = SMESHGUI::resourceMgr(); + if( !mgr ) + return; + SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog(); SMESHGUI_Preferences_ColorDlg *aDlg = - new SMESHGUI_Preferences_ColorDlg(QAD_Application::getDesktop(), ""); + new SMESHGUI_Preferences_ColorDlg(SMESHGUI::desktop(), ""); - QColor color; - QString SCr, SCg, SCb; - SCr = QAD_CONFIG->getSetting("SMESH:SettingsFillColorRed"); - SCg = QAD_CONFIG->getSetting("SMESH:SettingsFillColorGreen"); - SCb = QAD_CONFIG->getSetting("SMESH:SettingsFillColorBlue"); - if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty()) - color = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt()); - else color = QColor(0, 170, 255); + QColor color = mgr->colorValue( "SMESH", "SettingsFillColor", QColor(0, 170, 255) ); aDlg->SetColor(1, color); - - SCr = QAD_CONFIG->getSetting("SMESH:SettingsOutlineColorRed"); - SCg = QAD_CONFIG->getSetting("SMESH:SettingsOutlineColorGreen"); - SCb = QAD_CONFIG->getSetting("SMESH:SettingsOutlineColorBlue"); - if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty()) - color = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt()); - else color = QColor(0, 170, 255); + + color = mgr->colorValue( "SMESH", "SettingsOutlineColor", QColor(0, 170, 255) ); aDlg->SetColor(2, color); - - SCr = QAD_CONFIG->getSetting("SMESH:SettingsNodeColorRed"); - SCg = QAD_CONFIG->getSetting("SMESH:SettingsNodeColorGreen"); - SCb = QAD_CONFIG->getSetting("SMESH:SettingsNodeColorBlue"); - if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty()) - color = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt()); - else color = Qt::red; + + color = mgr->colorValue( "SMESH", "SettingsNodeColor", Qt::red ); aDlg->SetColor(3, color); - - QString SBr = QAD_CONFIG->getSetting("SMESH:SettingsBackFaceColorRed"); - QString SBg = QAD_CONFIG->getSetting("SMESH:SettingsBackFaceColorGreen"); - QString SBb = QAD_CONFIG->getSetting("SMESH:SettingsBackFaceColorBlue"); - if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty()) - color = QColor(SBr.toInt(), SBg.toInt(), SBb.toInt()); - else color = Qt::blue; + + color = mgr->colorValue( "SMESH", "SettingsBackFaceColor", Qt::blue ); aDlg->SetColor(4, color); - - QString intValue = QAD_CONFIG->getSetting("SMESH:SettingsWidth"); - if (intValue.isEmpty()) intValue = "1"; - aDlg->SetIntValue(1, intValue.toInt()); - intValue = QAD_CONFIG->getSetting("SMESH:SettingsNodesSize"); - if (intValue.isEmpty()) intValue = "3"; - aDlg->SetIntValue(2, intValue.toInt()); - intValue = QAD_CONFIG->getSetting("SMESH:SettingsShrinkCoeff"); - if (intValue.isEmpty()) intValue = "75"; - aDlg->SetIntValue(3, intValue.toInt()); - + + int iVal = mgr->integerValue( "SMESH", "SettingsWidth", 1 ); + aDlg->SetIntValue(1, iVal); + + iVal = mgr->integerValue( "SMESH", "SettingsNodesSize", 3 ); + aDlg->SetIntValue(2, iVal); + + iVal = mgr->integerValue( "SMESH", "SettingsShrinkCoeff", 75 ); + aDlg->SetIntValue(3, iVal); + if (aDlg->exec()) { - QColor colorFill = aDlg->GetColor(1); - QAD_CONFIG->addSetting("SMESH:SettingsFillColorRed", colorFill.red()); - QAD_CONFIG->addSetting("SMESH:SettingsFillColorGreen", colorFill.green()); - QAD_CONFIG->addSetting("SMESH:SettingsFillColorBlue", colorFill.blue()); - - QColor colorOutline = aDlg->GetColor(2); - QAD_CONFIG->addSetting("SMESH:SettingsOutlineColorRed", colorOutline.red()); - QAD_CONFIG->addSetting("SMESH:SettingsOutlineColorGreen", colorOutline.green()); - QAD_CONFIG->addSetting("SMESH:SettingsOutlineColorBlue", colorOutline.blue()); - - QColor colorNode = aDlg->GetColor(3); - QAD_CONFIG->addSetting("SMESH:SettingsNodeColorRed", colorNode.red()); - QAD_CONFIG->addSetting("SMESH:SettingsNodeColorGreen", colorNode.green()); - QAD_CONFIG->addSetting("SMESH:SettingsNodeColorBlue", colorNode.blue()); - - QColor colorBackFace = aDlg->GetColor(4); - QAD_CONFIG->addSetting("SMESH:SettingsBackFaceColorRed", colorBackFace.red()); - QAD_CONFIG->addSetting("SMESH:SettingsBackFaceColorGreen", colorBackFace.green()); - QAD_CONFIG->addSetting("SMESH:SettingsBackFaceColorBlue", colorBackFace.blue()); - - int width = aDlg->GetIntValue(1); - QAD_CONFIG->addSetting("SMESH:SettingsWidth", width); - - int nodes_size = aDlg->GetIntValue(2); - QAD_CONFIG->addSetting("SMESH:SettingsNodesSize", nodes_size); - - int shrink_coeff = aDlg->GetIntValue(3); - QAD_CONFIG->addSetting("SMESH:SettingsShrinkCoeff", shrink_coeff); + mgr->setValue( "SMESH", "SettingsFillColor", aDlg->GetColor(1) ); + mgr->setValue( "SMESH", "SettingsOutlineColor", aDlg->GetColor(2) ); + mgr->setValue( "SMESH", "SettingsNodeColor", aDlg->GetColor(3) ); + mgr->setValue( "SMESH", "SettingsBackFaceColor", aDlg->GetColor(4) ); + + mgr->setValue( "SMESH", "SettingsWidth", aDlg->GetIntValue(1) ); + mgr->setValue( "SMESH", "SettingsNodesSize", aDlg->GetIntValue(2) ); + mgr->setValue( "SMESH", "SettingsShrinkCoeff", aDlg->GetIntValue(3) ); } delete aDlg; } - + void Control( int theCommandID ) { - SALOME_Selection *Sel = SALOME_Selection::Selection( SMESH::GetActiveStudy()->getSelection() ); - if(Sel){ - Handle(SALOME_InteractiveObject) anIO = Sel->firstIObject(); + SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr(); + SALOME_ListIO selected; + if( aSel ) + aSel->selectedObjects( selected ); + + if( !selected.IsEmpty() ){ + Handle(SALOME_InteractiveObject) anIO = selected.First(); if(!anIO.IsNull()){ QString aTitle; SMESH_Actor::eControl aControl = SMESH_Actor::eNone; @@ -625,7 +635,7 @@ namespace{ } } } - + bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO, MeshObjectType theType, @@ -633,25 +643,31 @@ namespace{ QString & theOutTypeName) { SMESH_TypeFilter aTypeFilter( theType ); - if ( aTypeFilter.IsOk( theIO )) { - theOutTypeName = theInTypeName; - return true; + QString entry; + if( !theIO.IsNull() ) + { + entry = theIO->getEntry(); + SalomeApp_DataOwner owner( entry ); + if ( aTypeFilter.isOk( &owner )) { + theOutTypeName = theInTypeName; + return true; + } } return false; } - + QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO) { - SALOMEDS::Study_var aStudy = SMESH::GetActiveStudyDocument(); - SALOMEDS::SObject_var aSObj = aStudy->FindObjectID(theIO->getEntry()); - if (!aSObj->_is_nil()) { - SALOMEDS::SComponent_var aSComp = aSObj->GetFatherComponent(); - CORBA::String_var anID = aSComp->GetID(); + _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); + _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry()); + if (aSObj) { + _PTR(SComponent) aSComp = aSObj->GetFatherComponent(); + CORBA::String_var anID = aSComp->GetID().c_str(); if (!strcmp(anID.in(),theIO->getEntry())) return "Component"; } - + QString aTypeName; if ( CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) || @@ -661,25 +677,21 @@ namespace{ CheckOIType ( theIO, GROUP, "Group", aTypeName ) ) return aTypeName; - + return "NoType"; } QString CheckHomogeneousSelection() { - QAD_Study* aStudy = SMESH::GetActiveStudy(); - SALOME_Selection *aSel = SALOME_Selection::Selection(aStudy->getSelection()); - /* copy the list */ - SALOME_ListIO List; - SALOME_ListIteratorOfListIO Itinit(aSel->StoredIObjects()); - for (; Itinit.More(); Itinit.Next()) - { - List.Append(Itinit.Value()); - } + //SUIT_Study* aStudy = SMESH::GetActiveStudy(); + SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr(); + SALOME_ListIO selected; + if( aSel ) + aSel->selectedObjects( selected ); - QString RefType = CheckTypeObject(aSel->firstIObject()); - SALOME_ListIteratorOfListIO It(List); + QString RefType = CheckTypeObject(selected.First()); + SALOME_ListIteratorOfListIO It(selected); for (; It.More(); It.Next()) { Handle(SALOME_InteractiveObject) IObject = It.Value(); @@ -687,87 +699,91 @@ namespace{ if (Type.compare(RefType) != 0) return "Heterogeneous Selection"; } - - aSel->ClearIObjects(); - SALOME_ListIteratorOfListIO It1(List); - for (; It1.More(); It1.Next()) - { - int res = aSel->AddIObject(It1.Value()); - if (res == -1) - aStudy->highlight(It1.Value(), false); - if (res == 0) - aStudy->highlight(It1.Value(), true); - } + return RefType; } void OnEditDelete() { // VSR 17/11/04: check if all objects selected belong to SMESH component --> start - QString aParentComponent = ((SALOMEGUI_Desktop*)QAD_Application::getDesktop())->getComponentFromSelection(); - if ( aParentComponent != QAD_Application::getDesktop()->getActiveComponent() ) { - QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), - QObject::tr("ERR_ERROR"), - QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg(QAD_Application::getDesktop()->getComponentUserName( "SMESH" )), + SalomeApp_SelectionMgr* aSel = SMESHGUI::selectionMgr(); + SALOME_ListIO selected; aSel->selectedObjects( selected ); + + QString aParentComponent = QString::null; + for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() ) + { + QString cur = anIt.Value()->getComponentDataType(); + if( aParentComponent.isNull() ) + aParentComponent = cur; + else if( !aParentComponent.isEmpty() && aParentComponent!=cur ) + aParentComponent = ""; + } + + if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) { + SUIT_MessageBox::warn1 ( SMESHGUI::desktop(), + QObject::tr("ERR_ERROR"), + QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ), QObject::tr("BUT_OK") ); return; } // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish - if (QAD_MessageBox::warn2 - (QAD_Application::getDesktop(), + if (SUIT_MessageBox::warn2 + (SMESHGUI::desktop(), QObject::tr("SMESH_WRN_WARNING"), QObject::tr("SMESH_REALLY_DELETE"), QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"), 1, 0, 0) != 1) return; - QAD_Study* anActiveStudy = SMESH::GetActiveStudy(); - int nbSf = anActiveStudy->getStudyFramesCount(); - - SALOMEDS::Study_var aStudy = SMESH::GetActiveStudyDocument(); - SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeIOR_var anIOR; - - SALOME_Selection *Sel = SALOME_Selection::Selection(anActiveStudy->getSelection()); - SALOME_ListIteratorOfListIO It(Sel->StoredIObjects()); + SalomeApp_Application* anApp = dynamic_cast( SUIT_Session::session()->activeApplication() ); + SUIT_ViewManager* vm = anApp->activeViewManager(); + int nbSf = vm->getViewsCount(); + + _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); + _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder(); + _PTR(GenericAttribute) anAttr; + _PTR(AttributeIOR) anIOR; + + SALOME_ListIteratorOfListIO It(selected); aStudyBuilder->NewCommand(); // There is a transaction for(; It.More(); It.Next()){ Handle(SALOME_InteractiveObject) IObject = It.Value(); if(IObject->hasEntry()){ - SALOMEDS::SObject_var SO = aStudy->FindObjectID(IObject->getEntry()); - + _PTR(SObject) SO = aStudy->FindObjectID(IObject->getEntry()); + /* Erase child graphical objects */ - SALOMEDS::ChildIterator_var it = aStudy->NewChildIterator(SO); + _PTR(ChildIterator) it = aStudy->NewChildIterator(SO); for(it->InitEx(true); it->More(); it->Next()){ - SALOMEDS::SObject_var CSO = it->Value(); + _PTR(SObject) CSO = it->Value(); if(CSO->FindAttribute(anAttr, "AttributeIOR")){ - anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - + anIOR = anAttr; + + QPtrVector aViews = vm->getViews(); for(int i = 0; i < nbSf; i++){ - QAD_StudyFrame *sf = anActiveStudy->getStudyFrame(i); - CORBA::String_var anEntry = CSO->GetID(); + SUIT_ViewWindow *sf = aViews[i]; + CORBA::String_var anEntry = CSO->GetID().c_str(); if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.in())){ SMESH::RemoveActor(sf,anActor); } } } } - + /* Erase main graphical object */ + QPtrVector aViews = vm->getViews(); for(int i = 0; i < nbSf; i++){ - QAD_StudyFrame *sf = anActiveStudy->getStudyFrame(i); + SUIT_ViewWindow *sf = aViews[i]; if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,IObject->getEntry())){ SMESH::RemoveActor(sf,anActor); } } - + // Remove object(s) from data structures - SALOMEDS::SObject_var obj = aStudy->FindObjectID(IObject->getEntry()); - if(!obj->_is_nil()){ - SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow(obj->GetObject()); - SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow(obj->GetObject()); - + _PTR(SObject) obj = aStudy->FindObjectID(IObject->getEntry()); + if(obj){ + SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( obj ) ); + SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( obj ) ); + if ( !aGroup->_is_nil() ) { // DELETE GROUP SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh(); aMesh->RemoveGroup( aGroup ); @@ -778,23 +794,23 @@ namespace{ } else {// default action: remove SObject from the study // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH - //QAD_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy); + //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy); //op->start(); aStudyBuilder->RemoveObjectWithChildren( obj ); //op->finish(); } } - + } /* IObject->hasEntry() */ } /* more/next */ aStudyBuilder->CommitCommand(); - + /* Clear any previous selection */ - Sel->ClearIObjects(); - anActiveStudy->updateObjBrowser(); + SALOME_ListIO selected1; + aSel->setSelectedObjects( selected1 ); + + SMESHGUI::GetSMESHGUI()->updateObjBrowser(); } - - } //============================================================================= @@ -833,21 +849,36 @@ private: QFont myFont; }; +extern "C" { + Standard_EXPORT CAM_Module* createModule() + { + return SMESHGUI::GetSMESHGUI(); + } +} + +SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil(); + //============================================================================= /*! * */ //============================================================================= -SMESHGUI::SMESHGUI( const QString& theName, QObject* theParent ) : - SALOMEGUI( theName, theParent ) +SMESHGUI::SMESHGUI() : + SalomeApp_Module( "SMESH" ) { + if ( CORBA::is_nil( myComponentSMESH ) ) + { + SALOME_LifeCycleCORBA* ls = new SALOME_LifeCycleCORBA( getApp()->namingService() ); + Engines::Component_var comp = ls->FindOrLoad_Component( "FactoryServer", "SMESH" ); + myComponentSMESH = SMESH::SMESH_Gen::_narrow( comp ); + } + myActiveDialogBox = 0 ; myState = -1 ; - SMESH::GetSMESHGen(); SMESH::GetFilterManager(); SMESH::GetPattern(); - + /* load resources for all available meshers */ SMESH::InitAvailableHypotheses(); } @@ -862,6 +893,30 @@ SMESHGUI::~SMESHGUI() SMESH::GetFilterManager()->Destroy(); } +//============================================================================= +/*! + * + */ +//============================================================================= +SalomeApp_SelectionMgr* SMESHGUI::selectionMgr() +{ + SalomeApp_Application* anApp = dynamic_cast( SUIT_Session::session()->activeApplication() ); + if( anApp ) + return dynamic_cast( anApp->selectionMgr() ); + else + return 0; +} + +//============================================================================= +/*! + * + */ +//============================================================================= +SUIT_ResourceMgr* SMESHGUI::resourceMgr() +{ + return dynamic_cast( SUIT_Session::session()->resourceMgr() ); +} + //============================================================================= /*! * @@ -869,19 +924,24 @@ SMESHGUI::~SMESHGUI() //============================================================================= SMESHGUI* SMESHGUI::GetSMESHGUI() { - static SMESHGUI aSMESHGUI; - aSMESHGUI.myActiveStudy = SMESH::GetActiveStudy(); - SMESH::GetSMESHGen()->SetCurrentStudy( SMESH::GetActiveStudyDocument() ); + static SMESHGUI* aSMESHGUI = NULL; + if( !aSMESHGUI ) + aSMESHGUI = new SMESHGUI(); + if(_PTR(Study) aStudy = SMESH::GetActiveStudyDocument()) + GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() ); + + SUIT_ResourceMgr* mgr = resourceMgr(); + if( mgr ) /* Automatic Update flag */ - aSMESHGUI.myAutomaticUpdate = ( QAD_CONFIG->getSetting( "SMESH:AutomaticUpdate" ).compare( "true" ) == 0 ); + aSMESHGUI->myAutomaticUpdate = ( mgr->stringValue( "SMESH", "AutomaticUpdate" ).compare( "true" ) == 0 ); - return &aSMESHGUI; + return aSMESHGUI; } extern "C" { - Standard_EXPORT SALOMEGUI* GetComponentGUI() { + Standard_EXPORT SMESHGUI* GetComponentGUI() { return SMESHGUI::GetSMESHGUI(); } } @@ -893,8 +953,7 @@ extern "C" //============================================================================= void SMESHGUI::SetState(int aState) { - this->myState = aState; - return; + myState = aState; } //============================================================================= @@ -904,8 +963,7 @@ void SMESHGUI::SetState(int aState) //============================================================================= void SMESHGUI::ResetState() { - this->myState = -1; - return; + myState = -1; } //============================================================================= @@ -915,8 +973,7 @@ void SMESHGUI::ResetState() //============================================================================= void SMESHGUI::EmitSignalDeactivateDialog() { - emit this->SignalDeactivateActiveDialog(); - return; + emit SignalDeactivateActiveDialog(); } //============================================================================= @@ -926,8 +983,7 @@ void SMESHGUI::EmitSignalDeactivateDialog() //============================================================================= void SMESHGUI::EmitSignalStudyFrameChanged() { - emit this->SignalStudyFrameChanged(); - return; + emit SignalStudyFrameChanged(); } //============================================================================= @@ -938,7 +994,6 @@ void SMESHGUI::EmitSignalStudyFrameChanged() void SMESHGUI::EmitSignalCloseAllDialogs() { emit SignalCloseAllDialogs(); - return; } //============================================================================= @@ -948,7 +1003,7 @@ void SMESHGUI::EmitSignalCloseAllDialogs() //============================================================================= QDialog *SMESHGUI::GetActiveDialogBox() { - return this->myActiveDialogBox; + return myActiveDialogBox; } //============================================================================= @@ -958,7 +1013,7 @@ QDialog *SMESHGUI::GetActiveDialogBox() //============================================================================= void SMESHGUI::SetActiveDialogBox(QDialog * aDlg) { - this->myActiveDialogBox = (QDialog *) aDlg; + myActiveDialogBox = (QDialog *) aDlg; return; } @@ -967,9 +1022,13 @@ void SMESHGUI::SetActiveDialogBox(QDialog * aDlg) * */ //============================================================================= -QAD_Study *SMESHGUI::GetActiveStudy() +SUIT_Desktop* SMESHGUI::desktop() { - return this->myActiveStudy; + SalomeApp_Application* app = dynamic_cast( SUIT_Session::session()->activeApplication() ); + if( app ) + return app->desktop(); + else + return 0; } //============================================================================= @@ -977,33 +1036,13 @@ QAD_Study *SMESHGUI::GetActiveStudy() * */ //============================================================================= -QAD_Desktop *SMESHGUI::GetDesktop() +SalomeApp_Study* SMESHGUI::activeStudy() { - return QAD_Application::getDesktop(); -} - -//============================================================================= -/*! - * - */ -//============================================================================= -bool SMESHGUI::ActiveStudyChanged(QAD_Desktop* parent) -{ - MESSAGE("SMESHGUI::activeStudyChanged init."); - QAD_Study* prevStudy = myActiveStudy; - /* Create or retrieve an object SMESHGUI */ - MESSAGE("Active study changed : prev study =" << prevStudy); - SMESHGUI::GetSMESHGUI(); - EmitSignalStudyFrameChanged(); - MESSAGE("Active study changed : active study =" << myActiveStudy); - if ( prevStudy != myActiveStudy ) { - EmitSignalCloseAllDialogs(); - MESSAGE("Active study changed : SMESHGUI nullified" << endl); - //smeshGUI = 0; - SMESH::UpdateSelectionProp(); - } - MESSAGE("SMESHGUI::activeStudyChanged done."); - return true; + SUIT_Application* app = SUIT_Session::session()->activeApplication(); + if( app ) + return dynamic_cast( app->activeStudy() ); + else + return NULL; } //============================================================================= @@ -1016,7 +1055,7 @@ bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y) /* Here the position is on the bottom right corner - 10 */ // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint())); aDlg->adjustSize(); - QAD_Desktop *PP = QAD_Application::getDesktop(); + SUIT_Desktop *PP = desktop(); x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10); y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10); return true; @@ -1027,14 +1066,14 @@ bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y) * */ //============================================================================= -static int isStudyLocked(const SALOMEDS::Study_var& theStudy){ +static int isStudyLocked(_PTR(Study) theStudy){ return theStudy->GetProperties()->IsLocked(); } -static bool checkLock(const SALOMEDS::Study_var& theStudy) { +static bool checkLock(_PTR(Study) theStudy) { if (isStudyLocked(theStudy)) { - QAD_MessageBox::warn1 ( (QWidget*)QAD_Application::getDesktop(), - QObject::tr("WRN_WARNING"), + SUIT_MessageBox::warn1 ( SMESHGUI::desktop(), + QObject::tr("WRN_WARNING"), QObject::tr("WRN_STUDY_LOCKED"), QObject::tr("BUT_OK") ); return true; @@ -1044,12 +1083,12 @@ static bool checkLock(const SALOMEDS::Study_var& theStudy) { //======================================================================= //function : CheckActiveStudyLocked -//purpose : +//purpose : //======================================================================= -bool SMESHGUI::ActiveStudyLocked() +bool SMESHGUI::isActiveStudyLocked() { - SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument(); + _PTR(Study) aStudy = activeStudy()->studyDS(); return checkLock( aStudy ); } @@ -1058,38 +1097,61 @@ bool SMESHGUI::ActiveStudyLocked() * */ //============================================================================= -bool SMESHGUI::OnGUIEvent(int theCommandID, QAD_Desktop * parent) +bool SMESHGUI::OnGUIEvent( int theCommandID ) { - SALOMEDS::Study_var aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active + SalomeApp_Application* anApp = dynamic_cast( application() ); + if( !anApp ) + return false; + + _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active + SUIT_ResourceMgr* mgr = resourceMgr(); + if( !mgr ) + return false; + + SUIT_ViewManager* vm = application()->activeViewManager(); + if( !vm ) + return false; + + SUIT_ViewWindow* view =vm->getActiveView(); + SVTK_ViewWindow* vtkwnd = dynamic_cast( view ); + + QAction* act = action( theCommandID ); switch (theCommandID) { case 33: // DELETE if(checkLock(aStudy)) break; ::OnEditDelete(); break; - + case 113: // IMPORT case 112: case 111: { if(checkLock(aStudy)) break; - ::ImportMeshesFromFile(parent,SMESH::GetSMESHGen(),theCommandID); + ::ImportMeshesFromFile(GetSMESHGen(),theCommandID); break; } case 122: // EXPORT MED case 121: case 123: + case 124: + case 125: + case 126: { - ::ExportMeshToFile(parent, theCommandID); + ::ExportMeshToFile(theCommandID); break; } case 200: // SCALAR BAR { - SALOME_Selection *Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); - if( Sel && Sel->IObjectCount() ) { - Handle(SALOME_InteractiveObject) anIO = Sel->firstIObject(); + SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr(); + SALOME_ListIO selected; + if( aSel ) + aSel->selectedObjects( selected ); + + if( selected.Extent() ) { + Handle(SALOME_InteractiveObject) anIO = selected.First(); if( anIO->hasEntry() ) { if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) { anActor->SetControlMode( SMESH_Actor::eNone ); @@ -1100,8 +1162,12 @@ bool SMESHGUI::OnGUIEvent(int theCommandID, QAD_Desktop * parent) } case 201: { - SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); - SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( parent, Sel ); + SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr(); + SALOME_ListIO selected; + if( aSel ) + aSel->selectedObjects( selected ); + + SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( desktop(), aSel ); break; } @@ -1142,10 +1208,14 @@ bool SMESHGUI::OnGUIEvent(int theCommandID, QAD_Desktop * parent) case 301: anAction = SMESH::eDisplay; break; case 302: anAction = SMESH::eDisplayOnly; break; } - - SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection()); - if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { - SALOME_ListIteratorOfListIO It(Sel->StoredIObjects()); + + SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr(); + SALOME_ListIO selected; + if( aSel ) + aSel->selectedObjects( selected ); + + if ( vtkwnd ) { + SALOME_ListIteratorOfListIO It(selected); for (; It.More(); It.Next()) { Handle(SALOME_InteractiveObject) IOS = It.Value(); if (IOS->hasEntry()) { @@ -1153,20 +1223,22 @@ bool SMESHGUI::OnGUIEvent(int theCommandID, QAD_Desktop * parent) } } } - Sel->ClearIObjects(); + SALOME_ListIO selected1; + aSel->setSelectedObjects( selected1 ); break; } case 400: // NODES { if(checkLock(aStudy)) break; - if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { + + if ( vtkwnd ) { EmitSignalDeactivateDialog(); - SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection()); - new SMESHGUI_NodesDlg(parent, "", Sel); + + new SMESHGUI_NodesDlg( desktop(), "", SMESHGUI::selectionMgr() ); } else { - QAD_MessageBox::warn1(QAD_Application::getDesktop(), + SUIT_MessageBox::warn1(desktop(), tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"), tr("SMESH_BUT_OK")); @@ -1176,100 +1248,101 @@ bool SMESHGUI::OnGUIEvent(int theCommandID, QAD_Desktop * parent) case 2151: // FILTER { - if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) + if ( vtkwnd ) { EmitSignalDeactivateDialog(); - new SMESHGUI_FilterDlg( parent, SMESH::EDGE ); + new SMESHGUI_FilterDlg( this, SMESH::EDGE ); } break; } - + case 406: // MOVE NODE { - if ( myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK ) + if ( !vtkwnd ) { - QAD_MessageBox::warn1( GetDesktop(), tr( "SMESH_WRN_WARNING" ), + SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ), tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) ); break; } - + if(checkLock(aStudy)) break; - SALOME_Selection *Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); - new SMESHGUI_MoveNodesDlg( parent, Sel ); + new SMESHGUI_MoveNodesDlg(this); break; } - - case 701: // COMPUTE MESH + + case 701: // COMPUTE MESH { if(checkLock(aStudy)) break; - if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { - SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection()); - int nbSel = Sel->IObjectCount(); + if ( vtkwnd ) { + SalomeApp_SelectionMgr *Sel = selectionMgr(); + SALOME_ListIO selected; Sel->selectedObjects( selected ); + + int nbSel = selected.Extent(); if (nbSel != 1){ break; } SMESH::SMESH_Mesh_var aMesh; SMESH::SMESH_subMesh_var aSubMesh; - Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject(); + Handle(SALOME_InteractiveObject) IObject = selected.First(); if (IObject->hasEntry()){ - SALOMEDS::SObject_var aMeshSObj = aStudy->FindObjectID(IObject->getEntry()); + _PTR(SObject) aMeshSObj = aStudy->FindObjectID(IObject->getEntry()); GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh( aMeshSObj ); if ( aShapeObject->_is_nil() ) { // imported mesh break; } - if(!aMeshSObj->_is_nil()) { + if( aMeshSObj ) { SMESH::SMESH_Mesh_var aMesh = SMESH::SObjectToInterface(aMeshSObj); SMESH::SMESH_subMesh_var aSubMesh = SMESH::SObjectToInterface(aMeshSObj); - + if (!aMesh->_is_nil()){ GEOM::GEOM_Object_var refShapeObject = SMESH::GetShapeOnMeshOrSubMesh(aMeshSObj); if (!refShapeObject->_is_nil()) { - if(!SMESH::GetSMESHGen()->IsReadyToCompute(aMesh,refShapeObject)){ - QAD_MessageBox::warn1(QAD_Application::getDesktop(), + if(!GetSMESHGen()->IsReadyToCompute(aMesh,refShapeObject)){ + SUIT_MessageBox::warn1(desktop(), tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_MISSING_PARAMETERS"), tr("SMESH_BUT_OK")); break; } try{ - if (SMESH::GetSMESHGen()->Compute(aMesh,refShapeObject)) + if (GetSMESHGen()->Compute(aMesh,refShapeObject)) SMESH::ModifiedMesh(aMeshSObj,true); // TO Do : change icon of all submeshes else - QAD_MessageBox::warn1(QAD_Application::getDesktop(), + SUIT_MessageBox::warn1(desktop(), tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_COMPUTE_FAILED"), tr("SMESH_BUT_OK")); } catch(const SALOME::SALOME_Exception & S_ex){ - QtCatchCorbaException(S_ex); + SalomeApp_Tools::QtCatchCorbaException(S_ex); } } }else if(!aSubMesh->_is_nil()){ aMesh = aSubMesh->GetFather(); GEOM::GEOM_Object_var refShapeObject = SMESH::GetShapeOnMeshOrSubMesh(aMeshSObj); if(!refShapeObject->_is_nil()){ - bool compute = SMESH::GetSMESHGen()->IsReadyToCompute(aMesh,refShapeObject); + bool compute = GetSMESHGen()->IsReadyToCompute(aMesh,refShapeObject); if(!compute){ - QAD_MessageBox::warn1(QAD_Application::getDesktop(), + SUIT_MessageBox::warn1(desktop(), tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_MISSING_PARAMETERS"), tr("SMESH_BUT_OK")); break; } try{ - if ( SMESH::GetSMESHGen()->Compute(aMesh,refShapeObject) ) + if ( GetSMESHGen()->Compute(aMesh,refShapeObject) ) SMESH::ModifiedMesh(aMeshSObj,true); // TO Do : change icon of all submeshes else - QAD_MessageBox::warn1(QAD_Application::getDesktop(), + SUIT_MessageBox::warn1(desktop(), tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_COMPUTE_FAILED"), tr("SMESH_BUT_OK")); }catch(const SALOME::SALOME_Exception & S_ex){ - QtCatchCorbaException(S_ex); + SalomeApp_Tools::QtCatchCorbaException(S_ex); } } } @@ -1284,13 +1357,13 @@ bool SMESHGUI::OnGUIEvent(int theCommandID, QAD_Desktop * parent) if(!anActor){ anActor = SMESH::CreateActor(aStudy,IObject->getEntry()); if(anActor){ - SMESH::DisplayActor(myActiveStudy->getActiveStudyFrame(),anActor); //apo + SMESH::DisplayActor(view,anActor); //apo SMESH::FitAll(); } } } }else{ - QAD_MessageBox::warn1(QAD_Application::getDesktop(), + SUIT_MessageBox::warn1(desktop(), tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"), tr("SMESH_BUT_OK")); @@ -1298,28 +1371,26 @@ bool SMESHGUI::OnGUIEvent(int theCommandID, QAD_Desktop * parent) break; } - case 702: // ADD SUB MESH + case 702: // ADD SUB MESH { if(checkLock(aStudy)) break; - if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { + if( vtkwnd ) { EmitSignalDeactivateDialog(); - SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection()); - new SMESHGUI_AddSubMeshDlg(parent, "", Sel); + new SMESHGUI_AddSubMeshDlg( this ); } else { - QAD_MessageBox::warn1(QAD_Application::getDesktop(), + SUIT_MessageBox::warn1(desktop(), tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"), tr("SMESH_BUT_OK")); } break; } - - case 703: // INIT MESH + + case 703: // INIT MESH { if(checkLock(aStudy)) break; EmitSignalDeactivateDialog(); - SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection()); - new SMESHGUI_InitMeshDlg(parent, "", Sel); + new SMESHGUI_InitMeshDlg( this ); break; } @@ -1327,8 +1398,7 @@ bool SMESHGUI::OnGUIEvent(int theCommandID, QAD_Desktop * parent) { if(checkLock(aStudy)) break; EmitSignalDeactivateDialog(); - SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection()); - new SMESHGUI_EditHypothesesDlg(parent, "", Sel); + new SMESHGUI_EditHypothesesDlg( this ); break; } @@ -1336,8 +1406,7 @@ bool SMESHGUI::OnGUIEvent(int theCommandID, QAD_Desktop * parent) { if(checkLock(aStudy)) break; EmitSignalDeactivateDialog(); - SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection()); - new SMESHGUI_EditHypothesesDlg(parent, "", Sel); + new SMESHGUI_EditHypothesesDlg( this ); break; } @@ -1345,49 +1414,46 @@ bool SMESHGUI::OnGUIEvent(int theCommandID, QAD_Desktop * parent) { if(checkLock(aStudy)) break; EmitSignalDeactivateDialog(); - SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection()); - new SMESHGUI_EditHypothesesDlg(parent, "", Sel); + new SMESHGUI_EditHypothesesDlg( this ); break; } case 407: // DIAGONAL INVERSION case 408: // Delete diagonal { - if ( myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK ) + if ( !vtkwnd ) { - QAD_MessageBox::warn1( GetDesktop(), tr( "SMESH_WRN_WARNING" ), + SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ), tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) ); break; } if ( checkLock( aStudy ) ) break; - - SALOME_Selection *aSel = - SALOME_Selection::Selection( myActiveStudy->getSelection() ); + /*Standard_Boolean aRes; SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface(IObject); if ( aMesh->_is_nil() ) { - QAD_MessageBox::warn1(GetDesktop(), tr( "SMESH_WRN_WARNING" ), + SUIT_MessageBox::warn1(GetDesktop(), tr( "SMESH_WRN_WARNING" ), tr( "SMESH_BAD_SELECTION" ), tr( "SMESH_BUT_OK" ) ); break; } */ EmitSignalDeactivateDialog(); if ( theCommandID == 407 ) - new SMESHGUI_TrianglesInversionDlg( parent, aSel ); + new SMESHGUI_TrianglesInversionDlg(this); else - new SMESHGUI_UnionOfTwoTrianglesDlg( parent, aSel ); + new SMESHGUI_UnionOfTwoTrianglesDlg(this); break; } case 409: // Change orientation case 410: // Union of triangles case 411: // Cutting of quadrangles { - if ( myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK ) + if ( !vtkwnd ) { - QAD_MessageBox::warn1( GetDesktop(), tr( "SMESH_WRN_WARNING" ), + SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ), tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) ); break; } @@ -1395,17 +1461,14 @@ bool SMESHGUI::OnGUIEvent(int theCommandID, QAD_Desktop * parent) if ( checkLock( aStudy ) ) break; - SALOME_Selection *aSel = - SALOME_Selection::Selection( myActiveStudy->getSelection() ); - EmitSignalDeactivateDialog(); - SMESHGUI_MultiEditDlg* aDlg; + SMESHGUI_MultiEditDlg* aDlg = NULL; if ( theCommandID == 409 ) - aDlg = new SMESHGUI_ChangeOrientationDlg( parent, aSel ); + aDlg = new SMESHGUI_ChangeOrientationDlg(this); else if ( theCommandID == 410 ) - aDlg = new SMESHGUI_UnionOfTrianglesDlg( parent, aSel ); + aDlg = new SMESHGUI_UnionOfTrianglesDlg(this); else - aDlg = new SMESHGUI_CuttingOfQuadsDlg( parent, aSel ); + aDlg = new SMESHGUI_CuttingOfQuadsDlg(this); int x, y ; DefineDlgPosition( aDlg, x, y ); @@ -1416,13 +1479,12 @@ bool SMESHGUI::OnGUIEvent(int theCommandID, QAD_Desktop * parent) case 412: // Smoothing { if(checkLock(aStudy)) break; - if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { + if( vtkwnd ) { EmitSignalDeactivateDialog(); - SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection()); - new SMESHGUI_SmoothingDlg(parent, "", Sel); + new SMESHGUI_SmoothingDlg( this ); } else { - QAD_MessageBox::warn1(QAD_Application::getDesktop(), + SUIT_MessageBox::warn1(desktop(), tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"), tr("SMESH_BUT_OK")); } @@ -1430,29 +1492,26 @@ bool SMESHGUI::OnGUIEvent(int theCommandID, QAD_Desktop * parent) } case 413: // Extrusion { - if(checkLock(aStudy)) break; - if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { + if (checkLock(aStudy)) break; + if (vtkwnd) { EmitSignalDeactivateDialog(); - SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection()); - new SMESHGUI_ExtrusionDlg(parent, "", Sel); - } - else { - QAD_MessageBox::warn1(QAD_Application::getDesktop(), - tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"), - tr("SMESH_BUT_OK")); + new SMESHGUI_ExtrusionDlg ( this ); + } else { + SUIT_MessageBox::warn1(desktop(), + tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"), + tr("SMESH_BUT_OK")); } break; } case 414: // Revolution { if(checkLock(aStudy)) break; - if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { + if( vtkwnd ) { EmitSignalDeactivateDialog(); - SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection()); - new SMESHGUI_RevolutionDlg(parent, "", Sel); + new SMESHGUI_RevolutionDlg( this ); } else { - QAD_MessageBox::warn1(QAD_Application::getDesktop(), + SUIT_MessageBox::warn1(desktop(), tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"), tr("SMESH_BUT_OK")); } @@ -1462,15 +1521,13 @@ bool SMESHGUI::OnGUIEvent(int theCommandID, QAD_Desktop * parent) { if ( checkLock( aStudy ) ) break; - if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) + if ( vtkwnd ) { EmitSignalDeactivateDialog(); - SALOME_Selection *Sel = SALOME_Selection::Selection( - myActiveStudy->getSelection() ); - new SMESHGUI_MeshPatternDlg( parent, Sel ); + new SMESHGUI_MeshPatternDlg( this ); } else { - QAD_MessageBox::warn1(QAD_Application::getDesktop(), + SUIT_MessageBox::warn1(desktop(), tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"), tr("SMESH_BUT_OK")); } @@ -1478,16 +1535,14 @@ bool SMESHGUI::OnGUIEvent(int theCommandID, QAD_Desktop * parent) } case 416: // Extrusion along a path { - if(checkLock(aStudy)) break; - if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { + if (checkLock(aStudy)) break; + if (vtkwnd) { EmitSignalDeactivateDialog(); - SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection()); - new SMESHGUI_ExtrusionAlongPathDlg(parent, Sel); - } - else { - QAD_MessageBox::warn1(QAD_Application::getDesktop(), - tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"), - tr("SMESH_BUT_OK")); + new SMESHGUI_ExtrusionAlongPathDlg( this ); + } else { + SUIT_MessageBox::warn1(desktop(), + tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"), + tr("SMESH_BUT_OK")); } break; } @@ -1496,13 +1551,18 @@ bool SMESHGUI::OnGUIEvent(int theCommandID, QAD_Desktop * parent) if(checkLock(aStudy)) break; EmitSignalDeactivateDialog(); SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil(); - SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection()); - int nbSel = Sel->IObjectCount(); + + SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr(); + SALOME_ListIO selected; + if( aSel ) + aSel->selectedObjects( selected ); + + int nbSel = selected.Extent(); if (nbSel == 1) { // check if mesh is selected - aMesh = SMESH::GetMeshByIO(Sel->firstIObject()); + aMesh = SMESH::GetMeshByIO( selected.First() ); } - SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg(parent, "", Sel, aMesh); + SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aMesh); aDlg->show(); break; } @@ -1511,15 +1571,20 @@ bool SMESHGUI::OnGUIEvent(int theCommandID, QAD_Desktop * parent) { if(checkLock(aStudy)) break; EmitSignalDeactivateDialog(); - SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection()); - int nbSel = Sel->IObjectCount(); + + SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr(); + SALOME_ListIO selected; + if( aSel ) + aSel->selectedObjects( selected ); + + int nbSel = selected.Extent(); if (nbSel == 1) { // check if submesh is selected - Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject(); + Handle(SALOME_InteractiveObject) IObject = selected.First(); if (IObject->hasEntry()) { - SALOMEDS::SObject_var aSObj = aStudy->FindObjectID(IObject->getEntry()); - if(!aSObj->_is_nil()) { - SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow(aSObj->GetObject()); + _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry()); + if( aSObj ) { + SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) ); if (!aSubMesh->_is_nil()) { try { SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather(); @@ -1546,9 +1611,10 @@ bool SMESHGUI::OnGUIEvent(int theCommandID, QAD_Desktop * parent) SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes"); aGroup->Add(aVolumes.inout()); } - myActiveStudy->updateObjBrowser(true); + updateObjBrowser(); + }catch(const SALOME::SALOME_Exception & S_ex){ - QtCatchCorbaException(S_ex); + SalomeApp_Tools::QtCatchCorbaException(S_ex); } } } @@ -1561,9 +1627,13 @@ bool SMESHGUI::OnGUIEvent(int theCommandID, QAD_Desktop * parent) { if(checkLock(aStudy)) break; EmitSignalDeactivateDialog(); - SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection()); - SALOME_ListIO IOs; IOs = Sel->StoredIObjects(); // list copy - SALOME_ListIteratorOfListIO It (IOs); + + SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr(); + SALOME_ListIO selected; + if( aSel ) + aSel->selectedObjects( selected ); + + SALOME_ListIteratorOfListIO It (selected); int nbSelectedGroups = 0; for ( ; It.More(); It.Next() ) { @@ -1571,13 +1641,13 @@ bool SMESHGUI::OnGUIEvent(int theCommandID, QAD_Desktop * parent) SMESH::IObjectToInterface(It.Value()); if (!aGroup->_is_nil()) { nbSelectedGroups++; - SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg(parent, "", Sel, aGroup); + SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aGroup); aDlg->show(); } } if (nbSelectedGroups == 0) { - SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg(parent, "", Sel, SMESH::SMESH_Group::_nil()); + SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", SMESH::SMESH_Group::_nil()); aDlg->show(); } break; @@ -1611,15 +1681,13 @@ bool SMESHGUI::OnGUIEvent(int theCommandID, QAD_Desktop * parent) break; EmitSignalDeactivateDialog(); - SALOME_Selection *Sel = SALOME_Selection::Selection( - myActiveStudy->getSelection() ); int aMode; if ( theCommandID == 810 ) aMode = SMESHGUI_GroupOpDlg::UNION; else if ( theCommandID == 811 ) aMode = SMESHGUI_GroupOpDlg::INTERSECT; else aMode = SMESHGUI_GroupOpDlg::CUT; - ( new SMESHGUI_GroupOpDlg( parent, Sel, aMode ) )->show(); + ( new SMESHGUI_GroupOpDlg( desktop(), SMESHGUI::selectionMgr(), aMode ) )->show(); break; } @@ -1629,68 +1697,68 @@ bool SMESHGUI::OnGUIEvent(int theCommandID, QAD_Desktop * parent) break; EmitSignalDeactivateDialog(); - SALOME_Selection *Sel = SALOME_Selection::Selection( - myActiveStudy->getSelection() ); - ( new SMESHGUI_DeleteGroupDlg( parent, Sel ) )->show(); + new SMESHGUI_DeleteGroupDlg( desktop(), SMESHGUI::selectionMgr() ); break; } case 900: // MESH INFOS { EmitSignalDeactivateDialog(); - SALOME_Selection *Sel = - SALOME_Selection::Selection(myActiveStudy->getSelection()); - if ( Sel->IObjectCount() > 1 ) { // a dlg for each IO - SALOME_ListIO IOs; IOs = Sel->StoredIObjects(); // list copy - SALOME_ListIteratorOfListIO It (IOs); + SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr(); + SALOME_ListIO selected; + if( aSel ) + aSel->selectedObjects( selected ); + + if ( selected.Extent() > 1 ) { // a dlg for each IO + SALOME_ListIO IOs; + SALOME_ListIteratorOfListIO It (selected); for ( ; It.More(); It.Next() ) { - Sel->ClearIObjects(); - Sel->AddIObject( It.Value() ); - new SMESHGUI_MeshInfosDlg(parent, "", false); + IOs.Clear(); IOs.Append( It.Value() ); + aSel->setSelectedObjects( IOs ); + new SMESHGUI_MeshInfosDlg(this, "", false); } // restore selection - Sel->ClearIObjects(); - for (It.Initialize( IOs ) ; It.More(); It.Next() ) - Sel->AddIObject( It.Value() ); + aSel->setSelectedObjects( selected ); } else - new SMESHGUI_MeshInfosDlg(parent, "", false); + new SMESHGUI_MeshInfosDlg(this, "", false); break; } case 902: // STANDARD MESH INFOS { EmitSignalDeactivateDialog(); - SALOME_Selection *Sel = - SALOME_Selection::Selection(myActiveStudy->getSelection()); - if ( Sel->IObjectCount() > 1 ) { // a dlg for each IO - SALOME_ListIO IOs; IOs = Sel->StoredIObjects(); // list copy - SALOME_ListIteratorOfListIO It (IOs); + SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr(); + SALOME_ListIO selected; + if( aSel ) + aSel->selectedObjects( selected ); + + if ( selected.Extent() > 1 ) { // a dlg for each IO + SALOME_ListIO IOs; + SALOME_ListIteratorOfListIO It (selected); for ( ; It.More(); It.Next() ) { - Sel->ClearIObjects(); - Sel->AddIObject( It.Value() ); - new SMESHGUI_StandardMeshInfosDlg(parent, "", false); + IOs.Clear(); + IOs.Append( It.Value() ); + aSel->setSelectedObjects( IOs ); + new SMESHGUI_StandardMeshInfosDlg(desktop(), "", false); } // restore selection - Sel->ClearIObjects(); - for (It.Initialize( IOs ) ; It.More(); It.Next() ) - Sel->AddIObject( It.Value() ); + aSel->setSelectedObjects( selected ); } else - new SMESHGUI_StandardMeshInfosDlg(parent, "", false); + new SMESHGUI_StandardMeshInfosDlg(desktop(), "", false); break; } case 1001: // AUTOMATIC UPDATE PREFERENCES { - parent->menuBar()->setItemChecked(1001, !parent->menuBar()->isItemChecked(1001)); - if (parent->menuBar()->isItemChecked(1001)) { - QAD_CONFIG->addSetting("SMESH:AutomaticUpdate", "true"); + if (act->isOn()) { + mgr->setValue( "SMESH", "AutomaticUpdate", true ); myAutomaticUpdate = true; } else { - QAD_CONFIG->addSetting("SMESH:AutomaticUpdate", "false"); + mgr->setValue( "SMESH", "AutomaticUpdate", false ); myAutomaticUpdate = false; } break; @@ -1704,126 +1772,90 @@ bool SMESHGUI::OnGUIEvent(int theCommandID, QAD_Desktop * parent) case 1005: { - SMESHGUI_Preferences_ScalarBarDlg::ScalarBarPreferences( parent ); + SMESHGUI_Preferences_ScalarBarDlg::ScalarBarPreferences( desktop() ); break; } case 10070: { - ( new SMESHGUI_PrecisionDlg( parent ) )->exec(); + ( new SMESHGUI_PrecisionDlg( desktop() ) )->exec(); break; } case 10071: { - parent->menuBar()->setItemChecked(10071, !parent->menuBar()->isItemChecked(10071)); - if (parent->menuBar()->isItemChecked(10071)) { - QAD_CONFIG->addSetting("SMESH:DispayEntity","true"); + if (act->isOn()) { + mgr->setValue( "SMESH", "DispayEntity", true ); } else { - QAD_CONFIG->addSetting("SMESH:DispayEntity","false"); + mgr->setValue( "SMESH", "DispayEntity", false ); } break; } - case 1006: + case 1006: { SMESHGUI_Preferences_SelectionDlg* aDlg = - new SMESHGUI_Preferences_SelectionDlg(parent); + new SMESHGUI_Preferences_SelectionDlg(desktop()); - QColor aColor; - QString SCr, SCg, SCb; - SCr = QAD_CONFIG->getSetting("SMESH:SettingsPreSelectColorRed"); - SCg = QAD_CONFIG->getSetting("SMESH:SettingsPreSelectColorGreen"); - SCb = QAD_CONFIG->getSetting("SMESH:SettingsPreSelectColorBlue"); - if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty()) - aColor = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt()); - else aColor = Qt::cyan; + QColor aColor = mgr->colorValue( "SMESH", "SettingsPreSelectColor", Qt::cyan ); aDlg->SetColor(1, aColor); - SCr = QAD_CONFIG->getSetting("SMESH:SettingsItemSelectColorRed"); - SCg = QAD_CONFIG->getSetting("SMESH:SettingsItemSelectColorGreen"); - SCb = QAD_CONFIG->getSetting("SMESH:SettingsItemSelectColorBlue"); - if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty()) - aColor = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt()); - else aColor = Qt::yellow; + aColor = mgr->colorValue( "SMESH", "SettingsItemSelectColor", Qt::yellow ); aDlg->SetColor(2, aColor); - SCr = QAD_CONFIG->getSetting("SMESH:SettingsSelectColorRed"); - SCg = QAD_CONFIG->getSetting("SMESH:SettingsSelectColorGreen"); - SCb = QAD_CONFIG->getSetting("SMESH:SettingsSelectColorBlue"); - if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty()) - aColor = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt()); - else aColor = Qt::white; + aColor = mgr->colorValue( "SMESH", "SettingsSelectColor", Qt::white ); aDlg->SetColor(3, aColor); - QString SW1 = QAD_CONFIG->getSetting("SMESH:SettingsPreSelectWidth"); - if (SW1.isEmpty()) SW1 = "5"; - aDlg->SetWidth(1, SW1.toInt()); - - QString SW2 = QAD_CONFIG->getSetting("SMESH:SettingsItemSelectWidth"); - if (SW2.isEmpty()) SW2 = "5"; - aDlg->SetWidth(2, SW2.toInt()); - - QString SP1 = QAD_CONFIG->getSetting("SMESH:SettingsNodeSelectTol"); - if (SP1.isEmpty()) SP1 = "0.025"; - aDlg->SetPrecision(1, SP1.toDouble()); - - QString SP2 = QAD_CONFIG->getSetting("SMESH:SettingsElementsSelectTol"); - if (SP2.isEmpty()) SP2 = "0.001"; - aDlg->SetPrecision(2, SP2.toDouble()); + aDlg->SetWidth(1, mgr->integerValue( "SMESH", "SettingsPreSelectWidth", 5 ) ); + aDlg->SetWidth(2, mgr->integerValue( "SMESH", "SettingsItemSelectWidth", 5 ) ); + aDlg->SetPrecision(1, mgr->doubleValue( "SMESH", "SettingsNodeSelectTol", 0.025 ) ); + aDlg->SetPrecision(2, mgr->doubleValue( "SMESH", "SettingsElementsSelectTol", 0.001 ) ); if (aDlg->exec()) { - QColor aPreColor = aDlg->GetColor(1); - QAD_CONFIG->addSetting("SMESH:SettingsPreSelectColorRed", aPreColor.red()); - QAD_CONFIG->addSetting("SMESH:SettingsPreSelectColorGreen", aPreColor.green()); - QAD_CONFIG->addSetting("SMESH:SettingsPreSelectColorBlue", aPreColor.blue()); + QColor aPreColor = aDlg->GetColor(1), + aSelColor = aDlg->GetColor(2), + aHiColor = aDlg->GetColor(3); + int aPreWidth = aDlg->GetWidth(1), + aSelWidth = aDlg->GetWidth(2); + double aTolNodes = aDlg->GetPrecision(1), + aTolItems = aDlg->GetPrecision(2); - QColor aSelColor = aDlg->GetColor(2); - QAD_CONFIG->addSetting("SMESH:SettingsItemSelectColorRed", aSelColor.red()); - QAD_CONFIG->addSetting("SMESH:SettingsItemSelectColorGreen", aSelColor.green()); - QAD_CONFIG->addSetting("SMESH:SettingsItemSelectColorBlue", aSelColor.blue()); + mgr->setValue( "SMESH", "SettingsPreSelectColor", aPreColor ); + mgr->setValue( "SMESH", "SettingsItemSelectColor", aSelColor ); + mgr->setValue( "SMESH", "SettingsSelectColor", aHiColor ); - QColor aHiColor = aDlg->GetColor(3); - QAD_CONFIG->addSetting("SMESH:SettingsSelectColorRed", aHiColor.red()); - QAD_CONFIG->addSetting("SMESH:SettingsSelectColorGreen", aHiColor.green()); - QAD_CONFIG->addSetting("SMESH:SettingsSelectColorBlue", aHiColor.blue()); - - int aPreWidth = aDlg->GetWidth(1); - QAD_CONFIG->addSetting("SMESH:SettingsPreSelectWidth", aPreWidth); - int aSelWidth = aDlg->GetWidth(2); - QAD_CONFIG->addSetting("SMESH:SettingsItemSelectWidth", aSelWidth); - - double aTolNodes = aDlg->GetPrecision(1); - QAD_CONFIG->addSetting("SMESH:SettingsNodeSelectTol", aTolNodes); - double aTolItems = aDlg->GetPrecision(2); - QAD_CONFIG->addSetting("SMESH:SettingsElementsSelectTol", aTolItems); + mgr->setValue( "SMESH", "SettingsPreSelectWidth", aPreWidth ); + mgr->setValue( "SMESH", "SettingsItemSelectWidth", aSelWidth ); + mgr->setValue( "SMESH", "SettingsNodeSelectTol", aTolNodes ); + mgr->setValue( "SMESH", "SettingsElementsSelectTol", aTolItems ); // update current study settings SMESH::UpdateSelectionProp(); - QAD_StudyFrame* studyFrame = myActiveStudy->getActiveStudyFrame(); - if (studyFrame->getTypeView() == VIEW_VTK) { - VTKViewer_ViewFrame* aViewFrame = SMESH::GetVtkViewFrame(studyFrame); + if( vtkwnd ) { // update VTK viewer properties - VTKViewer_RenderWindowInteractor* anInteractor = aViewFrame->getRWInteractor(); + SVTK_RenderWindowInteractor* anInteractor = + dynamic_cast( vtkwnd->getRWInteractor() ); if (anInteractor) { - anInteractor->SetSelectionProp(aSelColor.red()/255., aSelColor.green()/255., + anInteractor->SetSelectionProp(aSelColor.red()/255., aSelColor.green()/255., aSelColor.blue()/255., aSelWidth); anInteractor->SetSelectionTolerance(aTolNodes, aTolItems); - VTKViewer_InteractorStyleSALOME* aStyle = anInteractor->GetInteractorStyleSALOME(); + SVTK_InteractorStyle* aStyle = + dynamic_cast( anInteractor->GetInteractorStyle() ); + if (aStyle) - aStyle->setPreselectionProp(aPreColor.red()/255., aPreColor.green()/255., + aStyle->setPreselectionProp(aPreColor.red()/255., aPreColor.green()/255., aPreColor.blue()/255., aPreWidth); } // update actors - vtkRenderer* aRenderer = aViewFrame->getRenderer(); + vtkRenderer* aRenderer = vtkwnd->getRenderer(); vtkActorCollection *aCollection = aRenderer->GetActors(); aCollection->InitTraversal(); while(vtkActor *anAct = aCollection->GetNextActor()){ if(SMESH_Actor *anActor = dynamic_cast(anAct)){ - anActor->SetHighlightColor(aHiColor.red()/255., aHiColor.green()/255., + anActor->SetHighlightColor(aHiColor.red()/255., aHiColor.green()/255., aHiColor.blue()/255.); - anActor->SetPreHighlightColor(aPreColor.red()/255., aPreColor.green()/255., + anActor->SetPreHighlightColor(aPreColor.red()/255., aPreColor.green()/255., aPreColor.blue()/255.); } } @@ -1836,12 +1868,16 @@ bool SMESHGUI::OnGUIEvent(int theCommandID, QAD_Desktop * parent) case 1100: // EDIT HYPOTHESIS { if(checkLock(aStudy)) break; - SALOME_Selection *Sel = - SALOME_Selection::Selection(myActiveStudy->getSelection()); - int nbSel = Sel->IObjectCount(); + + SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr(); + SALOME_ListIO selected; + if( aSel ) + aSel->selectedObjects( selected ); + + int nbSel = selected.Extent(); if (nbSel == 1) { - SMESH::SMESH_Hypothesis_var Hyp = SMESH::IObjectToInterface(Sel->firstIObject()); + SMESH::SMESH_Hypothesis_var Hyp = SMESH::IObjectToInterface(selected.First()); /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */ /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */ @@ -1867,65 +1903,76 @@ bool SMESHGUI::OnGUIEvent(int theCommandID, QAD_Desktop * parent) { if ( checkLock( aStudy ) ) break; - - SALOME_Selection *Sel = - SALOME_Selection::Selection( myActiveStudy->getSelection() ); - - SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); + + SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr(); + SALOME_ListIO selected; + if( aSel ) + aSel->selectedObjects( selected ); + + SALOME_ListIteratorOfListIO It( selected ); for ( ; It.More(); It.Next() ) { Handle(SALOME_InteractiveObject) IObject = It.Value(); - SALOMEDS::SObject_var obj = aStudy->FindObjectID( IObject->getEntry() ); - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeName_var aName; - if ( !obj->_is_nil() ) + _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() ); + _PTR(GenericAttribute) anAttr; + _PTR(AttributeName) aName; + if ( obj ) { if ( obj->FindAttribute(anAttr, "AttributeName") ) { - aName = SALOMEDS::AttributeName::_narrow( anAttr ); - QString newName = QString(aName->Value()); - newName = SALOMEGUI_NameDlg::getName( QAD_Application::getDesktop(), newName ); + aName = anAttr; + QString newName = QString(aName->Value().c_str()); + newName = SalomeApp_NameDlg::getName( desktop(), newName ); if ( !newName.isEmpty() ) { - myActiveStudy->renameIObject( IObject, newName ); + //old source: aStudy->renameIObject( IObject, newName ); + aName->SetValue( newName.latin1() ); // if current object is group update group's name SMESH::SMESH_GroupBase_var aGroup = SMESH::IObjectToInterface(IObject); if (!aGroup->_is_nil() ) aGroup->SetName( newName.latin1() ); + + updateObjBrowser(); } } } } break; } - + case 1102: // REMOVE HYPOTHESIS / ALGORITHMS { if(checkLock(aStudy)) break; - QAD_WaitCursor wc; - SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection()); - SALOME_ListIteratorOfListIO It(Sel->StoredIObjects()); + SUIT_OverrideCursor wc; + + SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr(); + SALOME_ListIO selected; + if( aSel ) + aSel->selectedObjects( selected ); + + SALOME_ListIteratorOfListIO It(selected); for (int i = 0; It.More(); It.Next(), i++) { Handle(SALOME_InteractiveObject) IObject = It.Value(); SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject); } - Sel->ClearIObjects(); - myActiveStudy->updateObjBrowser(true); + SALOME_ListIO selected1; + aSel->setSelectedObjects( selected1 ); + updateObjBrowser(); break; } case 401: // GEOM::EDGE case 4021: // TRIANGLE case 4022: // QUAD + case 4023: // POLYGON case 4031: // TETRA case 4032: // HEXA { if(checkLock(aStudy)) break; - if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { + if ( vtkwnd ) { EmitSignalDeactivateDialog(); - SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection()); SMDSAbs_ElementType type = SMDSAbs_Edge; int nbNodes = 2; switch (theCommandID) { @@ -1935,30 +1982,46 @@ bool SMESHGUI::OnGUIEvent(int theCommandID, QAD_Desktop * parent) type = SMDSAbs_Face; nbNodes = 4; break; case 4031: // TETRA type = SMDSAbs_Volume; nbNodes = 4; break; + case 4023: // POLYGON + type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON case 4032: // HEXA type = SMDSAbs_Volume; nbNodes = 8; break; + case 4033: // POLYHEDRE + type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE default:; } - new SMESHGUI_AddMeshElementDlg(parent, "", Sel, type, nbNodes); + new SMESHGUI_AddMeshElementDlg( this, "", type, nbNodes); } else { - QAD_MessageBox::warn1(QAD_Application::getDesktop(), + SUIT_MessageBox::warn1(desktop(), + tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"), + tr("SMESH_BUT_OK")); + } + break; + } + case 4033: // POLYHEDRON + { + if(checkLock(aStudy)) break; + if ( vtkwnd ) { + EmitSignalDeactivateDialog(); + new SMESHGUI_CreatePolyhedralVolumeDlg(this, "", FALSE ); + } + else { + SUIT_MessageBox::warn1(SMESHGUI::desktop(), tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"), tr("SMESH_BUT_OK")); } break; } - case 4041: // REMOVES NODES { if(checkLock(aStudy)) break; - if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { + if ( vtkwnd ) { EmitSignalDeactivateDialog(); - SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection()); - new SMESHGUI_RemoveNodesDlg(parent, "", Sel); + new SMESHGUI_RemoveNodesDlg(this); } else { - QAD_MessageBox::warn1(QAD_Application::getDesktop(), + SUIT_MessageBox::warn1(desktop(), tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"), tr("SMESH_BUT_OK")); } @@ -1967,14 +2030,13 @@ bool SMESHGUI::OnGUIEvent(int theCommandID, QAD_Desktop * parent) case 4042: // REMOVES ELEMENTS { if(checkLock(aStudy)) break; - if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { + if( vtkwnd ) { EmitSignalDeactivateDialog(); - SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection()); - new SMESHGUI_RemoveElementsDlg(parent, "", Sel); + new SMESHGUI_RemoveElementsDlg(this); } else { - QAD_MessageBox::warn1(QAD_Application::getDesktop(), + SUIT_MessageBox::warn1(desktop(), tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"), tr("SMESH_BUT_OK")); } @@ -1983,14 +2045,13 @@ bool SMESHGUI::OnGUIEvent(int theCommandID, QAD_Desktop * parent) case 4051: // RENUMBERING NODES { if(checkLock(aStudy)) break; - if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { + if( vtkwnd ) { EmitSignalDeactivateDialog(); - SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection()); - new SMESHGUI_RenumberingDlg(parent, "", Sel, 0); + new SMESHGUI_RenumberingDlg(desktop(), "", selectionMgr(), 0); } else { - QAD_MessageBox::warn1(QAD_Application::getDesktop(), + SUIT_MessageBox::warn1(desktop(), tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"), tr("SMESH_BUT_OK")); } @@ -1999,14 +2060,13 @@ bool SMESHGUI::OnGUIEvent(int theCommandID, QAD_Desktop * parent) case 4052: // RENUMBERING ELEMENTS { if(checkLock(aStudy)) break; - if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { + if ( vtkwnd ) { EmitSignalDeactivateDialog(); - SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection()); - new SMESHGUI_RenumberingDlg(parent, "", Sel, 1); + new SMESHGUI_RenumberingDlg(desktop(), "", selectionMgr(), 1); } else { - QAD_MessageBox::warn1(QAD_Application::getDesktop(), + SUIT_MessageBox::warn1(desktop(), tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"), tr("SMESH_BUT_OK")); } @@ -2015,13 +2075,12 @@ bool SMESHGUI::OnGUIEvent(int theCommandID, QAD_Desktop * parent) case 4061: // TRANSLATION { if(checkLock(aStudy)) break; - if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { + if ( vtkwnd ) { EmitSignalDeactivateDialog(); - SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection()); - new SMESHGUI_TranslationDlg(parent, "", Sel); + new SMESHGUI_TranslationDlg( this ); } else { - QAD_MessageBox::warn1(QAD_Application::getDesktop(), + SUIT_MessageBox::warn1(desktop(), tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"), tr("SMESH_BUT_OK")); } @@ -2030,13 +2089,12 @@ bool SMESHGUI::OnGUIEvent(int theCommandID, QAD_Desktop * parent) case 4062: // ROTATION { if(checkLock(aStudy)) break; - if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { + if( vtkwnd ) { EmitSignalDeactivateDialog(); - SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection()); - new SMESHGUI_RotationDlg(parent, "", Sel); + new SMESHGUI_RotationDlg( this ); } else { - QAD_MessageBox::warn1(QAD_Application::getDesktop(), + SUIT_MessageBox::warn1(desktop(), tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"), tr("SMESH_BUT_OK")); } @@ -2045,13 +2103,12 @@ bool SMESHGUI::OnGUIEvent(int theCommandID, QAD_Desktop * parent) case 4063: // SYMMETRY { if(checkLock(aStudy)) break; - if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { + if(vtkwnd) { EmitSignalDeactivateDialog(); - SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection()); - new SMESHGUI_SymmetryDlg(parent, "", Sel); + new SMESHGUI_SymmetryDlg( this ); } else { - QAD_MessageBox::warn1(QAD_Application::getDesktop(), + SUIT_MessageBox::warn1(desktop(), tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"), tr("SMESH_BUT_OK")); } @@ -2060,13 +2117,12 @@ bool SMESHGUI::OnGUIEvent(int theCommandID, QAD_Desktop * parent) case 4064: // SEWING { if(checkLock(aStudy)) break; - if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { + if(vtkwnd) { EmitSignalDeactivateDialog(); - SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection()); - new SMESHGUI_SewingDlg(parent, "", Sel); + new SMESHGUI_SewingDlg( this ); } else { - QAD_MessageBox::warn1(QAD_Application::getDesktop(), + SUIT_MessageBox::warn1(desktop(), tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"), tr("SMESH_BUT_OK")); } @@ -2075,13 +2131,12 @@ bool SMESHGUI::OnGUIEvent(int theCommandID, QAD_Desktop * parent) case 4065: // MERGE NODES { if(checkLock(aStudy)) break; - if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { + if(vtkwnd) { EmitSignalDeactivateDialog(); - SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection()); - new SMESHGUI_MergeNodesDlg(parent, "", Sel); + new SMESHGUI_MergeNodesDlg( this ); } else { - QAD_MessageBox::warn1(QAD_Application::getDesktop(), + SUIT_MessageBox::warn1(desktop(), tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"), tr("SMESH_BUT_OK")); } @@ -2093,14 +2148,14 @@ bool SMESHGUI::OnGUIEvent(int theCommandID, QAD_Desktop * parent) { if(checkLock(aStudy)) break; EmitSignalDeactivateDialog(); - new SMESHGUI_CreateHypothesesDlg (parent, "", FALSE, false); + new SMESHGUI_CreateHypothesesDlg ( this, "", FALSE, false ); break; } case 5010: // ALGO { if(checkLock(aStudy)) break; EmitSignalDeactivateDialog(); - new SMESHGUI_CreateHypothesesDlg (parent, "", FALSE, true); + new SMESHGUI_CreateHypothesesDlg ( this, "", FALSE, true); break; } @@ -2114,11 +2169,11 @@ bool SMESHGUI::OnGUIEvent(int theCommandID, QAD_Desktop * parent) aTypes.append( SMESH::FACE ); aTypes.append( SMESH::VOLUME ); } - new SMESHGUI_FilterLibraryDlg( parent, aTypes, SMESHGUI_FilterLibraryDlg::EDIT ); + new SMESHGUI_FilterLibraryDlg( desktop(), aTypes, SMESHGUI_FilterLibraryDlg::EDIT ); } break; - case 6017: // CONTROLS + case 6017: // CONTROLS case 6016: case 6015: case 6014: @@ -2130,13 +2185,16 @@ bool SMESHGUI::OnGUIEvent(int theCommandID, QAD_Desktop * parent) case 6019: case 6002: case 6003: - case 6004: - if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { - SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection()); - if ( Sel->IObjectCount() == 1 && Sel->firstIObject()->hasEntry() ) { - SALOMEDS::SObject_var SO = aStudy->FindObjectID( Sel->firstIObject()->getEntry() ); - if ( !SO->_is_nil() ) { - CORBA::Object_var aObject = SO->GetObject(); + case 6004: + if ( vtkwnd ) { + + SalomeApp_SelectionMgr* mgr = selectionMgr(); + SALOME_ListIO selected; mgr->selectedObjects( selected ); + + if ( selected.Extent() == 1 && selected.First()->hasEntry() ) { + _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() ); + if ( SO ) { + CORBA::Object_var aObject = SMESH::SObjectToObject( SO ); SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject ); SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject ); SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject ); @@ -2146,14 +2204,14 @@ bool SMESHGUI::OnGUIEvent(int theCommandID, QAD_Desktop * parent) } } } - QAD_MessageBox::warn1(GetDesktop(), + SUIT_MessageBox::warn1(desktop(), tr( "SMESH_WRN_WARNING" ), - tr( "SMESH_BAD_SELECTION" ), + tr( "SMESH_BAD_SELECTION" ), tr( "SMESH_BUT_OK" ) ); break; } else { - QAD_MessageBox::warn1(GetDesktop(), + SUIT_MessageBox::warn1(desktop(), tr( "SMESH_WRN_WARNING" ), tr( "NOT_A_VTK_VIEWER" ), tr( "SMESH_BUT_OK" ) ); @@ -2161,9 +2219,11 @@ bool SMESHGUI::OnGUIEvent(int theCommandID, QAD_Desktop * parent) break; case 9010: { - SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection()); - if (Sel->IObjectCount() == 1) { - Handle(SALOME_InteractiveObject) anIObject = Sel->firstIObject(); + SalomeApp_SelectionMgr* mgr = selectionMgr(); + SALOME_ListIO selected; mgr->selectedObjects( selected ); + + if (selected.Extent() == 1) { + Handle(SALOME_InteractiveObject) anIObject = selected.First(); if(anIObject->hasEntry()) if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){ anActor->SetPointsLabeled( !anActor->GetPointsLabeled() ); @@ -2173,9 +2233,11 @@ bool SMESHGUI::OnGUIEvent(int theCommandID, QAD_Desktop * parent) } case 9011: { - SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection()); - if (Sel->IObjectCount() == 1) { - Handle(SALOME_InteractiveObject) anIObject = Sel->firstIObject(); + SalomeApp_SelectionMgr* mgr = selectionMgr(); + SALOME_ListIO selected; mgr->selectedObjects( selected ); + + if (selected.Extent() == 1) { + Handle(SALOME_InteractiveObject) anIObject = selected.First(); if(anIObject->hasEntry()) if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){ anActor->SetCellsLabeled( !anActor->GetCellsLabeled() ); @@ -2186,41 +2248,40 @@ bool SMESHGUI::OnGUIEvent(int theCommandID, QAD_Desktop * parent) case 10001: // DISPLAY MODE PREFERENCE { // Wireframe - parent->menuBar()->setItemChecked(10001, true); - parent->menuBar()->setItemChecked(10002, false); - parent->menuBar()->setItemChecked(10004, false); - parent->menuBar()->setItemEnabled(10003, true); - QAD_CONFIG->addSetting("SMESH:DisplayMode", "Wireframe"); + act->setOn( true ); + action( 10002 )->setOn( false ); + action( 10004 )->setOn( false ); + action( 10003 )->setOn( true ); + mgr->setValue( "SMESH", "DisplayMode", "Wireframe"); break; } case 10002: { - parent->menuBar()->setItemChecked(10002, true); - parent->menuBar()->setItemChecked(10001, false); - parent->menuBar()->setItemChecked(10004, false); - parent->menuBar()->setItemEnabled(10003, true); - QAD_CONFIG->addSetting("SMESH:DisplayMode", "Shading"); + act->setOn( true ); + action( 10001 )->setOn( false ); + action( 10004 )->setOn( false ); + action( 10003 )->setOn( true ); + mgr->setValue( "SMESH", "DisplayMode", "Shading"); break; } case 10003: { - parent->menuBar()->setItemChecked(10003,!parent->menuBar()->isItemChecked(10003)); - QAD_CONFIG->addSetting("SMESH:Shrink", parent->menuBar()->isItemChecked(10003) ? "yes" : "no"); + mgr->setValue( "SMESH", "Shrink", act->isOn() ); break; } case 10004: { - parent->menuBar()->setItemChecked(10001, false); - parent->menuBar()->setItemChecked(10004, true); - parent->menuBar()->setItemChecked(10002, false); - parent->menuBar()->setItemEnabled(10003, false); - QAD_CONFIG->addSetting("SMESH:DisplayMode", "Nodes"); + act->setOn( true ); + action( 10001 )->setOn( false ); + action( 10002 )->setOn( false ); + action( 10003 )->setOn( false ); + mgr->setValue( "SMESH", "DisplayMode", "Nodes" ); break; } - + } - myActiveStudy->updateObjBrowser(true); + updateObjBrowser(); return true; } @@ -2229,8 +2290,7 @@ bool SMESHGUI::OnGUIEvent(int theCommandID, QAD_Desktop * parent) * */ //============================================================================= -bool SMESHGUI::OnMousePress(QMouseEvent * pe, QAD_Desktop * parent, - QAD_StudyFrame * studyFrame) +bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd ) { return false; } @@ -2240,8 +2300,7 @@ bool SMESHGUI::OnMousePress(QMouseEvent * pe, QAD_Desktop * parent, * */ //============================================================================= -bool SMESHGUI::OnMouseMove(QMouseEvent * pe, QAD_Desktop * parent, - QAD_StudyFrame * studyFrame) +bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd ) { return true; } @@ -2251,8 +2310,7 @@ bool SMESHGUI::OnMouseMove(QMouseEvent * pe, QAD_Desktop * parent, * */ //============================================================================= -bool SMESHGUI::OnKeyPress(QKeyEvent * pe, QAD_Desktop * parent, - QAD_StudyFrame * studyFrame) +bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd ) { return true; } @@ -2262,436 +2320,770 @@ bool SMESHGUI::OnKeyPress(QKeyEvent * pe, QAD_Desktop * parent, * */ //============================================================================= -bool SMESHGUI::SetSettings(QAD_Desktop * parent) +bool SMESHGUI::SetSettings(SUIT_Desktop* parent) { MESSAGE("SMESHGUI::SetSettings."); SMESHGUI::GetSMESHGUI(); + + SUIT_ResourceMgr* mgr = resourceMgr(); + if( !mgr ) + return false; - /* Display mode */ + // Display mode QString DisplayMode = "Shading"; - if ( QAD_CONFIG->hasSetting("SMESH:DisplayMode") ) - DisplayMode = QAD_CONFIG->getSetting("SMESH:DisplayMode"); + if ( mgr->hasValue("SMESH","DisplayMode") ) + DisplayMode = mgr->stringValue("SMESH","DisplayMode"); else - QAD_CONFIG->addSetting("SMESH:DisplayMode", "Shading"); + mgr->setValue("SMESH","DisplayMode", "Shading"); bool Shrink = false; - if ( QAD_CONFIG->hasSetting("SMESH:Shrink") ) - Shrink = QAD_CONFIG->getSetting("SMESH:Shrink") == "yes"; + if ( mgr->hasValue("SMESH","Shrink") ) + Shrink = mgr->stringValue("SMESH","Shrink") == "yes"; if (DisplayMode == "Wireframe") { // wireframe - parent->menuBar()->setItemChecked(10004, false); - parent->menuBar()->setItemChecked(10002, false); - parent->menuBar()->setItemChecked(10001, true); - parent->menuBar()->setItemEnabled(10003, true); + action( 10004 )->setOn( false ); + action( 10002 )->setOn( false ); + action( 10001 )->setOn( true ); + action( 10003 )->setOn( true ); } else if (DisplayMode == "Nodes") { // poins - parent->menuBar()->setItemChecked(10004, true); - parent->menuBar()->setItemChecked(10002, false); - parent->menuBar()->setItemChecked(10001, false); - parent->menuBar()->setItemEnabled(10003, false); + action( 10004 )->setOn( true ); + action( 10002 )->setOn( false ); + action( 10001 )->setOn( false ); + action( 10003 )->setOn( false ); } else { // default is shading - parent->menuBar()->setItemChecked(10004, false); - parent->menuBar()->setItemChecked(10002, true); - parent->menuBar()->setItemChecked(10001, false); - parent->menuBar()->setItemEnabled(10003, true); + action( 10004 )->setOn( false ); + action( 10002 )->setOn( true ); + action( 10001 )->setOn( false ); + action( 10003 )->setOn( true ); } - parent->menuBar()->setItemChecked(10003, Shrink); + action( 10003 )->setOn( Shrink ); - /* Automatic Update */ - QString AutoUpdate = QAD_CONFIG->getSetting("SMESH:AutomaticUpdate"); - if (AutoUpdate.compare("true") == 0) { - parent->menuBar()->setItemChecked(1001, true); + // Automatic Update + if ( mgr->booleanValue( "SMESH","AutomaticUpdate", false ) ) { + action( 1001 )->setOn( true ); myAutomaticUpdate = true; } else { - parent->menuBar()->setItemChecked(1001, false); + action( 1001 )->setOn( false ); myAutomaticUpdate = false; } - QString anIsDisplayEntity = QAD_CONFIG->getSetting("SMESH:DispayEntity"); - if(anIsDisplayEntity.compare("true") == 0) - parent->menuBar()->setItemChecked(10071,true); + if ( mgr->booleanValue( "SMESH","DispayEntity", false ) ) + action( 10071 )->setOn( true ); else - parent->menuBar()->setItemChecked(10071,false); + action( 10071 )->setOn( false ); - /* Selection */ + // Selection SMESH::UpdateSelectionProp(); - /* menus disable */ - parent->menuBar()->setItemEnabled(111, false); // IMPORT DAT + // menus disable + //action( 111 )->setEnabled( false ); // IMPORT DAT //parent->menuBar()->setItemEnabled(112, false); // IMPORT UNV return true; } -//============================================================================= -/*! - * - */ -//============================================================================= -void SMESHGUI::DefinePopup(QString & theContext, QString & theParent, QString & theObject) -{ - // NRI : Temporary added - // if ( myStudy->GetProperties()->IsLocked() ) { - // theObject = "NothingSelected"; - // theContext = "NothingSelected"; - // } - // NRI - - SALOME_Selection *Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); - int nbSel = Sel->IObjectCount(); - switch ( nbSel ) { - case 0: - theObject = "NothingSelected"; - theContext = "NothingSelected"; - break; - case 1: - if ( myState == 800 && Sel->HasIndex( Sel->firstIObject() ) ) - theObject = "Elements"; - else - theObject = ::CheckTypeObject( Sel->firstIObject() ); - theContext = ""; - break; - default: - theObject = ::CheckHomogeneousSelection(); - theContext = ""; - } -} - -//============================================================================= -/*! - * - */ -//============================================================================= -bool SMESHGUI::CustomPopup(QAD_Desktop* parent, QPopupMenu* popup, const QString& theContext, - const QString& theParent, const QString& theObject) -{ - // get active study frame - QAD_StudyFrame* studyFrame = myActiveStudy->getActiveStudyFrame(); - - // get parent component which selected object(s) belongs to - QString parentComp = ( (SALOMEGUI_Desktop*)parent )->getComponentFromSelection(); - - // get selection - SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); - int nbSel = Sel->IObjectCount(); - - if ( nbSel == 0 ) { - popup->clear(); - } - else if ( nbSel == 1 ) { - if ( parentComp != parent->getActiveComponent() ) { - // object not belongs to SMESH module - remove all commands except common Display/Erase... - while ( 1 ) { - int id = popup->idAt( 0 ); - if ( id <= QAD_TopLabel_Popup_ID ) - popup->removeItemAt( 0 ); - else - break; - } - } - else { - // get selected interactive object - Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject(); - SALOMEDS::SObject_var SO = SMESH::GetActiveStudyDocument()->FindObjectID( IObject->getEntry() ); - // find popup menu's TopLabel item - int topItem = popup->indexOf( QAD_TopLabel_Popup_ID ); - if ( topItem >= 0 ) { - if ( theParent == "Viewer" ) { - // set bold font for popup menu's TopLabel item (Viewer popup) - QFont fnt = popup->font(); fnt.setBold( TRUE ); - popup->removeItem( QAD_TopLabel_Popup_ID ); - popup->insertItem( new CustomItem( QString( IObject->getName() ), fnt ), QAD_TopLabel_Popup_ID, topItem ); - } - else if ( theParent == "ObjectBrowser" ) { - // remove popup menu's TopLabel item (Object Browser popup) - popup->removeItem( QAD_TopLabel_Popup_ID ); - } - } - - if ( theObject == "Hypothesis" || theObject == "Algorithm" ) { - // remove Display/Erase commands - popup->removeItem( QAD_Display_Popup_ID ); - popup->removeItem( QAD_DisplayOnly_Popup_ID ); - popup->removeItem( QAD_Erase_Popup_ID ); - // remove "Unassign ..." command if hyp/algo is not assigned - if ( SO->_is_nil() || !IObject->hasReference()/* !IsReferencedObject( SO ) */) - popup->removeItem( 1102 ); - } - else if ( theObject == "Mesh" || theObject == "SubMesh" || theObject == "Group" ) { - // get actor - GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh( SO ); - if ( aShapeObject->_is_nil() ) { - // imported mesh - popup->removeItem( 701 ); // Compute - popup->removeItem( 705 ); // Edit hypothesis - popup->removeItem( 706 ); // ... - } - SMESH::SMESH_GroupOnGeom_var aGeomGroup = - SMESH::SMESH_GroupOnGeom::_narrow( SO->GetObject() ); - if ( !aGeomGroup->_is_nil() ) // group linked on geometry - popup->removeItem( 803 ); // EDIT GROUP - - SMESH_Actor* anActor = SMESH::FindActorByEntry(IObject->getEntry()); - // if object has actor - if ( anActor && studyFrame->getTypeView() == VIEW_VTK ) { - VTKViewer_RenderWindowInteractor* myRenderInter = SMESH::GetCurrentVtkView()->getRWInteractor(); - if ( myRenderInter->isVisible( IObject ) ) { - popup->removeItem( QAD_Display_Popup_ID ); - popup->setItemChecked( 9010, anActor->GetPointsLabeled() ); // Numbering / Display Nodes # - popup->setItemChecked( 9011, anActor->GetCellsLabeled() ); // Numbering / Display Elements # - TVisualObjPtr aVisualObj = anActor->GetObject(); - int aNbEdges = aVisualObj->GetNbEntities(SMDSAbs_Edge); - int aNbFaces = aVisualObj->GetNbEntities(SMDSAbs_Face); - int aNbVolumes = aVisualObj->GetNbEntities(SMDSAbs_Volume); - - QMenuItem* mi = popup->findItem( 1131 ); - if ( mi && mi->popup() ) { - int prType = anActor->GetRepresentation(); - // Display Mode / Wireframe - if(aNbVolumes == 0 && aNbFaces == 0 && aNbEdges == 0){ - mi->popup()->removeItem( 211 ); - }else{ - mi->popup()->setItemChecked( 211, prType == SMESH_Actor::eEdge ); - } - // Display Mode / Shading - if(aNbFaces == 0 && aNbVolumes == 0){ - mi->popup()->removeItem( 212 ); - }else{ - mi->popup()->setItemChecked( 212, prType == SMESH_Actor::eSurface ); - } - // Display Mode / Points - mi->popup()->setItemChecked( 215, prType == SMESH_Actor::ePoint ); - // Display Mode / Shrink - bool isShrunk = anActor->IsShrunk(); - bool isShrunkable = anActor->IsShrunkable(); - mi->popup()->setItemChecked( 213, isShrunk ); - mi->popup()->setItemEnabled( 213, prType != SMESH_Actor::ePoint && isShrunkable); - } - - // Display Entity - mi = popup->findItem( 1135 ); - int aIsSomething=0; - if (aNbVolumes>0) aIsSomething++; - if (aNbFaces>0) aIsSomething++; - if (aNbEdges>0) aIsSomething++; - if ( mi && (aIsSomething <= 1)){ - popup->removeItem(1135); - }else if ( mi && mi->popup() ) { - QPopupMenu* aPopup = mi->popup(); - unsigned int aMode = anActor->GetEntityMode(); - - bool aIsVolumesMode = aMode & SMESH_Actor::eVolumes; - bool aIsFacesMode = aMode & SMESH_Actor::eFaces; - bool aIsEdgesMode = aMode & SMESH_Actor::eEdges; - - if(aNbVolumes == 0) - aPopup->removeItem( 219 ); - else - aPopup->setItemChecked( 219, aIsVolumesMode ); - - if(aNbFaces == 0) - aPopup->removeItem( 218 ); - else - aPopup->setItemChecked( 218, aIsFacesMode ); - - - if(aNbEdges == 0) - aPopup->removeItem( 217 ); - else - aPopup->setItemChecked( 217, aIsEdgesMode ); - - - bool aIsRemove = (aNbVolumes == 0 || aIsVolumesMode); - aIsRemove &= (aNbFaces == 0 || aIsFacesMode); - aIsRemove &= (aNbEdges == 0 || aIsEdgesMode); - - if(aIsRemove) - aPopup->removeItem( 220 ); - } - - // Controls - mi = popup->findItem( 2000 ); - if ( mi && mi->popup() ) { - SMESH_Actor::eControl cMode = anActor->GetControlMode(); - switch ( cMode ) { - case SMESH_Actor::eLength: - mi->popup()->setItemChecked( 6001, true ); break; - case SMESH_Actor::eLength2D: - mi->popup()->setItemChecked( 6018, true ); break; - case SMESH_Actor::eFreeEdges: - mi->popup()->setItemChecked( 6002, true ); - mi->popup()->removeItem( 201 ); - break; - case SMESH_Actor::eFreeBorders: - mi->popup()->setItemChecked( 6003, true ); - mi->popup()->removeItem( 201 ); - break; - case SMESH_Actor::eMultiConnection: - mi->popup()->setItemChecked( 6004, true ); break; - case SMESH_Actor::eMultiConnection2D: - mi->popup()->setItemChecked( 6019, true ); break; - case SMESH_Actor::eArea: - mi->popup()->setItemChecked( 6011, true ); break; - case SMESH_Actor::eTaper: - mi->popup()->setItemChecked( 6012, true ); break; - case SMESH_Actor::eAspectRatio: - mi->popup()->setItemChecked( 6013, true ); break; - case SMESH_Actor::eAspectRatio3D: - mi->popup()->setItemChecked( 6017, true ); break; - case SMESH_Actor::eMinimumAngle: - mi->popup()->setItemChecked( 6014, true ); break; - case SMESH_Actor::eWarping: - mi->popup()->setItemChecked( 6015, true ); break; - case SMESH_Actor::eSkew: - mi->popup()->setItemChecked( 6016, true ); break; - case SMESH_Actor::eNone: - default: - mi->popup()->removeItem( 200 ); - mi->popup()->removeItem( 201 ); - break; - } - TVisualObjPtr aVisualObj = anActor->GetObject(); - if(aNbEdges == 0){ - mi->popup()->removeItem( 6001 ); - mi->popup()->removeItem( 6003 ); - mi->popup()->removeItem( 6004 ); - } - if(aNbFaces == 0){ - mi->popup()->removeItem( 6018 ); - mi->popup()->removeItem( 6002 ); - mi->popup()->removeItem( 6011 ); - mi->popup()->removeItem( 6012 ); - mi->popup()->removeItem( 6013 ); - mi->popup()->removeItem( 6014 ); - mi->popup()->removeItem( 6015 ); - mi->popup()->removeItem( 6016 ); - mi->popup()->removeItem( 6019 ); - } - if(aNbVolumes == 0){ - mi->popup()->removeItem( 6017 ); - } - if(aNbFaces == 0 && aNbEdges == 0 && aNbVolumes == 0) - popup->removeItem( 2000 ); // Scalar Bar - } - } - else { - popup->removeItem( QAD_Erase_Popup_ID ); - popup->removeItem( 114 ); // Numbering popup menu - popup->removeItem( 1131 ); // Display mode - popup->removeItem( 1132 ); // Color / size - popup->removeItem( 1133 ); // Transparency - popup->removeItem( 1134 ); // Clipping - popup->removeItem( 2000 ); // Scalar Bar - } - // VSR 03/02/05 - check if actor is empty ----- start ----- - vtkUnstructuredGrid* vtkGrid = anActor->GetUnstructuredGrid(); - if ( vtkGrid->GetNumberOfPoints() + vtkGrid->GetNumberOfCells() == 0 ) { - popup->removeItem( QAD_Display_Popup_ID ); - popup->removeItem( QAD_DisplayOnly_Popup_ID ); - popup->removeItem( QAD_Erase_Popup_ID ); - } - // VSR 03/02/05 - check if actor is empty ----- finish ----- - } - else { - // object doesn't have actor - CORBA::Object_var anObject = SO->GetObject(); - bool bDisplay = false; - if ( !CORBA::is_nil( anObject ) ) { - SMESH::SMESH_Mesh_var aMeshObj = SMESH::SMESH_Mesh::_narrow( anObject ); - if ( !aMeshObj->_is_nil() && ( aMeshObj->NbNodes() > 0 || aMeshObj->NbFaces() > 0 || aMeshObj->NbVolumes() > 0 ) ) - bDisplay = true; - SMESH::SMESH_subMesh_var aSubMeshObj = SMESH::SMESH_subMesh::_narrow( anObject ); - if ( !aSubMeshObj->_is_nil() && ( aSubMeshObj->GetNumberOfNodes(false) > 0 || aSubMeshObj->GetNumberOfElements() > 0 ) ) - bDisplay = true; - SMESH::SMESH_GroupBase_var aGroupObj = SMESH::SMESH_GroupBase::_narrow( anObject ); - if ( !aGroupObj->_is_nil() && aGroupObj->Size() > 0 ) - bDisplay = true; - } - if ( !bDisplay ) { - popup->removeItem( QAD_Display_Popup_ID ); - popup->removeItem( QAD_DisplayOnly_Popup_ID ); - } - popup->removeItem( QAD_Erase_Popup_ID ); - popup->removeItem( 114 ); // Numbering popup menu - popup->removeItem( 1131 ); // Display mode - popup->removeItem( 1132 ); // Color / size - popup->removeItem( 1133 ); // Transparency - popup->removeItem( 1134 ); // Clipping - popup->removeItem( 2000 ); // Scalar Bar - } - } - else if( theObject!="Component" ) { - // another SMESH object - popup->removeItem( QAD_Display_Popup_ID ); - popup->removeItem( QAD_DisplayOnly_Popup_ID ); - popup->removeItem( QAD_Erase_Popup_ID ); - } - } - } - else { - // multiple selection - if ( parentComp != parent->getActiveComponent() ) { - // object not belongs to SMESH module - remove all commands except common Display/Erase... - while ( 1 ) { - int id = popup->idAt( 0 ); - if ( id <= QAD_TopLabel_Popup_ID ) - popup->removeItemAt( 0 ); - else - break; - } - if ( parentComp.isNull() ) { - // objects from different components are selected - popup->removeItem( QAD_DisplayOnly_Popup_ID ); - popup->removeItem( QAD_Display_Popup_ID ); - popup->removeItem( QAD_Erase_Popup_ID ); - } - } - else { - QString type = ::CheckHomogeneousSelection(); - if ( type != "Heterogeneous Selection" ) { - int topItem = popup->indexOf( QAD_TopLabel_Popup_ID ); - if ( topItem >= 0 ) { - // set bold font for popup menu's TopLabel item - QFont fnt = popup->font(); fnt.setBold( TRUE ); - popup->removeItem( QAD_TopLabel_Popup_ID ); - popup->insertItem( new CustomItem( QString("%1 ").arg( nbSel ) + type + "(s) ", fnt ), QAD_TopLabel_Popup_ID, topItem ); - } - } - } - } - return false; -} - //============================================================================= /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO) * Purpose: ensures that the actor for the given exists in the active VTK view */ //============================================================================= void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO, - QAD_ViewFrame* ) + SUIT_ViewWindow* wnd ) { if(theIO->hasEntry()){ - QAD_Study* aStudy = SMESHGUI::GetSMESHGUI()->GetActiveStudy(); - QAD_StudyFrame *aStudyFrame = aStudy->getActiveStudyFrame(); - SMESH::UpdateView(aStudyFrame,SMESH::eDisplay,theIO->getEntry()); + //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow(); + SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry()); } } -void SMESHGUI::SupportedViewType(int *buffer, int bufferSize) +//======================================================================= +// function : createSMESHAction +// purpose : +//======================================================================= +void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle ) { - if (!buffer || !bufferSize) + QIconSet icon; + QWidget* parent = application()->desktop(); + SUIT_ResourceMgr* resMgr = resourceMgr(); + QPixmap pix; + if ( icon_id.length() ) + pix = resMgr->loadPixmap( "SMESH", tr( icon_id ) ); + else + pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_" )+po_id ) ); + if ( !pix.isNull() ) + icon = QIconSet( pix ); + + QString tooltip = tr( QString( "TOP_" )+po_id ), + menu = tr( QString( "MEN_" )+po_id ), + status_bar = tr( QString( "STB_" )+po_id ); + + createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) ); +} + +//======================================================================= +// function : createPopupItem +// purpose : +//======================================================================= +void SMESHGUI::createPopupItem( const int id, + const QString& clients, + const QString& types, + const QString& theRule, + const int pId ) +{ + int parentId = pId; + if( pId!=-1 ) + parentId = popupMgr()->actionId( action( pId ) ); + + if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) ) + popupMgr()->insert( action( id ), parentId, 0 ); + + QChar lc = popupMgr()->equality(); + QString rule = "(%1) and (%2) and (%3)"; + rule = rule.arg( QString( "%1>0" ).arg( popupMgr()->selCountParam() ) ); + rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) ); + rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) ); + rule += theRule; + + bool cont = myRules.contains( id ); + if( cont ) + rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule ); + + popupMgr()->setRule( action( id ), rule, true ); + myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule ); +} + +//======================================================================= +// function : initialize +// purpose : +//======================================================================= +void SMESHGUI::initialize( CAM_Application* app ) +{ + SalomeApp_Module::initialize( app ); + + // ----- create actions -------------- + + createSMESHAction( 111, "DAT", "", (CTRL+Key_B) ); + createSMESHAction( 112, "UNV", "", (CTRL+Key_U) ); + createSMESHAction( 113, "MED", "", (CTRL+Key_M) ); + createSMESHAction( 114, "NUM" ); + createSMESHAction( 121, "DAT" ); + createSMESHAction( 122, "MED" ); + createSMESHAction( 123, "UNV" ); + createSMESHAction( 124, "EXPORT_DAT" ); + createSMESHAction( 125, "EXPORT_MED" ); + createSMESHAction( 126, "EXPORT_UNV" ); + createSMESHAction( 33, "DELETE", "ICON_DELETE" ); + createSMESHAction( 5105, "SEL_FILTER_LIB" ); + createSMESHAction( 5000, "CREATE_HYPO", "ICON_HYPO" ); + createSMESHAction( 5010, "CREATE_ALG", "ICON_PATTERN_2d" ); + createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" ); + createSMESHAction( 702, "LOCAL_HYPO", "ICON_DLG_ADD_SUBMESH" ); + createSMESHAction( 703, "GLOBAL_HYPO", "ICON_DLG_INIT_MESH" ); + createSMESHAction( 704, "EDIT_HYPO", "ICON_DLG_EDIT_MESH" ); + createSMESHAction( 705, "EDIT_GLOBAL_HYPO","ICON_DLG_EDIT_MESH" ); + createSMESHAction( 706, "EDIT_LOCAL_HYPO", "ICON_DLG_EDIT_MESH" ); + createSMESHAction( 801, "CREATE_GROUP", "ICON_SMESH_TREE_GROUP" ); + createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" ); + createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" ); + createSMESHAction( 804, "ADD" ); + createSMESHAction( 805, "REMOVE" ); + createSMESHAction( 810, "UN_GROUP", "ICON_UNION" ); + createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" ); + createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" ); + createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" ); + createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" ); + createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" ); + createSMESHAction( 6001, "LENGTH", "ICON_LENGTH" ); + createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE" ); + createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D" ); + createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION" ); + createSMESHAction( 6011, "AREA", "ICON_AREA" ); + createSMESHAction( 6012, "TAPER", "ICON_TAPER" ); + createSMESHAction( 6013, "ASPECT", "ICON_ASPECT" ); + createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE" ); + createSMESHAction( 6015, "WRAP", "ICON_WRAP" ); + createSMESHAction( 6016, "SKEW", "ICON_SKEW" ); + createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D" ); + createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D" ); + createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D" ); + createSMESHAction( 400, "NODE", "ICON_DLG_NODE" ); + createSMESHAction( 401, "EDGE", "ICON_DLG_EDGE" ); + createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" ); + createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" ); + createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" ); + createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" ); + createSMESHAction( 4041, "NODES", "ICON_DLG_REM_NODE" ); + createSMESHAction( 4042, "ELEMENTS", "ICON_DLG_REM_ELEMENT" ); + createSMESHAction( 4051, "NODES", "ICON_DLG_RENUMBERING_NODES" ); + createSMESHAction( 4052, "ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" ); + createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" ); + createSMESHAction( 4062, "ROT", "ICON_DLG_ROTATION" ); + createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" ); + createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" ); + createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" ); + createSMESHAction( 406, "MOVE", "ICON_DLG_MOVE_NODE" ); + createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" ); + createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" ); + createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" ); + createSMESHAction( 410, "UNION", "ICON_UNIONTRI" ); + createSMESHAction( 411, "CUT", "ICON_CUTQUAD" ); + createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" ); + createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" ); + createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" ); + createSMESHAction( 415, "MAP", "ICON_MAP" ); + createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" ); + createSMESHAction( 10001, "WIRE", "ICON_WIRE", 0, true ); + createSMESHAction( 10002, "SHADE", "ICON_SHADE", 0, true ); + createSMESHAction( 10003, "SHRINK", "ICON_SHRINK", 0, true ); + createSMESHAction( 10004, "NODES", "ICON_POINTS", 0, true ); + createSMESHAction( 1001, "AUTO_UPD", "", 0, true ); + createSMESHAction( 1003, "COLORS" ); + createSMESHAction( 1005, "SCALAR_BAR" ); + createSMESHAction( 1006, "SELECTION" ); + createSMESHAction( 10070, "PRECISION", "", 0, true ); + createSMESHAction( 10071, "DISP_ENT", "", 0, true ); + createSMESHAction( 200, "RESET" ); + createSMESHAction( 201, "SCALAR_BAR_PROP" ); + createSMESHAction( 211, "WIRE", "ICON_WIRE" ); + createSMESHAction( 212, "SHADE", "ICON_SHADE" ); + createSMESHAction( 213, "SHRINK", "ICON_SHRINK" ); + createSMESHAction( 214, "UPDATE", "ICON_UPDATE" ); + createSMESHAction( 215, "NODES", "ICON_POINTS" ); + createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE" ); + createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE" ); + createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS" ); + createSMESHAction( 220, "ALL" ); + createSMESHAction( 1101, "RENAME" ); + createSMESHAction( 9010, "NUM_NODES" ); + createSMESHAction( 9011, "NUM_ELEMENTS" ); + createSMESHAction( 1131, "DISPMODE" ); + createSMESHAction( 1132, "COLORS" ); + createSMESHAction( 1133, "TRANSP" ); + createSMESHAction( 1134, "CLIP" ); + createSMESHAction( 1135, "DISP_ENT" ); + createSMESHAction( 2000, "CTRL" ); + + createSMESHAction( 300, "ERASE" ); + createSMESHAction( 301, "DISPLAY" ); + createSMESHAction( 302, "DISPLAY_ONLY" ); + + // ----- create menu -------------- + int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ), + editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ), + toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 10 ), + hypoId = createMenu( tr( "MEN_HYPO" ), -1, 50, 10 ), + meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ), + ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ), + modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ), + prefId = createMenu( tr( "MEN_PREF" ), -1, 4, 10 ), + viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 ); + + createMenu( separator(), fileId ); + + int importId = createMenu( tr( "MEN_IMPORT" ), fileId, 11, 10 ), + exportId = createMenu( tr( "MEN_EXPORT" ), fileId, 12, 10 ), + + addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ), + removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ), + renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ), + transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 ), + + meshPrefId = createMenu( tr( "MEN_MESH" ), prefId, 100 ), + + dispModeId = createMenu( tr( "MEN_DISPMODE" ), meshPrefId, 1000 ), + qualityId = createMenu( tr( "MEN_QUALITY" ), meshPrefId, 1007 ); + + createMenu( 111, importId, -1 ); + createMenu( 112, importId, -1 ); + createMenu( 113, importId, -1 ); + + createMenu( 121, exportId, -1 ); + createMenu( 122, exportId, -1 ); + createMenu( 123, exportId, -1 ); + + createMenu( separator(), fileId, 10 ); + + createMenu( 33, editId, -1 ); + + createMenu( 5105, toolsId, -1 ); + + createMenu( 5000, hypoId, -1 ); + createMenu( 5010, hypoId, -1 ); + + createMenu( 703, meshId, -1 ); + createMenu( 702, meshId, -1 ); + createMenu( 704, meshId, -1 ); + createMenu( separator(), meshId, -1 ); + createMenu( 701, meshId, -1 ); + createMenu( separator(), meshId, -1 ); + createMenu( 801, meshId, -1 ); + createMenu( 802, meshId, -1 ); + createMenu( 803, meshId, -1 ); + createMenu( separator(), meshId, -1 ); + createMenu( 810, meshId, -1 ); + createMenu( 811, meshId, -1 ); + createMenu( 812, meshId, -1 ); + createMenu( separator(), meshId, -1 ); + createMenu( 813, meshId, -1 ); + createMenu( separator(), meshId, -1 ); + createMenu( 900, meshId, -1 ); + createMenu( 902, meshId, -1 ); + createMenu( separator(), meshId, -1 ); + + createMenu( 6003, ctrlId, -1 ); + createMenu( 6001, ctrlId, -1 ); + createMenu( 6004, ctrlId, -1 ); + createMenu( separator(), ctrlId, -1 ); + createMenu( 6002, ctrlId, -1 ); + createMenu( 6018, ctrlId, -1 ); + createMenu( 6019, ctrlId, -1 ); + createMenu( 6011, ctrlId, -1 ); + createMenu( 6012, ctrlId, -1 ); + createMenu( 6013, ctrlId, -1 ); + createMenu( 6014, ctrlId, -1 ); + createMenu( 6015, ctrlId, -1 ); + createMenu( 6016, ctrlId, -1 ); + createMenu( separator(), ctrlId, -1 ); + createMenu( 6017, ctrlId, -1 ); + createMenu( separator(), ctrlId, -1 ); + + createMenu( 400, addId, -1 ); + createMenu( 401, addId, -1 ); + createMenu( 4021, addId, -1 ); + createMenu( 4022, addId, -1 ); + createMenu( 4031, addId, -1 ); + createMenu( 4032, addId, -1 ); + + createMenu( 4041, removeId, -1 ); + createMenu( 4042, removeId, -1 ); + + createMenu( 4051, renumId, -1 ); + createMenu( 4052, renumId, -1 ); + + createMenu( 4061, transfId, -1 ); + createMenu( 4062, transfId, -1 ); + createMenu( 4063, transfId, -1 ); + createMenu( 4064, transfId, -1 ); + createMenu( 4065, transfId, -1 ); + + createMenu( 406, modifyId, -1 ); + createMenu( 407, modifyId, -1 ); + createMenu( 408, modifyId, -1 ); + createMenu( 409, modifyId, -1 ); + createMenu( 410, modifyId, -1 ); + createMenu( 411, modifyId, -1 ); + createMenu( 412, modifyId, -1 ); + createMenu( 413, modifyId, -1 ); + createMenu( 416, modifyId, -1 ); + createMenu( 414, modifyId, -1 ); + createMenu( 415, modifyId, -1 ); + + createMenu( 10001, dispModeId, -1 ); + createMenu( 10002, dispModeId, -1 ); + createMenu( 10004, dispModeId, -1 ); + createMenu( 10003, dispModeId, -1 ); + + createMenu( 1001, prefId, -1 ); + createMenu( separator(), prefId, -1 ); + createMenu( 1003, prefId, -1 ); + createMenu( separator(), prefId, -1 ); + createMenu( 1005, prefId, -1 ); + createMenu( separator(), prefId, -1 ); + createMenu( 1006, prefId, -1 ); + createMenu( separator(), prefId, -1 ); + + createMenu( 10070, qualityId, -1 ); + createMenu( 10071, qualityId, -1 ); + + createMenu( separator(), prefId, -1 ); + + createMenu( 214, viewId, -1 ); + + // ----- create toolbars -------------- + int meshTb = createTool( tr( "TB_MESH" ) ), + hypoTb = createTool( tr( "TB_HYPO" ) ), + ctrlTb = createTool( tr( "TB_CTRL" ) ), + addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ), + modifyTb = createTool( tr( "TB_MODIFY" ) ), + dispModeTb = createTool( tr( "TB_DISP_MODE" ) ); + + createTool( 703, meshTb ); + createTool( 702, meshTb ); + createTool( 704, meshTb ); + createTool( separator(), meshTb ); + createTool( 701, meshTb ); + createTool( separator(), meshTb ); + createTool( 801, meshTb ); + createTool( 802, meshTb ); + createTool( 803, meshTb ); + createTool( separator(), meshTb ); + createTool( 900, meshTb ); + createTool( 902, meshTb ); + createTool( separator(), meshTb ); + + createTool( 5000, hypoTb ); + createTool( 5010, hypoTb ); + + createTool( 6001, ctrlTb ); + createTool( 6003, ctrlTb ); + createTool( 6004, ctrlTb ); + createTool( separator(), ctrlTb ); + createTool( 6002, ctrlTb ); + createTool( 6018, ctrlTb ); + createTool( 6019, ctrlTb ); + createTool( 6011, ctrlTb ); + createTool( 6012, ctrlTb ); + createTool( 6013, ctrlTb ); + createTool( 6014, ctrlTb ); + createTool( 6015, ctrlTb ); + createTool( 6016, ctrlTb ); + createTool( separator(), ctrlTb ); + createTool( 6017, ctrlTb ); + createTool( separator(), ctrlTb ); + + createTool( 400, addRemTb ); + createTool( 401, addRemTb ); + createTool( 4021, addRemTb ); + createTool( 4022, addRemTb ); + createTool( 4031, addRemTb ); + createTool( 4032, addRemTb ); + createTool( separator(), addRemTb ); + createTool( 4041, addRemTb ); + createTool( 4042, addRemTb ); + createTool( separator(), addRemTb ); + createTool( 4051, addRemTb ); + createTool( 4052, addRemTb ); + createTool( separator(), addRemTb ); + createTool( 4061, addRemTb ); + createTool( 4062, addRemTb ); + createTool( 4063, addRemTb ); + createTool( 4064, addRemTb ); + createTool( 4065, addRemTb ); + createTool( separator(), addRemTb ); + + createTool( 406, modifyTb ); + createTool( 407, modifyTb ); + createTool( 408, modifyTb ); + createTool( 409, modifyTb ); + createTool( 410, modifyTb ); + createTool( 411, modifyTb ); + createTool( 412, modifyTb ); + createTool( 413, modifyTb ); + createTool( 416, modifyTb ); + createTool( 414, modifyTb ); + createTool( 415, modifyTb ); + + createTool( 214, dispModeTb ); + + + myRules.clear(); + QString OB = "'ObjectBrowser'", + View = "'" + SVTK_Viewer::Type() + "'", + pat = "'%1'", + mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ), + group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ), + hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ), + algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ), + elems = QString( "'%1' '%2' '%3' '%4' '%5'" ). + arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ). + arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ). + arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ). + arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ). + arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ), + subMesh = elems, + mesh_group = mesh + " " + subMesh + " " + group, + hyp_alg = hypo + " " + algo; + + // popup for object browser + + createPopupItem( 705, OB, mesh, "&& isComputable"); // EDIT_GLOBAL_HYPO + createPopupItem( 706, OB, subMesh, "&& isComputable" ); // EDIT_LOCAL_HYPO + createPopupItem( 803, OB, group ); // EDIT_GROUP + popupMgr()->insert( separator(), -1, 0 ); + createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE + createPopupItem( 214, OB, mesh_group ); // UPDATE + createPopupItem( 900, OB, mesh_group ); // ADV_INFO + createPopupItem( 902, OB, mesh ); // STD_INFO + popupMgr()->insert( separator(), -1, 0 ); + createPopupItem( 801, OB, mesh ); // CREATE_GROUP + createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP + popupMgr()->insert( separator(), -1, 0 ); + createPopupItem( 1100, OB, hypo ); // EDIT HYPOTHESIS + createPopupItem( 1102, OB, hyp_alg, "&& hasReference" ); // REMOVE HYPOTHESIS / ALGORITHMS + createPopupItem( 1101, OB, mesh_group + " " + hyp_alg ); // RENAME + popupMgr()->insert( separator(), -1, 0 ); + createPopupItem( 125, OB, mesh ); // EXPORT_MED + createPopupItem( 126, OB, mesh ); // EXPORT_UNV + createPopupItem( 33, OB, subMesh + " " + group ); // DELETE + popupMgr()->insert( separator(), -1, 0 ); + + // popup for viewer + createPopupItem( 803, View, group ); // EDIT_GROUP + createPopupItem( 804, View, elems ); // ADD + createPopupItem( 805, View, elems ); // REMOVE + popupMgr()->insert( separator(), -1, 0 ); + createPopupItem( 214, View, mesh_group ); // UPDATE + createPopupItem( 900, View, mesh_group ); // ADV_INFO + createPopupItem( 902, View, mesh ); // STD_INFO + popupMgr()->insert( separator(), -1, 0 ); + + int anId; + QString + isInvisible("not( isVisible )"), + isEmpty("numberOfNodes = 0"), + isNotEmpty("numberOfNodes <> 0"), + + // has nodes, edges, etc in VISIBLE! actor + hasNodes("(numberOfNodes > 0 && isVisible)"), + hasElems("count( elemTypes ) > 0"), + hasDifferentElems("count( elemTypes ) > 1"), + hasEdges("{'Edge'} in elemTypes"), + hasFaces("{'Face'} in elemTypes"), + hasVolumes("{'Volume'} in elemTypes"); + + QString aSelCount = popupMgr()->selCountParam() + "= 1"; + QString aClient = QString( popupMgr()->equality() )+ "client in {" + View + "}"; + QString aType = QString( popupMgr()->equality() ) + "type in {" + mesh_group + "}"; + QString aMeshInVTK = aClient + "&&" + aType + "&&" + aSelCount; + + //------------------------------------------------- + // Numbering + //------------------------------------------------- + anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 ); + + popupMgr()->insert( action( 9010 ), anId, -1 ); + popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&&" + hasNodes, true ); + popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", false ); + + popupMgr()->insert( action( 9011 ), anId, -1 ); + popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&&" + hasElems, true ); + popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", false ); + + popupMgr()->insert( separator(), -1, -1 ); + + //------------------------------------------------- + // Display Mode + //------------------------------------------------- + anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 ); + + popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE + popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, true ); + popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", false ); + + popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE + popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")",true); + popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", false ); + + popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS + popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, true ); + popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", false ); + + popupMgr()->insert( separator(), anId, -1 ); + + popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK + popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'",true); + popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", false ); + + //------------------------------------------------- + // Display Entity + //------------------------------------------------- + QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems; + + anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 ); + + popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES + popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&&" + hasEdges, true ); + popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", false ); + + popupMgr()->insert( action( 218 ), anId, -1 ); // FACES + popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&&" + hasFaces, true ); + popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", false ); + + popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES + popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&&" + hasVolumes, true ); + popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", false ); + + popupMgr()->insert( separator(), anId, -1 ); + + popupMgr()->insert( action( 220 ), anId, -1 ); // ALL + popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& not( elemTypes in entityMode )", true ); + + //------------------------------------------------- + // Color / Size + //------------------------------------------------- + popupMgr()->insert( action( 1132 ), -1, -1 ); + popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", true ); + + //------------------------------------------------- + // Transparency + //------------------------------------------------- + popupMgr()->insert( action( 1133 ), -1, -1 ); + popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", true ); + + //------------------------------------------------- + // Clipping + //------------------------------------------------- + popupMgr()->insert( action( 1134 ), -1, -1 ); + popupMgr()->setRule( action( 1134 ), aMeshInVTK + "&& isVisible", true ); + + popupMgr()->insert( separator(), -1, -1 ); + + //------------------------------------------------- + // Controls + //------------------------------------------------- + QString + aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges, + aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces, + aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes; + + anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 ); + + popupMgr()->insert( action( 200 ), anId, -1 ); // RESET + popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", true ); + + popupMgr()->insert( separator(), anId, -1 ); + + popupMgr()->insert( action( 6003 ), anId, -1 ); // FREE_BORDER + popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, true ); + popupMgr()->setRule( action( 6003 ), "&& controlMode = 'eFreeEdges'", true ); + + popupMgr()->insert( action( 6001 ), anId, -1 ); // LENGTH + popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, true ); + popupMgr()->setRule( action( 6001 ), "&& controlMode = 'eLength'", true ); + + popupMgr()->insert( action( 6004 ), anId, -1 ); // CONNECTION + popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, true ); + popupMgr()->setRule( action( 6004 ), "&& controlMode = 'eMultiConnection'", true ); + + popupMgr()->insert( separator(), anId, -1 ); + + popupMgr()->insert( action( 6002 ), anId, -1 ); // FREE_EDGE + popupMgr()->setRule( action( 6002 ), aMeshInVtkHasFaces, true ); + popupMgr()->setRule( action( 6002 ), "&& controlMode = 'eFreeBorders'", true ); + + popupMgr()->insert( action( 6018 ), anId, -1 ); // LENGTH_2D + popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, true ); + popupMgr()->setRule( action( 6018 ), "&& controlMode = 'eLength2D'", true ); + + popupMgr()->insert( action( 6019 ), anId, -1 ); // CONNECTION_2D + popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, true ); + popupMgr()->setRule( action( 6019 ), "&& controlMode = 'eMultiConnection2D'", true ); + + popupMgr()->insert( action( 6011 ), anId, -1 ); // AREA + popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, true ); + popupMgr()->setRule( action( 6011 ), "&& controlMode = 'eArea'", true ); + + popupMgr()->insert( action( 6012 ), anId, -1 ); // TAPER + popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, true ); + popupMgr()->setRule( action( 6012 ), "&& controlMode = 'eTaper'", true ); + + popupMgr()->insert( action( 6013 ), anId, -1 ); // ASPECT + popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, true ); + popupMgr()->setRule( action( 6013 ), "&& controlMode = 'eAspectRatio'", true ); + + popupMgr()->insert( action( 6014 ), anId, -1 ); // MIN_ANG + popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, true ); + popupMgr()->setRule( action( 6014 ), "&& controlMode = 'eMinimumAngle'", true ); + + popupMgr()->insert( action( 6015 ), anId, -1 ); // WRAP + popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, true ); + popupMgr()->setRule( action( 6015 ), "&& controlMode = 'eWarping'", true ); + + popupMgr()->insert( action( 6016 ), anId, -1 ); // SKEW + popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, true ); + popupMgr()->setRule( action( 6016 ), "&& controlMode = 'eSkew'", true ); + + popupMgr()->insert( separator(), anId, -1 ); + + popupMgr()->insert( action( 6017 ), anId, -1 ); // ASPECT_3D + popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, true ); + popupMgr()->setRule( action( 6017 ), "&& controlMode = 'eAspectRatio3D'", true ); + + popupMgr()->insert( separator(), anId, -1 ); + + popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP + popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", true ); + + popupMgr()->insert( separator(), -1, -1 ); + + //------------------------------------------------- + // Display / Erase + //------------------------------------------------- + aClient = "($client in {'VTKViewer' 'ObjectBrowser'})"; + QString aRule = aClient + " and " + aType + " and " + aSelCount; + popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY + popupMgr()->setRule( action( 301 ), aRule + "&&" + isNotEmpty + "&&" + isInvisible, true); + + popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE + popupMgr()->setRule( action( 300 ), aRule + "&&" + isNotEmpty + "&& isVisible", true ); + + popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY + popupMgr()->setRule( action( 302 ), aRule + "&&" + isNotEmpty, true ); + + popupMgr()->insert( separator(), -1, -1 ); +} + +void SMESHGUI::activateModule( SUIT_Study* study ) +{ + SalomeApp_Module::activateModule( study ); + + setMenuShown( true ); + setToolShown( true ); + + //SetSettings( desktop() ); +} + +void SMESHGUI::deactivateModule( SUIT_Study* study ) +{ + setMenuShown( false ); + setToolShown( false ); + + EmitSignalCloseAllDialogs(); + + SalomeApp_Module::deactivateModule( study ); +} + +void SMESHGUI::OnGUIEvent() +{ + const QObject* obj = sender(); + if ( !obj || !obj->inherits( "QAction" ) ) return; - buffer[0] = (int)VIEW_VTK; + int id = actionId((QAction*)obj); + if ( id != -1 ) + OnGUIEvent( id ); } -void SMESHGUI::Deactivate() +SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen() { - if ( SMESHGUI::GetSMESHGUI() ) { - SMESHGUI::GetSMESHGUI()->EmitSignalCloseAllDialogs(); - } + return myComponentSMESH; +} + +QString SMESHGUI::engineIOR() const +{ + CORBA::ORB_var anORB = getApp()->orb(); + CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen()); + return anIOR.in(); +} + +void SMESHGUI::contextMenuPopup( const QString& client, QPopupMenu* menu, QString& /*title*/ ) +{ + SMESHGUI_Selection sel( client, selectionMgr() ); + popupMgr()->updatePopup( menu, &sel ); +} + +void SMESHGUI::windows( QMap& aMap ) const +{ + aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft ); + aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::DockBottom ); +} + +void SMESHGUI::viewManagers( QStringList& list ) const +{ + list.append( SVTK_Viewer::Type() ); } diff --git a/src/SMESHGUI/SMESHGUI.h b/src/SMESHGUI/SMESHGUI.h index 4905f783f..3ed5b2922 100644 --- a/src/SMESHGUI/SMESHGUI.h +++ b/src/SMESHGUI/SMESHGUI.h @@ -11,7 +11,7 @@ // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software @@ -30,71 +30,96 @@ #define SMESHGUI_HeaderFile // SALOME Includes -#include "SALOMEGUI.h" -#include "SALOME_InteractiveObject.hxx" +#include +#include -class QAD_Desktop; -class QAD_Study; +#include +#include CORBA_SERVER_HEADER(SMESH_Gen) class QDialog; +class SUIT_Desktop; +class SUIT_Study; +class SUIT_ViewWindow; +class SUIT_ResourceMgr; +class SUIT_ViewManager; + +class SalomeApp_Study; +class SalomeApp_SelectionMgr; + //================================================================================= // class : SMESHGUI // purpose : //================================================================================= -class SMESHGUI : public SALOMEGUI +class SMESHGUI : public SalomeApp_Module { Q_OBJECT; -private : - QAD_Desktop* myDesktop; - QAD_Study* myActiveStudy; - QDialog* myActiveDialogBox; - - int myState; - bool myAutomaticUpdate; - public : - SMESHGUI( const QString& name = "", QObject* parent = 0 ); - static SMESHGUI* GetSMESHGUI() ; + SMESHGUI(); ~SMESHGUI(); - QAD_Desktop* GetDesktop() ; - QAD_Study* GetActiveStudy() ; - bool ActiveStudyLocked(); + static SMESH::SMESH_Gen_var GetSMESHGen(); + static SMESHGUI* GetSMESHGUI(); + static SalomeApp_SelectionMgr* selectionMgr(); + static SUIT_ResourceMgr* resourceMgr(); + static SUIT_Desktop* desktop() ; + static SalomeApp_Study* activeStudy(); + bool isActiveStudyLocked(); - QDialog* GetActiveDialogBox() ; - void SetActiveDialogBox(QDialog* aDlg) ; + virtual QString engineIOR() const; + virtual void initialize( CAM_Application* ); + virtual void windows( QMap& ) const; + virtual void viewManagers( QStringList& ) const; - void ResetState() ; + QDialog* GetActiveDialogBox() ; + void SetActiveDialogBox(QDialog* aDlg) ; + + void ResetState() ; void SetState(int aState) ; bool DefineDlgPosition(QWidget* aDlg, int& x, int& y) ; - virtual bool OnGUIEvent (int theCommandID, QAD_Desktop* parent); - virtual bool OnMousePress (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame); - virtual bool OnMouseMove (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame); - virtual bool OnKeyPress (QKeyEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame); - virtual bool ActiveStudyChanged( QAD_Desktop* parent ); - virtual bool SetSettings ( QAD_Desktop* parent ); - virtual void DefinePopup ( QString & theContext, QString & theParent, QString & theObject ); - virtual bool CustomPopup ( QAD_Desktop* parent, QPopupMenu* popup, const QString & theContext, - const QString & theParent, const QString & theObject ); - virtual void BuildPresentation ( const Handle(SALOME_InteractiveObject)& theIO, - QAD_ViewFrame* = 0 ); - virtual void SupportedViewType (int* buffer, int bufferSize); - virtual void Deactivate (); + virtual bool OnGUIEvent ( int id ); + virtual bool OnMousePress ( QMouseEvent*, SUIT_ViewWindow* ); + virtual bool OnMouseMove ( QMouseEvent*, SUIT_ViewWindow* ); + virtual bool OnKeyPress ( QKeyEvent*, SUIT_ViewWindow* ); - /* Non modal dialog boxes magement */ + virtual void contextMenuPopup( const QString&, QPopupMenu*, QString& ); + + virtual bool SetSettings ( SUIT_Desktop* ); + virtual void BuildPresentation ( const Handle(SALOME_InteractiveObject)&, + SUIT_ViewWindow* = 0 ); + + /* Non modal dialog boxes management */ void EmitSignalDeactivateDialog() ; void EmitSignalStudyFrameChanged() ; void EmitSignalCloseAllDialogs() ; +public slots: + virtual void deactivateModule( SUIT_Study* ); + virtual void activateModule( SUIT_Study* ); + +private slots: + void OnGUIEvent(); + signals: void SignalDeactivateActiveDialog() ; void SignalStudyFrameChanged() ; void SignalCloseAllDialogs() ; +protected: + void createSMESHAction( const int, const QString&, const QString& = QString(""), + const int = 0, const bool = false ); + void createPopupItem( const int, const QString&, const QString&, + const QString& = QString::null, const int = -1 ); + +private : + static SMESH::SMESH_Gen_var myComponentSMESH; + QDialog* myActiveDialogBox; + int myState; + bool myAutomaticUpdate; + QMap myRules; }; diff --git a/src/SMESHGUI/SMESHGUI_AddMeshElementDlg.cxx b/src/SMESHGUI/SMESHGUI_AddMeshElementDlg.cxx index f7860c799..a15542896 100644 --- a/src/SMESHGUI/SMESHGUI_AddMeshElementDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_AddMeshElementDlg.cxx @@ -1,23 +1,23 @@ // SMESH SMESHGUI : GUI for SMESH component // // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org // // // @@ -34,17 +34,30 @@ #include "SMESHGUI_MeshUtils.h" #include "SMESHGUI_IdValidator.h" #include "SMESH_ActorUtils.h" - -#include "VTKViewer_ViewFrame.h" + #include "SMDS_Mesh.hxx" #include "SMESH_Actor.h" -#include "QAD_Application.h" -#include "QAD_Desktop.h" -#include "QAD_MessageBox.h" +#include "SUIT_Session.h" + +#include "SVTK_Selection.h" +#include "SVTK_Selector.h" +#include "SALOME_ListIO.hxx" +#include "SALOME_ListIteratorOfListIO.hxx" + +#include "SalomeApp_Study.h" +#include "SalomeApp_Application.h" + +#include "SVTK_ViewModel.h" +#include "SVTK_ViewWindow.h" #include "utilities.h" +// OCCT Includes +#include +#include + +// VTK Includes #include #include #include @@ -69,39 +82,41 @@ #include #include +// STL includes #include -#include using namespace std; -namespace SMESH{ +namespace SMESH { - class TElementSimulation{ - QAD_Study* myStudy; - QAD_StudyFrame* myStudyFrame; - VTKViewer_ViewFrame* myViewFrame; + class TElementSimulation { + SalomeApp_Application* myApplication; + SUIT_ViewWindow* myViewWindow; + SVTK_ViewWindow* myVTKViewWindow; - SALOME_Actor *myPreviewActor; + SALOME_Actor* myPreviewActor; vtkDataSetMapper* myMapper; vtkUnstructuredGrid* myGrid; public: - - TElementSimulation(QAD_Study* theStudy): - myStudy(theStudy), - myStudyFrame(theStudy->getActiveStudyFrame()), - myViewFrame(GetVtkViewFrame(theStudy->getActiveStudyFrame())) + TElementSimulation (SalomeApp_Application* theApplication) { + myApplication = theApplication; + SUIT_ViewManager* mgr = theApplication->activeViewManager(); + if (!mgr) return; + myViewWindow = mgr->getActiveView(); + myVTKViewWindow = GetVtkViewWindow(myViewWindow); + myGrid = vtkUnstructuredGrid::New(); - + // Create and display actor myMapper = vtkDataSetMapper::New(); - myMapper->SetInput( myGrid ); + myMapper->SetInput(myGrid); myPreviewActor = SALOME_Actor::New(); myPreviewActor->PickableOff(); myPreviewActor->VisibilityOff(); - myPreviewActor->SetMapper( myMapper ); + myPreviewActor->SetMapper(myMapper); vtkProperty* aProp = vtkProperty::New(); float anRGB[3]; @@ -109,7 +124,7 @@ namespace SMESH{ anRGB[1] = GetFloat("SMESH:SettingsFillColorGreen", 170)/255.; anRGB[2] = GetFloat("SMESH:SettingsFillColorBlue", 255)/255.; aProp->SetColor(anRGB[0],anRGB[1],anRGB[2]); - myPreviewActor->SetProperty( aProp ); + myPreviewActor->SetProperty(aProp); aProp->Delete(); vtkProperty* aBackProp = vtkProperty::New(); @@ -117,39 +132,41 @@ namespace SMESH{ anRGB[1] = GetFloat("SMESH:SettingsBackFaceColorGreen", 0)/255.; anRGB[2] = GetFloat("SMESH:SettingsBackFaceColorBlue", 255)/255.; aBackProp->SetColor(anRGB[0],anRGB[1],anRGB[2]); - myPreviewActor->SetBackfaceProperty( aBackProp ); + myPreviewActor->SetBackfaceProperty(aBackProp); aBackProp->Delete(); - myViewFrame->AddActor( myPreviewActor ); - + myVTKViewWindow->AddActor(myPreviewActor); } - typedef std::vector TVTKIds; - void SetPosition(SMESH_Actor* theActor, - vtkIdType theType, - const TVTKIds& theIds) + void SetPosition (SMESH_Actor* theActor, + vtkIdType theType, + const TVTKIds& theIds) { vtkUnstructuredGrid *aGrid = theActor->GetUnstructuredGrid(); myGrid->SetPoints(aGrid->GetPoints()); const int* aConn = NULL; - switch(theType){ - case VTK_TETRA:{ - static int anIds[] = {0,2,1,3}; - aConn = anIds; - break; + switch (theType) { + case VTK_TETRA: + { + static int anIds[] = {0,2,1,3}; + aConn = anIds; + break; + } + case VTK_PYRAMID: + { + static int anIds[] = {0,3,2,1,4}; + aConn = anIds; + break; + } + case VTK_HEXAHEDRON: + { + static int anIds[] = {0,3,2,1,4,7,6,5}; + aConn = anIds; + break; + } } - case VTK_PYRAMID:{ - static int anIds[] = {0,3,2,1,4}; - aConn = anIds; - break; - } - case VTK_HEXAHEDRON:{ - static int anIds[] = {0,3,2,1,4,7,6,5}; - aConn = anIds; - break; - }} myGrid->Reset(); vtkIdList *anIds = vtkIdList::New(); @@ -170,15 +187,17 @@ namespace SMESH{ } - void SetVisibility(bool theVisibility){ + void SetVisibility (bool theVisibility) + { myPreviewActor->SetVisibility(theVisibility); RepaintCurrentView(); } - ~TElementSimulation(){ - if(FindVtkViewFrame(myStudy,myStudyFrame)){ - myViewFrame->RemoveActor(myPreviewActor); + ~TElementSimulation() + { + if (FindVtkViewWindow(myApplication->activeViewManager(), myViewWindow)) { + myVTKViewWindow->RemoveActor(myPreviewActor); } myPreviewActor->Delete(); @@ -187,35 +206,40 @@ namespace SMESH{ myGrid->Delete(); } - }; - } //================================================================================= -// class : SMESHGUI_AddMeshElementDlg() -// purpose : +// function : SMESHGUI_AddMeshElementDlg() +// purpose : constructor //================================================================================= -SMESHGUI_AddMeshElementDlg::SMESHGUI_AddMeshElementDlg( QWidget* parent, const char* name, - SALOME_Selection* Sel, - SMDSAbs_ElementType ElementType, int nbNodes, - bool modal, WFlags fl ) - : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | - Qt::WDestructiveClose) +SMESHGUI_AddMeshElementDlg::SMESHGUI_AddMeshElementDlg( SMESHGUI* theModule, + const char* name, + SMDSAbs_ElementType ElementType, int nbNodes, + bool modal, WFlags fl) + : QDialog( SMESH::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder | + WStyle_Title | WStyle_SysMenu | Qt::WDestructiveClose), + mySMESHGUI( theModule ), + mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ), + myViewWindow( SMESH::GetViewWindow( theModule ) ), + mySelector( myViewWindow->GetSelector() ) { - mySimulation = new SMESH::TElementSimulation(SMESH::GetActiveStudy()); + SalomeApp_Application* anApp = dynamic_cast + (SUIT_Session::session()->activeApplication()); + myIsPoly = false; + mySimulation = new SMESH::TElementSimulation (anApp); // verify nb nodes and type myNbNodes = nbNodes; myElementType = ElementType; - switch ( ElementType ) { + switch (ElementType) { case SMDSAbs_Face: - if ( myNbNodes != 3 && myNbNodes != 4 ) - myNbNodes = 3; - break; +// if (myNbNodes != 3 && myNbNodes != 4) +// myNbNodes = 3; +// break; case SMDSAbs_Volume: - if ( myNbNodes != 4 && myNbNodes != 8 ) //(nbNodes < 4 || nbNodes > 8 || nbNodes == 7) - myNbNodes = 4; +// if (myNbNodes != 4 && myNbNodes != 8) //(nbNodes < 4 || nbNodes > 8 || nbNodes == 7) +// myNbNodes = 4; break; default: myElementType = SMDSAbs_Edge; @@ -223,126 +247,133 @@ SMESHGUI_AddMeshElementDlg::SMESHGUI_AddMeshElementDlg( QWidget* parent, const c } QString elemName; - switch ( myNbNodes ) { - case 2: elemName = "EDGE"; break; - case 3: elemName = "TRIANGLE"; break; - case 4: elemName = - myElementType == SMDSAbs_Face ? elemName = "QUADRANGLE" : elemName = "TETRAS"; break; -// case 5: -// case 6: - default: // 8 + if (myNbNodes == 2) + elemName = "EDGE"; + else if (myNbNodes == 3) + elemName = "TRIANGLE"; + else if (myNbNodes == 4) + if (myElementType == SMDSAbs_Face) + elemName = "QUADRANGLE"; + else + elemName = "TETRAS"; + else if (myNbNodes == 8) elemName = "HEXAS"; + else if (myElementType == SMDSAbs_Face){ + elemName = "POLYGON"; + myIsPoly = true; } - QString iconName = tr( QString("ICON_DLG_%1").arg(elemName) ); - QString buttonGrTitle = tr( QString("SMESH_%1").arg(elemName) ); - QString caption = tr( QString("SMESH_ADD_%1_TITLE").arg(elemName) ); - QString grBoxTitle = tr( QString("SMESH_ADD_%1").arg(elemName) ); - - QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH", iconName )); - QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH", tr("ICON_SELECT"))); - - if ( !name ) - setName( "SMESHGUI_AddMeshElementDlg" ); - resize( 303, 185 ); - setCaption( caption ); - - setSizeGripEnabled( TRUE ); - SMESHGUI_AddMeshElementDlgLayout = new QGridLayout( this ); - SMESHGUI_AddMeshElementDlgLayout->setSpacing( 6 ); - SMESHGUI_AddMeshElementDlgLayout->setMargin( 11 ); - - /***************************************************************/ - GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); - GroupConstructors->setTitle( buttonGrTitle ); - GroupConstructors->setExclusive( TRUE ); - GroupConstructors->setColumnLayout(0, Qt::Vertical ); - GroupConstructors->layout()->setSpacing( 0 ); - GroupConstructors->layout()->setMargin( 0 ); - GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() ); - GroupConstructorsLayout->setAlignment( Qt::AlignTop ); - GroupConstructorsLayout->setSpacing( 6 ); - GroupConstructorsLayout->setMargin( 11 ); - Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" ); - Constructor1->setText( tr( "" ) ); - Constructor1->setPixmap( image0 ); - Constructor1->setChecked( TRUE ); - Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) ); - Constructor1->setMinimumSize( QSize( 50, 0 ) ); - GroupConstructorsLayout->addWidget( Constructor1, 0, 0 ); - QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); - GroupConstructorsLayout->addItem( spacer, 0, 1 ); - SMESHGUI_AddMeshElementDlgLayout->addWidget( GroupConstructors, 0, 0 ); - - /***************************************************************/ - GroupButtons = new QGroupBox( this, "GroupButtons" ); - GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); - GroupButtons->setTitle( tr( "" ) ); - GroupButtons->setColumnLayout(0, Qt::Vertical ); - GroupButtons->layout()->setSpacing( 0 ); - GroupButtons->layout()->setMargin( 0 ); - GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); - GroupButtonsLayout->setAlignment( Qt::AlignTop ); - GroupButtonsLayout->setSpacing( 6 ); - GroupButtonsLayout->setMargin( 11 ); - buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); - buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) ); - buttonCancel->setAutoDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonCancel, 0, 3 ); - buttonApply = new QPushButton( GroupButtons, "buttonApply" ); - buttonApply->setText( tr( "SMESH_BUT_APPLY" ) ); - buttonApply->setAutoDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); - QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); - GroupButtonsLayout->addItem( spacer_9, 0, 2 ); - buttonOk = new QPushButton( GroupButtons, "buttonOk" ); - buttonOk->setText( tr( "SMESH_BUT_OK" ) ); - buttonOk->setAutoDefault( TRUE ); - buttonOk->setDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); - SMESHGUI_AddMeshElementDlgLayout->addWidget( GroupButtons, 2, 0 ); + QString iconName = tr(QString("ICON_DLG_%1").arg(elemName)); + QString buttonGrTitle = tr(QString("SMESH_%1").arg(elemName)); + QString caption = tr(QString("SMESH_ADD_%1_TITLE").arg(elemName)); + QString grBoxTitle = tr(QString("SMESH_ADD_%1").arg(elemName)); + + QPixmap image0 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", iconName)); + QPixmap image1 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT"))); + + if (!name) + setName("SMESHGUI_AddMeshElementDlg"); + resize(303, 185); + setCaption(caption); + + setSizeGripEnabled(TRUE); + SMESHGUI_AddMeshElementDlgLayout = new QGridLayout(this); + SMESHGUI_AddMeshElementDlgLayout->setSpacing(6); + SMESHGUI_AddMeshElementDlgLayout->setMargin(11); /***************************************************************/ - GroupC1 = new QGroupBox( this, "GroupC1" ); - GroupC1->setTitle( grBoxTitle ); + GroupConstructors = new QButtonGroup(this, "GroupConstructors"); + GroupConstructors->setTitle(buttonGrTitle); - GroupC1->setMinimumSize( QSize( 0, 0 ) ); - GroupC1->setFrameShape( QGroupBox::Box ); - GroupC1->setFrameShadow( QGroupBox::Sunken ); - GroupC1->setColumnLayout(0, Qt::Vertical ); - GroupC1->layout()->setSpacing( 0 ); - GroupC1->layout()->setMargin( 0 ); - GroupC1Layout = new QGridLayout( GroupC1->layout() ); - GroupC1Layout->setAlignment( Qt::AlignTop ); - GroupC1Layout->setSpacing( 6 ); - GroupC1Layout->setMargin( 11 ); - TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" ); - TextLabelC1A1->setText( tr( "SMESH_ID_NODES" ) ); - TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) ); - TextLabelC1A1->setFrameShape( QLabel::NoFrame ); - TextLabelC1A1->setFrameShadow( QLabel::Plain ); - GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 ); - SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" ); - SelectButtonC1A1->setText( tr( "" ) ); - SelectButtonC1A1->setPixmap( image1 ); - SelectButtonC1A1->setToggleButton( FALSE ); - GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 ); - LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" ); -// LineEditC1A1->setReadOnly( TRUE ); - LineEditC1A1->setValidator( new SMESHGUI_IdValidator( this, "validator", myNbNodes )); - GroupC1Layout->addWidget( LineEditC1A1, 0, 2 ); + GroupConstructors->setExclusive(TRUE); + GroupConstructors->setColumnLayout(0, Qt::Vertical); + GroupConstructors->layout()->setSpacing(0); + GroupConstructors->layout()->setMargin(0); + GroupConstructorsLayout = new QGridLayout(GroupConstructors->layout()); + GroupConstructorsLayout->setAlignment(Qt::AlignTop); + GroupConstructorsLayout->setSpacing(6); + GroupConstructorsLayout->setMargin(11); + Constructor1 = new QRadioButton(GroupConstructors, "Constructor1"); + Constructor1->setText(tr("" )); + Constructor1->setPixmap(image0); + Constructor1->setChecked(TRUE); + Constructor1->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth())); + Constructor1->setMinimumSize(QSize(50, 0)); + GroupConstructorsLayout->addWidget(Constructor1, 0, 0); + QSpacerItem* spacer = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); + GroupConstructorsLayout->addItem(spacer, 0, 1); + SMESHGUI_AddMeshElementDlgLayout->addWidget(GroupConstructors, 0, 0); - if ( myElementType == SMDSAbs_Face ) { - Reverse = new QCheckBox( GroupC1, "Reverse" ); - Reverse->setText( tr( "SMESH_REVERSE" ) ); - GroupC1Layout->addWidget( Reverse, 1, 0 ); + /***************************************************************/ + GroupButtons = new QGroupBox(this, "GroupButtons"); + GroupButtons->setGeometry(QRect(10, 10, 281, 48)); + GroupButtons->setTitle(tr("" )); + GroupButtons->setColumnLayout(0, Qt::Vertical); + GroupButtons->layout()->setSpacing(0); + GroupButtons->layout()->setMargin(0); + GroupButtonsLayout = new QGridLayout(GroupButtons->layout()); + GroupButtonsLayout->setAlignment(Qt::AlignTop); + GroupButtonsLayout->setSpacing(6); + GroupButtonsLayout->setMargin(11); + buttonCancel = new QPushButton(GroupButtons, "buttonCancel"); + buttonCancel->setText(tr("SMESH_BUT_CLOSE" )); + buttonCancel->setAutoDefault(TRUE); + GroupButtonsLayout->addWidget(buttonCancel, 0, 3); + buttonApply = new QPushButton(GroupButtons, "buttonApply"); + buttonApply->setText(tr("SMESH_BUT_APPLY" )); + buttonApply->setAutoDefault(TRUE); + GroupButtonsLayout->addWidget(buttonApply, 0, 1); + QSpacerItem* spacer_9 = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); + GroupButtonsLayout->addItem(spacer_9, 0, 2); + buttonOk = new QPushButton(GroupButtons, "buttonOk"); + buttonOk->setText(tr("SMESH_BUT_OK" )); + buttonOk->setAutoDefault(TRUE); + buttonOk->setDefault(TRUE); + GroupButtonsLayout->addWidget(buttonOk, 0, 0); + SMESHGUI_AddMeshElementDlgLayout->addWidget(GroupButtons, 2, 0); + + /***************************************************************/ + GroupC1 = new QGroupBox(this, "GroupC1"); + GroupC1->setTitle(grBoxTitle); + + GroupC1->setMinimumSize(QSize(0, 0)); + GroupC1->setFrameShape(QGroupBox::Box); + GroupC1->setFrameShadow(QGroupBox::Sunken); + GroupC1->setColumnLayout(0, Qt::Vertical); + GroupC1->layout()->setSpacing(0); + GroupC1->layout()->setMargin(0); + GroupC1Layout = new QGridLayout(GroupC1->layout()); + GroupC1Layout->setAlignment(Qt::AlignTop); + GroupC1Layout->setSpacing(6); + GroupC1Layout->setMargin(11); + TextLabelC1A1 = new QLabel(GroupC1, "TextLabelC1A1"); + TextLabelC1A1->setText(tr("SMESH_ID_NODES" )); + TextLabelC1A1->setMinimumSize(QSize(50, 0)); + TextLabelC1A1->setFrameShape(QLabel::NoFrame); + TextLabelC1A1->setFrameShadow(QLabel::Plain); + GroupC1Layout->addWidget(TextLabelC1A1, 0, 0); + SelectButtonC1A1 = new QPushButton(GroupC1, "SelectButtonC1A1"); + SelectButtonC1A1->setText(tr("" )); + SelectButtonC1A1->setPixmap(image1); + SelectButtonC1A1->setToggleButton(FALSE); + GroupC1Layout->addWidget(SelectButtonC1A1, 0, 1); + LineEditC1A1 = new QLineEdit(GroupC1, "LineEditC1A1"); +// LineEditC1A1->setReadOnly(TRUE); + if (!myIsPoly) + LineEditC1A1->setValidator(new SMESHGUI_IdValidator(this, "validator", myNbNodes)); + GroupC1Layout->addWidget(LineEditC1A1, 0, 2); + + if (myElementType == SMDSAbs_Face) { + Reverse = new QCheckBox(GroupC1, "Reverse"); + Reverse->setText(tr("SMESH_REVERSE" )); + GroupC1Layout->addWidget(Reverse, 1, 0); } else Reverse = 0; - SMESHGUI_AddMeshElementDlgLayout->addWidget( GroupC1, 1, 0 ); + SMESHGUI_AddMeshElementDlgLayout->addWidget(GroupC1, 1, 0); - Init(Sel) ; /* Initialisations */ + Init(); /* Initialisations */ } //================================================================================= @@ -351,55 +382,52 @@ SMESHGUI_AddMeshElementDlg::SMESHGUI_AddMeshElementDlg( QWidget* parent, const c //================================================================================= SMESHGUI_AddMeshElementDlg::~SMESHGUI_AddMeshElementDlg() { - // no need to delete child widgets, Qt does it all for us + // no need to delete child widgets, Qt does it all for us delete mySimulation; } - //================================================================================= // function : Init() // purpose : //================================================================================= -void SMESHGUI_AddMeshElementDlg::Init( SALOME_Selection* Sel ) +void SMESHGUI_AddMeshElementDlg::Init() { - GroupC1->show(); - Constructor1->setChecked( TRUE ); - myEditCurrentArgument = LineEditC1A1 ; - mySelection = Sel; - mySMESHGUI = SMESHGUI::GetSMESHGUI() ; - mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; + Constructor1->setChecked(TRUE); + myEditCurrentArgument = LineEditC1A1; + mySMESHGUI->SetActiveDialogBox((QDialog*)this); - myOkNodes = false ; + myNbOkNodes = 0; myActor = 0; /* signals and slots connections */ - connect(buttonOk, SIGNAL( clicked() ), SLOT( ClickOnOk() ) ); - connect(buttonCancel, SIGNAL( clicked() ), SLOT( ClickOnCancel() ) ) ; - connect(buttonApply, SIGNAL( clicked() ), SLOT(ClickOnApply() ) ); + connect(buttonOk, SIGNAL(clicked()), SLOT(ClickOnOk())); + connect(buttonCancel, SIGNAL(clicked()), SLOT(ClickOnCancel())); + connect(buttonApply, SIGNAL(clicked()), SLOT(ClickOnApply())); - connect(SelectButtonC1A1, SIGNAL( clicked() ), SLOT( SetEditCurrentArgument() ) ) ; - connect(LineEditC1A1, SIGNAL( textChanged(const QString&) ), SLOT(onTextChange(const QString&))); - connect(mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), SLOT( DeactivateActiveDialog())); - connect(mySelection, SIGNAL( currentSelectionChanged() ), SLOT( SelectionIntoArgument() ) ); + connect(SelectButtonC1A1, SIGNAL(clicked()), SLOT(SetEditCurrentArgument())); + connect(LineEditC1A1, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&))); + connect(mySMESHGUI, SIGNAL (SignalDeactivateActiveDialog()), SLOT(DeactivateActiveDialog())); + connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(SelectionIntoArgument())); /* to close dialog if study frame change */ - connect( mySMESHGUI, SIGNAL ( SignalStudyFrameChanged() ), SLOT( ClickOnCancel() ) ) ; + connect(mySMESHGUI, SIGNAL (SignalStudyFrameChanged()), SLOT(ClickOnCancel())); - if ( Reverse ) - connect( Reverse, SIGNAL(stateChanged(int)), SLOT(CheckBox(int)) ); + if (Reverse) + connect(Reverse, SIGNAL(stateChanged(int)), SLOT(CheckBox(int))); - /* Move widget on the botton right corner of main widget */ - int x, y ; - mySMESHGUI->DefineDlgPosition( this, x, y ) ; - this->move( x, y ) ; - this->show() ; /* displays Dialog */ + // Move widget on the botton right corner of main widget + int x, y; + mySMESHGUI->DefineDlgPosition(this, x, y); + this->move(x, y); + this->show(); // displays Dialog // set selection mode SMESH::SetPointRepresentation(true); - QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true ); + + myViewWindow->SetSelectionMode( NodeSelection ); myBusy = false; - + SelectionIntoArgument(); } @@ -409,21 +437,20 @@ void SMESHGUI_AddMeshElementDlg::Init( SALOME_Selection* Sel ) //================================================================================= void SMESHGUI_AddMeshElementDlg::ClickOnApply() { - if ( myOkNodes && !mySMESHGUI->ActiveStudyLocked() ) { - + if (myNbOkNodes && !mySMESHGUI->isActiveStudyLocked()) { myBusy = true; SMESH::long_array_var anArrayOfIdeces = new SMESH::long_array; - anArrayOfIdeces->length( myNbNodes ); - bool reverse = ( Reverse && Reverse->isChecked() ); - QStringList aListId = QStringList::split( " ", myEditCurrentArgument->text(), false); - for ( int i = 0; i < aListId.count(); i++ ) - if ( reverse ) + anArrayOfIdeces->length(myNbNodes); + bool reverse = (Reverse && Reverse->isChecked()); + QStringList aListId = QStringList::split(" ", myEditCurrentArgument->text(), false); + for (int i = 0; i < aListId.count(); i++) + if (reverse) anArrayOfIdeces[i] = aListId[ myNbNodes - i - 1 ].toInt(); else anArrayOfIdeces[i] = aListId[ i ].toInt(); SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor(); - switch ( myElementType ) { + switch (myElementType) { case SMDSAbs_Edge: aMeshEditor->AddEdge(anArrayOfIdeces.inout()); break; case SMDSAbs_Face: @@ -432,15 +459,15 @@ void SMESHGUI_AddMeshElementDlg::ClickOnApply() aMeshEditor->AddVolume(anArrayOfIdeces.inout()); break; default:; } - - mySelection->ClearIObjects(); - mySelection->AddIObject( myActor->getIO(), false ); + + SALOME_ListIO aList; aList.Append( myActor->getIO() ); + mySelectionMgr->setSelectedObjects( aList, false ); SMESH::UpdateView(); mySimulation->SetVisibility(false); - buttonOk->setEnabled( false ); - buttonApply->setEnabled( false ); + buttonOk->setEnabled(false); + buttonApply->setEnabled(false); myEditCurrentArgument->setText(""); @@ -454,9 +481,9 @@ void SMESHGUI_AddMeshElementDlg::ClickOnApply() //================================================================================= void SMESHGUI_AddMeshElementDlg::ClickOnOk() { - this->ClickOnApply() ; - this->ClickOnCancel() ; - return ; + this->ClickOnApply(); + this->ClickOnCancel(); + return; } //================================================================================= @@ -465,64 +492,73 @@ void SMESHGUI_AddMeshElementDlg::ClickOnOk() //================================================================================= void SMESHGUI_AddMeshElementDlg::ClickOnCancel() { - mySelection->ClearIObjects(); + mySelectionMgr->clearSelected(); mySimulation->SetVisibility(false); SMESH::SetPointRepresentation(false); - QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); - disconnect( mySelection, 0, this, 0 ); - mySMESHGUI->ResetState() ; - reject() ; - return ; + myViewWindow->SetSelectionMode( ActorSelection ); + disconnect(mySelectionMgr, 0, this, 0); + mySMESHGUI->ResetState(); + reject(); + return; } -//======================================================================= -//function : onTextChange -//purpose : -//======================================================================= - -void SMESHGUI_AddMeshElementDlg::onTextChange(const QString& theNewText) +//================================================================================= +// function : onTextChange() +// purpose : +//================================================================================= +void SMESHGUI_AddMeshElementDlg::onTextChange (const QString& theNewText) { - if ( myBusy ) return; + if (myBusy) return; myBusy = true; - myOkNodes = false; + myNbOkNodes = 0; - buttonOk->setEnabled( false ); - buttonApply->setEnabled( false ); + buttonOk->setEnabled(false); + buttonApply->setEnabled(false); mySimulation->SetVisibility(false); // hilight entered nodes SMDS_Mesh* aMesh = 0; - if ( myActor ) + if (myActor) aMesh = myActor->GetObject()->GetMesh(); - if ( aMesh ) { - mySelection->ClearIObjects(); - mySelection->AddIObject( myActor->getIO() ); + if (aMesh) { + SALOME_ListIO aList; aList.Append( myActor->getIO() ); + mySelectionMgr->setSelectedObjects( aList, false ); - QStringList aListId = QStringList::split( " ", theNewText, false); - bool allOk = true; - for ( int i = 0; i < aListId.count(); i++ ) { - const SMDS_MeshNode * n = aMesh->FindNode( aListId[ i ].toInt() ); - if ( n ) { - if ( mySelection->IsIndexSelected( myActor->getIO(), n->GetID() )) - allOk = false; - else - mySelection->AddOrRemoveIndex (myActor->getIO(), n->GetID(), true); + TColStd_IndexedMapOfInteger selectedIndices; + TColStd_MapOfInteger newIndices; + mySelector->GetIndex(myActor->getIO(), selectedIndices); + + QStringList aListId = QStringList::split(" ", theNewText, false); + for (int i = 0; i < aListId.count(); i++) { + if( const SMDS_MeshNode * n = aMesh->FindNode( aListId[ i ].toInt() ) ) + { + if( selectedIndices.Add( n->GetID() ) ) + newIndices.Add( n->GetID() ); + myNbOkNodes++; } - else - allOk = false; } - myOkNodes = (allOk && myNbNodes == aListId.count() ); - - if ( myOkNodes ) { - buttonOk->setEnabled( true ); - buttonApply->setEnabled( true ); - displaySimulation(); + + if( newIndices.Extent()>0 ) + { + mySelector->AddOrRemoveIndex( myActor->getIO(), newIndices, true ); + myViewWindow->highlight( myActor->getIO(), true, true ); + } + bool aNodesOK = false; + if (myIsPoly && myElementType == SMDSAbs_Face && aListId.count() >=3 ){ + myNbOkNodes = aListId.count(); + aNodesOK = true; } } - + + if(myNbOkNodes) { + buttonOk->setEnabled(true); + buttonApply->setEnabled(true); + displaySimulation(); + } + myBusy = false; } @@ -532,91 +568,97 @@ void SMESHGUI_AddMeshElementDlg::onTextChange(const QString& theNewText) //================================================================================= void SMESHGUI_AddMeshElementDlg::SelectionIntoArgument() { - if ( myBusy ) return; + if (myBusy) return; // clear - - myOkNodes = false; + myNbOkNodes = 0; myActor = 0; myBusy = true; - myEditCurrentArgument->setText( "" ); + myEditCurrentArgument->setText(""); myBusy = false; - if ( !GroupButtons->isEnabled() ) // inactive + if (!GroupButtons->isEnabled()) // inactive return; - buttonOk->setEnabled( false ); - buttonApply->setEnabled( false ); + buttonOk->setEnabled(false); + buttonApply->setEnabled(false); mySimulation->SetVisibility(false); // SMESH::SetPointRepresentation(true); // get selected mesh + SALOME_ListIO aList; + mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type()); - int nbSel = mySelection->IObjectCount(); - if(nbSel != 1) + if (aList.Extent() != 1) return; - myMesh = SMESH::GetMeshByIO( mySelection->firstIObject() ); - if ( myMesh->_is_nil() ) + Handle(SALOME_InteractiveObject) anIO = aList.First(); + myMesh = SMESH::GetMeshByIO(anIO); + if (myMesh->_is_nil()) return; - myActor = SMESH::FindActorByEntry( mySelection->firstIObject()->getEntry() ); - if ( !myActor ) + myActor = SMESH::FindActorByEntry(anIO->getEntry()); + if (!myActor) return; // get selected nodes - QString aString = ""; - int nbNodes = SMESH::GetNameOfSelectedNodes(mySelection, aString) ; + int nbNodes = SMESH::GetNameOfSelectedNodes(mySelector,myActor->getIO(),aString); myBusy = true; - myEditCurrentArgument->setText( aString ); + myEditCurrentArgument->setText(aString); myBusy = false; - if ( myNbNodes != nbNodes ) + if (myIsPoly && myElementType == SMDSAbs_Face && nbNodes >= 3 ) { + myNbNodes = nbNodes; + } else if (myNbNodes != nbNodes) { return; + } // OK + myNbOkNodes = nbNodes; - myOkNodes = true; - - buttonOk->setEnabled( true ); - buttonApply->setEnabled( true ); + buttonOk->setEnabled(true); + buttonApply->setEnabled(true); displaySimulation(); } -//======================================================================= -//function : displaySimulation -//purpose : -//======================================================================= - +//================================================================================= +// function : displaySimulation() +// purpose : +//================================================================================= void SMESHGUI_AddMeshElementDlg::displaySimulation() { - if ( myOkNodes && GroupButtons->isEnabled() ) - { + if (myNbOkNodes && GroupButtons->isEnabled()) { SMESH::TElementSimulation::TVTKIds anIds; - QStringList aListId = QStringList::split( " ", myEditCurrentArgument->text(), false); - for ( int i = 0; i < aListId.count(); i++ ) - anIds.push_back( myActor->GetObject()->GetNodeVTKId( aListId[ i ].toInt() )); + QStringList aListId = QStringList::split(" ", myEditCurrentArgument->text(), false); + for (int i = 0; i < aListId.count(); i++) + anIds.push_back(myActor->GetObject()->GetNodeVTKId(aListId[ i ].toInt())); - if ( Reverse && Reverse->isChecked() ) + if (Reverse && Reverse->isChecked()) reverse(anIds.begin(),anIds.end()); vtkIdType aType = 0; - switch ( myNbNodes ) { - case 2: aType = VTK_LINE; break; - case 3: aType = VTK_TRIANGLE; break; - case 4: aType = myElementType == SMDSAbs_Face ? VTK_QUAD : VTK_TETRA; break; - case 8: aType = VTK_HEXAHEDRON; break; - default: return; + if (myIsPoly) + switch ( myElementType ) { + case SMDSAbs_Face : aType = VTK_POLYGON; break; + default: return; + } + else { + switch (myNbNodes) { + case 2: aType = VTK_LINE; break; + case 3: aType = VTK_TRIANGLE; break; + case 4: aType = myElementType == SMDSAbs_Face ? VTK_QUAD : VTK_TETRA; break; + case 8: aType = VTK_HEXAHEDRON; break; + default: return; + } } - + mySimulation->SetPosition(myActor,aType,anIds); } } - //================================================================================= // function : SetEditCurrentArgument() // purpose : @@ -624,11 +666,11 @@ void SMESHGUI_AddMeshElementDlg::displaySimulation() void SMESHGUI_AddMeshElementDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); - if(send == SelectButtonC1A1) { - LineEditC1A1->setFocus() ; + if (send == SelectButtonC1A1) { + LineEditC1A1->setFocus(); myEditCurrentArgument = LineEditC1A1; } - SelectionIntoArgument() ; + SelectionIntoArgument(); } //================================================================================= @@ -637,18 +679,16 @@ void SMESHGUI_AddMeshElementDlg::SetEditCurrentArgument() //================================================================================= void SMESHGUI_AddMeshElementDlg::DeactivateActiveDialog() { - if ( GroupConstructors->isEnabled() ) { - GroupConstructors->setEnabled(false) ; - GroupC1->setEnabled(false) ; - GroupButtons->setEnabled(false) ; + if (GroupConstructors->isEnabled()) { + GroupConstructors->setEnabled(false); + GroupC1->setEnabled(false); + GroupButtons->setEnabled(false); mySimulation->SetVisibility(false); - mySMESHGUI->ResetState() ; - mySMESHGUI->SetActiveDialogBox(0) ; + mySMESHGUI->ResetState(); + mySMESHGUI->SetActiveDialogBox(0); } - return ; } - //================================================================================= // function : ActivateThisDialog() // purpose : @@ -656,15 +696,15 @@ void SMESHGUI_AddMeshElementDlg::DeactivateActiveDialog() void SMESHGUI_AddMeshElementDlg::ActivateThisDialog() { /* Emit a signal to deactivate the active dialog */ - mySMESHGUI->EmitSignalDeactivateDialog() ; + mySMESHGUI->EmitSignalDeactivateDialog(); - GroupConstructors->setEnabled(true) ; - GroupC1->setEnabled(true) ; - GroupButtons->setEnabled(true) ; + GroupConstructors->setEnabled(true); + GroupC1->setEnabled(true); + GroupButtons->setEnabled(true); SMESH::SetPointRepresentation(true); - QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true ); + myViewWindow->SetSelectionMode( NodeSelection ); SelectionIntoArgument(); } @@ -672,47 +712,45 @@ void SMESHGUI_AddMeshElementDlg::ActivateThisDialog() // function : enterEvent() // purpose : //================================================================================= -void SMESHGUI_AddMeshElementDlg::enterEvent(QEvent* e) +void SMESHGUI_AddMeshElementDlg::enterEvent (QEvent*) { - if ( GroupConstructors->isEnabled() ) - return ; - ActivateThisDialog() ; - return ; + if (GroupConstructors->isEnabled()) + return; + ActivateThisDialog(); + return; } - //================================================================================= // function : closeEvent() // purpose : //================================================================================= -void SMESHGUI_AddMeshElementDlg::closeEvent( QCloseEvent* e ) +void SMESHGUI_AddMeshElementDlg::closeEvent (QCloseEvent*) { /* same than click on cancel button */ - this->ClickOnCancel() ; - return ; -} -//======================================================================= -//function : hideEvent -//purpose : caused by ESC key -//======================================================================= - -void SMESHGUI_AddMeshElementDlg::hideEvent ( QHideEvent * e ) -{ - if ( !isMinimized() ) - ClickOnCancel() ; + this->ClickOnCancel(); + return; } -//======================================================================= -//function : CheckBox -//purpose : -//======================================================================= - -void SMESHGUI_AddMeshElementDlg::CheckBox( int state ) +//================================================================================= +// function : hideEvent() +// purpose : caused by ESC key +//================================================================================= +void SMESHGUI_AddMeshElementDlg::hideEvent (QHideEvent*) { - if ( !myOkNodes ) + if (!isMinimized()) + ClickOnCancel(); +} + +//================================================================================= +// function : CheckBox() +// purpose : +//================================================================================= +void SMESHGUI_AddMeshElementDlg::CheckBox (int state) +{ + if (!myNbOkNodes) return; - - if ( state >= 0 ) { + + if (state >= 0) { mySimulation->SetVisibility(false); displaySimulation(); } diff --git a/src/SMESHGUI/SMESHGUI_AddMeshElementDlg.h b/src/SMESHGUI/SMESHGUI_AddMeshElementDlg.h index 4a785bbc5..a04635c30 100644 --- a/src/SMESHGUI/SMESHGUI_AddMeshElementDlg.h +++ b/src/SMESHGUI/SMESHGUI_AddMeshElementDlg.h @@ -29,7 +29,7 @@ #ifndef DIALOGBOX_ADD_FACE_H #define DIALOGBOX_ADD_FACE_H -#include "SALOME_Selection.h" +#include "SalomeApp_SelectionMgr.h" #include "SMDSAbs_ElementType.hxx" @@ -51,6 +51,8 @@ class QCheckBox; class SMESHGUI; class SMESH_Actor; class SMDS_Mesh; +class SVTK_ViewWindow; +class SVTK_Selector; namespace SMESH{ struct TElementSimulation; @@ -69,33 +71,35 @@ class SMESHGUI_AddMeshElementDlg : public QDialog Q_OBJECT public: - SMESHGUI_AddMeshElementDlg( QWidget* parent = 0, const char* name = 0, - SALOME_Selection* Sel = 0, + SMESHGUI_AddMeshElementDlg( SMESHGUI*, + const char* = 0, SMDSAbs_ElementType ElementType = SMDSAbs_Edge, int nbNodes = 2, bool modal = FALSE, WFlags fl = 0 ); ~SMESHGUI_AddMeshElementDlg(); private: - - void Init( SALOME_Selection* Sel ) ; - void closeEvent( QCloseEvent* e ) ; - void hideEvent ( QHideEvent * ); /* ESC key */ - void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */ + void Init (); + void closeEvent (QCloseEvent*); + void hideEvent (QHideEvent*); /* ESC key */ + void enterEvent (QEvent*); /* mouse enter the QWidget */ void displaySimulation(); - SMESHGUI* mySMESHGUI ; /* Current SMESHGUI object */ - SALOME_Selection* mySelection ; /* User shape selection */ - bool myOkNodes ; /* to check when arguments is defined */ - bool myBusy; + SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */ + SalomeApp_SelectionMgr* mySelectionMgr; /* User shape selection */ + int myNbOkNodes; /* to check when arguments is defined */ + bool myBusy; + SVTK_ViewWindow* myViewWindow; + SVTK_Selector* mySelector; - QLineEdit* myEditCurrentArgument; /* Current LineEdit */ + QLineEdit* myEditCurrentArgument; /* Current LineEdit */ - int myElementType ; - int myNbNodes; + int myElementType; + int myNbNodes; + bool myIsPoly; - SMESH::SMESH_Mesh_var myMesh; - SMESH_Actor* myActor; - SMESH::TElementSimulation* mySimulation; + SMESH::SMESH_Mesh_var myMesh; + SMESH_Actor* myActor; + SMESH::TElementSimulation* mySimulation; QButtonGroup* GroupConstructors; QRadioButton* Constructor1; diff --git a/src/SMESHGUI/SMESHGUI_AddSubMeshDlg.cxx b/src/SMESHGUI/SMESHGUI_AddSubMeshDlg.cxx index 250323da7..b07345819 100644 --- a/src/SMESHGUI/SMESHGUI_AddSubMeshDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_AddSubMeshDlg.cxx @@ -1,23 +1,23 @@ // SMESH SMESHGUI : GUI for SMESH component // // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org // // // @@ -33,16 +33,24 @@ #include "SMESHGUI_GEOMGenUtils.h" #include "SMESHGUI_HypothesesUtils.h" +#include "SMESH_TypeFilter.hxx" +#include "SMESH_NumberFilter.hxx" + #include "GEOMBase.h" -#include "QAD_Application.h" -#include "QAD_Desktop.h" -#include "QAD_MessageBox.h" -#include "QAD_WaitCursor.h" -#include "QAD_Operation.h" +#include "SUIT_Session.h" +#include "SUIT_MessageBox.h" +#include "SUIT_OverrideCursor.h" +#include "SUIT_Operation.h" +#include "SUIT_Desktop.h" +#include "SALOMEDSClient_Study.hxx" +#include "SALOMEDS_SObject.hxx" +#include "SALOME_ListIO.hxx" #include "SALOME_ListIteratorOfListIO.hxx" -#include "SALOMEGUI_QtCatchCorbaException.hxx" +#include "SalomeApp_Tools.h" + +#include "SVTK_ViewModel.h" #include "utilities.h" @@ -56,178 +64,181 @@ using namespace std; -namespace SMESH{ - SMESH::SMESH_subMesh_var AddSubMesh(SMESH::SMESH_Mesh_ptr theMesh, - GEOM::GEOM_Object_ptr theShapeObject, - const char* theMeshName ) +namespace SMESH { + SMESH::SMESH_subMesh_var AddSubMesh (SMESH::SMESH_Mesh_ptr theMesh, + GEOM::GEOM_Object_ptr theShapeObject, + const char* theMeshName) { SMESH::SMESH_subMesh_var aSubMesh; try { - if ( !theMesh->_is_nil() && !theShapeObject->_is_nil() ) - aSubMesh = theMesh->GetSubMesh( theShapeObject, theMeshName ); - } - catch( const SALOME::SALOME_Exception& S_ex ) { - QtCatchCorbaException( S_ex ); + if (!theMesh->_is_nil() && !theShapeObject->_is_nil()) + aSubMesh = theMesh->GetSubMesh(theShapeObject, theMeshName); + } catch (const SALOME::SALOME_Exception& S_ex) { + SalomeApp_Tools::QtCatchCorbaException(S_ex); } return aSubMesh._retn(); } } //================================================================================= -// class : SMESHGUI_AddSubMeshDlg() -// purpose : Constructs a SMESHGUI_AddSubMeshDlg which is a child of 'parent', with the +// function : SMESHGUI_AddSubMeshDlg() +// purpose : Constructs a SMESHGUI_AddSubMeshDlg which is a child of 'parent', with the // name 'name' and widget flags set to 'f'. // The dialog will by default be modeless, unless you set 'modal' to // TRUE to construct a modal dialog. //================================================================================= -SMESHGUI_AddSubMeshDlg::SMESHGUI_AddSubMeshDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl ) - : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose ) +SMESHGUI_AddSubMeshDlg::SMESHGUI_AddSubMeshDlg( SMESHGUI* theModule, const char* name, + bool modal, WFlags fl) + : QDialog( SMESH::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder | + WStyle_Title | WStyle_SysMenu | WDestructiveClose), + mySMESHGUI( theModule ), + mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ) { - QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SELECT"))); - if ( !name ) - setName( "SMESHGUI_AddSubMeshDlg" ); - setCaption( tr( "SMESH_ADD_SUBMESH" ) ); - setSizeGripEnabled( TRUE ); - QGridLayout* SMESHGUI_AddSubMeshDlgLayout = new QGridLayout( this ); - SMESHGUI_AddSubMeshDlgLayout->setSpacing( 6 ); - SMESHGUI_AddSubMeshDlgLayout->setMargin( 11 ); - - /***************************************************************/ - GroupC1 = new QGroupBox( tr( "SMESH_ARGUMENTS" ), this, "GroupC1" ); - GroupC1->setColumnLayout(0, Qt::Vertical ); - GroupC1->layout()->setSpacing( 0 ); - GroupC1->layout()->setMargin( 0 ); - QGridLayout* GroupC1Layout = new QGridLayout( GroupC1->layout() ); - GroupC1Layout->setAlignment( Qt::AlignTop ); - GroupC1Layout->setSpacing( 6 ); - GroupC1Layout->setMargin( 11 ); - - TextLabel_NameMesh = new QLabel( tr( "SMESH_NAME" ), GroupC1, "TextLabel_NameMesh" ); - GroupC1Layout->addWidget( TextLabel_NameMesh, 0, 0 ); - LineEdit_NameMesh = new QLineEdit( GroupC1, "LineEdit_NameMesh" ); - GroupC1Layout->addWidget( LineEdit_NameMesh, 0, 2 ); - - TextLabelC1A1 = new QLabel( tr( "SMESH_OBJECT_MESH" ), GroupC1, "TextLabelC1A1" ); - GroupC1Layout->addWidget( TextLabelC1A1, 1, 0 ); - SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" ); - SelectButtonC1A1->setPixmap( image0 ); - SelectButtonC1A1->setToggleButton( FALSE ); - GroupC1Layout->addWidget( SelectButtonC1A1, 1, 1 ); - LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" ); - LineEditC1A1->setReadOnly( true ); - GroupC1Layout->addWidget( LineEditC1A1, 1, 2 ); - - TextLabelC1A2 = new QLabel( tr( "SMESH_OBJECT_GEOM" ), GroupC1, "TextLabelC1A2" ); - GroupC1Layout->addWidget( TextLabelC1A2, 2, 0 ); - SelectButtonC1A2 = new QPushButton( GroupC1, "SelectButtonC1A2" ); - SelectButtonC1A2->setPixmap( image0 ); - SelectButtonC1A2->setToggleButton( FALSE ); - GroupC1Layout->addWidget( SelectButtonC1A2, 2, 1 ); - LineEditC1A2 = new QLineEdit( GroupC1, "LineEditC1A2" ); - LineEditC1A2->setReadOnly( true ); - GroupC1Layout->addWidget( LineEditC1A2, 2, 2 ); - - TextLabelC1A1Hyp = new QLabel( tr( "SMESH_OBJECT_HYPOTHESIS" ), GroupC1, "TextLabelC1A1Hyp" ); - GroupC1Layout->addWidget( TextLabelC1A1Hyp, 3, 0 ); - SelectButtonC1A1Hyp = new QPushButton( GroupC1, "SelectButtonC1A1Hyp" ); - SelectButtonC1A1Hyp->setPixmap( image0 ); - GroupC1Layout->addWidget( SelectButtonC1A1Hyp, 3, 1 ); - LineEditC1A1Hyp = new QLineEdit( GroupC1, "LineEditC1A1Hyp" ); - LineEditC1A1Hyp->setReadOnly( true ); - GroupC1Layout->addWidget( LineEditC1A1Hyp, 3, 2 ); - - TextLabelC1A1Algo = new QLabel( tr( "SMESH_OBJECT_ALGORITHM" ), GroupC1, "TextLabelC1A1Algo" ); - GroupC1Layout->addWidget( TextLabelC1A1Algo, 4, 0 ); - SelectButtonC1A1Algo = new QPushButton( GroupC1, "SelectButtonC1A1Algo" ); - SelectButtonC1A1Algo->setPixmap( image0 ); - GroupC1Layout->addWidget( SelectButtonC1A1Algo, 4, 1 ); - LineEditC1A1Algo = new QLineEdit( GroupC1, "LineEditC1A1Algo" ); - LineEditC1A1Algo->setReadOnly( true ); - GroupC1Layout->addWidget( LineEditC1A1Algo, 4, 2 ); - - SMESHGUI_AddSubMeshDlgLayout->addWidget( GroupC1, 1, 0 ); + QPixmap image0 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT"))); + if (!name) + setName("SMESHGUI_AddSubMeshDlg"); + setCaption(tr("SMESH_ADD_SUBMESH")); + setSizeGripEnabled(TRUE); + QGridLayout* SMESHGUI_AddSubMeshDlgLayout = new QGridLayout(this); + SMESHGUI_AddSubMeshDlgLayout->setSpacing(6); + SMESHGUI_AddSubMeshDlgLayout->setMargin(11); /***************************************************************/ - GroupButtons = new QGroupBox( this, "GroupButtons" ); - GroupButtons->setColumnLayout(0, Qt::Vertical ); - GroupButtons->layout()->setSpacing( 0 ); - GroupButtons->layout()->setMargin( 0 ); - QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); - GroupButtonsLayout->setAlignment( Qt::AlignTop ); - GroupButtonsLayout->setSpacing( 6 ); - GroupButtonsLayout->setMargin( 11 ); + GroupC1 = new QGroupBox (tr("SMESH_ARGUMENTS"), this, "GroupC1"); + GroupC1->setColumnLayout(0, Qt::Vertical); + GroupC1->layout()->setSpacing(0); + GroupC1->layout()->setMargin(0); + QGridLayout* GroupC1Layout = new QGridLayout (GroupC1->layout()); + GroupC1Layout->setAlignment(Qt::AlignTop); + GroupC1Layout->setSpacing(6); + GroupC1Layout->setMargin(11); - buttonOk = new QPushButton( tr( "SMESH_BUT_OK" ), GroupButtons, "buttonOk" ); - buttonOk->setAutoDefault( TRUE ); - buttonOk->setDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); + TextLabel_NameMesh = new QLabel (tr("SMESH_NAME"), GroupC1, "TextLabel_NameMesh"); + GroupC1Layout->addWidget(TextLabel_NameMesh, 0, 0); + LineEdit_NameMesh = new QLineEdit (GroupC1, "LineEdit_NameMesh"); + GroupC1Layout->addWidget(LineEdit_NameMesh, 0, 2); - buttonApply = new QPushButton( tr( "SMESH_BUT_APPLY" ), GroupButtons, "buttonApply" ); - buttonApply->setAutoDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); + TextLabelC1A1 = new QLabel (tr("SMESH_OBJECT_MESH"), GroupC1, "TextLabelC1A1"); + GroupC1Layout->addWidget(TextLabelC1A1, 1, 0); + SelectButtonC1A1 = new QPushButton (GroupC1, "SelectButtonC1A1"); + SelectButtonC1A1->setPixmap(image0); + SelectButtonC1A1->setToggleButton(FALSE); + GroupC1Layout->addWidget(SelectButtonC1A1, 1, 1); + LineEditC1A1 = new QLineEdit (GroupC1, "LineEditC1A1"); + LineEditC1A1->setReadOnly(true); + GroupC1Layout->addWidget(LineEditC1A1, 1, 2); - GroupButtonsLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 2 ); + TextLabelC1A2 = new QLabel(tr("SMESH_OBJECT_GEOM"), GroupC1, "TextLabelC1A2"); + GroupC1Layout->addWidget(TextLabelC1A2, 2, 0); + SelectButtonC1A2 = new QPushButton(GroupC1, "SelectButtonC1A2"); + SelectButtonC1A2->setPixmap(image0); + SelectButtonC1A2->setToggleButton(FALSE); + GroupC1Layout->addWidget(SelectButtonC1A2, 2, 1); + LineEditC1A2 = new QLineEdit(GroupC1, "LineEditC1A2"); + LineEditC1A2->setReadOnly(true); + GroupC1Layout->addWidget(LineEditC1A2, 2, 2); - buttonCancel = new QPushButton( tr( "SMESH_BUT_CLOSE" ), GroupButtons, "buttonCancel" ); - buttonCancel->setAutoDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonCancel, 0, 3 ); + TextLabelC1A1Hyp = new QLabel(tr("SMESH_OBJECT_HYPOTHESIS"), GroupC1, "TextLabelC1A1Hyp"); + GroupC1Layout->addWidget(TextLabelC1A1Hyp, 3, 0); + SelectButtonC1A1Hyp = new QPushButton(GroupC1, "SelectButtonC1A1Hyp"); + SelectButtonC1A1Hyp->setPixmap(image0); + GroupC1Layout->addWidget(SelectButtonC1A1Hyp, 3, 1); + LineEditC1A1Hyp = new QLineEdit(GroupC1, "LineEditC1A1Hyp"); + LineEditC1A1Hyp->setReadOnly(true); + GroupC1Layout->addWidget(LineEditC1A1Hyp, 3, 2); - SMESHGUI_AddSubMeshDlgLayout->addWidget( GroupButtons, 2, 0 ); + TextLabelC1A1Algo = new QLabel(tr("SMESH_OBJECT_ALGORITHM"), GroupC1, "TextLabelC1A1Algo"); + GroupC1Layout->addWidget(TextLabelC1A1Algo, 4, 0); + SelectButtonC1A1Algo = new QPushButton(GroupC1, "SelectButtonC1A1Algo"); + SelectButtonC1A1Algo->setPixmap(image0); + GroupC1Layout->addWidget(SelectButtonC1A1Algo, 4, 1); + LineEditC1A1Algo = new QLineEdit(GroupC1, "LineEditC1A1Algo"); + LineEditC1A1Algo->setReadOnly(true); + GroupC1Layout->addWidget(LineEditC1A1Algo, 4, 2); + + SMESHGUI_AddSubMeshDlgLayout->addWidget(GroupC1, 1, 0); /***************************************************************/ - Init( Sel ) ; + GroupButtons = new QGroupBox(this, "GroupButtons"); + GroupButtons->setColumnLayout(0, Qt::Vertical); + GroupButtons->layout()->setSpacing(0); + GroupButtons->layout()->setMargin(0); + QGridLayout* GroupButtonsLayout = new QGridLayout(GroupButtons->layout()); + GroupButtonsLayout->setAlignment(Qt::AlignTop); + GroupButtonsLayout->setSpacing(6); + GroupButtonsLayout->setMargin(11); + + buttonOk = new QPushButton(tr("SMESH_BUT_OK"), GroupButtons, "buttonOk"); + buttonOk->setAutoDefault(TRUE); + buttonOk->setDefault(TRUE); + GroupButtonsLayout->addWidget(buttonOk, 0, 0); + + buttonApply = new QPushButton(tr("SMESH_BUT_APPLY"), GroupButtons, "buttonApply"); + buttonApply->setAutoDefault(TRUE); + GroupButtonsLayout->addWidget(buttonApply, 0, 1); + + GroupButtonsLayout->addItem(new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, 2); + + buttonCancel = new QPushButton(tr("SMESH_BUT_CLOSE"), GroupButtons, "buttonCancel"); + buttonCancel->setAutoDefault(TRUE); + GroupButtonsLayout->addWidget(buttonCancel, 0, 3); + + SMESHGUI_AddSubMeshDlgLayout->addWidget(GroupButtons, 2, 0); + + /***************************************************************/ + Init(); } - //================================================================================= // function : ~SMESHGUI_AddSubMeshDlg() // purpose : Destroys the object and frees any allocated resources //================================================================================= SMESHGUI_AddSubMeshDlg::~SMESHGUI_AddSubMeshDlg() { - // no need to delete child widgets, Qt does it all for us + // no need to delete child widgets, Qt does it all for us } - //================================================================================= // function : Init() // purpose : //================================================================================= -void SMESHGUI_AddSubMeshDlg::Init( SALOME_Selection* Sel ) +void SMESHGUI_AddSubMeshDlg::Init () { - mySelection = Sel; - mySMESHGUI = SMESHGUI::GetSMESHGUI() ; - mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; + mySMESHGUI->SetActiveDialogBox((QDialog*)this); - myGeomFilter = new SALOME_TypeFilter( "GEOM" ); - myMeshFilter = new SMESH_TypeFilter( MESH ); - myAlgorithmFilter = new SMESH_TypeFilter( ALGORITHM ); - myHypothesisFilter = new SMESH_TypeFilter( HYPOTHESIS ); + //myGeomFilter = new SALOME_TypeFilter("GEOM"); + TColStd_MapOfInteger allTypesMap; + for (int i = 0; i < 10; i++) + allTypesMap.Add(i); + myGeomFilter = new SMESH_NumberFilter ("GEOM", TopAbs_SHAPE, 0, allTypesMap); + myMeshFilter = new SMESH_TypeFilter (MESH); + myAlgorithmFilter = new SMESH_TypeFilter (ALGORITHM); + myHypothesisFilter = new SMESH_TypeFilter (HYPOTHESIS); /* signals and slots connections */ - connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); - connect( buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) ); - connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ; + connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); + connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel())); - connect( SelectButtonC1A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; - connect( SelectButtonC1A2, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; - connect( SelectButtonC1A1Hyp, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; - connect( SelectButtonC1A1Algo, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + connect(SelectButtonC1A1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(SelectButtonC1A2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(SelectButtonC1A1Hyp, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(SelectButtonC1A1Algo, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); - connect( mySMESHGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; - connect( mySMESHGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; - - int x, y ; - mySMESHGUI->DefineDlgPosition( this, x, y ) ; - this->move( x, y ) ; - this->show() ; + connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog())); + connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel())); - LineEdit_NameMesh->setText( tr( "SMESH_SUBMESH" ) ); - LineEdit_NameMesh->setFocus() ; - myEditCurrentArgument = LineEditC1A1 ; - mySelection->ClearFilters() ; - mySelection->AddFilter( myMeshFilter ) ; + int x, y; + mySMESHGUI->DefineDlgPosition(this, x, y); + this->move(x, y); + this->show(); + + LineEdit_NameMesh->setText(tr("SMESH_SUBMESH")); + LineEdit_NameMesh->setFocus(); + myEditCurrentArgument = LineEditC1A1; + mySelectionMgr->clearFilters(); + mySelectionMgr->installFilter(myMeshFilter); SelectionIntoArgument(); } @@ -238,8 +249,8 @@ void SMESHGUI_AddSubMeshDlg::Init( SALOME_Selection* Sel ) //================================================================================= void SMESHGUI_AddSubMeshDlg::ClickOnOk() { - if ( this->ClickOnApply() ) - this->ClickOnCancel() ; + if (this->ClickOnApply()) + this->ClickOnCancel(); } //================================================================================= @@ -248,67 +259,68 @@ void SMESHGUI_AddSubMeshDlg::ClickOnOk() //================================================================================= bool SMESHGUI_AddSubMeshDlg::ClickOnApply() { - if (mySMESHGUI->ActiveStudyLocked()) + if (mySMESHGUI->isActiveStudyLocked()) return false; QString myNameSubMesh = LineEdit_NameMesh->text().stripWhiteSpace(); - if ( myNameSubMesh.isEmpty() ) { - QAD_MessageBox::warn1( this, tr( "SMESH_WRN_WARNING" ), tr( "SMESH_WRN_EMPTY_NAME" ), tr( "SMESH_BUT_OK" ) ); + if (myNameSubMesh.isEmpty()) { + SUIT_MessageBox::warn1(this, tr("SMESH_WRN_WARNING"), + tr("SMESH_WRN_EMPTY_NAME"), tr("SMESH_BUT_OK")); return false; } - - if ( myMesh->_is_nil() || myGeomShape->_is_nil() || ( !HypoList.count() && !AlgoList.count() ) ) + + if (myMesh->_is_nil() || myGeomShape->_is_nil() || + (!HypoList.count() && !AlgoList.count())) return false; - SALOMEDS::SObject_var aMeshSO = SMESH::FindSObject( myMesh ); - GEOM::GEOM_Object_var myMainShape = SMESH::GetShapeOnMeshOrSubMesh( aMeshSO ); - if ( myMainShape->_is_nil() ) + _PTR(SObject) aMeshSO = SMESH::FindSObject(myMesh); + GEOM::GEOM_Object_var myMainShape = SMESH::GetShapeOnMeshOrSubMesh(aMeshSO); + if (myMainShape->_is_nil()) return false; - QAD_WaitCursor wc; + SUIT_OverrideCursor wc; - QAD_Operation* op = new QAD_Operation( mySMESHGUI->GetActiveStudy() ); + SUIT_Operation* op = + new SUIT_Operation (SUIT_Session::session()->activeApplication()); // start transaction op->start(); - + // create submesh - SMESH::SMESH_subMesh_var aSubMesh = SMESH::AddSubMesh( myMesh, myGeomShape, myNameSubMesh ) ; + SMESH::SMESH_subMesh_var aSubMesh = SMESH::AddSubMesh(myMesh, myGeomShape, myNameSubMesh); int nbSuccess = 0; - - if ( !aSubMesh->_is_nil() ) { + + if (!aSubMesh->_is_nil()) { // assign hypotheses int nbAlgo = AlgoList.count(); int nbHyps = HypoList.count() + nbAlgo; - for( int i = 0; i < nbHyps; i++ ) { - SALOMEDS::SObject_var aHypSO = SMESH::GetActiveStudyDocument()->FindObjectID - ( i < nbAlgo ? AlgoList[i] : HypoList[i-nbAlgo] ); - if ( !aHypSO->_is_nil() ) { - CORBA::Object_var anObject = aHypSO->GetObject(); - if ( !CORBA::is_nil( anObject ) ) { - SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis::_narrow( anObject ); - if ( !aHyp->_is_nil() ) - if ( SMESH::AddHypothesisOnSubMesh( aSubMesh, aHyp ) ) + for (int i = 0; i < nbHyps; i++) { + _PTR(SObject) aHypSOClient = + SMESH::GetActiveStudyDocument()->FindObjectID + (i < nbAlgo ? AlgoList[i].latin1() : HypoList[i-nbAlgo].latin1()); + if (aHypSOClient) { + CORBA::Object_var anObject = _CAST(SObject,aHypSOClient)->GetObject(); + if (!CORBA::is_nil(anObject)) { + SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis::_narrow(anObject); + if (!aHyp->_is_nil()) + if (SMESH::AddHypothesisOnSubMesh(aSubMesh, aHyp)) nbSuccess++; - } - else { - SCRUTE( CORBA::is_nil( anObject )); + } else { + SCRUTE(CORBA::is_nil(anObject)); } - } - else { - SCRUTE( aHypSO->_is_nil() ); + } else { + SCRUTE(!aHypSOClient); } } + } else { + SCRUTE(aSubMesh->_is_nil()); } - else { - SCRUTE( aSubMesh->_is_nil() ); - } - - // commit transaction - op->finish(); - return ( nbSuccess > 0 ); -} + // commit transaction + op->commit(); + mySMESHGUI->updateObjBrowser(); + return (nbSuccess > 0); +} //================================================================================= // function : ClickOnCancel() @@ -319,16 +331,18 @@ void SMESHGUI_AddSubMeshDlg::ClickOnCancel() close(); } -//======================================================================= -//function : IsFatherOf -//purpose : -//======================================================================= - -static bool IsFatherOf( SALOMEDS::SObject_ptr SO, SALOMEDS::SObject_ptr fatherSO ) { - if ( !SO->_is_nil() && !fatherSO->_is_nil() ) { - SALOMEDS::SObject_var aSO = SO->GetFather(); - while( strlen( aSO->GetID() ) >= strlen( fatherSO->GetID() ) ) { - if ( QString( aSO->GetID() ) == QString( fatherSO->GetID() ) ) +//================================================================================= +// function : IsFatherOf() +// purpose : +//================================================================================= +static bool IsFatherOf (_PTR(SObject) SO, _PTR(SObject) fatherSO) +{ + if (SO && fatherSO) { + _PTR(SObject) aSO = SO->GetFather(); + //while (strlen(aSO->GetID()) >= strlen(fatherSO->GetID())) { + while (aSO->GetID().length() >= fatherSO->GetID().length()) { + //if (QString(aSO->GetID()) == QString(fatherSO->GetID())) + if (aSO->GetID() == fatherSO->GetID()) return true; aSO = aSO->GetFather(); } @@ -342,87 +356,86 @@ static bool IsFatherOf( SALOMEDS::SObject_ptr SO, SALOMEDS::SObject_ptr fatherSO //================================================================================= void SMESHGUI_AddSubMeshDlg::SelectionIntoArgument() { - QString aString = ""; - int nbSel = SMESH::GetNameOfSelectedIObjects(mySelection, aString) ; + QString aString = ""; - if ( myEditCurrentArgument == LineEditC1A1 ) { + SALOME_ListIO aList; + mySelectionMgr->selectedObjects(aList, SVTK_Viewer::Type()); + int nbSel = SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString); + + if (myEditCurrentArgument == LineEditC1A1) { // mesh - if ( nbSel != 1 ) { + if (nbSel != 1) { myMesh = SMESH::SMESH_Mesh::_nil(); aString = ""; - } - else { - Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ; - myMesh = SMESH::IObjectToInterface(IO) ; - if( myMesh->_is_nil() ) { + } else { + Handle(SALOME_InteractiveObject) IO = aList.First(); + myMesh = SMESH::IObjectToInterface(IO); + if (myMesh->_is_nil()) { aString = ""; } } myGeomShape = GEOM::GEOM_Object::_nil(); - LineEditC1A2->setText( "" ); - } - else if ( myEditCurrentArgument == LineEditC1A2 ) { + LineEditC1A2->setText(""); + + } else if (myEditCurrentArgument == LineEditC1A2) { // geom shape - if ( nbSel != 1 ) { + if (nbSel != 1) { myGeomShape = GEOM::GEOM_Object::_nil(); aString = ""; - } - else { - Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ; - myGeomShape = SMESH::IObjectToInterface(IO) ; - if( myGeomShape->_is_nil() || !GEOMBase::IsShape( myGeomShape ) ) - { + } else { + Handle(SALOME_InteractiveObject) IO = aList.First(); + myGeomShape = SMESH::IObjectToInterface(IO); + if (myGeomShape->_is_nil() || !GEOMBase::IsShape(myGeomShape)) { myGeomShape = GEOM::GEOM_Object::_nil(); aString = ""; } - if ( !myMesh->_is_nil() ) { - SALOMEDS::SObject_var aMeshSO = SMESH::FindSObject( myMesh ); - GEOM::GEOM_Object_var aMainGeomShape = SMESH::GetShapeOnMeshOrSubMesh( aMeshSO ); - SALOMEDS::SObject_var aMainGeomShapeSO = SMESH::FindSObject( aMainGeomShape ); - if ( aMainGeomShapeSO->_is_nil() || !IsFatherOf( SMESH::GetActiveStudyDocument()->FindObjectID( IO->getEntry() ), aMainGeomShapeSO ) ) { + if (!myMesh->_is_nil()) { + _PTR(SObject) aMeshSO = SMESH::FindSObject(myMesh); + GEOM::GEOM_Object_var aMainGeomShape = SMESH::GetShapeOnMeshOrSubMesh(aMeshSO); + _PTR(SObject) aMainGeomShapeSO = SMESH::FindSObject(aMainGeomShape); + if (!aMainGeomShapeSO || + !IsFatherOf(SMESH::GetActiveStudyDocument()->FindObjectID + (IO->getEntry()), aMainGeomShapeSO)) { myGeomShape = GEOM::GEOM_Object::_nil(); aString = ""; - } + } } } - } - else if ( myEditCurrentArgument == LineEditC1A1Hyp ) { + } else if (myEditCurrentArgument == LineEditC1A1Hyp) { // hypotheses HypoList.clear(); - if ( nbSel >= 1 ) { - SALOME_ListIteratorOfListIO Itinit( mySelection->StoredIObjects() ); - for ( ; Itinit.More(); Itinit.Next() ) { - HypoList.append( Itinit.Value()->getEntry() ); + if (nbSel >= 1) { + SALOME_ListIteratorOfListIO Itinit (aList); + for (; Itinit.More(); Itinit.Next()) { + HypoList.append(Itinit.Value()->getEntry()); } - if ( nbSel > 1 ) - aString = tr( "%1 Hypothesis" ).arg( nbSel ) ; - } - else { + if (nbSel > 1) + aString = tr("%1 Hypothesis").arg(nbSel); + } else { aString = ""; } - } - else if ( myEditCurrentArgument == LineEditC1A1Algo ) { + } else if (myEditCurrentArgument == LineEditC1A1Algo) { // algorithms - AlgoList.clear(); - if ( nbSel >= 1 ) { - SALOME_ListIteratorOfListIO Itinit( mySelection->StoredIObjects() ); - for ( ; Itinit.More(); Itinit.Next() ) { - AlgoList.append( Itinit.Value()->getEntry() ); + AlgoList.clear(); + if (nbSel >= 1) { + SALOME_ListIteratorOfListIO Itinit (aList); + for (; Itinit.More(); Itinit.Next()) { + AlgoList.append(Itinit.Value()->getEntry()); } - if ( nbSel > 1 ) - aString = tr( "%1 Algorithms" ).arg( nbSel ) ; - } - else { + if (nbSel > 1) + aString = tr("%1 Algorithms").arg(nbSel); + } else { aString = ""; } + } else { } - - myEditCurrentArgument->setText(aString) ; + + myEditCurrentArgument->setText(aString); + myEditCurrentArgument->setCursorPosition( 0 ); UpdateControlState(); } - //================================================================================= // function : SetEditCurrentArgument() // purpose : @@ -431,27 +444,27 @@ void SMESHGUI_AddSubMeshDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); if(send == SelectButtonC1A1) { - LineEditC1A1->setFocus() ; + LineEditC1A1->setFocus(); + mySelectionMgr->clearFilters(); + mySelectionMgr->installFilter(myMeshFilter); myEditCurrentArgument = LineEditC1A1; - mySelection->ClearFilters() ; - mySelection->AddFilter(myMeshFilter) ; } else if (send == SelectButtonC1A2) { - LineEditC1A2->setFocus() ; + LineEditC1A2->setFocus(); + mySelectionMgr->clearFilters(); + mySelectionMgr->installFilter(myGeomFilter); myEditCurrentArgument = LineEditC1A2; - mySelection->ClearFilters() ; - mySelection->AddFilter(myGeomFilter) ; - } else if( send == SelectButtonC1A1Hyp ) { - LineEditC1A1Hyp->setFocus() ; - myEditCurrentArgument = LineEditC1A1Hyp ; - mySelection->ClearFilters() ; - mySelection->AddFilter(myHypothesisFilter) ; - } else if( send == SelectButtonC1A1Algo ) { - LineEditC1A1Algo->setFocus() ; - myEditCurrentArgument = LineEditC1A1Algo ; - mySelection->ClearFilters() ; - mySelection->AddFilter(myAlgorithmFilter) ; + } else if(send == SelectButtonC1A1Hyp) { + LineEditC1A1Hyp->setFocus(); + mySelectionMgr->clearFilters(); + mySelectionMgr->installFilter(myHypothesisFilter); + myEditCurrentArgument = LineEditC1A1Hyp; + } else if(send == SelectButtonC1A1Algo) { + LineEditC1A1Algo->setFocus(); + mySelectionMgr->clearFilters(); + mySelectionMgr->installFilter(myAlgorithmFilter); + myEditCurrentArgument = LineEditC1A1Algo; } - SelectionIntoArgument() ; + SelectionIntoArgument(); } //================================================================================= @@ -460,48 +473,45 @@ void SMESHGUI_AddSubMeshDlg::SetEditCurrentArgument() //================================================================================= void SMESHGUI_AddSubMeshDlg::DeactivateActiveDialog() { - if ( GroupC1->isEnabled() ) { - disconnect( mySelection, 0, this, 0 ); - GroupC1->setEnabled(false) ; - GroupButtons->setEnabled(false) ; + if (GroupC1->isEnabled()) { + disconnect(mySelectionMgr, 0, this, 0); + GroupC1->setEnabled(false); + GroupButtons->setEnabled(false); } } - //================================================================================= // function : ActivateThisDialog() // purpose : //================================================================================= void SMESHGUI_AddSubMeshDlg::ActivateThisDialog() { - mySMESHGUI->EmitSignalDeactivateDialog() ; - GroupC1->setEnabled(true) ; - GroupButtons->setEnabled(true) ; - connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + mySMESHGUI->EmitSignalDeactivateDialog(); + GroupC1->setEnabled(true); + GroupButtons->setEnabled(true); + connect (mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); } - //================================================================================= // function : enterEvent() // purpose : //================================================================================= -void SMESHGUI_AddSubMeshDlg::enterEvent(QEvent* e) +void SMESHGUI_AddSubMeshDlg::enterEvent (QEvent*) { - if ( !GroupC1->isEnabled() ) - ActivateThisDialog() ; + if (!GroupC1->isEnabled()) + ActivateThisDialog(); } - //================================================================================= // function : closeEvent() // purpose : //================================================================================= -void SMESHGUI_AddSubMeshDlg::closeEvent( QCloseEvent* e ) +void SMESHGUI_AddSubMeshDlg::closeEvent (QCloseEvent* e) { - disconnect( mySelection, 0, this, 0 ); - mySMESHGUI->ResetState() ; - mySelection->ClearFilters() ; - QDialog::closeEvent( e ); + disconnect(mySelectionMgr, 0, this, 0); + mySMESHGUI->ResetState(); + mySelectionMgr->clearFilters(); + QDialog::closeEvent(e); } //================================================================================= @@ -510,14 +520,16 @@ void SMESHGUI_AddSubMeshDlg::closeEvent( QCloseEvent* e ) //================================================================================= void SMESHGUI_AddSubMeshDlg::UpdateControlState() { - bool isEnabled = ( !myMesh->_is_nil() && !myGeomShape->_is_nil() && ( HypoList.count() || AlgoList.count() ) ); + bool isEnabled = (!myMesh->_is_nil() && + !myGeomShape->_is_nil() && + (HypoList.count() || AlgoList.count())); bool isImportedMesh = false; - if ( !myMesh->_is_nil() ) { - SALOMEDS::SObject_var aMeshSO = SMESH::FindSObject( myMesh ); - GEOM::GEOM_Object_var myGeomShape = SMESH::GetShapeOnMeshOrSubMesh( aMeshSO ); + if (!myMesh->_is_nil()) { + _PTR(SObject) aMeshSO = SMESH::FindSObject(myMesh); + GEOM::GEOM_Object_var myGeomShape = SMESH::GetShapeOnMeshOrSubMesh(aMeshSO); isImportedMesh = myGeomShape->_is_nil(); } - buttonOk ->setEnabled( isEnabled && !isImportedMesh ); - buttonApply->setEnabled( isEnabled && !isImportedMesh ); + buttonOk ->setEnabled(isEnabled && !isImportedMesh); + buttonApply->setEnabled(isEnabled && !isImportedMesh); } diff --git a/src/SMESHGUI/SMESHGUI_AddSubMeshDlg.h b/src/SMESHGUI/SMESHGUI_AddSubMeshDlg.h index 3ede5c043..20e197618 100644 --- a/src/SMESHGUI/SMESHGUI_AddSubMeshDlg.h +++ b/src/SMESHGUI/SMESHGUI_AddSubMeshDlg.h @@ -29,9 +29,10 @@ #ifndef DIALOGBOX_ADD_SUBMESH_H #define DIALOGBOX_ADD_SUBMESH_H -#include "SALOME_Selection.h" -#include "SALOME_TypeFilter.hxx" -#include "SMESH_TypeFilter.hxx" +//#include "SMESH_TypeFilter.hxx" + +#include "SUIT_SelectionFilter.h" +#include "SalomeApp_SelectionMgr.h" // QT Includes #include @@ -57,33 +58,40 @@ class SMESHGUI_AddSubMeshDlg : public QDialog Q_OBJECT public: - SMESHGUI_AddSubMeshDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); + SMESHGUI_AddSubMeshDlg( SMESHGUI*, + const char* name = 0, + bool modal = FALSE, + WFlags fl = 0); ~SMESHGUI_AddSubMeshDlg(); protected: - void closeEvent( QCloseEvent* e ) ; - void enterEvent ( QEvent * ) ; + void closeEvent (QCloseEvent* e); + void enterEvent (QEvent *) ; private: - void Init( SALOME_Selection* Sel ) ; + void Init (); void UpdateControlState(); private: - SMESHGUI* mySMESHGUI ; - SALOME_Selection* mySelection ; - - SMESH::SMESH_Mesh_var myMesh; - GEOM::GEOM_Object_var myGeomShape ; - QLineEdit* myEditCurrentArgument; + SMESHGUI* mySMESHGUI; + SalomeApp_SelectionMgr* mySelectionMgr; - Handle(SALOME_TypeFilter) myGeomFilter; - Handle(SMESH_TypeFilter) myMeshFilter; - Handle(SMESH_TypeFilter) myHypothesisFilter; - Handle(SMESH_TypeFilter) myAlgorithmFilter; + SMESH::SMESH_Mesh_var myMesh; + GEOM::GEOM_Object_var myGeomShape; + QLineEdit* myEditCurrentArgument; - QStringList HypoList; - QStringList AlgoList; + //Handle(SALOME_TypeFilter) myMeshFilter; + //Handle(SMESH_TypeFilter) myMeshFilter; + //Handle(SMESH_TypeFilter) myHypothesisFilter; + //Handle(SMESH_TypeFilter) myAlgorithmFilter; + SUIT_SelectionFilter* myGeomFilter; + SUIT_SelectionFilter* myMeshFilter; + SUIT_SelectionFilter* myHypothesisFilter; + SUIT_SelectionFilter* myAlgorithmFilter; + + QStringList HypoList; + QStringList AlgoList; QGroupBox* GroupButtons; QPushButton* buttonOk; @@ -91,8 +99,8 @@ private: QPushButton* buttonCancel; QGroupBox* GroupC1; - QLabel* TextLabel_NameMesh ; - QLineEdit* LineEdit_NameMesh ; + QLabel* TextLabel_NameMesh; + QLineEdit* LineEdit_NameMesh; QLabel* TextLabelC1A1; QPushButton* SelectButtonC1A1; QLineEdit* LineEditC1A1; @@ -112,10 +120,10 @@ private slots: void ClickOnOk(); bool ClickOnApply(); void ClickOnCancel(); - void SetEditCurrentArgument() ; - void SelectionIntoArgument() ; - void DeactivateActiveDialog() ; - void ActivateThisDialog() ; + void SetEditCurrentArgument(); + void SelectionIntoArgument(); + void DeactivateActiveDialog(); + void ActivateThisDialog(); }; #endif // DIALOGBOX_ADD_SUBMESH_H diff --git a/src/SMESHGUI/SMESHGUI_ClippingDlg.cxx b/src/SMESHGUI/SMESHGUI_ClippingDlg.cxx index 2190ea2d5..f415162d5 100644 --- a/src/SMESHGUI/SMESHGUI_ClippingDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_ClippingDlg.cxx @@ -1,23 +1,23 @@ // SMESH SMESHGUI : GUI for SMESH component // // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org // // // @@ -32,7 +32,21 @@ #include "SMESHGUI_Utils.h" #include "SMESHGUI_VTKUtils.h" -#include +#include "SMESH_Actor.h" +#include "SMESH_ActorUtils.h" + +#include "SUIT_Session.h" +#include "SUIT_OverrideCursor.h" + +#include "SALOME_ListIO.hxx" +#include "SALOME_InteractiveObject.hxx" +#include "SALOME_ListIteratorOfListIO.hxx" + +#include "SalomeApp_Application.h" +#include "SalomeApp_SelectionMgr.h" + +#include "SVTK_Selector.h" +#include "SVTK_ViewWindow.h" // QT Includes #include @@ -42,6 +56,7 @@ #include #include +// VTK Includes #include #include #include @@ -53,57 +68,46 @@ #include #include #include - -#include "VTKViewer_ViewFrame.h" -#include "QAD_RightFrame.h" -#include "QAD_WaitCursor.h" -#include "SALOME_ListIteratorOfListIO.hxx" -#include "SMESH_Actor.h" -#include "SALOME_Selection.h" -#include "SALOME_InteractiveObject.hxx" -#include "SMESH_ActorUtils.h" - -#include "VTKViewer_ViewFrame.h" -#include "VTKViewer_RenderWindow.h" - #include +// STL includes +#include + using namespace std; class OrientedPlane: public vtkPlane { - QAD_Study* myStudy; - QAD_StudyFrame* myStudyFrame; - VTKViewer_ViewFrame* myViewFrame; - + SVTK_ViewWindow* myViewWindow; + vtkDataSetMapper* myMapper; - public: - static OrientedPlane *New(){ + static OrientedPlane *New() + { return new OrientedPlane(); } - static OrientedPlane *New(QAD_Study* theStudy){ - return new OrientedPlane(theStudy); + static OrientedPlane *New(SVTK_ViewWindow* theViewWindow) + { + return new OrientedPlane(theViewWindow); } - vtkTypeMacro(OrientedPlane, vtkPlane); - - + vtkTypeMacro (OrientedPlane, vtkPlane); + SMESH::Orientation myOrientation; float myDistance; double myAngle[2]; vtkPlaneSource* myPlaneSource; SALOME_Actor *myActor; - - void SetOrientation(SMESH::Orientation theOrientation) {myOrientation = theOrientation;} - SMESH::Orientation GetOrientation() {return myOrientation;} - void SetDistance(float theDistance) {myDistance = theDistance;} - float GetDistance() {return myDistance;} + void SetOrientation (SMESH::Orientation theOrientation) { myOrientation = theOrientation; } + SMESH::Orientation GetOrientation() { return myOrientation; } - void ShallowCopy(OrientedPlane* theOrientedPlane){ + void SetDistance (float theDistance) { myDistance = theDistance; } + float GetDistance() { return myDistance; } + + void ShallowCopy (OrientedPlane* theOrientedPlane) + { SetNormal(theOrientedPlane->GetNormal()); SetOrigin(theOrientedPlane->GetOrigin()); @@ -120,41 +124,38 @@ public: } protected: - OrientedPlane(QAD_Study* theStudy): + OrientedPlane(SVTK_ViewWindow* theViewWindow): + myViewWindow(theViewWindow), myOrientation(SMESH::XY), - myDistance(0.5), - myStudy(theStudy), - myStudyFrame(theStudy->getActiveStudyFrame()), - myViewFrame(SMESH::GetVtkViewFrame(theStudy->getActiveStudyFrame())) + myDistance(0.5) { Init(); - myViewFrame->AddActor( myActor ); + myViewWindow->AddActor(myActor); } OrientedPlane(): myOrientation(SMESH::XY), - myDistance(0.5), - myStudy(NULL), - myStudyFrame(NULL), - myViewFrame(NULL) + myViewWindow(NULL), + myDistance(0.5) { Init(); } - void Init(){ + void Init() + { myPlaneSource = vtkPlaneSource::New(); myAngle[0] = myAngle[1] = 0.0; // Create and display actor myMapper = vtkDataSetMapper::New(); - myMapper->SetInput( myPlaneSource->GetOutput() ); - + myMapper->SetInput(myPlaneSource->GetOutput()); + myActor = SALOME_Actor::New(); myActor->VisibilityOff(); myActor->PickableOff(); myActor->SetInfinitive(true); - myActor->SetMapper( myMapper ); + myActor->SetMapper(myMapper); vtkProperty* aProp = vtkProperty::New(); float anRGB[3]; @@ -163,40 +164,38 @@ protected: anRGB[2] = SMESH::GetFloat("SMESH:SettingsFillColorBlue", 255)/255.; aProp->SetColor(anRGB[0],anRGB[1],anRGB[2]); aProp->SetOpacity(0.75); - myActor->SetProperty( aProp ); + myActor->SetProperty(aProp); aProp->Delete(); - + vtkProperty* aBackProp = vtkProperty::New(); anRGB[0] = SMESH::GetFloat("SMESH:SettingsBackFaceColorRed", 0)/255.; anRGB[1] = SMESH::GetFloat("SMESH:SettingsBackFaceColorGreen", 0)/255.; anRGB[2] = SMESH::GetFloat("SMESH:SettingsBackFaceColorBlue", 255)/255.; aBackProp->SetColor(anRGB[0],anRGB[1],anRGB[2]); aBackProp->SetOpacity(0.75); - myActor->SetBackfaceProperty( aBackProp ); + myActor->SetBackfaceProperty(aBackProp); aBackProp->Delete(); } ~OrientedPlane(){ - if(myStudy && SMESH::FindVtkViewFrame(myStudy,myStudyFrame)){ - myViewFrame->RemoveActor(myActor); - } + myViewWindow->RemoveActor(myActor); myActor->Delete(); myMapper->RemoveAllInputs(); myMapper->Delete(); - + myPlaneSource->UnRegisterAllOutputs(); myPlaneSource->Delete(); }; - + private: // Not implemented. - OrientedPlane(const OrientedPlane&); - void operator=(const OrientedPlane&); + OrientedPlane (const OrientedPlane&); + void operator= (const OrientedPlane&); }; -struct TSetVisiblity{ +struct TSetVisiblity { TSetVisiblity(int theIsVisible): myIsVisible(theIsVisible){} void operator()(SMESH::TVTKPlane& theOrientedPlane){ theOrientedPlane->myActor->SetVisibility(myIsVisible); @@ -204,173 +203,175 @@ struct TSetVisiblity{ int myIsVisible; }; - //================================================================================= // class : SMESHGUI_ClippingDlg() -// purpose : +// purpose : // //================================================================================= -SMESHGUI_ClippingDlg::SMESHGUI_ClippingDlg( QWidget* parent, +SMESHGUI_ClippingDlg::SMESHGUI_ClippingDlg (SMESHGUI* theModule, const char* name, bool modal, - WFlags fl ) - : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose ) + WFlags fl): + QDialog(SMESH::GetDesktop(theModule), + name, + modal, + WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose), + mySelector(SMESH::GetViewWindow(theModule)->GetSelector()), + mySelectionMgr(SMESH::GetSelectionMgr(theModule)), + mySMESHGUI(theModule) { - if ( !name ) - setName( "SMESHGUI_ClippingDlg" ); - setCaption( tr( "SMESH_CLIPPING_TITLE" ) ); - setSizeGripEnabled( TRUE ); - QGridLayout* SMESHGUI_ClippingDlgLayout = new QGridLayout( this ); - SMESHGUI_ClippingDlgLayout->setSpacing( 6 ); - SMESHGUI_ClippingDlgLayout->setMargin( 11 ); + if (!name) + setName("SMESHGUI_ClippingDlg"); + setCaption(tr("SMESH_CLIPPING_TITLE")); + setSizeGripEnabled(TRUE); + QGridLayout* SMESHGUI_ClippingDlgLayout = new QGridLayout(this); + SMESHGUI_ClippingDlgLayout->setSpacing(6); + SMESHGUI_ClippingDlgLayout->setMargin(11); // Controls for selecting, creating, deleting planes - QGroupBox* GroupPlanes = new QGroupBox( this, "GroupPlanes" ); - GroupPlanes->setTitle( tr("Clipping planes") ); + QGroupBox* GroupPlanes = new QGroupBox (this, "GroupPlanes"); + GroupPlanes->setTitle(tr("Clipping planes")); GroupPlanes->setColumnLayout(0, Qt::Vertical); - GroupPlanes->layout()->setSpacing( 0 ); - GroupPlanes->layout()->setMargin( 0 ); - QGridLayout* GroupPlanesLayout = new QGridLayout( GroupPlanes->layout() ); - GroupPlanesLayout->setAlignment( Qt::AlignTop ); - GroupPlanesLayout->setSpacing( 6 ); - GroupPlanesLayout->setMargin( 11 ); - + GroupPlanes->layout()->setSpacing(0); + GroupPlanes->layout()->setMargin(0); + QGridLayout* GroupPlanesLayout = new QGridLayout (GroupPlanes->layout()); + GroupPlanesLayout->setAlignment(Qt::AlignTop); + GroupPlanesLayout->setSpacing(6); + GroupPlanesLayout->setMargin(11); + ComboBoxPlanes = new QComboBox(GroupPlanes, "ComboBoxPlanes"); - GroupPlanesLayout->addWidget( ComboBoxPlanes, 0, 0 ); - - QSpacerItem* spacerGP = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); - GroupPlanesLayout->addItem( spacerGP, 0, 1 ); - - buttonNew = new QPushButton( GroupPlanes, "buttonNew" ); - buttonNew->setText( tr( "SMESH_BUT_NEW" ) ); - GroupPlanesLayout->addWidget( buttonNew, 0, 2 ); - - buttonDelete = new QPushButton( GroupPlanes, "buttonDelete" ); - buttonDelete->setText( tr( "SMESH_BUT_DELETE" ) ); - GroupPlanesLayout->addWidget( buttonDelete, 0, 3 ); + GroupPlanesLayout->addWidget(ComboBoxPlanes, 0, 0); + + QSpacerItem* spacerGP = new QSpacerItem (20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); + GroupPlanesLayout->addItem(spacerGP, 0, 1); + + buttonNew = new QPushButton (GroupPlanes, "buttonNew"); + buttonNew->setText(tr("SMESH_BUT_NEW")); + GroupPlanesLayout->addWidget(buttonNew, 0, 2); + + buttonDelete = new QPushButton (GroupPlanes, "buttonDelete"); + buttonDelete->setText(tr("SMESH_BUT_DELETE")); + GroupPlanesLayout->addWidget(buttonDelete, 0, 3); // Controls for defining plane parameters - QGroupBox* GroupParameters = new QGroupBox( this, "GroupParameters" ); - GroupParameters->setTitle( tr("SMESH_PARAMETERS") ); + QGroupBox* GroupParameters = new QGroupBox (this, "GroupParameters"); + GroupParameters->setTitle(tr("SMESH_PARAMETERS")); GroupParameters->setColumnLayout(0, Qt::Vertical); - GroupParameters->layout()->setSpacing( 0 ); - GroupParameters->layout()->setMargin( 0 ); - QGridLayout* GroupParametersLayout = new QGridLayout( GroupParameters->layout() ); - GroupParametersLayout->setAlignment( Qt::AlignTop ); - GroupParametersLayout->setSpacing( 6 ); - GroupParametersLayout->setMargin( 11 ); - - TextLabelOrientation = new QLabel( GroupParameters, "TextLabelOrientation" ); - TextLabelOrientation->setText( tr("SMESH_ORIENTATION") ); - GroupParametersLayout->addWidget( TextLabelOrientation, 0, 0 ); - + GroupParameters->layout()->setSpacing(0); + GroupParameters->layout()->setMargin(0); + QGridLayout* GroupParametersLayout = new QGridLayout (GroupParameters->layout()); + GroupParametersLayout->setAlignment(Qt::AlignTop); + GroupParametersLayout->setSpacing(6); + GroupParametersLayout->setMargin(11); + + TextLabelOrientation = new QLabel(GroupParameters, "TextLabelOrientation"); + TextLabelOrientation->setText(tr("SMESH_ORIENTATION")); + GroupParametersLayout->addWidget(TextLabelOrientation, 0, 0); + ComboBoxOrientation = new QComboBox(GroupParameters, "ComboBoxOrientation"); - GroupParametersLayout->addWidget( ComboBoxOrientation, 0, 1 ); - - TextLabelDistance = new QLabel( GroupParameters, "TextLabelDistance" ); - TextLabelDistance->setText( tr("SMESH_DISTANCE") ); - GroupParametersLayout->addWidget( TextLabelDistance, 1, 0 ); + GroupParametersLayout->addWidget(ComboBoxOrientation, 0, 1); - SpinBoxDistance = new SMESHGUI_SpinBox( GroupParameters, "SpinBoxDistance" ); - GroupParametersLayout->addWidget( SpinBoxDistance, 1, 1 ); + TextLabelDistance = new QLabel(GroupParameters, "TextLabelDistance"); + TextLabelDistance->setText(tr("SMESH_DISTANCE")); + GroupParametersLayout->addWidget(TextLabelDistance, 1, 0); - TextLabelRot1 = new QLabel( GroupParameters, "TextLabelRot1" ); - TextLabelRot1->setText( tr("Rotation around X (Y to Z):") ); - GroupParametersLayout->addWidget( TextLabelRot1, 2, 0 ); + SpinBoxDistance = new SMESHGUI_SpinBox(GroupParameters, "SpinBoxDistance"); + GroupParametersLayout->addWidget(SpinBoxDistance, 1, 1); - SpinBoxRot1 = new SMESHGUI_SpinBox( GroupParameters, "SpinBoxRot1" ); - GroupParametersLayout->addWidget( SpinBoxRot1, 2, 1 ); - - TextLabelRot2 = new QLabel( GroupParameters, "TextLabelRot2" ); - TextLabelRot2->setText( tr("Rotation around Y (X to Z):") ); - GroupParametersLayout->addWidget( TextLabelRot2, 3, 0 ); - - SpinBoxRot2 = new SMESHGUI_SpinBox( GroupParameters, "SpinBoxRot2" ); - GroupParametersLayout->addWidget( SpinBoxRot2, 3, 1 ); + TextLabelRot1 = new QLabel(GroupParameters, "TextLabelRot1"); + TextLabelRot1->setText(tr("Rotation around X (Y to Z):")); + GroupParametersLayout->addWidget(TextLabelRot1, 2, 0); + + SpinBoxRot1 = new SMESHGUI_SpinBox(GroupParameters, "SpinBoxRot1"); + GroupParametersLayout->addWidget(SpinBoxRot1, 2, 1); + + TextLabelRot2 = new QLabel(GroupParameters, "TextLabelRot2"); + TextLabelRot2->setText(tr("Rotation around Y (X to Z):")); + GroupParametersLayout->addWidget(TextLabelRot2, 3, 0); + + SpinBoxRot2 = new SMESHGUI_SpinBox(GroupParameters, "SpinBoxRot2"); + GroupParametersLayout->addWidget(SpinBoxRot2, 3, 1); PreviewCheckBox = new QCheckBox(tr("Show preview"), GroupParameters); PreviewCheckBox->setChecked(true); - GroupParametersLayout->addWidget( PreviewCheckBox, 4, 0 ); + GroupParametersLayout->addWidget(PreviewCheckBox, 4, 0); AutoApplyCheckBox = new QCheckBox(tr("Auto Apply"), GroupParameters); AutoApplyCheckBox->setChecked(false); - GroupParametersLayout->addWidget( AutoApplyCheckBox, 4, 1 ); - - // Controls for "Ok", "Apply" and "Close" button - QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" ); - GroupButtons->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, GroupButtons->sizePolicy().hasHeightForWidth() ) ); - GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); - GroupButtons->setTitle( tr( "" ) ); - GroupButtons->setColumnLayout(0, Qt::Vertical ); - GroupButtons->layout()->setSpacing( 0 ); - GroupButtons->layout()->setMargin( 0 ); - QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); - GroupButtonsLayout->setAlignment( Qt::AlignTop ); - GroupButtonsLayout->setSpacing( 6 ); - GroupButtonsLayout->setMargin( 11 ); - buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); - buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) ); - buttonCancel->setAutoDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonCancel, 0, 3 ); - buttonApply = new QPushButton( GroupButtons, "buttonApply" ); - buttonApply->setText( tr( "SMESH_BUT_APPLY" ) ); - buttonApply->setAutoDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); - QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); - GroupButtonsLayout->addItem( spacer_9, 0, 2 ); - buttonOk = new QPushButton( GroupButtons, "buttonOk" ); - buttonOk->setText( tr( "SMESH_BUT_OK" ) ); - buttonOk->setAutoDefault( TRUE ); - buttonOk->setDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); + GroupParametersLayout->addWidget(AutoApplyCheckBox, 4, 1); - SMESHGUI_ClippingDlgLayout->addWidget( GroupPlanes, 0, 0 ); - SMESHGUI_ClippingDlgLayout->addWidget( GroupParameters, 1, 0 ); - SMESHGUI_ClippingDlgLayout->addWidget( GroupButtons, 2, 0 ); - - mySelection = SALOME_Selection::Selection( SMESHGUI::GetSMESHGUI()->GetActiveStudy()->getSelection()); + // Controls for "Ok", "Apply" and "Close" button + QGroupBox* GroupButtons = new QGroupBox(this, "GroupButtons"); + GroupButtons->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, GroupButtons->sizePolicy().hasHeightForWidth())); + GroupButtons->setGeometry(QRect(10, 10, 281, 48)); + GroupButtons->setTitle(tr("" )); + GroupButtons->setColumnLayout(0, Qt::Vertical); + GroupButtons->layout()->setSpacing(0); + GroupButtons->layout()->setMargin(0); + QGridLayout* GroupButtonsLayout = new QGridLayout(GroupButtons->layout()); + GroupButtonsLayout->setAlignment(Qt::AlignTop); + GroupButtonsLayout->setSpacing(6); + GroupButtonsLayout->setMargin(11); + buttonCancel = new QPushButton(GroupButtons, "buttonCancel"); + buttonCancel->setText(tr("SMESH_BUT_CLOSE" )); + buttonCancel->setAutoDefault(TRUE); + GroupButtonsLayout->addWidget(buttonCancel, 0, 3); + buttonApply = new QPushButton(GroupButtons, "buttonApply"); + buttonApply->setText(tr("SMESH_BUT_APPLY" )); + buttonApply->setAutoDefault(TRUE); + GroupButtonsLayout->addWidget(buttonApply, 0, 1); + QSpacerItem* spacer_9 = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); + GroupButtonsLayout->addItem(spacer_9, 0, 2); + buttonOk = new QPushButton(GroupButtons, "buttonOk"); + buttonOk->setText(tr("SMESH_BUT_OK" )); + buttonOk->setAutoDefault(TRUE); + buttonOk->setDefault(TRUE); + GroupButtonsLayout->addWidget(buttonOk, 0, 0); + + SMESHGUI_ClippingDlgLayout->addWidget(GroupPlanes, 0, 0); + SMESHGUI_ClippingDlgLayout->addWidget(GroupParameters, 1, 0); + SMESHGUI_ClippingDlgLayout->addWidget(GroupButtons, 2, 0); // Initial state - SpinBoxDistance->RangeStepAndValidator( 0.0, 1.0, 0.01, 3 ); - SpinBoxRot1->RangeStepAndValidator( -180.0, 180.0, 1, 3 ); - SpinBoxRot2->RangeStepAndValidator( -180.0, 180.0, 1, 3 ); + SpinBoxDistance->RangeStepAndValidator(0.0, 1.0, 0.01, 3); + SpinBoxRot1->RangeStepAndValidator(-180.0, 180.0, 1, 3); + SpinBoxRot2->RangeStepAndValidator(-180.0, 180.0, 1, 3); - ComboBoxOrientation->insertItem( tr("|| X-Y") ); - ComboBoxOrientation->insertItem( tr("|| Y-Z") ); - ComboBoxOrientation->insertItem( tr("|| Z-X") ); + ComboBoxOrientation->insertItem(tr("|| X-Y")); + ComboBoxOrientation->insertItem(tr("|| Y-Z")); + ComboBoxOrientation->insertItem(tr("|| Z-X")); SpinBoxDistance->SetValue(0.5); myActor = 0; myIsSelectPlane = false; onSelectionChanged(); - + // signals and slots connections : - connect( ComboBoxPlanes, SIGNAL( activated( int )), this, SLOT( onSelectPlane( int ) ) ); - connect( buttonNew, SIGNAL( clicked() ), this, SLOT( ClickOnNew() ) ); - connect( buttonDelete, SIGNAL( clicked() ), this, SLOT( ClickOnDelete() ) ); - connect( ComboBoxOrientation, SIGNAL( activated( int )), this, SLOT( onSelectOrientation( int ) ) ); - connect( SpinBoxDistance, SIGNAL( valueChanged( double )), this, SLOT( SetCurrentPlaneParam() ) ); - connect( SpinBoxRot1, SIGNAL( valueChanged( double )), this, SLOT( SetCurrentPlaneParam() ) ); - connect( SpinBoxRot2, SIGNAL( valueChanged( double )), this, SLOT( SetCurrentPlaneParam() ) ); - connect( PreviewCheckBox, SIGNAL( toggled( bool )), this, SLOT( OnPreviewToggle( bool ) ) ); - connect( AutoApplyCheckBox, SIGNAL( toggled( bool )), this, SLOT( ClickOnApply() ) ); - connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); - connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ; - connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) ); - connect( SMESHGUI::GetSMESHGUI(), SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnOk() ) ) ; - connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionChanged() ) ); + connect(ComboBoxPlanes, SIGNAL(activated(int)), this, SLOT(onSelectPlane(int))); + connect(buttonNew, SIGNAL(clicked()), this, SLOT(ClickOnNew())); + connect(buttonDelete, SIGNAL(clicked()), this, SLOT(ClickOnDelete())); + connect(ComboBoxOrientation, SIGNAL(activated(int)), this, SLOT(onSelectOrientation(int))); + connect(SpinBoxDistance, SIGNAL(valueChanged(double)), this, SLOT(SetCurrentPlaneParam())); + connect(SpinBoxRot1, SIGNAL(valueChanged(double)), this, SLOT(SetCurrentPlaneParam())); + connect(SpinBoxRot2, SIGNAL(valueChanged(double)), this, SLOT(SetCurrentPlaneParam())); + connect(PreviewCheckBox, SIGNAL(toggled(bool)), this, SLOT(OnPreviewToggle(bool))); + connect(AutoApplyCheckBox, SIGNAL(toggled(bool)), this, SLOT(ClickOnApply())); + connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel())); + connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); + connect(mySMESHGUI, SIGNAL (SignalCloseAllDialogs()), this, SLOT(ClickOnOk())); + connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(onSelectionChanged())); /* to close dialog if study frame change */ - connect( SMESHGUI::GetSMESHGUI(), SIGNAL ( SignalStudyFrameChanged() ), this, SLOT( ClickOnCancel() ) ) ; - + connect(mySMESHGUI, SIGNAL (SignalStudyFrameChanged()), this, SLOT(ClickOnCancel())); + /* Move widget on the botton right corner of main widget */ - int x, y ; - SMESHGUI::GetSMESHGUI()->DefineDlgPosition( this, x, y ) ; - this->move( x, y ) ; + int x, y; + mySMESHGUI->DefineDlgPosition(this, x, y); + this->move(x, y); this->show(); } - //================================================================================= // function : ~SMESHGUI_ClippingDlg() // purpose : @@ -379,44 +380,45 @@ SMESHGUI_ClippingDlg::~SMESHGUI_ClippingDlg() { // no need to delete child widgets, Qt does it all for us std::for_each(myPlanes.begin(),myPlanes.end(),TSetVisiblity(false)); - SMESH::RenderViewFrame(SMESH::GetCurrentVtkView()); + SMESH::RenderViewWindow(SMESH::GetViewWindow(mySMESHGUI)); } - +//======================================================================= +// function : ClickOnApply() +// purpose : +//======================================================================= void SMESHGUI_ClippingDlg::ClickOnApply() { if (!myActor) return; - if ( SMESHGUI::GetSMESHGUI()->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { - QAD_WaitCursor wc; - + if (SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow(mySMESHGUI)) { + SUIT_OverrideCursor wc; + myActor->RemoveAllClippingPlanes(); SMESH::TPlanes::iterator anIter = myPlanes.begin(); - for (;anIter != myPlanes.end();anIter++){ - OrientedPlane* anOrientedPlane = OrientedPlane::New(); + for (; anIter != myPlanes.end(); anIter++) { + OrientedPlane* anOrientedPlane = OrientedPlane::New(aViewWindow); anOrientedPlane->ShallowCopy(anIter->GetPointer()); myActor->AddClippingPlane(anOrientedPlane); anOrientedPlane->Delete(); } - SMESH::RenderViewFrame(SMESH::GetCurrentVtkView()); + SMESH::RenderViewWindow(aViewWindow); } } - //======================================================================= // function : ClickOnOk() // purpose : //======================================================================= void SMESHGUI_ClippingDlg::ClickOnOk() { - ClickOnApply() ; - ClickOnCancel() ; + ClickOnApply(); + ClickOnCancel(); } - //======================================================================= // function : ClickOnCancel() // purpose : @@ -426,26 +428,26 @@ void SMESHGUI_ClippingDlg::ClickOnCancel() close(); } - //================================================================================= // function : onSelectionChanged() // purpose : Called when selection is changed //================================================================================= void SMESHGUI_ClippingDlg::onSelectionChanged() { - if ( SMESHGUI::GetSMESHGUI()->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { - if ( mySelection->IObjectCount() ) { - Handle(SALOME_InteractiveObject) IOS = mySelection->firstIObject(); + if (SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow(mySMESHGUI)) { + const SALOME_ListIO& aList = mySelector->StoredIObjects(); + if (aList.Extent() > 0) { + Handle(SALOME_InteractiveObject) IOS = aList.First(); myActor = SMESH::FindActorByEntry(IOS->getEntry()); - if ( myActor ){ + if (myActor) { std::for_each(myPlanes.begin(),myPlanes.end(),TSetVisiblity(false)); myPlanes.clear(); vtkIdType anId = 0, anEnd = myActor->GetNumberOfClippingPlanes(); - for(; anId < anEnd; anId++){ - if(vtkImplicitFunction* aFunction = myActor->GetClippingPlane(anId)){ + for (; anId < anEnd; anId++) { + if (vtkImplicitFunction* aFunction = myActor->GetClippingPlane(anId)) { if(OrientedPlane* aPlane = OrientedPlane::SafeDownCast(aFunction)){ - OrientedPlane* anOrientedPlane = OrientedPlane::New(SMESH::GetActiveStudy()); + OrientedPlane* anOrientedPlane = OrientedPlane::New(aViewWindow); SMESH::TVTKPlane aTVTKPlane(anOrientedPlane); anOrientedPlane->Delete(); aTVTKPlane->ShallowCopy(aPlane); @@ -458,26 +460,25 @@ void SMESHGUI_ClippingDlg::onSelectionChanged() TSetVisiblity(PreviewCheckBox->isChecked())); } } + SMESH::RenderViewWindow(aViewWindow); } Sinchronize(); - SMESH::RenderViewFrame(SMESH::GetCurrentVtkView()); } - //======================================================================= // function : onSelectPlane() // purpose : //======================================================================= -void SMESHGUI_ClippingDlg::onSelectPlane(int theIndex) -{ +void SMESHGUI_ClippingDlg::onSelectPlane (int theIndex) +{ if (!myActor || myPlanes.empty()) return; - + OrientedPlane* aPlane = myPlanes[theIndex].GetPointer(); - + // Orientation SMESH::Orientation anOrientation = aPlane->GetOrientation(); - + // Rotations double aRot[2] = {aPlane->myAngle[0], aPlane->myAngle[1]}; @@ -486,15 +487,15 @@ void SMESHGUI_ClippingDlg::onSelectPlane(int theIndex) setDistance(aPlane->GetDistance()); setRotation(aRot[0], aRot[1]); switch (anOrientation) { - case SMESH::XY: + case SMESH::XY: ComboBoxOrientation->setCurrentItem(0); onSelectOrientation(0); break; - case SMESH::YZ: + case SMESH::YZ: ComboBoxOrientation->setCurrentItem(1); onSelectOrientation(1); break; - case SMESH::ZX: + case SMESH::ZX: ComboBoxOrientation->setCurrentItem(2); onSelectOrientation(2); break; @@ -502,7 +503,6 @@ void SMESHGUI_ClippingDlg::onSelectPlane(int theIndex) myIsSelectPlane = false; } - //======================================================================= // function : ClickOnNew() // purpose : @@ -511,19 +511,20 @@ void SMESHGUI_ClippingDlg::ClickOnNew() { if (!myActor) return; - - OrientedPlane* aPlane = OrientedPlane::New(SMESH::GetActiveStudy()); - SMESH::TVTKPlane aTVTKPlane(aPlane); - myPlanes.push_back(aTVTKPlane); - if(PreviewCheckBox->isChecked()) - aTVTKPlane->myActor->VisibilityOn(); + if(SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow(mySMESHGUI)){ + OrientedPlane* aPlane = OrientedPlane::New(aViewWindow); + SMESH::TVTKPlane aTVTKPlane(aPlane); + myPlanes.push_back(aTVTKPlane); - Sinchronize(); - SetCurrentPlaneParam(); + if (PreviewCheckBox->isChecked()) + aTVTKPlane->myActor->VisibilityOn(); + + Sinchronize(); + SetCurrentPlaneParam(); + } } - //======================================================================= // function : ClickOnDelete() // purpose : @@ -532,48 +533,46 @@ void SMESHGUI_ClippingDlg::ClickOnDelete() { if (!myActor || myPlanes.empty()) return; - + int aPlaneIndex = ComboBoxPlanes->currentItem(); - + SMESH::TPlanes::iterator anIter = myPlanes.begin() + aPlaneIndex; anIter->GetPointer()->myActor->SetVisibility(false); myPlanes.erase(anIter); - + if(AutoApplyCheckBox->isChecked()) ClickOnApply(); Sinchronize(); - SMESH::RenderViewFrame(SMESH::GetCurrentVtkView()); + SMESH::RenderViewWindow(SMESH::GetCurrentVtkView()); } - //======================================================================= // function : onSelectOrientation() // purpose : //======================================================================= -void SMESHGUI_ClippingDlg::onSelectOrientation(int theItem) +void SMESHGUI_ClippingDlg::onSelectOrientation (int theItem) { if (myPlanes.empty()) return; - + if (theItem == 0) { - TextLabelRot1->setText( tr( "Rotation around X (Y to Z):") ); - TextLabelRot2->setText( tr( "Rotation around Y (X to Z):" ) ); + TextLabelRot1->setText(tr("Rotation around X (Y to Z):")); + TextLabelRot2->setText(tr("Rotation around Y (X to Z):")); } else if (theItem == 1) { - TextLabelRot1->setText( tr( "Rotation around Y (Z to X):" ) ); - TextLabelRot2->setText( tr( "Rotation around Z (Y to X):" ) ); + TextLabelRot1->setText(tr("Rotation around Y (Z to X):")); + TextLabelRot2->setText(tr("Rotation around Z (Y to X):")); } else if (theItem == 2) { - TextLabelRot1->setText( tr( "Rotation around Z (X to Y):" ) ); - TextLabelRot2->setText( tr( "Rotation around X (Z to Y):" ) ); + TextLabelRot1->setText(tr("Rotation around Z (X to Y):")); + TextLabelRot2->setText(tr("Rotation around X (Z to Y):")); } - + if((QComboBox*)sender() == ComboBoxOrientation) SetCurrentPlaneParam(); } - //======================================================================= // function : Sinchronize() // purpose : @@ -582,21 +581,21 @@ void SMESHGUI_ClippingDlg::Sinchronize() { int aNbPlanes = myPlanes.size(); ComboBoxPlanes->clear(); - + QString aName; - for(int i = 1; i<=aNbPlanes ; i++){ + for(int i = 1; i<=aNbPlanes; i++) { aName = QString(tr("Plane# %1")).arg(i); ComboBoxPlanes->insertItem(aName); } - + int aPos = ComboBoxPlanes->count() - 1; ComboBoxPlanes->setCurrentItem(aPos); - + bool anIsControlsEnable = (aPos >= 0); - if(anIsControlsEnable){ + if (anIsControlsEnable) { onSelectPlane(aPos); - }else{ - ComboBoxPlanes->insertItem( tr("No planes") ); + } else { + ComboBoxPlanes->insertItem(tr("No planes")); SpinBoxRot1->SetValue(0.0); SpinBoxRot2->SetValue(0.0); SpinBoxDistance->SetValue(0.5); @@ -612,37 +611,33 @@ void SMESHGUI_ClippingDlg::Sinchronize() SpinBoxRot2->setEnabled(anIsControlsEnable); } - //======================================================================= // function : setRotation() // purpose : //======================================================================= -void SMESHGUI_ClippingDlg::setRotation( const double theRot1, const double theRot2 ) +void SMESHGUI_ClippingDlg::setRotation (const double theRot1, const double theRot2) { SpinBoxRot1->SetValue(theRot1); SpinBoxRot2->SetValue(theRot2); } - //======================================================================= -// function : SetCurrentPlaneParam +// function : SetCurrentPlaneParam() // purpose : //======================================================================= -void -SMESHGUI_ClippingDlg:: -SetCurrentPlaneParam() +void SMESHGUI_ClippingDlg::SetCurrentPlaneParam() { - if(myPlanes.empty() || myIsSelectPlane) + if (myPlanes.empty() || myIsSelectPlane) return; - + int aCurPlaneIndex = ComboBoxPlanes->currentItem(); - + OrientedPlane* aPlane = myPlanes[aCurPlaneIndex].GetPointer(); - + float aNormal[3]; SMESH::Orientation anOrientation; float aDir[3][3] = {{0, 0, 0}, {0, 0, 0}}; - { + { static double aCoeff = vtkMath::Pi()/180.0; float aRot[2] = {getRotation1(), getRotation2()}; @@ -653,10 +648,10 @@ SetCurrentPlaneParam() float aV[2] = {sqrt(1.0-anU[0]*anU[0]), sqrt(1.0-anU[1]*anU[1])}; aV[0] = aRot[0] > 0? aV[0]: -aV[0]; aV[1] = aRot[1] > 0? aV[1]: -aV[1]; - + switch (ComboBoxOrientation->currentItem()) { - case 0: - anOrientation = SMESH::XY; + case 0: + anOrientation = SMESH::XY; aDir[0][1] = anU[0]; aDir[0][2] = aV[0]; @@ -665,8 +660,8 @@ SetCurrentPlaneParam() aDir[1][2] = aV[1]; break; - case 1: - anOrientation = SMESH::YZ; + case 1: + anOrientation = SMESH::YZ; aDir[0][2] = anU[0]; aDir[0][0] = aV[0]; @@ -675,8 +670,8 @@ SetCurrentPlaneParam() aDir[1][0] = aV[1]; break; - case 2: - anOrientation = SMESH::ZX; + case 2: + anOrientation = SMESH::ZX; aDir[0][0] = anU[0]; aDir[0][1] = aV[0]; @@ -691,10 +686,10 @@ SetCurrentPlaneParam() vtkMath::Normalize(aNormal); vtkMath::Cross(aNormal,aDir[1],aDir[0]); } - + aPlane->SetOrientation(anOrientation); aPlane->SetDistance(getDistance()); - + myActor->SetPlaneParam(aNormal, getDistance(), aPlane); vtkDataSet* aDataSet = myActor->GetInput(); @@ -707,44 +702,48 @@ SetCurrentPlaneParam() {aDir[1][0]*aDel, aDir[1][1]*aDel, aDir[1][2]*aDel}}; float aParam, aPnt0[3], aPnt1[3], aPnt2[3]; - float aPnt01[3] = {aPnt[0] - aDelta[0][0] - aDelta[1][0], - aPnt[1] - aDelta[0][1] - aDelta[1][1], + float aPnt01[3] = {aPnt[0] - aDelta[0][0] - aDelta[1][0], + aPnt[1] - aDelta[0][1] - aDelta[1][1], aPnt[2] - aDelta[0][2] - aDelta[1][2]}; - float aPnt02[3] = {aPnt01[0] + aNormal[0], - aPnt01[1] + aNormal[1], + float aPnt02[3] = {aPnt01[0] + aNormal[0], + aPnt01[1] + aNormal[1], aPnt01[2] + aNormal[2]}; vtkPlane::IntersectWithLine(aPnt01,aPnt02,aNormal,anOrigin,aParam,aPnt0); - float aPnt11[3] = {aPnt[0] - aDelta[0][0] + aDelta[1][0], - aPnt[1] - aDelta[0][1] + aDelta[1][1], + float aPnt11[3] = {aPnt[0] - aDelta[0][0] + aDelta[1][0], + aPnt[1] - aDelta[0][1] + aDelta[1][1], aPnt[2] - aDelta[0][2] + aDelta[1][2]}; - float aPnt12[3] = {aPnt11[0] + aNormal[0], - aPnt11[1] + aNormal[1], + float aPnt12[3] = {aPnt11[0] + aNormal[0], + aPnt11[1] + aNormal[1], aPnt11[2] + aNormal[2]}; vtkPlane::IntersectWithLine(aPnt11,aPnt12,aNormal,anOrigin,aParam,aPnt1); - - float aPnt21[3] = {aPnt[0] + aDelta[0][0] - aDelta[1][0], - aPnt[1] + aDelta[0][1] - aDelta[1][1], + + float aPnt21[3] = {aPnt[0] + aDelta[0][0] - aDelta[1][0], + aPnt[1] + aDelta[0][1] - aDelta[1][1], aPnt[2] + aDelta[0][2] - aDelta[1][2]}; - float aPnt22[3] = {aPnt21[0] + aNormal[0], - aPnt21[1] + aNormal[1], + float aPnt22[3] = {aPnt21[0] + aNormal[0], + aPnt21[1] + aNormal[1], aPnt21[2] + aNormal[2]}; vtkPlane::IntersectWithLine(aPnt21,aPnt22,aNormal,anOrigin,aParam,aPnt2); - + vtkPlaneSource* aPlaneSource = aPlane->myPlaneSource; aPlaneSource->SetNormal(aNormal[0],aNormal[1],aNormal[2]); aPlaneSource->SetOrigin(aPnt0[0],aPnt0[1],aPnt0[2]); aPlaneSource->SetPoint1(aPnt1[0],aPnt1[1],aPnt1[2]); aPlaneSource->SetPoint2(aPnt2[0],aPnt2[1],aPnt2[2]); - + if(AutoApplyCheckBox->isChecked()) ClickOnApply(); - - SMESH::RenderViewFrame(SMESH::GetCurrentVtkView()); + + SMESH::RenderViewWindow(SMESH::GetCurrentVtkView()); } - -void SMESHGUI_ClippingDlg::OnPreviewToggle(bool theIsToggled){ +//======================================================================= +// function : OnPreviewToggle() +// purpose : +//======================================================================= +void SMESHGUI_ClippingDlg::OnPreviewToggle (bool theIsToggled) +{ std::for_each(myPlanes.begin(),myPlanes.end(),TSetVisiblity(theIsToggled)); - SMESH::RenderViewFrame(SMESH::GetCurrentVtkView()); + SMESH::RenderViewWindow(SMESH::GetCurrentVtkView()); } diff --git a/src/SMESHGUI/SMESHGUI_ClippingDlg.h b/src/SMESHGUI/SMESHGUI_ClippingDlg.h index 6a2bb493f..288724434 100644 --- a/src/SMESHGUI/SMESHGUI_ClippingDlg.h +++ b/src/SMESHGUI/SMESHGUI_ClippingDlg.h @@ -45,18 +45,22 @@ class QPushButton; class QTable; class QCheckBox; class QComboBox; -class SALOME_Selection; + +class SalomeApp_SelectionMgr; +class SVTK_Selector; + +class SMESHGUI; class SMESH_Actor; class OrientedPlane; -namespace SMESH{ - +namespace SMESH { + typedef vtkSmartPointer TVTKPlane; typedef std::vector TPlanes; enum Orientation {XY, YZ, ZX}; - + }; @@ -65,30 +69,32 @@ namespace SMESH{ // purpose : //================================================================================= class SMESHGUI_ClippingDlg : public QDialog -{ +{ Q_OBJECT public: - SMESHGUI_ClippingDlg( QWidget* parent = 0, + SMESHGUI_ClippingDlg (SMESHGUI* theModule, const char* name = 0, bool modal = false, - WFlags fl = 0 ); + WFlags fl = 0); + + float getDistance() { return (float)SpinBoxDistance->GetValue(); } + void setDistance (const float theDistance) { SpinBoxDistance->SetValue(theDistance); } + double getRotation1() { return SpinBoxRot1->GetValue(); } + double getRotation2() { return SpinBoxRot2->GetValue(); } + void setRotation (const double theRot1, const double theRot2); + void Sinchronize(); - float getDistance() {return (float)SpinBoxDistance->GetValue();} - void setDistance( const float theDistance) {SpinBoxDistance->SetValue(theDistance);} - double getRotation1() {return SpinBoxRot1->GetValue();} - double getRotation2() {return SpinBoxRot2->GetValue();} - void setRotation( const double theRot1, const double theRot2 ); - void Sinchronize(); - ~SMESHGUI_ClippingDlg(); private: - SALOME_Selection* mySelection; - SMESH_Actor* myActor; - SMESH::TPlanes myPlanes; - + SalomeApp_SelectionMgr* mySelectionMgr; + SVTK_Selector* mySelector; + SMESHGUI* mySMESHGUI; + SMESH_Actor* myActor; + SMESH::TPlanes myPlanes; + QComboBox* ComboBoxPlanes; QPushButton* buttonNew; QPushButton* buttonDelete; @@ -107,20 +113,19 @@ private: QPushButton* buttonApply; bool myIsSelectPlane; - + public slots: - - void onSelectPlane(int theIndex); + + void onSelectPlane (int theIndex); void ClickOnNew(); void ClickOnDelete(); - void onSelectOrientation(int theItem); + void onSelectOrientation (int theItem); void SetCurrentPlaneParam(); void onSelectionChanged(); - void OnPreviewToggle(bool theIsToggled); + void OnPreviewToggle (bool theIsToggled); void ClickOnOk(); void ClickOnCancel(); void ClickOnApply(); }; #endif // DIALOGBOX_TRANSPARENCYDLG_H - diff --git a/src/SMESHGUI/SMESHGUI_CreateHypothesesDlg.cxx b/src/SMESHGUI/SMESHGUI_CreateHypothesesDlg.cxx index 19d6b90fa..5e3e4b090 100644 --- a/src/SMESHGUI/SMESHGUI_CreateHypothesesDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_CreateHypothesesDlg.cxx @@ -1,21 +1,21 @@ // SMESH SMESHGUI : GUI for SMESH component // // Copyright (C) 2003 CEA -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// // See http://www.salome-platform.org or email : webmaster.salome@opencascade.org // // @@ -25,6 +25,20 @@ // Module : SMESH // $Header$ +#include "SMESHGUI_CreateHypothesesDlg.h" + +#include "SMESHGUI_HypothesesUtils.h" +#include "SMESHGUI_Hypotheses.h" +#include "SMESHGUI_Utils.h" +#include "SMESHGUI.h" + +#include "SUIT_Desktop.h" +#include "SUIT_ResourceMgr.h" + +#include "SALOME_ListIteratorOfListIO.hxx" + +#include "utilities.h" + // QT Includes #include #include @@ -33,98 +47,85 @@ #include #include -#include "QAD_Application.h" -#include "QAD_Desktop.h" - -#include "SALOME_ListIteratorOfListIO.hxx" - -#include "SMESHGUI_CreateHypothesesDlg.h" -#include "SMESHGUI_HypothesesUtils.h" -#include "SMESHGUI_Hypotheses.h" -#include "SMESHGUI_Utils.h" -#include "SMESHGUI.h" - -#include "utilities.h" - using namespace std; //================================================================================= -// class : SMESHGUI_CreateHypothesesDlg() -// purpose : Constructs a SMESHGUI_CreateHypothesesDlg which is a child of 'parent', with the +// function : SMESHGUI_CreateHypothesesDlg() +// purpose : Constructs a SMESHGUI_CreateHypothesesDlg which is a child of 'parent', with the // name 'name' and widget flags set to 'f'. // The dialog will by default be modeless, unless you set 'modal' to // TRUE to construct a modal dialog. //================================================================================= -SMESHGUI_CreateHypothesesDlg::SMESHGUI_CreateHypothesesDlg (QWidget* parent, +SMESHGUI_CreateHypothesesDlg::SMESHGUI_CreateHypothesesDlg (SMESHGUI* theModule, const char* name, bool modal, bool isAlgo) - : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose ), - myIsAlgo( isAlgo ) + : QDialog( SMESH::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder | + WStyle_Title | WStyle_SysMenu | WDestructiveClose), + myIsAlgo(isAlgo), + mySMESHGUI( theModule ) { - MESSAGE("SMESHGUI_CreateHypothesesDlg"); + if (!name) + setName("SMESHGUI_CreateHypothesesDlg"); + setCaption(isAlgo ? tr("SMESH_CREATE_ALGORITHMS" ) : tr("SMESH_CREATE_HYPOTHESES" )); + setSizeGripEnabled(TRUE); - if ( !name ) - setName( "SMESHGUI_CreateHypothesesDlg" ); - setCaption( isAlgo ? tr( "SMESH_CREATE_ALGORITHMS" ) : tr( "SMESH_CREATE_HYPOTHESES" ) ); - setSizeGripEnabled( TRUE ); - - QGridLayout* SMESHGUI_CreateHypothesesDlgLayout = new QGridLayout( this ); - SMESHGUI_CreateHypothesesDlgLayout->setSpacing( 6 ); - SMESHGUI_CreateHypothesesDlgLayout->setMargin( 11 ); + QGridLayout* SMESHGUI_CreateHypothesesDlgLayout = new QGridLayout(this); + SMESHGUI_CreateHypothesesDlgLayout->setSpacing(6); + SMESHGUI_CreateHypothesesDlgLayout->setMargin(11); /***************************************************************/ - GroupAlgorithms = new QGroupBox( this, "GroupAlgorithms" ); - GroupAlgorithms->setTitle( isAlgo ? tr("SMESH_AVAILABLE_ALGORITHMS") : tr("SMESH_AVAILABLE_HYPOTHESES") ); - GroupAlgorithms->setColumnLayout(0, Qt::Vertical ); - GroupAlgorithms->layout()->setSpacing( 0 ); - GroupAlgorithms->layout()->setMargin( 0 ); + GroupAlgorithms = new QGroupBox(this, "GroupAlgorithms"); + GroupAlgorithms->setTitle(isAlgo ? tr("SMESH_AVAILABLE_ALGORITHMS") : tr("SMESH_AVAILABLE_HYPOTHESES")); + GroupAlgorithms->setColumnLayout(0, Qt::Vertical); + GroupAlgorithms->layout()->setSpacing(0); + GroupAlgorithms->layout()->setMargin(0); - QGridLayout* hypLayout = new QGridLayout( GroupAlgorithms->layout() ); - hypLayout->setGeometry( QRect( 12, 18, 139, 250 ) ); - hypLayout->setAlignment( Qt::AlignTop ); - hypLayout->setSpacing( 6 ); - hypLayout->setMargin( 11 ); + QGridLayout* hypLayout = new QGridLayout(GroupAlgorithms->layout()); + hypLayout->setGeometry(QRect(12, 18, 139, 250)); + hypLayout->setAlignment(Qt::AlignTop); + hypLayout->setSpacing(6); + hypLayout->setMargin(11); - ListAlgoDefinition = new QListView( GroupAlgorithms, "ListAlgoDefinition" ); - ListAlgoDefinition->setMinimumSize( 400, 200 ); + ListAlgoDefinition = new QListView(GroupAlgorithms, "ListAlgoDefinition"); + ListAlgoDefinition->setMinimumSize(400, 200); ListAlgoDefinition->addColumn(""); ListAlgoDefinition->header()->hide(); ListAlgoDefinition->setSelectionMode(QListView::Single); ListAlgoDefinition->setResizeMode(QListView::AllColumns); - ListAlgoDefinition->setRootIsDecorated( true ); + ListAlgoDefinition->setRootIsDecorated(true); - hypLayout->addWidget( ListAlgoDefinition, 0, 0 ); - SMESHGUI_CreateHypothesesDlgLayout->addWidget( GroupAlgorithms, 0, 0 ); + hypLayout->addWidget(ListAlgoDefinition, 0, 0); + SMESHGUI_CreateHypothesesDlgLayout->addWidget(GroupAlgorithms, 0, 0); /***************************************************************/ - GroupButtons = new QGroupBox( this, "GroupButtons" ); - GroupButtons->setColumnLayout( 0, Qt::Vertical ); - GroupButtons->layout()->setSpacing( 0 ); - GroupButtons->layout()->setMargin( 0 ); - QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); - GroupButtonsLayout->setAlignment( Qt::AlignTop ); - GroupButtonsLayout->setSpacing( 6 ); - GroupButtonsLayout->setMargin( 11 ); + GroupButtons = new QGroupBox(this, "GroupButtons"); + GroupButtons->setColumnLayout(0, Qt::Vertical); + GroupButtons->layout()->setSpacing(0); + GroupButtons->layout()->setMargin(0); + QGridLayout* GroupButtonsLayout = new QGridLayout(GroupButtons->layout()); + GroupButtonsLayout->setAlignment(Qt::AlignTop); + GroupButtonsLayout->setSpacing(6); + GroupButtonsLayout->setMargin(11); - buttonApply = new QPushButton( GroupButtons, "buttonApply" ); - buttonApply->setText( tr( "SMESH_BUT_CREATE" ) ); - buttonApply->setAutoDefault( TRUE ); - buttonApply->setDefault( FALSE ); - buttonApply->setEnabled( FALSE ) ; - GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); + buttonApply = new QPushButton(GroupButtons, "buttonApply"); + buttonApply->setText(tr("SMESH_BUT_CREATE" )); + buttonApply->setAutoDefault(TRUE); + buttonApply->setDefault(FALSE); + buttonApply->setEnabled(FALSE); + GroupButtonsLayout->addWidget(buttonApply, 0, 1); - QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); - GroupButtonsLayout->addItem( spacer_9, 0, 2 ); + QSpacerItem* spacer_9 = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); + GroupButtonsLayout->addItem(spacer_9, 0, 2); - buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); - buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) ); - buttonCancel->setAutoDefault( TRUE ); - buttonCancel->setDefault( TRUE ); - buttonCancel->setEnabled( TRUE ) ; - GroupButtonsLayout->addWidget( buttonCancel, 0, 3 ); + buttonCancel = new QPushButton(GroupButtons, "buttonCancel"); + buttonCancel->setText(tr("SMESH_BUT_CLOSE" )); + buttonCancel->setAutoDefault(TRUE); + buttonCancel->setDefault(TRUE); + buttonCancel->setEnabled(TRUE); + GroupButtonsLayout->addWidget(buttonCancel, 0, 3); - SMESHGUI_CreateHypothesesDlgLayout->addWidget( GroupButtons, 1, 0 ); + SMESHGUI_CreateHypothesesDlgLayout->addWidget(GroupButtons, 1, 0); /***************************************************************/ Init(); @@ -136,7 +137,7 @@ SMESHGUI_CreateHypothesesDlg::SMESHGUI_CreateHypothesesDlg (QWidget* parent, //================================================================================= SMESHGUI_CreateHypothesesDlg::~SMESHGUI_CreateHypothesesDlg() { - // no need to delete child widgets, Qt does it all for us + // no need to delete child widgets, Qt does it all for us } //================================================================================= @@ -145,25 +146,24 @@ SMESHGUI_CreateHypothesesDlg::~SMESHGUI_CreateHypothesesDlg() //================================================================================= void SMESHGUI_CreateHypothesesDlg::Init() { - mySMESHGUI = SMESHGUI::GetSMESHGUI() ; - mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; + mySMESHGUI->SetActiveDialogBox((QDialog*)this); InitAlgoDefinition(); /* signals and slots connections */ - connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ; - connect( buttonApply , SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) ) ; + connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel())); + connect(buttonApply , SIGNAL(clicked()), this, SLOT(ClickOnApply())); -// connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; - connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; - - connect( ListAlgoDefinition, SIGNAL( selectionChanged() ), this, SLOT( onSelectionChanged() ) ); - connect( ListAlgoDefinition, SIGNAL( doubleClicked(QListViewItem*) ), this, SLOT( onDoubleClicked(QListViewItem*) ) ); +// connect(mySMESHGUI, SIGNAL (SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog())); + connect(mySMESHGUI, SIGNAL (SignalCloseAllDialogs()), this, SLOT(ClickOnCancel())); - int x, y ; - mySMESHGUI->DefineDlgPosition( this, x, y ) ; - this->move( x, y ) ; - this->show() ; + connect(ListAlgoDefinition, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged())); + connect(ListAlgoDefinition, SIGNAL(doubleClicked(QListViewItem*)), this, SLOT(onDoubleClicked(QListViewItem*))); + + int x, y; + mySMESHGUI->DefineDlgPosition(this, x, y); + this->move(x, y); + this->show(); } //================================================================================= @@ -172,7 +172,7 @@ void SMESHGUI_CreateHypothesesDlg::Init() //================================================================================= void SMESHGUI_CreateHypothesesDlg::ClickOnCancel() { - close() ; + close(); } //================================================================================= @@ -181,29 +181,26 @@ void SMESHGUI_CreateHypothesesDlg::ClickOnCancel() //================================================================================= void SMESHGUI_CreateHypothesesDlg::ClickOnApply() { - if (mySMESHGUI->ActiveStudyLocked()) + if (mySMESHGUI->isActiveStudyLocked()) return; QListViewItem* item = ListAlgoDefinition->selectedItem(); - if ( !item ) + if (!item) return; - QString aHypType = item->text( 1 ); + QString aHypType = item->text(1); MESSAGE("Apply " << aHypType); char* sHypType = (char*)aHypType.latin1(); HypothesisData* aHypData = SMESH::GetHypothesisData(sHypType); - if ( !aHypData ) + if (!aHypData) return; QString aClientLibName = aHypData->ClientLibName; MESSAGE("Client lib name = " << aClientLibName); - if (aClientLibName == "") - { + if (aClientLibName == "") { // Call hypothesis creation server method (without GUI) QString aHypName = aHypData->Label; SMESH::CreateHypothesis(sHypType, aHypName, myIsAlgo); - } - else - { + } else { // Get hypotheses creator client (GUI) SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(sHypType); @@ -222,29 +219,29 @@ void SMESHGUI_CreateHypothesesDlg::ClickOnApply() //================================================================================= void SMESHGUI_CreateHypothesesDlg::ActivateThisDialog() { - mySMESHGUI->EmitSignalDeactivateDialog() ; - GroupButtons->setEnabled(true) ; - return ; + mySMESHGUI->EmitSignalDeactivateDialog(); + GroupButtons->setEnabled(true); + return; } //================================================================================= // function : enterEvent() // purpose : //================================================================================= -void SMESHGUI_CreateHypothesesDlg::enterEvent(QEvent* e) +void SMESHGUI_CreateHypothesesDlg::enterEvent (QEvent*) { - ActivateThisDialog() ; - return ; + ActivateThisDialog(); + return; } //================================================================================= // function : closeEvent() // purpose : //================================================================================= -void SMESHGUI_CreateHypothesesDlg::closeEvent( QCloseEvent* e ) +void SMESHGUI_CreateHypothesesDlg::closeEvent (QCloseEvent* e) { mySMESHGUI->ResetState(); - QDialog::closeEvent( e ); + QDialog::closeEvent(e); } //================================================================================= @@ -254,16 +251,16 @@ void SMESHGUI_CreateHypothesesDlg::closeEvent( QCloseEvent* e ) void SMESHGUI_CreateHypothesesDlg::onSelectionChanged() { QListViewItem* item = ListAlgoDefinition->selectedItem(); - buttonApply->setEnabled( item && item->depth() > 0 ) ; + buttonApply->setEnabled(item && item->depth() > 0); } //================================================================================= // function : onDoubleClicked() // purpose : //================================================================================= -void SMESHGUI_CreateHypothesesDlg::onDoubleClicked(QListViewItem* i) +void SMESHGUI_CreateHypothesesDlg::onDoubleClicked (QListViewItem* i) { - if ( i && i->depth() > 0 ) + if (i && i->depth() > 0) this->ClickOnApply(); } @@ -275,24 +272,23 @@ void SMESHGUI_CreateHypothesesDlg::InitAlgoDefinition() { ListAlgoDefinition->clear(); QStringList HypList = SMESH::GetAvailableHypotheses(myIsAlgo); - for ( int i = 0; i < HypList.count(); ++i ) { - HypothesisData* aHypData = SMESH::GetHypothesisData( HypList[i] ); + for (int i = 0; i < HypList.count(); ++i) { + HypothesisData* aHypData = SMESH::GetHypothesisData(HypList[i]); QListViewItem* parentItem = 0; QListViewItem* childItem = ListAlgoDefinition->firstChild(); - while ( childItem ) { - if ( childItem->text(0) == aHypData->PluginName ) { + while (childItem) { + if (childItem->text(0) == aHypData->PluginName) { parentItem = childItem; break; } childItem = childItem->nextSibling(); } - if ( !parentItem ) - parentItem = new QListViewItem( ListAlgoDefinition, aHypData->PluginName ); - parentItem->setOpen( true ); - QListViewItem* aItem = new QListViewItem( parentItem, aHypData->Label, HypList[i] ); - QPixmap aPixMap (QAD_Desktop::getResourceManager()->loadPixmap - ("SMESH", tr(aHypData->IconId))); - if ( !aPixMap.isNull() ) - aItem->setPixmap( 0, aPixMap ); + if (!parentItem) + parentItem = new QListViewItem(ListAlgoDefinition, aHypData->PluginName); + parentItem->setOpen(true); + QListViewItem* aItem = new QListViewItem(parentItem, aHypData->Label, HypList[i]); + QPixmap aPixMap (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr(aHypData->IconId))); + if (!aPixMap.isNull()) + aItem->setPixmap(0, aPixMap); } } diff --git a/src/SMESHGUI/SMESHGUI_CreateHypothesesDlg.h b/src/SMESHGUI/SMESHGUI_CreateHypothesesDlg.h index e3ee5a9ce..e2bb65a67 100644 --- a/src/SMESHGUI/SMESHGUI_CreateHypothesesDlg.h +++ b/src/SMESHGUI/SMESHGUI_CreateHypothesesDlg.h @@ -57,7 +57,7 @@ class SMESHGUI_CreateHypothesesDlg : public QDialog Q_OBJECT public: - SMESHGUI_CreateHypothesesDlg (QWidget* parent = 0, + SMESHGUI_CreateHypothesesDlg (SMESHGUI*, const char* name = 0, bool modal = FALSE, bool isAlgo = FALSE); diff --git a/src/SMESHGUI/SMESHGUI_CreatePatternDlg.cxx b/src/SMESHGUI/SMESHGUI_CreatePatternDlg.cxx index fd903bbc6..a7990a79a 100755 --- a/src/SMESHGUI/SMESHGUI_CreatePatternDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_CreatePatternDlg.cxx @@ -1,797 +1,715 @@ -// SMESH SMESHGUI : GUI for SMESH component -// -// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -// -// -// -// File : SMESHGUI_CreatePatternDlg.cxx -// Author : Sergey LITONIN -// Module : SMESH - -#include "SMESHGUI_CreatePatternDlg.h" - -#include "QAD_Desktop.h" -#include "QAD_FileDlg.h" - -#include "SMESHGUI_PatternWidget.h" -#include "SMESHGUI_SpinBox.h" -#include "SMESHGUI.h" -#include "SALOME_Selection.h" -#include "SALOME_ListIteratorOfListOfFilter.hxx" -#include "SALOMEGUI_QtCatchCorbaException.hxx" -#include "SMESH_NumberFilter.hxx" -#include "SMESHGUI_Utils.h" -#include "SMESHGUI_VTKUtils.h" -#include "SMESHGUI_PatternUtils.h" - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define SPACING 5 -#define MARGIN 10 - -/* - Class : SMESHGUI_CreatePatternDlg - Description : Dialog to specify filters for VTK viewer -*/ - -//======================================================================= -// name : SMESHGUI_CreatePatternDlg::SMESHGUI_CreatePatternDlg -// Purpose : Constructor -//======================================================================= -SMESHGUI_CreatePatternDlg::SMESHGUI_CreatePatternDlg( QWidget* theParent, - SALOME_Selection* theSelection, - const int theType, - const char* theName ) -: QDialog( theParent, theName, false, - WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) -{ - setCaption( tr( "CAPTION" ) ); - - QVBoxLayout* aDlgLay = new QVBoxLayout( this, MARGIN, SPACING ); - - QFrame* aMainFrame = createMainFrame ( this ); - QFrame* aBtnFrame = createButtonFrame( this ); - - aDlgLay->addWidget( aMainFrame ); - aDlgLay->addWidget( aBtnFrame ); - - aDlgLay->setStretchFactor( aMainFrame, 1 ); - - Init( theSelection, theType ); -} - -//======================================================================= -// name : SMESHGUI_CreatePatternDlg::createMainFrame -// Purpose : Create frame containing dialog's input fields -//======================================================================= -QFrame* SMESHGUI_CreatePatternDlg::createMainFrame( QWidget* theParent ) -{ - QPixmap iconSlct( QAD_Desktop::getResourceManager()->loadPixmap( "SMESH", tr( "ICON_SELECT" ) ) ); - QPixmap icon2d ( QAD_Desktop::getResourceManager()->loadPixmap( "SMESH", tr( "ICON_PATTERN_2d" ) ) ); - QPixmap icon3d ( QAD_Desktop::getResourceManager()->loadPixmap( "SMESH", tr( "ICON_PATTERN_3d" ) ) ); - - QPixmap iconSample2d( QAD_Desktop::getResourceManager()->loadPixmap( "SMESH", tr( "ICON_PATTERN_SAMPLE_2D" ) ) ); - - QGroupBox* aMainGrp = new QGroupBox( 1, Qt::Horizontal, theParent ); - aMainGrp->setFrameStyle( QFrame::NoFrame ); - aMainGrp->setInsideMargin( 0 ); - - // Pattern type group - - myTypeGrp = new QButtonGroup( 1, Qt::Vertical, tr( "PATTERN_TYPE" ), aMainGrp ); - mySwitch2d = new QRadioButton( myTypeGrp ); - mySwitch3d = new QRadioButton( myTypeGrp ); - mySwitch2d->setPixmap( icon2d ); - mySwitch3d->setPixmap( icon3d ); - myTypeGrp->insert( mySwitch2d, Type_2d ); - myTypeGrp->insert( mySwitch3d, Type_3d ); - - QGroupBox* aPatternGrp = new QGroupBox( 1, Qt::Horizontal, tr( "PATTERN" ), aMainGrp ); - - // Mesh and pattern name group - - QGroupBox* aMeshGrp = new QGroupBox( 1, Qt::Vertical, aPatternGrp ); - aMeshGrp->setFrameStyle( QFrame::NoFrame ); - aMeshGrp->setInsideMargin( 0 ); - - new QLabel( tr( "MESH_OR_SUBMESH" ), aMeshGrp ); - - QPushButton* aSelBtn = new QPushButton( aMeshGrp ); - aSelBtn->setPixmap( iconSlct ); - myMeshEdit = new QLineEdit( aMeshGrp ); - myMeshEdit->setReadOnly( true ); - - QGroupBox* aPattGrp = new QGroupBox( 1, Qt::Vertical, aPatternGrp ); - aPattGrp->setFrameStyle( QFrame::NoFrame ); - aPattGrp->setInsideMargin( 0 ); - - new QLabel( tr( "PATTERN_NAME" ), aPattGrp ); - myName = new QLineEdit( aPattGrp ); - - // Picture 2d - - myPicture2d = new SMESHGUI_PatternWidget( aPatternGrp ), - myPicture2d->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); - - // Project check box - - myProjectChk = new QCheckBox( tr( "PROJECT" ), aPatternGrp ); - - // Connect signals and slots - - connect( myTypeGrp, SIGNAL( clicked( int ) ), SLOT( onTypeChanged( int ) ) ); - connect( myProjectChk, SIGNAL( toggled( bool ) ), SLOT( onProject( bool ) ) ); - connect( aSelBtn, SIGNAL( clicked() ), SLOT( onSelBtnClicked() ) ); - - return aMainGrp; -} - -//======================================================================= -// name : SMESHGUI_CreatePatternDlg::createButtonFrame -// Purpose : Create frame containing buttons -//======================================================================= -QFrame* SMESHGUI_CreatePatternDlg::createButtonFrame( QWidget* theParent ) -{ - QFrame* aFrame = new QFrame( theParent ); - aFrame->setFrameStyle( QFrame::Box | QFrame::Sunken ); - - myOkBtn = new QPushButton( tr( "SMESH_BUT_OK" ), aFrame ); - mySaveBtn = new QPushButton( tr( "SAVE" ), aFrame ); - myCloseBtn = new QPushButton( tr( "SMESH_BUT_CANCEL" ), aFrame ); - - QSpacerItem* aSpacer = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum ); - - QHBoxLayout* aLay = new QHBoxLayout( aFrame, MARGIN, SPACING ); - - aLay->addWidget( myOkBtn ); - aLay->addWidget( mySaveBtn ); - aLay->addItem( aSpacer); - aLay->addWidget( myCloseBtn ); - - connect( myOkBtn, SIGNAL( clicked() ), SLOT( onOk() ) ); - connect( myCloseBtn, SIGNAL( clicked() ), SLOT( onClose() ) ) ; - connect( mySaveBtn, SIGNAL( clicked() ), SLOT( onSave() ) ); - - return aFrame; -} - -//======================================================================= -// name : SMESHGUI_CreatePatternDlg::~SMESHGUI_CreatePatternDlg -// Purpose : Destructor -//======================================================================= -SMESHGUI_CreatePatternDlg::~SMESHGUI_CreatePatternDlg() -{ -} - -//======================================================================= -// name : SMESHGUI_CreatePatternDlg::onProject -// Purpose : SLOT. Called when state of "Project nodes on ther face" -// checkbox is changed -//======================================================================= -void SMESHGUI_CreatePatternDlg::onProject( bool ) -{ - loadFromObject( false ); - displayPreview(); -} - -//======================================================================= -// name : SMESHGUI_CreatePatternDlg::Init -// Purpose : Init dialog fields, connect signals and slots, show dialog -//======================================================================= -void SMESHGUI_CreatePatternDlg::Init( SALOME_Selection* theSelection, const int theType ) -{ - myIsLoaded = false; - myType = -1; - myNbPoints = -1; - mySelection = theSelection; - mySubMesh = SMESH::SMESH_subMesh::_nil(); - myMesh = SMESH::SMESH_Mesh::_nil(); - myGeomObj = GEOM::GEOM_Object::_nil(); - myPattern = SMESH::SMESH_Pattern::_nil(); - - erasePreview(); - - SMESHGUI* aSMESHGUI = SMESHGUI::GetSMESHGUI(); - aSMESHGUI->SetActiveDialogBox( ( QDialog* )this ); - - // selection and SMESHGUI - connect( mySelection, SIGNAL( currentSelectionChanged() ), SLOT( onSelectionDone() ) ); - connect( aSMESHGUI, SIGNAL( SignalDeactivateActiveDialog() ), SLOT( onDeactivate() ) ); - connect( aSMESHGUI, SIGNAL( SignalCloseAllDialogs() ), SLOT( onClose() ) ); - - mySwitch2d->setEnabled( theType == Type_2d ); - mySwitch3d->setEnabled( theType == Type_3d ); - - if ( theType == Type_2d ) - myProjectChk->show(); - else - myProjectChk->hide(); - - myTypeGrp->setButton( theType ); - onTypeChanged( theType ); - - myName->setText( getDefaultName() ); - myMeshEdit->setText( "" ); - - setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding ) ); - qApp->processEvents(); - updateGeometry(); - myPicture2d->updateGeometry(); - adjustSize(); - resize( minimumSize() ); - - activateSelection(); - onSelectionDone(); - - int x, y ; - aSMESHGUI->DefineDlgPosition( this, x, y ); - this->move( x, y ); - this->show(); -} - -//======================================================================= -// name : SMESHGUI_CreatePatternDlg::SetMesh -// Purpose : Set mesh to dialog -//======================================================================= -void SMESHGUI_CreatePatternDlg::SetMesh( SMESH::SMESH_Mesh_ptr thePtr ) -{ - myMesh = SMESH::SMESH_Mesh::_duplicate( thePtr ); - mySubMesh = SMESH::SMESH_subMesh::_nil(); - - bool isValidMesh = false; - if ( !myMesh->_is_nil() ) - { - SALOMEDS::SObject_var aSobj = SMESH::FindSObject( thePtr ); - CORBA::String_var anEntry = aSobj->GetID(); - Handle(SALOME_InteractiveObject) anIObj = - new SALOME_InteractiveObject( anEntry.in(), "SMESH" ); - - const SALOME_ListOfFilter& aList = mySelection->StoredFilters(); - SALOME_ListIteratorOfListOfFilter anIter( aList ); - for ( ; anIter.More(); anIter.Next() ) - if ( !anIter.Value()->IsOk( anIObj ) ) - break; - - if ( !anIter.More() ) - isValidMesh = true; - } - - - if ( isValidMesh ) - { - SALOMEDS::SObject_var aSO = SMESH::FindSObject( myMesh.in() ); - myMeshEdit->setText( aSO->GetName() ); - myGeomObj = getGeom( aSO ); - } - else - { - myMeshEdit->setText( "" ); - myGeomObj = GEOM::GEOM_Object::_nil(); - } - - if ( myType == Type_2d ) - { - loadFromObject( false ); - displayPreview(); - } -} - -//======================================================================= -// name : SMESHGUI_CreatePatternDlg::isValid -// Purpose : Verify validity of entry data -//======================================================================= -bool SMESHGUI_CreatePatternDlg::isValid() -{ - if ( myGeomObj->_is_nil() ) - { - QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), - tr( "SMESH_INSUFFICIENT_DATA" ), tr( "SMESHGUI_INVALID_PARAMETERS" ), QMessageBox::Ok ); - return false; - } - else - return true; -} - - - -//======================================================================= -// name : SMESHGUI_CreatePatternDlg::getDefaultName -// Purpose : Get default pattern name -//======================================================================= -QString SMESHGUI_CreatePatternDlg::getDefaultName() const -{ - return myType == Type_2d ? tr( "DEFAULT_2D" ) : tr( "DEFAULT_3D" ); -} - -//======================================================================= -// name : SMESHGUI_CreatePatternDlg::onSave -// Purpose : SLOT called when "Save" button pressed. Build pattern and - -// save it to disk -//======================================================================= -void SMESHGUI_CreatePatternDlg::onSave() -{ - try - { - if ( !isValid() ) - return; - - if ( !myIsLoaded ) - loadFromObject( true ); - - // Load pattern from object - if ( !myIsLoaded ) - return; - - /////////////////////////////////////////////////////// - QAD_FileDlg* aDlg = new QAD_FileDlg( this, false ); - aDlg->setCaption( tr( "SAVE_PATTERN" ) ); - aDlg->setMode( QFileDialogP::AnyFile ); - aDlg->setFilters( tr( "PATTERN_FILT" ) ); - if ( myName->text() != "" ) - aDlg->setSelection( myName->text() ); - - if ( aDlg->exec() != Accepted ) - return; - - QString fName = aDlg->selectedFile(); - if ( fName.isEmpty() ) - return; - - if ( QFileInfo( fName ).extension().isEmpty() ) - fName = autoExtension( fName ); - - fName = QDir::convertSeparators( fName ); - - QString aData( myPattern->GetString() ); - long aLen = aData.length(); - - QFile aFile( fName ); - aFile.open( IO_WriteOnly ); - long aWritten = aFile.writeBlock( aData, aLen ); - aFile.close(); - - if ( aWritten != aLen ) - { - QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), - tr( "SMESH_ERROR" ), tr( "ERROR_OF_SAVING" ), QMessageBox::Ok ); - } - else - { - QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); - disconnect( mySelection, 0, this, 0 ); - disconnect( SMESHGUI::GetSMESHGUI(), 0, this, 0 ); - SMESHGUI::GetSMESHGUI()->ResetState(); - accept(); - emit NewPattern(); - } - } - catch( const SALOME::SALOME_Exception& S_ex ) - { - QtCatchCorbaException( S_ex ); - } - catch( ... ) - { - } -} - -//======================================================================= -// name : SMESHGUI_CreatePatternDlg::GetPatternName -// Purpose : Get name of pattern -//======================================================================= -QString SMESHGUI_CreatePatternDlg::GetPatternName() const -{ - return myName->text(); -} - -//======================================================================= -// name : SMESHGUI_CreatePatternDlg::GetPattern -// Purpose : Get result pattern -//======================================================================= -SMESH::SMESH_Pattern_ptr SMESHGUI_CreatePatternDlg::GetPattern() -{ - return myPattern.in(); -} - -//======================================================================= -// name : SMESHGUI_CreatePatternDlg::onOk -// Purpose : SLOT called when "Ok" button pressed. -//======================================================================= -void SMESHGUI_CreatePatternDlg::onOk() -{ - try - { - if ( !isValid() ) - return; - - if ( !myIsLoaded ) - loadFromObject( true ); - - // Load pattern from object - if ( !myIsLoaded ) - return; - else - { - QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); - disconnect( mySelection, 0, this, 0 ); - disconnect( SMESHGUI::GetSMESHGUI(), 0, this, 0 ); - SMESHGUI::GetSMESHGUI()->ResetState(); - accept(); - emit NewPattern(); - } - } - catch( const SALOME::SALOME_Exception& S_ex ) - { - QtCatchCorbaException( S_ex ); - } - catch( ... ) - { - } -} - -//======================================================================= -// name : SMESHGUI_CreatePatternDlg::onClose -// Purpose : SLOT called when "Close" button pressed. Close dialog -//======================================================================= -void SMESHGUI_CreatePatternDlg::onClose() -{ - QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); - disconnect( mySelection, 0, this, 0 ); - disconnect( SMESHGUI::GetSMESHGUI(), 0, this, 0 ); - SMESHGUI::GetSMESHGUI()->ResetState(); - reject(); - emit Close(); -} - -//======================================================================= -// name : SMESHGUI_CreatePatternDlg::loadFromObject -// Purpose : Load pattern from geom object corresponding to the mesh/submesh -//======================================================================= -bool SMESHGUI_CreatePatternDlg::loadFromObject( const bool theMess ) -{ - try - { - myIsLoaded = false; - - if ( myPattern->_is_nil() ) - myPattern = SMESH::GetPattern(); - - if ( myMesh->_is_nil() && mySubMesh->_is_nil() || myGeomObj->_is_nil() ) - return false; - - SMESH::SMESH_Mesh_ptr aMesh = mySubMesh->_is_nil() ? myMesh.in() : mySubMesh->GetFather(); - - myIsLoaded = myType == Type_2d - ? myPattern->LoadFromFace( aMesh, myGeomObj, myProjectChk->isChecked() ) - : myPattern->LoadFrom3DBlock( aMesh, myGeomObj ); - - if ( !myIsLoaded && theMess ) - { - QString aMess; - SMESH::SMESH_Pattern::ErrorCode aCode = myPattern->GetErrorCode(); - - if ( aCode == SMESH::SMESH_Pattern::ERR_LOAD_EMPTY_SUBMESH ) aMess = tr( "ERR_LOAD_EMPTY_SUBMESH" ); - else if ( aCode == SMESH::SMESH_Pattern::ERR_LOADF_NARROW_FACE ) aMess = tr( "ERR_LOADF_NARROW_FACE" ); - else if ( aCode == SMESH::SMESH_Pattern::ERR_LOADF_CLOSED_FACE ) aMess = tr( "ERR_LOADF_CLOSED_FACE" ); - else if ( aCode == SMESH::SMESH_Pattern::ERR_LOADV_BAD_SHAPE ) aMess = tr( "ERR_LOADV_BAD_SHAPE" ); - else if ( aCode == SMESH::SMESH_Pattern::ERR_LOADV_COMPUTE_PARAMS ) aMess = tr( "ERR_LOADV_COMPUTE_PARAMS" ); - else aMess = tr( "ERROR_OF_CREATION" ); - - QMessageBox::information( - SMESHGUI::GetSMESHGUI()->GetDesktop(), tr( "SMESH_ERROR" ), aMess, QMessageBox::Ok ); - } - - } - catch( const SALOME::SALOME_Exception& S_ex ) - { - QtCatchCorbaException( S_ex ); - } - - return myIsLoaded; -} - -//======================================================================= -// name : SMESHGUI_CreatePatternDlg::getGeom -// Purpose : Retrieve geom object from SObject -//======================================================================= -GEOM::GEOM_Object_ptr SMESHGUI_CreatePatternDlg::getGeom( SALOMEDS::SObject_ptr theSO ) -{ - if ( theSO->_is_nil() ) - return GEOM::GEOM_Object::_nil(); - - SALOMEDS::Study_var aStudy = - SMESHGUI::GetSMESHGUI()->GetActiveStudy()->getStudyDocument(); - - SALOMEDS::ChildIterator_var anIter = aStudy->NewChildIterator( theSO ); - for( ; anIter->More(); anIter->Next() ) - { - SALOMEDS::SObject_var aSO = anIter->Value(); - SALOMEDS::SObject_var aRefSO; - - GEOM::GEOM_Object_var aMeshShape = GEOM::GEOM_Object::_narrow( - aSO->ReferencedObject( aRefSO )? aRefSO->GetObject() : aSO->GetObject() ); - - if ( !aMeshShape->_is_nil() ) - return aMeshShape._retn(); - } - return GEOM::GEOM_Object::_nil(); -} - -//======================================================================= -// name : SMESHGUI_CreatePatternDlg::onSelectionDone -// Purpose : SLOT called when selection changed -//======================================================================= -void SMESHGUI_CreatePatternDlg::onSelectionDone() -{ - try - { - if ( mySelection->IObjectCount() != 1 ) - return; - - // Get mesh or sub-mesh from selection - Handle(SALOME_InteractiveObject) anIO = mySelection->firstIObject(); - SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface( anIO ); - SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface( anIO ); - if ( aMesh->_is_nil() && aSubMesh->_is_nil() ) - return; - - // Get geom object corresponding to the mesh - SALOMEDS::SObject_var aSO; - if ( !aMesh->_is_nil() ) - aSO = SMESH::FindSObject( aMesh.in() ); - else - aSO = SMESH::FindSObject( aSubMesh.in() ); - - - GEOM::GEOM_Object_var aGeomObj = getGeom( aSO ); - if ( aGeomObj->_is_nil() ) - return; - - myGeomObj = aGeomObj; - - // init class fields - if ( !aMesh->_is_nil() ) - { - myMesh = aMesh; - mySubMesh = SMESH::SMESH_subMesh::_nil(); - } - else - { - mySubMesh = aSubMesh; - myMesh = SMESH::SMESH_Mesh::_nil(); - } - - QString aName; - SMESH::GetNameOfSelectedIObjects( mySelection, aName ); - myMeshEdit->setText( aName ); - - if ( myType == Type_2d ) - { - loadFromObject( true ); - displayPreview(); - } - } - catch( ... ) - { - myMesh = SMESH::SMESH_Mesh::_nil(); - mySubMesh = SMESH::SMESH_subMesh::_nil(); - myGeomObj = GEOM::GEOM_Object::_nil(); - erasePreview(); - } -} - -//======================================================================= -// name : SMESHGUI_CreatePatternDlg::onDeactivate -// Purpose : SLOT called when dialog must be deativated -//======================================================================= -void SMESHGUI_CreatePatternDlg::onDeactivate() -{ - disconnect( mySelection, 0, this, 0 ); - setEnabled( false ); -} - -//======================================================================= -// name : SMESHGUI_CreatePatternDlg::enterEvent -// Purpose : Event filter -//======================================================================= -void SMESHGUI_CreatePatternDlg::enterEvent( QEvent* ) -{ - SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog(); - setEnabled( true ); - activateSelection(); - connect( mySelection, SIGNAL( currentSelectionChanged() ), SLOT( onSelectionDone() ) ); -} - - -//================================================================================= -// function : closeEvent() -// purpose : Close dialog box -//================================================================================= -void SMESHGUI_CreatePatternDlg::closeEvent( QCloseEvent* e ) -{ - onClose() ; -} - -//======================================================================= -// name : SMESHGUI_CreatePatternDlg::onSelBtnClicked -// Purpose : SLOT. Called when -> button clicked. -//======================================================================= -void SMESHGUI_CreatePatternDlg::onSelBtnClicked() -{ - onSelectionDone(); -} - -//================================================================ -// Function : SMESHGUI_CreatePatternDlg::autoExtension -// Purpose : Append extension to the file name -//================================================================ -QString SMESHGUI_CreatePatternDlg::autoExtension( const QString& theFileName ) const -{ - QString anExt = theFileName.section( '.', -1 ); - return anExt != "smp" && anExt != "SMP" ? theFileName + ".smp" : theFileName; -} - -//======================================================================= -// name : SMESHGUI_CreatePatternDlg::displayPreview -// Purpose : Display preview -//======================================================================= -void SMESHGUI_CreatePatternDlg::displayPreview() -{ - - // Redisplay preview in dialog - - try - { - if ( !myIsLoaded ) - erasePreview(); - else - { - SMESH::point_array_var pnts = myPattern->GetPoints(); - SMESH::long_array_var keyPoints = myPattern->GetKeyPoints(); - SMESH::array_of_long_array_var elemPoints = myPattern->GetElementPoints(false); - - if ( pnts->length() == 0 || - keyPoints->length() == 0 || - elemPoints->length() == 0 ) - { - myIsLoaded = false; - erasePreview(); - return; - } - - PointVector aPoints( pnts->length() ); - QValueVector aKeyPoints( keyPoints->length() ); - ConnectivityVector anElemPoints( elemPoints->length() ); - - for ( int i = 0, n = pnts->length(); i < n; i++ ) - aPoints[ i ] = pnts[ i ]; - - for ( int i2 = 0, n2 = keyPoints->length(); i2 < n2; i2++ ) - aKeyPoints[ i2 ] = keyPoints[ i2 ]; - - for ( int i3 = 0, n3 = elemPoints->length(); i3 < n3; i3++ ) - { - QValueVector aVec( elemPoints[ i3 ].length() ); - for ( int i4 = 0, n4 = elemPoints[ i3 ].length(); i4 < n4; i4++ ) - aVec[ i4 ] = elemPoints[ i3 ][ i4 ]; - - anElemPoints[ i3 ] = aVec; - } - - myPicture2d->SetPoints( aPoints, aKeyPoints, anElemPoints ); - } - - return; - } - catch( const SALOME::SALOME_Exception& S_ex ) - { - QtCatchCorbaException( S_ex ); - } - catch( ... ) - { - } - erasePreview(); -} - -//======================================================================= -// name : SMESHGUI_CreatePatternDlg::erasePreview -// Purpose : Erase preview -//======================================================================= -void SMESHGUI_CreatePatternDlg::erasePreview() - -{ - // Erase preview in 2D viewer - myPicture2d->SetPoints( PointVector(), QValueVector(), ConnectivityVector() ); -} - -//======================================================================= -// name : SMESHGUI_CreatePatternDlg::activateSelection -// Purpose : Activate selection in accordance with current pattern type -//======================================================================= -void SMESHGUI_CreatePatternDlg::activateSelection() -{ - mySelection->ClearFilters(); - QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); - - if ( myType == Type_2d ) - { - mySelection->AddFilter( - new SMESH_NumberFilter( "SMESH", TopAbs_SHAPE, -1, TopAbs_FACE ) ); - } - else - { - TColStd_MapOfInteger aTypes; - aTypes.Add( TopAbs_SHELL ); - aTypes.Add( TopAbs_SOLID ); - mySelection->AddFilter( new SMESH_NumberFilter( - "SMESH", TopAbs_FACE, 6, aTypes, GEOM::GEOM_Object::_nil(), true ) ); - } -} - -//======================================================================= -// name : SMESHGUI_CreatePatternDlg::onTypeChanged -// Purpose : SLOT. Called when pattern type changed. -// Change dialog's look and feel -//======================================================================= -void SMESHGUI_CreatePatternDlg::onTypeChanged( int theType ) -{ - if ( myType == theType ) - return; - - myType = theType; - - if ( theType == Type_2d ) - myPicture2d->show(); - else - myPicture2d->hide(); -} - - - - - - - - - - - - - - - - - - - - - +// SMESH SMESHGUI : GUI for SMESH component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESHGUI_CreatePatternDlg.cxx +// Author : Sergey LITONIN +// Module : SMESH + +#include "SMESHGUI_CreatePatternDlg.h" + +#include "SMESHGUI.h" +#include "SMESHGUI_SpinBox.h" +#include "SMESHGUI_PatternWidget.h" +#include "SMESHGUI_Utils.h" +#include "SMESHGUI_VTKUtils.h" +#include "SMESHGUI_PatternUtils.h" +#include "SMESHGUI_GEOMGenUtils.h" + +#include "SMESH_NumberFilter.hxx" + +#include "SUIT_ResourceMgr.h" +#include "SUIT_Desktop.h" +#include "SUIT_FileDlg.h" + +#include "SalomeApp_Study.h" +#include "SalomeApp_DataOwner.h" +#include "SalomeApp_SelectionMgr.h" +#include "SalomeApp_Tools.h" + +#include "SALOMEDS_SObject.hxx" + +#include "SALOME_ListIO.hxx" +#include "SVTK_ViewModel.h" +#include "SVTK_ViewWindow.h" +#include "SVTK_Selector.h" +#include "SVTK_Selection.h" + +// OCCT Includes +#include + +// QT Includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define SPACING 5 +#define MARGIN 10 + +/*! + * Class : SMESHGUI_CreatePatternDlg + * Description : Dialog to specify filters for VTK viewer + */ + +//======================================================================= +// function : SMESHGUI_CreatePatternDlg() +// purpose : Constructor +//======================================================================= +SMESHGUI_CreatePatternDlg::SMESHGUI_CreatePatternDlg( SMESHGUI* theModule, + const int theType, + const char* theName) + : QDialog( SMESH::GetDesktop( theModule ), theName, false, + WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu), + mySMESHGUI( theModule ), + mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ), + myViewWindow( SMESH::GetViewWindow( theModule ) ), + mySelector( myViewWindow->GetSelector() ) +{ + setCaption(tr("CAPTION")); + + QVBoxLayout* aDlgLay = new QVBoxLayout (this, MARGIN, SPACING); + + QFrame* aMainFrame = createMainFrame (this); + QFrame* aBtnFrame = createButtonFrame(this); + + aDlgLay->addWidget(aMainFrame); + aDlgLay->addWidget(aBtnFrame); + + aDlgLay->setStretchFactor(aMainFrame, 1); + + Init(theType); +} + +//======================================================================= +// function : createMainFrame() +// purpose : Create frame containing dialog's input fields +//======================================================================= +QFrame* SMESHGUI_CreatePatternDlg::createMainFrame (QWidget* theParent) +{ + QPixmap iconSlct (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT"))); + QPixmap icon2d (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_PATTERN_2d"))); + QPixmap icon3d (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_PATTERN_3d"))); + QPixmap iconSample2d (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_PATTERN_SAMPLE_2D"))); + + QGroupBox* aMainGrp = new QGroupBox(1, Qt::Horizontal, theParent); + aMainGrp->setFrameStyle(QFrame::NoFrame); + aMainGrp->setInsideMargin(0); + + // Pattern type group + + myTypeGrp = new QButtonGroup (1, Qt::Vertical, tr("PATTERN_TYPE"), aMainGrp); + mySwitch2d = new QRadioButton (myTypeGrp); + mySwitch3d = new QRadioButton (myTypeGrp); + mySwitch2d->setPixmap(icon2d); + mySwitch3d->setPixmap(icon3d); + myTypeGrp->insert(mySwitch2d, Type_2d); + myTypeGrp->insert(mySwitch3d, Type_3d); + + QGroupBox* aPatternGrp = new QGroupBox(1, Qt::Horizontal, tr("PATTERN"), aMainGrp); + + // Mesh and pattern name group + + QGroupBox* aMeshGrp = new QGroupBox(1, Qt::Vertical, aPatternGrp); + aMeshGrp->setFrameStyle(QFrame::NoFrame); + aMeshGrp->setInsideMargin(0); + + new QLabel(tr("MESH_OR_SUBMESH"), aMeshGrp); + + QPushButton* aSelBtn = new QPushButton(aMeshGrp); + aSelBtn->setPixmap(iconSlct); + myMeshEdit = new QLineEdit(aMeshGrp); + myMeshEdit->setReadOnly(true); + + QGroupBox* aPattGrp = new QGroupBox(1, Qt::Vertical, aPatternGrp); + aPattGrp->setFrameStyle(QFrame::NoFrame); + aPattGrp->setInsideMargin(0); + + new QLabel(tr("PATTERN_NAME"), aPattGrp); + myName = new QLineEdit(aPattGrp); + + // Picture 2d + + myPicture2d = new SMESHGUI_PatternWidget(aPatternGrp), + myPicture2d->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); + + // Project check box + + myProjectChk = new QCheckBox(tr("PROJECT"), aPatternGrp); + + // Connect signals and slots + + connect(myTypeGrp, SIGNAL(clicked(int) ), SLOT(onTypeChanged(int))); + connect(myProjectChk, SIGNAL(toggled(bool)), SLOT(onProject(bool) )); + connect(aSelBtn, SIGNAL(clicked() ), SLOT(onSelBtnClicked())); + + return aMainGrp; +} + +//======================================================================= +// function : createButtonFrame() +// purpose : Create frame containing buttons +//======================================================================= +QFrame* SMESHGUI_CreatePatternDlg::createButtonFrame (QWidget* theParent) +{ + QFrame* aFrame = new QFrame(theParent); + aFrame->setFrameStyle(QFrame::Box | QFrame::Sunken); + + myOkBtn = new QPushButton(tr("SMESH_BUT_OK" ), aFrame); + mySaveBtn = new QPushButton(tr("SAVE" ), aFrame); + myCloseBtn = new QPushButton(tr("SMESH_BUT_CANCEL"), aFrame); + + QSpacerItem* aSpacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum); + + QHBoxLayout* aLay = new QHBoxLayout(aFrame, MARGIN, SPACING); + + aLay->addWidget(myOkBtn); + aLay->addWidget(mySaveBtn); + aLay->addItem(aSpacer); + aLay->addWidget(myCloseBtn); + + connect(myOkBtn, SIGNAL(clicked()), SLOT(onOk())); + connect(myCloseBtn, SIGNAL(clicked()), SLOT(onClose())); + connect(mySaveBtn, SIGNAL(clicked()), SLOT(onSave())); + + return aFrame; +} + +//======================================================================= +// function : ~SMESHGUI_CreatePatternDlg() +// purpose : Destructor +//======================================================================= +SMESHGUI_CreatePatternDlg::~SMESHGUI_CreatePatternDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + +//======================================================================= +// function : onProject() +// purpose : SLOT. Called when state of "Project nodes on ther face" +// checkbox is changed +//======================================================================= +void SMESHGUI_CreatePatternDlg::onProject (bool) +{ + loadFromObject(false); + displayPreview(); +} + +//======================================================================= +// function : Init() +// purpose : Init dialog fields, connect signals and slots, show dialog +//======================================================================= +void SMESHGUI_CreatePatternDlg::Init( const int theType ) +{ + myIsLoaded = false; + myType = -1; + myNbPoints = -1; + mySubMesh = SMESH::SMESH_subMesh::_nil(); + myMesh = SMESH::SMESH_Mesh::_nil(); + myGeomObj = GEOM::GEOM_Object::_nil(); + myPattern = SMESH::SMESH_Pattern::_nil(); + + erasePreview(); + + mySMESHGUI->SetActiveDialogBox((QDialog*)this); + + // selection and SMESHGUI + connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(onSelectionDone())); + connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), SLOT(onDeactivate())); + connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), SLOT(onClose())); + + mySwitch2d->setEnabled(theType == Type_2d); + mySwitch3d->setEnabled(theType == Type_3d); + + if (theType == Type_2d) + myProjectChk->show(); + else + myProjectChk->hide(); + + myTypeGrp->setButton(theType); + onTypeChanged(theType); + + myName->setText(getDefaultName()); + myMeshEdit->setText(""); + + setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); + qApp->processEvents(); + updateGeometry(); + myPicture2d->updateGeometry(); + adjustSize(); + resize(minimumSize()); + + activateSelection(); + onSelectionDone(); + + int x, y; + mySMESHGUI->DefineDlgPosition(this, x, y); + this->move(x, y); + this->show(); +} + +//======================================================================= +// function : SetMesh() +// purpose : Set mesh to dialog +//======================================================================= +void SMESHGUI_CreatePatternDlg::SetMesh (SMESH::SMESH_Mesh_ptr thePtr) +{ + myMesh = SMESH::SMESH_Mesh::_duplicate(thePtr); + mySubMesh = SMESH::SMESH_subMesh::_nil(); + + bool isValidMesh = false; + if (!myMesh->_is_nil()) + { + _PTR(SObject) aSobj = SMESH::FindSObject(myMesh.in()); + //Handle(SALOME_InteractiveObject) anIObj = + // new SALOME_InteractiveObject(aSobj->GetID().c_str(), "SMESH"); + SUIT_DataOwnerPtr anIObj (new SalomeApp_DataOwner(aSobj->GetID().c_str())); + + isValidMesh = mySelectionMgr->isOk(anIObj); + } + + if (isValidMesh) { + _PTR(SObject) aSO = SMESH::FindSObject(myMesh.in()); + myMeshEdit->setText(aSO->GetName().c_str()); + myGeomObj = SMESH::GetGeom(aSO); + } else { + myMeshEdit->setText(""); + myGeomObj = GEOM::GEOM_Object::_nil(); + } + + if (myType == Type_2d) { + loadFromObject(false); + displayPreview(); + } +} + +//======================================================================= +// function : isValid() +// purpose : Verify validity of entry data +//======================================================================= +bool SMESHGUI_CreatePatternDlg::isValid() +{ + if (myGeomObj->_is_nil()) { + QMessageBox::information(SMESH::GetDesktop( mySMESHGUI ), + tr("SMESH_INSUFFICIENT_DATA"), + tr("SMESHGUI_INVALID_PARAMETERS"), + QMessageBox::Ok); + return false; + } + else + return true; +} + +//======================================================================= +// function : getDefaultName() +// purpose : Get default pattern name +//======================================================================= +QString SMESHGUI_CreatePatternDlg::getDefaultName() const +{ + return myType == Type_2d ? tr("DEFAULT_2D") : tr("DEFAULT_3D"); +} + +//======================================================================= +// function : onSave() +// purpose : SLOT called when "Save" button pressed. Build pattern and +// save it to disk +//======================================================================= +void SMESHGUI_CreatePatternDlg::onSave() +{ + try { + if (!isValid()) + return; + + if (!myIsLoaded) + loadFromObject(true); + + // Load pattern from object + if (!myIsLoaded) + return; + + /////////////////////////////////////////////////////// + SUIT_FileDlg* aDlg = new SUIT_FileDlg (this, false); + aDlg->setCaption(tr("SAVE_PATTERN")); + aDlg->setMode(QFileDialog::AnyFile); + aDlg->setFilters(tr("PATTERN_FILT")); + if (myName->text() != "") + aDlg->setSelection(myName->text()); + + if (aDlg->exec() != Accepted) + return; + + QString fName = aDlg->selectedFile(); + if (fName.isEmpty()) + return; + + if (QFileInfo(fName).extension().isEmpty()) + fName = autoExtension(fName); + + fName = QDir::convertSeparators(fName); + + QString aData (myPattern->GetString()); + long aLen = aData.length(); + + QFile aFile (fName); + aFile.open(IO_WriteOnly); + long aWritten = aFile.writeBlock(aData, aLen); + aFile.close(); + + if (aWritten != aLen) { + QMessageBox::information(SMESH::GetDesktop( mySMESHGUI ), tr("SMESH_ERROR"), + tr("ERROR_OF_SAVING"), QMessageBox::Ok); + } else { + //SUIT_Application::getDesktop()->setSelectionModes(ActorSelection); + myViewWindow->SetSelectionMode(ActorSelection); + disconnect(mySelectionMgr, 0, this, 0); + disconnect(mySMESHGUI, 0, this, 0); + mySMESHGUI->ResetState(); + accept(); + emit NewPattern(); + } + } catch (const SALOME::SALOME_Exception& S_ex) { + SalomeApp_Tools::QtCatchCorbaException(S_ex); + } catch (...) { + } +} + +//======================================================================= +// function : GetPatternName() +// purpose : Get name of pattern +//======================================================================= +QString SMESHGUI_CreatePatternDlg::GetPatternName() const +{ + return myName->text(); +} + +//======================================================================= +// function : GetPattern() +// purpose : Get result pattern +//======================================================================= +SMESH::SMESH_Pattern_ptr SMESHGUI_CreatePatternDlg::GetPattern() +{ + return myPattern.in(); +} + +//======================================================================= +// function : onOk() +// purpose : SLOT called when "Ok" button pressed. +//======================================================================= +void SMESHGUI_CreatePatternDlg::onOk() +{ + try { + if (!isValid()) + return; + + if (!myIsLoaded) + loadFromObject(true); + + // Load pattern from object + if (!myIsLoaded) { + return; + } else { + //SUIT_Application::getDesktop()->setSelectionModes(ActorSelection); + myViewWindow->SetSelectionMode(ActorSelection); + disconnect(mySelectionMgr, 0, this, 0); + disconnect(mySMESHGUI, 0, this, 0); + mySMESHGUI->ResetState(); + accept(); + emit NewPattern(); + } + } catch (const SALOME::SALOME_Exception& S_ex) { + SalomeApp_Tools::QtCatchCorbaException(S_ex); + } catch (...) { + } +} + +//======================================================================= +// function : onClose() +// purpose : SLOT called when "Close" button pressed. Close dialog +//======================================================================= +void SMESHGUI_CreatePatternDlg::onClose() +{ + myViewWindow->SetSelectionMode(ActorSelection); + disconnect(mySelectionMgr, 0, this, 0); + disconnect(mySMESHGUI, 0, this, 0); + mySMESHGUI->ResetState(); + reject(); + emit Close(); +} + +//======================================================================= +// function : loadFromObject() +// purpose : Load pattern from geom object corresponding to the mesh/submesh +//======================================================================= +bool SMESHGUI_CreatePatternDlg::loadFromObject (const bool theMess) +{ + try { + myIsLoaded = false; + + if (myPattern->_is_nil()) + myPattern = SMESH::GetPattern(); + + if (myMesh->_is_nil() && mySubMesh->_is_nil() || myGeomObj->_is_nil()) + return false; + + SMESH::SMESH_Mesh_ptr aMesh = mySubMesh->_is_nil() ? myMesh.in() : mySubMesh->GetFather(); + + myIsLoaded = myType == Type_2d + ? myPattern->LoadFromFace(aMesh, myGeomObj, myProjectChk->isChecked()) + : myPattern->LoadFrom3DBlock(aMesh, myGeomObj); + + if (!myIsLoaded && theMess) { + QString aMess; + SMESH::SMESH_Pattern::ErrorCode aCode = myPattern->GetErrorCode(); + + if (aCode == SMESH::SMESH_Pattern::ERR_LOAD_EMPTY_SUBMESH ) aMess = tr("ERR_LOAD_EMPTY_SUBMESH"); + else if (aCode == SMESH::SMESH_Pattern::ERR_LOADF_NARROW_FACE ) aMess = tr("ERR_LOADF_NARROW_FACE"); + else if (aCode == SMESH::SMESH_Pattern::ERR_LOADF_CLOSED_FACE ) aMess = tr("ERR_LOADF_CLOSED_FACE"); + else if (aCode == SMESH::SMESH_Pattern::ERR_LOADV_BAD_SHAPE ) aMess = tr("ERR_LOADV_BAD_SHAPE"); + else if (aCode == SMESH::SMESH_Pattern::ERR_LOADV_COMPUTE_PARAMS) aMess = tr("ERR_LOADV_COMPUTE_PARAMS"); + else aMess = tr("ERROR_OF_CREATION"); + + QMessageBox::information(SMESH::GetDesktop( mySMESHGUI ), + tr("SMESH_ERROR"), aMess, QMessageBox::Ok); + } + } catch (const SALOME::SALOME_Exception& S_ex) { + SalomeApp_Tools::QtCatchCorbaException(S_ex); + } + + return myIsLoaded; +} + +//======================================================================= +// function : onSelectionDone() +// purpose : SLOT called when selection changed +//======================================================================= +void SMESHGUI_CreatePatternDlg::onSelectionDone() +{ + try { + SALOME_ListIO aList; + mySelectionMgr->selectedObjects(aList, SVTK_Viewer::Type()); + if (aList.Extent() != 1) + return; + + // Get mesh or sub-mesh from selection + Handle(SALOME_InteractiveObject) anIO = aList.First(); + SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface(anIO); + SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface(anIO); + if (aMesh->_is_nil() && aSubMesh->_is_nil()) + return; + + // Get geom object corresponding to the mesh + _PTR(SObject) aSO; + if (!aMesh->_is_nil()) + aSO = SMESH::FindSObject(aMesh.in()); + else + aSO = SMESH::FindSObject(aSubMesh.in()); + + GEOM::GEOM_Object_var aGeomObj = SMESH::GetGeom(aSO); + if (aGeomObj->_is_nil()) + return; + + myGeomObj = aGeomObj; + + // init class fields + if (!aMesh->_is_nil()) { + myMesh = aMesh; + mySubMesh = SMESH::SMESH_subMesh::_nil(); + } else { + mySubMesh = aSubMesh; + myMesh = SMESH::SMESH_Mesh::_nil(); + } + + QString aName; + SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aName); + myMeshEdit->setText(aName); + + if (myType == Type_2d) { + loadFromObject(true); + displayPreview(); + } + } catch (...) { + myMesh = SMESH::SMESH_Mesh::_nil(); + mySubMesh = SMESH::SMESH_subMesh::_nil(); + myGeomObj = GEOM::GEOM_Object::_nil(); + erasePreview(); + } +} + +//======================================================================= +// function : onDeactivate() +// purpose : SLOT called when dialog must be deativated +//======================================================================= +void SMESHGUI_CreatePatternDlg::onDeactivate() +{ + disconnect(mySelectionMgr, 0, this, 0); + setEnabled(false); +} + +//======================================================================= +// function : enterEvent() +// purpose : Event filter +//======================================================================= +void SMESHGUI_CreatePatternDlg::enterEvent (QEvent*) +{ + mySMESHGUI->EmitSignalDeactivateDialog(); + setEnabled(true); + activateSelection(); + connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(onSelectionDone())); +} + +//================================================================================= +// function : closeEvent() +// purpose : Close dialog box +//================================================================================= +void SMESHGUI_CreatePatternDlg::closeEvent (QCloseEvent*) +{ + onClose(); +} + +//======================================================================= +// function : onSelBtnClicked() +// purpose : SLOT. Called when -> button clicked. +//======================================================================= +void SMESHGUI_CreatePatternDlg::onSelBtnClicked() +{ + onSelectionDone(); +} + +//================================================================ +// function : autoExtension() +// purpose : Append extension to the file name +//================================================================ +QString SMESHGUI_CreatePatternDlg::autoExtension (const QString& theFileName) const +{ + QString anExt = theFileName.section('.', -1); + return anExt != "smp" && anExt != "SMP" ? theFileName + ".smp" : theFileName; +} + +//======================================================================= +// function : displayPreview() +// purpose : Display preview +//======================================================================= +void SMESHGUI_CreatePatternDlg::displayPreview() +{ + // Redisplay preview in dialog + try { + if (!myIsLoaded) { + erasePreview(); + } else { + SMESH::point_array_var pnts = myPattern->GetPoints(); + SMESH::long_array_var keyPoints = myPattern->GetKeyPoints(); + SMESH::array_of_long_array_var elemPoints = myPattern->GetElementPoints(false); + + if (pnts->length() == 0 || + keyPoints->length() == 0 || + elemPoints->length() == 0) { + myIsLoaded = false; + erasePreview(); + return; + } + + PointVector aPoints (pnts->length()); + QValueVector aKeyPoints (keyPoints->length()); + ConnectivityVector anElemPoints (elemPoints->length()); + + for (int i = 0, n = pnts->length(); i < n; i++) + aPoints[ i ] = pnts[ i ]; + + for (int i2 = 0, n2 = keyPoints->length(); i2 < n2; i2++) + aKeyPoints[ i2 ] = keyPoints[ i2 ]; + + for (int i3 = 0, n3 = elemPoints->length(); i3 < n3; i3++) { + QValueVector aVec (elemPoints[ i3 ].length()); + for (int i4 = 0, n4 = elemPoints[ i3 ].length(); i4 < n4; i4++) + aVec[ i4 ] = elemPoints[ i3 ][ i4 ]; + + anElemPoints[ i3 ] = aVec; + } + + myPicture2d->SetPoints(aPoints, aKeyPoints, anElemPoints); + } + + return; + + } catch (const SALOME::SALOME_Exception& S_ex) { + SalomeApp_Tools::QtCatchCorbaException(S_ex); + } catch (...) { + } + erasePreview(); +} + +//======================================================================= +// function : erasePreview() +// purpose : Erase preview +//======================================================================= +void SMESHGUI_CreatePatternDlg::erasePreview() +{ + // Erase preview in 2D viewer + myPicture2d->SetPoints(PointVector(), QValueVector(), ConnectivityVector()); +} + +//======================================================================= +// function : activateSelection() +// purpose : Activate selection in accordance with current pattern type +//======================================================================= +void SMESHGUI_CreatePatternDlg::activateSelection() +{ + mySelectionMgr->clearFilters(); + //SUIT_Application::getDesktop()->setSelectionModes(ActorSelection); + myViewWindow->SetSelectionMode(ActorSelection); + + if (myType == Type_2d) { + mySelectionMgr->installFilter(new SMESH_NumberFilter + ("SMESH", TopAbs_SHAPE, -1, TopAbs_FACE)); + } else { + TColStd_MapOfInteger aTypes; + aTypes.Add(TopAbs_SHELL); + aTypes.Add(TopAbs_SOLID); + mySelectionMgr->installFilter(new SMESH_NumberFilter + ("SMESH", TopAbs_FACE, 6, aTypes, GEOM::GEOM_Object::_nil(), true)); + } +} + +//======================================================================= +// function : onTypeChanged() +// purpose : SLOT. Called when pattern type changed. +// Change dialog's look and feel +//======================================================================= +void SMESHGUI_CreatePatternDlg::onTypeChanged (int theType) +{ + if (myType == theType) + return; + + myType = theType; + + if (theType == Type_2d) + myPicture2d->show(); + else + myPicture2d->hide(); +} diff --git a/src/SMESHGUI/SMESHGUI_CreatePatternDlg.h b/src/SMESHGUI/SMESHGUI_CreatePatternDlg.h index 40fbfe1b7..d0ff40e63 100755 --- a/src/SMESHGUI/SMESHGUI_CreatePatternDlg.h +++ b/src/SMESHGUI/SMESHGUI_CreatePatternDlg.h @@ -1,158 +1,147 @@ -// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -// -// -// -// File : SMESHGUI_CreatePatternDlg.h -// Author : Sergey LITONIN -// Module : SMESH - - -#ifndef SMESHGUI_CreatePatternDlg_H -#define SMESHGUI_CreatePatternDlg_H - -#include - -// IDL Headers -#include -#include CORBA_SERVER_HEADER(GEOM_Gen) -#include CORBA_SERVER_HEADER(SMESH_Mesh) -#include CORBA_SERVER_HEADER(SMESH_Pattern) - -class SMESHGUI_PatternWidget; -class QCloseEvent; -class QFrame; -class QLineEdit; -class SMESHGUI_SpinBox; -class QPushButton; -class SALOME_Selection; -class QRadioButton; -class QCheckBox; -class QButtonGroup; -class QLabel; - -/* - Class : SMESHGUI_CreatePatternDlg - Description : Dialog to specify filters for VTK viewer -*/ - -class SMESHGUI_CreatePatternDlg : public QDialog -{ - Q_OBJECT - -public: - - enum { Type_2d, Type_3d }; - -public: - SMESHGUI_CreatePatternDlg( QWidget*, - SALOME_Selection*, - const int, - const char* = 0 ); - virtual ~SMESHGUI_CreatePatternDlg(); - - void Init( SALOME_Selection*, const int ); - QString GetPatternName() const; - SMESH::SMESH_Pattern_ptr GetPattern(); - void SetMesh( SMESH::SMESH_Mesh_ptr ); - -signals: - - void NewPattern(); - void Close(); - -private: - - void closeEvent( QCloseEvent* e ) ; - void enterEvent ( QEvent * ) ; - -private slots: - - void onOk(); - void onSave(); - void onClose(); - - void onDeactivate(); - - void onSelectionDone(); - void onTypeChanged( int ); - void onProject( bool ); - void onSelBtnClicked(); - -private: - - QFrame* createButtonFrame( QWidget* ); - QFrame* createMainFrame ( QWidget* ); - void displayPreview(); - void erasePreview(); - void activateSelection(); - QString autoExtension( const QString& theFileName ) const; - bool isValid(); - bool loadFromObject( const bool = true ); - QString getDefaultName() const; - GEOM::GEOM_Object_ptr getGeom( SALOMEDS::SObject_ptr ); - -private: - - QPushButton* myOkBtn; - QPushButton* mySaveBtn; - QPushButton* myCloseBtn; - - QButtonGroup* myTypeGrp; - QRadioButton* mySwitch2d; - QRadioButton* mySwitch3d; - QRadioButton* mySwitchSMESH_Pattern3d; - - QLineEdit* myMeshEdit; - QLineEdit* myName; - - SMESHGUI_PatternWidget* myPicture2d; - - QCheckBox* myProjectChk; - - SALOME_Selection* mySelection; - int myNbPoints; - int myType; - - SMESH::SMESH_Mesh_var myMesh; - SMESH::SMESH_subMesh_var mySubMesh; - GEOM::GEOM_Object_var myGeomObj; - - SMESH::SMESH_Pattern_var myPattern; - bool myIsLoaded; -}; - -#endif - - - - - - - - - - - - - - - - - +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESHGUI_CreatePatternDlg.h +// Author : Sergey LITONIN +// Module : SMESH + + +#ifndef SMESHGUI_CreatePatternDlg_H +#define SMESHGUI_CreatePatternDlg_H + +#include + +// IDL Headers +#include +#include CORBA_SERVER_HEADER(GEOM_Gen) +#include CORBA_SERVER_HEADER(SMESH_Mesh) +#include CORBA_SERVER_HEADER(SMESH_Pattern) + +class SMESHGUI_PatternWidget; +class SALOMEDSClient_SObject; + +class QCloseEvent; +class QFrame; +class QLineEdit; +class SMESHGUI_SpinBox; +class QPushButton; +class SalomeApp_SelectionMgr; +class QRadioButton; +class QCheckBox; +class QButtonGroup; +class QLabel; +class SVTK_ViewWindow; +class SVTK_Selector; +class SMESHGUI; + +/*! + * Class : SMESHGUI_CreatePatternDlg + * Description : Dialog to specify filters for VTK viewer + */ + +class SMESHGUI_CreatePatternDlg : public QDialog +{ + Q_OBJECT + +public: + enum { Type_2d, Type_3d }; + +public: + SMESHGUI_CreatePatternDlg( SMESHGUI*, + const int, + const char* = 0); + virtual ~SMESHGUI_CreatePatternDlg(); + + void Init(const int); + QString GetPatternName() const; + SMESH::SMESH_Pattern_ptr GetPattern(); + void SetMesh (SMESH::SMESH_Mesh_ptr); + +signals: + + void NewPattern(); + void Close(); + +private: + + void closeEvent (QCloseEvent* e); + void enterEvent (QEvent*); + +private slots: + + void onOk(); + void onSave(); + void onClose(); + + void onDeactivate(); + + void onSelectionDone(); + void onTypeChanged (int); + void onProject (bool); + void onSelBtnClicked(); + +private: + + QFrame* createButtonFrame (QWidget*); + QFrame* createMainFrame (QWidget*); + void displayPreview(); + void erasePreview(); + void activateSelection(); + QString autoExtension (const QString& theFileName) const; + bool isValid(); + bool loadFromObject (const bool = true); + QString getDefaultName() const; + GEOM::GEOM_Object_ptr getGeom (SALOMEDSClient_SObject*) const; + +private: + + QPushButton* myOkBtn; + QPushButton* mySaveBtn; + QPushButton* myCloseBtn; + + QButtonGroup* myTypeGrp; + QRadioButton* mySwitch2d; + QRadioButton* mySwitch3d; + QRadioButton* mySwitchSMESH_Pattern3d; + + QLineEdit* myMeshEdit; + QLineEdit* myName; + + SMESHGUI_PatternWidget* myPicture2d; + + QCheckBox* myProjectChk; + + SMESHGUI* mySMESHGUI; + SVTK_ViewWindow* myViewWindow; + SVTK_Selector* mySelector; + SalomeApp_SelectionMgr* mySelectionMgr; + int myNbPoints; + int myType; + + SMESH::SMESH_Mesh_var myMesh; + SMESH::SMESH_subMesh_var mySubMesh; + GEOM::GEOM_Object_var myGeomObj; + + SMESH::SMESH_Pattern_var myPattern; + bool myIsLoaded; +}; + +#endif diff --git a/src/SMESHGUI/SMESHGUI_CreatePolyhedralVolumeDlg.cxx b/src/SMESHGUI/SMESHGUI_CreatePolyhedralVolumeDlg.cxx new file mode 100644 index 000000000..3a572c897 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_CreatePolyhedralVolumeDlg.cxx @@ -0,0 +1,1003 @@ +// SMESH SMESHGUI : GUI for SMESH component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESHGUI_CreatePolyhedralVolumeDlg.cxx +// Author : Michael ZORIN +// Module : SMESH +// $Header: + +#include "SMESHGUI_CreatePolyhedralVolumeDlg.h" + +#include "SMESHGUI.h" +#include "SMESHGUI_Utils.h" +#include "SMESHGUI_VTKUtils.h" +#include "SMESHGUI_MeshUtils.h" +#include "SMESHGUI_IdValidator.h" +#include "SMESH_ActorUtils.h" +#include "SMESHGUI_SpinBox.h" +#include "SMESH_Actor.h" +#include "SMESH_TypeFilter.hxx" +#include "SMDS_Mesh.hxx" + +#include "VTKViewer_ViewWindow.h" + +#include "SUIT_ResourceMgr.h" + +#include "SalomeApp_Application.h" +#include "SalomeApp_Study.h" +#include "SUIT_Desktop.h" +#include "SUIT_MessageBox.h" +#include "SalomeApp_SelectionMgr.h" +#include "utilities.h" + +#include "SVTK_ViewWindow.h" +#include "SVTK_Selector.h" + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +// QT Includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// IDL Headers +#include "SALOMEconfig.h" +#include CORBA_SERVER_HEADER(SMESH_Group) + +using namespace std; + +namespace SMESH{ + +class TPolySimulation{ + SVTK_ViewWindow* myViewWindow; + + SALOME_Actor *myPreviewActor; + vtkDataSetMapper* myMapper; + vtkUnstructuredGrid* myGrid; + + public: + + TPolySimulation(SalomeApp_Application* app) + { + SUIT_ViewManager* mgr = app->activeViewManager(); + myViewWindow = mgr ? dynamic_cast( mgr->getActiveView() ) : NULL; + + myGrid = vtkUnstructuredGrid::New(); + + // Create and display actor + myMapper = vtkDataSetMapper::New(); + myMapper->SetInput( myGrid ); + + myPreviewActor = SALOME_Actor::New(); + myPreviewActor->PickableOff(); + myPreviewActor->VisibilityOff(); + myPreviewActor->SetMapper( myMapper ); + + vtkProperty* aProp = vtkProperty::New(); + float anRGB[3]; + anRGB[0] = GetFloat("SMESH:SettingsFillColorRed", 0)/255.; + anRGB[1] = GetFloat("SMESH:SettingsFillColorGreen", 170)/255.; + anRGB[2] = GetFloat("SMESH:SettingsFillColorBlue", 255)/255.; + aProp->SetColor(anRGB[0],anRGB[1],anRGB[2]); + myPreviewActor->SetProperty( aProp ); + aProp->Delete(); + + vtkProperty* aBackProp = vtkProperty::New(); + anRGB[0] = GetFloat("SMESH:SettingsBackFaceColorRed", 0)/255.; + anRGB[1] = GetFloat("SMESH:SettingsBackFaceColorGreen", 0)/255.; + anRGB[2] = GetFloat("SMESH:SettingsBackFaceColorBlue", 255)/255.; + aBackProp->SetColor(anRGB[0],anRGB[1],anRGB[2]); + myPreviewActor->SetBackfaceProperty( aBackProp ); + aBackProp->Delete(); + + myViewWindow->AddActor( myPreviewActor ); + + } + + + typedef std::vector TVTKIds; + void SetPosition(SMESH_Actor* theActor, + vtkIdType theType, + const TVTKIds& theIds, + bool theReset=true) + { + vtkUnstructuredGrid *aGrid = theActor->GetUnstructuredGrid(); + myGrid->SetPoints(aGrid->GetPoints()); + + if (theReset) ResetGrid(theReset); + + vtkIdList *anIds = vtkIdList::New(); + + for (int i = 0, iEnd = theIds.size(); i < iEnd; i++) + anIds->InsertId(i,theIds[i]); + + myGrid->InsertNextCell(theType,anIds); + anIds->Delete(); + + myGrid->Modified(); + + SetVisibility(true); + } + + void ResetGrid(bool theReset=true){ + if (theReset) myGrid->Reset(); + } + + void SetVisibility(bool theVisibility){ + myPreviewActor->SetVisibility(theVisibility); + RepaintCurrentView(); + } + + + ~TPolySimulation(){ + if( myViewWindow ) + myViewWindow->RemoveActor(myPreviewActor); + + myPreviewActor->Delete(); + + myMapper->RemoveAllInputs(); + myMapper->Delete(); + + myGrid->Delete(); + } + + }; +} + +//================================================================================= +// class : SMESHGUI_CreatePolyhedralVolumeDlgDlg() +// purpose : +//================================================================================= +SMESHGUI_CreatePolyhedralVolumeDlg::SMESHGUI_CreatePolyhedralVolumeDlg( SMESHGUI* theModule, const char* name, + bool modal, WFlags fl ) + : QDialog( SMESH::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | Qt::WDestructiveClose), + mySMESHGUI( theModule ), + mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ), + myViewWindow( SMESH::GetViewWindow( theModule ) ), + mySelector( myViewWindow->GetSelector() ) +{ + QPixmap image0( SMESHGUI::resourceMgr()->loadPixmap( "SMESH",tr("ICON_SELECT"))); + + if ( !name ) + setName( "SMESHGUI_CreatePolyhedralVolumeDlg" ); + resize( 300, 185 ); + setCaption( tr( "SMESH_CREATE_POLYHEDRAL_VOLUME_TITLE" ) ); + setSizeGripEnabled( TRUE ); + SMESHGUI_CreatePolyhedralVolumeDlgLayout = new QGridLayout( this ); + SMESHGUI_CreatePolyhedralVolumeDlgLayout->setSpacing( 6 ); + SMESHGUI_CreatePolyhedralVolumeDlgLayout->setMargin( 11 ); + + /***************************************************************/ + GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); + GroupConstructors->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)0, 0, 0, GroupConstructors->sizePolicy().hasHeightForWidth() ) ); + GroupConstructors->setTitle( tr( "SMESH_ELEMENTS_TYPE" ) ); + GroupConstructors->setExclusive( TRUE ); + GroupConstructors->setColumnLayout(0, Qt::Vertical ); + GroupConstructors->layout()->setSpacing( 0 ); + GroupConstructors->layout()->setMargin( 0 ); + GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() ); + GroupConstructorsLayout->setAlignment( Qt::AlignTop ); + GroupConstructorsLayout->setSpacing( 6 ); + GroupConstructorsLayout->setMargin( 11 ); + RadioButton1= new QRadioButton( GroupConstructors, "RadioButton1" ); + RadioButton1->setText( tr( "MESH_NODE" ) ); + GroupConstructorsLayout->addWidget( RadioButton1, 0, 0 ); + RadioButton2= new QRadioButton( GroupConstructors, "RadioButton2" ); + RadioButton2->setText( tr( "SMESH_FACE" ) ); + GroupConstructorsLayout->addWidget( RadioButton2, 0, 2 ); + SMESHGUI_CreatePolyhedralVolumeDlgLayout->addWidget( GroupConstructors, 0, 0 ); + + /***************************************************************/ + GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, GroupButtons->sizePolicy().hasHeightForWidth() ) ); + GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); + GroupButtons->setTitle( tr( "" ) ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 6 ); + GroupButtonsLayout->setMargin( 11 ); + buttonCancel = new QPushButton( GroupButtons, "cancel" ); + buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) ); + buttonCancel->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonCancel, 0, 3 ); + buttonApply = new QPushButton( GroupButtons, "apply" ); + buttonApply->setText( tr( "SMESH_BUT_APPLY" ) ); + buttonApply->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); + QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupButtonsLayout->addItem( spacer_9, 0, 2 ); + buttonOk = new QPushButton( GroupButtons, "ok" ); + buttonOk->setText( tr( "SMESH_BUT_OK" ) ); + buttonOk->setAutoDefault( TRUE ); + buttonOk->setDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); + SMESHGUI_CreatePolyhedralVolumeDlgLayout->addWidget( GroupButtons, 2, 0 ); + + /***************************************************************/ + GroupContent = new QGroupBox( this, "GroupContent" ); + GroupContent->setTitle( tr( "SMESH_CONTENT" ) ); + GroupContent->setColumnLayout(0, Qt::Vertical ); + GroupContent->layout()->setSpacing( 0 ); + GroupContent->layout()->setMargin( 0 ); + GroupContentLayout = new QGridLayout( GroupContent->layout() ); + GroupContentLayout->setAlignment( Qt::AlignTop ); + GroupContentLayout->setSpacing( 6 ); + GroupContentLayout->setMargin( 11 ); + + QFrame* anIds = new QFrame(GroupContent, "anIds"); + QGridLayout* aLayout = new QGridLayout(anIds, 1, 3); + aLayout->setSpacing(6); + aLayout->setAutoAdd(false); + + TextLabelIds = new QLabel( anIds, "TextLabelIds" ); + TextLabelIds->setText( tr( "SMESH_ID_NODES" ) ); + TextLabelIds->setFixedWidth(74); + aLayout->addWidget( TextLabelIds, 0, 0 ); + + SelectElementsButton = new QPushButton( anIds, "SelectElementsButton" ); + SelectElementsButton->setText( tr( "" ) ); + SelectElementsButton->setPixmap( image0 ); + SelectElementsButton->setToggleButton( FALSE ); + aLayout->addWidget( SelectElementsButton, 0, 1 ); + + LineEditElements = new QLineEdit( anIds, "LineEditElements" ); + LineEditElements->setValidator( new SMESHGUI_IdValidator( this, "validator" )); + aLayout->addWidget( LineEditElements, 0, 2 ); + + GroupContentLayout->addMultiCellWidget(anIds, 0, 0, 0, 1); + + myFacesByNodesLabel = new QLabel(GroupContent, "faces by nodes label"); + myFacesByNodesLabel->setText(tr("FACES_BY_NODES")); + GroupContentLayout->addWidget( myFacesByNodesLabel, 1, 0 ); + + myFacesByNodes = new QListBox(GroupContent, "faces by nodes list"); + myFacesByNodes->setSelectionMode(QListBox::Extended); + myFacesByNodes->setMinimumHeight(150); + GroupContentLayout->addMultiCellWidget( myFacesByNodes, 2, 4, 0, 0 ); + + AddButton = new QPushButton(GroupContent, "add"); + AddButton->setText(tr("SMESH_BUT_ADD")); + AddButton->setMaximumWidth(85); + GroupContentLayout->addWidget( AddButton, 2, 1 ); + + RemoveButton = new QPushButton(GroupContent, "remove"); + RemoveButton->setText(tr("SMESH_BUT_REMOVE")); + RemoveButton->setMaximumWidth(85); + GroupContentLayout->addWidget( RemoveButton, 3, 1 ); + + Preview = new QCheckBox( GroupContent, "Preview" ); + Preview->setText( tr( "SMESH_POLYEDRE_PREVIEW" ) ); + GroupContentLayout->addWidget( Preview , 5, 0 ); + + SMESHGUI_CreatePolyhedralVolumeDlgLayout->addWidget( GroupContent, 1, 0 ); + + GroupContent->show(); + RadioButton1->setChecked( TRUE ); + + mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; + + Init(); +} + +//================================================================================= +// function : ~SMESHGUI_CreatePolyhedralVolumeDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +SMESHGUI_CreatePolyhedralVolumeDlg::~SMESHGUI_CreatePolyhedralVolumeDlg() +{ + // no need to delete child widgets, Qt does it all for us + delete mySimulation; +} + +static bool busy = false; +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void SMESHGUI_CreatePolyhedralVolumeDlg::Init() +{ + myEditCurrentArgument = LineEditElements; + mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; + + myNbOkElements = 0; + myActor = 0; + + mySimulation = new SMESH::TPolySimulation( dynamic_cast( mySMESHGUI->application() ) ); + + /* signals and slots connections */ + connect(buttonOk, SIGNAL( clicked() ), SLOT( ClickOnOk() ) ); + connect(buttonCancel, SIGNAL( clicked() ), SLOT( ClickOnCancel() ) ) ; + connect(buttonApply, SIGNAL( clicked() ), SLOT(ClickOnApply() ) ); + + connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) ); + connect(SelectElementsButton, SIGNAL( clicked() ), SLOT( SetEditCurrentArgument() ) ) ; + connect(LineEditElements, SIGNAL( textChanged(const QString&) ), SLOT(onTextChange(const QString&))); + + connect(myFacesByNodes, SIGNAL(selectionChanged()), this, SLOT(onListSelectionChanged())); + connect(AddButton, SIGNAL(clicked()), this, SLOT(onAdd())); + connect(RemoveButton, SIGNAL(clicked()), this, SLOT(onRemove())); + + connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; + connect( mySelectionMgr, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + connect( Preview, SIGNAL(toggled(bool)), this, SLOT(ClickOnPreview(bool))); + /* to close dialog if study change */ + connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; + + /* Move widget on the botton right corner of main widget */ + int x, y ; + mySMESHGUI->DefineDlgPosition( this, x, y ) ; + this->move( x, y ) ; + this->show() ; /* displays Dialog */ + + ConstructorsClicked(0); + SelectionIntoArgument(); +} + + +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void SMESHGUI_CreatePolyhedralVolumeDlg::ConstructorsClicked(int constructorId) +{ + disconnect(mySelectionMgr, 0, this, 0); + + SALOME_ListIO aList; + mySelectionMgr->setSelectedObjects( aList ); + myEditCurrentArgument->clear(); + myNbOkElements = 0; + buttonApply->setEnabled(false); + buttonOk->setEnabled(false); + mySimulation->SetVisibility(false); + + switch(constructorId) + { + case 0 : + { + if ( myActor ){ + myActor->SetPointRepresentation(true); + } + else + SMESH::SetPointRepresentation(true); + myViewWindow->SetSelectionMode(NodeSelection); + + AddButton->setEnabled(false); + RemoveButton->setEnabled(false); + TextLabelIds->setText( tr( "SMESH_ID_NODES" ) ); + myFacesByNodesLabel->show(); + myFacesByNodes->clear(); + myFacesByNodes->show(); + AddButton->show(); + RemoveButton->show(); + Preview->show(); + break; + } + case 1 : + { + SMESH::SetPointRepresentation(false); + myViewWindow->SetSelectionMode(FaceSelection); + + TextLabelIds->setText( tr( "SMESH_ID_FACES" ) ); + myFacesByNodesLabel->hide(); + myFacesByNodes->hide(); + AddButton->hide(); + RemoveButton->hide(); + Preview->show(); + break; + } + } + + connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); +} + +//================================================================================= +// function : ClickOnPreview() +// purpose : +//================================================================================= +void SMESHGUI_CreatePolyhedralVolumeDlg::ClickOnPreview(bool theToggled){ + Preview->setChecked(theToggled); + displaySimulation(); +} + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +void SMESHGUI_CreatePolyhedralVolumeDlg::ClickOnApply() +{ + if ( myNbOkElements>0 && !mySMESHGUI->isActiveStudyLocked()) + { + busy = true; + if (GetConstructorId() == 0) + { + SMESH::long_array_var anIdsOfNodes = new SMESH::long_array; + SMESH::long_array_var aQuantities = new SMESH::long_array; + + aQuantities->length( myFacesByNodes->count() ); + + TColStd_ListOfInteger aNodesIds; + + QListBoxItem* anItem; + int aNbQuantities = 0; + for (anItem = myFacesByNodes->firstItem(); anItem != 0; anItem = anItem->next()) { + QStringList anIds = QStringList::split(" ", anItem->text()); + int aNbNodesInFace = 0; + for (QStringList::iterator it = anIds.begin(); it != anIds.end(); ++it, ++aNbNodesInFace) + aNodesIds.Append( (*it).toInt() ); + + aQuantities[aNbQuantities++] = aNbNodesInFace; + } + + anIdsOfNodes->length(aNodesIds.Extent()); + + int aNbIdsOfNodes = 0; + TColStd_ListIteratorOfListOfInteger It; + It.Initialize(aNodesIds); + for(;It.More();It.Next()) + anIdsOfNodes[aNbIdsOfNodes++] = It.Value(); + + try{ + SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor(); + QApplication::setOverrideCursor(Qt::waitCursor); + aMeshEditor->AddPolyhedralVolume(anIdsOfNodes, aQuantities); + QApplication::restoreOverrideCursor(); + }catch(SALOME::SALOME_Exception& exc){ + INFOS("Follow exception was cought:\n\t"<text() ); + anIdsOfFaces->length(aListId.count()); + for ( int i = 0; i < aListId.count(); i++ ) + anIdsOfFaces[i] = aListId[i].toInt(); + + try{ + SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor(); + QApplication::setOverrideCursor(Qt::waitCursor); + aMeshEditor->AddPolyhedralVolumeByFaces(anIdsOfFaces); + QApplication::restoreOverrideCursor(); + }catch(SALOME::SALOME_Exception& exc){ + INFOS("Follow exception was cought:\n\t"<setSelectedObjects( aList ); + mySimulation->SetVisibility(false); + SMESH::UpdateView(); + ConstructorsClicked( GetConstructorId() ); + busy = false; + } +} + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void SMESHGUI_CreatePolyhedralVolumeDlg::ClickOnOk() +{ + ClickOnApply() ; + ClickOnCancel() ; +} + + +//================================================================================= +// function : ClickOnCancel() +// purpose : +//================================================================================= +void SMESHGUI_CreatePolyhedralVolumeDlg::ClickOnCancel() +{ + mySelectionMgr->clearFilters(); + SALOME_ListIO aList; + mySelectionMgr->setSelectedObjects( aList ); + SMESH::SetPointRepresentation(false); + mySimulation->SetVisibility(false); + myViewWindow->SetSelectionMode( ActorSelection ); + disconnect( mySelectionMgr, 0, this, 0 ); + mySMESHGUI->ResetState() ; + reject() ; +} + +//======================================================================= +//function : onTextChange +//purpose : +//======================================================================= + +void SMESHGUI_CreatePolyhedralVolumeDlg::onTextChange(const QString& theNewText) +{ + if ( busy ) return; + busy = true; + + mySimulation->SetVisibility(false); + + SMDS_Mesh* aMesh = 0; + if ( myActor ) + aMesh = myActor->GetObject()->GetMesh(); + + if (GetConstructorId() == 0) + { + if ( aMesh ) { + SALOME_ListIO aList; aList.Append( myActor->getIO() ); + mySelectionMgr->setSelectedObjects( aList ); + + TColStd_IndexedMapOfInteger selectedIndices; + TColStd_MapOfInteger newIndices; + mySelector->GetIndex( myActor->getIO(), selectedIndices); + + QStringList aListId = QStringList::split( " ", theNewText, false); + for ( int i = 0; i < aListId.count(); i++ ) { + const SMDS_MeshNode * n = aMesh->FindNode( aListId[ i ].toInt() ); + if ( n ) { + /*if ( mySelectionMgr->IsIndexSelected( myActor->getIO(), n->GetID() )) + allOk = false; + else + mySelectionMgr->AddOrRemoveIndex (myActor->getIO(), n->GetID(), true);*/ + if (selectedIndices.Add(n->GetID())) + newIndices.Add(n->GetID()); + myNbOkElements++; + } + } + + if (newIndices.Extent() > 0){ + mySelector->AddOrRemoveIndex( myActor->getIO(), newIndices, true ); + myViewWindow->highlight( myActor->getIO(), true, true ); + } + +/* bool aNodesOK = false; + if (aListId.count() >= 3) + aNodesOK = true; + + allOk = (allOk && aNodesOK);*/ + + if ( myNbOkElements>0 && aListId.count()>=3) + AddButton->setEnabled(true); + else + AddButton->setEnabled(false); + +// if (allOk && !myOkElements) + displaySimulation(); + } + } + else if (GetConstructorId() == 1) + { + myNbOkElements = 0; + buttonOk->setEnabled( false ); + buttonApply->setEnabled( false ); + + // check entered ids of faces and hilight them + QStringList aListId; + if ( aMesh ) { + SALOME_ListIO aList; aList.Append( myActor->getIO() ); + mySelectionMgr->setSelectedObjects( aList ); + + TColStd_IndexedMapOfInteger selectedIndices; + TColStd_MapOfInteger newIndices; + mySelector->GetIndex( myActor->getIO(), selectedIndices); + + aListId = QStringList::split( " ", theNewText, false); + + for ( int i = 0; i < aListId.count(); i++ ) { + const SMDS_MeshElement * e = aMesh->FindElement( aListId[ i ].toInt() ); + if ( e ) { + /*if ( mySelectionMgr->IsIndexSelected( myActor->getIO(), e->GetID() )) + myOkElements = false; + else + mySelectionMgr->AddOrRemoveIndex (myActor->getIO(), e->GetID(), true);*/ + if (selectedIndices.Add(e->GetID())) + newIndices.Add(e->GetID()); + myNbOkElements++; + } + } + + if (newIndices.Extent() > 0){ + mySelector->AddOrRemoveIndex( myActor->getIO(), newIndices, true ); + myViewWindow->highlight( myActor->getIO(), true, true ); + } + + if ( myNbOkElements ) { + if (aListId.count()>1){ + buttonOk->setEnabled( true ); + buttonApply->setEnabled( true ); + } + else{ + buttonOk->setEnabled( false ); + buttonApply->setEnabled( false ); + } + displaySimulation(); + } + } + } + busy = false; +} + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed or other case +//================================================================================= +void SMESHGUI_CreatePolyhedralVolumeDlg::SelectionIntoArgument() +{ + if ( busy ) return; + + // clear + + if (GetConstructorId() == 1 || myFacesByNodes->count() <= 1) + { + myNbOkElements = 0; + AddButton->setEnabled(false); + buttonOk->setEnabled( false ); + buttonApply->setEnabled( false ); + } + + myActor = 0; + + busy = true; + myEditCurrentArgument->setText( "" ); + busy = false; + if ( !GroupButtons->isEnabled() ) // inactive + return; + + mySimulation->SetVisibility(false); + + // get selected mesh + + SALOME_ListIO selected; + mySelectionMgr->selectedObjects( selected ); + int nbSel = selected.Extent(); + if(nbSel != 1){ + return; + } + + myMesh = SMESH::GetMeshByIO( selected.First() ); + if ( myMesh->_is_nil() ) + return; + + myActor = SMESH::FindActorByObject(myMesh); + if ( !myActor ) + return; + + // get selected nodes/faces + QString aString = ""; + switch(GetConstructorId()){ + case 0:{ + int anbNodes = SMESH::GetNameOfSelectedNodes(mySelector, myActor->getIO(), aString); + if (anbNodes >= 3) + AddButton->setEnabled(true); + else + break; + busy = true; + myEditCurrentArgument->setText( aString ); + busy = false; + break; + } + case 1:{ + // get selected faces + int aNbFaces = SMESH::GetNameOfSelectedElements(mySelector, myActor->getIO(), aString); + if (aNbFaces<=1) + return; + busy = true; + myEditCurrentArgument->setText( aString ); + busy = false; + + // OK + myNbOkElements = 1; + buttonOk->setEnabled( true ); + buttonApply->setEnabled( true ); + break; + } + default: return; + } + + displaySimulation(); +} + +//======================================================================= +//function : displaySimulation +//purpose : +//======================================================================= +void SMESHGUI_CreatePolyhedralVolumeDlg::displaySimulation() +{ + if ( (myNbOkElements || AddButton->isEnabled()) && GroupButtons->isEnabled() && myActor) + { + SMESH::TPolySimulation::TVTKIds aVTKIds; + vtkIdType aType = VTK_CONVEX_POINT_SET ; + if (GetConstructorId() == 0){ + if(!Preview->isChecked()) myActor->SetEntityMode(SMESH_Actor::eFaces); + else myActor->SetEntityMode(SMESH_Actor::eVolumes); + if (!AddButton->isEnabled()){ + QListBoxItem* anItem; + mySimulation->ResetGrid(true); + for (anItem = myFacesByNodes->firstItem(); anItem != 0; anItem = anItem->next()) { + QStringList anIds = QStringList::split(" ", anItem->text()); + SMESH::TPolySimulation::TVTKIds aVTKIds_faces; + for (QStringList::iterator it = anIds.begin(); it != anIds.end(); ++it){ + vtkIdType aId = myActor->GetObject()->GetNodeVTKId( (*it).toInt() ) ; + aVTKIds.push_back(aId); + aVTKIds_faces.push_back(aId); + } + if(!Preview->isChecked()){ + aType = VTK_POLYGON; + mySimulation->SetPosition(myActor, aType, aVTKIds_faces,false); + } + } + if(Preview->isChecked()){ + mySimulation->SetPosition(myActor, aType, aVTKIds); + } + } else { + // add ids from edit line + QStringList anEditIds = QStringList::split( " ", myEditCurrentArgument->text(), false); + myActor->SetEntityMode(SMESH_Actor::eFaces); + for ( int i = 0; i < anEditIds.count(); i++ ) + aVTKIds.push_back( myActor->GetObject()->GetNodeVTKId( anEditIds[ i ].toInt() )); + aType = VTK_POLYGON; + mySimulation->SetPosition(myActor, aType, aVTKIds); + } + }else if(GetConstructorId() == 1){ + SMDS_Mesh* aMesh = 0; + if ( myActor ){ + aMesh = myActor->GetObject()->GetMesh(); + if (Preview->isChecked()) + myActor->SetEntityMode(SMESH_Actor::eVolumes); + else + myActor->SetEntityMode(SMESH_Actor::eFaces); + } + if ( aMesh ) { + QStringList aListId = QStringList::split( " ", myEditCurrentArgument->text(), false); + for ( int i = 0; i < aListId.count(); i++ ) + { + const SMDS_MeshElement * anElem = aMesh->FindElement( aListId[ i ].toInt() ); + if ( !anElem ) + return; + + SMDS_ElemIteratorPtr anIter = anElem->nodesIterator(); + SMESH::TPolySimulation::TVTKIds aVTKIds_faces; + while( anIter->more() ) + if ( const SMDS_MeshNode* aNode = (SMDS_MeshNode*)anIter->next() ){ + vtkIdType aId = myActor->GetObject()->GetNodeVTKId( aNode->GetID() ) ; + aVTKIds.push_back(aId); + aVTKIds_faces.push_back(aId); + } + if(!Preview->isChecked()){ + aType = VTK_POLYGON; + mySimulation->SetPosition(myActor, aType, aVTKIds_faces); + } + } + if(Preview->isChecked()) + mySimulation->SetPosition(myActor, aType, aVTKIds); + } + } + } +} + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void SMESHGUI_CreatePolyhedralVolumeDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + if(send == SelectElementsButton) { + LineEditElements->setFocus() ; + myEditCurrentArgument = LineEditElements; + } + SelectionIntoArgument(); +} + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : +//================================================================================= +void SMESHGUI_CreatePolyhedralVolumeDlg::DeactivateActiveDialog() +{ + if ( GroupConstructors->isEnabled() ) { + GroupConstructors->setEnabled(false) ; + GroupContent->setEnabled(false) ; + GroupButtons->setEnabled(false) ; + mySimulation->SetVisibility(false); + mySMESHGUI->ResetState() ; + mySMESHGUI->SetActiveDialogBox(0) ; + } +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void SMESHGUI_CreatePolyhedralVolumeDlg::ActivateThisDialog() +{ + /* Emit a signal to deactivate the active dialog */ + mySMESHGUI->EmitSignalDeactivateDialog() ; + GroupConstructors->setEnabled(true) ; + GroupContent->setEnabled(true) ; + GroupButtons->setEnabled(true) ; + + mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; + + myViewWindow->SetSelectionMode( FaceSelection ); + SelectionIntoArgument(); +} + + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void SMESHGUI_CreatePolyhedralVolumeDlg::enterEvent(QEvent* e) +{ + if ( GroupConstructors->isEnabled() ) + return ; + ActivateThisDialog() ; +} + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void SMESHGUI_CreatePolyhedralVolumeDlg::closeEvent( QCloseEvent* e ) +{ + /* same than click on cancel button */ + this->ClickOnCancel() ; +} + + +//======================================================================= +//function : hideEvent +//purpose : caused by ESC key +//======================================================================= + +void SMESHGUI_CreatePolyhedralVolumeDlg::hideEvent ( QHideEvent * e ) +{ + if ( !isMinimized() ) + ClickOnCancel(); +} + + +//================================================================================= +// function : GetConstructorId() +// purpose : +//================================================================================= +int SMESHGUI_CreatePolyhedralVolumeDlg::GetConstructorId() +{ + if ( GroupConstructors != NULL && GroupConstructors->selected() != NULL ) + return GroupConstructors->id( GroupConstructors->selected() ); + return -1; +} + +//================================================================================= +// function : onAdd() +// purpose : +//================================================================================= +void SMESHGUI_CreatePolyhedralVolumeDlg::onAdd() +{ + SALOME_ListIO selected; + mySelectionMgr->selectedObjects( selected ); + int aNbSel = selected.Extent(); + if (aNbSel == 0 || !myActor || myMesh->_is_nil()) return; + + busy = true; + + if ( !(myEditCurrentArgument->text().isEmpty()) ) + { + myFacesByNodes->insertItem(myEditCurrentArgument->text()); + //myFacesByNodes->setSelected(myFacesByNodes->count() - 1, true); + myNbOkElements = 1; + myEditCurrentArgument->clear(); + AddButton->setEnabled(false); + RemoveButton->setEnabled(true); + buttonOk->setEnabled( true ); + if(myFacesByNodes->count()>1) buttonApply->setEnabled( true ); + } + busy = false; + onListSelectionChanged(); + displaySimulation(); +} + +//================================================================================= +// function : onRemove() +// purpose : +//================================================================================= +void SMESHGUI_CreatePolyhedralVolumeDlg::onRemove() +{ + busy = true; + for (int i = myFacesByNodes->count(); i > 0; i--) { + if (myFacesByNodes->isSelected(i-1)) { + myFacesByNodes->removeItem(i-1); + } + } + if (myFacesByNodes->count() < 1){ + myNbOkElements = 0; + RemoveButton->setEnabled(false); + buttonOk->setEnabled( false ); + buttonApply->setEnabled( false ); + } + else if (myFacesByNodes->count() == 1){ + myNbOkElements = 0; + buttonOk->setEnabled( false ); + buttonApply->setEnabled( false ); + } + displaySimulation(); + busy = false; + onListSelectionChanged(); +} + +//================================================================================= +// function : onListSelectionChanged() +// purpose : Called when selection in element list is changed +//================================================================================= +void SMESHGUI_CreatePolyhedralVolumeDlg::onListSelectionChanged() +{ + if (busy || !myActor) return; + busy = true; + + SALOME_ListIO list; + mySelectionMgr->setSelectedObjects( list ); + TColStd_MapOfInteger aIndexes; + QListBoxItem* anItem; + for (anItem = myFacesByNodes->firstItem(); anItem != 0; anItem = anItem->next()) { + if (anItem->isSelected()) { + QStringList anIds = QStringList::split(" ", anItem->text()); + for (QStringList::iterator it = anIds.begin(); it != anIds.end(); ++it) + aIndexes.Add((*it).toInt()); + } + } + mySelector->AddOrRemoveIndex(myActor->getIO(), aIndexes, true ); + myViewWindow->highlight( myActor->getIO(), true, true ); + list.Append( myActor->getIO() ); + mySelectionMgr->setSelectedObjects( list ); + + busy = false; +} diff --git a/src/SMESHGUI/SMESHGUI_CreatePolyhedralVolumeDlg.h b/src/SMESHGUI/SMESHGUI_CreatePolyhedralVolumeDlg.h new file mode 100644 index 000000000..ba7cf2cc5 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_CreatePolyhedralVolumeDlg.h @@ -0,0 +1,135 @@ +// SMESH SMESHGUI : GUI for SMESH component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESHGUI_CreatePolyhedralVolumeDlg.h +// Author : Michael ZORIN +// Module : SMESH +// $Header: + +#ifndef DIALOGBOX_CREATEPOLYHEDRAL_H +#define DIALOGBOX_CREATEPOLYHEDRAL_H + +// QT Includes +#include + +class QGridLayout; +class QButtonGroup; +class QGroupBox; +class QListBox; +class QLabel; +class QLineEdit; +class QPushButton; +class QRadioButton; +class QCheckBox; +class SMESHGUI; +class SMESH_Actor; +class SVTK_Selector; +class SVTK_ViewWindow; +class SalomeApp_SelectionMgr; + +namespace SMESH{ + struct TPolySimulation; +} + +// IDL Headers +#include +#include CORBA_SERVER_HEADER(SMESH_Mesh) + +//================================================================================= +// class : SMESHGUI_CreatePolyhedralVolumeDlg +// purpose : +//================================================================================= +class SMESHGUI_CreatePolyhedralVolumeDlg : public QDialog +{ + Q_OBJECT + +public: + SMESHGUI_CreatePolyhedralVolumeDlg( SMESHGUI*, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); + ~SMESHGUI_CreatePolyhedralVolumeDlg(); + +private: + + void Init() ; + void closeEvent( QCloseEvent* e ) ; + void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */ + void hideEvent ( QHideEvent * ); /* ESC key */ + int GetConstructorId(); + void displaySimulation(); + + SMESHGUI* mySMESHGUI ; /* Current SMESHGUI object */ + SalomeApp_SelectionMgr* mySelectionMgr ; /* User shape selection */ + SVTK_ViewWindow* myViewWindow; + SVTK_Selector* mySelector; + QString myIDs; + int myNbOkElements ; /* to check when elements are defined */ + + QLineEdit* myEditCurrentArgument; + + SMESH::SMESH_Mesh_var myMesh; + SMESH_Actor* myActor; + SMESH::TPolySimulation* mySimulation; + + QButtonGroup* GroupConstructors; + QRadioButton* RadioButton1; + QRadioButton* RadioButton2; + QCheckBox* Preview; + QGroupBox* GroupButtons; + QPushButton* buttonOk; + QPushButton* buttonCancel; + QPushButton* buttonApply; + QGroupBox* GroupContent; + QLabel* TextLabelIds; + QPushButton* SelectElementsButton; + QLineEdit* LineEditElements; + QListBox* myFacesByNodes; + QLabel* myFacesByNodesLabel; + QPushButton* AddButton; + QPushButton* RemoveButton; + + public slots: + + void onAdd(); + void onRemove(); + + private slots: + + void ConstructorsClicked(int constructorId); + void ClickOnPreview(bool theToggled); + void ClickOnOk(); + void ClickOnCancel(); + void ClickOnApply(); + void SetEditCurrentArgument() ; + void SelectionIntoArgument() ; + void DeactivateActiveDialog() ; + void ActivateThisDialog() ; + void onTextChange(const QString&); + void onListSelectionChanged(); + +protected: + QGridLayout* SMESHGUI_CreatePolyhedralVolumeDlgLayout; + QGridLayout* GroupConstructorsLayout; + QGridLayout* GroupButtonsLayout; + QGridLayout* GroupContentLayout; +}; + +#endif // DIALOGBOX_CREATEPOLYHEDRAL_H diff --git a/src/SMESHGUI/SMESHGUI_DeleteGroupDlg.cxx b/src/SMESHGUI/SMESHGUI_DeleteGroupDlg.cxx index db93adf3b..b71866823 100644 --- a/src/SMESHGUI/SMESHGUI_DeleteGroupDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_DeleteGroupDlg.cxx @@ -1,23 +1,23 @@ // SMESH SMESHGUI : GUI for SMESH component // // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org // // // @@ -28,14 +28,21 @@ #include "SMESHGUI_DeleteGroupDlg.h" #include "SMESHGUI.h" -#include "SMESH_TypeFilter.hxx" #include "SMESHGUI_Utils.h" #include "SMESHGUI_VTKUtils.h" -#include "QAD_Desktop.h" -#include "SALOME_Selection.h" +#include "SMESH_TypeFilter.hxx" + +#include "SUIT_Desktop.h" + +#include "SalomeApp_Study.h" +#include "SalomeApp_SelectionMgr.h" + +#include "SVTK_Selection.h" +#include "SALOME_ListIO.hxx" #include "SALOME_ListIteratorOfListIO.hxx" +// QT Includes #include #include #include @@ -45,251 +52,256 @@ #include #include +// IDL Headers #include "SALOMEconfig.h" #include CORBA_SERVER_HEADER(SMESH_Mesh) #define SPACING 5 #define MARGIN 10 -/* - Class : SMESHGUI_DeleteGroupDlg - Description : Delete groups and their contents -*/ +/*! + * Class : SMESHGUI_DeleteGroupDlg + * Description : Delete groups and their contents + */ -//======================================================================= -// name : SMESHGUI_DeleteGroupDlg::SMESHGUI_DeleteGroupDlg -// Purpose : Constructor -//======================================================================= -SMESHGUI_DeleteGroupDlg::SMESHGUI_DeleteGroupDlg( QWidget* theParent, - SALOME_Selection* theSelection ) -: QDialog( theParent, "SMESHGUI_DeleteGroupDlg", false, - WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +//================================================================================= +// function : SMESHGUI_DeleteGroupDlg() +// purpose : Constructor +//================================================================================= +SMESHGUI_DeleteGroupDlg::SMESHGUI_DeleteGroupDlg (QWidget* theParent, + SalomeApp_SelectionMgr* theSelection) + : QDialog(theParent, "SMESHGUI_DeleteGroupDlg", false, + WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) { - setCaption( tr( "CAPTION" ) ); + setCaption(tr("CAPTION")); - QVBoxLayout* aDlgLay = new QVBoxLayout( this, MARGIN, SPACING ); + QVBoxLayout* aDlgLay = new QVBoxLayout(this, MARGIN, SPACING); - QFrame* aMainFrame = createMainFrame ( this ); - QFrame* aBtnFrame = createButtonFrame( this ); + QFrame* aMainFrame = createMainFrame (this); + QFrame* aBtnFrame = createButtonFrame(this); - aDlgLay->addWidget( aMainFrame ); - aDlgLay->addWidget( aBtnFrame ); + aDlgLay->addWidget(aMainFrame); + aDlgLay->addWidget(aBtnFrame); - aDlgLay->setStretchFactor( aMainFrame, 1 ); + aDlgLay->setStretchFactor(aMainFrame, 1); - Init( theSelection ) ; + Init(theSelection); } -//======================================================================= -// name : SMESHGUI_DeleteGroupDlg::createMainFrame -// Purpose : Create frame containing dialog's input fields -//======================================================================= -QFrame* SMESHGUI_DeleteGroupDlg::createMainFrame( QWidget* theParent ) +//================================================================================= +// function : createMainFrame() +// purpose : Create frame containing dialog's input fields +//================================================================================= +QFrame* SMESHGUI_DeleteGroupDlg::createMainFrame (QWidget* theParent) { - QGroupBox* aMainGrp = new QGroupBox( 1, Qt::Horizontal, tr( "SELECTED_GROUPS" ), theParent ); - - myListBox = new QListBox( aMainGrp ); - myListBox->setMinimumHeight( 100 ); - myListBox->setSelectionMode( QListBox::NoSelection ); - myListBox->setRowMode( QListBox::FitToWidth ); - + QGroupBox* aMainGrp = + new QGroupBox(1, Qt::Horizontal, tr("SELECTED_GROUPS"), theParent); + + myListBox = new QListBox(aMainGrp); + myListBox->setMinimumHeight(100); + myListBox->setSelectionMode(QListBox::NoSelection); + myListBox->setRowMode(QListBox::FitToWidth); + return aMainGrp; } -//======================================================================= -// name : SMESHGUI_DeleteGroupDlg::createButtonFrame -// Purpose : Create frame containing buttons -//======================================================================= -QFrame* SMESHGUI_DeleteGroupDlg::createButtonFrame( QWidget* theParent ) +//================================================================================= +// function : createButtonFrame() +// purpose : Create frame containing buttons +//================================================================================= +QFrame* SMESHGUI_DeleteGroupDlg::createButtonFrame (QWidget* theParent) { - QFrame* aFrame = new QFrame( theParent ); - aFrame->setFrameStyle( QFrame::Box | QFrame::Sunken ); + QFrame* aFrame = new QFrame(theParent); + aFrame->setFrameStyle(QFrame::Box | QFrame::Sunken); - myOkBtn = new QPushButton( tr( "SMESH_BUT_OK" ), aFrame ); - myApplyBtn = new QPushButton( tr( "SMESH_BUT_APPLY" ), aFrame ); - myCloseBtn = new QPushButton( tr( "SMESH_BUT_CLOSE" ), aFrame ); + myOkBtn = new QPushButton(tr("SMESH_BUT_OK" ), aFrame); + myApplyBtn = new QPushButton(tr("SMESH_BUT_APPLY"), aFrame); + myCloseBtn = new QPushButton(tr("SMESH_BUT_CLOSE"), aFrame); - QSpacerItem* aSpacer = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum ); + QSpacerItem* aSpacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum); - QHBoxLayout* aLay = new QHBoxLayout( aFrame, MARGIN, SPACING ); + QHBoxLayout* aLay = new QHBoxLayout(aFrame, MARGIN, SPACING); + + aLay->addWidget(myOkBtn); + aLay->addWidget(myApplyBtn); + aLay->addItem(aSpacer); + aLay->addWidget(myCloseBtn); - aLay->addWidget( myOkBtn ); - aLay->addWidget( myApplyBtn ); - aLay->addItem( aSpacer); - aLay->addWidget( myCloseBtn ); - // connect signals and slots - connect( myOkBtn, SIGNAL( clicked() ), SLOT( onOk() ) ); - connect( myCloseBtn, SIGNAL( clicked() ), SLOT( onClose() ) ) ; - connect( myApplyBtn, SIGNAL( clicked() ), SLOT( onApply() ) ); - + connect(myOkBtn, SIGNAL(clicked()), SLOT(onOk())); + connect(myCloseBtn, SIGNAL(clicked()), SLOT(onClose())); + connect(myApplyBtn, SIGNAL(clicked()), SLOT(onApply())); + return aFrame; } -//======================================================================= -// name : SMESHGUI_DeleteGroupDlg::~SMESHGUI_DeleteGroupDlg +//================================================================================= +// name : ~SMESHGUI_DeleteGroupDlg() // Purpose : Destructor -//======================================================================= +//================================================================================= SMESHGUI_DeleteGroupDlg::~SMESHGUI_DeleteGroupDlg() { } -//======================================================================= -// name : SMESHGUI_DeleteGroupDlg::Init -// Purpose : Init dialog fields, connect signals and slots, show dialog -//======================================================================= -void SMESHGUI_DeleteGroupDlg::Init( SALOME_Selection* theSelection ) +//================================================================================= +// function : Init() +// purpose : Init dialog fields, connect signals and slots, show dialog +//================================================================================= +void SMESHGUI_DeleteGroupDlg::Init (SalomeApp_SelectionMgr* theSelection) { myBlockSelection = false; - mySelection = theSelection; + mySelectionMgr = theSelection; SMESHGUI* aSMESHGUI = SMESHGUI::GetSMESHGUI(); - aSMESHGUI->SetActiveDialogBox( ( QDialog* )this ) ; - + aSMESHGUI->SetActiveDialogBox((QDialog*)this); + // selection and SMESHGUI - connect( mySelection, SIGNAL( currentSelectionChanged() ), SLOT( onSelectionDone() ) ); - connect( aSMESHGUI, SIGNAL( SignalDeactivateActiveDialog() ), SLOT( onDeactivate() ) ); - connect( aSMESHGUI, SIGNAL( SignalCloseAllDialogs() ), SLOT( onClose() ) ); - - int x, y ; - aSMESHGUI->DefineDlgPosition( this, x, y ); - this->move( x, y ); - this->show(); + connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(onSelectionDone())); + connect(aSMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), SLOT(onDeactivate())); + connect(aSMESHGUI, SIGNAL(SignalCloseAllDialogs()), SLOT(onClose())); + + int x, y; + aSMESHGUI->DefineDlgPosition(this, x, y); + this->move(x, y); + this->show(); // set selection mode - QAD_Application::getDesktop()->SetSelectionMode( ActorSelection, true ); - mySelection->AddFilter( new SMESH_TypeFilter( GROUP ) ); +#ifdef NEW_GUI + mySelectionMgr->setSelectionModes(ActorSelection, true); +#else + mySelectionMgr->setSelectionModes(ActorSelection); +#endif + mySelectionMgr->installFilter(new SMESH_TypeFilter(GROUP)); onSelectionDone(); return; } -//======================================================================= -// name : SMESHGUI_DeleteGroupDlg::isValid -// Purpose : Verify validity of input data -//======================================================================= +//================================================================================= +// function : isValid() +// purpose : Verify validity of input data +//================================================================================= bool SMESHGUI_DeleteGroupDlg::isValid() { - if ( myListBox->count() == 0 ) - { - QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), - tr( "SMESH_INSUFFICIENT_DATA" ), tr( "NO_SELECTED_GROUPS" ), QMessageBox::Ok ); + if (myListBox->count() == 0) { + QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"), + tr("NO_SELECTED_GROUPS"), QMessageBox::Ok); return false; } - - return !SMESHGUI::GetSMESHGUI()->ActiveStudyLocked(); + + return !SMESHGUI::GetSMESHGUI()->isActiveStudyLocked(); } -//======================================================================= -// name : SMESHGUI_DeleteGroupDlg::onApply -// Purpose : SLOT called when "Apply" button pressed. -//======================================================================= +//================================================================================= +// function : onApply() +// purpose : SLOT called when "Apply" button pressed. +//================================================================================= bool SMESHGUI_DeleteGroupDlg::onApply() { - if ( !isValid() ) + if (!isValid()) return false; myBlockSelection = true; - + QValueList::iterator anIter; - for ( anIter = myListGrp.begin(); anIter != myListGrp.end(); ++anIter ) - { + for (anIter = myListGrp.begin(); anIter != myListGrp.end(); ++anIter) { SMESH::SMESH_Mesh_ptr aMesh = (*anIter)->GetMesh(); - if ( !aMesh->_is_nil() ) - aMesh->RemoveGroupWithContents( *anIter ); + if (!aMesh->_is_nil()) + aMesh->RemoveGroupWithContents(*anIter); } myListBox->clear(); myListGrp.clear(); - mySelection->ClearIObjects(); + mySelectionMgr->clearSelected(); SMESH::UpdateView(); - SMESHGUI::GetSMESHGUI()->GetActiveStudy()->updateObjBrowser( true ); - + SMESHGUI::GetSMESHGUI()->updateObjBrowser(true); + myBlockSelection = false; return true; } -//======================================================================= -// name : SMESHGUI_DeleteGroupDlg::onOk -// Purpose : SLOT called when "Ok" button pressed. -//======================================================================= +//================================================================================= +// function : onOk() +// purpose : SLOT called when "Ok" button pressed. +//================================================================================= void SMESHGUI_DeleteGroupDlg::onOk() { - if ( onApply() ) + if (onApply()) onClose(); } -//======================================================================= -// name : SMESHGUI_DeleteGroupDlg::onClose -// Purpose : SLOT called when "Close" button pressed. Close dialog -//======================================================================= +//================================================================================= +// function : onClose() +// purpose : SLOT called when "Close" button pressed. Close dialog +//================================================================================= void SMESHGUI_DeleteGroupDlg::onClose() { - QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); - disconnect( mySelection, 0, this, 0 ); - disconnect( SMESHGUI::GetSMESHGUI(), 0, this, 0 ); - SMESHGUI::GetSMESHGUI()->ResetState() ; - mySelection->ClearFilters(); + mySelectionMgr->setSelectionModes(ActorSelection); + disconnect(mySelectionMgr, 0, this, 0); + disconnect(SMESHGUI::GetSMESHGUI(), 0, this, 0); + SMESHGUI::GetSMESHGUI()->ResetState(); + mySelectionMgr->clearFilters(); reject(); } -//======================================================================= -// name : SMESHGUI_DeleteGroupDlg::onSelectionDone -// Purpose : SLOT called when selection changed -//======================================================================= +//================================================================================= +// function : onSelectionDone() +// purpose : SLOT called when selection changed +//================================================================================= void SMESHGUI_DeleteGroupDlg::onSelectionDone() { - if ( myBlockSelection ) + if (myBlockSelection) return; - + myListGrp.clear(); QStringList aNames; - - const SALOME_ListIO& aListIO = mySelection->StoredIObjects(); - SALOME_ListIteratorOfListIO anIter( aListIO ); - for( ; anIter.More(); anIter.Next() ) - { - SMESH::SMESH_GroupBase_var aGroup = - SMESH::IObjectToInterface( anIter.Value() ); - if ( !aGroup->_is_nil() ) - { - aNames.append( aGroup->GetName() ); - myListGrp.append( aGroup ); + + SALOME_ListIO aListIO; + mySelectionMgr->selectedObjects(aListIO); + SALOME_ListIteratorOfListIO anIter (aListIO); + for (; anIter.More(); anIter.Next()) { + SMESH::SMESH_GroupBase_var aGroup = + SMESH::IObjectToInterface(anIter.Value()); + if (!aGroup->_is_nil()) { + aNames.append(aGroup->GetName()); + myListGrp.append(aGroup); } } - + myListBox->clear(); - myListBox->insertStringList( aNames ); + myListBox->insertStringList(aNames); } -//======================================================================= -// name : SMESHGUI_DeleteGroupDlg::onDeactivate -// Purpose : SLOT called when dialog must be deativated -//======================================================================= +//================================================================================= +// function : onDeactivate() +// purpose : SLOT called when dialog must be deativated +//================================================================================= void SMESHGUI_DeleteGroupDlg::onDeactivate() { - mySelection->ClearFilters(); - setEnabled( false ); + mySelectionMgr->clearFilters(); + setEnabled(false); } -//======================================================================= -// name : SMESHGUI_DeleteGroupDlg::enterEvent -// Purpose : Event filter -//======================================================================= -void SMESHGUI_DeleteGroupDlg::enterEvent( QEvent* ) +//================================================================================= +// function : enterEvent() +// purpose : Event filter +//================================================================================= +void SMESHGUI_DeleteGroupDlg::enterEvent (QEvent*) { - SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog() ; - setEnabled( true ); - QAD_Application::getDesktop()->SetSelectionMode( ActorSelection, true ); - mySelection->AddFilter( new SMESH_TypeFilter( GROUP ) ); + SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog(); + setEnabled(true); +#ifdef NEW_GUI + mySelectionMgr->setSelectionModes(ActorSelection, true); +#else + mySelectionMgr->setSelectionModes(ActorSelection); +#endif + mySelectionMgr->installFilter(new SMESH_TypeFilter (GROUP)); } - //================================================================================= // function : closeEvent() // purpose : //================================================================================= -void SMESHGUI_DeleteGroupDlg::closeEvent( QCloseEvent* ) +void SMESHGUI_DeleteGroupDlg::closeEvent (QCloseEvent*) { - onClose() ; + onClose(); } - diff --git a/src/SMESHGUI/SMESHGUI_DeleteGroupDlg.h b/src/SMESHGUI/SMESHGUI_DeleteGroupDlg.h index 1669dc705..1d86778a7 100644 --- a/src/SMESHGUI/SMESHGUI_DeleteGroupDlg.h +++ b/src/SMESHGUI/SMESHGUI_DeleteGroupDlg.h @@ -36,61 +36,56 @@ class QCloseEvent; class QFrame; class QPushButton; -class SALOME_Selection; +class SalomeApp_SelectionMgr; class QListBox; -/* - Class : SMESHGUI_DeleteGroupDlg - Description : Delete groups and their contents -*/ +/*! + * Class : SMESHGUI_DeleteGroupDlg + * Description : Delete groups and their contents + */ class SMESHGUI_DeleteGroupDlg : public QDialog -{ +{ Q_OBJECT - -public: - SMESHGUI_DeleteGroupDlg( QWidget*, SALOME_Selection* ); - virtual ~SMESHGUI_DeleteGroupDlg(); - void Init( SALOME_Selection* ) ; - +public: + SMESHGUI_DeleteGroupDlg (QWidget*, + SalomeApp_SelectionMgr*); + virtual ~SMESHGUI_DeleteGroupDlg(); + + void Init (SalomeApp_SelectionMgr*); + private: - void closeEvent( QCloseEvent* e ) ; - void enterEvent ( QEvent * ) ; - + void closeEvent (QCloseEvent*); + void enterEvent (QEvent*); + private slots: - void onOk(); - bool onApply(); - void onClose(); + void onOk(); + bool onApply(); + void onClose(); - void onDeactivate(); + void onDeactivate(); - void onSelectionDone(); + void onSelectionDone(); private: - QFrame* createButtonFrame( QWidget* ); - QFrame* createMainFrame ( QWidget* ); - bool isValid(); - + QFrame* createButtonFrame (QWidget*); + QFrame* createMainFrame (QWidget*); + bool isValid(); + private: - QPushButton* myOkBtn; - QPushButton* myApplyBtn; - QPushButton* myCloseBtn; - QListBox* myListBox; - SALOME_Selection* mySelection; - + QPushButton* myOkBtn; + QPushButton* myApplyBtn; + QPushButton* myCloseBtn; + QListBox* myListBox; + SalomeApp_SelectionMgr* mySelectionMgr; + QValueList myListGrp; bool myBlockSelection; - }; #endif - - - - - diff --git a/src/SMESHGUI/SMESHGUI_EditHypothesesDlg.cxx b/src/SMESHGUI/SMESHGUI_EditHypothesesDlg.cxx index 2d162996a..16feafbc5 100644 --- a/src/SMESHGUI/SMESHGUI_EditHypothesesDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_EditHypothesesDlg.cxx @@ -1,23 +1,23 @@ // SMESH SMESHGUI : GUI for SMESH component // // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org // // // @@ -33,18 +33,25 @@ #include "SMESHGUI_GEOMGenUtils.h" #include "SMESHGUI_HypothesesUtils.h" +#include "SMESH_TypeFilter.hxx" +#include "SMESH_NumberFilter.hxx" + +#include "SALOME_ListIO.hxx" #include "SALOME_ListIteratorOfListIO.hxx" -#include "QAD_Application.h" -#include "QAD_Desktop.h" -#include "QAD_WaitCursor.h" -#include "QAD_Operation.h" +#include "SALOMEDSClient_Study.hxx" +#include "SALOMEDSClient_AttributeIOR.hxx" +#include "SALOMEDSClient_AttributeName.hxx" -#include "SALOMEconfig.h" -#include CORBA_CLIENT_HEADER(SALOMEDS_Attributes) +#include "SUIT_Session.h" +#include "SUIT_OverrideCursor.h" +#include "SUIT_Operation.h" +#include "SUIT_Desktop.h" #include "utilities.h" +#include "SVTK_ViewModel.h" + // QT Includes #include #include @@ -67,10 +74,10 @@ public: enum { RTTI_IOR = 1000 }; public: - ListBoxIOR( QListBox* listbox, + ListBoxIOR (QListBox* listbox, const char* ior, const QString& text = QString::null) - : QListBoxText( listbox, text ), myIOR( ior ) {} + : QListBoxText(listbox, text), myIOR(ior) {} virtual ~ListBoxIOR() {}; virtual int rtti() const { return RTTI_IOR; } const char* GetIOR() { return myIOR.c_str(); } @@ -81,12 +88,12 @@ private: #define ALLOW_CHANGE_SHAPE 0 -int findItem( QListBox* listBox, const string& ior ) +int findItem (QListBox* listBox, const string& ior) { - for ( int i = 0; i < listBox->count(); i++ ) { - if ( listBox->item( i )->rtti() == ListBoxIOR::RTTI_IOR ) { - ListBoxIOR* anItem = ( ListBoxIOR* )( listBox->item( i ) ); - if ( anItem && ior == string( anItem->GetIOR() ) ) + for (int i = 0; i < listBox->count(); i++) { + if (listBox->item(i)->rtti() == ListBoxIOR::RTTI_IOR) { + ListBoxIOR* anItem = (ListBoxIOR*)(listBox->item(i)); + if (anItem && ior == string(anItem->GetIOR())) return i; } } @@ -94,215 +101,218 @@ int findItem( QListBox* listBox, const string& ior ) } //================================================================================= -// class : SMESHGUI_EditHypothesesDlg() -// purpose : Constructs a SMESHGUI_EditHypothesesDlg which is a child of 'parent', with the +// function : SMESHGUI_EditHypothesesDlg() +// purpose : Constructs a SMESHGUI_EditHypothesesDlg which is a child of 'parent', with the // name 'name' and widget flags set to 'f'. // The dialog will by default be modeless, unless you set 'modal' to // TRUE to construct a modal dialog. //================================================================================= -SMESHGUI_EditHypothesesDlg::SMESHGUI_EditHypothesesDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl ) - : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose ), - myImportedMesh( false ) +SMESHGUI_EditHypothesesDlg::SMESHGUI_EditHypothesesDlg (SMESHGUI* theModule, const char* name, + bool modal, WFlags fl) + : QDialog( SMESH::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder | + WStyle_Title | WStyle_SysMenu | WDestructiveClose), + myImportedMesh(false), + mySMESHGUI( theModule ), + mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ) { - QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SELECT"))); - if ( !name ) - setName( "SMESHGUI_EditHypothesesDlg" ); - setCaption( tr( "SMESH_EDIT_HYPOTHESES" ) ); - setSizeGripEnabled( TRUE ); - QGridLayout* SMESHGUI_EditHypothesesDlgLayout = new QGridLayout( this ); - SMESHGUI_EditHypothesesDlgLayout->setSpacing( 6 ); - SMESHGUI_EditHypothesesDlgLayout->setMargin( 11 ); + QPixmap image0 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT"))); + if (!name) + setName("SMESHGUI_EditHypothesesDlg"); + setCaption(tr("SMESH_EDIT_HYPOTHESES")); + setSizeGripEnabled(TRUE); + QGridLayout* SMESHGUI_EditHypothesesDlgLayout = new QGridLayout(this); + SMESHGUI_EditHypothesesDlgLayout->setSpacing(6); + SMESHGUI_EditHypothesesDlgLayout->setMargin(11); /***************************************************************/ - GroupC1 = new QGroupBox( tr( "SMESH_ARGUMENTS" ), this, "GroupC1" ); - GroupC1->setColumnLayout(0, Qt::Vertical ); - GroupC1->layout()->setSpacing( 0 ); - GroupC1->layout()->setMargin( 0 ); - QGridLayout* GroupC1Layout = new QGridLayout( GroupC1->layout() ); - GroupC1Layout->setAlignment( Qt::AlignTop ); - GroupC1Layout->setSpacing( 6 ); - GroupC1Layout->setMargin( 11 ); + GroupC1 = new QGroupBox(tr("SMESH_ARGUMENTS"), this, "GroupC1"); + GroupC1->setColumnLayout(0, Qt::Vertical); + GroupC1->layout()->setSpacing(0); + GroupC1->layout()->setMargin(0); + QGridLayout* GroupC1Layout = new QGridLayout(GroupC1->layout()); + GroupC1Layout->setAlignment(Qt::AlignTop); + GroupC1Layout->setSpacing(6); + GroupC1Layout->setMargin(11); - TextLabelC1A1 = new QLabel( tr( "SMESH_OBJECT_MESHorSUBMESH" ), GroupC1, "TextLabelC1A1" ); - GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 ); - SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" ); - SelectButtonC1A1->setPixmap( image0 ); - GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 ); - LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" ); - LineEditC1A1->setReadOnly( true ); - GroupC1Layout->addWidget( LineEditC1A1, 0, 2 ); + TextLabelC1A1 = new QLabel(tr("SMESH_OBJECT_MESHorSUBMESH"), GroupC1, "TextLabelC1A1"); + GroupC1Layout->addWidget(TextLabelC1A1, 0, 0); + SelectButtonC1A1 = new QPushButton(GroupC1, "SelectButtonC1A1"); + SelectButtonC1A1->setPixmap(image0); + GroupC1Layout->addWidget(SelectButtonC1A1, 0, 1); + LineEditC1A1 = new QLineEdit(GroupC1, "LineEditC1A1"); + LineEditC1A1->setReadOnly(true); + GroupC1Layout->addWidget(LineEditC1A1, 0, 2); - TextLabelC1A2 = new QLabel( tr( "SMESH_OBJECT_GEOM" ), GroupC1, "TextLabelC1A2" ); - GroupC1Layout->addWidget( TextLabelC1A2, 1, 0 ); - SelectButtonC1A2 = new QPushButton( GroupC1, "SelectButtonC1A2" ); - SelectButtonC1A2->setPixmap( image0 ); - SelectButtonC1A2->setToggleButton( FALSE ); - GroupC1Layout->addWidget( SelectButtonC1A2, 1, 1 ); - LineEditC1A2 = new QLineEdit( GroupC1, "LineEditC1A2" ); - LineEditC1A2->setReadOnly( true ); - GroupC1Layout->addWidget( LineEditC1A2, 1, 2 ); + TextLabelC1A2 = new QLabel(tr("SMESH_OBJECT_GEOM"), GroupC1, "TextLabelC1A2"); + GroupC1Layout->addWidget(TextLabelC1A2, 1, 0); + SelectButtonC1A2 = new QPushButton(GroupC1, "SelectButtonC1A2"); + SelectButtonC1A2->setPixmap(image0); + SelectButtonC1A2->setToggleButton(FALSE); + GroupC1Layout->addWidget(SelectButtonC1A2, 1, 1); + LineEditC1A2 = new QLineEdit(GroupC1, "LineEditC1A2"); + LineEditC1A2->setReadOnly(true); + GroupC1Layout->addWidget(LineEditC1A2, 1, 2); - SMESHGUI_EditHypothesesDlgLayout->addWidget( GroupC1, 0, 0 ); + SMESHGUI_EditHypothesesDlgLayout->addWidget(GroupC1, 0, 0); /***************************************************************/ - GroupHypotheses = new QGroupBox( tr( "SMESH_HYPOTHESES" ), this, "GroupHypotheses" ); - GroupHypotheses->setColumnLayout(0, Qt::Vertical ); - GroupHypotheses->layout()->setSpacing( 0 ); - GroupHypotheses->layout()->setMargin( 0 ); - QGridLayout* grid_3 = new QGridLayout( GroupHypotheses->layout() ); - grid_3->setAlignment( Qt::AlignTop ); - grid_3->setSpacing( 6 ); - grid_3->setMargin( 11 ); + GroupHypotheses = new QGroupBox(tr("SMESH_HYPOTHESES"), this, "GroupHypotheses"); + GroupHypotheses->setColumnLayout(0, Qt::Vertical); + GroupHypotheses->layout()->setSpacing(0); + GroupHypotheses->layout()->setMargin(0); + QGridLayout* grid_3 = new QGridLayout(GroupHypotheses->layout()); + grid_3->setAlignment(Qt::AlignTop); + grid_3->setSpacing(6); + grid_3->setMargin(11); - TextHypDefinition = new QLabel( tr( "SMESH_AVAILABLE" ), GroupHypotheses, "TextHypDefinition" ); - grid_3->addWidget( TextHypDefinition, 0, 0 ); + TextHypDefinition = new QLabel(tr("SMESH_AVAILABLE"), GroupHypotheses, "TextHypDefinition"); + grid_3->addWidget(TextHypDefinition, 0, 0); - ListHypDefinition = new QListBox( GroupHypotheses, "ListHypDefinition" ); - ListHypDefinition->setMinimumSize( 100, 100 ); - grid_3->addWidget( ListHypDefinition, 1, 0 ); + ListHypDefinition = new QListBox(GroupHypotheses, "ListHypDefinition"); + ListHypDefinition->setMinimumSize(100, 100); + grid_3->addWidget(ListHypDefinition, 1, 0); - TextHypAssignation = new QLabel( tr( "SMESH_EDIT_USED" ), GroupHypotheses, "TextHypAssignation" ); - grid_3->addWidget( TextHypAssignation, 0, 1 ); + TextHypAssignation = new QLabel(tr("SMESH_EDIT_USED"), GroupHypotheses, "TextHypAssignation"); + grid_3->addWidget(TextHypAssignation, 0, 1); - ListHypAssignation = new QListBox( GroupHypotheses, "ListHypAssignation" ); - ListHypAssignation->setMinimumSize( 100, 100 ); - grid_3->addWidget( ListHypAssignation, 1, 1 ); + ListHypAssignation = new QListBox(GroupHypotheses, "ListHypAssignation"); + ListHypAssignation->setMinimumSize(100, 100); + grid_3->addWidget(ListHypAssignation, 1, 1); - SMESHGUI_EditHypothesesDlgLayout->addWidget( GroupHypotheses, 1, 0 ); + SMESHGUI_EditHypothesesDlgLayout->addWidget(GroupHypotheses, 1, 0); /***************************************************************/ - GroupAlgorithms = new QGroupBox( tr( "SMESH_ADD_ALGORITHM" ), this, "GroupAlgorithms" ); - GroupAlgorithms->setColumnLayout(0, Qt::Vertical ); - GroupAlgorithms->layout()->setSpacing( 0 ); - GroupAlgorithms->layout()->setMargin( 0 ); - QGridLayout* grid_4 = new QGridLayout( GroupAlgorithms->layout() ); - grid_4->setAlignment( Qt::AlignTop ); - grid_4->setSpacing( 6 ); - grid_4->setMargin( 11 ); + GroupAlgorithms = new QGroupBox(tr("SMESH_ADD_ALGORITHM"), this, "GroupAlgorithms"); + GroupAlgorithms->setColumnLayout(0, Qt::Vertical); + GroupAlgorithms->layout()->setSpacing(0); + GroupAlgorithms->layout()->setMargin(0); + QGridLayout* grid_4 = new QGridLayout(GroupAlgorithms->layout()); + grid_4->setAlignment(Qt::AlignTop); + grid_4->setSpacing(6); + grid_4->setMargin(11); - TextAlgoDefinition = new QLabel( tr( "SMESH_AVAILABLE" ), GroupAlgorithms, "TextAlgoDefinition" ); - grid_4->addWidget( TextAlgoDefinition, 0, 0 ); + TextAlgoDefinition = new QLabel(tr("SMESH_AVAILABLE"), GroupAlgorithms, "TextAlgoDefinition"); + grid_4->addWidget(TextAlgoDefinition, 0, 0); - ListAlgoDefinition = new QListBox( GroupAlgorithms, "ListAlgoDefinition" ); - ListAlgoDefinition->setMinimumSize( 100, 100 ); - grid_4->addWidget( ListAlgoDefinition, 1, 0 ); + ListAlgoDefinition = new QListBox(GroupAlgorithms, "ListAlgoDefinition"); + ListAlgoDefinition->setMinimumSize(100, 100); + grid_4->addWidget(ListAlgoDefinition, 1, 0); - TextAlgoAssignation = new QLabel( tr( "SMESH_EDIT_USED" ), GroupAlgorithms, "TextAlgoAssignation" ); - grid_4->addWidget( TextAlgoAssignation, 0, 1 ); + TextAlgoAssignation = new QLabel(tr("SMESH_EDIT_USED"), GroupAlgorithms, "TextAlgoAssignation"); + grid_4->addWidget(TextAlgoAssignation, 0, 1); - ListAlgoAssignation = new QListBox( GroupAlgorithms, "ListAlgoAssignation" ); - ListAlgoAssignation ->setMinimumSize( 100, 100 ); - grid_4->addWidget( ListAlgoAssignation, 1, 1 ); + ListAlgoAssignation = new QListBox(GroupAlgorithms, "ListAlgoAssignation"); + ListAlgoAssignation ->setMinimumSize(100, 100); + grid_4->addWidget(ListAlgoAssignation, 1, 1); - SMESHGUI_EditHypothesesDlgLayout->addWidget( GroupAlgorithms, 2, 0 ); + SMESHGUI_EditHypothesesDlgLayout->addWidget(GroupAlgorithms, 2, 0); /***************************************************************/ - GroupButtons = new QGroupBox( this, "GroupButtons" ); - GroupButtons->setColumnLayout(0, Qt::Vertical ); - GroupButtons->layout()->setSpacing( 0 ); - GroupButtons->layout()->setMargin( 0 ); - QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); - GroupButtonsLayout->setAlignment( Qt::AlignTop ); - GroupButtonsLayout->setSpacing( 6 ); - GroupButtonsLayout->setMargin( 11 ); + GroupButtons = new QGroupBox(this, "GroupButtons"); + GroupButtons->setColumnLayout(0, Qt::Vertical); + GroupButtons->layout()->setSpacing(0); + GroupButtons->layout()->setMargin(0); + QGridLayout* GroupButtonsLayout = new QGridLayout(GroupButtons->layout()); + GroupButtonsLayout->setAlignment(Qt::AlignTop); + GroupButtonsLayout->setSpacing(6); + GroupButtonsLayout->setMargin(11); - buttonOk = new QPushButton( tr( "SMESH_BUT_OK" ), GroupButtons, "buttonOk" ); - buttonOk->setAutoDefault( TRUE ); - buttonOk->setDefault( FALSE ); - GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); + buttonOk = new QPushButton(tr("SMESH_BUT_OK"), GroupButtons, "buttonOk"); + buttonOk->setAutoDefault(TRUE); + buttonOk->setDefault(FALSE); + GroupButtonsLayout->addWidget(buttonOk, 0, 0); - buttonApply = new QPushButton( tr( "SMESH_BUT_APPLY" ), GroupButtons, "buttonApply" ); - buttonApply->setAutoDefault( TRUE ); - buttonApply->setDefault( FALSE ); - GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); + buttonApply = new QPushButton(tr("SMESH_BUT_APPLY"), GroupButtons, "buttonApply"); + buttonApply->setAutoDefault(TRUE); + buttonApply->setDefault(FALSE); + GroupButtonsLayout->addWidget(buttonApply, 0, 1); - GroupButtonsLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 2 ); + GroupButtonsLayout->addItem(new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, 2); - buttonCancel = new QPushButton( tr( "SMESH_BUT_CLOSE" ), GroupButtons, "buttonCancel" ); - buttonCancel->setAutoDefault( TRUE ); - buttonCancel->setDefault( TRUE ); - buttonCancel->setEnabled( TRUE ) ; - GroupButtonsLayout->addWidget( buttonCancel, 0, 3 ); + buttonCancel = new QPushButton(tr("SMESH_BUT_CLOSE"), GroupButtons, "buttonCancel"); + buttonCancel->setAutoDefault(TRUE); + buttonCancel->setDefault(TRUE); + buttonCancel->setEnabled(TRUE); + GroupButtonsLayout->addWidget(buttonCancel, 0, 3); - SMESHGUI_EditHypothesesDlgLayout->addWidget( GroupButtons, 4, 0 ); + SMESHGUI_EditHypothesesDlgLayout->addWidget(GroupButtons, 4, 0); /***************************************************************/ - Init(Sel) ; + Init(); } - //================================================================================= // function : ~SMESHGUI_EditHypothesesDlg() // purpose : Destroys the object and frees any allocated resources //================================================================================= SMESHGUI_EditHypothesesDlg::~SMESHGUI_EditHypothesesDlg() { - // no need to delete child widgets, Qt does it all for us + // no need to delete child widgets, Qt does it all for us } - //================================================================================= // function : Init() // purpose : //================================================================================= -void SMESHGUI_EditHypothesesDlg::Init( SALOME_Selection* Sel ) +void SMESHGUI_EditHypothesesDlg::Init() { - mySelection = Sel; - mySMESHGUI = SMESHGUI::GetSMESHGUI() ; - mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; + mySMESHGUI->SetActiveDialogBox((QDialog*)this); InitHypDefinition(); InitAlgoDefinition(); - myGeomFilter = new SALOME_TypeFilter( "GEOM" ); - myMeshOrSubMeshFilter = new SMESH_TypeFilter( MESHorSUBMESH ); + //myGeomFilter = new SALOME_TypeFilter ("GEOM"); + TColStd_MapOfInteger allTypesMap; + for (int i = 0; i < 10; i++) + allTypesMap.Add(i); + myGeomFilter = new SMESH_NumberFilter ("GEOM", TopAbs_SHAPE, 0, allTypesMap); + myMeshOrSubMeshFilter = new SMESH_TypeFilter (MESHorSUBMESH); myGeomShape = GEOM::GEOM_Object::_nil(); myMesh = SMESH::SMESH_Mesh::_nil(); mySubMesh = SMESH::SMESH_subMesh::_nil(); /* signals and slots connections */ - connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); - connect( buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) ); - connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ); + connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); + connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel())); - connect( SelectButtonC1A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; - connect( SelectButtonC1A2, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + connect(SelectButtonC1A1, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument())); + connect(SelectButtonC1A2, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument())); - connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); - connect( mySMESHGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; - connect( mySMESHGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; - - connect( ListHypAssignation, SIGNAL( doubleClicked(QListBoxItem*) ), this, SLOT( removeItem(QListBoxItem*) ) ); - connect( ListAlgoAssignation, SIGNAL( doubleClicked(QListBoxItem*) ), this, SLOT( removeItem(QListBoxItem*) ) ); - - connect( ListHypDefinition, SIGNAL( doubleClicked(QListBoxItem*) ), this, SLOT( addItem(QListBoxItem*) ) ); - connect( ListAlgoDefinition, SIGNAL( doubleClicked(QListBoxItem*) ), this, SLOT( addItem(QListBoxItem*) ) ); + connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog())); + connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel())); - int x, y ; - mySMESHGUI->DefineDlgPosition( this, x, y ) ; - this->move( x, y ) ; - this->show() ; + connect(ListHypAssignation, SIGNAL(doubleClicked(QListBoxItem*)), this, SLOT(removeItem(QListBoxItem*))); + connect(ListAlgoAssignation, SIGNAL(doubleClicked(QListBoxItem*)), this, SLOT(removeItem(QListBoxItem*))); - LineEditC1A1->setFocus() ; + connect(ListHypDefinition, SIGNAL(doubleClicked(QListBoxItem*)), this, SLOT(addItem(QListBoxItem*))); + connect(ListAlgoDefinition, SIGNAL(doubleClicked(QListBoxItem*)), this, SLOT(addItem(QListBoxItem*))); + + int x, y; + mySMESHGUI->DefineDlgPosition(this, x, y); + this->move(x, y); + this->show(); + + LineEditC1A1->setFocus(); myEditCurrentArgument = LineEditC1A1; - mySelection->ClearFilters() ; - mySelection->AddFilter(myMeshOrSubMeshFilter) ; + mySelectionMgr->clearFilters(); + mySelectionMgr->installFilter(myMeshOrSubMeshFilter); SelectionIntoArgument(); UpdateControlState(); } - //================================================================================= // function : ClickOnOk() // purpose : //================================================================================= void SMESHGUI_EditHypothesesDlg::ClickOnOk() { - if ( ClickOnApply() ) - ClickOnCancel() ; + if (ClickOnApply()) + ClickOnCancel(); } //================================================================================= @@ -311,40 +321,39 @@ void SMESHGUI_EditHypothesesDlg::ClickOnOk() //================================================================================= bool SMESHGUI_EditHypothesesDlg::ClickOnApply() { - if (mySMESHGUI->ActiveStudyLocked()) + if (mySMESHGUI->isActiveStudyLocked()) return false; bool aRes = false; - QAD_WaitCursor wc; + SUIT_OverrideCursor wc; - QAD_Operation* op = new QAD_Operation( mySMESHGUI->GetActiveStudy() ); + SUIT_Operation* op = new SUIT_Operation + (SUIT_Session::session()->activeApplication()); // start transaction op->start(); - - if ( !myMesh->_is_nil() ) + + if (!myMesh->_is_nil()) aRes = StoreMesh(); - else if ( !mySubMesh->_is_nil() ) + else if (!mySubMesh->_is_nil()) aRes = StoreSubMesh(); - if ( true/*aRes*/ ) // abort desynchronizes contents of a Study and a mesh on server - { + if (true/*aRes*/) { // abort desynchronizes contents of a Study and a mesh on server // commit transaction - op->finish(); + op->commit(); InitHypAssignation(); InitAlgoAssignation(); - } - else + } else { // abort transaction op->abort(); + } UpdateControlState(); return aRes; } - //================================================================================= // function : ClickOnCancel() // purpose : @@ -354,56 +363,58 @@ void SMESHGUI_EditHypothesesDlg::ClickOnCancel() close(); } - //================================================================================= // function : SelectionIntoArgument() // purpose : Called when selection as changed or other case //================================================================================= void SMESHGUI_EditHypothesesDlg::SelectionIntoArgument() { - QString aString = ""; + QString aString = ""; - int nbSel = SMESH::GetNameOfSelectedIObjects(mySelection, aString) ; - - if ( myEditCurrentArgument == LineEditC1A1 ) { - if ( nbSel != 1 ) { - myMesh = SMESH::SMESH_Mesh::_nil(); - mySubMesh = SMESH::SMESH_subMesh::_nil(); - aString = ""; + SALOME_ListIO aList; + mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type()); + + int nbSel = SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString); + + if (myEditCurrentArgument == LineEditC1A1) { + if (nbSel != 1) { + myMesh = SMESH::SMESH_Mesh::_nil(); + mySubMesh = SMESH::SMESH_subMesh::_nil(); + aString = ""; } else { - Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ; - myMesh = SMESH::IObjectToInterface(IO) ; - if(myMesh->_is_nil()){ - mySubMesh = SMESH::IObjectToInterface(IO) ; - if(mySubMesh->_is_nil()){ + Handle(SALOME_InteractiveObject) IO = aList.First(); + myMesh = SMESH::IObjectToInterface(IO); + if (myMesh->_is_nil()) { + mySubMesh = SMESH::IObjectToInterface(IO); + if (mySubMesh->_is_nil()) { aString = ""; } } } - myEditCurrentArgument->setText( aString ); - - myGeomShape = GEOM::GEOM_Object::_nil(); // InitGeom() will try to retrieve a shape from myMesh or mySubMesh + myEditCurrentArgument->setText(aString); + + // InitGeom() will try to retrieve a shape from myMesh or mySubMesh + myGeomShape = GEOM::GEOM_Object::_nil(); InitGeom(); - + myImportedMesh = myGeomShape->_is_nil(); - + InitHypAssignation(); InitAlgoAssignation(); - } - else if ( myEditCurrentArgument == LineEditC1A2 ) { - if ( nbSel != 1 ) + + } else if (myEditCurrentArgument == LineEditC1A2) { + if (nbSel != 1) { myGeomShape = GEOM::GEOM_Object::_nil(); - else { - Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ; - myGeomShape = SMESH::IObjectToInterface(IO) ; + } else { + Handle(SALOME_InteractiveObject) IO = aList.First(); + myGeomShape = SMESH::IObjectToInterface(IO); } InitGeom(); - } + } UpdateControlState(); } - //================================================================================= // function : SetEditCurrentArgument() // purpose : @@ -412,17 +423,17 @@ void SMESHGUI_EditHypothesesDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); if(send == SelectButtonC1A1) { - LineEditC1A1->setFocus() ; + LineEditC1A1->setFocus(); myEditCurrentArgument = LineEditC1A1; - mySelection->ClearFilters() ; - mySelection->AddFilter(myMeshOrSubMeshFilter) ; + mySelectionMgr->clearFilters(); + mySelectionMgr->installFilter(myMeshOrSubMeshFilter); } else if (send == SelectButtonC1A2) { - LineEditC1A2->setFocus() ; + LineEditC1A2->setFocus(); myEditCurrentArgument = LineEditC1A2; - mySelection->ClearFilters() ; - mySelection->AddFilter(myGeomFilter) ; - } - SelectionIntoArgument() ; + mySelectionMgr->clearFilters(); + mySelectionMgr->installFilter(myGeomFilter); + } + SelectionIntoArgument(); } //================================================================================= @@ -431,61 +442,57 @@ void SMESHGUI_EditHypothesesDlg::SetEditCurrentArgument() //================================================================================= void SMESHGUI_EditHypothesesDlg::DeactivateActiveDialog() { - if ( GroupC1->isEnabled() ) { - disconnect( mySelection, 0, this, 0 ); - GroupC1->setEnabled(false) ; - GroupButtons->setEnabled(false) ; + if (GroupC1->isEnabled()) { + disconnect(mySelectionMgr, 0, this, 0); + GroupC1->setEnabled(false); + GroupButtons->setEnabled(false); } } - //================================================================================= // function : ActivateThisDialog() // purpose : //================================================================================= void SMESHGUI_EditHypothesesDlg::ActivateThisDialog() { - mySMESHGUI->EmitSignalDeactivateDialog() ; - GroupC1->setEnabled(true) ; - GroupButtons->setEnabled(true) ; - connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + mySMESHGUI->EmitSignalDeactivateDialog(); + GroupC1->setEnabled(true); + GroupButtons->setEnabled(true); + connect (mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); } - //================================================================================= // function : enterEvent() // purpose : //================================================================================= -void SMESHGUI_EditHypothesesDlg::enterEvent(QEvent* e) +void SMESHGUI_EditHypothesesDlg::enterEvent (QEvent*) { - if ( !GroupC1->isEnabled() ) + if (!GroupC1->isEnabled()) ActivateThisDialog(); } - //================================================================================= // function : closeEvent() // purpose : //================================================================================= -void SMESHGUI_EditHypothesesDlg::closeEvent( QCloseEvent* e ) +void SMESHGUI_EditHypothesesDlg::closeEvent (QCloseEvent* e) { - disconnect( mySelection, 0, this, 0 ); - mySMESHGUI->ResetState() ; - mySelection->ClearFilters() ; - QDialog::closeEvent( e ); + disconnect(mySelectionMgr, 0, this, 0); + mySMESHGUI->ResetState(); + mySelectionMgr->clearFilters(); + QDialog::closeEvent(e); } //======================================================================= -//function : IsOld -//purpose : +// function : IsOld() +// purpose : //======================================================================= - -bool SMESHGUI_EditHypothesesDlg::IsOld(QListBoxItem* hypItem) +bool SMESHGUI_EditHypothesesDlg::IsOld (QListBoxItem* hypItem) { - if ( hypItem->rtti() == ListBoxIOR::RTTI_IOR ) { - ListBoxIOR* hyp = ( ListBoxIOR* ) hypItem; - return (myMapOldHypos.find( hyp->GetIOR() ) != myMapOldHypos.end() || - myMapOldAlgos.find( hyp->GetIOR() ) != myMapOldAlgos.end() ); + if (hypItem->rtti() == ListBoxIOR::RTTI_IOR) { + ListBoxIOR* hyp = (ListBoxIOR*) hypItem; + return (myMapOldHypos.find(hyp->GetIOR()) != myMapOldHypos.end() || + myMapOldAlgos.find(hyp->GetIOR()) != myMapOldAlgos.end()); } return false; @@ -495,75 +502,74 @@ bool SMESHGUI_EditHypothesesDlg::IsOld(QListBoxItem* hypItem) // function : removeItem() // purpose : //================================================================================= -void SMESHGUI_EditHypothesesDlg::removeItem(QListBoxItem* item) +void SMESHGUI_EditHypothesesDlg::removeItem (QListBoxItem* item) { const QObject* aSender = sender(); if (!item) return; - if ( aSender == ListHypAssignation ) { - myNbModification += IsOld( item ) ? 1 : -1; - ListHypAssignation->removeItem( ListHypAssignation->index( item ) ); - } - else if ( aSender == ListAlgoAssignation ) { - myNbModification += IsOld( item ) ? 1 : -1; - ListAlgoAssignation->removeItem( ListAlgoAssignation->index( item ) ); + if (aSender == ListHypAssignation) { + myNbModification += IsOld(item) ? 1 : -1; + ListHypAssignation->removeItem(ListHypAssignation->index(item)); + } + else if (aSender == ListAlgoAssignation) { + myNbModification += IsOld(item) ? 1 : -1; + ListAlgoAssignation->removeItem(ListAlgoAssignation->index(item)); } - UpdateControlState(); } - //================================================================================= // function : addItem() // purpose : //================================================================================= -void SMESHGUI_EditHypothesesDlg::addItem(QListBoxItem* item) +void SMESHGUI_EditHypothesesDlg::addItem (QListBoxItem* item) { const QObject* aSender = sender(); if (!item) return; ListBoxIOR* i = 0; - if ( item->rtti() == ListBoxIOR::RTTI_IOR ) + if (item->rtti() == ListBoxIOR::RTTI_IOR) i = (ListBoxIOR*)item; if (!i) return; - + bool isFound = false; - if ( aSender == ListHypDefinition ) { - for ( int j = 0, n = ListHypAssignation->count(); !isFound && j < n; j++ ) { - if ( ListHypAssignation->item( j )->rtti() == ListBoxIOR::RTTI_IOR ) { - ListBoxIOR* anItem = (ListBoxIOR*)ListHypAssignation->item( j ); - isFound = !strcmp( anItem->GetIOR(), i->GetIOR() ); + ListBoxIOR* anItem; + if (aSender == ListHypDefinition) { + for (int j = 0, n = ListHypAssignation->count(); !isFound && j < n; j++) { + if (ListHypAssignation->item(j)->rtti() == ListBoxIOR::RTTI_IOR) { + anItem = (ListBoxIOR*)ListHypAssignation->item(j); + isFound = !strcmp(anItem->GetIOR(), i->GetIOR()); } } - if ( !isFound ) - ListBoxIOR* anItem = new ListBoxIOR( ListHypAssignation, - CORBA::string_dup( i->GetIOR() ), - CORBA::string_dup( i->text().latin1() ) ); - } - else if ( aSender == ListAlgoDefinition ) { - for ( int j = 0, n = ListAlgoAssignation->count(); !isFound && j < n; j++ ) { - if ( ListAlgoAssignation->item( j )->rtti() == ListBoxIOR::RTTI_IOR ) { - ListBoxIOR* anItem = (ListBoxIOR*)ListAlgoAssignation->item( j ); - isFound = !strcmp( anItem->GetIOR(), i->GetIOR() ); + if (!isFound) + anItem = new ListBoxIOR (ListHypAssignation, + CORBA::string_dup(i->GetIOR()), + CORBA::string_dup(i->text().latin1())); + + } else if (aSender == ListAlgoDefinition) { + for (int j = 0, n = ListAlgoAssignation->count(); !isFound && j < n; j++) { + if (ListAlgoAssignation->item(j)->rtti() == ListBoxIOR::RTTI_IOR) { + anItem = (ListBoxIOR*)ListAlgoAssignation->item(j); + isFound = !strcmp(anItem->GetIOR(), i->GetIOR()); } } - if ( !isFound ) - ListBoxIOR* anItem = new ListBoxIOR( ListAlgoAssignation, - CORBA::string_dup( i->GetIOR() ), - CORBA::string_dup( i->text().latin1() ) ); + if (!isFound) + anItem = new ListBoxIOR (ListAlgoAssignation, + CORBA::string_dup(i->GetIOR()), + CORBA::string_dup(i->text().latin1())); + } else { } - if ( !isFound ) - myNbModification += IsOld( item ) ? -1 : 1; + if (!isFound) + myNbModification += IsOld(item) ? -1 : 1; UpdateControlState(); } - //================================================================================= // function : InitHypDefinition() // purpose : @@ -572,27 +578,29 @@ void SMESHGUI_EditHypothesesDlg::InitHypDefinition() { ListHypDefinition->clear(); - SALOMEDS::SComponent_var father = SMESH::GetActiveStudyDocument()->FindComponent("SMESH"); - if ( father->_is_nil() ) + _PTR(SComponent) father = SMESH::GetActiveStudyDocument()->FindComponent("SMESH"); + if (!father) return; - SALOMEDS::SObject_var HypothesisRoot; - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeName_var aName; - SALOMEDS::AttributeIOR_var anIOR; + _PTR(SObject) HypothesisRoot; + _PTR(GenericAttribute) anAttr; + _PTR(AttributeName) aName; + _PTR(AttributeIOR) anIOR; - int Tag_HypothesisRoot = 1; - if (father->FindSubObject (1, HypothesisRoot)) { - SALOMEDS::ChildIterator_var it = SMESH::GetActiveStudyDocument()->NewChildIterator(HypothesisRoot); + //int Tag_HypothesisRoot = 1; + if (father->FindSubObject(1, HypothesisRoot)) { + _PTR(ChildIterator) it = + SMESH::GetActiveStudyDocument()->NewChildIterator(HypothesisRoot); + ListBoxIOR* anItem; for (; it->More();it->Next()) { - SALOMEDS::SObject_var Obj = it->Value(); - if (Obj->FindAttribute(anAttr, "AttributeName") ) { - aName = SALOMEDS::AttributeName::_narrow(anAttr); + _PTR(SObject) Obj = it->Value(); + if (Obj->FindAttribute(anAttr, "AttributeName")) { + aName = anAttr; if (Obj->FindAttribute(anAttr, "AttributeIOR")) { - anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - ListBoxIOR* anItem = new ListBoxIOR( ListHypDefinition, - anIOR->Value(), - aName->Value() ); + anIOR = anAttr; + anItem = new ListBoxIOR (ListHypDefinition, + anIOR->Value().c_str(), + aName->Value().c_str()); } } } @@ -606,37 +614,36 @@ void SMESHGUI_EditHypothesesDlg::InitHypDefinition() void SMESHGUI_EditHypothesesDlg::InitHypAssignation() { myNbModification = 0; -// MESSAGE ( " InitHypAssignation " << myMesh->_is_nil() ) -// MESSAGE ( " InitHypAssignation " << mySubMesh->_is_nil() ) myMapOldHypos.clear(); ListHypAssignation->clear(); - if ( myImportedMesh ) + if (myImportedMesh) return; - SALOMEDS::SObject_var aMorSM, AHR, aRef; - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeName_var aName; - SALOMEDS::AttributeIOR_var anIOR; + _PTR(SObject) aMorSM, AHR, aRef; + _PTR(GenericAttribute) anAttr; + _PTR(AttributeName) aName; + _PTR(AttributeIOR) anIOR; - if ( !myMesh->_is_nil() ) - aMorSM = SMESH::FindSObject( myMesh ); - else if ( !mySubMesh->_is_nil() ) - aMorSM = SMESH::FindSObject( mySubMesh ); + if (!myMesh->_is_nil()) + aMorSM = SMESH::FindSObject(myMesh); + else if (!mySubMesh->_is_nil()) + aMorSM = SMESH::FindSObject(mySubMesh); - if ( !aMorSM->_is_nil() && aMorSM->FindSubObject (2, AHR)) { - SALOMEDS::ChildIterator_var it = SMESH::GetActiveStudyDocument()->NewChildIterator(AHR); + if (aMorSM && aMorSM->FindSubObject(2, AHR)) { + _PTR(ChildIterator) it = + SMESH::GetActiveStudyDocument()->NewChildIterator(AHR); for (; it->More();it->Next()) { - SALOMEDS::SObject_var Obj = it->Value(); - if ( Obj->ReferencedObject(aRef) ) { - if (aRef->FindAttribute(anAttr, "AttributeName") ) { - aName = SALOMEDS::AttributeName::_narrow(anAttr); + _PTR(SObject) Obj = it->Value(); + if (Obj->ReferencedObject(aRef)) { + if (aRef->FindAttribute(anAttr, "AttributeName")) { + aName = anAttr; if (aRef->FindAttribute(anAttr, "AttributeIOR")) { - anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - ListBoxIOR* anItem = new ListBoxIOR( ListHypAssignation, - anIOR->Value(), - aName->Value() ); - myMapOldHypos[ anIOR->Value() ] = ListHypAssignation->index( anItem ); + anIOR = anAttr; + ListBoxIOR* anItem = new ListBoxIOR (ListHypAssignation, + anIOR->Value().c_str(), + aName->Value().c_str()); + myMapOldHypos[ anIOR->Value() ] = ListHypAssignation->index(anItem); } } } @@ -652,70 +659,69 @@ void SMESHGUI_EditHypothesesDlg::InitAlgoDefinition() { ListAlgoDefinition->clear(); - SALOMEDS::SComponent_var father = SMESH::GetActiveStudyDocument()->FindComponent("SMESH"); - if ( father->_is_nil() ) + _PTR(SComponent) father = SMESH::GetActiveStudyDocument()->FindComponent("SMESH"); + if (!father) return; - SALOMEDS::SObject_var AlgorithmsRoot; - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeName_var aName; - SALOMEDS::AttributeIOR_var anIOR; + _PTR(SObject) AlgorithmsRoot; + _PTR(GenericAttribute) anAttr; + _PTR(AttributeName) aName; + _PTR(AttributeIOR) anIOR; if (father->FindSubObject (2, AlgorithmsRoot)) { - SALOMEDS::ChildIterator_var it = SMESH::GetActiveStudyDocument()->NewChildIterator(AlgorithmsRoot); + _PTR(ChildIterator) it = + SMESH::GetActiveStudyDocument()->NewChildIterator(AlgorithmsRoot); + ListBoxIOR* anItem; for (; it->More();it->Next()) { - SALOMEDS::SObject_var Obj = it->Value(); - if (Obj->FindAttribute(anAttr, "AttributeName") ) { - aName = SALOMEDS::AttributeName::_narrow(anAttr); + _PTR(SObject) Obj = it->Value(); + if (Obj->FindAttribute(anAttr, "AttributeName")) { + aName = anAttr; if (Obj->FindAttribute(anAttr, "AttributeIOR")) { - anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - ListBoxIOR* anItem = new ListBoxIOR( ListAlgoDefinition, - anIOR->Value(), - aName->Value() ); + anIOR = anAttr; + anItem = new ListBoxIOR (ListAlgoDefinition, + anIOR->Value().c_str(), + aName->Value().c_str()); } } } } } - //================================================================================= // function : InitAlgoAssignation() // purpose : //================================================================================= void SMESHGUI_EditHypothesesDlg::InitAlgoAssignation() { - MESSAGE ( " InitAlgoAssignation " << myMesh->_is_nil() ) - MESSAGE ( " InitAlgoAssignation " << mySubMesh->_is_nil() ) - myMapOldAlgos.clear(); ListAlgoAssignation->clear(); - if ( myImportedMesh ) + if (myImportedMesh) return; - SALOMEDS::SObject_var aMorSM, AHR, aRef; - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeName_var aName; - SALOMEDS::AttributeIOR_var anIOR; + _PTR(SObject) aMorSM, AHR, aRef; + _PTR(GenericAttribute) anAttr; + _PTR(AttributeName) aName; + _PTR(AttributeIOR) anIOR; - if ( !myMesh->_is_nil() ) - aMorSM = SMESH::FindSObject( myMesh ); - else if ( !mySubMesh->_is_nil() ) - aMorSM = SMESH::FindSObject( mySubMesh ); + if (!myMesh->_is_nil()) + aMorSM = SMESH::FindSObject(myMesh); + else if (!mySubMesh->_is_nil()) + aMorSM = SMESH::FindSObject(mySubMesh); - if ( !aMorSM->_is_nil() && aMorSM->FindSubObject (3, AHR)) { - SALOMEDS::ChildIterator_var it = SMESH::GetActiveStudyDocument()->NewChildIterator(AHR); + if (aMorSM && aMorSM->FindSubObject(3, AHR)) { + _PTR(ChildIterator) it = + SMESH::GetActiveStudyDocument()->NewChildIterator(AHR); for (; it->More();it->Next()) { - SALOMEDS::SObject_var Obj = it->Value(); - if ( Obj->ReferencedObject(aRef) ) { - if (aRef->FindAttribute(anAttr, "AttributeName") ) { - aName = SALOMEDS::AttributeName::_narrow(anAttr); + _PTR(SObject) Obj = it->Value(); + if (Obj->ReferencedObject(aRef)) { + if (aRef->FindAttribute(anAttr, "AttributeName")) { + aName = anAttr; if (aRef->FindAttribute(anAttr, "AttributeIOR")) { - anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - ListBoxIOR* anItem = new ListBoxIOR( ListAlgoAssignation, - anIOR->Value(), - aName->Value() ); - myMapOldAlgos[ anIOR->Value() ] = ListAlgoAssignation->index( anItem ); + anIOR = anAttr; + ListBoxIOR* anItem = new ListBoxIOR (ListAlgoAssignation, + anIOR->Value().c_str(), + aName->Value().c_str()); + myMapOldAlgos[ anIOR->Value() ] = ListAlgoAssignation->index(anItem); } } } @@ -729,28 +735,29 @@ void SMESHGUI_EditHypothesesDlg::InitAlgoAssignation() //================================================================================= void SMESHGUI_EditHypothesesDlg::InitGeom() { - LineEditC1A2->setText("") ; + LineEditC1A2->setText(""); - if ( myGeomShape->_is_nil() && !myMesh->_is_nil() ) { - SALOMEDS::SObject_var aMesh = SMESH::FindSObject( myMesh ); - if ( !aMesh->_is_nil() ) + if (myGeomShape->_is_nil() && !myMesh->_is_nil()) { + _PTR(SObject) aMesh = SMESH::FindSObject(myMesh); + if (aMesh) myGeomShape = SMESH::GetShapeOnMeshOrSubMesh(aMesh); } - if ( myGeomShape->_is_nil() && !mySubMesh->_is_nil() ) { - SALOMEDS::SObject_var aSubMesh = SMESH::FindSObject( mySubMesh ); - if ( !aSubMesh->_is_nil() ) + if (myGeomShape->_is_nil() && !mySubMesh->_is_nil()) { + _PTR(SObject) aSubMesh = SMESH::FindSObject(mySubMesh); + if (aSubMesh) myGeomShape = SMESH::GetShapeOnMeshOrSubMesh(aSubMesh); } - - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeName_var aName; - if ( !myGeomShape->_is_nil() && (!myMesh->_is_nil() || !mySubMesh->_is_nil()) ) { - SALOMEDS::Study_var aStudy = SMESH::GetActiveStudyDocument(); - SALOMEDS::SObject_var aSO = aStudy->FindObjectIOR( aStudy->ConvertObjectToIOR(myGeomShape) ); - if ( !aSO->_is_nil() ) { - if (aSO->FindAttribute(anAttr, "AttributeName") ) { - aName = SALOMEDS::AttributeName::_narrow(anAttr); - LineEditC1A2->setText( QString(aName->Value()) ) ; + + _PTR(GenericAttribute) anAttr; + _PTR(AttributeName) aName; + if (!myGeomShape->_is_nil() && (!myMesh->_is_nil() || !mySubMesh->_is_nil())) { + _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); + //_PTR(SObject) aSO = aStudy->FindObjectIOR(aStudy->ConvertObjectToIOR(myGeomShape)); + _PTR(SObject) aSO = aStudy->FindObjectID(myGeomShape->GetStudyEntry()); + if (aSO) { + if (aSO->FindAttribute(anAttr, "AttributeName")) { + aName = anAttr; + LineEditC1A2->setText(QString(aName->Value().c_str())); } } } @@ -762,18 +769,21 @@ void SMESHGUI_EditHypothesesDlg::InitGeom() //================================================================================= void SMESHGUI_EditHypothesesDlg::UpdateControlState() { - bool isEnabled = ( !myMesh ->_is_nil() && !myGeomShape->_is_nil() && ListHypAssignation->count() && ListAlgoAssignation->count() ) || - ( !mySubMesh->_is_nil() && !myGeomShape->_is_nil() && ( ListHypAssignation->count() || ListAlgoAssignation->count() ) ); + bool isEnabled = (!myMesh->_is_nil() && !myGeomShape->_is_nil() && + ListHypAssignation->count() && ListAlgoAssignation->count()) + || + (!mySubMesh->_is_nil() && !myGeomShape->_is_nil() && + (ListHypAssignation->count() || ListAlgoAssignation->count())); - buttonOk ->setEnabled( myNbModification && isEnabled && !myImportedMesh ); - buttonApply->setEnabled( myNbModification && isEnabled && !myImportedMesh ); + buttonOk ->setEnabled(myNbModification && isEnabled && !myImportedMesh); + buttonApply->setEnabled(myNbModification && isEnabled && !myImportedMesh); - SelectButtonC1A2 ->setEnabled( ALLOW_CHANGE_SHAPE && !myImportedMesh ); - LineEditC1A2 ->setEnabled( ALLOW_CHANGE_SHAPE && !myImportedMesh ); - ListHypDefinition ->setEnabled( !myImportedMesh ); - ListHypAssignation ->setEnabled( !myImportedMesh ); - ListAlgoDefinition ->setEnabled( !myImportedMesh ); - ListAlgoAssignation->setEnabled( !myImportedMesh ); + SelectButtonC1A2 ->setEnabled(ALLOW_CHANGE_SHAPE && !myImportedMesh); + LineEditC1A2 ->setEnabled(ALLOW_CHANGE_SHAPE && !myImportedMesh); + ListHypDefinition ->setEnabled(!myImportedMesh); + ListHypAssignation ->setEnabled(!myImportedMesh); + ListAlgoDefinition ->setEnabled(!myImportedMesh); + ListAlgoAssignation->setEnabled(!myImportedMesh); } //================================================================================= @@ -783,13 +793,15 @@ void SMESHGUI_EditHypothesesDlg::UpdateControlState() bool SMESHGUI_EditHypothesesDlg::StoreMesh() { MapIOR anOldHypos, aNewHypos; - if ( myGeomShape->_is_nil() ) + if (myGeomShape->_is_nil()) return false; + // 1. Check whether the geometric shape has changed - SALOMEDS::SObject_var aMeshSO = SMESH::FindSObject( myMesh ); - GEOM::GEOM_Object_var aIniGeomShape = SMESH::GetShapeOnMeshOrSubMesh( aMeshSO ); - bool bShapeChanged = aIniGeomShape->_is_nil() || !aIniGeomShape->_is_equivalent( myGeomShape ); - if ( bShapeChanged ) { + _PTR(SObject) aMeshSO = SMESH::FindSObject(myMesh); + GEOM::GEOM_Object_var aIniGeomShape = SMESH::GetShapeOnMeshOrSubMesh(aMeshSO); + bool bShapeChanged = aIniGeomShape->_is_nil() || + !aIniGeomShape->_is_equivalent(myGeomShape); + if (bShapeChanged) { // VSR : TODO : Set new shape - not supported yet by SMESH engine // 1. remove all old hypotheses and algorithms and also submeshes // 2. set new shape @@ -797,63 +809,71 @@ bool SMESHGUI_EditHypothesesDlg::StoreMesh() int nbFail = 0; MapIOR::iterator it; + // 2. remove not used hypotheses from the mesh - for ( it = myMapOldHypos.begin(); it != myMapOldHypos.end(); ++it ) { + for (it = myMapOldHypos.begin(); it != myMapOldHypos.end(); ++it) { string ior = it->first; - int index = findItem( ListHypAssignation, ior ); - if ( index < 0 ) { - SMESH::SMESH_Hypothesis_var aHyp = SMESH::IORToInterface(ior.c_str()); - if ( !aHyp->_is_nil() ){ - if (!SMESH::RemoveHypothesisOrAlgorithmOnMesh( aMeshSO, aHyp )) + int index = findItem(ListHypAssignation, ior); + if (index < 0) { + SMESH::SMESH_Hypothesis_var aHyp = + SMESH::IORToInterface(ior.c_str()); + if (!aHyp->_is_nil()) { + if (!SMESH::RemoveHypothesisOrAlgorithmOnMesh(aMeshSO, aHyp)) nbFail++; } } } + // 3. remove not used algorithms from the mesh - for ( it = myMapOldAlgos.begin(); it != myMapOldAlgos.end(); ++it ) { + for (it = myMapOldAlgos.begin(); it != myMapOldAlgos.end(); ++it) { string ior = it->first; - int index = findItem( ListAlgoAssignation, ior ); - if ( index < 0 ) { - SMESH::SMESH_Hypothesis_var aHyp = SMESH::IORToInterface(ior.c_str()); - if ( !aHyp->_is_nil() ){ - if (!SMESH::RemoveHypothesisOrAlgorithmOnMesh( aMeshSO, aHyp )) + int index = findItem(ListAlgoAssignation, ior); + if (index < 0) { + SMESH::SMESH_Hypothesis_var aHyp = + SMESH::IORToInterface(ior.c_str()); + if (!aHyp->_is_nil()) { + if (!SMESH::RemoveHypothesisOrAlgorithmOnMesh(aMeshSO, aHyp)) nbFail++; } } } + // 4. Add new algorithms - for ( int i = 0; i < ListAlgoAssignation->count(); i++ ) { - if ( ListAlgoAssignation->item( i )->rtti() == ListBoxIOR::RTTI_IOR ) { - ListBoxIOR* anItem = ( ListBoxIOR* )( ListAlgoAssignation->item( i ) ); - if ( anItem ) { + for (int i = 0; i < ListAlgoAssignation->count(); i++) { + if (ListAlgoAssignation->item(i)->rtti() == ListBoxIOR::RTTI_IOR) { + ListBoxIOR* anItem = (ListBoxIOR*)(ListAlgoAssignation->item(i)); + if (anItem) { string ior = anItem->GetIOR(); - if ( myMapOldAlgos.find( ior ) == myMapOldAlgos.end() ) { - SMESH::SMESH_Hypothesis_var aHyp = SMESH::IORToInterface(ior.c_str()); - if ( !aHyp->_is_nil() ){ - if (!SMESH::AddHypothesisOnMesh( myMesh, aHyp )) + if (myMapOldAlgos.find(ior) == myMapOldAlgos.end()) { + SMESH::SMESH_Hypothesis_var aHyp = + SMESH::IORToInterface(ior.c_str()); + if (!aHyp->_is_nil()) { + if (!SMESH::AddHypothesisOnMesh(myMesh, aHyp)) nbFail++; } } } } } + // 5. Add new hypotheses - for ( int i = 0; i < ListHypAssignation->count(); i++ ) { - if ( ListHypAssignation->item( i )->rtti() == ListBoxIOR::RTTI_IOR ) { - ListBoxIOR* anItem = ( ListBoxIOR* )( ListHypAssignation->item( i ) ); - if ( anItem ) { + for (int i = 0; i < ListHypAssignation->count(); i++) { + if (ListHypAssignation->item(i)->rtti() == ListBoxIOR::RTTI_IOR) { + ListBoxIOR* anItem = (ListBoxIOR*)(ListHypAssignation->item(i)); + if (anItem) { string ior = anItem->GetIOR(); - if ( myMapOldHypos.find( ior ) == myMapOldHypos.end() ) { - SMESH::SMESH_Hypothesis_var aHyp = SMESH::IORToInterface(ior.c_str()); - if ( !aHyp->_is_nil() ){ - if (!SMESH::AddHypothesisOnMesh( myMesh, aHyp )) + if (myMapOldHypos.find(ior) == myMapOldHypos.end()) { + SMESH::SMESH_Hypothesis_var aHyp = + SMESH::IORToInterface(ior.c_str()); + if (!aHyp->_is_nil()) { + if (!SMESH::AddHypothesisOnMesh(myMesh, aHyp)) nbFail++; } } } } } - return ( nbFail == 0 ); + return (nbFail == 0); } //================================================================================= @@ -863,74 +883,79 @@ bool SMESHGUI_EditHypothesesDlg::StoreMesh() bool SMESHGUI_EditHypothesesDlg::StoreSubMesh() { MapIOR anOldHypos, aNewHypos; - if ( myGeomShape->_is_nil() ) + if (myGeomShape->_is_nil()) return false; + // 1. Check whether the geometric shape has changed - SALOMEDS::SObject_var aSubMeshSO = SMESH::FindSObject( mySubMesh ); - GEOM::GEOM_Object_var aIniGeomShape = SMESH::GetShapeOnMeshOrSubMesh( aSubMeshSO ); - bool bShapeChanged = aIniGeomShape->_is_nil() || !aIniGeomShape->_is_equivalent( myGeomShape ); - if ( bShapeChanged ) { + _PTR(SObject) aSubMeshSO = SMESH::FindSObject(mySubMesh); + GEOM::GEOM_Object_var aIniGeomShape = SMESH::GetShapeOnMeshOrSubMesh(aSubMeshSO); + bool bShapeChanged = aIniGeomShape->_is_nil() || !aIniGeomShape->_is_equivalent(myGeomShape); + if (bShapeChanged) { // VSR : TODO : Set new shape - not supported yet by engine // 1. remove all old hypotheses and algorithms // 2. set new shape } int nbFail = 0; MapIOR::iterator it; + // 2. remove not used hypotheses from the submesh - for ( it = myMapOldHypos.begin(); it != myMapOldHypos.end(); ++it ) { + for (it = myMapOldHypos.begin(); it != myMapOldHypos.end(); ++it) { string ior = it->first; - int index = findItem( ListHypAssignation, ior ); - if ( index < 0 ) { + int index = findItem(ListHypAssignation, ior); + if (index < 0) { SMESH::SMESH_Hypothesis_var aHyp = SMESH::IORToInterface(ior.c_str()); - if ( !aHyp->_is_nil() ){ - if (!SMESH::RemoveHypothesisOrAlgorithmOnMesh( aSubMeshSO, aHyp )) + if (!aHyp->_is_nil()) { + if (!SMESH::RemoveHypothesisOrAlgorithmOnMesh(aSubMeshSO, aHyp)) nbFail++; } } } + // 3. remove not used algorithms from the submesh - for ( it = myMapOldAlgos.begin(); it != myMapOldAlgos.end(); ++it ) { + for (it = myMapOldAlgos.begin(); it != myMapOldAlgos.end(); ++it) { string ior = it->first; - int index = findItem( ListAlgoAssignation, ior ); - if ( index < 0 ) { + int index = findItem(ListAlgoAssignation, ior); + if (index < 0) { SMESH::SMESH_Hypothesis_var aHyp = SMESH::IORToInterface(ior.c_str()); - if ( !aHyp->_is_nil() ){ - if (!SMESH::RemoveHypothesisOrAlgorithmOnMesh( aSubMeshSO, aHyp )) + if (!aHyp->_is_nil()){ + if (!SMESH::RemoveHypothesisOrAlgorithmOnMesh(aSubMeshSO, aHyp)) nbFail++; } } } + // 4. Add new algorithms - for ( int i = 0; i < ListAlgoAssignation->count(); i++ ) { - if ( ListAlgoAssignation->item( i )->rtti() == ListBoxIOR::RTTI_IOR ) { - ListBoxIOR* anItem = ( ListBoxIOR* )( ListAlgoAssignation->item( i ) ); - if ( anItem ) { + for (int i = 0; i < ListAlgoAssignation->count(); i++) { + if (ListAlgoAssignation->item(i)->rtti() == ListBoxIOR::RTTI_IOR) { + ListBoxIOR* anItem = (ListBoxIOR*)(ListAlgoAssignation->item(i)); + if (anItem) { string ior = anItem->GetIOR(); - if ( myMapOldAlgos.find( ior ) == myMapOldAlgos.end() ) { + if (myMapOldAlgos.find(ior) == myMapOldAlgos.end()) { SMESH::SMESH_Hypothesis_var aHyp = SMESH::IORToInterface(ior.c_str()); - if ( !aHyp->_is_nil() ){ - if (!SMESH::AddHypothesisOnSubMesh( mySubMesh, aHyp )) + if (!aHyp->_is_nil()){ + if (!SMESH::AddHypothesisOnSubMesh(mySubMesh, aHyp)) nbFail++; } } } } } + // 5. Add new hypotheses - for ( int i = 0; i < ListHypAssignation->count(); i++ ) { - if ( ListHypAssignation->item( i )->rtti() == ListBoxIOR::RTTI_IOR ) { - ListBoxIOR* anItem = ( ListBoxIOR* )( ListHypAssignation->item( i ) ); - if ( anItem ) { + for (int i = 0; i < ListHypAssignation->count(); i++) { + if (ListHypAssignation->item(i)->rtti() == ListBoxIOR::RTTI_IOR) { + ListBoxIOR* anItem = (ListBoxIOR*)(ListHypAssignation->item(i)); + if (anItem) { string ior = anItem->GetIOR(); - if ( myMapOldHypos.find( ior ) == myMapOldHypos.end() ) { + if (myMapOldHypos.find(ior) == myMapOldHypos.end()) { SMESH::SMESH_Hypothesis_var aHyp = SMESH::IORToInterface(ior.c_str()); - if ( !aHyp->_is_nil() ){ - if (!SMESH::AddHypothesisOnSubMesh( mySubMesh, aHyp )) + if (!aHyp->_is_nil()){ + if (!SMESH::AddHypothesisOnSubMesh(mySubMesh, aHyp)) nbFail++; } } } } } - return ( nbFail == 0 ); + return (nbFail == 0); } diff --git a/src/SMESHGUI/SMESHGUI_EditHypothesesDlg.h b/src/SMESHGUI/SMESHGUI_EditHypothesesDlg.h index 11ca8d494..6c40460e5 100644 --- a/src/SMESHGUI/SMESHGUI_EditHypothesesDlg.h +++ b/src/SMESHGUI/SMESHGUI_EditHypothesesDlg.h @@ -29,9 +29,9 @@ #ifndef DIALOGBOX_EDIT_HYPOTHESES_H #define DIALOGBOX_EDIT_HYPOTHESES_H -#include "SALOME_Selection.h" -#include "SALOME_TypeFilter.hxx" -#include "SMESH_TypeFilter.hxx" +//#include "SMESH_TypeFilter.hxx" +#include "SUIT_SelectionFilter.h" +#include "SalomeApp_SelectionMgr.h" // QT Includes #include @@ -52,26 +52,29 @@ class QListBox; class QListBoxItem; class SMESHGUI; -typedef map MapIOR; +typedef map MapIOR; //================================================================================= // class : SMESHGUI_EditHypothesesDlg // purpose : //================================================================================= class SMESHGUI_EditHypothesesDlg : public QDialog -{ +{ Q_OBJECT public: - SMESHGUI_EditHypothesesDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); + SMESHGUI_EditHypothesesDlg (SMESHGUI*, + const char* name = 0, + bool modal = FALSE, + WFlags fl = 0); ~SMESHGUI_EditHypothesesDlg(); protected: - virtual void closeEvent( QCloseEvent* e ); - virtual void enterEvent ( QEvent* ); + virtual void closeEvent (QCloseEvent*); + virtual void enterEvent (QEvent*); private: - void Init( SALOME_Selection* Sel ) ; + void Init(); void InitHypDefinition(); void InitAlgoDefinition(); @@ -88,23 +91,25 @@ private: bool IsOld(QListBoxItem* hypItem); private: - SMESHGUI* mySMESHGUI ; - SALOME_Selection* mySelection ; - - GEOM::GEOM_Object_var myGeomShape ; + SMESHGUI* mySMESHGUI; + SalomeApp_SelectionMgr* mySelectionMgr; + + GEOM::GEOM_Object_var myGeomShape; QLineEdit* myEditCurrentArgument; SMESH::SMESH_Mesh_var myMesh; SMESH::SMESH_subMesh_var mySubMesh; - Handle(SALOME_TypeFilter) myGeomFilter; - Handle(SMESH_TypeFilter) myMeshOrSubMeshFilter; + //Handle(SALOME_TypeFilter) myGeomFilter; + //Handle(SMESH_TypeFilter) myMeshOrSubMeshFilter; + SUIT_SelectionFilter* myGeomFilter; + SUIT_SelectionFilter* myMeshOrSubMeshFilter; MapIOR myMapOldHypos, myMapOldAlgos; int myNbModification; bool myImportedMesh; - + QGroupBox* GroupButtons; QPushButton* buttonOk; QPushButton* buttonApply; @@ -134,10 +139,10 @@ private slots: void ClickOnOk(); bool ClickOnApply(); void ClickOnCancel(); - void SetEditCurrentArgument() ; - void SelectionIntoArgument() ; - void DeactivateActiveDialog() ; - void ActivateThisDialog() ; + void SetEditCurrentArgument(); + void SelectionIntoArgument(); + void DeactivateActiveDialog(); + void ActivateThisDialog(); void removeItem(QListBoxItem*); void addItem(QListBoxItem*); diff --git a/src/SMESHGUI/SMESHGUI_ExtrusionAlongPathDlg.cxx b/src/SMESHGUI/SMESHGUI_ExtrusionAlongPathDlg.cxx index 989518fe0..46222594e 100644 --- a/src/SMESHGUI/SMESHGUI_ExtrusionAlongPathDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_ExtrusionAlongPathDlg.cxx @@ -1,55 +1,70 @@ // SMESH SMESHGUI : GUI for SMESH component // // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org // // // // File : SMESHGUI_ExtrusionAlongPathDlg.cxx // Author : Vadim SANDLER // Module : SMESH -// $Header: +// $Header: #include "SMESHGUI_ExtrusionAlongPathDlg.h" + #include "SMESHGUI.h" -#include "SMESHGUI_SpinBox.h" #include "SMESHGUI_Utils.h" #include "SMESHGUI_VTKUtils.h" #include "SMESHGUI_MeshUtils.h" +#include "SMESHGUI_SpinBox.h" #include "SMESHGUI_IdValidator.h" + #include "SMESH_Actor.h" +#include "SMESH_TypeFilter.hxx" #include "SMESH_NumberFilter.hxx" +#include "SMESH_LogicalFilter.hxx" + #include "SMDS_Mesh.hxx" -#include "GEOM_ShapeTypeFilter.hxx" + #include "GEOMBase.h" -#include "QAD_Application.h" -#include "QAD_WaitCursor.h" -#include "QAD_Desktop.h" -#include "QAD_MessageBox.h" +#include "SUIT_ResourceMgr.h" +#include "SUIT_OverrideCursor.h" +#include "SUIT_Desktop.h" +#include "SUIT_MessageBox.h" + +#include "SVTK_ViewModel.h" +#include "SVTK_ViewWindow.h" +#include "SVTK_Selector.h" +#include "SVTK_Selection.h" +#include "SALOME_ListIO.hxx" + #include "utilities.h" +// OCCT Includes #include #include #include #include #include +#include +#include // QT Includes #include @@ -65,6 +80,7 @@ #include #include #include +#include // IDL Headers #include "SALOMEconfig.h" @@ -73,664 +89,665 @@ using namespace std; //================================================================================= -// function : SMESHGUI_ExtrusionAlongPathDlg::SMESHGUI_ExtrusionAlongPathDlg() +// function : SMESHGUI_ExtrusionAlongPathDlg() // purpose : constructor //================================================================================= -SMESHGUI_ExtrusionAlongPathDlg::SMESHGUI_ExtrusionAlongPathDlg( QWidget* parent, SALOME_Selection* Sel, bool modal ) - : QDialog( parent, "SMESHGUI_ExtrusionAlongPathDlg", modal, - WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | Qt::WDestructiveClose ) +SMESHGUI_ExtrusionAlongPathDlg::SMESHGUI_ExtrusionAlongPathDlg( SMESHGUI* theModule, + bool modal ) + : QDialog( SMESH::GetDesktop( theModule ), "SMESHGUI_ExtrusionAlongPathDlg", modal, + WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | Qt::WDestructiveClose), + mySMESHGUI( theModule ), + mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ), + myViewWindow( SMESH::GetViewWindow( theModule ) ), + mySelector( myViewWindow->GetSelector() ) { - MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::SMESHGUI_ExtrusionAlongPathDlg"); + QPixmap edgeImage (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_DLG_EDGE"))); + QPixmap faceImage (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_DLG_TRIANGLE"))); + QPixmap selectImage (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT"))); + QPixmap addImage (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_APPEND"))); + QPixmap removeImage (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_REMOVE"))); + myType = -1; - QPixmap edgeImage ( QAD_Desktop::getResourceManager()->loadPixmap( "SMESH", tr( "ICON_DLG_EDGE" ) ) ); - QPixmap faceImage ( QAD_Desktop::getResourceManager()->loadPixmap( "SMESH", tr( "ICON_DLG_TRIANGLE" ) ) ); - QPixmap selectImage( QAD_Desktop::getResourceManager()->loadPixmap( "SMESH", tr( "ICON_SELECT" ) ) ); - QPixmap addImage ( QAD_Desktop::getResourceManager()->loadPixmap( "SMESH", tr( "ICON_APPEND" ) ) ); - QPixmap removeImage( QAD_Desktop::getResourceManager()->loadPixmap( "SMESH", tr( "ICON_REMOVE" ) ) ); - setCaption( tr( "EXTRUSION_ALONG_PATH" ) ); - setSizeGripEnabled( TRUE ); + setCaption(tr("EXTRUSION_ALONG_PATH")); + setSizeGripEnabled(TRUE); - QGridLayout* topLayout = new QGridLayout( this ); - topLayout->setSpacing( 6 ); topLayout->setMargin( 11 ); + QGridLayout* topLayout = new QGridLayout(this); + topLayout->setSpacing(6); + topLayout->setMargin(11); /***************************************************************/ // Elements type group box (1d / 2d elements) - ElementsTypeGrp = new QButtonGroup( tr( "SMESH_EXTRUSION" ), this ); - ElementsTypeGrp->setColumnLayout( 0, Qt::Vertical ); - ElementsTypeGrp->layout()->setSpacing( 0 ); ElementsTypeGrp->layout()->setMargin( 0 ); - QGridLayout* ElementsTypeGrpLayout = new QGridLayout( ElementsTypeGrp->layout() ); - ElementsTypeGrpLayout->setAlignment( Qt::AlignTop ); - ElementsTypeGrpLayout->setSpacing( 6 ); ElementsTypeGrpLayout->setMargin( 11 ); + GroupConstructors = new QButtonGroup(tr("SMESH_EXTRUSION"), this); + GroupConstructors->setColumnLayout(0, Qt::Vertical); + GroupConstructors->layout()->setSpacing(0); + GroupConstructors->layout()->setMargin(0); + QGridLayout* GroupConstructorsLayout = new QGridLayout(GroupConstructors->layout()); + GroupConstructorsLayout->setAlignment(Qt::AlignTop); + GroupConstructorsLayout->setSpacing(6); GroupConstructorsLayout->setMargin(11); - Elements1dRB = new QRadioButton( ElementsTypeGrp ); - Elements1dRB->setPixmap( edgeImage ); - Elements2dRB = new QRadioButton( ElementsTypeGrp ); - Elements2dRB->setPixmap( faceImage ); - Elements1dRB->setChecked( true ); + Elements1dRB = new QRadioButton(GroupConstructors); + Elements1dRB->setPixmap(edgeImage); + Elements2dRB = new QRadioButton(GroupConstructors); + Elements2dRB->setPixmap(faceImage); + Elements1dRB->setChecked(true); // layouting - ElementsTypeGrpLayout->addWidget( Elements1dRB, 0, 0 ); - ElementsTypeGrpLayout->addWidget( Elements2dRB, 0, 2 ); - + GroupConstructorsLayout->addWidget(Elements1dRB, 0, 0); + GroupConstructorsLayout->addWidget(Elements2dRB, 0, 2); + /***************************************************************/ // Arguments group box - ArgumentsGrp = new QGroupBox( tr( "EXTRUSION_1D" ), this ); - ArgumentsGrp->setColumnLayout( 0, Qt::Vertical ); - ArgumentsGrp->layout()->setSpacing( 0 ); ArgumentsGrp->layout()->setMargin( 0 ); - QGridLayout* ArgumentsGrpLayout = new QGridLayout( ArgumentsGrp->layout() ); - ArgumentsGrpLayout->setAlignment( Qt::AlignTop ); - ArgumentsGrpLayout->setSpacing( 6 ); ArgumentsGrpLayout->setMargin( 11 ); + GroupArguments = new QGroupBox(tr("EXTRUSION_1D"), this); + GroupArguments->setColumnLayout(0, Qt::Vertical); + GroupArguments->layout()->setSpacing(0); GroupArguments->layout()->setMargin(0); + QGridLayout* GroupArgumentsLayout = new QGridLayout(GroupArguments->layout()); + GroupArgumentsLayout->setAlignment(Qt::AlignTop); + GroupArgumentsLayout->setSpacing(6); GroupArgumentsLayout->setMargin(11); // Controls for elements selection - ElementsLab = new QLabel( tr( "SMESH_ID_ELEMENTS" ), ArgumentsGrp ); + ElementsLab = new QLabel(tr("SMESH_ID_ELEMENTS"), GroupArguments); - SelectElementsButton = new QToolButton( ArgumentsGrp ); - SelectElementsButton->setPixmap( selectImage ); + SelectElementsButton = new QToolButton(GroupArguments); + SelectElementsButton->setPixmap(selectImage); - ElementsLineEdit = new QLineEdit( ArgumentsGrp ); - ElementsLineEdit->setValidator( new SMESHGUI_IdValidator( this ) ); + ElementsLineEdit = new QLineEdit(GroupArguments); + ElementsLineEdit->setValidator(new SMESHGUI_IdValidator(this)); // Controls for the whole mesh selection - MeshCheck = new QCheckBox( tr( "SMESH_SELECT_WHOLE_MESH" ), ArgumentsGrp ); + MeshCheck = new QCheckBox(tr("SMESH_SELECT_WHOLE_MESH"), GroupArguments); // Controls for path selection - PathGrp = new QGroupBox( tr( "SMESH_PATH" ), ArgumentsGrp ); - PathGrp->setColumnLayout( 0, Qt::Vertical ); - PathGrp->layout()->setSpacing( 0 ); PathGrp->layout()->setMargin( 0 ); - QGridLayout* PathGrpLayout = new QGridLayout( PathGrp->layout() ); - PathGrpLayout->setAlignment( Qt::AlignTop ); - PathGrpLayout->setSpacing( 6 ); PathGrpLayout->setMargin( 11 ); - + PathGrp = new QGroupBox(tr("SMESH_PATH"), GroupArguments); + PathGrp->setColumnLayout(0, Qt::Vertical); + PathGrp->layout()->setSpacing(0); PathGrp->layout()->setMargin(0); + QGridLayout* PathGrpLayout = new QGridLayout(PathGrp->layout()); + PathGrpLayout->setAlignment(Qt::AlignTop); + PathGrpLayout->setSpacing(6); PathGrpLayout->setMargin(11); + // Controls for path mesh selection - PathMeshLab = new QLabel( tr( "SMESH_PATH_MESH" ), PathGrp ); + PathMeshLab = new QLabel(tr("SMESH_PATH_MESH"), PathGrp); - SelectPathMeshButton = new QToolButton( PathGrp ); - SelectPathMeshButton->setPixmap( selectImage ); + SelectPathMeshButton = new QToolButton(PathGrp); + SelectPathMeshButton->setPixmap(selectImage); - PathMeshLineEdit = new QLineEdit( PathGrp ); - PathMeshLineEdit->setReadOnly( true ); + PathMeshLineEdit = new QLineEdit(PathGrp); + PathMeshLineEdit->setReadOnly(true); // Controls for path shape selection - PathShapeLab = new QLabel( tr( "SMESH_PATH_SHAPE" ), PathGrp ); + PathShapeLab = new QLabel(tr("SMESH_PATH_SHAPE"), PathGrp); - SelectPathShapeButton = new QToolButton( PathGrp ); - SelectPathShapeButton->setPixmap( selectImage ); + SelectPathShapeButton = new QToolButton(PathGrp); + SelectPathShapeButton->setPixmap(selectImage); - PathShapeLineEdit = new QLineEdit( PathGrp ); - PathShapeLineEdit->setReadOnly( true ); + PathShapeLineEdit = new QLineEdit(PathGrp); + PathShapeLineEdit->setReadOnly(true); // Controls for path starting point selection - StartPointLab = new QLabel( tr( "SMESH_PATH_START" ), PathGrp ); + StartPointLab = new QLabel(tr("SMESH_PATH_START"), PathGrp); - SelectStartPointButton = new QToolButton( PathGrp ); - SelectStartPointButton->setPixmap( selectImage ); + SelectStartPointButton = new QToolButton(PathGrp); + SelectStartPointButton->setPixmap(selectImage); - StartPointLineEdit = new QLineEdit( PathGrp ); - StartPointLineEdit->setValidator( new QIntValidator( this ) ); + StartPointLineEdit = new QLineEdit(PathGrp); + StartPointLineEdit->setValidator(new QIntValidator(this)); // layouting - PathGrpLayout->addWidget( PathMeshLab, 0, 0 ); - PathGrpLayout->addWidget( SelectPathMeshButton, 0, 1 ); - PathGrpLayout->addWidget( PathMeshLineEdit, 0, 2 ); - PathGrpLayout->addWidget( PathShapeLab, 1, 0 ); - PathGrpLayout->addWidget( SelectPathShapeButton, 1, 1 ); - PathGrpLayout->addWidget( PathShapeLineEdit, 1, 2 ); - PathGrpLayout->addWidget( StartPointLab, 2, 0 ); - PathGrpLayout->addWidget( SelectStartPointButton, 2, 1 ); - PathGrpLayout->addWidget( StartPointLineEdit, 2, 2 ); + PathGrpLayout->addWidget(PathMeshLab, 0, 0); + PathGrpLayout->addWidget(SelectPathMeshButton, 0, 1); + PathGrpLayout->addWidget(PathMeshLineEdit, 0, 2); + PathGrpLayout->addWidget(PathShapeLab, 1, 0); + PathGrpLayout->addWidget(SelectPathShapeButton, 1, 1); + PathGrpLayout->addWidget(PathShapeLineEdit, 1, 2); + PathGrpLayout->addWidget(StartPointLab, 2, 0); + PathGrpLayout->addWidget(SelectStartPointButton, 2, 1); + PathGrpLayout->addWidget(StartPointLineEdit, 2, 2); // Controls for base point defining - BasePointCheck = new QCheckBox( tr( "SMESH_USE_BASE_POINT" ), ArgumentsGrp ); + BasePointCheck = new QCheckBox(tr("SMESH_USE_BASE_POINT"), GroupArguments); - BasePointGrp = new QGroupBox( tr( "SMESH_BASE_POINT" ), ArgumentsGrp ); - BasePointGrp->setColumnLayout( 0, Qt::Vertical ); - BasePointGrp->layout()->setSpacing( 0 ); BasePointGrp->layout()->setMargin( 0 ); - QGridLayout* BasePointGrpLayout = new QGridLayout( BasePointGrp->layout() ); - BasePointGrpLayout->setAlignment( Qt::AlignTop ); - BasePointGrpLayout->setSpacing( 6 ); BasePointGrpLayout->setMargin( 11 ); - - SelectBasePointButton = new QToolButton( BasePointGrp ); - SelectBasePointButton->setPixmap( selectImage ); + BasePointGrp = new QGroupBox(tr("SMESH_BASE_POINT"), GroupArguments); + BasePointGrp->setColumnLayout(0, Qt::Vertical); + BasePointGrp->layout()->setSpacing(0); BasePointGrp->layout()->setMargin(0); + QGridLayout* BasePointGrpLayout = new QGridLayout(BasePointGrp->layout()); + BasePointGrpLayout->setAlignment(Qt::AlignTop); + BasePointGrpLayout->setSpacing(6); BasePointGrpLayout->setMargin(11); - XLab = new QLabel( tr( "SMESH_X" ), BasePointGrp ); - XSpin = new SMESHGUI_SpinBox( BasePointGrp ); - YLab = new QLabel( tr( "SMESH_Y" ), BasePointGrp ); - YSpin = new SMESHGUI_SpinBox( BasePointGrp ); - ZLab = new QLabel( tr( "SMESH_Z" ), BasePointGrp ); - ZSpin = new SMESHGUI_SpinBox( BasePointGrp ); + SelectBasePointButton = new QToolButton(BasePointGrp); + SelectBasePointButton->setPixmap(selectImage); + + XLab = new QLabel(tr("SMESH_X"), BasePointGrp); + XSpin = new SMESHGUI_SpinBox(BasePointGrp); + YLab = new QLabel(tr("SMESH_Y"), BasePointGrp); + YSpin = new SMESHGUI_SpinBox(BasePointGrp); + ZLab = new QLabel(tr("SMESH_Z"), BasePointGrp); + ZSpin = new SMESHGUI_SpinBox(BasePointGrp); // layouting - BasePointGrpLayout->addWidget( SelectBasePointButton, 0, 0 ); - BasePointGrpLayout->addWidget( XLab, 0, 1 ); - BasePointGrpLayout->addWidget( XSpin, 0, 2 ); - BasePointGrpLayout->addWidget( YLab, 0, 3 ); - BasePointGrpLayout->addWidget( YSpin, 0, 4 ); - BasePointGrpLayout->addWidget( ZLab, 0, 5 ); - BasePointGrpLayout->addWidget( ZSpin, 0, 6 ); + BasePointGrpLayout->addWidget(SelectBasePointButton, 0, 0); + BasePointGrpLayout->addWidget(XLab, 0, 1); + BasePointGrpLayout->addWidget(XSpin, 0, 2); + BasePointGrpLayout->addWidget(YLab, 0, 3); + BasePointGrpLayout->addWidget(YSpin, 0, 4); + BasePointGrpLayout->addWidget(ZLab, 0, 5); + BasePointGrpLayout->addWidget(ZSpin, 0, 6); // Controls for angles defining - AnglesCheck = new QCheckBox( tr( "SMESH_USE_ANGLES" ), ArgumentsGrp ); - - AnglesGrp = new QGroupBox( tr( "SMESH_ANGLES" ), ArgumentsGrp ); - AnglesGrp->setColumnLayout( 0, Qt::Vertical ); - AnglesGrp->layout()->setSpacing( 0 ); AnglesGrp->layout()->setMargin( 0 ); - QGridLayout* AnglesGrpLayout = new QGridLayout( AnglesGrp->layout() ); - AnglesGrpLayout->setAlignment( Qt::AlignTop ); - AnglesGrpLayout->setSpacing( 6 ); AnglesGrpLayout->setMargin( 11 ); - - AnglesList = new QListBox( AnglesGrp ); - AnglesList->setSelectionMode( QListBox::Extended ); + AnglesCheck = new QCheckBox(tr("SMESH_USE_ANGLES"), GroupArguments); - AddAngleButton = new QToolButton( AnglesGrp ); - AddAngleButton->setPixmap( addImage ); + AnglesGrp = new QGroupBox(tr("SMESH_ANGLES"), GroupArguments); + AnglesGrp->setColumnLayout(0, Qt::Vertical); + AnglesGrp->layout()->setSpacing(0); AnglesGrp->layout()->setMargin(0); + QGridLayout* AnglesGrpLayout = new QGridLayout(AnglesGrp->layout()); + AnglesGrpLayout->setAlignment(Qt::AlignTop); + AnglesGrpLayout->setSpacing(6); AnglesGrpLayout->setMargin(11); - RemoveAngleButton = new QToolButton( AnglesGrp ); - RemoveAngleButton->setPixmap( removeImage ); + AnglesList = new QListBox(AnglesGrp); + AnglesList->setSelectionMode(QListBox::Extended); - AngleSpin = new SMESHGUI_SpinBox( AnglesGrp ); + AddAngleButton = new QToolButton(AnglesGrp); + AddAngleButton->setPixmap(addImage); + + RemoveAngleButton = new QToolButton(AnglesGrp); + RemoveAngleButton->setPixmap(removeImage); + + AngleSpin = new SMESHGUI_SpinBox(AnglesGrp); // layouting - QVBoxLayout* bLayout = new QVBoxLayout(); - bLayout->addWidget( AddAngleButton ); - bLayout->addSpacing( 6 ); - bLayout->addWidget( RemoveAngleButton ); + QVBoxLayout* bLayout = new QVBoxLayout(); + bLayout->addWidget(AddAngleButton); + bLayout->addSpacing(6); + bLayout->addWidget(RemoveAngleButton); bLayout->addStretch(); - AnglesGrpLayout->addMultiCellWidget( AnglesList, 0, 1, 0, 0 ); - AnglesGrpLayout->addMultiCellLayout( bLayout, 0, 1, 1, 1 ); - AnglesGrpLayout->addWidget( AngleSpin, 0, 2 ); - AnglesGrpLayout->setRowStretch( 1, 10 ); - + AnglesGrpLayout->addMultiCellWidget(AnglesList, 0, 1, 0, 0); + AnglesGrpLayout->addMultiCellLayout(bLayout, 0, 1, 1, 1); + AnglesGrpLayout->addWidget( AngleSpin, 0, 2 ); + AnglesGrpLayout->setRowStretch(1, 10); + // layouting - ArgumentsGrpLayout->addWidget( ElementsLab, 0, 0 ); - ArgumentsGrpLayout->addWidget( SelectElementsButton, 0, 1 ); - ArgumentsGrpLayout->addWidget( ElementsLineEdit, 0, 2 ); - ArgumentsGrpLayout->addMultiCellWidget( MeshCheck, 1, 1, 0, 2 ); - ArgumentsGrpLayout->addMultiCellWidget( PathGrp, 2, 2, 0, 2 ); - ArgumentsGrpLayout->addWidget( BasePointCheck, 3, 0 ); - ArgumentsGrpLayout->addMultiCellWidget( BasePointGrp, 3, 4, 1, 2 ); - ArgumentsGrpLayout->addWidget( AnglesCheck, 5, 0 ); - ArgumentsGrpLayout->addMultiCellWidget( AnglesGrp, 5, 6, 1, 2 ); - ArgumentsGrpLayout->setRowStretch( 6, 10 ); + GroupArgumentsLayout->addWidget( ElementsLab, 0, 0 ); + GroupArgumentsLayout->addWidget( SelectElementsButton, 0, 1 ); + GroupArgumentsLayout->addWidget( ElementsLineEdit, 0, 2 ); + GroupArgumentsLayout->addMultiCellWidget(MeshCheck, 1, 1, 0, 2); + GroupArgumentsLayout->addMultiCellWidget(PathGrp, 2, 2, 0, 2); + GroupArgumentsLayout->addWidget( BasePointCheck, 3, 0 ); + GroupArgumentsLayout->addMultiCellWidget(BasePointGrp, 3, 4, 1, 2); + GroupArgumentsLayout->addWidget( AnglesCheck, 5, 0 ); + GroupArgumentsLayout->addMultiCellWidget(AnglesGrp, 5, 6, 1, 2); + GroupArgumentsLayout->setRowStretch(6, 10); /***************************************************************/ // common buttons group box - ButtonsGrp = new QGroupBox( this ); - ButtonsGrp->setColumnLayout( 0, Qt::Vertical ); - ButtonsGrp->layout()->setSpacing( 0 ); ButtonsGrp->layout()->setMargin( 0 ); - QGridLayout* ButtonsGrpLayout = new QGridLayout( ButtonsGrp->layout() ); - ButtonsGrpLayout->setAlignment( Qt::AlignTop ); - ButtonsGrpLayout->setSpacing( 6 ); ButtonsGrpLayout->setMargin( 11 ); + GroupButtons = new QGroupBox(this); + GroupButtons->setColumnLayout(0, Qt::Vertical); + GroupButtons->layout()->setSpacing(0); + GroupButtons->layout()->setMargin(0); + QGridLayout* GroupButtonsLayout = new QGridLayout(GroupButtons->layout()); + GroupButtonsLayout->setAlignment(Qt::AlignTop); + GroupButtonsLayout->setSpacing(6); GroupButtonsLayout->setMargin(11); - OkButton = new QPushButton( tr( "SMESH_BUT_OK" ), ButtonsGrp ); - OkButton->setAutoDefault( true ); - OkButton->setDefault( true ); + OkButton = new QPushButton(tr("SMESH_BUT_OK"), GroupButtons); + OkButton->setAutoDefault(true); + OkButton->setDefault(true); - ApplyButton = new QPushButton( tr( "SMESH_BUT_APPLY" ), ButtonsGrp ); - ApplyButton->setAutoDefault( true ); + ApplyButton = new QPushButton(tr("SMESH_BUT_APPLY"), GroupButtons); + ApplyButton->setAutoDefault(true); - CloseButton = new QPushButton( tr( "SMESH_BUT_CLOSE" ), ButtonsGrp ); - CloseButton->setAutoDefault( true ); + CloseButton = new QPushButton(tr("SMESH_BUT_CLOSE"), GroupButtons); + CloseButton->setAutoDefault(true); // layouting - ButtonsGrpLayout->addWidget( OkButton, 0, 0 ); - ButtonsGrpLayout->addWidget( ApplyButton, 0, 1 ); - ButtonsGrpLayout->addWidget( CloseButton, 0, 3 ); - ButtonsGrpLayout->addColSpacing( 2, 10 ); - ButtonsGrpLayout->setColStretch( 2, 10 ); + GroupButtonsLayout->addWidget(OkButton, 0, 0); + GroupButtonsLayout->addWidget(ApplyButton, 0, 1); + GroupButtonsLayout->addWidget(CloseButton, 0, 3); + GroupButtonsLayout->addColSpacing(2, 10); + GroupButtonsLayout->setColStretch(2, 10); /***************************************************************/ // layouting - topLayout->addWidget( ElementsTypeGrp, 0, 0 ); - topLayout->addWidget( ArgumentsGrp, 1, 0 ); - topLayout->addWidget( ButtonsGrp, 2, 0 ); + topLayout->addWidget(GroupConstructors, 0, 0); + topLayout->addWidget(GroupArguments, 1, 0); + topLayout->addWidget(GroupButtons, 2, 0); /***************************************************************/ // Initialisations - XSpin->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 ); - YSpin->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 ); - ZSpin->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 ); - AngleSpin->RangeStepAndValidator( -999999.999, +999999.999, 5.0, 3 ); - - mySelection = Sel; - mySMESHGUI = SMESHGUI::GetSMESHGUI() ; - mySMESHGUI->SetActiveDialogBox( this ) ; - + XSpin->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3); + YSpin->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3); + ZSpin->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3); + AngleSpin->RangeStepAndValidator(-999999.999, +999999.999, 5.0, 3); + + mySMESHGUI->SetActiveDialogBox(this); + // Costruction of the logical filter for the elements: mesh/sub-mesh/group - SMESH_ListOfFilter aListOfFilters; - Handle(SMESH_TypeFilter) aMeshOrSubMeshFilter = new SMESH_TypeFilter( MESHorSUBMESH ); - if ( !aMeshOrSubMeshFilter.IsNull() ) - aListOfFilters.Append( aMeshOrSubMeshFilter ); - Handle(SMESH_TypeFilter) aSmeshGroupFilter = new SMESH_TypeFilter( GROUP ); - if ( !aSmeshGroupFilter.IsNull() ) - aListOfFilters.Append( aSmeshGroupFilter ); - - myElementsFilter = new SMESH_LogicalFilter( aListOfFilters, SMESH_LogicalFilter::LO_OR ); - - myPathMeshFilter = new SMESH_TypeFilter( MESH ); - + SMESH_TypeFilter* aMeshOrSubMeshFilter = new SMESH_TypeFilter (MESHorSUBMESH); + SMESH_TypeFilter* aSmeshGroupFilter = new SMESH_TypeFilter (GROUP); + + QPtrList aListOfFilters; + if (aMeshOrSubMeshFilter) aListOfFilters.append(aMeshOrSubMeshFilter); + if (aSmeshGroupFilter) aListOfFilters.append(aSmeshGroupFilter); + + myElementsFilter = new SMESH_LogicalFilter (aListOfFilters, SMESH_LogicalFilter::LO_OR); + myPathMeshFilter = new SMESH_TypeFilter (MESH); + Init(); /***************************************************************/ // signals-slots connections - connect( OkButton, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); - connect( CloseButton, SIGNAL( clicked() ), this, SLOT( reject() ) ) ; - connect( ApplyButton, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) ); + connect(OkButton, SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(CloseButton, SIGNAL(clicked()), this, SLOT(reject())); + connect(ApplyButton, SIGNAL(clicked()), this, SLOT(ClickOnApply())); - connect( AddAngleButton, SIGNAL( clicked() ), this, SLOT( OnAngleAdded() ) ); - connect( RemoveAngleButton, SIGNAL( clicked() ), this, SLOT( OnAngleRemoved() ) ); + connect(AddAngleButton, SIGNAL(clicked()), this, SLOT(OnAngleAdded())); + connect(RemoveAngleButton, SIGNAL(clicked()), this, SLOT(OnAngleRemoved())); - connect( ElementsTypeGrp, SIGNAL( clicked( int ) ), SLOT( TypeChanged( int ) ) ); - - connect( SelectElementsButton, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; - connect( SelectPathMeshButton, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; - connect( SelectPathShapeButton, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; - connect( SelectStartPointButton, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; - connect( SelectBasePointButton, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + connect(GroupConstructors, SIGNAL(clicked(int)), SLOT(ConstructorsClicked(int))); - connect( mySMESHGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; - connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); - connect( mySMESHGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( reject() ) ) ; + connect(SelectElementsButton, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(SelectPathMeshButton, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(SelectPathShapeButton, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(SelectStartPointButton, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(SelectBasePointButton, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - connect( ElementsLineEdit, SIGNAL( textChanged( const QString& ) ), - SLOT( onTextChange( const QString& ) ) ); - connect( StartPointLineEdit, SIGNAL( textChanged( const QString& ) ), - SLOT( onTextChange( const QString& ) ) ); + connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog())); + connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(reject())); - connect( MeshCheck, SIGNAL( toggled( bool ) ), SLOT( onSelectMesh() ) ); - connect( AnglesCheck, SIGNAL( toggled( bool ) ), SLOT( onAnglesCheck() ) ); - connect( BasePointCheck, SIGNAL( toggled( bool ) ), SLOT( onBasePointCheck() ) ); + connect(ElementsLineEdit, SIGNAL(textChanged(const QString&)), + SLOT(onTextChange(const QString&))); + connect(StartPointLineEdit, SIGNAL(textChanged(const QString&)), + SLOT(onTextChange(const QString&))); - AnglesList->installEventFilter( this ); - ElementsLineEdit->installEventFilter( this ); - StartPointLineEdit->installEventFilter( this ); - XSpin->editor()->installEventFilter( this ); - YSpin->editor()->installEventFilter( this ); - ZSpin->editor()->installEventFilter( this ); + connect(MeshCheck, SIGNAL(toggled(bool)), SLOT(onSelectMesh())); + connect(AnglesCheck, SIGNAL(toggled(bool)), SLOT(onAnglesCheck())); + connect(BasePointCheck, SIGNAL(toggled(bool)), SLOT(onBasePointCheck())); + + AnglesList->installEventFilter(this); + ElementsLineEdit->installEventFilter(this); + StartPointLineEdit->installEventFilter(this); + XSpin->editor()->installEventFilter(this); + YSpin->editor()->installEventFilter(this); + ZSpin->editor()->installEventFilter(this); /***************************************************************/ // set position and show dialog box - int x, y ; - mySMESHGUI->DefineDlgPosition( this, x, y ) ; - this->move( x, y ) ; - this->show() ; // displays Dialog + int x, y; + mySMESHGUI->DefineDlgPosition(this, x, y); + this->move(x, y); + this->show(); // displays Dialog } //================================================================================= -// function : SMESHGUI_ExtrusionAlongPathDlg::~SMESHGUI_ExtrusionAlongPathDlg() +// function : ~SMESHGUI_ExtrusionAlongPathDlg() // purpose : destructor //================================================================================= SMESHGUI_ExtrusionAlongPathDlg::~SMESHGUI_ExtrusionAlongPathDlg() { - MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::~SMESHGUI_ExtrusionAlongPathDlg"); // no need to delete child widgets, Qt does it all for us } //================================================================================= -// function : SMESHGUI_ExtrusionAlongPathDlg::eventFilter -// purpose : event filter -//================================================================================= -bool SMESHGUI_ExtrusionAlongPathDlg::eventFilter( QObject* object, QEvent* event ) -{ - if ( event->type() == QEvent::KeyPress ) { - QKeyEvent* ke = ( QKeyEvent* )event; - if ( object == AnglesList ) { - if ( ke->key() == Key_Delete ) - OnAngleRemoved(); - } - } - else if ( event->type() == QEvent::FocusIn ) { - if ( object == ElementsLineEdit ) { - if ( myEditCurrentArgument != ElementsLineEdit ) - SetEditCurrentArgument( SelectElementsButton ); - } - else if ( object == StartPointLineEdit ) { - if ( myEditCurrentArgument != StartPointLineEdit ) - SetEditCurrentArgument( SelectStartPointButton ); - } - else if ( object == XSpin->editor() || object == YSpin->editor() || object == ZSpin->editor() ) { - if ( myEditCurrentArgument != XSpin ) - SetEditCurrentArgument( SelectBasePointButton ); - } - } - return QDialog::eventFilter( object, event ); -} - -//================================================================================= -// function : SMESHGUI_ExtrusionAlongPathDlg::Init() +// function : Init() // purpose : initialization //================================================================================= -void SMESHGUI_ExtrusionAlongPathDlg::Init( bool ResetControls ) +void SMESHGUI_ExtrusionAlongPathDlg::Init (bool ResetControls) { - MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::Init"); myBusy = false; myEditCurrentArgument = 0; - + myMesh = SMESH::SMESH_Mesh::_nil(); myIDSource = SMESH::SMESH_IDSource::_nil(); myMeshActor = 0; myPathMesh = SMESH::SMESH_Mesh::_nil(); myPathShape = GEOM::GEOM_Object::_nil(); - + ElementsLineEdit->clear(); PathMeshLineEdit->clear(); PathShapeLineEdit->clear(); StartPointLineEdit->clear(); - if( ResetControls ) { - XSpin->SetValue( 0.0 ); - YSpin->SetValue( 0.0 ); - ZSpin->SetValue( 0.0 ); - - AngleSpin->SetValue( 45 ); - MeshCheck->setChecked( false ); - TypeChanged( 0 ); + if (ResetControls) { + XSpin->SetValue(0.0); + YSpin->SetValue(0.0); + ZSpin->SetValue(0.0); + + AngleSpin->SetValue(45); + MeshCheck->setChecked(false); + ConstructorsClicked(0); onSelectMesh(); onAnglesCheck(); onBasePointCheck(); } - SetEditCurrentArgument( 0 ); + SetEditCurrentArgument(0); } //================================================================================= -// function : SMESHGUI_ExtrusionAlongPathDlg::TypeChanged() -// purpose : Called when user changes type of elements ( 1d / 2d ) +// function : ConstructorsClicked() +// purpose : Called when user changes type of elements (1d / 2d) //================================================================================= -void SMESHGUI_ExtrusionAlongPathDlg::TypeChanged( int type ) +void SMESHGUI_ExtrusionAlongPathDlg::ConstructorsClicked (int type) { - MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::TypeChanged"); - if ( myType != type ) { - disconnect( mySelection, 0, this, 0 ); - - if ( type == 0 ) - ArgumentsGrp->setTitle( tr( "EXTRUSION_1D" ) ); - else if ( type == 1 ) - ArgumentsGrp->setTitle( tr( "EXTRUSION_2D" ) ); - - // clear elements ID list - if ( !MeshCheck->isChecked() ) { - ElementsLineEdit->clear(); - } - // set selection mode if necessary - if( myEditCurrentArgument == ElementsLineEdit ) { - mySelection->ClearIObjects(); - mySelection->ClearFilters(); - SMESH::SetPickable(); - - SMESH::SetPointRepresentation( false ); - if ( MeshCheck->isChecked() ) { - QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); - mySelection->AddFilter( myElementsFilter ); - } - else { - if ( type == 0 ) - QAD_Application::getDesktop()->SetSelectionMode( EdgeSelection, true ); - if ( type == 1 ) - QAD_Application::getDesktop()->SetSelectionMode( FaceSelection, true ); - } - } - connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); - } - myType = type; -} + if (myType == type) return; + disconnect(mySelectionMgr, 0, this, 0); + + if (type == 0) + GroupArguments->setTitle(tr("EXTRUSION_1D")); + else if (type == 1) + GroupArguments->setTitle(tr("EXTRUSION_2D")); + + // clear elements ID list + if (!MeshCheck->isChecked()) { + ElementsLineEdit->clear(); + } + // set selection mode if necessary + if (myEditCurrentArgument == ElementsLineEdit) { + mySelectionMgr->clearSelected(); + mySelectionMgr->clearFilters(); + SMESH::SetPickable(); + + SMESH::SetPointRepresentation(false); + if (MeshCheck->isChecked()) { + myViewWindow->SetSelectionMode(ActorSelection); + mySelectionMgr->installFilter(myElementsFilter); + } else { + if (type == 0) + myViewWindow->SetSelectionMode(EdgeSelection); + if (type == 1) + myViewWindow->SetSelectionMode(FaceSelection); + } + } + connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + + myType = type; +} //================================================================================= -// function : SMESHGUI_ExtrusionAlongPathDlg::ClickOnApply() +// function : ClickOnApply() // purpose : Called when user presses button //================================================================================= bool SMESHGUI_ExtrusionAlongPathDlg::ClickOnApply() { - MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::ClickOnApply"); - if ( mySMESHGUI->ActiveStudyLocked() ) { + if (mySMESHGUI->isActiveStudyLocked()) return false; - } - - if( myMesh->_is_nil() || MeshCheck->isChecked() && myIDSource->_is_nil() || !myMeshActor || myPathMesh->_is_nil() || myPathShape->_is_nil() ) { + + if (myMesh->_is_nil() || MeshCheck->isChecked() && myIDSource->_is_nil() || + !myMeshActor || myPathMesh->_is_nil() || myPathShape->_is_nil()) return false; - } SMESH::long_array_var anElementsId = new SMESH::long_array; - if ( MeshCheck->isChecked() ) { + if (MeshCheck->isChecked()) { // If "Select whole mesh, submesh or group" check box is on -> // get all elements of the required type from the object selected // if MESH object is selected - if ( !CORBA::is_nil( SMESH::SMESH_Mesh::_narrow( myIDSource ) ) ) { + if (!CORBA::is_nil(SMESH::SMESH_Mesh::_narrow(myIDSource))) { // get mesh - SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( myIDSource ); + SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow(myIDSource); // get IDs from mesh... - if ( Elements1dRB->isChecked() ) + if (Elements1dRB->isChecked()) // 1d elements - anElementsId = aMesh->GetElementsByType( SMESH::EDGE ); - else if ( Elements2dRB->isChecked() ) { - anElementsId = aMesh->GetElementsByType( SMESH::FACE ); + anElementsId = aMesh->GetElementsByType(SMESH::EDGE); + else if (Elements2dRB->isChecked()) { + anElementsId = aMesh->GetElementsByType(SMESH::FACE); } } // SUBMESH is selected - if ( !CORBA::is_nil( SMESH::SMESH_subMesh::_narrow( myIDSource ) ) ) { + if (!CORBA::is_nil(SMESH::SMESH_subMesh::_narrow(myIDSource))) { // get submesh - SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( myIDSource ); + SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow(myIDSource); // get IDs from submesh - if ( Elements1dRB->isChecked() ) + if (Elements1dRB->isChecked()) // 1d elements - anElementsId = aSubMesh->GetElementsByType( SMESH::EDGE ); - else if ( Elements2dRB->isChecked() ) + anElementsId = aSubMesh->GetElementsByType(SMESH::EDGE); + else if (Elements2dRB->isChecked()) // 2d elements - anElementsId = aSubMesh->GetElementsByType( SMESH::FACE ); - } + anElementsId = aSubMesh->GetElementsByType(SMESH::FACE); + } // GROUP is selected - if ( !CORBA::is_nil( SMESH::SMESH_GroupBase::_narrow( myIDSource ) ) ) { + if (!CORBA::is_nil(SMESH::SMESH_GroupBase::_narrow(myIDSource))) { // get smesh group - SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( myIDSource ); + SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow(myIDSource); // get IDs from group // 1d elements or 2d elements - if ( Elements1dRB->isChecked() && aGroup->GetType() == SMESH::EDGE || - Elements2dRB->isChecked() && aGroup->GetType() == SMESH::FACE ) + if (Elements1dRB->isChecked() && aGroup->GetType() == SMESH::EDGE || + Elements2dRB->isChecked() && aGroup->GetType() == SMESH::FACE) anElementsId = aGroup->GetListOfID(); } - } - else { + } else { // If "Select whole mesh, submesh or group" check box is off -> // use only elements of given type selected by user SMDS_Mesh* aMesh = myMeshActor->GetObject()->GetMesh(); - if ( aMesh ) { - QStringList aListElementsId = QStringList::split( " ", ElementsLineEdit->text(), false ); + if (aMesh) { + QStringList aListElementsId = QStringList::split(" ", ElementsLineEdit->text(), false); anElementsId = new SMESH::long_array; - anElementsId->length( aListElementsId.count() ); + anElementsId->length(aListElementsId.count()); bool bOk; int j = 0; - for ( int i = 0; i < aListElementsId.count(); i++ ) { - long ind = aListElementsId[ i ].toLong( &bOk ); - if ( bOk ) { - const SMDS_MeshElement* e = aMesh->FindElement( ind ); - if ( e ) { - bool typeMatch = Elements1dRB->isChecked() && e->GetType() == SMDSAbs_Edge || + for (int i = 0; i < aListElementsId.count(); i++) { + long ind = aListElementsId[ i ].toLong(&bOk); + if (bOk) { + const SMDS_MeshElement* e = aMesh->FindElement(ind); + if (e) { + bool typeMatch = Elements1dRB->isChecked() && e->GetType() == SMDSAbs_Edge || Elements2dRB->isChecked() && e->GetType() == SMDSAbs_Face; - if ( typeMatch ) + if (typeMatch) anElementsId[ j++ ] = ind; } } } - anElementsId->length( j ); + anElementsId->length(j); } } - - if ( anElementsId->length() <= 0 ) { + + if (anElementsId->length() <= 0) { return false; } - if ( StartPointLineEdit->text().stripWhiteSpace().isEmpty() ) { + if (StartPointLineEdit->text().stripWhiteSpace().isEmpty()) { return false; } - + bool bOk; - long aNodeStart = StartPointLineEdit->text().toLong( &bOk ); - if ( !bOk ) { + long aNodeStart = StartPointLineEdit->text().toLong(&bOk); + if (!bOk) { return false; } - + // get angles SMESH::double_array_var anAngles = new SMESH::double_array; - if ( AnglesCheck->isChecked() ) { - anAngles->length( AnglesList->count() ); + if (AnglesCheck->isChecked()) { + anAngles->length(AnglesList->count()); int j = 0; bool bOk; - for ( int i = 0; i < AnglesList->count(); i++ ) { - double angle = AnglesList->text( i ).toDouble( &bOk ); - if ( bOk ) + for (int i = 0; i < AnglesList->count(); i++) { + double angle = AnglesList->text(i).toDouble(&bOk); + if (bOk) anAngles[ j++ ] = angle*PI/180; } - anAngles->length( j ); + anAngles->length(j); } // get base point SMESH::PointStruct aBasePoint; - if ( BasePointCheck->isChecked() ) { + if (BasePointCheck->isChecked()) { aBasePoint.x = XSpin->GetValue(); aBasePoint.y = YSpin->GetValue(); aBasePoint.z = ZSpin->GetValue(); } - - try { - QAD_WaitCursor wc; - SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor(); - SMESH::SMESH_MeshEditor::Extrusion_Error retVal = - aMeshEditor->ExtrusionAlongPath( anElementsId.inout(), myPathMesh, myPathShape, aNodeStart, - AnglesCheck->isChecked(), anAngles.inout(), - BasePointCheck->isChecked(), aBasePoint ); - wc.stop(); - switch ( retVal ) { + try { + SUIT_OverrideCursor wc; + SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor(); + SMESH::SMESH_MeshEditor::Extrusion_Error retVal = + aMeshEditor->ExtrusionAlongPath(anElementsId.inout(), myPathMesh, myPathShape, aNodeStart, + AnglesCheck->isChecked(), anAngles.inout(), + BasePointCheck->isChecked(), aBasePoint); + + //wc.stop(); + wc.suspend(); + switch (retVal) { case SMESH::SMESH_MeshEditor::EXTR_NO_ELEMENTS: - QAD_MessageBox::warn1( QAD_Application::getDesktop(), - tr( "SMESH_ERROR" ), - tr( "NO_ELEMENTS_SELECTED" ), - tr( "SMESH_BUT_OK" ) ); + SUIT_MessageBox::warn1(SMESHGUI::desktop(), + tr("SMESH_ERROR"), + tr("NO_ELEMENTS_SELECTED"), + tr("SMESH_BUT_OK")); return false; break; case SMESH::SMESH_MeshEditor::EXTR_PATH_NOT_EDGE: - QAD_MessageBox::warn1( QAD_Application::getDesktop(), - tr( "SMESH_ERROR" ), - tr( "SELECTED_PATH_IS_NOT_EDGE" ), - tr( "SMESH_BUT_OK" ) ); + SUIT_MessageBox::warn1(SMESHGUI::desktop(), + tr("SMESH_ERROR"), + tr("SELECTED_PATH_IS_NOT_EDGE"), + tr("SMESH_BUT_OK")); return false; break; case SMESH::SMESH_MeshEditor::EXTR_BAD_PATH_SHAPE: - QAD_MessageBox::warn1( QAD_Application::getDesktop(), - tr( "SMESH_ERROR" ), - tr( "BAD_SHAPE_TYPE" ), - tr( "SMESH_BUT_OK" ) ); + SUIT_MessageBox::warn1(SMESHGUI::desktop(), + tr("SMESH_ERROR"), + tr("BAD_SHAPE_TYPE"), + tr("SMESH_BUT_OK")); return false; break; case SMESH::SMESH_MeshEditor::EXTR_BAD_STARTING_NODE: - QAD_MessageBox::warn1( QAD_Application::getDesktop(), - tr( "SMESH_ERROR" ), - tr( "EXTR_BAD_STARTING_NODE" ), - tr( "SMESH_BUT_OK" ) ); + SUIT_MessageBox::warn1(SMESHGUI::desktop(), + tr("SMESH_ERROR"), + tr("EXTR_BAD_STARTING_NODE"), + tr("SMESH_BUT_OK")); return false; break; case SMESH::SMESH_MeshEditor::EXTR_BAD_ANGLES_NUMBER: - QAD_MessageBox::warn1( QAD_Application::getDesktop(), - tr( "SMESH_ERROR" ), - tr( "WRONG_ANGLES_NUMBER" ), - tr( "SMESH_BUT_OK" ) ); + SUIT_MessageBox::warn1(SMESHGUI::desktop(), + tr("SMESH_ERROR"), + tr("WRONG_ANGLES_NUMBER"), + tr("SMESH_BUT_OK")); return false; break; case SMESH::SMESH_MeshEditor::EXTR_CANT_GET_TANGENT: - QAD_MessageBox::warn1( QAD_Application::getDesktop(), - tr( "SMESH_ERROR" ), - tr( "CANT_GET_TANGENT" ), - tr( "SMESH_BUT_OK" ) ); + SUIT_MessageBox::warn1(SMESHGUI::desktop(), + tr("SMESH_ERROR"), + tr("CANT_GET_TANGENT"), + tr("SMESH_BUT_OK")); return false; break; case SMESH::SMESH_MeshEditor::EXTR_OK: break; } - } - catch( ... ) { + } catch (...) { return false; } - - mySelection->ClearIObjects(); + + mySelectionMgr->clearSelected(); SMESH::UpdateView(); - Init( false ); - TypeChanged( GetConstructorId() ); + Init(false); + ConstructorsClicked(GetConstructorId()); return true; } //================================================================================= -// function : SMESHGUI_ExtrusionAlongPathDlg::ClickOnOk() +// function : ClickOnOk() // purpose : Called when user presses button //================================================================================= void SMESHGUI_ExtrusionAlongPathDlg::ClickOnOk() { - MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::ClickOnOk"); - if ( !ClickOnApply() ) - return; - reject(); + if (ClickOnApply()) + reject(); +} + +//================================================================================= +// function : reject() +// purpose : Called when dialog box is closed +//================================================================================= +void SMESHGUI_ExtrusionAlongPathDlg::reject() +{ + disconnect(mySelectionMgr, 0, this, 0); + mySelectionMgr->clearFilters(); + mySelectionMgr->clearSelected(); + SMESH::SetPickable(); // ??? + SMESH::SetPointRepresentation(false); + myViewWindow->SetSelectionMode(ActorSelection); + mySMESHGUI->ResetState(); + QDialog::reject(); } //======================================================================= -// function : SMESHGUI_ExtrusionAlongPathDlg::onTextChange -// purpose : +// function : onTextChange() +// purpose : //======================================================================= - -void SMESHGUI_ExtrusionAlongPathDlg::onTextChange(const QString& theNewText) +void SMESHGUI_ExtrusionAlongPathDlg::onTextChange (const QString& theNewText) { - MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::onTextChange"); QLineEdit* send = (QLineEdit*)sender(); - if ( send != StartPointLineEdit && send != ElementsLineEdit ) - send = ElementsLineEdit; // return if busy - if ( myBusy ) - return; + if (myBusy) return; // set busy flag - SetBusy sb( this ); - - if ( send == ElementsLineEdit && myEditCurrentArgument == ElementsLineEdit ) { + SetBusy sb (this); + + if (send != StartPointLineEdit && send != ElementsLineEdit) + send = ElementsLineEdit; + + if (send == ElementsLineEdit && myEditCurrentArgument == ElementsLineEdit) { // hilight entered elements SMDS_Mesh* aMesh = 0; - if ( myMeshActor ) + if (myMeshActor) aMesh = myMeshActor->GetObject()->GetMesh(); - if ( aMesh ) { - mySelection->ClearIObjects(); - mySelection->AddIObject( myMeshActor->getIO() ); - - QStringList aListId = QStringList::split( " ", theNewText, false ); + + if (aMesh) { + //mySelectionMgr->clearSelected(); + //mySelectionMgr->AddIObject(myMeshActor->getIO()); + SALOME_ListIO aList; + aList.Append(myMeshActor->getIO()); + mySelectionMgr->setSelectedObjects(aList, false); + + QStringList aListId = QStringList::split(" ", theNewText, false); bool bOk; - for ( int i = 0; i < aListId.count(); i++ ) { - long ind = aListId[ i ].toLong( &bOk ); - if ( bOk ) { - const SMDS_MeshElement* e = aMesh->FindElement( ind ); - if ( e ) { + const Handle(SALOME_InteractiveObject)& anIO = myMeshActor->getIO(); + TColStd_IndexedMapOfInteger selectedIndices; + TColStd_MapOfInteger newIndices; + mySelector->GetIndex(anIO, selectedIndices); + for (int i = 0; i < aListId.count(); i++) { + long ind = aListId[ i ].toLong(&bOk); + if (bOk) { + const SMDS_MeshElement* e = aMesh->FindElement(ind); + if (e) { // check also type of element - bool typeMatch = Elements1dRB->isChecked() && e->GetType() == SMDSAbs_Edge || + bool typeMatch = Elements1dRB->isChecked() && e->GetType() == SMDSAbs_Edge || Elements2dRB->isChecked() && e->GetType() == SMDSAbs_Face; - if ( typeMatch ) { - if ( !mySelection->IsIndexSelected( myMeshActor->getIO(), e->GetID() ) ) - mySelection->AddOrRemoveIndex( myMeshActor->getIO(), e->GetID(), true ); + if (typeMatch) { + if (selectedIndices.Add(e->GetID())) { + newIndices.Add(e->GetID()); + } } } } } + if (newIndices.Extent() > 0) { + mySelector->AddOrRemoveIndex(anIO, newIndices, true); + myViewWindow->highlight( anIO, true, true ); + } } - } - else if ( send == StartPointLineEdit && myEditCurrentArgument == StartPointLineEdit ) { - if ( !myPathMesh->_is_nil() ) { - SMESH_Actor* aPathActor = SMESH::FindActorByObject( myPathMesh ); + } else if (send == StartPointLineEdit && + myEditCurrentArgument == StartPointLineEdit) { + if (!myPathMesh->_is_nil()) { + SMESH_Actor* aPathActor = SMESH::FindActorByObject(myPathMesh); SMDS_Mesh* aMesh = 0; - if ( aPathActor ) + if (aPathActor) aMesh = aPathActor->GetObject()->GetMesh(); - if ( aMesh ) { - mySelection->ClearIObjects(); - mySelection->AddIObject( aPathActor->getIO() ); - + if (aMesh) { + //mySelectionMgr->clearSelected(); + //mySelectionMgr->AddIObject(aPathActor->getIO()); + SALOME_ListIO aList; + aList.Append(aPathActor->getIO()); + mySelectionMgr->setSelectedObjects(aList, false); + bool bOk; - long ind = theNewText.toLong( &bOk ); - if ( bOk ) { - const SMDS_MeshNode* n = aMesh->FindNode( ind ); - if ( n ) { - if ( !mySelection->IsIndexSelected( aPathActor->getIO(), n->GetID() ) ) { - mySelection->AddOrRemoveIndex( aPathActor->getIO(), n->GetID(), true ); + long ind = theNewText.toLong(&bOk); + if (bOk) { + const SMDS_MeshNode* n = aMesh->FindNode(ind); + if (n) { + //if (!mySelectionMgr->IsIndexSelected(aPathActor->getIO(), n->GetID())) { + TColStd_IndexedMapOfInteger selectedIndices; + TColStd_MapOfInteger newIndices; + mySelector->GetIndex(aPathActor->getIO(), selectedIndices); + if (selectedIndices.Add(n->GetID())) { + newIndices.Add(n->GetID()); + mySelector->AddOrRemoveIndex( aPathActor->getIO(), newIndices, true ); + myViewWindow->highlight( aPathActor->getIO(), true, true ); } } } @@ -740,66 +757,61 @@ void SMESHGUI_ExtrusionAlongPathDlg::onTextChange(const QString& theNewText) } //================================================================================= -// function : SMESHGUI_ExtrusionAlongPathDlg::SelectionIntoArgument() +// function : SelectionIntoArgument() // purpose : Called when selection as changed or other case //================================================================================= void SMESHGUI_ExtrusionAlongPathDlg::SelectionIntoArgument() { - MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::SelectionIntoArgument"); - // return if busy - if ( myBusy ) - return; - + if (myBusy) return; + // return if dialog box is inactive - if ( !ButtonsGrp->isEnabled() ) + if (!GroupButtons->isEnabled()) return; // selected objects count - int nbSel = mySelection->IObjectCount(); + const SALOME_ListIO& aList = mySelector->StoredIObjects(); + int nbSel = aList.Extent(); + if (nbSel != 1) + return; // set busy flag - SetBusy sb( this ); + SetBusy sb (this); - if ( myEditCurrentArgument == ElementsLineEdit ) { + if (myEditCurrentArgument == ElementsLineEdit) { // we are now selecting mesh elements (or whole mesh/submesh/group) // reset ElementsLineEdit->clear(); myMesh = SMESH::SMESH_Mesh::_nil(); myIDSource = SMESH::SMESH_IDSource::_nil(); myMeshActor = 0; - - // only one object is acceptable - if( nbSel != 1 ) - return; // try to get mesh from selection - Handle( SALOME_InteractiveObject ) IO = mySelection->firstIObject(); - myMesh = SMESH::GetMeshByIO( IO ); - if( myMesh->_is_nil() ) + Handle(SALOME_InteractiveObject) IO = aList.First(); + myMesh = SMESH::GetMeshByIO(IO); + if (myMesh->_is_nil()) return; // find actor - myMeshActor = SMESH::FindActorByObject( myMesh ); - if ( !myMeshActor ) + myMeshActor = SMESH::FindActorByObject(myMesh); + if (!myMeshActor) return; - if ( MeshCheck->isChecked() ) { + if (MeshCheck->isChecked()) { // If "Select whole mesh, submesh or group" check box is on -> // get ID source and put it's name to the edit box QString aString; - SMESH::GetNameOfSelectedIObjects( mySelection, aString ); + SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString); - myIDSource = SMESH::IObjectToInterface( IO ); - ElementsLineEdit->setText( aString ); - } - else { + myIDSource = SMESH::IObjectToInterface(IO); + ElementsLineEdit->setText(aString); + } else { // If "Select whole mesh, submesh or group" check box is off -> // try to get selected elements IDs QString aString; - int aNbUnits = SMESH::GetNameOfSelectedElements( mySelection, aString ); - ElementsLineEdit->setText( aString ); + //int aNbUnits = SMESH::GetNameOfSelectedElements(mySelectionMgr, aString); + SMESH::GetNameOfSelectedElements(mySelector, myMeshActor->getIO(), aString); + ElementsLineEdit->setText(aString); } - } - else if ( myEditCurrentArgument == PathMeshLineEdit ) { + } else if (myEditCurrentArgument == PathMeshLineEdit) { // we are now selecting path mesh // reset PathMeshLineEdit->clear(); @@ -808,21 +820,16 @@ void SMESHGUI_ExtrusionAlongPathDlg::SelectionIntoArgument() myPathShape = GEOM::GEOM_Object::_nil(); StartPointLineEdit->clear(); - // only one object is acceptable - if( nbSel != 1 ) - return; - // try to get mesh from selection - Handle( SALOME_InteractiveObject ) IO = mySelection->firstIObject(); - myPathMesh = SMESH::IObjectToInterface( IO ); - if( myPathMesh->_is_nil() ) + Handle(SALOME_InteractiveObject) IO = aList.First(); + myPathMesh = SMESH::IObjectToInterface(IO); + if(myPathMesh->_is_nil()) return; QString aString; - SMESH::GetNameOfSelectedIObjects( mySelection, aString ); - PathMeshLineEdit->setText( aString ); - } - else if ( myEditCurrentArgument == PathShapeLineEdit ) { + SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString); + PathMeshLineEdit->setText(aString); + } else if (myEditCurrentArgument == PathShapeLineEdit) { // we are now selecting path mesh // reset PathShapeLineEdit->clear(); @@ -830,338 +837,322 @@ void SMESHGUI_ExtrusionAlongPathDlg::SelectionIntoArgument() StartPointLineEdit->clear(); // return if path mesh is not yet selected - if ( myPathMesh->_is_nil() ) - return; - - // only one object is acceptable - if( nbSel != 1 ) + if (myPathMesh->_is_nil()) return; // try to get shape from selection - Handle( SALOME_InteractiveObject ) IO = mySelection->firstIObject(); - myPathShape = SMESH::IObjectToInterface( IO ); - if ( myPathShape->_is_nil() ) + Handle(SALOME_InteractiveObject) IO = aList.First(); + myPathShape = SMESH::IObjectToInterface(IO); + if (myPathShape->_is_nil()) return; QString aString; - SMESH::GetNameOfSelectedIObjects( mySelection, aString ); - PathShapeLineEdit->setText( aString ); - } - else if ( myEditCurrentArgument == StartPointLineEdit ) { + SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString); + PathShapeLineEdit->setText(aString); + } else if (myEditCurrentArgument == StartPointLineEdit) { // we are now selecting start point of path // reset StartPointLineEdit->clear(); // return if path mesh or path shape is not yet selected - if ( myPathMesh->_is_nil() || myPathShape->_is_nil() ) - return; - - // only one object is acceptable - if( nbSel != 1 ) + if (myPathMesh->_is_nil() || myPathShape->_is_nil()) return; // try to get shape from selection - Handle( SALOME_InteractiveObject ) IO = mySelection->firstIObject(); - + Handle(SALOME_InteractiveObject) IO = aList.First(); + QString aString; - int aNbUnits = SMESH::GetNameOfSelectedElements( mySelection, aString ); - if ( aNbUnits == 1 ) - StartPointLineEdit->setText( aString.stripWhiteSpace() ); - } - else if ( myEditCurrentArgument == XSpin ) { + int aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, myMeshActor->getIO(), aString); + if (aNbUnits == 1) + StartPointLineEdit->setText(aString.stripWhiteSpace()); + + } else if (myEditCurrentArgument == XSpin) { // we are now selecting base point // reset is not performed here! // return if is not enabled - if ( !BasePointGrp->isEnabled() ) + if (!BasePointGrp->isEnabled()) return; - // only one object is acceptable - if( nbSel != 1 ) - return; - // try to get shape from selection - Handle( SALOME_InteractiveObject ) IO = mySelection->firstIObject(); - + Handle(SALOME_InteractiveObject) IO = aList.First(); + // check if geom vertex is selected - GEOM::GEOM_Object_var aGeomObj = SMESH::IObjectToInterface( IO ); + GEOM::GEOM_Object_var aGeomObj = SMESH::IObjectToInterface(IO); TopoDS_Vertex aVertex; - if( !aGeomObj->_is_nil() ) { - if( aGeomObj->IsShape() && GEOMBase::GetShape( aGeomObj, aVertex ) && !aVertex.IsNull() ) { - gp_Pnt aPnt = BRep_Tool::Pnt( aVertex ); - XSpin->SetValue( aPnt.X() ); - YSpin->SetValue( aPnt.Y() ); - ZSpin->SetValue( aPnt.Z() ); + if (!aGeomObj->_is_nil()) { + if (aGeomObj->IsShape() && GEOMBase::GetShape(aGeomObj, aVertex) && !aVertex.IsNull()) { + gp_Pnt aPnt = BRep_Tool::Pnt(aVertex); + XSpin->SetValue(aPnt.X()); + YSpin->SetValue(aPnt.Y()); + ZSpin->SetValue(aPnt.Z()); } return; } // check if smesh node is selected - SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO( IO ); - if( aMesh->_is_nil() ) + SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(IO); + if (aMesh->_is_nil()) return; QString aString; - int aNbUnits = SMESH::GetNameOfSelectedNodes( mySelection, aString ); + int aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, myMeshActor->getIO(), aString); // return if more than one node is selected - if( aNbUnits != 1 ) + if (aNbUnits != 1) return; - - SMESH_Actor* aMeshActor = SMESH::FindActorByObject( aMesh ); - if ( !aMeshActor ) + + SMESH_Actor* aMeshActor = SMESH::FindActorByObject(aMesh); + if (!aMeshActor) return; SMDS_Mesh* mesh = aMeshActor->GetObject()->GetMesh(); if (!mesh) return; - const SMDS_MeshNode* n = mesh->FindNode( aString.toLong() ); - if ( !n ) + const SMDS_MeshNode* n = mesh->FindNode(aString.toLong()); + if (!n) return; - XSpin->SetValue( n->X() ); - YSpin->SetValue( n->Y() ); - ZSpin->SetValue( n->Z() ); + XSpin->SetValue(n->X()); + YSpin->SetValue(n->Y()); + ZSpin->SetValue(n->Z()); } } //================================================================================= -// function : SMESHGUI_ExtrusionAlongPathDlg::SetEditCurrentArgument() +// function : SetEditCurrentArgument() // purpose : //================================================================================= void SMESHGUI_ExtrusionAlongPathDlg::SetEditCurrentArgument() { - MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::SetEditCurrentArgument"); QToolButton* send = (QToolButton*)sender(); - if ( send != SelectElementsButton && - send != SelectPathMeshButton && - send != SelectPathShapeButton && - send != SelectStartPointButton && - send != SelectBasePointButton ) + if (send != SelectElementsButton && + send != SelectPathMeshButton && + send != SelectPathShapeButton && + send != SelectStartPointButton && + send != SelectBasePointButton) return; - SetEditCurrentArgument( send ); + SetEditCurrentArgument(send); } //================================================================================= -// function : SMESHGUI_ExtrusionAlongPathDlg::SetEditCurrentArgument() +// function : SetEditCurrentArgument() // purpose : //================================================================================= -void SMESHGUI_ExtrusionAlongPathDlg::SetEditCurrentArgument( QToolButton* button ) +void SMESHGUI_ExtrusionAlongPathDlg::SetEditCurrentArgument (QToolButton* button) { - MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::SetEditCurrentArgument(button)"); - disconnect( mySelection, 0, this, 0 ); - mySelection->ClearIObjects(); - mySelection->ClearFilters(); + disconnect(mySelectionMgr, 0, this, 0); + mySelectionMgr->clearSelected(); + mySelectionMgr->clearFilters(); SMESH::SetPickable(); - - if( button == SelectElementsButton ) { + + if (button == SelectElementsButton) { myEditCurrentArgument = ElementsLineEdit; - SMESH::SetPointRepresentation( false ); - if ( MeshCheck->isChecked() ) { - QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); - mySelection->AddFilter( myElementsFilter ); + SMESH::SetPointRepresentation(false); + if (MeshCheck->isChecked()) { + myViewWindow->SetSelectionMode(ActorSelection); + mySelectionMgr->installFilter(myElementsFilter); + } else { + if (Elements1dRB->isChecked()) + myViewWindow->SetSelectionMode(EdgeSelection); + else if (Elements2dRB->isChecked()) + myViewWindow->SetSelectionMode(FaceSelection); } - else { - if ( Elements1dRB->isChecked() ) - QAD_Application::getDesktop()->SetSelectionMode( EdgeSelection, true ); - else if ( Elements2dRB->isChecked() ) - QAD_Application::getDesktop()->SetSelectionMode( FaceSelection, true ); - } - } - else if ( button == SelectPathMeshButton ) { + } else if (button == SelectPathMeshButton) { myEditCurrentArgument = PathMeshLineEdit; - SMESH::SetPointRepresentation( false ); - QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); - mySelection->AddFilter( myPathMeshFilter ); + SMESH::SetPointRepresentation(false); + myViewWindow->SetSelectionMode(ActorSelection); + mySelectionMgr->installFilter(myPathMeshFilter); } - else if ( button == SelectPathShapeButton ) { + else if (button == SelectPathShapeButton) { myEditCurrentArgument = PathShapeLineEdit; - SMESH::SetPointRepresentation( false ); - QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); + SMESH::SetPointRepresentation(false); + myViewWindow->SetSelectionMode(ActorSelection); - if ( !myPathMesh->_is_nil() ) { + if (!myPathMesh->_is_nil()) { GEOM::GEOM_Object_var aMainShape = myPathMesh->GetShapeToMesh(); - SMESH_Actor* aPathActor = SMESH::FindActorByObject( myPathMesh ); + SMESH_Actor* aPathActor = SMESH::FindActorByObject(myPathMesh); - if ( !aMainShape->_is_nil() && aPathActor ) - mySelection->AddFilter( new SMESH_NumberFilter( "GEOM", TopAbs_SHAPE, -1, TopAbs_EDGE, aMainShape ) ); - //SMESH::SetPickable( aPathActor ); + if (!aMainShape->_is_nil() && aPathActor) + mySelectionMgr->installFilter(new SMESH_NumberFilter ("GEOM", TopAbs_SHAPE, -1, + TopAbs_EDGE, aMainShape)); + //SMESH::SetPickable(aPathActor); } } - else if ( button == SelectStartPointButton ) { + else if (button == SelectStartPointButton) { myEditCurrentArgument = StartPointLineEdit; - if ( !myPathMesh->_is_nil() ) { - SMESH_Actor* aPathActor = SMESH::FindActorByObject( myPathMesh ); - if ( aPathActor ) { - SMESH::SetPointRepresentation( true ); - QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true ); - SMESH::SetPickable( aPathActor ); + if (!myPathMesh->_is_nil()) { + SMESH_Actor* aPathActor = SMESH::FindActorByObject(myPathMesh); + if (aPathActor) { + SMESH::SetPointRepresentation(true); + myViewWindow->SetSelectionMode(NodeSelection); + SMESH::SetPickable(aPathActor); } } } - else if ( button == SelectBasePointButton ) { + else if (button == SelectBasePointButton) { myEditCurrentArgument = XSpin; - SMESH::SetPointRepresentation( true ); - QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true ); + SMESH::SetPointRepresentation(true); + myViewWindow->SetSelectionMode(NodeSelection); - SMESH_ListOfFilter aListOfFilters; - Handle(SMESH_TypeFilter) aMeshOrSubMeshFilter = new SMESH_TypeFilter( MESHorSUBMESH ); - if ( !aMeshOrSubMeshFilter.IsNull() ) - aListOfFilters.Append( aMeshOrSubMeshFilter ); - Handle(SMESH_TypeFilter) aSmeshGroupFilter = new SMESH_TypeFilter( GROUP ); - if ( !aSmeshGroupFilter.IsNull() ) - aListOfFilters.Append( aSmeshGroupFilter ); - //Handle(GEOM_ShapeTypeFilter) aVertexFilter = new GEOM_ShapeTypeFilter( TopAbs_VERTEX ); - Handle(SMESH_NumberFilter) aVertexFilter = new SMESH_NumberFilter( "GEOM", TopAbs_SHAPE, -1, TopAbs_VERTEX, GEOM::GEOM_Object::_nil() ); - if ( !aVertexFilter.IsNull() ) - aListOfFilters.Append( aVertexFilter ); - - mySelection->AddFilter( new SMESH_LogicalFilter( aListOfFilters, SMESH_LogicalFilter::LO_OR ) ); + SMESH_TypeFilter* aMeshOrSubMeshFilter = new SMESH_TypeFilter(MESHorSUBMESH); + SMESH_TypeFilter* aSmeshGroupFilter = new SMESH_TypeFilter(GROUP); + SMESH_NumberFilter* aVertexFilter = new SMESH_NumberFilter ("GEOM", TopAbs_SHAPE, + -1, TopAbs_VERTEX); + QPtrList aListOfFilters; + if (aMeshOrSubMeshFilter) aListOfFilters.append(aMeshOrSubMeshFilter); + if (aSmeshGroupFilter) aListOfFilters.append(aSmeshGroupFilter); + if (aVertexFilter) aListOfFilters.append(aVertexFilter); + + mySelectionMgr->installFilter(new SMESH_LogicalFilter + (aListOfFilters, SMESH_LogicalFilter::LO_OR)); } - if ( myEditCurrentArgument && !myEditCurrentArgument->hasFocus() ) + if (myEditCurrentArgument && !myEditCurrentArgument->hasFocus()) myEditCurrentArgument->setFocus(); - connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); SelectionIntoArgument(); } //================================================================================= -// function : SMESHGUI_ExtrusionAlongPathDlg::DeactivateActiveDialog() +// function : DeactivateActiveDialog() // purpose : Deactivates this dialog //================================================================================= void SMESHGUI_ExtrusionAlongPathDlg::DeactivateActiveDialog() { - MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::DeactivateActiveDialog"); - if ( ElementsTypeGrp->isEnabled() ) { - ElementsTypeGrp->setEnabled( false ); - ArgumentsGrp->setEnabled( false ); - ButtonsGrp->setEnabled( false ); - mySMESHGUI->ResetState(); - mySMESHGUI->SetActiveDialogBox( 0 ); + if (GroupConstructors->isEnabled()) { + GroupConstructors->setEnabled(false); + GroupArguments->setEnabled(false); + GroupButtons->setEnabled(false); + mySMESHGUI->ResetState(); + mySMESHGUI->SetActiveDialogBox(0); } } //================================================================================= -// function : SMESHGUI_ExtrusionAlongPathDlg::ActivateThisDialog() +// function : ActivateThisDialog() // purpose : Activates this dialog //================================================================================= void SMESHGUI_ExtrusionAlongPathDlg::ActivateThisDialog() { - MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::ActivateThisDialog"); // Emit a signal to deactivate the active dialog - mySMESHGUI->EmitSignalDeactivateDialog(); - ElementsTypeGrp->setEnabled( true ); - ArgumentsGrp->setEnabled( true ); - ButtonsGrp->setEnabled( true ); - - mySMESHGUI->SetActiveDialogBox( this ); + mySMESHGUI->EmitSignalDeactivateDialog(); + GroupConstructors->setEnabled(true); + GroupArguments->setEnabled(true); + GroupButtons->setEnabled(true); - TypeChanged( GetConstructorId() ); + mySMESHGUI->SetActiveDialogBox(this); + + ConstructorsClicked(GetConstructorId()); SelectionIntoArgument(); } //================================================================================= -// function : SMESHGUI_ExtrusionAlongPathDlg::enterEvent() +// function : enterEvent() // purpose : Mouse enter event //================================================================================= -void SMESHGUI_ExtrusionAlongPathDlg::enterEvent(QEvent* e) +void SMESHGUI_ExtrusionAlongPathDlg::enterEvent (QEvent*) { - MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::enterEvent"); - if ( ElementsTypeGrp->isEnabled() ) - return; - ActivateThisDialog(); -} - -//================================================================================= -// function : SMESHGUI_ExtrusionAlongPathDlg::reject() -// purpose : Called when dialog box is closed -//================================================================================= -void SMESHGUI_ExtrusionAlongPathDlg::reject() -{ - MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::reject"); - disconnect( mySelection, 0, this, 0 ); - mySelection->ClearFilters(); - mySelection->ClearIObjects(); - SMESH::SetPickable(); - SMESH::SetPointRepresentation( false ); - QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); - mySMESHGUI->ResetState() ; - QDialog::reject(); -} - -//================================================================================= -// function : SMESHGUI_ExtrusionAlongPathDlg::GetConstructorId() -// purpose : -//================================================================================= -int SMESHGUI_ExtrusionAlongPathDlg::GetConstructorId() -{ - MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::GetConstructorId"); - if ( ElementsTypeGrp != NULL && ElementsTypeGrp->selected() != NULL ) - return ElementsTypeGrp->id( ElementsTypeGrp->selected() ); - return -1; + if (!GroupConstructors->isEnabled()) + ActivateThisDialog(); } //======================================================================= -// function : SMESHGUI_ExtrusionAlongPathDlg::onSelectMesh +// function : onSelectMesh() // purpose : //======================================================================= void SMESHGUI_ExtrusionAlongPathDlg::onSelectMesh() { - MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::onSelectMesh"); bool toSelectMesh = MeshCheck->isChecked(); - - ElementsLineEdit->setReadOnly( toSelectMesh ); - ElementsLab->setText( toSelectMesh ? tr( "SMESH_NAME" ) : tr( "SMESH_ID_ELEMENTS" ) ); + + ElementsLineEdit->setReadOnly(toSelectMesh); + ElementsLab->setText(toSelectMesh ? tr("SMESH_NAME") : tr("SMESH_ID_ELEMENTS")); ElementsLineEdit->clear(); - - SetEditCurrentArgument( SelectElementsButton ); + + SetEditCurrentArgument(SelectElementsButton); +} + +//================================================================================= +// function : GetConstructorId() +// purpose : +//================================================================================= +int SMESHGUI_ExtrusionAlongPathDlg::GetConstructorId() +{ + if (GroupConstructors != NULL && GroupConstructors->selected() != NULL) + return GroupConstructors->id(GroupConstructors->selected()); + return -1; } //======================================================================= -// function : SMESHGUI_ExtrusionAlongPathDlg::onAnglesCheck +// function : onAnglesCheck() // purpose : called when "Use Angles" check box is switched //======================================================================= void SMESHGUI_ExtrusionAlongPathDlg::onAnglesCheck() { - MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::onAnglesCheck"); - AnglesGrp->setEnabled( AnglesCheck->isChecked() ); + AnglesGrp->setEnabled(AnglesCheck->isChecked()); } //======================================================================= -// function : SMESHGUI_ExtrusionAlongPathDlg::onBasePointCheck +// function : onBasePointCheck() // purpose : called when "Use Base Point" check box is switched //======================================================================= void SMESHGUI_ExtrusionAlongPathDlg::onBasePointCheck() { - MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::onBasePointCheck"); - BasePointGrp->setEnabled( BasePointCheck->isChecked() ); + BasePointGrp->setEnabled(BasePointCheck->isChecked()); } //======================================================================= -// function : SMESHGUI_ExtrusionAlongPathDlg::OnAngleAdded +// function : OnAngleAdded() // purpose : Called when user adds angle to the list //======================================================================= void SMESHGUI_ExtrusionAlongPathDlg::OnAngleAdded() { - MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::OnAngleAdded"); - AnglesList->insertItem( QString::number( AngleSpin->GetValue() ) ); + AnglesList->insertItem(QString::number(AngleSpin->GetValue())); } //======================================================================= -// function : SMESHGUI_ExtrusionAlongPathDlg::OnAngleRemoved +// function : OnAngleRemoved() // purpose : Called when user removes angle(s) from the list //======================================================================= void SMESHGUI_ExtrusionAlongPathDlg::OnAngleRemoved() { - MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::OnAngleRemoved"); QList aList; - aList.setAutoDelete( false ); - for ( int i = 0; i < AnglesList->count(); i++ ) - if ( AnglesList->isSelected( i ) ) - aList.append( AnglesList->item( i ) ); + aList.setAutoDelete(false); + for (int i = 0; i < AnglesList->count(); i++) + if (AnglesList->isSelected(i)) + aList.append(AnglesList->item(i)); - for ( int i = 0; i < aList.count(); i++ ) - delete aList.at( i ); + for (int i = 0; i < aList.count(); i++) + delete aList.at(i); } +//================================================================================= +// function : eventFilter() +// purpose : event filter ??? +//================================================================================= +bool SMESHGUI_ExtrusionAlongPathDlg::eventFilter (QObject* object, QEvent* event) +{ + if (event->type() == QEvent::KeyPress) { + QKeyEvent* ke = (QKeyEvent*)event; + if (object == AnglesList) { + if (ke->key() == Key_Delete) + OnAngleRemoved(); + } + } + else if (event->type() == QEvent::FocusIn) { + if (object == ElementsLineEdit) { + if (myEditCurrentArgument != ElementsLineEdit) + SetEditCurrentArgument(SelectElementsButton); + } + else if (object == StartPointLineEdit) { + if (myEditCurrentArgument != StartPointLineEdit) + SetEditCurrentArgument(SelectStartPointButton); + } + else if (object == XSpin->editor() || object == YSpin->editor() || object == ZSpin->editor()) { + if (myEditCurrentArgument != XSpin) + SetEditCurrentArgument(SelectBasePointButton); + } + } + return QDialog::eventFilter(object, event); +} diff --git a/src/SMESHGUI/SMESHGUI_ExtrusionAlongPathDlg.h b/src/SMESHGUI/SMESHGUI_ExtrusionAlongPathDlg.h index 951dbb3ef..4b70c5ed8 100644 --- a/src/SMESHGUI/SMESHGUI_ExtrusionAlongPathDlg.h +++ b/src/SMESHGUI/SMESHGUI_ExtrusionAlongPathDlg.h @@ -29,9 +29,9 @@ #ifndef DIALOGBOX_EXTRUSION_PATH_H #define DIALOGBOX_EXTRUSION_PATH_H -#include "SALOME_Selection.h" -#include "SMESH_LogicalFilter.hxx" -#include "SMESH_TypeFilter.hxx" +#include "SalomeApp_SelectionMgr.h" +#include "SUIT_SelectionFilter.h" + // QT Includes #include @@ -44,9 +44,13 @@ class QLineEdit; class QCheckBox; class QListBox; class QPushButton; -class SMESHGUI_SpinBox; + class SMESHGUI; class SMESH_Actor; +class SMESHGUI_SpinBox; +class SVTK_ViewWindow; +class SVTK_Selector; + // IDL Headers #include @@ -57,12 +61,12 @@ class SMESH_Actor; // purpose : //================================================================================= class SMESHGUI_ExtrusionAlongPathDlg : public QDialog -{ +{ Q_OBJECT class SetBusy { public: - SetBusy( SMESHGUI_ExtrusionAlongPathDlg* _dlg ) { myDlg = _dlg; myDlg->myBusy = true; } + SetBusy (SMESHGUI_ExtrusionAlongPathDlg* _dlg) { myDlg = _dlg; myDlg->myBusy = true; } ~SetBusy() { myDlg->myBusy = false; } private: SMESHGUI_ExtrusionAlongPathDlg* myDlg; @@ -70,39 +74,41 @@ class SMESHGUI_ExtrusionAlongPathDlg : public QDialog friend class SetBusy; public: - SMESHGUI_ExtrusionAlongPathDlg( QWidget* parent = 0, SALOME_Selection* Sel = 0, bool modal = FALSE ); + SMESHGUI_ExtrusionAlongPathDlg (SMESHGUI*, + bool modal = FALSE); ~SMESHGUI_ExtrusionAlongPathDlg(); - bool eventFilter( QObject* object, QEvent* event ); - -protected slots: - void reject(); + bool eventFilter (QObject* object, QEvent* event); private: - void Init( bool ResetControls = true ) ; - void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */ + void Init (bool ResetControls = true); + void enterEvent (QEvent*); /* mouse enter the QWidget */ int GetConstructorId(); - void SetEditCurrentArgument( QToolButton* button ); + void SetEditCurrentArgument (QToolButton* button); + + SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */ + SalomeApp_SelectionMgr* mySelectionMgr; /* User shape selection */ + SVTK_ViewWindow* myViewWindow; + SVTK_Selector* mySelector; + + QWidget* myEditCurrentArgument; /* Current argument */ - SMESHGUI* mySMESHGUI ; /* Current SMESHGUI object */ - SALOME_Selection* mySelection ; /* User shape selection */ - QWidget* myEditCurrentArgument; /* Current argument */ - bool myBusy; - SMESH::SMESH_IDSource_var myIDSource; SMESH::SMESH_Mesh_var myMesh; SMESH_Actor* myMeshActor; + SMESH::SMESH_IDSource_var myIDSource; SMESH::SMESH_Mesh_var myPathMesh; GEOM::GEOM_Object_var myPathShape; - Handle(SMESH_LogicalFilter) myElementsFilter; - Handle(SMESH_TypeFilter) myPathMeshFilter; + SUIT_SelectionFilter* myElementsFilter; + SUIT_SelectionFilter* myPathMeshFilter; int myType; // widgets - QButtonGroup* ElementsTypeGrp; + QButtonGroup* GroupConstructors; QRadioButton* Elements1dRB; QRadioButton* Elements2dRB; - QGroupBox* ArgumentsGrp; + + QGroupBox* GroupArguments; QLabel* ElementsLab; QToolButton* SelectElementsButton; QLineEdit* ElementsLineEdit; @@ -132,20 +138,24 @@ private: SMESHGUI_SpinBox* YSpin; QLabel* ZLab; SMESHGUI_SpinBox* ZSpin; - QGroupBox* ButtonsGrp; + + QGroupBox* GroupButtons; QPushButton* OkButton; QPushButton* ApplyButton; QPushButton* CloseButton; - + +protected slots: + void reject(); + private slots: - void TypeChanged( int type ); + void ConstructorsClicked (int); void ClickOnOk(); bool ClickOnApply(); void SetEditCurrentArgument(); void SelectionIntoArgument(); void DeactivateActiveDialog(); void ActivateThisDialog(); - void onTextChange(const QString&); + void onTextChange (const QString&); void onSelectMesh(); void onAnglesCheck(); void onBasePointCheck(); diff --git a/src/SMESHGUI/SMESHGUI_ExtrusionDlg.cxx b/src/SMESHGUI/SMESHGUI_ExtrusionDlg.cxx index 7e3ad503f..1a42cceba 100644 --- a/src/SMESHGUI/SMESHGUI_ExtrusionDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_ExtrusionDlg.cxx @@ -1,47 +1,64 @@ // SMESH SMESHGUI : GUI for SMESH component // // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org // // // // File : SMESHGUI_ExtrusionDlg.cxx // Author : Michael ZORIN // Module : SMESH -// $Header: +// $Header: #include "SMESHGUI_ExtrusionDlg.h" + #include "SMESHGUI.h" -#include "SMESHGUI_SpinBox.h" #include "SMESHGUI_Utils.h" #include "SMESHGUI_VTKUtils.h" #include "SMESHGUI_MeshUtils.h" +#include "SMESHGUI_SpinBox.h" #include "SMESHGUI_IdValidator.h" + #include "SMESH_Actor.h" #include "SMESH_TypeFilter.hxx" +#include "SMESH_NumberFilter.hxx" +#include "SMESH_LogicalFilter.hxx" + #include "SMDS_Mesh.hxx" -#include "QAD_Application.h" -#include "QAD_Desktop.h" -#include "QAD_MessageBox.h" +#include "SUIT_ResourceMgr.h" +#include "SUIT_OverrideCursor.h" +#include "SUIT_Desktop.h" +#include "SUIT_MessageBox.h" + +#include "SVTK_ViewModel.h" +#include "SVTK_ViewWindow.h" +#include "SVTK_Selector.h" +#include "SVTK_Selection.h" +#include "SALOME_ListIO.hxx" + #include "utilities.h" +// OCCT Includes +#include +#include + // QT Includes #include #include @@ -51,8 +68,8 @@ #include #include #include +#include #include -#include #include #include @@ -63,390 +80,401 @@ using namespace std; //================================================================================= -// class : SMESHGUI_ExtrusionDlg() -// purpose : +// function : SMESHGUI_ExtrusionDlg() +// purpose : constructor //================================================================================= -SMESHGUI_ExtrusionDlg::SMESHGUI_ExtrusionDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, - bool modal, WFlags fl ) - : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | - Qt::WDestructiveClose) +SMESHGUI_ExtrusionDlg::SMESHGUI_ExtrusionDlg (SMESHGUI* theModule, + bool modal) + : QDialog( SMESH::GetDesktop( theModule ), "SMESHGUI_ExtrusionDlg", modal, WStyle_Customize | + WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | Qt::WDestructiveClose), + mySMESHGUI( theModule ), + mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ), + myViewWindow( SMESH::GetViewWindow( theModule ) ), + mySelector( myViewWindow->GetSelector() ) { - QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_DLG_EDGE"))); - QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_DLG_TRIANGLE"))); - QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SELECT"))); + QPixmap image0 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_DLG_EDGE"))); + QPixmap image1 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_DLG_TRIANGLE"))); + QPixmap image2 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT"))); - if ( !name ) - setName( "SMESHGUI_ExtrusionDlg" ); - resize( 303, 185 ); - setCaption( tr( "EXTRUSION_ALONG_LINE" ) ); - setSizeGripEnabled( TRUE ); - SMESHGUI_ExtrusionDlgLayout = new QGridLayout( this ); - SMESHGUI_ExtrusionDlgLayout->setSpacing( 6 ); - SMESHGUI_ExtrusionDlgLayout->setMargin( 11 ); + resize(303, 185); + setCaption(tr("EXTRUSION_ALONG_LINE")); + setSizeGripEnabled(TRUE); + + QGridLayout* SMESHGUI_ExtrusionDlgLayout = new QGridLayout(this); + SMESHGUI_ExtrusionDlgLayout->setSpacing(6); + SMESHGUI_ExtrusionDlgLayout->setMargin(11); /***************************************************************/ - GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); - GroupConstructors->setTitle( tr( "SMESH_EXTRUSION" ) ); - GroupConstructors->setExclusive( TRUE ); - GroupConstructors->setColumnLayout(0, Qt::Vertical ); - GroupConstructors->layout()->setSpacing( 0 ); - GroupConstructors->layout()->setMargin( 0 ); - GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() ); - GroupConstructorsLayout->setAlignment( Qt::AlignTop ); - GroupConstructorsLayout->setSpacing( 6 ); - GroupConstructorsLayout->setMargin( 11 ); - RadioButton1= new QRadioButton( GroupConstructors, "RadioButton1" ); - RadioButton1->setText( tr( "" ) ); - RadioButton1->setPixmap( image0 ); - GroupConstructorsLayout->addWidget( RadioButton1, 0, 0 ); - RadioButton2= new QRadioButton( GroupConstructors, "RadioButton2" ); - RadioButton2->setText( tr( "" ) ); - RadioButton2->setPixmap( image1 ); - GroupConstructorsLayout->addWidget( RadioButton2, 0, 2 ); - SMESHGUI_ExtrusionDlgLayout->addWidget( GroupConstructors, 0, 0 ); - - /***************************************************************/ - GroupButtons = new QGroupBox( this, "GroupButtons" ); - GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); - GroupButtons->setTitle( tr( "" ) ); - GroupButtons->setColumnLayout(0, Qt::Vertical ); - GroupButtons->layout()->setSpacing( 0 ); - GroupButtons->layout()->setMargin( 0 ); - GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); - GroupButtonsLayout->setAlignment( Qt::AlignTop ); - GroupButtonsLayout->setSpacing( 6 ); - GroupButtonsLayout->setMargin( 11 ); - buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); - buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) ); - buttonCancel->setAutoDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonCancel, 0, 3 ); - buttonApply = new QPushButton( GroupButtons, "buttonApply" ); - buttonApply->setText( tr( "SMESH_BUT_APPLY" ) ); - buttonApply->setAutoDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); - QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); - GroupButtonsLayout->addItem( spacer_9, 0, 2 ); - buttonOk = new QPushButton( GroupButtons, "buttonOk" ); - buttonOk->setText( tr( "SMESH_BUT_OK" ) ); - buttonOk->setAutoDefault( TRUE ); - buttonOk->setDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); - SMESHGUI_ExtrusionDlgLayout->addWidget( GroupButtons, 2, 0 ); + GroupConstructors = new QButtonGroup("GroupConstructors", this); + GroupConstructors->setTitle(tr("SMESH_EXTRUSION")); + GroupConstructors->setExclusive(TRUE); + GroupConstructors->setColumnLayout(0, Qt::Vertical); + GroupConstructors->layout()->setSpacing(0); + GroupConstructors->layout()->setMargin(0); + QGridLayout* GroupConstructorsLayout = new QGridLayout(GroupConstructors->layout()); + GroupConstructorsLayout->setAlignment(Qt::AlignTop); + GroupConstructorsLayout->setSpacing(6); + GroupConstructorsLayout->setMargin(11); + RadioButton1= new QRadioButton(GroupConstructors, "RadioButton1"); + RadioButton1->setText(tr("")); + RadioButton1->setPixmap(image0); + GroupConstructorsLayout->addWidget(RadioButton1, 0, 0); + RadioButton2= new QRadioButton(GroupConstructors, "RadioButton2"); + RadioButton2->setText(tr("")); + RadioButton2->setPixmap(image1); + GroupConstructorsLayout->addWidget(RadioButton2, 0, 2); + SMESHGUI_ExtrusionDlgLayout->addWidget(GroupConstructors, 0, 0); /***************************************************************/ - GroupArguments = new QGroupBox( this, "GroupArguments" ); - GroupArguments->setTitle( tr( "EXTRUSION_1D" ) ); - GroupArguments->setColumnLayout(0, Qt::Vertical ); - GroupArguments->layout()->setSpacing( 0 ); - GroupArguments->layout()->setMargin( 0 ); - GroupArgumentsLayout = new QGridLayout( GroupArguments->layout()); - GroupArgumentsLayout->setAlignment( Qt::AlignTop ); - GroupArgumentsLayout->setSpacing( 6 ); - GroupArgumentsLayout->setMargin( 11 ); + GroupButtons = new QGroupBox(this, "GroupButtons"); + GroupButtons->setGeometry(QRect(10, 10, 281, 48)); + GroupButtons->setTitle(tr("")); + GroupButtons->setColumnLayout(0, Qt::Vertical); + GroupButtons->layout()->setSpacing(0); + GroupButtons->layout()->setMargin(0); + QGridLayout* GroupButtonsLayout = new QGridLayout(GroupButtons->layout()); + GroupButtonsLayout->setAlignment(Qt::AlignTop); + GroupButtonsLayout->setSpacing(6); + GroupButtonsLayout->setMargin(11); + buttonCancel = new QPushButton(GroupButtons, "buttonCancel"); + buttonCancel->setText(tr("SMESH_BUT_CLOSE" )); + buttonCancel->setAutoDefault(TRUE); + GroupButtonsLayout->addWidget(buttonCancel, 0, 3); + buttonApply = new QPushButton(GroupButtons, "buttonApply"); + buttonApply->setText(tr("SMESH_BUT_APPLY" )); + buttonApply->setAutoDefault(TRUE); + GroupButtonsLayout->addWidget(buttonApply, 0, 1); + QSpacerItem* spacer_9 = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); + GroupButtonsLayout->addItem(spacer_9, 0, 2); + buttonOk = new QPushButton(GroupButtons, "buttonOk"); + buttonOk->setText(tr("SMESH_BUT_OK" )); + buttonOk->setAutoDefault(TRUE); + buttonOk->setDefault(TRUE); + GroupButtonsLayout->addWidget(buttonOk, 0, 0); + SMESHGUI_ExtrusionDlgLayout->addWidget(GroupButtons, 2, 0); + + /***************************************************************/ + GroupArguments = new QGroupBox(this, "GroupArguments"); + GroupArguments->setTitle(tr("EXTRUSION_1D")); + GroupArguments->setColumnLayout(0, Qt::Vertical); + GroupArguments->layout()->setSpacing(0); + GroupArguments->layout()->setMargin(0); + QGridLayout* GroupArgumentsLayout = new QGridLayout(GroupArguments->layout()); + GroupArgumentsLayout->setAlignment(Qt::AlignTop); + GroupArgumentsLayout->setSpacing(6); + GroupArgumentsLayout->setMargin(11); // Controls for elements selection - TextLabelElements = new QLabel( GroupArguments, "TextLabelElements" ); - TextLabelElements->setText( tr( "SMESH_ID_ELEMENTS" ) ); + TextLabelElements = new QLabel(GroupArguments, "TextLabelElements"); + TextLabelElements->setText(tr("SMESH_ID_ELEMENTS" )); TextLabelElements->setFixedWidth(74); - GroupArgumentsLayout->addWidget( TextLabelElements, 0, 0 ); + GroupArgumentsLayout->addWidget(TextLabelElements, 0, 0); - SelectElementsButton = new QPushButton( GroupArguments, "SelectElementsButton" ); - SelectElementsButton->setText( tr( "" ) ); - SelectElementsButton->setPixmap( image2 ); - SelectElementsButton->setToggleButton( FALSE ); - GroupArgumentsLayout->addWidget( SelectElementsButton, 0, 1 ); - - LineEditElements = new QLineEdit( GroupArguments, "LineEditElements" ); - LineEditElements->setValidator( new SMESHGUI_IdValidator( this, "validator" )); - GroupArgumentsLayout->addMultiCellWidget( LineEditElements, 0, 0, 2, 7 ); + SelectElementsButton = new QPushButton(GroupArguments, "SelectElementsButton"); + SelectElementsButton->setText(tr("" )); + SelectElementsButton->setPixmap(image2); + SelectElementsButton->setToggleButton(FALSE); + GroupArgumentsLayout->addWidget(SelectElementsButton, 0, 1); + + LineEditElements = new QLineEdit(GroupArguments, "LineEditElements"); + LineEditElements->setValidator(new SMESHGUI_IdValidator(this, "validator")); + GroupArgumentsLayout->addMultiCellWidget(LineEditElements, 0, 0, 2, 7); // Control for the whole mesh selection - CheckBoxMesh = new QCheckBox( GroupArguments, "CheckBoxMesh" ); - CheckBoxMesh->setText( tr( "SMESH_SELECT_WHOLE_MESH" ) ); - GroupArgumentsLayout->addMultiCellWidget( CheckBoxMesh, 1, 1, 0, 7 ); + CheckBoxMesh = new QCheckBox(GroupArguments, "CheckBoxMesh"); + CheckBoxMesh->setText(tr("SMESH_SELECT_WHOLE_MESH" )); + GroupArgumentsLayout->addMultiCellWidget(CheckBoxMesh, 1, 1, 0, 7); // Controls for vector selection - TextLabelVector = new QLabel( GroupArguments, "TextLabelVector" ); - TextLabelVector->setText( tr( "SMESH_VECTOR" ) ); - GroupArgumentsLayout->addWidget( TextLabelVector, 2, 0 ); - - TextLabelDx = new QLabel( GroupArguments, "TextLabelDx" ); - TextLabelDx->setText( tr( "SMESH_DX" ) ); - GroupArgumentsLayout->addWidget( TextLabelDx, 2, 2 ); + TextLabelVector = new QLabel(GroupArguments, "TextLabelVector"); + TextLabelVector->setText(tr("SMESH_VECTOR")); + GroupArgumentsLayout->addWidget(TextLabelVector, 2, 0); + + TextLabelDx = new QLabel(GroupArguments, "TextLabelDx"); + TextLabelDx->setText(tr("SMESH_DX")); + GroupArgumentsLayout->addWidget(TextLabelDx, 2, 2); SpinBox_Dx = new SMESHGUI_SpinBox(GroupArguments, "SpinBox_Dx"); - GroupArgumentsLayout->addWidget( SpinBox_Dx, 2, 3 ); + GroupArgumentsLayout->addWidget(SpinBox_Dx, 2, 3); - TextLabelDy = new QLabel( GroupArguments, "TextLabelDy" ); - TextLabelDy->setText( tr( "SMESH_DY" ) ); - GroupArgumentsLayout->addWidget( TextLabelDy, 2, 4 ); + TextLabelDy = new QLabel(GroupArguments, "TextLabelDy"); + TextLabelDy->setText(tr("SMESH_DY")); + GroupArgumentsLayout->addWidget(TextLabelDy, 2, 4); SpinBox_Dy = new SMESHGUI_SpinBox(GroupArguments, "SpinBox_Dy"); - GroupArgumentsLayout->addWidget( SpinBox_Dy, 2, 5 ); + GroupArgumentsLayout->addWidget(SpinBox_Dy, 2, 5); + + TextLabelDz = new QLabel(GroupArguments, "TextLabelDz"); + TextLabelDz->setText(tr("SMESH_DZ")); + GroupArgumentsLayout->addWidget(TextLabelDz, 2, 6); - TextLabelDz = new QLabel( GroupArguments, "TextLabelDz" ); - TextLabelDz->setText( tr( "SMESH_DZ" ) ); - GroupArgumentsLayout->addWidget( TextLabelDz, 2, 6 ); - SpinBox_Dz = new SMESHGUI_SpinBox(GroupArguments, "SpinBox_Dz"); - GroupArgumentsLayout->addWidget( SpinBox_Dz, 2, 7 ); - + GroupArgumentsLayout->addWidget(SpinBox_Dz, 2, 7); + // Controls for nb. steps defining - TextLabelNbSteps = new QLabel( GroupArguments, "TextLabelNbSteps" ); - TextLabelNbSteps->setText( tr( "SMESH_NUMBEROFSTEPS" ) ); - GroupArgumentsLayout->addMultiCellWidget( TextLabelNbSteps, 3, 3, 0, 1 ); + TextLabelNbSteps = new QLabel(GroupArguments, "TextLabelNbSteps"); + TextLabelNbSteps->setText(tr("SMESH_NUMBEROFSTEPS" )); + GroupArgumentsLayout->addMultiCellWidget(TextLabelNbSteps, 3, 3, 0, 1); SpinBox_NbSteps = new QSpinBox(GroupArguments, "SpinBox_NbSteps"); - GroupArgumentsLayout->addMultiCellWidget( SpinBox_NbSteps, 3, 3, 2, 7 ); - - SMESHGUI_ExtrusionDlgLayout->addWidget( GroupArguments, 1, 0 ); - + GroupArgumentsLayout->addMultiCellWidget(SpinBox_NbSteps, 3, 3, 2, 7); + + SMESHGUI_ExtrusionDlgLayout->addWidget(GroupArguments, 1, 0); + /* Initialisations */ - SpinBox_Dx->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 ); - SpinBox_Dy->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 ); - SpinBox_Dz->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 ); + SpinBox_Dx->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3); + SpinBox_Dy->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3); + SpinBox_Dz->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3); QIntValidator* anIntValidator = new QIntValidator(SpinBox_NbSteps); SpinBox_NbSteps->setValidator(anIntValidator); - SpinBox_NbSteps->setRange( 1, 999999 ); - + SpinBox_NbSteps->setRange(1, 999999); + GroupArguments->show(); - RadioButton1->setChecked( TRUE ); - mySelection = Sel; + RadioButton1->setChecked(TRUE); + + mySMESHGUI->SetActiveDialogBox(this); + + // Costruction of the logical filter for the elements: mesh/sub-mesh/group + SMESH_TypeFilter* aMeshOrSubMeshFilter = new SMESH_TypeFilter (MESHorSUBMESH); + SMESH_TypeFilter* aSmeshGroupFilter = new SMESH_TypeFilter (GROUP); + + QPtrList aListOfFilters; + if (aMeshOrSubMeshFilter) aListOfFilters.append(aMeshOrSubMeshFilter); + if (aSmeshGroupFilter) aListOfFilters.append(aSmeshGroupFilter); + + myMeshOrSubMeshOrGroupFilter = + new SMESH_LogicalFilter (aListOfFilters, SMESH_LogicalFilter::LO_OR); - mySMESHGUI = SMESHGUI::GetSMESHGUI() ; - mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; - - // Costruction of the logical filter - SMESH_ListOfFilter aListOfFilters; - Handle(SMESH_TypeFilter) aMeshOrSubMeshFilter = new SMESH_TypeFilter( MESHorSUBMESH ); - if ( !aMeshOrSubMeshFilter.IsNull() ) - aListOfFilters.Append( aMeshOrSubMeshFilter ); - Handle(SMESH_TypeFilter) aSmeshGroupFilter = new SMESH_TypeFilter( GROUP ); - if ( !aSmeshGroupFilter.IsNull() ) - aListOfFilters.Append( aSmeshGroupFilter ); - - myMeshOrSubMeshOrGroupFilter = new SMESH_LogicalFilter( aListOfFilters, SMESH_LogicalFilter::LO_OR ); - Init(); - /* signals and slots connections */ - connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); - connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ; - connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) ); - connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) ); - - connect( SelectElementsButton, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; - connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; - connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); - /* to close dialog if study change */ - connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; - connect( LineEditElements, SIGNAL( textChanged( const QString& )), - SLOT( onTextChange( const QString& ))); - connect( CheckBoxMesh, SIGNAL( toggled( bool )), - SLOT( onSelectMesh( bool ))); + /***************************************************************/ + // signals and slots connections + connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel())); + connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); + connect(GroupConstructors, SIGNAL(clicked(int)), SLOT(ConstructorsClicked(int))); + + connect(SelectElementsButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument())); + connect(mySMESHGUI, SIGNAL (SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog())); + connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + /* to close dialog if study change */ + connect(mySMESHGUI, SIGNAL (SignalCloseAllDialogs()), this, SLOT(ClickOnCancel())); + connect(LineEditElements, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&))); + connect(CheckBoxMesh, SIGNAL(toggled(bool)), SLOT(onSelectMesh(bool))); + + /***************************************************************/ /* Move widget on the botton right corner of main widget */ - int x, y ; - mySMESHGUI->DefineDlgPosition( this, x, y ) ; - this->move( x, y ) ; - this->show() ; /* displays Dialog */ + int x, y; + mySMESHGUI->DefineDlgPosition(this, x, y); + this->move(x, y); + this->show(); // displays Dialog ConstructorsClicked(0); } //================================================================================= // function : ~SMESHGUI_ExtrusionDlg() -// purpose : Destroys the object and frees any allocated resources +// purpose : destructor //================================================================================= SMESHGUI_ExtrusionDlg::~SMESHGUI_ExtrusionDlg() { // no need to delete child widgets, Qt does it all for us } - //================================================================================= // function : Init() -// purpose : +// purpose : initialization //================================================================================= -void SMESHGUI_ExtrusionDlg::Init( bool ResetControls ) +void SMESHGUI_ExtrusionDlg::Init (bool ResetControls) { - myBusy = false; - + myBusy = false; + LineEditElements->clear(); myElementsId = ""; - myNbOkElements = 0 ; + myNbOkElements = 0; - buttonOk->setEnabled( false ); - buttonApply->setEnabled( false ); - - myActor = 0; + buttonOk->setEnabled(false); + buttonApply->setEnabled(false); + + myActor = 0; myMesh = SMESH::SMESH_Mesh::_nil(); - - if( ResetControls ) - { - SpinBox_NbSteps->setValue(1); - SpinBox_Dx->SetValue(0); - SpinBox_Dy->SetValue(0); - SpinBox_Dz->SetValue(0); - - CheckBoxMesh->setChecked(false); - onSelectMesh( false ); - } -} + if (ResetControls) { + SpinBox_NbSteps->setValue(1); + SpinBox_Dx->SetValue(0); + SpinBox_Dy->SetValue(0); + SpinBox_Dz->SetValue(0); + + CheckBoxMesh->setChecked(false); + onSelectMesh(false); + } +} //================================================================================= // function : ConstructorsClicked() // purpose : Radio button management //================================================================================= -void SMESHGUI_ExtrusionDlg::ConstructorsClicked(int constructorId) +void SMESHGUI_ExtrusionDlg::ConstructorsClicked (int constructorId) { - disconnect(mySelection, 0, this, 0); - - switch(constructorId) - { - case 0 : - { - GroupArguments->setTitle( tr( "EXTRUSION_1D" ) ); - if ( !CheckBoxMesh->isChecked() ) - QAD_Application::getDesktop()->SetSelectionMode( EdgeSelection, true ); - break; - } - case 1 : - { - GroupArguments->setTitle( tr( "EXTRUSION_2D" ) ); - if ( !CheckBoxMesh->isChecked() ) - QAD_Application::getDesktop()->SetSelectionMode( FaceSelection, true ); - break; - } + disconnect(mySelectionMgr, 0, this, 0); + + switch (constructorId) { + case 0: + { + GroupArguments->setTitle(tr("EXTRUSION_1D")); + if (!CheckBoxMesh->isChecked()) + myViewWindow->SetSelectionMode(EdgeSelection); + break; } + case 1: + { + GroupArguments->setTitle(tr("EXTRUSION_2D")); + if (!CheckBoxMesh->isChecked()) + myViewWindow->SetSelectionMode(FaceSelection); + break; + } + } myEditCurrentArgument = LineEditElements; LineEditElements->setFocus(); - + if (CheckBoxMesh->isChecked()) onSelectMesh(true); - - connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); -} + connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); +} //================================================================================= // function : ClickOnApply() -// purpose : +// purpose : Called when user presses button //================================================================================= -void SMESHGUI_ExtrusionDlg::ClickOnApply() +bool SMESHGUI_ExtrusionDlg::ClickOnApply() { - if (mySMESHGUI->ActiveStudyLocked()) - return; - - if ( myNbOkElements) - { - QStringList aListElementsId = QStringList::split( " ", myElementsId, false); - - SMESH::long_array_var anElementsId = new SMESH::long_array; - - anElementsId->length( aListElementsId.count() ); - for ( int i = 0; i < aListElementsId.count(); i++ ) - anElementsId[i] = aListElementsId[i].toInt(); - - SMESH::DirStruct aVector; - aVector.PS.x = SpinBox_Dx->GetValue(); - aVector.PS.y = SpinBox_Dy->GetValue(); - aVector.PS.z = SpinBox_Dz->GetValue(); + if (mySMESHGUI->isActiveStudyLocked()) + return false; - long aNbSteps = (long)SpinBox_NbSteps->value(); + if (myNbOkElements) { + QStringList aListElementsId = QStringList::split(" ", myElementsId, false); - try - { - SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor(); - QApplication::setOverrideCursor(Qt::waitCursor); - aMeshEditor->ExtrusionSweep(anElementsId.inout(), aVector, aNbSteps); - QApplication::restoreOverrideCursor(); - } - catch( ... ) - { - } - - mySelection->ClearIObjects(); - SMESH::UpdateView(); - Init( false); - ConstructorsClicked( GetConstructorId() ); + SMESH::long_array_var anElementsId = new SMESH::long_array; + + anElementsId->length(aListElementsId.count()); + for (int i = 0; i < aListElementsId.count(); i++) + anElementsId[i] = aListElementsId[i].toInt(); + + SMESH::DirStruct aVector; + aVector.PS.x = SpinBox_Dx->GetValue(); + aVector.PS.y = SpinBox_Dy->GetValue(); + aVector.PS.z = SpinBox_Dz->GetValue(); + + long aNbSteps = (long)SpinBox_NbSteps->value(); + + try { + SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor(); + QApplication::setOverrideCursor(Qt::waitCursor); + aMeshEditor->ExtrusionSweep(anElementsId.inout(), aVector, aNbSteps); + QApplication::restoreOverrideCursor(); + } catch (...) { } + + mySelectionMgr->clearSelected(); + SMESH::UpdateView(); + Init(false); + ConstructorsClicked(GetConstructorId()); + } + return true; } //================================================================================= // function : ClickOnOk() -// purpose : +// purpose : Called when user presses button //================================================================================= void SMESHGUI_ExtrusionDlg::ClickOnOk() { - ClickOnApply(); - ClickOnCancel(); + if (ClickOnApply()) + ClickOnCancel(); } - //================================================================================= // function : ClickOnCancel() -// purpose : +// purpose : Called when dialog box is closed //================================================================================= void SMESHGUI_ExtrusionDlg::ClickOnCancel() { - mySelection->ClearFilters(); - mySelection->ClearIObjects(); + disconnect(mySelectionMgr, 0, this, 0); + mySelectionMgr->clearFilters(); + mySelectionMgr->clearSelected(); + SMESH::SetPickable(); // ??? SMESH::SetPointRepresentation(false); - QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); - disconnect( mySelection, 0, this, 0 ); - mySMESHGUI->ResetState() ; - reject() ; + myViewWindow->SetSelectionMode(ActorSelection); + mySMESHGUI->ResetState(); + reject(); } -//======================================================================= -//function : onTextChange -//purpose : -//======================================================================= -void SMESHGUI_ExtrusionDlg::onTextChange(const QString& theNewText) +//================================================================================= +// function : onTextChange() +// purpose : +//================================================================================= +void SMESHGUI_ExtrusionDlg::onTextChange (const QString& theNewText) { QLineEdit* send = (QLineEdit*)sender(); - - if ( myBusy ) return; + + // return if busy + if (myBusy) return; + + // set busy flag myBusy = true; - + if (send == LineEditElements) myNbOkElements = 0; - - buttonOk->setEnabled( false ); - buttonApply->setEnabled( false ); - + + buttonOk->setEnabled(false); + buttonApply->setEnabled(false); + // hilight entered elements/nodes SMDS_Mesh* aMesh = 0; - if ( myActor ) + if (myActor) aMesh = myActor->GetObject()->GetMesh(); - - if ( aMesh ) { - mySelection->ClearIObjects(); - mySelection->AddIObject( myActor->getIO() ); - - QStringList aListId = QStringList::split( " ", theNewText, false); - + + if (aMesh) { + //mySelectionMgr->clearSelected(); + //mySelectionMgr->AddIObject(myActor->getIO()); + SALOME_ListIO aList; + aList.Append(myActor->getIO()); + mySelectionMgr->setSelectedObjects(aList, false); + + QStringList aListId = QStringList::split(" ", theNewText, false); + if (send == LineEditElements) { - for ( int i = 0; i < aListId.count(); i++ ) { - const SMDS_MeshElement * e = aMesh->FindElement( aListId[ i ].toInt() ); - if ( e ) { - if ( !mySelection->IsIndexSelected( myActor->getIO(), e->GetID() )) - mySelection->AddOrRemoveIndex (myActor->getIO(), e->GetID(), true); + const Handle(SALOME_InteractiveObject)& anIO = myActor->getIO(); + TColStd_IndexedMapOfInteger selectedIndices; + TColStd_MapOfInteger newIndices; + mySelector->GetIndex(anIO, selectedIndices); + for (int i = 0; i < aListId.count(); i++) { + const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt()); + if (e) { + //if (!mySelectionMgr->IsIndexSelected(myActor->getIO(), e->GetID())) { + if (selectedIndices.Add(e->GetID())) { + //mySelectionMgr->AddOrRemoveIndex(myActor->getIO(), e->GetID(), true); + newIndices.Add(e->GetID()); + } myNbOkElements++; } } + if (newIndices.Extent() > 0) { + mySelector->AddOrRemoveIndex(anIO, newIndices, true); + myViewWindow->highlight( anIO, true, true ); + } myElementsId = theNewText; } } - - if ( myNbOkElements ) { - buttonOk->setEnabled( true ); - buttonApply->setEnabled( true ); + + if (myNbOkElements) { + buttonOk->setEnabled(true); + buttonApply->setEnabled(true); } - + myBusy = false; } @@ -456,144 +484,129 @@ void SMESHGUI_ExtrusionDlg::onTextChange(const QString& theNewText) //================================================================================= void SMESHGUI_ExtrusionDlg::SelectionIntoArgument() { - if ( myBusy ) return; - + if (myBusy) return; + + // return if dialog box is inactive + if (!GroupButtons->isEnabled()) + return; + // clear myActor = 0; QString aString = ""; + // set busy flag myBusy = true; - myEditCurrentArgument->setText( aString ); + + myEditCurrentArgument->setText(aString); myNbOkElements = 0; - buttonOk->setEnabled( false ); - buttonApply->setEnabled( false ); + buttonOk->setEnabled(false); + buttonApply->setEnabled(false); myBusy = false; - - if ( !GroupButtons->isEnabled() ) // inactive - return; - - buttonOk->setEnabled( false ); - buttonApply->setEnabled( false ); - + // get selected mesh - - int nbSel = SMESH::GetNameOfSelectedIObjects(mySelection, aString); - if(nbSel != 1) + SALOME_ListIO aList; + mySelectionMgr->selectedObjects(aList, SVTK_Viewer::Type()); + int nbSel = SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString); + if (nbSel != 1) return; - - Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject(); + + Handle(SALOME_InteractiveObject) IO = aList.First(); myMesh = SMESH::GetMeshByIO(IO); - if(myMesh->_is_nil()) + if (myMesh->_is_nil()) return; + myActor = SMESH::FindActorByObject(myMesh); if (!myActor) return; - - if (myEditCurrentArgument == LineEditElements) - { - int aNbElements = 0; - myElementsId = ""; - - if (CheckBoxMesh->isChecked()) - { - SMESH::GetNameOfSelectedIObjects(mySelection, aString); - - int aConstructorId = GetConstructorId(); - if(!SMESH::IObjectToInterface(IO)->_is_nil()) //MESH - { - // get IDs from mesh - SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh(); - if (!aSMDSMesh) - return; - - if (aConstructorId == 0) - { - SMDS_EdgeIteratorPtr anIter = aSMDSMesh->edgesIterator(); - - while ( anIter->more() ) - { - const SMDS_MeshEdge * edge = anIter->next(); - if ( edge ) { - myElementsId += QString(" %1").arg(edge->GetID()); - aNbElements++; - } - } - } - else if (aConstructorId == 1) - { - SMDS_FaceIteratorPtr anIter = aSMDSMesh->facesIterator(); - while ( anIter->more() ) - { - const SMDS_MeshFace * face = anIter->next(); - if ( face ) { - myElementsId += QString(" %1").arg(face->GetID()); - aNbElements++; - } - } - } - } - else if (!SMESH::IObjectToInterface(IO)->_is_nil()) //SUBMESH - { - // get submesh - SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface(IO) ; - - // get IDs from submesh - SMESH::long_array_var anElementsIds = new SMESH::long_array; - if (aConstructorId == 0) - anElementsIds = aSubMesh->GetElementsByType(SMESH::EDGE); - else if (aConstructorId == 1) - anElementsIds = aSubMesh->GetElementsByType(SMESH::FACE); - - for ( int i = 0; i < anElementsIds->length(); i++ ) - myElementsId += QString(" %1").arg(anElementsIds[i]); - aNbElements = anElementsIds->length(); - } - else // GROUP - { - // get smesh group - SMESH::SMESH_GroupBase_var aGroup = - SMESH::IObjectToInterface(IO); - if (aGroup->_is_nil()) - return; - - if ( (aConstructorId == 0 && aGroup->GetType()!= SMESH::EDGE) || - (aConstructorId == 1 && aGroup->GetType()!= SMESH::FACE) ) - return; - - // get IDs from smesh group - SMESH::long_array_var anElementsIds = new SMESH::long_array; - anElementsIds = aGroup->GetListOfID(); - for ( int i = 0; i < anElementsIds->length(); i++ ) - myElementsId += QString(" %1").arg(anElementsIds[i]); - aNbElements = anElementsIds->length(); - } - } - else - { - aNbElements = SMESH::GetNameOfSelectedElements(mySelection, aString) ; - myElementsId = aString; - } - - if(aNbElements < 1) - return ; - - myNbOkElements = true; + if (myEditCurrentArgument == LineEditElements) { + int aNbElements = 0; + myElementsId = ""; + + if (CheckBoxMesh->isChecked()) { + int aConstructorId = GetConstructorId(); + + SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString); + + if (!SMESH::IObjectToInterface(IO)->_is_nil()) { //MESH + // get IDs from mesh + SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh(); + if (!aSMDSMesh) + return; + + if (aConstructorId == 0) { + SMDS_EdgeIteratorPtr anIter = aSMDSMesh->edgesIterator(); + + while (anIter->more()) { + const SMDS_MeshEdge * edge = anIter->next(); + if (edge) { + myElementsId += QString(" %1").arg(edge->GetID()); + aNbElements++; + } + } + } else if (aConstructorId == 1) { + SMDS_FaceIteratorPtr anIter = aSMDSMesh->facesIterator(); + while (anIter->more()) { + const SMDS_MeshFace * face = anIter->next(); + if (face) { + myElementsId += QString(" %1").arg(face->GetID()); + aNbElements++; + } + } + } + } else if (!SMESH::IObjectToInterface(IO)->_is_nil()) { //SUBMESH + // get submesh + SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface(IO); + + // get IDs from submesh + SMESH::long_array_var anElementsIds = new SMESH::long_array; + if (aConstructorId == 0) + anElementsIds = aSubMesh->GetElementsByType(SMESH::EDGE); + else if (aConstructorId == 1) + anElementsIds = aSubMesh->GetElementsByType(SMESH::FACE); + + for (int i = 0; i < anElementsIds->length(); i++) + myElementsId += QString(" %1").arg(anElementsIds[i]); + aNbElements = anElementsIds->length(); + } else { // GROUP + // get smesh group + SMESH::SMESH_GroupBase_var aGroup = + SMESH::IObjectToInterface(IO); + if (aGroup->_is_nil()) + return; + + if ((aConstructorId == 0 && aGroup->GetType() != SMESH::EDGE) || + (aConstructorId == 1 && aGroup->GetType()!= SMESH::FACE)) + return; + + // get IDs from smesh group + SMESH::long_array_var anElementsIds = new SMESH::long_array; + anElementsIds = aGroup->GetListOfID(); + for (int i = 0; i < anElementsIds->length(); i++) + myElementsId += QString(" %1").arg(anElementsIds[i]); + aNbElements = anElementsIds->length(); + } + } else { + aNbElements = SMESH::GetNameOfSelectedElements(mySelector, myActor->getIO(), aString); + myElementsId = aString; } - + + if (aNbElements < 1) + return; + + myNbOkElements = true; + } + myBusy = true; - myEditCurrentArgument->setText( aString ); + myEditCurrentArgument->setText(aString); myBusy = false; - - // OK - - if(myNbOkElements) - { - buttonOk->setEnabled( true ); - buttonApply->setEnabled( true ); - } -} + // OK + if (myNbOkElements) { + buttonOk->setEnabled(true); + buttonApply->setEnabled(true); + } +} //================================================================================= // function : SetEditCurrentArgument() @@ -602,151 +615,136 @@ void SMESHGUI_ExtrusionDlg::SelectionIntoArgument() void SMESHGUI_ExtrusionDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); - - disconnect( mySelection, 0, this, 0 ); - mySelection->ClearIObjects(); - mySelection->ClearFilters(); - - if(send == SelectElementsButton) { + + disconnect(mySelectionMgr, 0, this, 0); + mySelectionMgr->clearSelected(); + mySelectionMgr->clearFilters(); + + if (send == SelectElementsButton) { myEditCurrentArgument = LineEditElements; - if (CheckBoxMesh->isChecked()) - { - QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); - mySelection->AddFilter(myMeshOrSubMeshOrGroupFilter); - } - else - { - int aConstructorId = GetConstructorId(); - if (aConstructorId == 0) - QAD_Application::getDesktop()->SetSelectionMode( EdgeSelection, true ); - else if (aConstructorId == 1) - QAD_Application::getDesktop()->SetSelectionMode( FaceSelection, true ); - } + if (CheckBoxMesh->isChecked()) { + myViewWindow->SetSelectionMode(ActorSelection); + mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter); + } else { + int aConstructorId = GetConstructorId(); + if (aConstructorId == 0) + myViewWindow->SetSelectionMode(EdgeSelection); + else if (aConstructorId == 1) + myViewWindow->SetSelectionMode(FaceSelection); + } } - + myEditCurrentArgument->setFocus(); - connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); - SelectionIntoArgument() ; + connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + SelectionIntoArgument(); } //================================================================================= // function : DeactivateActiveDialog() -// purpose : +// purpose : Deactivates this dialog //================================================================================= void SMESHGUI_ExtrusionDlg::DeactivateActiveDialog() { - if ( GroupConstructors->isEnabled() ) { - GroupConstructors->setEnabled(false) ; - GroupArguments->setEnabled(false) ; - GroupButtons->setEnabled(false) ; - mySMESHGUI->ResetState() ; - mySMESHGUI->SetActiveDialogBox(0) ; + if (GroupConstructors->isEnabled()) { + GroupConstructors->setEnabled(false); + GroupArguments->setEnabled(false); + GroupButtons->setEnabled(false); + mySMESHGUI->ResetState(); + mySMESHGUI->SetActiveDialogBox(0); } } - //================================================================================= // function : ActivateThisDialog() -// purpose : +// purpose : Activates this dialog //================================================================================= void SMESHGUI_ExtrusionDlg::ActivateThisDialog() { - /* Emit a signal to deactivate the active dialog */ - mySMESHGUI->EmitSignalDeactivateDialog() ; - GroupConstructors->setEnabled(true) ; - GroupArguments->setEnabled(true) ; - GroupButtons->setEnabled(true) ; - - mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; + // Emit a signal to deactivate the active dialog + mySMESHGUI->EmitSignalDeactivateDialog(); + GroupConstructors->setEnabled(true); + GroupArguments->setEnabled(true); + GroupButtons->setEnabled(true); + + mySMESHGUI->SetActiveDialogBox(this); ConstructorsClicked(GetConstructorId()); SelectionIntoArgument(); } - //================================================================================= // function : enterEvent() -// purpose : +// purpose : Mouse enter event //================================================================================= -void SMESHGUI_ExtrusionDlg::enterEvent(QEvent* e) +void SMESHGUI_ExtrusionDlg::enterEvent (QEvent*) { - if ( GroupConstructors->isEnabled() ) - return ; - ActivateThisDialog() ; + if (!GroupConstructors->isEnabled()) + ActivateThisDialog(); } - //================================================================================= // function : closeEvent() // purpose : //================================================================================= -void SMESHGUI_ExtrusionDlg::closeEvent( QCloseEvent* e ) -{ - /* same than click on cancel button */ - this->ClickOnCancel() ; -} +//void SMESHGUI_ExtrusionDlg::closeEvent (QCloseEvent*) +//{ +// /* same than click on cancel button */ +// this->ClickOnCancel(); +//} +// +//================================================================================= +// function : hideEvent() +// purpose : caused by ESC key +//================================================================================= +//void SMESHGUI_ExtrusionDlg::hideEvent (QHideEvent*) +//{ +// if (!isMinimized()) +// ClickOnCancel(); +//} - -//======================================================================= -//function : hideEvent -//purpose : caused by ESC key -//======================================================================= - -void SMESHGUI_ExtrusionDlg::hideEvent ( QHideEvent * e ) -{ - if ( !isMinimized() ) - ClickOnCancel(); -} - - -//======================================================================= -//function : onSelectMesh -//purpose : -//======================================================================= -void SMESHGUI_ExtrusionDlg::onSelectMesh ( bool toSelectMesh ) +//================================================================================= +// function : onSelectMesh() +// purpose : +//================================================================================= +void SMESHGUI_ExtrusionDlg::onSelectMesh (bool toSelectMesh) { if (toSelectMesh) - TextLabelElements->setText( tr( "SMESH_NAME" ) ); + TextLabelElements->setText(tr("SMESH_NAME")); else - TextLabelElements->setText( tr( "SMESH_ID_ELEMENTS" ) ); - - if (myEditCurrentArgument != LineEditElements) - { - LineEditElements->clear(); - return; - } - - mySelection->ClearFilters() ; - - if (toSelectMesh) - { - QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); - mySelection->AddFilter(myMeshOrSubMeshOrGroupFilter); - LineEditElements->setReadOnly(true); - } - else - { - int aConstructorId = GetConstructorId(); - if (aConstructorId == 0) - QAD_Application::getDesktop()->SetSelectionMode( EdgeSelection, true ); - else if (aConstructorId == 0) - QAD_Application::getDesktop()->SetSelectionMode( FaceSelection, true ); - - LineEditElements->setReadOnly(false); - onTextChange(LineEditElements->text()); - } - + TextLabelElements->setText(tr("SMESH_ID_ELEMENTS")); + + if (myEditCurrentArgument != LineEditElements) { + LineEditElements->clear(); + return; + } + + mySelectionMgr->clearFilters(); + + if (toSelectMesh) { + myViewWindow->SetSelectionMode(ActorSelection); + mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter); + LineEditElements->setReadOnly(true); + } else { + int aConstructorId = GetConstructorId(); + if (aConstructorId == 0) + myViewWindow->SetSelectionMode(EdgeSelection); + else if (aConstructorId == 0) + myViewWindow->SetSelectionMode(FaceSelection); + + LineEditElements->setReadOnly(false); + onTextChange(LineEditElements->text()); + } + SelectionIntoArgument(); } - //================================================================================= // function : GetConstructorId() -// purpose : +// purpose : //================================================================================= int SMESHGUI_ExtrusionDlg::GetConstructorId() -{ - if ( GroupConstructors != NULL && GroupConstructors->selected() != NULL ) - return GroupConstructors->id( GroupConstructors->selected() ); +{ + if (GroupConstructors != NULL && GroupConstructors->selected() != NULL) + return GroupConstructors->id(GroupConstructors->selected()); return -1; } diff --git a/src/SMESHGUI/SMESHGUI_ExtrusionDlg.h b/src/SMESHGUI/SMESHGUI_ExtrusionDlg.h index c6f80f0e2..ab086e5b1 100644 --- a/src/SMESHGUI/SMESHGUI_ExtrusionDlg.h +++ b/src/SMESHGUI/SMESHGUI_ExtrusionDlg.h @@ -29,102 +29,101 @@ #ifndef DIALOGBOX_EXTRUSION_H #define DIALOGBOX_EXTRUSION_H -#include "SALOME_Selection.h" -#include "SMESH_LogicalFilter.hxx" +#include "SalomeApp_SelectionMgr.h" +#include "SUIT_SelectionFilter.h" // QT Includes #include class QGridLayout; class QButtonGroup; +class QRadioButton; class QGroupBox; class QLabel; class QLineEdit; -class QPushButton; -class QRadioButton; class QCheckBox; class QSpinBox; -class SMESHGUI_SpinBox; +class QPushButton; + class SMESHGUI; class SMESH_Actor; +class SMESHGUI_SpinBox; +class SVTK_ViewWindow; +class SVTK_Selector; // IDL Headers #include #include CORBA_SERVER_HEADER(SMESH_Mesh) - //================================================================================= // class : SMESHGUI_ExtrusionDlg // purpose : //================================================================================= class SMESHGUI_ExtrusionDlg : public QDialog -{ - Q_OBJECT +{ + Q_OBJECT public: - SMESHGUI_ExtrusionDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); - ~SMESHGUI_ExtrusionDlg(); + SMESHGUI_ExtrusionDlg (SMESHGUI*, + bool modal = FALSE); + ~SMESHGUI_ExtrusionDlg(); private: + void Init (bool ResetControls = true); + void enterEvent (QEvent*); /* mouse enter the QWidget */ + int GetConstructorId(); + //void closeEvent (QCloseEvent*); + //void hideEvent (QHideEvent*); /* ESC key */ - void Init( bool ResetControls = true ) ; - void closeEvent( QCloseEvent* e ) ; - void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */ - void hideEvent ( QHideEvent * ); /* ESC key */ - int GetConstructorId(); + SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */ + SalomeApp_SelectionMgr* mySelectionMgr; /* User shape selection */ + QLineEdit* myEditCurrentArgument; /* Current LineEdit */ + QString myElementsId; + int myNbOkElements; /* to check when elements are defined */ + SVTK_ViewWindow* myViewWindow; + SVTK_Selector* mySelector; - SMESHGUI* mySMESHGUI ; /* Current SMESHGUI object */ - SALOME_Selection* mySelection ; /* User shape selection */ - QString myElementsId; - int myNbOkElements ; /* to check when elements are defined */ - - QLineEdit* myEditCurrentArgument; /* Current LineEdit */ + bool myBusy; + SMESH::SMESH_Mesh_var myMesh; + SMESH_Actor* myActor; + SUIT_SelectionFilter* myMeshOrSubMeshOrGroupFilter; - bool myBusy; - SMESH::SMESH_Mesh_var myMesh; - SMESH_Actor* myActor; - Handle(SMESH_LogicalFilter) myMeshOrSubMeshOrGroupFilter; + // widgets + QButtonGroup* GroupConstructors; + QRadioButton* RadioButton1; + QRadioButton* RadioButton2; - QButtonGroup* GroupConstructors; - QRadioButton* RadioButton1; - QRadioButton* RadioButton2; - QGroupBox* GroupButtons; - QPushButton* buttonOk; - QPushButton* buttonCancel; - QPushButton* buttonApply; - QGroupBox* GroupArguments; - QLabel* TextLabelElements; - QPushButton* SelectElementsButton; - QLineEdit* LineEditElements; - QCheckBox* CheckBoxMesh; - QLabel* TextLabelVector; - QLabel* TextLabelDx; - SMESHGUI_SpinBox* SpinBox_Dx; - QLabel* TextLabelDy; - SMESHGUI_SpinBox* SpinBox_Dy; - QLabel* TextLabelDz; - SMESHGUI_SpinBox* SpinBox_Dz; - QLabel* TextLabelNbSteps; - QSpinBox* SpinBox_NbSteps; - - private slots: + QGroupBox* GroupArguments; + QLabel* TextLabelElements; + QPushButton* SelectElementsButton; + QLineEdit* LineEditElements; + QCheckBox* CheckBoxMesh; + QLabel* TextLabelVector; + QLabel* TextLabelDx; + SMESHGUI_SpinBox* SpinBox_Dx; + QLabel* TextLabelDy; + SMESHGUI_SpinBox* SpinBox_Dy; + QLabel* TextLabelDz; + SMESHGUI_SpinBox* SpinBox_Dz; + QLabel* TextLabelNbSteps; + QSpinBox* SpinBox_NbSteps; - void ConstructorsClicked(int constructorId); - void ClickOnOk(); - void ClickOnCancel(); - void ClickOnApply(); - void SetEditCurrentArgument() ; - void SelectionIntoArgument() ; - void DeactivateActiveDialog() ; - void ActivateThisDialog() ; - void onTextChange(const QString&); - void onSelectMesh(bool toSelectMesh); - -protected: - QGridLayout* SMESHGUI_ExtrusionDlgLayout; - QGridLayout* GroupConstructorsLayout; - QGridLayout* GroupButtonsLayout; - QGridLayout* GroupArgumentsLayout; + QGroupBox* GroupButtons; + QPushButton* buttonOk; + QPushButton* buttonCancel; + QPushButton* buttonApply; + +private slots: + void ConstructorsClicked (int); + void ClickOnOk(); + bool ClickOnApply(); + void ClickOnCancel(); + void SetEditCurrentArgument(); + void SelectionIntoArgument(); + void DeactivateActiveDialog(); + void ActivateThisDialog(); + void onTextChange (const QString&); + void onSelectMesh (bool toSelectMesh); }; #endif // DIALOGBOX_EXTRUSION_H diff --git a/src/SMESHGUI/SMESHGUI_Filter.cxx b/src/SMESHGUI/SMESHGUI_Filter.cxx index 52f36378b..19b3fcb1a 100755 --- a/src/SMESHGUI/SMESHGUI_Filter.cxx +++ b/src/SMESHGUI/SMESHGUI_Filter.cxx @@ -26,17 +26,21 @@ // Module : SMESH #include "SMESHGUI_Filter.h" + +#include "SMESHGUI.h" #include "SMESHGUI_Utils.h" + +#include "SMESH_Actor.h" #include "SMDS_Mesh.hxx" #include "SMDS_MeshElement.hxx" #include "SMDSAbs_ElementType.hxx" -#include - +// OCCT Includes #include #include -#include "SMESH_Actor.h" -#include "SMESHGUI.h" + +// VTK Includes +#include IMPLEMENT_STANDARD_HANDLE(SMESHGUI_Filter, VTKViewer_Filter) IMPLEMENT_STANDARD_RTTIEXT(SMESHGUI_Filter, VTKViewer_Filter) @@ -86,7 +90,7 @@ bool SMESHGUI_PredicateFilter::IsValid( const int theCellId ) const SMESH_Actor* anActor = dynamic_cast( myActor ); if ( !anActor || anActor->GetObject() == 0 ) return false; - + SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh(); SMESH::ElementType anElemType = myPred->GetElementType(); int aMeshId = anElemType == SMESH::NODE ? anActor->GetNodeObjId( theCellId ) @@ -98,7 +102,7 @@ bool SMESHGUI_PredicateFilter::IsValid( const int theCellId ) const : aMesh->FindElement( aMeshId ); if ( anElem != 0 && anElem->GetType() != (SMDSAbs_ElementType)myPred->GetElementType() ) return true; - + return myPred->IsSatisfy( aMeshId ); } @@ -114,10 +118,10 @@ bool SMESHGUI_PredicateFilter::IsObjValid( const int theObjId ) const SMESH_Actor* anActor = ( SMESH_Actor* )myActor; if ( anActor->GetObject() == 0 ) return false; - + SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh(); SMESH::ElementType anElemType = 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 ) @@ -158,7 +162,10 @@ void SMESHGUI_PredicateFilter::SetActor( SALOME_Actor* theActor ) if ( myActor != 0 && !myPred->_is_nil() ) { - Handle(SALOME_InteractiveObject) anIO = myActor->getIO(); + SALOME_Actor* sActor = dynamic_cast( myActor ); + Handle(SALOME_InteractiveObject) anIO; + if( sActor ) + anIO = sActor->getIO(); if ( !anIO.IsNull() ) { SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface(anIO); @@ -214,10 +221,10 @@ bool SMESHGUI_QuadrangleFilter::IsValid( const int theCellId ) const SMESH_Actor* anActor = ( SMESH_Actor* )myActor; if ( anActor->GetObject() == 0 ) return false; - + SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh(); const SMDS_MeshElement* anElem = aMesh->FindElement( anActor->GetElemObjId( theCellId ) ); - + return anElem && anElem->GetType() == SMDSAbs_Face && anElem->NbNodes() == 4; } @@ -233,7 +240,7 @@ bool SMESHGUI_QuadrangleFilter::IsObjValid( const int theObjId ) const SMESH_Actor* anActor = ( SMESH_Actor* )myActor; if ( anActor->GetObject() == 0 ) return false; - + SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh(); const SMDS_MeshElement* anElem = aMesh->FindElement( theObjId ); @@ -291,7 +298,7 @@ bool SMESHGUI_TriangleFilter::IsValid( const int theCellId ) const SMESH_Actor* anActor = ( SMESH_Actor* )myActor; if ( anActor->GetObject() == 0 ) return false; - + SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh(); const SMDS_MeshElement* anElem = aMesh->FindElement( anActor->GetElemObjId( theCellId ) ); @@ -310,7 +317,7 @@ bool SMESHGUI_TriangleFilter::IsObjValid( const int theObjId ) const SMESH_Actor* anActor = ( SMESH_Actor* )myActor; if ( anActor->GetObject() == 0 ) return false; - + SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh(); const SMDS_MeshElement* anElem = aMesh->FindElement( theObjId ); @@ -367,7 +374,7 @@ bool SMESHGUI_FacesFilter::IsValid( const int theCellId ) const SMESH_Actor* anActor = ( SMESH_Actor* )myActor; if ( anActor->GetObject() == 0 ) return false; - + SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh(); const SMDS_MeshElement* anElem = aMesh->FindElement( anActor->GetElemObjId( theCellId ) ); @@ -386,7 +393,7 @@ bool SMESHGUI_FacesFilter::IsObjValid( const int theObjId ) const SMESH_Actor* anActor = ( SMESH_Actor* )myActor; if ( anActor->GetObject() == 0 ) return false; - + SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh(); const SMDS_MeshElement* anElem = aMesh->FindElement( theObjId ); @@ -444,7 +451,7 @@ bool SMESHGUI_VolumesFilter::IsValid( const int theCellId ) const SMESH_Actor* anActor = ( SMESH_Actor* )myActor; if ( anActor->GetObject() == 0 ) return false; - + SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh(); const SMDS_MeshElement* anElem = aMesh->FindElement( anActor->GetElemObjId( theCellId ) ); @@ -463,7 +470,7 @@ bool SMESHGUI_VolumesFilter::IsObjValid( const int theObjId ) const SMESH_Actor* anActor = ( SMESH_Actor* )myActor; if ( anActor->GetObject() == 0 ) return false; - + SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh(); const SMDS_MeshElement* anElem = aMesh->FindElement( theObjId ); @@ -488,14 +495,3 @@ bool SMESHGUI_VolumesFilter::IsNodeFilter() const { return false; } - - - - - - - - - - - diff --git a/src/SMESHGUI/SMESHGUI_Filter.h b/src/SMESHGUI/SMESHGUI_Filter.h index a7fc9e1b3..0114f38b8 100755 --- a/src/SMESHGUI/SMESHGUI_Filter.h +++ b/src/SMESHGUI/SMESHGUI_Filter.h @@ -13,11 +13,11 @@ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org // // // @@ -50,7 +50,7 @@ enum SMESHGUI_FilterType /* Class : SMESHGUI_Filter - Description : Base class for SMESH selection filters for VTK viewer. + Description : Base class for SMESH selection filters for VTK viewer. */ DEFINE_STANDARD_HANDLE(SMESHGUI_Filter, VTKViewer_Filter) diff --git a/src/SMESHGUI/SMESHGUI_FilterDlg.cxx b/src/SMESHGUI/SMESHGUI_FilterDlg.cxx index 62a04bb74..873c5f688 100755 --- a/src/SMESHGUI/SMESHGUI_FilterDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_FilterDlg.cxx @@ -1,22 +1,22 @@ // SMESH SMESHGUI : GUI for SMESH component // // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org // // @@ -30,35 +30,47 @@ #include "SMESHGUI.h" #include "SMESHGUI_Utils.h" #include "SMESHGUI_VTKUtils.h" -#include "SMESHGUI_FilterUtils.h" - #include "SMESHGUI_Filter.h" -#include "SMESH_Actor.h" -#include "VTKViewer_ViewFrame.h" -#include "QAD_Desktop.h" -#include "QAD_MessageBox.h" -#include "QAD_RightFrame.h" -#include "QAD_Config.h" -#include "SALOME_ListIteratorOfListIO.hxx" -#include "SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger.hxx" -#include "SALOMEGUI_QtCatchCorbaException.hxx" +#include "SMESHGUI_FilterUtils.h" #include "SMESHGUI_FilterLibraryDlg.h" -#include "SALOME_TypeFilter.hxx" + +#include "SMESH_Actor.h" +#include "SMESH_NumberFilter.hxx" +#include "SMESH_TypeFilter.hxx" #include "GEOMBase.h" -#include "GEOM_FaceFilter.hxx" +#include "GEOM_FaceFilter.h" +#include "GEOM_TypeFilter.h" +#include "SUIT_Desktop.h" +#include "SUIT_ResourceMgr.h" + +#include "SalomeApp_Application.h" +#include "SalomeApp_Tools.h" +#include "SalomeApp_Study.h" + +#include "SALOME_ListIO.hxx" +#include "SALOME_ListIteratorOfListIO.hxx" +#include "SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger.hxx" +#include "SALOMEDSClient_Study.hxx" + +#include "SVTK_ViewWindow.h" +#include "SVTK_Selector.h" + +// OCCT Includes +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include -#include -#include -#include -#include -#include -#include -#include +// QT Includes #include #include #include @@ -85,23 +97,23 @@ #include "SALOMEconfig.h" #include CORBA_SERVER_HEADER(SMESH_Group) -#define SPACING 5 +#define SPACING 5 #define MARGIN 10 using namespace SMESH; -static int maxLength( const QMap theMap, const QFontMetrics& theMetrics ) +static int maxLength (const QMap theMap, const QFontMetrics& theMetrics) { int aRes = 0; QMap::const_iterator anIter; - for ( anIter = theMap.begin(); anIter != theMap.end(); ++anIter ) - aRes = Max( aRes, theMetrics.width( anIter.data() ) ); - return aRes; + for (anIter = theMap.begin(); anIter != theMap.end(); ++anIter) + aRes = Max(aRes, theMetrics.width(anIter.data())); + return aRes; } -static int getFilterId( SMESH::ElementType theType ) +static int getFilterId (SMESH::ElementType theType) { - switch ( theType ) + switch (theType) { case SMESH::NODE : return SMESHGUI_NodeFilter; case SMESH::EDGE : return SMESHGUI_EdgeFilter; @@ -121,127 +133,126 @@ class SMESHGUI_FilterTable::AdditionalWidget : public QFrame { public: enum { Tolerance }; - + public: - AdditionalWidget( QWidget* theParent ); + AdditionalWidget(QWidget* theParent); virtual ~AdditionalWidget(); - virtual void GetParameters( QValueList& ) const; - virtual bool IsValid( const bool theMsg = true ) const; - virtual double GetDouble( const int theId ) const; - virtual int GetInteger( const int theId ) const; - virtual QString GetString( const int theId ) const; - virtual void SetDouble( const int theId, const double theVal ); - virtual void SetInteger( const int theId, const int theVal ); - virtual void SetString( const int theId, const QString& theVal ); - void SetEditable( const int theId, const bool isEditable ); - void SetEditable( const bool isEditable ); + virtual void GetParameters(QValueList&) const; + virtual bool IsValid(const bool theMsg = true) const; + virtual double GetDouble(const int theId) const; + virtual int GetInteger(const int theId) const; + virtual QString GetString(const int theId) const; + virtual void SetDouble(const int theId, const double theVal); + virtual void SetInteger(const int theId, const int theVal); + virtual void SetString(const int theId, const QString& theVal); + void SetEditable(const int theId, const bool isEditable); + void SetEditable(const bool isEditable); private: QMap< int, QLineEdit* > myLineEdits; }; -SMESHGUI_FilterTable::AdditionalWidget::AdditionalWidget( QWidget* theParent ) -: QFrame( theParent ) +SMESHGUI_FilterTable::AdditionalWidget::AdditionalWidget (QWidget* theParent) + : QFrame(theParent) { - QLabel* aLabel = new QLabel( tr( "SMESH_TOLERANCE" ), this ); - myLineEdits[ Tolerance ] = new QLineEdit( this ); - QDoubleValidator* aValidator = new QDoubleValidator( myLineEdits[ Tolerance ] ); - aValidator->setBottom( 0 ); - myLineEdits[ Tolerance ]->setValidator( aValidator ); + QLabel* aLabel = new QLabel(tr("SMESH_TOLERANCE"), this); + myLineEdits[ Tolerance ] = new QLineEdit(this); + QDoubleValidator* aValidator = new QDoubleValidator(myLineEdits[ Tolerance ]); + aValidator->setBottom(0); + myLineEdits[ Tolerance ]->setValidator(aValidator); - QHBoxLayout* aLay = new QHBoxLayout( this, 0, SPACING ); - aLay->addWidget( aLabel ); - aLay->addWidget( myLineEdits[ Tolerance ] ); - - QSpacerItem* aSpacer = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum ); - aLay->addItem( aSpacer ); + QHBoxLayout* aLay = new QHBoxLayout(this, 0, SPACING); + aLay->addWidget(aLabel); + aLay->addWidget(myLineEdits[ Tolerance ]); - QString aText = QString( "%1" ).arg( Precision::Confusion() ); - myLineEdits[ Tolerance ]->setText( aText ); + QSpacerItem* aSpacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum); + aLay->addItem(aSpacer); + + QString aText = QString("%1").arg(Precision::Confusion()); + myLineEdits[ Tolerance ]->setText(aText); } -SMESHGUI_FilterTable::AdditionalWidget::~AdditionalWidget() + + SMESHGUI_FilterTable::AdditionalWidget::~AdditionalWidget() { } -void SMESHGUI_FilterTable::AdditionalWidget::GetParameters( QValueList& theList ) const +void SMESHGUI_FilterTable::AdditionalWidget::GetParameters (QValueList& theList) const { theList.clear(); - theList.append( Tolerance ); + theList.append(Tolerance); } -bool SMESHGUI_FilterTable::AdditionalWidget::IsValid( const bool theMsg ) const +bool SMESHGUI_FilterTable::AdditionalWidget::IsValid (const bool theMsg) const { - if ( !isEnabled() ) + if (!isEnabled()) return true; QValueList aParams; - GetParameters( aParams ); + GetParameters(aParams); QValueList::const_iterator anIter; - for ( anIter = aParams.begin(); anIter != aParams.end(); ++anIter ) - { + for (anIter = aParams.begin(); anIter != aParams.end(); ++anIter) { const QLineEdit* aWg = myLineEdits[ *anIter ]; int p = 0; QString aText = aWg->text(); - if ( aWg->isEnabled() && aWg->validator()->validate( aText, p ) != QValidator::Acceptable ) - { - if ( theMsg ) - QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), - tr( "SMESH_INSUFFICIENT_DATA" ), tr( "SMESHGUI_INVALID_PARAMETERS" ), QMessageBox::Ok ); - return false; + if (aWg->isEnabled() && aWg->validator()->validate(aText, p) != QValidator::Acceptable) { + if (theMsg) + QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"), + tr("SMESHGUI_INVALID_PARAMETERS"), QMessageBox::Ok); + return false; } } return true; } -double SMESHGUI_FilterTable::AdditionalWidget::GetDouble( const int theId ) const +double SMESHGUI_FilterTable::AdditionalWidget::GetDouble (const int theId) const { - return myLineEdits.contains( theId ) ? myLineEdits[ theId ]->text().toDouble() : 0; + return myLineEdits.contains(theId) ? myLineEdits[ theId ]->text().toDouble() : 0; } -int SMESHGUI_FilterTable::AdditionalWidget::GetInteger( const int theId ) const +int SMESHGUI_FilterTable::AdditionalWidget::GetInteger (const int theId) const { - return myLineEdits.contains( theId ) ? myLineEdits[ theId ]->text().toInt() : 0; + return myLineEdits.contains(theId) ? myLineEdits[ theId ]->text().toInt() : 0; } -QString SMESHGUI_FilterTable::AdditionalWidget::GetString( const int theId ) const +QString SMESHGUI_FilterTable::AdditionalWidget::GetString (const int theId) const { - return myLineEdits.contains( theId ) ? myLineEdits[ theId ]->text() : QString(""); + return myLineEdits.contains(theId) ? myLineEdits[ theId ]->text() : QString(""); } -void SMESHGUI_FilterTable::AdditionalWidget::SetDouble( const int theId, const double theVal ) +void SMESHGUI_FilterTable::AdditionalWidget::SetDouble (const int theId, const double theVal) { - if ( myLineEdits.contains( theId ) ) - myLineEdits[ theId ]->setText( QString( "%1" ).arg( theVal ) ); + if (myLineEdits.contains(theId)) + myLineEdits[ theId ]->setText(QString("%1").arg(theVal)); } -void SMESHGUI_FilterTable::AdditionalWidget::SetInteger( const int theId, const int theVal ) +void SMESHGUI_FilterTable::AdditionalWidget::SetInteger (const int theId, const int theVal) { - if ( myLineEdits.contains( theId ) ) - myLineEdits[ theId ]->setText( QString( "%1" ).arg( theVal ) ); + if (myLineEdits.contains(theId)) + myLineEdits[ theId ]->setText(QString("%1").arg(theVal)); } -void SMESHGUI_FilterTable::AdditionalWidget::SetString( const int theId, const QString& theVal ) +void SMESHGUI_FilterTable::AdditionalWidget::SetString (const int theId, const QString& theVal) { - if ( myLineEdits.contains( theId ) ) - myLineEdits[ theId ]->setText( theVal ); + if (myLineEdits.contains(theId)) + myLineEdits[ theId ]->setText(theVal); } -void SMESHGUI_FilterTable::AdditionalWidget::SetEditable( const int theId, const bool isEditable ) +void SMESHGUI_FilterTable::AdditionalWidget::SetEditable (const int theId, const bool isEditable) { - if ( myLineEdits.contains( theId ) ) - myLineEdits[ theId ]->setEdited( isEditable ); + if (myLineEdits.contains(theId)) + myLineEdits[ theId ]->setEdited(isEditable); } -void SMESHGUI_FilterTable::AdditionalWidget::SetEditable( const bool isEditable ) +void SMESHGUI_FilterTable::AdditionalWidget::SetEditable (const bool isEditable) { QValueList aParams; - GetParameters( aParams ); + GetParameters(aParams); QValueList::const_iterator anIter; - for ( anIter = aParams.begin(); anIter != aParams.end(); ++anIter ) - myLineEdits[ *anIter ]->setEdited( isEditable ); + for (anIter = aParams.begin(); anIter != aParams.end(); ++anIter) + myLineEdits[ *anIter ]->setEdited(isEditable); } /* @@ -250,97 +261,95 @@ void SMESHGUI_FilterTable::AdditionalWidget::SetEditable( const bool isEditable */ class SMESHGUI_FilterTable::ComboItem : public QComboTableItem - { public: - ComboItem( QTable*, const QMap& ); + ComboItem(QTable*, const QMap&); virtual ~ComboItem(); - virtual void setStringList ( const QStringList & l ); - void setStringList( const QMap& theIds ); + virtual void setStringList (const QStringList & l); + void setStringList(const QMap& theIds); int GetValue() const; - void SetValue( const int ); - + void SetValue(const int); + private: - + QMap myNumToId; QMap myIdToNum; }; -SMESHGUI_FilterTable::ComboItem::ComboItem( QTable* theParent, - const QMap& theIds ) -: QComboTableItem( theParent, QStringList() ) +SMESHGUI_FilterTable::ComboItem::ComboItem (QTable* theParent, + const QMap& theIds) +: QComboTableItem(theParent, QStringList()) { - setStringList( theIds ); + setStringList(theIds); } -void SMESHGUI_FilterTable::ComboItem::setStringList( const QStringList & l ) +void SMESHGUI_FilterTable::ComboItem::setStringList (const QStringList & l) { - QComboTableItem::setStringList( l ); + QComboTableItem::setStringList(l); } -void SMESHGUI_FilterTable::ComboItem::setStringList( const QMap& theIds ) +void SMESHGUI_FilterTable::ComboItem::setStringList (const QMap& theIds) { int i = 0; QStringList aList; QMap::const_iterator anIter; - for ( anIter = theIds.begin(); anIter != theIds.end(); ++anIter ) - { + for (anIter = theIds.begin(); anIter != theIds.end(); ++anIter) { myNumToId[ i ] = anIter.key(); myIdToNum[ anIter.key() ] = i; - aList.append( anIter.data() ); + aList.append(anIter.data()); i++; } - setStringList( aList ); + setStringList(aList); } SMESHGUI_FilterTable::ComboItem::~ComboItem() { } - + int SMESHGUI_FilterTable::ComboItem::GetValue() const { return myNumToId[ currentItem() ]; } -void SMESHGUI_FilterTable::ComboItem::SetValue( const int theVal ) +void SMESHGUI_FilterTable::ComboItem::SetValue (const int theVal) { - setCurrentItem( myIdToNum[ theVal ] ); + setCurrentItem(myIdToNum[ theVal ]); } /* - Class : SMESHGUI_FilterTable::Table + Class : SMESHGUI_FilterTable::Table Description : Table used by this widget */ class SMESHGUI_FilterTable::Table : public QTable { public: - Table( QWidget* parent ); - Table( int numRows, int numCols, QWidget* parent = 0 ); + Table(QWidget* parent); + Table(int numRows, int numCols, QWidget* parent = 0); virtual ~Table(); - void SetEditable( const bool state, const int row, const int col ); - bool IsEditable( const int row, const int col ) const; + void SetEditable(const bool state, const int row, const int col); + bool IsEditable(const int row, const int col) const; - virtual void insertRows( int row, int count = 1 ); - virtual QString text( int row, int col ) const; + virtual void insertRows(int row, int count = 1); + virtual QString text(int row, int col) const; }; //======================================================================= // name : SMESHGUI_FilterTable::Table::Table // Purpose : Constructor //======================================================================= -SMESHGUI_FilterTable::Table::Table( QWidget* parent ) -: QTable( parent, "SMESHGUI_FilterTable::Table" ) +SMESHGUI_FilterTable::Table::Table (QWidget* parent) +: QTable(parent, "SMESHGUI_FilterTable::Table") { } -SMESHGUI_FilterTable::Table::Table( int numRows, int numCols, QWidget* parent ) -: QTable( numRows, numCols, parent, "SMESHGUI_FilterTable::Table" ) +SMESHGUI_FilterTable::Table::Table (int numRows, int numCols, QWidget* parent) +: QTable(numRows, numCols, parent, "SMESHGUI_FilterTable::Table") { } @@ -352,63 +361,63 @@ SMESHGUI_FilterTable::Table::~Table() // name : SMESHGUI_FilterTable::Table::SetEditable // Purpose : Set editable of specified cell //======================================================================= -void SMESHGUI_FilterTable::Table::SetEditable( const bool isEditable, const int row, const int col ) +void SMESHGUI_FilterTable::Table::SetEditable (const bool isEditable, + const int row, const int col) { - QTableItem* anItem = item( row, col ); - if( anItem ) - takeItem( anItem ); + QTableItem* anItem = item(row, col); + if(anItem) + takeItem(anItem); - if ( !isEditable ) - setItem( row, col, new QTableItem( this, QTableItem::Never, "" ) ); + if (!isEditable) + setItem(row, col, new QTableItem(this, QTableItem::Never, "")); else - setItem( row, col, new QTableItem( this, QTableItem::OnTyping, "" ) ); + setItem(row, col, new QTableItem(this, QTableItem::OnTyping, "")); } //======================================================================= // name : SMESHGUI_FilterTable::Table::IsEditable // Purpose : Verify wheter cell is editable //======================================================================= -bool SMESHGUI_FilterTable::Table::IsEditable( const int row, const int col ) const +bool SMESHGUI_FilterTable::Table::IsEditable (const int row, const int col) const { - QTableItem* anItem = item( row, col ); + QTableItem* anItem = item(row, col); return anItem == 0 || anItem->editType() != QTableItem::Never; } //======================================================================= // name : SMESHGUI_FilterTable::Table::insertRows -// Purpose : Insert rows ( virtual redefined ) +// Purpose : Insert rows (virtual redefined) //======================================================================= -void SMESHGUI_FilterTable::Table::insertRows( int row, int count ) +void SMESHGUI_FilterTable::Table::insertRows (int row, int count) { int anEditRow = currEditRow(); int anEditCol = currEditCol(); - if ( anEditRow >= 0 && anEditCol >= 0 ) - endEdit( anEditRow, anEditCol, true, false ); + if (anEditRow >= 0 && anEditCol >= 0) + endEdit(anEditRow, anEditCol, true, false); - QTable::insertRows( row, count ); + QTable::insertRows(row, count); } //======================================================================= // name : SMESHGUI_FilterTable::Table::text -// Purpose : Get text from cell ( virtual redefined ) +// Purpose : Get text from cell (virtual redefined) //======================================================================= -QString SMESHGUI_FilterTable::Table::text( int row, int col ) const +QString SMESHGUI_FilterTable::Table::text (int row, int col) const { int anEditRow = currEditRow(); int anEditCol = currEditCol(); - if ( anEditRow >= 0 && anEditCol >= 0 && anEditRow == row && anEditCol == col ) - ((Table*)this)->endEdit( row, col, true, false ); + if (anEditRow >= 0 && anEditCol >= 0 && anEditRow == row && anEditCol == col) + ((Table*)this)->endEdit(row, col, true, false); - return QTable::text( row, col ); + return QTable::text(row, col); } - /* Class : SMESHGUI_FilterTable - Description : Frame containig + Description : Frame containig - Button group for switching entity type - Table for displaying filter criterions - Buttons for editing table and filter libraries @@ -418,25 +427,25 @@ QString SMESHGUI_FilterTable::Table::text( int row, int col ) const // name : SMESHGUI_FilterTable::SMESHGUI_FilterTable // Purpose : Constructor //======================================================================= -SMESHGUI_FilterTable::SMESHGUI_FilterTable( QWidget* parent, - const int type ) -: QFrame( parent ) +SMESHGUI_FilterTable::SMESHGUI_FilterTable (QWidget* parent, + const int type) +: QFrame(parent) { myEntityType = -1; - Init( type ); -} + Init(type); +} //======================================================================= // name : SMESHGUI_FilterTable::SMESHGUI_FilterTable // Purpose : Constructor //======================================================================= -SMESHGUI_FilterTable::SMESHGUI_FilterTable( QWidget* parent, - const QValueList& types ) -: QFrame( parent ) +SMESHGUI_FilterTable::SMESHGUI_FilterTable (QWidget* parent, + const QValueList& types) +: QFrame(parent) { myEntityType = -1; - Init( types ); -} + Init(types); +} SMESHGUI_FilterTable::~SMESHGUI_FilterTable() { @@ -446,153 +455,153 @@ SMESHGUI_FilterTable::~SMESHGUI_FilterTable() // name : SMESHGUI_FilterTable::Init // Purpose : Create table corresponding to the specified type //======================================================================= -void SMESHGUI_FilterTable::Init( const int type ) +void SMESHGUI_FilterTable::Init (const int type) { QValueList aTypes; - aTypes.append( type ); - Init( aTypes ); + aTypes.append(type); + Init(aTypes); } //======================================================================= // name : SMESHGUI_FilterTable::Init // Purpose : Create table corresponding to the specified type //======================================================================= -void SMESHGUI_FilterTable::Init( const QValueList& theTypes ) +void SMESHGUI_FilterTable::Init (const QValueList& theTypes) { - if ( theTypes.isEmpty() ) + if (theTypes.isEmpty()) return; - + // Create buttons if necessary - - if ( myTables.isEmpty() ) + + if (myTables.isEmpty()) { int aType = theTypes.first(); // create main layout - QVBoxLayout* aMainLay = new QVBoxLayout( this ); - QGroupBox* aMainGrp = new QGroupBox( 1, Qt::Horizontal, this ); - aMainGrp->setFrameStyle( QFrame::NoFrame ); - aMainGrp->setInsideMargin( 0 ); - aMainLay->addWidget( aMainGrp ); - + QVBoxLayout* aMainLay = new QVBoxLayout(this); + QGroupBox* aMainGrp = new QGroupBox(1, Qt::Horizontal, this); + aMainGrp->setFrameStyle(QFrame::NoFrame); + aMainGrp->setInsideMargin(0); + aMainLay->addWidget(aMainGrp); + // create switch of entity types - myEntityTypeGrp = new QButtonGroup( 1, Qt::Vertical, tr( "ENTITY_TYPE" ), aMainGrp ); + myEntityTypeGrp = new QButtonGroup(1, Qt::Vertical, tr("ENTITY_TYPE"), aMainGrp); const QMap& aSupportedTypes = getSupportedTypes(); QMap::const_iterator anIter; - for ( anIter = aSupportedTypes.begin(); anIter != aSupportedTypes.end(); ++anIter ) + for (anIter = aSupportedTypes.begin(); anIter != aSupportedTypes.end(); ++anIter) { - QRadioButton* aBtn = new QRadioButton( anIter.data(), myEntityTypeGrp ); - myEntityTypeGrp->insert( aBtn, anIter.key() ); + QRadioButton* aBtn = new QRadioButton(anIter.data(), myEntityTypeGrp); + myEntityTypeGrp->insert(aBtn, anIter.key()); } - myTableGrp = new QGroupBox( 1, Qt::Horizontal, tr( "FILTER" ), aMainGrp ); - QFrame* aTableFrame = new QFrame( myTableGrp ); - - // create table - mySwitchTableGrp = new QGroupBox( 1, Qt::Horizontal, aTableFrame ); - mySwitchTableGrp->setFrameStyle( QFrame::NoFrame ); - mySwitchTableGrp->setInsideMargin( 0 ); - - myTables[ aType ] = createTable( mySwitchTableGrp, aType ); - - // create buttons - myAddBtn = new QPushButton( tr( "ADD" ), aTableFrame ); - myRemoveBtn = new QPushButton( tr( "REMOVE" ), aTableFrame ); - myClearBtn = new QPushButton( tr( "CLEAR" ), aTableFrame ); - myInsertBtn = new QPushButton( tr( "INSERT" ), aTableFrame ); - myCopyFromBtn = new QPushButton( tr( "COPY_FROM" ), aTableFrame ); - myAddToBtn = new QPushButton( tr( "ADD_TO" ), aTableFrame ); + myTableGrp = new QGroupBox(1, Qt::Horizontal, tr("FILTER"), aMainGrp ); + QFrame* aTableFrame = new QFrame(myTableGrp); - myAddBtn->setAutoDefault( false ); - myRemoveBtn->setAutoDefault( false ); - myClearBtn->setAutoDefault( false ); - myInsertBtn->setAutoDefault( false ); - myCopyFromBtn->setAutoDefault( false ); - myAddToBtn->setAutoDefault( false ); + // create table + mySwitchTableGrp = new QGroupBox(1, Qt::Horizontal, aTableFrame); + mySwitchTableGrp->setFrameStyle(QFrame::NoFrame); + mySwitchTableGrp->setInsideMargin(0); + + myTables[ aType ] = createTable(mySwitchTableGrp, aType); + + // create buttons + myAddBtn = new QPushButton(tr("ADD"), aTableFrame); + myRemoveBtn = new QPushButton(tr("REMOVE"), aTableFrame); + myClearBtn = new QPushButton(tr("CLEAR"), aTableFrame); + myInsertBtn = new QPushButton(tr("INSERT"), aTableFrame); + myCopyFromBtn = new QPushButton(tr("COPY_FROM"), aTableFrame); + myAddToBtn = new QPushButton(tr("ADD_TO"), aTableFrame); + + myAddBtn->setAutoDefault(false); + myRemoveBtn->setAutoDefault(false); + myClearBtn->setAutoDefault(false); + myInsertBtn->setAutoDefault(false); + myCopyFromBtn->setAutoDefault(false); + myAddToBtn->setAutoDefault(false); myCopyFromBtn->hide(); myAddToBtn->hide(); - - // layout widgets - QGridLayout* aLay = new QGridLayout( aTableFrame, 8, 2, 0, SPACING ); - aLay->addMultiCellWidget( mySwitchTableGrp, 0, 6, 0, 0 ); - aLay->addWidget( myAddBtn, 0, 1 ); - aLay->addWidget( myInsertBtn, 1, 1 ); - aLay->addWidget( myRemoveBtn, 2, 1 ); - aLay->addWidget( myClearBtn, 3, 1 ); - aLay->addWidget( myCopyFromBtn, 5, 1 ); - aLay->addWidget( myAddToBtn, 6, 1 ); - aLay->addMultiCellWidget( createAdditionalFrame( aTableFrame ), 7, 7, 0, 1 ); - - aLay->setColStretch( 0, 1 ); - aLay->setColStretch( 1, 0 ); - - QSpacerItem* aVSpacer = new QSpacerItem( 0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding ); - aLay->addItem( aVSpacer, 4, 1 ); - + // layout widgets + QGridLayout* aLay = new QGridLayout(aTableFrame, 8, 2, 0, SPACING); + + aLay->addMultiCellWidget(mySwitchTableGrp, 0, 6, 0, 0); + aLay->addWidget(myAddBtn, 0, 1); + aLay->addWidget(myInsertBtn, 1, 1); + aLay->addWidget(myRemoveBtn, 2, 1); + aLay->addWidget(myClearBtn, 3, 1); + aLay->addWidget(myCopyFromBtn, 5, 1); + aLay->addWidget(myAddToBtn, 6, 1); + aLay->addMultiCellWidget(createAdditionalFrame(aTableFrame), 7, 7, 0, 1 ); + + aLay->setColStretch(0, 1); + aLay->setColStretch(1, 0); + + QSpacerItem* aVSpacer = new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding); + aLay->addItem(aVSpacer, 4, 1); + // signals and slots - connect( myAddBtn, SIGNAL( clicked() ), this, SLOT( onAddBtn() ) ); - connect( myInsertBtn, SIGNAL( clicked() ), this, SLOT( onInsertBtn() ) ); - connect( myRemoveBtn, SIGNAL( clicked() ), this, SLOT( onRemoveBtn() ) ); - connect( myClearBtn, SIGNAL( clicked() ), this, SLOT( onClearBtn() ) ); - - connect( myCopyFromBtn, SIGNAL( clicked() ), this, SLOT( onCopyFromBtn() ) ); - connect( myAddToBtn, SIGNAL( clicked() ), this, SLOT( onAddToBtn() ) ); - - connect( myEntityTypeGrp, SIGNAL( clicked( int ) ), this, SLOT( onEntityType( int ) ) ); - + connect(myAddBtn, SIGNAL(clicked()), this, SLOT(onAddBtn())); + connect(myInsertBtn, SIGNAL(clicked()), this, SLOT(onInsertBtn())); + connect(myRemoveBtn, SIGNAL(clicked()), this, SLOT(onRemoveBtn())); + connect(myClearBtn, SIGNAL(clicked()), this, SLOT(onClearBtn())); + + connect(myCopyFromBtn, SIGNAL(clicked()), this, SLOT(onCopyFromBtn())); + connect(myAddToBtn, SIGNAL(clicked()), this, SLOT(onAddToBtn())); + + connect(myEntityTypeGrp, SIGNAL(clicked(int)), this, SLOT(onEntityType(int))); + myLibDlg = 0; } - + // Hide buttons of entity types if necessary const QMap& aSupportedTypes = getSupportedTypes(); QMap::const_iterator anIt; - for ( anIt = aSupportedTypes.begin(); anIt != aSupportedTypes.end(); ++anIt ) + for (anIt = aSupportedTypes.begin(); anIt != aSupportedTypes.end(); ++anIt) { - QButton* aBtn = myEntityTypeGrp->find( anIt.key() ); - theTypes.contains( anIt.key() ) ? aBtn->show() : aBtn->hide(); + QButton* aBtn = myEntityTypeGrp->find(anIt.key()); + theTypes.contains(anIt.key()) ? aBtn->show() : aBtn->hide(); } // select first button if there is no selected buttons or it is hidden QButton* aBtn = myEntityTypeGrp->selected(); - if ( aBtn == 0 || theTypes.find( myEntityTypeGrp->id( aBtn ) ) == theTypes.end() ) - myEntityTypeGrp->setButton( theTypes.first() ); + if ( aBtn == 0 || theTypes.find(myEntityTypeGrp->id(aBtn)) == theTypes.end()) + myEntityTypeGrp->setButton(theTypes.first()); - if ( theTypes.count() == 1 ) + if (theTypes.count() == 1) myEntityTypeGrp->hide(); else myEntityTypeGrp->show(); myTableGrp->updateGeometry(); - int aType = myEntityTypeGrp->id( myEntityTypeGrp->selected() ); - onEntityType( aType ); + int aType = myEntityTypeGrp->id(myEntityTypeGrp->selected()); + onEntityType(aType); } //======================================================================= // name : SMESHGUI_FilterTable::GetTableGrp // Purpose : Get group box containing table. May be used for adding new widgets in it -////======================================================================= -QWidget* SMESHGUI_FilterTable::createAdditionalFrame( QWidget* theParent ) +//======================================================================= +QWidget* SMESHGUI_FilterTable::createAdditionalFrame (QWidget* theParent) { - QFrame* aFrame = new QFrame( theParent ); - - QFrame* aLine1 = new QFrame( aFrame ); - QFrame* aLine2 = new QFrame( aFrame ); - aLine1->setFrameStyle( QFrame::HLine | QFrame::Sunken ); - aLine2->setFrameStyle( QFrame::HLine | QFrame::Sunken ); - aLine1->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed) ); - aLine2->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed) ); - - QLabel* aLabel = new QLabel( tr( "ADDITIONAL_PARAMETERS" ), aFrame ); + QFrame* aFrame = new QFrame(theParent); - myWgStack = new QWidgetStack( aFrame ); + QFrame* aLine1 = new QFrame(aFrame); + QFrame* aLine2 = new QFrame(aFrame); + aLine1->setFrameStyle(QFrame::HLine | QFrame::Sunken); + aLine2->setFrameStyle(QFrame::HLine | QFrame::Sunken); + aLine1->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); + aLine2->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); - QGridLayout* aLay = new QGridLayout( aFrame, 2, 3, 0, SPACING ); - aLay->addWidget( aLine1, 0, 0 ); - aLay->addWidget( aLabel, 0, 1 ); - aLay->addWidget( aLine2, 0, 2 ); - aLay->addMultiCellWidget( myWgStack, 1, 1, 0, 2 ); + QLabel* aLabel = new QLabel(tr("ADDITIONAL_PARAMETERS"), aFrame); + + myWgStack = new QWidgetStack(aFrame); + + QGridLayout* aLay = new QGridLayout(aFrame, 2, 3, 0, SPACING); + aLay->addWidget(aLine1, 0, 0); + aLay->addWidget(aLabel, 0, 1); + aLay->addWidget(aLine2, 0, 2); + aLay->addMultiCellWidget(myWgStack, 1, 1, 0, 2); return aFrame; } @@ -600,7 +609,7 @@ QWidget* SMESHGUI_FilterTable::createAdditionalFrame( QWidget* theParent ) //======================================================================= // name : SMESHGUI_FilterTable::GetTableGrp // Purpose : Get group box containing table. May be used for adding new widgets in it -////======================================================================= +//======================================================================= QGroupBox* SMESHGUI_FilterTable::GetTableGrp() { return myTableGrp; @@ -609,28 +618,28 @@ QGroupBox* SMESHGUI_FilterTable::GetTableGrp() //======================================================================= // name : SMESHGUI_FilterTable::onEntityType // Purpose : SLOT. Called when entity type changed. -// Display corresponding table +// Display corresponding table //======================================================================= -void SMESHGUI_FilterTable::onEntityType( int theType ) +void SMESHGUI_FilterTable::onEntityType (int theType) { - if ( myEntityType == theType ) + if (myEntityType == theType) return; myIsValid = true; emit NeedValidation(); - if ( !myIsValid ) + if (!myIsValid) { - myEntityTypeGrp->setButton( myEntityType ); + myEntityTypeGrp->setButton(myEntityType); return; } myEntityType = theType; - - if ( !myTables.contains( theType ) ) - myTables[ theType ] = createTable( mySwitchTableGrp, theType ); - + + if (!myTables.contains(theType)) + myTables[ theType ] = createTable(mySwitchTableGrp, theType); + TableMap::iterator anIter; - for ( anIter = myTables.begin(); anIter != myTables.end(); ++anIter ) + for (anIter = myTables.begin(); anIter != myTables.end(); ++anIter) myEntityType == anIter.key() ? anIter.data()->show() : anIter.data()->hide(); updateBtnState(); @@ -638,7 +647,7 @@ void SMESHGUI_FilterTable::onEntityType( int theType ) myTables[ myEntityType ]->updateGeometry(); adjustSize(); - emit EntityTypeChanged( theType ); + emit EntityTypeChanged(theType); } @@ -646,56 +655,51 @@ void SMESHGUI_FilterTable::onEntityType( int theType ) // name : SMESHGUI_FilterTable::IsValid // Purpose : Verify validity of entered data //======================================================================= -bool SMESHGUI_FilterTable::IsValid( const bool theMess, const int theEntityType ) const +bool SMESHGUI_FilterTable::IsValid (const bool theMess, const int theEntityType) const { int aType = theEntityType == -1 ? GetType() : theEntityType; Table* aTable = myTables[ aType ]; - for ( int i = 0, n = aTable->numRows(); i < n; i++ ) + for (int i = 0, n = aTable->numRows(); i < n; i++) { - int aCriterion = GetCriterionType( i, aType ); + int aCriterion = GetCriterionType(i, aType); - if ( aCriterion == FT_RangeOfIds || + if (aCriterion == FT_RangeOfIds || aCriterion == FT_BelongToGeom || aCriterion == FT_BelongToPlane || aCriterion == FT_BelongToCylinder || - aCriterion == FT_LyingOnGeom) - { - if ( aTable->text( i, 2 ).isEmpty() ) - { - if ( theMess ) - QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), - tr( "SMESH_INSUFFICIENT_DATA" ), tr( "ERROR" ), QMessageBox::Ok ); + aCriterion == FT_LyingOnGeom) { + if (aTable->text(i, 2).isEmpty()) { + if (theMess) + QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"), + tr("ERROR"), QMessageBox::Ok); return false; } - } - else - { + } else { bool aRes = false; - aTable->blockSignals( true ); - double aThreshold = ( int )aTable->text( i, 2 ).toDouble( &aRes ); - aTable->blockSignals( false ); + aTable->blockSignals(true); + double aThreshold = (int)aTable->text(i, 2).toDouble(&aRes); + aTable->blockSignals(false); - if ( !aRes && aTable->IsEditable( i, 2 ) ) - { - if ( theMess ) - QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), - tr( "SMESH_INSUFFICIENT_DATA" ), tr( "ERROR" ), QMessageBox::Ok ); + if (!aRes && aTable->IsEditable(i, 2)) { + if (theMess) + QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"), + tr("ERROR"), QMessageBox::Ok); return false; } - else if ( aType == SMESH::EDGE && - GetCriterionType( i, aType ) == SMESH::FT_MultiConnection && - aThreshold == 1 ) + else if (aType == SMESH::EDGE && + GetCriterionType(i, aType) == SMESH::FT_MultiConnection && + aThreshold == 1) { - if ( theMess ) - QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), - tr( "SMESH_INSUFFICIENT_DATA" ), tr( "MULTIEDGES_ERROR" ), QMessageBox::Ok ); + if (theMess) + QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"), + tr("MULTIEDGES_ERROR"), QMessageBox::Ok); return false; } } - QTableItem* anItem = aTable->item( i, 0 ); - if ( myAddWidgets.contains( anItem ) && !myAddWidgets[ anItem ]->IsValid() ) + QTableItem* anItem = aTable->item(i, 0); + if (myAddWidgets.contains(anItem) && !myAddWidgets[ anItem ]->IsValid()) return false; } @@ -706,7 +710,7 @@ bool SMESHGUI_FilterTable::IsValid( const bool theMess, const int theEntityType // name : SMESHGUI_FilterTable::SetValidity // Purpose : Set validity of the table //======================================================================= -void SMESHGUI_FilterTable::SetValidity( const bool isValid ) +void SMESHGUI_FilterTable::SetValidity (const bool isValid) { myIsValid = isValid; } @@ -724,10 +728,10 @@ int SMESHGUI_FilterTable::GetType() const // name : SMESHGUI_FilterTable::SetType // Purpose : Set current entity type //======================================================================= -void SMESHGUI_FilterTable::SetType( const int type ) +void SMESHGUI_FilterTable::SetType (const int type) { - myEntityTypeGrp->setButton( type ); - onEntityType( type ); + myEntityTypeGrp->setButton(type); + onEntityType(type); } //======================================================================= @@ -736,18 +740,18 @@ void SMESHGUI_FilterTable::SetType( const int type ) //======================================================================= void SMESHGUI_FilterTable::RestorePreviousEntityType() { - SetType( myEntityType ); + SetType(myEntityType); } //======================================================================= // name : SMESHGUI_FilterTable::GetCriterionType -// Purpose : Get type of criterion from specified row ( corresponding enums in h-file ) +// Purpose : Get type of criterion from specified row (corresponding enums in h-file) //======================================================================= -int SMESHGUI_FilterTable::GetCriterionType( const int theRow, const int theType ) const +int SMESHGUI_FilterTable::GetCriterionType (const int theRow, const int theType) const { int aType = theType == -1 ? GetType() : theType; Table* aTable = myTables[ aType ]; - ComboItem* anItem = (ComboItem*)aTable->item( theRow, 0 ); + ComboItem* anItem = (ComboItem*)aTable->item(theRow, 0); return anItem != 0 ? anItem->GetValue() : FT_Undefined; } @@ -755,90 +759,90 @@ int SMESHGUI_FilterTable::GetCriterionType( const int theRow, const int theType // name : SMESHGUI_FilterTable::GetCriterion // Purpose : Get parameters of criterion from specified row //======================================================================= -void SMESHGUI_FilterTable::GetCriterion( const int theRow, +void SMESHGUI_FilterTable::GetCriterion (const int theRow, SMESH::Filter::Criterion& theCriterion, - const int theEntityType ) const + const int theEntityType) const { int aType = theEntityType == -1 ? GetType() : theEntityType; Table* aTable = myTables[ aType ]; - - theCriterion.Type = ( (ComboItem*)aTable->item( theRow, 0 ) )->GetValue(); - theCriterion.UnaryOp = ( (QCheckTableItem*)aTable->item( theRow, 3 ) )->isChecked() ? FT_LogicalNOT : FT_Undefined; + + theCriterion.Type = ((ComboItem*)aTable->item(theRow, 0))->GetValue(); + theCriterion.UnaryOp = ((QCheckTableItem*)aTable->item(theRow, 3))->isChecked() ? FT_LogicalNOT : FT_Undefined; theCriterion.BinaryOp = theRow != aTable->numRows() - 1 ? - ( (ComboItem*)aTable->item( theRow, 4 ) )->GetValue() : FT_Undefined; + ((ComboItem*)aTable->item(theRow, 4))->GetValue() : FT_Undefined; theCriterion.TypeOfElement = (ElementType)aType; - int aCriterionType = GetCriterionType( theRow, aType ); + int aCriterionType = GetCriterionType(theRow, aType); - if ( aCriterionType != FT_RangeOfIds && + if (aCriterionType != FT_RangeOfIds && aCriterionType != FT_BelongToGeom && aCriterionType != FT_BelongToPlane && aCriterionType != FT_BelongToCylinder && aCriterionType != FT_LyingOnGeom) { - theCriterion.Compare = ( (ComboItem*)aTable->item( theRow, 1 ) )->GetValue(); - theCriterion.Threshold = aTable->item( theRow, 2 )->text().toDouble(); + theCriterion.Compare = ((ComboItem*)aTable->item(theRow, 1))->GetValue(); + theCriterion.Threshold = aTable->item(theRow, 2)->text().toDouble(); } else - theCriterion.ThresholdStr = aTable->text( theRow, 2 ).latin1(); + theCriterion.ThresholdStr = aTable->text(theRow, 2).latin1(); - QTableItem* anItem = aTable->item( theRow, 0 ); - if ( myAddWidgets.contains( anItem ) ) - theCriterion.Tolerance = myAddWidgets[ anItem ]->GetDouble( AdditionalWidget::Tolerance ); + QTableItem* anItem = aTable->item(theRow, 0); + if (myAddWidgets.contains(anItem)) + theCriterion.Tolerance = myAddWidgets[ anItem ]->GetDouble(AdditionalWidget::Tolerance); } //======================================================================= // name : SMESHGUI_FilterTable::SetCriterion // Purpose : Set parameters of criterion of specified row //======================================================================= -void SMESHGUI_FilterTable::SetCriterion( const int theRow, +void SMESHGUI_FilterTable::SetCriterion (const int theRow, const SMESH::Filter::Criterion& theCriterion, - const int theEntityType ) + const int theEntityType) { int aType = theEntityType == -1 ? GetType() : theEntityType; Table* aTable = myTables[ aType ]; - if ( theRow > aTable->numRows() - 1 ) + if (theRow > aTable->numRows() - 1) return; - ( (ComboItem*)aTable->item( theRow, 0 ) )->SetValue( theCriterion.Type ); - onCriterionChanged( theRow, 0, aType ); - ( (ComboItem*)aTable->item( theRow, 1 ) )->SetValue( theCriterion.Compare ); - ( (QCheckTableItem*)aTable->item( theRow, 3 ) )->setChecked( theCriterion.UnaryOp == FT_LogicalNOT ); + ((ComboItem*)aTable->item(theRow, 0))->SetValue(theCriterion.Type); + onCriterionChanged(theRow, 0, aType); + ((ComboItem*)aTable->item(theRow, 1))->SetValue(theCriterion.Compare); + ((QCheckTableItem*)aTable->item(theRow, 3))->setChecked(theCriterion.UnaryOp == FT_LogicalNOT); - if ( theCriterion.BinaryOp != FT_Undefined ) + if (theCriterion.BinaryOp != FT_Undefined) { - if ( !aTable->IsEditable( theRow, 4 ) ) - aTable->setItem( theRow, 4, getBinaryItem( aTable ) ); - ( (ComboItem*)aTable->item( theRow, 4 ) )->SetValue( theCriterion.BinaryOp ); + if (!aTable->IsEditable(theRow, 4)) + aTable->setItem(theRow, 4, getBinaryItem(aTable)); + ((ComboItem*)aTable->item(theRow, 4))->SetValue(theCriterion.BinaryOp); } else - aTable->SetEditable( false, theRow, 4 ); + aTable->SetEditable(false, theRow, 4); - if ( theCriterion.Type != FT_RangeOfIds && + if (theCriterion.Type != FT_RangeOfIds && theCriterion.Type != FT_BelongToGeom && theCriterion.Type != FT_BelongToPlane && theCriterion.Type != FT_BelongToCylinder && theCriterion.Type != FT_LyingOnGeom) - aTable->setText( theRow, 2, QString( "%1" ).arg( theCriterion.Threshold, 0, 'g', 15 ) ); + aTable->setText(theRow, 2, QString("%1").arg(theCriterion.Threshold, 0, 'g', 15)); else - aTable->setText( theRow, 2, QString( theCriterion.ThresholdStr ) ); + aTable->setText(theRow, 2, QString(theCriterion.ThresholdStr)); - if ( theCriterion.Compare == FT_EqualTo || + if (theCriterion.Compare == FT_EqualTo || theCriterion.Type == FT_BelongToPlane || - theCriterion.Type == FT_BelongToCylinder ) + theCriterion.Type == FT_BelongToCylinder) { - QTableItem* anItem = aTable->item( theRow, 0 ); - if ( !myAddWidgets.contains( anItem ) ) + QTableItem* anItem = aTable->item(theRow, 0); + if (!myAddWidgets.contains(anItem)) { - myAddWidgets[ anItem ] = new AdditionalWidget( myWgStack ); - myWgStack->addWidget( myAddWidgets[ anItem ] ); + myAddWidgets[ anItem ] = new AdditionalWidget(myWgStack); + myWgStack->addWidget(myAddWidgets[ anItem ]); } - myAddWidgets[ anItem ]->SetDouble( AdditionalWidget::Tolerance, theCriterion.Tolerance ); + myAddWidgets[ anItem ]->SetDouble(AdditionalWidget::Tolerance, theCriterion.Tolerance); } - emit CretarionChanged( theRow, aType ); + emit CretarionChanged(theRow, aType); } @@ -851,8 +855,8 @@ void SMESHGUI_FilterTable::Update() Table* aTable = myTables[ GetType() ]; int aCurrRow = aTable->currentRow(); int numRows = aTable->numRows(); - if ( ( aCurrRow < 0 || aCurrRow >= numRows ) && numRows > 0 ) - aTable->setCurrentCell( 0, 0 ); + if ((aCurrRow < 0 || aCurrRow >= numRows) && numRows > 0) + aTable->setCurrentCell(0, 0); updateAdditionalWidget(); } @@ -860,20 +864,20 @@ void SMESHGUI_FilterTable::Update() // name : SMESHGUI_FilterTable::AddCriterion // Purpose : Add criterion with parameters //======================================================================= -void SMESHGUI_FilterTable::AddCriterion( const SMESH::Filter::Criterion& theCriterion, - const int theEntityType ) +void SMESHGUI_FilterTable::AddCriterion (const SMESH::Filter::Criterion& theCriterion, + const int theEntityType) { int aType = theEntityType == -1 ? GetType() : theEntityType; Table* aTable = myTables[ aType ]; - addRow( aTable, aType ); - SetCriterion( aTable->numRows() - 1, theCriterion ); + addRow(aTable, aType); + SetCriterion(aTable->numRows() - 1, theCriterion); } //======================================================================= // name : SMESHGUI_FilterTable::NumRows // Purpose : Get number of criterions of current type //======================================================================= -int SMESHGUI_FilterTable::NumRows( const int theEntityType ) const +int SMESHGUI_FilterTable::NumRows (const int theEntityType) const { return myTables[ theEntityType == -1 ? GetType() : theEntityType ]->numRows(); } @@ -882,18 +886,18 @@ int SMESHGUI_FilterTable::NumRows( const int theEntityType ) const // name : SMESHGUI_FilterTable::Clear // Purpose : Clear current table //======================================================================= -void SMESHGUI_FilterTable::Clear( const int theType ) +void SMESHGUI_FilterTable::Clear (const int theType) { int aType = theType == -1 ? GetType() : theType; QTable* aTable = myTables[ aType ]; - if ( aTable->numRows() == 0 ) + if (aTable->numRows() == 0) return; - while ( aTable->numRows() > 0 ) + while (aTable->numRows() > 0) { - removeAdditionalWidget( aTable, 0 ); - aTable->removeRow( 0 ); + removeAdditionalWidget(aTable, 0); + aTable->removeRow(0); } updateBtnState(); @@ -907,7 +911,7 @@ void SMESHGUI_FilterTable::Clear( const int theType ) void SMESHGUI_FilterTable::onAddBtn() { int aType = GetType(); - addRow( myTables[ aType ], aType ); + addRow(myTables[ aType ], aType); Update(); } @@ -919,7 +923,7 @@ void SMESHGUI_FilterTable::onAddBtn() //======================================================================= void SMESHGUI_FilterTable::onInsertBtn() { - addRow( myTables[ GetType() ], GetType(), false ); + addRow(myTables[ GetType() ], GetType(), false); } //======================================================================= @@ -931,25 +935,25 @@ void SMESHGUI_FilterTable::onRemoveBtn() { Table* aTable = myTables[ GetType() ]; - if ( aTable->numRows() == 0 ) + if (aTable->numRows() == 0) return; QMemArray aRows; - for ( int i = 0, n = aTable->numRows(); i < n; i++ ) + for (int i = 0, n = aTable->numRows(); i < n; i++) { - if ( aTable->isRowSelected( i ) ) + if (aTable->isRowSelected(i)) { - aRows.resize( aRows.size() + 1 ); + aRows.resize(aRows.size() + 1); aRows[ aRows.size() - 1 ] = i; - removeAdditionalWidget( aTable, i ); + removeAdditionalWidget(aTable, i); } } - aTable->removeRows( aRows ); + aTable->removeRows(aRows); // remove control of binary logical operation from last row - if ( aTable->numRows() > 0 ) - aTable->SetEditable( false, aTable->numRows() - 1, 4 ); + if (aTable->numRows() > 0) + aTable->SetEditable(false, aTable->numRows() - 1, 4); updateBtnState(); } @@ -962,27 +966,27 @@ void SMESHGUI_FilterTable::updateAdditionalWidget() { Table* aTable = myTables[ GetType() ]; int aRow = aTable->currentRow(); - if ( aRow < 0 || aRow >= aTable->numRows() ) + if (aRow < 0 || aRow >= aTable->numRows()) { - myWgStack->setEnabled( false ); + myWgStack->setEnabled(false); return; } - ComboItem* anItem = ( (ComboItem*)aTable->item( aRow, 0 ) ); - bool toEnable = ( (ComboItem*)aTable->item( aRow, 1 ) )->GetValue() == FT_EqualTo && - GetCriterionType( aRow ) != FT_BelongToGeom && - GetCriterionType( aRow ) != FT_LyingOnGeom && - GetCriterionType( aRow ) != FT_RangeOfIds && - GetCriterionType( aRow ) != FT_FreeEdges && - GetCriterionType( aRow ) != FT_BadOrientedVolume; - if ( !myAddWidgets.contains( anItem ) ) + ComboItem* anItem = ((ComboItem*)aTable->item(aRow, 0)); + bool toEnable = ((ComboItem*)aTable->item(aRow, 1))->GetValue() == FT_EqualTo && + GetCriterionType(aRow) != FT_BelongToGeom && + GetCriterionType(aRow) != FT_LyingOnGeom && + GetCriterionType(aRow) != FT_RangeOfIds && + GetCriterionType(aRow) != FT_FreeEdges && + GetCriterionType(aRow) != FT_BadOrientedVolume; + if (!myAddWidgets.contains(anItem)) { - myAddWidgets[ anItem ] = new AdditionalWidget( myWgStack ); - myWgStack->addWidget( myAddWidgets[ anItem ] ); + myAddWidgets[ anItem ] = new AdditionalWidget(myWgStack); + myWgStack->addWidget(myAddWidgets[ anItem ]); } - myWgStack->raiseWidget( myWgStack->id( myAddWidgets[ anItem ] ) ); - myWgStack->setEnabled( toEnable ); + myWgStack->raiseWidget(myWgStack->id(myAddWidgets[ anItem ])); + myWgStack->setEnabled(toEnable); } //======================================================================= @@ -990,15 +994,15 @@ void SMESHGUI_FilterTable::updateAdditionalWidget() // Purpose : Remove widgets containing additional parameters from widget // stack and internal map //======================================================================= -void SMESHGUI_FilterTable::removeAdditionalWidget( QTable* theTable, const int theRow ) +void SMESHGUI_FilterTable::removeAdditionalWidget (QTable* theTable, const int theRow) { - QTableItem* anItem = theTable->item( theRow, 0 ); - if ( myAddWidgets.contains( anItem ) ) + QTableItem* anItem = theTable->item(theRow, 0); + if (myAddWidgets.contains(anItem)) { - myWgStack->removeWidget( myAddWidgets[ anItem ] ); - myAddWidgets[ anItem ]->reparent( 0, QPoint() ); + myWgStack->removeWidget(myAddWidgets[ anItem ]); + myAddWidgets[ anItem ]->reparent(0, QPoint()); delete myAddWidgets[ anItem ]; - myAddWidgets.remove( anItem ); + myAddWidgets.remove(anItem); } } @@ -1011,13 +1015,13 @@ void SMESHGUI_FilterTable::onClearBtn() { QTable* aTable = myTables[ GetType() ]; - if ( aTable->numRows() == 0 ) + if (aTable->numRows() == 0) return; - while ( aTable->numRows() > 0 ) + while (aTable->numRows() > 0) { - removeAdditionalWidget( aTable, 0 ); - aTable->removeRow( 0 ); + removeAdditionalWidget(aTable, 0); + aTable->removeRow(0); } updateBtnState(); @@ -1027,63 +1031,63 @@ void SMESHGUI_FilterTable::onClearBtn() // name : SMESHGUI_FilterTable::onCurrentChanged() // Purpose : SLOT. Called when current cell changed //======================================================================= -void SMESHGUI_FilterTable::onCurrentChanged( int theRow, int theCol ) +void SMESHGUI_FilterTable::onCurrentChanged (int theRow, int theCol) { updateAdditionalWidget(); - emit CurrentChanged( theRow, theCol ); + emit CurrentChanged(theRow, theCol); } //======================================================================= // name : SMESHGUI_FilterTable::onCriterionChanged() // Purpose : Provides reaction on change of criterion //======================================================================= -void SMESHGUI_FilterTable::onCriterionChanged( const int row, const int col, const int entityType ) +void SMESHGUI_FilterTable::onCriterionChanged (const int row, const int col, const int entityType) { int aType = entityType == -1 ? GetType() : entityType; Table* aTable = myTables[ aType ]; - ComboItem* aCompareItem = (ComboItem*)aTable->item( row, 1 ); + ComboItem* aCompareItem = (ComboItem*)aTable->item(row, 1); - int aCriterionType = GetCriterionType( row ); + int aCriterionType = GetCriterionType(row); - if ( aType == SMESH::EDGE && aCriterionType == SMESH::FT_FreeBorders || - aType == SMESH::FACE && aCriterionType == SMESH::FT_FreeEdges || - aType == SMESH::VOLUME && aCriterionType == SMESH::FT_BadOrientedVolume ) + if (aType == SMESH::EDGE && aCriterionType == SMESH::FT_FreeBorders || + aType == SMESH::FACE && aCriterionType == SMESH::FT_FreeEdges || + aType == SMESH::VOLUME && aCriterionType == SMESH::FT_BadOrientedVolume) { - if ( aCompareItem->count() > 0 ) - aCompareItem->setStringList( QStringList() ); - aTable->SetEditable( false, row, 2 ); + if (aCompareItem->count() > 0) + aCompareItem->setStringList(QStringList()); + aTable->SetEditable(false, row, 2); } - else if ( aCriterionType == SMESH::FT_RangeOfIds || + else if (aCriterionType == SMESH::FT_RangeOfIds || aCriterionType == SMESH::FT_BelongToGeom || aCriterionType == SMESH::FT_BelongToPlane || aCriterionType == SMESH::FT_BelongToCylinder || aCriterionType == SMESH::FT_LyingOnGeom) { QMap aMap; - aMap[ FT_EqualTo ] = tr( "EQUAL_TO" ); - aCompareItem->setStringList( aMap ); - if ( !aTable->IsEditable( row, 2 ) ) - aTable->SetEditable( true, row, 2 ); + aMap[ FT_EqualTo ] = tr("EQUAL_TO"); + aCompareItem->setStringList(aMap); + if (!aTable->IsEditable(row, 2)) + aTable->SetEditable(true, row, 2); } else { - if ( aCompareItem->count() != 3 ) + if (aCompareItem->count() != 3) { - aCompareItem->setStringList( QStringList() ); - aCompareItem->setStringList( getCompare() ); + aCompareItem->setStringList(QStringList()); + aCompareItem->setStringList(getCompare()); } - QString aText = aTable->text( row, 2 ); + QString aText = aTable->text(row, 2); bool isOk = false; - aText.toDouble( &isOk ); - aTable->setText( row, 2, isOk ? aText : QString("") ); - if ( !aTable->IsEditable( row, 2 ) ) - aTable->SetEditable( true, row, 2 ); + aText.toDouble(&isOk); + aTable->setText(row, 2, isOk ? aText : QString("")); + if (!aTable->IsEditable(row, 2)) + aTable->SetEditable(true, row, 2); } updateAdditionalWidget(); - - emit CretarionChanged( row, entityType ); + + emit CretarionChanged(row, entityType); } //======================================================================= @@ -1091,9 +1095,9 @@ void SMESHGUI_FilterTable::onCriterionChanged( const int row, const int col, con // Purpose : SLOT. Called then contents of table changed // Provides reaction on change of criterion //======================================================================= -void SMESHGUI_FilterTable::onCriterionChanged( int row, int col ) +void SMESHGUI_FilterTable::onCriterionChanged (int row, int col) { - onCriterionChanged( row, col, -1 ); + onCriterionChanged(row, col, -1); } //======================================================================= @@ -1103,8 +1107,8 @@ void SMESHGUI_FilterTable::onCriterionChanged( int row, int col ) int SMESHGUI_FilterTable::getFirstSelectedRow() const { QTable* aTable = myTables[ GetType() ]; - for ( int i = 0, n = aTable->numRows(); i < n; i++ ) - if ( aTable->isRowSelected( i ) ) + for (int i = 0, n = aTable->numRows(); i < n; i++) + if (aTable->isRowSelected(i)) return i; int aRow = aTable->currentRow(); @@ -1115,60 +1119,60 @@ int SMESHGUI_FilterTable::getFirstSelectedRow() const // name : SMESHGUI_FilterTable::addRow // Purpose : Add row at the end of table //======================================================================= -void SMESHGUI_FilterTable::addRow( Table* theTable, const int theType, const bool toTheEnd ) +void SMESHGUI_FilterTable::addRow (Table* theTable, const int theType, const bool toTheEnd) { int aCurrRow = 0; int aSelectedRow = getFirstSelectedRow(); int aCurrCol = theTable->currentColumn(); - if ( toTheEnd || aSelectedRow == -1 ) + if (toTheEnd || aSelectedRow == -1) { - theTable->insertRows( theTable->numRows() ); + theTable->insertRows(theTable->numRows()); aCurrRow = theTable->numRows() - 1; } else { - theTable->insertRows( aSelectedRow ); + theTable->insertRows(aSelectedRow); aCurrRow = aSelectedRow; } // Criteria - theTable->setItem( aCurrRow, 0, getCriterionItem( theTable, theType ) ); + theTable->setItem(aCurrRow, 0, getCriterionItem(theTable, theType)); // Compare - theTable->setItem( aCurrRow, 1, getCompareItem( theTable ) ); + theTable->setItem(aCurrRow, 1, getCompareItem(theTable)); // Threshold - //theTable->setItem( aCurrRow, 2, new QTableItem( theTable ) ); + //theTable->setItem(aCurrRow, 2, new QTableItem(theTable)); //Logical operation NOT - theTable->setItem( aCurrRow, 3, getUnaryItem( theTable ) ); - + theTable->setItem(aCurrRow, 3, getUnaryItem(theTable)); + // Logical binary operation for previous value int anAddBinOpStr = -1; - if ( aCurrRow == theTable->numRows() - 1 ) + if (aCurrRow == theTable->numRows() - 1) anAddBinOpStr = aCurrRow - 1; - else if ( aCurrRow >= 0 ) + else if (aCurrRow >= 0 ) anAddBinOpStr = aCurrRow; - - if ( theTable->item( aCurrRow, 4 ) == 0 || - theTable->item( aCurrRow, 4 )->rtti() != 1 ) + + if (theTable->item(aCurrRow, 4) == 0 || + theTable->item(aCurrRow, 4)->rtti() != 1) { - - if ( anAddBinOpStr >= 0 && - ( theTable->item( anAddBinOpStr, 4 ) == 0 || - theTable->item( anAddBinOpStr, 4 )->rtti() != 1 ) ) - theTable->setItem( anAddBinOpStr, 4, getBinaryItem( theTable ) ); + + if (anAddBinOpStr >= 0 && + (theTable->item(anAddBinOpStr, 4) == 0 || + theTable->item(anAddBinOpStr, 4)->rtti() != 1)) + theTable->setItem(anAddBinOpStr, 4, getBinaryItem(theTable)); } - - theTable->SetEditable( false, theTable->numRows() - 1, 4 ); - if ( aCurrRow >=0 && aCurrRow < theTable->numRows() && - aCurrCol >=0 && aCurrCol < theTable->numRows() ) - theTable->setCurrentCell( aCurrRow, aCurrCol ); + theTable->SetEditable(false, theTable->numRows() - 1, 4); - onCriterionChanged( aCurrRow, 0 ); + if (aCurrRow >=0 && aCurrRow < theTable->numRows() && + aCurrCol >=0 && aCurrCol < theTable->numRows()) + theTable->setCurrentCell(aCurrRow, aCurrCol); + + onCriterionChanged(aCurrRow, 0); updateBtnState(); } @@ -1177,43 +1181,43 @@ void SMESHGUI_FilterTable::addRow( Table* theTable, const int theType, const boo // name : SMESHGUI_FilterTable::getCriterionItem // Purpose : Get combo table item for criteria of specified type //======================================================================= -QTableItem* SMESHGUI_FilterTable::getCriterionItem( QTable* theParent , const int theType ) +QTableItem* SMESHGUI_FilterTable::getCriterionItem (QTable* theParent , const int theType) { - return new ComboItem( theParent, getCriteria( theType ) ); + return new ComboItem(theParent, getCriteria(theType)); } //======================================================================= // name : SMESHGUI_FilterTable::getCompareItem // Purpose : Get combo table item for operation of comparision //======================================================================= -QTableItem* SMESHGUI_FilterTable::getCompareItem( QTable* theParent ) +QTableItem* SMESHGUI_FilterTable::getCompareItem (QTable* theParent) { - return new ComboItem( theParent, getCompare() ); + return new ComboItem(theParent, getCompare()); } //======================================================================= // name : SMESHGUI_FilterTable::getBinaryItem // Purpose : //======================================================================= -QTableItem* SMESHGUI_FilterTable::getBinaryItem( QTable* theParent ) +QTableItem* SMESHGUI_FilterTable::getBinaryItem (QTable* theParent) { static QMap aMap; - if ( aMap.isEmpty() ) + if (aMap.isEmpty()) { - aMap[ SMESH::FT_LogicalAND ] = tr( "AND" ); - aMap[ SMESH::FT_LogicalOR ] = tr( "OR" ); + aMap[ SMESH::FT_LogicalAND ] = tr("AND"); + aMap[ SMESH::FT_LogicalOR ] = tr("OR"); } - return new ComboItem( theParent, aMap ); + return new ComboItem(theParent, aMap); } //======================================================================= // name : SMESHGUI_FilterTable::getUnaryItem // Purpose : Get check table item //======================================================================= -QTableItem* SMESHGUI_FilterTable::getUnaryItem( QTable* theParent ) +QTableItem* SMESHGUI_FilterTable::getUnaryItem (QTable* theParent) { - return new QCheckTableItem( theParent, tr( "NOT" ) ); + return new QCheckTableItem(theParent, tr("NOT")); } //======================================================================= @@ -1223,12 +1227,12 @@ QTableItem* SMESHGUI_FilterTable::getUnaryItem( QTable* theParent ) const QMap& SMESHGUI_FilterTable::getSupportedTypes() const { static QMap aTypes; - if ( aTypes.isEmpty() ) + if (aTypes.isEmpty()) { - aTypes[ SMESH::NODE ] = tr( "NODES" ); - aTypes[ SMESH::EDGE ] = tr( "EDGES" ); - aTypes[ SMESH::FACE ] = tr( "FACES" ); - aTypes[ SMESH::VOLUME ] = tr( "VOLUMES" ); + aTypes[ SMESH::NODE ] = tr("NODES"); + aTypes[ SMESH::EDGE ] = tr("EDGES"); + aTypes[ SMESH::FACE ] = tr("FACES"); + aTypes[ SMESH::VOLUME ] = tr("VOLUMES"); } return aTypes; @@ -1238,69 +1242,69 @@ const QMap& SMESHGUI_FilterTable::getSupportedTypes() const // name : SMESHGUI_FilterTable::getCriteria // Purpose : Get criteria for specified type //======================================================================= -const QMap& SMESHGUI_FilterTable::getCriteria( const int theType ) const +const QMap& SMESHGUI_FilterTable::getCriteria (const int theType) const { - if ( theType == SMESH::NODE ) + if (theType == SMESH::NODE) { static QMap aCriteria; - if ( aCriteria.isEmpty() ) + if (aCriteria.isEmpty()) { - aCriteria[ SMESH::FT_RangeOfIds ] = tr( "RANGE_OF_IDS" ); - aCriteria[ SMESH::FT_BelongToGeom ] = tr( "BELONG_TO_GEOM" ); - aCriteria[ SMESH::FT_BelongToPlane ] = tr( "BELONG_TO_PLANE" ); - aCriteria[ SMESH::FT_BelongToCylinder ] = tr( "BELONG_TO_CYLINDER" ); - aCriteria[ SMESH::FT_LyingOnGeom ] = tr( "LYING_ON_GEOM" ); + aCriteria[ SMESH::FT_RangeOfIds ] = tr("RANGE_OF_IDS"); + aCriteria[ SMESH::FT_BelongToGeom ] = tr("BELONG_TO_GEOM"); + aCriteria[ SMESH::FT_BelongToPlane ] = tr("BELONG_TO_PLANE"); + aCriteria[ SMESH::FT_BelongToCylinder ] = tr("BELONG_TO_CYLINDER"); + aCriteria[ SMESH::FT_LyingOnGeom ] = tr("LYING_ON_GEOM"); } return aCriteria; } - else if ( theType == SMESH::EDGE ) + else if (theType == SMESH::EDGE) { static QMap aCriteria; - if ( aCriteria.isEmpty() ) + if (aCriteria.isEmpty()) { - aCriteria[ SMESH::FT_FreeBorders ] = tr( "FREE_BORDERS" ); - aCriteria[ SMESH::FT_MultiConnection ] = tr( "MULTI_BORDERS" ); - aCriteria[ SMESH::FT_Length ] = tr( "LENGTH" ); - aCriteria[ SMESH::FT_RangeOfIds ] = tr( "RANGE_OF_IDS" ); - aCriteria[ SMESH::FT_BelongToGeom ] = tr( "BELONG_TO_GEOM" ); - aCriteria[ SMESH::FT_BelongToPlane ] = tr( "BELONG_TO_PLANE" ); - aCriteria[ SMESH::FT_BelongToCylinder ] = tr( "BELONG_TO_CYLINDER" ); - aCriteria[ SMESH::FT_LyingOnGeom ] = tr( "LYING_ON_GEOM" ); + aCriteria[ SMESH::FT_FreeBorders ] = tr("FREE_BORDERS"); + aCriteria[ SMESH::FT_MultiConnection ] = tr("MULTI_BORDERS"); + aCriteria[ SMESH::FT_Length ] = tr("LENGTH"); + aCriteria[ SMESH::FT_RangeOfIds ] = tr("RANGE_OF_IDS"); + aCriteria[ SMESH::FT_BelongToGeom ] = tr("BELONG_TO_GEOM"); + aCriteria[ SMESH::FT_BelongToPlane ] = tr("BELONG_TO_PLANE"); + aCriteria[ SMESH::FT_BelongToCylinder ] = tr("BELONG_TO_CYLINDER"); + aCriteria[ SMESH::FT_LyingOnGeom ] = tr("LYING_ON_GEOM"); } return aCriteria; } - else if ( theType == SMESH::FACE ) + else if (theType == SMESH::FACE) { static QMap aCriteria; - if ( aCriteria.isEmpty() ) + if (aCriteria.isEmpty()) { - aCriteria[ SMESH::FT_AspectRatio ] = tr( "ASPECT_RATIO" ); - aCriteria[ SMESH::FT_Warping ] = tr( "WARPING" ); - aCriteria[ SMESH::FT_MinimumAngle ] = tr( "MINIMUM_ANGLE" ); - aCriteria[ SMESH::FT_Taper ] = tr( "TAPER" ); - aCriteria[ SMESH::FT_Skew ] = tr( "SKEW" ); - aCriteria[ SMESH::FT_Area ] = tr( "AREA" ); - aCriteria[ SMESH::FT_FreeEdges ] = tr( "FREE_EDGES" ); - aCriteria[ SMESH::FT_RangeOfIds ] = tr( "RANGE_OF_IDS" ); - aCriteria[ SMESH::FT_BelongToGeom ] = tr( "BELONG_TO_GEOM" ); - aCriteria[ SMESH::FT_BelongToPlane ] = tr( "BELONG_TO_PLANE" ); - aCriteria[ SMESH::FT_BelongToCylinder ] = tr( "BELONG_TO_CYLINDER" ); - aCriteria[ SMESH::FT_LyingOnGeom ] = tr( "LYING_ON_GEOM" ); - aCriteria[ SMESH::FT_Length2D ] = tr( "LENGTH2D" ); - aCriteria[ SMESH::FT_MultiConnection2D] = tr( "MULTI2D_BORDERS" ); + aCriteria[ SMESH::FT_AspectRatio ] = tr("ASPECT_RATIO"); + aCriteria[ SMESH::FT_Warping ] = tr("WARPING"); + aCriteria[ SMESH::FT_MinimumAngle ] = tr("MINIMUM_ANGLE"); + aCriteria[ SMESH::FT_Taper ] = tr("TAPER"); + aCriteria[ SMESH::FT_Skew ] = tr("SKEW"); + aCriteria[ SMESH::FT_Area ] = tr("AREA"); + aCriteria[ SMESH::FT_FreeEdges ] = tr("FREE_EDGES"); + aCriteria[ SMESH::FT_RangeOfIds ] = tr("RANGE_OF_IDS"); + aCriteria[ SMESH::FT_BelongToGeom ] = tr("BELONG_TO_GEOM"); + aCriteria[ SMESH::FT_BelongToPlane ] = tr("BELONG_TO_PLANE"); + aCriteria[ SMESH::FT_BelongToCylinder ] = tr("BELONG_TO_CYLINDER"); + aCriteria[ SMESH::FT_LyingOnGeom ] = tr("LYING_ON_GEOM"); + aCriteria[ SMESH::FT_Length2D ] = tr("LENGTH2D"); + aCriteria[ SMESH::FT_MultiConnection2D] = tr("MULTI2D_BORDERS"); } return aCriteria; } - else if ( theType == SMESH::VOLUME ) + else if (theType == SMESH::VOLUME) { static QMap aCriteria; - if ( aCriteria.isEmpty() ) + if (aCriteria.isEmpty()) { - aCriteria[ SMESH::FT_AspectRatio3D] = tr( "ASPECT_RATIO_3D" ); - 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_BadOrientedVolume ] = tr( "BAD_ORIENTED_VOLUME" ); + aCriteria[ SMESH::FT_AspectRatio3D] = tr("ASPECT_RATIO_3D"); + 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_BadOrientedVolume ] = tr("BAD_ORIENTED_VOLUME"); } return aCriteria; } @@ -1320,11 +1324,11 @@ const QMap& SMESHGUI_FilterTable::getCompare() const { static QMap aMap; - if ( aMap.isEmpty() ) + if (aMap.isEmpty()) { - aMap[ SMESH::FT_LessThan ] = tr( "LESS_THAN" ); - aMap[ SMESH::FT_MoreThan ] = tr( "MORE_THAN" ); - aMap[ SMESH::FT_EqualTo ] = tr( "EQUAL_TO" ); + aMap[ SMESH::FT_LessThan ] = tr("LESS_THAN"); + aMap[ SMESH::FT_MoreThan ] = tr("MORE_THAN"); + aMap[ SMESH::FT_EqualTo ] = tr("EQUAL_TO" ); } return aMap; @@ -1334,57 +1338,57 @@ const QMap& SMESHGUI_FilterTable::getCompare() const // name : SMESHGUI_FilterTable::createTable // Purpose : Create table //======================================================================= -SMESHGUI_FilterTable::Table* SMESHGUI_FilterTable::createTable( QWidget* theParent, - const int theType ) +SMESHGUI_FilterTable::Table* SMESHGUI_FilterTable::createTable (QWidget* theParent, + const int theType) { // create table - Table* aTable= new Table( 0, 5, theParent ); + Table* aTable= new Table(0, 5, theParent); QHeader* aHeaders = aTable->horizontalHeader(); - QFontMetrics aMetrics( aHeaders->font() ); + QFontMetrics aMetrics(aHeaders->font()); // append spaces to the header of criteria in order to // provide visibility of criterion inside comboboxes static int aMaxLenCr = 0; - if ( aMaxLenCr == 0 ) + if (aMaxLenCr == 0) { const QMap& aSupportedTypes = getSupportedTypes(); QMap::const_iterator anIter; - for ( anIter = aSupportedTypes.begin(); anIter != aSupportedTypes.end(); ++anIter ) - aMaxLenCr = Max( maxLength( getCriteria( anIter.key() ), aMetrics ), aMaxLenCr ); + for (anIter = aSupportedTypes.begin(); anIter != aSupportedTypes.end(); ++anIter) + aMaxLenCr = Max(maxLength(getCriteria(anIter.key()), aMetrics), aMaxLenCr); } - static int aLenCr = abs( aMaxLenCr - - aMetrics.width( tr( "CRITERION" ) ) ) / aMetrics.width( ' ' ) + 5; + static int aLenCr = abs( aMaxLenCr - + aMetrics.width(tr("CRITERION"))) / aMetrics.width(' ') + 5; QString aCrStr; - aCrStr.fill( ' ', aLenCr ); + aCrStr.fill(' ', aLenCr); QString aCoStr; - aCoStr.fill( ' ', 10 ); + aCoStr.fill(' ', 10); - aHeaders->setLabel( 0, tr( "CRITERION" ) + aCrStr ); - aHeaders->setLabel( 1, tr( "COMPARE" ) + aCoStr ); - aHeaders->setLabel( 2, tr( "THRESHOLD_VALUE" ) ); - aHeaders->setLabel( 3, tr( "UNARY" ) ); - aHeaders->setLabel( 4, tr( "BINARY" ) + " " ); + aHeaders->setLabel(0, tr("CRITERION") + aCrStr); + aHeaders->setLabel(1, tr("COMPARE") + aCoStr); + aHeaders->setLabel(2, tr("THRESHOLD_VALUE")); + aHeaders->setLabel(3, tr("UNARY")); + aHeaders->setLabel(4, tr("BINARY") + " "); // set geometry of the table - for ( int i = 0; i <= 4; i++ ) - aTable->adjustColumn( i ); + for (int i = 0; i <= 4; i++) + aTable->adjustColumn(i); aTable->updateGeometry(); QSize aSize = aTable->sizeHint(); int aWidth = aSize.width(); - aTable->setMinimumSize( QSize( aWidth, aWidth / 2 ) ); - aTable->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding) ); + aTable->setMinimumSize(QSize(aWidth, aWidth / 2)); + aTable->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); - connect( aTable, SIGNAL( valueChanged( int, int ) ), - this, SLOT( onCriterionChanged( int, int ) ) ); + connect(aTable, SIGNAL(valueChanged(int, int)), + this, SLOT(onCriterionChanged(int, int))); - connect( aTable, SIGNAL( currentChanged( int, int ) ), - this, SLOT( onCurrentChanged( int, int ) ) ); + connect(aTable, SIGNAL(currentChanged(int, int)), + this, SLOT(onCurrentChanged(int, int))); return aTable; } @@ -1395,22 +1399,22 @@ SMESHGUI_FilterTable::Table* SMESHGUI_FilterTable::createTable( QWidget* thePar //======================================================================= void SMESHGUI_FilterTable::updateBtnState() { - myRemoveBtn->setEnabled( myTables[ GetType() ]->numRows() > 0 ); - myClearBtn->setEnabled( myTables[ GetType() ]->numRows() > 0 ); + myRemoveBtn->setEnabled(myTables[ GetType() ]->numRows() > 0); + myClearBtn->setEnabled(myTables[ GetType() ]->numRows() > 0); } //======================================================================= // name : SMESHGUI_FilterTable::SetEditable // Purpose : Set read only flag for tables. Show/hide buttons for work with rows //======================================================================= -void SMESHGUI_FilterTable::SetEditable( const bool isEditable ) +void SMESHGUI_FilterTable::SetEditable (const bool isEditable) { TableMap::iterator anIter; - for ( anIter = myTables.begin(); anIter != myTables.end(); ++anIter ) + for (anIter = myTables.begin(); anIter != myTables.end(); ++anIter) { - anIter.data()->setReadOnly( !isEditable ); + anIter.data()->setReadOnly(!isEditable); - if ( isEditable ) + if (isEditable) { myAddBtn->show(); myInsertBtn->show(); @@ -1427,27 +1431,27 @@ void SMESHGUI_FilterTable::SetEditable( const bool isEditable ) } QMap::iterator anIter2; - for ( anIter2 = myAddWidgets.begin(); anIter2 != myAddWidgets.end(); ++anIter2 ) - anIter2.data()->SetEditable( isEditable ); + for (anIter2 = myAddWidgets.begin(); anIter2 != myAddWidgets.end(); ++anIter2) + anIter2.data()->SetEditable(isEditable); } //======================================================================= // name : SMESHGUI_FilterTable::SetEnabled // Purpose : Enable/Disable table. Switching type of elements already enabled //======================================================================= -void SMESHGUI_FilterTable::SetEnabled( const bool isEnabled ) +void SMESHGUI_FilterTable::SetEnabled (const bool isEnabled) { - myAddBtn->setEnabled( isEnabled ); - myInsertBtn->setEnabled( isEnabled ); - myRemoveBtn->setEnabled( isEnabled ); - myClearBtn->setEnabled( isEnabled ); + myAddBtn->setEnabled(isEnabled); + myInsertBtn->setEnabled(isEnabled); + myRemoveBtn->setEnabled(isEnabled); + myClearBtn->setEnabled(isEnabled); - if ( isEnabled ) + if (isEnabled) updateBtnState(); - + QMap::iterator anIter2; - for ( anIter2 = myAddWidgets.begin(); anIter2 != myAddWidgets.end(); ++anIter2 ) - anIter2.data()->setEnabled( isEnabled ); + for (anIter2 = myAddWidgets.begin(); anIter2 != myAddWidgets.end(); ++anIter2) + anIter2.data()->setEnabled(isEnabled); } //======================================================================= @@ -1463,9 +1467,9 @@ bool SMESHGUI_FilterTable::IsEditable() const // name : SMESHGUI_FilterTable::SetLibsEnabled // Purpose : Show/hide buttons for work with libraries //======================================================================= -void SMESHGUI_FilterTable::SetLibsEnabled( const bool isEnabled ) +void SMESHGUI_FilterTable::SetLibsEnabled (const bool isEnabled) { - if ( isEnabled ) + if (isEnabled) { myCopyFromBtn->show(); myAddToBtn->show(); @@ -1484,15 +1488,15 @@ void SMESHGUI_FilterTable::SetLibsEnabled( const bool isEnabled ) //======================================================================= void SMESHGUI_FilterTable::onCopyFromBtn() { - if ( myLibDlg == 0 ) + if (myLibDlg == 0) myLibDlg = new SMESHGUI_FilterLibraryDlg( - this, GetType(), SMESHGUI_FilterLibraryDlg::COPY_FROM ); + this, GetType(), SMESHGUI_FilterLibraryDlg::COPY_FROM); else - myLibDlg->Init( GetType(), SMESHGUI_FilterLibraryDlg::COPY_FROM ); + myLibDlg->Init(GetType(), SMESHGUI_FilterLibraryDlg::COPY_FROM); - if ( myLibDlg->exec() == QDialog::Accepted ) + if (myLibDlg->exec() == QDialog::Accepted) { - Copy( myLibDlg->GetTable() ); + Copy(myLibDlg->GetTable()); Update(); } } @@ -1504,32 +1508,32 @@ void SMESHGUI_FilterTable::onCopyFromBtn() //======================================================================= void SMESHGUI_FilterTable::onAddToBtn() { - if ( !IsValid( true ) ) + if (!IsValid(true)) return; - if ( myLibDlg == 0 ) + if (myLibDlg == 0) myLibDlg = new SMESHGUI_FilterLibraryDlg( - this, GetType(), SMESHGUI_FilterLibraryDlg::ADD_TO ); + this, GetType(), SMESHGUI_FilterLibraryDlg::ADD_TO); else - myLibDlg->Init( GetType(), SMESHGUI_FilterLibraryDlg::ADD_TO ); + myLibDlg->Init(GetType(), SMESHGUI_FilterLibraryDlg::ADD_TO); + + myLibDlg->SetTable(this); - myLibDlg->SetTable( this ); - myLibDlg->exec(); -} +} //======================================================================= // name : SMESHGUI_FilterTable::Copy // Purpose : Initialise table with values of other table //======================================================================= -void SMESHGUI_FilterTable::Copy( const SMESHGUI_FilterTable* theTable ) +void SMESHGUI_FilterTable::Copy (const SMESHGUI_FilterTable* theTable) { Clear(); - for ( int i = 0, n = theTable->NumRows(); i < n; i++ ) + for (int i = 0, n = theTable->NumRows(); i < n; i++) { SMESH::Filter::Criterion aCriterion = SMESHGUI_FilterDlg::createCriterion(); - theTable->GetCriterion( i, aCriterion ); - AddCriterion( aCriterion ); + theTable->GetCriterion(i, aCriterion); + AddCriterion(aCriterion); } } @@ -1537,7 +1541,7 @@ void SMESHGUI_FilterTable::Copy( const SMESHGUI_FilterTable* theTable ) // name : SMESHGUI_FilterTable::CurrentCell // Purpose : Returns current cell //======================================================================= -bool SMESHGUI_FilterTable::CurrentCell( int& theRow, int& theCol ) const +bool SMESHGUI_FilterTable::CurrentCell (int& theRow, int& theCol) const { theRow = myTables[ GetType() ]->currentRow(); theCol = myTables[ GetType() ]->currentColumn(); @@ -1546,36 +1550,36 @@ bool SMESHGUI_FilterTable::CurrentCell( int& theRow, int& theCol ) const //======================================================================= // name : SMESHGUI_FilterTable::SetText -// Purpose : Set text and internal value in cell of threshold value +// Purpose : Set text and internal value in cell of threshold value //======================================================================= -void SMESHGUI_FilterTable::SetThreshold( const int theRow, +void SMESHGUI_FilterTable::SetThreshold (const int theRow, const QString& theText, - const int theEntityType ) + const int theEntityType) { Table* aTable = myTables[ theEntityType == -1 ? GetType() : theEntityType ]; - aTable->setText( theRow, 2, theText ); + aTable->setText(theRow, 2, theText); } //======================================================================= // name : SMESHGUI_FilterTable::SetText // Purpose : Get text and internal value from cell of threshold value //======================================================================= -bool SMESHGUI_FilterTable::GetThreshold( const int theRow, +bool SMESHGUI_FilterTable::GetThreshold (const int theRow, QString& theText, - const int theEntityType ) + const int theEntityType) { Table* aTable = myTables[ theEntityType == -1 ? GetType() : theEntityType ]; - QTableItem* anItem = aTable->item( theRow, 2 ); - if ( anItem != 0 ) + QTableItem* anItem = aTable->item(theRow, 2); + if (anItem != 0) { theText = anItem->text(); - return true; + return true; } else return false; } -/* +/* Class : SMESHGUI_FilterDlg Description : Dialog to specify filters for VTK viewer */ @@ -1585,82 +1589,90 @@ bool SMESHGUI_FilterTable::GetThreshold( const int theRow, // name : SMESHGUI_FilterDlg::SMESHGUI_FilterDlg // Purpose : Constructor //======================================================================= -SMESHGUI_FilterDlg::SMESHGUI_FilterDlg( QWidget* theParent, +SMESHGUI_FilterDlg::SMESHGUI_FilterDlg( SMESHGUI* theModule, const QValueList& theTypes, - const char* theName ) -: QDialog( theParent, theName, false, - WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) + const char* theName) +: QDialog( SMESH::GetDesktop( theModule ), theName, false, + WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu), + mySMESHGUI( theModule ), + mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ), + myViewWindow( SMESH::GetViewWindow( theModule ) ), + mySelector( myViewWindow->GetSelector() ) { - construct( theTypes ); + construct(theTypes); } //======================================================================= // name : SMESHGUI_FilterDlg::SMESHGUI_FilterDlg // Purpose : Constructor //======================================================================= -SMESHGUI_FilterDlg::SMESHGUI_FilterDlg( QWidget* theParent, +SMESHGUI_FilterDlg::SMESHGUI_FilterDlg( SMESHGUI* theModule, const int theType, - const char* theName ) -: QDialog( theParent, theName, false, - WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) + const char* theName) +: QDialog( SMESH::GetDesktop( theModule ), theName, false, + WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu), + mySMESHGUI( theModule ), + mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ), + myViewWindow( SMESH::GetViewWindow( theModule ) ), + mySelector( myViewWindow->GetSelector() ) { QValueList aTypes; - aTypes.append( theType ); - construct( aTypes ); + aTypes.append(theType); + construct(aTypes); } //======================================================================= // name : SMESHGUI_FilterDlg::construct -// Purpose : Construct dialog ( called by constructor ) +// Purpose : Construct dialog (called by constructor) //======================================================================= -void SMESHGUI_FilterDlg::construct( const QValueList& theTypes ) +void SMESHGUI_FilterDlg::construct (const QValueList& theTypes) { myTypes = theTypes; - setCaption( tr( "CAPTION" ) ); + setCaption(tr("CAPTION")); - QVBoxLayout* aDlgLay = new QVBoxLayout( this, MARGIN, SPACING ); + QVBoxLayout* aDlgLay = new QVBoxLayout (this, MARGIN, SPACING); - myMainFrame = createMainFrame ( this ); - QFrame* aBtnFrame = createButtonFrame( this ); + myMainFrame = createMainFrame (this); + QFrame* aBtnFrame = createButtonFrame(this); - aDlgLay->addWidget( myMainFrame ); - aDlgLay->addWidget( aBtnFrame ); + aDlgLay->addWidget(myMainFrame); + aDlgLay->addWidget(aBtnFrame); - aDlgLay->setStretchFactor( myMainFrame, 1 ); + aDlgLay->setStretchFactor(myMainFrame, 1); - Init( myTypes ); + Init(myTypes); } //======================================================================= // name : SMESHGUI_FilterDlg::createMainFrame // Purpose : Create frame containing dialog's input fields //======================================================================= -QFrame* SMESHGUI_FilterDlg::createMainFrame( QWidget* theParent ) +QFrame* SMESHGUI_FilterDlg::createMainFrame (QWidget* theParent) { - QGroupBox* aMainFrame = new QGroupBox( 1, Qt::Horizontal, theParent ); - aMainFrame->setFrameStyle( QFrame::NoFrame ); - aMainFrame->setInsideMargin( 0 ); + QGroupBox* aMainFrame = new QGroupBox(1, Qt::Horizontal, theParent); + aMainFrame->setFrameStyle(QFrame::NoFrame); + aMainFrame->setInsideMargin(0); // filter frame - myTable = new SMESHGUI_FilterTable( aMainFrame, myTypes ); - myTable->SetLibsEnabled( true ); + myTable = new SMESHGUI_FilterTable(aMainFrame, myTypes); + myTable->SetLibsEnabled(true); - QFrame* aLine = new QFrame( myTable->GetTableGrp() ); - aLine->setFrameStyle( QFrame::HLine | QFrame::Sunken ); + QFrame* aLine = new QFrame(myTable->GetTableGrp()); + aLine->setFrameStyle(QFrame::HLine | QFrame::Sunken); - mySetInViewer = new QCheckBox( tr( "SET_IN_VIEWER" ), myTable->GetTableGrp() ); - mySetInViewer->setChecked( true ); + mySetInViewer = new QCheckBox(tr("SET_IN_VIEWER"), myTable->GetTableGrp()); + mySetInViewer->setChecked(true); // other controls - mySourceGrp = createSourceGroup( aMainFrame ); + mySourceGrp = createSourceGroup(aMainFrame); - connect( myTable, SIGNAL( CretarionChanged( const int, const int ) ), - SLOT( onCriterionChanged( const int, const int ) ) ); + connect(myTable, SIGNAL(CretarionChanged(const int, const int)), + SLOT(onCriterionChanged(const int, const int))); - connect( myTable, SIGNAL( CurrentChanged( int, int ) ), - SLOT( onCurrentChanged( int, int ) ) ); + connect(myTable, SIGNAL(CurrentChanged(int, int)), + SLOT(onCurrentChanged(int, int))); return aMainFrame; } @@ -1669,30 +1681,30 @@ QFrame* SMESHGUI_FilterDlg::createMainFrame( QWidget* theParent ) // name : SMESHGUI_FilterDlg::createSourceFrame // Purpose : Create frame containing source radio button //======================================================================= -QButtonGroup* SMESHGUI_FilterDlg::createSourceGroup( QWidget* theParent ) +QButtonGroup* SMESHGUI_FilterDlg::createSourceGroup (QWidget* theParent) { - QButtonGroup* aGrp = new QButtonGroup( 1, Qt::Vertical, tr( "SOURCE" ), theParent ); + QButtonGroup* aGrp = new QButtonGroup(1, Qt::Vertical, tr("SOURCE"), theParent); - QRadioButton* aMeshBtn = new QRadioButton( tr( "MESH" ), aGrp ); - QRadioButton* aSelBtn = new QRadioButton( tr( "SELECTION" ), aGrp ); - QRadioButton* aGrpBtn = new QRadioButton( tr( "CURRENT_GROUP" ), aGrp ); + QRadioButton* aMeshBtn = new QRadioButton(tr("MESH"), aGrp); + QRadioButton* aSelBtn = new QRadioButton(tr("SELECTION"), aGrp); + QRadioButton* aGrpBtn = new QRadioButton(tr("CURRENT_GROUP"), aGrp); - aGrp->insert( aMeshBtn, Mesh ); - aGrp->insert( aSelBtn, Selection ); - aGrp->insert( aGrpBtn, Dialog ); + aGrp->insert(aMeshBtn, Mesh); + aGrp->insert(aSelBtn, Selection); + aGrp->insert(aGrpBtn, Dialog); - aGrp->setButton( Selection ); + aGrp->setButton(Selection); return aGrp; } //======================================================================= // name : SMESHGUI_FilterDlg::updateMainButtons -// Purpose : Update visibility of main buttons ( OK, Cancel, Close ... ) +// Purpose : Update visibility of main buttons (OK, Cancel, Close ...) //======================================================================= void SMESHGUI_FilterDlg::updateMainButtons() { - if ( myTypes.count() == 1 ) + if (myTypes.count() == 1) { myButtons[ BTN_Cancel ]->show(); myButtons[ BTN_Apply ]->hide(); @@ -1712,23 +1724,23 @@ void SMESHGUI_FilterDlg::updateMainButtons() // name : SMESHGUI_FilterDlg::createButtonFrame // Purpose : Create frame containing buttons //======================================================================= -QFrame* SMESHGUI_FilterDlg::createButtonFrame( QWidget* theParent ) +QFrame* SMESHGUI_FilterDlg::createButtonFrame (QWidget* theParent) { - QGroupBox* aGrp = new QGroupBox( 1, Qt::Vertical, theParent ); + QGroupBox* aGrp = new QGroupBox(1, Qt::Vertical, theParent); - myButtons[ BTN_OK ] = new QPushButton( tr( "SMESH_BUT_OK" ), aGrp ); - myButtons[ BTN_Apply ] = new QPushButton( tr( "SMESH_BUT_APPLY" ), aGrp ); + myButtons[ BTN_OK ] = new QPushButton(tr("SMESH_BUT_OK" ), aGrp); + myButtons[ BTN_Apply ] = new QPushButton(tr("SMESH_BUT_APPLY"), aGrp); - QLabel* aLbl = new QLabel( aGrp ); - aLbl->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + QLabel* aLbl = new QLabel(aGrp); + aLbl->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); - myButtons[ BTN_Cancel ] = new QPushButton( tr( "SMESH_BUT_CANCEL" ), aGrp ); - myButtons[ BTN_Close ] = new QPushButton( tr( "SMESH_BUT_CLOSE" ), aGrp ); + myButtons[ BTN_Cancel ] = new QPushButton(tr("SMESH_BUT_CANCEL"), aGrp); + myButtons[ BTN_Close ] = new QPushButton(tr("SMESH_BUT_CLOSE"), aGrp); - connect( myButtons[ BTN_OK ], SIGNAL( clicked() ), SLOT( onOk() ) ); - connect( myButtons[ BTN_Cancel ], SIGNAL( clicked() ), SLOT( onClose() ) ) ; - connect( myButtons[ BTN_Close ], SIGNAL( clicked() ), SLOT( onClose() ) ) ; - connect( myButtons[ BTN_Apply ], SIGNAL( clicked() ), SLOT( onApply() ) ); + connect(myButtons[ BTN_OK ], SIGNAL(clicked()), SLOT(onOk())); + connect(myButtons[ BTN_Cancel ], SIGNAL(clicked()), SLOT(onClose())); + connect(myButtons[ BTN_Close ], SIGNAL(clicked()), SLOT(onClose())); + connect(myButtons[ BTN_Apply ], SIGNAL(clicked()), SLOT(onApply())); updateMainButtons(); @@ -1747,82 +1759,80 @@ SMESHGUI_FilterDlg::~SMESHGUI_FilterDlg() // name : SMESHGUI_FilterDlg::Init // Purpose : Init dialog fields, connect signals and slots, show dialog //======================================================================= -void SMESHGUI_FilterDlg::Init( const int type ) +void SMESHGUI_FilterDlg::Init (const int type) { QValueList aTypes; - aTypes.append( type ); - Init( aTypes ); + aTypes.append(type); + Init(aTypes); } //======================================================================= // name : SMESHGUI_FilterDlg::Init // Purpose : Init dialog fields, connect signals and slots, show dialog //======================================================================= -void SMESHGUI_FilterDlg::Init( const QValueList& theTypes ) +void SMESHGUI_FilterDlg::Init (const QValueList& theTypes) { mySourceWg = 0; - mySelection = 0; myTypes = theTypes; myMesh = SMESH::SMESH_Mesh::_nil(); myIObjects.Clear(); myIsSelectionChanged = false; - myTable->Init( theTypes ); + myTable->Init(theTypes); // set caption - if ( theTypes.count() == 1 ) + if (theTypes.count() == 1) { int aType = theTypes.first(); - if ( aType == SMESH::NODE ) setCaption( tr( "NODES_TLT" ) ); - else if ( aType == SMESH::EDGE ) setCaption( tr( "EDGES_TLT" ) ); - else if ( aType == SMESH::FACE ) setCaption( tr( "FACES_TLT" ) ); - else if ( aType == SMESH::VOLUME ) setCaption( tr( "VOLUMES_TLT" ) ); + if (aType == SMESH::NODE ) setCaption(tr("NODES_TLT")); + else if (aType == SMESH::EDGE ) setCaption(tr("EDGES_TLT")); + else if (aType == SMESH::FACE ) setCaption(tr("FACES_TLT")); + else if (aType == SMESH::VOLUME) setCaption(tr("VOLUMES_TLT")); } else - setCaption( tr( "TLT" ) ); + setCaption(tr("TLT")); qApp->processEvents(); updateGeometry(); adjustSize(); - setEnabled( true ); + setEnabled(true); - mySMESHGUI = SMESHGUI::GetSMESHGUI() ; - mySMESHGUI->SetActiveDialogBox( ( QDialog* )this ) ; + mySMESHGUI->SetActiveDialogBox((QDialog*)this); - connect( mySMESHGUI, SIGNAL( SignalDeactivateActiveDialog() ), SLOT( onDeactivate() ) ); - connect( mySMESHGUI, SIGNAL( SignalCloseAllDialogs() ), SLOT( onClose() ) ); + connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), SLOT(onDeactivate())); + connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), SLOT(onClose())); - int x, y ; - mySMESHGUI->DefineDlgPosition( this, x, y ); - this->move( x, y ); + int x, y; + mySMESHGUI->DefineDlgPosition(this, x, y); + this->move(x, y); updateMainButtons(); updateSelection(); // Initialise filter table with values of previous filter QValueList::const_iterator anIter; - for ( anIter = theTypes.begin(); anIter != theTypes.end(); ++anIter ) + for (anIter = theTypes.begin(); anIter != theTypes.end(); ++anIter) { - myTable->Clear( *anIter ); - if ( !myFilter[ *anIter ]->_is_nil() ) + myTable->Clear(*anIter); + if (!myFilter[ *anIter ]->_is_nil()) { SMESH::Filter::Criteria_var aCriteria = new SMESH::Filter::Criteria; - if ( myFilter[ *anIter ]->GetCriteria( aCriteria ) ) + if (myFilter[ *anIter ]->GetCriteria(aCriteria)) { - for ( int i = 0, n = aCriteria->length(); i < n; i++ ) - myTable->AddCriterion( aCriteria[ i ], *anIter ); + for (int i = 0, n = aCriteria->length(); i < n; i++) + myTable->AddCriterion(aCriteria[ i ], *anIter); } } } - if ( myInsertState.contains( theTypes.first() ) ) - mySetInViewer->setChecked( myInsertState[ theTypes.first() ] ); + if (myInsertState.contains(theTypes.first())) + mySetInViewer->setChecked(myInsertState[ theTypes.first() ]); else - mySetInViewer->setChecked( true ); - if ( myApplyToState.contains( theTypes.first() ) ) - mySourceGrp->setButton( myApplyToState[ theTypes.first() ] ); + mySetInViewer->setChecked(true); + if (myApplyToState.contains(theTypes.first())) + mySourceGrp->setButton(myApplyToState[ theTypes.first() ]); else - mySourceGrp->setButton( Selection ); + mySourceGrp->setButton(Selection); } //======================================================================= @@ -1832,12 +1842,12 @@ void SMESHGUI_FilterDlg::Init( const QValueList& theTypes ) //======================================================================= void SMESHGUI_FilterDlg::onOk() { - if ( onApply() ) + if (onApply()) { - mySelection->ClearFilters(); - disconnect( mySMESHGUI, 0, this, 0 ); - disconnect( mySelection, 0, this, 0 ); - mySMESHGUI->ResetState() ; + mySelectionMgr->clearFilters(); + disconnect(mySMESHGUI, 0, this, 0); + disconnect(mySelectionMgr, 0, this, 0); + mySMESHGUI->ResetState(); accept(); emit Accepted(); } @@ -1850,29 +1860,32 @@ void SMESHGUI_FilterDlg::onOk() void SMESHGUI_FilterDlg::onClose() { // Restore previously selected object - if ( mySelection ) + if (mySelectionMgr) { - mySelection->ClearFilters(); - mySelection->Clear(); - SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger anIter( myIObjects ); - for ( ; anIter.More(); anIter.Next() ) + SALOME_ListIO aList; + mySelectionMgr->clearFilters(); + mySelectionMgr->clearSelected(); + SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger anIter (myIObjects); + for (; anIter.More(); anIter.Next()) { - mySelection->AddIObject( anIter.Key() ); + aList.Append(anIter.Key()); TColStd_MapOfInteger aResMap; const TColStd_IndexedMapOfInteger& anIndMap = anIter.Value(); - for ( int i = 1, n = anIndMap.Extent(); i <= n; i++ ) - aResMap.Add( anIndMap( i ) ); - - mySelection->AddOrRemoveIndex( anIter.Key(), aResMap, false ); + for (int i = 1, n = anIndMap.Extent(); i <= n; i++) + aResMap.Add(anIndMap(i)); + + mySelector->AddOrRemoveIndex( anIter.Key(), aResMap, false); + myViewWindow->highlight( anIter.Key(), true, true ); } + mySelectionMgr->setSelectedObjects(aList, false); } - disconnect( mySMESHGUI, 0, this, 0 ); - disconnect( mySelection, 0, this, 0 ); - mySMESHGUI->ResetState() ; - reject() ; - return ; + disconnect(mySMESHGUI, 0, this, 0); + disconnect(mySelectionMgr, 0, this, 0); + mySMESHGUI->ResetState(); + reject(); + return; } //======================================================================= @@ -1881,67 +1894,66 @@ void SMESHGUI_FilterDlg::onClose() //======================================================================= void SMESHGUI_FilterDlg::onDeactivate() { - setEnabled( false ); + setEnabled(false); } //======================================================================= // name : SMESHGUI_FilterDlg::enterEvent // Purpose : Event filter //======================================================================= -void SMESHGUI_FilterDlg::enterEvent( QEvent* ) +void SMESHGUI_FilterDlg::enterEvent (QEvent*) { // mySMESHGUI->EmitSignalDeactivateDialog(); - mySMESHGUI->SetActiveDialogBox( (QDialog*)this ); + mySMESHGUI->SetActiveDialogBox((QDialog*)this); mySMESHGUI->ResetState(); - setEnabled( true ); + setEnabled(true); } - -//================================================================================= -// function : closeEvent() -// purpose : -//================================================================================= -void SMESHGUI_FilterDlg::closeEvent( QCloseEvent* e ) +//======================================================================= +// name : closeEvent() +// Purpose : +//======================================================================= +void SMESHGUI_FilterDlg::closeEvent (QCloseEvent*) { - onClose() ; + onClose(); } //======================================================================= // name : SMESHGUI_FilterDlg::getIdsFromWg // Purpose : Retrieve list of ids from given widget //======================================================================= -void SMESHGUI_FilterDlg::getIdsFromWg( const QWidget* theWg, QValueList& theRes ) const +void SMESHGUI_FilterDlg::getIdsFromWg (const QWidget* theWg, QValueList& theRes) const { theRes.clear(); - if ( theWg == 0 ) + if (theWg == 0) return; - if ( theWg->inherits( "QListBox" ) ) + if (theWg->inherits("QListBox")) { - QListBox* aListBox = ( QListBox* )theWg; + QListBox* aListBox = (QListBox*)theWg; bool b; - for ( int i = 0, n = aListBox->count(); i < n; i++ ) + for (int i = 0, n = aListBox->count(); i < n; i++) { - int anId = aListBox->text( i ).toInt( &b ); - if ( b ) - theRes.append( anId ); + int anId = aListBox->text(i).toInt(&b); + if (b) + theRes.append(anId); } } - else if ( theWg->inherits( "QLineEdit" ) ) + else if (theWg->inherits("QLineEdit")) { - QLineEdit* aLineEdit = ( QLineEdit* )theWg; + QLineEdit* aLineEdit = (QLineEdit*)theWg; QString aStr = aLineEdit->text(); - QRegExp aRegExp( "(\\d+)" ); + QRegExp aRegExp("(\\d+)"); bool b; int aPos = 0; - while ( aPos >= 0 ) + while (aPos >= 0) { - aPos = aRegExp.search( aStr, aPos ); - if ( aPos > -1 ) + aPos = aRegExp.search(aStr, aPos); + if (aPos > -1) { - int anId = aRegExp.cap( 1 ).toInt( &b ); - if ( b ) - theRes.append( anId ); + int anId = aRegExp.cap(1).toInt(&b); + if (b) + theRes.append(anId); aPos += aRegExp.matchedLength(); } } @@ -1952,9 +1964,9 @@ void SMESHGUI_FilterDlg::getIdsFromWg( const QWidget* theWg, QValueList& th // name : SMESHGUI_FilterDlg::getSelMode // Purpose : Get selection mode of specified type //======================================================================= -Selection_Mode SMESHGUI_FilterDlg::getSelMode( const int theType ) const +Selection_Mode SMESHGUI_FilterDlg::getSelMode (const int theType) const { - switch ( theType ) + switch (theType) { case SMESH::NODE : return NodeSelection; case SMESH::EDGE : return EdgeSelection; @@ -1969,36 +1981,36 @@ Selection_Mode SMESHGUI_FilterDlg::getSelMode( const int theType ) const // name : SMESHGUI_FilterDlg::setIdsToWg // Purpose : Insert identifiers in specified widgets //======================================================================= -void SMESHGUI_FilterDlg::setIdsToWg( QWidget* theWg, const QValueList& theIds ) +void SMESHGUI_FilterDlg::setIdsToWg (QWidget* theWg, const QValueList& theIds) { - if ( theWg == 0 ) + if (theWg == 0) return; - if ( theWg->inherits( "QListBox" ) ) + if (theWg->inherits("QListBox")) { - QListBox* aListBox = ( QListBox* )theWg; + QListBox* aListBox = (QListBox*)theWg; aListBox->clear(); QStringList aStrList; QValueList::const_iterator anIter; - for ( anIter = theIds.begin(); anIter != theIds.end(); ++anIter ) - aStrList.append( QString( "%1" ).arg( *anIter ) ); + for (anIter = theIds.begin(); anIter != theIds.end(); ++anIter) + aStrList.append(QString("%1").arg(*anIter)); - aListBox->insertStringList( aStrList ); + aListBox->insertStringList(aStrList); } - else if ( theWg->inherits( "QLineEdit" ) ) + else if (theWg->inherits("QLineEdit")) { - QLineEdit* aLineEdit = ( QLineEdit* )theWg; + QLineEdit* aLineEdit = (QLineEdit*)theWg; QString aStr; QValueList::const_iterator anIter; - for ( anIter = theIds.begin(); anIter != theIds.end(); ++ anIter ) - aStr += QString( "%1 " ).arg( *anIter ); + for (anIter = theIds.begin(); anIter != theIds.end(); ++ anIter) + aStr += QString("%1 ").arg(*anIter); - if ( !aStr.isEmpty() ) - aStr.remove( aStr.length() - 1, 1 ); + if (!aStr.isEmpty()) + aStr.remove(aStr.length() - 1, 1); - aLineEdit->setText( aStr ); + aLineEdit->setText(aStr); } } @@ -2008,64 +2020,57 @@ void SMESHGUI_FilterDlg::setIdsToWg( QWidget* theWg, const QValueList& theI //======================================================================= bool SMESHGUI_FilterDlg::isValid() const { - if ( !myTable->IsValid() ) + if (!myTable->IsValid()) return false; - - for ( int i = 0, n = myTable->NumRows(); i < n; i++ ) + + for (int i = 0, n = myTable->NumRows(); i < n; i++) { - int aType = myTable->GetCriterionType( i ); - if ( aType == FT_BelongToGeom || + int aType = myTable->GetCriterionType(i); + if (aType == FT_BelongToGeom || aType == FT_BelongToPlane || aType == FT_BelongToCylinder || - aType == FT_LyingOnGeom) - { + aType == FT_LyingOnGeom) { QString aName; - myTable->GetThreshold( i, aName ); - - SALOMEDS::Study::ListOfSObject_var aList = SMESHGUI::GetSMESHGUI()->GetActiveStudy()-> - getStudyDocument()->FindObjectByName( aName.latin1(), "GEOM" ); - if ( aList->length() == 0 ) - { - QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), - tr( "SMESH_INSUFFICIENT_DATA" ), tr( "BAD_SHAPE_NAME" ).arg( aName ), QMessageBox::Ok ); + myTable->GetThreshold(i, aName); + + std::vector<_PTR(SObject)> aList = + SMESH::GetActiveStudyDocument()->FindObjectByName(aName.latin1(), "GEOM"); + if (aList.size() == 0) { + QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"), + tr("BAD_SHAPE_NAME").arg(aName), QMessageBox::Ok); return false; } - if ( aType == FT_BelongToCylinder || aType == FT_BelongToPlane ) - { - GEOM::GEOM_Object_var aGeomObj = - GEOM::GEOM_Object::_narrow( aList[ 0 ]->GetObject() ); - if ( !aGeomObj->_is_nil() ) - { + if (aType == FT_BelongToCylinder || aType == FT_BelongToPlane) { + CORBA::Object_var anObject = SMESH::SObjectToObject(aList[ 0 ]); + //GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow(aList[ 0 ]->GetObject()); + GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow(anObject); + if (!aGeomObj->_is_nil()) { TopoDS_Shape aFace; - if ( !GEOMBase::GetShape( aGeomObj, aFace ) || + if (!GEOMBase::GetShape(aGeomObj, aFace) || aFace.IsNull() || - aFace.ShapeType() != TopAbs_FACE ) - { - QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), - tr( "SMESH_INSUFFICIENT_DATA" ), tr( "SHAPE_IS_NOT_A_FACE" ).arg( aName ), QMessageBox::Ok ); + aFace.ShapeType() != TopAbs_FACE) { + QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"), + tr("SHAPE_IS_NOT_A_FACE").arg(aName), QMessageBox::Ok); return false; } - Handle(Geom_Surface) aSurf = BRep_Tool::Surface( TopoDS::Face( aFace ) ); - if ( aSurf.IsNull() ) - { - QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), - tr( "SMESH_INSUFFICIENT_DATA" ), tr( "SHAPE_IS_NOT_A_FACE" ).arg( aName ), QMessageBox::Ok ); + Handle(Geom_Surface) aSurf = BRep_Tool::Surface(TopoDS::Face(aFace)); + if (aSurf.IsNull()) { + QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"), + tr("SHAPE_IS_NOT_A_FACE").arg(aName), QMessageBox::Ok); return false; } - if ( aType == FT_BelongToPlane && !aSurf->IsKind( STANDARD_TYPE( Geom_Plane ) ) ) - { - QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), - tr( "SMESH_INSUFFICIENT_DATA" ), tr( "SHAPE_IS_NOT_A_PLANE" ).arg( aName ), QMessageBox::Ok ); + if (aType == FT_BelongToPlane && !aSurf->IsKind(STANDARD_TYPE(Geom_Plane))) { + QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"), + tr("SHAPE_IS_NOT_A_PLANE").arg(aName), QMessageBox::Ok); return false; } - if ( aType == FT_BelongToCylinder && !aSurf->IsKind( STANDARD_TYPE( Geom_CylindricalSurface ) ) ) - { - QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), - tr( "SMESH_INSUFFICIENT_DATA" ), tr( "SHAPE_IS_NOT_A_CYLINDER" ).arg( aName ), QMessageBox::Ok ); + if (aType == FT_BelongToCylinder && !aSurf->IsKind(STANDARD_TYPE(Geom_CylindricalSurface))) { + QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"), + tr("SHAPE_IS_NOT_A_CYLINDER").arg(aName), QMessageBox::Ok); return false; } } @@ -2081,7 +2086,7 @@ bool SMESHGUI_FilterDlg::isValid() const // Purpose : Set widget of parent dialog containing idsto be filtered if // user select corresponding source radio button //======================================================================= -void SMESHGUI_FilterDlg::SetSourceWg( QWidget* theWg ) +void SMESHGUI_FilterDlg::SetSourceWg (QWidget* theWg) { mySourceWg = theWg; } @@ -2090,7 +2095,7 @@ void SMESHGUI_FilterDlg::SetSourceWg( QWidget* theWg ) // name : SMESHGUI_FilterDlg::SetGroupIds // Purpose : Set mesh //======================================================================= -void SMESHGUI_FilterDlg::SetMesh( SMESH::SMESH_Mesh_ptr theMesh ) +void SMESHGUI_FilterDlg::SetMesh (SMESH::SMESH_Mesh_ptr theMesh) { myMesh = theMesh; } @@ -2099,26 +2104,22 @@ void SMESHGUI_FilterDlg::SetMesh( SMESH::SMESH_Mesh_ptr theMesh ) // name : SMESHGUI_FilterDlg::SetSelection // Purpose : Get filtered ids //======================================================================= -void SMESHGUI_FilterDlg::SetSelection( SALOME_Selection* theSel ) +void SMESHGUI_FilterDlg::SetSelection() { - if ( mySelection ) - disconnect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionDone() ) ); - - mySelection = theSel; + if (mySelectionMgr) + disconnect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(onSelectionDone())); - if ( mySelection ) - { + if (mySelectionMgr) { myIObjects.Clear(); - const SALOME_ListIO& anObjs = mySelection->StoredIObjects(); - SALOME_ListIteratorOfListIO anIter( anObjs ); - for ( ;anIter.More(); anIter.Next() ) - { + const SALOME_ListIO& anObjs = mySelector->StoredIObjects(); + SALOME_ListIteratorOfListIO anIter (anObjs); + for (; anIter.More(); anIter.Next()) { TColStd_IndexedMapOfInteger aMap; - mySelection->GetIndex( anIter.Value(), aMap ); - myIObjects.Bind( anIter.Value(), aMap ); + mySelector->GetIndex(anIter.Value(), aMap); + myIObjects.Bind(anIter.Value(), aMap); } - - connect( mySelection, SIGNAL( currentSelectionChanged() ), SLOT( onSelectionDone() ) ); + + connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(onSelectionDone())); updateSelection(); } @@ -2133,34 +2134,31 @@ void SMESHGUI_FilterDlg::SetSelection( SALOME_Selection* theSel ) //======================================================================= bool SMESHGUI_FilterDlg::onApply() { - if ( !isValid() ) + if (!isValid()) return false; - try - { + try { int aCurrType = myTable->GetType(); - if ( !createFilter( aCurrType ) ) + if (!createFilter(aCurrType)) return false; insertFilterInViewer(); - if ( !myFilter[ aCurrType ]->GetPredicate()->_is_nil() ) - { + if (!myFilter[ aCurrType ]->GetPredicate()->_is_nil()) { QValueList aResultIds; - filterSource( aCurrType, aResultIds ); - selectInViewer( aCurrType, aResultIds ); + filterSource(aCurrType, aResultIds); + selectInViewer(aCurrType, aResultIds); } myInsertState[ aCurrType ] = mySetInViewer->isChecked(); - myApplyToState[ aCurrType ] = mySourceGrp->id( mySourceGrp->selected() ); - + myApplyToState[ aCurrType ] = mySourceGrp->id(mySourceGrp->selected()); } - catch( const SALOME::SALOME_Exception& S_ex ) + catch(const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException( S_ex ); + SalomeApp_Tools::QtCatchCorbaException(S_ex); } - catch( ... ) + catch(...) { } @@ -2171,37 +2169,37 @@ bool SMESHGUI_FilterDlg::onApply() // name : SMESHGUI_FilterDlg::createFilter // Purpose : Create predicate for given type //======================================================================= -bool SMESHGUI_FilterDlg::createFilter( const int theType ) +bool SMESHGUI_FilterDlg::createFilter (const int theType) { SMESH::FilterManager_var aFilterMgr = SMESH::GetFilterManager(); - if ( aFilterMgr->_is_nil() ) + if (aFilterMgr->_is_nil()) return false; int n = myTable->NumRows(); SMESH::Filter::Criteria_var aCriteria = new SMESH::Filter::Criteria; - aCriteria->length( n ); + aCriteria->length(n); long aPrecision = -1; - if ( QAD_CONFIG->hasSetting( "SMESH:ControlsPrecision" ) ) - { - QString aStr = QAD_CONFIG->getSetting( "SMESH:ControlsPrecision" ); + SUIT_ResourceMgr* mgr = SMESHGUI::resourceMgr(); + + if (mgr && mgr->hasValue("SMESH", "ControlsPrecision")) { + QString aStr = mgr->stringValue("SMESH", "ControlsPrecision"); bool isOk = false; - int aVal = aStr.toInt( &isOk ); - if ( isOk ) + int aVal = aStr.toInt(&isOk); + if (isOk) aPrecision = aVal; } - - for ( CORBA::ULong i = 0; i < n; i++ ) - { + + for (CORBA::ULong i = 0; i < n; i++) { SMESH::Filter::Criterion aCriterion = createCriterion(); - myTable->GetCriterion( i, aCriterion ); + myTable->GetCriterion(i, aCriterion); aCriterion.Precision = aPrecision; aCriteria[ i ] = aCriterion; } myFilter[ theType ] = aFilterMgr->CreateFilter(); - myFilter[ theType ]->SetCriteria( aCriteria.inout() ); + myFilter[ theType ]->SetCriteria(aCriteria.inout()); return true; } @@ -2212,19 +2210,17 @@ bool SMESHGUI_FilterDlg::createFilter( const int theType ) //======================================================================= void SMESHGUI_FilterDlg::insertFilterInViewer() { - if ( VTKViewer_InteractorStyleSALOME* aStyle = SMESH::GetInteractorStyle() ) - { + if (SVTK_InteractorStyle* aStyle = SMESH::GetInteractorStyle()) { SMESH::ElementType anEntType = (SMESH::ElementType)myTable->GetType(); - if ( myFilter[ myTable->GetType() ]->_is_nil() || + if (myFilter[ myTable->GetType() ]->_is_nil() || myFilter[ myTable->GetType() ]->GetPredicate()->_is_nil() || - !mySetInViewer->isChecked() ) - SMESH::RemoveFilter( getFilterId( anEntType ), aStyle ); - else - { + !mySetInViewer->isChecked()) { + SMESH::RemoveFilter(getFilterId(anEntType), aStyle); + } else { Handle(SMESHGUI_PredicateFilter) aFilter = new SMESHGUI_PredicateFilter(); - aFilter->SetPredicate( myFilter[ myTable->GetType() ]->GetPredicate() ); - SMESH::SetFilter( aFilter, aStyle ); + aFilter->SetPredicate(myFilter[ myTable->GetType() ]->GetPredicate()); + SMESH::SetFilter(aFilter, aStyle); } } } @@ -2233,34 +2229,34 @@ void SMESHGUI_FilterDlg::insertFilterInViewer() // name : SMESHGUI_FilterDlg::filterSource // Purpose : Filter source ids //======================================================================= -void SMESHGUI_FilterDlg::filterSource( const int theType, - QValueList& theResIds ) +void SMESHGUI_FilterDlg::filterSource (const int theType, + QValueList& theResIds) { theResIds.clear(); - if ( myFilter[ theType ]->_is_nil() ) + if (myFilter[ theType ]->_is_nil()) return; - int aSourceId = mySourceGrp->id( mySourceGrp->selected() ); + int aSourceId = mySourceGrp->id(mySourceGrp->selected()); - if ( aSourceId == Mesh ) + if (aSourceId == Mesh) { - if ( myMesh->_is_nil() ) + if (myMesh->_is_nil()) return; - SMESH::long_array_var anIds = myFilter[ theType ]->GetElementsId( myMesh ); - for ( int i = 0, n = anIds->length(); i < n; i++ ) - theResIds.append( anIds[ i ] ); + SMESH::long_array_var anIds = myFilter[ theType ]->GetElementsId(myMesh); + for (int i = 0, n = anIds->length(); i < n; i++) + theResIds.append(anIds[ i ]); } - else if ( aSourceId == Selection ) + else if (aSourceId == Selection) { - filterSelectionSource( theType, theResIds ); + filterSelectionSource(theType, theResIds); } - else if ( aSourceId == Dialog ) + else if (aSourceId == Dialog) { // retrieve ids from dialog QValueList aDialogIds; - getIdsFromWg( mySourceWg, aDialogIds ); + getIdsFromWg(mySourceWg, aDialogIds); - if ( myMesh->_is_nil() ) + if (myMesh->_is_nil()) { theResIds = aDialogIds; return; @@ -2268,14 +2264,14 @@ void SMESHGUI_FilterDlg::filterSource( const int theType, // filter ids SMESH::Predicate_ptr aPred = myFilter[ theType ]->GetPredicate(); - aPred->SetMesh( myMesh ); + aPred->SetMesh(myMesh); QValueList::const_iterator anIter; - for ( anIter = aDialogIds.begin(); anIter != aDialogIds.end(); ++ anIter ) - if ( aPred->IsSatisfy( *anIter ) ) - theResIds.append( *anIter ); + for (anIter = aDialogIds.begin(); anIter != aDialogIds.end(); ++ anIter) + if (aPred->IsSatisfy(*anIter)) + theResIds.append(*anIter); // set ids to the dialog - setIdsToWg( mySourceWg, theResIds ); + setIdsToWg(mySourceWg, theResIds); } } @@ -2283,57 +2279,57 @@ void SMESHGUI_FilterDlg::filterSource( const int theType, // name : SMESHGUI_FilterDlg::filterSelectionSource // Purpose : Filter source selection //======================================================================= -void SMESHGUI_FilterDlg::filterSelectionSource( const int theType, - QValueList& theResIds ) +void SMESHGUI_FilterDlg::filterSelectionSource (const int theType, + QValueList& theResIds) { theResIds.clear(); - if ( myMesh->_is_nil() || mySelection == 0 ) + if (myMesh->_is_nil() || mySelectionMgr == 0) return; // Create map of entities to be filtered TColStd_MapOfInteger aToBeFiltered; - SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger anIter( myIObjects ); + SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger anIter(myIObjects); - for ( ; anIter.More(); anIter.Next() ) + for (; anIter.More(); anIter.Next()) { // process sub mesh - SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface( anIter.Key() ); - if ( !aSubMesh->_is_nil() ) + SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface(anIter.Key()); + if (!aSubMesh->_is_nil()) { - if ( aSubMesh->GetFather()->GetId() == myMesh->GetId() ) + if (aSubMesh->GetFather()->GetId() == myMesh->GetId()) { SMESH::long_array_var anIds = theType == SMESH::NODE ? aSubMesh->GetNodesId() : aSubMesh->GetElementsId(); - for ( int i = 0, n = anIds->length(); i < n; i++ ) - aToBeFiltered.Add( anIds[ i ] ); + for (int i = 0, n = anIds->length(); i < n; i++) + aToBeFiltered.Add(anIds[ i ]); } } // process group SMESH::SMESH_GroupBase_var aGroup = - SMESH::IObjectToInterface( anIter.Key() ); - if ( !aGroup->_is_nil() ) + SMESH::IObjectToInterface(anIter.Key()); + if (!aGroup->_is_nil()) { - if ( aGroup->GetType() == theType && aGroup->GetMesh()->GetId() == myMesh->GetId() ) + if (aGroup->GetType() == theType && aGroup->GetMesh()->GetId() == myMesh->GetId()) { SMESH::long_array_var anIds = aGroup->GetListOfID(); - for ( int i = 0, n = anIds->length(); i < n; i++ ) - aToBeFiltered.Add( anIds[ i ] ); + for (int i = 0, n = anIds->length(); i < n; i++) + aToBeFiltered.Add(anIds[ i ]); } } // process mesh - SMESH::SMESH_Mesh_var aMeshPtr = SMESH::IObjectToInterface( anIter.Key() ); - if ( !aMeshPtr->_is_nil() && aMeshPtr->GetId() == myMesh->GetId() ) + SMESH::SMESH_Mesh_var aMeshPtr = SMESH::IObjectToInterface(anIter.Key()); + if (!aMeshPtr->_is_nil() && aMeshPtr->GetId() == myMesh->GetId()) { const TColStd_IndexedMapOfInteger& aSelMap = anIter.Value(); - if ( aSelMap.Extent() > 0 ) + if (aSelMap.Extent() > 0) { - if( SMESH::FindActorByEntry( anIter.Key()->getEntry() ) ) + if(SMESH::FindActorByEntry(anIter.Key()->getEntry())) { - for ( int i = 1; i <= aSelMap.Extent(); i++ ) - aToBeFiltered.Add( aSelMap(i) ); + for (int i = 1; i <= aSelMap.Extent(); i++) + aToBeFiltered.Add(aSelMap(i)); } } } @@ -2341,67 +2337,69 @@ void SMESHGUI_FilterDlg::filterSelectionSource( const int theType, // Filter entities SMESH::Predicate_ptr aPred = myFilter[ theType ]->GetPredicate(); - aPred->SetMesh( myMesh ); - TColStd_MapIteratorOfMapOfInteger aResIter( aToBeFiltered ); - for ( ; aResIter.More(); aResIter.Next() ) - if ( aPred->IsSatisfy( aResIter.Key() ) ) - theResIds.append( aResIter.Key() ); + aPred->SetMesh(myMesh); + TColStd_MapIteratorOfMapOfInteger aResIter(aToBeFiltered); + for (; aResIter.More(); aResIter.Next()) + if (aPred->IsSatisfy(aResIter.Key())) + theResIds.append(aResIter.Key()); } //======================================================================= // name : SMESHGUI_FilterDlg::selectInViewer // Purpose : Select given entities in viewer //======================================================================= -void SMESHGUI_FilterDlg::selectInViewer( const int theType, const QValueList& theIds ) +void SMESHGUI_FilterDlg::selectInViewer (const int theType, const QValueList& theIds) { - if ( mySelection == 0 || myMesh->_is_nil() ) + if (mySelectionMgr == 0 || myMesh->_is_nil()) return; - mySelection->ClearFilters(); + mySelectionMgr->clearFilters(); // Set new selection mode if necessary - Selection_Mode aSelMode = getSelMode( theType ); - if ( aSelMode != mySelection->SelectionMode() ) - { - mySelection->ClearIObjects(); - mySelection->ClearFilters(); - if ( aSelMode == NodeSelection ) + Selection_Mode aSelMode = getSelMode(theType); + if (myViewWindow->SelectionMode()!=aSelMode) { + mySelectionMgr->clearSelected(); + mySelectionMgr->clearFilters(); + if (aSelMode == NodeSelection) SMESH::SetPointRepresentation(true); - QAD_Application::getDesktop()->SetSelectionMode( aSelMode ); + myViewWindow->SetSelectionMode(aSelMode); } // Clear selection SMESH_Actor* anActor = SMESH::FindActorByObject(myMesh); - if ( !anActor || !anActor->hasIO() ) + if (!anActor || !anActor->hasIO()) return; Handle(SALOME_InteractiveObject) anIO = anActor->getIO(); - mySelection->ClearIObjects(); - mySelection->AddIObject( anIO, false ); + //mySelectionMgr->clearSelected(); + //mySelectionMgr->AddIObject(anIO, false); + SALOME_ListIO aList; + aList.Append(anIO); + mySelectionMgr->setSelectedObjects(aList, false); // Remove filter corresponding to the current type from viewer int aType = myTable->GetType(); int aFilterId = SMESHGUI_UnknownFilter; - if ( aType == SMESH::EDGE ) aFilterId = SMESHGUI_EdgeFilter; - else if ( aType == SMESH::FACE ) aFilterId = SMESHGUI_FaceFilter; - else if ( aType == SMESH::VOLUME ) aFilterId = SMESHGUI_VolumeFilter; - Handle(VTKViewer_Filter) aFilter = SMESH::GetFilter( aFilterId ); - SMESH::RemoveFilter( aFilterId ); + if (aType == SMESH::EDGE ) aFilterId = SMESHGUI_EdgeFilter; + else if (aType == SMESH::FACE ) aFilterId = SMESHGUI_FaceFilter; + else if (aType == SMESH::VOLUME) aFilterId = SMESHGUI_VolumeFilter; + Handle(VTKViewer_Filter) aFilter = SMESH::GetFilter(aFilterId); + SMESH::RemoveFilter(aFilterId); // get vtk ids TColStd_MapOfInteger aMap; QValueList::const_iterator anIter; - for ( anIter = theIds.begin(); anIter != theIds.end(); ++anIter ) - { - aMap.Add( *anIter ); + for (anIter = theIds.begin(); anIter != theIds.end(); ++anIter) { + aMap.Add(*anIter); } // Set new selection - mySelection->AddOrRemoveIndex( anIO, aMap, false, true ); + mySelector->AddOrRemoveIndex(anIO, aMap, false); + myViewWindow->highlight( anIO, true, true ); // insert previously stored filter in viewer if necessary - if ( !aFilter.IsNull() ) - SMESH::SetFilter( aFilter ); + if (!aFilter.IsNull()) + SMESH::SetFilter(aFilter); } //======================================================================= @@ -2432,25 +2430,27 @@ SMESH::Filter::Criterion SMESHGUI_FilterDlg::createCriterion() void SMESHGUI_FilterDlg::onSelectionDone() { int aRow, aCol; - if ( mySelection->IObjectCount() != 1 || - !myTable->CurrentCell( aRow, aCol ) || - myTable->GetCriterionType( aRow ) != FT_BelongToGeom && - myTable->GetCriterionType( aRow ) != FT_BelongToPlane && - myTable->GetCriterionType( aRow ) != FT_BelongToCylinder && - myTable->GetCriterionType( aRow ) != FT_LyingOnGeom ) + const SALOME_ListIO& aList = mySelector->StoredIObjects(); + + if (aList.Extent() != 1 || + !myTable->CurrentCell(aRow, aCol) || + myTable->GetCriterionType(aRow) != FT_BelongToGeom && + myTable->GetCriterionType(aRow) != FT_BelongToPlane && + myTable->GetCriterionType(aRow) != FT_BelongToCylinder && + myTable->GetCriterionType(aRow) != FT_LyingOnGeom) return; - Handle(SALOME_InteractiveObject) anIO = mySelection->firstIObject() ; - GEOM::GEOM_Object_var anObj = SMESH::IObjectToInterface( anIO ) ; - if ( !anObj->_is_nil() ) - myTable->SetThreshold( aRow, GEOMBase::GetName(anObj) ); + Handle(SALOME_InteractiveObject) anIO = aList.First(); + GEOM::GEOM_Object_var anObj = SMESH::IObjectToInterface(anIO); + if (!anObj->_is_nil()) + myTable->SetThreshold(aRow, GEOMBase::GetName(anObj)); } //======================================================================= // name : SMESHGUI_FilterDlg::onCriterionChanged // Purpose : SLOT called when cretarion of current row changed. Update selection //======================================================================= -void SMESHGUI_FilterDlg::onCriterionChanged( const int , const int ) +void SMESHGUI_FilterDlg::onCriterionChanged (const int , const int) { updateSelection(); } @@ -2459,7 +2459,7 @@ void SMESHGUI_FilterDlg::onCriterionChanged( const int , const int ) // name : SMESHGUI_FilterDlg::onCurrentChanged // Purpose : SLOT called when current row changed. Update selection //======================================================================= -void SMESHGUI_FilterDlg::onCurrentChanged( int, int ) +void SMESHGUI_FilterDlg::onCurrentChanged (int, int) { updateSelection(); } @@ -2470,55 +2470,43 @@ void SMESHGUI_FilterDlg::onCurrentChanged( int, int ) //======================================================================= void SMESHGUI_FilterDlg::updateSelection() { - if ( mySelection == 0 ) + if (mySelectionMgr == 0) return; - - mySelection->ClearFilters(); + + TColStd_MapOfInteger allTypes; + for( int i=0; i<10; i++ ) + allTypes.Add( i ); + SalomeApp_Study* aStudy = dynamic_cast( mySMESHGUI->application()->activeStudy() ); + if( !aStudy ) + return; + + + mySelectionMgr->clearFilters(); int aRow, aCol; - - if ( myTable->CurrentCell( aRow, aCol ) && - ( myTable->GetCriterionType( aRow ) == FT_BelongToGeom || - myTable->GetCriterionType( aRow ) == FT_BelongToPlane || - myTable->GetCriterionType( aRow ) == FT_BelongToCylinder || - myTable->GetCriterionType( aRow ) == FT_LyingOnGeom) ) - { - if ( myTable->GetCriterionType( aRow ) == FT_BelongToGeom || myTable->GetCriterionType( aRow ) == FT_LyingOnGeom ) - mySelection->AddFilter( new SALOME_TypeFilter( "GEOM" ) ); - else if ( myTable->GetCriterionType( aRow ) == FT_BelongToPlane ) - mySelection->AddFilter( new GEOM_FaceFilter( StdSelect_Plane ) ); - else if ( myTable->GetCriterionType( aRow ) == FT_BelongToCylinder ) - mySelection->AddFilter( new GEOM_FaceFilter( StdSelect_Cylinder ) ); + if (myTable->CurrentCell(aRow, aCol) && + (myTable->GetCriterionType(aRow) == FT_BelongToGeom || + myTable->GetCriterionType(aRow) == FT_BelongToPlane || + myTable->GetCriterionType(aRow) == FT_BelongToCylinder || + myTable->GetCriterionType(aRow) == FT_LyingOnGeom)) { + + if (myTable->GetCriterionType(aRow) == FT_BelongToGeom || + myTable->GetCriterionType(aRow) == FT_LyingOnGeom) { + + mySelectionMgr->installFilter(new SMESH_NumberFilter("GEOM",TopAbs_SHAPE,0,allTypes)); + + } else if (myTable->GetCriterionType(aRow) == FT_BelongToPlane) { + mySelectionMgr->installFilter(new GEOM_FaceFilter( aStudy, StdSelect_Plane ) ); + + } else if (myTable->GetCriterionType(aRow) == FT_BelongToCylinder) { + mySelectionMgr->installFilter(new GEOM_FaceFilter( aStudy, StdSelect_Cylinder ) ); + } myIsSelectionChanged = true; - } - else - { - if ( myIsSelectionChanged ) - mySelection->AddFilter( new SALOME_TypeFilter( "This filter deactivate selection" ) ); + + } else { + if (myIsSelectionChanged) { + mySelectionMgr->installFilter(new SMESH_NumberFilter ("This filter deactivates selection",TopAbs_SHAPE,0,allTypes)); + } } } - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/SMESHGUI/SMESHGUI_FilterDlg.h b/src/SMESHGUI/SMESHGUI_FilterDlg.h index f63d2b2e0..cbef2c66f 100755 --- a/src/SMESHGUI/SMESHGUI_FilterDlg.h +++ b/src/SMESHGUI/SMESHGUI_FilterDlg.h @@ -34,9 +34,10 @@ #include #include -#include "SALOME_Selection.h" +#include "SalomeApp_SelectionMgr.h" #include "SALOME_InteractiveObject.hxx" #include "SALOME_DataMapOfIOMapOfInteger.hxx" +#include "SVTK_Selection.h" #include @@ -55,17 +56,19 @@ class QStringList; class QTable; class QTableItem; class QWidgetStack; -class SALOME_Selection; +class SalomeApp_SelectionMgr; class SMESHGUI; class SMESHGUI_FilterLibraryDlg; +class SVTK_Selector; +class SVTK_ViewWindow; -/* - Class : SMESHGUI_FilterTable - Description : Frame containig - - Button group for switching entity type - - Table for displaying filter criterions - - Buttons for editing table -*/ +/*! + * Class : SMESHGUI_FilterTable + * Description : Frame containig + * - Button group for switching entity type + * - Table for displaying filter criterions + * - Buttons for editing table + */ class SMESHGUI_FilterTable : public QFrame { @@ -78,66 +81,64 @@ class SMESHGUI_FilterTable : public QFrame typedef QMap TableMap; public: - - SMESHGUI_FilterTable( QWidget* parent, - const int type ); - SMESHGUI_FilterTable( QWidget* parent, - const QValueList& type ); + SMESHGUI_FilterTable (QWidget* parent, + const int type); + SMESHGUI_FilterTable (QWidget* parent, + const QValueList& type); virtual ~SMESHGUI_FilterTable(); - - void Init( const int type ); - void Init( const QValueList& types ); + + void Init (const int type); + void Init (const QValueList& types); QGroupBox* GetTableGrp(); - bool IsValid( const bool = true, const int theEntityType = -1 ) const; + bool IsValid (const bool = true, const int theEntityType = -1) const; int GetType() const; - void SetType( const int ); + void SetType (const int); void RestorePreviousEntityType(); - int NumRows( const int theEntityType = -1 ) const; - void Clear( const int theEntityType = -1 ); - void SetEditable( const bool ); - void SetEnabled( const bool ); - void SetLibsEnabled( const bool ); + int NumRows (const int theEntityType = -1) const; + void Clear (const int theEntityType = -1); + void SetEditable (const bool); + void SetEnabled (const bool); + void SetLibsEnabled (const bool); bool IsEditable() const; - int GetCriterionType( const int theRow, const int theType = -1 ) const; - - void GetCriterion( const int theRow, + int GetCriterionType (const int theRow, const int theType = -1) const; + + void GetCriterion (const int theRow, SMESH::Filter::Criterion& theCriterion, - const int theEntityType = -1 ) const; + const int theEntityType = -1) const; - void SetCriterion( const int theRow, + void SetCriterion (const int theRow, const SMESH::Filter::Criterion& theCriterion, - const int theEntityType = -1 ); + const int theEntityType = -1); - void AddCriterion( const SMESH::Filter::Criterion& theCriterion, - const int theEntityType = -1 ); - - void Copy( const SMESHGUI_FilterTable* ); - void SetValidity( const bool ); + void AddCriterion (const SMESH::Filter::Criterion& theCriterion, + const int theEntityType = -1); - bool CurrentCell( int& theRow, int& theCol ) const; - void SetThreshold( const int theRow, + void Copy (const SMESHGUI_FilterTable*); + void SetValidity (const bool); + + bool CurrentCell (int& theRow, int& theCol) const; + void SetThreshold (const int theRow, const QString& theText, - const int theEntityType = -1 ); + const int theEntityType = -1); - bool GetThreshold( const int theRow, + bool GetThreshold (const int theRow, QString& theText, - const int theEntityType = -1 ); + const int theEntityType = -1); void Update(); - signals: void CopyFromClicked(); void AddToClicked(); - void EntityTypeChanged( const int ); + void EntityTypeChanged (const int); void NeedValidation(); - void CretarionChanged( const int theRow, const int theEntityType ); - void CurrentChanged( int, int ); - + void CretarionChanged (const int theRow, const int theEntityType); + void CurrentChanged (int, int); + private slots: void onAddBtn(); @@ -146,30 +147,30 @@ private slots: void onClearBtn(); void onCopyFromBtn(); void onAddToBtn(); - void onCriterionChanged( int, int ); - void onEntityType( int ); - void onCurrentChanged( int, int ); + void onCriterionChanged (int, int); + void onEntityType (int); + void onCurrentChanged (int, int); private: - void addRow( Table*, const int, const bool toTheEnd = true ); - QTableItem* getCriterionItem( QTable*, const int ); - QTableItem* getCompareItem( QTable* ); - QTableItem* getUnaryItem( QTable* ); - QTableItem* getBinaryItem( QTable* ); - const QMap& getCriteria( const int theType ) const; + void addRow (Table*, const int, const bool toTheEnd = true); + QTableItem* getCriterionItem (QTable*, const int); + QTableItem* getCompareItem (QTable*); + QTableItem* getUnaryItem (QTable*); + QTableItem* getBinaryItem (QTable*); + const QMap& getCriteria (const int theType) const; const QMap& getCompare() const; - Table* createTable( QWidget*, const int ); - QWidget* createAdditionalFrame( QWidget* theParent ); + Table* createTable (QWidget*, const int); + QWidget* createAdditionalFrame (QWidget* theParent); int getFirstSelectedRow() const; - void onCriterionChanged( const int, const int, const int ); - + void onCriterionChanged (const int, const int, const int); + void updateBtnState(); - void removeAdditionalWidget( QTable* theTable, const int theRow ); + void removeAdditionalWidget (QTable* theTable, const int theRow); void updateAdditionalWidget(); const QMap& getSupportedTypes() const; - + private: QGroupBox* myTableGrp; @@ -186,45 +187,46 @@ private: QButtonGroup* myEntityTypeGrp; int myEntityType; int myIsValid; - + SMESHGUI_FilterLibraryDlg* myLibDlg; - QWidgetStack* myWgStack; + QWidgetStack* myWgStack; + QMap myAddWidgets; }; -/* - Class : SMESHGUI_FilterDlg - Description : Dialog to specify filters for VTK viewer -*/ +/*! + * Class : SMESHGUI_FilterDlg + * Description : Dialog to specify filters for VTK viewer + */ class SMESHGUI_FilterDlg : public QDialog -{ +{ Q_OBJECT // Source elements to be selected enum { Mesh, Selection, Dialog, None }; - + // Buttons enum { BTN_OK, BTN_Cancel, BTN_Apply, BTN_Close }; public: - SMESHGUI_FilterDlg( QWidget* parent, + SMESHGUI_FilterDlg( SMESHGUI*, const QValueList& types, - const char* name = 0 ); - - SMESHGUI_FilterDlg( QWidget* parent, + const char* name = 0); + + SMESHGUI_FilterDlg( SMESHGUI*, const int type, - const char* name = 0 ); + const char* name = 0); virtual ~SMESHGUI_FilterDlg(); - void Init( const QValueList& types ); - void Init( const int type ); + void Init (const QValueList& types); + void Init (const int type); - void SetSelection( SALOME_Selection* ); - void SetMesh( SMESH::SMESH_Mesh_ptr ); - void SetSourceWg( QWidget* ); + void SetSelection(); + void SetMesh (SMESH::SMESH_Mesh_ptr); + void SetSourceWg (QWidget*); static SMESH::Filter::Criterion createCriterion(); @@ -239,35 +241,35 @@ private slots: void onClose(); void onDeactivate(); void onSelectionDone(); - void onCriterionChanged( const int, const int ); - void onCurrentChanged( int, int ); - + void onCriterionChanged (const int, const int); + void onCurrentChanged (int, int); + private: - void construct( const QValueList& types ); + void construct (const QValueList& types); - void closeEvent( QCloseEvent* e ); - void enterEvent ( QEvent * ); + void closeEvent (QCloseEvent*); + void enterEvent (QEvent*); // dialog creation - QFrame* createButtonFrame( QWidget* ); - QFrame* createMainFrame( QWidget* ); - QButtonGroup* createSourceGroup( QWidget* ); + QFrame* createButtonFrame (QWidget*); + QFrame* createMainFrame (QWidget*); + QButtonGroup* createSourceGroup (QWidget*); void updateMainButtons(); - + // execution bool isValid() const; - bool createFilter( const int theType ); + bool createFilter (const int theType); void insertFilterInViewer(); - void selectInViewer( const int theType, - const QValueList& theIds ); - void filterSource( const int theType, - QValueList& theResIds ); - void filterSelectionSource( const int theType, - QValueList& theResIds ); - void getIdsFromWg( const QWidget*, QValueList& ) const; - void setIdsToWg( QWidget*, const QValueList& ); - Selection_Mode getSelMode( const int ) const; + void selectInViewer (const int theType, + const QValueList& theIds); + void filterSource (const int theType, + QValueList& theResIds); + void filterSelectionSource (const int theType, + QValueList& theResIds); + void getIdsFromWg (const QWidget*, QValueList&) const; + void setIdsToWg (QWidget*, const QValueList&); + Selection_Mode getSelMode (const int) const; void updateSelection(); private: @@ -285,7 +287,9 @@ private: // initial fields QValueList myTypes; SMESHGUI* mySMESHGUI; - SALOME_Selection* mySelection; + SalomeApp_SelectionMgr* mySelectionMgr; + SVTK_Selector* mySelector; + SVTK_ViewWindow* myViewWindow; SMESH::SMESH_Mesh_ptr myMesh; QWidget* mySourceWg; @@ -297,23 +301,3 @@ private: }; #endif - - - - - - - - - - - - - - - - - - - - diff --git a/src/SMESHGUI/SMESHGUI_FilterLibraryDlg.cxx b/src/SMESHGUI/SMESHGUI_FilterLibraryDlg.cxx index c5db40231..e8fffa426 100644 --- a/src/SMESHGUI/SMESHGUI_FilterLibraryDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_FilterLibraryDlg.cxx @@ -1,23 +1,23 @@ // SMESH SMESHGUI : GUI for SMESH component // // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org // // // @@ -26,13 +26,16 @@ // Module : SMESH #include "SMESHGUI_FilterLibraryDlg.h" + #include "SMESHGUI.h" #include "SMESHGUI_Utils.h" #include "SMESHGUI_FilterUtils.h" -#include -#include +#include "SUIT_Session.h" +#include "SUIT_Desktop.h" +#include "SUIT_FileDlg.h" +// QT Includes #include #include #include @@ -49,24 +52,24 @@ #define SPACING 5 #define MARGIN 10 -/* - Class : SMESHGUI_FilterLibraryDlg::Dialog - Description : Dialog for opening filter library -*/ +/*! + * Class : SMESHGUI_FilterLibraryDlg::Dialog + * Description : Dialog for opening filter library + */ -class SMESHGUI_FilterLibraryDlg::Dialog : public QAD_FileDlg +class SMESHGUI_FilterLibraryDlg::Dialog : public SUIT_FileDlg { -public: - Dialog( QWidget* theParent, const bool theToOpen ); + public: + Dialog(QWidget* theParent, const bool theToOpen); virtual ~Dialog(); - -protected: + + protected: virtual bool acceptData(); }; -SMESHGUI_FilterLibraryDlg::Dialog::Dialog( QWidget* theParent, - const bool theToOpen ) -: QAD_FileDlg( theParent, theToOpen ) +SMESHGUI_FilterLibraryDlg::Dialog::Dialog (QWidget* theParent, + const bool theToOpen) + : SUIT_FileDlg(theParent, theToOpen) { } @@ -76,148 +79,150 @@ SMESHGUI_FilterLibraryDlg::Dialog::~Dialog() bool SMESHGUI_FilterLibraryDlg::Dialog::acceptData() { - if ( mode() != QFileDialogP::AnyFile ) - return QAD_FileDlg::acceptData(); - else - return true; +#ifdef NEW_GUI + if (mode() != QFileDialogP::AnyFile) + return SUIT_FileDlg::acceptData(); +#endif + + return true; } - -/* - Class : SMESHGUI_FilterLibraryDlg - Description : Dialog to specify filters for VTK viewer -*/ +/*! + * Class : SMESHGUI_FilterLibraryDlg + * Description : Dialog to specify filters for VTK viewer + */ //======================================================================= // name : SMESHGUI_FilterLibraryDlg::SMESHGUI_FilterLibraryDlg // Purpose : Constructor //======================================================================= -SMESHGUI_FilterLibraryDlg::SMESHGUI_FilterLibraryDlg( QWidget* theParent, +SMESHGUI_FilterLibraryDlg::SMESHGUI_FilterLibraryDlg (QWidget* theParent, const QValueList& theTypes, const int theMode, - const char* theName ) -: QDialog( theParent, theName, true, - WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) + const char* theName) + : QDialog(theParent, theName, true, WStyle_Customize | + WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) { - construct( theTypes, theMode ); + construct(theTypes, theMode); } //======================================================================= // name : SMESHGUI_FilterLibraryDlg::SMESHGUI_FilterLibraryDlg // Purpose : Constructor //======================================================================= -SMESHGUI_FilterLibraryDlg::SMESHGUI_FilterLibraryDlg( QWidget* theParent, +SMESHGUI_FilterLibraryDlg::SMESHGUI_FilterLibraryDlg (QWidget* theParent, const int theType, const int theMode, - const char* theName ) -: QDialog( theParent, theName, true, - WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) + const char* theName) + : QDialog(theParent, theName, true, WStyle_Customize | + WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) { QValueList aTypes; - aTypes.append( theType ); - construct( aTypes, theMode ); + aTypes.append(theType); + construct(aTypes, theMode); } //======================================================================= // name : SMESHGUI_FilterLibraryDlg::construct -// Purpose : Construct dialog ( called by constructor ) +// Purpose : Construct dialog (called by constructor) //======================================================================= -void SMESHGUI_FilterLibraryDlg::construct( const QValueList& theTypes, const int theMode ) +void SMESHGUI_FilterLibraryDlg::construct (const QValueList& theTypes, + const int theMode) { myTypes = theTypes; myMode = theMode; - QVBoxLayout* aDlgLay = new QVBoxLayout( this, MARGIN, SPACING ); + QVBoxLayout* aDlgLay = new QVBoxLayout(this, MARGIN, SPACING); - myMainFrame = createMainFrame ( this ); - QFrame* aBtnFrame = createButtonFrame( this ); + myMainFrame = createMainFrame (this); + QFrame* aBtnFrame = createButtonFrame(this); - aDlgLay->addWidget( myMainFrame ); - aDlgLay->addWidget( aBtnFrame ); + aDlgLay->addWidget(myMainFrame); + aDlgLay->addWidget(aBtnFrame); - aDlgLay->setStretchFactor( myMainFrame, 1 ); + aDlgLay->setStretchFactor(myMainFrame, 1); - Init( myTypes, myMode ); + Init(myTypes, myMode); } //======================================================================= // name : SMESHGUI_FilterLibraryDlg::createMainFrame // Purpose : Create frame containing dialog's input fields //======================================================================= -QFrame* SMESHGUI_FilterLibraryDlg::createMainFrame( QWidget* theParent ) +QFrame* SMESHGUI_FilterLibraryDlg::createMainFrame (QWidget* theParent) { - QGroupBox* aMainFrame = new QGroupBox( 1, Qt::Horizontal, theParent ); - aMainFrame->setFrameStyle( QFrame::NoFrame ); - aMainFrame->setInsideMargin( 0 ); + QGroupBox* aMainFrame = new QGroupBox(1, Qt::Horizontal, theParent); + aMainFrame->setFrameStyle(QFrame::NoFrame); + aMainFrame->setInsideMargin(0); // library name - - QGroupBox* aGrp = new QGroupBox( 1, Qt::Vertical, aMainFrame ); - aGrp->setFrameStyle( QFrame::NoFrame ); - aGrp->setInsideMargin( 0 ); - - new QLabel( tr( "LIBRARY_FILE" ), aGrp ); - myFileName = new QLineEdit( aGrp ); - myOpenBtn = new QPushButton( aGrp ); - myOpenBtn->setPixmap( QAD_Desktop::getResourceManager()->loadPixmap( - "QAD", tr("ICON_FILE_OPEN") ) ); - - // filters list box - - aGrp = new QGroupBox( 1, Qt::Vertical, tr( "FILTER_NAMES" ), aMainFrame ); - QFrame* aFrame = new QFrame( aGrp ); - myListBox = new QListBox( aFrame ); - myAddBtn = new QPushButton( tr( "ADD" ), aFrame ); - myDeleteBtn = new QPushButton( tr( "DELETE" ), aFrame ); - QGridLayout* aLay = new QGridLayout( aFrame, 3, 2, 0, 5 ); - aLay->addMultiCellWidget( myListBox, 0, 2, 0, 0 ); - aLay->addWidget( myAddBtn, 0, 1 ); - aLay->addWidget( myDeleteBtn, 1, 1 ); - QSpacerItem* aVSpacer = new QSpacerItem( 0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding ); - aLay->addItem( aVSpacer, 2, 1 ); + QGroupBox* aGrp = new QGroupBox(1, Qt::Vertical, aMainFrame); + aGrp->setFrameStyle(QFrame::NoFrame); + aGrp->setInsideMargin(0); + + new QLabel(tr("LIBRARY_FILE"), aGrp); + myFileName = new QLineEdit(aGrp); + myOpenBtn = new QPushButton(aGrp); + myOpenBtn->setPixmap(SUIT_Session::session()->resourceMgr()->loadPixmap( + "SUIT", tr("ICON_FILE_OPEN"))); + + // filters list box + + aGrp = new QGroupBox(1, Qt::Vertical, tr("FILTER_NAMES"), aMainFrame); + QFrame* aFrame = new QFrame(aGrp); + myListBox = new QListBox(aFrame); + myAddBtn = new QPushButton(tr("ADD"), aFrame); + myDeleteBtn = new QPushButton(tr("DELETE"), aFrame); + + QGridLayout* aLay = new QGridLayout(aFrame, 3, 2, 0, 5); + aLay->addMultiCellWidget(myListBox, 0, 2, 0, 0); + aLay->addWidget(myAddBtn, 0, 1); + aLay->addWidget(myDeleteBtn, 1, 1); + QSpacerItem* aVSpacer = new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding); + aLay->addItem(aVSpacer, 2, 1); // filter name - - myNameGrp = new QGroupBox( 1, Qt::Vertical, aMainFrame ); - myNameGrp->setFrameStyle( QFrame::NoFrame ); - myNameGrp->setInsideMargin( 0 ); - new QLabel( tr( "FILTER_NAME" ), myNameGrp ); - myName = new QLineEdit( myNameGrp ); + + myNameGrp = new QGroupBox(1, Qt::Vertical, aMainFrame); + myNameGrp->setFrameStyle(QFrame::NoFrame); + myNameGrp->setInsideMargin(0); + new QLabel(tr("FILTER_NAME"), myNameGrp); + myName = new QLineEdit(myNameGrp); // table - - myTable = new SMESHGUI_FilterTable( aMainFrame, myTypes ); - myTable->SetEditable( myMode == EDIT ); - myTable->SetLibsEnabled( false ); - myListBox->setMinimumHeight( ( int )( myTable->sizeHint().height() * 0.5 ) ); - myListBox->setRowMode( QListBox::FitToWidth ); - myListBox->setSelectionMode( QListBox::Single ); + myTable = new SMESHGUI_FilterTable(aMainFrame, myTypes); + myTable->SetEditable(myMode == EDIT); + myTable->SetLibsEnabled(false); - myOpenBtn->setAutoDefault( false ); - myAddBtn->setAutoDefault( false ); - myDeleteBtn->setAutoDefault( false ); + myListBox->setMinimumHeight((int)(myTable->sizeHint().height() * 0.5)); + myListBox->setRowMode(QListBox::FitToWidth); + myListBox->setSelectionMode(QListBox::Single); + + myOpenBtn->setAutoDefault(false); + myAddBtn->setAutoDefault(false); + myDeleteBtn->setAutoDefault(false); // connect signals and slots - - connect( myFileName, SIGNAL( returnPressed() ), this, SLOT( onReturnPressed() ) ); - connect( myOpenBtn , SIGNAL( clicked() ), this, SLOT( onBrowse() ) ); - connect( myListBox, SIGNAL( highlighted( const QString& ) ), - this, SLOT( onFilterChanged( const QString& ) ) ); + connect(myFileName, SIGNAL(returnPressed()), this, SLOT(onReturnPressed())); + connect(myOpenBtn , SIGNAL(clicked()), this, SLOT(onBrowse())); - connect( myAddBtn, SIGNAL( clicked() ), this, SLOT( onAddBtnPressed() ) ); - connect( myDeleteBtn, SIGNAL( clicked() ), this, SLOT( onDeleteBtnPressed() ) ); + connect(myListBox, SIGNAL(highlighted(const QString&)), + this, SLOT(onFilterChanged(const QString&))); - connect( myName, SIGNAL( textChanged( const QString& ) ), - this, SLOT( onFilterNameChanged( const QString& ) ) ); + connect(myAddBtn, SIGNAL(clicked()), this, SLOT(onAddBtnPressed())); + connect(myDeleteBtn, SIGNAL(clicked()), this, SLOT(onDeleteBtnPressed())); - connect( myTable, SIGNAL( EntityTypeChanged( const int ) ), - this, SLOT( onEntityTypeChanged( const int ) ) ); + connect(myName, SIGNAL(textChanged(const QString&)), + this, SLOT(onFilterNameChanged(const QString&))); + + connect(myTable, SIGNAL(EntityTypeChanged(const int)), + this, SLOT(onEntityTypeChanged(const int))); + + connect(myTable, SIGNAL(NeedValidation()), this, SLOT(onNeedValidation())); - connect( myTable, SIGNAL( NeedValidation() ), this, SLOT( onNeedValidation() ) ); - return aMainFrame; } @@ -225,27 +230,27 @@ QFrame* SMESHGUI_FilterLibraryDlg::createMainFrame( QWidget* theParent ) // name : SMESHGUI_FilterLibraryDlg::createButtonFrame // Purpose : Create frame containing buttons //======================================================================= -QFrame* SMESHGUI_FilterLibraryDlg::createButtonFrame( QWidget* theParent ) +QFrame* SMESHGUI_FilterLibraryDlg::createButtonFrame (QWidget* theParent) { - QGroupBox* aGrp = new QGroupBox( 1, Qt::Vertical, theParent ); + QGroupBox* aGrp = new QGroupBox(1, Qt::Vertical, theParent); - myButtons[ BTN_OK ] = new QPushButton( tr( "SMESH_BUT_OK" ), aGrp ); - myButtons[ BTN_Apply ] = new QPushButton( tr( "SMESH_BUT_APPLY" ), aGrp ); + myButtons[ BTN_OK ] = new QPushButton(tr("SMESH_BUT_OK" ), aGrp); + myButtons[ BTN_Apply ] = new QPushButton(tr("SMESH_BUT_APPLY"), aGrp); - QLabel* aLbl = new QLabel( aGrp ); - aLbl->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + QLabel* aLbl = new QLabel(aGrp); + aLbl->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); - myButtons[ BTN_Cancel ] = new QPushButton( tr( "SMESH_BUT_CANCEL" ), aGrp ); - myButtons[ BTN_Close ] = new QPushButton( tr( "SMESH_BUT_CLOSE" ), aGrp ); + myButtons[ BTN_Cancel ] = new QPushButton(tr("SMESH_BUT_CANCEL"), aGrp); + myButtons[ BTN_Close ] = new QPushButton(tr("SMESH_BUT_CLOSE"), aGrp); - connect( myButtons[ BTN_OK ], SIGNAL( clicked() ), SLOT( onOk() ) ); - connect( myButtons[ BTN_Cancel ], SIGNAL( clicked() ), SLOT( onClose() ) ) ; - connect( myButtons[ BTN_Close ], SIGNAL( clicked() ), SLOT( onClose() ) ) ; - connect( myButtons[ BTN_Apply ], SIGNAL( clicked() ), SLOT( onApply() ) ); + connect(myButtons[ BTN_OK ], SIGNAL(clicked()), SLOT(onOk())); + connect(myButtons[ BTN_Cancel ], SIGNAL(clicked()), SLOT(onClose())); + connect(myButtons[ BTN_Close ], SIGNAL(clicked()), SLOT(onClose())); + connect(myButtons[ BTN_Apply ], SIGNAL(clicked()), SLOT(onApply())); QMap::iterator anIter; - for ( anIter = myButtons.begin(); anIter != myButtons.end(); ++anIter ) - anIter.data()->setAutoDefault( false ); + for (anIter = myButtons.begin(); anIter != myButtons.end(); ++anIter) + anIter.data()->setAutoDefault(false); updateMainButtons(); @@ -254,18 +259,15 @@ QFrame* SMESHGUI_FilterLibraryDlg::createButtonFrame( QWidget* theParent ) //======================================================================= // name : SMESHGUI_FilterLibraryDlg::updateMainButtons -// Purpose : Update visibility of main buttons ( OK, Cancel, Close ... ) +// Purpose : Update visibility of main buttons (OK, Cancel, Close ...) //======================================================================= void SMESHGUI_FilterLibraryDlg::updateMainButtons() { - if ( myTypes.count() == 1 ) - { + if (myTypes.count() == 1) { myButtons[ BTN_Cancel ]->show(); myButtons[ BTN_Apply ]->hide(); myButtons[ BTN_Close ]->hide(); - } - else - { + } else { myButtons[ BTN_Cancel ]->hide(); myButtons[ BTN_Apply ]->show(); myButtons[ BTN_Close ]->show(); @@ -284,70 +286,71 @@ SMESHGUI_FilterLibraryDlg::~SMESHGUI_FilterLibraryDlg() // name : SMESHGUI_FilterLibraryDlg::Init // Purpose : Init dialog fields, connect signals and slots, show dialog //======================================================================= -void SMESHGUI_FilterLibraryDlg::Init( const int type, const int theMode ) +void SMESHGUI_FilterLibraryDlg::Init (const int type, const int theMode) { QValueList aTypes; - aTypes.append( type ); - Init( aTypes, theMode ); + aTypes.append(type); + Init(aTypes, theMode); } //======================================================================= // name : SMESHGUI_FilterLibraryDlg::Init // Purpose : Init dialog fields, connect signals and slots, show dialog //======================================================================= -void SMESHGUI_FilterLibraryDlg::Init( const QValueList& theTypes, const int theMode ) +void SMESHGUI_FilterLibraryDlg::Init (const QValueList& theTypes, + const int theMode) { myMode = theMode; myTypes = theTypes; - myTable->Init( theTypes ); + myTable->Init(theTypes); myCurrFilterName = ""; myCurrFilter = -1; myListBox->clear(); myName->clear(); myTable->Clear(); - + updateControlsVisibility(); - setEnabled( true ); + setEnabled(true); SMESHGUI* aModeler = SMESHGUI::GetSMESHGUI(); - connect( aModeler, SIGNAL( SignalDeactivateActiveDialog() ), SLOT( onDeactivate() ) ); - connect( aModeler, SIGNAL( SignalCloseAllDialogs() ), SLOT( onClose() ) ); + connect(aModeler, SIGNAL(SignalDeactivateActiveDialog()), SLOT(onDeactivate())); + connect(aModeler, SIGNAL(SignalCloseAllDialogs()), SLOT(onClose())); - if ( myMode == ADD_TO ) + if (myMode == ADD_TO) { - setCaption( tr( "ADD_TO_TLT" ) ); - if ( myFileName->text().isEmpty() ) - myFileName->setText( getDefaultLibraryName() ); + setCaption(tr("ADD_TO_TLT")); + if (myFileName->text().isEmpty()) + myFileName->setText(getDefaultLibraryName()); processNewLibrary(); } - else if ( myMode == COPY_FROM ) + else if (myMode == COPY_FROM) { - setCaption( tr( "COPY_FROM_TLT" ) ); - if ( myFileName->text().isEmpty() ) - myFileName->setText( getDefaultLibraryName() ); + setCaption(tr("COPY_FROM_TLT")); + if (myFileName->text().isEmpty()) + myFileName->setText(getDefaultLibraryName()); processNewLibrary(); - if ( myListBox->count() > 0 ) - myListBox->setCurrentItem( 0 ); + if (myListBox->count() > 0) + myListBox->setCurrentItem(0); } else { - setCaption( tr( "EDIT_LIB_TLT" ) ); - if ( myFileName->text().isEmpty() ) - myFileName->setText( getDefaultLibraryName() ); + setCaption(tr("EDIT_LIB_TLT")); + if (myFileName->text().isEmpty()) + myFileName->setText(getDefaultLibraryName()); processNewLibrary(); - if ( myListBox->count() > 0 ) - myListBox->setCurrentItem( 0 ); + if (myListBox->count() > 0) + myListBox->setCurrentItem(0); } - int x, y ; - aModeler->DefineDlgPosition( this, x, y ); - this->move( x, y ); + int x, y; + aModeler->DefineDlgPosition(this, x, y); + this->move(x, y); this->show(); updateMainButtons(); - isPermissionValid( false ); + isPermissionValid(false); } //======================================================================= @@ -356,29 +359,29 @@ void SMESHGUI_FilterLibraryDlg::Init( const QValueList& theTypes, const int //======================================================================= void SMESHGUI_FilterLibraryDlg::updateControlsVisibility() { - if ( myMode == ADD_TO ) + if (myMode == ADD_TO) { myNameGrp->show(); - myNameGrp->setEnabled( true ); + myNameGrp->setEnabled(true); myAddBtn->hide(); myDeleteBtn->hide(); - myTable->SetEditable( false ); + myTable->SetEditable(false); } - else if ( myMode == COPY_FROM ) + else if (myMode == COPY_FROM) { myNameGrp->hide(); - myNameGrp->setEnabled( false ); + myNameGrp->setEnabled(false); myAddBtn->hide(); myDeleteBtn->hide(); - myTable->SetEditable( false ); + myTable->SetEditable(false); } - else if ( myMode == EDIT ) + else if (myMode == EDIT) { myNameGrp->show(); - myNameGrp->setEnabled( true ); + myNameGrp->setEnabled(true); myAddBtn->show(); myDeleteBtn->show(); - myTable->SetEditable( true ); + myTable->SetEditable(true); } qApp->processEvents(); @@ -392,52 +395,46 @@ void SMESHGUI_FilterLibraryDlg::updateControlsVisibility() //======================================================================= bool SMESHGUI_FilterLibraryDlg::onApply() { - if ( !isValid( true ) || !isPermissionValid( false ) ) + if (!isValid(true) || !isPermissionValid(false)) return false; - if ( myLibrary->_is_nil() ) - { - QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), - tr( "SMESH_WRN_WARNING" ), tr( "LIBRARY_IS_NOT_LOADED" ), QMessageBox::Ok ); + if (myLibrary->_is_nil()) { + QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_WRN_WARNING"), + tr("LIBRARY_IS_NOT_LOADED"), QMessageBox::Ok); return false; } const char* aName = myFileName->text().latin1(); - if ( strcmp( myLibrary->GetFileName(), aName ) != 0 ) - myLibrary->SetFileName( aName ); + if (strcmp(myLibrary->GetFileName(), aName) != 0) + myLibrary->SetFileName(aName); bool aResult = false; - if ( myMode == COPY_FROM || myListBox->count() == 0 ) - { + if (myMode == COPY_FROM || myListBox->count() == 0) { aResult = true; - } - else if ( myMode == EDIT || myMode == ADD_TO ) - { + } else if (myMode == EDIT || myMode == ADD_TO) { SMESH::Filter_var aFilter = createFilter(); - if ( !myLibrary->Replace( myCurrFilterName, myName->text(), aFilter.in() ) ) - { - QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), - tr( "SMESH_ERROR" ), tr( "ERROR_OF_EDITING" ), QMessageBox::Ok ); + if (!myLibrary->Replace(myCurrFilterName, myName->text(), aFilter.in())) { + QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_ERROR"), + tr("ERROR_OF_EDITING"), QMessageBox::Ok); aResult = false; } else aResult = true; } - if ( aResult && myMode != COPY_FROM ) + if (aResult && myMode != COPY_FROM) aResult = myLibrary->Save(); - if ( aResult ) - { + if (aResult) { char* aFileName = myLibrary->GetFileName(); - getDefaultLibraryName() = QString( aFileName ); + getDefaultLibraryName() = QString(aFileName); delete aFileName; + } else if (myMode != COPY_FROM) { + QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_ERROR"), + tr("ERROR_OF_SAVING"), QMessageBox::Ok); + } else { } - else if ( myMode != COPY_FROM ) - QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), - tr( "SMESH_ERROR" ), tr( "ERROR_OF_SAVING" ), QMessageBox::Ok ); - return aResult; } @@ -449,10 +446,10 @@ bool SMESHGUI_FilterLibraryDlg::onApply() //======================================================================= void SMESHGUI_FilterLibraryDlg::onOk() { - if ( onApply() ) + if (onApply()) { - disconnect( SMESHGUI::GetSMESHGUI(), 0, this, 0 ); - SMESHGUI::GetSMESHGUI()->ResetState() ; + disconnect(SMESHGUI::GetSMESHGUI(), 0, this, 0); + SMESHGUI::GetSMESHGUI()->ResetState(); accept(); } } @@ -463,9 +460,9 @@ void SMESHGUI_FilterLibraryDlg::onOk() //======================================================================= void SMESHGUI_FilterLibraryDlg::onClose() { - disconnect( SMESHGUI::GetSMESHGUI(), 0, this, 0 ); - SMESHGUI::GetSMESHGUI()->ResetState() ; - reject() ; + disconnect(SMESHGUI::GetSMESHGUI(), 0, this, 0); + SMESHGUI::GetSMESHGUI()->ResetState(); + reject(); } //======================================================================= @@ -474,25 +471,25 @@ void SMESHGUI_FilterLibraryDlg::onClose() //======================================================================= void SMESHGUI_FilterLibraryDlg::onDeactivate() { - setEnabled( false ); + setEnabled(false); } //======================================================================= // name : SMESHGUI_FilterLibraryDlg::enterEvent // Purpose : Event filter //======================================================================= -void SMESHGUI_FilterLibraryDlg::enterEvent( QEvent* ) +void SMESHGUI_FilterLibraryDlg::enterEvent(QEvent*) { - setEnabled( true ); + setEnabled(true); } //================================================================================= // function : closeEvent() // purpose : Close dialog //================================================================================= -void SMESHGUI_FilterLibraryDlg::closeEvent( QCloseEvent* e ) +void SMESHGUI_FilterLibraryDlg::closeEvent(QCloseEvent* e) { - onClose() ; + onClose(); } //======================================================================= @@ -508,20 +505,20 @@ QString SMESHGUI_FilterLibraryDlg::getFileName() const // Function : setFileName // Purpose : Set file name to line edit //================================================================ -void SMESHGUI_FilterLibraryDlg::setFileName( const QString& txt, const bool autoExt ) +void SMESHGUI_FilterLibraryDlg::setFileName(const QString& txt, const bool autoExt) { - if ( myFileName == 0 ) + if (myFileName == 0) return; - myFileName->setText( autoExt ? autoExtension( txt ) : txt ); + myFileName->setText(autoExt ? autoExtension(txt) : txt); } //================================================================ // Function : autoExtension // Purpose : Append extension to the file name //================================================================ -QString SMESHGUI_FilterLibraryDlg::autoExtension( const QString& theFileName ) const +QString SMESHGUI_FilterLibraryDlg::autoExtension(const QString& theFileName) const { - QString anExt = theFileName.section( '.', -1 ); + QString anExt = theFileName.section('.', -1); return anExt != "xml" && anExt != "XML" ? theFileName + ".xml" : theFileName; } @@ -529,19 +526,19 @@ QString SMESHGUI_FilterLibraryDlg::autoExtension( const QString& theFileName ) c // Function : filterWildCards // Purpose : //================================================================ -QStringList SMESHGUI_FilterLibraryDlg::filterWildCards( const QString& theFilter ) const +QStringList SMESHGUI_FilterLibraryDlg::filterWildCards(const QString& theFilter) const { QStringList res; - int b = theFilter.findRev( "(" ); - int e = theFilter.findRev( ")" ); - if ( b != -1 && e != -1 ) + int b = theFilter.findRev("("); + int e = theFilter.findRev(")"); + if (b != -1 && e != -1) { - QString content = theFilter.mid( b + 1, e - b - 1 ).stripWhiteSpace(); - QStringList lst = QStringList::split( " ", content ); - for ( QStringList::const_iterator it = lst.begin(); it != lst.end(); ++it ) - if ( (*it).find( "." ) != -1 ) - res.append( (*it).stripWhiteSpace() ); + QString content = theFilter.mid(b + 1, e - b - 1).stripWhiteSpace(); + QStringList lst = QStringList::split(" ", content); + for (QStringList::const_iterator it = lst.begin(); it != lst.end(); ++it) + if ((*it).find(".") != -1) + res.append((*it).stripWhiteSpace()); } return res; } @@ -553,10 +550,10 @@ QStringList SMESHGUI_FilterLibraryDlg::filterWildCards( const QString& theFilter QStringList SMESHGUI_FilterLibraryDlg::prepareFilters() const { static QStringList aList; - if ( aList.isEmpty() ) + if (aList.isEmpty()) { - aList.append( tr( "XML_FILT" ) ); - //aList.append( tr( "ALL_FILES_FILTER" ) ); + aList.append(tr("XML_FILT")); + //aList.append(tr("ALL_FILES_FILTER")); } return aList; @@ -568,48 +565,49 @@ QStringList SMESHGUI_FilterLibraryDlg::prepareFilters() const //================================================================ void SMESHGUI_FilterLibraryDlg::onBrowse() { - Dialog* aDlg = new Dialog( this, true ); - aDlg->setCaption( tr( "OPEN_LIBRARY" ) ); + Dialog* aDlg = new Dialog(this, true); + aDlg->setCaption(tr("OPEN_LIBRARY")); - aDlg->setMode( myMode == COPY_FROM ? QFileDialogP::ExistingFile : QFileDialogP::AnyFile ); - aDlg->setFilters( prepareFilters() ); - aDlg->setSelection( getFileName() ); + //aDlg->setMode(myMode == COPY_FROM ? QFileDialogP::ExistingFile : QFileDialogP::AnyFile); + aDlg->setMode(myMode == COPY_FROM ? QFileDialog::ExistingFile : QFileDialog::AnyFile); + aDlg->setFilters(prepareFilters()); + aDlg->setSelection(getFileName()); - QPushButton* anOkBtn = ( QPushButton* )aDlg->child( "OK", "QPushButton" ); - if ( anOkBtn != 0 ) - anOkBtn->setText( tr( "SMESH_BUT_OK" ) ); + QPushButton* anOkBtn = (QPushButton*)aDlg->child("OK", "QPushButton"); + if (anOkBtn != 0) + anOkBtn->setText(tr("SMESH_BUT_OK")); - if ( aDlg->exec() != Accepted ) + if (aDlg->exec() != Accepted) return; QString fName = aDlg->selectedFile(); - if ( fName.isEmpty() ) + if (fName.isEmpty()) return; - if ( QFileInfo( fName ).extension().isEmpty() ) - fName = autoExtension( fName ); + if (QFileInfo(fName).extension().isEmpty()) + fName = autoExtension(fName); - fName = QDir::convertSeparators( fName ); - QString prev = QDir::convertSeparators( getFileName() ); + fName = QDir::convertSeparators(fName); + QString prev = QDir::convertSeparators(getFileName()); - if ( prev == fName ) + if (prev == fName) return; - setFileName( fName ); + setFileName(fName); - QString aName = myListBox->text( myListBox->count() - 1 ); + QString aName = myListBox->text(myListBox->count() - 1); processNewLibrary(); - if ( myMode == ADD_TO ) + if (myMode == ADD_TO) { - myTable->Copy( (SMESHGUI_FilterTable*)parentWidget() ); + myTable->Copy((SMESHGUI_FilterTable*)parentWidget()); myCurrFilterName = ""; myCurrFilter = -1; - addFilterToLib( aName ); + addFilterToLib(aName); } - isPermissionValid( false ); + isPermissionValid(false); } //======================================================================= @@ -619,22 +617,18 @@ void SMESHGUI_FilterLibraryDlg::onBrowse() void SMESHGUI_FilterLibraryDlg::processNewLibrary() { SMESH::FilterManager_var aFilterMgr = SMESH::GetFilterManager(); - if ( aFilterMgr->_is_nil() ) + if (aFilterMgr->_is_nil()) return; - myLibrary = aFilterMgr->LoadLibrary( autoExtension( getFileName() ) ); - if ( myLibrary->_is_nil() ) - { - if ( myMode == COPY_FROM ) - { - QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), - tr( "SMESH_ERROR" ), tr( "ERROR_LOAD" ), QMessageBox::Ok ); + myLibrary = aFilterMgr->LoadLibrary(autoExtension(getFileName())); + if (myLibrary->_is_nil()) { + if (myMode == COPY_FROM) { + QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_ERROR"), + tr("ERROR_LOAD"), QMessageBox::Ok); return; - } - else - { + } else { myLibrary = aFilterMgr->CreateLibrary(); - myLibrary->SetFileName( getFileName().latin1() ); + myLibrary->SetFileName(getFileName().latin1()); } } @@ -648,26 +642,26 @@ void SMESHGUI_FilterLibraryDlg::processNewLibrary() void SMESHGUI_FilterLibraryDlg::updateList() { QStringList aList; - SMESH::string_array_var aNames = myLibrary->GetNames( (SMESH::ElementType)myTable->GetType() ); - for ( int i = 0, n = aNames->length(); i < n; i++ ) - aList.append( QString( aNames[ i ] ) ); + SMESH::string_array_var aNames = myLibrary->GetNames((SMESH::ElementType)myTable->GetType()); + for (int i = 0, n = aNames->length(); i < n; i++) + aList.append(QString(aNames[ i ])); myListBox->clear(); - myListBox->insertStringList( aList ); - if ( myListBox->count() == 0 ) + myListBox->insertStringList(aList); + if (myListBox->count() == 0) { - myTable->Clear( myTable->GetType() ); + myTable->Clear(myTable->GetType()); myName->clear(); - myName->setEnabled( false ); - myTable->SetEnabled( false ); + myName->setEnabled(false); + myTable->SetEnabled(false); } else { - myName->setEnabled( true ); - myTable->SetEnabled( true ); - if ( myListBox->count() ) + myName->setEnabled(true); + myTable->SetEnabled(true); + if (myListBox->count()) { myCurrFilterName = ""; - myListBox->setCurrentItem( 0 ); + myListBox->setCurrentItem(0); } } } @@ -676,28 +670,24 @@ void SMESHGUI_FilterLibraryDlg::updateList() // name : SMESHGUI_FilterLibraryDlg::isNameValid // Purpose : Verify validity if entered data //======================================================================= -bool SMESHGUI_FilterLibraryDlg::isNameValid( const bool theMess ) const +bool SMESHGUI_FilterLibraryDlg::isNameValid(const bool theMess) const { // verify validity of filter name - if ( myName->isEnabled() && !myCurrFilterName.isEmpty() ) - { + if (myName->isEnabled() && !myCurrFilterName.isEmpty()) { QString aCurrName = myName->text(); - if ( aCurrName.isEmpty() ) - { - if ( theMess ) - QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), - tr( "SMESH_INSUFFICIENT_DATA" ), tr( "EMPTY_FILTER_NAME" ), QMessageBox::Ok ); + if (aCurrName.isEmpty()) { + if (theMess) + QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"), + tr("EMPTY_FILTER_NAME"), QMessageBox::Ok); return false; } SMESH::string_array_var aNames = myLibrary->GetAllNames(); - for ( int f = 0, n = aNames->length(); f < n; f++ ) - { - if ( aNames[ f ] == aCurrName && aNames[ f ] != myCurrFilterName ) - { - if ( theMess ) - QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), - tr( "SMESH_INSUFFICIENT_DATA" ), tr( "ERROR_FILTER_NAME" ), QMessageBox::Ok ); + for (int f = 0, n = aNames->length(); f < n; f++) { + if (aNames[ f ] == aCurrName && aNames[ f ] != myCurrFilterName) { + if (theMess) + QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"), + tr("ERROR_FILTER_NAME"), QMessageBox::Ok); return false; } } @@ -710,44 +700,42 @@ bool SMESHGUI_FilterLibraryDlg::isNameValid( const bool theMess ) const // name : SMESHGUI_FilterLibraryDlg::isPermissionValid // Purpose : Verify write permission on file //======================================================================= -bool SMESHGUI_FilterLibraryDlg::isPermissionValid( const bool theIsExistingOnly ) +bool SMESHGUI_FilterLibraryDlg::isPermissionValid(const bool theIsExistingOnly) { - if ( myMode == COPY_FROM ) + if (myMode == COPY_FROM) return true; - + // Verify write permission bool isWritable = false; - QString fName( myFileName->text() ); - if ( QFileInfo( fName ).extension().isEmpty() ) - fName = autoExtension( fName ); + QString fName(myFileName->text()); + if (QFileInfo(fName).extension().isEmpty()) + fName = autoExtension(fName); - fName = QDir::convertSeparators( fName ); + fName = QDir::convertSeparators(fName); - if ( QFileInfo( fName ).exists() ) - isWritable = QFileInfo( fName ).isWritable(); - else if ( !theIsExistingOnly ) - { - QFileInfo aDirInfo( QFileInfo( fName ).dirPath( true ) ); + if (QFileInfo(fName).exists()) { + isWritable = QFileInfo(fName).isWritable(); + } else if (!theIsExistingOnly) { + QFileInfo aDirInfo(QFileInfo(fName).dirPath(true)); isWritable = aDirInfo.isWritable(); - /*if ( QDir( QFileInfo( fName ).dirPath( true ) ).exists() || - QDir().mkdir( QFileInfo( fName ).dirPath( true ) ) ) + /*if (QDir(QFileInfo(fName).dirPath(true)).exists() || + QDir().mkdir(QFileInfo(fName).dirPath(true))) { - QFile aFile( fName ); - if ( aFile.open( IO_WriteOnly ) ) + QFile aFile(fName); + if (aFile.open(IO_WriteOnly)) isWritable = true; else aFile.close(); } */ - } - else + } else { isWritable = true; + } - if ( !isWritable ) - { - QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), - tr( "SMESH_WRN_WARNING" ), tr( "NO_PERMISSION" ), QMessageBox::Ok ); + if (!isWritable) { + QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_WRN_WARNING"), + tr("NO_PERMISSION"), QMessageBox::Ok); return false; } @@ -758,10 +746,10 @@ bool SMESHGUI_FilterLibraryDlg::isPermissionValid( const bool theIsExistingOnly // name : SMESHGUI_FilterLibraryDlg::isValid // Purpose : Verify validity if entered data //======================================================================= -bool SMESHGUI_FilterLibraryDlg::isValid( const bool theMess ) const +bool SMESHGUI_FilterLibraryDlg::isValid(const bool theMess) const { // verify validity of table - if ( !myTable->IsValid( theMess ) || !isNameValid( theMess ) ) + if (!myTable->IsValid(theMess) || !isNameValid(theMess)) return false; else return true; @@ -771,44 +759,44 @@ bool SMESHGUI_FilterLibraryDlg::isValid( const bool theMess ) const // name : SMESHGUI_FilterLibraryDlg::onFilterChanged // Purpose : SLOT. Called when selected filter of library changed //======================================================================= -void SMESHGUI_FilterLibraryDlg::onFilterChanged( const QString& theName ) +void SMESHGUI_FilterLibraryDlg::onFilterChanged(const QString& theName) { - if ( myLibrary->_is_nil() ) + if (myLibrary->_is_nil()) return; // Save parameters of filter if it was changed - if ( !myCurrFilterName.isEmpty() && myTable->IsEditable() ) + if (!myCurrFilterName.isEmpty() && myTable->IsEditable()) { - if ( !isValid( true ) ) + if (!isValid(true)) { - myListBox->blockSignals( true ); - myListBox->setCurrentItem( myCurrFilter ); - myListBox->blockSignals( false ); + myListBox->blockSignals(true); + myListBox->setCurrentItem(myCurrFilter); + myListBox->blockSignals(false); return; } SMESH::Filter_var aFilter = createFilter(); - myLibrary->Replace( myCurrFilterName.latin1(), myName->text().latin1(), aFilter ); + myLibrary->Replace(myCurrFilterName.latin1(), myName->text().latin1(), aFilter); } // Fill table with filter parameters - SMESH::Filter_var aFilter = myLibrary->Copy( theName ); + SMESH::Filter_var aFilter = myLibrary->Copy(theName); myCurrFilterName = theName; myCurrFilter = myListBox->currentItem(); - myName->setText( theName ); + myName->setText(theName); + - SMESH::Filter::Criteria_var aCriteria; - myTable->Clear( myTable->GetType() ); + myTable->Clear(myTable->GetType()); - if ( !aFilter->GetCriteria( aCriteria ) ) + if (!aFilter->GetCriteria(aCriteria)) return; - for ( int i = 0, n = aCriteria->length(); i < n; i++ ) - myTable->AddCriterion( aCriteria[ i ], myTable->GetType() ); + for (int i = 0, n = aCriteria->length(); i < n; i++) + myTable->AddCriterion(aCriteria[ i ], myTable->GetType()); myTable->Update(); } @@ -820,19 +808,19 @@ void SMESHGUI_FilterLibraryDlg::onFilterChanged( const QString& theName ) //======================================================================= void SMESHGUI_FilterLibraryDlg::onReturnPressed() { - QString aName = myListBox->text( myListBox->count() - 1 ); - + QString aName = myListBox->text(myListBox->count() - 1); + processNewLibrary(); - if ( myMode == ADD_TO ) + if (myMode == ADD_TO) { - myTable->Copy( (SMESHGUI_FilterTable*)parentWidget() ); + myTable->Copy((SMESHGUI_FilterTable*)parentWidget()); myCurrFilterName = ""; myCurrFilter = -1; - addFilterToLib( aName ); + addFilterToLib(aName); } - isPermissionValid( false ); + isPermissionValid(false); } //======================================================================= @@ -841,15 +829,15 @@ void SMESHGUI_FilterLibraryDlg::onReturnPressed() //======================================================================= void SMESHGUI_FilterLibraryDlg::enableMainButtons() { - /*bool isEnabled = isValid( false ); - if ( myButtons.contains( BTN_OK ) ) - myButtons[ BTN_OK ]->setEnabled( isEnabled ); - else if ( myButtons.contains( BTN_Apply ) ) - myButtons[ BTN_OK ]->setEnabled( isEnabled ); - if ( myButtons.contains( BTN_Cancel ) ) - myButtons[ BTN_Cancel ]->setEnabled( isEnabled ); - else if ( myButtons.contains( BTN_Close ) ) - myButtons[ BTN_Cancel ]->setEnabled( isEnabled ); + /*bool isEnabled = isValid(false); + if (myButtons.contains(BTN_OK)) + myButtons[ BTN_OK ]->setEnabled(isEnabled); + else if (myButtons.contains(BTN_Apply)) + myButtons[ BTN_OK ]->setEnabled(isEnabled); + if (myButtons.contains(BTN_Cancel)) + myButtons[ BTN_Cancel ]->setEnabled(isEnabled); + else if (myButtons.contains(BTN_Close)) + myButtons[ BTN_Cancel ]->setEnabled(isEnabled); */ } @@ -857,23 +845,23 @@ void SMESHGUI_FilterLibraryDlg::enableMainButtons() // name : SMESHGUI_FilterLibraryDlg::createFilter // Purpose : Cerate filter in accordance with library //======================================================================= -SMESH::Filter_ptr SMESHGUI_FilterLibraryDlg::createFilter( const int theType ) +SMESH::Filter_ptr SMESHGUI_FilterLibraryDlg::createFilter(const int theType) { - int n = myTable->NumRows( theType ); + int n = myTable->NumRows(theType); SMESH::Filter::Criteria_var aCriteria = new SMESH::Filter::Criteria; - aCriteria->length( n ); + aCriteria->length(n); - for ( int i = 0; i < n; i++ ) + for (int i = 0; i < n; i++) { SMESH::Filter::Criterion aCriterion = SMESHGUI_FilterDlg::createCriterion(); - myTable->GetCriterion( i, aCriterion ); + myTable->GetCriterion(i, aCriterion); aCriteria[ i ] = aCriterion; } SMESH::FilterManager_var aFilterMgr = SMESH::GetFilterManager(); SMESH::Filter_var aFilter = aFilterMgr->CreateFilter(); - aFilter->SetCriteria( aCriteria.inout() ); + aFilter->SetCriteria(aCriteria.inout()); return aFilter._retn(); } @@ -886,29 +874,28 @@ SMESH::Filter_ptr SMESHGUI_FilterLibraryDlg::createFilter( const int theType ) void SMESHGUI_FilterLibraryDlg::onAddBtnPressed() { // Save parameters of filter if it was changed - if ( !myCurrFilterName.isEmpty() && myTable->IsEditable() ) + if (!myCurrFilterName.isEmpty() && myTable->IsEditable()) { - if ( !isValid( true ) ) + if (!isValid(true)) return; SMESH::Filter_var aFilter = createFilter(); - myLibrary->Replace( myCurrFilterName.latin1(), myName->text().latin1(), aFilter ); + myLibrary->Replace(myCurrFilterName.latin1(), myName->text().latin1(), aFilter); } - addFilterToLib( getDefaultFilterName() ); + addFilterToLib(getDefaultFilterName()); } //======================================================================= -// name : SMESHGUI_FilterLibraryDlg::onAddBtnPressed +// name : onAddBtnPressed() // Purpose : SLOT. Called when "Add" button pressed // Add new filter to the end of library //======================================================================= -void SMESHGUI_FilterLibraryDlg::addFilterToLib( const QString& theName ) +void SMESHGUI_FilterLibraryDlg::addFilterToLib (const QString& theName) { - if ( myLibrary->_is_nil() ) - { - QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), - tr( "SMESH_WRN_WARNING" ), tr( "LIBRARY_IS_NOT_LOADED" ), QMessageBox::Ok ); + if (myLibrary->_is_nil()) { + QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_WRN_WARNING"), + tr("LIBRARY_IS_NOT_LOADED"), QMessageBox::Ok); return; } @@ -916,10 +903,10 @@ void SMESHGUI_FilterLibraryDlg::addFilterToLib( const QString& theName ) SMESH::Filter_var aFilter = createFilter(); // if name of filter already exist in the library assign default name for the filter - QString aName( theName ); + QString aName(theName); SMESH::string_array_var aNames = myLibrary->GetAllNames(); - for ( int i = 0, n = aNames->length(); i < n; i++ ) - if ( aName == QString( aNames[ i ] ) ) + for (int i = 0, n = aNames->length(); i < n; i++) + if (aName == QString(aNames[ i ])) { aName = getDefaultFilterName(); break; @@ -927,23 +914,22 @@ void SMESHGUI_FilterLibraryDlg::addFilterToLib( const QString& theName ) // add new filter in library bool aResult = !aFilter->GetPredicate()->_is_nil() - ? myLibrary->Add( aName.latin1(), aFilter ) - : myLibrary->AddEmpty( aName.latin1(), (SMESH::ElementType)myTable->GetType() ); - - if ( !aResult ) - { - QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), - tr( "SMESH_ERROR" ), tr( "ERROR_OF_ADDING" ), QMessageBox::Ok ); + ? myLibrary->Add(aName.latin1(), aFilter) + : myLibrary->AddEmpty(aName.latin1(), (SMESH::ElementType)myTable->GetType()); + + if (!aResult) { + QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_ERROR"), + tr("ERROR_OF_ADDING"), QMessageBox::Ok); } updateList(); myCurrFilterName = ""; myCurrFilter = -1; - setSelected( aName ); + setSelected(aName); - if ( theName != aName ) - QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), tr( "SMESH_WARNING" ), - tr( "ASSIGN_NEW_NAME" ).arg( theName ).arg( aName ) , QMessageBox::Ok ); + if (theName != aName) + QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_WARNING"), + tr("ASSIGN_NEW_NAME").arg(theName).arg(aName), QMessageBox::Ok); } //======================================================================= @@ -953,10 +939,10 @@ void SMESHGUI_FilterLibraryDlg::addFilterToLib( const QString& theName ) QString& SMESHGUI_FilterLibraryDlg::getDefaultLibraryName() const { static QString aName; - if ( aName.isEmpty() ) + if (aName.isEmpty()) { - QString aHomeDir = QDir( QDir::home() ).absPath(); - aName = aHomeDir + "/" + tr ( "LIB_NAME" ); + QString aHomeDir = QDir(QDir::home()).absPath(); + aName = aHomeDir + "/" + tr ("LIB_NAME"); } return aName; } @@ -969,35 +955,35 @@ QString SMESHGUI_FilterLibraryDlg::getDefaultFilterName() const { QString aName; - if ( myTable->GetType() == SMESH::NODE ) - aName = tr( "NODE" ); - else if ( myTable->GetType() == SMESH::EDGE ) - aName = tr( "EDGE" ); - else if ( myTable->GetType() == SMESH::FACE ) - aName = tr( "FACE" ); - else if ( myTable->GetType() == SMESH::VOLUME ) - aName = tr( "VOLUME" ); - else if ( myTable->GetType() == SMESH::ALL ) - aName = tr( "ELEMENT" ); - else - aName = tr( "SELECTION" ); + if (myTable->GetType() == SMESH::NODE) + aName = tr("NODE"); + else if (myTable->GetType() == SMESH::EDGE) + aName = tr("EDGE"); + else if (myTable->GetType() == SMESH::FACE) + aName = tr("FACE"); + else if (myTable->GetType() == SMESH::VOLUME) + aName = tr("VOLUME"); + else if (myTable->GetType() == SMESH::ALL) + aName = tr("ELEMENT"); + else + aName = tr("SELECTION"); - aName += tr( "FILTER" ); + aName += tr("FILTER"); QMap< QString, int > anAllNames; SMESH::string_array_var aNames = myLibrary->GetAllNames(); - for( int i = 0, n = aNames->length(); i < n; i++ ) - anAllNames[ QString( aNames[ i ] ) ] = -1; + for(int i = 0, n = aNames->length(); i < n; i++) + anAllNames[ QString(aNames[ i ]) ] = -1; bool isNotValid = true; int k = 1; QString aNewName; - while ( isNotValid ) + while (isNotValid) { isNotValid = false; - aNewName = aName + "_" + QString( "%1" ).arg( k ); - if ( anAllNames.contains( aNewName ) ) + aNewName = aName + "_" + QString("%1").arg(k); + if (anAllNames.contains(aNewName)) { isNotValid = true; k++; @@ -1011,12 +997,12 @@ QString SMESHGUI_FilterLibraryDlg::getDefaultFilterName() const // name : SMESHGUI_FilterLibraryDlg::setSelected // Purpose : set selected item in list box containing filters //======================================================================= -bool SMESHGUI_FilterLibraryDlg::setSelected( const QString& theName ) +bool SMESHGUI_FilterLibraryDlg::setSelected(const QString& theName) { - int anIndex = getIndex( theName ); - if ( anIndex != -1 ) + int anIndex = getIndex(theName); + if (anIndex != -1) { - myListBox->setCurrentItem( anIndex ); + myListBox->setCurrentItem(anIndex); myCurrFilterName = theName; myCurrFilter = anIndex; } @@ -1027,10 +1013,10 @@ bool SMESHGUI_FilterLibraryDlg::setSelected( const QString& theName ) // name : SMESHGUI_FilterLibraryDlg::getIndex // Purpose : Get index of the filter in list box //======================================================================= -int SMESHGUI_FilterLibraryDlg::getIndex( const QString& theName ) const +int SMESHGUI_FilterLibraryDlg::getIndex(const QString& theName) const { - for ( int i = 0, n = myListBox->count(); i < n; i++ ) - if ( myListBox->text( i ) == theName) + for (int i = 0, n = myListBox->count(); i < n; i++) + if (myListBox->text(i) == theName) return i; return -1; } @@ -1041,67 +1027,62 @@ int SMESHGUI_FilterLibraryDlg::getIndex( const QString& theName ) const //======================================================================= void SMESHGUI_FilterLibraryDlg::onDeleteBtnPressed() { - if ( myLibrary->_is_nil() ) - { - QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), - tr( "SMESH_WRN_WARNING" ), tr( "LIBRARY_IS_NOT_LOADED" ), QMessageBox::Ok ); + if (myLibrary->_is_nil()) { + QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_WRN_WARNING"), + tr("LIBRARY_IS_NOT_LOADED"), QMessageBox::Ok); return; } - int anIndex = getIndex( myCurrFilterName ); + int anIndex = getIndex(myCurrFilterName); - if ( anIndex == -1 || !myLibrary->Delete( myCurrFilterName.latin1() ) ) - { - QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), - tr( "SMESH_ERROR" ), tr( "ERROR_OF_DELETING" ), QMessageBox::Ok ); - } - else - { + if (anIndex == -1 || !myLibrary->Delete(myCurrFilterName.latin1())) { + QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_ERROR"), + tr("ERROR_OF_DELETING"), QMessageBox::Ok); + } else { myCurrFilterName = ""; myCurrFilterName = -1; - myListBox->removeItem( anIndex ); - - if ( anIndex >= 1 ) - myListBox->setSelected( anIndex - 1, true ); - else if ( anIndex == 0 && myListBox->count() > 0 ) - myListBox->setSelected( 0, true ); + myListBox->removeItem(anIndex); + + if (anIndex >= 1) + myListBox->setSelected(anIndex - 1, true); + else if (anIndex == 0 && myListBox->count() > 0) + myListBox->setSelected(0, true); else myTable->Clear(); } - myTable->SetEnabled( myListBox->count() > 0 ); - if ( myListBox->count() == 0 ) - { - myName->setText( "" ); - myName->setEnabled( false ); + myTable->SetEnabled(myListBox->count() > 0); + if (myListBox->count() == 0) { + myName->setText(""); + myName->setEnabled(false); } } //======================================================================= -// name : SMESHGUI_FilterLibraryDlg::onFilterNameChanged +// name : onFilterNameChanged() // Purpose : SLOT. Called when name of filter changed // Change filter name in list box //======================================================================= -void SMESHGUI_FilterLibraryDlg::onFilterNameChanged( const QString& theName ) +void SMESHGUI_FilterLibraryDlg::onFilterNameChanged (const QString& theName) { int aCurrItem = myListBox->currentItem(); - if ( aCurrItem == -1 ) + if (aCurrItem == -1) return; - myListBox->blockSignals( true ); - myListBox->changeItem( theName, aCurrItem ); - myListBox->blockSignals( false ); + myListBox->blockSignals(true); + myListBox->changeItem(theName, aCurrItem); + myListBox->blockSignals(false); } //======================================================================= // name : SMESHGUI_FilterLibraryDlg::SetTable // Purpose : Set table //======================================================================= -void SMESHGUI_FilterLibraryDlg::SetTable( const SMESHGUI_FilterTable* theTable ) +void SMESHGUI_FilterLibraryDlg::SetTable(const SMESHGUI_FilterTable* theTable) { - myTable->Copy( theTable ); - myName->setText( getDefaultFilterName() ); - addFilterToLib( myName->text() ); + myTable->Copy(theTable); + myName->setText(getDefaultFilterName()); + addFilterToLib(myName->text()); myTable->Update(); } @@ -1119,41 +1100,34 @@ const SMESHGUI_FilterTable* SMESHGUI_FilterLibraryDlg::GetTable() const // name : SMESHGUI_FilterLibraryDlg::onEntityTypeChanged // Purpose : SLOT. Called when entiyt type changed //======================================================================= -void SMESHGUI_FilterLibraryDlg::onEntityTypeChanged( const int theType ) +void SMESHGUI_FilterLibraryDlg::onEntityTypeChanged(const int theType) { - if ( myLibrary->_is_nil() ) + if (myLibrary->_is_nil()) return; myName->clear(); myCurrFilterName = ""; myCurrFilter = -1; updateList(); - if ( myListBox->count() ) - myListBox->setCurrentItem( 0 ); + if (myListBox->count()) + myListBox->setCurrentItem(0); } //======================================================================= // name : SMESHGUI_FilterLibraryDlg::onNeedValidation -// Purpose : +// Purpose : //======================================================================= void SMESHGUI_FilterLibraryDlg::onNeedValidation() { - if ( !myCurrFilterName.isEmpty() ) + if (!myCurrFilterName.isEmpty()) { - bool valid = isValid( true ); - myTable->SetValidity( valid ); + bool valid = isValid(true); + myTable->SetValidity(valid); - if ( valid ) + if (valid) { - SMESH::Filter_var aFilter = createFilter( myTable->GetType() ); - myLibrary->Replace( myCurrFilterName.latin1(), myName->text().latin1(), aFilter ); + SMESH::Filter_var aFilter = createFilter(myTable->GetType()); + myLibrary->Replace(myCurrFilterName.latin1(), myName->text().latin1(), aFilter); } } } - - - - - - - diff --git a/src/SMESHGUI/SMESHGUI_FilterUtils.cxx b/src/SMESHGUI/SMESHGUI_FilterUtils.cxx index 4b0ae92de..f02434220 100644 --- a/src/SMESHGUI/SMESHGUI_FilterUtils.cxx +++ b/src/SMESHGUI/SMESHGUI_FilterUtils.cxx @@ -1,37 +1,31 @@ // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org #include "SMESHGUI_FilterUtils.h" -#include "SMESHGUI_SMESHGenUtils.h" +#include "SMESHGUI.h" namespace SMESH { - SMESH::FilterManager_var GetFilterManager() { - static SMESH::FilterManager_var aFilterManager; - if(CORBA::is_nil(aFilterManager)){ - aFilterManager = GetSMESHGen()->CreateFilterManager(); - } - return aFilterManager; + return SMESHGUI::GetSMESHGen()->CreateFilterManager(); // DumpPython } - } diff --git a/src/SMESHGUI/SMESHGUI_GEOMGenUtils.cxx b/src/SMESHGUI/SMESHGUI_GEOMGenUtils.cxx index a7dc4011b..c9ffc82e6 100644 --- a/src/SMESHGUI/SMESHGUI_GEOMGenUtils.cxx +++ b/src/SMESHGUI/SMESHGUI_GEOMGenUtils.cxx @@ -1,48 +1,52 @@ // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org - -#include "QAD_Desktop.h" +#include #include "SMESHGUI_GEOMGenUtils.h" #include "SMESHGUI_Utils.h" + +#include + +#include +#include +#include + #include CORBA_CLIENT_HEADER(SMESH_Mesh) -namespace SMESH{ + +namespace SMESH { GEOM::GEOM_Gen_var GetGEOMGen() { static GEOM::GEOM_Gen_var aGEOMGen; - if(CORBA::is_nil(aGEOMGen)){ - if(QAD_Desktop* aDesktop = QAD_Application::getDesktop()){ - Engines::Component_var aComponent = aDesktop->getEngine("FactoryServer","GEOM"); - aGEOMGen = GEOM::GEOM_Gen::_narrow(aComponent); - } - } + + if(CORBA::is_nil(aGEOMGen)) + aGEOMGen = GeometryGUI::GetGeomGen(); return aGEOMGen; } - - GEOM::GEOM_Object_var GetShapeOnMeshOrSubMesh(SALOMEDS::SObject_ptr theMeshOrSubmesh) + GEOM::GEOM_Object_var GetShapeOnMeshOrSubMesh(_PTR(SObject) theMeshOrSubmesh) { - if(!theMeshOrSubmesh->_is_nil()) { - CORBA::Object_var Obj = theMeshOrSubmesh->GetObject(); + SALOMEDS_SObject* aMeshOrSubmesh = _CAST(SObject,theMeshOrSubmesh); + if(aMeshOrSubmesh) { + CORBA::Object_var Obj = aMeshOrSubmesh->GetObject(); if ( !CORBA::is_nil( Obj ) ) { SMESH::SMESH_Mesh_var aMesh = SObjectToInterface( theMeshOrSubmesh ); @@ -57,4 +61,32 @@ namespace SMESH{ return GEOM::GEOM_Object::_nil(); } + GEOM::GEOM_Object_ptr GetGeom (_PTR(SObject) theSO) + { + if (!theSO) + return GEOM::GEOM_Object::_nil(); + + _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); + if (!aStudy) + return GEOM::GEOM_Object::_nil(); + + _PTR(ChildIterator) anIter (aStudy->NewChildIterator(theSO)); + for (; anIter->More(); anIter->Next()) { + _PTR(SObject) aSObject = anIter->Value(); + _PTR(SObject) aRefSOClient; + GEOM::GEOM_Object_var aMeshShape; + + if (aSObject->ReferencedObject(aRefSOClient)) { + SALOMEDS_SObject* aRefSO = _CAST(SObject,aRefSOClient); + aMeshShape = GEOM::GEOM_Object::_narrow(aRefSO->GetObject()); + } else { + SALOMEDS_SObject* aSO = _CAST(SObject,aSObject); + aMeshShape = GEOM::GEOM_Object::_narrow(aSO->GetObject()); + } + + if (!aMeshShape->_is_nil()) + return aMeshShape._retn(); + } + return GEOM::GEOM_Object::_nil(); + } } diff --git a/src/SMESHGUI/SMESHGUI_GEOMGenUtils.h b/src/SMESHGUI/SMESHGUI_GEOMGenUtils.h index ebc0a43e9..6f2ccb9b3 100644 --- a/src/SMESHGUI/SMESHGUI_GEOMGenUtils.h +++ b/src/SMESHGUI/SMESHGUI_GEOMGenUtils.h @@ -10,7 +10,7 @@ // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. -// +// // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA @@ -22,17 +22,18 @@ #include "SALOMEconfig.h" #include CORBA_SERVER_HEADER(GEOM_Gen) -#include CORBA_CLIENT_HEADER(SALOMEDS) +#include "SALOMEDSClient_definitions.hxx" + +class SALOMEDSClient_SObject; namespace SMESH { - GEOM::GEOM_Gen_var GetGEOMGen(); - GEOM::GEOM_Object_var GetShapeOnMeshOrSubMesh(SALOMEDS::SObject_ptr theSObject); + GEOM::GEOM_Object_var GetShapeOnMeshOrSubMesh (_PTR(SObject) theSObject); + GEOM::GEOM_Object_ptr GetGeom (_PTR(SObject) theSO); } - #endif diff --git a/src/SMESHGUI/SMESHGUI_GroupDlg.cxx b/src/SMESHGUI/SMESHGUI_GroupDlg.cxx index 457cfecd3..5f7b9da9d 100644 --- a/src/SMESHGUI/SMESHGUI_GroupDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_GroupDlg.cxx @@ -1,23 +1,23 @@ // SMESH SMESHGUI : GUI for SMESH component // // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org or email : webmaster.salome@opencascade.org +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org or email : webmaster.salome@opencascade.org // // // @@ -28,7 +28,6 @@ #include "SMESHGUI_GroupDlg.h" #include "SMESHGUI_FilterDlg.h" -#include "SMESHGUI_Filter.h" #include "SMESHGUI.h" #include "SMESHGUI_Utils.h" @@ -38,18 +37,25 @@ #include "SMESHGUI_FilterUtils.h" #include "SMESHGUI_GEOMGenUtils.h" -#include "SALOMEGUI_QtCatchCorbaException.hxx" +#include "SMESH_TypeFilter.hxx" +#include "SMESH_Actor.h" +#include "GEOMBase.h" + +#include "SUIT_Desktop.h" +#include "SUIT_ResourceMgr.h" + +#include "SalomeApp_Tools.h" +#include "SALOMEDSClient_Study.hxx" +#include "SALOME_ListIO.hxx" #include "SALOME_ListIteratorOfListIO.hxx" -#include "VTKViewer_ViewFrame.h" -#include "QAD_Application.h" -#include "QAD_Desktop.h" -#include "QAD_MessageBox.h" -#include "QAD_RightFrame.h" + +#include "SVTK_ViewWindow.h" +#include "SVTK_Selector.h" + #include "utilities.h" -#include "SMESH_Actor.h" - -#include "GEOMBase.h" +// OCCT Includes +#include // QT Includes #include @@ -74,15 +80,20 @@ using namespace std; //================================================================================= -// class : SMESHGUI_GroupDlg() -// purpose : +// function : SMESHGUI_GroupDlg() +// purpose : //================================================================================= -SMESHGUI_GroupDlg::SMESHGUI_GroupDlg( QWidget* parent, const char* name, SALOME_Selection* theSel, - SMESH::SMESH_Mesh_ptr theMesh, bool modal, WFlags fl ) - : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose ) +SMESHGUI_GroupDlg::SMESHGUI_GroupDlg( SMESHGUI* theModule, const char* name, + SMESH::SMESH_Mesh_ptr theMesh, bool modal, WFlags fl) + : QDialog( SMESH::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder | + WStyle_Title | WStyle_SysMenu | WDestructiveClose), + mySMESHGUI( theModule ), + mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ), + myViewWindow( SMESH::GetViewWindow( theModule ) ), + mySelector( myViewWindow->GetSelector() ) { - if ( !name ) setName( "SMESHGUI_GroupDlg" ); - initDialog(theSel, true); + if (!name) setName("SMESHGUI_GroupDlg"); + initDialog(true); if (!theMesh->_is_nil()) init(theMesh); else { @@ -91,49 +102,62 @@ SMESHGUI_GroupDlg::SMESHGUI_GroupDlg( QWidget* parent, const char* name, SALOME_ myGeomGroupBtn->setEnabled(false); myGeomGroupLine->setEnabled(false); } - + /* Move widget on the botton right corner of main widget */ int x, y ; mySMESHGUI->DefineDlgPosition(this, x, y); this->move(x, y); } -SMESHGUI_GroupDlg::SMESHGUI_GroupDlg( QWidget* parent, const char* name, SALOME_Selection* theSel, - SMESH::SMESH_Group_ptr theGroup, bool modal, WFlags fl ) - : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose ) +//================================================================================= +// function : SMESHGUI_GroupDlg() +// purpose : +//================================================================================= +SMESHGUI_GroupDlg::SMESHGUI_GroupDlg( SMESHGUI* theModule, const char* name, + SMESH::SMESH_Group_ptr theGroup, bool modal, WFlags fl) + : QDialog( SMESH::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder | + WStyle_Title | WStyle_SysMenu | WDestructiveClose), + mySMESHGUI( theModule ), + mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ), + myViewWindow( SMESH::GetViewWindow( theModule ) ), + mySelector( myViewWindow->GetSelector() ) { - if ( !name ) setName( "SMESHGUI_GroupDlg" ); - initDialog(theSel, false); + if (!name) setName("SMESHGUI_GroupDlg"); + initDialog(false); if (!theGroup->_is_nil()) init(theGroup); else { mySelectSubMesh->setEnabled(false); mySelectGroup->setEnabled(false); } - + /* Move widget on the botton right corner of main widget */ int x, y ; mySMESHGUI->DefineDlgPosition(this, x, y); this->move(x, y); } -void SMESHGUI_GroupDlg::initDialog(SALOME_Selection* theSel, bool create) +//================================================================================= +// function : SMESHGUI_GroupDlg() +// purpose : +//================================================================================= +void SMESHGUI_GroupDlg::initDialog(bool create) { myFilterDlg = 0; myCreate = create; myCurrentLineEdit = 0; - - QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SELECT"))); + + QPixmap image0 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT"))); if (create) - setCaption( tr( "SMESH_CREATE_GROUP_TITLE" ) ); + setCaption(tr("SMESH_CREATE_GROUP_TITLE")); else - setCaption( tr( "SMESH_EDIT_GROUP_TITLE" ) ); - - setSizeGripEnabled( TRUE ); + setCaption(tr("SMESH_EDIT_GROUP_TITLE")); + + setSizeGripEnabled(TRUE); QGridLayout* aMainLayout = new QGridLayout(this, 7, 3, 11, 6); - + /***************************************************************/ QLabel* meshGroupLab = new QLabel(this, "mesh/group label"); if (create) @@ -144,7 +168,7 @@ void SMESHGUI_GroupDlg::initDialog(SALOME_Selection* theSel, bool create) myMeshGroupBtn->setPixmap(image0); myMeshGroupLine = new QLineEdit(this, "mesh/group line"); myMeshGroupLine->setReadOnly(true); - + /***************************************************************/ myTypeGroup = new QButtonGroup(1, Qt::Vertical, this, "Group types"); myTypeGroup->setTitle(tr("SMESH_ELEMENTS_TYPE")); @@ -161,7 +185,7 @@ void SMESHGUI_GroupDlg::initDialog(SALOME_Selection* theSel, bool create) } myTypeGroup->setEnabled(create); myTypeId = -1; - + /***************************************************************/ QLabel* aName = new QLabel(this, "name label"); aName->setText(tr("SMESH_NAME")); @@ -181,7 +205,7 @@ void SMESHGUI_GroupDlg::initDialog(SALOME_Selection* theSel, bool create) myWGStack = new QWidgetStack( this, "widget stack"); QWidget* wg1 = new QFrame( myWGStack, "first widget" ); QWidget* wg2 = new QFrame( myWGStack, "second widget" ); - + /***************************************************************/ QGroupBox* aContentBox = new QGroupBox(1, Qt::Horizontal, wg1, "content box"); aContentBox->setTitle(tr("SMESH_CONTENT")); @@ -220,7 +244,7 @@ void SMESHGUI_GroupDlg::initDialog(SALOME_Selection* theSel, bool create) /***************************************************************/ QGroupBox* aSelectBox = new QGroupBox(3, Qt::Horizontal, wg1, "select box"); aSelectBox->setTitle(tr("SMESH_SELECT_FROM")); - + mySelectSubMesh = new QCheckBox(aSelectBox, "submesh checkbox"); mySelectSubMesh->setText(tr("SMESH_SUBMESH")); mySelectSubMesh->setMinimumSize(50, 0); @@ -230,7 +254,7 @@ void SMESHGUI_GroupDlg::initDialog(SALOME_Selection* theSel, bool create) mySubMeshLine = new QLineEdit(aSelectBox, "submesh line"); mySubMeshLine->setReadOnly(true); onSelectSubMesh(false); - + mySelectGroup = new QCheckBox(aSelectBox, "group checkbox"); mySelectGroup->setText(tr("SMESH_GROUP")); mySelectGroup->setMinimumSize(50, 0); @@ -240,7 +264,7 @@ void SMESHGUI_GroupDlg::initDialog(SALOME_Selection* theSel, bool create) myGroupLine = new QLineEdit(aSelectBox, "group line"); myGroupLine->setReadOnly(true); onSelectGroup(false); - + /***************************************************************/ QGridLayout* wg1Layout = new QGridLayout( wg1, 3, 1, 0, 6 ); wg1Layout->addWidget(aContentBox, 0, 0); @@ -256,7 +280,7 @@ void SMESHGUI_GroupDlg::initDialog(SALOME_Selection* theSel, bool create) myGeomGroupLine = new QLineEdit(wg2, "geometry group line"); myGeomGroupLine->setReadOnly(true); //VSR ??? onSelectGeomGroup(false); - + /***************************************************************/ QGridLayout* wg2Layout = new QGridLayout( wg2, 2, 3, 0, 6 ); wg2Layout->addWidget(geomObject, 0, 0); @@ -331,8 +355,6 @@ void SMESHGUI_GroupDlg::initDialog(SALOME_Selection* theSel, bool create) connect(aCloseBtn, SIGNAL(clicked()), this, SLOT(onClose())); /* Init selection */ - mySelection = theSel; - mySMESHGUI = SMESHGUI::GetSMESHGUI(); mySMESHGUI->SetActiveDialogBox(this); mySMESHGUI->SetState(800); @@ -343,14 +365,14 @@ void SMESHGUI_GroupDlg::initDialog(SALOME_Selection* theSel, bool create) connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(onDeactivate())); connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(onClose())); - connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(onObjectSelectionChanged())); + connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(onObjectSelectionChanged())); myGrpTypeGroup->setButton(myGrpTypeGroup->id(rb1)); // VSR !!! onGrpTypeChanged(myGrpTypeGroup->id(rb1)); // VSR!!! if (myMesh->_is_nil() ) myTypeGroup->setButton(0); - + updateButtons(); } @@ -368,21 +390,22 @@ SMESHGUI_GroupDlg::~SMESHGUI_GroupDlg() } } - //================================================================================= // function : Init() // purpose : //================================================================================= -void SMESHGUI_GroupDlg::init(SMESH::SMESH_Mesh_ptr theMesh) +void SMESHGUI_GroupDlg::init (SMESH::SMESH_Mesh_ptr theMesh) { /* init data from current selection */ myMesh = SMESH::SMESH_Mesh::_duplicate(theMesh); myGroup = SMESH::SMESH_Group::_nil(); - + myActor = SMESH::FindActorByObject(myMesh); SMESH::SetPickable(myActor); - - QString aName = mySelection->firstIObject()->getName(); + + const SALOME_ListIO& aList = mySelector->StoredIObjects(); + + QString aName = aList.First()->getName(); myMeshGroupLine->setText(aName) ; myMeshGroupLine->home( false ); @@ -396,24 +419,24 @@ void SMESHGUI_GroupDlg::init(SMESH::SMESH_Mesh_ptr theMesh) // function : Init() // purpose : //================================================================================= -void SMESHGUI_GroupDlg::init(SMESH::SMESH_Group_ptr theGroup) +void SMESHGUI_GroupDlg::init (SMESH::SMESH_Group_ptr theGroup) { myMesh = theGroup->GetMesh(); myGroup = SMESH::SMESH_Group::_duplicate(theGroup); - + myActor = SMESH::FindActorByObject(myMesh); if ( !myActor ) myActor = SMESH::FindActorByObject(myGroup); SMESH::SetPickable(myActor); - + int aType = 0; switch(theGroup->GetType()) { case SMESH::NODE: aType= 0; break; case SMESH::EDGE: aType = 1; break; case SMESH::FACE: aType = 2; break; case SMESH::VOLUME: aType = 3; break; - } - + } + myName->setText(myGroup->GetName()); myName->home(false); myMeshGroupLine->setText(myGroup->GetName()); @@ -423,7 +446,7 @@ void SMESHGUI_GroupDlg::init(SMESH::SMESH_Group_ptr theGroup) myElements->clear(); setSelectionMode(aType); myTypeId = aType; - + myIdList.clear(); if (!theGroup->IsEmpty()) { SMESH::long_array_var anElements = myGroup->GetListOfID(); @@ -436,15 +459,14 @@ void SMESHGUI_GroupDlg::init(SMESH::SMESH_Group_ptr theGroup) } } - //================================================================================= // function : updateButtons() -// purpose : +// purpose : //================================================================================= void SMESHGUI_GroupDlg::updateButtons() { - bool enable; - + bool enable; + if (myGrpTypeId == 0) enable = !myName->text().stripWhiteSpace().isEmpty() && myElements->count() > 0; else if (myGrpTypeId == 1) @@ -458,9 +480,9 @@ void SMESHGUI_GroupDlg::updateButtons() //================================================================================= // function : onNameChanged() -// purpose : +// purpose : //================================================================================= -void SMESHGUI_GroupDlg::onNameChanged(const QString& text) +void SMESHGUI_GroupDlg::onNameChanged (const QString& text) { updateButtons(); } @@ -469,7 +491,7 @@ void SMESHGUI_GroupDlg::onNameChanged(const QString& text) // function : onTypeChanged() // purpose : Group elements type radio button management //================================================================================= -void SMESHGUI_GroupDlg::onTypeChanged(int id) +void SMESHGUI_GroupDlg::onTypeChanged (int id) { if (myTypeId != id) { myElements->clear(); @@ -483,7 +505,7 @@ void SMESHGUI_GroupDlg::onTypeChanged(int id) // function : onGrpTypeChanged() // purpose : Group type radio button management //================================================================================= -void SMESHGUI_GroupDlg::onGrpTypeChanged(int id) +void SMESHGUI_GroupDlg::onGrpTypeChanged (int id) { if (myGrpTypeId != id) { myWGStack->raiseWidget( id ); @@ -496,47 +518,46 @@ void SMESHGUI_GroupDlg::onGrpTypeChanged(int id) // function : setSelectionMode() // purpose : Radio button management //================================================================================= -void SMESHGUI_GroupDlg::setSelectionMode(int theMode) +void SMESHGUI_GroupDlg::setSelectionMode (int theMode) { // PAL7314 if (myMesh->_is_nil()) return; - + if (mySelectionMode != theMode) { - mySelection->ClearIObjects(); - mySelection->ClearFilters(); + mySelectionMgr->clearSelected(); + mySelectionMgr->clearFilters(); SMESH::SetPointRepresentation(false); if (theMode < 4) { - switch(theMode){ + switch (theMode) { case 0: - if ( myActor ) + if (myActor) myActor->SetPointRepresentation(true); else SMESH::SetPointRepresentation(true); - QAD_Application::getDesktop()->SetSelectionMode(NodeSelection, true); + myViewWindow->SetSelectionMode(NodeSelection); break; case 1: - QAD_Application::getDesktop()->SetSelectionMode(EdgeSelection, true); + myViewWindow->SetSelectionMode(EdgeSelection); break; case 2: - QAD_Application::getDesktop()->SetSelectionMode(FaceSelection, true); + myViewWindow->SetSelectionMode(FaceSelection); break; default: - QAD_Application::getDesktop()->SetSelectionMode(VolumeSelection, true); + myViewWindow->SetSelectionMode(VolumeSelection); } - } - else { - QAD_Application::getDesktop()->SetSelectionMode(ActorSelection, true); + } else { + myViewWindow->SetSelectionMode(ActorSelection); if (theMode == 4) - mySelection->AddFilter(mySubMeshFilter); + mySelectionMgr->installFilter(mySubMeshFilter); else if (theMode == 5) - mySelection->AddFilter(myGroupFilter); + mySelectionMgr->installFilter(myGroupFilter); else if (theMode == 6) - mySelection->AddFilter(myMeshFilter); + mySelectionMgr->installFilter(myMeshFilter); } mySelectionMode = theMode; } -} +} //================================================================================= // function : onApply() @@ -544,11 +565,13 @@ void SMESHGUI_GroupDlg::setSelectionMode(int theMode) //================================================================================= bool SMESHGUI_GroupDlg::onApply() { - if (mySMESHGUI->ActiveStudyLocked()) + if (mySMESHGUI->isActiveStudyLocked()) return false; - - if ( myGrpTypeId == 0 && !myName->text().stripWhiteSpace().isEmpty() && myElements->count() > 0) { - mySelection->ClearIObjects(); + + if (myGrpTypeId == 0 && + !myName->text().stripWhiteSpace().isEmpty() && + myElements->count() > 0) { + mySelectionMgr->clearSelected(); if (myGroup->_is_nil()) { SMESH::ElementType aType = SMESH::ALL; switch(myTypeId) { @@ -567,19 +590,19 @@ bool SMESHGUI_GroupDlg::onApply() myGroup = SMESH::AddGroup(myMesh, aType, myName->text()); myGroup->Add(anIdList.inout()); - + /* init for next operation */ myName->setText(""); myElements->clear(); myGroup = SMESH::SMESH_Group::_nil(); - } - else { + + } else { myGroup->SetName(myName->text()); QValueList aAddList; QValueList::iterator anIt; QListBoxItem* anItem; - + for (anItem = myElements->firstItem(); anItem != 0; anItem = anItem->next()) { int anId = anItem->text().toInt(); if ((anIt = myIdList.find(anId)) == myIdList.end()) @@ -609,33 +632,36 @@ bool SMESHGUI_GroupDlg::onApply() myIdList.append(anItem->text().toInt()); } - mySMESHGUI->GetActiveStudy()->updateObjBrowser(true); + mySMESHGUI->updateObjBrowser(true); SMESH::UpdateView(); // asv: fix of BUG PAL5515 - mySelection->ClearIObjects(); + mySelectionMgr->clearSelected(); + return true; + } else if (myGrpTypeId == 1 && + !myName->text().stripWhiteSpace().isEmpty() && + !CORBA::is_nil(myGeomGroup)) + { + SMESH::ElementType aType = SMESH::ALL; + switch (myTypeId) { + case 0: aType = SMESH::NODE; break; + case 1: aType = SMESH::EDGE; break; + case 2: aType = SMESH::FACE; break; + case 3: aType = SMESH::VOLUME; break; + } + + _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); + GEOM::GEOM_IGroupOperations_var aGroupOp = + SMESH::GetGEOMGen()->GetIGroupOperations(aStudy->StudyId()); + + SMESH::SMESH_GroupOnGeom_var aGroupOnGeom = + myMesh->CreateGroupFromGEOM(aType, myName->text(),myGeomGroup); + + mySMESHGUI->updateObjBrowser(true); + mySelectionMgr->clearSelected(); + /* init for next operation */ + myName->setText(""); return true; } - else if (myGrpTypeId == 1 && !myName->text().stripWhiteSpace().isEmpty() && !CORBA::is_nil( myGeomGroup )) - { - SMESH::ElementType aType = SMESH::ALL; - switch(myTypeId) { - case 0: aType = SMESH::NODE; break; - case 1: aType = SMESH::EDGE; break; - case 2: aType = SMESH::FACE; break; - case 3: aType = SMESH::VOLUME; break; - } - - SALOMEDS::Study_var aStudy = SMESH::GetActiveStudyDocument(); - GEOM::GEOM_IGroupOperations_var aGroupOp = SMESH::GetGEOMGen()->GetIGroupOperations(aStudy->StudyId()); - - SMESH::SMESH_GroupOnGeom_var aGroupOnGeom = myMesh->CreateGroupFromGEOM(aType, myName->text(),myGeomGroup); - - mySMESHGUI->GetActiveStudy()->updateObjBrowser(true); - mySelection->ClearIObjects(); - /* init for next operation */ - myName->setText(""); - return true; - } - + return false; } @@ -661,7 +687,7 @@ void SMESHGUI_GroupDlg::onListSelectionChanged() busy = true; if (myCurrentLineEdit == 0) { - mySelection->ClearIObjects(); + mySelectionMgr->clearSelected(); TColStd_MapOfInteger aIndexes; QListBoxItem* anItem; for (anItem = myElements->firstItem(); anItem != 0; anItem = anItem->next()) { @@ -670,8 +696,11 @@ void SMESHGUI_GroupDlg::onListSelectionChanged() aIndexes.Add(anId); } } - mySelection->AddOrRemoveIndex(myActor->getIO(), aIndexes, false, false); - mySelection->AddIObject(myActor->getIO()); + mySelector->AddOrRemoveIndex(myActor->getIO(), aIndexes, false); + SALOME_ListIO aList; + aList.Append(myActor->getIO()); + mySelectionMgr->setSelectedObjects(aList,false); + myViewWindow->highlight( myActor->getIO(), true, true ); } busy = false; } @@ -685,175 +714,180 @@ void SMESHGUI_GroupDlg::onObjectSelectionChanged() if (busy || !isEnabled()) return; busy = true; - int aNbSel = mySelection->IObjectCount(); + const SALOME_ListIO& aList = mySelector->StoredIObjects(); + + int aNbSel = aList.Extent(); myElements->clearSelection(); - + if (myCurrentLineEdit) { - myCurrentLineEdit->setText("") ; + myCurrentLineEdit->setText(""); QString aString = ""; - - if (myCurrentLineEdit == myMeshGroupLine) - { - mySelectSubMesh->setEnabled(false); - mySelectGroup->setEnabled(false); - myGroupLine->setText(""); - mySubMeshLine->setText(""); - - myGeomGroupBtn->setEnabled(false); - myGeomGroupLine->setEnabled(false); - myGeomGroupLine->setText(""); - if (!myCreate) - myName->setText(""); - - myElements->clear(); - if(aNbSel != 1) - { - myGroup = SMESH::SMESH_Group::_nil(); - myMesh = SMESH::SMESH_Mesh::_nil(); - busy = false; - return; - } - Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject(); - - if (myCreate) - { - myMesh = SMESH::IObjectToInterface(IO); - if(myMesh->_is_nil()) - return; - myGroup = SMESH::SMESH_Group::_nil(); - - myActor = SMESH::FindActorByObject(myMesh); - SMESH::SetPickable(myActor); - - aString = mySelection->firstIObject()->getName(); - myMeshGroupLine->setText(aString) ; - myMeshGroupLine->home( false ); - - mySelectSubMesh->setEnabled(true); - mySelectGroup->setEnabled(true); - myGeomGroupBtn->setEnabled(true); - myGeomGroupLine->setEnabled(true); - updateButtons(); - } - else - { - SMESH::SMESH_Group_var aGroup = SMESH::IObjectToInterface(IO); - if(aGroup->_is_nil()) - return; - busy = false; - myCurrentLineEdit = 0; - init(aGroup); - busy = true; - mySelectSubMesh->setEnabled(true); - mySelectGroup->setEnabled(true); - myGeomGroupBtn->setEnabled(true); - myGeomGroupLine->setEnabled(true); - } - myCurrentLineEdit = 0; - busy = false; - if (!myCreate) - return; + if (myCurrentLineEdit == myMeshGroupLine) { + mySelectSubMesh->setEnabled(false); + mySelectGroup->setEnabled(false); + myGroupLine->setText(""); + mySubMeshLine->setText(""); - if (myTypeId == -1) - onTypeChanged(0); - else - { - myElements->clear(); - setSelectionMode(myTypeId); - } - - return; + myGeomGroupBtn->setEnabled(false); + myGeomGroupLine->setEnabled(false); + myGeomGroupLine->setText(""); + if (!myCreate) + myName->setText(""); + + myElements->clear(); + + if (aNbSel != 1) { + myGroup = SMESH::SMESH_Group::_nil(); + myMesh = SMESH::SMESH_Mesh::_nil(); + busy = false; + return; } - else if (myCurrentLineEdit == myGeomGroupLine) - { - - if(aNbSel != 1) - { - myGeomGroup = GEOM::GEOM_Object::_nil(); - busy = false; - return; - } - - Standard_Boolean testResult = Standard_False; - myGeomGroup = GEOMBase::ConvertIOinGEOMObject(mySelection->firstIObject(), testResult ); - - // Check if the object is a geometry group - if(!testResult || CORBA::is_nil( myGeomGroup )) - { - myGeomGroup = GEOM::GEOM_Object::_nil(); - busy = false; - return; - } - // Check if group constructed on the same shape as a mesh or on its child - SALOMEDS::Study_var aStudy = SMESH::GetActiveStudyDocument(); - GEOM::GEOM_IGroupOperations_var anOp = SMESH::GetGEOMGen()->GetIGroupOperations(aStudy->StudyId()); - // The main shape of the group - GEOM::GEOM_Object_var aGroupMainShape; - if( myGeomGroup->GetType() == 37 ) - aGroupMainShape = anOp->GetMainShape( myGeomGroup ); - else - aGroupMainShape = GEOM::GEOM_Object::_duplicate(myGeomGroup); - SALOMEDS::SObject_var aGroupMainShapeSO = aStudy->FindObjectIOR( aStudy->ConvertObjectToIOR(aGroupMainShape) ); - // The mesh SObject - SALOMEDS::SObject_var aMeshSO = aStudy->FindObjectIOR( aStudy->ConvertObjectToIOR(myMesh) ); - if ( aMeshSO->_is_nil() ) { - myGeomGroup = GEOM::GEOM_Object::_nil(); - busy = false; + Handle(SALOME_InteractiveObject) IO = aList.First(); + + if (myCreate) { + myMesh = SMESH::IObjectToInterface(IO); + if (myMesh->_is_nil()) + { + busy = false; return; - } - SALOMEDS::SObject_var anObj, aRef; - bool isRefOrSubShape = false; - if ( aMeshSO->FindSubObject( 1, anObj ) && anObj->ReferencedObject( aRef )) { - if ( strcmp( aRef->GetID(), aGroupMainShapeSO->GetID() ) == 0 ) - isRefOrSubShape = true; - else - { - SALOMEDS::SObject_var aFather = aGroupMainShapeSO->GetFather(); - SALOMEDS::SComponent_var aComponent = aGroupMainShapeSO->GetFatherComponent(); - while ( !isRefOrSubShape && strcmp( aFather->GetID(), aComponent->GetID() ) != 0 ) - { - if (strcmp( aRef->GetID(), aFather->GetID() ) == 0) - isRefOrSubShape = true; - else - aFather = aFather->GetFather(); - } - } } - if ( !isRefOrSubShape ) - { - myGeomGroup = GEOM::GEOM_Object::_nil(); - busy = false; - return; - } + myGroup = SMESH::SMESH_Group::_nil(); + + myActor = SMESH::FindActorByObject(myMesh); + SMESH::SetPickable(myActor); + + aString = aList.First()->getName(); + myMeshGroupLine->setText(aString) ; + myMeshGroupLine->home( false ); + + mySelectSubMesh->setEnabled(true); + mySelectGroup->setEnabled(true); + myGeomGroupBtn->setEnabled(true); + myGeomGroupLine->setEnabled(true); + updateButtons(); + } else { + SMESH::SMESH_Group_var aGroup = SMESH::IObjectToInterface(IO); + if (aGroup->_is_nil()) + { + busy = false; + return; + } + busy = false; + myCurrentLineEdit = 0; + init(aGroup); + busy = true; + mySelectSubMesh->setEnabled(true); + mySelectGroup->setEnabled(true); + myGeomGroupBtn->setEnabled(true); + myGeomGroupLine->setEnabled(true); } - + myCurrentLineEdit = 0; + busy = false; + if (!myCreate) + { + busy = false; + return; + } + + if (myTypeId == -1) + onTypeChanged(0); + else { + myElements->clear(); + setSelectionMode(myTypeId); + } + + busy = false; + return; + + } else if (myCurrentLineEdit == myGeomGroupLine) { + if (aNbSel != 1) { + myGeomGroup = GEOM::GEOM_Object::_nil(); + busy = false; + return; + } + + Standard_Boolean testResult = Standard_False; + myGeomGroup = GEOMBase::ConvertIOinGEOMObject(aList.First(), testResult); + + // Check if the object is a geometry group + if (!testResult || CORBA::is_nil(myGeomGroup)) { + myGeomGroup = GEOM::GEOM_Object::_nil(); + busy = false; + return; + } + // Check if group constructed on the same shape as a mesh or on its child + _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); + GEOM::GEOM_IGroupOperations_var anOp = + SMESH::GetGEOMGen()->GetIGroupOperations(aStudy->StudyId()); + + // The main shape of the group + GEOM::GEOM_Object_var aGroupMainShape; + if (myGeomGroup->GetType() == 37) + aGroupMainShape = anOp->GetMainShape(myGeomGroup); + else + aGroupMainShape = GEOM::GEOM_Object::_duplicate(myGeomGroup); + _PTR(SObject) aGroupMainShapeSO = + //aStudy->FindObjectIOR(aStudy->ConvertObjectToIOR(aGroupMainShape)); + aStudy->FindObjectIOR(aGroupMainShape->GetStudyEntry()); + + // The mesh SObject + _PTR(SObject) aMeshSO = SMESH::FindSObject(myMesh); + if (!aMeshSO) { + myGeomGroup = GEOM::GEOM_Object::_nil(); + busy = false; + return; + } + _PTR(SObject) anObj, aRef; + bool isRefOrSubShape = false; + if (aMeshSO->FindSubObject(1, anObj) && anObj->ReferencedObject(aRef)) { + //if (strcmp(aRef->GetID(), aGroupMainShapeSO->GetID()) == 0) { + if (aRef->GetID() == aGroupMainShapeSO->GetID()) { + isRefOrSubShape = true; + } else { + _PTR(SObject) aFather = aGroupMainShapeSO->GetFather(); + _PTR(SComponent) aComponent = aGroupMainShapeSO->GetFatherComponent(); + //while (!isRefOrSubShape && strcmp(aFather->GetID(), aComponent->GetID()) != 0) { + while (!isRefOrSubShape && aFather->GetID() != aComponent->GetID()) { + //if (strcmp(aRef->GetID(), aFather->GetID()) == 0) + if (aRef->GetID() == aFather->GetID()) + isRefOrSubShape = true; + else + aFather = aFather->GetFather(); + } + } + } + if (!isRefOrSubShape) { + myGeomGroup = GEOM::GEOM_Object::_nil(); + busy = false; + return; + } + } + if (aNbSel >= 1) { if (aNbSel > 1) { if (myCurrentLineEdit == mySubMeshLine) aString = tr("SMESH_SUBMESH_SELECTED").arg(aNbSel); else if (myCurrentLineEdit == myGroupLine || myCurrentLineEdit == myGeomGroupLine) aString = tr("SMESH_GROUP_SELECTED").arg(aNbSel); - } - else { - aString = mySelection->firstIObject()->getName(); + } else { + aString = aList.First()->getName(); } } - - myCurrentLineEdit->setText(aString) ; - myCurrentLineEdit->home( false ); - + + myCurrentLineEdit->setText(aString); + myCurrentLineEdit->home(false); + updateButtons(); - } - else { + + } else { if (aNbSel == 1) { QString aListStr = ""; int aNbItems = 0; if (myTypeId == 0) { - aNbItems = SMESH::GetNameOfSelectedNodes(mySelection, aListStr); - } - else { - aNbItems = SMESH::GetNameOfSelectedElements(mySelection, aListStr); + aNbItems = SMESH::GetNameOfSelectedNodes(mySelector, myActor->getIO(), aListStr); + } else { + aNbItems = SMESH::GetNameOfSelectedElements(mySelector, myActor->getIO(), aListStr); } if (aNbItems > 0) { QStringList anElements = QStringList::split(" ", aListStr); @@ -865,18 +899,17 @@ void SMESHGUI_GroupDlg::onObjectSelectionChanged() } } } - - if ( !myActor ) { - if ( !myGroup->_is_nil() ) + + if (!myActor) { + if (!myGroup->_is_nil()) myActor = SMESH::FindActorByObject(myGroup); else myActor = SMESH::FindActorByObject(myMesh); } - + busy = false; } - //================================================================================= // function : onSelectSubMesh() // purpose : Called when selection in 3D view or ObjectBrowser is changed @@ -886,7 +919,7 @@ void SMESHGUI_GroupDlg::onSelectSubMesh(bool on) if (on) { if (mySelectGroup->isChecked()) { mySelectGroup->setChecked(false); - } + } //VSR: else if (mySelectGeomGroup->isChecked()) { //VSR: mySelectGeomGroup->setChecked(false); //VSR: } @@ -987,7 +1020,7 @@ void SMESHGUI_GroupDlg::setCurrentSelection() //================================================================================= // function : setFilters() -// purpose : SLOT. Called when "Filter" button pressed. +// purpose : SLOT. Called when "Filter" button pressed. //================================================================================= void SMESHGUI_GroupDlg::setFilters() { @@ -1003,13 +1036,13 @@ void SMESHGUI_GroupDlg::setFilters() if ( myFilterDlg == 0 ) { - myFilterDlg = new SMESHGUI_FilterDlg( (QWidget*)parent(), aType ); + myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, aType ); connect( myFilterDlg, SIGNAL( Accepted() ), SLOT( onFilterAccepted() ) ); } else myFilterDlg->Init( aType ); - myFilterDlg->SetSelection( mySelection ); + myFilterDlg->SetSelection(); myFilterDlg->SetMesh( myMesh ); myFilterDlg->SetSourceWg( myElements ); @@ -1037,7 +1070,9 @@ void SMESHGUI_GroupDlg::onFilterAccepted() //================================================================================= void SMESHGUI_GroupDlg::onAdd() { - int aNbSel = mySelection->IObjectCount(); + const SALOME_ListIO& aList = mySelector->StoredIObjects(); + int aNbSel = aList.Extent(); + if (aNbSel == 0 || !myActor || myMesh->_is_nil()) return; busy = true; @@ -1055,10 +1090,10 @@ void SMESHGUI_GroupDlg::onAdd() QString aListStr = ""; int aNbItems = 0; if (myTypeId == 0) { - aNbItems = SMESH::GetNameOfSelectedNodes(mySelection, myActor->getIO(), aListStr); + aNbItems = SMESH::GetNameOfSelectedNodes(mySelector, myActor->getIO(), aListStr); } else { - aNbItems = SMESH::GetNameOfSelectedElements(mySelection, myActor->getIO(), aListStr); + aNbItems = SMESH::GetNameOfSelectedElements(mySelector, myActor->getIO(), aListStr); } if (aNbItems > 0) { QStringList anElements = QStringList::split(" ", aListStr); @@ -1072,16 +1107,18 @@ void SMESHGUI_GroupDlg::onAdd() myElements->setSelected(anItem, true); } } - } - else if (myCurrentLineEdit == mySubMeshLine) { - SALOME_ListIteratorOfListIO anIt(mySelection->StoredIObjects()); + } else if (myCurrentLineEdit == mySubMeshLine) { + //SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects()); + const SALOME_ListIO& aList = mySelector->StoredIObjects(); + SALOME_ListIteratorOfListIO anIt (aList); for (; anIt.More(); anIt.Next()) { - SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface(anIt.Value()); + SMESH::SMESH_subMesh_var aSubMesh = + SMESH::IObjectToInterface(anIt.Value()); if (!aSubMesh->_is_nil()) { // check if mesh is the same if (aSubMesh->GetFather()->GetId() == myMesh->GetId()) { try { - SMESH::long_array_var anElements = aSubMesh->GetElementsByType ( aType ); + SMESH::long_array_var anElements = aSubMesh->GetElementsByType(aType); int k = anElements->length(); QListBoxItem* anItem = 0; for (int i = 0; i < k; i++) { @@ -1095,7 +1132,7 @@ void SMESHGUI_GroupDlg::onAdd() } } catch (const SALOME::SALOME_Exception& ex) { - QtCatchCorbaException(ex); + SalomeApp_Tools::QtCatchCorbaException(ex); } } } @@ -1103,11 +1140,14 @@ void SMESHGUI_GroupDlg::onAdd() mySelectSubMesh->setChecked(false); busy = false; onListSelectionChanged(); - } - else if (myCurrentLineEdit == myGroupLine) { - SALOME_ListIteratorOfListIO anIt(mySelection->StoredIObjects()); + + } else if (myCurrentLineEdit == myGroupLine) { + //SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects()); + const SALOME_ListIO& aList = mySelector->StoredIObjects(); + SALOME_ListIteratorOfListIO anIt (aList); for (; anIt.More(); anIt.Next()) { - SMESH::SMESH_Group_var aGroup = SMESH::IObjectToInterface(anIt.Value()); + SMESH::SMESH_Group_var aGroup = + SMESH::IObjectToInterface(anIt.Value()); if (!aGroup->_is_nil()) { // check if mesh is the same if (aGroup->GetType() == aType && aGroup->GetMesh()->GetId() == myMesh->GetId()) { @@ -1129,34 +1169,36 @@ void SMESHGUI_GroupDlg::onAdd() mySelectGroup->setChecked(false); busy = false; onListSelectionChanged(); - } - else if (myCurrentLineEdit == myGeomGroupLine && !CORBA::is_nil(myGeomGroup)) { - - SALOMEDS::Study_var aStudy = SMESH::GetActiveStudyDocument(); - GEOM::GEOM_IGroupOperations_var aGroupOp = SMESH::GetGEOMGen()->GetIGroupOperations(aStudy->StudyId()); - + + } else if (myCurrentLineEdit == myGeomGroupLine && !CORBA::is_nil(myGeomGroup)) { + _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); + GEOM::GEOM_IGroupOperations_var aGroupOp = + SMESH::GetGEOMGen()->GetIGroupOperations(aStudy->StudyId()); + SMESH::ElementType aGroupType = SMESH::ALL; switch(aGroupOp->GetType(myGeomGroup)) { case 7: aGroupType = SMESH::NODE; break; case 6: aGroupType = SMESH::EDGE; break; case 4: aGroupType = SMESH::FACE; break; case 2: aGroupType = SMESH::VOLUME; break; - default: return; + default: busy = false; return; } - + if (aGroupType == aType) { - SALOMEDS::SObject_var aGroupSO = aStudy->FindObjectIOR( aStudy->ConvertObjectToIOR(myGeomGroup) ); + _PTR(SObject) aGroupSO = + //aStudy->FindObjectIOR(aStudy->ConvertObjectToIOR(myGeomGroup)); + aStudy->FindObjectIOR(myGeomGroup->GetStudyEntry()); // Construct filter SMESH::FilterManager_var aFilterMgr = SMESH::GetFilterManager(); SMESH::Filter_var aFilter = aFilterMgr->CreateFilter(); SMESH::BelongToGeom_var aBelongToGeom = aFilterMgr->CreateBelongToGeom();; aBelongToGeom->SetGeom(myGeomGroup); - aBelongToGeom->SetShapeName(aGroupSO->GetName()); + aBelongToGeom->SetShapeName(aGroupSO->GetName().c_str()); aBelongToGeom->SetElementType(aType); - aFilter->SetPredicate( aBelongToGeom ); - - SMESH::long_array_var anElements = aFilter->GetElementsId( myMesh ); - + aFilter->SetPredicate(aBelongToGeom); + + SMESH::long_array_var anElements = aFilter->GetElementsId(myMesh); + int k = anElements->length(); QListBoxItem* anItem = 0; for (int i = 0; i < k; i++) { @@ -1169,13 +1211,13 @@ void SMESHGUI_GroupDlg::onAdd() myElements->setSelected(anItem, true); } } - + //VSR: mySelectGeomGroup->setChecked(false); busy = false; onListSelectionChanged(); } busy = false; - // mySelection->ClearIObjects(); + // mySelectionMgr->clearSelected(); updateButtons(); } @@ -1192,11 +1234,12 @@ void SMESHGUI_GroupDlg::onRemove() myElements->removeItem(i-1); } } - } - else { - int aNbSel = mySelection->IObjectCount(); + } else { + const SALOME_ListIO& aList = mySelector->StoredIObjects(); + int aNbSel = aList.Extent(); + if (aNbSel == 0) { busy = false; return; } - + SMESH::ElementType aType = SMESH::ALL; switch(myTypeId) { case 0: aType = SMESH::NODE; break; @@ -1206,7 +1249,9 @@ void SMESHGUI_GroupDlg::onRemove() } if (myCurrentLineEdit == mySubMeshLine) { - SALOME_ListIteratorOfListIO anIt(mySelection->StoredIObjects()); + //SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects()); + const SALOME_ListIO& aList = mySelector->StoredIObjects(); + SALOME_ListIteratorOfListIO anIt (aList); for (; anIt.More(); anIt.Next()) { SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface(anIt.Value()); if (!aSubMesh->_is_nil()) { @@ -1223,7 +1268,7 @@ void SMESHGUI_GroupDlg::onRemove() } } catch (const SALOME::SALOME_Exception& ex) { - QtCatchCorbaException(ex); + SalomeApp_Tools::QtCatchCorbaException(ex); } } else { @@ -1237,7 +1282,7 @@ void SMESHGUI_GroupDlg::onRemove() } } catch (const SALOME::SALOME_Exception& ex) { - QtCatchCorbaException(ex); + SalomeApp_Tools::QtCatchCorbaException(ex); } } } @@ -1246,7 +1291,9 @@ void SMESHGUI_GroupDlg::onRemove() } else if (myCurrentLineEdit == myGroupLine) { Standard_Boolean aRes; - SALOME_ListIteratorOfListIO anIt(mySelection->StoredIObjects()); + //SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects()); + const SALOME_ListIO& aList = mySelector->StoredIObjects(); + SALOME_ListIteratorOfListIO anIt (aList); for (; anIt.More(); anIt.Next()) { SMESH::SMESH_Group_var aGroup = SMESH::IObjectToInterface(anIt.Value()); if (aRes && !aGroup->_is_nil()) { @@ -1287,7 +1334,7 @@ void SMESHGUI_GroupDlg::onSort() // fill the array for (anItem = myElements->firstItem(), i = 0; anItem != 0; anItem = anItem->next(), i++) { anArray[i] = anItem->text().toInt(); - if (anItem->isSelected()) + if (anItem->isSelected()) aSelected.append(anItem->text()); } // sort & update list @@ -1309,65 +1356,64 @@ void SMESHGUI_GroupDlg::onSort() // function : closeEvent() // purpose : //================================================================================= -void SMESHGUI_GroupDlg::closeEvent( QCloseEvent* e ) +void SMESHGUI_GroupDlg::closeEvent (QCloseEvent*) { onClose(); } -//======================================================================= -// name : SMESHGUI_GroupDlg::onClose -// Purpose : SLOT called when "Close" button pressed. Close dialog -//======================================================================= +//================================================================================= +// function : SMESHGUI_GroupDlg::onClose +// purpose : SLOT called when "Close" button pressed. Close dialog +//================================================================================= void SMESHGUI_GroupDlg::onClose() { - QAD_StudyFrame* aStudyFrame = mySMESHGUI->GetActiveStudy()->getActiveStudyFrame(); - if (aStudyFrame->getTypeView() == VIEW_VTK) { + if (SMESH::GetCurrentVtkView()) { SMESH::RemoveFilters(); // PAL6938 -- clean all mesh entity filters SMESH::SetPointRepresentation(false); SMESH::SetPickable(); } - - mySelection->ClearIObjects(); - QAD_Application::getDesktop()->SetSelectionMode(ActorSelection); - mySelection->ClearFilters(); + + mySelectionMgr->clearSelected(); + myViewWindow->SetSelectionMode(ActorSelection); + mySelectionMgr->clearFilters(); mySMESHGUI->ResetState(); reject(); } -//======================================================================= -// name : SMESHGUI_GroupDlg::onDeactivate -// Purpose : SLOT called when dialog must be deativated -//======================================================================= +//================================================================================= +// function : SMESHGUI_GroupDlg::onDeactivate +// purpose : SLOT called when dialog must be deativated +//================================================================================= void SMESHGUI_GroupDlg::onDeactivate() { mySMESHGUI->ResetState(); - setEnabled( false ); + setEnabled(false); } -//======================================================================= -// name : SMESHGUI_GroupDlg::enterEvent -// Purpose : Event filter -//======================================================================= -void SMESHGUI_GroupDlg::enterEvent( QEvent* ) +//================================================================================= +// function : SMESHGUI_GroupDlg::enterEvent +// purpose : Event filter +//================================================================================= +void SMESHGUI_GroupDlg::enterEvent (QEvent*) { - if ( !isEnabled() ) { - SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog(); - setEnabled( true ); + if (!isEnabled()) { + mySMESHGUI->EmitSignalDeactivateDialog(); + setEnabled(true); mySelectionMode = -1; - setSelectionMode( myTypeId ); - mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; + setSelectionMode(myTypeId); + //mySMESHGUI->SetActiveDialogBox((QDialog*)this); + mySMESHGUI->SetActiveDialogBox(this); mySMESHGUI->SetState(800); } } -//======================================================================= -//function : hideEvent -//purpose : caused by ESC key -//======================================================================= - -void SMESHGUI_GroupDlg::hideEvent ( QHideEvent * e ) +//================================================================================= +// function : hideEvent +// purpose : caused by ESC key +//================================================================================= +void SMESHGUI_GroupDlg::hideEvent (QHideEvent*) { - if ( !isMinimized() ) + if (!isMinimized()) onClose(); } diff --git a/src/SMESHGUI/SMESHGUI_GroupDlg.h b/src/SMESHGUI/SMESHGUI_GroupDlg.h index 9c19f9563..797c084ca 100644 --- a/src/SMESHGUI/SMESHGUI_GroupDlg.h +++ b/src/SMESHGUI/SMESHGUI_GroupDlg.h @@ -28,8 +28,9 @@ #ifndef DIALOGBOX_GROUP_H #define DIALOGBOX_GROUP_H -#include "SALOME_Selection.h" -#include "SMESH_TypeFilter.hxx" +#include "SalomeApp_SelectionMgr.h" +//#include "SMESH_TypeFilter.hxx" +#include "SUIT_SelectionFilter.h" // QT Includes #include @@ -50,6 +51,8 @@ class QWidgetStack; class SMESHGUI; class SMESH_Actor; class SMESHGUI_FilterDlg; +class SVTK_Selector; +class SVTK_ViewWindow; //================================================================================= // class : SMESHGUI_GroupDlg @@ -60,11 +63,14 @@ class SMESHGUI_GroupDlg : public QDialog Q_OBJECT public: - SMESHGUI_GroupDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* theSel = 0, + SMESHGUI_GroupDlg( SMESHGUI*, + const char* name = 0, SMESH::SMESH_Mesh_ptr theMesh = SMESH::SMESH_Mesh::_nil(), bool modal = FALSE, WFlags fl = 0 ); - SMESHGUI_GroupDlg( QWidget* parent, const char* name, SALOME_Selection* theSel, - SMESH::SMESH_Group_ptr theGroup, bool modal = FALSE, WFlags fl = 0 ); + SMESHGUI_GroupDlg( SMESHGUI*, + const char* name, + SMESH::SMESH_Group_ptr theGroup, + bool modal = FALSE, WFlags fl = 0 ); ~SMESHGUI_GroupDlg(); public slots: @@ -98,21 +104,23 @@ private slots: void onFilterAccepted(); private: - void initDialog(SALOME_Selection* theSel, bool create); + void initDialog(bool create); void init(SMESH::SMESH_Mesh_ptr theMesh); void init(SMESH::SMESH_Group_ptr theGroup); void closeEvent(QCloseEvent* e); - void enterEvent ( QEvent * ) ; - void hideEvent ( QHideEvent * ); /* ESC key */ + void enterEvent (QEvent*); + void hideEvent (QHideEvent*); /* ESC key */ void setSelectionMode(int theMode); void updateButtons(); - SMESHGUI* mySMESHGUI ; /* Current SMESHGUI object */ - SALOME_Selection* mySelection ; /* User shape selection */ - SMESH_Actor* myActor; /* Current mesh actor */ - int myGrpTypeId ; /* Current group type id : standalone or group on geometry */ - int myTypeId ; /* Current type id = radio button id */ - QLineEdit* myCurrentLineEdit; /* Current LineEdit */ + SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */ + SalomeApp_SelectionMgr* mySelectionMgr; /* User shape selection */ + SMESH_Actor* myActor; /* Current mesh actor */ + int myGrpTypeId; /* Current group type id : standalone or group on geometry */ + int myTypeId; /* Current type id = radio button id */ + QLineEdit* myCurrentLineEdit; /* Current LineEdit */ + SVTK_ViewWindow* myViewWindow; + SVTK_Selector* mySelector; QPushButton* myMeshGroupBtn; QLineEdit* myMeshGroupLine; @@ -144,9 +152,12 @@ private: GEOM::GEOM_Object_var myGeomGroup; int mySelectionMode; - Handle(SMESH_TypeFilter) myMeshFilter; - Handle(SMESH_TypeFilter) mySubMeshFilter; - Handle(SMESH_TypeFilter) myGroupFilter; + //Handle(SMESH_TypeFilter) myMeshFilter; + //Handle(SMESH_TypeFilter) mySubMeshFilter; + //Handle(SMESH_TypeFilter) myGroupFilter; + SUIT_SelectionFilter* myMeshFilter; + SUIT_SelectionFilter* mySubMeshFilter; + SUIT_SelectionFilter* myGroupFilter; SMESHGUI_FilterDlg* myFilterDlg; diff --git a/src/SMESHGUI/SMESHGUI_GroupOpDlg.cxx b/src/SMESHGUI/SMESHGUI_GroupOpDlg.cxx index c5b07386e..04a03263a 100644 --- a/src/SMESHGUI/SMESHGUI_GroupOpDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_GroupOpDlg.cxx @@ -1,23 +1,23 @@ // SMESH SMESHGUI : GUI for SMESH component // // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org // // // @@ -27,13 +27,19 @@ #include "SMESHGUI_GroupOpDlg.h" -#include "QAD_Desktop.h" - #include "SMESHGUI.h" #include "SMESHGUI_Utils.h" -#include "SALOME_Selection.h" + #include "SMESH_TypeFilter.hxx" +#include "SUIT_ResourceMgr.h" +#include "SUIT_Desktop.h" + +#include "SalomeApp_SelectionMgr.h" +#include "SVTK_Selection.h" +#include "SALOME_ListIO.hxx" + +// QT Includes #include #include #include @@ -46,71 +52,73 @@ #define SPACING 5 #define MARGIN 10 -/* - Class : SMESHGUI_GroupOpDlg - Description : Perform boolean operations on groups -*/ +/*! + * Class : SMESHGUI_GroupOpDlg + * Description : Perform boolean operations on groups + */ //======================================================================= // name : SMESHGUI_GroupOpDlg::SMESHGUI_GroupOpDlg // Purpose : Constructor //======================================================================= -SMESHGUI_GroupOpDlg::SMESHGUI_GroupOpDlg( QWidget* theParent, - SALOME_Selection* theSelection, - const int theMode ) -: QDialog( theParent, "SMESHGUI_GroupOpDlg", false, - WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +SMESHGUI_GroupOpDlg::SMESHGUI_GroupOpDlg (QWidget* theParent, + SalomeApp_SelectionMgr* theSelection, + const int theMode) + : QDialog(theParent, "SMESHGUI_GroupOpDlg", false, + WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) { myMode = theMode; - if ( myMode == UNION ) setCaption( tr( "UNION_OF_TWO_GROUPS" ) ); - else if ( myMode == INTERSECT ) setCaption( tr( "INTERSECTION_OF_TWO_GROUPS" ) ); - else setCaption( tr( "CUT_OF_TWO_GROUPS" ) ); + if (myMode == UNION) setCaption(tr("UNION_OF_TWO_GROUPS")); + else if (myMode == INTERSECT) setCaption(tr("INTERSECTION_OF_TWO_GROUPS")); + else setCaption(tr("CUT_OF_TWO_GROUPS")); - QVBoxLayout* aDlgLay = new QVBoxLayout( this, MARGIN, SPACING ); + QVBoxLayout* aDlgLay = new QVBoxLayout (this, MARGIN, SPACING); - QFrame* aMainFrame = createMainFrame ( this ); - QFrame* aBtnFrame = createButtonFrame( this ); + QFrame* aMainFrame = createMainFrame (this); + QFrame* aBtnFrame = createButtonFrame(this); - aDlgLay->addWidget( aMainFrame ); - aDlgLay->addWidget( aBtnFrame ); + aDlgLay->addWidget(aMainFrame); + aDlgLay->addWidget(aBtnFrame); - aDlgLay->setStretchFactor( aMainFrame, 1 ); + aDlgLay->setStretchFactor(aMainFrame, 1); - Init( theSelection ); + Init(theSelection); } //======================================================================= // name : SMESHGUI_GroupOpDlg::createMainFrame // Purpose : Create frame containing dialog's input fields //======================================================================= -QFrame* SMESHGUI_GroupOpDlg::createMainFrame( QWidget* theParent ) +QFrame* SMESHGUI_GroupOpDlg::createMainFrame (QWidget* theParent) { - QGroupBox* aMainGrp = new QGroupBox( 1, Qt::Horizontal, theParent ); - aMainGrp->setFrameStyle( QFrame::NoFrame ); - aMainGrp->setInsideMargin( 0 ); - - QGroupBox* aNameGrp = new QGroupBox( 1, Qt::Vertical, tr( "NAME" ), aMainGrp ); - new QLabel( tr( "RESULT_NAME" ), aNameGrp ); - myNameEdit = new QLineEdit( aNameGrp ); - - QGroupBox* anArgGrp = new QGroupBox( 3, Qt::Horizontal, tr( "ARGUMENTS" ), aMainGrp ); - - new QLabel( myMode == CUT ? tr( "MAIN_OBJECT" ) :tr( "OBJECT_1" ), anArgGrp ); - myBtn1 = new QPushButton( anArgGrp ); - myEdit1 = new QLineEdit( anArgGrp ); - - new QLabel( myMode == CUT ? tr( "TOOL_OBJECT" ) :tr( "OBJECT_2" ), anArgGrp ); - myBtn2 = new QPushButton( anArgGrp ); - myEdit2 = new QLineEdit( anArgGrp ); - - myEdit1->setReadOnly( true ); - myEdit2->setReadOnly( true ); + QGroupBox* aMainGrp = new QGroupBox(1, Qt::Horizontal, theParent); + aMainGrp->setFrameStyle(QFrame::NoFrame); + aMainGrp->setInsideMargin(0); + + QGroupBox* aNameGrp = new QGroupBox(1, Qt::Vertical, tr("NAME"), aMainGrp); + new QLabel(tr("RESULT_NAME"), aNameGrp); + myNameEdit = new QLineEdit(aNameGrp); + + QGroupBox* anArgGrp = new QGroupBox(3, Qt::Horizontal, tr("ARGUMENTS"), aMainGrp); + + new QLabel(myMode == CUT ? tr("MAIN_OBJECT") :tr("OBJECT_1"), anArgGrp); + myBtn1 = new QPushButton(anArgGrp); + myEdit1 = new QLineEdit(anArgGrp); + myEdit1->setAlignment( Qt::AlignLeft ); + + new QLabel(myMode == CUT ? tr("TOOL_OBJECT") :tr("OBJECT_2"), anArgGrp); + myBtn2 = new QPushButton(anArgGrp); + myEdit2 = new QLineEdit(anArgGrp); + myEdit2->setAlignment( Qt::AlignLeft ); + + myEdit1->setReadOnly(true); + myEdit2->setReadOnly(true); + + QPixmap aPix (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT"))); + myBtn1->setPixmap(aPix); + myBtn2->setPixmap(aPix); - QPixmap aPix( QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr( "ICON_SELECT" ) ) ); - myBtn1->setPixmap( aPix ); - myBtn2->setPixmap( aPix ); - return aMainGrp; } @@ -118,28 +126,28 @@ QFrame* SMESHGUI_GroupOpDlg::createMainFrame( QWidget* theParent ) // name : SMESHGUI_GroupOpDlg::createButtonFrame // Purpose : Create frame containing buttons //======================================================================= -QFrame* SMESHGUI_GroupOpDlg::createButtonFrame( QWidget* theParent ) +QFrame* SMESHGUI_GroupOpDlg::createButtonFrame (QWidget* theParent) { - QFrame* aFrame = new QFrame( theParent ); - aFrame->setFrameStyle( QFrame::Box | QFrame::Sunken ); + QFrame* aFrame = new QFrame(theParent); + aFrame->setFrameStyle(QFrame::Box | QFrame::Sunken); - myOkBtn = new QPushButton( tr( "SMESH_BUT_OK" ), aFrame ); - myApplyBtn = new QPushButton( tr( "SMESH_BUT_APPLY" ), aFrame ); - myCloseBtn = new QPushButton( tr( "SMESH_BUT_CLOSE" ), aFrame ); + myOkBtn = new QPushButton(tr("SMESH_BUT_OK" ), aFrame); + myApplyBtn = new QPushButton(tr("SMESH_BUT_APPLY"), aFrame); + myCloseBtn = new QPushButton(tr("SMESH_BUT_CLOSE"), aFrame); - QSpacerItem* aSpacer = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum ); + QSpacerItem* aSpacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum); - QHBoxLayout* aLay = new QHBoxLayout( aFrame, MARGIN, SPACING ); + QHBoxLayout* aLay = new QHBoxLayout(aFrame, MARGIN, SPACING); + + aLay->addWidget(myOkBtn); + aLay->addWidget(myApplyBtn); + aLay->addItem(aSpacer); + aLay->addWidget(myCloseBtn); - aLay->addWidget( myOkBtn ); - aLay->addWidget( myApplyBtn ); - aLay->addItem( aSpacer); - aLay->addWidget( myCloseBtn ); - // connect signals and slots - connect( myOkBtn, SIGNAL( clicked() ), SLOT( onOk() ) ); - connect( myCloseBtn, SIGNAL( clicked() ), SLOT( onClose() ) ) ; - connect( myApplyBtn, SIGNAL( clicked() ), SLOT( onApply() ) ); + connect(myOkBtn, SIGNAL(clicked()), SLOT(onOk())); + connect(myCloseBtn, SIGNAL(clicked()), SLOT(onClose())); + connect(myApplyBtn, SIGNAL(clicked()), SLOT(onApply())); return aFrame; } @@ -156,32 +164,36 @@ SMESHGUI_GroupOpDlg::~SMESHGUI_GroupOpDlg() // name : SMESHGUI_GroupOpDlg::Init // Purpose : Init dialog fields, connect signals and slots, show dialog //======================================================================= -void SMESHGUI_GroupOpDlg::Init( SALOME_Selection* theSelection ) +void SMESHGUI_GroupOpDlg::Init (SalomeApp_SelectionMgr* theSelection) { - mySelection = theSelection; + mySelectionMgr = theSelection; SMESHGUI* aSMESHGUI = SMESHGUI::GetSMESHGUI(); - aSMESHGUI->SetActiveDialogBox( ( QDialog* )this ) ; + aSMESHGUI->SetActiveDialogBox((QDialog*)this); myFocusWg = myEdit1; - + myGroup1 = SMESH::SMESH_GroupBase::_nil(); myGroup2 = SMESH::SMESH_GroupBase::_nil(); - + // selection and SMESHGUI - connect( mySelection, SIGNAL( currentSelectionChanged() ), SLOT( onSelectionDone() ) ); - connect( aSMESHGUI, SIGNAL( SignalDeactivateActiveDialog() ), SLOT( onDeactivate() ) ); - connect( aSMESHGUI, SIGNAL( SignalCloseAllDialogs() ), SLOT( ClickOnClose() ) ); - - connect( myBtn1, SIGNAL( clicked() ), this, SLOT( onFocusChanged() ) ); - connect( myBtn2, SIGNAL( clicked() ), this, SLOT( onFocusChanged() ) ); - - int x, y ; - aSMESHGUI->DefineDlgPosition( this, x, y ); - this->move( x, y ); - this->show(); + connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(onSelectionDone())); + connect(aSMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), SLOT(onDeactivate())); + connect(aSMESHGUI, SIGNAL(SignalCloseAllDialogs()), SLOT(ClickOnClose())); + + connect(myBtn1, SIGNAL(clicked()), this, SLOT(onFocusChanged())); + connect(myBtn2, SIGNAL(clicked()), this, SLOT(onFocusChanged())); + + int x, y; + aSMESHGUI->DefineDlgPosition(this, x, y); + this->move(x, y); + this->show(); // set selection mode - QAD_Application::getDesktop()->SetSelectionMode( ActorSelection, true ); - mySelection->AddFilter( new SMESH_TypeFilter( GROUP ) ); +#ifdef NEW_GUI + mySelectionMgr->setSelectionModes(ActorSelection, true); +#else + mySelectionMgr->setSelectionModes(ActorSelection); +#endif + mySelectionMgr->installFilter(new SMESH_TypeFilter (GROUP)); return; } @@ -193,85 +205,77 @@ void SMESHGUI_GroupOpDlg::Init( SALOME_Selection* theSelection ) bool SMESHGUI_GroupOpDlg::isValid() { // Verify validity of group name - if ( myNameEdit->text() == "" ) - { - QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), - tr( "SMESH_INSUFFICIENT_DATA" ), tr( "EMPTY_NAME" ), QMessageBox::Ok ); + if (myNameEdit->text() == "") { + QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"), + tr("EMPTY_NAME"), QMessageBox::Ok); return false; } // Verufy wheter arguments speciffiyed - if ( myGroup1->_is_nil() || myGroup2->_is_nil() ) - { - QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), - tr( "SMESH_INSUFFICIENT_DATA" ), tr( "INCORRECT_ARGUMENTS" ), QMessageBox::Ok ); + if (myGroup1->_is_nil() || myGroup2->_is_nil()) { + QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"), + tr("INCORRECT_ARGUMENTS"), QMessageBox::Ok); return false; } // Verify whether arguments belongs to same mesh SMESH::SMESH_Mesh_ptr aMesh1 = myGroup1->GetMesh(); SMESH::SMESH_Mesh_ptr aMesh2 = myGroup2->GetMesh(); - + int aMeshId1 = !aMesh1->_is_nil() ? aMesh1->GetId() : -1; int aMeshId2 = !aMesh2->_is_nil() ? aMesh2->GetId() : -1; - - if ( aMeshId1 != aMeshId2 || aMeshId1 == -1 ) - { - QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), - tr( "SMESH_INSUFFICIENT_DATA" ), tr( "DIFF_MESHES" ), QMessageBox::Ok ); + + if (aMeshId1 != aMeshId2 || aMeshId1 == -1) { + QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"), + tr("DIFF_MESHES"), QMessageBox::Ok); return false; } // Verify whether groups have same types of entities - if ( myGroup1->GetType() != myGroup2->GetType() ) - { - QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), - tr( "SMESH_INSUFFICIENT_DATA" ), tr( "DIFF_TYPES" ), QMessageBox::Ok ); + if (myGroup1->GetType() != myGroup2->GetType()) { + QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"), + tr("DIFF_TYPES"), QMessageBox::Ok); return false; } - - + return true; } //======================================================================= // name : SMESHGUI_GroupOpDlg::onApply -// Purpose : SLOT called when "Apply" button pressed. +// Purpose : SLOT called when "Apply" button pressed. //======================================================================= bool SMESHGUI_GroupOpDlg::onApply() { - if ( !isValid() || SMESHGUI::GetSMESHGUI()->ActiveStudyLocked() ) + if (!isValid() || SMESHGUI::GetSMESHGUI()->isActiveStudyLocked()) return false; - + SMESH::SMESH_Mesh_ptr aMesh = myGroup1->GetMesh(); QString aName = myNameEdit->text(); SMESH::SMESH_Group_ptr aNewGrp = SMESH::SMESH_Group::_nil(); - - if ( myMode == UNION ) aNewGrp = aMesh->UnionGroups( myGroup1, myGroup2, aName.latin1() ); - else if ( myMode == INTERSECT ) aNewGrp = aMesh->IntersectGroups( myGroup1, myGroup2, aName.latin1() ); - else aNewGrp = aMesh->CutGroups( myGroup1, myGroup2, aName.latin1() ); - if ( !aNewGrp->_is_nil() ) - { - SMESHGUI::GetSMESHGUI()->GetActiveStudy()->updateObjBrowser( true ); + if (myMode == UNION) aNewGrp = aMesh->UnionGroups(myGroup1, myGroup2, aName.latin1()); + else if (myMode == INTERSECT) aNewGrp = aMesh->IntersectGroups(myGroup1, myGroup2, aName.latin1()); + else aNewGrp = aMesh->CutGroups(myGroup1, myGroup2, aName.latin1()); + + if (!aNewGrp->_is_nil()) { + SMESHGUI::GetSMESHGUI()->updateObjBrowser(true); reset(); return true; - } - else - { - QMessageBox::critical( SMESHGUI::GetSMESHGUI()->GetDesktop(), - tr( "SMESH_ERROR" ), tr( "SMESH_OPERATION_FAILED" ), "OK" ); + } else { + QMessageBox::critical(SMESHGUI::desktop(), tr("SMESH_ERROR"), + tr("SMESH_OPERATION_FAILED"), "OK"); return false; } } //======================================================================= // name : SMESHGUI_GroupOpDlg::onOk -// Purpose : SLOT called when "Ok" button pressed. +// Purpose : SLOT called when "Ok" button pressed. //======================================================================= void SMESHGUI_GroupOpDlg::onOk() { - if ( onApply() ) + if (onApply()) onClose(); } @@ -281,11 +285,11 @@ void SMESHGUI_GroupOpDlg::onOk() //======================================================================= void SMESHGUI_GroupOpDlg::onClose() { - QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); - disconnect( mySelection, 0, this, 0 ); - disconnect( SMESHGUI::GetSMESHGUI(), 0, this, 0 ); + mySelectionMgr->setSelectionModes(ActorSelection); + disconnect(mySelectionMgr, 0, this, 0); + disconnect(SMESHGUI::GetSMESHGUI(), 0, this, 0); SMESHGUI::GetSMESHGUI()->ResetState(); - mySelection->ClearFilters(); + mySelectionMgr->clearFilters(); reject(); } @@ -295,23 +299,26 @@ void SMESHGUI_GroupOpDlg::onClose() //======================================================================= void SMESHGUI_GroupOpDlg::onSelectionDone() { - if ( myFocusWg == myEdit1 ) + if (myFocusWg == myEdit1) myGroup1 = SMESH::SMESH_GroupBase::_nil(); else myGroup2 = SMESH::SMESH_GroupBase::_nil(); - - myFocusWg->setText( "" ); - - if ( mySelection->IObjectCount() == 1 ) - { - SMESH::SMESH_GroupBase_var aGroup = - SMESH::IObjectToInterface( mySelection->firstIObject() ); - - if ( !aGroup->_is_nil() ) - { - myFocusWg->setText( aGroup->GetName() ); - if ( myFocusWg == myEdit1 ) + myFocusWg->setText(""); + + SALOME_ListIO aList; + mySelectionMgr->selectedObjects(aList); + + if (aList.Extent() == 1) { + SMESH::SMESH_GroupBase_var aGroup = + SMESH::IObjectToInterface(aList.First()); + + if (!aGroup->_is_nil()) + { + myFocusWg->setText(aGroup->GetName()); + myFocusWg->setCursorPosition( 0 ); + + if (myFocusWg == myEdit1) myGroup1 = aGroup; else myGroup2 = aGroup; @@ -325,30 +332,33 @@ void SMESHGUI_GroupOpDlg::onSelectionDone() //======================================================================= void SMESHGUI_GroupOpDlg::onDeactivate() { - setEnabled( false ); - mySelection->ClearFilters(); + setEnabled(false); + mySelectionMgr->clearFilters(); } //======================================================================= // name : SMESHGUI_GroupOpDlg::enterEvent // Purpose : Event filter //======================================================================= -void SMESHGUI_GroupOpDlg::enterEvent( QEvent* ) +void SMESHGUI_GroupOpDlg::enterEvent (QEvent*) { - SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog() ; - setEnabled( true ); - QAD_Application::getDesktop()->SetSelectionMode( ActorSelection, true ); - mySelection->AddFilter( new SMESH_TypeFilter( GROUP ) ); + SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog(); + setEnabled(true); +#ifdef NEW_GUI + mySelectionMgr->setSelectionModes(ActorSelection, true); +#else + mySelectionMgr->setSelectionModes(ActorSelection); +#endif + mySelectionMgr->installFilter(new SMESH_TypeFilter (GROUP)); } - -//================================================================================= -// function : closeEvent() -// purpose : -//================================================================================= -void SMESHGUI_GroupOpDlg::closeEvent( QCloseEvent* ) +//======================================================================= +// name : SMESHGUI_GroupOpDlg::closeEvent +// purpose : +//======================================================================= +void SMESHGUI_GroupOpDlg::closeEvent (QCloseEvent*) { - onClose() ; + onClose(); } //======================================================================= @@ -368,34 +378,9 @@ void SMESHGUI_GroupOpDlg::onFocusChanged() //======================================================================= void SMESHGUI_GroupOpDlg::reset() { - myNameEdit->setText( "" ); - myEdit1->setText( "" ); - myEdit2->setText( "" ); + myNameEdit->setText(""); + myEdit1->setText(""); + myEdit2->setText(""); myFocusWg = myEdit1; myNameEdit->setFocus(); } - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/SMESHGUI/SMESHGUI_GroupOpDlg.h b/src/SMESHGUI/SMESHGUI_GroupOpDlg.h index a82136f14..d05201390 100644 --- a/src/SMESHGUI/SMESHGUI_GroupOpDlg.h +++ b/src/SMESHGUI/SMESHGUI_GroupOpDlg.h @@ -36,7 +36,7 @@ class QCloseEvent; class QLabel; class QFrame; class QPushButton; -class SALOME_Selection; +class SalomeApp_SelectionMgr; class QLineEdit; /* @@ -52,10 +52,10 @@ public: enum { UNION, INTERSECT, CUT }; public: - SMESHGUI_GroupOpDlg( QWidget*, SALOME_Selection*, const int ); + SMESHGUI_GroupOpDlg( QWidget*, SalomeApp_SelectionMgr*, const int ); virtual ~SMESHGUI_GroupOpDlg(); - void Init( SALOME_Selection* ) ; + void Init( SalomeApp_SelectionMgr* ) ; private: @@ -91,7 +91,7 @@ private: QPushButton* myBtn1; QPushButton* myBtn2; - SALOME_Selection* mySelection; + SalomeApp_SelectionMgr* mySelectionMgr; int myMode; QLineEdit* myFocusWg; @@ -102,8 +102,3 @@ private: }; #endif - - - - - diff --git a/src/SMESHGUI/SMESHGUI_GroupUtils.cxx b/src/SMESHGUI/SMESHGUI_GroupUtils.cxx index 14462a9be..d2aa17f3a 100644 --- a/src/SMESHGUI/SMESHGUI_GroupUtils.cxx +++ b/src/SMESHGUI/SMESHGUI_GroupUtils.cxx @@ -1,29 +1,34 @@ // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -#include "QAD_Study.h" -#include "SALOMEGUI_QtCatchCorbaException.hxx" - #include "SMESHGUI_GroupUtils.h" + +#include "SMESHGUI.h" #include "SMESHGUI_Utils.h" +#include "SUIT_Session.h" +#include "SalomeApp_Application.h" +#include "SalomeApp_Tools.h" + +#include "OB_Browser.h" + namespace SMESH { @@ -37,10 +42,12 @@ namespace SMESH aGroup = theMesh->CreateGroup( theType, theGroupName ); } catch( const SALOME::SALOME_Exception& S_ex ) { - QtCatchCorbaException( S_ex ); + SalomeApp_Tools::QtCatchCorbaException( S_ex ); } - GetActiveStudy()->updateObjBrowser( true ); + //SalomeApp_Application* app = + // dynamic_cast(SUIT_Session::session()->activeApplication()); + //if (app) app->objectBrowser()->updateTree(); + SMESHGUI::GetSMESHGUI()->updateObjBrowser(); return aGroup._retn(); } - } diff --git a/src/SMESHGUI/SMESHGUI_HypothesesUtils.cxx b/src/SMESHGUI/SMESHGUI_HypothesesUtils.cxx index 5d47d4c19..619ec75dc 100644 --- a/src/SMESHGUI/SMESHGUI_HypothesesUtils.cxx +++ b/src/SMESHGUI/SMESHGUI_HypothesesUtils.cxx @@ -1,49 +1,54 @@ // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +#include "SMESHGUI_HypothesesUtils.h" + +#include "SMESHGUI.h" +#include "SMESHGUI_Hypotheses.h" +#include "SMESHGUI_XmlHandler.h" +#include "SMESHGUI_Utils.h" +#include "SMESHGUI_GEOMGenUtils.h" + +#include "SUIT_Tools.h" +#include "SUIT_Desktop.h" +#include "SUIT_MessageBox.h" +#include "SUIT_OverrideCursor.h" +#include "SUIT_ResourceMgr.h" +#include "SUIT_Session.h" + +#include "OB_Browser.h" + +#include "SalomeApp_Study.h" +#include "SalomeApp_Tools.h" +#include "SalomeApp_Application.h" + +#include +#include + +#include "SALOMEconfig.h" +#include CORBA_CLIENT_HEADER(SALOMEDS_Attributes) + #include #include #include -#include "QAD.h" -#include "QAD_Tools.h" -#include "QAD_Config.h" -#include "QAD_Desktop.h" -#include "QAD_MessageBox.h" -#include "QAD_WaitCursor.h" -#include "QAD_ResourceMgr.h" - -#include "SALOMEGUI_QtCatchCorbaException.hxx" - -#include "SMESHGUI_HypothesesUtils.h" -#include "SMESHGUI_Hypotheses.h" -#include "SMESHGUI_XmlHandler.h" -#include "SMESHGUI.h" - -#include "SMESHGUI_Utils.h" -#include "SMESHGUI_GEOMGenUtils.h" -#include "SMESHGUI_SMESHGenUtils.h" - -#include "SALOMEconfig.h" -#include CORBA_CLIENT_HEADER(SALOMEDS_Attributes) - #ifdef _DEBUG_ static int MYDEBUG = 0; #else @@ -51,7 +56,7 @@ static int MYDEBUG = 0; #endif namespace SMESH{ - + using namespace std; typedef map THypothesisDataMap; @@ -61,12 +66,12 @@ namespace SMESH{ typedef map THypCreatorMap; THypCreatorMap myHypCreatorMap; - void addMap( const THypothesisDataMap& theMap, + void addMap(const THypothesisDataMap& theMap, THypothesisDataMap& toMap) { THypothesisDataMap::const_iterator it; - for ( it = theMap.begin(); it != theMap.end(); it++ ) - toMap.insert( *it ); + for (it = theMap.begin(); it != theMap.end(); it++) + toMap.insert(*it); } @@ -74,79 +79,79 @@ namespace SMESH{ SMESH::SMESH_Hypothesis_ptr theHyp, const bool theIsAddition) { - if ( theHypStatus > SMESH::HYP_OK ) { - + if (theHypStatus > SMESH::HYP_OK) { + // get Hyp name QString aHypName ("NULL Hypothesis"); - if ( !CORBA::is_nil( theHyp )) { - SALOMEDS::SObject_var Shyp = SMESH::FindSObject( theHyp ); - if ( !CORBA::is_nil( Shyp )) + if (!CORBA::is_nil(theHyp)) { + _PTR(SObject) Shyp = SMESH::FindSObject(theHyp); + if (Shyp) // name in study - aHypName = Shyp->GetName(); + aHypName = Shyp->GetName().c_str(); else // label in xml file - aHypName = GetHypothesisData( theHyp->GetName() )->Label; + aHypName = GetHypothesisData(theHyp->GetName())->Label; } // message - bool isFatal = ( theHypStatus >= SMESH::HYP_UNKNOWN_FATAL ); + bool isFatal = (theHypStatus >= SMESH::HYP_UNKNOWN_FATAL); QString aMsg; - if ( theIsAddition ) - aMsg = ( isFatal ? "SMESH_CANT_ADD_HYP" : "SMESH_ADD_HYP_WRN"); + if (theIsAddition) + aMsg = (isFatal ? "SMESH_CANT_ADD_HYP" : "SMESH_ADD_HYP_WRN"); else - aMsg = ( isFatal ? "SMESH_CANT_RM_HYP" : "SMESH_RM_HYP_WRN"); - - aMsg = QObject::tr( aMsg ).arg( aHypName ) + - QObject::tr( QString( "SMESH_HYP_%1" ).arg( theHypStatus )); - - QAD_MessageBox::warn1(QAD_Application::getDesktop(), - QObject::tr( "SMESH_WRN_WARNING" ), + aMsg = (isFatal ? "SMESH_CANT_RM_HYP" : "SMESH_RM_HYP_WRN"); + + aMsg = QObject::tr(aMsg).arg(aHypName) + + QObject::tr(QString("SMESH_HYP_%1").arg(theHypStatus)); + + SUIT_MessageBox::warn1(SMESHGUI::desktop(), + QObject::tr("SMESH_WRN_WARNING"), aMsg, - QObject::tr( "SMESH_BUT_OK" )); + QObject::tr("SMESH_BUT_OK")); } } void InitAvailableHypotheses() { - QAD_WaitCursor wc; + SUIT_OverrideCursor wc; if (myHypothesesMap.empty() && myAlgorithmsMap.empty()) { // Resource manager - QAD_ResourceMgr* resMgr = QAD_Desktop::createResourceManager(); + SUIT_ResourceMgr* resMgr = SMESHGUI::resourceMgr(); if (!resMgr) return; - + // Find name of a resource XML file ("SMESH_Meshers.xml"); QString HypsXml; char* cenv = getenv("SMESH_MeshersList"); if (cenv) HypsXml.sprintf("%s", cenv); - - QStringList HypsXmlList = QStringList::split( ":", HypsXml, false ); + + QStringList HypsXmlList = QStringList::split(":", HypsXml, false); if (HypsXmlList.count() == 0) { - QAD_MessageBox::error1(QAD_Application::getDesktop(), + SUIT_MessageBox::error1(SMESHGUI::desktop(), QObject::tr("SMESH_WRN_WARNING"), QObject::tr("MESHERS_FILE_NO_VARIABLE"), QObject::tr("SMESH_BUT_OK")); return; } - + // loop on files in HypsXml QString aNoAccessFiles; - for ( int i = 0; i < HypsXmlList.count(); i++ ) { + for (int i = 0; i < HypsXmlList.count(); i++) { QString HypsXml = HypsXmlList[ i ]; - + // Find full path to the resource XML file QString xmlFile = HypsXml + ".xml"; - xmlFile = QAD_Tools::addSlash(resMgr->findFile(xmlFile, HypsXml)) + xmlFile; - - QFile file (QAD_Tools::unix2win(xmlFile)); + xmlFile = resMgr->path("resources", "SMESH", xmlFile); + + QFile file (xmlFile); if (file.exists() && file.open(IO_ReadOnly)) { file.close(); - + SMESHGUI_XmlHandler* aXmlHandler = new SMESHGUI_XmlHandler(); ASSERT(aXmlHandler); - + QXmlInputSource source (file); QXmlSimpleReader reader; reader.setContentHandler(aXmlHandler); @@ -154,11 +159,11 @@ namespace SMESH{ bool ok = reader.parse(source); file.close(); if (ok) { - addMap( aXmlHandler->myHypothesesMap, myHypothesesMap ); - addMap( aXmlHandler->myAlgorithmsMap, myAlgorithmsMap ); + addMap(aXmlHandler->myHypothesesMap, myHypothesesMap); + addMap(aXmlHandler->myAlgorithmsMap, myAlgorithmsMap); } else { - QAD_MessageBox::error1(QAD_Application::getDesktop(), + SUIT_MessageBox::error1(SMESHGUI::desktop(), QObject::tr("INF_PARSE_ERROR"), QObject::tr(aXmlHandler->errorProtocol()), QObject::tr("SMESH_BUT_OK")); @@ -171,17 +176,17 @@ namespace SMESH{ aNoAccessFiles += ", " + xmlFile; } } // end loop - - + + if (!aNoAccessFiles.isEmpty()) { QString aMess = QObject::tr("MESHERS_FILE_CANT_OPEN") + " " + aNoAccessFiles + "\n"; aMess += QObject::tr("MESHERS_FILE_CHECK_VARIABLE"); - wc.stop(); - QAD_MessageBox::warn1(QAD_Application::getDesktop(), + wc.suspend(); + SUIT_MessageBox::warn1(SMESHGUI::desktop(), QObject::tr("SMESH_WRN_WARNING"), aMess, QObject::tr("SMESH_BUT_OK")); - wc.start(); + wc.resume(); } } } @@ -190,10 +195,10 @@ namespace SMESH{ QStringList GetAvailableHypotheses(const bool isAlgo) { QStringList aHypList; - + // Init list of available hypotheses, if needed InitAvailableHypotheses(); - + // fill list of hypotheses/algorithms THypothesisDataMap::iterator anIter; if (isAlgo) { @@ -208,10 +213,10 @@ namespace SMESH{ aHypList.append(((*anIter).first).c_str()); } } - + return aHypList; } - + HypothesisData* GetHypothesisData (const char* aHypType) { @@ -237,7 +242,7 @@ namespace SMESH{ if(MYDEBUG) MESSAGE("Get HypothesisCreator for " << aHypType); SMESHGUI_GenericHypothesisCreator* aCreator = 0; - + // check, if creator for this hypothesis type already exists if (myHypCreatorMap.find(aHypType) != myHypCreatorMap.end()) { aCreator = myHypCreatorMap[aHypType]; @@ -270,7 +275,7 @@ namespace SMESH{ typedef SMESHGUI_GenericHypothesisCreator* (*GetHypothesisCreator) \ (QString aHypType, QString aServerLibName, SMESHGUI* aSMESHGUI); GetHypothesisCreator procHandle = - (GetHypothesisCreator)dlsym( libHandle, "GetHypothesisCreator" ); + (GetHypothesisCreator)dlsym(libHandle, "GetHypothesisCreator"); if (!procHandle) { if(MYDEBUG) MESSAGE("bad hypothesis client plugin library"); dlclose(libHandle); @@ -290,7 +295,7 @@ namespace SMESH{ } } catch (const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); + SalomeApp_Tools::QtCatchCorbaException(S_ex); } } @@ -305,24 +310,29 @@ namespace SMESH{ if(MYDEBUG) MESSAGE("Create " << aHypType << " with name " << aHypName); SMESH::SMESH_Hypothesis_var Hyp; - + HypothesisData* aHypData = GetHypothesisData(aHypType); QString aServLib = aHypData->ServerLibName; - + try { - Hyp = SMESH::GetSMESHGen()->CreateHypothesis(aHypType, aServLib); + Hyp = SMESHGUI::GetSMESHGen()->CreateHypothesis(aHypType, aServLib); if (!Hyp->_is_nil()) { - SALOMEDS::SObject_var SHyp = SMESH::FindSObject(Hyp.in()); - if (!SHyp->_is_nil()) { - if ( strcmp(aHypName,"") != 0 ) - SMESH::SetName( SHyp, aHypName ); - GetActiveStudy()->updateObjBrowser(true); + _PTR(SObject) SHyp = SMESH::FindSObject(Hyp.in()); + if (SHyp) { + //if (strcmp(aHypName,"") != 0) + if (strlen(aHypName) > 0) + SMESH::SetName(SHyp, aHypName); + //SalomeApp_Application* app = + // dynamic_cast(SUIT_Session::session()->activeApplication()); + //if (app) + // app->objectBrowser()->updateTree(); + SMESHGUI::GetSMESHGUI()->updateObjBrowser(); return Hyp._retn(); } } } catch (const SALOME::SALOME_Exception & S_ex) { - QtCatchCorbaException(S_ex); + SalomeApp_Tools::QtCatchCorbaException(S_ex); } return SMESH::SMESH_Hypothesis::_nil(); @@ -332,29 +342,29 @@ namespace SMESH{ bool AddHypothesisOnMesh (SMESH::SMESH_Mesh_ptr aMesh, SMESH::SMESH_Hypothesis_ptr aHyp) { if(MYDEBUG) MESSAGE ("SMESHGUI::AddHypothesisOnMesh"); - int res = SMESH::HYP_UNKNOWN_FATAL; - QAD_WaitCursor wc; - - if ( !aMesh->_is_nil() ) { - SALOMEDS::SObject_var SM = SMESH::FindSObject( aMesh ); + int res = SMESH::HYP_UNKNOWN_FATAL; + SUIT_OverrideCursor wc; + + if (!aMesh->_is_nil()) { + _PTR(SObject) SM = SMESH::FindSObject(aMesh); GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh(SM); try { - res = aMesh->AddHypothesis( aShapeObject, aHyp ); - if ( res < SMESH::HYP_UNKNOWN_FATAL ) { - SALOMEDS::SObject_var SH = SMESH::FindSObject(aHyp); - if ( !SM->_is_nil() && !SH->_is_nil() ) { + res = aMesh->AddHypothesis(aShapeObject, aHyp); + if (res < SMESH::HYP_UNKNOWN_FATAL) { + _PTR(SObject) SH = SMESH::FindSObject(aHyp); + if (SM && SH) { SMESH::ModifiedMesh(SM, false); } } - if ( res > SMESH::HYP_OK ) { - wc.stop(); - processHypothesisStatus( res, aHyp, true ); - wc.start(); + if (res > SMESH::HYP_OK) { + wc.suspend(); + processHypothesisStatus(res, aHyp, true); + wc.resume(); } } - catch( const SALOME::SALOME_Exception& S_ex ) { - wc.stop(); - QtCatchCorbaException( S_ex ); + catch(const SALOME::SALOME_Exception& S_ex) { + wc.suspend(); + SalomeApp_Tools::QtCatchCorbaException(S_ex); res = SMESH::HYP_UNKNOWN_FATAL; } } @@ -364,164 +374,164 @@ namespace SMESH{ bool AddHypothesisOnSubMesh (SMESH::SMESH_subMesh_ptr aSubMesh, SMESH::SMESH_Hypothesis_ptr aHyp) { - if(MYDEBUG) MESSAGE( "SMESHGUI::AddHypothesisOnSubMesh() "); + if(MYDEBUG) MESSAGE("SMESHGUI::AddHypothesisOnSubMesh() "); int res = SMESH::HYP_UNKNOWN_FATAL; - QAD_WaitCursor wc; - - if ( !aSubMesh->_is_nil() && ! aHyp->_is_nil() ) { + SUIT_OverrideCursor wc; + + if (!aSubMesh->_is_nil() && ! aHyp->_is_nil()) { try { SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather(); - SALOMEDS::SObject_var SsubM = SMESH::FindSObject( aSubMesh ); - GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh( SsubM ); - if ( !aMesh->_is_nil() && !SsubM->_is_nil() && !aShapeObject->_is_nil() ) { - res = aMesh->AddHypothesis( aShapeObject, aHyp ); - if ( res < SMESH::HYP_UNKNOWN_FATAL ) { - SALOMEDS::SObject_var meshSO = SMESH::FindSObject( aMesh ); - if ( !meshSO->_is_nil() ) - SMESH::ModifiedMesh( meshSO, false ); + _PTR(SObject) SsubM = SMESH::FindSObject(aSubMesh); + GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh(SsubM); + if (!aMesh->_is_nil() && SsubM && !aShapeObject->_is_nil()) { + res = aMesh->AddHypothesis(aShapeObject, aHyp); + if (res < SMESH::HYP_UNKNOWN_FATAL) { + _PTR(SObject) meshSO = SMESH::FindSObject(aMesh); + if (meshSO) + SMESH::ModifiedMesh(meshSO, false); } - if ( res > SMESH::HYP_OK ) { - wc.stop(); - processHypothesisStatus( res, aHyp, true ); - wc.start(); + if (res > SMESH::HYP_OK) { + wc.suspend(); + processHypothesisStatus(res, aHyp, true); + wc.resume(); } } else { - SCRUTE( aHyp->_is_nil() ); - SCRUTE( aMesh->_is_nil() ); - SCRUTE( SsubM->_is_nil() ); - SCRUTE( aShapeObject->_is_nil() ); + SCRUTE(aHyp->_is_nil()); + SCRUTE(aMesh->_is_nil()); + SCRUTE(!SsubM); + SCRUTE(aShapeObject->_is_nil()); } } - catch( const SALOME::SALOME_Exception& S_ex ) { - wc.stop(); - QtCatchCorbaException( S_ex ); + catch(const SALOME::SALOME_Exception& S_ex) { + wc.suspend(); + SalomeApp_Tools::QtCatchCorbaException(S_ex); res = SMESH::HYP_UNKNOWN_FATAL; } } else { - SCRUTE( aSubMesh->_is_nil() ); - SCRUTE( aHyp->_is_nil() ); + SCRUTE(aSubMesh->_is_nil()); + SCRUTE(aHyp->_is_nil()); } return res < SMESH::HYP_UNKNOWN_FATAL; } - + bool RemoveHypothesisOrAlgorithmOnMesh (const Handle(SALOME_InteractiveObject)& IObject) { int res = SMESH::HYP_UNKNOWN_FATAL; - QAD_WaitCursor wc; - + SUIT_OverrideCursor wc; + if (IObject->hasReference()) { try { - SALOMEDS::Study_var aStudy = GetActiveStudyDocument(); + _PTR(Study) aStudy = GetActiveStudyDocument(); SMESH_Hypothesis_var anHyp = IObjectToInterface(IObject); - SALOMEDS::SObject_var aHypSObj = aStudy->FindObjectID(IObject->getReference()); - if (!aHypSObj->_is_nil()) { - SALOMEDS::SObject_var MorSM = SMESH::GetMeshOrSubmesh(aHypSObj); - if (!MorSM->_is_nil()) { + _PTR(SObject) aHypSObj = aStudy->FindObjectID(IObject->getReference()); + if (aHypSObj) { + _PTR(SObject) MorSM = SMESH::GetMeshOrSubmesh(aHypSObj); + if (MorSM) { GEOM::GEOM_Object_var aShape = SMESH::GetShapeOnMeshOrSubMesh(MorSM); if (!aShape->_is_nil()){ - SMESH::SMESH_Mesh_var aMesh = + SMESH::SMESH_Mesh_var aMesh = SMESH::SObjectToInterface(MorSM); SMESH::SMESH_subMesh_var aSubMesh = SMESH::SObjectToInterface(MorSM); - + if (!aSubMesh->_is_nil()) aMesh = aSubMesh->GetFather(); - + if (!aMesh->_is_nil()) { res = aMesh->RemoveHypothesis(aShape, anHyp); - if ( res < SMESH::HYP_UNKNOWN_FATAL ) { - SALOMEDS::SObject_var meshSO = SMESH::FindSObject( aMesh ); - if ( !meshSO->_is_nil() ) + if (res < SMESH::HYP_UNKNOWN_FATAL) { + _PTR(SObject) meshSO = SMESH::FindSObject(aMesh); + if (meshSO) SMESH::ModifiedMesh(meshSO, false); } - if ( res > SMESH::HYP_OK ) { - wc.stop(); - processHypothesisStatus( res, anHyp, false ); - wc.start(); + if (res > SMESH::HYP_OK) { + wc.suspend(); + processHypothesisStatus(res, anHyp, false); + wc.resume(); } } } } } } - catch( const SALOME::SALOME_Exception& S_ex ) { - wc.stop(); - QtCatchCorbaException( S_ex ); + catch(const SALOME::SALOME_Exception& S_ex) { + wc.suspend(); + SalomeApp_Tools::QtCatchCorbaException(S_ex); res = SMESH::HYP_UNKNOWN_FATAL; } - } + } else if (IObject->hasEntry()) { if(MYDEBUG) MESSAGE("IObject entry " << IObject->getEntry()); } return res < SMESH::HYP_UNKNOWN_FATAL; } - - bool RemoveHypothesisOrAlgorithmOnMesh (SALOMEDS::SObject_ptr MorSM, + + bool RemoveHypothesisOrAlgorithmOnMesh (_PTR(SObject) MorSM, SMESH::SMESH_Hypothesis_ptr anHyp) { - SALOMEDS::SObject_var AHR, aRef; SALOMEDS::GenericAttribute_var anAttr; SALOMEDS::AttributeIOR_var anIOR; int res = SMESH::HYP_UNKNOWN_FATAL; - QAD_WaitCursor wc; - - if (!MorSM->_is_nil()) { + SUIT_OverrideCursor wc; + + if (MorSM) { try { GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh(MorSM); if (!aShapeObject->_is_nil()) { SMESH::SMESH_Mesh_var aMesh = SMESH::SObjectToInterface(MorSM); SMESH::SMESH_subMesh_var aSubMesh = SMESH::SObjectToInterface(MorSM); - - if ( !aSubMesh->_is_nil() ) + + if (!aSubMesh->_is_nil()) aMesh = aSubMesh->GetFather(); - + if (!aMesh->_is_nil()) { res = aMesh->RemoveHypothesis(aShapeObject, anHyp); - if ( res < SMESH::HYP_UNKNOWN_FATAL ) { - SALOMEDS::SObject_var meshSO = SMESH::FindSObject( aMesh ); - if ( !meshSO->_is_nil() ) + if (res < SMESH::HYP_UNKNOWN_FATAL) { + _PTR(SObject) meshSO = SMESH::FindSObject(aMesh); + if (meshSO) SMESH::ModifiedMesh(meshSO, false); } - if ( res > SMESH::HYP_OK ) { - wc.stop(); - processHypothesisStatus( res, anHyp, false ); - wc.start(); + if (res > SMESH::HYP_OK) { + wc.suspend(); + processHypothesisStatus(res, anHyp, false); + wc.resume(); } } } - } catch( const SALOME::SALOME_Exception& S_ex ) { - wc.stop(); - QtCatchCorbaException( S_ex ); + } catch(const SALOME::SALOME_Exception& S_ex) { + wc.suspend(); + SalomeApp_Tools::QtCatchCorbaException(S_ex); res = SMESH::HYP_UNKNOWN_FATAL; } } return res < SMESH::HYP_UNKNOWN_FATAL; } - SALOMEDS::Study::ListOfSObject* GetMeshesUsingAlgoOrHypothesis( SMESH::SMESH_Hypothesis_ptr AlgoOrHyp ) + SObjectList GetMeshesUsingAlgoOrHypothesis(SMESH::SMESH_Hypothesis_ptr AlgoOrHyp) { - SALOMEDS::Study::ListOfSObject_var listSOmesh = - new SALOMEDS::Study::ListOfSObject; - listSOmesh->length(0); + SObjectList listSOmesh; + listSOmesh.resize(0); + unsigned int index = 0; if (!AlgoOrHyp->_is_nil()) { - SALOMEDS::SObject_var SO_Hypothesis = SMESH::FindSObject(AlgoOrHyp); - if (!SO_Hypothesis->_is_nil()) { - SALOMEDS::Study::ListOfSObject_var listSO = - GetActiveStudyDocument()->FindDependances(SO_Hypothesis); - if(MYDEBUG) MESSAGE("SMESHGUI::GetMeshesUsingAlgoOrHypothesis(): dependency number ="<length()); - for (unsigned int i = 0; i < listSO->length(); i++) { - SALOMEDS::SObject_ptr SO = listSO[i]; - if (!SO->_is_nil()) { - SALOMEDS::SObject_var aFather = SO->GetFather(); - if (!aFather->_is_nil()) { - SALOMEDS::SObject_var SOfatherFather = aFather->GetFather(); - if (!SOfatherFather->_is_nil()) { + _PTR(SObject) SO_Hypothesis = SMESH::FindSObject(AlgoOrHyp); + if (SO_Hypothesis) { + SObjectList listSO = + SMESHGUI::activeStudy()->studyDS()->FindDependances(SO_Hypothesis); + + if(MYDEBUG) MESSAGE("SMESHGUI::GetMeshesUsingAlgoOrHypothesis(): dependency number ="<GetFather(); + if (aFather) { + _PTR(SObject) SOfatherFather = aFather->GetFather(); + if (SOfatherFather) { if(MYDEBUG) MESSAGE("SMESHGUI::GetMeshesUsingAlgoOrHypothesis(): dependency added to list"); index++; - listSOmesh->length(index); + listSOmesh.resize(index); listSOmesh[index - 1] = SOfatherFather; } } @@ -529,8 +539,7 @@ namespace SMESH{ } } } - if(MYDEBUG) MESSAGE("SMESHGUI::GetMeshesUsingAlgoOrHypothesis(): completed"); - return listSOmesh._retn(); + if (MYDEBUG) MESSAGE("SMESHGUI::GetMeshesUsingAlgoOrHypothesis(): completed"); + return listSOmesh; } - } diff --git a/src/SMESHGUI/SMESHGUI_HypothesesUtils.h b/src/SMESHGUI/SMESHGUI_HypothesesUtils.h index d87f45cb8..16d935b1e 100644 --- a/src/SMESHGUI/SMESHGUI_HypothesesUtils.h +++ b/src/SMESHGUI/SMESHGUI_HypothesesUtils.h @@ -32,14 +32,18 @@ #include #include "SALOME_InteractiveObject.hxx" +#include "SALOMEDSClient_definitions.hxx" #include "SALOMEconfig.h" #include CORBA_CLIENT_HEADER(SALOMEDS) #include CORBA_SERVER_HEADER(SMESH_Mesh) #include CORBA_SERVER_HEADER(SMESH_Hypothesis) +#include + class HypothesisData; class SMESHGUI_GenericHypothesisCreator; +class SALOMEDSClient_SObject; namespace SMESH{ @@ -61,10 +65,11 @@ namespace SMESH{ bool RemoveHypothesisOrAlgorithmOnMesh(const Handle(SALOME_InteractiveObject)& IObject); - bool RemoveHypothesisOrAlgorithmOnMesh(SALOMEDS::SObject_ptr MorSM, + bool RemoveHypothesisOrAlgorithmOnMesh(_PTR(SObject) MorSM, SMESH::SMESH_Hypothesis_ptr anHyp); - SALOMEDS::Study::ListOfSObject* GetMeshesUsingAlgoOrHypothesis(SMESH::SMESH_Hypothesis_ptr AlgoOrHyp ) ; + typedef std::vector<_PTR(SObject)> SObjectList; + SObjectList GetMeshesUsingAlgoOrHypothesis(SMESH::SMESH_Hypothesis_ptr AlgoOrHyp ) ; } diff --git a/src/SMESHGUI/SMESHGUI_InitMeshDlg.cxx b/src/SMESHGUI/SMESHGUI_InitMeshDlg.cxx index 68a737503..ce686c62a 100644 --- a/src/SMESHGUI/SMESHGUI_InitMeshDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_InitMeshDlg.cxx @@ -1,23 +1,23 @@ // SMESH SMESHGUI : GUI for SMESH component // // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org // // // @@ -30,19 +30,26 @@ #include "SMESHGUI.h" #include "SMESHGUI_Utils.h" -#include "SMESHGUI_SMESHGenUtils.h" #include "SMESHGUI_HypothesesUtils.h" +#include "SMESH_TypeFilter.hxx" +#include "SMESH_NumberFilter.hxx" + #include "GEOMBase.h" -#include "QAD_Application.h" -#include "QAD_Desktop.h" -#include "QAD_MessageBox.h" -#include "QAD_WaitCursor.h" -#include "QAD_Operation.h" +#include "SUIT_Session.h" +#include "SUIT_MessageBox.h" +#include "SUIT_OverrideCursor.h" +#include "SUIT_Operation.h" +#include "SUIT_Desktop.h" +#include "SALOMEDSClient_Study.hxx" +#include "SALOMEDS_SObject.hxx" +#include "SALOME_ListIO.hxx" #include "SALOME_ListIteratorOfListIO.hxx" -#include "SALOMEGUI_QtCatchCorbaException.hxx" +#include "SalomeApp_Tools.h" + +#include "SVTK_ViewModel.h" #include "utilities.h" @@ -56,23 +63,23 @@ using namespace std; -namespace SMESH{ - SMESH::SMESH_Mesh_var InitMesh(GEOM::GEOM_Object_ptr theShapeObject, - const char* theMeshName) +namespace SMESH { + SMESH::SMESH_Mesh_var InitMesh (GEOM::GEOM_Object_ptr theShapeObject, + const char* theMeshName) { SMESH::SMESH_Mesh_var aMesh; try { - SMESH::SMESH_Gen_var aSMESHGen = SMESH::GetSMESHGen(); - if ( !aSMESHGen->_is_nil() && !theShapeObject->_is_nil() ) { - aMesh = aSMESHGen->CreateMesh( theShapeObject ); - if ( !aMesh->_is_nil() ) { - SALOMEDS::SObject_var aMeshSObject = SMESH::FindSObject( aMesh.in() ); - SMESH::SetName( aMeshSObject, theMeshName ); + SMESH::SMESH_Gen_var aSMESHGen = SMESHGUI::GetSMESHGen(); + if (!aSMESHGen->_is_nil() && !theShapeObject->_is_nil()) { + aMesh = aSMESHGen->CreateMesh(theShapeObject); + if (!aMesh->_is_nil()) { + _PTR(SObject) aMeshSObject = SMESH::FindSObject(aMesh.in()); + SMESH::SetName(aMeshSObject, theMeshName); } } } - catch( const SALOME::SALOME_Exception& S_ex ) { - QtCatchCorbaException( S_ex ); + catch (const SALOME::SALOME_Exception& S_ex) { + SalomeApp_Tools::QtCatchCorbaException(S_ex); } return aMesh._retn(); } @@ -80,162 +87,166 @@ namespace SMESH{ //================================================================================= // class : SMESHGUI_InitMeshDlg() -// purpose : Constructs a SMESHGUI_InitMeshDlg which is a child of 'parent', with the +// purpose : Constructs a SMESHGUI_InitMeshDlg which is a child of 'parent', with the // name 'name' and widget flags set to 'f'. // The dialog will by default be modeless, unless you set 'modal' to // TRUE to construct a modal dialog. //================================================================================= -SMESHGUI_InitMeshDlg::SMESHGUI_InitMeshDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl ) - : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose ) +SMESHGUI_InitMeshDlg::SMESHGUI_InitMeshDlg (SMESHGUI* theModule, const char* name, + bool modal, WFlags fl) + : QDialog( SMESH::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder | + WStyle_Title | WStyle_SysMenu | WDestructiveClose), + mySMESHGUI( theModule ), + mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ) { - QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SELECT"))); - if ( !name ) - setName( "SMESHGUI_InitMeshDlg" ); - setCaption( tr( "SMESH_INIT_MESH" ) ); - setSizeGripEnabled( TRUE ); - QGridLayout* SMESHGUI_InitMeshDlgLayout = new QGridLayout( this ); - SMESHGUI_InitMeshDlgLayout->setSpacing( 6 ); - SMESHGUI_InitMeshDlgLayout->setMargin( 11 ); - - /***************************************************************/ - GroupC1 = new QGroupBox( tr( "SMESH_ARGUMENTS" ), this, "GroupC1" ); - GroupC1->setColumnLayout(0, Qt::Vertical ); - GroupC1->layout()->setSpacing( 0 ); - GroupC1->layout()->setMargin( 0 ); - QGridLayout* GroupC1Layout = new QGridLayout( GroupC1->layout() ); - GroupC1Layout->setAlignment( Qt::AlignTop ); - GroupC1Layout->setSpacing( 6 ); - GroupC1Layout->setMargin( 11 ); + QPixmap image0 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT"))); + if (!name) + setName("SMESHGUI_InitMeshDlg"); - TextLabel_NameMesh = new QLabel( tr( "SMESH_NAME" ), GroupC1, "TextLabel_NameMesh" ); - GroupC1Layout->addWidget( TextLabel_NameMesh, 0, 0 ); - LineEdit_NameMesh = new QLineEdit( GroupC1, "LineEdit_NameMesh" ); - GroupC1Layout->addWidget( LineEdit_NameMesh, 0, 2 ); - - TextLabelC1A1 = new QLabel( tr( "SMESH_OBJECT_GEOM" ), GroupC1, "TextLabelC1A1" ); - GroupC1Layout->addWidget( TextLabelC1A1, 1, 0 ); - SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" ); - SelectButtonC1A1->setPixmap( image0 ); - SelectButtonC1A1->setToggleButton( FALSE ); - GroupC1Layout->addWidget( SelectButtonC1A1, 1, 1 ); - LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" ); - LineEditC1A1->setReadOnly( true ); - GroupC1Layout->addWidget( LineEditC1A1, 1, 2 ); - - TextLabelC1A1Hyp = new QLabel( tr( "SMESH_OBJECT_HYPOTHESIS" ), GroupC1, "TextLabelC1A1Hyp" ); - GroupC1Layout->addWidget( TextLabelC1A1Hyp, 2, 0 ); - SelectButtonC1A1Hyp = new QPushButton( GroupC1, "SelectButtonC1A1Hyp" ); - SelectButtonC1A1Hyp->setPixmap( image0 ); - GroupC1Layout->addWidget( SelectButtonC1A1Hyp, 2, 1 ); - LineEditC1A1Hyp = new QLineEdit( GroupC1, "LineEditC1A1Hyp" ); - LineEditC1A1Hyp->setReadOnly( true ); - GroupC1Layout->addWidget( LineEditC1A1Hyp, 2, 2 ); - - TextLabelC1A1Algo = new QLabel( tr( "SMESH_OBJECT_ALGORITHM" ), GroupC1, "TextLabelC1A1Algo" ); - GroupC1Layout->addWidget( TextLabelC1A1Algo, 3, 0 ); - SelectButtonC1A1Algo = new QPushButton( GroupC1, "SelectButtonC1A1Algo" ); - SelectButtonC1A1Algo->setPixmap( image0 ); - GroupC1Layout->addWidget( SelectButtonC1A1Algo, 3, 1 ); - LineEditC1A1Algo = new QLineEdit( GroupC1, "LineEditC1A1Algo" ); - LineEditC1A1Algo->setReadOnly( true ); - GroupC1Layout->addWidget( LineEditC1A1Algo, 3, 2 ); - - SMESHGUI_InitMeshDlgLayout->addWidget( GroupC1, 1, 0 ); + setCaption(tr("SMESH_INIT_MESH")); + setSizeGripEnabled(TRUE); + QGridLayout* SMESHGUI_InitMeshDlgLayout = new QGridLayout (this); + SMESHGUI_InitMeshDlgLayout->setSpacing(6); + SMESHGUI_InitMeshDlgLayout->setMargin(11); /***************************************************************/ - GroupButtons = new QGroupBox( this, "GroupButtons" ); - GroupButtons->setColumnLayout(0, Qt::Vertical ); - GroupButtons->layout()->setSpacing( 0 ); - GroupButtons->layout()->setMargin( 0 ); - QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); - GroupButtonsLayout->setAlignment( Qt::AlignTop ); - GroupButtonsLayout->setSpacing( 6 ); - GroupButtonsLayout->setMargin( 11 ); + GroupC1 = new QGroupBox(tr("SMESH_ARGUMENTS"), this, "GroupC1"); + GroupC1->setColumnLayout(0, Qt::Vertical); + GroupC1->layout()->setSpacing(0); + GroupC1->layout()->setMargin(0); + QGridLayout* GroupC1Layout = new QGridLayout(GroupC1->layout()); + GroupC1Layout->setAlignment(Qt::AlignTop); + GroupC1Layout->setSpacing(6); + GroupC1Layout->setMargin(11); - buttonOk = new QPushButton( tr( "SMESH_BUT_OK" ), GroupButtons, "buttonOk" ); - buttonOk->setAutoDefault( TRUE ); - buttonOk->setDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); + TextLabel_NameMesh = new QLabel(tr("SMESH_NAME"), GroupC1, "TextLabel_NameMesh"); + GroupC1Layout->addWidget(TextLabel_NameMesh, 0, 0); + LineEdit_NameMesh = new QLineEdit(GroupC1, "LineEdit_NameMesh"); + GroupC1Layout->addWidget(LineEdit_NameMesh, 0, 2); - buttonApply = new QPushButton( tr( "SMESH_BUT_APPLY" ), GroupButtons, "buttonApply" ); - buttonApply->setAutoDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); + TextLabelC1A1 = new QLabel(tr("SMESH_OBJECT_GEOM"), GroupC1, "TextLabelC1A1"); + GroupC1Layout->addWidget(TextLabelC1A1, 1, 0); + SelectButtonC1A1 = new QPushButton(GroupC1, "SelectButtonC1A1"); + SelectButtonC1A1->setPixmap(image0); + SelectButtonC1A1->setToggleButton(FALSE); + GroupC1Layout->addWidget(SelectButtonC1A1, 1, 1); + LineEditC1A1 = new QLineEdit(GroupC1, "LineEditC1A1"); + LineEditC1A1->setReadOnly(true); + GroupC1Layout->addWidget(LineEditC1A1, 1, 2); - GroupButtonsLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 2 ); + TextLabelC1A1Hyp = new QLabel(tr("SMESH_OBJECT_HYPOTHESIS"), GroupC1, "TextLabelC1A1Hyp"); + GroupC1Layout->addWidget(TextLabelC1A1Hyp, 2, 0); + SelectButtonC1A1Hyp = new QPushButton(GroupC1, "SelectButtonC1A1Hyp"); + SelectButtonC1A1Hyp->setPixmap(image0); + GroupC1Layout->addWidget(SelectButtonC1A1Hyp, 2, 1); + LineEditC1A1Hyp = new QLineEdit(GroupC1, "LineEditC1A1Hyp"); + LineEditC1A1Hyp->setReadOnly(true); + GroupC1Layout->addWidget(LineEditC1A1Hyp, 2, 2); - buttonCancel = new QPushButton( tr( "SMESH_BUT_CLOSE" ), GroupButtons, "buttonCancel" ); - buttonCancel->setAutoDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonCancel, 0, 3 ); + TextLabelC1A1Algo = new QLabel(tr("SMESH_OBJECT_ALGORITHM"), GroupC1, "TextLabelC1A1Algo"); + GroupC1Layout->addWidget(TextLabelC1A1Algo, 3, 0); + SelectButtonC1A1Algo = new QPushButton(GroupC1, "SelectButtonC1A1Algo"); + SelectButtonC1A1Algo->setPixmap(image0); + GroupC1Layout->addWidget(SelectButtonC1A1Algo, 3, 1); + LineEditC1A1Algo = new QLineEdit(GroupC1, "LineEditC1A1Algo"); + LineEditC1A1Algo->setReadOnly(true); + GroupC1Layout->addWidget(LineEditC1A1Algo, 3, 2); - SMESHGUI_InitMeshDlgLayout->addWidget( GroupButtons, 2, 0 ); + SMESHGUI_InitMeshDlgLayout->addWidget(GroupC1, 1, 0); /***************************************************************/ - Init( Sel ) ; + GroupButtons = new QGroupBox(this, "GroupButtons"); + GroupButtons->setColumnLayout(0, Qt::Vertical); + GroupButtons->layout()->setSpacing(0); + GroupButtons->layout()->setMargin(0); + QGridLayout* GroupButtonsLayout = new QGridLayout(GroupButtons->layout()); + GroupButtonsLayout->setAlignment(Qt::AlignTop); + GroupButtonsLayout->setSpacing(6); + GroupButtonsLayout->setMargin(11); + + buttonOk = new QPushButton(tr("SMESH_BUT_OK"), GroupButtons, "buttonOk"); + buttonOk->setAutoDefault(TRUE); + buttonOk->setDefault(TRUE); + GroupButtonsLayout->addWidget(buttonOk, 0, 0); + + buttonApply = new QPushButton(tr("SMESH_BUT_APPLY"), GroupButtons, "buttonApply"); + buttonApply->setAutoDefault(TRUE); + GroupButtonsLayout->addWidget(buttonApply, 0, 1); + + GroupButtonsLayout->addItem(new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, 2); + + buttonCancel = new QPushButton(tr("SMESH_BUT_CLOSE"), GroupButtons, "buttonCancel"); + buttonCancel->setAutoDefault(TRUE); + GroupButtonsLayout->addWidget(buttonCancel, 0, 3); + + SMESHGUI_InitMeshDlgLayout->addWidget(GroupButtons, 2, 0); + + /***************************************************************/ + Init(); } - //================================================================================= // function : ~SMESHGUI_InitMeshDlg() // purpose : Destroys the object and frees any allocated resources //================================================================================= SMESHGUI_InitMeshDlg::~SMESHGUI_InitMeshDlg() { - // no need to delete child widgets, Qt does it all for us + // no need to delete child widgets, Qt does it all for us } - //================================================================================= // function : Init() // purpose : //================================================================================= -void SMESHGUI_InitMeshDlg::Init( SALOME_Selection* Sel ) +void SMESHGUI_InitMeshDlg::Init () { - mySelection = Sel; - mySMESHGUI = SMESHGUI::GetSMESHGUI() ; - mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; + mySMESHGUI->SetActiveDialogBox((QDialog*)this); - myGeomFilter = new SALOME_TypeFilter( "GEOM" ); - myAlgorithmFilter = new SMESH_TypeFilter( ALGORITHM ); - myHypothesisFilter = new SMESH_TypeFilter( HYPOTHESIS ); + //myGeomFilter = new SALOME_TypeFilter("GEOM"); + TColStd_MapOfInteger allTypesMap; + for (int i = 0; i < 10; i++) + allTypesMap.Add(i); + myGeomFilter = new SMESH_NumberFilter ("GEOM", TopAbs_SHAPE, 0, allTypesMap); + myAlgorithmFilter = new SMESH_TypeFilter (ALGORITHM); + myHypothesisFilter = new SMESH_TypeFilter (HYPOTHESIS); /* signals and slots connections */ - connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); - connect( buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) ); - connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ; + connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); + connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel())); - connect( SelectButtonC1A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; - connect( SelectButtonC1A1Hyp, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; - connect( SelectButtonC1A1Algo, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + connect(SelectButtonC1A1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(SelectButtonC1A1Hyp, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(SelectButtonC1A1Algo, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); - connect( mySMESHGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; - connect( mySMESHGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; - - int x, y ; - mySMESHGUI->DefineDlgPosition( this, x, y ) ; - this->move( x, y ) ; - this->show() ; + connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog())); + connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel())); - LineEdit_NameMesh->setText( GetDefaultMeshName() ); - LineEdit_NameMesh->setFocus() ; - myEditCurrentArgument = LineEditC1A1 ; - mySelection->ClearFilters() ; - mySelection->AddFilter( myGeomFilter ) ; + int x, y; + mySMESHGUI->DefineDlgPosition(this, x, y); + this->move(x, y); + this->show(); + + LineEdit_NameMesh->setText(GetDefaultMeshName()); + LineEdit_NameMesh->setFocus(); + myEditCurrentArgument = LineEditC1A1; + mySelectionMgr->clearFilters(); + mySelectionMgr->installFilter(myGeomFilter); SelectionIntoArgument(); UpdateControlState(); } - //================================================================================= // function : ClickOnOk() // purpose : //================================================================================= void SMESHGUI_InitMeshDlg::ClickOnOk() { - if ( this->ClickOnApply() ) - this->ClickOnCancel() ; + if (this->ClickOnApply()) + this->ClickOnCancel(); } //================================================================================= @@ -244,38 +255,41 @@ void SMESHGUI_InitMeshDlg::ClickOnOk() //================================================================================= bool SMESHGUI_InitMeshDlg::ClickOnApply() { - if (mySMESHGUI->ActiveStudyLocked()) + if (mySMESHGUI->isActiveStudyLocked()) return false; QString myNameMesh = LineEdit_NameMesh->text().stripWhiteSpace(); - if ( myNameMesh.isEmpty() ) { - QAD_MessageBox::warn1( this, tr( "SMESH_WRN_WARNING" ), tr( "SMESH_WRN_EMPTY_NAME" ), tr( "SMESH_BUT_OK" ) ); + if (myNameMesh.isEmpty()) { + SUIT_MessageBox::warn1(this, tr("SMESH_WRN_WARNING"), + tr("SMESH_WRN_EMPTY_NAME"), tr("SMESH_BUT_OK")); return false; } - - if ( myGeomShape->_is_nil() || !HypoList.count() || !AlgoList.count() ) + + if (myGeomShape->_is_nil() || !HypoList.count() || !AlgoList.count()) return false; - QAD_WaitCursor wc; + SUIT_OverrideCursor wc; - QAD_Operation* op = new QAD_Operation( mySMESHGUI->GetActiveStudy() ); + SUIT_Operation* op = + new SUIT_Operation (SUIT_Session::session()->activeApplication()); // start transaction op->start(); - + // create mesh - SMESH::SMESH_Mesh_var aMesh = SMESH::InitMesh( myGeomShape, myNameMesh ) ; - - if ( !aMesh->_is_nil() ) { + SMESH::SMESH_Mesh_var aMesh = SMESH::InitMesh(myGeomShape, myNameMesh); + + if (!aMesh->_is_nil()) { // assign hypotheses - for( int i = 0; i < HypoList.count(); i++ ) { - SALOMEDS::SObject_var aHypSO = SMESH::GetActiveStudyDocument()->FindObjectID( HypoList[i] ); - if ( !aHypSO->_is_nil() ) { - CORBA::Object_var anObject = aHypSO->GetObject(); - if ( !CORBA::is_nil( anObject ) ) { - SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis::_narrow( anObject ); - if ( !aHyp->_is_nil() ) { - if ( !SMESH::AddHypothesisOnMesh( aMesh, aHyp ) ) { + for (int i = 0; i < HypoList.count(); i++) { + _PTR(SObject) aHypSOClient = + SMESH::GetActiveStudyDocument()->FindObjectID(HypoList[i].latin1()); + if (aHypSOClient) { + CORBA::Object_var anObject = _CAST(SObject,aHypSOClient)->GetObject(); + if (!CORBA::is_nil(anObject)) { + SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis::_narrow(anObject); + if (!aHyp->_is_nil()) { + if (!SMESH::AddHypothesisOnMesh(aMesh, aHyp)) { // abort transaction op->abort(); return false; @@ -285,14 +299,15 @@ bool SMESHGUI_InitMeshDlg::ClickOnApply() } } // assign algorithms - for( int i = 0; i < AlgoList.count(); i++ ) { - SALOMEDS::SObject_var aHypSO = SMESH::GetActiveStudyDocument()->FindObjectID( AlgoList[i] ); - if ( !aHypSO->_is_nil() ) { - CORBA::Object_var anObject = aHypSO->GetObject(); - if ( !CORBA::is_nil( anObject ) ) { - SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis::_narrow( anObject ); - if ( !aHyp->_is_nil() ) { - if ( !SMESH::AddHypothesisOnMesh( aMesh, aHyp ) ) { + for (int i = 0; i < AlgoList.count(); i++) { + _PTR(SObject) aHypSOClient = + SMESH::GetActiveStudyDocument()->FindObjectID(AlgoList[i].latin1()); + if (aHypSOClient) { + CORBA::Object_var anObject = _CAST(SObject,aHypSOClient)->GetObject(); + if (!CORBA::is_nil(anObject)) { + SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis::_narrow(anObject); + if (!aHyp->_is_nil()) { + if (!SMESH::AddHypothesisOnMesh(aMesh, aHyp)) { // abort transaction op->abort(); return false; @@ -303,12 +318,12 @@ bool SMESHGUI_InitMeshDlg::ClickOnApply() } } // commit transaction - op->finish(); - LineEdit_NameMesh->setText( GetDefaultMeshName() ); + op->commit(); + mySMESHGUI->updateObjBrowser(); + LineEdit_NameMesh->setText(GetDefaultMeshName()); return true; } - //================================================================================= // function : ClickOnCancel() // purpose : @@ -318,73 +333,66 @@ void SMESHGUI_InitMeshDlg::ClickOnCancel() close(); } - //================================================================================= // function : SelectionIntoArgument() // purpose : Called when selection as changed or other case //================================================================================= void SMESHGUI_InitMeshDlg::SelectionIntoArgument() { - QString aString = ""; + QString aString = ""; - int nbSel = SMESH::GetNameOfSelectedIObjects( mySelection, aString ); + SALOME_ListIO aList; + mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type()); - if ( myEditCurrentArgument == LineEditC1A1 ) - { + int nbSel = SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString); + + if (myEditCurrentArgument == LineEditC1A1) { // geom shape - if ( nbSel != 1 ) - { + if (nbSel != 1) { myGeomShape = GEOM::GEOM_Object::_nil(); aString = ""; - } - else - { - Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ; - myGeomShape = SMESH::IObjectToInterface( IO ) ; - if ( myGeomShape->_is_nil() || !GEOMBase::IsShape( myGeomShape ) ) - { + } else { + Handle(SALOME_InteractiveObject) IO = aList.First(); + myGeomShape = SMESH::IObjectToInterface(IO); + if (myGeomShape->_is_nil() || !GEOMBase::IsShape(myGeomShape)) { myGeomShape = GEOM::GEOM_Object::_nil(); aString = ""; } } - } - else if ( myEditCurrentArgument == LineEditC1A1Hyp ) { + } else if (myEditCurrentArgument == LineEditC1A1Hyp) { // hypotheses HypoList.clear(); - if ( nbSel >= 1 ) { - SALOME_ListIteratorOfListIO Itinit( mySelection->StoredIObjects() ); - for ( ; Itinit.More(); Itinit.Next() ) { - HypoList.append( Itinit.Value()->getEntry() ); + if (nbSel >= 1) { + SALOME_ListIteratorOfListIO Itinit (aList); + for (; Itinit.More(); Itinit.Next()) { + HypoList.append(Itinit.Value()->getEntry()); } - if ( nbSel > 1 ) - aString = tr( "%1 Hypothesis" ).arg( nbSel ) ; - } - else { + if (nbSel > 1) + aString = tr("%1 Hypothesis").arg(nbSel); + } else { aString = ""; } - } - else if ( myEditCurrentArgument == LineEditC1A1Algo ) { + } else if (myEditCurrentArgument == LineEditC1A1Algo) { // algorithms - AlgoList.clear(); - if ( nbSel >= 1 ) { - SALOME_ListIteratorOfListIO Itinit( mySelection->StoredIObjects() ); - for ( ; Itinit.More(); Itinit.Next() ) { - AlgoList.append( Itinit.Value()->getEntry() ); + AlgoList.clear(); + if (nbSel >= 1) { + SALOME_ListIteratorOfListIO Itinit (aList); + for (; Itinit.More(); Itinit.Next()) { + AlgoList.append(Itinit.Value()->getEntry()); } - if ( nbSel > 1 ) - aString = tr( "%1 Algorithms" ).arg( nbSel ) ; - } - else { + if (nbSel > 1) + aString = tr("%1 Algorithms").arg(nbSel); + } else { aString = ""; } + } else { } - myEditCurrentArgument->setText(aString) ; + myEditCurrentArgument->setText(aString); UpdateControlState(); } - //================================================================================= // function : SetEditCurrentArgument() // purpose : @@ -392,23 +400,23 @@ void SMESHGUI_InitMeshDlg::SelectionIntoArgument() void SMESHGUI_InitMeshDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); - if(send == SelectButtonC1A1) { - LineEditC1A1->setFocus() ; + if (send == SelectButtonC1A1) { + LineEditC1A1->setFocus(); myEditCurrentArgument = LineEditC1A1; - mySelection->ClearFilters() ; - mySelection->AddFilter(myGeomFilter) ; - } else if( send == SelectButtonC1A1Hyp ) { - LineEditC1A1Hyp->setFocus() ; - myEditCurrentArgument = LineEditC1A1Hyp ; - mySelection->ClearFilters() ; - mySelection->AddFilter(myHypothesisFilter) ; - } else if( send == SelectButtonC1A1Algo ) { - LineEditC1A1Algo->setFocus() ; - myEditCurrentArgument = LineEditC1A1Algo ; - mySelection->ClearFilters() ; - mySelection->AddFilter(myAlgorithmFilter) ; + mySelectionMgr->clearFilters(); + mySelectionMgr->installFilter(myGeomFilter); + } else if (send == SelectButtonC1A1Hyp) { + LineEditC1A1Hyp->setFocus(); + myEditCurrentArgument = LineEditC1A1Hyp; + mySelectionMgr->clearFilters(); + mySelectionMgr->installFilter(myHypothesisFilter); + } else if (send == SelectButtonC1A1Algo) { + LineEditC1A1Algo->setFocus(); + myEditCurrentArgument = LineEditC1A1Algo; + mySelectionMgr->clearFilters(); + mySelectionMgr->installFilter(myAlgorithmFilter); } - SelectionIntoArgument() ; + SelectionIntoArgument(); } //================================================================================= @@ -417,48 +425,45 @@ void SMESHGUI_InitMeshDlg::SetEditCurrentArgument() //================================================================================= void SMESHGUI_InitMeshDlg::DeactivateActiveDialog() { - if ( GroupC1->isEnabled() ) { - disconnect( mySelection, 0, this, 0 ); - GroupC1->setEnabled(false) ; - GroupButtons->setEnabled(false) ; + if (GroupC1->isEnabled()) { + disconnect(mySelectionMgr, 0, this, 0); + GroupC1->setEnabled(false); + GroupButtons->setEnabled(false); } } - //================================================================================= // function : ActivateThisDialog() // purpose : //================================================================================= void SMESHGUI_InitMeshDlg::ActivateThisDialog() { - mySMESHGUI->EmitSignalDeactivateDialog() ; - GroupC1->setEnabled(true) ; - GroupButtons->setEnabled(true) ; - connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + mySMESHGUI->EmitSignalDeactivateDialog(); + GroupC1->setEnabled(true); + GroupButtons->setEnabled(true); + connect (mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); } - //================================================================================= // function : enterEvent() // purpose : //================================================================================= -void SMESHGUI_InitMeshDlg::enterEvent(QEvent* e) +void SMESHGUI_InitMeshDlg::enterEvent (QEvent* e) { - if ( !GroupC1->isEnabled() ) - ActivateThisDialog() ; + if (!GroupC1->isEnabled()) + ActivateThisDialog(); } - //================================================================================= // function : closeEvent() // purpose : //================================================================================= -void SMESHGUI_InitMeshDlg::closeEvent( QCloseEvent* e ) +void SMESHGUI_InitMeshDlg::closeEvent (QCloseEvent* e) { - disconnect( mySelection, 0, this, 0 ); - mySMESHGUI->ResetState() ; - mySelection->ClearFilters() ; - QDialog::closeEvent( e ); + disconnect(mySelectionMgr, 0, this, 0); + mySMESHGUI->ResetState(); + mySelectionMgr->clearFilters(); + QDialog::closeEvent(e); } //================================================================================= @@ -467,10 +472,10 @@ void SMESHGUI_InitMeshDlg::closeEvent( QCloseEvent* e ) //================================================================================= void SMESHGUI_InitMeshDlg::UpdateControlState() { - bool isEnabled = ( !myGeomShape->_is_nil() && HypoList.count() && AlgoList.count() ); + bool isEnabled = (!myGeomShape->_is_nil() && HypoList.count() && AlgoList.count()); - buttonOk ->setEnabled( isEnabled ); - buttonApply->setEnabled( isEnabled ); + buttonOk ->setEnabled(isEnabled); + buttonApply->setEnabled(isEnabled); } //================================================================================= @@ -479,20 +484,15 @@ void SMESHGUI_InitMeshDlg::UpdateControlState() //================================================================================= QString SMESHGUI_InitMeshDlg::GetDefaultMeshName() { - SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument(); + _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); int aNumber = 0; QString aMeshName; - SALOMEDS::SObject_var obj; - - do - { - aMeshName = QString(tr("SMESH_OBJECT_MESH")) +"_"+QString::number(++aNumber); - obj = aStudy->FindObject(aMeshName); - } - while (!obj->_is_nil()); + _PTR(SObject) obj; + + do { + aMeshName = QString(tr("SMESH_OBJECT_MESH")) + "_" + QString::number(++aNumber); + obj = aStudy->FindObject(aMeshName.latin1()); + } while (obj); return aMeshName; } - - - diff --git a/src/SMESHGUI/SMESHGUI_InitMeshDlg.h b/src/SMESHGUI/SMESHGUI_InitMeshDlg.h index afdcc8584..1a6f4ed57 100644 --- a/src/SMESHGUI/SMESHGUI_InitMeshDlg.h +++ b/src/SMESHGUI/SMESHGUI_InitMeshDlg.h @@ -29,9 +29,10 @@ #ifndef DIALOGBOX_INIT_MESH_H #define DIALOGBOX_INIT_MESH_H -#include "SALOME_Selection.h" -#include "SALOME_TypeFilter.hxx" -#include "SMESH_TypeFilter.hxx" +//#include "SMESH_TypeFilter.hxx" + +#include "SUIT_SelectionFilter.h" +#include "SalomeApp_SelectionMgr.h" // QT Includes #include @@ -57,7 +58,10 @@ class SMESHGUI_InitMeshDlg : public QDialog Q_OBJECT public: - SMESHGUI_InitMeshDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); + SMESHGUI_InitMeshDlg ( SMESHGUI*, + const char* = 0, + bool modal = FALSE, + WFlags fl = 0 ); ~SMESHGUI_InitMeshDlg(); protected: @@ -65,24 +69,27 @@ protected: void enterEvent( QEvent * ) ; private: - void Init( SALOME_Selection* Sel ) ; + void Init(); void UpdateControlState(); QString SMESHGUI_InitMeshDlg::GetDefaultMeshName(); private: - SMESHGUI* mySMESHGUI ; - SALOME_Selection* mySelection ; - - GEOM::GEOM_Object_var myGeomShape ; - QLineEdit* myEditCurrentArgument; + SMESHGUI* mySMESHGUI; + SalomeApp_SelectionMgr* mySelectionMgr; - Handle(SALOME_TypeFilter) myGeomFilter; - Handle(SMESH_TypeFilter) myHypothesisFilter; - Handle(SMESH_TypeFilter) myAlgorithmFilter; + GEOM::GEOM_Object_var myGeomShape; + QLineEdit* myEditCurrentArgument; - QStringList HypoList; - QStringList AlgoList; + //Handle(SALOME_TypeFilter) myGeomFilter; + SUIT_SelectionFilter* myGeomFilter; + //SMESH_TypeFilter* myHypothesisFilter; + //SMESH_TypeFilter* myAlgorithmFilter; + SUIT_SelectionFilter* myHypothesisFilter; + SUIT_SelectionFilter* myAlgorithmFilter; + + QStringList HypoList; + QStringList AlgoList; QGroupBox* GroupButtons; QPushButton* buttonOk; @@ -90,8 +97,8 @@ private: QPushButton* buttonApply; QGroupBox* GroupC1; - QLabel* TextLabel_NameMesh ; - QLineEdit* LineEdit_NameMesh ; + QLabel* TextLabel_NameMesh; + QLineEdit* LineEdit_NameMesh; QLabel* TextLabelC1A1; QPushButton* SelectButtonC1A1; QLineEdit* LineEditC1A1; @@ -108,10 +115,10 @@ private slots: void ClickOnOk(); bool ClickOnApply(); void ClickOnCancel(); - void SetEditCurrentArgument() ; - void SelectionIntoArgument() ; - void DeactivateActiveDialog() ; - void ActivateThisDialog() ; + void SetEditCurrentArgument(); + void SelectionIntoArgument(); + void DeactivateActiveDialog(); + void ActivateThisDialog(); }; #endif // DIALOGBOX_INIT_MESH_H diff --git a/src/SMESHGUI/SMESHGUI_MergeNodesDlg.cxx b/src/SMESHGUI/SMESHGUI_MergeNodesDlg.cxx index d4816fea7..2a36a93af 100644 --- a/src/SMESHGUI/SMESHGUI_MergeNodesDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_MergeNodesDlg.cxx @@ -1,30 +1,30 @@ // SMESH SMESHGUI : GUI for SMESH component // // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org // // // // File : SMESHGUI_MergeNodesDlg.cxx // Author : Michael ZORIN // Module : SMESH -// $Header: +// $Header: #include "SMESHGUI_MergeNodesDlg.h" @@ -33,16 +33,26 @@ #include "SMESHGUI_VTKUtils.h" #include "SMESHGUI_IdValidator.h" #include "SMESHGUI_SpinBox.h" + #include "SMESH_Actor.h" +#include "SMESH_TypeFilter.hxx" #include "SMDS_Mesh.hxx" #include "GEOMBase.h" -#include "QAD_Application.h" -#include "QAD_Desktop.h" -#include "QAD_MessageBox.h" +#include "SUIT_ResourceMgr.h" + +#include "SVTK_ViewModel.h" +#include "SVTK_ViewWindow.h" +#include "SVTK_Selector.h" +#include "SVTK_Selection.h" +#include "SALOME_ListIO.hxx" + #include "utilities.h" +// OCCT Includes +#include + // QT Includes #include #include @@ -62,206 +72,212 @@ using namespace std; //================================================================================= // class : SMESHGUI_MergeNodesDlg() -// purpose : +// purpose : //================================================================================= -SMESHGUI_MergeNodesDlg::SMESHGUI_MergeNodesDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, - bool modal, WFlags fl ) - : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | - Qt::WDestructiveClose) +SMESHGUI_MergeNodesDlg::SMESHGUI_MergeNodesDlg( SMESHGUI* theModule, const char* name, + bool modal, WFlags fl) + : QDialog( SMESH::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder | + WStyle_Title | WStyle_SysMenu | Qt::WDestructiveClose), + mySMESHGUI( theModule ), + mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ), + myViewWindow( SMESH::GetViewWindow( theModule ) ), + mySelector( myViewWindow->GetSelector() ) { - QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SMESH_MERGE_NODES"))); - QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SELECT"))); - - if ( !name ) - setName( "SMESHGUI_MergeNodesDlg" ); - resize( 303, 185 ); - setCaption( tr( "SMESH_MERGE_NODES" ) ); - setSizeGripEnabled( TRUE ); - SMESHGUI_MergeNodesDlgLayout = new QGridLayout( this ); - SMESHGUI_MergeNodesDlgLayout->setSpacing( 6 ); - SMESHGUI_MergeNodesDlgLayout->setMargin( 11 ); - - /***************************************************************/ - GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); - GroupConstructors->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)0, 0, 0, GroupConstructors->sizePolicy().hasHeightForWidth() ) ); - GroupConstructors->setTitle( tr( "SMESH_MERGE_NODES" ) ); - GroupConstructors->setExclusive( TRUE ); - GroupConstructors->setColumnLayout(0, Qt::Vertical ); - GroupConstructors->layout()->setSpacing( 0 ); - GroupConstructors->layout()->setMargin( 0 ); - GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() ); - GroupConstructorsLayout->setAlignment( Qt::AlignTop ); - GroupConstructorsLayout->setSpacing( 6 ); - GroupConstructorsLayout->setMargin( 11 ); - QHBoxLayout* RBLayout = new QHBoxLayout( 0, 0, 6, "Layout2"); - RadioButton1= new QRadioButton( GroupConstructors, "RadioButton1" ); - RadioButton1->setText( tr( "" ) ); - RadioButton1->setPixmap( image0 ); - RBLayout->addWidget( RadioButton1); - GroupConstructorsLayout->addLayout( RBLayout, 0, 0 ); - SMESHGUI_MergeNodesDlgLayout->addWidget( GroupConstructors, 0, 0 ); - - /***************************************************************/ - GroupButtons = new QGroupBox( this, "GroupButtons" ); - GroupButtons->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, GroupButtons->sizePolicy().hasHeightForWidth() ) ); - GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); - GroupButtons->setTitle( tr( "" ) ); - GroupButtons->setColumnLayout(0, Qt::Vertical ); - GroupButtons->layout()->setSpacing( 0 ); - GroupButtons->layout()->setMargin( 0 ); - GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); - GroupButtonsLayout->setAlignment( Qt::AlignTop ); - GroupButtonsLayout->setSpacing( 6 ); - GroupButtonsLayout->setMargin( 11 ); - buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); - buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) ); - buttonCancel->setAutoDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonCancel, 0, 3 ); - buttonApply = new QPushButton( GroupButtons, "buttonApply" ); - buttonApply->setText( tr( "SMESH_BUT_APPLY" ) ); - buttonApply->setAutoDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); - QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); - GroupButtonsLayout->addItem( spacer_9, 0, 2 ); - buttonOk = new QPushButton( GroupButtons, "buttonOk" ); - buttonOk->setText( tr( "SMESH_BUT_OK" ) ); - buttonOk->setAutoDefault( TRUE ); - buttonOk->setDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); - SMESHGUI_MergeNodesDlgLayout->addWidget( GroupButtons, 4, 0 ); + QPixmap image0 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SMESH_MERGE_NODES"))); + QPixmap image1 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT"))); + + if (!name) + setName("SMESHGUI_MergeNodesDlg"); + resize(303, 185); + setCaption(tr("SMESH_MERGE_NODES")); + setSizeGripEnabled(TRUE); + SMESHGUI_MergeNodesDlgLayout = new QGridLayout(this); + SMESHGUI_MergeNodesDlgLayout->setSpacing(6); + SMESHGUI_MergeNodesDlgLayout->setMargin(11); /***************************************************************/ - + GroupConstructors = new QButtonGroup(this, "GroupConstructors"); + GroupConstructors->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)5, + (QSizePolicy::SizeType)0, 0, 0, + GroupConstructors->sizePolicy().hasHeightForWidth())); + GroupConstructors->setTitle(tr("SMESH_MERGE_NODES" )); + GroupConstructors->setExclusive(TRUE); + GroupConstructors->setColumnLayout(0, Qt::Vertical); + GroupConstructors->layout()->setSpacing(0); + GroupConstructors->layout()->setMargin(0); + GroupConstructorsLayout = new QGridLayout(GroupConstructors->layout()); + GroupConstructorsLayout->setAlignment(Qt::AlignTop); + GroupConstructorsLayout->setSpacing(6); + GroupConstructorsLayout->setMargin(11); + QHBoxLayout* RBLayout = new QHBoxLayout(0, 0, 6, "Layout2"); + RadioButton1= new QRadioButton(GroupConstructors, "RadioButton1"); + RadioButton1->setText(tr("" )); + RadioButton1->setPixmap(image0); + RBLayout->addWidget(RadioButton1); + GroupConstructorsLayout->addLayout(RBLayout, 0, 0); + SMESHGUI_MergeNodesDlgLayout->addWidget(GroupConstructors, 0, 0); + + /***************************************************************/ + GroupButtons = new QGroupBox(this, "GroupButtons"); + GroupButtons->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)7, + (QSizePolicy::SizeType)0, 0, 0, + GroupButtons->sizePolicy().hasHeightForWidth())); + GroupButtons->setGeometry(QRect(10, 10, 281, 48)); + GroupButtons->setTitle(tr("" )); + GroupButtons->setColumnLayout(0, Qt::Vertical); + GroupButtons->layout()->setSpacing(0); + GroupButtons->layout()->setMargin(0); + GroupButtonsLayout = new QGridLayout(GroupButtons->layout()); + GroupButtonsLayout->setAlignment(Qt::AlignTop); + GroupButtonsLayout->setSpacing(6); + GroupButtonsLayout->setMargin(11); + buttonCancel = new QPushButton(GroupButtons, "buttonCancel"); + buttonCancel->setText(tr("SMESH_BUT_CLOSE" )); + buttonCancel->setAutoDefault(TRUE); + GroupButtonsLayout->addWidget(buttonCancel, 0, 3); + buttonApply = new QPushButton(GroupButtons, "buttonApply"); + buttonApply->setText(tr("SMESH_BUT_APPLY" )); + buttonApply->setAutoDefault(TRUE); + GroupButtonsLayout->addWidget(buttonApply, 0, 1); + QSpacerItem* spacer_9 = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); + GroupButtonsLayout->addItem(spacer_9, 0, 2); + buttonOk = new QPushButton(GroupButtons, "buttonOk"); + buttonOk->setText(tr("SMESH_BUT_OK" )); + buttonOk->setAutoDefault(TRUE); + buttonOk->setDefault(TRUE); + GroupButtonsLayout->addWidget(buttonOk, 0, 0); + SMESHGUI_MergeNodesDlgLayout->addWidget(GroupButtons, 4, 0); + + /***************************************************************/ + // Controls for mesh defining - GroupMesh = new QGroupBox( this, "GroupMesh" ); - GroupMesh->setTitle( tr( "SMESH_MESH" ) ); - GroupMesh->setColumnLayout(0, Qt::Vertical ); - GroupMesh->layout()->setSpacing( 0 ); - GroupMesh->layout()->setMargin( 0 ); - GroupMeshLayout = new QGridLayout( GroupMesh->layout() ); - GroupMeshLayout->setAlignment( Qt::AlignTop ); - GroupMeshLayout->setSpacing( 6 ); - GroupMeshLayout->setMargin( 11 ); - - TextLabelName = new QLabel( GroupMesh, "TextLabelName" ); - TextLabelName->setText( tr( "SMESH_NAME" ) ); - GroupMeshLayout->addWidget( TextLabelName, 0, 0 ); + GroupMesh = new QGroupBox(this, "GroupMesh"); + GroupMesh->setTitle(tr("SMESH_MESH")); + GroupMesh->setColumnLayout(0, Qt::Vertical); + GroupMesh->layout()->setSpacing(0); + GroupMesh->layout()->setMargin(0); + GroupMeshLayout = new QGridLayout(GroupMesh->layout()); + GroupMeshLayout->setAlignment(Qt::AlignTop); + GroupMeshLayout->setSpacing(6); + GroupMeshLayout->setMargin(11); - SelectMeshButton = new QPushButton( GroupMesh, "SelectMeshButton" ); - SelectMeshButton->setPixmap( image1 ); - GroupMeshLayout->addWidget( SelectMeshButton, 0, 1 ); + TextLabelName = new QLabel(GroupMesh, "TextLabelName"); + TextLabelName->setText(tr("SMESH_NAME")); + GroupMeshLayout->addWidget(TextLabelName, 0, 0); + + SelectMeshButton = new QPushButton(GroupMesh, "SelectMeshButton"); + SelectMeshButton->setPixmap(image1); + GroupMeshLayout->addWidget(SelectMeshButton, 0, 1); LineEditMesh = new QLineEdit(GroupMesh, "LineEditMesh"); LineEditMesh->setReadOnly(true); - GroupMeshLayout->addWidget( LineEditMesh, 0, 2 ); - - SMESHGUI_MergeNodesDlgLayout->addWidget( GroupMesh, 1, 0 ); - - // Controls for coincident nodes detecting - GroupCoincident = new QGroupBox( this, "GroupCoincident" ); - GroupCoincident->setTitle( tr( "COINCIDENT_NODES" ) ); - GroupCoincident->setColumnLayout(0, Qt::Vertical ); - GroupCoincident->layout()->setSpacing( 0 ); - GroupCoincident->layout()->setMargin( 0 ); - QGridLayout* GroupCoincidentLayout = new QGridLayout( GroupCoincident->layout() ); - GroupCoincidentLayout->setAlignment( Qt::AlignTop ); - GroupCoincidentLayout->setSpacing( 6 ); - GroupCoincidentLayout->setMargin( 11 ); + GroupMeshLayout->addWidget(LineEditMesh, 0, 2); - TextLabelTolerance = new QLabel( GroupCoincident, "TextLabelTolerance" ); - TextLabelTolerance->setText( tr( "SMESH_TOLERANCE" ) ); - GroupCoincidentLayout->addWidget( TextLabelTolerance, 0, 0 ); - - SpinBoxTolerance = new SMESHGUI_SpinBox( GroupCoincident, "SpinBoxTolerance" ); - GroupCoincidentLayout->addWidget( SpinBoxTolerance, 0, 1 ); - - QPushButton* DetectButton = new QPushButton( GroupCoincident, "DetectButton" ); - DetectButton->setText( tr("DETECT") ); - GroupCoincidentLayout->addWidget( DetectButton, 0, 2 ); - - ListCoincident = new QListView( GroupCoincident ); - ListCoincident->setSorting( -1 ); - ListCoincident->addColumn( "Nodes" ); + SMESHGUI_MergeNodesDlgLayout->addWidget(GroupMesh, 1, 0); + + // Controls for coincident nodes detecting + GroupCoincident = new QGroupBox(this, "GroupCoincident"); + GroupCoincident->setTitle(tr("COINCIDENT_NODES")); + GroupCoincident->setColumnLayout(0, Qt::Vertical); + GroupCoincident->layout()->setSpacing(0); + GroupCoincident->layout()->setMargin(0); + QGridLayout* GroupCoincidentLayout = new QGridLayout(GroupCoincident->layout()); + GroupCoincidentLayout->setAlignment(Qt::AlignTop); + GroupCoincidentLayout->setSpacing(6); + GroupCoincidentLayout->setMargin(11); + + TextLabelTolerance = new QLabel(GroupCoincident, "TextLabelTolerance"); + TextLabelTolerance->setText(tr("SMESH_TOLERANCE")); + GroupCoincidentLayout->addWidget(TextLabelTolerance, 0, 0); + + SpinBoxTolerance = new SMESHGUI_SpinBox(GroupCoincident, "SpinBoxTolerance"); + GroupCoincidentLayout->addWidget(SpinBoxTolerance, 0, 1); + + QPushButton* DetectButton = new QPushButton(GroupCoincident, "DetectButton"); + DetectButton->setText(tr("DETECT")); + GroupCoincidentLayout->addWidget(DetectButton, 0, 2); + + ListCoincident = new QListView(GroupCoincident); + ListCoincident->setSorting(-1); + ListCoincident->addColumn("Nodes"); ListCoincident->header()->hide(); - - GroupCoincidentLayout->addMultiCellWidget( ListCoincident, 1, 1, 0, 1 ); + + GroupCoincidentLayout->addMultiCellWidget(ListCoincident, 1, 1, 0, 1); SelectAllCB = new QCheckBox(GroupCoincident, "SelectAllCB"); SelectAllCB->setText(tr("SELECT_ALL")); - GroupCoincidentLayout->addWidget( SelectAllCB, 2, 0 ); - - SMESHGUI_MergeNodesDlgLayout->addWidget( GroupCoincident, 2, 0 ); + GroupCoincidentLayout->addWidget(SelectAllCB, 2, 0); + + SMESHGUI_MergeNodesDlgLayout->addWidget(GroupCoincident, 2, 0); // Controls for editing group of nodes - GroupEdit = new QGroupBox( this, "GroupEdit" ); - GroupEdit->setTitle( tr( "EDIT_GROUP_OF_NODES" ) ); - GroupEdit->setColumnLayout(0, Qt::Vertical ); - GroupEdit->layout()->setSpacing( 0 ); - GroupEdit->layout()->setMargin( 0 ); - QGridLayout* GroupEditLayout = new QGridLayout( GroupEdit->layout() ); - GroupEditLayout->setAlignment( Qt::AlignTop ); - GroupEditLayout->setSpacing( 6 ); - GroupEditLayout->setMargin( 11 ); - - ListEdit = new QListBox( GroupEdit, "ListEdit" ); + GroupEdit = new QGroupBox(this, "GroupEdit"); + GroupEdit->setTitle(tr("EDIT_GROUP_OF_NODES")); + GroupEdit->setColumnLayout(0, Qt::Vertical); + GroupEdit->layout()->setSpacing(0); + GroupEdit->layout()->setMargin(0); + QGridLayout* GroupEditLayout = new QGridLayout(GroupEdit->layout()); + GroupEditLayout->setAlignment(Qt::AlignTop); + GroupEditLayout->setSpacing(6); + GroupEditLayout->setMargin(11); + + ListEdit = new QListBox(GroupEdit, "ListEdit"); ListEdit->setColumnMode(QListBox::FitToHeight); - ListEdit->setSelectionMode( QListBox::Extended ); - GroupEditLayout->addMultiCellWidget( ListEdit, 0, 2, 0, 0 ); - - QPushButton* AddButton = new QPushButton( GroupEdit, "AddButton" ); - AddButton->setText( tr("SMESH_BUT_ADD") ); - GroupEditLayout->addWidget( AddButton, 0, 1 ); - - QPushButton* RemoveButton = new QPushButton( GroupEdit, "RemoveButton" ); - RemoveButton->setText( tr("SMESH_BUT_REMOVE") ); - GroupEditLayout->addWidget( RemoveButton, 1, 1 ); - - QSpacerItem* spacer = new QSpacerItem( 20, 200, QSizePolicy::Minimum, QSizePolicy::Expanding ); - GroupEditLayout->addItem( spacer, 2, 1 ); - - SMESHGUI_MergeNodesDlgLayout->addWidget( GroupEdit, 3, 0 ); - + ListEdit->setSelectionMode(QListBox::Extended); + GroupEditLayout->addMultiCellWidget(ListEdit, 0, 2, 0, 0); + + QPushButton* AddButton = new QPushButton(GroupEdit, "AddButton"); + AddButton->setText(tr("SMESH_BUT_ADD")); + GroupEditLayout->addWidget(AddButton, 0, 1); + + QPushButton* RemoveButton = new QPushButton(GroupEdit, "RemoveButton"); + RemoveButton->setText(tr("SMESH_BUT_REMOVE")); + GroupEditLayout->addWidget(RemoveButton, 1, 1); + + QSpacerItem* spacer = new QSpacerItem(20, 200, QSizePolicy::Minimum, QSizePolicy::Expanding); + GroupEditLayout->addItem(spacer, 2, 1); + + SMESHGUI_MergeNodesDlgLayout->addWidget(GroupEdit, 3, 0); + /* Initialisations */ - SpinBoxTolerance->RangeStepAndValidator( 0.0, 999999.999, 0.1, 3 ); + SpinBoxTolerance->RangeStepAndValidator(0.0, 999999.999, 0.1, 3); SpinBoxTolerance->SetValue(1e-05); - - RadioButton1->setChecked( TRUE ); - + + RadioButton1->setChecked(TRUE); + myActor = 0; - mySelection = Sel; - - mySMESHGUI = SMESHGUI::GetSMESHGUI() ; - mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; - - myMeshOrSubMeshFilter = new SMESH_TypeFilter( MESHorSUBMESH ); + mySMESHGUI = SMESHGUI::GetSMESHGUI(); + mySMESHGUI->SetActiveDialogBox((QDialog*)this); + + myMeshOrSubMeshFilter = new SMESH_TypeFilter (MESHorSUBMESH); /* signals and slots connections */ - connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); - connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ); - connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) ); - - connect( SelectMeshButton, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ); - connect( DetectButton, SIGNAL ( clicked() ), this, SLOT( onDetect() ) ); - connect( ListCoincident, SIGNAL ( selectionChanged() ), this, SLOT( onSelectNodesGroup() ) ); - connect( ListCoincident, SIGNAL ( pressed( QListViewItem* ) ), this, SLOT( updateControls() ) ); - connect( ListCoincident, SIGNAL ( currentChanged( QListViewItem* ) ), this, SLOT( updateControls() ) ); - connect( SelectAllCB, SIGNAL( toggled(bool) ), this, SLOT(onSelectAll(bool) ) ); - connect( ListEdit, SIGNAL ( selectionChanged() ), this, SLOT( onSelectNodesFromGroup() ) ); - connect( AddButton, SIGNAL ( clicked() ), this, SLOT( onAdd() ) ); - connect( RemoveButton, SIGNAL ( clicked() ), this, SLOT( onRemove() ) ); + connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel())); + connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); - connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ); - connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + connect(SelectMeshButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument())); + connect(DetectButton, SIGNAL (clicked()), this, SLOT(onDetect())); + connect(ListCoincident, SIGNAL (selectionChanged()), this, SLOT(onSelectNodesGroup())); + connect(ListCoincident, SIGNAL (pressed(QListViewItem*)), this, SLOT(updateControls())); + connect(ListCoincident, SIGNAL (currentChanged(QListViewItem*)), this, SLOT(updateControls())); + connect(SelectAllCB, SIGNAL(toggled(bool)), this, SLOT(onSelectAll(bool))); + connect(ListEdit, SIGNAL (selectionChanged()), this, SLOT(onSelectNodesFromGroup())); + connect(AddButton, SIGNAL (clicked()), this, SLOT(onAdd())); + connect(RemoveButton, SIGNAL (clicked()), this, SLOT(onRemove())); + + connect(mySMESHGUI, SIGNAL (SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog())); + connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); /* to close dialog if study change */ - connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ); - + connect(mySMESHGUI, SIGNAL (SignalCloseAllDialogs()), this, SLOT(ClickOnCancel())); + /* Move widget on the botton right corner of main widget */ - int x, y ; - mySMESHGUI->DefineDlgPosition( this, x, y ) ; - this->move( x, y ) ; - this->show() ; /* displays Dialog */ - + int x, y; + mySMESHGUI->DefineDlgPosition(this, x, y); + this->move(x, y); + this->show(); /* displays Dialog */ + resize(0,0); buttonOk->setEnabled(false); buttonApply->setEnabled(false); @@ -276,51 +292,46 @@ SMESHGUI_MergeNodesDlg::~SMESHGUI_MergeNodesDlg() // no need to delete child widgets, Qt does it all for us } - //================================================================================= // function : ClickOnApply() // purpose : //================================================================================= bool SMESHGUI_MergeNodesDlg::ClickOnApply() { - if (mySMESHGUI->ActiveStudyLocked() || myMesh->_is_nil()) + if (mySMESHGUI->isActiveStudyLocked() || myMesh->_is_nil()) return false; - try - { - SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor(); + try { + SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor(); - QApplication::setOverrideCursor(Qt::waitCursor); - SMESH::array_of_long_array_var aGroupsOfNodes = new SMESH::array_of_long_array; - aGroupsOfNodes->length(ListCoincident->childCount()); - QListViewItem* item = ListCoincident->firstChild(); + QApplication::setOverrideCursor(Qt::waitCursor); + SMESH::array_of_long_array_var aGroupsOfNodes = new SMESH::array_of_long_array; + aGroupsOfNodes->length(ListCoincident->childCount()); + QListViewItem* item = ListCoincident->firstChild(); - int anArrayNum = 0; - while (item) - { - QStringList aListIds = QStringList(""); - if (((QCheckListItem*) item)->isOn()) - aListIds = QStringList::split( " ", item->text(0), false); - - SMESH::long_array_var anIds = new SMESH::long_array; - anIds->length(aListIds.count()); - - for ( int i = 0; i < aListIds.count(); i++ ) - anIds[i] = aListIds[i].toInt(); - - aGroupsOfNodes[anArrayNum++] = anIds.inout(); - - item = item->itemBelow(); - } + int anArrayNum = 0; + while (item) { + QStringList aListIds = QStringList(""); + if (((QCheckListItem*) item)->isOn()) + aListIds = QStringList::split(" ", item->text(0), false); - aMeshEditor->MergeNodes (aGroupsOfNodes.inout()); - QApplication::restoreOverrideCursor(); - } - catch( ... ) - { + SMESH::long_array_var anIds = new SMESH::long_array; + anIds->length(aListIds.count()); + + for (int i = 0; i < aListIds.count(); i++) + anIds[i] = aListIds[i].toInt(); + + aGroupsOfNodes[anArrayNum++] = anIds.inout(); + + item = item->itemBelow(); } - mySelection->ClearIObjects(); + aMeshEditor->MergeNodes (aGroupsOfNodes.inout()); + QApplication::restoreOverrideCursor(); + } catch(...) { + } + + mySelectionMgr->clearSelected(); SMESH::UpdateView(); onDetect(); @@ -333,191 +344,176 @@ bool SMESHGUI_MergeNodesDlg::ClickOnApply() //================================================================================= void SMESHGUI_MergeNodesDlg::ClickOnOk() { - if( ClickOnApply()) - ClickOnCancel() ; + if (ClickOnApply()) + ClickOnCancel(); } - //================================================================================= // function : ClickOnCancel() // purpose : //================================================================================= void SMESHGUI_MergeNodesDlg::ClickOnCancel() { - mySelection->ClearFilters(); - mySelection->ClearIObjects(); + mySelectionMgr->clearFilters(); + mySelectionMgr->clearSelected(); SMESH::SetPointRepresentation(false); - QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); - disconnect( mySelection, 0, this, 0 ); - mySMESHGUI->ResetState() ; - reject() ; + myViewWindow->SetSelectionMode(ActorSelection); + disconnect(mySelectionMgr, 0, this, 0); + mySMESHGUI->ResetState(); + reject(); } - //================================================================================= // function : onEditNodesGroup() // purpose : //================================================================================= void SMESHGUI_MergeNodesDlg::onEditNodesGroup() { - if ( ListCoincident->childCount() < 1 ) + if (ListCoincident->childCount() < 1) return; QString aNewIds = ""; - + QListBoxItem* anItem; for (anItem = ListEdit->firstItem(); anItem != 0; anItem = anItem->next()) aNewIds+=QString(" %1").arg(anItem->text()); - + ListCoincident->currentItem()->setText(0, aNewIds); } - //================================================================================= // function : updateControls() -// purpose : +// purpose : //================================================================================= void SMESHGUI_MergeNodesDlg::updateControls() { - if ( ListCoincident->childCount() < 1 ) - { - SMESH::SetPointRepresentation(false); - QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); - return; - } - + if (ListCoincident->childCount() < 1) { + SMESH::SetPointRepresentation(false); + myViewWindow->SetSelectionMode(ActorSelection); + return; + } + bool hasChecked = false, hasUnchecked = false; - + QListViewItem* item = ListCoincident->firstChild(); - - while (item && (!hasChecked || !hasUnchecked)) - { - if (((QCheckListItem*) item)->isOn()) - hasChecked = true; - else - hasUnchecked = true; - - item = item->itemBelow(); - } - + + while (item && (!hasChecked || !hasUnchecked)) { + if (((QCheckListItem*) item)->isOn()) + hasChecked = true; + else + hasUnchecked = true; + + item = item->itemBelow(); + } + if (hasUnchecked) SelectAllCB->setChecked(false); - + bool enable = !(myMesh->_is_nil()) && hasChecked; - + buttonOk->setEnabled(enable); buttonApply->setEnabled(enable); } - //================================================================================= // function : onDetect() -// purpose : +// purpose : //================================================================================= void SMESHGUI_MergeNodesDlg::onDetect() { - if(myMesh->_is_nil()) + if (myMesh->_is_nil()) return; - try - { - SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor(); - - QApplication::setOverrideCursor(Qt::waitCursor); - ListCoincident->clear(); - ListEdit->clear(); - - SMESH::array_of_long_array_var aNodeGroups; - aMeshEditor->FindCoincidentNodes(SpinBoxTolerance->GetValue(), aNodeGroups); - - for ( int i = 0; i < aNodeGroups->length(); i++ ) - { - SMESH::long_array& aGroup = aNodeGroups[i]; - - QString aNodeIds; - for ( int j = 0; j < aGroup.length(); j++ ) - aNodeIds+=QString(" %1").arg(aGroup[j]); - - new QCheckListItem ( ListCoincident, aNodeIds, QCheckListItem::CheckBox ); - } - QApplication::restoreOverrideCursor(); + try { + SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor(); + + QApplication::setOverrideCursor(Qt::waitCursor); + ListCoincident->clear(); + ListEdit->clear(); + + SMESH::array_of_long_array_var aNodeGroups; + aMeshEditor->FindCoincidentNodes(SpinBoxTolerance->GetValue(), aNodeGroups); + + for (int i = 0; i < aNodeGroups->length(); i++) { + SMESH::long_array& aGroup = aNodeGroups[i]; + + QString aNodeIds; + for (int j = 0; j < aGroup.length(); j++) + aNodeIds+=QString(" %1").arg(aGroup[j]); + + new QCheckListItem (ListCoincident, aNodeIds, QCheckListItem::CheckBox); } - catch( ... ) - { - } - + QApplication::restoreOverrideCursor(); + } catch(...) { + } + updateControls(); } - //================================================================================= // function : onSelectNodesGroup() -// purpose : +// purpose : //================================================================================= void SMESHGUI_MergeNodesDlg::onSelectNodesGroup() { - if(!myActor) + if (!myActor) return; - + myEditCurrentArgument = (QWidget*)ListCoincident; - + QListViewItem* aSelectedItem = ListCoincident->selectedItem(); if (!aSelectedItem) return; - - QStringList aListId = QStringList::split( " ", aSelectedItem->text(0), false); - + + QStringList aListId = QStringList::split(" ", aSelectedItem->text(0), false); + ListEdit->clear(); ListEdit->insertStringList(aListId); - - mySelection->ClearIObjects(); - mySelection->AddIObject( myActor->getIO() ); - + + //mySelectionMgr->clearSelected(); + //mySelectionMgr->AddIObject(myActor->getIO()); + SALOME_ListIO aList; + aList.Append(myActor->getIO()); + mySelectionMgr->setSelectedObjects(aList, false); + SMESH::SetPointRepresentation(true); - QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true ); - + myViewWindow->SetSelectionMode(NodeSelection); + ListEdit->selectAll(true); } - //================================================================================= // function : onSelectAll() -// purpose : +// purpose : //================================================================================= -void SMESHGUI_MergeNodesDlg::onSelectAll(bool isToggled) +void SMESHGUI_MergeNodesDlg::onSelectAll (bool isToggled) { - if (isToggled) - { - int aNbItems = 0; - QListViewItem* item = ListCoincident->firstChild(); - while (item) - { - aNbItems++; - if (!((QCheckListItem*) item)->isOn()) - ((QCheckListItem*) item)->setOn(true); - item = item->itemBelow(); - } - - if (aNbItems) - { - buttonOk->setEnabled(true); - buttonApply->setEnabled(true); - } + if (isToggled) { + int aNbItems = 0; + QListViewItem* item = ListCoincident->firstChild(); + while (item) { + aNbItems++; + if (!((QCheckListItem*) item)->isOn()) + ((QCheckListItem*) item)->setOn(true); + item = item->itemBelow(); } -} + if (aNbItems) { + buttonOk->setEnabled(true); + buttonApply->setEnabled(true); + } + } +} //================================================================================= // function : onSelectNodesFromGroup() -// purpose : +// purpose : //================================================================================= void SMESHGUI_MergeNodesDlg::onSelectNodesFromGroup() { - if (!myActor) + if (!myActor) return; - - mySelection->ClearIObjects(); - + TColStd_MapOfInteger aIndexes; QListBoxItem* anItem; for (anItem = ListEdit->firstItem(); anItem != 0; anItem = anItem->next()) { @@ -526,14 +522,16 @@ void SMESHGUI_MergeNodesDlg::onSelectNodesFromGroup() aIndexes.Add(anId); } } - mySelection->AddOrRemoveIndex(myActor->getIO(), aIndexes, false, false); - mySelection->AddIObject(myActor->getIO()); -} + mySelector->AddOrRemoveIndex(myActor->getIO(), aIndexes, false); + SALOME_ListIO aList; + aList.Append(myActor->getIO()); + mySelectionMgr->setSelectedObjects(aList); +} //================================================================================= // function : onAdd() -// purpose : +// purpose : //================================================================================= void SMESHGUI_MergeNodesDlg::onAdd() { @@ -542,14 +540,14 @@ void SMESHGUI_MergeNodesDlg::onAdd() QString aListStr = ""; int aNbNnodes = 0; - - aNbNnodes = SMESH::GetNameOfSelectedNodes(mySelection, myActor->getIO(), aListStr); + + aNbNnodes = SMESH::GetNameOfSelectedNodes(mySelector, myActor->getIO(), aListStr); if (aNbNnodes < 1) return; - + QStringList aNodes = QStringList::split(" ", aListStr); QListBoxItem* anItem = 0; - + for (QStringList::iterator it = aNodes.begin(); it != aNodes.end(); ++it) { anItem = ListEdit->findItem(*it, Qt::ExactMatch); if (!anItem) { @@ -558,54 +556,49 @@ void SMESHGUI_MergeNodesDlg::onAdd() } ListEdit->setSelected(anItem, true); } - + onEditNodesGroup(); } - //================================================================================= // function : onRemove() -// purpose : +// purpose : //================================================================================= void SMESHGUI_MergeNodesDlg::onRemove() { if (myEditCurrentArgument != (QWidget*)ListCoincident) return; - - for (int i = ListEdit->count(); i > 0; i--) - { - if (ListEdit->isSelected(i-1)) - ListEdit->removeItem(i-1); - } + + for (int i = ListEdit->count(); i > 0; i--) { + if (ListEdit->isSelected(i-1)) + ListEdit->removeItem(i-1); + } onEditNodesGroup(); } - //================================================================================= // function : SetEditCurrentArgument() -// purpose : +// purpose : //================================================================================= void SMESHGUI_MergeNodesDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); - - disconnect( mySelection, 0, this, 0 ); - mySelection->ClearIObjects(); - mySelection->ClearFilters(); - - if(send == SelectMeshButton) - { - myEditCurrentArgument = (QWidget*)LineEditMesh; - SMESH::SetPointRepresentation(false); - QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); - mySelection->AddFilter(myMeshOrSubMeshFilter) ; - } - - myEditCurrentArgument->setFocus(); - connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); - SelectionIntoArgument() ; -} + disconnect(mySelectionMgr, 0, this, 0); + mySelectionMgr->clearSelected(); + mySelectionMgr->clearFilters(); + + if (send == SelectMeshButton) { + myEditCurrentArgument = (QWidget*)LineEditMesh; + SMESH::SetPointRepresentation(false); + myViewWindow->SetSelectionMode(ActorSelection); + mySelectionMgr->installFilter(myMeshOrSubMeshFilter); + } + + myEditCurrentArgument->setFocus(); + connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + SelectionIntoArgument(); +} //================================================================================= // function : SelectionIntoArgument() @@ -613,47 +606,47 @@ void SMESHGUI_MergeNodesDlg::SetEditCurrentArgument() //================================================================================= void SMESHGUI_MergeNodesDlg::SelectionIntoArgument() { - if (myEditCurrentArgument == (QWidget*)LineEditMesh) - { - QString aString = ""; - LineEditMesh->setText( aString ); - - ListCoincident->clear(); - ListEdit->clear(); + if (myEditCurrentArgument == (QWidget*)LineEditMesh) { + QString aString = ""; + LineEditMesh->setText(aString); - int nbSel = SMESH::GetNameOfSelectedIObjects(mySelection, aString); - if(nbSel != 1) - return; - - Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject(); - myMesh = SMESH::IObjectToInterface(IO) ; - myActor = SMESH::FindActorByEntry( mySelection->firstIObject()->getEntry() ); - if(myMesh->_is_nil() || !myActor) - return; - - LineEditMesh->setText( aString ); - } + ListCoincident->clear(); + ListEdit->clear(); + + int nbSel = SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString); + if (nbSel != 1) + return; + + SALOME_ListIO aList; + mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type()); + + Handle(SALOME_InteractiveObject) IO = aList.First(); + myMesh = SMESH::IObjectToInterface(IO); + myActor = SMESH::FindActorByEntry(aList.First()->getEntry()); + if (myMesh->_is_nil() || !myActor) + return; + + LineEditMesh->setText(aString); + } } - //================================================================================= // function : DeactivateActiveDialog() // purpose : //================================================================================= void SMESHGUI_MergeNodesDlg::DeactivateActiveDialog() { - if ( GroupConstructors->isEnabled() ) { - GroupConstructors->setEnabled(false) ; + if (GroupConstructors->isEnabled()) { + GroupConstructors->setEnabled(false); GroupMesh->setEnabled(false); GroupCoincident->setEnabled(false); GroupEdit->setEnabled(false); - GroupButtons->setEnabled(false) ; - mySMESHGUI->ResetState() ; - mySMESHGUI->SetActiveDialogBox(0) ; + GroupButtons->setEnabled(false); + mySMESHGUI->ResetState(); + mySMESHGUI->SetActiveDialogBox(0); } } - //================================================================================= // function : ActivateThisDialog() // purpose : @@ -661,49 +654,44 @@ void SMESHGUI_MergeNodesDlg::DeactivateActiveDialog() void SMESHGUI_MergeNodesDlg::ActivateThisDialog() { /* Emit a signal to deactivate the active dialog */ - mySMESHGUI->EmitSignalDeactivateDialog() ; - GroupConstructors->setEnabled(true) ; + mySMESHGUI->EmitSignalDeactivateDialog(); + GroupConstructors->setEnabled(true); GroupMesh->setEnabled(true); GroupCoincident->setEnabled(true); GroupEdit->setEnabled(true); - GroupButtons->setEnabled(true) ; - - mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; - + GroupButtons->setEnabled(true); + + mySMESHGUI->SetActiveDialogBox((QDialog*)this); + SelectionIntoArgument(); } - //================================================================================= // function : enterEvent() // purpose : //================================================================================= -void SMESHGUI_MergeNodesDlg::enterEvent(QEvent* e) +void SMESHGUI_MergeNodesDlg::enterEvent (QEvent*) { - if ( GroupConstructors->isEnabled() ) - return ; - ActivateThisDialog() ; + if (!GroupConstructors->isEnabled()) + ActivateThisDialog(); } - //================================================================================= // function : closeEvent() // purpose : //================================================================================= -void SMESHGUI_MergeNodesDlg::closeEvent( QCloseEvent* e ) +void SMESHGUI_MergeNodesDlg::closeEvent (QCloseEvent*) { /* same than click on cancel button */ - ClickOnCancel() ; + ClickOnCancel(); } - //======================================================================= -//function : hideEvent +//function : hideEvent() //purpose : caused by ESC key //======================================================================= - -void SMESHGUI_MergeNodesDlg::hideEvent ( QHideEvent * e ) +void SMESHGUI_MergeNodesDlg::hideEvent (QHideEvent*) { - if ( !isMinimized() ) + if (!isMinimized()) ClickOnCancel(); } diff --git a/src/SMESHGUI/SMESHGUI_MergeNodesDlg.h b/src/SMESHGUI/SMESHGUI_MergeNodesDlg.h index ad390853b..b679a94f0 100644 --- a/src/SMESHGUI/SMESHGUI_MergeNodesDlg.h +++ b/src/SMESHGUI/SMESHGUI_MergeNodesDlg.h @@ -29,8 +29,9 @@ #ifndef DIALOGBOX_MERGENODES_H #define DIALOGBOX_MERGENODES_H -#include "SALOME_Selection.h" -#include "SMESH_TypeFilter.hxx" +#include "SalomeApp_SelectionMgr.h" +//#include "SMESH_TypeFilter.hxx" +#include "SUIT_SelectionFilter.h" // QT Includes #include @@ -49,6 +50,9 @@ class QListBox; class SMESHGUI; class SMESHGUI_SpinBox; class SMESH_Actor; +class SVTK_ViewWindow; +class SVTK_Selector; + // IDL Headers #include @@ -64,26 +68,31 @@ class SMESHGUI_MergeNodesDlg : public QDialog Q_OBJECT public: - SMESHGUI_MergeNodesDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); + SMESHGUI_MergeNodesDlg( SMESHGUI*, + const char* name = 0, + bool modal = FALSE, + WFlags fl = 0); ~SMESHGUI_MergeNodesDlg(); private: - - void Init() ; - void closeEvent( QCloseEvent* e ) ; - void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */ + void Init(); + void closeEvent( QCloseEvent* e ); + void enterEvent ( QEvent * ); /* mouse enter the QWidget */ void hideEvent ( QHideEvent * ); /* ESC key */ void onEditNodesGroup(); - - SMESHGUI* mySMESHGUI ; /* Current SMESHGUI object */ - SALOME_Selection* mySelection ; /* User shape selection */ - + + SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */ + SalomeApp_SelectionMgr* mySelectionMgr; /* User shape selection */ + SVTK_ViewWindow* myViewWindow; + SVTK_Selector* mySelector; + QWidget* myEditCurrentArgument; SMESH::SMESH_Mesh_var myMesh; SMESH_Actor* myActor; - Handle(SMESH_TypeFilter) myMeshOrSubMeshFilter; - + //Handle(SMESH_TypeFilter) myMeshOrSubMeshFilter; + SUIT_SelectionFilter* myMeshOrSubMeshFilter; + QButtonGroup* GroupConstructors; QRadioButton* RadioButton1; QGroupBox* GroupButtons; diff --git a/src/SMESHGUI/SMESHGUI_MeshInfosDlg.cxx b/src/SMESHGUI/SMESHGUI_MeshInfosDlg.cxx index dd130b2fe..cd16d80bd 100644 --- a/src/SMESHGUI/SMESHGUI_MeshInfosDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_MeshInfosDlg.cxx @@ -1,23 +1,23 @@ // SMESH SMESHGUI : GUI for SMESH component // // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org // // // @@ -26,6 +26,21 @@ // Module : SMESH // $Header$ +#include "SMESHGUI_MeshInfosDlg.h" + +#include "SMESHGUI.h" +#include "SMESHGUI_Utils.h" + +#include "SUIT_Desktop.h" +#include "SUIT_ResourceMgr.h" +#include "SUIT_OverrideCursor.h" + +#include "SalomeApp_SelectionMgr.h" +#include "SALOMEDSClient_Study.hxx" +#include "SALOME_ListIO.hxx" + +#include "utilities.h" + // QT Includes #include #include @@ -35,389 +50,398 @@ #include #include -#include "QAD_Application.h" -#include "QAD_Desktop.h" -#include "QAD_WaitCursor.h" - -#include "SMESHGUI_MeshInfosDlg.h" -#include "SMESHGUI_Utils.h" -#include "SMESHGUI.h" - // IDL Headers #include "SALOMEconfig.h" #include CORBA_SERVER_HEADER(SMESH_Mesh) #include CORBA_SERVER_HEADER(SMESH_Group) -#include "utilities.h" - using namespace std; -#define COLONIZE( str ) ( QString( str ).contains( ":" ) > 0 ? QString( str ) : QString( str ) + " :" ) +#define COLONIZE(str) (QString(str).contains(":") > 0 ? QString(str) : QString(str) + " :" ) //================================================================================= -/*! - * SMESHGUI_MeshInfosDlg::SMESHGUI_MeshInfosDlg - * - * Constructor - */ +// function : SMESHGUI_MeshInfosDlg() +// purpose : Constructor //================================================================================= -SMESHGUI_MeshInfosDlg::SMESHGUI_MeshInfosDlg( QWidget* parent, const char* name, bool modal, WFlags fl ) - : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose ) +SMESHGUI_MeshInfosDlg::SMESHGUI_MeshInfosDlg (SMESHGUI* theModule, + const char* name, + bool modal, + WFlags fl): + QDialog(SMESH::GetDesktop(theModule), + name, + modal, + WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose), + mySelectionMgr(SMESH::GetSelectionMgr(theModule)), + mySMESHGUI(theModule) { - if ( !name ) - setName( "SMESHGUI_MeshInfosDlg" ); - setCaption( tr( "SMESH_MESHINFO_TITLE" ) ); - setSizeGripEnabled( TRUE ); + if (!name) + setName("SMESHGUI_MeshInfosDlg"); + setCaption(tr("SMESH_MESHINFO_TITLE")); + setSizeGripEnabled(TRUE); myStartSelection = true; myIsActiveWindow = true; - QVBoxLayout* aTopLayout = new QVBoxLayout( this ); - aTopLayout->setSpacing( 6 ); aTopLayout->setMargin( 11 ); + QVBoxLayout* aTopLayout = new QVBoxLayout(this); + aTopLayout->setSpacing(6); aTopLayout->setMargin(11); // select button & label - QPixmap image0( QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr( "ICON_SELECT" ) ) ); - mySelectBtn = new QPushButton( this, "mySelectBtn" ); - mySelectBtn->setPixmap( image0 ); - mySelectBtn->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) ); + QPixmap image0(SMESHGUI::resourceMgr()->loadPixmap("SMESH",tr("ICON_SELECT"))); + mySelectBtn = new QPushButton(this, "mySelectBtn"); + mySelectBtn->setPixmap(image0); + mySelectBtn->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); - mySelectLab = new QLabel( this, "mySelectLab" ); - mySelectLab->setAlignment( AlignCenter ); - QFont fnt = mySelectLab->font(); fnt.setBold( true ); - mySelectLab->setFont( fnt ); + mySelectLab = new QLabel(this, "mySelectLab"); + mySelectLab->setAlignment(AlignCenter); + QFont fnt = mySelectLab->font(); fnt.setBold(true); + mySelectLab->setFont(fnt); - QHBoxLayout* aSelectLayout = new QHBoxLayout; - aSelectLayout->setMargin( 0 ); aSelectLayout->setSpacing( 0 ); - aSelectLayout->addWidget( mySelectBtn ); - aSelectLayout->addWidget( mySelectLab ); + QHBoxLayout* aSelectLayout = new QHBoxLayout; + aSelectLayout->setMargin(0); aSelectLayout->setSpacing(0); + aSelectLayout->addWidget(mySelectBtn); + aSelectLayout->addWidget(mySelectLab); // top widget stack - myWGStack = new QWidgetStack( this ); + myWGStack = new QWidgetStack(this); // no valid selection - QWidget* myBadWidget = new QWidget( myWGStack ); - QVBoxLayout* aBadLayout = new QVBoxLayout( myBadWidget ); - QLabel* myBadLab = new QLabel( tr( "SMESH_BAD_SELECTION" ), myBadWidget, "myBadLab" ); - myBadLab->setAlignment( Qt::AlignCenter ); - myBadLab->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); - aBadLayout->addWidget( myBadLab ); - myWGStack->addWidget( myBadWidget, 0 ); - + QWidget* myBadWidget = new QWidget(myWGStack); + QVBoxLayout* aBadLayout = new QVBoxLayout(myBadWidget); + QLabel* myBadLab = new QLabel(tr("SMESH_BAD_SELECTION"), myBadWidget, "myBadLab"); + myBadLab->setAlignment(Qt::AlignCenter); + myBadLab->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); + aBadLayout->addWidget(myBadLab); + myWGStack->addWidget(myBadWidget, 0); + // mesh - myMeshWidget = new QWidget( myWGStack ); - QGridLayout* aMeshLayout = new QGridLayout( myMeshWidget ); - aMeshLayout->setSpacing( 6 ); aMeshLayout->setMargin( 0 ); - myWGStack->addWidget( myMeshWidget ); - + myMeshWidget = new QWidget(myWGStack); + QGridLayout* aMeshLayout = new QGridLayout(myMeshWidget); + aMeshLayout->setSpacing(6); aMeshLayout->setMargin(0); + myWGStack->addWidget(myMeshWidget); + // --> name - QLabel* myMeshNameLab = new QLabel( COLONIZE( tr( "SMESH_MESHINFO_NAME" ) ), myMeshWidget, "myMeshNameLab" ); - myMeshName = new QLabel( myMeshWidget, "myMeshName" ); - myMeshName->setMinimumWidth( 100 ); - QFrame* line1 = new QFrame( myMeshWidget ); - line1->setFrameStyle( QFrame::HLine | QFrame::Sunken ); - + QLabel* myMeshNameLab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_NAME")), myMeshWidget, "myMeshNameLab"); + myMeshName = new QLabel(myMeshWidget, "myMeshName"); + myMeshName->setMinimumWidth(100); + QFrame* line1 = new QFrame(myMeshWidget); + line1->setFrameStyle(QFrame::HLine | QFrame::Sunken); + // --> nodes - QLabel* myMeshNbNodesLab = new QLabel( COLONIZE( tr( "SMESH_MESHINFO_NODES" ) ), myMeshWidget, "myMeshNbNodesLab" ); - myMeshNbNodes = new QLabel( myMeshWidget, "myMeshNbNodes" ); - myMeshNbNodes->setMinimumWidth( 100 ); - + QLabel* myMeshNbNodesLab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_NODES")), myMeshWidget, "myMeshNbNodesLab"); + myMeshNbNodes = new QLabel(myMeshWidget, "myMeshNbNodes"); + myMeshNbNodes->setMinimumWidth(100); + // --> edges - QLabel* myMeshNbEdgesLab = new QLabel( COLONIZE( tr( "SMESH_MESHINFO_EDGES" ) ), myMeshWidget, "myMeshNbEdgesLab" ); - myMeshNbEdges = new QLabel( myMeshWidget, "myMeshNbEdges" ); - myMeshNbEdges->setMinimumWidth( 100 ); - + QLabel* myMeshNbEdgesLab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_EDGES")), myMeshWidget, "myMeshNbEdgesLab"); + myMeshNbEdges = new QLabel(myMeshWidget, "myMeshNbEdges"); + myMeshNbEdges->setMinimumWidth(100); + // --> faces - myMeshFacesGroup = new QGroupBox( tr( "SMESH_MESHINFO_FACES" ), myMeshWidget, "myMeshFacesGroup" ); - myMeshFacesGroup->setColumnLayout(0, Qt::Vertical ); - myMeshFacesGroup->layout()->setSpacing( 0 ); myMeshFacesGroup->layout()->setMargin( 0 ); - QGridLayout* myMeshFacesGroupLayout = new QGridLayout( myMeshFacesGroup->layout() ); - myMeshFacesGroupLayout->setAlignment( Qt::AlignTop ); - myMeshFacesGroupLayout->setSpacing( 6 ); myMeshFacesGroupLayout->setMargin( 11 ); + myMeshFacesGroup = new QGroupBox(tr("SMESH_MESHINFO_FACES"), myMeshWidget, "myMeshFacesGroup"); + myMeshFacesGroup->setColumnLayout(0, Qt::Vertical); + myMeshFacesGroup->layout()->setSpacing(0); myMeshFacesGroup->layout()->setMargin(0); + QGridLayout* myMeshFacesGroupLayout = new QGridLayout(myMeshFacesGroup->layout()); + myMeshFacesGroupLayout->setAlignment(Qt::AlignTop); + myMeshFacesGroupLayout->setSpacing(6); myMeshFacesGroupLayout->setMargin(11); // --> faces --> total - QLabel* myMeshNbFacesLab = new QLabel( COLONIZE( tr( "SMESH_MESHINFO_TOTAL" ) ), myMeshFacesGroup, "myMeshNbFacesLab" ); - myMeshNbFacesLab->setFont( fnt ); - myMeshNbFaces = new QLabel( myMeshFacesGroup, "myMeshNbFaces" ); - myMeshNbFaces->setMinimumWidth( 100 ); - myMeshNbFaces->setFont( fnt ); - + QLabel* myMeshNbFacesLab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_TOTAL")), myMeshFacesGroup, "myMeshNbFacesLab"); + myMeshNbFacesLab->setFont(fnt); + myMeshNbFaces = new QLabel(myMeshFacesGroup, "myMeshNbFaces"); + myMeshNbFaces->setMinimumWidth(100); + myMeshNbFaces->setFont(fnt); + // --> faces --> triangles - QLabel* myMeshNbTrianglesLab = new QLabel( COLONIZE( tr( "SMESH_MESHINFO_TRIANGLES" ) ), myMeshFacesGroup, "myMeshNbTrianglesLab" ); - myMeshNbTriangles = new QLabel( myMeshFacesGroup, "myMeshNbTriangles" ); - myMeshNbTriangles->setMinimumWidth( 100 ); - + QLabel* myMeshNbTrianglesLab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_TRIANGLES")), myMeshFacesGroup, "myMeshNbTrianglesLab"); + myMeshNbTriangles = new QLabel(myMeshFacesGroup, "myMeshNbTriangles"); + myMeshNbTriangles->setMinimumWidth(100); + // --> faces --> quadrangles - QLabel* myMeshNbQuadranglesLab = new QLabel( COLONIZE( tr( "SMESH_MESHINFO_QUADRANGLES" ) ), myMeshFacesGroup, "myMeshNbQuadranglesLab" ); - myMeshNbQuadrangles = new QLabel( myMeshFacesGroup, "myMeshNbQuadrangles" ); - myMeshNbQuadrangles->setMinimumWidth( 100 ); - - myMeshFacesGroupLayout->addWidget( myMeshNbFacesLab, 0, 0 ); - myMeshFacesGroupLayout->addWidget( myMeshNbFaces, 0, 1 ); - myMeshFacesGroupLayout->addWidget( myMeshNbTrianglesLab, 1, 0 ); - myMeshFacesGroupLayout->addWidget( myMeshNbTriangles, 1, 1 ); - myMeshFacesGroupLayout->addWidget( myMeshNbQuadranglesLab, 2, 0 ); - myMeshFacesGroupLayout->addWidget( myMeshNbQuadrangles, 2, 1 ); + QLabel* myMeshNbQuadranglesLab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_QUADRANGLES")), myMeshFacesGroup, "myMeshNbQuadranglesLab"); + myMeshNbQuadrangles = new QLabel(myMeshFacesGroup, "myMeshNbQuadrangles"); + myMeshNbQuadrangles->setMinimumWidth(100); + + // --> faces --> polygons + QLabel* myMeshNbPolygonesLab = new QLabel( COLONIZE( tr( "SMESH_MESHINFO_POLYGONES" ) ), myMeshFacesGroup, "myMeshNbPolygonesLab" ); + myMeshNbPolygones = new QLabel( myMeshFacesGroup, "myMeshNbPolygones" ); + myMeshNbPolygones->setMinimumWidth( 100 ); + + myMeshFacesGroupLayout->addWidget(myMeshNbFacesLab, 0, 0); + myMeshFacesGroupLayout->addWidget(myMeshNbFaces, 0, 1); + myMeshFacesGroupLayout->addWidget(myMeshNbTrianglesLab, 1, 0); + myMeshFacesGroupLayout->addWidget(myMeshNbTriangles, 1, 1); + myMeshFacesGroupLayout->addWidget(myMeshNbQuadranglesLab, 2, 0); + myMeshFacesGroupLayout->addWidget(myMeshNbQuadrangles, 2, 1); + myMeshFacesGroupLayout->addWidget( myMeshNbPolygonesLab, 3, 0 ); + myMeshFacesGroupLayout->addWidget( myMeshNbPolygones, 3, 1 ); // --> volumes - myMeshVolumesGroup = new QGroupBox( tr( "SMESH_MESHINFO_VOLUMES" ), myMeshWidget, "myMeshVolumesGroup" ); - myMeshVolumesGroup->setColumnLayout(0, Qt::Vertical ); - myMeshVolumesGroup->layout()->setSpacing( 0 ); myMeshVolumesGroup->layout()->setMargin( 0 ); - QGridLayout* myMeshVolumesGroupLayout = new QGridLayout( myMeshVolumesGroup->layout() ); - myMeshVolumesGroupLayout->setAlignment( Qt::AlignTop ); - myMeshVolumesGroupLayout->setSpacing( 6 ); myMeshVolumesGroupLayout->setMargin( 11 ); - + myMeshVolumesGroup = new QGroupBox(tr("SMESH_MESHINFO_VOLUMES"), myMeshWidget, "myMeshVolumesGroup"); + myMeshVolumesGroup->setColumnLayout(0, Qt::Vertical); + myMeshVolumesGroup->layout()->setSpacing(0); myMeshVolumesGroup->layout()->setMargin(0); + QGridLayout* myMeshVolumesGroupLayout = new QGridLayout(myMeshVolumesGroup->layout()); + myMeshVolumesGroupLayout->setAlignment(Qt::AlignTop); + myMeshVolumesGroupLayout->setSpacing(6); myMeshVolumesGroupLayout->setMargin(11); + // --> volumes --> total - QLabel* myMeshNbVolumesLab = new QLabel( COLONIZE( tr( "SMESH_MESHINFO_TOTAL" ) ), myMeshVolumesGroup, "myMeshNbVolumesLab" ); - myMeshNbVolumesLab->setFont( fnt ); - myMeshNbVolumes = new QLabel( myMeshVolumesGroup, "myMeshNbVolumes" ); - myMeshNbVolumes->setMinimumWidth( 100 ); - myMeshNbVolumes->setFont( fnt ); - + QLabel* myMeshNbVolumesLab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_TOTAL")), myMeshVolumesGroup, "myMeshNbVolumesLab"); + myMeshNbVolumesLab->setFont(fnt); + myMeshNbVolumes = new QLabel(myMeshVolumesGroup, "myMeshNbVolumes"); + myMeshNbVolumes->setMinimumWidth(100); + myMeshNbVolumes->setFont(fnt); + // --> volumes --> tetrahedrons - QLabel* myMeshNbTetraLab = new QLabel( COLONIZE( tr( "SMESH_MESHINFO_TETRAS" ) ), myMeshVolumesGroup, "myMeshNbTetraLab" ); - myMeshNbTetra = new QLabel( myMeshVolumesGroup, "myMeshNbTetra" ); - myMeshNbTetra->setMinimumWidth( 100 ); - + QLabel* myMeshNbTetraLab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_TETRAS")), myMeshVolumesGroup, "myMeshNbTetraLab"); + myMeshNbTetra = new QLabel(myMeshVolumesGroup, "myMeshNbTetra"); + myMeshNbTetra->setMinimumWidth(100); + // --> volumes --> hexahedrons - QLabel* myMeshNbHexaLab = new QLabel( COLONIZE( tr( "SMESH_MESHINFO_HEXAS" ) ), myMeshVolumesGroup, "myMeshNbHexaLab" ); - myMeshNbHexa = new QLabel( myMeshVolumesGroup, "myMeshNbHexa" ); - myMeshNbHexaLab->setMinimumWidth( 100 ); - + QLabel* myMeshNbHexaLab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_HEXAS")), myMeshVolumesGroup, "myMeshNbHexaLab"); + myMeshNbHexa = new QLabel(myMeshVolumesGroup, "myMeshNbHexa"); + myMeshNbHexaLab->setMinimumWidth(100); + // --> volumes --> prisms - QLabel* myMeshNbPrismLab = new QLabel( COLONIZE( tr( "SMESH_MESHINFO_PRISMS" ) ), myMeshVolumesGroup, "myMeshNbPrismLab" ); - myMeshNbPrism = new QLabel( myMeshVolumesGroup, "myMeshNbPrism" ); - myMeshNbPrism->setMinimumWidth( 100 ); - + QLabel* myMeshNbPrismLab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_PRISMS")), myMeshVolumesGroup, "myMeshNbPrismLab"); + myMeshNbPrism = new QLabel(myMeshVolumesGroup, "myMeshNbPrism"); + myMeshNbPrism->setMinimumWidth(100); + // --> volumes --> pyramids - QLabel* myMeshNbPyraLab = new QLabel( COLONIZE( tr( "SMESH_MESHINFO_PYRAS" ) ), myMeshVolumesGroup, "myMeshNbPyraLab" ); - myMeshNbPyra = new QLabel( myMeshVolumesGroup, "myMeshNbPyra" ); - myMeshNbPyra->setMinimumWidth( 100 ); - - myMeshVolumesGroupLayout->addWidget( myMeshNbVolumesLab, 0, 0 ); - myMeshVolumesGroupLayout->addWidget( myMeshNbVolumes, 0, 1 ); - myMeshVolumesGroupLayout->addWidget( myMeshNbTetraLab, 1, 0 ); - myMeshVolumesGroupLayout->addWidget( myMeshNbTetra, 1, 1 ); - myMeshVolumesGroupLayout->addWidget( myMeshNbHexaLab, 2, 0 ); - myMeshVolumesGroupLayout->addWidget( myMeshNbHexa, 2, 1 ); - myMeshVolumesGroupLayout->addWidget( myMeshNbPrismLab, 3, 0 ); - myMeshVolumesGroupLayout->addWidget( myMeshNbPrism, 3, 1 ); - myMeshVolumesGroupLayout->addWidget( myMeshNbPyraLab, 4, 0 ); - myMeshVolumesGroupLayout->addWidget( myMeshNbPyra, 4, 1 ); - - aMeshLayout->addWidget( myMeshNameLab, 0, 0 ); - aMeshLayout->addWidget( myMeshName, 0, 1 ); - aMeshLayout->addMultiCellWidget( line1, 1, 1, 0, 1 ); - aMeshLayout->addWidget( myMeshNbNodesLab, 2, 0 ); - aMeshLayout->addWidget( myMeshNbNodes, 2, 1 ); - aMeshLayout->addWidget( myMeshNbEdgesLab, 3, 0 ); - aMeshLayout->addWidget( myMeshNbEdges, 3, 1 ); - aMeshLayout->addMultiCellWidget( myMeshFacesGroup, 4, 4, 0, 1 ); - aMeshLayout->addMultiCellWidget( myMeshVolumesGroup, 5, 5, 0, 1 ); - aMeshLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Minimum, QSizePolicy::Expanding ), 6, 0 ); + QLabel* myMeshNbPyraLab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_PYRAS")), myMeshVolumesGroup, "myMeshNbPyraLab"); + myMeshNbPyra = new QLabel(myMeshVolumesGroup, "myMeshNbPyra"); + myMeshNbPyra->setMinimumWidth(100); + + // --> volumes --> polyherones + QLabel* myMeshNbPolyhedronesLab = new QLabel( COLONIZE( tr( "SMESH_MESHINFO_POLYEDRES" ) ), myMeshVolumesGroup, "myMeshNbPolyhedronLab" ); + myMeshNbPolyhedrones = new QLabel( myMeshVolumesGroup, "myMeshNbPolyhedrones" ); + myMeshNbPolyhedrones->setMinimumWidth( 100 ); + + myMeshVolumesGroupLayout->addWidget(myMeshNbVolumesLab, 0, 0); + myMeshVolumesGroupLayout->addWidget(myMeshNbVolumes, 0, 1); + myMeshVolumesGroupLayout->addWidget(myMeshNbTetraLab, 1, 0); + myMeshVolumesGroupLayout->addWidget(myMeshNbTetra, 1, 1); + myMeshVolumesGroupLayout->addWidget(myMeshNbHexaLab, 2, 0); + myMeshVolumesGroupLayout->addWidget(myMeshNbHexa, 2, 1); + myMeshVolumesGroupLayout->addWidget(myMeshNbPrismLab, 3, 0); + myMeshVolumesGroupLayout->addWidget(myMeshNbPrism, 3, 1); + myMeshVolumesGroupLayout->addWidget(myMeshNbPyraLab, 4, 0); + myMeshVolumesGroupLayout->addWidget(myMeshNbPyra, 4, 1); + myMeshVolumesGroupLayout->addWidget( myMeshNbPolyhedronesLab, 5, 0 ); + myMeshVolumesGroupLayout->addWidget( myMeshNbPolyhedrones, 5, 1 ); + + aMeshLayout->addWidget(myMeshNameLab, 0, 0); + aMeshLayout->addWidget(myMeshName, 0, 1); + aMeshLayout->addMultiCellWidget(line1, 1, 1, 0, 1); + aMeshLayout->addWidget(myMeshNbNodesLab, 2, 0); + aMeshLayout->addWidget(myMeshNbNodes, 2, 1); + aMeshLayout->addWidget(myMeshNbEdgesLab, 3, 0); + aMeshLayout->addWidget(myMeshNbEdges, 3, 1); + aMeshLayout->addMultiCellWidget(myMeshFacesGroup, 4, 4, 0, 1); + aMeshLayout->addMultiCellWidget(myMeshVolumesGroup, 5, 5, 0, 1); + aMeshLayout->addItem(new QSpacerItem(5, 5, QSizePolicy::Minimum, QSizePolicy::Expanding), 6, 0); // submesh - mySubMeshWidget = new QWidget( myWGStack ); - QGridLayout* aSubMeshLayout = new QGridLayout( mySubMeshWidget ); - aSubMeshLayout->setSpacing( 6 ); aSubMeshLayout->setMargin( 0 ); - myWGStack->addWidget( mySubMeshWidget ); - + mySubMeshWidget = new QWidget(myWGStack); + QGridLayout* aSubMeshLayout = new QGridLayout(mySubMeshWidget); + aSubMeshLayout->setSpacing(6); aSubMeshLayout->setMargin(0); + myWGStack->addWidget(mySubMeshWidget); + // --> name - QLabel* mySubMeshNameLab = new QLabel( COLONIZE( tr( "SMESH_MESHINFO_NAME" ) ), mySubMeshWidget, "mySubMeshNameLab" ); - mySubMeshName = new QLabel( mySubMeshWidget, "mySubMeshName" ); - mySubMeshName->setMinimumWidth( 100 ); - QFrame* line2 = new QFrame( mySubMeshWidget ); - line2->setFrameStyle( QFrame::HLine | QFrame::Sunken ); - + QLabel* mySubMeshNameLab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_NAME")), mySubMeshWidget, "mySubMeshNameLab"); + mySubMeshName = new QLabel(mySubMeshWidget, "mySubMeshName"); + mySubMeshName->setMinimumWidth(100); + QFrame* line2 = new QFrame(mySubMeshWidget); + line2->setFrameStyle(QFrame::HLine | QFrame::Sunken); + // --> nodes - QLabel* mySubMeshNbNodesLab = new QLabel( COLONIZE( tr( "SMESH_MESHINFO_NODES" ) ), mySubMeshWidget, "mySubMeshNbNodesLab" ); - mySubMeshNbNodes = new QLabel( mySubMeshWidget, "mySubMeshNbNodes" ); - mySubMeshNbNodes->setMinimumWidth( 100 ); - + QLabel* mySubMeshNbNodesLab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_NODES")), mySubMeshWidget, "mySubMeshNbNodesLab"); + mySubMeshNbNodes = new QLabel(mySubMeshWidget, "mySubMeshNbNodes"); + mySubMeshNbNodes->setMinimumWidth(100); + // --> elements - mySubMeshElementsGroup = new QGroupBox( tr( "SMESH_MESHINFO_ELEMENTS" ), mySubMeshWidget, "mySubMeshElementsGroup" ); - mySubMeshElementsGroup->setColumnLayout(0, Qt::Vertical ); - mySubMeshElementsGroup->layout()->setSpacing( 0 ); mySubMeshElementsGroup->layout()->setMargin( 0 ); - QGridLayout* mySubMeshElementsGroupLayout = new QGridLayout( mySubMeshElementsGroup->layout() ); - mySubMeshElementsGroupLayout->setAlignment( Qt::AlignTop ); - mySubMeshElementsGroupLayout->setSpacing( 6 ); mySubMeshElementsGroupLayout->setMargin( 11 ); + mySubMeshElementsGroup = new QGroupBox(tr("SMESH_MESHINFO_ELEMENTS"), mySubMeshWidget, "mySubMeshElementsGroup"); + mySubMeshElementsGroup->setColumnLayout(0, Qt::Vertical); + mySubMeshElementsGroup->layout()->setSpacing(0); mySubMeshElementsGroup->layout()->setMargin(0); + QGridLayout* mySubMeshElementsGroupLayout = new QGridLayout(mySubMeshElementsGroup->layout()); + mySubMeshElementsGroupLayout->setAlignment(Qt::AlignTop); + mySubMeshElementsGroupLayout->setSpacing(6); mySubMeshElementsGroupLayout->setMargin(11); // --> elements --> total - QLabel* mySubMeshNbElementsLab = new QLabel( COLONIZE( tr( "SMESH_MESHINFO_TOTAL" ) ), mySubMeshElementsGroup, "mySubMeshNbElementsLab" ); - mySubMeshNbElementsLab->setFont( fnt ); - mySubMeshNbElements = new QLabel( mySubMeshElementsGroup, "mySubMeshNbElements" ); - mySubMeshNbElements->setMinimumWidth( 100 ); - mySubMeshNbElements->setFont( fnt ); - - // --> elements --> edges - QLabel* mySubMeshNbEdgesLab = new QLabel( COLONIZE( tr( "SMESH_MESHINFO_EDGES" ) ), mySubMeshElementsGroup, "mySubMeshNbEdgesLab" ); - mySubMeshNbEdges = new QLabel( mySubMeshElementsGroup, "mySubMeshNbEdges" ); - mySubMeshNbEdges->setMinimumWidth( 100 ); - - // --> elements --> faces - QLabel* mySubMeshNbFacesLab = new QLabel( COLONIZE( tr( "SMESH_MESHINFO_FACES" ) ), mySubMeshElementsGroup, "mySubMeshNbFacesLab" ); - mySubMeshNbFaces = new QLabel( mySubMeshElementsGroup, "mySubMeshNbFaces" ); - mySubMeshNbFaces->setMinimumWidth( 100 ); - - // --> elements --> volumes - QLabel* mySubMeshNbVolumesLab = new QLabel( COLONIZE( tr( "SMESH_MESHINFO_VOLUMES" ) ), mySubMeshElementsGroup, "mySubMeshNbVolumesLab" ); - mySubMeshNbVolumes = new QLabel( mySubMeshElementsGroup, "mySubMeshNbVolumes" ); - mySubMeshNbVolumes->setMinimumWidth( 100 ); - - mySubMeshElementsGroupLayout->addWidget( mySubMeshNbElementsLab, 0, 0 ); - mySubMeshElementsGroupLayout->addWidget( mySubMeshNbElements, 0, 1 ); - mySubMeshElementsGroupLayout->addWidget( mySubMeshNbEdgesLab, 1, 0 ); - mySubMeshElementsGroupLayout->addWidget( mySubMeshNbEdges, 1, 1 ); - mySubMeshElementsGroupLayout->addWidget( mySubMeshNbFacesLab, 2, 0 ); - mySubMeshElementsGroupLayout->addWidget( mySubMeshNbFaces, 2, 1 ); - mySubMeshElementsGroupLayout->addWidget( mySubMeshNbVolumesLab, 3, 0 ); - mySubMeshElementsGroupLayout->addWidget( mySubMeshNbVolumes, 3, 1 ); + QLabel* mySubMeshNbElementsLab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_TOTAL")), mySubMeshElementsGroup, "mySubMeshNbElementsLab"); + mySubMeshNbElementsLab->setFont(fnt); + mySubMeshNbElements = new QLabel(mySubMeshElementsGroup, "mySubMeshNbElements"); + mySubMeshNbElements->setMinimumWidth(100); + mySubMeshNbElements->setFont(fnt); - aSubMeshLayout->addWidget( mySubMeshNameLab, 0, 0 ); - aSubMeshLayout->addWidget( mySubMeshName, 0, 1 ); - aSubMeshLayout->addMultiCellWidget( line2, 1, 1, 0, 1 ); - aSubMeshLayout->addWidget( mySubMeshNbNodesLab, 2, 0 ); - aSubMeshLayout->addWidget( mySubMeshNbNodes, 2, 1 ); - aSubMeshLayout->addMultiCellWidget( mySubMeshElementsGroup, 3, 3, 0, 1 ); - aSubMeshLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Minimum, QSizePolicy::Expanding ), 4, 0 ); + // --> elements --> edges + QLabel* mySubMeshNbEdgesLab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_EDGES")), mySubMeshElementsGroup, "mySubMeshNbEdgesLab"); + mySubMeshNbEdges = new QLabel(mySubMeshElementsGroup, "mySubMeshNbEdges"); + mySubMeshNbEdges->setMinimumWidth(100); + + // --> elements --> faces + QLabel* mySubMeshNbFacesLab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_FACES")), mySubMeshElementsGroup, "mySubMeshNbFacesLab"); + mySubMeshNbFaces = new QLabel(mySubMeshElementsGroup, "mySubMeshNbFaces"); + mySubMeshNbFaces->setMinimumWidth(100); + + // --> elements --> volumes + QLabel* mySubMeshNbVolumesLab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_VOLUMES")), mySubMeshElementsGroup, "mySubMeshNbVolumesLab"); + mySubMeshNbVolumes = new QLabel(mySubMeshElementsGroup, "mySubMeshNbVolumes"); + mySubMeshNbVolumes->setMinimumWidth(100); + + mySubMeshElementsGroupLayout->addWidget(mySubMeshNbElementsLab, 0, 0); + mySubMeshElementsGroupLayout->addWidget(mySubMeshNbElements, 0, 1); + mySubMeshElementsGroupLayout->addWidget(mySubMeshNbEdgesLab, 1, 0); + mySubMeshElementsGroupLayout->addWidget(mySubMeshNbEdges, 1, 1); + mySubMeshElementsGroupLayout->addWidget(mySubMeshNbFacesLab, 2, 0); + mySubMeshElementsGroupLayout->addWidget(mySubMeshNbFaces, 2, 1); + mySubMeshElementsGroupLayout->addWidget(mySubMeshNbVolumesLab, 3, 0); + mySubMeshElementsGroupLayout->addWidget(mySubMeshNbVolumes, 3, 1); + + aSubMeshLayout->addWidget(mySubMeshNameLab, 0, 0); + aSubMeshLayout->addWidget(mySubMeshName, 0, 1); + aSubMeshLayout->addMultiCellWidget(line2, 1, 1, 0, 1); + aSubMeshLayout->addWidget(mySubMeshNbNodesLab, 2, 0); + aSubMeshLayout->addWidget(mySubMeshNbNodes, 2, 1); + aSubMeshLayout->addMultiCellWidget(mySubMeshElementsGroup, 3, 3, 0, 1); + aSubMeshLayout->addItem(new QSpacerItem(5, 5, QSizePolicy::Minimum, QSizePolicy::Expanding), 4, 0); // group - myGroupWidget = new QWidget( myWGStack ); - QGridLayout* myGroupWidgetLayout = new QGridLayout( myGroupWidget ); - myGroupWidgetLayout->setSpacing( 6 ); myGroupWidgetLayout->setMargin( 0 ); - myWGStack->addWidget( myGroupWidget ); - + myGroupWidget = new QWidget(myWGStack); + QGridLayout* myGroupWidgetLayout = new QGridLayout(myGroupWidget); + myGroupWidgetLayout->setSpacing(6); myGroupWidgetLayout->setMargin(0); + myWGStack->addWidget(myGroupWidget); + // --> name - QLabel* myGroupNameLab = new QLabel( COLONIZE( tr( "SMESH_MESHINFO_NAME" ) ), myGroupWidget, "myGroupNameLab" ); - myGroupName = new QLabel( myGroupWidget, "myGroupName" ); - myGroupName->setMinimumWidth( 100 ); - QFrame* line3 = new QFrame( myGroupWidget ); - line3->setFrameStyle( QFrame::HLine | QFrame::Sunken ); - + QLabel* myGroupNameLab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_NAME")), myGroupWidget, "myGroupNameLab"); + myGroupName = new QLabel(myGroupWidget, "myGroupName"); + myGroupName->setMinimumWidth(100); + QFrame* line3 = new QFrame(myGroupWidget); + line3->setFrameStyle(QFrame::HLine | QFrame::Sunken); + // --> type - QLabel* myGroupTypeLab = new QLabel( COLONIZE( tr( "SMESH_MESHINFO_TYPE" ) ), myGroupWidget, "myGroupTypeLab" ); - myGroupType = new QLabel( myGroupWidget, "myGroupType" ); - myGroupType->setMinimumWidth( 100 ); + QLabel* myGroupTypeLab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_TYPE")), myGroupWidget, "myGroupTypeLab"); + myGroupType = new QLabel(myGroupWidget, "myGroupType"); + myGroupType->setMinimumWidth(100); // --> number of entities - QLabel* myGroupNbLab = new QLabel( COLONIZE( tr( "SMESH_MESHINFO_ENTITIES" ) ), myGroupWidget, "myGroupNbLab" ); - myGroupNb = new QLabel( myGroupWidget, "myGroupNb" ); - myGroupNb->setMinimumWidth( 100 ); - - myGroupWidgetLayout->addWidget( myGroupNameLab, 0, 0 ); - myGroupWidgetLayout->addWidget( myGroupName, 0, 1 ); - myGroupWidgetLayout->addMultiCellWidget( line3, 1, 1, 0, 1 ); - myGroupWidgetLayout->addWidget( myGroupTypeLab, 2, 0 ); - myGroupWidgetLayout->addWidget( myGroupType, 2, 1 ); - myGroupWidgetLayout->addWidget( myGroupNbLab, 3, 0 ); - myGroupWidgetLayout->addWidget( myGroupNb, 3, 1 ); - myGroupWidgetLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Minimum, QSizePolicy::Expanding ), 4, 0 ); + QLabel* myGroupNbLab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_ENTITIES")), myGroupWidget, "myGroupNbLab"); + myGroupNb = new QLabel(myGroupWidget, "myGroupNb"); + myGroupNb->setMinimumWidth(100); + + myGroupWidgetLayout->addWidget(myGroupNameLab, 0, 0); + myGroupWidgetLayout->addWidget(myGroupName, 0, 1); + myGroupWidgetLayout->addMultiCellWidget(line3, 1, 1, 0, 1); + myGroupWidgetLayout->addWidget(myGroupTypeLab, 2, 0); + myGroupWidgetLayout->addWidget(myGroupType, 2, 1); + myGroupWidgetLayout->addWidget(myGroupNbLab, 3, 0); + myGroupWidgetLayout->addWidget(myGroupNb, 3, 1); + myGroupWidgetLayout->addItem(new QSpacerItem(5, 5, QSizePolicy::Minimum, QSizePolicy::Expanding), 4, 0); // buttons - myButtonsGroup = new QGroupBox( this, "myButtonsGroup" ); - myButtonsGroup->setColumnLayout(0, Qt::Vertical ); - myButtonsGroup->layout()->setSpacing( 0 ); myButtonsGroup->layout()->setMargin( 0 ); - QHBoxLayout* myButtonsGroupLayout = new QHBoxLayout( myButtonsGroup->layout() ); - myButtonsGroupLayout->setAlignment( Qt::AlignTop ); - myButtonsGroupLayout->setSpacing( 6 ); myButtonsGroupLayout->setMargin( 11 ); - + myButtonsGroup = new QGroupBox(this, "myButtonsGroup"); + myButtonsGroup->setColumnLayout(0, Qt::Vertical); + myButtonsGroup->layout()->setSpacing(0); myButtonsGroup->layout()->setMargin(0); + QHBoxLayout* myButtonsGroupLayout = new QHBoxLayout(myButtonsGroup->layout()); + myButtonsGroupLayout->setAlignment(Qt::AlignTop); + myButtonsGroupLayout->setSpacing(6); myButtonsGroupLayout->setMargin(11); + // buttons --> OK button - myOkBtn = new QPushButton( tr( "SMESH_BUT_OK" ), myButtonsGroup, "myOkBtn" ); - myOkBtn->setAutoDefault( TRUE ); myOkBtn->setDefault( TRUE ); + myOkBtn = new QPushButton(tr("SMESH_BUT_OK" ), myButtonsGroup, "myOkBtn"); + myOkBtn->setAutoDefault(TRUE); myOkBtn->setDefault(TRUE); myButtonsGroupLayout->addStretch(); - myButtonsGroupLayout->addWidget( myOkBtn ); + myButtonsGroupLayout->addWidget(myOkBtn); myButtonsGroupLayout->addStretch(); - aTopLayout->addLayout( aSelectLayout ); - aTopLayout->addWidget( myWGStack ); - aTopLayout->addWidget( myButtonsGroup ); - - mySelection = SALOME_Selection::Selection( SMESHGUI::GetSMESHGUI()->GetActiveStudy()->getSelection() ); - SMESHGUI::GetSMESHGUI()->SetActiveDialogBox( this ) ; + aTopLayout->addLayout(aSelectLayout); + aTopLayout->addWidget(myWGStack); + aTopLayout->addWidget(myButtonsGroup); + + mySMESHGUI->SetActiveDialogBox(this); // connect signals - connect( myOkBtn, SIGNAL( clicked() ), this, SLOT( close() ) ); - connect( mySelectBtn, SIGNAL( clicked() ), this, SLOT( onStartSelection() ) ); - connect( SMESHGUI::GetSMESHGUI(), SIGNAL( SignalCloseAllDialogs() ), this, SLOT( close() ) ) ; - connect( SMESHGUI::GetSMESHGUI(), SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; - connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionChanged() ) ); + connect(myOkBtn, SIGNAL(clicked()), this, SLOT(close())); + connect(mySelectBtn, SIGNAL(clicked()), this, SLOT(onStartSelection())); + connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(close())); + connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog())); + connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(onSelectionChanged())); // resize and move dialog, then show int x, y; - SMESHGUI::GetSMESHGUI()->DefineDlgPosition( this, x, y ); - this->move( x, y ); + mySMESHGUI->DefineDlgPosition(this, x, y); + this->move(x, y); this->show(); - cout<<"----"<height()<width()<IObjectCount(); - if ( nbSel == 1 ) { + SUIT_OverrideCursor wc; + + SALOME_ListIO aList; + mySelectionMgr->selectedObjects(aList); + + int nbSel = aList.Extent(); + if (nbSel == 1) { myStartSelection = false; - mySelectLab->setText( "" ); - Handle(SALOME_InteractiveObject) IObject = mySelection->firstIObject(); - SALOMEDS::SObject_var aSO = SMESH::GetActiveStudyDocument()->FindObjectID( IObject->getEntry() ); - if ( !aSO->_is_nil() ) { - CORBA::Object_var anObject = aSO->GetObject(); - if ( !CORBA::is_nil( anObject ) ) { - SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( anObject ); - if ( !aMesh->_is_nil() ) { - myWGStack->raiseWidget( myMeshWidget ); - setCaption( tr( "SMESH_MESHINFO_TITLE" ) + " [" + tr("SMESH_OBJECT_MESH") +"]" ); - myMeshName->setText( aSO->GetName() ); - myMeshNbNodes->setNum( (int)aMesh->NbNodes() ); - myMeshNbEdges->setNum( (int)aMesh->NbEdges() ); - myMeshNbFaces->setNum( (int)aMesh->NbFaces() ); - myMeshNbTriangles->setNum( (int)aMesh->NbTriangles() ); - myMeshNbQuadrangles->setNum( (int)aMesh->NbQuadrangles() ); - myMeshNbVolumes->setNum( (int)aMesh->NbVolumes() ); - myMeshNbTetra->setNum( (int)aMesh->NbTetras() ); - myMeshNbHexa->setNum( (int)aMesh->NbHexas() ); - myMeshNbPrism->setNum( (int)aMesh->NbPrisms() ); - myMeshNbPyra->setNum( (int)aMesh->NbPyramids() ); + mySelectLab->setText(""); + Handle(SALOME_InteractiveObject) IObject = aList.First(); + _PTR(SObject) aSO = SMESH::GetActiveStudyDocument()->FindObjectID(IObject->getEntry()); + if (aSO) { + //CORBA::Object_var anObject = aSO->GetObject(); + CORBA::Object_var anObject = SMESH::SObjectToObject(aSO); + if (!CORBA::is_nil(anObject)) { + SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow(anObject); + if (!aMesh->_is_nil()) { + myWGStack->raiseWidget(myMeshWidget); + setCaption(tr("SMESH_MESHINFO_TITLE") + " [" + tr("SMESH_OBJECT_MESH") + "]"); + myMeshName->setText(aSO->GetName().c_str()); + myMeshNbNodes->setNum((int)aMesh->NbNodes()); + myMeshNbEdges->setNum((int)aMesh->NbEdges()); + myMeshNbFaces->setNum((int)aMesh->NbFaces()); + myMeshNbTriangles->setNum((int)aMesh->NbTriangles()); + myMeshNbQuadrangles->setNum((int)aMesh->NbQuadrangles()); + myMeshNbPolygones->setNum( (int)aMesh->NbPolygons() ); + myMeshNbVolumes->setNum((int)aMesh->NbVolumes()); + myMeshNbTetra->setNum((int)aMesh->NbTetras()); + myMeshNbHexa->setNum((int)aMesh->NbHexas()); + myMeshNbPrism->setNum((int)aMesh->NbPrisms()); + myMeshNbPyra->setNum((int)aMesh->NbPyramids()); + myMeshNbPolyhedrones->setNum( (int)aMesh->NbPolyhedrons() ); return; } - SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( anObject ); - if ( !aSubMesh->_is_nil() ) { - myWGStack->raiseWidget( mySubMeshWidget ); - setCaption( tr( "SMESH_MESHINFO_TITLE" ) + " [" + tr("SMESH_SUBMESH") +"]" ); - mySubMeshName->setText( aSO->GetName() ); - mySubMeshNbNodes->setNum( (int)aSubMesh->GetNumberOfNodes( true ) ); - mySubMeshNbElements->setNum( (int)aSubMesh->GetNumberOfElements() ); - mySubMeshNbEdges->setNum( (int)( aSubMesh->GetElementsByType( SMESH::EDGE )->length() ) ); - mySubMeshNbFaces->setNum( (int)( aSubMesh->GetElementsByType( SMESH::FACE )->length() ) ); - mySubMeshNbVolumes->setNum( (int)( aSubMesh->GetElementsByType( SMESH::VOLUME )->length() ) ); + SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow(anObject); + if (!aSubMesh->_is_nil()) { + myWGStack->raiseWidget(mySubMeshWidget); + setCaption(tr("SMESH_MESHINFO_TITLE") + " [" + tr("SMESH_SUBMESH") + "]"); + mySubMeshName->setText(aSO->GetName().c_str()); + mySubMeshNbNodes->setNum((int)aSubMesh->GetNumberOfNodes(true)); + mySubMeshNbElements->setNum((int)aSubMesh->GetNumberOfElements()); + mySubMeshNbEdges->setNum((int)(aSubMesh->GetElementsByType(SMESH::EDGE)->length())); + mySubMeshNbFaces->setNum((int)(aSubMesh->GetElementsByType(SMESH::FACE)->length())); + mySubMeshNbVolumes->setNum((int)(aSubMesh->GetElementsByType(SMESH::VOLUME)->length())); return; } - SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( anObject ); - if ( !aGroup->_is_nil() ) { - myWGStack->raiseWidget( myGroupWidget ); - setCaption( tr( "SMESH_MESHINFO_TITLE" ) + " [" + tr("SMESH_GROUP") +"]" ); - myGroupName->setText( aSO->GetName() ); + SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow(anObject); + if (!aGroup->_is_nil()) { + myWGStack->raiseWidget(myGroupWidget); + setCaption(tr("SMESH_MESHINFO_TITLE") + " [" + tr("SMESH_GROUP") + "]"); + myGroupName->setText(aSO->GetName().c_str()); int aType = aGroup->GetType(); QString strType; - switch ( aType ) { + switch (aType) { case SMESH::NODE: strType = "SMESH_MESHINFO_NODES"; break; case SMESH::EDGE: @@ -429,16 +453,16 @@ void SMESHGUI_MeshInfosDlg::DumpMeshInfos() default: strType = "SMESH_MESHINFO_ALL_TYPES"; break; } - - myGroupType->setText( tr( strType ) ); - myGroupNb->setNum( (int)aGroup->Size() ); + + myGroupType->setText(tr(strType)); + myGroupNb->setNum((int)aGroup->Size()); return; } } } } - myWGStack->raiseWidget( 0 ); - setCaption( tr( "SMESH_MESHINFO_TITLE" ) ); + myWGStack->raiseWidget(0); + setCaption(tr("SMESH_MESHINFO_TITLE")); } //================================================================================= @@ -447,45 +471,41 @@ void SMESHGUI_MeshInfosDlg::DumpMeshInfos() //================================================================================= void SMESHGUI_MeshInfosDlg::onSelectionChanged() { - if ( myStartSelection ) + if (myStartSelection) DumpMeshInfos(); } - //================================================================================= // function : closeEvent() // purpose : //================================================================================= -void SMESHGUI_MeshInfosDlg::closeEvent( QCloseEvent* e ) +void SMESHGUI_MeshInfosDlg::closeEvent (QCloseEvent* e) { - SMESHGUI::GetSMESHGUI()->ResetState(); - QDialog::closeEvent( e ); + mySMESHGUI->ResetState(); + QDialog::closeEvent(e); } - //================================================================================= // function : windowActivationChange() // purpose : called when window is activated/deactivated //================================================================================= -void SMESHGUI_MeshInfosDlg::windowActivationChange( bool oldActive ) +void SMESHGUI_MeshInfosDlg::windowActivationChange (bool oldActive) { - QDialog::windowActivationChange( oldActive ); - if ( isActiveWindow() && myIsActiveWindow != isActiveWindow() ) - ActivateThisDialog() ; + QDialog::windowActivationChange(oldActive); + if (isActiveWindow() && myIsActiveWindow != isActiveWindow()) + ActivateThisDialog(); myIsActiveWindow = isActiveWindow(); } - //================================================================================= // function : DeactivateActiveDialog() // purpose : //================================================================================= void SMESHGUI_MeshInfosDlg::DeactivateActiveDialog() { - disconnect( mySelection, 0, this, 0 ); + disconnect(mySelectionMgr, 0, this, 0); } - //================================================================================= // function : ActivateThisDialog() // purpose : @@ -493,8 +513,8 @@ void SMESHGUI_MeshInfosDlg::DeactivateActiveDialog() void SMESHGUI_MeshInfosDlg::ActivateThisDialog() { /* Emit a signal to deactivate any active dialog */ - SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog() ; - connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionChanged() ) ); + mySMESHGUI->EmitSignalDeactivateDialog(); + connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(onSelectionChanged())); } //================================================================================= @@ -506,5 +526,5 @@ void SMESHGUI_MeshInfosDlg::onStartSelection() myStartSelection = true; onSelectionChanged(); myStartSelection = true; - mySelectLab->setText( tr( "INF_SELECT_OBJECT" ) ); + mySelectLab->setText(tr("INF_SELECT_OBJECT")); } diff --git a/src/SMESHGUI/SMESHGUI_MeshInfosDlg.h b/src/SMESHGUI/SMESHGUI_MeshInfosDlg.h index c8123d8c0..49db8c13a 100644 --- a/src/SMESHGUI/SMESHGUI_MeshInfosDlg.h +++ b/src/SMESHGUI/SMESHGUI_MeshInfosDlg.h @@ -35,15 +35,20 @@ class QGroupBox; class QLabel; class QPushButton; -class SALOME_Selection; class QWidgetStack; +class SalomeApp_SelectionMgr; +class SMESHGUI; + class SMESHGUI_MeshInfosDlg : public QDialog { Q_OBJECT public: - SMESHGUI_MeshInfosDlg( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); + SMESHGUI_MeshInfosDlg( SMESHGUI* theModule, + const char* name = 0, + bool modal = FALSE, + WFlags fl = 0 ); ~SMESHGUI_MeshInfosDlg(); protected: @@ -58,10 +63,11 @@ private slots: void onStartSelection(); private: - SALOME_Selection* mySelection; - bool myStartSelection; - bool myIsActiveWindow; - + SMESHGUI* mySMESHGUI; + SalomeApp_SelectionMgr* mySelectionMgr; + bool myStartSelection; + bool myIsActiveWindow; + QPushButton* mySelectBtn; QLabel* mySelectLab; @@ -75,13 +81,15 @@ private: QLabel* myMeshNbFaces; QLabel* myMeshNbTriangles; QLabel* myMeshNbQuadrangles; + QLabel* myMeshNbPolygones; QGroupBox* myMeshVolumesGroup; QLabel* myMeshNbVolumes; QLabel* myMeshNbTetra; QLabel* myMeshNbHexa; QLabel* myMeshNbPyra; QLabel* myMeshNbPrism; - + QLabel* myMeshNbPolyhedrones; + QWidget* mySubMeshWidget; QLabel* mySubMeshName; QLabel* mySubMeshNbNodes; diff --git a/src/SMESHGUI/SMESHGUI_MeshPatternDlg.cxx b/src/SMESHGUI/SMESHGUI_MeshPatternDlg.cxx index efc4eec75..2093f8ae1 100755 --- a/src/SMESHGUI/SMESHGUI_MeshPatternDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_MeshPatternDlg.cxx @@ -1,23 +1,23 @@ // SMESH SMESHGUI : GUI for SMESH component // // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org // // // @@ -27,29 +27,44 @@ #include "SMESHGUI_MeshPatternDlg.h" -#include "QAD_Desktop.h" -#include "QAD_FileDlg.h" - -#include "SMESHGUI_SpinBox.h" #include "SMESHGUI.h" -#include "SALOME_Selection.h" -#include "SMESH_NumberFilter.hxx" -#include "SMESHGUI_Utils.h" -#include "SMESHGUI_VTKUtils.h" +#include "SMESHGUI_SpinBox.h" #include "SMESHGUI_CreatePatternDlg.h" #include "SMESHGUI_PatternWidget.h" -#include "SMESH_Actor.h" -#include "SALOMEGUI_QtCatchCorbaException.hxx" -#include "VTKViewer_ViewFrame.h" +#include "SMESHGUI_Utils.h" +#include "SMESHGUI_VTKUtils.h" #include "SMESHGUI_PatternUtils.h" +#include "SMESHGUI_GEOMGenUtils.h" + +#include "SMESH_Actor.h" #include "SMESH_ActorUtils.h" -#include "SMDS_MeshElement.hxx" +#include "SMESH_NumberFilter.hxx" + #include "SMDS_Mesh.hxx" +#include "SMDS_MeshElement.hxx" -#include "QAD_Config.h" +#include "SUIT_ResourceMgr.h" +#include "SUIT_Desktop.h" +#include "SUIT_FileDlg.h" +#include "SalomeApp_SelectionMgr.h" +#include "SalomeApp_Tools.h" +#include "SalomeApp_Study.h" + +#include "SALOMEDS_SObject.hxx" + +#include "SALOME_ListIO.hxx" +#include "SVTK_Selection.h" + +#include "SVTK_ViewModel.h" +#include "SVTK_Selector.h" +#include "SVTK_ViewWindow.h" + +// OCCT Includes #include +#include +// QT Includes #include #include #include @@ -63,7 +78,12 @@ #include #include #include +#include +#include +#include +#include +// VTK Includes #include #include #include @@ -75,210 +95,211 @@ #define SPACING 5 #define MARGIN 10 -/* - Class : SMESHGUI_MeshPatternDlg - Description : Dialog to specify filters for VTK viewer -*/ +/*! + * Class : SMESHGUI_MeshPatternDlg + * Description : Dialog to specify filters for VTK viewer + */ //======================================================================= // name : SMESHGUI_MeshPatternDlg::SMESHGUI_MeshPatternDlg // Purpose : Constructor //======================================================================= -SMESHGUI_MeshPatternDlg::SMESHGUI_MeshPatternDlg( QWidget* theParent, - SALOME_Selection* theSelection, - const char* theName ) -: QDialog( theParent, theName, false, - WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ), - myBusy( false ) +SMESHGUI_MeshPatternDlg::SMESHGUI_MeshPatternDlg( SMESHGUI* theModule, + const char* theName ) + : QDialog( SMESH::GetDesktop( theModule ), theName, false, WStyle_Customize | + WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu), + myBusy(false), + mySMESHGUI( theModule ), + mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ), + myViewWindow( SMESH::GetViewWindow( theModule ) ), + mySelector( myViewWindow->GetSelector() ) { - setCaption( tr( "CAPTION" ) ); + setCaption(tr("CAPTION")); - QVBoxLayout* aDlgLay = new QVBoxLayout( this, MARGIN, SPACING ); + QVBoxLayout* aDlgLay = new QVBoxLayout(this, MARGIN, SPACING); - QFrame* aMainFrame = createMainFrame ( this ); - QFrame* aBtnFrame = createButtonFrame( this ); + QFrame* aMainFrame = createMainFrame (this); + QFrame* aBtnFrame = createButtonFrame(this); + aDlgLay->addWidget(aMainFrame); + aDlgLay->addWidget(aBtnFrame); - - - aDlgLay->addWidget( aMainFrame ); - aDlgLay->addWidget( aBtnFrame ); - - aDlgLay->setStretchFactor( aMainFrame, 1 ); + aDlgLay->setStretchFactor(aMainFrame, 1); myCreationDlg = 0; - Init( theSelection ); + Init(); } //======================================================================= // name : SMESHGUI_MeshPatternDlg::createMainFrame // Purpose : Create frame containing dialog's input fields //======================================================================= -QFrame* SMESHGUI_MeshPatternDlg::createMainFrame( QWidget* theParent ) +QFrame* SMESHGUI_MeshPatternDlg::createMainFrame (QWidget* theParent) { - QPixmap iconSlct( QAD_Desktop::getResourceManager()->loadPixmap( "SMESH", tr( "ICON_SELECT" ) ) ); - QPixmap icon2d ( QAD_Desktop::getResourceManager()->loadPixmap( "SMESH", tr( "ICON_PATTERN_2d" ) ) ); - QPixmap icon3d ( QAD_Desktop::getResourceManager()->loadPixmap( "SMESH", tr( "ICON_PATTERN_3d" ) ) ); - QPixmap iconOpen( QAD_Desktop::getResourceManager()->loadPixmap( "SMESH", tr( "ICON_FILE_OPEN" ) ) ); + QPixmap iconSlct (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT"))); + QPixmap icon2d (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_PATTERN_2d"))); + QPixmap icon3d (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_PATTERN_3d"))); + QPixmap iconOpen (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_FILE_OPEN"))); - QPixmap iconSample2d( QAD_Desktop::getResourceManager()->loadPixmap( "SMESH", tr( "ICON_PATTERN_SAMPLE_2D" ) ) ); - QPixmap iconSample3d( QAD_Desktop::getResourceManager()->loadPixmap( "SMESH", tr( "ICON_PATTERN_SAMPLE_3D" ) ) ); + QPixmap iconSample2d (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_PATTERN_SAMPLE_2D"))); + QPixmap iconSample3d (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_PATTERN_SAMPLE_3D"))); - QGroupBox* aMainGrp = new QGroupBox( 1, Qt::Horizontal, theParent ); - aMainGrp->setFrameStyle( QFrame::NoFrame ); - aMainGrp->setInsideMargin( 0 ); + QGroupBox* aMainGrp = new QGroupBox (1, Qt::Horizontal, theParent); + aMainGrp->setFrameStyle(QFrame::NoFrame); + aMainGrp->setInsideMargin(0); // Pattern type group - - myTypeGrp = new QButtonGroup( 1, Qt::Vertical, tr( "PATTERN_TYPE" ), aMainGrp ); - mySwitch2d = new QRadioButton( myTypeGrp ); - mySwitch3d = new QRadioButton( myTypeGrp ); - mySwitch2d->setPixmap( icon2d ); - mySwitch3d->setPixmap( icon3d ); - myTypeGrp->insert( mySwitch2d, Type_2d ); - myTypeGrp->insert( mySwitch3d, Type_3d ); + myTypeGrp = new QButtonGroup (1, Qt::Vertical, tr("PATTERN_TYPE"), aMainGrp); + mySwitch2d = new QRadioButton (myTypeGrp); + mySwitch3d = new QRadioButton (myTypeGrp); + mySwitch2d->setPixmap(icon2d); + mySwitch3d->setPixmap(icon3d); + myTypeGrp->insert(mySwitch2d, Type_2d); + myTypeGrp->insert(mySwitch3d, Type_3d); // Mesh group - - QGroupBox* aMeshGrp = new QGroupBox( 1, Qt::Vertical, tr( "SMESH_MESH" ), aMainGrp ); - new QLabel( tr( "SMESH_MESH" ), aMeshGrp ); - mySelBtn[ Mesh ] = new QPushButton( aMeshGrp ); - mySelBtn[ Mesh ]->setPixmap( iconSlct ); - mySelEdit[ Mesh ] = new QLineEdit( aMeshGrp ); - mySelEdit[ Mesh ]->setReadOnly( true ); + + QGroupBox* aMeshGrp = new QGroupBox(1, Qt::Vertical, tr("SMESH_MESH"), aMainGrp); + new QLabel(tr("SMESH_MESH"), aMeshGrp); + mySelBtn[ Mesh ] = new QPushButton(aMeshGrp); + mySelBtn[ Mesh ]->setPixmap(iconSlct); + mySelEdit[ Mesh ] = new QLineEdit(aMeshGrp); + mySelEdit[ Mesh ]->setReadOnly(true); // Pattern group - - QGroupBox* aPatGrp = new QGroupBox( 1, Qt::Horizontal, tr( "PATTERN" ), aMainGrp ); + + QGroupBox* aPatGrp = new QGroupBox(1, Qt::Horizontal, tr("PATTERN"), aMainGrp); // pattern name - QGroupBox* aNameGrp = new QGroupBox( 1, Qt::Vertical, aPatGrp ); - aNameGrp->setFrameStyle( QFrame::NoFrame ); - aNameGrp->setInsideMargin( 0 ); - new QLabel( tr( "PATTERN" ), aNameGrp ); - myName = new QLineEdit( aNameGrp ); - myName->setReadOnly( true ); - myOpenBtn = new QPushButton( aNameGrp ); - myOpenBtn->setPixmap( iconOpen ); - myNewBtn = new QPushButton( tr( "NEW" ), aNameGrp ); + QGroupBox* aNameGrp = new QGroupBox(1, Qt::Vertical, aPatGrp); + aNameGrp->setFrameStyle(QFrame::NoFrame); + aNameGrp->setInsideMargin(0); + new QLabel(tr("PATTERN"), aNameGrp); + myName = new QLineEdit(aNameGrp); + myName->setReadOnly(true); + myOpenBtn = new QPushButton(aNameGrp); + myOpenBtn->setPixmap(iconOpen); + myNewBtn = new QPushButton(tr("NEW"), aNameGrp); // Mode selection check box - myRefine = new QCheckBox( tr( "REFINE" ), aPatGrp ); + myRefine = new QCheckBox(tr("REFINE"), aPatGrp); // selection widgets for Apply to geom mode - myGeomGrp = new QGroupBox( 3, Qt::Horizontal, aPatGrp ); - myGeomGrp->setFrameStyle( QFrame::NoFrame ); - myGeomGrp->setInsideMargin( 0 ); + myGeomGrp = new QGroupBox(3, Qt::Horizontal, aPatGrp); + myGeomGrp->setFrameStyle(QFrame::NoFrame); + myGeomGrp->setInsideMargin(0); - for ( int i = Object; i <= Vertex2; i++ ) + for (int i = Object; i <= Vertex2; i++) { - mySelLbl[ i ] = new QLabel( myGeomGrp ); - mySelBtn[ i ] = new QPushButton( myGeomGrp ); - mySelBtn[ i ]->setPixmap( iconSlct ); - mySelEdit[ i ] = new QLineEdit( myGeomGrp ); - mySelEdit[ i ]->setReadOnly( true ); + mySelLbl[ i ] = new QLabel(myGeomGrp); + mySelBtn[ i ] = new QPushButton(myGeomGrp); + mySelBtn[ i ]->setPixmap(iconSlct); + mySelEdit[ i ] = new QLineEdit(myGeomGrp); + mySelEdit[ i ]->setReadOnly(true); } // Widgets for refinement of existing mesh elements - myRefineGrp = new QFrame( aPatGrp ); - myRefineGrp->setFrameStyle( QFrame::NoFrame ); - QGridLayout* aRefGrid = new QGridLayout( myRefineGrp, 3, 3, 0, 5 ); + myRefineGrp = new QFrame(aPatGrp); + myRefineGrp->setFrameStyle(QFrame::NoFrame); + QGridLayout* aRefGrid = new QGridLayout(myRefineGrp, 3, 3, 0, 5); - mySelLbl[ Ids ] = new QLabel( myRefineGrp ); - mySelBtn[ Ids ] = new QPushButton( myRefineGrp ); - mySelBtn[ Ids ]->setPixmap( iconSlct ); - mySelEdit[ Ids ] = new QLineEdit( myRefineGrp ); + mySelLbl[ Ids ] = new QLabel(myRefineGrp); + mySelBtn[ Ids ] = new QPushButton(myRefineGrp); + mySelBtn[ Ids ]->setPixmap(iconSlct); + mySelEdit[ Ids ] = new QLineEdit(myRefineGrp); - QLabel* aNodeLbl = new QLabel( tr( "NODE_1" ), myRefineGrp ); - myNode1 = new QSpinBox( myRefineGrp ); - myNode2Lbl = new QLabel( tr( "NODE_2" ), myRefineGrp ); - myNode2 = new QSpinBox( myRefineGrp ); + QLabel* aNodeLbl = new QLabel(tr("NODE_1"), myRefineGrp); + myNode1 = new QSpinBox(myRefineGrp); + myNode2Lbl = new QLabel(tr("NODE_2"), myRefineGrp); + myNode2 = new QSpinBox(myRefineGrp); - aRefGrid->addWidget( mySelLbl [ Ids ], 0, 0 ); - aRefGrid->addWidget( mySelBtn [ Ids ], 0, 1 ); - aRefGrid->addWidget( mySelEdit[ Ids ], 0, 2 ); - aRefGrid->addWidget( aNodeLbl, 1, 0 ); - aRefGrid->addMultiCellWidget( myNode1, 1, 1, 1, 2 ); - aRefGrid->addWidget( myNode2Lbl, 2, 0 ); - aRefGrid->addMultiCellWidget( myNode2, 2, 2, 1, 2 ); + aRefGrid->addWidget(mySelLbl [ Ids ], 0, 0); + aRefGrid->addWidget(mySelBtn [ Ids ], 0, 1); + aRefGrid->addWidget(mySelEdit[ Ids ], 0, 2); + aRefGrid->addWidget(aNodeLbl, 1, 0); + aRefGrid->addMultiCellWidget(myNode1, 1, 1, 1, 2); + aRefGrid->addWidget(myNode2Lbl, 2, 0); + aRefGrid->addMultiCellWidget(myNode2, 2, 2, 1, 2); // reverse check box - myReverseChk = new QCheckBox( tr( "REVERSE" ), aPatGrp ); + myReverseChk = new QCheckBox(tr("REVERSE"), aPatGrp); + + // CreatePoly check box + myCreatePolygonsChk = new QCheckBox( tr( "CREATE_POLYGONS_NEAR_BOUNDARY" ), aPatGrp ); + myCreatePolyedrsChk = new QCheckBox( tr( "CREATE_POLYEDRS_NEAR_BOUNDARY" ), aPatGrp ); // Pictures 2d and 3d - for ( int i = 0; i < 2; i++ ) - { - if ( i == 0 ) - { - myPicture2d = new SMESHGUI_PatternWidget( aPatGrp ), - myPicture2d->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); - } - else - { - myPicture3d = new QFrame( aPatGrp ), - myPreview3d = new QLabel( myPicture3d ); - myPreview3d->setPixmap( iconSample3d ); - QGridLayout* aLay = new QGridLayout( myPicture3d, 3, 3, 0, 0 ); - QSpacerItem* aSpacerH1 = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum ); - QSpacerItem* aSpacerH2 = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum ); - QSpacerItem* aSpacerV1 = new QSpacerItem( 0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding ); - QSpacerItem* aSpacerV2 = new QSpacerItem( 0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding ); - aLay->addItem( aSpacerH1, 1, 0 ); - aLay->addItem( aSpacerH2, 1, 2 ); - aLay->addItem( aSpacerV1, 0, 1 ); - aLay->addItem( aSpacerV2, 2, 1 ); - aLay->addWidget( myPreview3d, 1, 1 ); + for (int i = 0; i < 2; i++) { + if (i == 0) { + myPicture2d = new SMESHGUI_PatternWidget(aPatGrp), + myPicture2d->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); + } else { + myPicture3d = new QFrame(aPatGrp), + myPreview3d = new QLabel(myPicture3d); + myPreview3d->setPixmap(iconSample3d); + QGridLayout* aLay = new QGridLayout(myPicture3d, 3, 3, 0, 0); + QSpacerItem* aSpacerH1 = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum); + QSpacerItem* aSpacerH2 = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum); + QSpacerItem* aSpacerV1 = new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding); + QSpacerItem* aSpacerV2 = new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding); + aLay->addItem(aSpacerH1, 1, 0); + aLay->addItem(aSpacerH2, 1, 2); + aLay->addItem(aSpacerV1, 0, 1); + aLay->addItem(aSpacerV2, 2, 1); + aLay->addWidget(myPreview3d, 1, 1); } } - myPreviewChk = new QCheckBox( tr( "PREVIEW" ), aPatGrp ); + myPreviewChk = new QCheckBox(tr("PREVIEW"), aPatGrp); // Connect signals and slots - connect( myTypeGrp, SIGNAL( clicked( int ) ), SLOT( onTypeChanged( int ) ) ); - connect( myOpenBtn, SIGNAL( clicked() ), SLOT( onOpen() ) ); - connect( myNewBtn, SIGNAL( clicked() ), SLOT( onNew() ) ); - connect( myReverseChk, SIGNAL( toggled( bool ) ), SLOT( onReverse( bool ) ) ); - connect( myPreviewChk, SIGNAL( toggled( bool ) ), SLOT( onPreview( bool ) ) ); - connect( myRefine, SIGNAL( toggled( bool ) ), SLOT( onModeToggled( bool ) ) ); - connect( myNode1, SIGNAL( valueChanged( int ) ), SLOT( onNodeChanged( int ) ) ); - connect( myNode2, SIGNAL( valueChanged( int ) ), SLOT( onNodeChanged( int ) ) ); - connect( mySelEdit[Ids], SIGNAL( textChanged( const QString& ) ), SLOT( onTextChanged( const QString& ) ) ); + connect(myTypeGrp, SIGNAL(clicked(int)), SLOT(onTypeChanged(int))); + connect(myOpenBtn, SIGNAL(clicked()), SLOT(onOpen())); + connect(myNewBtn, SIGNAL(clicked()), SLOT(onNew())); + + connect(myReverseChk, SIGNAL(toggled(bool)), SLOT(onReverse(bool))); + connect(myPreviewChk, SIGNAL(toggled(bool)), SLOT(onPreview(bool))); + connect(myRefine, SIGNAL(toggled(bool)), SLOT(onModeToggled(bool))); + + connect(myNode1, SIGNAL(valueChanged(int)), SLOT(onNodeChanged(int))); + connect(myNode2, SIGNAL(valueChanged(int)), SLOT(onNodeChanged(int))); + + connect(mySelEdit[Ids], SIGNAL(textChanged(const QString&)), SLOT(onTextChanged(const QString&))); QMap< int, QPushButton* >::iterator anIter; - for ( anIter = mySelBtn.begin(); anIter != mySelBtn.end(); ++anIter ) - connect( *anIter, SIGNAL( clicked() ), SLOT( onSelInputChanged() ) ); + for (anIter = mySelBtn.begin(); anIter != mySelBtn.end(); ++anIter) + connect(*anIter, SIGNAL(clicked()), SLOT(onSelInputChanged())); return aMainGrp; } //======================================================================= - // name : SMESHGUI_MeshPatternDlg::createButtonFrame // Purpose : Create frame containing buttons //======================================================================= -QFrame* SMESHGUI_MeshPatternDlg::createButtonFrame( QWidget* theParent ) +QFrame* SMESHGUI_MeshPatternDlg::createButtonFrame (QWidget* theParent) { - QFrame* aFrame = new QFrame( theParent ); - aFrame->setFrameStyle( QFrame::Box | QFrame::Sunken ); + QFrame* aFrame = new QFrame(theParent); + aFrame->setFrameStyle(QFrame::Box | QFrame::Sunken); - myOkBtn = new QPushButton( tr( "SMESH_BUT_OK" ), aFrame ); - myApplyBtn = new QPushButton( tr( "SMESH_BUT_APPLY" ), aFrame ); - myCloseBtn = new QPushButton( tr( "SMESH_BUT_CLOSE" ), aFrame ); + myOkBtn = new QPushButton(tr("SMESH_BUT_OK" ), aFrame); + myApplyBtn = new QPushButton(tr("SMESH_BUT_APPLY"), aFrame); + myCloseBtn = new QPushButton(tr("SMESH_BUT_CLOSE"), aFrame); - QSpacerItem* aSpacer = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum ); + QSpacerItem* aSpacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum); - QHBoxLayout* aLay = new QHBoxLayout( aFrame, MARGIN, SPACING ); + QHBoxLayout* aLay = new QHBoxLayout(aFrame, MARGIN, SPACING); - aLay->addWidget( myOkBtn ); - aLay->addWidget( myApplyBtn ); - aLay->addItem( aSpacer); - aLay->addWidget( myCloseBtn ); + aLay->addWidget(myOkBtn); + aLay->addWidget(myApplyBtn); + aLay->addItem(aSpacer); + aLay->addWidget(myCloseBtn); - connect( myOkBtn, SIGNAL( clicked() ), SLOT( onOk() ) ); - connect( myCloseBtn, SIGNAL( clicked() ), SLOT( onClose() ) ) ; - connect( myApplyBtn, SIGNAL( clicked() ), SLOT( onApply() ) ); + connect(myOkBtn, SIGNAL(clicked()), SLOT(onOk())); + connect(myCloseBtn, SIGNAL(clicked()), SLOT(onClose())); + connect(myApplyBtn, SIGNAL(clicked()), SLOT(onApply())); return aFrame; } @@ -295,7 +316,7 @@ SMESHGUI_MeshPatternDlg::~SMESHGUI_MeshPatternDlg() // name : SMESHGUI_MeshPatternDlg::Init // Purpose : Init dialog fields, connect signals and slots, show dialog //======================================================================= -void SMESHGUI_MeshPatternDlg::Init( SALOME_Selection* theSelection ) +void SMESHGUI_MeshPatternDlg::Init() { myPattern = SMESH::GetPattern(); myPreviewActor = 0; @@ -303,9 +324,7 @@ void SMESHGUI_MeshPatternDlg::Init( SALOME_Selection* theSelection ) mySelInput = Mesh; myType = -1; myNbPoints = -1; - mySelection = theSelection; - SMESHGUI* aSMESHGUI = SMESHGUI::GetSMESHGUI(); - aSMESHGUI->SetActiveDialogBox( ( QDialog* )this ); + mySMESHGUI->SetActiveDialogBox((QDialog*)this); myMesh = SMESH::SMESH_Mesh::_nil(); myMeshShape = GEOM::GEOM_Object::_nil(); @@ -314,24 +333,24 @@ void SMESHGUI_MeshPatternDlg::Init( SALOME_Selection* theSelection ) myGeomObj[ Vertex2 ] = GEOM::GEOM_Object::_nil(); // selection and SMESHGUI - connect( mySelection, SIGNAL( currentSelectionChanged() ), SLOT( onSelectionDone() ) ); - connect( aSMESHGUI, SIGNAL( SignalDeactivateActiveDialog() ), SLOT( onDeactivate() ) ); - connect( aSMESHGUI, SIGNAL( SignalCloseAllDialogs() ), SLOT( onClose() ) ); + connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(onSelectionDone())); + connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), SLOT(onDeactivate())); + connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), SLOT(onClose())); - myTypeGrp->setButton( Type_2d ); - onTypeChanged( Type_2d ); - onModeToggled( isRefine() ); + myTypeGrp->setButton(Type_2d); + onTypeChanged(Type_2d); + onModeToggled(isRefine()); updateGeometry(); - resize( minimumSize() ); + resize(minimumSize()); activateSelection(); onSelectionDone(); - int x, y ; - aSMESHGUI->DefineDlgPosition( this, x, y ); - this->move( x, y ); + int x, y; + mySMESHGUI->DefineDlgPosition(this, x, y); + this->move(x, y); this->show(); } @@ -339,20 +358,24 @@ void SMESHGUI_MeshPatternDlg::Init( SALOME_Selection* theSelection ) // name : SMESHGUI_MeshPatternDlg::isValid // Purpose : Verify validity of entry data //======================================================================= -bool SMESHGUI_MeshPatternDlg::isValid( const bool theMess ) +bool SMESHGUI_MeshPatternDlg::isValid (const bool theMess) { QValueList ids; - if ( ( isRefine() && ( myMesh->_is_nil() || !getIds( ids ) || getNode( false ) < 0 || myType == Type_3d && ( getNode( true ) < 0 || getNode( false ) == getNode( true ) ) ) ) - || ( !isRefine() && ( myMesh->_is_nil() || myMeshShape->_is_nil() || myGeomObj[ Object ]->_is_nil() || - myGeomObj[ Vertex1 ]->_is_nil() || myType == Type_3d && myGeomObj[ Vertex2 ]->_is_nil() ) ) ) + if ((isRefine() && + (myMesh->_is_nil() || !getIds(ids) || getNode(false) < 0 || + myType == Type_3d && (getNode(true) < 0 || getNode(false) == getNode(true)))) + || + (!isRefine() && + (myMesh->_is_nil() || myMeshShape->_is_nil() || myGeomObj[ Object ]->_is_nil() || + myGeomObj[ Vertex1 ]->_is_nil() || myType == Type_3d && myGeomObj[ Vertex2 ]->_is_nil()))) { - if ( theMess ) - QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), - tr( "SMESH_INSUFFICIENT_DATA" ), tr( "SMESHGUI_INVALID_PARAMETERS" ), QMessageBox::Ok ); + if (theMess) + QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"), + tr("SMESHGUI_INVALID_PARAMETERS"), QMessageBox::Ok); return false; } - else - return true; + + return true; } //======================================================================= @@ -361,67 +384,62 @@ bool SMESHGUI_MeshPatternDlg::isValid( const bool theMess ) //======================================================================= bool SMESHGUI_MeshPatternDlg::onApply() { - try - { - if ( !isValid() ) + try { + if (!isValid()) return false; erasePreview(); - if ( isRefine() ) { // Refining existing mesh elements + if (isRefine()) { // Refining existing mesh elements QValueList ids; - getIds( ids ); + getIds(ids); SMESH::long_array_var varIds = new SMESH::long_array(); - varIds->length( ids.count() ); + varIds->length(ids.count()); int i = 0; - for ( QValueList::iterator it = ids.begin(); it != ids.end(); ++it ) + for (QValueList::iterator it = ids.begin(); it != ids.end(); ++it) varIds[i++] = *it; myType == Type_2d - ? myPattern->ApplyToMeshFaces ( myMesh, varIds, getNode( false ), myReverseChk->isChecked() ) - : myPattern->ApplyToHexahedrons( myMesh, varIds, getNode( false ), getNode( true ) ); - } - else { // Applying a pattern to geometrical object - if ( myType == Type_2d ) - myPattern->ApplyToFace( - myGeomObj[ Object ], myGeomObj[ Vertex1 ], myReverseChk->isChecked() ); - else - myPattern->ApplyTo3DBlock( - myGeomObj[ Object ], myGeomObj[ Vertex1 ], myGeomObj[ Vertex2 ] ); + ? myPattern->ApplyToMeshFaces (myMesh, varIds, getNode(false), myReverseChk->isChecked()) + : myPattern->ApplyToHexahedrons(myMesh, varIds, getNode(false), getNode(true)); + + } else { // Applying a pattern to geometrical object + if (myType == Type_2d) + myPattern->ApplyToFace(myGeomObj[Object], myGeomObj[Vertex1], myReverseChk->isChecked()); + else + myPattern->ApplyTo3DBlock(myGeomObj[Object], myGeomObj[Vertex1], myGeomObj[Vertex2]); } - if ( myPattern->MakeMesh( myMesh ) ) - { - mySelection->ClearIObjects(); - SMESHGUI* aCompGUI = SMESHGUI::GetSMESHGUI(); - if ( !isRefine() && !QAD_CONFIG->getSetting( "SMESH:AutomaticUpdate" ).compare( "true" ) ) { - SALOMEDS::SObject_var aSO = SMESH::FindSObject( myMesh.in() ); - SMESH_Actor* anActor = SMESH::FindActorByEntry( aSO->GetID() ); - if(!anActor){ - anActor = SMESH::CreateActor( aSO->GetStudy(), aSO->GetID() ); - if(anActor){ - SMESH::DisplayActor( aCompGUI->GetActiveStudy()->getActiveStudyFrame(), anActor ); + bool toCreatePolygons = myCreatePolygonsChk->isChecked(); + bool toCreatePolyedrs = myCreatePolyedrsChk->isChecked(); + if ( myPattern->MakeMesh( myMesh, toCreatePolygons, toCreatePolyedrs ) ) { + mySelectionMgr->clearSelected(); + SUIT_ResourceMgr* mgr = SMESHGUI::resourceMgr(); + bool autoUpdate = false; + if (mgr && mgr->stringValue("SMESH", "AutomaticUpdate").compare("true") == 0) + autoUpdate = true; + if (!isRefine() && autoUpdate) { + _PTR(SObject) aSO = SMESH::FindSObject(myMesh.in()); + SMESH_Actor* anActor = SMESH::FindActorByEntry(aSO->GetID().c_str()); + if (!anActor) { + anActor = SMESH::CreateActor(aSO->GetStudy(), aSO->GetID().c_str()); + if (anActor) { + SMESH::DisplayActor(SMESH::GetActiveWindow(), anActor); SMESH::FitAll(); } } } SMESH::UpdateView(); - - aCompGUI->GetActiveStudy()->updateObjBrowser( true ); + + mySMESHGUI->updateObjBrowser(true); return true; - } - else - { - QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), - tr( "SMESH_ERROR" ), tr( "SMESH_OPERATION_FAILED" ), QMessageBox::Ok ); + } else { + QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_ERROR"), + tr("SMESH_OPERATION_FAILED"), QMessageBox::Ok); return false; } - } - catch( const SALOME::SALOME_Exception& S_ex ) - { - QtCatchCorbaException( S_ex ); - } - catch( ... ) - { + } catch (const SALOME::SALOME_Exception& S_ex) { + SalomeApp_Tools::QtCatchCorbaException(S_ex); + } catch (...) { } return false; @@ -433,7 +451,7 @@ bool SMESHGUI_MeshPatternDlg::onApply() //======================================================================= void SMESHGUI_MeshPatternDlg::onOk() { - if ( onApply() ) + if (onApply()) onClose(); } @@ -443,77 +461,47 @@ void SMESHGUI_MeshPatternDlg::onOk() //======================================================================= void SMESHGUI_MeshPatternDlg::onClose() { - mySelection->ClearFilters(); + mySelectionMgr->clearFilters(); SMESH::SetPickable(); - QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); - disconnect( mySelection, 0, this, 0 ); - disconnect( SMESHGUI::GetSMESHGUI(), 0, this, 0 ); - SMESHGUI::GetSMESHGUI()->ResetState(); + myViewWindow->SetSelectionMode(ActorSelection); + disconnect(mySelectionMgr, 0, this, 0); + disconnect(mySMESHGUI, 0, this, 0); + mySMESHGUI->ResetState(); erasePreview(); reject(); } - - //======================================================================= // name : SMESHGUI_MeshPatternDlg::onSelectionDone // Purpose : SLOT called when selection changed //======================================================================= void SMESHGUI_MeshPatternDlg::onSelectionDone() { - if ( myBusy ) + if (myBusy) return; - - try - { - if ( mySelInput == Mesh ) - { - if ( mySelection->IObjectCount() != 1 ) + + try { + if (mySelInput == Mesh) { + SALOME_ListIO aList; + mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type()); + if (aList.Extent() != 1) return; // Retrieve mesh from selection - Handle(SALOME_InteractiveObject) anIO = mySelection->firstIObject(); - SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface( anIO ); - if ( aMesh->_is_nil() ) + Handle(SALOME_InteractiveObject) anIO = aList.First(); + SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface(anIO); + if (aMesh->_is_nil()) return; // Get geom object corresponding to the mesh - SALOMEDS::Study_var aStudy = - SMESHGUI::GetSMESHGUI()->GetActiveStudy()->getStudyDocument(); - - SALOMEDS::SObject_var aSO = SMESH::FindSObject( aMesh.in() ); - if ( aSO->_is_nil() ) - return; - - bool isFound = false; - SALOMEDS::ChildIterator_var anIter = aStudy->NewChildIterator( aSO ); - for( ; anIter->More(); anIter->Next() ) - { - SALOMEDS::SObject_var aSO = anIter->Value(); - SALOMEDS::SObject_var aRefSO; - - GEOM::GEOM_Object_var aMeshShape = GEOM::GEOM_Object::_narrow( - aSO->ReferencedObject( aRefSO )? aRefSO->GetObject() : aSO->GetObject() ); - - if ( !aMeshShape->_is_nil() ) - { - isFound = true; - myMeshShape = aMeshShape; - break; - - } - } - - if ( !isFound ) - myMeshShape = GEOM::GEOM_Object::_nil(); + _PTR(SObject) aSO = SMESH::FindSObject(aMesh.in()); + myMeshShape = SMESH::GetGeom(aSO); // Clear fields of geom objects if mesh was changed - if ( myMesh != aMesh ) - { - for ( int i = Object; i <= Ids; i++ ) - { + if (myMesh != aMesh) { + for (int i = Object; i <= Ids; i++) { myGeomObj[ i ] = GEOM::GEOM_Object::_nil(); - mySelEdit[ i ]->setText( "" ); + mySelEdit[ i ]->setText(""); } } @@ -521,36 +509,38 @@ void SMESHGUI_MeshPatternDlg::onSelectionDone() // Set name of mesh in line edit QString aName; - SMESH::GetNameOfSelectedIObjects( mySelection, aName ); - mySelEdit[ Mesh ]->setText( aName ); - } - else if ( mySelInput == Ids ) { + SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aName); + mySelEdit[ Mesh ]->setText(aName); + + } else if (mySelInput == Ids) { + SALOME_ListIO aList; + mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type()); + QString anIds; - if ( !SMESH::GetNameOfSelectedElements( mySelection, anIds ) ) + if (!SMESH::GetNameOfSelectedElements(mySelector, aList.First(), anIds)) anIds = ""; - + myBusy = true; - mySelEdit[ Ids ]->setText( anIds ); + mySelEdit[ Ids ]->setText(anIds); myBusy = false; - } - else - { - if ( mySelection->IObjectCount() != 1 ) + + } else { + SALOME_ListIO aList; + mySelectionMgr->selectedObjects(aList, SVTK_Viewer::Type()); + if (aList.Extent() != 1) return; // Get geom object from selection - Handle(SALOME_InteractiveObject) anIO = mySelection->firstIObject(); - GEOM::GEOM_Object_var anObj = SMESH::IObjectToInterface( anIO ); - if ( anObj->_is_nil() ) + Handle(SALOME_InteractiveObject) anIO = aList.First(); + GEOM::GEOM_Object_var anObj = SMESH::IObjectToInterface(anIO); + if (anObj->_is_nil()) return; // Clear fields of vertexes if face or 3d block was changed - if ( anObj != myGeomObj[ mySelInput ] && mySelInput == Object ) - { - for ( int i = Vertex1; i <= Vertex2; i++ ) - { + if (anObj != myGeomObj[ mySelInput ] && mySelInput == Object) { + for (int i = Vertex1; i <= Vertex2; i++) { myGeomObj[ i ] = GEOM::GEOM_Object::_nil(); - mySelEdit[ i ]->setText( "" ); + mySelEdit[ i ]->setText(""); } } @@ -558,17 +548,13 @@ void SMESHGUI_MeshPatternDlg::onSelectionDone() // Set name of geom object in line edit QString aName; - SMESH::GetNameOfSelectedIObjects( mySelection, aName ); - mySelEdit[ mySelInput ]->setText( aName ); + SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aName); + mySelEdit[ mySelInput ]->setText(aName); } - } - catch( const SALOME::SALOME_Exception& S_ex ) - { - QtCatchCorbaException( S_ex ); + } catch (const SALOME::SALOME_Exception& S_ex) { + SalomeApp_Tools::QtCatchCorbaException(S_ex); resetSelInput(); - } - catch( ... ) - { + } catch (...) { resetSelInput(); } @@ -582,7 +568,7 @@ void SMESHGUI_MeshPatternDlg::onSelectionDone() //======================================================================= void SMESHGUI_MeshPatternDlg::resetSelInput() { - if ( mySelInput == Mesh ) + if (mySelInput == Mesh) { myMesh = SMESH::SMESH_Mesh::_nil(); myMeshShape = GEOM::GEOM_Object::_nil(); @@ -591,7 +577,7 @@ void SMESHGUI_MeshPatternDlg::resetSelInput() else myGeomObj[ mySelInput ] = GEOM::GEOM_Object::_nil(); - mySelEdit[ mySelInput ]->setText( "" ); + mySelEdit[ mySelInput ]->setText(""); } //======================================================================= @@ -600,39 +586,38 @@ void SMESHGUI_MeshPatternDlg::resetSelInput() //======================================================================= void SMESHGUI_MeshPatternDlg::onDeactivate() { - mySelection->ClearFilters(); - //if ( myReverseChk->isChecked() ) + mySelectionMgr->clearFilters(); + //if (myReverseChk->isChecked()) // erasePreview(); - disconnect( mySelection, 0, this, 0 ); - setEnabled( false ); + disconnect(mySelectionMgr, 0, this, 0); + setEnabled(false); } //======================================================================= // name : SMESHGUI_MeshPatternDlg::enterEvent // Purpose : Event filter //======================================================================= -void SMESHGUI_MeshPatternDlg::enterEvent( QEvent* ) +void SMESHGUI_MeshPatternDlg::enterEvent (QEvent*) { - if ( myIsCreateDlgOpen ) + if (myIsCreateDlgOpen) return; - - if ( myReverseChk->isChecked() ) + + if (myReverseChk->isChecked()) displayPreview(); - SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog() ; - setEnabled( true ); + mySMESHGUI->EmitSignalDeactivateDialog(); + setEnabled(true); activateSelection(); - connect( mySelection, SIGNAL( currentSelectionChanged() ), SLOT( onSelectionDone() ) ); - onTextChanged( mySelEdit[Ids]->text() ); + connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(onSelectionDone())); + onTextChanged(mySelEdit[Ids]->text()); } - -//================================================================================= -// function : closeEvent() -// purpose : -//================================================================================= -void SMESHGUI_MeshPatternDlg::closeEvent( QCloseEvent* e ) +//======================================================================= +// name : SMESHGUI_MeshPatternDlg::closeEvent +// Purpose : +//======================================================================= +void SMESHGUI_MeshPatternDlg::closeEvent (QCloseEvent*) { - onClose() ; + onClose(); } //======================================================================= @@ -643,8 +628,8 @@ void SMESHGUI_MeshPatternDlg::closeEvent( QCloseEvent* e ) void SMESHGUI_MeshPatternDlg::onSelInputChanged() { const QObject* aSender = sender(); - for ( int i = Mesh; i <= Ids; i++ ) - if ( aSender == mySelBtn[ i ] ) + for (int i = Mesh; i <= Ids; i++) + if (aSender == mySelBtn[ i ]) mySelInput = i; activateSelection(); @@ -655,27 +640,25 @@ void SMESHGUI_MeshPatternDlg::onSelInputChanged() // name : SMESHGUI_MeshPatternDlg::prepareFilters // Purpose : Prepare filters for dialog //======================================================================= - QStringList SMESHGUI_MeshPatternDlg::prepareFilters() const { static QStringList aList; - if ( aList.isEmpty() ) + if (aList.isEmpty()) { - aList.append( tr( "PATTERN_FILT" ) ); - //aList.append( tr( "ALL_FILES_FILTER" ) ); + aList.append(tr("PATTERN_FILT")); + //aList.append(tr("ALL_FILES_FILTER")); } return aList; } -//================================================================ - -// Function : SMESHGUI_MeshPatternDlg::autoExtension -// Purpose : Append extension to the file name -//================================================================ -QString SMESHGUI_MeshPatternDlg::autoExtension( const QString& theFileName ) const +//======================================================================= +// name : SMESHGUI_MeshPatternDlg::autoExtension +// Purpose : Append extension to the file name +//======================================================================= +QString SMESHGUI_MeshPatternDlg::autoExtension (const QString& theFileName) const { - QString anExt = theFileName.section( '.', -1 ); + QString anExt = theFileName.section('.', -1); return anExt != "smp" && anExt != "SMP" ? theFileName + ".smp" : theFileName; } @@ -686,53 +669,51 @@ QString SMESHGUI_MeshPatternDlg::autoExtension( const QString& theFileName ) con //======================================================================= void SMESHGUI_MeshPatternDlg::onOpen() { - QAD_FileDlg* aDlg = new QAD_FileDlg( this, true ); - aDlg->setCaption( tr( "LOAD_PATTERN" ) ); - aDlg->setMode( QFileDialogP::ExistingFile ); - aDlg->setFilters( prepareFilters() ); - if ( myName->text() != "" ) - aDlg->setSelection( myName->text() + ".smp" ); - QPushButton* anOkBtn = ( QPushButton* )aDlg->child( "OK", "QPushButton" ); - if ( anOkBtn != 0 ) - anOkBtn->setText( tr( "SMESH_BUT_OK" ) ); + SUIT_FileDlg* aDlg = new SUIT_FileDlg (this, true); + aDlg->setCaption(tr("LOAD_PATTERN")); + aDlg->setMode(QFileDialog::ExistingFile); + aDlg->setFilters(prepareFilters()); + if (myName->text() != "") + aDlg->setSelection(myName->text() + ".smp"); + QPushButton* anOkBtn = (QPushButton*)aDlg->child("OK", "QPushButton"); + if (anOkBtn != 0) + anOkBtn->setText(tr("SMESH_BUT_OK")); - if ( aDlg->exec() != Accepted ) + if (aDlg->exec() != Accepted) return; QString fName = aDlg->selectedFile(); - if ( fName.isEmpty() ) + if (fName.isEmpty()) return; - if ( QFileInfo( fName ).extension().isEmpty() ) - fName = autoExtension( fName ); + if (QFileInfo(fName).extension().isEmpty()) + fName = autoExtension(fName); - fName = QDir::convertSeparators( fName ); - - QString prev = QDir::convertSeparators( myName->text() ); - if ( prev == fName ) + fName = QDir::convertSeparators(fName); + + QString prev = QDir::convertSeparators(myName->text()); + if (prev == fName) return; // Read string from file - QFile aFile( fName ); - if ( !aFile.open( IO_ReadOnly ) ) - { - QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), - tr( "SMESH_ERROR" ), tr( "ERROR_OF_OPENING" ), QMessageBox::Ok ); + QFile aFile(fName); + if (!aFile.open(IO_ReadOnly)) { + QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_ERROR"), + tr("ERROR_OF_OPENING"), QMessageBox::Ok); return; } - + QByteArray aDataArray = aFile.readAll(); const char* aData = aDataArray.data(); - if ( aData == 0 ) - { - QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), - tr( "SMESH_ERROR" ), tr( "ERROR_OF_READING" ), QMessageBox::Ok ); + if (aData == 0) { + QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_ERROR"), + tr("ERROR_OF_READING"), QMessageBox::Ok); return; } - - if ( loadFromFile( aData ) ) - myName->setText( QFileInfo( fName ).baseName() ); - + + if (loadFromFile(aData)) + myName->setText(QFileInfo(fName).baseName()); + updateWgState(); displayPreview(); } @@ -743,11 +724,10 @@ void SMESHGUI_MeshPatternDlg::onOpen() //======================================================================= void SMESHGUI_MeshPatternDlg::onCloseCreationDlg() { - setEnabled( true ); + setEnabled(true); myIsCreateDlgOpen = false; } - //======================================================================= // name : SMESHGUI_MeshPatternDlg::onOkCreationDlg // Purpose : SLOT. Called when "Pattern creation" dialog closed with OK @@ -755,32 +735,31 @@ void SMESHGUI_MeshPatternDlg::onCloseCreationDlg() //======================================================================= void SMESHGUI_MeshPatternDlg::onOkCreationDlg() { - myPattern = SMESH::SMESH_Pattern::_duplicate( myCreationDlg->GetPattern() ); - myName->setText( myCreationDlg->GetPatternName() ); + myPattern = SMESH::SMESH_Pattern::_duplicate(myCreationDlg->GetPattern()); + myName->setText(myCreationDlg->GetPatternName()); displayPreview(); - setEnabled( true ); + setEnabled(true); myIsCreateDlgOpen = false; } - //======================================================================= // name : SMESHGUI_MeshPatternDlg::onNew // Purpose : SLOT. Called when "New..." button clicked. Create new pattern //======================================================================= void SMESHGUI_MeshPatternDlg::onNew() { - setEnabled( false ); + setEnabled(false); myIsCreateDlgOpen = true; - if ( myCreationDlg == 0 ) + if (myCreationDlg == 0) { - myCreationDlg = new SMESHGUI_CreatePatternDlg( this, mySelection, myType ); - connect( myCreationDlg, SIGNAL( NewPattern() ), SLOT( onOkCreationDlg() ) ); - connect( myCreationDlg, SIGNAL( Close() ), SLOT( onCloseCreationDlg() ) ); + myCreationDlg = new SMESHGUI_CreatePatternDlg( mySMESHGUI, myType); + connect(myCreationDlg, SIGNAL(NewPattern()), SLOT(onOkCreationDlg())); + connect(myCreationDlg, SIGNAL(Close()), SLOT(onCloseCreationDlg())); } else - myCreationDlg->Init( mySelection, myType ); + myCreationDlg->Init(myType); - myCreationDlg->SetMesh( myMesh ); + myCreationDlg->SetMesh(myMesh); myCreationDlg->show(); } @@ -789,7 +768,7 @@ void SMESHGUI_MeshPatternDlg::onNew() // Purpose : SLOT. Called when state of "Reverse order..." checkbox chaged // Calculate new points of the mesh to be created. Redisplay preview //======================================================================= -void SMESHGUI_MeshPatternDlg::onReverse( bool ) +void SMESHGUI_MeshPatternDlg::onReverse (bool) { displayPreview(); } @@ -800,7 +779,7 @@ void SMESHGUI_MeshPatternDlg::onReverse( bool ) // Purpose : SLOT. Called when state of "Preview" checkbox changed // Display/Erase preview //======================================================================= -void SMESHGUI_MeshPatternDlg::onPreview( bool ) +void SMESHGUI_MeshPatternDlg::onPreview (bool) { displayPreview(); } @@ -811,53 +790,42 @@ void SMESHGUI_MeshPatternDlg::onPreview( bool ) //======================================================================= void SMESHGUI_MeshPatternDlg::displayPreview() { - try - { + try { // Redisplay preview in dialog - SMESH::point_array_var pnts = myPattern->GetPoints(); SMESH::long_array_var keyPoints = myPattern->GetKeyPoints(); SMESH::array_of_long_array_var elemPoints = myPattern->GetElementPoints(false); - if ( pnts->length() == 0 || - keyPoints->length() == 0 || - elemPoints->length() == 0 ) - { + if (pnts->length() == 0 || + keyPoints->length() == 0 || + elemPoints->length() == 0) { erasePreview(); return; - } + } else { + PointVector aPoints(pnts->length()); + QValueVector aKeyPoints(keyPoints->length()); + ConnectivityVector anElemPoints(elemPoints->length()); - else - { - PointVector aPoints( pnts->length() ); - QValueVector aKeyPoints( keyPoints->length() ); - ConnectivityVector anElemPoints( elemPoints->length() ); - - for ( int i = 0, n = pnts->length(); i < n; i++ ) + for (int i = 0, n = pnts->length(); i < n; i++) aPoints[ i ] = pnts[ i ]; - for ( int i2 = 0, n2 = keyPoints->length(); i2 < n2; i2++ ) + for (int i2 = 0, n2 = keyPoints->length(); i2 < n2; i2++) aKeyPoints[ i2 ] = keyPoints[ i2 ]; - for ( int i3 = 0, n3 = elemPoints->length(); i3 < n3; i3++ ) - { - QValueVector aVec( elemPoints[ i3 ].length() ); - for ( int i4 = 0, n4 = elemPoints[ i3 ].length(); i4 < n4; i4++ ) + for (int i3 = 0, n3 = elemPoints->length(); i3 < n3; i3++) { + QValueVector aVec(elemPoints[ i3 ].length()); + for (int i4 = 0, n4 = elemPoints[ i3 ].length(); i4 < n4; i4++) aVec[ i4 ] = elemPoints[ i3 ][ i4 ]; anElemPoints[ i3 ] = aVec; } - myPicture2d->SetPoints( aPoints, aKeyPoints, anElemPoints ); + myPicture2d->SetPoints(aPoints, aKeyPoints, anElemPoints); } - // Redisplay preview in 3D viewer - - if ( myPreviewActor != 0 ) - { - if ( VTKViewer_ViewFrame* vf = SMESH::GetCurrentVtkView() ) - { + if (myPreviewActor != 0) { + if (SVTK_ViewWindow* vf = SMESH::GetCurrentVtkView()) { vf->RemoveActor(myPreviewActor); vf->Repaint(); } @@ -865,45 +833,41 @@ void SMESHGUI_MeshPatternDlg::displayPreview() myPreviewActor = 0; } - if ( !myPreviewChk->isChecked() || !isValid( false ) ) + if (!myPreviewChk->isChecked() || !isValid(false)) return; vtkUnstructuredGrid* aGrid = getGrid(); - if ( aGrid == 0 ) + if (aGrid == 0) return; // Create and display actor vtkDataSetMapper* aMapper = vtkDataSetMapper::New(); - aMapper->SetInput( aGrid ); + aMapper->SetInput(aGrid); myPreviewActor = SALOME_Actor::New(); myPreviewActor->PickableOff(); - myPreviewActor->SetMapper( aMapper ); + myPreviewActor->SetMapper(aMapper); vtkProperty* aProp = vtkProperty::New(); aProp->SetRepresentationToWireframe(); - aProp->SetColor( 250, 0, 250 ); - if ( SMESH::FindActorByObject( myMesh ) ) - aProp->SetLineWidth( SMESH::GetFloat( "SMESH:SettingsWidth", 1 ) +1 ); + aProp->SetColor(250, 0, 250); + if (SMESH::FindActorByObject(myMesh)) + aProp->SetLineWidth(SMESH::GetFloat("SMESH:SettingsWidth", 1) +1); else - aProp->SetLineWidth( 1 ); - myPreviewActor->SetProperty( aProp ); + aProp->SetLineWidth(1); + myPreviewActor->SetProperty(aProp); - myPreviewActor->SetRepresentation( 3 ); + myPreviewActor->SetRepresentation(3); - SMESH::GetCurrentVtkView()->AddActor( myPreviewActor ); + SMESH::GetCurrentVtkView()->AddActor(myPreviewActor); SMESH::GetCurrentVtkView()->Repaint(); aProp->Delete(); aGrid->Delete(); - } - catch( const SALOME::SALOME_Exception& S_ex ) - { - QtCatchCorbaException( S_ex ); + } catch (const SALOME::SALOME_Exception& S_ex) { + SalomeApp_Tools::QtCatchCorbaException(S_ex); erasePreview(); - } - catch( ... ) - { + } catch (...) { erasePreview(); } } @@ -915,14 +879,14 @@ void SMESHGUI_MeshPatternDlg::displayPreview() void SMESHGUI_MeshPatternDlg::erasePreview() { // Erase preview in 2D viewer - myPicture2d->SetPoints( PointVector(), QValueVector(), ConnectivityVector() ); + myPicture2d->SetPoints(PointVector(), QValueVector(), ConnectivityVector()); // Erase preview in 3D viewer - if ( myPreviewActor == 0 ) + if (myPreviewActor == 0) return; - if ( VTKViewer_ViewFrame* vf = SMESH::GetCurrentVtkView() ) + if (SVTK_ViewWindow* vf = SMESH::GetCurrentVtkView()) { vf->RemoveActor(myPreviewActor); vf->Repaint(); @@ -937,60 +901,51 @@ void SMESHGUI_MeshPatternDlg::erasePreview() //======================================================================= void SMESHGUI_MeshPatternDlg::updateWgState() { - if ( myMesh->_is_nil() ) - { - for ( int i = Object; i <= Ids; i++ ) - { - mySelBtn [ i ]->setEnabled( false ); - mySelEdit[ i ]->setEnabled( false ); - mySelEdit[ i ]->setText( "" ); + if (myMesh->_is_nil()) { + for (int i = Object; i <= Ids; i++) { + mySelBtn [ i ]->setEnabled(false); + mySelEdit[ i ]->setEnabled(false); + mySelEdit[ i ]->setText(""); } - myNode1->setEnabled( false ); - myNode2->setEnabled( false ); - myNode1->setRange( 0, 0 ); - myNode2->setRange( 0, 0 ); - } - else - { - mySelBtn [ Object ]->setEnabled( true ); - mySelEdit[ Object ]->setEnabled( true ); - mySelBtn [ Ids ] ->setEnabled( true ); - mySelEdit[ Ids ] ->setEnabled( true ); - - if ( myGeomObj[ Object ]->_is_nil() ) - { - for ( int i = Vertex1; i <= Vertex2; i++ ) - { - mySelBtn [ i ]->setEnabled( false ); - mySelEdit[ i ]->setEnabled( false ); - mySelEdit[ i ]->setText( "" ); + myNode1->setEnabled(false); + myNode2->setEnabled(false); + myNode1->setRange(0, 0); + myNode2->setRange(0, 0); + } else { + mySelBtn [ Object ]->setEnabled(true); + mySelEdit[ Object ]->setEnabled(true); + mySelBtn [ Ids ] ->setEnabled(true); + mySelEdit[ Ids ] ->setEnabled(true); + + if (myGeomObj[ Object ]->_is_nil()) { + for (int i = Vertex1; i <= Vertex2; i++) { + mySelBtn [ i ]->setEnabled(false); + mySelEdit[ i ]->setEnabled(false); + mySelEdit[ i ]->setText(""); } - } - else - { - for ( int i = Object; i <= Vertex2; i++ ) - { - mySelBtn [ i ]->setEnabled( true ); - mySelEdit[ i ]->setEnabled( true ); + } else { + for (int i = Object; i <= Vertex2; i++) { + mySelBtn [ i ]->setEnabled(true); + mySelEdit[ i ]->setEnabled(true); } } QValueList ids; - if ( !CORBA::is_nil( myPattern ) && getIds( ids ) ) { + if (!CORBA::is_nil(myPattern) && getIds(ids)) { SMESH::long_array_var keyPoints = myPattern->GetKeyPoints(); - if ( keyPoints->length() ) { - myNode1->setEnabled( true ); - myNode2->setEnabled( true ); - myNode1->setRange( 1, keyPoints->length() ); - myNode2->setRange( 1, keyPoints->length() ); + if (keyPoints->length()) { + myNode1->setEnabled(true); + myNode2->setEnabled(true); + myNode1->setRange(1, keyPoints->length()); + myNode2->setRange(1, keyPoints->length()); return; } } - myNode1->setEnabled( false ); - myNode2->setEnabled( false ); - myNode1->setRange( 0, 0 ); - myNode2->setRange( 0, 0 ); + myNode1->setEnabled(false); + myNode2->setEnabled(false); + myNode1->setRange(0, 0); + myNode2->setRange(0, 0); } } @@ -1000,47 +955,42 @@ void SMESHGUI_MeshPatternDlg::updateWgState() //======================================================================= void SMESHGUI_MeshPatternDlg::activateSelection() { - mySelection->ClearFilters(); - if ( mySelInput == Ids ) { - SMESH_Actor* anActor = SMESH::FindActorByObject( myMesh ); - if ( anActor ) + mySelectionMgr->clearFilters(); + if (mySelInput == Ids) { + SMESH_Actor* anActor = SMESH::FindActorByObject(myMesh); + if (anActor) SMESH::SetPickable(anActor); - if ( myType == Type_2d ) - QAD_Application::getDesktop()->SetSelectionMode( FaceSelection, true ); + if (myType == Type_2d) + myViewWindow->SetSelectionMode(FaceSelection); else - QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true ); + myViewWindow->SetSelectionMode(CellSelection); } else { SMESH::SetPickable(); - QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); + //mySelectionMgr->setSelectionModes(ActorSelection); + myViewWindow->SetSelectionMode(ActorSelection); } - - if ( mySelInput == Object && !myMeshShape->_is_nil() ) - { - if ( myType == Type_2d ) - { - if ( myNbPoints > 0 ) - mySelection->AddFilter( new SMESH_NumberFilter( - "GEOM", TopAbs_VERTEX, myNbPoints, TopAbs_FACE, myMeshShape ) ); + if (mySelInput == Object && !myMeshShape->_is_nil()) { + if (myType == Type_2d) { + if (myNbPoints > 0) + mySelectionMgr->installFilter + (new SMESH_NumberFilter ("GEOM", TopAbs_VERTEX, myNbPoints, TopAbs_FACE, myMeshShape)); else - mySelection->AddFilter( new SMESH_NumberFilter( - "GEOM", TopAbs_SHAPE, myNbPoints, TopAbs_FACE, myMeshShape ) ); - } - else - { + mySelectionMgr->installFilter + (new SMESH_NumberFilter ("GEOM", TopAbs_SHAPE, myNbPoints, TopAbs_FACE, myMeshShape)); + } else { TColStd_MapOfInteger aTypes; - aTypes.Add( TopAbs_SHELL ); - aTypes.Add( TopAbs_SOLID ); - mySelection->AddFilter( new SMESH_NumberFilter( - "GEOM", TopAbs_FACE, 6, aTypes, myMeshShape, true ) ); + aTypes.Add(TopAbs_SHELL); + aTypes.Add(TopAbs_SOLID); + mySelectionMgr->installFilter + (new SMESH_NumberFilter ("GEOM", TopAbs_FACE, 6, aTypes, myMeshShape, true)); } - } - else if ( ( mySelInput == Vertex1 || mySelInput == Vertex2 ) && !myGeomObj[ Object ]->_is_nil() ) - { - mySelection->AddFilter( new SMESH_NumberFilter( - "GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX, myGeomObj[ Object ] ) ); + } else if ((mySelInput == Vertex1 || mySelInput == Vertex2) && !myGeomObj[ Object ]->_is_nil()) { + mySelectionMgr->installFilter + (new SMESH_NumberFilter ("GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX, myGeomObj[ Object ])); + } else { } } @@ -1048,56 +998,48 @@ void SMESHGUI_MeshPatternDlg::activateSelection() // name : SMESHGUI_MeshPatternDlg::loadFromFile // Purpose : Load pattern from file //======================================================================= -bool SMESHGUI_MeshPatternDlg::loadFromFile( const QString& theName ) +bool SMESHGUI_MeshPatternDlg::loadFromFile (const QString& theName) { - try - { + try { SMESH::SMESH_Pattern_var aPattern = SMESH::GetPattern(); - if ( !aPattern->LoadFromFile( theName.latin1() ) || - myType == Type_2d && !aPattern->Is2D()) - { + if (!aPattern->LoadFromFile(theName.latin1()) || + myType == Type_2d && !aPattern->Is2D()) { SMESH::SMESH_Pattern::ErrorCode aCode = aPattern->GetErrorCode(); QString aMess; - if ( aCode == SMESH::SMESH_Pattern::ERR_READ_NB_POINTS ) aMess = tr( "ERR_READ_NB_POINTS" ); - else if ( aCode == SMESH::SMESH_Pattern::ERR_READ_POINT_COORDS ) aMess = tr( "ERR_READ_POINT_COORDS" ); - else if ( aCode == SMESH::SMESH_Pattern::ERR_READ_TOO_FEW_POINTS ) aMess = tr( "ERR_READ_TOO_FEW_POINTS" ); - else if ( aCode == SMESH::SMESH_Pattern::ERR_READ_3D_COORD ) aMess = tr( "ERR_READ_3D_COORD" ); - else if ( aCode == SMESH::SMESH_Pattern::ERR_READ_NO_KEYPOINT ) aMess = tr( "ERR_READ_NO_KEYPOINT" ); - else if ( aCode == SMESH::SMESH_Pattern::ERR_READ_BAD_INDEX ) aMess = tr( "ERR_READ_BAD_INDEX" ); - else if ( aCode == SMESH::SMESH_Pattern::ERR_READ_ELEM_POINTS ) aMess = tr( "ERR_READ_ELEM_POINTS" ); - else if ( aCode == SMESH::SMESH_Pattern::ERR_READ_NO_ELEMS ) aMess = tr( "ERR_READ_NO_ELEMS" ); - else if ( aCode == SMESH::SMESH_Pattern::ERR_READ_BAD_KEY_POINT ) aMess = tr( "ERR_READ_BAD_KEY_POINT" ); - else aMess = tr( "ERROR_OF_LOADING" ); + if (aCode == SMESH::SMESH_Pattern::ERR_READ_NB_POINTS ) aMess = tr("ERR_READ_NB_POINTS"); + else if (aCode == SMESH::SMESH_Pattern::ERR_READ_POINT_COORDS ) aMess = tr("ERR_READ_POINT_COORDS"); + else if (aCode == SMESH::SMESH_Pattern::ERR_READ_TOO_FEW_POINTS) aMess = tr("ERR_READ_TOO_FEW_POINTS"); + else if (aCode == SMESH::SMESH_Pattern::ERR_READ_3D_COORD ) aMess = tr("ERR_READ_3D_COORD"); + else if (aCode == SMESH::SMESH_Pattern::ERR_READ_NO_KEYPOINT ) aMess = tr("ERR_READ_NO_KEYPOINT"); + else if (aCode == SMESH::SMESH_Pattern::ERR_READ_BAD_INDEX ) aMess = tr("ERR_READ_BAD_INDEX"); + else if (aCode == SMESH::SMESH_Pattern::ERR_READ_ELEM_POINTS ) aMess = tr("ERR_READ_ELEM_POINTS"); + else if (aCode == SMESH::SMESH_Pattern::ERR_READ_NO_ELEMS ) aMess = tr("ERR_READ_NO_ELEMS"); + else if (aCode == SMESH::SMESH_Pattern::ERR_READ_BAD_KEY_POINT ) aMess = tr("ERR_READ_BAD_KEY_POINT"); + else aMess = tr("ERROR_OF_LOADING"); - QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), - tr( "SMESH_ERROR" ), aMess, QMessageBox::Ok ); + QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_ERROR"), aMess, QMessageBox::Ok); return false; - } - else - { + } else { myPattern = aPattern; return true; } - } - catch( const SALOME::SALOME_Exception& S_ex ) - { - QtCatchCorbaException( S_ex ); - QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), - tr( "SMESH_ERROR" ), tr( "ERROR_OF_LOADING" ), QMessageBox::Ok ); + } catch (const SALOME::SALOME_Exception& S_ex) { + SalomeApp_Tools::QtCatchCorbaException(S_ex); + QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_ERROR"), + tr("ERROR_OF_LOADING"), QMessageBox::Ok); return false; } } //======================================================================= // name : SMESHGUI_MeshPatternDlg::onTypeChanged - // Purpose : SLOT. Called when pattern type changed. // Change dialog's look and feel //======================================================================= -void SMESHGUI_MeshPatternDlg::onTypeChanged( int theType ) +void SMESHGUI_MeshPatternDlg::onTypeChanged (int theType) { - if ( myType == theType ) + if (myType == theType) return; myType = theType; @@ -1108,14 +1050,15 @@ void SMESHGUI_MeshPatternDlg::onTypeChanged( int theType ) myGeomObj[ Vertex2 ] = GEOM::GEOM_Object::_nil(); myPattern = SMESH::GetPattern(); - myName->setText( "" ); - mySelEdit[ Object ]->setText( "" ); - mySelEdit[ Vertex1 ]->setText( "" ); - mySelEdit[ Vertex2 ]->setText( "" ); - mySelEdit[ Ids ] ->setText( "" ); + myName->setText(""); + mySelEdit[ Object ]->setText(""); + mySelEdit[ Vertex1 ]->setText(""); + mySelEdit[ Vertex2 ]->setText(""); + mySelEdit[ Ids ] ->setText(""); + myCreatePolygonsChk->show(); + myCreatePolyedrsChk->show(); - if ( theType == Type_2d ) - { + if (theType == Type_2d) { // Geom widgets mySelLbl [ Vertex2 ]->hide(); mySelBtn [ Vertex2 ]->hide(); @@ -1123,15 +1066,13 @@ void SMESHGUI_MeshPatternDlg::onTypeChanged( int theType ) myReverseChk->show(); myPicture2d->show(); myPicture3d->hide(); - mySelLbl[ Object ]->setText( tr( "FACE" ) ); - mySelLbl[ Vertex1 ]->setText( tr( "VERTEX" ) ); + mySelLbl[ Object ]->setText(tr("FACE")); + mySelLbl[ Vertex1 ]->setText(tr("VERTEX")); // Refine widgets - mySelLbl[ Ids ]->setText( tr( "MESH_FACES" ) ); + mySelLbl[ Ids ]->setText(tr("MESH_FACES")); myNode2Lbl->hide(); myNode2 ->hide(); - } - else - { + } else { // Geom widgets mySelLbl [ Vertex2 ]->show(); mySelBtn [ Vertex2 ]->show(); @@ -1139,11 +1080,11 @@ void SMESHGUI_MeshPatternDlg::onTypeChanged( int theType ) myReverseChk->hide(); myPicture2d->hide(); myPicture3d->show(); - mySelLbl[ Object ]->setText( tr( "3D_BLOCK" ) ); - mySelLbl[ Vertex1 ]->setText( tr( "VERTEX1" ) ); - mySelLbl[ Vertex2 ]->setText( tr( "VERTEX2" ) ); + mySelLbl[ Object ]->setText(tr("3D_BLOCK")); + mySelLbl[ Vertex1 ]->setText(tr("VERTEX1")); + mySelLbl[ Vertex2 ]->setText(tr("VERTEX2")); // Refine widgets - mySelLbl[ Ids ]->setText( tr( "MESH_VOLUMES" ) ); + mySelLbl[ Ids ]->setText(tr("MESH_VOLUMES")); myNode2Lbl->show(); myNode2 ->show(); } @@ -1160,49 +1101,45 @@ void SMESHGUI_MeshPatternDlg::onTypeChanged( int theType ) //======================================================================= vtkUnstructuredGrid* SMESHGUI_MeshPatternDlg::getGrid() { - try - { + try { // Get points from pattern SMESH::point_array_var pnts; QValueList ids; - if ( isRefine() && getIds( ids ) ) { + if (isRefine() && getIds(ids)) { SMESH::long_array_var varIds = new SMESH::long_array(); - varIds->length( ids.count() ); + varIds->length(ids.count()); int i = 0; - for ( QValueList::iterator it = ids.begin(); it != ids.end(); ++it ) + for (QValueList::iterator it = ids.begin(); it != ids.end(); ++it) varIds[i++] = *it; pnts = myType == Type_2d - ? myPattern->ApplyToMeshFaces ( myMesh, varIds, getNode( false ), myReverseChk->isChecked() ) - : myPattern->ApplyToHexahedrons( myMesh, varIds, getNode( false ), getNode( true ) ); - } - else { + ? myPattern->ApplyToMeshFaces (myMesh, varIds, getNode(false), myReverseChk->isChecked()) + : myPattern->ApplyToHexahedrons(myMesh, varIds, getNode(false), getNode(true)); + } else { pnts = myType == Type_2d - ? myPattern->ApplyToFace ( myGeomObj[ Object ], myGeomObj[ Vertex1 ], myReverseChk->isChecked() ) - : myPattern->ApplyTo3DBlock( myGeomObj[ Object ], myGeomObj[ Vertex1 ], myGeomObj[ Vertex2 ] ); + ? myPattern->ApplyToFace (myGeomObj[ Object ], myGeomObj[ Vertex1 ], myReverseChk->isChecked()) + : myPattern->ApplyTo3DBlock(myGeomObj[ Object ], myGeomObj[ Vertex1 ], myGeomObj[ Vertex2 ]); } SMESH::array_of_long_array_var elemPoints = myPattern->GetElementPoints(true); - if ( pnts->length() == 0 || elemPoints->length() == 0 ) + if (pnts->length() == 0 || elemPoints->length() == 0) return 0; - - // to do : to be removed ///////////////////////////////////////////// #ifdef DEB_SLN - for ( int i1 = 0, n1 = pnts->length(); i1 < n1; i1++ ) - printf( "%d: %g %g %g\n", i1, pnts[ i1 ].x, pnts[ i1 ].y, pnts[ i1 ].z ); + for (int i1 = 0, n1 = pnts->length(); i1 < n1; i1++) + printf("%d: %g %g %g\n", i1, pnts[ i1 ].x, pnts[ i1 ].y, pnts[ i1 ].z); - printf( "\nELEMENTS : \n" ); - for ( int i2 = 0, n2 = elemPoints->length(); i2 < n2; i2++ ) + printf("\nELEMENTS : \n"); + for (int i2 = 0, n2 = elemPoints->length(); i2 < n2; i2++) { - printf( "%d: ", i2 ); - for ( int i3 = 0, n3 = elemPoints[ i2 ].length(); i3 < n3; i3++ ) - printf( "%d ", elemPoints[ i2 ][ i3 ] ); + printf("%d: ", i2); + for (int i3 = 0, n3 = elemPoints[ i2 ].length(); i3 < n3; i3++) + printf("%d ", elemPoints[ i2 ][ i3 ]); - printf( "\n" ); + printf("\n"); } #endif @@ -1211,56 +1148,55 @@ vtkUnstructuredGrid* SMESHGUI_MeshPatternDlg::getGrid() // Calculate number of points used for cell vtkIdType aNbCells = elemPoints->length(); vtkIdType aCellsSize = 0; - for ( int i = 0, n = elemPoints->length(); i < n; i++ ) + for (int i = 0, n = elemPoints->length(); i < n; i++) aCellsSize += elemPoints[ i ].length(); // Create unstructured grid and other usefull arrays vtkUnstructuredGrid* aGrid = vtkUnstructuredGrid::New(); vtkCellArray* aConnectivity = vtkCellArray::New(); - aConnectivity->Allocate( aCellsSize, 0 ); + aConnectivity->Allocate(aCellsSize, 0); vtkPoints* aPoints = vtkPoints::New(); - aPoints->SetNumberOfPoints( pnts->length() ); + aPoints->SetNumberOfPoints(pnts->length()); vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New(); - aCellTypesArray->SetNumberOfComponents( 1 ); - aCellTypesArray->Allocate( aNbCells * aCellTypesArray->GetNumberOfComponents() ); + aCellTypesArray->SetNumberOfComponents(1); + aCellTypesArray->Allocate(aNbCells * aCellTypesArray->GetNumberOfComponents()); vtkIdList *anIdList = vtkIdList::New(); // Fill array of points - for ( int p = 0, nbPnt = pnts->length(); p < nbPnt; p++ ) - aPoints->SetPoint( p, pnts[ p ].x, pnts[ p ].y, pnts[ p ].z ); + for (int p = 0, nbPnt = pnts->length(); p < nbPnt; p++) + aPoints->SetPoint(p, pnts[ p ].x, pnts[ p ].y, pnts[ p ].z); - for ( int e = 0, nbElem = elemPoints->length(); e < nbElem; e++ ) - { + for (int e = 0, nbElem = elemPoints->length(); e < nbElem; e++) { int nbPoints = elemPoints[ e ].length(); - anIdList->SetNumberOfIds( nbPoints ); - for ( int i = 0; i < nbPoints; i++ ) - anIdList->SetId( i, elemPoints[ e ][ i ] ); + anIdList->SetNumberOfIds(nbPoints); + for (int i = 0; i < nbPoints; i++) + anIdList->SetId(i, elemPoints[ e ][ i ]); - aConnectivity->InsertNextCell( anIdList ); + aConnectivity->InsertNextCell(anIdList); - if ( nbPoints == 3 ) aCellTypesArray->InsertNextValue( VTK_TRIANGLE ); - else if ( nbPoints == 5 ) aCellTypesArray->InsertNextValue( VTK_PYRAMID ); - else if ( nbPoints == 6 ) aCellTypesArray->InsertNextValue( VTK_WEDGE ); - else if ( nbPoints == 8 ) aCellTypesArray->InsertNextValue( VTK_HEXAHEDRON ); - else if ( nbPoints == 4 && myType == Type_2d ) aCellTypesArray->InsertNextValue( VTK_QUAD ); - else if ( nbPoints == 4 && myType == Type_3d ) aCellTypesArray->InsertNextValue( VTK_TETRA ); - else aCellTypesArray->InsertNextValue( VTK_EMPTY_CELL ); + if (nbPoints == 3) aCellTypesArray->InsertNextValue(VTK_TRIANGLE); + else if (nbPoints == 5) aCellTypesArray->InsertNextValue(VTK_PYRAMID); + else if (nbPoints == 6) aCellTypesArray->InsertNextValue(VTK_WEDGE); + else if (nbPoints == 8) aCellTypesArray->InsertNextValue(VTK_HEXAHEDRON); + else if (nbPoints == 4 && myType == Type_2d) aCellTypesArray->InsertNextValue(VTK_QUAD); + else if (nbPoints == 4 && myType == Type_3d) aCellTypesArray->InsertNextValue(VTK_TETRA); + else aCellTypesArray->InsertNextValue(VTK_EMPTY_CELL); } vtkIntArray* aCellLocationsArray = vtkIntArray::New(); - aCellLocationsArray->SetNumberOfComponents( 1 ); - aCellLocationsArray->SetNumberOfTuples( aNbCells ); + aCellLocationsArray->SetNumberOfComponents(1); + aCellLocationsArray->SetNumberOfTuples(aNbCells); aConnectivity->InitTraversal(); - for( vtkIdType idType = 0, *pts, npts; aConnectivity->GetNextCell( npts, pts ); idType++ ) - aCellLocationsArray->SetValue( idType, aConnectivity->GetTraversalLocation( npts ) ); + for (vtkIdType idType = 0, *pts, npts; aConnectivity->GetNextCell(npts, pts); idType++) + aCellLocationsArray->SetValue(idType, aConnectivity->GetTraversalLocation(npts)); - aGrid->SetPoints( aPoints ); - aGrid->SetCells( aCellTypesArray, aCellLocationsArray,aConnectivity ); + aGrid->SetPoints(aPoints); + aGrid->SetCells(aCellTypesArray, aCellLocationsArray,aConnectivity); aConnectivity->Delete(); aPoints->Delete(); @@ -1269,18 +1205,16 @@ vtkUnstructuredGrid* SMESHGUI_MeshPatternDlg::getGrid() aCellLocationsArray->Delete(); return aGrid; - } - catch( ... ) - { + } catch (...) { return 0; } } //======================================================================= // name : onModeToggled -// Purpose : +// Purpose : //======================================================================= -void SMESHGUI_MeshPatternDlg::onModeToggled( bool on ) +void SMESHGUI_MeshPatternDlg::onModeToggled (bool on) { on ? myRefineGrp->show() : myRefineGrp->hide(); on ? myGeomGrp->hide() : myGeomGrp->show(); @@ -1290,7 +1224,7 @@ void SMESHGUI_MeshPatternDlg::onModeToggled( bool on ) //======================================================================= // name : isRefine -// Purpose : +// Purpose : //======================================================================= bool SMESHGUI_MeshPatternDlg::isRefine() const { @@ -1298,61 +1232,72 @@ bool SMESHGUI_MeshPatternDlg::isRefine() const } //======================================================================= -//function : onTextChanged -//purpose : +// name : onTextChanged +// Purpose : //======================================================================= -void SMESHGUI_MeshPatternDlg::onTextChanged(const QString& theNewText) +void SMESHGUI_MeshPatternDlg::onTextChanged (const QString& theNewText) { - if ( myBusy || !isRefine() ) + if (myBusy || !isRefine()) return; myBusy = true; - if ( mySelInput != Ids ) { + if (mySelInput != Ids) { mySelInput = Ids; activateSelection(); } // hilight entered elements/nodes SMDS_Mesh* aMesh = 0; - SMESH_Actor* anActor = SMESH::FindActorByObject( myMesh ); - if ( anActor ) + SMESH_Actor* anActor = SMESH::FindActorByObject(myMesh); + if (anActor) aMesh = anActor->GetObject()->GetMesh(); - if ( aMesh ) { - mySelection->ClearIObjects(); - mySelection->AddIObject( anActor->getIO() ); + if (aMesh) { + QStringList aListId = QStringList::split(" ", theNewText, false); - QStringList aListId = QStringList::split( " ", theNewText, false); + SALOME_ListIO aList; + aList.Append(anActor->getIO()); + mySelectionMgr->setSelectedObjects(aList, false); - for ( int i = 0; i < aListId.count(); i++ ) { - const SMDS_MeshElement * e = aMesh->FindElement( aListId[ i ].toInt() ); - if ( e && e->GetType() == ( myType == Type_2d ? SMDSAbs_Face : SMDSAbs_Volume ) ) { - if ( !mySelection->IsIndexSelected( anActor->getIO(), e->GetID() ) ) - mySelection->AddOrRemoveIndex( anActor->getIO(), e->GetID(), true ); + TColStd_IndexedMapOfInteger selectedIndices; + TColStd_MapOfInteger newIndices; + mySelector->GetIndex(anActor->getIO(), selectedIndices); + + for (int i = 0; i < aListId.count(); i++) { + const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt()); + if (e && e->GetType() == (myType == Type_2d ? SMDSAbs_Face : SMDSAbs_Volume)) { + if (selectedIndices.Add(e->GetID())) { + newIndices.Add(e->GetID()); + } } } + if (newIndices.Extent() > 0) + { + mySelector->AddOrRemoveIndex( anActor->getIO(), newIndices, true); + myViewWindow->highlight( anActor->getIO(), true, true ); + } } myBusy = false; } //======================================================================= -//function : onNodeChanged -//purpose : +// name : onNodeChanged +// Purpose : //======================================================================= -void SMESHGUI_MeshPatternDlg::onNodeChanged( int value ) +void SMESHGUI_MeshPatternDlg::onNodeChanged (int value) { - if ( myType == Type_3d ) { + if (myType == Type_3d) { QSpinBox* first = (QSpinBox*)sender(); QSpinBox* second = first == myNode1 ? myNode2 : myNode1; int secondVal = second->value(); - if ( secondVal == value ) { + if (secondVal == value) { secondVal = value == second->maxValue() ? second->minValue() : value + 1; bool blocked = second->signalsBlocked(); - second->blockSignals( true ); - second->setValue( secondVal ); - second->blockSignals( blocked ); + second->blockSignals(true); + second->setValue(secondVal); + second->blockSignals(blocked); } } @@ -1360,30 +1305,29 @@ void SMESHGUI_MeshPatternDlg::onNodeChanged( int value ) } //======================================================================= -//function : getIds -//purpose : +// name : getIds +// Purpose : //======================================================================= -bool SMESHGUI_MeshPatternDlg::getIds( QValueList& ids ) const +bool SMESHGUI_MeshPatternDlg::getIds (QValueList& ids) const { ids.clear(); - QStringList strIds = QStringList::split( " ", mySelEdit[Ids]->text() ); + QStringList strIds = QStringList::split(" ", mySelEdit[Ids]->text()); bool isOk; int val; - for ( QStringList::iterator it = strIds.begin(); it != strIds.end(); ++it ) { - val = (*it).toInt( &isOk ); - if ( isOk ) - ids.append( val ); + for (QStringList::iterator it = strIds.begin(); it != strIds.end(); ++it) { + val = (*it).toInt(&isOk); + if (isOk) + ids.append(val); } return ids.count(); } //======================================================================= -//function : getNode1 -//purpose : +// name : getNode1 +// Purpose : //======================================================================= -int SMESHGUI_MeshPatternDlg::getNode( bool second ) const +int SMESHGUI_MeshPatternDlg::getNode (bool second) const { return second ? myNode2->value() - 1 : myNode1->value() - 1; } - diff --git a/src/SMESHGUI/SMESHGUI_MeshPatternDlg.h b/src/SMESHGUI/SMESHGUI_MeshPatternDlg.h index 26a733236..b1cf5b9d7 100755 --- a/src/SMESHGUI/SMESHGUI_MeshPatternDlg.h +++ b/src/SMESHGUI/SMESHGUI_MeshPatternDlg.h @@ -40,7 +40,7 @@ class QFrame; class QLineEdit; class SMESHGUI_SpinBox; class QPushButton; -class SALOME_Selection; +class SalomeApp_SelectionMgr; class QRadioButton; class QCheckBox; class QButtonGroup; @@ -51,6 +51,9 @@ class SMESHGUI_CreatePatternDlg; class SMESHGUI_PatternWidget; class vtkUnstructuredGrid; class SALOME_Actor; +class SVTK_ViewWindow; +class SVTK_Selector; +class SMESHGUI; /* Class : SMESHGUI_MeshPatternDlg @@ -68,12 +71,11 @@ class SMESHGUI_MeshPatternDlg : public QDialog enum { Mesh, Object, Vertex1, Vertex2, Ids }; public: - SMESHGUI_MeshPatternDlg( QWidget*, - SALOME_Selection*, + SMESHGUI_MeshPatternDlg( SMESHGUI*, const char* = 0 ); virtual ~SMESHGUI_MeshPatternDlg(); - void Init( SALOME_Selection* ); + void Init(); private slots: @@ -145,13 +147,18 @@ private: QPushButton* myNewBtn; QCheckBox* myReverseChk; + QCheckBox* myCreatePolygonsChk; + QCheckBox* myCreatePolyedrsChk; SMESHGUI_PatternWidget* myPicture2d; QFrame* myPicture3d; QLabel* myPreview3d; QCheckBox* myPreviewChk; - - SALOME_Selection* mySelection; + + SMESHGUI* mySMESHGUI; + SVTK_ViewWindow* myViewWindow; + SVTK_Selector* mySelector; + SalomeApp_SelectionMgr* mySelectionMgr; int mySelInput; int myNbPoints; int myType; @@ -168,20 +175,3 @@ private: }; #endif - - - - - - - - - - - - - - - - - diff --git a/src/SMESHGUI/SMESHGUI_MoveNodesDlg.cxx b/src/SMESHGUI/SMESHGUI_MoveNodesDlg.cxx index e163f8095..fba4f187f 100644 --- a/src/SMESHGUI/SMESHGUI_MoveNodesDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_MoveNodesDlg.cxx @@ -1,23 +1,23 @@ // SMESH SMESHGUI : GUI for SMESH component // // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org // // // @@ -31,7 +31,6 @@ #include "SMESHGUI.h" #include "SMESHGUI_SpinBox.h" #include "SMESHGUI_IdValidator.h" - #include "SMESHGUI_Utils.h" #include "SMESHGUI_VTKUtils.h" #include "SMESHGUI_MeshUtils.h" @@ -40,14 +39,23 @@ #include "SMDS_Mesh.hxx" #include "SMDS_MeshNode.hxx" -#include "SALOME_Selection.h" -#include "VTKViewer_ViewFrame.h" -#include "QAD_Desktop.h" -#include "QAD_RightFrame.h" -#include "QAD_MessageBox.h" +#include "SalomeApp_SelectionMgr.h" +#include "SUIT_ResourceMgr.h" +#include "SUIT_Desktop.h" + +#include "SVTK_Selector.h" +#include "SVTK_ViewModel.h" +#include "SVTK_ViewWindow.h" +#include "SALOME_ListIO.hxx" + +#include "SVTK_ViewWindow.h" #include "utilities.h" +// OCCT includes +#include + +// VTK includes #include #include #include @@ -56,6 +64,7 @@ #include #include +// QT includes #include #include #include @@ -75,60 +84,63 @@ //================================================================================= -// class : SMESHGUI_MoveNodesDlg() -// purpose : +// name : SMESHGUI_MoveNodesDlg::SMESHGUI_MoveNodesDlg +// Purpose : //================================================================================= -SMESHGUI_MoveNodesDlg::SMESHGUI_MoveNodesDlg( QWidget* theParent, - SALOME_Selection* theSelection, - const char* theName ) - -: QDialog( theParent, theName, false, - WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +SMESHGUI_MoveNodesDlg::SMESHGUI_MoveNodesDlg (SMESHGUI* theModule, + const char* theName): + QDialog(SMESH::GetDesktop(theModule), + theName, + false, + WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu), + mySelector(SMESH::GetViewWindow(theModule)->GetSelector()), + mySelectionMgr(SMESH::GetSelectionMgr(theModule)), + myViewWindow(SMESH::GetViewWindow(theModule)), + mySMESHGUI(theModule) { myPreviewActor = 0; myBusy = false; - mySelection = 0; - - setCaption( tr( "CAPTION" ) ); - QVBoxLayout* aDlgLay = new QVBoxLayout( this, MARGIN, SPACING ); + setCaption(tr("CAPTION")); - QFrame* aMainFrame = createMainFrame ( this ); - QFrame* aBtnFrame = createButtonFrame( this ); + QVBoxLayout* aDlgLay = new QVBoxLayout (this, MARGIN, SPACING); - aDlgLay->addWidget( aMainFrame ); - aDlgLay->addWidget( aBtnFrame ); + QFrame* aMainFrame = createMainFrame (this); + QFrame* aBtnFrame = createButtonFrame(this); - aDlgLay->setStretchFactor( aMainFrame, 1 ); + aDlgLay->addWidget(aMainFrame); + aDlgLay->addWidget(aBtnFrame); - Init( theSelection ) ; + aDlgLay->setStretchFactor(aMainFrame, 1); + + Init(); } //======================================================================= // name : SMESHGUI_MoveNodesDlg::createButtonFrame // Purpose : Create frame containing buttons //======================================================================= -QFrame* SMESHGUI_MoveNodesDlg::createButtonFrame( QWidget* theParent ) +QFrame* SMESHGUI_MoveNodesDlg::createButtonFrame (QWidget* theParent) { - QFrame* aFrame = new QFrame( theParent ); - aFrame->setFrameStyle( QFrame::Box | QFrame::Sunken ); + QFrame* aFrame = new QFrame(theParent); + aFrame->setFrameStyle(QFrame::Box | QFrame::Sunken); - myOkBtn = new QPushButton( tr( "SMESH_BUT_OK" ), aFrame ); - myApplyBtn = new QPushButton( tr( "SMESH_BUT_APPLY" ), aFrame ); - myCloseBtn = new QPushButton( tr( "SMESH_BUT_CLOSE" ), aFrame ); + myOkBtn = new QPushButton(tr("SMESH_BUT_OK" ), aFrame); + myApplyBtn = new QPushButton(tr("SMESH_BUT_APPLY"), aFrame); + myCloseBtn = new QPushButton(tr("SMESH_BUT_CLOSE"), aFrame); - QSpacerItem* aSpacer = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum ); + QSpacerItem* aSpacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum); - QHBoxLayout* aLay = new QHBoxLayout( aFrame, MARGIN, SPACING ); + QHBoxLayout* aLay = new QHBoxLayout(aFrame, MARGIN, SPACING); - aLay->addWidget( myOkBtn ); - aLay->addWidget( myApplyBtn ); - aLay->addItem( aSpacer); - aLay->addWidget( myCloseBtn ); + aLay->addWidget(myOkBtn); + aLay->addWidget(myApplyBtn); + aLay->addItem(aSpacer); + aLay->addWidget(myCloseBtn); - connect( myOkBtn, SIGNAL( clicked() ), SLOT( onOk() ) ); - connect( myCloseBtn, SIGNAL( clicked() ), SLOT( onClose() ) ) ; - connect( myApplyBtn, SIGNAL( clicked() ), SLOT( onApply() ) ); + connect(myOkBtn, SIGNAL(clicked()), SLOT(onOk())); + connect(myCloseBtn, SIGNAL(clicked()), SLOT(onClose())); + connect(myApplyBtn, SIGNAL(clicked()), SLOT(onApply())); return aFrame; } @@ -137,49 +149,47 @@ QFrame* SMESHGUI_MoveNodesDlg::createButtonFrame( QWidget* theParent ) // name : SMESHGUI_MoveNodesDlg::createMainFrame // Purpose : Create frame containing dialog's input fields //======================================================================= -QFrame* SMESHGUI_MoveNodesDlg::createMainFrame( QWidget* theParent ) +QFrame* SMESHGUI_MoveNodesDlg::createMainFrame (QWidget* theParent) { - QFrame* aFrame = new QFrame( theParent ); + QFrame* aFrame = new QFrame(theParent); - QPixmap iconMoveNode( - QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr( "ICON_DLG_MOVE_NODE" ) ) ); - QPixmap iconSelect( - QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr( "ICON_SELECT" ) ) ); + QPixmap iconMoveNode (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_DLG_MOVE_NODE"))); + QPixmap iconSelect (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT"))); - QButtonGroup* aPixGrp = new QButtonGroup( 1, Qt::Vertical, tr( "MESH_NODE" ), aFrame ); - aPixGrp->setExclusive( TRUE ); - QRadioButton* aRBut = new QRadioButton( aPixGrp ); - aRBut->setPixmap( iconMoveNode ); - aRBut->setChecked( TRUE ); + QButtonGroup* aPixGrp = new QButtonGroup(1, Qt::Vertical, tr("MESH_NODE"), aFrame); + aPixGrp->setExclusive(TRUE); + QRadioButton* aRBut = new QRadioButton(aPixGrp); + aRBut->setPixmap(iconMoveNode); + aRBut->setChecked(TRUE); - QGroupBox* anIdGrp = new QGroupBox( 1, Qt::Vertical, tr( "SMESH_MOVE" ), aFrame ); - new QLabel( tr( "NODE_ID" ), anIdGrp ); - ( new QPushButton( anIdGrp ) )->setPixmap( iconSelect ); - myId = new QLineEdit( anIdGrp ); - myId->setValidator( new SMESHGUI_IdValidator( this, "validator", 1 )); + QGroupBox* anIdGrp = new QGroupBox(1, Qt::Vertical, tr("SMESH_MOVE"), aFrame); + new QLabel(tr("NODE_ID"), anIdGrp); + (new QPushButton(anIdGrp))->setPixmap(iconSelect); + myId = new QLineEdit(anIdGrp); + myId->setValidator(new SMESHGUI_IdValidator(this, "validator", 1)); - QGroupBox* aCoordGrp = new QGroupBox( 1, Qt::Vertical, tr( "SMESH_COORDINATES" ), aFrame ); - new QLabel( tr( "SMESH_X" ), aCoordGrp ); - myX = new SMESHGUI_SpinBox( aCoordGrp ); - new QLabel( tr( "SMESH_Y" ), aCoordGrp ); - myY = new SMESHGUI_SpinBox( aCoordGrp ); - new QLabel( tr( "SMESH_Z" ), aCoordGrp ); - myZ = new SMESHGUI_SpinBox( aCoordGrp ); + QGroupBox* aCoordGrp = new QGroupBox(1, Qt::Vertical, tr("SMESH_COORDINATES"), aFrame); + new QLabel(tr("SMESH_X"), aCoordGrp); + myX = new SMESHGUI_SpinBox(aCoordGrp); + new QLabel(tr("SMESH_Y"), aCoordGrp); + myY = new SMESHGUI_SpinBox(aCoordGrp); + new QLabel(tr("SMESH_Z"), aCoordGrp); + myZ = new SMESHGUI_SpinBox(aCoordGrp); - myX->RangeStepAndValidator( -999999.999, +999999.999, 25.0, 3 ); - myY->RangeStepAndValidator( -999999.999, +999999.999, 25.0, 3 ); - myZ->RangeStepAndValidator( -999999.999, +999999.999, 25.0, 3 ); + myX->RangeStepAndValidator(-999999.999, +999999.999, 25.0, 3); + myY->RangeStepAndValidator(-999999.999, +999999.999, 25.0, 3); + myZ->RangeStepAndValidator(-999999.999, +999999.999, 25.0, 3); - QVBoxLayout* aLay = new QVBoxLayout( aFrame ); - aLay->addWidget( aPixGrp ); - aLay->addWidget( anIdGrp ); - aLay->addWidget( aCoordGrp ); + QVBoxLayout* aLay = new QVBoxLayout(aFrame); + aLay->addWidget(aPixGrp); + aLay->addWidget(anIdGrp); + aLay->addWidget(aCoordGrp); // connect signale and slots - connect( myX, SIGNAL ( valueChanged( double) ), this, SLOT( redisplayPreview() ) ); - connect( myY, SIGNAL ( valueChanged( double) ), this, SLOT( redisplayPreview() ) ); - connect( myZ, SIGNAL ( valueChanged( double) ), this, SLOT( redisplayPreview() ) ); - connect( myId, SIGNAL( textChanged(const QString&) ), SLOT( onTextChange(const QString&) )); + connect(myX, SIGNAL (valueChanged(double)), this, SLOT(redisplayPreview())); + connect(myY, SIGNAL (valueChanged(double)), this, SLOT(redisplayPreview())); + connect(myZ, SIGNAL (valueChanged(double)), this, SLOT(redisplayPreview())); + connect(myId, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&))); return aFrame; } @@ -197,32 +207,31 @@ SMESHGUI_MoveNodesDlg::~SMESHGUI_MoveNodesDlg() // name : SMESHGUI_MoveNodesDlg::Init // Purpose : Init dialog fields //======================================================================= -void SMESHGUI_MoveNodesDlg::Init( SALOME_Selection* theSelection ) +void SMESHGUI_MoveNodesDlg::Init() { myPreviewActor = 0; myMeshActor = 0; myBusy = false; - mySelection = theSelection; - SMESHGUI* aSMESHGUI = SMESHGUI::GetSMESHGUI(); - aSMESHGUI->SetActiveDialogBox( ( QDialog* )this ) ; + mySMESHGUI->SetActiveDialogBox((QDialog*)this); // selection and SMESHGUI - connect( mySelection, SIGNAL( currentSelectionChanged() ), SLOT( onSelectionDone() ) ); - connect( aSMESHGUI, SIGNAL( SignalDeactivateActiveDialog() ), SLOT( onDeactivate() ) ); - connect( aSMESHGUI, SIGNAL( SignalCloseAllDialogs() ), SLOT( onClose() ) ); + connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(onSelectionDone())); + connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), SLOT(onDeactivate())); + connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), SLOT(onClose())); reset(); - setEnabled( true ); + setEnabled(true); - int x, y ; - aSMESHGUI->DefineDlgPosition( this, x, y ); - this->move( x, y ); + int x, y; + mySMESHGUI->DefineDlgPosition(this, x, y); + this->move(x, y); this->show(); // set selection mode SMESH::SetPointRepresentation(true); - QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true ); + myViewWindow->SetSelectionMode(NodeSelection); + onSelectionDone(); } @@ -230,13 +239,12 @@ void SMESHGUI_MoveNodesDlg::Init( SALOME_Selection* theSelection ) // name : SMESHGUI_MoveNodesDlg::isValid // Purpose : Verify validity of entry information //======================================================================= -bool SMESHGUI_MoveNodesDlg::isValid( const bool theMess ) const +bool SMESHGUI_MoveNodesDlg::isValid (const bool theMess) const { - if ( myId->text().isEmpty() ) - { - if ( theMess ) - QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), - tr( "SMESH_WARNING" ), tr( "NODE_ID_IS_NOT_DEFINED" ), QMessageBox::Ok ); + if (myId->text().isEmpty()) { + if (theMess) + QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_WARNING"), + tr("NODE_ID_IS_NOT_DEFINED"), QMessageBox::Ok); return false; } return true; @@ -249,115 +257,108 @@ bool SMESHGUI_MoveNodesDlg::isValid( const bool theMess ) const void SMESHGUI_MoveNodesDlg::reset() { myId->clear(); - myX->SetValue( 0 ); - myY->SetValue( 0 ); - myZ->SetValue( 0 ); + myX->SetValue(0); + myY->SetValue(0); + myZ->SetValue(0); redisplayPreview(); updateButtons(); } //======================================================================= -// name : SMESHGUI_MoveNodesDlg::nApply +// name : SMESHGUI_MoveNodesDlg::onApply // Purpose : SLOT called when "Apply" button pressed. //======================================================================= bool SMESHGUI_MoveNodesDlg::onApply() { - if (SMESHGUI::GetSMESHGUI()->ActiveStudyLocked()) + if (SMESHGUI::GetSMESHGUI()->isActiveStudyLocked()) return false; - if ( !isValid( true ) ) + if (!isValid(true)) return false; - SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO( myMeshActor->getIO() ); - if(aMesh->_is_nil() ) - { - QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), - tr( "SMESH_ERROR" ), tr( "SMESHG_NO_MESH" ), QMessageBox::Ok ); + SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(myMeshActor->getIO()); + if (aMesh->_is_nil()) { + QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_ERROR"), + tr("SMESHG_NO_MESH"), QMessageBox::Ok); return false; } SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor(); - if ( aMeshEditor->_is_nil() ) + if (aMeshEditor->_is_nil()) return false; int anId = myId->text().toInt(); bool aResult = false; - try - { - aResult = aMeshEditor->MoveNode( anId, myX->GetValue(), myY->GetValue(), myZ->GetValue() ); - } - catch( ... ) - { + try { + aResult = aMeshEditor->MoveNode(anId, myX->GetValue(), myY->GetValue(), myZ->GetValue()); + } catch (...) { } - if ( aResult ) - { - Handle(SALOME_InteractiveObject) anIO = myMeshActor->getIO(); - mySelection->ClearIObjects(); + if (aResult) { + SALOME_ListIO aList; + aList.Append(myMeshActor->getIO()); + mySelectionMgr->setSelectedObjects(aList,false); SMESH::UpdateView(); - mySelection->AddIObject( anIO, false ); reset(); } return aResult; } - //======================================================================= // name : SMESHGUI_MoveNodesDlg::onOk // Purpose : SLOT called when "Ok" button pressed. //======================================================================= void SMESHGUI_MoveNodesDlg::onOk() { - if ( onApply() ) + if (onApply()) onClose(); } - //======================================================================= // name : SMESHGUI_MoveNodesDlg::onClose // Purpose : SLOT called when "Close" button pressed. Close dialog //======================================================================= void SMESHGUI_MoveNodesDlg::onClose() { - mySelection->ClearIObjects(); + mySelectionMgr->clearSelected(); SMESH::SetPointRepresentation(false); - QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); - disconnect( mySelection, 0, this, 0 ); - disconnect( SMESHGUI::GetSMESHGUI(), 0, this, 0 ); - SMESHGUI::GetSMESHGUI()->ResetState(); + mySelector->SetSelectionMode(ActorSelection); + disconnect(mySelectionMgr, 0, this, 0); + disconnect(mySMESHGUI, 0, this, 0); + mySMESHGUI->ResetState(); reject(); } - - //======================================================================= -//function : onTextChange -//purpose : +// name : SMESHGUI_MoveNodesDlg::onTextChange +// Purpose : //======================================================================= - -void SMESHGUI_MoveNodesDlg::onTextChange(const QString& theNewText) +void SMESHGUI_MoveNodesDlg::onTextChange (const QString& theNewText) { - if ( myBusy ) return; + if (myBusy) return; - myOkBtn->setEnabled( false ); - myApplyBtn->setEnabled( false ); + myOkBtn->setEnabled(false); + myApplyBtn->setEnabled(false); erasePreview(); // select entered node - SMDS_Mesh* aMesh = 0; - if ( myMeshActor ) - aMesh = myMeshActor->GetObject()->GetMesh(); - if ( aMesh ) { + if(myMeshActor){ + if(SMDS_Mesh* aMesh = myMeshActor->GetObject()->GetMesh()){ + myBusy = true; + Handle(SALOME_InteractiveObject) anIO = myMeshActor->getIO(); + SALOME_ListIO aList; + aList.Append(anIO); + mySelectionMgr->setSelectedObjects(aList,false); + myBusy = false; - myBusy = true; - mySelection->ClearIObjects(); - mySelection->AddIObject( myMeshActor->getIO() ); - myBusy = false; - - const SMDS_MeshElement * e = aMesh->FindElement( theNewText.toInt() ); - if ( e ) - mySelection->AddOrRemoveIndex (myMeshActor->getIO(), e->GetID(), true); + if(const SMDS_MeshElement *anElem = aMesh->FindElement(theNewText.toInt())) { + TColStd_MapOfInteger aListInd; + aListInd.Add(anElem->GetID()); + mySelector->AddOrRemoveIndex(anIO,aListInd, true); + myViewWindow->highlight(anIO,true,true); + } + } } } @@ -367,22 +368,25 @@ void SMESHGUI_MoveNodesDlg::onTextChange(const QString& theNewText) //======================================================================= void SMESHGUI_MoveNodesDlg::onSelectionDone() { - if ( myBusy ) return; + if (myBusy) return; myMeshActor = 0; - if ( mySelection->IObjectCount() == 1 ) { - myMeshActor = SMESH::FindActorByEntry(mySelection->firstIObject()->getEntry()); - if ( myMeshActor ) - { + SALOME_ListIO aList; + mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type()); + + if (aList.Extent() == 1) { + Handle(SALOME_InteractiveObject) anIO = aList.First(); + myMeshActor = SMESH::FindActorByEntry(anIO->getEntry()); + if(myMeshActor){ QString aText; - if ( SMESH::GetNameOfSelectedNodes( mySelection, aText ) == 1 ) { + if (SMESH::GetNameOfSelectedNodes(mySelector,anIO,aText) == 1) { if(SMDS_Mesh* aMesh = myMeshActor->GetObject()->GetMesh()) { if(const SMDS_MeshNode* aNode = aMesh->FindNode(aText.toInt())) { myBusy = true; - myId->setText( aText ); - myX->SetValue( aNode->X() ); - myY->SetValue( aNode->Y() ); - myZ->SetValue( aNode->Z() ); + myId->setText(aText); + myX->SetValue(aNode->X()); + myY->SetValue(aNode->Y()); + myZ->SetValue(aNode->Z()); myBusy = false; erasePreview(); // avoid overlapping of a selection and a preview updateButtons(); @@ -396,57 +400,52 @@ void SMESHGUI_MoveNodesDlg::onSelectionDone() reset(); } - //======================================================================= // name : SMESHGUI_MoveNodesDlg::onDeactivate // Purpose : SLOT called when dialog must be deativated //======================================================================= void SMESHGUI_MoveNodesDlg::onDeactivate() { - setEnabled( false ); + setEnabled(false); erasePreview(); } - //======================================================================= // name : SMESHGUI_MoveNodesDlg::enterEvent // Purpose : Event filter //======================================================================= -void SMESHGUI_MoveNodesDlg::enterEvent( QEvent* ) +void SMESHGUI_MoveNodesDlg::enterEvent (QEvent*) { - if ( !isEnabled() ) - { + if (!isEnabled()) { SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog(); // set selection mode SMESH::SetPointRepresentation(true); - QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true ); + myViewWindow->SetSelectionMode(NodeSelection); redisplayPreview(); - - setEnabled( true ); + + setEnabled(true); } } - -//================================================================================= -// function : closeEvent() -// purpose : -//================================================================================= -void SMESHGUI_MoveNodesDlg::closeEvent( QCloseEvent* e ) +//======================================================================= +// name : SMESHGUI_MoveNodesDlg::closeEvent +// Purpose : +//======================================================================= +void SMESHGUI_MoveNodesDlg::closeEvent (QCloseEvent*) { - onClose() ; - SMESH::GetCurrentVtkView()->Repaint(); + onClose(); + myViewWindow->Repaint(); } //======================================================================= -//function : hideEvent -//purpose : may be caused by ESC key +// name : SMESHGUI_MoveNodesDlg::hideEvent +// Purpose : may be caused by ESC key //======================================================================= - -void SMESHGUI_MoveNodesDlg::hideEvent ( QHideEvent * e ) +void SMESHGUI_MoveNodesDlg::hideEvent (QHideEvent*) { - if ( !isMinimized() ) + if (!isMinimized()) onClose(); } @@ -456,9 +455,9 @@ void SMESHGUI_MoveNodesDlg::hideEvent ( QHideEvent * e ) //======================================================================= void SMESHGUI_MoveNodesDlg::updateButtons() { - bool isEnabled = isValid( false ); - myOkBtn->setEnabled( isEnabled ); - myApplyBtn->setEnabled( isEnabled ); + bool isEnabled = isValid(false); + myOkBtn->setEnabled(isEnabled); + myApplyBtn->setEnabled(isEnabled); } //======================================================================= @@ -467,14 +466,13 @@ void SMESHGUI_MoveNodesDlg::updateButtons() //======================================================================= void SMESHGUI_MoveNodesDlg::erasePreview() { - if ( myPreviewActor == 0 ) + if (myPreviewActor == 0) return; - if ( VTKViewer_ViewFrame* vf = SMESH::GetCurrentVtkView() ) - vf->RemoveActor(myPreviewActor); + myViewWindow->RemoveActor(myPreviewActor); myPreviewActor->Delete(); myPreviewActor = 0; - SMESH::GetCurrentVtkView()->Repaint(); + myViewWindow->Repaint(); } //======================================================================= @@ -483,73 +481,71 @@ void SMESHGUI_MoveNodesDlg::erasePreview() //======================================================================= void SMESHGUI_MoveNodesDlg::redisplayPreview() { - if ( myBusy ) + if (myBusy) return; - - if ( myPreviewActor != 0 ) + + if (myPreviewActor != 0) erasePreview(); - - if ( !isValid( false ) ) + + if (!isValid(false)) return; vtkUnstructuredGrid* aGrid = vtkUnstructuredGrid::New(); - + vtkPoints* aPoints = vtkPoints::New(); - aPoints->SetNumberOfPoints( 1 ); - aPoints->SetPoint( 0, myX->GetValue(), myY->GetValue(), myZ->GetValue() ); + aPoints->SetNumberOfPoints(1); + aPoints->SetPoint(0, myX->GetValue(), myY->GetValue(), myZ->GetValue()); // Create cells - + vtkIdList *anIdList = vtkIdList::New(); - anIdList->SetNumberOfIds( 1 ); + anIdList->SetNumberOfIds(1); vtkCellArray *aCells = vtkCellArray::New(); - aCells->Allocate( 2, 0 ); + aCells->Allocate(2, 0); vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New(); - aCellTypesArray->SetNumberOfComponents( 1 ); - aCellTypesArray->Allocate( 1 ); + aCellTypesArray->SetNumberOfComponents(1); + aCellTypesArray->Allocate(1); - anIdList->SetId( 0, 0 ); - aCells->InsertNextCell( anIdList ); - aCellTypesArray->InsertNextValue( VTK_VERTEX ); + anIdList->SetId(0, 0); + aCells->InsertNextCell(anIdList); + aCellTypesArray->InsertNextValue(VTK_VERTEX); + anIdList->Delete(); vtkIntArray* aCellLocationsArray = vtkIntArray::New(); - aCellLocationsArray->SetNumberOfComponents( 1 ); - aCellLocationsArray->SetNumberOfTuples( 1 ); + aCellLocationsArray->SetNumberOfComponents(1); + aCellLocationsArray->SetNumberOfTuples(1); aCells->InitTraversal(); vtkIdType npts; - aCellLocationsArray->SetValue( 0, aCells->GetTraversalLocation( npts ) ); + aCellLocationsArray->SetValue(0, aCells->GetTraversalLocation(npts)); - aGrid->SetCells( aCellTypesArray, aCellLocationsArray, aCells ); + aGrid->SetPoints(aPoints); + aPoints->Delete(); - aGrid->SetPoints( aPoints ); - aGrid->SetCells( aCellTypesArray, aCellLocationsArray,aCells ); - - // Create and display actor - vtkDataSetMapper* aMapper = vtkDataSetMapper::New(); - aMapper->SetInput( aGrid ); - - myPreviewActor = SALOME_Actor::New(); - myPreviewActor->PickableOff(); - myPreviewActor->SetMapper( aMapper ); - - vtkProperty* aProp = vtkProperty::New(); - aProp->SetRepresentationToWireframe(); - aProp->SetColor( 250, 0, 250 ); - aProp->SetPointSize( 5 ); - myPreviewActor->SetProperty( aProp ); - - SMESH::GetCurrentVtkView()->AddActor( myPreviewActor ); - SMESH::GetCurrentVtkView()->Repaint(); - - aProp->Delete(); + aGrid->SetCells(aCellTypesArray,aCellLocationsArray,aCells); aCellLocationsArray->Delete(); aCellTypesArray->Delete(); aCells->Delete(); - anIdList->Delete(); - aPoints->Delete(); + + // Create and display actor + vtkDataSetMapper* aMapper = vtkDataSetMapper::New(); + aMapper->SetInput(aGrid); aGrid->Delete(); + + myPreviewActor = SALOME_Actor::New(); + myPreviewActor->PickableOff(); + myPreviewActor->SetMapper(aMapper); + aMapper->Delete(); + + vtkProperty* aProp = vtkProperty::New(); + aProp->SetRepresentationToWireframe(); + aProp->SetColor(250, 0, 250); + aProp->SetPointSize(5); + myPreviewActor->SetProperty(aProp); + aProp->Delete(); + + myViewWindow->AddActor(myPreviewActor); + myViewWindow->Repaint(); } - diff --git a/src/SMESHGUI/SMESHGUI_MoveNodesDlg.h b/src/SMESHGUI/SMESHGUI_MoveNodesDlg.h index c1b18de9c..4163c5421 100644 --- a/src/SMESHGUI/SMESHGUI_MoveNodesDlg.h +++ b/src/SMESHGUI/SMESHGUI_MoveNodesDlg.h @@ -29,15 +29,21 @@ #ifndef DIALOGBOX_MOVE_NODES_H #define DIALOGBOX_MOVE_NODES_H +#include "SalomeApp_SelectionMgr.h" + #include -#include "SALOME_Selection.h" class QLineEdit; class QPushButton; class SMESHGUI_SpinBox; class SALOME_Actor; class QFrame; + +class SMESHGUI; class SMESH_Actor; +class SUIT_Desktop; +class SVTK_Selector; +class SVTK_ViewWindow; //================================================================================= // class : SMESHGUI_MoveNodesDlg @@ -49,12 +55,11 @@ class SMESHGUI_MoveNodesDlg : public QDialog public: - SMESHGUI_MoveNodesDlg( QWidget*, - SALOME_Selection*, - const char* = 0 ); + SMESHGUI_MoveNodesDlg(SMESHGUI* theModule, + const char* name = 0); virtual ~SMESHGUI_MoveNodesDlg(); - void Init( SALOME_Selection* ) ; + void Init(); private slots: @@ -91,7 +96,10 @@ private: SMESHGUI_SpinBox* myY; SMESHGUI_SpinBox* myZ; - SALOME_Selection* mySelection; + SalomeApp_SelectionMgr* mySelectionMgr; + SVTK_ViewWindow* myViewWindow; + SVTK_Selector* mySelector; + SMESHGUI* mySMESHGUI; SALOME_Actor* myPreviewActor; SMESH_Actor* myMeshActor; diff --git a/src/SMESHGUI/SMESHGUI_MultiEditDlg.cxx b/src/SMESHGUI/SMESHGUI_MultiEditDlg.cxx index d311b490e..f1d940061 100755 --- a/src/SMESHGUI/SMESHGUI_MultiEditDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_MultiEditDlg.cxx @@ -1,23 +1,23 @@ // SMESH SMESHGUI : GUI for SMESH component // // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org // // // @@ -34,22 +34,35 @@ #include "SMESHGUI_VTKUtils.h" #include "SMESHGUI_MeshUtils.h" -#include "QAD_Desktop.h" -#include "QAD_RightFrame.h" - -#include "VTKViewer_ViewFrame.h" - #include "SMESH_Actor.h" +#include "SMESH_TypeFilter.hxx" #include "SMDS_Mesh.hxx" #include "SMDS_MeshElement.hxx" -#include "SALOME_Selection.h" -#include "SALOME_ListIteratorOfListIO.hxx" -#include "VTKViewer_InteractorStyleSALOME.h" +#include "SUIT_ResourceMgr.h" +#include "SUIT_Desktop.h" +#include "SalomeApp_SelectionMgr.h" +#include "SALOME_ListIO.hxx" +#include "SALOME_ListIteratorOfListIO.hxx" + +#include "SVTK_Selector.h" +#include "SVTK_ViewModel.h" +#include "SVTK_ViewWindow.h" +#include "SVTK_InteractorStyle.h" + +// OCCT Includes +#include +#include +#include +#include + +// VTK Includes #include #include #include +#include +#include #include #include #include @@ -57,11 +70,7 @@ #include #include -#include -#include -#include -#include - +// QT Includes #include #include #include @@ -81,106 +90,109 @@ #define SPACING 5 #define MARGIN 10 -/* - Class : SMESHGUI_MultiEditDlg - Description : Description : Inversion of the diagonal of a pseudo-quadrangle formed by - 2 neighboring triangles with 1 common edge -*/ +/*! + * Class : SMESHGUI_MultiEditDlg + * Description : Description : Inversion of the diagonal of a pseudo-quadrangle formed by + * 2 neighboring triangles with 1 common edge + */ //======================================================================= // name : SMESHGUI_MultiEditDlg::SMESHGUI_MultiEditDlg // Purpose : Constructor //======================================================================= -SMESHGUI_MultiEditDlg::SMESHGUI_MultiEditDlg( QWidget* theParent, - SALOME_Selection* theSelection, - const int theMode, - const bool the3d2d, - const char* theName ) -: QDialog( theParent, theName, false, - WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose ) +SMESHGUI_MultiEditDlg +::SMESHGUI_MultiEditDlg(SMESHGUI* theModule, + const int theMode, + const bool the3d2d, + const char* theName): + QDialog(SMESH::GetDesktop(theModule), + theName, + false, + WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose), + mySelector(SMESH::GetViewWindow(theModule)->GetSelector()), + mySelectionMgr(SMESH::GetSelectionMgr(theModule)), + myViewWindow(SMESH::GetViewWindow(theModule)), + mySMESHGUI(theModule) { myFilterDlg = 0; - mySubmeshFilter = new SMESH_TypeFilter( SUBMESH ); - myGroupFilter = new SMESH_TypeFilter( GROUP ); - myEntityType = 0; myFilterType = theMode; - QVBoxLayout* aDlgLay = new QVBoxLayout( this, MARGIN, SPACING ); + QVBoxLayout* aDlgLay = new QVBoxLayout(this, MARGIN, SPACING); - QFrame* aMainFrame = createMainFrame ( this, the3d2d ); - QFrame* aBtnFrame = createButtonFrame( this ); + QFrame* aMainFrame = createMainFrame (this, the3d2d); + QFrame* aBtnFrame = createButtonFrame(this); - aDlgLay->addWidget( aMainFrame ); - aDlgLay->addWidget( aBtnFrame ); + aDlgLay->addWidget(aMainFrame); + aDlgLay->addWidget(aBtnFrame); - aDlgLay->setStretchFactor( aMainFrame, 1 ); - aDlgLay->setStretchFactor( aBtnFrame, 0 ); - Init( theSelection ) ; + aDlgLay->setStretchFactor(aMainFrame, 1); + aDlgLay->setStretchFactor(aBtnFrame, 0); + Init(); } //======================================================================= // name : SMESHGUI_MultiEditDlg::createMainFrame // Purpose : Create frame containing dialog's input fields //======================================================================= -QFrame* SMESHGUI_MultiEditDlg::createMainFrame( QWidget* theParent, const bool the3d2d ) +QFrame* SMESHGUI_MultiEditDlg::createMainFrame (QWidget* theParent, const bool the3d2d) { - QGroupBox* aMainGrp = new QGroupBox( 1, Qt::Horizontal, theParent ); - aMainGrp->setFrameStyle( QFrame::NoFrame ); - aMainGrp->setInsideMargin( 0 ); + QGroupBox* aMainGrp = new QGroupBox(1, Qt::Horizontal, theParent); + aMainGrp->setFrameStyle(QFrame::NoFrame); + aMainGrp->setInsideMargin(0); + + QPixmap aPix (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT"))); - QPixmap aPix( QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr( "ICON_SELECT" ) ) ); - // "Selected cells" group - mySelGrp = new QGroupBox( 1, Qt::Horizontal, aMainGrp ); + mySelGrp = new QGroupBox(1, Qt::Horizontal, aMainGrp); myEntityTypeGrp = 0; - if ( the3d2d ) { - myEntityTypeGrp = new QHButtonGroup( tr("SMESH_ELEMENTS_TYPE"), mySelGrp ); - (new QRadioButton( tr("SMESH_FACE"), myEntityTypeGrp ))->setChecked( true ); - (new QRadioButton( tr("SMESH_VOLUME"), myEntityTypeGrp )); - myEntityType = myEntityTypeGrp->id( myEntityTypeGrp->selected() ); + if (the3d2d) { + myEntityTypeGrp = new QHButtonGroup(tr("SMESH_ELEMENTS_TYPE"), mySelGrp); + (new QRadioButton(tr("SMESH_FACE"), myEntityTypeGrp))->setChecked(true); + (new QRadioButton(tr("SMESH_VOLUME"), myEntityTypeGrp)); + myEntityType = myEntityTypeGrp->id(myEntityTypeGrp->selected()); } - QFrame* aFrame = new QFrame( mySelGrp ); - - myListBox = new QListBox( aFrame ); - myListBox->setSelectionMode( QListBox::Extended ); - myListBox->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding) ); -// myListBox->setColumnMode( QListBox::FitToHeight ); - myListBox->installEventFilter( this ); - - myFilterBtn = new QPushButton( tr( "FILTER" ) , aFrame ); - myAddBtn = new QPushButton( tr( "ADD" ) , aFrame ); - myRemoveBtn = new QPushButton( tr( "REMOVE" ) , aFrame ); - mySortBtn = new QPushButton( tr( "SORT_LIST" ), aFrame ); + QFrame* aFrame = new QFrame(mySelGrp); - QGridLayout* aLay = new QGridLayout( aFrame, 5, 2, 0, 5 ); - aLay->addMultiCellWidget( myListBox, 0, 4, 0, 0 ); - aLay->addWidget( myFilterBtn, 0, 1 ); - aLay->addWidget( myAddBtn, 1, 1 ); - aLay->addWidget( myRemoveBtn, 2, 1 ); - aLay->addWidget( mySortBtn, 3, 1 ); - - QSpacerItem* aSpacer = new QSpacerItem( 0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding ); - aLay->addItem( aSpacer, 4, 1 ); - - myToAllChk = new QCheckBox( tr( "TO_ALL" ), mySelGrp ); + myListBox = new QListBox(aFrame); + myListBox->setSelectionMode(QListBox::Extended); + myListBox->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); +// myListBox->setColumnMode(QListBox::FitToHeight); + myListBox->installEventFilter(this); + + myFilterBtn = new QPushButton(tr("FILTER") , aFrame); + myAddBtn = new QPushButton(tr("ADD") , aFrame); + myRemoveBtn = new QPushButton(tr("REMOVE") , aFrame); + mySortBtn = new QPushButton(tr("SORT_LIST"), aFrame); + + QGridLayout* aLay = new QGridLayout(aFrame, 5, 2, 0, 5); + aLay->addMultiCellWidget(myListBox, 0, 4, 0, 0); + aLay->addWidget(myFilterBtn, 0, 1); + aLay->addWidget(myAddBtn, 1, 1); + aLay->addWidget(myRemoveBtn, 2, 1); + aLay->addWidget(mySortBtn, 3, 1); + + QSpacerItem* aSpacer = new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding); + aLay->addItem(aSpacer, 4, 1); + + myToAllChk = new QCheckBox(tr("TO_ALL"), mySelGrp); // "Select from" group - QGroupBox* aGrp = new QGroupBox( 3, Qt::Horizontal, tr( "SELECT_FROM" ), aMainGrp ); - - mySubmeshChk = new QCheckBox( tr( "SMESH_SUBMESH" ), aGrp ); - mySubmeshBtn = new QPushButton( aGrp ); - mySubmesh = new QLineEdit( aGrp ); - mySubmesh->setReadOnly( true ); - mySubmeshBtn->setPixmap( aPix ); - - myGroupChk = new QCheckBox( tr( "GROUP" ), aGrp ); - myGroupBtn = new QPushButton( aGrp ); - myGroup = new QLineEdit( aGrp ); - myGroup->setReadOnly( true ); - myGroupBtn->setPixmap( aPix ); + QGroupBox* aGrp = new QGroupBox(3, Qt::Horizontal, tr("SELECT_FROM"), aMainGrp); + + mySubmeshChk = new QCheckBox(tr("SMESH_SUBMESH"), aGrp); + mySubmeshBtn = new QPushButton(aGrp); + mySubmesh = new QLineEdit(aGrp); + mySubmesh->setReadOnly(true); + mySubmeshBtn->setPixmap(aPix); + + myGroupChk = new QCheckBox(tr("GROUP"), aGrp); + myGroupBtn = new QPushButton(aGrp); + myGroup = new QLineEdit(aGrp); + myGroup->setReadOnly(true); + myGroupBtn->setPixmap(aPix); return aMainGrp; } @@ -189,23 +201,23 @@ QFrame* SMESHGUI_MultiEditDlg::createMainFrame( QWidget* theParent, const bool t // name : SMESHGUI_MultiEditDlg::createButtonFrame // Purpose : Create frame containing buttons //======================================================================= -QFrame* SMESHGUI_MultiEditDlg::createButtonFrame( QWidget* theParent ) +QFrame* SMESHGUI_MultiEditDlg::createButtonFrame (QWidget* theParent) { - QFrame* aFrame = new QFrame( theParent ); - aFrame->setFrameStyle( QFrame::Box | QFrame::Sunken ); + QFrame* aFrame = new QFrame (theParent); + aFrame->setFrameStyle(QFrame::Box | QFrame::Sunken); - myOkBtn = new QPushButton( tr( "SMESH_BUT_OK" ), aFrame ); - myApplyBtn = new QPushButton( tr( "SMESH_BUT_APPLY" ), aFrame ); - myCloseBtn = new QPushButton( tr( "SMESH_BUT_CLOSE" ), aFrame ); + myOkBtn = new QPushButton (tr("SMESH_BUT_OK" ), aFrame); + myApplyBtn = new QPushButton (tr("SMESH_BUT_APPLY"), aFrame); + myCloseBtn = new QPushButton (tr("SMESH_BUT_CLOSE"), aFrame); - QSpacerItem* aSpacer = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum ); + QSpacerItem* aSpacer = new QSpacerItem (0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum); - QHBoxLayout* aLay = new QHBoxLayout( aFrame, MARGIN, SPACING ); + QHBoxLayout* aLay = new QHBoxLayout (aFrame, MARGIN, SPACING); - aLay->addWidget( myOkBtn ); - aLay->addWidget( myApplyBtn ); - aLay->addItem( aSpacer); - aLay->addWidget( myCloseBtn ); + aLay->addWidget(myOkBtn); + aLay->addWidget(myApplyBtn); + aLay->addItem(aSpacer); + aLay->addWidget(myCloseBtn); return aFrame; } @@ -214,7 +226,7 @@ QFrame* SMESHGUI_MultiEditDlg::createButtonFrame( QWidget* theParent ) // name : SMESHGUI_MultiEditDlg::isValid // Purpose : Verify validity of input data //======================================================================= -bool SMESHGUI_MultiEditDlg::isValid( const bool /*theMess*/ ) const +bool SMESHGUI_MultiEditDlg::isValid (const bool /*theMess*/) const { return (!myMesh->_is_nil() && (myListBox->count() > 0 || (myToAllChk->isChecked() && myActor))); @@ -226,9 +238,9 @@ bool SMESHGUI_MultiEditDlg::isValid( const bool /*theMess*/ ) const //======================================================================= SMESHGUI_MultiEditDlg::~SMESHGUI_MultiEditDlg() { - if ( myFilterDlg != 0 ) + if (myFilterDlg != 0) { - myFilterDlg->reparent( 0, QPoint() ); + myFilterDlg->reparent(0, QPoint()); delete myFilterDlg; } } @@ -237,25 +249,23 @@ SMESHGUI_MultiEditDlg::~SMESHGUI_MultiEditDlg() // name : SMESHGUI_MultiEditDlg::eventFilter // Purpose : event filter //======================================================================= -bool SMESHGUI_MultiEditDlg::eventFilter( QObject* object, QEvent* event ) +bool SMESHGUI_MultiEditDlg::eventFilter (QObject* object, QEvent* event) { - if ( object == myListBox && event->type() == QEvent::KeyPress ) { + if (object == myListBox && event->type() == QEvent::KeyPress) { QKeyEvent* ke = (QKeyEvent*)event; - if ( ke->key() == Key_Delete ) + if (ke->key() == Key_Delete) onRemoveBtn(); } - return QDialog::eventFilter( object, event ); + return QDialog::eventFilter(object, event); } //======================================================================= // name : SMESHGUI_MultiEditDlg::Init // Purpose : Init dialog fields, connect signals and slots, show dialog //======================================================================= -void SMESHGUI_MultiEditDlg::Init( SALOME_Selection* theSelection ) +void SMESHGUI_MultiEditDlg::Init() { - SMESHGUI* aSMESHGUI = SMESHGUI::GetSMESHGUI(); - mySelection = theSelection; - aSMESHGUI->SetActiveDialogBox( ( QDialog* )this ) ; + mySMESHGUI->SetActiveDialogBox((QDialog*)this); myListBox->clear(); myIds.Clear(); myBusy = false; @@ -263,29 +273,29 @@ void SMESHGUI_MultiEditDlg::Init( SALOME_Selection* theSelection ) emit ListContensChanged(); // main buttons - connect( myOkBtn, SIGNAL( clicked() ), SLOT( onOk() ) ); - connect( myCloseBtn, SIGNAL( clicked() ), SLOT( onClose() ) ) ; - connect( myApplyBtn, SIGNAL( clicked() ), SLOT( onApply() ) ); + connect(myOkBtn, SIGNAL(clicked()), SLOT(onOk())); + connect(myCloseBtn, SIGNAL(clicked()), SLOT(onClose())); + connect(myApplyBtn, SIGNAL(clicked()), SLOT(onApply())); // selection and SMESHGUI - connect( mySelection, SIGNAL( currentSelectionChanged() ), SLOT( onSelectionDone() ) ); - connect( aSMESHGUI, SIGNAL( SignalDeactivateActiveDialog() ), SLOT( onDeactivate() ) ); - connect( aSMESHGUI, SIGNAL( SignalCloseAllDialogs() ), SLOT( onClose() ) ); + connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(onSelectionDone())); + connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), SLOT(onDeactivate())); + connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), SLOT(onClose())); // dialog controls - connect( myFilterBtn, SIGNAL( clicked() ), SLOT( onFilterBtn() ) ); - connect( myAddBtn , SIGNAL( clicked() ), SLOT( onAddBtn() ) ); - connect( myRemoveBtn, SIGNAL( clicked() ), SLOT( onRemoveBtn() ) ); - connect( mySortBtn , SIGNAL( clicked() ), SLOT( onSortListBtn() ) ); - - connect( mySubmeshChk, SIGNAL( stateChanged( int ) ), SLOT( onSubmeshChk() ) ); - connect( myGroupChk , SIGNAL( stateChanged( int ) ), SLOT( onGroupChk() ) ); - connect( myToAllChk , SIGNAL( stateChanged( int ) ), SLOT( onToAllChk() ) ); + connect(myFilterBtn, SIGNAL(clicked()), SLOT(onFilterBtn() )); + connect(myAddBtn , SIGNAL(clicked()), SLOT(onAddBtn() )); + connect(myRemoveBtn, SIGNAL(clicked()), SLOT(onRemoveBtn() )); + connect(mySortBtn , SIGNAL(clicked()), SLOT(onSortListBtn())); - if ( myEntityTypeGrp ) - connect( myEntityTypeGrp, SIGNAL( clicked(int) ), SLOT( on3d2dChanged(int) ) ); + connect(mySubmeshChk, SIGNAL(stateChanged(int)), SLOT(onSubmeshChk())); + connect(myGroupChk , SIGNAL(stateChanged(int)), SLOT(onGroupChk() )); + connect(myToAllChk , SIGNAL(stateChanged(int)), SLOT(onToAllChk() )); - connect( myListBox, SIGNAL( selectionChanged() ), SLOT( onListSelectionChanged() ) ); + if (myEntityTypeGrp) + connect(myEntityTypeGrp, SIGNAL(clicked(int)), SLOT(on3d2dChanged(int))); + + connect(myListBox, SIGNAL(selectionChanged()), SLOT(onListSelectionChanged())); onSelectionDone(); @@ -296,12 +306,12 @@ void SMESHGUI_MultiEditDlg::Init( SALOME_Selection* theSelection ) //======================================================================= // name : SMESHGUI_MultiEditDlg::onOk -// Purpose : SLOT called when "Ok" button pressed. +// Purpose : SLOT called when "Ok" button pressed. // Assign filters VTK viewer and close dialog //======================================================================= void SMESHGUI_MultiEditDlg::onOk() { - if ( onApply() ) + if (onApply()) onClose(); } @@ -312,35 +322,34 @@ void SMESHGUI_MultiEditDlg::onOk() SMESH::long_array_var SMESHGUI_MultiEditDlg::getIds() { SMESH::long_array_var anIds = new SMESH::long_array; - - if ( myToAllChk->isChecked() ) + + if (myToAllChk->isChecked()) { myIds.Clear(); - SMESH_Actor * anActor = SMESH::FindActorByObject( myMesh ); - if ( !anActor ) + SMESH_Actor * anActor = SMESH::FindActorByObject(myMesh); + if (!anActor) anActor = myActor; - if ( anActor != 0 ) + if (anActor != 0) { TVisualObjPtr aVisualObj = anActor->GetObject(); vtkUnstructuredGrid* aGrid = aVisualObj->GetUnstructuredGrid(); - if ( aGrid != 0 ) - { - for ( int i = 0, n = aGrid->GetNumberOfCells(); i < n; i++ ) - { - vtkCell* aCell = aGrid->GetCell( i ); - if ( aCell != 0 ) - { + if (aGrid != 0) { + for (int i = 0, n = aGrid->GetNumberOfCells(); i < n; i++) { + vtkCell* aCell = aGrid->GetCell(i); + if (aCell != 0) { vtkTriangle* aTri = vtkTriangle::SafeDownCast(aCell); vtkQuad* aQua = vtkQuad::SafeDownCast(aCell); - vtkCell3D* a3d = vtkCell3D::SafeDownCast(aCell); + vtkPolygon* aPG = vtkPolygon::SafeDownCast(aCell); - if ( aTri && myFilterType == SMESHGUI_TriaFilter || - aQua && myFilterType == SMESHGUI_QuadFilter || - ( aTri || aQua ) && myFilterType == SMESHGUI_FaceFilter || - a3d && myFilterType == SMESHGUI_VolumeFilter ) - { - int anObjId = aVisualObj->GetElemObjId( i ); - myIds.Add( anObjId ); + vtkCell3D* a3d = vtkCell3D::SafeDownCast(aCell); + vtkConvexPointSet* aPH = vtkConvexPointSet::SafeDownCast(aCell); + + if (aTri && myFilterType == SMESHGUI_TriaFilter || + aQua && myFilterType == SMESHGUI_QuadFilter || + (aTri || aQua || aPG) && myFilterType == SMESHGUI_FaceFilter || + (a3d || aPH) && myFilterType == SMESHGUI_VolumeFilter) { + int anObjId = aVisualObj->GetElemObjId(i); + myIds.Add(anObjId); } } } @@ -348,9 +357,9 @@ SMESH::long_array_var SMESHGUI_MultiEditDlg::getIds() } } - anIds->length( myIds.Extent() ); - TColStd_MapIteratorOfMapOfInteger anIter( myIds ); - for ( int i = 0; anIter.More(); anIter.Next() ) + anIds->length(myIds.Extent()); + TColStd_MapIteratorOfMapOfInteger anIter(myIds); + for (int i = 0; anIter.More(); anIter.Next() ) { anIds[ i++ ] = anIter.Key(); } @@ -363,17 +372,17 @@ SMESH::long_array_var SMESHGUI_MultiEditDlg::getIds() //======================================================================= void SMESHGUI_MultiEditDlg::onClose() { - QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); - disconnect( mySelection, 0, this, 0 ); - disconnect( SMESHGUI::GetSMESHGUI(), 0, this, 0 ); - SMESHGUI::GetSMESHGUI()->ResetState(); - + myViewWindow->SetSelectionMode(ActorSelection); + disconnect(mySelectionMgr, 0, this, 0); + disconnect(mySMESHGUI, 0, this, 0); + mySMESHGUI->ResetState(); + SMESH::RemoveFilters(); SMESH::SetPickable(); - mySelection->ClearIObjects(); - mySelection->ClearFilters(); - + mySelectionMgr->clearSelected(); + mySelectionMgr->clearFilters(); + reject(); } @@ -383,73 +392,62 @@ void SMESHGUI_MultiEditDlg::onClose() //======================================================================= void SMESHGUI_MultiEditDlg::onSelectionDone() { - if ( myBusy || !isEnabled() ) return; + if (myBusy || !isEnabled()) return; myBusy = true; - int nbSel = mySelection->IObjectCount(); + const SALOME_ListIO& aList = mySelector->StoredIObjects(); + + int nbSel = aList.Extent(); myListBox->clearSelection(); - if ( mySubmeshChk->isChecked() || myGroupChk->isChecked() ) - { + if (mySubmeshChk->isChecked() || myGroupChk->isChecked()) { QLineEdit* aNameEdit = mySubmeshChk->isChecked() ? mySubmesh : myGroup; - int nbSel = mySelection->IObjectCount(); - if ( nbSel == 1 ) - { - Handle(SALOME_InteractiveObject) anIO = mySelection->firstIObject(); - anIO.IsNull() ? aNameEdit->clear() : aNameEdit->setText( anIO->getName() ); + if (nbSel == 1) { + Handle(SALOME_InteractiveObject) anIO = aList.First(); + anIO.IsNull() ? aNameEdit->clear() : aNameEdit->setText(anIO->getName()); - if ( mySubmeshChk->isChecked() ) - { + if (mySubmeshChk->isChecked()) { SMESH::SMESH_subMesh_var aSubMesh = - SMESH::IObjectToInterface( anIO ); - if ( !aSubMesh->_is_nil() ) + SMESH::IObjectToInterface(anIO); + if (!aSubMesh->_is_nil()) myMesh = aSubMesh->GetFather(); - } - else - { + } else { SMESH::SMESH_GroupBase_var aGroup = - SMESH::IObjectToInterface( anIO ); - if ( !aGroup->_is_nil() ) + SMESH::IObjectToInterface(anIO); + if (!aGroup->_is_nil()) myMesh = aGroup->GetMesh(); } - } - else if ( nbSel > 1 ) - { - QString aStr = mySubmeshChk->isChecked() ? - tr( "SMESH_SUBMESH_SELECTED" ) : tr( "SMESH_GROUP_SELECTED" ); - aNameEdit->setText( aStr.arg( nbSel ) ); - } - else + } else if (nbSel > 1) { + QString aStr = mySubmeshChk->isChecked() ? + tr("SMESH_SUBMESH_SELECTED") : tr("SMESH_GROUP_SELECTED"); + aNameEdit->setText(aStr.arg(nbSel)); + } else { aNameEdit->clear(); - } - else if ( nbSel == 1 ) - { + } + } else if (nbSel == 1) { QString aListStr = ""; - int aNbItems = SMESH::GetNameOfSelectedElements(mySelection, aListStr); - if ( aNbItems > 0 ) - { + Handle(SALOME_InteractiveObject) anIO = aList.First(); + int aNbItems = SMESH::GetNameOfSelectedElements(mySelector,anIO,aListStr); + if (aNbItems > 0) { QStringList anElements = QStringList::split(" ", aListStr); QListBoxItem* anItem = 0; - for ( QStringList::iterator it = anElements.begin(); it != anElements.end(); ++it) - { - anItem = myListBox->findItem( *it, Qt::ExactMatch ); - if (anItem) myListBox->setSelected( anItem, true ); + for (QStringList::iterator it = anElements.begin(); it != anElements.end(); ++it) { + anItem = myListBox->findItem(*it, Qt::ExactMatch); + if (anItem) myListBox->setSelected(anItem, true); } } - myMesh = SMESH::GetMeshByIO( mySelection->firstIObject() ); + myMesh = SMESH::GetMeshByIO(anIO); } - if ( nbSel == 1 ) { - myActor = SMESH::FindActorByEntry(mySelection->firstIObject()->getEntry()); + if (nbSel == 1) { + myActor = SMESH::FindActorByEntry(aList.First()->getEntry()); if (!myActor) - myActor = SMESH::FindActorByObject( myMesh ); - VTKViewer_InteractorStyleSALOME* aStyle = SMESH::GetInteractorStyle(); - Handle(VTKViewer_Filter) aFilter = aStyle->GetFilter( myFilterType ); - if ( !aFilter.IsNull() ) - aFilter->SetActor( myActor ); -//if ( myActor ) -// SMESH::SetPickable(myActor); + myActor = SMESH::FindActorByObject(myMesh); + SVTK_InteractorStyle* aStyle = SMESH::GetInteractorStyle(); + Handle(VTKViewer_Filter) aFilter = aStyle->GetFilter(myFilterType); + if (!aFilter.IsNull()) + aFilter->SetActor(myActor); } myBusy = false; @@ -462,39 +460,37 @@ void SMESHGUI_MultiEditDlg::onSelectionDone() //======================================================================= void SMESHGUI_MultiEditDlg::onDeactivate() { - setEnabled( false ); + setEnabled(false); } //======================================================================= // name : SMESHGUI_MultiEditDlg::enterEvent // Purpose : Event filter //======================================================================= -void SMESHGUI_MultiEditDlg::enterEvent( QEvent* ) +void SMESHGUI_MultiEditDlg::enterEvent (QEvent*) { - if ( !isEnabled() ) { - SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog(); - setEnabled( true ); + if (!isEnabled()) { + mySMESHGUI->EmitSignalDeactivateDialog(); + setEnabled(true); setSelectionMode(); } } - -//================================================================================= -// function : closeEvent() -// purpose : -//================================================================================= -void SMESHGUI_MultiEditDlg::closeEvent( QCloseEvent* e ) +//======================================================================= +// name : SMESHGUI_MultiEditDlg::closeEvent +// Purpose : +//======================================================================= +void SMESHGUI_MultiEditDlg::closeEvent (QCloseEvent*) { - onClose() ; + onClose(); } //======================================================================= -//function : hideEvent -//purpose : caused by ESC key +// name : SMESHGUI_MultiEditDlg::hideEvent +// Purpose : caused by ESC key //======================================================================= - -void SMESHGUI_MultiEditDlg::hideEvent ( QHideEvent * e ) +void SMESHGUI_MultiEditDlg::hideEvent (QHideEvent*) { - if ( !isMinimized() ) + if (!isMinimized()) onClose(); } @@ -505,42 +501,40 @@ void SMESHGUI_MultiEditDlg::hideEvent ( QHideEvent * e ) //======================================================================= void SMESHGUI_MultiEditDlg::onFilterBtn() { - if ( myFilterDlg == 0 ) - { - myFilterDlg = new SMESHGUI_FilterDlg( (QWidget*)parent(), entityType() ? SMESH::VOLUME : SMESH::FACE ); - connect( myFilterDlg, SIGNAL( Accepted() ), SLOT( onFilterAccepted() ) ); + if (myFilterDlg == 0) { + myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, entityType() ? SMESH::VOLUME : SMESH::FACE); + connect(myFilterDlg, SIGNAL(Accepted()), SLOT(onFilterAccepted())); + } else { + myFilterDlg->Init(entityType() ? SMESH::VOLUME : SMESH::FACE); } - else - myFilterDlg->Init( entityType() ? SMESH::VOLUME : SMESH::FACE ); - myFilterDlg->SetSelection( mySelection ); - myFilterDlg->SetMesh( myMesh ); - myFilterDlg->SetSourceWg( myListBox ); + myFilterDlg->SetSelection(); + myFilterDlg->SetMesh(myMesh); + myFilterDlg->SetSourceWg(myListBox); myFilterDlg->show(); } -//================================================================================= -// function : onFilterAccepted() -// purpose : SLOT. Called when Filter dlg closed with OK button. +//======================================================================= +// name : onFilterAccepted() +// Purpose : SLOT. Called when Filter dlg closed with OK button. // Uncheck "Select submesh" and "Select group" checkboxes -//================================================================================= +//======================================================================= void SMESHGUI_MultiEditDlg::onFilterAccepted() { myIds.Clear(); - for ( int i = 0, n = myListBox->count(); i < n; i++ ) - myIds.Add( myListBox->text( i ).toInt() ); + for (int i = 0, n = myListBox->count(); i < n; i++) + myIds.Add(myListBox->text(i).toInt()); emit ListContensChanged(); - if ( mySubmeshChk->isChecked() || myGroupChk->isChecked() ) - { - mySubmeshChk->blockSignals( true ); - myGroupChk->blockSignals( true ); - mySubmeshChk->setChecked( false ); - myGroupChk->setChecked( false ); - mySubmeshChk->blockSignals( false ); - myGroupChk->blockSignals( false ); + if (mySubmeshChk->isChecked() || myGroupChk->isChecked()) { + mySubmeshChk->blockSignals(true); + myGroupChk->blockSignals(true); + mySubmeshChk->setChecked(false); + myGroupChk->setChecked(false); + mySubmeshChk->blockSignals(false); + myGroupChk->blockSignals(false); } updateButtons(); } @@ -549,13 +543,13 @@ void SMESHGUI_MultiEditDlg::onFilterAccepted() // name : SMESHGUI_MultiEditDlg::isIdValid // Purpose : Verify whether Id of element satisfies to filters from viewer //======================================================================= -bool SMESHGUI_MultiEditDlg::isIdValid( const int theId ) const +bool SMESHGUI_MultiEditDlg::isIdValid (const int theId) const { - VTKViewer_InteractorStyleSALOME* aStyle = SMESH::GetInteractorStyle(); + SVTK_InteractorStyle* aStyle = SMESH::GetInteractorStyle(); Handle(SMESHGUI_Filter) aFilter = - Handle(SMESHGUI_Filter)::DownCast( aStyle->GetFilter( myFilterType ) ); + Handle(SMESHGUI_Filter)::DownCast(aStyle->GetFilter(myFilterType)); - return ( !aFilter.IsNull() && aFilter->IsObjValid( theId ) ); + return (!aFilter.IsNull() && aFilter->IsObjValid(theId)); } //======================================================================= @@ -565,74 +559,67 @@ bool SMESHGUI_MultiEditDlg::isIdValid( const int theId ) const //======================================================================= void SMESHGUI_MultiEditDlg::onAddBtn() { - int nbSelected = mySelection->IObjectCount(); - if ( nbSelected == 0 ) + const SALOME_ListIO& aList = mySelector->StoredIObjects(); + + int nbSelected = aList.Extent(); + if (nbSelected == 0) return; TColStd_IndexedMapOfInteger toBeAdded; - - if ( !mySubmeshChk->isChecked() && !myGroupChk->isChecked() ) - { - if ( nbSelected == 1 ) - SMESH::GetSelected( mySelection, toBeAdded ); - } - else if ( mySubmeshChk->isChecked() ) - { - SALOME_ListIteratorOfListIO anIter( mySelection->StoredIObjects() ); - for ( ; anIter.More(); anIter.Next() ) - { - SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface( anIter.Value() ); - if ( !aSubMesh->_is_nil() ) - { - if ( aSubMesh->GetFather()->GetId() == myMesh->GetId() ) - { + + if (!mySubmeshChk->isChecked() && !myGroupChk->isChecked()) { + if (nbSelected == 1) + mySelector->GetIndex(aList.First(),toBeAdded); + } else if (mySubmeshChk->isChecked()) { + SALOME_ListIteratorOfListIO anIter(aList); + for (; anIter.More(); anIter.Next()) { + SMESH::SMESH_subMesh_var aSubMesh = + SMESH::IObjectToInterface(anIter.Value()); + if (!aSubMesh->_is_nil()) { + if (aSubMesh->GetFather()->GetId() == myMesh->GetId()) { SMESH::long_array_var anIds = aSubMesh->GetElementsId(); - for ( int i = 0, n = anIds->length(); i < n; i++ ) - { - if ( isIdValid( anIds[ i ] ) ) - toBeAdded.Add( anIds[ i ] ); + for (int i = 0, n = anIds->length(); i < n; i++) { + if (isIdValid(anIds[ i ])) + toBeAdded.Add(anIds[ i ]); } } } } - } - else if ( myGroupChk->isChecked() ) - { - SALOME_ListIteratorOfListIO anIter( mySelection->StoredIObjects() ); - for ( ; anIter.More(); anIter.Next() ) - { + } else if (myGroupChk->isChecked()) { + SALOME_ListIteratorOfListIO anIter(aList); + for (; anIter.More(); anIter.Next()) { SMESH::SMESH_GroupBase_var aGroup = - SMESH::IObjectToInterface( anIter.Value() ); - if ( !aGroup->_is_nil() && ( aGroup->GetType() == SMESH::FACE && entityType() == 0 || aGroup->GetType() == SMESH::VOLUME && entityType() == 1 ) ) - { - if ( aGroup->GetMesh()->GetId() == myMesh->GetId() ) - { + SMESH::IObjectToInterface(anIter.Value()); + if (!aGroup->_is_nil() && (aGroup->GetType() == SMESH::FACE && + entityType() == 0 || aGroup->GetType() == SMESH::VOLUME && + entityType() == 1)) { + if (aGroup->GetMesh()->GetId() == myMesh->GetId()) { SMESH::long_array_var anIds = aGroup->GetListOfID(); - for ( int i = 0, n = anIds->length(); i < n; i++ ) - { - if ( isIdValid( anIds[ i ] ) ) - toBeAdded.Add( anIds[ i ] ); + for (int i = 0, n = anIds->length(); i < n; i++) { + if (isIdValid(anIds[ i ])) + toBeAdded.Add(anIds[ i ]); } } } } + } else { } myBusy = true; - bool isGroupOrSubmesh = ( mySubmeshChk->isChecked() || myGroupChk->isChecked() ); - mySubmeshChk->setChecked( false ); - myGroupChk->setChecked( false ); - for( int i = 1; i <= toBeAdded.Extent(); i++ ) - if ( myIds.Add( toBeAdded(i) ) ) { - QListBoxItem * item = new QListBoxText( QString( "%1" ).arg( toBeAdded(i) )); - myListBox->insertItem( item ); - myListBox->setSelected( item, true ); + bool isGroupOrSubmesh = (mySubmeshChk->isChecked() || myGroupChk->isChecked()); + mySubmeshChk->setChecked(false); + myGroupChk->setChecked(false); + for(int i = 1; i <= toBeAdded.Extent(); i++) + if (myIds.Add(toBeAdded(i))) { + QListBoxItem * item = new QListBoxText(QString("%1").arg(toBeAdded(i))); + myListBox->insertItem(item); + myListBox->setSelected(item, true); } myBusy = false; - emit ListContensChanged(); + emit ListContensChanged(); - if ( isGroupOrSubmesh ) + if (isGroupOrSubmesh) onListSelectionChanged(); updateButtons(); @@ -645,38 +632,40 @@ void SMESHGUI_MultiEditDlg::onAddBtn() void SMESHGUI_MultiEditDlg::updateButtons() { bool isOk = isValid(false); - myOkBtn->setEnabled( isOk ); - myApplyBtn->setEnabled( isOk ); + myOkBtn->setEnabled(isOk); + myApplyBtn->setEnabled(isOk); bool isListBoxNonEmpty = myListBox->count() > 0; bool isToAll = myToAllChk->isChecked(); - myFilterBtn->setEnabled( !isToAll ); - myRemoveBtn->setEnabled( isListBoxNonEmpty && !isToAll ); - mySortBtn->setEnabled( isListBoxNonEmpty &&!isToAll ); - - if ( isToAll || - myMesh->_is_nil() || - mySelection->IObjectCount() != 1 || - (SMESH::IObjectToInterface( mySelection->firstIObject() )->_is_nil() && - SMESH::IObjectToInterface( mySelection->firstIObject() )->_is_nil() && - SMESH::IObjectToInterface( mySelection->firstIObject() )->_is_nil()) ) - myAddBtn->setEnabled( false ); + myFilterBtn->setEnabled(!isToAll); + myRemoveBtn->setEnabled(isListBoxNonEmpty && !isToAll); + mySortBtn->setEnabled(isListBoxNonEmpty &&!isToAll); + + const SALOME_ListIO& aList = mySelector->StoredIObjects(); + + if (isToAll || + myMesh->_is_nil() || + aList.Extent() != 1 || + (SMESH::IObjectToInterface(aList.First())->_is_nil() && + SMESH::IObjectToInterface(aList.First())->_is_nil() && + SMESH::IObjectToInterface(aList.First())->_is_nil())) + myAddBtn->setEnabled(false); else - myAddBtn->setEnabled( true ); - - mySubmeshChk->setEnabled( !isToAll ); - mySubmeshBtn->setEnabled( mySubmeshChk->isChecked() ); - mySubmesh->setEnabled( mySubmeshChk->isChecked() ); - - myGroupChk->setEnabled( !isToAll ); - myGroupBtn->setEnabled( myGroupChk->isChecked() ); - myGroup->setEnabled( myGroupChk->isChecked() ); - - if ( !mySubmeshChk->isChecked() ) + myAddBtn->setEnabled(true); + + mySubmeshChk->setEnabled(!isToAll); + mySubmeshBtn->setEnabled(mySubmeshChk->isChecked()); + mySubmesh->setEnabled(mySubmeshChk->isChecked()); + + myGroupChk->setEnabled(!isToAll); + myGroupBtn->setEnabled(myGroupChk->isChecked()); + myGroup->setEnabled(myGroupChk->isChecked()); + + if (!mySubmeshChk->isChecked()) mySubmesh->clear(); - if ( !myGroupChk->isChecked() ) + if (!myGroupChk->isChecked()) myGroup->clear(); - + } //======================================================================= @@ -687,22 +676,22 @@ void SMESHGUI_MultiEditDlg::updateButtons() void SMESHGUI_MultiEditDlg::onRemoveBtn() { myBusy = true; - - for ( int i = 0, n = myListBox->count(); i < n; i++ ) + + for (int i = 0, n = myListBox->count(); i < n; i++) { - for ( int i = myListBox->count(); i > 0; i--) { - if ( myListBox->isSelected( i - 1 ) ) + for (int i = myListBox->count(); i > 0; i--) { + if (myListBox->isSelected(i - 1)) { - int anId = myListBox->text( i - 1 ).toInt(); - myIds.Remove( anId ); - myIds.Remove( anId ); - myListBox->removeItem( i-1 ); + int anId = myListBox->text(i - 1).toInt(); + myIds.Remove(anId); + myIds.Remove(anId); + myListBox->removeItem(i-1); } - } + } } myBusy = false; - emit ListContensChanged(); + emit ListContensChanged(); updateButtons(); } @@ -716,28 +705,28 @@ void SMESHGUI_MultiEditDlg::onSortListBtn() myBusy = true; int i, k = myListBox->count(); - if ( k > 0 ) + if (k > 0) { QStringList aSelected; - std::vector anArray( k ); + std::vector anArray(k); QListBoxItem* anItem; - for ( anItem = myListBox->firstItem(), i = 0; anItem != 0; anItem = anItem->next(), i++) + for (anItem = myListBox->firstItem(), i = 0; anItem != 0; anItem = anItem->next(), i++) { anArray[ i ] = anItem->text().toInt(); - if ( anItem->isSelected() ) - aSelected.append( anItem->text() ); + if (anItem->isSelected()) + aSelected.append(anItem->text()); } - - std::sort( anArray.begin(), anArray.end() ); - myListBox->clear(); - for ( i = 0; i < k; i++ ) - myListBox->insertItem( QString::number( anArray[ i ] ) ); - for ( QStringList::iterator it = aSelected.begin(); it != aSelected.end(); ++it ) + std::sort(anArray.begin(), anArray.end()); + myListBox->clear(); + for (i = 0; i < k; i++) + myListBox->insertItem(QString::number(anArray[ i ])); + + for (QStringList::iterator it = aSelected.begin(); it != aSelected.end(); ++it) { - anItem = myListBox->findItem( *it, Qt::ExactMatch ); - if ( anItem ) - myListBox->setSelected( anItem, true ); + anItem = myListBox->findItem(*it, Qt::ExactMatch); + if (anItem) + myListBox->setSelected(anItem, true); } } myBusy = false; @@ -750,31 +739,30 @@ void SMESHGUI_MultiEditDlg::onSortListBtn() //======================================================================= void SMESHGUI_MultiEditDlg::onListSelectionChanged() { - if ( myActor == 0 || myBusy ) - return; - - if ( mySubmeshChk->isChecked() || myGroupChk->isChecked() ) + if (myActor == 0 || myBusy) return; - SMESH_Actor * anActor = SMESH::FindActorByObject( myMesh ); - if ( !anActor ) + if (mySubmeshChk->isChecked() || myGroupChk->isChecked()) + return; + + SMESH_Actor * anActor = SMESH::FindActorByObject(myMesh); + if (!anActor) anActor = myActor; TVisualObjPtr anObj = anActor->GetObject(); TColStd_MapOfInteger anIndexes; - for ( QListBoxItem* anItem = myListBox->firstItem(); anItem != 0; anItem = anItem->next() ) + for (QListBoxItem* anItem = myListBox->firstItem(); anItem != 0; anItem = anItem->next()) { - if ( anItem->isSelected() ) + if (anItem->isSelected()) { int anId = anItem->text().toInt(); - if ( anObj->GetElemVTKId( anId ) >= 0 ) // avoid exception in hilight + if (anObj->GetElemVTKId(anId) >= 0) // avoid exception in hilight anIndexes.Add(anId); } } - - mySelection->ClearIObjects(); - mySelection->AddOrRemoveIndex( anActor->getIO(), anIndexes, false, false ); - mySelection->AddIObject( anActor->getIO() ); + + mySelector->AddOrRemoveIndex(anActor->getIO(),anIndexes,false); + myViewWindow->highlight(anActor->getIO(),true,true); } //======================================================================= @@ -785,14 +773,14 @@ void SMESHGUI_MultiEditDlg::onListSelectionChanged() void SMESHGUI_MultiEditDlg::onSubmeshChk() { bool isChecked = mySubmeshChk->isChecked(); - mySubmeshBtn->setEnabled( isChecked ); - mySubmesh->setEnabled( isChecked ); - if ( !isChecked ) + mySubmeshBtn->setEnabled(isChecked); + mySubmesh->setEnabled(isChecked); + if (!isChecked) mySubmesh->clear(); - if ( isChecked && myGroupChk->isChecked() ) - myGroupChk->setChecked( false ); - - setSelectionMode(); + if (isChecked && myGroupChk->isChecked()) + myGroupChk->setChecked(false); + + setSelectionMode(); } //======================================================================= @@ -803,12 +791,12 @@ void SMESHGUI_MultiEditDlg::onSubmeshChk() void SMESHGUI_MultiEditDlg::onGroupChk() { bool isChecked = myGroupChk->isChecked(); - myGroupBtn->setEnabled( isChecked ); - myGroup->setEnabled( isChecked ); - if ( !isChecked ) + myGroupBtn->setEnabled(isChecked); + myGroup->setEnabled(isChecked); + if (!isChecked) myGroup->clear(); - if ( isChecked && mySubmeshChk->isChecked() ) - mySubmeshChk->setChecked( false ); + if (isChecked && mySubmeshChk->isChecked()) + mySubmeshChk->setChecked(false); setSelectionMode(); } @@ -816,27 +804,23 @@ void SMESHGUI_MultiEditDlg::onGroupChk() //======================================================================= // name : SMESHGUI_MultiEditDlg::onToAllChk // Purpose : SLOT. Called when state of "Apply to all" check box changed. -// Activate/deactivate selection +// Activate/deactivate selection //======================================================================= void SMESHGUI_MultiEditDlg::onToAllChk() { bool isChecked = myToAllChk->isChecked(); - if ( isChecked ) + if (isChecked) myListBox->clear(); myIds.Clear(); emit ListContensChanged(); - + updateButtons(); setSelectionMode(); - - if ( myActor ) - mySelection->AddIObject( myActor->getIO(), true ); } - //======================================================================= // name : SMESHGUI_MultiEditDlg::setSelectionMode // Purpose : Set selection mode @@ -844,60 +828,56 @@ void SMESHGUI_MultiEditDlg::onToAllChk() void SMESHGUI_MultiEditDlg::setSelectionMode() { SMESH::RemoveFilters(); - - mySelection->ClearIObjects(); - mySelection->ClearFilters(); - - if ( mySubmeshChk->isChecked() ) { - QAD_Application::getDesktop()->SetSelectionMode( ActorSelection, true ); - mySelection->AddFilter( mySubmeshFilter ); + + mySelectionMgr->clearSelected(); + mySelectionMgr->clearFilters(); + + if (mySubmeshChk->isChecked()) { + myViewWindow->SetSelectionMode(ActorSelection); + mySelectionMgr->installFilter(new SMESH_TypeFilter(SUBMESH)); } - else if ( myGroupChk->isChecked() ) { - QAD_Application::getDesktop()->SetSelectionMode( ActorSelection, true ); - mySelection->AddFilter( myGroupFilter ); + else if (myGroupChk->isChecked()) { + myViewWindow->SetSelectionMode(ActorSelection); + mySelectionMgr->installFilter(new SMESH_TypeFilter(GROUP)); } - if ( entityType() ) { - QAD_Application::getDesktop()->SetSelectionMode( VolumeSelection, true ); - SMESH::SetFilter( new SMESHGUI_VolumesFilter() ); - } - else { - QAD_Application::getDesktop()->SetSelectionMode( FaceSelection, true ); - if ( myFilterType == SMESHGUI_TriaFilter ) - SMESH::SetFilter( new SMESHGUI_TriangleFilter() ); - else if ( myFilterType == SMESHGUI_QuadFilter ) - SMESH::SetFilter( new SMESHGUI_QuadrangleFilter() ); + + if (entityType()) { + myViewWindow->SetSelectionMode(VolumeSelection); + SMESH::SetFilter(new SMESHGUI_VolumesFilter()); + } else { + myViewWindow->SetSelectionMode(FaceSelection); + if (myFilterType == SMESHGUI_TriaFilter) + SMESH::SetFilter(new SMESHGUI_TriangleFilter()); + else if (myFilterType == SMESHGUI_QuadFilter) + SMESH::SetFilter(new SMESHGUI_QuadrangleFilter()); else - SMESH::SetFilter( new SMESHGUI_FacesFilter() ); + SMESH::SetFilter(new SMESHGUI_FacesFilter()); } } //======================================================================= // name : SMESHGUI_MultiEditDlg::onApply -// Purpose : SLOT. Called when "Apply" button clicked. +// Purpose : SLOT. Called when "Apply" button clicked. //======================================================================= bool SMESHGUI_MultiEditDlg::onApply() { - if ( SMESHGUI::GetSMESHGUI()->ActiveStudyLocked() ) + if (mySMESHGUI->isActiveStudyLocked()) return false; - if ( !isValid( true ) ) + if (!isValid(true)) return false; SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor(); - if ( aMeshEditor->_is_nil() ) + if (aMeshEditor->_is_nil()) return false; myBusy = true; SMESH::long_array_var anIds = getIds(); - bool aResult = process( aMeshEditor, anIds.inout() ); - if ( aResult ) - { - if ( myActor ) - { - mySelection->ClearIObjects(); + bool aResult = process(aMeshEditor, anIds.inout()); + if (aResult) { + if (myActor) { SMESH::UpdateView(); - mySelection->AddIObject( myActor->getIO(), false ); } myListBox->clear(); @@ -913,21 +893,21 @@ bool SMESHGUI_MultiEditDlg::onApply() //======================================================================= // name : SMESHGUI_MultiEditDlg::on3d2dChanged -// Purpose : +// Purpose : //======================================================================= -void SMESHGUI_MultiEditDlg::on3d2dChanged(int type) +void SMESHGUI_MultiEditDlg::on3d2dChanged (int type) { - if ( myEntityType != type ) { + if (myEntityType != type) { myEntityType = type; - + myListBox->clear(); myIds.Clear(); emit ListContensChanged(); - - if ( type ) + + if (type) myFilterType = SMESHGUI_VolumeFilter; - else + else myFilterType = SMESHGUI_FaceFilter; updateButtons(); @@ -937,80 +917,78 @@ void SMESHGUI_MultiEditDlg::on3d2dChanged(int type) //======================================================================= // name : SMESHGUI_MultiEditDlg::entityType -// Purpose : +// Purpose : //======================================================================= - -int SMESHGUI_MultiEditDlg::entityType() +int SMESHGUI_MultiEditDlg::entityType() { return myEntityType; } /* - Class : SMESHGUI_ChangeOrientationDlg - Description : Modification of orientation of faces -*/ + * Class : SMESHGUI_ChangeOrientationDlg + * Description : Modification of orientation of faces + */ -SMESHGUI_ChangeOrientationDlg::SMESHGUI_ChangeOrientationDlg( QWidget* theParent, - SALOME_Selection* theSelection, - const char* theName ) -: SMESHGUI_MultiEditDlg( theParent, theSelection, SMESHGUI_FaceFilter, true, theName ) +SMESHGUI_ChangeOrientationDlg +::SMESHGUI_ChangeOrientationDlg(SMESHGUI* theModule, + const char* theName): + SMESHGUI_MultiEditDlg(theModule, SMESHGUI_FaceFilter, true, theName) { - setCaption( tr( "CAPTION" ) ); + setCaption(tr("CAPTION")); } SMESHGUI_ChangeOrientationDlg::~SMESHGUI_ChangeOrientationDlg() { } -bool SMESHGUI_ChangeOrientationDlg::process( SMESH::SMESH_MeshEditor_ptr theEditor, - const SMESH::long_array& theIds ) +bool SMESHGUI_ChangeOrientationDlg::process (SMESH::SMESH_MeshEditor_ptr theEditor, + const SMESH::long_array& theIds) { - return theEditor->Reorient( theIds ); + return theEditor->Reorient(theIds); } -/* - Class : SMESHGUI_UnionOfTrianglesDlg - Description : Construction of quadrangles by automatic association of triangles -*/ +/*! + * Class : SMESHGUI_UnionOfTrianglesDlg + * Description : Construction of quadrangles by automatic association of triangles + */ -SMESHGUI_UnionOfTrianglesDlg::SMESHGUI_UnionOfTrianglesDlg( QWidget* theParent, - SALOME_Selection* theSelection, - const char* theName ) -: SMESHGUI_MultiEditDlg( theParent, theSelection, SMESHGUI_TriaFilter, false, theName ) +SMESHGUI_UnionOfTrianglesDlg +::SMESHGUI_UnionOfTrianglesDlg(SMESHGUI* theModule, + const char* theName): + SMESHGUI_MultiEditDlg(theModule, SMESHGUI_TriaFilter, false, theName) { - setCaption( tr( "CAPTION" ) ); + setCaption(tr("CAPTION")); } SMESHGUI_UnionOfTrianglesDlg::~SMESHGUI_UnionOfTrianglesDlg() { } -bool SMESHGUI_UnionOfTrianglesDlg::process( SMESH::SMESH_MeshEditor_ptr theEditor, - const SMESH::long_array& theIds ) +bool SMESHGUI_UnionOfTrianglesDlg::process (SMESH::SMESH_MeshEditor_ptr theEditor, + const SMESH::long_array& theIds) { - return theEditor->TriToQuad(theIds, SMESH::NumericalFunctor::_nil(), 1. ); + return theEditor->TriToQuad(theIds, SMESH::NumericalFunctor::_nil(), 1.); } -/* - Class : SMESHGUI_CuttingOfQuadsDlg - Description : Construction of quadrangles by automatic association of triangles -*/ +/*! + * Class : SMESHGUI_CuttingOfQuadsDlg + * Description : Construction of quadrangles by automatic association of triangles + */ -SMESHGUI_CuttingOfQuadsDlg::SMESHGUI_CuttingOfQuadsDlg( QWidget* theParent, - SALOME_Selection* theSelection, - const char* theName ) -: SMESHGUI_MultiEditDlg( theParent, theSelection, SMESHGUI_QuadFilter, false, theName ) +SMESHGUI_CuttingOfQuadsDlg +::SMESHGUI_CuttingOfQuadsDlg(SMESHGUI* theModule, + const char* theName): + SMESHGUI_MultiEditDlg(theModule, SMESHGUI_QuadFilter, false, theName) { - - setCaption( tr( "CAPTION" ) ); + setCaption(tr("CAPTION")); myPreviewActor = 0; - myUseDiagChk = new QCheckBox( tr( "USE_DIAGONAL_2_4" ), mySelGrp ); - myPreviewChk = new QCheckBox( tr( "PREVIEW" ), mySelGrp ); + myUseDiagChk = new QCheckBox (tr("USE_DIAGONAL_2_4"), mySelGrp); + myPreviewChk = new QCheckBox (tr("PREVIEW"), mySelGrp); - connect( myPreviewChk, SIGNAL( stateChanged( int ) ), this, SLOT( onPreviewChk() ) ); - connect( myUseDiagChk, SIGNAL( stateChanged( int ) ), this, SLOT( onPreviewChk() ) ); - connect( this, SIGNAL( ListContensChanged() ), this, SLOT( onPreviewChk() ) ); + connect(myPreviewChk, SIGNAL(stateChanged(int)), this, SLOT(onPreviewChk())); + connect(myUseDiagChk, SIGNAL(stateChanged(int)), this, SLOT(onPreviewChk())); + connect(this, SIGNAL(ListContensChanged()), this, SLOT(onPreviewChk())); } SMESHGUI_CuttingOfQuadsDlg::~SMESHGUI_CuttingOfQuadsDlg() @@ -1023,10 +1001,10 @@ void SMESHGUI_CuttingOfQuadsDlg::onClose() SMESHGUI_MultiEditDlg::onClose(); } -bool SMESHGUI_CuttingOfQuadsDlg::process( SMESH::SMESH_MeshEditor_ptr theEditor, - const SMESH::long_array& theIds ) +bool SMESHGUI_CuttingOfQuadsDlg::process (SMESH::SMESH_MeshEditor_ptr theEditor, + const SMESH::long_array& theIds) { - return theEditor->SplitQuad( theIds, !myUseDiagChk->isChecked() ); + return theEditor->SplitQuad(theIds, !myUseDiagChk->isChecked()); } void SMESHGUI_CuttingOfQuadsDlg::onPreviewChk() @@ -1036,11 +1014,10 @@ void SMESHGUI_CuttingOfQuadsDlg::onPreviewChk() void SMESHGUI_CuttingOfQuadsDlg::erasePreview() { - if ( myPreviewActor == 0 ) + if (myPreviewActor == 0) return; - - if ( VTKViewer_ViewFrame* vf = SMESH::GetCurrentVtkView() ) - { + + if (SVTK_ViewWindow* vf = SMESH::GetCurrentVtkView()) { vf->RemoveActor(myPreviewActor); vf->Repaint(); } @@ -1050,124 +1027,124 @@ void SMESHGUI_CuttingOfQuadsDlg::erasePreview() void SMESHGUI_CuttingOfQuadsDlg::displayPreview() { - if ( myActor == 0 ) + if (myActor == 0) return; - if ( myPreviewActor != 0 ) + if (myPreviewActor != 0) erasePreview(); // get Ids of elements SMESH::long_array_var anElemIds = getIds(); - if ( getIds()->length() == 0 ) + if (getIds()->length() == 0) return; SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh(); - if ( aMesh == 0 ) + if (aMesh == 0) return; bool isDiag24 = myUseDiagChk->isChecked(); //Create grid vtkUnstructuredGrid* aGrid = vtkUnstructuredGrid::New(); - + vtkIdType aNbCells = anElemIds->length() * 2; vtkIdType aCellsSize = 4 * aNbCells; vtkCellArray* aConnectivity = vtkCellArray::New(); - aConnectivity->Allocate( aCellsSize, 0 ); + aConnectivity->Allocate(aCellsSize, 0); vtkPoints* aPoints = vtkPoints::New(); - aPoints->SetNumberOfPoints( anElemIds->length() * 4 ); - + aPoints->SetNumberOfPoints(anElemIds->length() * 4); + vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New(); - aCellTypesArray->SetNumberOfComponents( 1 ); - aCellTypesArray->Allocate( aNbCells * aCellTypesArray->GetNumberOfComponents() ); + aCellTypesArray->SetNumberOfComponents(1); + aCellTypesArray->Allocate(aNbCells * aCellTypesArray->GetNumberOfComponents()); vtkIdList *anIdList = vtkIdList::New(); - anIdList->SetNumberOfIds( 3 ); + anIdList->SetNumberOfIds(3); TColStd_DataMapOfIntegerInteger anIdToVtk; int aNodes[ 4 ]; int nbPoints = -1; - for ( int i = 0, n = anElemIds->length(); i < n; i++ ) + for (int i = 0, n = anElemIds->length(); i < n; i++) { - const SMDS_MeshElement* anElem = aMesh->FindElement( anElemIds[ i ] ); - if ( anElem == 0 || anElem->NbNodes() != 4 ) + const SMDS_MeshElement* anElem = aMesh->FindElement(anElemIds[ i ]); + if (anElem == 0 || anElem->NbNodes() != 4) continue; - + SMDS_ElemIteratorPtr anIter = anElem->nodesIterator(); int k = 0; - while( anIter->more() ) - if ( const SMDS_MeshNode* aNode = (SMDS_MeshNode*)anIter->next() ) + while(anIter->more()) + if (const SMDS_MeshNode* aNode = (SMDS_MeshNode*)anIter->next()) { - if ( !anIdToVtk.IsBound( aNode->GetID() ) ) + if (!anIdToVtk.IsBound(aNode->GetID())) { - aPoints->SetPoint( ++nbPoints, aNode->X(), aNode->Y(), aNode->Z() ); - anIdToVtk.Bind( aNode->GetID(), nbPoints ); + aPoints->SetPoint(++nbPoints, aNode->X(), aNode->Y(), aNode->Z()); + anIdToVtk.Bind(aNode->GetID(), nbPoints); } - + aNodes[ k++ ] = aNode->GetID(); } - if ( k != 4 ) + if (k != 4) continue; - if ( !isDiag24 ) + if (!isDiag24) { - anIdList->SetId( 0, anIdToVtk( aNodes[ 0 ] ) ); - anIdList->SetId( 1, anIdToVtk( aNodes[ 1 ] ) ); - anIdList->SetId( 2, anIdToVtk( aNodes[ 2 ] ) ); - aConnectivity->InsertNextCell( anIdList ); - aCellTypesArray->InsertNextValue( VTK_TRIANGLE ); + anIdList->SetId(0, anIdToVtk(aNodes[ 0 ])); + anIdList->SetId(1, anIdToVtk(aNodes[ 1 ])); + anIdList->SetId(2, anIdToVtk(aNodes[ 2 ])); + aConnectivity->InsertNextCell(anIdList); + aCellTypesArray->InsertNextValue(VTK_TRIANGLE); - anIdList->SetId( 0, anIdToVtk( aNodes[ 2 ] ) ); - anIdList->SetId( 1, anIdToVtk( aNodes[ 3 ] ) ); - anIdList->SetId( 2, anIdToVtk( aNodes[ 0 ] ) ); - aConnectivity->InsertNextCell( anIdList ); - aCellTypesArray->InsertNextValue( VTK_TRIANGLE ); + anIdList->SetId(0, anIdToVtk(aNodes[ 2 ])); + anIdList->SetId(1, anIdToVtk(aNodes[ 3 ])); + anIdList->SetId(2, anIdToVtk(aNodes[ 0 ])); + aConnectivity->InsertNextCell(anIdList); + aCellTypesArray->InsertNextValue(VTK_TRIANGLE); } else { - anIdList->SetId( 0, anIdToVtk( aNodes[ 1 ] ) ); - anIdList->SetId( 1, anIdToVtk( aNodes[ 2 ] ) ); - anIdList->SetId( 2, anIdToVtk( aNodes[ 3 ] ) ); - aConnectivity->InsertNextCell( anIdList ); - aCellTypesArray->InsertNextValue( VTK_TRIANGLE ); + anIdList->SetId(0, anIdToVtk(aNodes[ 1 ])); + anIdList->SetId(1, anIdToVtk(aNodes[ 2 ])); + anIdList->SetId(2, anIdToVtk(aNodes[ 3 ])); + aConnectivity->InsertNextCell(anIdList); + aCellTypesArray->InsertNextValue(VTK_TRIANGLE); - anIdList->SetId( 0, anIdToVtk( aNodes[ 3 ] ) ); - anIdList->SetId( 1, anIdToVtk( aNodes[ 0 ] ) ); - anIdList->SetId( 2, anIdToVtk( aNodes[ 1 ] ) ); - aConnectivity->InsertNextCell( anIdList ); - aCellTypesArray->InsertNextValue( VTK_TRIANGLE ); + anIdList->SetId(0, anIdToVtk(aNodes[ 3 ])); + anIdList->SetId(1, anIdToVtk(aNodes[ 0 ])); + anIdList->SetId(2, anIdToVtk(aNodes[ 1 ])); + aConnectivity->InsertNextCell(anIdList); + aCellTypesArray->InsertNextValue(VTK_TRIANGLE); } } vtkIntArray* aCellLocationsArray = vtkIntArray::New(); - aCellLocationsArray->SetNumberOfComponents( 1 ); - aCellLocationsArray->SetNumberOfTuples( aNbCells ); + aCellLocationsArray->SetNumberOfComponents(1); + aCellLocationsArray->SetNumberOfTuples(aNbCells); aConnectivity->InitTraversal(); - for( vtkIdType idType = 0, *pts, npts; aConnectivity->GetNextCell( npts, pts ); idType++ ) - aCellLocationsArray->SetValue( idType, aConnectivity->GetTraversalLocation( npts ) ); + for(vtkIdType idType = 0, *pts, npts; aConnectivity->GetNextCell(npts, pts); idType++) + aCellLocationsArray->SetValue(idType, aConnectivity->GetTraversalLocation(npts)); - aGrid->SetPoints( aPoints ); - aGrid->SetCells( aCellTypesArray, aCellLocationsArray,aConnectivity ); + aGrid->SetPoints(aPoints); + aGrid->SetCells(aCellTypesArray, aCellLocationsArray,aConnectivity); // Create and display actor vtkDataSetMapper* aMapper = vtkDataSetMapper::New(); - aMapper->SetInput( aGrid ); - + aMapper->SetInput(aGrid); + myPreviewActor = SALOME_Actor::New(); myPreviewActor->PickableOff(); - myPreviewActor->SetMapper( aMapper ); + myPreviewActor->SetMapper(aMapper); vtkProperty* aProp = vtkProperty::New(); aProp->SetRepresentationToWireframe(); - aProp->SetColor( 250, 0, 250 ); - aProp->SetLineWidth( myActor->GetLineWidth() + 1 ); - myPreviewActor->SetProperty( aProp ); + aProp->SetColor(250, 0, 250); + aProp->SetLineWidth(myActor->GetLineWidth() + 1); + myPreviewActor->SetProperty(aProp); - SMESH::GetCurrentVtkView()->AddActor( myPreviewActor ); + SMESH::GetCurrentVtkView()->AddActor(myPreviewActor); SMESH::GetCurrentVtkView()->Repaint(); aProp->Delete(); @@ -1179,26 +1156,3 @@ void SMESHGUI_CuttingOfQuadsDlg::displayPreview() aCellTypesArray->Delete(); aCellLocationsArray->Delete(); } - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/SMESHGUI/SMESHGUI_MultiEditDlg.h b/src/SMESHGUI/SMESHGUI_MultiEditDlg.h index 48a59a962..3a5558fe1 100755 --- a/src/SMESHGUI/SMESHGUI_MultiEditDlg.h +++ b/src/SMESHGUI/SMESHGUI_MultiEditDlg.h @@ -28,7 +28,9 @@ #define SMESHGUI_MultiEditDlg_H #include -#include "SMESH_TypeFilter.hxx" + +#include "SUIT_SelectionFilter.h" + #include #include @@ -42,12 +44,18 @@ class QFrame; class QLineEdit; class SMESHGUI_SpinBox; class QPushButton; -class SALOME_Selection; -class SMESH_Actor; -class SALOME_Actor; class QButtonGroup; class QObject; +class SMESH_Actor; +class SALOME_Actor; +class SalomeApp_SelectionMgr; + +class SMESHGUI; +class SMESH_Actor; +class SVTK_Selector; +class SVTK_ViewWindow; + /* Class : SMESHGUI_MultiEditDlg Description : Base class for dialogs of diagonal inversion and @@ -59,14 +67,13 @@ class SMESHGUI_MultiEditDlg : public QDialog Q_OBJECT public: - SMESHGUI_MultiEditDlg( QWidget*, - SALOME_Selection*, - const int, - const bool = false, - const char* = 0 ); + SMESHGUI_MultiEditDlg(SMESHGUI* theModule, + const int, + const bool = false, + const char* = 0 ); virtual ~SMESHGUI_MultiEditDlg(); - void Init( SALOME_Selection* ) ; + void Init() ; bool eventFilter( QObject* object, QEvent* event ); @@ -113,10 +120,14 @@ protected: QPushButton* myOkBtn; QPushButton* myApplyBtn; QPushButton* myCloseBtn; - SALOME_Selection* mySelection; - SMESH::SMESH_Mesh_var myMesh; SMESH_Actor* myActor; + SMESH::SMESH_Mesh_var myMesh; + SalomeApp_SelectionMgr* mySelectionMgr; + SVTK_ViewWindow* myViewWindow; + SVTK_Selector* mySelector; + SMESHGUI* mySMESHGUI; + QGroupBox* mySelGrp; QListBox* myListBox; @@ -139,8 +150,6 @@ protected: SMESHGUI_FilterDlg* myFilterDlg; TColStd_MapOfInteger myIds; int myFilterType; - Handle(SMESH_TypeFilter) mySubmeshFilter; - Handle(SMESH_TypeFilter) myGroupFilter; bool myBusy; int myEntityType; }; @@ -154,9 +163,8 @@ class SMESHGUI_ChangeOrientationDlg : public SMESHGUI_MultiEditDlg Q_OBJECT public: - SMESHGUI_ChangeOrientationDlg( QWidget*, - SALOME_Selection*, - const char* = 0 ); + SMESHGUI_ChangeOrientationDlg(SMESHGUI* theModule, + const char* = 0); virtual ~SMESHGUI_ChangeOrientationDlg(); protected: @@ -173,9 +181,8 @@ class SMESHGUI_UnionOfTrianglesDlg : public SMESHGUI_MultiEditDlg Q_OBJECT public: - SMESHGUI_UnionOfTrianglesDlg( QWidget*, - SALOME_Selection*, - const char* = 0 ); + SMESHGUI_UnionOfTrianglesDlg(SMESHGUI* theModule, + const char* = 0); virtual ~SMESHGUI_UnionOfTrianglesDlg(); protected: @@ -192,9 +199,8 @@ class SMESHGUI_CuttingOfQuadsDlg : public SMESHGUI_MultiEditDlg Q_OBJECT public: - SMESHGUI_CuttingOfQuadsDlg( QWidget*, - SALOME_Selection*, - const char* = 0 ); + SMESHGUI_CuttingOfQuadsDlg(SMESHGUI* theModule, + const char* = 0); virtual ~SMESHGUI_CuttingOfQuadsDlg(); protected: diff --git a/src/SMESHGUI/SMESHGUI_NodesDlg.cxx b/src/SMESHGUI/SMESHGUI_NodesDlg.cxx index 67b0daa23..a3f0966ff 100644 --- a/src/SMESHGUI/SMESHGUI_NodesDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_NodesDlg.cxx @@ -1,23 +1,23 @@ // SMESH SMESHGUI : GUI for SMESH component // // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org // // // @@ -29,28 +29,35 @@ #include "SMESHGUI_NodesDlg.h" #include "SMESHGUI.h" +#include "SMESHGUI_SpinBox.h" #include "SMESHGUI_Utils.h" +#include "SMESHGUI_VTKUtils.h" #include "SMESHGUI_MeshUtils.h" -#include "SMESHGUI_VTKUtils.h" -#include "SMESH_ActorUtils.h" - -#include "VTKViewer_ViewFrame.h" -#include "SALOME_Actor.h" - -#include "SMESHGUI_SpinBox.h" - -#include "QAD_Application.h" -#include "QAD_Desktop.h" -#include "QAD_WaitCursor.h" -#include "QAD_MessageBox.h" - #include "SMESH_Actor.h" +#include "SMESH_ActorUtils.h" #include "SMESH_ObjectDef.h" #include "SMDS_Mesh.hxx" #include "SMDS_MeshNode.hxx" +#include "SUIT_Session.h" +#include "SUIT_OverrideCursor.h" +#include "SUIT_ViewWindow.h" +#include "SUIT_ViewManager.h" +#include "SUIT_MessageBox.h" + +#include "SalomeApp_Study.h" +#include "SalomeApp_Application.h" + +#include "SVTK_ViewWindow.h" + +#include "SALOME_Actor.h" +#include "SALOME_ListIO.hxx" +#include "SVTK_Selection.h" + +#include "utilities.h" + // VTK Includes #include #include @@ -79,100 +86,99 @@ #include #include -#include "utilities.h" - using namespace std; -namespace SMESH{ +namespace SMESH { - void AddNode(SMESH::SMESH_Mesh_ptr theMesh, float x, float y, float z){ - QAD_WaitCursor wc; - try{ - SALOMEDS::SObject_var aSobj = SMESH::FindSObject(theMesh); - CORBA::String_var anEntry = aSobj->GetID(); + void AddNode (SMESH::SMESH_Mesh_ptr theMesh, float x, float y, float z) + { + SUIT_OverrideCursor wc; + try { + _PTR(SObject) aSobj = SMESH::FindSObject(theMesh); SMESH::SMESH_MeshEditor_var aMeshEditor = theMesh->GetMeshEditor(); aMeshEditor->AddNode(x,y,z); - SALOMEDS::Study_var aStudy = GetActiveStudyDocument(); + _PTR(Study) aStudy = GetActiveStudyDocument(); CORBA::Long anId = aStudy->StudyId(); - if(TVisualObjPtr aVisualObj = SMESH::GetVisualObj(anId,anEntry.in())){ + if (TVisualObjPtr aVisualObj = SMESH::GetVisualObj(anId, aSobj->GetID().c_str())) { aVisualObj->Update(true); } - }catch(SALOME::SALOME_Exception& exc) { - INFOS("Follow exception was cought:\n\t"<getActiveStudyFrame()), - myViewFrame(GetVtkViewFrame(theStudy->getActiveStudyFrame())) + TNodeSimulation (SalomeApp_Application* theApplication) { + myApplication = theApplication; + SUIT_ViewManager* mgr = theApplication->activeViewManager(); + if (!mgr) return; + myViewWindow = mgr->getActiveView(); + myVTKViewWindow = GetVtkViewWindow(myViewWindow); + vtkUnstructuredGrid* aGrid = vtkUnstructuredGrid::New(); - + // Create points myPoints = vtkPoints::New(); - myPoints->SetNumberOfPoints( 1 ); + myPoints->SetNumberOfPoints(1); myPoints->SetPoint(0,0.0,0.0,0.0); - + // Create cells vtkIdList *anIdList = vtkIdList::New(); - anIdList->SetNumberOfIds( 1 ); + anIdList->SetNumberOfIds(1); vtkCellArray *aCells = vtkCellArray::New(); - aCells->Allocate( 2, 0 ); + aCells->Allocate(2, 0); vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New(); - aCellTypesArray->SetNumberOfComponents( 1 ); - aCellTypesArray->Allocate( 1 ); - - anIdList->SetId( 0, 0 ); - aCells->InsertNextCell( anIdList ); - aCellTypesArray->InsertNextValue( VTK_VERTEX ); - + aCellTypesArray->SetNumberOfComponents(1); + aCellTypesArray->Allocate(1); + + anIdList->SetId(0, 0); + aCells->InsertNextCell(anIdList); + aCellTypesArray->InsertNextValue(VTK_VERTEX); + vtkIntArray* aCellLocationsArray = vtkIntArray::New(); - aCellLocationsArray->SetNumberOfComponents( 1 ); - aCellLocationsArray->SetNumberOfTuples( 1 ); - + aCellLocationsArray->SetNumberOfComponents(1); + aCellLocationsArray->SetNumberOfTuples(1); + aCells->InitTraversal(); vtkIdType npts; - aCellLocationsArray->SetValue( 0, aCells->GetTraversalLocation( npts ) ); - - aGrid->SetCells( aCellTypesArray, aCellLocationsArray, aCells ); + aCellLocationsArray->SetValue(0, aCells->GetTraversalLocation(npts)); - aGrid->SetPoints( myPoints ); - aGrid->SetCells( aCellTypesArray, aCellLocationsArray,aCells ); + aGrid->SetCells(aCellTypesArray, aCellLocationsArray, aCells); + + aGrid->SetPoints(myPoints); + aGrid->SetCells(aCellTypesArray, aCellLocationsArray,aCells); aCellLocationsArray->Delete(); aCellTypesArray->Delete(); aCells->Delete(); - anIdList->Delete(); + anIdList->Delete(); // Create and display actor myMapper = vtkDataSetMapper::New(); - myMapper->SetInput( aGrid ); + myMapper->SetInput(aGrid); aGrid->Delete(); myPreviewActor = SALOME_Actor::New(); myPreviewActor->SetInfinitive(true); myPreviewActor->VisibilityOff(); myPreviewActor->PickableOff(); - myPreviewActor->SetMapper( myMapper ); + myPreviewActor->SetMapper(myMapper); vtkProperty* aProp = vtkProperty::New(); aProp->SetRepresentationToPoints(); @@ -186,30 +192,29 @@ namespace SMESH{ float aPointSize = GetFloat("SMESH:SettingsNodesSize",3); aProp->SetPointSize(aPointSize); - myPreviewActor->SetProperty( aProp ); + myPreviewActor->SetProperty(aProp); aProp->Delete(); - myViewFrame->AddActor( myPreviewActor ); - + myVTKViewWindow->AddActor(myPreviewActor); } - - void SetPosition(float x, float y, float z){ + void SetPosition (float x, float y, float z) + { myPoints->SetPoint(0,x,y,z); myPoints->Modified(); SetVisibility(true); } - - void SetVisibility(bool theVisibility){ + void SetVisibility (bool theVisibility) + { myPreviewActor->SetVisibility(theVisibility); RepaintCurrentView(); } - - ~TNodeSimulation(){ - if(FindVtkViewFrame(myStudy,myStudyFrame)){ - myViewFrame->RemoveActor(myPreviewActor); + ~TNodeSimulation() + { + if (FindVtkViewWindow(myApplication->activeViewManager(), myViewWindow)) { + myVTKViewWindow->RemoveActor(myPreviewActor); } myPreviewActor->Delete(); @@ -218,121 +223,119 @@ namespace SMESH{ myPoints->Delete(); } - }; - } - //================================================================================= // class : SMESHGUI_NodesDlg() -// purpose : +// purpose : //================================================================================= -SMESHGUI_NodesDlg::SMESHGUI_NodesDlg( QWidget* parent, +SMESHGUI_NodesDlg::SMESHGUI_NodesDlg (QWidget* parent, const char* name, - SALOME_Selection* Sel, + SalomeApp_SelectionMgr* Sel, bool modal, - WFlags fl ) - : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | - Qt::WDestructiveClose) + WFlags fl) + : QDialog(parent, name, modal, WStyle_Customize | WStyle_NormalBorder | + WStyle_Title | WStyle_SysMenu | Qt::WDestructiveClose) { - mySimulation = new SMESH::TNodeSimulation(SMESH::GetActiveStudy()); + SalomeApp_Application* anApp = dynamic_cast + (SUIT_Session::session()->activeApplication()); + mySimulation = new SMESH::TNodeSimulation (anApp); - QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_DLG_NODE"))); - if ( !name ) - setName( "SMESHGUI_NodesDlg" ); - resize( 303, 185 ); - setCaption( tr( "MESH_NODE_TITLE" ) ); - setSizeGripEnabled( TRUE ); - SMESHGUI_NodesDlgLayout = new QGridLayout( this ); - SMESHGUI_NodesDlgLayout->setSpacing( 6 ); - SMESHGUI_NodesDlgLayout->setMargin( 11 ); + QPixmap image0 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_DLG_NODE"))); + if (!name) + setName("SMESHGUI_NodesDlg"); + resize(303, 185); + setCaption(tr("MESH_NODE_TITLE")); + setSizeGripEnabled(TRUE); + SMESHGUI_NodesDlgLayout = new QGridLayout(this); + SMESHGUI_NodesDlgLayout->setSpacing(6); + SMESHGUI_NodesDlgLayout->setMargin(11); /***************************************************************/ - GroupButtons = new QGroupBox( this, "GroupButtons" ); - GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); - GroupButtons->setTitle( tr( "" ) ); - GroupButtons->setColumnLayout(0, Qt::Vertical ); - GroupButtons->layout()->setSpacing( 0 ); - GroupButtons->layout()->setMargin( 0 ); - GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); - GroupButtonsLayout->setAlignment( Qt::AlignTop ); - GroupButtonsLayout->setSpacing( 6 ); - GroupButtonsLayout->setMargin( 11 ); - buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); - buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) ); - buttonCancel->setAutoDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonCancel, 0, 3 ); - buttonApply = new QPushButton( GroupButtons, "buttonApply" ); - buttonApply->setText( tr( "SMESH_BUT_APPLY" ) ); - buttonApply->setAutoDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); - QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); - GroupButtonsLayout->addItem( spacer_9, 0, 2 ); - buttonOk = new QPushButton( GroupButtons, "buttonOk" ); - buttonOk->setText( tr( "SMESH_BUT_OK" ) ); - buttonOk->setAutoDefault( TRUE ); - buttonOk->setDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); - SMESHGUI_NodesDlgLayout->addWidget( GroupButtons, 2, 0 ); + GroupButtons = new QGroupBox(this, "GroupButtons"); + GroupButtons->setGeometry(QRect(10, 10, 281, 48)); + GroupButtons->setTitle(tr("" )); + GroupButtons->setColumnLayout(0, Qt::Vertical); + GroupButtons->layout()->setSpacing(0); + GroupButtons->layout()->setMargin(0); + GroupButtonsLayout = new QGridLayout(GroupButtons->layout()); + GroupButtonsLayout->setAlignment(Qt::AlignTop); + GroupButtonsLayout->setSpacing(6); + GroupButtonsLayout->setMargin(11); + buttonCancel = new QPushButton(GroupButtons, "buttonCancel"); + buttonCancel->setText(tr("SMESH_BUT_CLOSE" )); + buttonCancel->setAutoDefault(TRUE); + GroupButtonsLayout->addWidget(buttonCancel, 0, 3); + buttonApply = new QPushButton(GroupButtons, "buttonApply"); + buttonApply->setText(tr("SMESH_BUT_APPLY" )); + buttonApply->setAutoDefault(TRUE); + GroupButtonsLayout->addWidget(buttonApply, 0, 1); + QSpacerItem* spacer_9 = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); + GroupButtonsLayout->addItem(spacer_9, 0, 2); + buttonOk = new QPushButton(GroupButtons, "buttonOk"); + buttonOk->setText(tr("SMESH_BUT_OK" )); + buttonOk->setAutoDefault(TRUE); + buttonOk->setDefault(TRUE); + GroupButtonsLayout->addWidget(buttonOk, 0, 0); + SMESHGUI_NodesDlgLayout->addWidget(GroupButtons, 2, 0); /***************************************************************/ - GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); - GroupConstructors->setTitle( tr( "MESH_NODE" ) ); - GroupConstructors->setExclusive( TRUE ); - GroupConstructors->setColumnLayout(0, Qt::Vertical ); - GroupConstructors->layout()->setSpacing( 0 ); - GroupConstructors->layout()->setMargin( 0 ); - GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() ); - GroupConstructorsLayout->setAlignment( Qt::AlignTop ); - GroupConstructorsLayout->setSpacing( 6 ); - GroupConstructorsLayout->setMargin( 11 ); - Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" ); - Constructor1->setText( tr( "" ) ); - Constructor1->setPixmap( image0 ); - Constructor1->setChecked( TRUE ); - GroupConstructorsLayout->addWidget( Constructor1, 0, 0 ); - QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); - GroupConstructorsLayout->addItem( spacer_2, 0, 1 ); - SMESHGUI_NodesDlgLayout->addWidget( GroupConstructors, 0, 0 ); + GroupConstructors = new QButtonGroup(this, "GroupConstructors"); + GroupConstructors->setTitle(tr("MESH_NODE" )); + GroupConstructors->setExclusive(TRUE); + GroupConstructors->setColumnLayout(0, Qt::Vertical); + GroupConstructors->layout()->setSpacing(0); + GroupConstructors->layout()->setMargin(0); + GroupConstructorsLayout = new QGridLayout(GroupConstructors->layout()); + GroupConstructorsLayout->setAlignment(Qt::AlignTop); + GroupConstructorsLayout->setSpacing(6); + GroupConstructorsLayout->setMargin(11); + Constructor1 = new QRadioButton(GroupConstructors, "Constructor1"); + Constructor1->setText(tr("" )); + Constructor1->setPixmap(image0); + Constructor1->setChecked(TRUE); + GroupConstructorsLayout->addWidget(Constructor1, 0, 0); + QSpacerItem* spacer_2 = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); + GroupConstructorsLayout->addItem(spacer_2, 0, 1); + SMESHGUI_NodesDlgLayout->addWidget(GroupConstructors, 0, 0); /***************************************************************/ - GroupCoordinates = new QGroupBox( this, "GroupCoordinates" ); - GroupCoordinates->setTitle( tr( "SMESH_COORDINATES" ) ); - GroupCoordinates->setColumnLayout(0, Qt::Vertical ); - GroupCoordinates->layout()->setSpacing( 0 ); - GroupCoordinates->layout()->setMargin( 0 ); - GroupCoordinatesLayout = new QGridLayout( GroupCoordinates->layout() ); - GroupCoordinatesLayout->setAlignment( Qt::AlignTop ); - GroupCoordinatesLayout->setSpacing( 6 ); - GroupCoordinatesLayout->setMargin( 11 ); - TextLabel_X = new QLabel( GroupCoordinates, "TextLabel_X" ); - TextLabel_X->setText( tr( "SMESH_X" ) ); - GroupCoordinatesLayout->addWidget( TextLabel_X, 0, 0 ); - TextLabel_Y = new QLabel( GroupCoordinates, "TextLabel_Y" ); - TextLabel_Y->setText( tr( "SMESH_Y" ) ); - GroupCoordinatesLayout->addWidget( TextLabel_Y, 0, 2 ); - - TextLabel_Z = new QLabel( GroupCoordinates, "TextLabel_Z" ); - TextLabel_Z->setText( tr( "SMESH_Z" ) ); - GroupCoordinatesLayout->addWidget( TextLabel_Z, 0, 4 ); - - SpinBox_X = new SMESHGUI_SpinBox( GroupCoordinates, "SpinBox_X" ) ; - GroupCoordinatesLayout->addWidget( SpinBox_X, 0, 1 ); + GroupCoordinates = new QGroupBox(this, "GroupCoordinates"); + GroupCoordinates->setTitle(tr("SMESH_COORDINATES" )); + GroupCoordinates->setColumnLayout(0, Qt::Vertical); + GroupCoordinates->layout()->setSpacing(0); + GroupCoordinates->layout()->setMargin(0); + GroupCoordinatesLayout = new QGridLayout(GroupCoordinates->layout()); + GroupCoordinatesLayout->setAlignment(Qt::AlignTop); + GroupCoordinatesLayout->setSpacing(6); + GroupCoordinatesLayout->setMargin(11); + TextLabel_X = new QLabel(GroupCoordinates, "TextLabel_X"); + TextLabel_X->setText(tr("SMESH_X" )); + GroupCoordinatesLayout->addWidget(TextLabel_X, 0, 0); + TextLabel_Y = new QLabel(GroupCoordinates, "TextLabel_Y"); + TextLabel_Y->setText(tr("SMESH_Y" )); + GroupCoordinatesLayout->addWidget(TextLabel_Y, 0, 2); - SpinBox_Y = new SMESHGUI_SpinBox( GroupCoordinates, "SpinBox_Y" ) ; - GroupCoordinatesLayout->addWidget( SpinBox_Y, 0, 3 ); - - SpinBox_Z = new SMESHGUI_SpinBox( GroupCoordinates, "SpinBox_Z" ) ; - GroupCoordinatesLayout->addWidget( SpinBox_Z, 0, 5 ); + TextLabel_Z = new QLabel(GroupCoordinates, "TextLabel_Z"); + TextLabel_Z->setText(tr("SMESH_Z" )); + GroupCoordinatesLayout->addWidget(TextLabel_Z, 0, 4); + + SpinBox_X = new SMESHGUI_SpinBox(GroupCoordinates, "SpinBox_X"); + GroupCoordinatesLayout->addWidget(SpinBox_X, 0, 1); + + SpinBox_Y = new SMESHGUI_SpinBox(GroupCoordinates, "SpinBox_Y"); + GroupCoordinatesLayout->addWidget(SpinBox_Y, 0, 3); + + SpinBox_Z = new SMESHGUI_SpinBox(GroupCoordinates, "SpinBox_Z"); + GroupCoordinatesLayout->addWidget(SpinBox_Z, 0, 5); + + SMESHGUI_NodesDlgLayout->addWidget(GroupCoordinates, 1, 0); - SMESHGUI_NodesDlgLayout->addWidget( GroupCoordinates, 1, 0 ); - /* Initialisation and display */ - Init(Sel) ; + Init(Sel); } - //======================================================================= // function : ~SMESHGUI_NodesDlg() // purpose : Destructor @@ -342,54 +345,57 @@ SMESHGUI_NodesDlg::~SMESHGUI_NodesDlg() delete mySimulation; } - //================================================================================= // function : Init() // purpose : //================================================================================= -void SMESHGUI_NodesDlg::Init(SALOME_Selection* Sel) +void SMESHGUI_NodesDlg::Init (SalomeApp_SelectionMgr* Sel) { /* Get setting of step value from file configuration */ - double step ; - // QString St = QAD_CONFIG->getSetting( "xxxxxxxxxxxxx" ) ; TODO - // step = St.toDouble() ; TODO - step = 25.0 ; - - /* min, max, step and decimals for spin boxes */ - SpinBox_X->RangeStepAndValidator( -999.999, +999.999, step, 3 ) ; - SpinBox_Y->RangeStepAndValidator( -999.999, +999.999, step, 3 ) ; - SpinBox_Z->RangeStepAndValidator( -999.999, +999.999, step, 3 ) ; - SpinBox_X->SetValue( 0.0 ) ; - SpinBox_Y->SetValue( 0.0 ) ; - SpinBox_Z->SetValue( 0.0 ) ; - - mySelection = Sel ; - myMeshGUI = SMESHGUI::GetSMESHGUI() ; - myMeshGUI->SetActiveDialogBox( (QDialog*)this ) ; - - /* signals and slots connections */ - connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); - connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ); - connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) ); - - connect( SpinBox_X, SIGNAL ( valueChanged(double) ), SLOT( ValueChangedInSpinBox(double) )) ; - connect( SpinBox_Y, SIGNAL ( valueChanged(double) ), SLOT( ValueChangedInSpinBox(double) )) ; - connect( SpinBox_Z, SIGNAL ( valueChanged(double) ), SLOT( ValueChangedInSpinBox(double) )) ; + double step; + // QString St = SUIT_CONFIG->getSetting("xxxxxxxxxxxxx"); TODO + // step = St.toDouble(); TODO + step = 25.0; - connect( mySelection, SIGNAL( currentSelectionChanged() ), SLOT( SelectionIntoArgument() )); - connect( myMeshGUI, SIGNAL ( SignalDeactivateActiveDialog() ), SLOT( DeactivateActiveDialog() )) ; + /* min, max, step and decimals for spin boxes */ + SpinBox_X->RangeStepAndValidator(-999.999, +999.999, step, 3); + SpinBox_Y->RangeStepAndValidator(-999.999, +999.999, step, 3); + SpinBox_Z->RangeStepAndValidator(-999.999, +999.999, step, 3); + SpinBox_X->SetValue(0.0); + SpinBox_Y->SetValue(0.0); + SpinBox_Z->SetValue(0.0); + + mySelectionMgr = Sel; + myMeshGUI = SMESHGUI::GetSMESHGUI(); + myMeshGUI->SetActiveDialogBox((QDialog*)this); + + /* signals and slots connections */ + connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel())); + connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); + + connect(SpinBox_X, SIGNAL (valueChanged(double)), SLOT(ValueChangedInSpinBox(double))); + connect(SpinBox_Y, SIGNAL (valueChanged(double)), SLOT(ValueChangedInSpinBox(double))); + connect(SpinBox_Z, SIGNAL (valueChanged(double)), SLOT(ValueChangedInSpinBox(double))); + + connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(SelectionIntoArgument())); + connect(myMeshGUI, SIGNAL (SignalDeactivateActiveDialog()), SLOT(DeactivateActiveDialog())); /* to close dialog if study frame change */ - connect( myMeshGUI, SIGNAL ( SignalStudyFrameChanged() ), SLOT( ClickOnCancel() ) ) ; - + connect(myMeshGUI, SIGNAL (SignalStudyFrameChanged()), SLOT(ClickOnCancel())); + /* Move widget on the botton right corner of main widget */ - int x, y ; - myMeshGUI->DefineDlgPosition( this, x, y ) ; - this->move( x, y ) ; - this->show() ; + int x, y; + myMeshGUI->DefineDlgPosition(this, x, y); + this->move(x, y); + this->show(); // set selection mode SMESH::SetPointRepresentation(true); - QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true ); +#ifdef NEW_GUI + mySelectionMgr->setSelectionModes(NodeSelection, true); +#else + mySelectionMgr->setSelectionModes(NodeSelection); +#endif SelectionIntoArgument(); } @@ -398,16 +404,15 @@ void SMESHGUI_NodesDlg::Init(SALOME_Selection* Sel) // function : ValueChangedInSpinBox() // purpose : //================================================================================= -void SMESHGUI_NodesDlg::ValueChangedInSpinBox( double newValue ) +void SMESHGUI_NodesDlg::ValueChangedInSpinBox (double newValue) { - if(!myMesh->_is_nil()){ - double vx = SpinBox_X->GetValue() ; - double vy = SpinBox_Y->GetValue() ; - double vz = SpinBox_Z->GetValue() ; + if (!myMesh->_is_nil()) { + double vx = SpinBox_X->GetValue(); + double vy = SpinBox_Y->GetValue(); + double vz = SpinBox_Z->GetValue(); mySimulation->SetPosition(vx,vy,vz); } - return ; } //================================================================================= @@ -416,73 +421,83 @@ void SMESHGUI_NodesDlg::ValueChangedInSpinBox( double newValue ) //================================================================================= void SMESHGUI_NodesDlg::ClickOnOk() { - if ( ClickOnApply() ) - ClickOnCancel() ; + if (ClickOnApply()) + ClickOnCancel(); } -//======================================================================= +//================================================================================= // function : ClickOnApply() // purpose : -//======================================================================= +//================================================================================= bool SMESHGUI_NodesDlg::ClickOnApply() { - if (myMeshGUI->ActiveStudyLocked()) + if (myMeshGUI->isActiveStudyLocked()) return false; - if ( myMesh->_is_nil() ) { - QAD_MessageBox::warn1(QAD_Application::getDesktop(), - tr("SMESH_WRN_WARNING"), - tr("MESH_IS_NOT_SELECTED"), - tr("SMESH_BUT_OK")); + if (myMesh->_is_nil()) { + SUIT_MessageBox::warn1(SMESHGUI::desktop(), tr("SMESH_WRN_WARNING"), + tr("MESH_IS_NOT_SELECTED"), tr("SMESH_BUT_OK")); return false; } - + /* Recup args and call method */ - double x = SpinBox_X->GetValue() ; - double y = SpinBox_Y->GetValue() ; - double z = SpinBox_Z->GetValue() ; + double x = SpinBox_X->GetValue(); + double y = SpinBox_Y->GetValue(); + double z = SpinBox_Z->GetValue(); mySimulation->SetVisibility(false); - SMESH::AddNode(myMesh,x,y,z) ; + SMESH::AddNode(myMesh,x,y,z); SMESH::SetPointRepresentation(true); // select myMesh - if ( mySelection->IObjectCount() != 1 ) { - if(VTKViewer_ViewFrame* aViewFrame = SMESH::GetCurrentVtkView()) { - vtkActorCollection *aCollection = aViewFrame->getRenderer()->GetActors(); + SALOME_ListIO aList; + mySelectionMgr->selectedObjects(aList); + if (aList.Extent() != 1) { + if (SVTK_ViewWindow* aViewWindow = SMESH::GetCurrentVtkView()) { + vtkActorCollection *aCollection = aViewWindow->getRenderer()->GetActors(); aCollection->InitTraversal(); - while(vtkActor *anAct = aCollection->GetNextActor()){ - if(SMESH_Actor *anActor = dynamic_cast(anAct)) - if(anActor->hasIO()) - if(SMESH_MeshObj *aMeshObj = dynamic_cast(anActor->GetObject().get())) - if(myMesh->_is_equivalent( aMeshObj->GetMeshServer() )) - { - mySelection->ClearIObjects(); - mySelection->AddIObject( anActor->getIO(), false ); + while (vtkActor *anAct = aCollection->GetNextActor()) { + if (SMESH_Actor *anActor = dynamic_cast(anAct)) { + if (anActor->hasIO()) { + if (SMESH_MeshObj *aMeshObj = dynamic_cast(anActor->GetObject().get())) { + if (myMesh->_is_equivalent(aMeshObj->GetMeshServer())) { +#ifdef NEW_GUI + mySelectionMgr->clearSelected(); + mySelectionMgr->AddIObject(anActor->getIO(), false); +#else + aList.Clear(); + aList.Append(anActor->getIO()); + mySelectionMgr->setSelectedObjects(aList, false); +#endif break; } + } + } + } } } } return true; } - -//======================================================================= +//================================================================================= // function : ClickOnCancel() // purpose : -//======================================================================= +//================================================================================= void SMESHGUI_NodesDlg::ClickOnCancel() { - mySelection->ClearIObjects(); + MESSAGE("SMESHGUI_NodesDlg::ClickOnCancel() 1"); + disconnect(mySelectionMgr, 0, this, 0); + mySelectionMgr->clearSelected(); + mySelectionMgr->setSelectionModes(ActorSelection); + + MESSAGE("SMESHGUI_NodesDlg::ClickOnCancel() 2"); mySimulation->SetVisibility(false); SMESH::SetPointRepresentation(false); - QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); - disconnect( mySelection, 0, this, 0 ); myMeshGUI->ResetState(); - reject() ; - return ; -} + reject(); + MESSAGE("SMESHGUI_NodesDlg::ClickOnCancel() 3"); +} //================================================================================= // function : SelectionIntoArgument() @@ -490,26 +505,28 @@ void SMESHGUI_NodesDlg::ClickOnCancel() //================================================================================= void SMESHGUI_NodesDlg::SelectionIntoArgument() { - if ( !GroupConstructors->isEnabled() ) + if (!GroupConstructors->isEnabled()) return; mySimulation->SetVisibility(false); SMESH::SetPointRepresentation(true); - if(mySelection->IObjectCount() == 1){ - Handle(SALOME_InteractiveObject) anIO = mySelection->firstIObject(); - if(anIO->hasEntry()){ + SALOME_ListIO aList; + mySelectionMgr->selectedObjects(aList); + if (aList.Extent() == 1) { + Handle(SALOME_InteractiveObject) anIO = aList.First(); + if (anIO->hasEntry()) { myMesh = SMESH::GetMeshByIO(anIO); - if(myMesh->_is_nil()) return; + if (myMesh->_is_nil()) return; QString aText; - if(SMESH::GetNameOfSelectedNodes( mySelection, aText ) == 1){ - if(SMESH_Actor* anActor = SMESH::FindActorByObject(myMesh.in())){ - if(SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh()){ - if(const SMDS_MeshNode* aNode = aMesh->FindNode(aText.toInt())){ - SpinBox_X->SetValue( aNode->X() ); - SpinBox_Y->SetValue( aNode->Y() ) ; - SpinBox_Z->SetValue( aNode->Z() ) ; - } + if (SMESH::GetNameOfSelectedNodes(mySelectionMgr, aText) == 1) { + if (SMESH_Actor* anActor = SMESH::FindActorByObject(myMesh.in())) { + if (SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh()) { + if (const SMDS_MeshNode* aNode = aMesh->FindNode(aText.toInt())) { + SpinBox_X->SetValue(aNode->X()); + SpinBox_Y->SetValue(aNode->Y()); + SpinBox_Z->SetValue(aNode->Z()); + } } } } @@ -520,24 +537,22 @@ void SMESHGUI_NodesDlg::SelectionIntoArgument() } } - -//======================================================================= +//================================================================================= // function : closeEvent() // purpose : -//======================================================================= -void SMESHGUI_NodesDlg::closeEvent(QCloseEvent* e) +//================================================================================= +void SMESHGUI_NodesDlg::closeEvent (QCloseEvent*) { - this->ClickOnCancel() ; /* same than click on cancel button */ + this->ClickOnCancel(); /* same than click on cancel button */ } -//======================================================================= -//function : hideEvent -//purpose : caused by ESC key -//======================================================================= - -void SMESHGUI_NodesDlg::hideEvent ( QHideEvent * e ) +//================================================================================= +// function : hideEvent() +// purpose : caused by ESC key +//================================================================================= +void SMESHGUI_NodesDlg::hideEvent (QHideEvent*) { - if ( !isMinimized() ) + if (!isMinimized()) ClickOnCancel(); } @@ -545,43 +560,45 @@ void SMESHGUI_NodesDlg::hideEvent ( QHideEvent * e ) // function : enterEvent() // purpose : to reactivate this dialog box when mouse enter onto the window //================================================================================= -void SMESHGUI_NodesDlg::enterEvent( QEvent* e) +void SMESHGUI_NodesDlg::enterEvent(QEvent*) { - if ( !GroupConstructors->isEnabled() ) - ActivateThisDialog() ; + if (!GroupConstructors->isEnabled()) + ActivateThisDialog(); } - //================================================================================= // function : DeactivateActiveDialog() // purpose : public slot to deactivate if active //================================================================================= void SMESHGUI_NodesDlg::DeactivateActiveDialog() { - if ( GroupConstructors->isEnabled() ) { - GroupConstructors->setEnabled(false) ; - GroupCoordinates->setEnabled(false) ; - GroupButtons->setEnabled(false) ; - mySimulation->SetVisibility(false) ; - myMeshGUI->ResetState() ; - myMeshGUI->SetActiveDialogBox(0) ; + if (GroupConstructors->isEnabled()) { + GroupConstructors->setEnabled(false); + GroupCoordinates->setEnabled(false); + GroupButtons->setEnabled(false); + mySimulation->SetVisibility(false); + myMeshGUI->ResetState(); + myMeshGUI->SetActiveDialogBox(0); } } - //================================================================================= // function : ActivateThisDialog() // purpose : //================================================================================= -void SMESHGUI_NodesDlg::ActivateThisDialog( ) +void SMESHGUI_NodesDlg::ActivateThisDialog() { - myMeshGUI->EmitSignalDeactivateDialog() ; - GroupConstructors->setEnabled(true) ; - GroupCoordinates->setEnabled(true) ; - GroupButtons->setEnabled(true) ; + myMeshGUI->EmitSignalDeactivateDialog(); + GroupConstructors->setEnabled(true); + GroupCoordinates->setEnabled(true); + GroupButtons->setEnabled(true); SMESH::SetPointRepresentation(true); - QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true ); +#ifdef NEW_GUI + mySelectionMgr->setSelectionModes(NodeSelection, true); +#else + mySelectionMgr->setSelectionModes(NodeSelection); +#endif SelectionIntoArgument(); } diff --git a/src/SMESHGUI/SMESHGUI_NodesDlg.h b/src/SMESHGUI/SMESHGUI_NodesDlg.h index 8cf17d17d..50e84b155 100644 --- a/src/SMESHGUI/SMESHGUI_NodesDlg.h +++ b/src/SMESHGUI/SMESHGUI_NodesDlg.h @@ -29,7 +29,7 @@ #ifndef DIALOGBOX_NODES_H #define DIALOGBOX_NODES_H -#include "SALOME_Selection.h" +#include "SalomeApp_SelectionMgr.h" #include #include @@ -64,25 +64,25 @@ class SMESHGUI_NodesDlg : public QDialog Q_OBJECT public: - SMESHGUI_NodesDlg( QWidget* parent = 0, const char* name = 0, - SALOME_Selection* Sel = 0, + SMESHGUI_NodesDlg (QWidget* parent = 0, const char* name = 0, + SalomeApp_SelectionMgr* Sel = 0, bool modal = FALSE, - WFlags fl = 0 ); + WFlags fl = 0); ~SMESHGUI_NodesDlg(); - -private : - SALOME_Selection* mySelection ; - SMESHGUI* myMeshGUI ; +private: - SMESH::SMESH_Mesh_var myMesh; + SalomeApp_SelectionMgr* mySelectionMgr; + SMESHGUI* myMeshGUI; + + SMESH::SMESH_Mesh_var myMesh; SMESH::TNodeSimulation* mySimulation; - void Init(SALOME_Selection* Sel) ; + void Init (SalomeApp_SelectionMgr*); void enterEvent(QEvent* e); - void closeEvent(QCloseEvent* e) ; - void hideEvent ( QHideEvent * ); /* ESC key */ + void closeEvent(QCloseEvent*); + void hideEvent (QHideEvent *); /* ESC key */ QButtonGroup* GroupConstructors; QRadioButton* Constructor1; @@ -118,4 +118,3 @@ protected: }; #endif // DIALOGBOX_NODES_H - diff --git a/src/SMESHGUI/SMESHGUI_PatternUtils.cxx b/src/SMESHGUI/SMESHGUI_PatternUtils.cxx index e552b9d7d..718162f2b 100644 --- a/src/SMESHGUI/SMESHGUI_PatternUtils.cxx +++ b/src/SMESHGUI/SMESHGUI_PatternUtils.cxx @@ -19,14 +19,13 @@ #include "SMESHGUI_PatternUtils.h" -#include "SMESHGUI_SMESHGenUtils.h" +#include "SMESHGUI.h" -namespace SMESH{ +namespace SMESH { SMESH::SMESH_Pattern_var GetPattern() { - return GetSMESHGen()->GetPattern(); + return SMESHGUI::GetSMESHGen()->GetPattern(); } - } diff --git a/src/SMESHGUI/SMESHGUI_PatternWidget.cxx b/src/SMESHGUI/SMESHGUI_PatternWidget.cxx index 80614980c..178800a62 100644 --- a/src/SMESHGUI/SMESHGUI_PatternWidget.cxx +++ b/src/SMESHGUI/SMESHGUI_PatternWidget.cxx @@ -1,30 +1,30 @@ // SMESH SMESHGUI : GUI for SMESH component // // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org // // // // File : SMESHGUI_PatternWidget.cxx // Author : Michael ZORIN // Module : SMESH -// $Header: +// $Header: #include "SMESHGUI_PatternWidget.h" @@ -35,59 +35,57 @@ //================================================================================= // class : SMESHGUI_PatternWidget() -// purpose : +// purpose : //================================================================================= -SMESHGUI_PatternWidget::SMESHGUI_PatternWidget( QWidget* parent, const char* name, WFlags fl ) - : QFrame( parent, name, WStyle_Customize) +SMESHGUI_PatternWidget::SMESHGUI_PatternWidget (QWidget* parent, const char* name, WFlags fl) + : QFrame(parent, name, WStyle_Customize) { myMinU = myMinV = myMaxU = myMaxV = 0; setMinimumHeight(150); repaint(); } - - //================================================================================= // function : ~SMESHGUI_PatternWidget() -// purpose : +// purpose : //================================================================================= SMESHGUI_PatternWidget::~SMESHGUI_PatternWidget() { } - //================================================================================= -// function : SMESHGUI_PatternWidget::SetPoints -// purpose : +// function : SetPoints() +// purpose : //================================================================================= -void SMESHGUI_PatternWidget::SetPoints( PointVector thePoints, QValueVector theKeys, ConnectivityVector theConnections ) +void SMESHGUI_PatternWidget::SetPoints (PointVector thePoints, + QValueVector theKeys, + ConnectivityVector theConnections) { myPoints = thePoints; myKeys = theKeys; myConnections = theConnections; - + if (!thePoints.size()) return; - + myMinU = myMaxU = (thePoints[0]).x; myMinV = myMaxV = (thePoints[0]).y; double x, y; - - for (int i = 1; i < thePoints.size(); i++) - { - x = (thePoints[i]).x; - y = (thePoints[i]).y; - - if ( myMinU > x ) - myMinU = x; - if ( myMaxU < x) - myMaxU = x; - if ( myMinV > y ) - myMinV = y; - if ( myMaxV < y) - myMaxV = y; - } - + + for (int i = 1; i < thePoints.size(); i++) { + x = (thePoints[i]).x; + y = (thePoints[i]).y; + + if (myMinU > x) + myMinU = x; + if (myMaxU < x) + myMaxU = x; + if (myMinV > y) + myMinV = y; + if (myMaxV < y) + myMaxV = y; + } + repaint(); } @@ -95,77 +93,73 @@ static const int Shift = 4; // shift of the point number from point static const int Border = 20; //================================================================================= -// function : SMESHGUI_PatternWidget::paintEvent -// purpose : +// function : paintEvent() +// purpose : //================================================================================= -void SMESHGUI_PatternWidget::paintEvent( QPaintEvent * ) +void SMESHGUI_PatternWidget::paintEvent (QPaintEvent*) { - QPainter paint( this ); - paint.setBrush (Qt::SolidPattern ); + QPainter paint (this); + paint.setBrush(Qt::SolidPattern); //Draw points const int aRadius = 3; // radius of a point - - for (int i = 0; i < myKeys.size() && i < myPoints.size(); i++) - { - SMESH::PointStruct aPoint = myPoints[ myKeys[i] ]; - QPoint aQPnt = MapCoords( aPoint.x, aPoint.y); - - paint.drawPie( aQPnt.x() - aRadius, aQPnt.y() - aRadius, aRadius*2, aRadius*2, 5760, 5760 ); - paint.drawText( aQPnt.x() + Shift, aQPnt.y() - Shift, QString::number( i+1 ) ); - } - - //Draw lines - for (int i = 0; i < myConnections.size(); i++) - { - QValueVector aCVector = myConnections[i]; - if ( aCVector.size() == 0 ) - continue; - - SMESH::PointStruct aPoint = myPoints[ aCVector[0] ]; - const QPoint aBeginPnt = MapCoords( aPoint.x, aPoint.y); - QPoint aFirstPnt = aBeginPnt, aSecondPnt; - - for (int j = 1; j < aCVector.size(); j++) - { - aPoint = myPoints[ aCVector[j] ]; - aSecondPnt = MapCoords( aPoint.x, aPoint.y); - paint.drawLine(aFirstPnt, aSecondPnt); - aFirstPnt = aSecondPnt; - } - - paint.drawLine(aBeginPnt, aSecondPnt); + for (int i = 0; i < myKeys.size() && i < myPoints.size(); i++) { + SMESH::PointStruct aPoint = myPoints[ myKeys[i] ]; + QPoint aQPnt = MapCoords(aPoint.x, aPoint.y); + + paint.drawPie(aQPnt.x() - aRadius, aQPnt.y() - aRadius, aRadius*2, aRadius*2, 5760, 5760); + paint.drawText(aQPnt.x() + Shift, aQPnt.y() - Shift, QString::number(i+1)); + } + + //Draw lines + for (int i = 0; i < myConnections.size(); i++) { + QValueVector aCVector = myConnections[i]; + + if (aCVector.size() == 0) + continue; + + SMESH::PointStruct aPoint = myPoints[ aCVector[0] ]; + const QPoint aBeginPnt = MapCoords(aPoint.x, aPoint.y); + QPoint aFirstPnt = aBeginPnt, aSecondPnt; + + for (int j = 1; j < aCVector.size(); j++) { + aPoint = myPoints[ aCVector[j] ]; + aSecondPnt = MapCoords(aPoint.x, aPoint.y); + paint.drawLine(aFirstPnt, aSecondPnt); + aFirstPnt = aSecondPnt; } + + paint.drawLine(aBeginPnt, aSecondPnt); + } } - //================================================================================= -// function : SMESHGUI_PatternWidget::MapCoords -// purpose : +// function : MapCoords() +// purpose : //================================================================================= -QPoint SMESHGUI_PatternWidget::MapCoords( const double u, const double v ) +QPoint SMESHGUI_PatternWidget::MapCoords (const double u, const double v) { int aWidth = width() - 2*Border; int aHeight = height() - 2*Border; double aUBound = myMaxU - myMinU; double aVBound = myMaxV - myMinV; - + double aUScale = aWidth/aUBound; double aVScale = aHeight/aVBound; - + double aScale; aUScale <= aVScale ? aScale = aUScale : aScale = aVScale; - double aUMiddle = ( myMaxU + myMinU )/2; - double aVMiddle = ( myMaxV + myMinV )/2; - - int x = int( aWidth/2 + (u - aUMiddle)*aScale + Border - Shift); - - int y = int( aHeight/2 + (aVMiddle - v)*aScale + Border + Shift); - + double aUMiddle = (myMaxU + myMinU)/2; + double aVMiddle = (myMaxV + myMinV)/2; + + int x = int(aWidth/2 + (u - aUMiddle)*aScale + Border - Shift); + + int y = int(aHeight/2 + (aVMiddle - v)*aScale + Border + Shift); + QPoint aPoint = QPoint(x, y); - + return aPoint; } diff --git a/src/SMESHGUI/SMESHGUI_PrecisionDlg.cxx b/src/SMESHGUI/SMESHGUI_PrecisionDlg.cxx index 2255978a6..5024a235e 100755 --- a/src/SMESHGUI/SMESHGUI_PrecisionDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_PrecisionDlg.cxx @@ -1,22 +1,22 @@ // SMESH SMESHGUI : GUI for SMESH component // // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org // // @@ -26,10 +26,12 @@ // Module : SMESH #include "SMESHGUI_PrecisionDlg.h" -#include "QAD_Config.h" + #include "SMESHGUI.h" #include "SMESHGUI_VTKUtils.h" +#include "SUIT_ResourceMgr.h" + #include #include #include @@ -37,40 +39,39 @@ #include #include -#define SPACING 5 +#define SPACING 5 #define MARGIN 10 #define DEFAULT_VAL 10 #define RANGE 128 -/* - Class : SMESHGUI_PrecisionDlg - Description : Dialog to specify precision of mesh quality controls -*/ +/*! + * Class : SMESHGUI_PrecisionDlg + * Description : Dialog to specify precision of mesh quality controls + */ //======================================================================= // name : SMESHGUI_PrecisionDlg::SMESHGUI_PrecisionDlg // Purpose : Constructor //======================================================================= -SMESHGUI_PrecisionDlg::SMESHGUI_PrecisionDlg( QWidget* theParent ) -: QDialog( theParent, "SMESHGUI_PrecisionDlg", true, - WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +SMESHGUI_PrecisionDlg::SMESHGUI_PrecisionDlg (QWidget* theParent) + : QDialog(theParent, "SMESHGUI_PrecisionDlg", true, + WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) { - setCaption( tr( "CAPTION" ) ); + setCaption(tr("CAPTION")); - QVBoxLayout* aDlgLay = new QVBoxLayout( this, MARGIN, SPACING ); + QVBoxLayout* aDlgLay = new QVBoxLayout (this, MARGIN, SPACING); - QFrame* aMainFrame = createMainFrame ( this ); - QFrame* aBtnFrame = createButtonFrame( this ); + QFrame* aMainFrame = createMainFrame (this); + QFrame* aBtnFrame = createButtonFrame(this); - aDlgLay->addWidget( aMainFrame ); - aDlgLay->addWidget( aBtnFrame ); + aDlgLay->addWidget(aMainFrame); + aDlgLay->addWidget(aBtnFrame); - aDlgLay->setStretchFactor( aMainFrame, 1 ); + aDlgLay->setStretchFactor(aMainFrame, 1); - setMinimumWidth( (int)( QFontMetrics( font() ).width( tr( "CAPTION" ) ) * 1.5 ) ); + setMinimumWidth((int)(QFontMetrics(font()).width(tr("CAPTION")) * 1.5)); Init(); - } //======================================================================= @@ -85,21 +86,21 @@ SMESHGUI_PrecisionDlg::~SMESHGUI_PrecisionDlg() // name : SMESHGUI_PrecisionDlg::createButtonFrame // Purpose : Create frame containing buttons //======================================================================= -QFrame* SMESHGUI_PrecisionDlg::createButtonFrame( QWidget* theParent ) +QFrame* SMESHGUI_PrecisionDlg::createButtonFrame (QWidget* theParent) { - QGroupBox* aGrp = new QGroupBox( 1, Qt::Vertical, theParent ); - aGrp->setFrameStyle( QFrame::NoFrame ); - aGrp->setInsideMargin( 0 ); + QGroupBox* aGrp = new QGroupBox (1, Qt::Vertical, theParent); + aGrp->setFrameStyle(QFrame::NoFrame); + aGrp->setInsideMargin(0); - myOKBtn = new QPushButton( tr( "SMESH_BUT_OK" ), aGrp ); + myOKBtn = new QPushButton (tr("SMESH_BUT_OK"), aGrp); - QLabel* aLbl = new QLabel( aGrp ); - aLbl->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + QLabel* aLbl = new QLabel (aGrp); + aLbl->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); - myCancelBtn = new QPushButton( tr( "SMESH_BUT_CANCEL" ), aGrp ); + myCancelBtn = new QPushButton (tr("SMESH_BUT_CANCEL"), aGrp); - connect( myOKBtn, SIGNAL( clicked() ), SLOT( onOk() ) ); - connect( myCancelBtn, SIGNAL( clicked() ), SLOT( onClose() ) ); + connect(myOKBtn, SIGNAL(clicked()), SLOT(onOk())); + connect(myCancelBtn, SIGNAL(clicked()), SLOT(onClose())); return aGrp; } @@ -108,14 +109,14 @@ QFrame* SMESHGUI_PrecisionDlg::createButtonFrame( QWidget* theParent ) // name : SMESHGUI_PrecisionDlg:: createMainFrame // Purpose : Create frame containing dialog's input fields //======================================================================= -QFrame* SMESHGUI_PrecisionDlg::createMainFrame( QWidget* theParent ) +QFrame* SMESHGUI_PrecisionDlg::createMainFrame (QWidget* theParent) { - QGroupBox* aGrp = new QGroupBox( 2, Qt::Horizontal, theParent ); - new QLabel( tr( "PRECISION" ), aGrp ); - mySpinBox = new QSpinBox( 0, RANGE, 1, aGrp ); - myNotUseChk = new QCheckBox( tr( "NOT_USE" ), aGrp ); + QGroupBox* aGrp = new QGroupBox(2, Qt::Horizontal, theParent); + new QLabel (tr("PRECISION"), aGrp); + mySpinBox = new QSpinBox (0, RANGE, 1, aGrp); + myNotUseChk = new QCheckBox (tr("NOT_USE"), aGrp); - connect( myNotUseChk, SIGNAL( toggled( bool ) ), SLOT( onNotUse() ) ); + connect(myNotUseChk, SIGNAL(toggled(bool)), SLOT(onNotUse())); return aGrp; } @@ -126,25 +127,22 @@ QFrame* SMESHGUI_PrecisionDlg::createMainFrame( QWidget* theParent ) //======================================================================= void SMESHGUI_PrecisionDlg::Init() { - if ( QAD_CONFIG->hasSetting( "SMESH:ControlsPrecision" ) ) - { - QString aStr = QAD_CONFIG->getSetting( "SMESH:ControlsPrecision" ); - bool isOk = false; - int aVal = aStr.toInt( &isOk ); - mySpinBox->setValue( isOk ? aVal : DEFAULT_VAL ); - myNotUseChk->setChecked( !isOk ); - } - else - { - mySpinBox->setValue( DEFAULT_VAL ); - myNotUseChk->setChecked( true ); + bool isOk = false; + int aVal = DEFAULT_VAL; + SUIT_ResourceMgr* mgr = SMESHGUI::resourceMgr(); + if (mgr && mgr->hasValue("SMESH", "ControlsPrecision")) { + QString aStr = mgr->stringValue("SMESH", "ControlsPrecision"); + aVal = aStr.toInt(&isOk); } + mySpinBox->setValue(isOk ? aVal : DEFAULT_VAL); + myNotUseChk->setChecked(!isOk); + onNotUse(); SMESHGUI* aSMESHGUI = SMESHGUI::GetSMESHGUI(); - aSMESHGUI->SetActiveDialogBox( ( QDialog* )this ) ; - connect( aSMESHGUI, SIGNAL( SignalCloseAllDialogs() ), SLOT( onClose() ) ); + aSMESHGUI->SetActiveDialogBox((QDialog*)this); + connect(aSMESHGUI, SIGNAL(SignalCloseAllDialogs()), SLOT(onClose())); } //======================================================================= @@ -153,20 +151,22 @@ void SMESHGUI_PrecisionDlg::Init() //======================================================================= void SMESHGUI_PrecisionDlg::onOk() { - if ( myNotUseChk->isChecked() ) - { - QAD_CONFIG->removeSettings( "SMESH:ControlsPrecision" ); - SMESH::SetControlsPrecision( -1 ); - } - else - { + SUIT_ResourceMgr* mgr = SMESHGUI::resourceMgr(); + if (myNotUseChk->isChecked()) { + if (mgr) { + mgr->remove("SMESH", "ControlsPrecision"); + } + SMESH::SetControlsPrecision(-1); + } else { mySpinBox->clearFocus(); int aVal = mySpinBox->value(); - QAD_CONFIG->addSetting( "SMESH:ControlsPrecision", QString( "%1" ).arg( aVal ) ); - SMESH::SetControlsPrecision( aVal ); + if (mgr) { + mgr->setValue("SMESH", "ControlsPrecision", QString("%1").arg(aVal)); + } + SMESH::SetControlsPrecision(aVal); } - - disconnect( SMESHGUI::GetSMESHGUI(), 0, this, 0 ); + + disconnect(SMESHGUI::GetSMESHGUI(), 0, this, 0); SMESHGUI::GetSMESHGUI()->ResetState() ; accept(); } @@ -177,45 +177,24 @@ void SMESHGUI_PrecisionDlg::onOk() //======================================================================= void SMESHGUI_PrecisionDlg::onClose() { - disconnect( SMESHGUI::GetSMESHGUI(), 0, this, 0 ); + disconnect(SMESHGUI::GetSMESHGUI(), 0, this, 0); reject(); } -//================================================================================= -// function : SMESHGUI_PrecisionDlg::closeEvent() -// purpose : -//================================================================================= -void SMESHGUI_PrecisionDlg::closeEvent( QCloseEvent* ) +//======================================================================= +// name : SMESHGUI_PrecisionDlg::closeEvent +// Purpose : +//======================================================================= +void SMESHGUI_PrecisionDlg::closeEvent (QCloseEvent*) { onClose(); } //======================================================================= -// name : SMESHGUI_PrecisionDlg::onClose +// name : SMESHGUI_PrecisionDlg::onNotUse // Purpose : SLOT. Called when state of "Do not use" check box changed //======================================================================= void SMESHGUI_PrecisionDlg::onNotUse() { - mySpinBox->setEnabled( !myNotUseChk->isChecked() ); + mySpinBox->setEnabled(!myNotUseChk->isChecked()); } - - - - - - - - - - - - - - - - - - - - - diff --git a/src/SMESHGUI/SMESHGUI_Preferences_ColorDlg.cxx b/src/SMESHGUI/SMESHGUI_Preferences_ColorDlg.cxx index 6e9bff6e3..abe998f85 100644 --- a/src/SMESHGUI/SMESHGUI_Preferences_ColorDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_Preferences_ColorDlg.cxx @@ -1,23 +1,23 @@ // SMESH SMESHGUI : GUI for SMESH component // // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org // // // @@ -26,12 +26,12 @@ // Module : SMESH // $Header$ -using namespace std; #include "SMESHGUI_Preferences_ColorDlg.h" #include "SMESHGUI.h" #include "utilities.h" +// QT Includes #include #include #include @@ -41,134 +41,139 @@ using namespace std; #include #include #include -#include +#include #include -/* - * Constructs a SMESHGUI_Preferences_ColorDlg which is a child of 'parent', with the - * name 'name' and widget flags set to 'f' - * - * The dialog will by default be modeless, unless you set 'modal' to - * TRUE to construct a modal dialog. - */ -SMESHGUI_Preferences_ColorDlg::SMESHGUI_Preferences_ColorDlg( QWidget* parent, const char* name ) - : QDialog( parent, name, true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +using namespace std; + +//================================================================================= +// function : SMESHGUI_Preferences_ColorDlg() +// purpose : Constructs a SMESHGUI_Preferences_ColorDlg which is a child +// of 'parent', with the name 'name' and widget flags set to 'f' +// The dialog will by default be modeless, unless you +// set'modal' to TRUE to construct a modal dialog. +//================================================================================= +SMESHGUI_Preferences_ColorDlg::SMESHGUI_Preferences_ColorDlg (QWidget* parent, + const char* name) + : QDialog(parent, name, true, WStyle_Customize | + WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) { - if ( !name ) - setName( "SMESHGUI_Preferences_ColorDlg" ); - setCaption( tr( "Preferences - Set Color" ) ); - setSizeGripEnabled( TRUE ); - QGridLayout* SMESHGUI_Preferences_ColorDlgLayout = new QGridLayout( this ); - SMESHGUI_Preferences_ColorDlgLayout->setSpacing( 6 ); - SMESHGUI_Preferences_ColorDlgLayout->setMargin( 11 ); + if (!name) + setName("SMESHGUI_Preferences_ColorDlg"); + setCaption(tr("Preferences - Set Color")); + setSizeGripEnabled(TRUE); + QGridLayout* SMESHGUI_Preferences_ColorDlgLayout = new QGridLayout(this); + SMESHGUI_Preferences_ColorDlgLayout->setSpacing(6); + SMESHGUI_Preferences_ColorDlgLayout->setMargin(11); - ButtonGroup1 = new QButtonGroup( tr( "Elements" ), this, "ButtonGroup1" ); - ButtonGroup1->setColumnLayout(0, Qt::Vertical ); - ButtonGroup1->layout()->setSpacing( 0 ); - ButtonGroup1->layout()->setMargin( 0 ); - QGridLayout* ButtonGroup1Layout = new QGridLayout( ButtonGroup1->layout() ); - ButtonGroup1Layout->setAlignment( Qt::AlignTop ); - ButtonGroup1Layout->setSpacing( 6 ); - ButtonGroup1Layout->setMargin( 11 ); + ButtonGroup1 = new QButtonGroup(tr("Elements"), this, "ButtonGroup1"); + ButtonGroup1->setColumnLayout(0, Qt::Vertical); + ButtonGroup1->layout()->setSpacing(0); + ButtonGroup1->layout()->setMargin(0); + QGridLayout* ButtonGroup1Layout = new QGridLayout(ButtonGroup1->layout()); + ButtonGroup1Layout->setAlignment(Qt::AlignTop); + ButtonGroup1Layout->setSpacing(6); + ButtonGroup1Layout->setMargin(11); - TextLabel_Fill = new QLabel( tr( "Fill" ), ButtonGroup1, "TextLabel_2D_Fill" ); - ButtonGroup1Layout->addWidget( TextLabel_Fill, 0, 0 ); + TextLabel_Fill = new QLabel(tr("Fill"), ButtonGroup1, "TextLabel_2D_Fill"); + ButtonGroup1Layout->addWidget(TextLabel_Fill, 0, 0); - btnFillColor = new QPushButton( ButtonGroup1, "btnFillColor" ); - btnFillColor->setFixedSize( QSize( 25, 25 ) ); - ButtonGroup1Layout->addWidget( btnFillColor, 0, 1 ); + btnFillColor = new QPushButton(ButtonGroup1, "btnFillColor"); + btnFillColor->setFixedSize(QSize(25, 25)); + ButtonGroup1Layout->addWidget(btnFillColor, 0, 1); - TextLabel_Outine = new QLabel( tr( "Outline" ), ButtonGroup1, "TextLabel_2D_Outine" ); - ButtonGroup1Layout->addWidget( TextLabel_Outine, 0, 2 ); + TextLabel_Outine = new QLabel(tr("Outline"), ButtonGroup1, "TextLabel_2D_Outine"); + ButtonGroup1Layout->addWidget(TextLabel_Outine, 0, 2); - btnOutlineColor = new QPushButton( ButtonGroup1, "btnOutlineColor" ); - btnOutlineColor->setFixedSize( QSize( 25, 25 ) ); - ButtonGroup1Layout->addWidget( btnOutlineColor, 0, 3 ); + btnOutlineColor = new QPushButton(ButtonGroup1, "btnOutlineColor"); + btnOutlineColor->setFixedSize(QSize(25, 25)); + ButtonGroup1Layout->addWidget(btnOutlineColor, 0, 3); - TextLabel_Width = new QLabel( tr( "Width" ), ButtonGroup1, "TextLabel_2D_Width" ); - ButtonGroup1Layout->addWidget( TextLabel_Width, 0, 4 ); + TextLabel_Width = new QLabel(tr("Width"), ButtonGroup1, "TextLabel_2D_Width"); + ButtonGroup1Layout->addWidget(TextLabel_Width, 0, 4); - SpinBox_Width = new QSpinBox( 0, 5, 1, ButtonGroup1, "SpinBox_Width" ); - SpinBox_Width->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - SpinBox_Width->setWrapping( FALSE ); - SpinBox_Width->setButtonSymbols( QSpinBox::PlusMinus ); - ButtonGroup1Layout->addWidget( SpinBox_Width, 0, 5 ); + SpinBox_Width = new QSpinBox(0, 5, 1, ButtonGroup1, "SpinBox_Width"); + SpinBox_Width->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); + SpinBox_Width->setWrapping(FALSE); + SpinBox_Width->setButtonSymbols(QSpinBox::PlusMinus); + ButtonGroup1Layout->addWidget(SpinBox_Width, 0, 5); - TextLabel_BackFace = new QLabel( tr( "Back Face" ), ButtonGroup1, "TextLabel_BackFace" ); - ButtonGroup1Layout->addWidget( TextLabel_BackFace, 1, 0 ); + TextLabel_BackFace = new QLabel(tr("Back Face"), ButtonGroup1, "TextLabel_BackFace"); + ButtonGroup1Layout->addWidget(TextLabel_BackFace, 1, 0); - btnBackFaceColor = new QPushButton( ButtonGroup1, "btnBackFaceColor" ); - btnBackFaceColor->setFixedSize( QSize( 25, 25 ) ); - ButtonGroup1Layout->addWidget( btnBackFaceColor, 1, 1 ); + btnBackFaceColor = new QPushButton(ButtonGroup1, "btnBackFaceColor"); + btnBackFaceColor->setFixedSize(QSize(25, 25)); + ButtonGroup1Layout->addWidget(btnBackFaceColor, 1, 1); - TextLabel_ShrinkCoeff = new QLabel( tr( "Shrink coef." ), ButtonGroup1, "TextLabel_ShrinkCoeff" ); - ButtonGroup1Layout->addWidget( TextLabel_ShrinkCoeff, 2, 0 ); + TextLabel_ShrinkCoeff = new QLabel(tr("Shrink coef."), ButtonGroup1, "TextLabel_ShrinkCoeff"); + ButtonGroup1Layout->addWidget(TextLabel_ShrinkCoeff, 2, 0); - SpinBox_Shrink = new QSpinBox( 20, 100, 1, ButtonGroup1, "SpinBox_Shrink" ); - SpinBox_Shrink->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - SpinBox_Shrink->setButtonSymbols( QSpinBox::PlusMinus ); - ButtonGroup1Layout->addMultiCellWidget( SpinBox_Shrink, 2, 2, 1, 5); + SpinBox_Shrink = new QSpinBox(20, 100, 1, ButtonGroup1, "SpinBox_Shrink"); + SpinBox_Shrink->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); + SpinBox_Shrink->setButtonSymbols(QSpinBox::PlusMinus); + ButtonGroup1Layout->addMultiCellWidget(SpinBox_Shrink, 2, 2, 1, 5); - SMESHGUI_Preferences_ColorDlgLayout->addWidget( ButtonGroup1, 0, 0 ); + SMESHGUI_Preferences_ColorDlgLayout->addWidget(ButtonGroup1, 0, 0); - ButtonGroup2 = new QButtonGroup( tr( "Nodes" ), this, "ButtonGroup2" ); - ButtonGroup2->setColumnLayout(0, Qt::Vertical ); - ButtonGroup2->layout()->setSpacing( 0 ); - ButtonGroup2->layout()->setMargin( 0 ); - QGridLayout* ButtonGroup2Layout = new QGridLayout( ButtonGroup2->layout() ); - ButtonGroup2Layout->setAlignment( Qt::AlignTop ); - ButtonGroup2Layout->setSpacing( 6 ); - ButtonGroup2Layout->setMargin( 11 ); + ButtonGroup2 = new QButtonGroup(tr("Nodes"), this, "ButtonGroup2"); + ButtonGroup2->setColumnLayout(0, Qt::Vertical); + ButtonGroup2->layout()->setSpacing(0); + ButtonGroup2->layout()->setMargin(0); + QGridLayout* ButtonGroup2Layout = new QGridLayout(ButtonGroup2->layout()); + ButtonGroup2Layout->setAlignment(Qt::AlignTop); + ButtonGroup2Layout->setSpacing(6); + ButtonGroup2Layout->setMargin(11); - TextLabel_Nodes_Color = new QLabel( tr( "Color" ), ButtonGroup2, "TextLabel_Nodes_Color" ); - ButtonGroup2Layout->addWidget( TextLabel_Nodes_Color, 0, 0 ); + TextLabel_Nodes_Color = new QLabel(tr("Color"), ButtonGroup2, "TextLabel_Nodes_Color"); + ButtonGroup2Layout->addWidget(TextLabel_Nodes_Color, 0, 0); - btnNodeColor = new QPushButton( ButtonGroup2, "btnNodeColor" ); - btnNodeColor->setFixedSize( QSize( 25, 25 ) ); - ButtonGroup2Layout->addWidget( btnNodeColor, 0, 1 ); + btnNodeColor = new QPushButton(ButtonGroup2, "btnNodeColor"); + btnNodeColor->setFixedSize(QSize(25, 25)); + ButtonGroup2Layout->addWidget(btnNodeColor, 0, 1); - TextLabel_Nodes_Size = new QLabel( tr( "Size" ), ButtonGroup2, "TextLabel_Nodes_Size" ); - ButtonGroup2Layout->addWidget( TextLabel_Nodes_Size, 0, 2 ); + TextLabel_Nodes_Size = new QLabel(tr("Size"), ButtonGroup2, "TextLabel_Nodes_Size"); + ButtonGroup2Layout->addWidget(TextLabel_Nodes_Size, 0, 2); - SpinBox_Nodes_Size = new QSpinBox( 0, 5, 1, ButtonGroup2, "SpinBox_Nodes_Size" ); - SpinBox_Nodes_Size->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - SpinBox_Nodes_Size->setWrapping( FALSE ); - SpinBox_Nodes_Size->setButtonSymbols( QSpinBox::PlusMinus ); - ButtonGroup2Layout->addWidget( SpinBox_Nodes_Size, 0, 3 ); + SpinBox_Nodes_Size = new QSpinBox(0, 5, 1, ButtonGroup2, "SpinBox_Nodes_Size"); + SpinBox_Nodes_Size->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); + SpinBox_Nodes_Size->setWrapping(FALSE); + SpinBox_Nodes_Size->setButtonSymbols(QSpinBox::PlusMinus); + ButtonGroup2Layout->addWidget(SpinBox_Nodes_Size, 0, 3); - SMESHGUI_Preferences_ColorDlgLayout->addWidget( ButtonGroup2, 1, 0 ); + SMESHGUI_Preferences_ColorDlgLayout->addWidget(ButtonGroup2, 1, 0); - GroupButtons = new QButtonGroup( this, "GroupButtons" ); - GroupButtons->setColumnLayout(0, Qt::Vertical ); - GroupButtons->layout()->setSpacing( 0 ); - GroupButtons->layout()->setMargin( 0 ); - QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); - GroupButtonsLayout->setAlignment( Qt::AlignTop ); - GroupButtonsLayout->setSpacing( 6 ); - GroupButtonsLayout->setMargin( 11 ); + GroupButtons = new QButtonGroup(this, "GroupButtons"); + GroupButtons->setColumnLayout(0, Qt::Vertical); + GroupButtons->layout()->setSpacing(0); + GroupButtons->layout()->setMargin(0); + QGridLayout* GroupButtonsLayout = new QGridLayout(GroupButtons->layout()); + GroupButtonsLayout->setAlignment(Qt::AlignTop); + GroupButtonsLayout->setSpacing(6); + GroupButtonsLayout->setMargin(11); - buttonOk = new QPushButton( tr( "&OK" ), GroupButtons, "buttonOk" ); - buttonOk->setAutoDefault( TRUE ); - buttonOk->setDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); + buttonOk = new QPushButton(tr("&OK"), GroupButtons, "buttonOk"); + buttonOk->setAutoDefault(TRUE); + buttonOk->setDefault(TRUE); + GroupButtonsLayout->addWidget(buttonOk, 0, 0); - GroupButtonsLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 ); + GroupButtonsLayout->addItem(new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, 1); - buttonCancel = new QPushButton( tr( "&Cancel" ), GroupButtons, "buttonCancel" ); - buttonCancel->setAutoDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonCancel, 0, 2 ); + buttonCancel = new QPushButton(tr("&Cancel"), GroupButtons, "buttonCancel"); + buttonCancel->setAutoDefault(TRUE); + GroupButtonsLayout->addWidget(buttonCancel, 0, 2); - SMESHGUI_Preferences_ColorDlgLayout->addWidget( GroupButtons, 2, 0 ); + SMESHGUI_Preferences_ColorDlgLayout->addWidget(GroupButtons, 2, 0); Init(); } -/* - * Destroys the object and frees any allocated resources - */ +//================================================================================= +// function : ~SMESHGUI_Preferences_ColorDlg() +// purpose : Destructor +//================================================================================= SMESHGUI_Preferences_ColorDlg::~SMESHGUI_Preferences_ColorDlg() { - // no need to delete child widgets, Qt does it all for us + // no need to delete child widgets, Qt does it all for us } //================================================================================= @@ -176,27 +181,27 @@ SMESHGUI_Preferences_ColorDlg::~SMESHGUI_Preferences_ColorDlg() // purpose : //================================================================================= void SMESHGUI_Preferences_ColorDlg::Init() -{ - mySMESHGUI = SMESHGUI::GetSMESHGUI() ; - mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; - +{ + mySMESHGUI = SMESHGUI::GetSMESHGUI(); + mySMESHGUI->SetActiveDialogBox((QDialog*)this); + /* signals and slots connections */ - connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); - connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ; + connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel())); - connect( btnFillColor, SIGNAL( clicked() ), this, SLOT( SelectFillColor() ) ) ; - connect( btnOutlineColor, SIGNAL( clicked() ), this, SLOT( SelectOutlineColor() ) ) ; - connect( btnNodeColor, SIGNAL( clicked() ), this, SLOT( SelectNodeColor() ) ) ; - connect( btnBackFaceColor, SIGNAL( clicked() ), this, SLOT( SelectBackFaceColor() ) ) ; + connect(btnFillColor, SIGNAL(clicked()), this, SLOT(SelectFillColor())); + connect(btnOutlineColor, SIGNAL(clicked()), this, SLOT(SelectOutlineColor())); + connect(btnNodeColor, SIGNAL(clicked()), this, SLOT(SelectNodeColor())); + connect(btnBackFaceColor, SIGNAL(clicked()), this, SLOT(SelectBackFaceColor())); - connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; + connect(mySMESHGUI, SIGNAL (SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog())); /* to close dialog if study change */ - connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; - + connect(mySMESHGUI, SIGNAL (SignalCloseAllDialogs()), this, SLOT(ClickOnCancel())); + /* Move widget on the botton right corner of main widget */ - int x, y ; - mySMESHGUI->DefineDlgPosition( this, x, y ) ; - this->move( x, y ) ; + int x, y; + mySMESHGUI->DefineDlgPosition(this, x, y); + this->move(x, y); } //================================================================================= @@ -206,8 +211,8 @@ void SMESHGUI_Preferences_ColorDlg::Init() void SMESHGUI_Preferences_ColorDlg::SelectFillColor() { QColor color = btnFillColor->palette().active().button(); - color = QColorDialog::getColor( color ); - if ( color.isValid() ) { + color = QColorDialog::getColor(color); + if (color.isValid()) { QPalette pal = btnFillColor->palette(); pal.setColor(QColorGroup::Button, color); btnFillColor->setPalette(pal); @@ -221,8 +226,8 @@ void SMESHGUI_Preferences_ColorDlg::SelectFillColor() void SMESHGUI_Preferences_ColorDlg::SelectBackFaceColor() { QColor color = btnBackFaceColor->palette().active().button(); - color = QColorDialog::getColor( color ); - if ( color.isValid() ) { + color = QColorDialog::getColor(color); + if (color.isValid()) { QPalette pal = btnBackFaceColor->palette(); pal.setColor(QColorGroup::Button, color); btnBackFaceColor->setPalette(pal); @@ -236,8 +241,8 @@ void SMESHGUI_Preferences_ColorDlg::SelectBackFaceColor() void SMESHGUI_Preferences_ColorDlg::SelectOutlineColor() { QColor color = btnOutlineColor->palette().active().button(); - color = QColorDialog::getColor( color ); - if ( color.isValid() ) { + color = QColorDialog::getColor(color); + if (color.isValid()) { QPalette pal = btnOutlineColor->palette(); pal.setColor(QColorGroup::Button, color); btnOutlineColor->setPalette(pal); @@ -251,8 +256,8 @@ void SMESHGUI_Preferences_ColorDlg::SelectOutlineColor() void SMESHGUI_Preferences_ColorDlg::SelectNodeColor() { QColor color = btnNodeColor->palette().active().button(); - color = QColorDialog::getColor( color ); - if ( color.isValid() ) { + color = QColorDialog::getColor(color); + if (color.isValid()) { QPalette pal = btnNodeColor->palette(); pal.setColor(QColorGroup::Button, color); btnNodeColor->setPalette(pal); @@ -276,7 +281,7 @@ void SMESHGUI_Preferences_ColorDlg::ClickOnOk() void SMESHGUI_Preferences_ColorDlg::ClickOnCancel() { mySMESHGUI->ResetState(); - reject() ; + reject(); } //================================================================================= @@ -285,18 +290,15 @@ void SMESHGUI_Preferences_ColorDlg::ClickOnCancel() //================================================================================= void SMESHGUI_Preferences_ColorDlg::DeactivateActiveDialog() { - return ; } - - //================================================================================= // function : closeEvent() // purpose : //================================================================================= -void SMESHGUI_Preferences_ColorDlg::closeEvent( QCloseEvent* e ) +void SMESHGUI_Preferences_ColorDlg::closeEvent (QCloseEvent*) { - this->ClickOnCancel() ; /* same than click on cancel button */ + this->ClickOnCancel(); /* same than click on cancel button */ } //================================================================================= @@ -306,19 +308,17 @@ void SMESHGUI_Preferences_ColorDlg::closeEvent( QCloseEvent* e ) void SMESHGUI_Preferences_ColorDlg::ActivateThisDialog() { /* Emit a signal to deactivate any active dialog */ - mySMESHGUI->EmitSignalDeactivateDialog() ; - - return ; + mySMESHGUI->EmitSignalDeactivateDialog(); } //================================================================================= // function : SetColor() // purpose : //================================================================================= -void SMESHGUI_Preferences_ColorDlg::SetColor(int type, QColor color) +void SMESHGUI_Preferences_ColorDlg::SetColor (int type, QColor color) { switch (type) { - case 1 : // fill + case 1 : // fill { QPalette pal = btnFillColor->palette(); pal.setColor(QColorGroup::Button, color); @@ -353,7 +353,7 @@ void SMESHGUI_Preferences_ColorDlg::SetColor(int type, QColor color) // function : GetColor() // purpose : //================================================================================= -QColor SMESHGUI_Preferences_ColorDlg::GetColor(int type) +QColor SMESHGUI_Preferences_ColorDlg::GetColor (int type) { QColor color; switch (type) { @@ -367,9 +367,9 @@ QColor SMESHGUI_Preferences_ColorDlg::GetColor(int type) //================================================================================= // function : SetIntValue() -// purpose : +// purpose : //================================================================================= -void SMESHGUI_Preferences_ColorDlg::SetIntValue(int type, int value) +void SMESHGUI_Preferences_ColorDlg::SetIntValue (int type, int value) { switch (type) { case 1 : SpinBox_Width->setValue(value); break; // width @@ -380,9 +380,9 @@ void SMESHGUI_Preferences_ColorDlg::SetIntValue(int type, int value) //================================================================================= // function : GetIntValue() -// purpose : +// purpose : //================================================================================= -int SMESHGUI_Preferences_ColorDlg::GetIntValue(int type) +int SMESHGUI_Preferences_ColorDlg::GetIntValue (int type) { int res = 0; switch (type) { diff --git a/src/SMESHGUI/SMESHGUI_Preferences_ColorDlg.h b/src/SMESHGUI/SMESHGUI_Preferences_ColorDlg.h index 296312ab0..5ad2c5403 100644 --- a/src/SMESHGUI/SMESHGUI_Preferences_ColorDlg.h +++ b/src/SMESHGUI/SMESHGUI_Preferences_ColorDlg.h @@ -30,8 +30,8 @@ #define SMESHGUI_PREFERENCES_COLORDLG_H // SALOME Includes -#include "QAD_Config.h" -#include "QAD_Settings.h" +//#include "SUIT_Config.h" +//#include "SUIT_Settings.h" // IDL Headers #include diff --git a/src/SMESHGUI/SMESHGUI_Preferences_ScalarBarDlg.cxx b/src/SMESHGUI/SMESHGUI_Preferences_ScalarBarDlg.cxx index c2474d067..850194b22 100644 --- a/src/SMESHGUI/SMESHGUI_Preferences_ScalarBarDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_Preferences_ScalarBarDlg.cxx @@ -1,23 +1,23 @@ // SMESH SMESHGUI : GUI for SMESH component // // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org // // // @@ -31,6 +31,15 @@ #include "SMESHGUI.h" #include "SMESHGUI_VTKUtils.h" +#include "SMESH_Actor.h" + +#include "SUIT_ResourceMgr.h" + +#include "SalomeApp_SelectionMgr.h" +#include "SALOME_ListIO.hxx" + +#include + #include #include #include @@ -49,12 +58,6 @@ #include #include -#include "QAD_SpinBoxDbl.h" -#include "QAD_Config.h" -#include "SALOME_Selection.h" -#include "SMESHGUI.h" -#include "SMESH_Actor.h" - #define MINIMUM_WIDTH 70 #define MARGIN_SIZE 11 #define SPACING_SIZE 6 @@ -80,14 +83,13 @@ SMESHGUI_Preferences_ScalarBarDlg* SMESHGUI_Preferences_ScalarBarDlg::myDlg = 0; * Gets the only instance of "Scalar Bar Properties" dialog box */ //================================================================================================= -void SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties(QWidget* parent, - SALOME_Selection* Sel) +void SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties (QWidget* parent, + SalomeApp_SelectionMgr* Sel) { - if ( !myDlg ) { - myDlg = new SMESHGUI_Preferences_ScalarBarDlg( parent, Sel, false ); + if (!myDlg) { + myDlg = new SMESHGUI_Preferences_ScalarBarDlg (parent, Sel, false); myDlg->show(); - } - else { + } else { myDlg->show(); myDlg->setActiveWindow(); myDlg->raise(); @@ -102,9 +104,10 @@ void SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties(QWidget* parent, * Opens "Scalar Bar Preferences" dialog box */ //================================================================================================= -void SMESHGUI_Preferences_ScalarBarDlg::ScalarBarPreferences( QWidget* parent ) +void SMESHGUI_Preferences_ScalarBarDlg::ScalarBarPreferences (QWidget* parent) { - SMESHGUI_Preferences_ScalarBarDlg* aDlg = new SMESHGUI_Preferences_ScalarBarDlg( parent, 0, true ); + SMESHGUI_Preferences_ScalarBarDlg* aDlg = + new SMESHGUI_Preferences_ScalarBarDlg (parent, 0, true); aDlg->exec(); } @@ -115,16 +118,17 @@ void SMESHGUI_Preferences_ScalarBarDlg::ScalarBarPreferences( QWidget* parent ) * Constructor */ //================================================================================================= -SMESHGUI_Preferences_ScalarBarDlg::SMESHGUI_Preferences_ScalarBarDlg(QWidget* parent, - SALOME_Selection* Sel, - bool modal) - : QDialog( parent, 0, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose ) +SMESHGUI_Preferences_ScalarBarDlg::SMESHGUI_Preferences_ScalarBarDlg (QWidget* parent, + SalomeApp_SelectionMgr* Sel, + bool modal) + : QDialog(parent, 0, modal, WStyle_Customize | WStyle_NormalBorder | + WStyle_Title | WStyle_SysMenu | WDestructiveClose) { - setName( "SMESHGUI_Preferences_ScalarBarDlg" ); - setCaption( Sel ? tr( "SMESH_PROPERTIES_SCALARBAR" ) : tr( "SMESH_PREFERENCES_SCALARBAR" ) ); - setSizeGripEnabled( TRUE ); + setName("SMESHGUI_Preferences_ScalarBarDlg"); + setCaption(Sel ? tr("SMESH_PROPERTIES_SCALARBAR") : tr("SMESH_PREFERENCES_SCALARBAR")); + setSizeGripEnabled(TRUE); - mySelection = Sel; + mySelectionMgr = Sel; myActor = 0; /******************************************************************************/ @@ -135,14 +139,14 @@ SMESHGUI_Preferences_ScalarBarDlg::SMESHGUI_Preferences_ScalarBarDlg(QWidget* pa /******************************************************************************/ // Scalar range - if ( mySelection ) { + if ( mySelectionMgr ) { myRangeGrp = new QGroupBox ( tr( "SMESH_RANGE_SCALARBAR" ), this, "myRangeGrp" ); myRangeGrp->setColumnLayout( 0, Qt::Vertical ); myRangeGrp->layout()->setSpacing( 0 ); myRangeGrp->layout()->setMargin( 0 ); QGridLayout* myRangeGrpLayout = new QGridLayout( myRangeGrp->layout() ); myRangeGrpLayout->setAlignment( Qt::AlignTop ); myRangeGrpLayout->setSpacing( SPACING_SIZE ); myRangeGrpLayout->setMargin( MARGIN_SIZE ); - + myMinEdit = new QLineEdit( myRangeGrp, "myMinEdit" ); myMinEdit->setMinimumWidth( MINIMUM_WIDTH ); myMinEdit->setValidator( new QDoubleValidator( this ) ); @@ -168,29 +172,29 @@ SMESHGUI_Preferences_ScalarBarDlg::SMESHGUI_Preferences_ScalarBarDlg(QWidget* pa QGridLayout* myFontGrpLayout = new QGridLayout( myFontGrp->layout() ); myFontGrpLayout->setAlignment( Qt::AlignTop ); myFontGrpLayout->setSpacing( SPACING_SIZE ); myFontGrpLayout->setMargin( MARGIN_SIZE ); - + myTitleColorBtn = new QToolButton( myFontGrp, "myTitleColorBtn" ); - + myTitleFontCombo = new QComboBox( false, myFontGrp, "myTitleFontCombo" ); myTitleFontCombo->setMinimumWidth( MINIMUM_WIDTH ); myTitleFontCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); myTitleFontCombo->insertItem( tr( "SMESH_FONT_ARIAL" ) ); myTitleFontCombo->insertItem( tr( "SMESH_FONT_COURIER" ) ); myTitleFontCombo->insertItem( tr( "SMESH_FONT_TIMES" ) ); - + myTitleBoldCheck = new QCheckBox( tr( "SMESH_FONT_BOLD" ), myFontGrp, "myTitleBoldCheck" ); myTitleItalicCheck = new QCheckBox( tr( "SMESH_FONT_ITALIC" ), myFontGrp, "myTitleItalicCheck" ); myTitleShadowCheck = new QCheckBox( tr( "SMESH_FONT_SHADOW" ), myFontGrp, "myTitleShadowCheck" ); myLabelsColorBtn = new QToolButton( myFontGrp, "myLabelsColorBtn" ); - + myLabelsFontCombo = new QComboBox( false, myFontGrp, "myLabelsFontCombo" ); myLabelsFontCombo->setMinimumWidth( MINIMUM_WIDTH ); myLabelsFontCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); myLabelsFontCombo->insertItem( tr( "SMESH_FONT_ARIAL" ) ); myLabelsFontCombo->insertItem( tr( "SMESH_FONT_COURIER" ) ); myLabelsFontCombo->insertItem( tr( "SMESH_FONT_TIMES" ) ); - + myLabelsBoldCheck = new QCheckBox( tr( "SMESH_FONT_BOLD" ), myFontGrp, "myLabelsBoldCheck" ); myLabelsItalicCheck = new QCheckBox( tr( "SMESH_FONT_ITALIC" ), myFontGrp, "myLabelsItalicCheck" ); myLabelsShadowCheck = new QCheckBox( tr( "SMESH_FONT_SHADOW" ), myFontGrp, "myLabelsShadowCheck" ); @@ -201,7 +205,7 @@ SMESHGUI_Preferences_ScalarBarDlg::SMESHGUI_Preferences_ScalarBarDlg(QWidget* pa myFontGrpLayout->addWidget( myTitleBoldCheck, 0, 3 ); myFontGrpLayout->addWidget( myTitleItalicCheck, 0, 4 ); myFontGrpLayout->addWidget( myTitleShadowCheck, 0, 5 ); - + myFontGrpLayout->addWidget( new QLabel( tr( "SMESH_LABELS" ), myFontGrp, "myFontLabelsLab" ), 1, 0 ); myFontGrpLayout->addWidget( myLabelsColorBtn, 1, 1 ); myFontGrpLayout->addWidget( myLabelsFontCombo, 1, 2 ); @@ -220,7 +224,7 @@ SMESHGUI_Preferences_ScalarBarDlg::SMESHGUI_Preferences_ScalarBarDlg(QWidget* pa QGridLayout* myLabColorGrpLayout = new QGridLayout( myLabColorGrp->layout() ); myLabColorGrpLayout->setAlignment( Qt::AlignTop ); myLabColorGrpLayout->setSpacing( SPACING_SIZE ); myLabColorGrpLayout->setMargin( MARGIN_SIZE ); - + myColorsSpin = new QSpinBox( 2, 256, 1, myLabColorGrp, "myColorsSpin" ); myColorsSpin->setMinimumWidth( MINIMUM_WIDTH ); myColorsSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); @@ -245,7 +249,7 @@ SMESHGUI_Preferences_ScalarBarDlg::SMESHGUI_Preferences_ScalarBarDlg(QWidget* pa QGridLayout* myOrientationGrpLayout = new QGridLayout( myOrientationGrp->layout() ); myOrientationGrpLayout->setAlignment( Qt::AlignTop ); myOrientationGrpLayout->setSpacing( SPACING_SIZE ); myOrientationGrpLayout->setMargin( MARGIN_SIZE ); - + myVertRadioBtn = new QRadioButton( tr( "SMESH_VERTICAL" ), myOrientationGrp, "myVertRadioBtn" ); myHorizRadioBtn = new QRadioButton( tr( "SMESH_HORIZONTAL" ), myOrientationGrp, "myHorizRadioBtn" ); myVertRadioBtn->setChecked( true ); @@ -258,26 +262,26 @@ SMESHGUI_Preferences_ScalarBarDlg::SMESHGUI_Preferences_ScalarBarDlg(QWidget* pa /******************************************************************************/ // Position & Size - myOriginDimGrp = new QGroupBox ( tr( "SMESH_POSITION_SIZE_SCALARBAR" ), this, "myOriginDimGrp" ); - myOriginDimGrp->setColumnLayout( 0, Qt::Vertical ); + myOriginDimGrp = new QGroupBox (tr("SMESH_POSITION_SIZE_SCALARBAR"), this, "myOriginDimGrp"); + myOriginDimGrp->setColumnLayout(0, Qt::Vertical); myOriginDimGrp->layout()->setSpacing( 0 ); myOriginDimGrp->layout()->setMargin( 0 ); QGridLayout* myOriginDimGrpLayout = new QGridLayout( myOriginDimGrp->layout() ); myOriginDimGrpLayout->setAlignment( Qt::AlignTop ); myOriginDimGrpLayout->setSpacing( SPACING_SIZE ); myOriginDimGrpLayout->setMargin( MARGIN_SIZE ); - - myXSpin = new QAD_SpinBoxDbl( myOriginDimGrp, 0.0, 1.0, 0.1 ); + + myXSpin = new QtxDblSpinBox (0.0, 1.0, 0.1, myOriginDimGrp); myXSpin->setMinimumWidth( MINIMUM_WIDTH ); myXSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - myYSpin = new QAD_SpinBoxDbl( myOriginDimGrp, 0.0, 1.0, 0.1 ); + myYSpin = new QtxDblSpinBox(0.0, 1.0, 0.1, myOriginDimGrp); myYSpin->setMinimumWidth( MINIMUM_WIDTH ); myYSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - myWidthSpin = new QAD_SpinBoxDbl( myOriginDimGrp, 0.0, 1.0, 0.1 ); + myWidthSpin = new QtxDblSpinBox(0.0, 1.0, 0.1, myOriginDimGrp); myWidthSpin->setMinimumWidth( MINIMUM_WIDTH ); myWidthSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - myHeightSpin = new QAD_SpinBoxDbl( myOriginDimGrp, 0.0, 1.0, 0.1 ); + myHeightSpin = new QtxDblSpinBox(0.0, 1.0, 0.1, myOriginDimGrp); myHeightSpin->setMinimumWidth( MINIMUM_WIDTH ); myHeightSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); @@ -305,14 +309,14 @@ SMESHGUI_Preferences_ScalarBarDlg::SMESHGUI_Preferences_ScalarBarDlg(QWidget* pa myOkBtn = new QPushButton( tr( "SMESH_BUT_OK" ), myButtonGrp, "myOkBtn" ); myOkBtn->setAutoDefault( TRUE ); myOkBtn->setDefault( TRUE ); myButtonGrpLayout->addWidget( myOkBtn ); - if ( mySelection ) { + if ( mySelectionMgr ) { myApplyBtn = new QPushButton( tr( "SMESH_BUT_APPLY" ), myButtonGrp, "myApplyBtn" ); myApplyBtn->setAutoDefault( TRUE ); myButtonGrpLayout->addWidget( myApplyBtn ); } myButtonGrpLayout->addStretch(); myCancelBtn = new QPushButton( tr( "SMESH_BUT_CANCEL" ), myButtonGrp, "myCancelBtn" ); - if ( mySelection ) + if ( mySelectionMgr ) myCancelBtn->setText( tr( "SMESH_BUT_CLOSE" ) ); myCancelBtn->setAutoDefault( TRUE ); myButtonGrpLayout->addWidget( myCancelBtn ); @@ -322,87 +326,96 @@ SMESHGUI_Preferences_ScalarBarDlg::SMESHGUI_Preferences_ScalarBarDlg(QWidget* pa /***************************************************************/ // Init // --> first init from preferences - QColor titleColor( 255, 255, 255 ); - if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarTitleColor" ) ) { - QStringList aTColor = QStringList::split( ":", QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleColor" ), false ); - titleColor = QColor( ( aTColor.count() > 0 ? aTColor[0].toInt() : 255 ), - ( aTColor.count() > 1 ? aTColor[1].toInt() : 255 ), - ( aTColor.count() > 2 ? aTColor[2].toInt() : 255 ) ); - } - myTitleColorBtn->setPaletteBackgroundColor( titleColor ); - myTitleFontCombo->setCurrentItem( 0 ); - if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarTitleFont" ) ) { - if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleFont" ) == "Arial" ) - myTitleFontCombo->setCurrentItem( 0 ); - if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleFont" ) == "Courier" ) - myTitleFontCombo->setCurrentItem( 1 ); - if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleFont" ) == "Times" ) - myTitleFontCombo->setCurrentItem( 2 ); - } - myTitleBoldCheck->setChecked( QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleBold" ) == "true" ); - myTitleItalicCheck->setChecked( QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleItalic" ) == "true" ); - myTitleShadowCheck->setChecked( QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleShadow" ) == "true" ); + SUIT_ResourceMgr* mgr = SMESHGUI::resourceMgr(); - QColor labelColor( 255, 255, 255 ); - if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarLabelColor" ) ) { - QStringList aLColor = QStringList::split( ":", QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelColor" ), false ); - labelColor = QColor( ( aLColor.count() > 0 ? aLColor[0].toInt() : 255 ), - ( aLColor.count() > 1 ? aLColor[1].toInt() : 255 ), - ( aLColor.count() > 2 ? aLColor[2].toInt() : 255 ) ); + QColor titleColor (255, 255, 255); + if (mgr && mgr->hasValue("SMESH", "ScalarBarTitleColor")) { + QStringList aTColor = + QStringList::split(":", mgr->stringValue("SMESH", "ScalarBarTitleColor"), false); + titleColor = QColor((aTColor.count() > 0 ? aTColor[0].toInt() : 255), + (aTColor.count() > 1 ? aTColor[1].toInt() : 255), + (aTColor.count() > 2 ? aTColor[2].toInt() : 255)); } - myLabelsColorBtn->setPaletteBackgroundColor( labelColor ); - myLabelsFontCombo->setCurrentItem( 0 ); - if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarLabelFont" ) ) { - if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelFont" ) == "Arial" ) - myLabelsFontCombo->setCurrentItem( 0 ); - if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelFont" ) == "Courier" ) - myLabelsFontCombo->setCurrentItem( 1 ); - if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelFont" ) == "Times" ) - myLabelsFontCombo->setCurrentItem( 2 ); + myTitleColorBtn->setPaletteBackgroundColor(titleColor); + myTitleFontCombo->setCurrentItem(0); + if (mgr && mgr->hasValue("SMESH", "ScalarBarTitleFont")) { + if (mgr->stringValue("SMESH", "ScalarBarTitleFont") == "Arial") + myTitleFontCombo->setCurrentItem(0); + if (mgr->stringValue("SMESH", "ScalarBarTitleFont") == "Courier") + myTitleFontCombo->setCurrentItem(1); + if (mgr->stringValue("SMESH", "ScalarBarTitleFont") == "Times") + myTitleFontCombo->setCurrentItem(2); } - myLabelsBoldCheck->setChecked( QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelBold" ) == "true" ); - myLabelsItalicCheck->setChecked( QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelItalic" ) == "true" ); - myLabelsShadowCheck->setChecked( QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelShadow" ) == "true" ); + myTitleBoldCheck->setChecked (mgr && mgr->stringValue("SMESH", "ScalarBarTitleBold") == "true"); + myTitleItalicCheck->setChecked(mgr && mgr->stringValue("SMESH", "ScalarBarTitleItalic") == "true"); + myTitleShadowCheck->setChecked(mgr && mgr->stringValue("SMESH", "ScalarBarTitleShadow") == "true"); + + QColor labelColor (255, 255, 255); + if (mgr && mgr->hasValue("SMESH", "ScalarBarLabelColor")) { + QStringList aLColor = + QStringList::split(":", mgr->stringValue("SMESH", "ScalarBarLabelColor"), false); + labelColor = QColor((aLColor.count() > 0 ? aLColor[0].toInt() : 255), + (aLColor.count() > 1 ? aLColor[1].toInt() : 255), + (aLColor.count() > 2 ? aLColor[2].toInt() : 255)); + } + myLabelsColorBtn->setPaletteBackgroundColor(labelColor); + myLabelsFontCombo->setCurrentItem(0); + if (mgr && mgr->hasValue("SMESH", "ScalarBarLabelFont")) { + if (mgr->stringValue("SMESH", "ScalarBarLabelFont") == "Arial") + myLabelsFontCombo->setCurrentItem(0); + if (mgr->stringValue("SMESH", "ScalarBarLabelFont") == "Courier") + myLabelsFontCombo->setCurrentItem(1); + if (mgr->stringValue("SMESH", "ScalarBarLabelFont") == "Times") + myLabelsFontCombo->setCurrentItem(2); + } + myLabelsBoldCheck ->setChecked(mgr && mgr->stringValue("SMESH", "ScalarBarLabelBold") == "true"); + myLabelsItalicCheck->setChecked(mgr && mgr->stringValue("SMESH", "ScalarBarLabelItalic") == "true"); + myLabelsShadowCheck->setChecked(mgr && mgr->stringValue("SMESH", "ScalarBarLabelShadow") == "true"); int aNbColors = 64; - if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarNbOfColors" ) ) - aNbColors = QAD_CONFIG->getSetting( "SMESH:ScalarBarNbOfColors" ).toInt(); - myColorsSpin->setValue( aNbColors ); - int aNbLabels = 5; - if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarNbOfLabels" ) ) - aNbLabels = QAD_CONFIG->getSetting( "SMESH:ScalarBarNbOfLabels" ).toInt(); - myLabelsSpin->setValue( aNbLabels ); + if (mgr && mgr->hasValue("SMESH", "ScalarBarNbOfColors")) + aNbColors = mgr->integerValue("SMESH", "ScalarBarNbOfColors"); + myColorsSpin->setValue(aNbColors); - QString aOrientation = QAD_CONFIG->getSetting( "SMESH:ScalarBarOrientation" ); - if ( aOrientation == "Horizontal" ) - myHorizRadioBtn->setChecked( true ); + int aNbLabels = 5; + if (mgr && mgr->hasValue("SMESH", "ScalarBarNbOfLabels")) + aNbLabels = mgr->integerValue("SMESH", "ScalarBarNbOfLabels"); + myLabelsSpin->setValue(aNbLabels); + + QString aOrientation = (mgr ? mgr->stringValue("SMESH", "ScalarBarOrientation") : ""); + if (aOrientation == "Horizontal") + myHorizRadioBtn->setChecked(true); else - myVertRadioBtn->setChecked( true ); + myVertRadioBtn->setChecked(true); myIniOrientation = myVertRadioBtn->isChecked(); - if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarXPosition" ) ) - myIniX = QAD_CONFIG->getSetting( "SMESH:ScalarBarXPosition" ).toDouble(); + if (mgr && mgr->hasValue("SMESH", "ScalarBarXPosition")) + myIniX = mgr->doubleValue("SMESH", "ScalarBarXPosition"); else myIniX = myHorizRadioBtn->isChecked() ? DEF_HOR_X : DEF_VER_X; - if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarYPosition" ) ) - myIniY = QAD_CONFIG->getSetting( "SMESH:ScalarBarYPosition" ).toDouble(); + + if (mgr && mgr->hasValue("SMESH", "ScalarBarYPosition")) + myIniY = mgr->doubleValue("SMESH", "ScalarBarYPosition"); else myIniY = myHorizRadioBtn->isChecked() ? DEF_HOR_Y : DEF_VER_Y; - if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarWidth" ) ) - myIniW = QAD_CONFIG->getSetting( "SMESH:ScalarBarWidth" ).toDouble(); + + if (mgr && mgr->hasValue("SMESH", "ScalarBarWidth")) + myIniW = mgr->doubleValue("SMESH", "ScalarBarWidth"); else myIniW = myHorizRadioBtn->isChecked() ? DEF_HOR_W : DEF_VER_W; - if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarHeight" ) ) - myIniH = QAD_CONFIG->getSetting( "SMESH:ScalarBarHeight" ).toDouble(); + + if (mgr && mgr->hasValue("SMESH", "ScalarBarHeight")) + myIniH = mgr->doubleValue("SMESH", "ScalarBarHeight"); else myIniH = myHorizRadioBtn->isChecked() ? DEF_HOR_H : DEF_VER_H; - setOriginAndSize( myIniX, myIniY, myIniW, myIniH ); - if ( mySelection ) { + setOriginAndSize(myIniX, myIniY, myIniW, myIniH); + + if (mySelectionMgr) { // --> then init from selection if necessary onSelectionChanged(); } - + /***************************************************************/ // Connect section connect( myTitleColorBtn, SIGNAL( clicked() ), this, SLOT( onTitleColor() ) ); @@ -412,9 +425,9 @@ SMESHGUI_Preferences_ScalarBarDlg::SMESHGUI_Preferences_ScalarBarDlg(QWidget* pa connect( myXSpin, SIGNAL( valueChanged( double ) ), this, SLOT( onXYChanged() ) ); connect( myYSpin, SIGNAL( valueChanged( double ) ), this, SLOT( onXYChanged() ) ); connect( myOrientationGrp, SIGNAL( clicked( int ) ), this, SLOT( onOrientationChanged() ) ); - if ( mySelection ) { + if ( mySelectionMgr ) { connect( myApplyBtn, SIGNAL( clicked() ), this, SLOT( onApply() ) ); - connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionChanged() ) ); + connect( mySelectionMgr, SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionChanged() ) ); } connect( SMESHGUI::GetSMESHGUI(), SIGNAL( SignalCloseAllDialogs() ), this, SLOT( onCancel() ) ) ; } @@ -452,9 +465,9 @@ void SMESHGUI_Preferences_ScalarBarDlg::onOk() //================================================================================================= bool SMESHGUI_Preferences_ScalarBarDlg::onApply() { - if ( mySelection ) { + if (mySelectionMgr) { // Scalar Bar properties - if ( !myActor ) + if (!myActor) return false; vtkScalarBarActor* myScalarBarActor = myActor->GetScalarBarActor(); @@ -502,42 +515,49 @@ bool SMESHGUI_Preferences_ScalarBarDlg::onApply() double aMax = myMaxEdit->text().toDouble(); myScalarBarActor->GetLookupTable()->SetRange( aMin, aMax ); SMESH::RepaintCurrentView(); - } - else { + } else { // Scalar Bar preferences + SUIT_ResourceMgr* mgr = SMESHGUI::resourceMgr(); + if (!mgr) return false; + QColor titleColor = myTitleColorBtn->paletteBackgroundColor(); - QAD_CONFIG->addSetting( "SMESH:ScalarBarTitleColor", QString().sprintf( "%d:%d:%d", titleColor.red(), titleColor.green(), titleColor.blue() ) ); - if ( myTitleFontCombo->currentItem() == 0 ) - QAD_CONFIG->addSetting( "SMESH:ScalarBarTitleFont", "Arial" ); - else if ( myTitleFontCombo->currentItem() == 1 ) - QAD_CONFIG->addSetting( "SMESH:ScalarBarTitleFont", "Courier" ); + mgr->setValue("SMESH", "ScalarBarTitleColor", + QString().sprintf("%d:%d:%d", titleColor.red(), titleColor.green(), titleColor.blue())); + if (myTitleFontCombo->currentItem() == 0) + mgr->setValue("SMESH", "ScalarBarTitleFont", "Arial"); + else if (myTitleFontCombo->currentItem() == 1) + mgr->setValue("SMESH", "ScalarBarTitleFont", "Courier"); else - QAD_CONFIG->addSetting( "SMESH:ScalarBarTitleFont", "Times" ); - QAD_CONFIG->addSetting( "SMESH:ScalarBarTitleBold", myTitleBoldCheck->isChecked() ? "true" : "false" ); - QAD_CONFIG->addSetting( "SMESH:ScalarBarTitleItalic", myTitleItalicCheck->isChecked() ? "true" : "false" ); - QAD_CONFIG->addSetting( "SMESH:ScalarBarTitleShadow", myTitleShadowCheck->isChecked() ? "true" : "false" ); + mgr->setValue("SMESH", "ScalarBarTitleFont", "Times"); + + mgr->setValue("SMESH", "ScalarBarTitleBold" , myTitleBoldCheck ->isChecked() ? "true" : "false"); + mgr->setValue("SMESH", "ScalarBarTitleItalic", myTitleItalicCheck->isChecked() ? "true" : "false"); + mgr->setValue("SMESH", "ScalarBarTitleShadow", myTitleShadowCheck->isChecked() ? "true" : "false"); QColor labelColor = myLabelsColorBtn->paletteBackgroundColor(); - QAD_CONFIG->addSetting( "SMESH:ScalarBarLabelColor", QString().sprintf( "%d:%d:%d", labelColor.red(), labelColor.green(),labelColor. blue() ) ); - if ( myLabelsFontCombo->currentItem() == 0 ) - QAD_CONFIG->addSetting( "SMESH:ScalarBarLabelFont", "Arial" ); + mgr->setValue("SMESH", "ScalarBarLabelColor", + QString().sprintf("%d:%d:%d", labelColor.red(), labelColor.green(),labelColor. blue())); + + if (myLabelsFontCombo->currentItem() == 0) + mgr->setValue("SMESH", "ScalarBarLabelFont", "Arial"); else if ( myLabelsFontCombo->currentItem() == 1 ) - QAD_CONFIG->addSetting( "SMESH:ScalarBarLabelFont", "Courier" ); + mgr->setValue("SMESH", "ScalarBarLabelFont", "Courier"); else - QAD_CONFIG->addSetting( "SMESH:ScalarBarLabelFont", "Times" ); - QAD_CONFIG->addSetting( "SMESH:ScalarBarLabelBold", myLabelsBoldCheck->isChecked() ? "true" : "false" ); - QAD_CONFIG->addSetting( "SMESH:ScalarBarLabelItalic", myLabelsItalicCheck->isChecked() ? "true" : "false" ); - QAD_CONFIG->addSetting( "SMESH:ScalarBarLabelShadow", myLabelsShadowCheck->isChecked() ? "true" : "false" ); + mgr->setValue("SMESH", "ScalarBarLabelFont", "Times"); - QAD_CONFIG->addSetting( "SMESH:ScalarBarNbOfColors", myColorsSpin->value() ); - QAD_CONFIG->addSetting( "SMESH:ScalarBarNbOfLabels", myLabelsSpin->value() ); + mgr->setValue("SMESH", "ScalarBarLabelBold", myLabelsBoldCheck->isChecked() ? "true" : "false"); + mgr->setValue("SMESH", "ScalarBarLabelItalic", myLabelsItalicCheck->isChecked() ? "true" : "false"); + mgr->setValue("SMESH", "ScalarBarLabelShadow", myLabelsShadowCheck->isChecked() ? "true" : "false"); - QAD_CONFIG->addSetting( "SMESH:ScalarBarOrientation", myHorizRadioBtn->isChecked() ? "Horizontal" : "Vertical" ); - - QAD_CONFIG->addSetting( "SMESH:ScalarBarXPosition", myXSpin->value() ); - QAD_CONFIG->addSetting( "SMESH:ScalarBarYPosition", myYSpin->value() ); - QAD_CONFIG->addSetting( "SMESH:ScalarBarWidth", myWidthSpin->value() ); - QAD_CONFIG->addSetting( "SMESH:ScalarBarHeight", myHeightSpin->value() ); + mgr->setValue("SMESH", "ScalarBarNbOfColors", myColorsSpin->value()); + mgr->setValue("SMESH", "ScalarBarNbOfLabels", myLabelsSpin->value()); + + mgr->setValue("SMESH", "ScalarBarOrientation", myHorizRadioBtn->isChecked() ? "Horizontal" : "Vertical"); + + mgr->setValue("SMESH", "ScalarBarXPosition", myXSpin->value()); + mgr->setValue("SMESH", "ScalarBarYPosition", myYSpin->value()); + mgr->setValue("SMESH", "ScalarBarWidth", myWidthSpin->value()); + mgr->setValue("SMESH", "ScalarBarHeight", myHeightSpin->value()); } return true; } @@ -565,7 +585,7 @@ void SMESHGUI_Preferences_ScalarBarDlg::onTitleColor() { QColor aColor = myTitleColorBtn->paletteBackgroundColor(); aColor = QColorDialog::getColor( aColor, this ); - if ( aColor.isValid() ) + if ( aColor.isValid() ) myTitleColorBtn->setPaletteBackgroundColor( aColor ); } @@ -580,7 +600,7 @@ void SMESHGUI_Preferences_ScalarBarDlg::onLabelsColor() { QColor aColor = myLabelsColorBtn->paletteBackgroundColor(); aColor = QColorDialog::getColor( aColor, this ); - if ( aColor.isValid() ) + if ( aColor.isValid() ) myLabelsColorBtn->setPaletteBackgroundColor( aColor ); } @@ -593,15 +613,18 @@ void SMESHGUI_Preferences_ScalarBarDlg::onLabelsColor() //================================================================================================= void SMESHGUI_Preferences_ScalarBarDlg::onSelectionChanged() { - if( mySelection ) { - if ( mySelection->IObjectCount() == 1 ) { - Handle(SALOME_InteractiveObject) anIO = mySelection->firstIObject(); + if (mySelectionMgr) { + SALOME_ListIO aList; + mySelectionMgr->selectedObjects(aList); + + if (aList.Extent() == 1) { + Handle(SALOME_InteractiveObject) anIO = aList.First(); if( anIO->hasEntry() ) { SMESH_Actor* anActor = SMESH::FindActorByEntry(anIO->getEntry()); if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) { myActor = anActor; vtkScalarBarActor* myScalarBarActor = myActor->GetScalarBarActor(); - + if ( myScalarBarActor->GetLookupTable() ) { float *range = myScalarBarActor->GetLookupTable()->GetRange(); myMinEdit->setText( QString::number( range[0] ) ); @@ -634,7 +657,7 @@ void SMESHGUI_Preferences_ScalarBarDlg::onSelectionChanged() else myHorizRadioBtn->setChecked( true ); myIniOrientation = myVertRadioBtn->isChecked(); - + myIniX = myScalarBarActor->GetPosition()[0]; myIniY = myScalarBarActor->GetPosition()[1]; myIniW = myScalarBarActor->GetWidth(); @@ -672,7 +695,7 @@ void SMESHGUI_Preferences_ScalarBarDlg::onSelectionChanged() //================================================================================================= void SMESHGUI_Preferences_ScalarBarDlg::closeEvent( QCloseEvent* e ) { - if ( mySelection ) // "Properties" dialog box + if ( mySelectionMgr ) // "Properties" dialog box myDlg = 0; QDialog::closeEvent( e ); } @@ -720,14 +743,14 @@ void SMESHGUI_Preferences_ScalarBarDlg::setOriginAndSize( const double x, * Called when orientation is changed */ //================================================================================================= -void SMESHGUI_Preferences_ScalarBarDlg::onOrientationChanged() +void SMESHGUI_Preferences_ScalarBarDlg::onOrientationChanged() { int aOrientation = myVertRadioBtn->isChecked(); if ( aOrientation == myIniOrientation ) setOriginAndSize( myIniX, myIniY, myIniW, myIniH ); else - setOriginAndSize( aOrientation ? DEF_VER_X : DEF_HOR_X, - aOrientation ? DEF_VER_Y : DEF_HOR_Y, - aOrientation ? DEF_VER_W : DEF_HOR_W, + setOriginAndSize( aOrientation ? DEF_VER_X : DEF_HOR_X, + aOrientation ? DEF_VER_Y : DEF_HOR_Y, + aOrientation ? DEF_VER_W : DEF_HOR_W, aOrientation ? DEF_VER_H : DEF_HOR_H ); } diff --git a/src/SMESHGUI/SMESHGUI_Preferences_ScalarBarDlg.h b/src/SMESHGUI/SMESHGUI_Preferences_ScalarBarDlg.h index bde914a36..f436c649c 100644 --- a/src/SMESHGUI/SMESHGUI_Preferences_ScalarBarDlg.h +++ b/src/SMESHGUI/SMESHGUI_Preferences_ScalarBarDlg.h @@ -41,8 +41,11 @@ class QPushButton; class QToolButton; class QRadioButton; class QSpinBox; -class QAD_SpinBoxDbl; -class SALOME_Selection; + +class QtxDblSpinBox; + +class SalomeApp_SelectionMgr; + class SMESH_Actor; class SMESHGUI_Preferences_ScalarBarDlg : public QDialog @@ -52,10 +55,10 @@ class SMESHGUI_Preferences_ScalarBarDlg : public QDialog public: ~SMESHGUI_Preferences_ScalarBarDlg(); static void ScalarBarPreferences( QWidget* parent ); - static void ScalarBarProperties ( QWidget* parent, SALOME_Selection* Sel ); + static void ScalarBarProperties ( QWidget* parent, SalomeApp_SelectionMgr* Sel ); protected: - SMESHGUI_Preferences_ScalarBarDlg( QWidget* parent = 0, SALOME_Selection* Sel = 0, bool modal = FALSE ); + SMESHGUI_Preferences_ScalarBarDlg( QWidget* parent = 0, SalomeApp_SelectionMgr* Sel = 0, bool modal = FALSE ); static SMESHGUI_Preferences_ScalarBarDlg* myDlg; void closeEvent( QCloseEvent* e ); void setOriginAndSize( const double x, const double y, const double w, const double h ); @@ -71,10 +74,10 @@ protected slots: void onOrientationChanged(); private: - SALOME_Selection* mySelection; - SMESH_Actor* myActor; - double myIniX, myIniY, myIniW, myIniH; - int myIniOrientation; + SalomeApp_SelectionMgr* mySelectionMgr; + SMESH_Actor* myActor; + double myIniX, myIniY, myIniW, myIniH; + int myIniOrientation; QGroupBox* myRangeGrp; QLineEdit* myMinEdit; @@ -101,10 +104,10 @@ private: QRadioButton* myHorizRadioBtn; QGroupBox* myOriginDimGrp; - QAD_SpinBoxDbl* myXSpin; - QAD_SpinBoxDbl* myYSpin; - QAD_SpinBoxDbl* myWidthSpin; - QAD_SpinBoxDbl* myHeightSpin; + QtxDblSpinBox* myXSpin; + QtxDblSpinBox* myYSpin; + QtxDblSpinBox* myWidthSpin; + QtxDblSpinBox* myHeightSpin; QGroupBox* myButtonGrp; QPushButton* myOkBtn; diff --git a/src/SMESHGUI/SMESHGUI_RemoveElementsDlg.cxx b/src/SMESHGUI/SMESHGUI_RemoveElementsDlg.cxx index 18a63d2be..011402ab7 100644 --- a/src/SMESHGUI/SMESHGUI_RemoveElementsDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_RemoveElementsDlg.cxx @@ -1,23 +1,23 @@ // SMESH SMESHGUI : GUI for SMESH component // // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org // // // @@ -33,14 +33,24 @@ #include "SMESHGUI_VTKUtils.h" #include "SMESHGUI_MeshUtils.h" #include "SMESHGUI_IdValidator.h" + #include "SMESH_Actor.h" #include "SMDS_Mesh.hxx" -#include "QAD_Application.h" -#include "QAD_Desktop.h" -#include "QAD_MessageBox.h" +#include "SUIT_ResourceMgr.h" +#include "SUIT_Desktop.h" + +#include "SVTK_Selector.h" +#include "SVTK_ViewModel.h" +#include "SVTK_ViewWindow.h" +#include "SALOME_ListIO.hxx" + #include "utilities.h" +// OCCT Includes +#include +#include + // QT Includes #include #include @@ -59,104 +69,115 @@ using namespace std; //================================================================================= // class : SMESHGUI_RemoveElementsDlg() -// purpose : +// purpose : //================================================================================= -SMESHGUI_RemoveElementsDlg::SMESHGUI_RemoveElementsDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, - bool modal, WFlags fl ) - : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +SMESHGUI_RemoveElementsDlg +::SMESHGUI_RemoveElementsDlg (SMESHGUI* theModule, + const char* name, + bool modal, + WFlags fl) + : QDialog(SMESH::GetDesktop(theModule), + name, + modal, + WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | Qt::WDestructiveClose), + mySelector(SMESH::GetViewWindow(theModule)->GetSelector()), + mySelectionMgr(SMESH::GetSelectionMgr(theModule)), + myViewWindow(SMESH::GetViewWindow(theModule)), + mySMESHGUI(theModule), + myBusy(false) { - QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_DLG_REM_ELEMENT"))); - QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SELECT"))); + QPixmap image0 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_DLG_REM_ELEMENT"))); + QPixmap image1 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT"))); - if ( !name ) - setName( "SMESHGUI_RemoveElementsDlg" ); - resize( 303, 185 ); - setCaption( tr( "SMESH_REMOVE_ELEMENTS_TITLE" ) ); - setSizeGripEnabled( TRUE ); - SMESHGUI_RemoveElementsDlgLayout = new QGridLayout( this ); - SMESHGUI_RemoveElementsDlgLayout->setSpacing( 6 ); - SMESHGUI_RemoveElementsDlgLayout->setMargin( 11 ); + if (!name) + setName("SMESHGUI_RemoveElementsDlg"); + resize(303, 185); + setCaption(tr("SMESH_REMOVE_ELEMENTS_TITLE")); + setSizeGripEnabled(TRUE); + SMESHGUI_RemoveElementsDlgLayout = new QGridLayout(this); + SMESHGUI_RemoveElementsDlgLayout->setSpacing(6); + SMESHGUI_RemoveElementsDlgLayout->setMargin(11); /***************************************************************/ - GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); - GroupConstructors->setTitle( tr( "SMESH_ELEMENTS" ) ); - GroupConstructors->setExclusive( TRUE ); - GroupConstructors->setColumnLayout(0, Qt::Vertical ); - GroupConstructors->layout()->setSpacing( 0 ); - GroupConstructors->layout()->setMargin( 0 ); - GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() ); - GroupConstructorsLayout->setAlignment( Qt::AlignTop ); - GroupConstructorsLayout->setSpacing( 6 ); - GroupConstructorsLayout->setMargin( 11 ); - Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" ); - Constructor1->setText( tr( "" ) ); - Constructor1->setPixmap( image0 ); - Constructor1->setChecked( TRUE ); - Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) ); - Constructor1->setMinimumSize( QSize( 50, 0 ) ); - GroupConstructorsLayout->addWidget( Constructor1, 0, 0 ); - QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); - GroupConstructorsLayout->addItem( spacer, 0, 1 ); - SMESHGUI_RemoveElementsDlgLayout->addWidget( GroupConstructors, 0, 0 ); - - /***************************************************************/ - GroupButtons = new QGroupBox( this, "GroupButtons" ); - GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); - GroupButtons->setTitle( tr( "" ) ); - GroupButtons->setColumnLayout(0, Qt::Vertical ); - GroupButtons->layout()->setSpacing( 0 ); - GroupButtons->layout()->setMargin( 0 ); - GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); - GroupButtonsLayout->setAlignment( Qt::AlignTop ); - GroupButtonsLayout->setSpacing( 6 ); - GroupButtonsLayout->setMargin( 11 ); - buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); - buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) ); - buttonCancel->setAutoDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonCancel, 0, 3 ); - buttonApply = new QPushButton( GroupButtons, "buttonApply" ); - buttonApply->setText( tr( "SMESH_BUT_APPLY" ) ); - buttonApply->setAutoDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); - QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); - GroupButtonsLayout->addItem( spacer_9, 0, 2 ); - buttonOk = new QPushButton( GroupButtons, "buttonOk" ); - buttonOk->setText( tr( "SMESH_BUT_OK" ) ); - buttonOk->setAutoDefault( TRUE ); - buttonOk->setDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); - SMESHGUI_RemoveElementsDlgLayout->addWidget( GroupButtons, 2, 0 ); + GroupConstructors = new QButtonGroup(this, "GroupConstructors"); + GroupConstructors->setTitle(tr("SMESH_ELEMENTS" )); + GroupConstructors->setExclusive(TRUE); + GroupConstructors->setColumnLayout(0, Qt::Vertical); + GroupConstructors->layout()->setSpacing(0); + GroupConstructors->layout()->setMargin(0); + GroupConstructorsLayout = new QGridLayout(GroupConstructors->layout()); + GroupConstructorsLayout->setAlignment(Qt::AlignTop); + GroupConstructorsLayout->setSpacing(6); + GroupConstructorsLayout->setMargin(11); + Constructor1 = new QRadioButton(GroupConstructors, "Constructor1"); + Constructor1->setText(tr("" )); + Constructor1->setPixmap(image0); + Constructor1->setChecked(TRUE); + Constructor1->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth())); + Constructor1->setMinimumSize(QSize(50, 0)); + GroupConstructorsLayout->addWidget(Constructor1, 0, 0); + QSpacerItem* spacer = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); + GroupConstructorsLayout->addItem(spacer, 0, 1); + SMESHGUI_RemoveElementsDlgLayout->addWidget(GroupConstructors, 0, 0); /***************************************************************/ - GroupC1 = new QGroupBox( this, "GroupC1" ); - GroupC1->setTitle( tr( "SMESH_REMOVE" ) ); - GroupC1->setMinimumSize( QSize( 0, 0 ) ); - GroupC1->setFrameShape( QGroupBox::Box ); - GroupC1->setFrameShadow( QGroupBox::Sunken ); - GroupC1->setColumnLayout(0, Qt::Vertical ); - GroupC1->layout()->setSpacing( 0 ); - GroupC1->layout()->setMargin( 0 ); - GroupC1Layout = new QGridLayout( GroupC1->layout() ); - GroupC1Layout->setAlignment( Qt::AlignTop ); - GroupC1Layout->setSpacing( 6 ); - GroupC1Layout->setMargin( 11 ); - TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" ); - TextLabelC1A1->setText( tr( "SMESH_ID_ELEMENTS" ) ); - TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) ); - TextLabelC1A1->setFrameShape( QLabel::NoFrame ); - TextLabelC1A1->setFrameShadow( QLabel::Plain ); - GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 ); - SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" ); - SelectButtonC1A1->setText( tr( "" ) ); - SelectButtonC1A1->setPixmap( image1 ); - SelectButtonC1A1->setToggleButton( FALSE ); - GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 ); - LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" ); - LineEditC1A1->setValidator( new SMESHGUI_IdValidator( this, "validator" )); - GroupC1Layout->addWidget( LineEditC1A1, 0, 2 ); - SMESHGUI_RemoveElementsDlgLayout->addWidget( GroupC1, 1, 0 ); + GroupButtons = new QGroupBox(this, "GroupButtons"); + GroupButtons->setGeometry(QRect(10, 10, 281, 48)); + GroupButtons->setTitle(tr("" )); + GroupButtons->setColumnLayout(0, Qt::Vertical); + GroupButtons->layout()->setSpacing(0); + GroupButtons->layout()->setMargin(0); + GroupButtonsLayout = new QGridLayout(GroupButtons->layout()); + GroupButtonsLayout->setAlignment(Qt::AlignTop); + GroupButtonsLayout->setSpacing(6); + GroupButtonsLayout->setMargin(11); + buttonCancel = new QPushButton(GroupButtons, "buttonCancel"); + buttonCancel->setText(tr("SMESH_BUT_CLOSE" )); + buttonCancel->setAutoDefault(TRUE); + GroupButtonsLayout->addWidget(buttonCancel, 0, 3); + buttonApply = new QPushButton(GroupButtons, "buttonApply"); + buttonApply->setText(tr("SMESH_BUT_APPLY" )); + buttonApply->setAutoDefault(TRUE); + GroupButtonsLayout->addWidget(buttonApply, 0, 1); + QSpacerItem* spacer_9 = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); + GroupButtonsLayout->addItem(spacer_9, 0, 2); + buttonOk = new QPushButton(GroupButtons, "buttonOk"); + buttonOk->setText(tr("SMESH_BUT_OK" )); + buttonOk->setAutoDefault(TRUE); + buttonOk->setDefault(TRUE); + GroupButtonsLayout->addWidget(buttonOk, 0, 0); + SMESHGUI_RemoveElementsDlgLayout->addWidget(GroupButtons, 2, 0); - Init(Sel) ; /* Initialisations */ + /***************************************************************/ + GroupC1 = new QGroupBox(this, "GroupC1"); + GroupC1->setTitle(tr("SMESH_REMOVE" )); + GroupC1->setMinimumSize(QSize(0, 0)); + GroupC1->setFrameShape(QGroupBox::Box); + GroupC1->setFrameShadow(QGroupBox::Sunken); + GroupC1->setColumnLayout(0, Qt::Vertical); + GroupC1->layout()->setSpacing(0); + GroupC1->layout()->setMargin(0); + GroupC1Layout = new QGridLayout(GroupC1->layout()); + GroupC1Layout->setAlignment(Qt::AlignTop); + GroupC1Layout->setSpacing(6); + GroupC1Layout->setMargin(11); + TextLabelC1A1 = new QLabel(GroupC1, "TextLabelC1A1"); + TextLabelC1A1->setText(tr("SMESH_ID_ELEMENTS" )); + TextLabelC1A1->setMinimumSize(QSize(50, 0)); + TextLabelC1A1->setFrameShape(QLabel::NoFrame); + TextLabelC1A1->setFrameShadow(QLabel::Plain); + GroupC1Layout->addWidget(TextLabelC1A1, 0, 0); + SelectButtonC1A1 = new QPushButton(GroupC1, "SelectButtonC1A1"); + SelectButtonC1A1->setText(tr("" )); + SelectButtonC1A1->setPixmap(image1); + SelectButtonC1A1->setToggleButton(FALSE); + GroupC1Layout->addWidget(SelectButtonC1A1, 0, 1); + LineEditC1A1 = new QLineEdit(GroupC1, "LineEditC1A1"); + LineEditC1A1->setValidator(new SMESHGUI_IdValidator(this, "validator")); + GroupC1Layout->addWidget(LineEditC1A1, 0, 2); + SMESHGUI_RemoveElementsDlgLayout->addWidget(GroupC1, 1, 0); + + Init(); /* Initialisations */ } //================================================================================= @@ -165,96 +186,85 @@ SMESHGUI_RemoveElementsDlg::SMESHGUI_RemoveElementsDlg( QWidget* parent, const c //================================================================================= SMESHGUI_RemoveElementsDlg::~SMESHGUI_RemoveElementsDlg() { - // no need to delete child widgets, Qt does it all for us + // no need to delete child widgets, Qt does it all for us } - //================================================================================= // function : Init() // purpose : //================================================================================= -void SMESHGUI_RemoveElementsDlg::Init( SALOME_Selection* Sel ) +void SMESHGUI_RemoveElementsDlg::Init() { - GroupC1->show(); - myConstructorId = 0 ; - Constructor1->setChecked( TRUE ); - myEditCurrentArgument = LineEditC1A1 ; + myConstructorId = 0; + Constructor1->setChecked(TRUE); + myEditCurrentArgument = LineEditC1A1; - mySelection = Sel; - myNbOkElements = false ; - mySMESHGUI = SMESHGUI::GetSMESHGUI() ; - mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; + myNbOkElements = false; + mySMESHGUI->SetActiveDialogBox((QDialog*)this); myActor = 0; myBusy = false; /* signals and slots connections */ - connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); - connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ; - connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) ); - connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) ); + connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel())); + connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); + connect(GroupConstructors, SIGNAL(clicked(int)), SLOT(ConstructorsClicked(int))); - connect( SelectButtonC1A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; - connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; - connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + connect(SelectButtonC1A1, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument())); + connect(mySMESHGUI, SIGNAL (SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog())); + connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); /* to close dialog if study change */ - connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; - connect( myEditCurrentArgument, SIGNAL( textChanged( const QString& )), - SLOT( onTextChange( const QString& ))); + connect(mySMESHGUI, SIGNAL (SignalCloseAllDialogs()), this, SLOT(ClickOnCancel())); + connect(myEditCurrentArgument, SIGNAL(textChanged(const QString&)), + SLOT(onTextChange(const QString&))); /* Move widget on the botton right corner of main widget */ - int x, y ; - mySMESHGUI->DefineDlgPosition( this, x, y ) ; - this->move( x, y ) ; - this->show() ; /* displays Dialog */ + int x, y; + mySMESHGUI->DefineDlgPosition(this, x, y); + this->move(x, y); + this->show(); /* displays Dialog */ - QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true ); + myViewWindow->SetSelectionMode(CellSelection); SelectionIntoArgument(); } - //================================================================================= // function : ConstructorsClicked() // purpose : Radio button management //================================================================================= -void SMESHGUI_RemoveElementsDlg::ConstructorsClicked(int constructorId) +void SMESHGUI_RemoveElementsDlg::ConstructorsClicked (int) { - return ; } - //================================================================================= // function : ClickOnApply() // purpose : //================================================================================= void SMESHGUI_RemoveElementsDlg::ClickOnApply() { - if (mySMESHGUI->ActiveStudyLocked()) + if (mySMESHGUI->isActiveStudyLocked()) return; - if ( myNbOkElements ) { - QStringList aListId = QStringList::split( " ", myEditCurrentArgument->text(), false); + if (myNbOkElements) { + QStringList aListId = QStringList::split(" ", myEditCurrentArgument->text(), false); SMESH::long_array_var anArrayOfIdeces = new SMESH::long_array; - anArrayOfIdeces->length( aListId.count() ); - for ( int i = 0; i < aListId.count(); i++ ) + anArrayOfIdeces->length(aListId.count()); + for (int i = 0; i < aListId.count(); i++) anArrayOfIdeces[i] = aListId[ i ].toInt(); bool aResult = false; - try - { + try { SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor(); - aResult = aMeshEditor->RemoveElements(anArrayOfIdeces.inout()) ; - } - catch( ... ) - { + aResult = aMeshEditor->RemoveElements(anArrayOfIdeces.inout()); + } catch (...) { } - if ( aResult ) - { - Handle(SALOME_InteractiveObject) anIO = myActor->getIO(); - mySelection->ClearIObjects(); + if (aResult) { + SALOME_ListIO aList; + aList.Append(myActor->getIO()); + mySelectionMgr->setSelectedObjects(aList, false); SMESH::UpdateView(); - mySelection->AddIObject( anIO, false ); } } } @@ -265,10 +275,10 @@ void SMESHGUI_RemoveElementsDlg::ClickOnApply() //================================================================================= void SMESHGUI_RemoveElementsDlg::ClickOnOk() { - this->ClickOnApply() ; - this->ClickOnCancel() ; + this->ClickOnApply(); + this->ClickOnCancel(); - return ; + return; } //================================================================================= @@ -277,53 +287,61 @@ void SMESHGUI_RemoveElementsDlg::ClickOnOk() //================================================================================= void SMESHGUI_RemoveElementsDlg::ClickOnCancel() { - mySelection->ClearIObjects(); - QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); - disconnect( mySelection, 0, this, 0 ); - mySMESHGUI->ResetState() ; - reject() ; - return ; + mySelectionMgr->clearSelected(); + myViewWindow->SetSelectionMode(ActorSelection); + disconnect(mySelectionMgr, 0, this, 0); + mySMESHGUI->ResetState(); + reject(); + return; } - //======================================================================= //function : onTextChange -//purpose : +//purpose : //======================================================================= - -void SMESHGUI_RemoveElementsDlg::onTextChange(const QString& theNewText) +void SMESHGUI_RemoveElementsDlg::onTextChange (const QString& theNewText) { - if ( myBusy ) return; + if (myBusy) + return; myBusy = true; myNbOkElements = 0; - buttonOk->setEnabled( false ); - buttonApply->setEnabled( false ); + buttonOk->setEnabled(false); + buttonApply->setEnabled(false); // hilight entered elements - SMDS_Mesh* aMesh = 0; - if ( myActor ) - aMesh = myActor->GetObject()->GetMesh(); - if ( aMesh ) { - - mySelection->ClearIObjects(); - mySelection->AddIObject( myActor->getIO() ); - - QStringList aListId = QStringList::split( " ", theNewText, false); - for ( int i = 0; i < aListId.count(); i++ ) { - const SMDS_MeshElement * e = aMesh->FindElement( aListId[ i ].toInt() ); - if ( e ) { - if ( !mySelection->IsIndexSelected( myActor->getIO(), e->GetID() )) - mySelection->AddOrRemoveIndex (myActor->getIO(), e->GetID(), true); - myNbOkElements++; + if(myActor){ + if(SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh()){ + Handle(SALOME_InteractiveObject) anIO = myActor->getIO(); + SALOME_ListIO aList; + aList.Append(anIO); + mySelectionMgr->setSelectedObjects(aList, false); + + TColStd_IndexedMapOfInteger selectedIndices; + TColStd_MapOfInteger newIndices; + mySelector->GetIndex(anIO,selectedIndices); + + QStringList aListId = QStringList::split(" ", theNewText, false); + for (int i = 0; i < aListId.count(); i++) { + if(const SMDS_MeshElement *anElem = aMesh->FindElement(aListId[i].toInt())) { + if (selectedIndices.Add(anElem->GetID())) { + newIndices.Add(anElem->GetID()); + } + myNbOkElements++; + } + } + + if (newIndices.Extent() > 0){ + mySelector->AddOrRemoveIndex(anIO,newIndices,true); + myViewWindow->highlight(anIO,true,true); } } + } - if ( myNbOkElements ) { - buttonOk->setEnabled( true ); - buttonApply->setEnabled( true ); - } + if (myNbOkElements) { + buttonOk->setEnabled(true); + buttonApply->setEnabled(true); } myBusy = false; @@ -335,7 +353,7 @@ void SMESHGUI_RemoveElementsDlg::onTextChange(const QString& theNewText) //================================================================================= void SMESHGUI_RemoveElementsDlg::SelectionIntoArgument() { - if ( myBusy ) return; + if (myBusy) return; // clear @@ -343,48 +361,50 @@ void SMESHGUI_RemoveElementsDlg::SelectionIntoArgument() myActor = 0; myBusy = true; - myEditCurrentArgument->setText( "" ); + myEditCurrentArgument->setText(""); myBusy = false; - if ( !GroupButtons->isEnabled() ) // inactive + if (!GroupButtons->isEnabled()) // inactive return; - buttonOk->setEnabled( false ); - buttonApply->setEnabled( false ); + buttonOk->setEnabled(false); + buttonApply->setEnabled(false); // get selected mesh - int nbSel = mySelection->IObjectCount(); - if(nbSel != 1) + SALOME_ListIO aList; + mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type()); + + int nbSel = aList.Extent(); + if (nbSel != 1) return; - myMesh = SMESH::GetMeshByIO( mySelection->firstIObject() ); - if ( myMesh->_is_nil() ) + Handle(SALOME_InteractiveObject) anIO = aList.First(); + myMesh = SMESH::GetMeshByIO(anIO); + if (myMesh->_is_nil()) return; - myActor = SMESH::FindActorByEntry( mySelection->firstIObject()->getEntry() ); - if ( !myActor ) + myActor = SMESH::FindActorByEntry(anIO->getEntry()); + if (!myActor) return; // get selected nodes - QString aString = ""; - int nbElems = SMESH::GetNameOfSelectedElements(mySelection, aString) ; + int nbElems = SMESH::GetNameOfSelectedElements(mySelector,anIO,aString); if(nbElems < 1) - return ; + return; myBusy = true; - myEditCurrentArgument->setText( aString ); + myEditCurrentArgument->setText(aString); myBusy = false; // OK myNbOkElements = nbElems; - buttonOk->setEnabled( true ); - buttonApply->setEnabled( true ); + buttonOk->setEnabled(true); + buttonApply->setEnabled(true); } - //================================================================================= // function : SetEditCurrentArgument() // purpose : @@ -395,16 +415,16 @@ void SMESHGUI_RemoveElementsDlg::SetEditCurrentArgument() switch (myConstructorId) { case 0: /* default constructor */ - { + { if(send == SelectButtonC1A1) { - LineEditC1A1->setFocus() ; + LineEditC1A1->setFocus(); myEditCurrentArgument = LineEditC1A1; } - SelectionIntoArgument() ; + SelectionIntoArgument(); break; } } - return ; + return; } //================================================================================= @@ -413,15 +433,15 @@ void SMESHGUI_RemoveElementsDlg::SetEditCurrentArgument() //================================================================================= void SMESHGUI_RemoveElementsDlg::DeactivateActiveDialog() { - if ( GroupConstructors->isEnabled() ) { - GroupConstructors->setEnabled(false) ; - GroupC1->setEnabled(false) ; - GroupButtons->setEnabled(false) ; + if (GroupConstructors->isEnabled()) { + GroupConstructors->setEnabled(false); + GroupC1->setEnabled(false); + GroupButtons->setEnabled(false); + mySMESHGUI->ResetState(); // ?? + mySMESHGUI->SetActiveDialogBox(0); // ?? } - return ; } - //================================================================================= // function : ActivateThisDialog() // purpose : @@ -429,45 +449,46 @@ void SMESHGUI_RemoveElementsDlg::DeactivateActiveDialog() void SMESHGUI_RemoveElementsDlg::ActivateThisDialog() { /* Emit a signal to deactivate the active dialog */ - mySMESHGUI->EmitSignalDeactivateDialog() ; + mySMESHGUI->EmitSignalDeactivateDialog(); - GroupConstructors->setEnabled(true) ; - GroupC1->setEnabled(true) ; - GroupButtons->setEnabled(true) ; + GroupConstructors->setEnabled(true); + GroupC1->setEnabled(true); + GroupButtons->setEnabled(true); - QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true ); + mySMESHGUI->SetActiveDialogBox((QDialog*)this); // ?? + + myViewWindow->SetSelectionMode(NodeSelection); + + SelectionIntoArgument(); // ?? } - //================================================================================= // function : enterEvent() // purpose : //================================================================================= -void SMESHGUI_RemoveElementsDlg::enterEvent(QEvent* e) +void SMESHGUI_RemoveElementsDlg::enterEvent (QEvent*) { - if ( !GroupConstructors->isEnabled() ) - ActivateThisDialog() ; + if (!GroupConstructors->isEnabled()) + ActivateThisDialog(); } - //================================================================================= // function : closeEvent() // purpose : //================================================================================= -void SMESHGUI_RemoveElementsDlg::closeEvent( QCloseEvent* e ) +void SMESHGUI_RemoveElementsDlg::closeEvent (QCloseEvent*) { /* same than click on cancel button */ - this->ClickOnCancel() ; - return ; + this->ClickOnCancel(); + return; } //======================================================================= //function : hideEvent //purpose : caused by ESC key //======================================================================= - -void SMESHGUI_RemoveElementsDlg::hideEvent ( QHideEvent * e ) +void SMESHGUI_RemoveElementsDlg::hideEvent (QHideEvent * e) { - if ( !isMinimized() ) + if (!isMinimized()) ClickOnCancel(); } diff --git a/src/SMESHGUI/SMESHGUI_RemoveElementsDlg.h b/src/SMESHGUI/SMESHGUI_RemoveElementsDlg.h index e18ad584b..e112f65f1 100644 --- a/src/SMESHGUI/SMESHGUI_RemoveElementsDlg.h +++ b/src/SMESHGUI/SMESHGUI_RemoveElementsDlg.h @@ -29,7 +29,7 @@ #ifndef DIALOGBOX_REMOVE_ELEMENTS_H #define DIALOGBOX_REMOVE_ELEMENTS_H -#include "SALOME_Selection.h" +#include "SalomeApp_SelectionMgr.h" // QT Includes #include @@ -44,8 +44,11 @@ class QLabel; class QLineEdit; class QPushButton; class QRadioButton; + class SMESHGUI; class SMESH_Actor; +class SVTK_Selector; +class SVTK_ViewWindow; // IDL Headers #include @@ -60,20 +63,26 @@ class SMESHGUI_RemoveElementsDlg : public QDialog Q_OBJECT public: - SMESHGUI_RemoveElementsDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); + SMESHGUI_RemoveElementsDlg(SMESHGUI* theModule, + const char* name = 0, + bool modal = FALSE, + WFlags fl = 0); ~SMESHGUI_RemoveElementsDlg(); private: - void Init( SALOME_Selection* Sel ) ; + void Init() ; void closeEvent( QCloseEvent* e ) ; void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */ void hideEvent ( QHideEvent * ); /* ESC key */ - SMESHGUI* mySMESHGUI ; /* Current SMESHGUI object */ - SALOME_Selection* mySelection ; /* User shape selection */ - int myNbOkElements ; /* to check when arguments is defined */ - int myConstructorId ; /* Current constructor id = radio button id */ + SalomeApp_SelectionMgr* mySelectionMgr; + SVTK_ViewWindow* myViewWindow; + SVTK_Selector* mySelector; + SMESHGUI* mySMESHGUI; + + int myNbOkElements; /* to check when arguments is defined */ + int myConstructorId; /* Current constructor id = radio button id */ QLineEdit* myEditCurrentArgument; /* Current LineEdit */ bool myBusy; diff --git a/src/SMESHGUI/SMESHGUI_RemoveNodesDlg.cxx b/src/SMESHGUI/SMESHGUI_RemoveNodesDlg.cxx index 3990a51b0..9df083576 100644 --- a/src/SMESHGUI/SMESHGUI_RemoveNodesDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_RemoveNodesDlg.cxx @@ -1,23 +1,23 @@ // SMESH SMESHGUI : GUI for SMESH component // // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org // // // @@ -33,14 +33,24 @@ #include "SMESHGUI_VTKUtils.h" #include "SMESHGUI_MeshUtils.h" #include "SMESHGUI_IdValidator.h" + #include "SMESH_Actor.h" #include "SMDS_Mesh.hxx" -#include "QAD_Application.h" -#include "QAD_Desktop.h" -#include "QAD_MessageBox.h" +#include "SUIT_ResourceMgr.h" +#include "SUIT_Desktop.h" + +#include "SVTK_Selector.h" +#include "SVTK_ViewModel.h" +#include "SVTK_ViewWindow.h" +#include "SALOME_ListIO.hxx" + #include "utilities.h" +// OCCT Includes +#include +#include + // QT Includes #include #include @@ -59,106 +69,115 @@ using namespace std; //================================================================================= // class : SMESHGUI_RemoveNodesDlg() -// purpose : +// purpose : //================================================================================= -SMESHGUI_RemoveNodesDlg::SMESHGUI_RemoveNodesDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, - bool modal, WFlags fl ) - : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | - Qt::WDestructiveClose), - myBusy( false ) +SMESHGUI_RemoveNodesDlg +::SMESHGUI_RemoveNodesDlg(SMESHGUI* theModule, + const char* name, + bool modal, + WFlags fl) + : QDialog(SMESH::GetDesktop(theModule), + name, + modal, + WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | Qt::WDestructiveClose), + mySelector(SMESH::GetViewWindow(theModule)->GetSelector()), + mySelectionMgr(SMESH::GetSelectionMgr(theModule)), + myViewWindow(SMESH::GetViewWindow(theModule)), + mySMESHGUI(theModule), + myBusy(false) { - QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_DLG_REM_NODE"))); - QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SELECT"))); + QPixmap image0 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_DLG_REM_NODE"))); + QPixmap image1 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT"))); - if ( !name ) - setName( "SMESHGUI_RemoveNodesDlg" ); - resize( 303, 185 ); - setCaption( tr( "SMESH_REMOVE_NODES_TITLE" ) ); - setSizeGripEnabled( TRUE ); - SMESHGUI_RemoveNodesDlgLayout = new QGridLayout( this ); - SMESHGUI_RemoveNodesDlgLayout->setSpacing( 6 ); - SMESHGUI_RemoveNodesDlgLayout->setMargin( 11 ); + if (!name) + setName("SMESHGUI_RemoveNodesDlg"); + resize(303, 185); + setCaption(tr("SMESH_REMOVE_NODES_TITLE" )); + setSizeGripEnabled(TRUE); + SMESHGUI_RemoveNodesDlgLayout = new QGridLayout(this); + SMESHGUI_RemoveNodesDlgLayout->setSpacing(6); + SMESHGUI_RemoveNodesDlgLayout->setMargin(11); /***************************************************************/ - GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); - GroupConstructors->setTitle( tr( "SMESH_NODES" ) ); - GroupConstructors->setExclusive( TRUE ); - GroupConstructors->setColumnLayout(0, Qt::Vertical ); - GroupConstructors->layout()->setSpacing( 0 ); - GroupConstructors->layout()->setMargin( 0 ); - GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() ); - GroupConstructorsLayout->setAlignment( Qt::AlignTop ); - GroupConstructorsLayout->setSpacing( 6 ); - GroupConstructorsLayout->setMargin( 11 ); - Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" ); - Constructor1->setText( tr( "" ) ); - Constructor1->setPixmap( image0 ); - Constructor1->setChecked( TRUE ); - Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) ); - Constructor1->setMinimumSize( QSize( 50, 0 ) ); - GroupConstructorsLayout->addWidget( Constructor1, 0, 0 ); - QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); - GroupConstructorsLayout->addItem( spacer, 0, 1 ); - SMESHGUI_RemoveNodesDlgLayout->addWidget( GroupConstructors, 0, 0 ); - - /***************************************************************/ - GroupButtons = new QGroupBox( this, "GroupButtons" ); - GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); - GroupButtons->setTitle( tr( "" ) ); - GroupButtons->setColumnLayout(0, Qt::Vertical ); - GroupButtons->layout()->setSpacing( 0 ); - GroupButtons->layout()->setMargin( 0 ); - GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); - GroupButtonsLayout->setAlignment( Qt::AlignTop ); - GroupButtonsLayout->setSpacing( 6 ); - GroupButtonsLayout->setMargin( 11 ); - buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); - buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) ); - buttonCancel->setAutoDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonCancel, 0, 3 ); - buttonApply = new QPushButton( GroupButtons, "buttonApply" ); - buttonApply->setText( tr( "SMESH_BUT_APPLY" ) ); - buttonApply->setAutoDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); - QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); - GroupButtonsLayout->addItem( spacer_9, 0, 2 ); - buttonOk = new QPushButton( GroupButtons, "buttonOk" ); - buttonOk->setText( tr( "SMESH_BUT_OK" ) ); - buttonOk->setAutoDefault( TRUE ); - buttonOk->setDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); - SMESHGUI_RemoveNodesDlgLayout->addWidget( GroupButtons, 2, 0 ); + GroupConstructors = new QButtonGroup(this, "GroupConstructors"); + GroupConstructors->setTitle(tr("SMESH_NODES" )); + GroupConstructors->setExclusive(TRUE); + GroupConstructors->setColumnLayout(0, Qt::Vertical); + GroupConstructors->layout()->setSpacing(0); + GroupConstructors->layout()->setMargin(0); + GroupConstructorsLayout = new QGridLayout(GroupConstructors->layout()); + GroupConstructorsLayout->setAlignment(Qt::AlignTop); + GroupConstructorsLayout->setSpacing(6); + GroupConstructorsLayout->setMargin(11); + Constructor1 = new QRadioButton(GroupConstructors, "Constructor1"); + Constructor1->setText(tr("" )); + Constructor1->setPixmap(image0); + Constructor1->setChecked(TRUE); + Constructor1->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth())); + Constructor1->setMinimumSize(QSize(50, 0)); + GroupConstructorsLayout->addWidget(Constructor1, 0, 0); + QSpacerItem* spacer = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); + GroupConstructorsLayout->addItem(spacer, 0, 1); + SMESHGUI_RemoveNodesDlgLayout->addWidget(GroupConstructors, 0, 0); /***************************************************************/ - GroupC1 = new QGroupBox( this, "GroupC1" ); - GroupC1->setTitle( tr( "SMESH_REMOVE" ) ); - GroupC1->setMinimumSize( QSize( 0, 0 ) ); - GroupC1->setFrameShape( QGroupBox::Box ); - GroupC1->setFrameShadow( QGroupBox::Sunken ); - GroupC1->setColumnLayout(0, Qt::Vertical ); - GroupC1->layout()->setSpacing( 0 ); - GroupC1->layout()->setMargin( 0 ); - GroupC1Layout = new QGridLayout( GroupC1->layout() ); - GroupC1Layout->setAlignment( Qt::AlignTop ); - GroupC1Layout->setSpacing( 6 ); - GroupC1Layout->setMargin( 11 ); - TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" ); - TextLabelC1A1->setText( tr( "SMESH_ID_NODES" ) ); - TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) ); - TextLabelC1A1->setFrameShape( QLabel::NoFrame ); - TextLabelC1A1->setFrameShadow( QLabel::Plain ); - GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 ); - SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" ); - SelectButtonC1A1->setText( tr( "" ) ); - SelectButtonC1A1->setPixmap( image1 ); - SelectButtonC1A1->setToggleButton( FALSE ); - GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 ); - LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" ); - LineEditC1A1->setValidator( new SMESHGUI_IdValidator( this, "validator" )); - GroupC1Layout->addWidget( LineEditC1A1, 0, 2 ); - SMESHGUI_RemoveNodesDlgLayout->addWidget( GroupC1, 1, 0 ); + GroupButtons = new QGroupBox(this, "GroupButtons"); + GroupButtons->setGeometry(QRect(10, 10, 281, 48)); + GroupButtons->setTitle(tr("" )); + GroupButtons->setColumnLayout(0, Qt::Vertical); + GroupButtons->layout()->setSpacing(0); + GroupButtons->layout()->setMargin(0); + GroupButtonsLayout = new QGridLayout(GroupButtons->layout()); + GroupButtonsLayout->setAlignment(Qt::AlignTop); + GroupButtonsLayout->setSpacing(6); + GroupButtonsLayout->setMargin(11); + buttonCancel = new QPushButton(GroupButtons, "buttonCancel"); + buttonCancel->setText(tr("SMESH_BUT_CLOSE" )); + buttonCancel->setAutoDefault(TRUE); + GroupButtonsLayout->addWidget(buttonCancel, 0, 3); + buttonApply = new QPushButton(GroupButtons, "buttonApply"); + buttonApply->setText(tr("SMESH_BUT_APPLY" )); + buttonApply->setAutoDefault(TRUE); + GroupButtonsLayout->addWidget(buttonApply, 0, 1); + QSpacerItem* spacer_9 = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); + GroupButtonsLayout->addItem(spacer_9, 0, 2); + buttonOk = new QPushButton(GroupButtons, "buttonOk"); + buttonOk->setText(tr("SMESH_BUT_OK" )); + buttonOk->setAutoDefault(TRUE); + buttonOk->setDefault(TRUE); + GroupButtonsLayout->addWidget(buttonOk, 0, 0); + SMESHGUI_RemoveNodesDlgLayout->addWidget(GroupButtons, 2, 0); - Init(Sel) ; /* Initialisations */ + /***************************************************************/ + GroupC1 = new QGroupBox(this, "GroupC1"); + GroupC1->setTitle(tr("SMESH_REMOVE" )); + GroupC1->setMinimumSize(QSize(0, 0)); + GroupC1->setFrameShape(QGroupBox::Box); + GroupC1->setFrameShadow(QGroupBox::Sunken); + GroupC1->setColumnLayout(0, Qt::Vertical); + GroupC1->layout()->setSpacing(0); + GroupC1->layout()->setMargin(0); + GroupC1Layout = new QGridLayout(GroupC1->layout()); + GroupC1Layout->setAlignment(Qt::AlignTop); + GroupC1Layout->setSpacing(6); + GroupC1Layout->setMargin(11); + TextLabelC1A1 = new QLabel(GroupC1, "TextLabelC1A1"); + TextLabelC1A1->setText(tr("SMESH_ID_NODES" )); + TextLabelC1A1->setMinimumSize(QSize(50, 0)); + TextLabelC1A1->setFrameShape(QLabel::NoFrame); + TextLabelC1A1->setFrameShadow(QLabel::Plain); + GroupC1Layout->addWidget(TextLabelC1A1, 0, 0); + SelectButtonC1A1 = new QPushButton(GroupC1, "SelectButtonC1A1"); + SelectButtonC1A1->setText(tr("" )); + SelectButtonC1A1->setPixmap(image1); + SelectButtonC1A1->setToggleButton(FALSE); + GroupC1Layout->addWidget(SelectButtonC1A1, 0, 1); + LineEditC1A1 = new QLineEdit(GroupC1, "LineEditC1A1"); + LineEditC1A1->setValidator(new SMESHGUI_IdValidator(this, "validator")); + GroupC1Layout->addWidget(LineEditC1A1, 0, 2); + SMESHGUI_RemoveNodesDlgLayout->addWidget(GroupC1, 1, 0); + + Init(); /* Initialisations */ } //================================================================================= @@ -167,99 +186,83 @@ SMESHGUI_RemoveNodesDlg::SMESHGUI_RemoveNodesDlg( QWidget* parent, const char* n //================================================================================= SMESHGUI_RemoveNodesDlg::~SMESHGUI_RemoveNodesDlg() { - // no need to delete child widgets, Qt does it all for us + // no need to delete child widgets, Qt does it all for us } - //================================================================================= // function : Init() // purpose : //================================================================================= -void SMESHGUI_RemoveNodesDlg::Init( SALOME_Selection* Sel ) +void SMESHGUI_RemoveNodesDlg::Init() { - myBusy = false; - GroupC1->show(); - myConstructorId = 0 ; - Constructor1->setChecked( TRUE ); - myEditCurrentArgument = LineEditC1A1 ; - mySelection = Sel; - myNbOkNodes = 0 ; - myActor = 0; - mySMESHGUI = SMESHGUI::GetSMESHGUI() ; - mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; + myConstructorId = 0; + Constructor1->setChecked(TRUE); + myEditCurrentArgument = LineEditC1A1; + + myNbOkNodes = 0; + mySMESHGUI->SetActiveDialogBox((QDialog*)this); + myActor = 0; + myBusy = false; /* signals and slots connections */ - connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); - connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ; - connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) ); - connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) ); + connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel())); + connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); + connect(GroupConstructors, SIGNAL(clicked(int)), SLOT(ConstructorsClicked(int))); - connect( SelectButtonC1A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; - connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; - connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); - /* to close dialog if study change */ - connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; - connect( myEditCurrentArgument, SIGNAL( textChanged( const QString& )), - SLOT( onTextChange( const QString& ))); + connect(SelectButtonC1A1, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument())); + connect(mySMESHGUI, SIGNAL (SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog())); + connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); /* Move widget on the botton right corner of main widget */ - int x, y ; - mySMESHGUI->DefineDlgPosition( this, x, y ) ; - this->move( x, y ) ; - this->show() ; /* displays Dialog */ + int x, y; + mySMESHGUI->DefineDlgPosition(this, x, y); + this->move(x, y); + this->show(); /* displays Dialog */ SMESH::SetPointRepresentation(true); - QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true ); + myViewWindow->SetSelectionMode(NodeSelection); SelectionIntoArgument(); - return ; } - //================================================================================= // function : ConstructorsClicked() // purpose : Radio button management //================================================================================= -void SMESHGUI_RemoveNodesDlg::ConstructorsClicked(int constructorId) +void SMESHGUI_RemoveNodesDlg::ConstructorsClicked (int) { - return ; } - //================================================================================= // function : ClickOnApply() // purpose : //================================================================================= void SMESHGUI_RemoveNodesDlg::ClickOnApply() { - if (mySMESHGUI->ActiveStudyLocked()) + if (mySMESHGUI->isActiveStudyLocked()) return; - - if ( myNbOkNodes ) - { - QStringList aListId = QStringList::split( " ", myEditCurrentArgument->text(), false); + + if (myNbOkNodes) { + QStringList aListId = QStringList::split(" ", myEditCurrentArgument->text(), false); SMESH::long_array_var anArrayOfIdeces = new SMESH::long_array; - anArrayOfIdeces->length( aListId.count() ); - for ( int i = 0; i < aListId.count(); i++ ) + anArrayOfIdeces->length(aListId.count()); + for (int i = 0; i < aListId.count(); i++) anArrayOfIdeces[i] = aListId[ i ].toInt(); bool aResult = false; - try - { + try { SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor(); - aResult = aMeshEditor->RemoveNodes(anArrayOfIdeces.inout()) ; - } - catch( ... ) - { + aResult = aMeshEditor->RemoveNodes(anArrayOfIdeces.inout()); + } catch(...) { } - if ( aResult ) - { - Handle(SALOME_InteractiveObject) anIO = myActor->getIO(); - mySelection->ClearIObjects(); + if (aResult) { + SALOME_ListIO aList; + aList.Append(myActor->getIO()); + mySelectionMgr->setSelectedObjects(aList, false); SMESH::UpdateView(); - mySelection->AddIObject( anIO, false ); } SMESH::SetPointRepresentation(true); @@ -272,66 +275,70 @@ void SMESHGUI_RemoveNodesDlg::ClickOnApply() //================================================================================= void SMESHGUI_RemoveNodesDlg::ClickOnOk() { - this->ClickOnApply() ; - this->ClickOnCancel() ; - - return ; + ClickOnApply(); + ClickOnCancel(); } - //================================================================================= // function : ClickOnCancel() // purpose : //================================================================================= void SMESHGUI_RemoveNodesDlg::ClickOnCancel() { - mySelection->ClearIObjects(); + mySelectionMgr->clearSelected(); SMESH::SetPointRepresentation(false); - QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); - disconnect( mySelection, 0, this, 0 ); - mySMESHGUI->ResetState() ; - reject() ; - return ; + myViewWindow->SetSelectionMode(ActorSelection); + disconnect(mySelectionMgr, 0, this, 0); + mySMESHGUI->ResetState(); + reject(); } //======================================================================= //function : onTextChange -//purpose : +//purpose : //======================================================================= - -void SMESHGUI_RemoveNodesDlg::onTextChange(const QString& theNewText) +void SMESHGUI_RemoveNodesDlg::onTextChange (const QString& theNewText) { - if ( myBusy ) return; + if (myBusy) return; myBusy = true; myNbOkNodes = 0; - buttonOk->setEnabled( false ); - buttonApply->setEnabled( false ); + buttonOk->setEnabled(false); + buttonApply->setEnabled(false); // hilight entered nodes - SMDS_Mesh* aMesh = 0; - if ( myActor ) - aMesh = myActor->GetObject()->GetMesh(); - if ( aMesh ) { + if(myActor){ + if(SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh()){ + Handle(SALOME_InteractiveObject) anIO = myActor->getIO(); + SALOME_ListIO aList; + aList.Append(anIO); + mySelectionMgr->setSelectedObjects(aList, false); + + TColStd_IndexedMapOfInteger selectedIndices; + TColStd_MapOfInteger newIndices; + mySelector->GetIndex(anIO,selectedIndices); + + QStringList aListId = QStringList::split(" ", theNewText, false); + for (int i = 0; i < aListId.count(); i++) { + if (const SMDS_MeshNode *aNode = aMesh->FindNode(aListId[ i ].toInt())) { + if (selectedIndices.Add(aNode->GetID())) { + newIndices.Add(aNode->GetID()); + } + myNbOkNodes++; + } + } - mySelection->ClearIObjects(); - mySelection->AddIObject( myActor->getIO() ); - - QStringList aListId = QStringList::split( " ", theNewText, false); - for ( int i = 0; i < aListId.count(); i++ ) { - const SMDS_MeshNode * n = aMesh->FindNode( aListId[ i ].toInt() ); - if ( n ) { - if ( !mySelection->IsIndexSelected( myActor->getIO(), n->GetID() )) - mySelection->AddOrRemoveIndex (myActor->getIO(), n->GetID(), true); - myNbOkNodes++; + if(newIndices.Extent() > 0){ + mySelector->AddOrRemoveIndex(anIO,newIndices,true); + myViewWindow->highlight(anIO,true,true); } } + } - if ( myNbOkNodes ) { - buttonOk->setEnabled( true ); - buttonApply->setEnabled( true ); - } + if (myNbOkNodes) { + buttonOk->setEnabled(true); + buttonApply->setEnabled(true); } myBusy = false; @@ -343,7 +350,7 @@ void SMESHGUI_RemoveNodesDlg::onTextChange(const QString& theNewText) //================================================================================= void SMESHGUI_RemoveNodesDlg::SelectionIntoArgument() { - if ( myBusy ) return; + if (myBusy) return; // clear @@ -351,48 +358,50 @@ void SMESHGUI_RemoveNodesDlg::SelectionIntoArgument() myActor = 0; myBusy = true; - myEditCurrentArgument->setText( "" ); + myEditCurrentArgument->setText(""); myBusy = false; - if ( !GroupButtons->isEnabled() ) // inactive + if (!GroupButtons->isEnabled()) // inactive return; - buttonOk->setEnabled( false ); - buttonApply->setEnabled( false ); + buttonOk->setEnabled(false); + buttonApply->setEnabled(false); // get selected mesh + SALOME_ListIO aList; + mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type()); - int nbSel = mySelection->IObjectCount(); - if(nbSel != 1) + int nbSel = aList.Extent(); + if (nbSel != 1) return; - myMesh = SMESH::GetMeshByIO( mySelection->firstIObject() ); - if ( myMesh->_is_nil() ) + Handle(SALOME_InteractiveObject) anIO = aList.First(); + myMesh = SMESH::GetMeshByIO(anIO); + if (myMesh->_is_nil()) return; - myActor = SMESH::FindActorByEntry( mySelection->firstIObject()->getEntry() ); - if ( !myActor ) + myActor = SMESH::FindActorByEntry(anIO->getEntry()); + if (!myActor) return; // get selected nodes QString aString = ""; - int nbNodes = SMESH::GetNameOfSelectedNodes(mySelection, aString) ; + int nbNodes = SMESH::GetNameOfSelectedNodes(mySelector,anIO,aString); if(nbNodes < 1) - return ; + return; myBusy = true; - myEditCurrentArgument->setText( aString ); + myEditCurrentArgument->setText(aString); myBusy = false; // OK myNbOkNodes = true; - buttonOk->setEnabled( true ); - buttonApply->setEnabled( true ); + buttonOk->setEnabled(true); + buttonApply->setEnabled(true); } - //================================================================================= // function : SetEditCurrentArgument() // purpose : @@ -403,16 +412,16 @@ void SMESHGUI_RemoveNodesDlg::SetEditCurrentArgument() switch (myConstructorId) { case 0: /* default constructor */ - { + { if(send == SelectButtonC1A1) { - LineEditC1A1->setFocus() ; + LineEditC1A1->setFocus(); myEditCurrentArgument = LineEditC1A1; } - SelectionIntoArgument() ; + SelectionIntoArgument(); break; } } - return ; + return; } //================================================================================= @@ -421,17 +430,15 @@ void SMESHGUI_RemoveNodesDlg::SetEditCurrentArgument() //================================================================================= void SMESHGUI_RemoveNodesDlg::DeactivateActiveDialog() { - if ( GroupConstructors->isEnabled() ) { - GroupConstructors->setEnabled(false) ; - GroupC1->setEnabled(false) ; - GroupButtons->setEnabled(false) ; - mySMESHGUI->ResetState() ; - mySMESHGUI->SetActiveDialogBox(0) ; + if (GroupConstructors->isEnabled()) { + GroupConstructors->setEnabled(false); + GroupC1->setEnabled(false); + GroupButtons->setEnabled(false); + mySMESHGUI->ResetState(); // ?? + mySMESHGUI->SetActiveDialogBox(0); // ?? } - return ; } - //================================================================================= // function : ActivateThisDialog() // purpose : @@ -439,52 +446,47 @@ void SMESHGUI_RemoveNodesDlg::DeactivateActiveDialog() void SMESHGUI_RemoveNodesDlg::ActivateThisDialog() { /* Emit a signal to deactivate the active dialog */ - mySMESHGUI->EmitSignalDeactivateDialog() ; - GroupConstructors->setEnabled(true) ; - GroupC1->setEnabled(true) ; - GroupButtons->setEnabled(true) ; - - mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; + mySMESHGUI->EmitSignalDeactivateDialog(); + + GroupConstructors->setEnabled(true); + GroupC1->setEnabled(true); + GroupButtons->setEnabled(true); + + mySMESHGUI->SetActiveDialogBox((QDialog*)this); // ?? SMESH::SetPointRepresentation(true); - QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true ); + myViewWindow->SetSelectionMode(NodeSelection); - SelectionIntoArgument(); + SelectionIntoArgument(); // ?? } - //================================================================================= // function : enterEvent() // purpose : //================================================================================= -void SMESHGUI_RemoveNodesDlg::enterEvent(QEvent* e) +void SMESHGUI_RemoveNodesDlg::enterEvent (QEvent*) { - if ( GroupConstructors->isEnabled() ) - return ; - ActivateThisDialog() ; - return ; + if (!GroupConstructors->isEnabled()) + ActivateThisDialog(); } - //================================================================================= // function : closeEvent() // purpose : //================================================================================= -void SMESHGUI_RemoveNodesDlg::closeEvent( QCloseEvent* e ) +void SMESHGUI_RemoveNodesDlg::closeEvent (QCloseEvent*) { /* same than click on cancel button */ - this->ClickOnCancel() ; - return ; + this->ClickOnCancel(); + return; } - //======================================================================= //function : hideEvent //purpose : caused by ESC key //======================================================================= - -void SMESHGUI_RemoveNodesDlg::hideEvent ( QHideEvent * e ) +void SMESHGUI_RemoveNodesDlg::hideEvent (QHideEvent * e) { - if ( !isMinimized() ) + if (!isMinimized()) ClickOnCancel(); } diff --git a/src/SMESHGUI/SMESHGUI_RemoveNodesDlg.h b/src/SMESHGUI/SMESHGUI_RemoveNodesDlg.h index d40edccf8..6a847e2cf 100644 --- a/src/SMESHGUI/SMESHGUI_RemoveNodesDlg.h +++ b/src/SMESHGUI/SMESHGUI_RemoveNodesDlg.h @@ -29,7 +29,7 @@ #ifndef DIALOGBOX_REMOVE_NODES_H #define DIALOGBOX_REMOVE_NODES_H -#include "SALOME_Selection.h" +#include "SalomeApp_SelectionMgr.h" // QT Includes #include @@ -47,8 +47,11 @@ class QLabel; class QLineEdit; class QPushButton; class QRadioButton; + class SMESHGUI; class SMESH_Actor; +class SVTK_Selector; +class SVTK_ViewWindow; // IDL Headers #include @@ -59,25 +62,31 @@ class SMESH_Actor; // purpose : //================================================================================= class SMESHGUI_RemoveNodesDlg : public QDialog -{ +{ Q_OBJECT public: - SMESHGUI_RemoveNodesDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); + SMESHGUI_RemoveNodesDlg(SMESHGUI* theModule, + const char* name = 0, + bool modal = FALSE, + WFlags fl = 0); ~SMESHGUI_RemoveNodesDlg(); private: - void Init( SALOME_Selection* Sel ) ; + void Init() ; void closeEvent( QCloseEvent* e ) ; - void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */ - void hideEvent ( QHideEvent * ); /* ESC key */ + void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */ + void hideEvent ( QHideEvent * ); /* ESC key */ - SMESHGUI* mySMESHGUI ; /* Current SMESHGUI object */ - SALOME_Selection* mySelection ; /* User shape selection */ - int myNbOkNodes ; /* to check when arguments is defined */ - int myConstructorId ; /* Current constructor id = radio button id */ - QLineEdit* myEditCurrentArgument; /* Current LineEdit */ + SalomeApp_SelectionMgr* mySelectionMgr; + SVTK_ViewWindow* myViewWindow; + SVTK_Selector* mySelector; + SMESHGUI* mySMESHGUI; + + int myNbOkNodes; /* to check when arguments is defined */ + int myConstructorId; /* Current constructor id = radio button id */ + QLineEdit* myEditCurrentArgument; /* Current LineEdit */ bool myBusy; SMESH::SMESH_Mesh_var myMesh; diff --git a/src/SMESHGUI/SMESHGUI_RenumberingDlg.cxx b/src/SMESHGUI/SMESHGUI_RenumberingDlg.cxx index 00ede0b48..f886e45d5 100644 --- a/src/SMESHGUI/SMESHGUI_RenumberingDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_RenumberingDlg.cxx @@ -1,23 +1,23 @@ // SMESH SMESHGUI : GUI for SMESH component // // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org // // // @@ -31,12 +31,15 @@ #include "SMESHGUI.h" #include "SMESHGUI_Utils.h" #include "SMESHGUI_VTKUtils.h" + #include "SMESH_Actor.h" +#include "SMESH_TypeFilter.hxx" #include "SMDS_Mesh.hxx" -#include "QAD_Application.h" -#include "QAD_Desktop.h" -#include "QAD_MessageBox.h" +#include "SUIT_Session.h" + +#include "SALOME_ListIO.hxx" + #include "utilities.h" // QT Includes @@ -54,120 +57,120 @@ using namespace std; //================================================================================= // class : SMESHGUI_RenumberingDlg() -// purpose : +// purpose : //================================================================================= -SMESHGUI_RenumberingDlg::SMESHGUI_RenumberingDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, - const int unit, bool modal, WFlags fl ) - : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | - Qt::WDestructiveClose) +SMESHGUI_RenumberingDlg::SMESHGUI_RenumberingDlg (QWidget* parent, const char* name, + SalomeApp_SelectionMgr* Sel, + const int unit, bool modal, WFlags fl) + : QDialog(parent, name, modal, WStyle_Customize | WStyle_NormalBorder | + WStyle_Title | WStyle_SysMenu | Qt::WDestructiveClose) { myUnit = unit; - if ( !name ) - setName( "SMESHGUI_RenumberingDlg" ); - resize( 303, 185 ); - + if (!name) + setName("SMESHGUI_RenumberingDlg"); + resize(303, 185); QPixmap image0; - QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SELECT"))); + QPixmap image1(SUIT_Session::session()->resourceMgr()->loadPixmap("SMESH",tr("ICON_SELECT"))); if (unit == 0) { - image0 = QPixmap(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_DLG_RENUMBERING_NODES"))); - setCaption( tr( "SMESH_RENUMBERING_NODES_TITLE" ) ); + image0 = QPixmap(SUIT_Session::session()->resourceMgr()->loadPixmap("SMESH",tr("ICON_DLG_RENUMBERING_NODES"))); + setCaption(tr("SMESH_RENUMBERING_NODES_TITLE" )); } else if (unit == 1) { - image0 = QPixmap(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_DLG_RENUMBERING_ELEMENTS"))); - setCaption( tr( "SMESH_RENUMBERING_ELEMENTS_TITLE" ) ); + image0 = QPixmap(SUIT_Session::session()->resourceMgr()->loadPixmap("SMESH",tr("ICON_DLG_RENUMBERING_ELEMENTS"))); + setCaption(tr("SMESH_RENUMBERING_ELEMENTS_TITLE" )); } - - setSizeGripEnabled( TRUE ); - SMESHGUI_RenumberingDlgLayout = new QGridLayout( this ); - SMESHGUI_RenumberingDlgLayout->setSpacing( 6 ); - SMESHGUI_RenumberingDlgLayout->setMargin( 11 ); - + + setSizeGripEnabled(TRUE); + SMESHGUI_RenumberingDlgLayout = new QGridLayout(this); + SMESHGUI_RenumberingDlgLayout->setSpacing(6); + SMESHGUI_RenumberingDlgLayout->setMargin(11); + /***************************************************************/ - GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); + GroupConstructors = new QButtonGroup(this, "GroupConstructors"); if (unit == 0) - GroupConstructors->setTitle( tr( "SMESH_NODES" ) ); + GroupConstructors->setTitle(tr("SMESH_NODES" )); else if (unit == 1) - GroupConstructors->setTitle( tr( "SMESH_ELEMENTS" ) ); - GroupConstructors->setExclusive( TRUE ); - GroupConstructors->setColumnLayout(0, Qt::Vertical ); - GroupConstructors->layout()->setSpacing( 0 ); - GroupConstructors->layout()->setMargin( 0 ); - GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() ); - GroupConstructorsLayout->setAlignment( Qt::AlignTop ); - GroupConstructorsLayout->setSpacing( 6 ); - GroupConstructorsLayout->setMargin( 11 ); - Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" ); - Constructor1->setText( tr( "" ) ); - Constructor1->setPixmap( image0 ); - Constructor1->setChecked( TRUE ); - Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) ); - Constructor1->setMinimumSize( QSize( 50, 0 ) ); - GroupConstructorsLayout->addWidget( Constructor1, 0, 0 ); - QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); - GroupConstructorsLayout->addItem( spacer, 0, 1 ); - SMESHGUI_RenumberingDlgLayout->addWidget( GroupConstructors, 0, 0 ); - + GroupConstructors->setTitle(tr("SMESH_ELEMENTS" )); + GroupConstructors->setExclusive(TRUE); + GroupConstructors->setColumnLayout(0, Qt::Vertical); + GroupConstructors->layout()->setSpacing(0); + GroupConstructors->layout()->setMargin(0); + GroupConstructorsLayout = new QGridLayout(GroupConstructors->layout()); + GroupConstructorsLayout->setAlignment(Qt::AlignTop); + GroupConstructorsLayout->setSpacing(6); + GroupConstructorsLayout->setMargin(11); + Constructor1 = new QRadioButton(GroupConstructors, "Constructor1"); + Constructor1->setText(tr("" )); + Constructor1->setPixmap(image0); + Constructor1->setChecked(TRUE); + Constructor1->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth())); + Constructor1->setMinimumSize(QSize(50, 0)); + GroupConstructorsLayout->addWidget(Constructor1, 0, 0); + QSpacerItem* spacer = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); + GroupConstructorsLayout->addItem(spacer, 0, 1); + SMESHGUI_RenumberingDlgLayout->addWidget(GroupConstructors, 0, 0); + /***************************************************************/ - GroupButtons = new QGroupBox( this, "GroupButtons" ); - GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); - GroupButtons->setTitle( tr( "" ) ); - GroupButtons->setColumnLayout(0, Qt::Vertical ); - GroupButtons->layout()->setSpacing( 0 ); - GroupButtons->layout()->setMargin( 0 ); - GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); - GroupButtonsLayout->setAlignment( Qt::AlignTop ); - GroupButtonsLayout->setSpacing( 6 ); - GroupButtonsLayout->setMargin( 11 ); - buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); - buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) ); - buttonCancel->setAutoDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonCancel, 0, 3 ); - buttonApply = new QPushButton( GroupButtons, "buttonApply" ); - buttonApply->setText( tr( "SMESH_BUT_APPLY" ) ); - buttonApply->setAutoDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); - QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); - GroupButtonsLayout->addItem( spacer_9, 0, 2 ); - buttonOk = new QPushButton( GroupButtons, "buttonOk" ); - buttonOk->setText( tr( "SMESH_BUT_OK" ) ); - buttonOk->setAutoDefault( TRUE ); - buttonOk->setDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); - SMESHGUI_RenumberingDlgLayout->addWidget( GroupButtons, 2, 0 ); - + GroupButtons = new QGroupBox(this, "GroupButtons"); + GroupButtons->setGeometry(QRect(10, 10, 281, 48)); + GroupButtons->setTitle(tr("" )); + GroupButtons->setColumnLayout(0, Qt::Vertical); + GroupButtons->layout()->setSpacing(0); + GroupButtons->layout()->setMargin(0); + GroupButtonsLayout = new QGridLayout(GroupButtons->layout()); + GroupButtonsLayout->setAlignment(Qt::AlignTop); + GroupButtonsLayout->setSpacing(6); + GroupButtonsLayout->setMargin(11); + buttonCancel = new QPushButton(GroupButtons, "buttonCancel"); + buttonCancel->setText(tr("SMESH_BUT_CLOSE" )); + buttonCancel->setAutoDefault(TRUE); + GroupButtonsLayout->addWidget(buttonCancel, 0, 3); + buttonApply = new QPushButton(GroupButtons, "buttonApply"); + buttonApply->setText(tr("SMESH_BUT_APPLY" )); + buttonApply->setAutoDefault(TRUE); + GroupButtonsLayout->addWidget(buttonApply, 0, 1); + QSpacerItem* spacer_9 = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); + GroupButtonsLayout->addItem(spacer_9, 0, 2); + buttonOk = new QPushButton(GroupButtons, "buttonOk"); + buttonOk->setText(tr("SMESH_BUT_OK" )); + buttonOk->setAutoDefault(TRUE); + buttonOk->setDefault(TRUE); + GroupButtonsLayout->addWidget(buttonOk, 0, 0); + SMESHGUI_RenumberingDlgLayout->addWidget(GroupButtons, 2, 0); + /***************************************************************/ - GroupMesh = new QGroupBox( this, "GroupMesh" ); - GroupMesh->setTitle( tr( "SMESH_RENUMBERING" ) ); - GroupMesh->setMinimumSize( QSize( 0, 0 ) ); - GroupMesh->setFrameShape( QGroupBox::Box ); - GroupMesh->setFrameShadow( QGroupBox::Sunken ); - GroupMesh->setColumnLayout(0, Qt::Vertical ); - GroupMesh->layout()->setSpacing( 0 ); - GroupMesh->layout()->setMargin( 0 ); - GroupMeshLayout = new QGridLayout( GroupMesh->layout() ); - GroupMeshLayout->setAlignment( Qt::AlignTop ); - GroupMeshLayout->setSpacing( 6 ); - GroupMeshLayout->setMargin( 11 ); - TextLabelMesh = new QLabel( GroupMesh, "TextLabelMesh" ); - TextLabelMesh->setText( tr( "SMESH_MESH" ) ); - TextLabelMesh->setMinimumSize( QSize( 50, 0 ) ); - TextLabelMesh->setFrameShape( QLabel::NoFrame ); - TextLabelMesh->setFrameShadow( QLabel::Plain ); - GroupMeshLayout->addWidget( TextLabelMesh, 0, 0 ); - SelectButton = new QPushButton( GroupMesh, "SelectButton" ); - SelectButton->setText( tr( "" ) ); - SelectButton->setPixmap( image1 ); - SelectButton->setToggleButton( FALSE ); - GroupMeshLayout->addWidget( SelectButton, 0, 1 ); - LineEditMesh = new QLineEdit( GroupMesh, "LineEditMesh" ); - LineEditMesh->setReadOnly( true ); - GroupMeshLayout->addWidget( LineEditMesh, 0, 2 ); - SMESHGUI_RenumberingDlgLayout->addWidget( GroupMesh, 1, 0 ); - - Init(Sel) ; /* Initialisations */ + GroupMesh = new QGroupBox(this, "GroupMesh"); + GroupMesh->setTitle(tr("SMESH_RENUMBERING" )); + GroupMesh->setMinimumSize(QSize(0, 0)); + GroupMesh->setFrameShape(QGroupBox::Box); + GroupMesh->setFrameShadow(QGroupBox::Sunken); + GroupMesh->setColumnLayout(0, Qt::Vertical); + GroupMesh->layout()->setSpacing(0); + GroupMesh->layout()->setMargin(0); + GroupMeshLayout = new QGridLayout(GroupMesh->layout()); + GroupMeshLayout->setAlignment(Qt::AlignTop); + GroupMeshLayout->setSpacing(6); + GroupMeshLayout->setMargin(11); + TextLabelMesh = new QLabel(GroupMesh, "TextLabelMesh"); + TextLabelMesh->setText(tr("SMESH_MESH")); + TextLabelMesh->setMinimumSize(QSize(50, 0)); + TextLabelMesh->setFrameShape(QLabel::NoFrame); + TextLabelMesh->setFrameShadow(QLabel::Plain); + GroupMeshLayout->addWidget(TextLabelMesh, 0, 0); + SelectButton = new QPushButton(GroupMesh, "SelectButton"); + SelectButton->setText(tr("" )); + SelectButton->setPixmap(image1); + SelectButton->setToggleButton(FALSE); + GroupMeshLayout->addWidget(SelectButton, 0, 1); + LineEditMesh = new QLineEdit(GroupMesh, "LineEditMesh"); + LineEditMesh->setReadOnly(true); + GroupMeshLayout->addWidget(LineEditMesh, 0, 2); + SMESHGUI_RenumberingDlgLayout->addWidget(GroupMesh, 1, 0); + + Init(Sel); /* Initialisations */ } //================================================================================= @@ -179,79 +182,74 @@ SMESHGUI_RenumberingDlg::~SMESHGUI_RenumberingDlg() // no need to delete child widgets, Qt does it all for us } - //================================================================================= // function : Init() // purpose : //================================================================================= -void SMESHGUI_RenumberingDlg::Init( SALOME_Selection* Sel ) +void SMESHGUI_RenumberingDlg::Init (SalomeApp_SelectionMgr* Sel) { - GroupMesh->show(); - myConstructorId = 0 ; - Constructor1->setChecked( TRUE ); - mySelection = Sel; - mySMESHGUI = SMESHGUI::GetSMESHGUI() ; - mySMESHGUI->SetActiveDialogBox( (QDialog*)this ); + myConstructorId = 0; + Constructor1->setChecked(TRUE); + mySelectionMgr = Sel; + mySMESHGUI = SMESHGUI::GetSMESHGUI(); + mySMESHGUI->SetActiveDialogBox((QDialog*)this); myMesh = SMESH::SMESH_Mesh::_nil(); - - myMeshFilter = new SMESH_TypeFilter( MESH ); + + myMeshFilter = new SMESH_TypeFilter (MESH); /* signals and slots connections */ - connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); - connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ; - connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) ); - connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) ); - - connect( SelectButton, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; - connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; - connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel())); + connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); + connect(GroupConstructors, SIGNAL(clicked(int)), SLOT(ConstructorsClicked(int))); + + connect(SelectButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument())); + connect(mySMESHGUI, SIGNAL (SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog())); + connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); /* to close dialog if study change */ - connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; - + connect(mySMESHGUI, SIGNAL (SignalCloseAllDialogs()), this, SLOT(ClickOnCancel())); + /* Move widget on the botton right corner of main widget */ - int x, y ; - mySMESHGUI->DefineDlgPosition( this, x, y ) ; - this->move( x, y ) ; - this->show() ; /* displays Dialog */ - - myEditCurrentArgument = LineEditMesh ; + int x, y; + mySMESHGUI->DefineDlgPosition(this, x, y); + this->move(x, y); + this->show(); /* displays Dialog */ + + myEditCurrentArgument = LineEditMesh; LineEditMesh->setFocus(); - mySelection->ClearFilters() ; - mySelection->AddFilter( myMeshFilter ) ; - + mySelectionMgr->clearFilters(); + mySelectionMgr->installFilter(myMeshFilter); + SelectionIntoArgument(); } - //================================================================================= // function : ConstructorsClicked() // purpose : Radio button management //================================================================================= -void SMESHGUI_RenumberingDlg::ConstructorsClicked(int constructorId) +void SMESHGUI_RenumberingDlg::ConstructorsClicked (int) { - return ; } - //================================================================================= // function : ClickOnApply() // purpose : //================================================================================= void SMESHGUI_RenumberingDlg::ClickOnApply() { - if (mySMESHGUI->ActiveStudyLocked()) + if (mySMESHGUI->isActiveStudyLocked()) return; - - if ( !myMesh->_is_nil()) + + if (!myMesh->_is_nil()) { try { SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor(); SMESH_Actor* anActor = SMESH::FindActorByObject(myMesh); bool isUnitsLabeled = false; - + if (myUnit == 0 && anActor) { isUnitsLabeled = anActor->GetPointsLabeled(); if (isUnitsLabeled) anActor->SetPointsLabeled(false); @@ -260,7 +258,7 @@ void SMESHGUI_RenumberingDlg::ClickOnApply() isUnitsLabeled = anActor->GetCellsLabeled(); if (isUnitsLabeled) anActor->SetCellsLabeled(false); } - + QApplication::setOverrideCursor(Qt::waitCursor); if (myUnit == 0) { aMeshEditor->RenumberNodes(); @@ -272,11 +270,11 @@ void SMESHGUI_RenumberingDlg::ClickOnApply() } QApplication::restoreOverrideCursor(); } - catch( ... ) + catch(...) { } - - mySelection->ClearIObjects(); + + mySelectionMgr->clearSelected(); SMESH::UpdateView(); } } @@ -287,59 +285,57 @@ void SMESHGUI_RenumberingDlg::ClickOnApply() //================================================================================= void SMESHGUI_RenumberingDlg::ClickOnOk() { - ClickOnApply() ; - ClickOnCancel() ; + ClickOnApply(); + ClickOnCancel(); } - //================================================================================= // function : ClickOnCancel() // purpose : //================================================================================= void SMESHGUI_RenumberingDlg::ClickOnCancel() { - mySelection->ClearIObjects(); - mySelection->ClearFilters(); - disconnect( mySelection, 0, this, 0 ); - mySMESHGUI->ResetState() ; - reject() ; + mySelectionMgr->clearSelected(); + mySelectionMgr->clearFilters(); + disconnect(mySelectionMgr, 0, this, 0); + mySMESHGUI->ResetState(); + reject(); } - //================================================================================= // function : SelectionIntoArgument() // purpose : Called when selection as changed or other case //================================================================================= void SMESHGUI_RenumberingDlg::SelectionIntoArgument() { - if ( !GroupButtons->isEnabled() ) // inactive + if (!GroupButtons->isEnabled()) // inactive return; - - QString aString = ""; - - int nbSel = SMESH::GetNameOfSelectedIObjects(mySelection, aString) ; - if ( myEditCurrentArgument == LineEditMesh ) { + QString aString = ""; + + SALOME_ListIO aList; + mySelectionMgr->selectedObjects(aList); + int nbSel = SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString); + + if (myEditCurrentArgument == LineEditMesh) { // mesh - if ( nbSel != 1 ) { + if (nbSel != 1) { myMesh = SMESH::SMESH_Mesh::_nil(); aString = ""; - } - else { - Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ; - myMesh = SMESH::IObjectToInterface(IO) ; - if( myMesh->_is_nil() ) + } else { + Handle(SALOME_InteractiveObject) IO = aList.First(); + myMesh = SMESH::IObjectToInterface(IO); + if (myMesh->_is_nil()) aString = ""; } } - - myEditCurrentArgument->setText(aString) ; - - bool isEnabled = (!myMesh->_is_nil()); - buttonOk->setEnabled( isEnabled ); - buttonApply->setEnabled( isEnabled ); -} + myEditCurrentArgument->setText(aString); + + bool isEnabled = (!myMesh->_is_nil()); + buttonOk->setEnabled(isEnabled); + buttonApply->setEnabled(isEnabled); +} //================================================================================= // function : SetEditCurrentArgument() @@ -351,12 +347,12 @@ void SMESHGUI_RenumberingDlg::SetEditCurrentArgument() switch (myConstructorId) { case 0: /* default constructor */ - { + { if(send == SelectButton) { - LineEditMesh->setFocus() ; + LineEditMesh->setFocus(); myEditCurrentArgument = LineEditMesh; } - SelectionIntoArgument() ; + SelectionIntoArgument(); break; } } @@ -368,16 +364,15 @@ void SMESHGUI_RenumberingDlg::SetEditCurrentArgument() //================================================================================= void SMESHGUI_RenumberingDlg::DeactivateActiveDialog() { - if ( GroupConstructors->isEnabled() ) { - GroupConstructors->setEnabled(false) ; - GroupMesh->setEnabled(false) ; - GroupButtons->setEnabled(false) ; - mySMESHGUI->ResetState() ; - mySMESHGUI->SetActiveDialogBox(0) ; + if (GroupConstructors->isEnabled()) { + GroupConstructors->setEnabled(false); + GroupMesh->setEnabled(false); + GroupButtons->setEnabled(false); + mySMESHGUI->ResetState(); + mySMESHGUI->SetActiveDialogBox(0); } } - //================================================================================= // function : ActivateThisDialog() // purpose : @@ -385,46 +380,42 @@ void SMESHGUI_RenumberingDlg::DeactivateActiveDialog() void SMESHGUI_RenumberingDlg::ActivateThisDialog() { /* Emit a signal to deactivate the active dialog */ - mySMESHGUI->EmitSignalDeactivateDialog() ; - GroupConstructors->setEnabled(true) ; - GroupMesh->setEnabled(true) ; - GroupButtons->setEnabled(true) ; - - mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; + mySMESHGUI->EmitSignalDeactivateDialog(); + GroupConstructors->setEnabled(true); + GroupMesh->setEnabled(true); + GroupButtons->setEnabled(true); + + mySMESHGUI->SetActiveDialogBox((QDialog*)this); SelectionIntoArgument(); } - //================================================================================= // function : enterEvent() // purpose : //================================================================================= void SMESHGUI_RenumberingDlg::enterEvent(QEvent* e) { - if ( GroupConstructors->isEnabled() ) - return ; - ActivateThisDialog() ; + if (GroupConstructors->isEnabled()) + return; + ActivateThisDialog(); } - //================================================================================= // function : closeEvent() // purpose : //================================================================================= -void SMESHGUI_RenumberingDlg::closeEvent( QCloseEvent* e ) +void SMESHGUI_RenumberingDlg::closeEvent(QCloseEvent* e) { /* same than click on cancel button */ - this->ClickOnCancel() ; + this->ClickOnCancel(); } - //======================================================================= //function : hideEvent //purpose : caused by ESC key //======================================================================= - -void SMESHGUI_RenumberingDlg::hideEvent ( QHideEvent * e ) +void SMESHGUI_RenumberingDlg::hideEvent (QHideEvent * e) { - if ( !isMinimized() ) + if (!isMinimized()) ClickOnCancel(); } diff --git a/src/SMESHGUI/SMESHGUI_RenumberingDlg.h b/src/SMESHGUI/SMESHGUI_RenumberingDlg.h index be6bb435c..74f89af67 100644 --- a/src/SMESHGUI/SMESHGUI_RenumberingDlg.h +++ b/src/SMESHGUI/SMESHGUI_RenumberingDlg.h @@ -29,8 +29,9 @@ #ifndef DIALOGBOX_RENUMBERING_H #define DIALOGBOX_RENUMBERING_H -#include "SALOME_Selection.h" -#include "SMESH_TypeFilter.hxx" +#include "SalomeApp_SelectionMgr.h" +//#include "SMESH_TypeFilter.hxx" +#include "SUIT_SelectionFilter.h" // QT Includes #include @@ -59,24 +60,30 @@ class SMESHGUI_RenumberingDlg : public QDialog Q_OBJECT public: - SMESHGUI_RenumberingDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, const int unit = 0, bool modal = FALSE, WFlags fl = 0 ); + SMESHGUI_RenumberingDlg (QWidget* parent = 0, + const char* name = 0, + SalomeApp_SelectionMgr* Sel = 0, + const int unit = 0, + bool modal = FALSE, + WFlags fl = 0); ~SMESHGUI_RenumberingDlg(); private: - void Init( SALOME_Selection* Sel ) ; + void Init( SalomeApp_SelectionMgr* Sel ) ; void closeEvent( QCloseEvent* e ) ; - void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */ - void hideEvent ( QHideEvent * ); /* ESC key */ + void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */ + void hideEvent ( QHideEvent * ); /* ESC key */ - SMESHGUI* mySMESHGUI ; /* Current SMESHGUI object */ - SALOME_Selection* mySelection ; /* User shape selection */ - int myConstructorId ; /* Current constructor id = radio button id */ - QLineEdit* myEditCurrentArgument; /* Current LineEdit */ + SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */ + SalomeApp_SelectionMgr* mySelectionMgr; /* User shape selection */ + int myConstructorId; /* Current constructor id = radio button id */ + QLineEdit* myEditCurrentArgument; /* Current LineEdit */ int myUnit; SMESH::SMESH_Mesh_var myMesh; - Handle(SMESH_TypeFilter) myMeshFilter; + //Handle(SMESH_TypeFilter) myMeshFilter; + SUIT_SelectionFilter* myMeshFilter; QButtonGroup* GroupConstructors; QRadioButton* Constructor1; diff --git a/src/SMESHGUI/SMESHGUI_RevolutionDlg.cxx b/src/SMESHGUI/SMESHGUI_RevolutionDlg.cxx index f7782b57d..731f9460d 100644 --- a/src/SMESHGUI/SMESHGUI_RevolutionDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_RevolutionDlg.cxx @@ -1,47 +1,59 @@ // SMESH SMESHGUI : GUI for SMESH component // // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org // // // // File : SMESHGUI_RevolutionDlg.cxx // Author : Michael ZORIN // Module : SMESH -// $Header: +// $Header: #include "SMESHGUI_RevolutionDlg.h" + #include "SMESHGUI.h" #include "SMESHGUI_SpinBox.h" #include "SMESHGUI_Utils.h" #include "SMESHGUI_VTKUtils.h" #include "SMESHGUI_MeshUtils.h" #include "SMESHGUI_IdValidator.h" + #include "SMESH_Actor.h" #include "SMESH_TypeFilter.hxx" +#include "SMESH_LogicalFilter.hxx" #include "SMDS_Mesh.hxx" -#include "QAD_Application.h" -#include "QAD_Desktop.h" -#include "QAD_MessageBox.h" +#include "SUIT_ResourceMgr.h" + +#include "SVTK_ViewModel.h" +#include "SVTK_ViewWindow.h" +#include "SVTK_Selector.h" +#include "SVTK_Selection.h" +#include "SALOME_ListIO.hxx" + #include "utilities.h" +// OCCT Includes +#include +#include + // QT Includes #include #include @@ -52,7 +64,7 @@ #include #include #include -#include +#include #include #include @@ -64,269 +76,271 @@ using namespace std; //================================================================================= // class : SMESHGUI_RevolutionDlg() -// purpose : +// purpose : //================================================================================= -SMESHGUI_RevolutionDlg::SMESHGUI_RevolutionDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, - bool modal, WFlags fl ) - : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | - Qt::WDestructiveClose) +SMESHGUI_RevolutionDlg::SMESHGUI_RevolutionDlg( SMESHGUI* theModule, const char* name, + bool modal, WFlags fl) + : QDialog( SMESH::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder | + WStyle_Title | WStyle_SysMenu | Qt::WDestructiveClose), + mySMESHGUI( theModule ), + mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ), + myViewWindow( SMESH::GetViewWindow( theModule ) ), + mySelector( myViewWindow->GetSelector() ) { - QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_DLG_EDGE"))); - QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_DLG_TRIANGLE"))); - QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SELECT"))); + QPixmap image0 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_DLG_EDGE"))); + QPixmap image1 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_DLG_TRIANGLE"))); + QPixmap image2 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT"))); - if ( !name ) - setName( "SMESHGUI_RevolutionDlg" ); - resize( 303, 185 ); - setCaption( tr( "REVOLUTION_AROUND_AXIS" ) ); - setSizeGripEnabled( TRUE ); - SMESHGUI_RevolutionDlgLayout = new QGridLayout( this ); - SMESHGUI_RevolutionDlgLayout->setSpacing( 6 ); - SMESHGUI_RevolutionDlgLayout->setMargin( 11 ); + if (!name) + setName("SMESHGUI_RevolutionDlg"); + resize(303, 185); + setCaption(tr("REVOLUTION_AROUND_AXIS")); + setSizeGripEnabled(TRUE); + SMESHGUI_RevolutionDlgLayout = new QGridLayout(this); + SMESHGUI_RevolutionDlgLayout->setSpacing(6); + SMESHGUI_RevolutionDlgLayout->setMargin(11); /***************************************************************/ - GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); - GroupConstructors->setTitle( tr( "SMESH_REVOLUTION" ) ); - GroupConstructors->setExclusive( TRUE ); - GroupConstructors->setColumnLayout(0, Qt::Vertical ); - GroupConstructors->layout()->setSpacing( 0 ); - GroupConstructors->layout()->setMargin( 0 ); - GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() ); - GroupConstructorsLayout->setAlignment( Qt::AlignTop ); - GroupConstructorsLayout->setSpacing( 6 ); - GroupConstructorsLayout->setMargin( 11 ); - RadioButton1= new QRadioButton( GroupConstructors, "RadioButton1" ); - RadioButton1->setText( tr( "" ) ); - RadioButton1->setPixmap( image0 ); - GroupConstructorsLayout->addWidget( RadioButton1, 0, 0 ); - RadioButton2= new QRadioButton( GroupConstructors, "RadioButton2" ); - RadioButton2->setText( tr( "" ) ); - RadioButton2->setPixmap( image1 ); - GroupConstructorsLayout->addWidget( RadioButton2, 0, 2 ); - SMESHGUI_RevolutionDlgLayout->addWidget( GroupConstructors, 0, 0 ); - - /***************************************************************/ - GroupButtons = new QGroupBox( this, "GroupButtons" ); - GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); - GroupButtons->setTitle( tr( "" ) ); - GroupButtons->setColumnLayout(0, Qt::Vertical ); - GroupButtons->layout()->setSpacing( 0 ); - GroupButtons->layout()->setMargin( 0 ); - GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); - GroupButtonsLayout->setAlignment( Qt::AlignTop ); - GroupButtonsLayout->setSpacing( 6 ); - GroupButtonsLayout->setMargin( 11 ); - buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); - buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) ); - buttonCancel->setAutoDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonCancel, 0, 3 ); - buttonApply = new QPushButton( GroupButtons, "buttonApply" ); - buttonApply->setText( tr( "SMESH_BUT_APPLY" ) ); - buttonApply->setAutoDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); - QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); - GroupButtonsLayout->addItem( spacer_9, 0, 2 ); - buttonOk = new QPushButton( GroupButtons, "buttonOk" ); - buttonOk->setText( tr( "SMESH_BUT_OK" ) ); - buttonOk->setAutoDefault( TRUE ); - buttonOk->setDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); - SMESHGUI_RevolutionDlgLayout->addWidget( GroupButtons, 2, 0 ); + GroupConstructors = new QButtonGroup(this, "GroupConstructors"); + GroupConstructors->setTitle(tr("SMESH_REVOLUTION" )); + GroupConstructors->setExclusive(TRUE); + GroupConstructors->setColumnLayout(0, Qt::Vertical); + GroupConstructors->layout()->setSpacing(0); + GroupConstructors->layout()->setMargin(0); + GroupConstructorsLayout = new QGridLayout(GroupConstructors->layout()); + GroupConstructorsLayout->setAlignment(Qt::AlignTop); + GroupConstructorsLayout->setSpacing(6); + GroupConstructorsLayout->setMargin(11); + RadioButton1= new QRadioButton(GroupConstructors, "RadioButton1"); + RadioButton1->setText(tr("" )); + RadioButton1->setPixmap(image0); + GroupConstructorsLayout->addWidget(RadioButton1, 0, 0); + RadioButton2= new QRadioButton(GroupConstructors, "RadioButton2"); + RadioButton2->setText(tr("" )); + RadioButton2->setPixmap(image1); + GroupConstructorsLayout->addWidget(RadioButton2, 0, 2); + SMESHGUI_RevolutionDlgLayout->addWidget(GroupConstructors, 0, 0); /***************************************************************/ - GroupArguments = new QGroupBox( this, "GroupArguments" ); - GroupArguments->setTitle( tr( "REVOLUTION_1D" ) ); - GroupArguments->setColumnLayout(0, Qt::Vertical ); - GroupArguments->layout()->setSpacing( 0 ); - GroupArguments->layout()->setMargin( 0 ); - GroupArgumentsLayout = new QGridLayout( GroupArguments->layout() ); - GroupArgumentsLayout->setAlignment( Qt::AlignTop ); - GroupArgumentsLayout->setSpacing( 6 ); - GroupArgumentsLayout->setMargin( 11 ); + GroupButtons = new QGroupBox(this, "GroupButtons"); + GroupButtons->setGeometry(QRect(10, 10, 281, 48)); + GroupButtons->setTitle(tr("" )); + GroupButtons->setColumnLayout(0, Qt::Vertical); + GroupButtons->layout()->setSpacing(0); + GroupButtons->layout()->setMargin(0); + GroupButtonsLayout = new QGridLayout(GroupButtons->layout()); + GroupButtonsLayout->setAlignment(Qt::AlignTop); + GroupButtonsLayout->setSpacing(6); + GroupButtonsLayout->setMargin(11); + buttonCancel = new QPushButton(GroupButtons, "buttonCancel"); + buttonCancel->setText(tr("SMESH_BUT_CLOSE" )); + buttonCancel->setAutoDefault(TRUE); + GroupButtonsLayout->addWidget(buttonCancel, 0, 3); + buttonApply = new QPushButton(GroupButtons, "buttonApply"); + buttonApply->setText(tr("SMESH_BUT_APPLY" )); + buttonApply->setAutoDefault(TRUE); + GroupButtonsLayout->addWidget(buttonApply, 0, 1); + QSpacerItem* spacer_9 = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); + GroupButtonsLayout->addItem(spacer_9, 0, 2); + buttonOk = new QPushButton(GroupButtons, "buttonOk"); + buttonOk->setText(tr("SMESH_BUT_OK" )); + buttonOk->setAutoDefault(TRUE); + buttonOk->setDefault(TRUE); + GroupButtonsLayout->addWidget(buttonOk, 0, 0); + SMESHGUI_RevolutionDlgLayout->addWidget(GroupButtons, 2, 0); + + /***************************************************************/ + GroupArguments = new QGroupBox(this, "GroupArguments"); + GroupArguments->setTitle(tr("REVOLUTION_1D")); + GroupArguments->setColumnLayout(0, Qt::Vertical); + GroupArguments->layout()->setSpacing(0); + GroupArguments->layout()->setMargin(0); + GroupArgumentsLayout = new QGridLayout(GroupArguments->layout()); + GroupArgumentsLayout->setAlignment(Qt::AlignTop); + GroupArgumentsLayout->setSpacing(6); + GroupArgumentsLayout->setMargin(11); // Controls for elements selection - TextLabelElements = new QLabel( GroupArguments, "TextLabelElements" ); - TextLabelElements->setText( tr( "SMESH_ID_ELEMENTS" ) ); + TextLabelElements = new QLabel(GroupArguments, "TextLabelElements"); + TextLabelElements->setText(tr("SMESH_ID_ELEMENTS" )); TextLabelElements->setFixedWidth(74); - GroupArgumentsLayout->addWidget( TextLabelElements, 0, 0 ); + GroupArgumentsLayout->addWidget(TextLabelElements, 0, 0); - SelectElementsButton = new QPushButton( GroupArguments, "SelectElementsButton" ); - SelectElementsButton->setText( tr( "" ) ); - SelectElementsButton->setPixmap( image2 ); - SelectElementsButton->setToggleButton( FALSE ); - GroupArgumentsLayout->addWidget( SelectElementsButton, 0, 1 ); + SelectElementsButton = new QPushButton(GroupArguments, "SelectElementsButton"); + SelectElementsButton->setText(tr("" )); + SelectElementsButton->setPixmap(image2); + SelectElementsButton->setToggleButton(FALSE); + GroupArgumentsLayout->addWidget(SelectElementsButton, 0, 1); - LineEditElements = new QLineEdit( GroupArguments, "LineEditElements" ); - LineEditElements->setValidator( new SMESHGUI_IdValidator( this, "validator" )); - GroupArgumentsLayout->addWidget( LineEditElements, 0, 2 ); + LineEditElements = new QLineEdit(GroupArguments, "LineEditElements"); + LineEditElements->setValidator(new SMESHGUI_IdValidator(this, "validator")); + GroupArgumentsLayout->addWidget(LineEditElements, 0, 2); // Control for the whole mesh selection - CheckBoxMesh = new QCheckBox( GroupArguments, "CheckBoxMesh" ); - CheckBoxMesh->setText( tr( "SMESH_SELECT_WHOLE_MESH" ) ); - GroupArgumentsLayout->addMultiCellWidget( CheckBoxMesh, 1, 1, 0, 3 ); + CheckBoxMesh = new QCheckBox(GroupArguments, "CheckBoxMesh"); + CheckBoxMesh->setText(tr("SMESH_SELECT_WHOLE_MESH" )); + GroupArgumentsLayout->addMultiCellWidget(CheckBoxMesh, 1, 1, 0, 3); // Controls for axis defining - GroupAxis = new QGroupBox( GroupArguments, "GroupAxis" ); - GroupAxis->setTitle( tr( "SMESH_AXIS" ) ); - GroupAxis->setColumnLayout(0, Qt::Vertical ); - GroupAxis->layout()->setSpacing( 0 ); - GroupAxis->layout()->setMargin( 0 ); - QGridLayout* GroupAxisLayout = new QGridLayout( GroupAxis->layout() ); - GroupAxisLayout->setAlignment( Qt::AlignTop ); - GroupAxisLayout->setSpacing( 6 ); - GroupAxisLayout->setMargin( 11 ); - - TextLabelPoint = new QLabel( GroupAxis, "TextLabelPoint" ); - TextLabelPoint->setText( tr( "SMESH_POINT" ) ); - GroupAxisLayout->addWidget( TextLabelPoint, 0, 0 ); + GroupAxis = new QGroupBox(GroupArguments, "GroupAxis"); + GroupAxis->setTitle(tr("SMESH_AXIS")); + GroupAxis->setColumnLayout(0, Qt::Vertical); + GroupAxis->layout()->setSpacing(0); + GroupAxis->layout()->setMargin(0); + QGridLayout* GroupAxisLayout = new QGridLayout(GroupAxis->layout()); + GroupAxisLayout->setAlignment(Qt::AlignTop); + GroupAxisLayout->setSpacing(6); + GroupAxisLayout->setMargin(11); - SelectPointButton = new QPushButton( GroupAxis, "SelectPointButton" ); - SelectPointButton->setPixmap( image2 ); - GroupAxisLayout->addWidget( SelectPointButton, 0, 1 ); - - TextLabelX = new QLabel( GroupAxis, "TextLabelX" ); - TextLabelX->setText( tr( "SMESH_X" ) ); - GroupAxisLayout->addWidget( TextLabelX, 0, 2 ); + TextLabelPoint = new QLabel(GroupAxis, "TextLabelPoint"); + TextLabelPoint->setText(tr("SMESH_POINT")); + GroupAxisLayout->addWidget(TextLabelPoint, 0, 0); - SpinBox_X = new SMESHGUI_SpinBox( GroupAxis, "SpinBox_X"); - GroupAxisLayout->addWidget( SpinBox_X, 0, 3 ); - - TextLabelY = new QLabel( GroupAxis, "TextLabelY" ); - TextLabelY->setText( tr( "SMESH_Y" ) ); - GroupAxisLayout->addWidget( TextLabelY, 0, 4 ); + SelectPointButton = new QPushButton(GroupAxis, "SelectPointButton"); + SelectPointButton->setPixmap(image2); + GroupAxisLayout->addWidget(SelectPointButton, 0, 1); - SpinBox_Y = new SMESHGUI_SpinBox( GroupAxis, "SpinBox_Y"); - GroupAxisLayout->addWidget( SpinBox_Y, 0, 5 ); + TextLabelX = new QLabel(GroupAxis, "TextLabelX"); + TextLabelX->setText(tr("SMESH_X")); + GroupAxisLayout->addWidget(TextLabelX, 0, 2); - TextLabelZ = new QLabel( GroupAxis, "TextLabelZ" ); - TextLabelZ->setText( tr( "SMESH_Z" ) ); - GroupAxisLayout->addWidget( TextLabelZ, 0, 6 ); - - SpinBox_Z = new SMESHGUI_SpinBox( GroupAxis, "SpinBox_Z"); - GroupAxisLayout->addWidget( SpinBox_Z, 0, 7 ); + SpinBox_X = new SMESHGUI_SpinBox(GroupAxis, "SpinBox_X"); + GroupAxisLayout->addWidget(SpinBox_X, 0, 3); - TextLabelVector = new QLabel( GroupAxis, "TextLabelVector" ); - TextLabelVector->setText( tr( "SMESH_VECTOR" ) ); - GroupAxisLayout->addWidget( TextLabelVector, 1, 0 ); - - SelectVectorButton = new QPushButton( GroupAxis, "SelectVectorButton" ); - SelectVectorButton->setPixmap( image2 ); - GroupAxisLayout->addWidget( SelectVectorButton, 1, 1 ); - - TextLabelDX = new QLabel( GroupAxis, "TextLabelDX" ); - TextLabelDX->setText( tr( "SMESH_DX" ) ); - GroupAxisLayout->addWidget( TextLabelDX, 1, 2 ); + TextLabelY = new QLabel(GroupAxis, "TextLabelY"); + TextLabelY->setText(tr("SMESH_Y")); + GroupAxisLayout->addWidget(TextLabelY, 0, 4); - SpinBox_DX = new SMESHGUI_SpinBox( GroupAxis, "SpinBox_DX"); - GroupAxisLayout->addWidget( SpinBox_DX, 1, 3 ); - - TextLabelDY = new QLabel( GroupAxis, "TextLabelDY" ); - TextLabelDY->setText( tr( "SMESH_DY" ) ); - GroupAxisLayout->addWidget( TextLabelDY, 1, 4 ); + SpinBox_Y = new SMESHGUI_SpinBox(GroupAxis, "SpinBox_Y"); + GroupAxisLayout->addWidget(SpinBox_Y, 0, 5); - SpinBox_DY = new SMESHGUI_SpinBox( GroupAxis, "SpinBox_DY"); - GroupAxisLayout->addWidget( SpinBox_DY, 1, 5 ); + TextLabelZ = new QLabel(GroupAxis, "TextLabelZ"); + TextLabelZ->setText(tr("SMESH_Z")); + GroupAxisLayout->addWidget(TextLabelZ, 0, 6); - TextLabelDZ = new QLabel( GroupAxis, "TextLabelDZ" ); - TextLabelDZ->setText( tr( "SMESH_DZ" ) ); - GroupAxisLayout->addWidget( TextLabelDZ, 1, 6 ); - - SpinBox_DZ = new SMESHGUI_SpinBox( GroupAxis, "SpinBox_DZ"); - GroupAxisLayout->addWidget( SpinBox_DZ, 1, 7 ); + SpinBox_Z = new SMESHGUI_SpinBox(GroupAxis, "SpinBox_Z"); + GroupAxisLayout->addWidget(SpinBox_Z, 0, 7); + + TextLabelVector = new QLabel(GroupAxis, "TextLabelVector"); + TextLabelVector->setText(tr("SMESH_VECTOR")); + GroupAxisLayout->addWidget(TextLabelVector, 1, 0); + + SelectVectorButton = new QPushButton(GroupAxis, "SelectVectorButton"); + SelectVectorButton->setPixmap(image2); + GroupAxisLayout->addWidget(SelectVectorButton, 1, 1); + + TextLabelDX = new QLabel(GroupAxis, "TextLabelDX"); + TextLabelDX->setText(tr("SMESH_DX")); + GroupAxisLayout->addWidget(TextLabelDX, 1, 2); + + SpinBox_DX = new SMESHGUI_SpinBox(GroupAxis, "SpinBox_DX"); + GroupAxisLayout->addWidget(SpinBox_DX, 1, 3); + + TextLabelDY = new QLabel(GroupAxis, "TextLabelDY"); + TextLabelDY->setText(tr("SMESH_DY")); + GroupAxisLayout->addWidget(TextLabelDY, 1, 4); + + SpinBox_DY = new SMESHGUI_SpinBox(GroupAxis, "SpinBox_DY"); + GroupAxisLayout->addWidget(SpinBox_DY, 1, 5); + + TextLabelDZ = new QLabel(GroupAxis, "TextLabelDZ"); + TextLabelDZ->setText(tr("SMESH_DZ")); + GroupAxisLayout->addWidget(TextLabelDZ, 1, 6); + + SpinBox_DZ = new SMESHGUI_SpinBox(GroupAxis, "SpinBox_DZ"); + GroupAxisLayout->addWidget(SpinBox_DZ, 1, 7); + + GroupArgumentsLayout->addMultiCellWidget(GroupAxis, 2, 2, 0, 3); - GroupArgumentsLayout->addMultiCellWidget( GroupAxis, 2, 2, 0, 3 ); - // Controls for angle defining - TextLabelAngle = new QLabel( GroupArguments, "TextLabelAngle" ); - TextLabelAngle->setText( tr( "SMESH_ANGLE" ) ); - GroupArgumentsLayout->addMultiCellWidget( TextLabelAngle, 3, 3, 0, 1 ); + TextLabelAngle = new QLabel(GroupArguments, "TextLabelAngle"); + TextLabelAngle->setText(tr("SMESH_ANGLE" )); + GroupArgumentsLayout->addMultiCellWidget(TextLabelAngle, 3, 3, 0, 1); SpinBox_Angle = new SMESHGUI_SpinBox(GroupArguments, "SpinBox_Angle"); - GroupArgumentsLayout->addWidget( SpinBox_Angle, 3, 2 ); - + GroupArgumentsLayout->addWidget(SpinBox_Angle, 3, 2); + // Controls for nb. steps defining - TextLabelNbSteps = new QLabel( GroupArguments, "TextLabelNbSteps" ); - TextLabelNbSteps->setText( tr( "SMESH_NUMBEROFSTEPS" ) ); - GroupArgumentsLayout->addMultiCellWidget( TextLabelNbSteps, 4, 4, 0, 1 ); + TextLabelNbSteps = new QLabel(GroupArguments, "TextLabelNbSteps"); + TextLabelNbSteps->setText(tr("SMESH_NUMBEROFSTEPS" )); + GroupArgumentsLayout->addMultiCellWidget(TextLabelNbSteps, 4, 4, 0, 1); SpinBox_NbSteps = new QSpinBox(GroupArguments, "SpinBox_NbSteps"); - GroupArgumentsLayout->addWidget( SpinBox_NbSteps, 4, 2 ); - + GroupArgumentsLayout->addWidget(SpinBox_NbSteps, 4, 2); + // Controls for tolerance defining - TextLabelTolerance = new QLabel( GroupArguments, "TextLabelTolerance" ); - TextLabelTolerance->setText( tr( "SMESH_TOLERANCE" ) ); - GroupArgumentsLayout->addMultiCellWidget( TextLabelTolerance, 5, 5, 0, 1 ); + TextLabelTolerance = new QLabel(GroupArguments, "TextLabelTolerance"); + TextLabelTolerance->setText(tr("SMESH_TOLERANCE")); + GroupArgumentsLayout->addMultiCellWidget(TextLabelTolerance, 5, 5, 0, 1); SpinBox_Tolerance = new SMESHGUI_SpinBox(GroupArguments, "SpinBox_Tolerance"); - GroupArgumentsLayout->addWidget( SpinBox_Tolerance, 5, 2 ); + GroupArgumentsLayout->addWidget(SpinBox_Tolerance, 5, 2); + + SMESHGUI_RevolutionDlgLayout->addWidget(GroupArguments, 1, 0); - SMESHGUI_RevolutionDlgLayout->addWidget( GroupArguments, 1, 0 ); - /* Initialisations */ - SpinBox_X->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 ); - SpinBox_Y->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 ); - SpinBox_Z->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 ); - SpinBox_DX->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 ); - SpinBox_DY->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 ); - SpinBox_DZ->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 ); + SpinBox_X->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3); + SpinBox_Y->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3); + SpinBox_Z->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3); + SpinBox_DX->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3); + SpinBox_DY->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3); + SpinBox_DZ->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3); + + SpinBox_Angle->RangeStepAndValidator(-999999.999, +999999.999, 5.0, 3); - SpinBox_Angle->RangeStepAndValidator( -999999.999, +999999.999, 5.0, 3 ); - QIntValidator* anIntValidator = new QIntValidator(SpinBox_NbSteps); SpinBox_NbSteps->setValidator(anIntValidator); - SpinBox_NbSteps->setRange( 1, 999999 ); - - SpinBox_Tolerance->RangeStepAndValidator( 0.0, +999999.999, 0.1, 6 ); - + SpinBox_NbSteps->setRange(1, 999999); + + SpinBox_Tolerance->RangeStepAndValidator(0.0, +999999.999, 0.1, 6); + GroupArguments->show(); - RadioButton1->setChecked( TRUE ); - mySelection = Sel; + RadioButton1->setChecked(TRUE); + + mySMESHGUI->SetActiveDialogBox((QDialog*)this); - mySMESHGUI = SMESHGUI::GetSMESHGUI() ; - mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; - // Costruction of the logical filter - SMESH_ListOfFilter aListOfFilters; - Handle(SMESH_TypeFilter) aMeshOrSubMeshFilter = new SMESH_TypeFilter( MESHorSUBMESH ); - if ( !aMeshOrSubMeshFilter.IsNull() ) - aListOfFilters.Append( aMeshOrSubMeshFilter ); - Handle(SMESH_TypeFilter) aSmeshGroupFilter = new SMESH_TypeFilter( GROUP ); - if ( !aSmeshGroupFilter.IsNull() ) - aListOfFilters.Append( aSmeshGroupFilter ); - - myMeshOrSubMeshOrGroupFilter = new SMESH_LogicalFilter( aListOfFilters, SMESH_LogicalFilter::LO_OR ); - + SMESH_TypeFilter* aMeshOrSubMeshFilter = new SMESH_TypeFilter (MESHorSUBMESH); + SMESH_TypeFilter* aSmeshGroupFilter = new SMESH_TypeFilter (GROUP); + + QPtrList aListOfFilters; + if (aMeshOrSubMeshFilter) aListOfFilters.append(aMeshOrSubMeshFilter); + if (aSmeshGroupFilter) aListOfFilters.append(aSmeshGroupFilter); + + myMeshOrSubMeshOrGroupFilter = + new SMESH_LogicalFilter (aListOfFilters, SMESH_LogicalFilter::LO_OR); + Init(); + /* signals and slots connections */ - connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); - connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ; - connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) ); - connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) ); - - connect( SelectElementsButton, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; - connect( SelectPointButton, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; - connect( SelectVectorButton, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel())); + connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); + connect(GroupConstructors, SIGNAL(clicked(int)), SLOT(ConstructorsClicked(int))); - connect( SpinBox_DX, SIGNAL( valueChanged( double )), this, SLOT(onVectorChanged() ) ); - connect( SpinBox_DY, SIGNAL( valueChanged( double )), this, SLOT(onVectorChanged() ) ); - connect( SpinBox_DZ, SIGNAL( valueChanged( double )), this, SLOT(onVectorChanged() ) ); + connect(SelectElementsButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument())); + connect(SelectPointButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument())); + connect(SelectVectorButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument())); - connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; - connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + connect(SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged())); + connect(SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged())); + connect(SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged())); + + connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog())); + connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); /* to close dialog if study change */ - connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; - connect( LineEditElements, SIGNAL( textChanged( const QString& )), - SLOT( onTextChange( const QString& ))); - connect( CheckBoxMesh, SIGNAL( toggled( bool )), - SLOT( onSelectMesh( bool ))); - + connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel())); + connect(LineEditElements, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&))); + connect(CheckBoxMesh, SIGNAL(toggled(bool)), SLOT(onSelectMesh(bool))); + /* Move widget on the botton right corner of main widget */ - int x, y ; - mySMESHGUI->DefineDlgPosition( this, x, y ) ; - this->move( x, y ) ; - this->show() ; /* displays Dialog */ + int x, y; + mySMESHGUI->DefineDlgPosition(this, x, y); + this->move(x, y); + this->show(); /* displays Dialog */ ConstructorsClicked(0); + resize(0,0); // ?? } //================================================================================= @@ -338,83 +352,79 @@ SMESHGUI_RevolutionDlg::~SMESHGUI_RevolutionDlg() // no need to delete child widgets, Qt does it all for us } - //================================================================================= // function : Init() // purpose : //================================================================================= -void SMESHGUI_RevolutionDlg::Init( bool ResetControls ) +void SMESHGUI_RevolutionDlg::Init (bool ResetControls) { myBusy = false; - + myEditCurrentArgument = 0; LineEditElements->clear(); myElementsId = ""; - myNbOkElements = 0 ; - - myActor = 0; - myMesh = SMESH::SMESH_Mesh::_nil(); - - if( ResetControls ) - { - SpinBox_X->SetValue(0.0); - SpinBox_Y->SetValue(0.0); - SpinBox_Z->SetValue(0.0); - SpinBox_DX->SetValue(0.0); - SpinBox_DY->SetValue(0.0); - SpinBox_DZ->SetValue(0.0); - - SpinBox_Angle->SetValue(45); - SpinBox_NbSteps->setValue(1); - SpinBox_Tolerance->SetValue(1e-05); - - CheckBoxMesh->setChecked(false); - onSelectMesh( false ); - } -} + myNbOkElements = 0; + myActor = 0; + myMesh = SMESH::SMESH_Mesh::_nil(); + + if (ResetControls) { + SpinBox_X->SetValue(0.0); + SpinBox_Y->SetValue(0.0); + SpinBox_Z->SetValue(0.0); + SpinBox_DX->SetValue(0.0); + SpinBox_DY->SetValue(0.0); + SpinBox_DZ->SetValue(0.0); + + SpinBox_Angle->SetValue(45); + SpinBox_NbSteps->setValue(1); + SpinBox_Tolerance->SetValue(1e-05); + + CheckBoxMesh->setChecked(false); + onSelectMesh(false); + } +} //================================================================================= // function : ConstructorsClicked() // purpose : Radio button management //================================================================================= -void SMESHGUI_RevolutionDlg::ConstructorsClicked(int constructorId) +void SMESHGUI_RevolutionDlg::ConstructorsClicked (int constructorId) { - disconnect(mySelection, 0, this, 0); - + disconnect(mySelectionMgr, 0, this, 0); + Selection_Mode aSelMode = ActorSelection; - switch(constructorId) - { - case 0 : - { - GroupArguments->setTitle( tr( "REVOLUTION_1D" ) ); - aSelMode = EdgeSelection; - break; - } - case 1 : - { - GroupArguments->setTitle( tr( "REVOLUTION_2D" ) ); - aSelMode = FaceSelection; - break; - } + switch (constructorId) { + case 0: + { + GroupArguments->setTitle(tr("REVOLUTION_1D")); + aSelMode = EdgeSelection; + break; } - - if (myEditCurrentArgument != (QWidget*)LineEditElements) + case 1: + { + GroupArguments->setTitle(tr("REVOLUTION_2D")); + aSelMode = FaceSelection; + break; + } + } + + if (myEditCurrentArgument != (QWidget*)LineEditElements) { SMESH::SetPointRepresentation(false); - + } + if (!CheckBoxMesh->isChecked()) - QAD_Application::getDesktop()->SetSelectionMode( aSelMode, true ); - + myViewWindow->SetSelectionMode(aSelMode); + myEditCurrentArgument = (QWidget*)LineEditElements; LineEditElements->setFocus(); - + if (CheckBoxMesh->isChecked()) onSelectMesh(true); - - connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); -} + connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); +} //================================================================================= // function : ClickOnApply() @@ -422,48 +432,44 @@ void SMESHGUI_RevolutionDlg::ConstructorsClicked(int constructorId) //================================================================================= void SMESHGUI_RevolutionDlg::ClickOnApply() { - if (mySMESHGUI->ActiveStudyLocked()) + if (mySMESHGUI->isActiveStudyLocked()) return; - - if ( myNbOkElements && IsAxisOk()) - { - QStringList aListElementsId = QStringList::split( " ", myElementsId, false); - - SMESH::long_array_var anElementsId = new SMESH::long_array; - - anElementsId->length( aListElementsId.count() ); - for ( int i = 0; i < aListElementsId.count(); i++ ) - anElementsId[i] = aListElementsId[i].toInt(); - - SMESH::AxisStruct anAxis; - - anAxis.x = SpinBox_X->GetValue(); - anAxis.y = SpinBox_Y->GetValue(); - anAxis.z = SpinBox_Z->GetValue();; - anAxis.vx = SpinBox_DX->GetValue(); - anAxis.vy = SpinBox_DY->GetValue(); - anAxis.vz = SpinBox_DZ->GetValue(); - double anAngle = (SpinBox_Angle->GetValue())*PI/180; - long aNbSteps = (long)SpinBox_NbSteps->value(); - double aTolerance = SpinBox_Tolerance->GetValue(); + if (myNbOkElements && IsAxisOk()) { + QStringList aListElementsId = QStringList::split(" ", myElementsId, false); - try - { - SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor(); - QApplication::setOverrideCursor(Qt::waitCursor); - aMeshEditor->RotationSweep(anElementsId.inout(), anAxis, anAngle, aNbSteps, aTolerance); - QApplication::restoreOverrideCursor(); - } - catch( ... ) - { - } - - mySelection->ClearIObjects(); - SMESH::UpdateView(); - Init( false); - ConstructorsClicked( GetConstructorId() ); + SMESH::long_array_var anElementsId = new SMESH::long_array; + + anElementsId->length(aListElementsId.count()); + for (int i = 0; i < aListElementsId.count(); i++) + anElementsId[i] = aListElementsId[i].toInt(); + + SMESH::AxisStruct anAxis; + + anAxis.x = SpinBox_X->GetValue(); + anAxis.y = SpinBox_Y->GetValue(); + anAxis.z = SpinBox_Z->GetValue();; + anAxis.vx = SpinBox_DX->GetValue(); + anAxis.vy = SpinBox_DY->GetValue(); + anAxis.vz = SpinBox_DZ->GetValue(); + + double anAngle = (SpinBox_Angle->GetValue())*PI/180; + long aNbSteps = (long)SpinBox_NbSteps->value(); + double aTolerance = SpinBox_Tolerance->GetValue(); + + try { + SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor(); + QApplication::setOverrideCursor(Qt::waitCursor); + aMeshEditor->RotationSweep(anElementsId.inout(), anAxis, anAngle, aNbSteps, aTolerance); + QApplication::restoreOverrideCursor(); + } catch (...) { } + + mySelectionMgr->clearSelected(); + SMESH::UpdateView(); + Init(false); + ConstructorsClicked(GetConstructorId()); + } } //================================================================================= @@ -472,73 +478,87 @@ void SMESHGUI_RevolutionDlg::ClickOnApply() //================================================================================= void SMESHGUI_RevolutionDlg::ClickOnOk() { - ClickOnApply() ; - ClickOnCancel() ; + ClickOnApply(); + ClickOnCancel(); } - //================================================================================= // function : ClickOnCancel() // purpose : //================================================================================= void SMESHGUI_RevolutionDlg::ClickOnCancel() { - mySelection->ClearFilters(); - mySelection->ClearIObjects(); + disconnect(mySelectionMgr, 0, this, 0); + mySelectionMgr->clearFilters(); + mySelectionMgr->clearSelected(); SMESH::SetPointRepresentation(false); - QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); - disconnect( mySelection, 0, this, 0 ); - mySMESHGUI->ResetState() ; - reject() ; + myViewWindow->SetSelectionMode(ActorSelection); + mySMESHGUI->ResetState(); + reject(); } //======================================================================= -//function : onTextChange -//purpose : +// function : onTextChange() +// purpose : //======================================================================= - -void SMESHGUI_RevolutionDlg::onTextChange(const QString& theNewText) +void SMESHGUI_RevolutionDlg::onTextChange (const QString& theNewText) { QLineEdit* send = (QLineEdit*)sender(); - if ( myBusy ) return; + if (myBusy) return; myBusy = true; - + if (send == LineEditElements) myNbOkElements = 0; - - buttonOk->setEnabled( false ); - buttonApply->setEnabled( false ); - + + buttonOk->setEnabled(false); + buttonApply->setEnabled(false); + // hilight entered elements SMDS_Mesh* aMesh = 0; - if ( myActor ) + if (myActor) aMesh = myActor->GetObject()->GetMesh(); - - if ( aMesh ) { - mySelection->ClearIObjects(); - mySelection->AddIObject( myActor->getIO() ); - - QStringList aListId = QStringList::split( " ", theNewText, false); - + + if (aMesh) { if (send == LineEditElements) { - for ( int i = 0; i < aListId.count(); i++ ) { - const SMDS_MeshElement * e = aMesh->FindElement( aListId[ i ].toInt() ); - if ( e ) { - if ( !mySelection->IsIndexSelected( myActor->getIO(), e->GetID() )) - mySelection->AddOrRemoveIndex (myActor->getIO(), e->GetID(), true); + //mySelectionMgr->clearSelected(); + //mySelectionMgr->AddIObject(myActor->getIO()); + SALOME_ListIO aList; + aList.Append(myActor->getIO()); + mySelectionMgr->setSelectedObjects(aList, false); + + TColStd_IndexedMapOfInteger selectedIndices; + TColStd_MapOfInteger newIndices; + mySelector->GetIndex(myActor->getIO(), selectedIndices); + + QStringList aListId = QStringList::split(" ", theNewText, false); + for (int i = 0; i < aListId.count(); i++) { + const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt()); + if (e) { + //if (!mySelectionMgr->IsIndexSelected(myActor->getIO(), e->GetID())) { + if (selectedIndices.Add(e->GetID())) { + //mySelectionMgr->AddOrRemoveIndex (myActor->getIO(), e->GetID(), true); + newIndices.Add(e->GetID()); + } myNbOkElements++; } } + + if (newIndices.Extent() > 0) + { + mySelector->AddOrRemoveIndex(myActor->getIO(), newIndices, true); + myViewWindow->highlight( myActor->getIO(), true, true ); + } + myElementsId = theNewText; } } - - if ( myNbOkElements && IsAxisOk() ) { - buttonOk->setEnabled( true ); - buttonApply->setEnabled( true ); + + if (myNbOkElements && IsAxisOk()) { + buttonOk->setEnabled(true); + buttonApply->setEnabled(true); } - + myBusy = false; } @@ -548,175 +568,159 @@ void SMESHGUI_RevolutionDlg::onTextChange(const QString& theNewText) //================================================================================= void SMESHGUI_RevolutionDlg::SelectionIntoArgument() { - if ( myBusy ) return; - + if (myBusy) return; + // clear myActor = 0; QString aString = ""; myBusy = true; - if (myEditCurrentArgument == (QWidget*)LineEditElements) - { - LineEditElements->setText( aString ); - myNbOkElements = 0; - buttonOk->setEnabled( false ); - buttonApply->setEnabled( false ); - } + if (myEditCurrentArgument == (QWidget*)LineEditElements) { + LineEditElements->setText(aString); + myNbOkElements = 0; + buttonOk->setEnabled(false); + buttonApply->setEnabled(false); + } myBusy = false; - - if ( !GroupButtons->isEnabled() ) // inactive + + if (!GroupButtons->isEnabled()) // inactive return; - + // get selected mesh - int nbSel = mySelection->IObjectCount(); - if(nbSel != 1) + const SALOME_ListIO& aList = mySelector->StoredIObjects(); + + int nbSel = aList.Extent(); + if (nbSel != 1) return; - - Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject(); + + Handle(SALOME_InteractiveObject) IO = aList.First(); myMesh = SMESH::GetMeshByIO(IO); - if(myMesh->_is_nil()) + if (myMesh->_is_nil()) return; + myActor = SMESH::FindActorByObject(myMesh); + if (!myActor) + myActor = SMESH::FindActorByEntry(IO->getEntry()); if (!myActor) return; - + int aNbUnits = 0; - if (myEditCurrentArgument == (QWidget*)LineEditElements) - { - myElementsId = ""; - - if (CheckBoxMesh->isChecked()) - { - SMESH::GetNameOfSelectedIObjects(mySelection, aString); - - int aConstructorId = GetConstructorId(); + if (myEditCurrentArgument == (QWidget*)LineEditElements) { + myElementsId = ""; - if(!SMESH::IObjectToInterface(IO)->_is_nil()) //MESH - { - // get IDs from mesh - SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh(); - if (!aSMDSMesh) - return; - - if (aConstructorId == 0) - { - SMDS_EdgeIteratorPtr anIter = aSMDSMesh->edgesIterator(); - - while ( anIter->more() ) - { - const SMDS_MeshEdge * edge = anIter->next(); - if ( edge ) { - myElementsId += QString(" %1").arg(edge->GetID()); - aNbUnits++; - } - } - } - else if (aConstructorId == 1) - { - SMDS_FaceIteratorPtr anIter = aSMDSMesh->facesIterator(); - while ( anIter->more() ) - { - const SMDS_MeshFace * face = anIter->next(); - if ( face ) { - myElementsId += QString(" %1").arg(face->GetID()); - aNbUnits++; - } - } - } - } - else if (!SMESH::IObjectToInterface(IO)->_is_nil()) //SUBMESH - { - // get submesh - SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface(IO) ; - - // get IDs from submesh - SMESH::long_array_var anElementsIds = new SMESH::long_array; - if (aConstructorId == 0) - anElementsIds = aSubMesh->GetElementsByType(SMESH::EDGE); - else if (aConstructorId == 1) - anElementsIds = aSubMesh->GetElementsByType(SMESH::FACE); - - for ( int i = 0; i < anElementsIds->length(); i++ ) - myElementsId += QString(" %1").arg(anElementsIds[i]); - aNbUnits = anElementsIds->length(); - } - else // GROUP - { - // get smesh group - SMESH::SMESH_GroupBase_var aGroup = - SMESH::IObjectToInterface(IO); - if (aGroup->_is_nil()) - return; - - if ( (aConstructorId == 0 && aGroup->GetType()!= SMESH::EDGE) || - (aConstructorId == 1 && aGroup->GetType()!= SMESH::FACE) ) - return; - - // get IDs from smesh group - SMESH::long_array_var anElementsIds = new SMESH::long_array; - anElementsIds = aGroup->GetListOfID(); - for ( int i = 0; i < anElementsIds->length(); i++ ) - myElementsId += QString(" %1").arg(anElementsIds[i]); - aNbUnits = anElementsIds->length(); - } - } - else - { - aNbUnits = SMESH::GetNameOfSelectedElements(mySelection, aString) ; - myElementsId = aString; - } - - if(aNbUnits < 1) - return ; - - myNbOkElements = true; + if (CheckBoxMesh->isChecked()) { + int aConstructorId = GetConstructorId(); + + SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString); + + if (!SMESH::IObjectToInterface(IO)->_is_nil()) { //MESH + // get IDs from mesh + SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh(); + if (!aSMDSMesh) + return; + + if (aConstructorId == 0) { + SMDS_EdgeIteratorPtr anIter = aSMDSMesh->edgesIterator(); + + while (anIter->more()) { + const SMDS_MeshEdge * edge = anIter->next(); + if (edge) { + myElementsId += QString(" %1").arg(edge->GetID()); + aNbUnits++; + } + } + } else if (aConstructorId == 1) { + SMDS_FaceIteratorPtr anIter = aSMDSMesh->facesIterator(); + while (anIter->more()) { + const SMDS_MeshFace * face = anIter->next(); + if (face) { + myElementsId += QString(" %1").arg(face->GetID()); + aNbUnits++; + } + } + } + } else if (!SMESH::IObjectToInterface(IO)->_is_nil()) { //SUBMESH + // get submesh + SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface(IO); + + // get IDs from submesh + SMESH::long_array_var anElementsIds = new SMESH::long_array; + if (aConstructorId == 0) + anElementsIds = aSubMesh->GetElementsByType(SMESH::EDGE); + else if (aConstructorId == 1) + anElementsIds = aSubMesh->GetElementsByType(SMESH::FACE); + + for (int i = 0; i < anElementsIds->length(); i++) + myElementsId += QString(" %1").arg(anElementsIds[i]); + aNbUnits = anElementsIds->length(); + } else { // GROUP + // get smesh group + SMESH::SMESH_GroupBase_var aGroup = + SMESH::IObjectToInterface(IO); + if (aGroup->_is_nil()) + return; + + if ((aConstructorId == 0 && aGroup->GetType()!= SMESH::EDGE) || + (aConstructorId == 1 && aGroup->GetType()!= SMESH::FACE)) + return; + + // get IDs from smesh group + SMESH::long_array_var anElementsIds = new SMESH::long_array; + anElementsIds = aGroup->GetListOfID(); + for (int i = 0; i < anElementsIds->length(); i++) { + myElementsId += QString(" %1").arg(anElementsIds[i]); + } + aNbUnits = anElementsIds->length(); + } + } else { + aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, myActor->getIO(), aString); + myElementsId = aString; } - else - { - aNbUnits = SMESH::GetNameOfSelectedNodes(mySelection, aString); - if(aNbUnits != 1) - return; - - SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh(); - if (!aMesh) - return; - const SMDS_MeshNode * n = aMesh->FindNode( aString.toInt() ); - if ( !n ) - return; - - double x = n->X(); - double y = n->Y(); - double z = n->Z(); + if (aNbUnits < 1) + return; - if (myEditCurrentArgument == (QWidget*)SpinBox_X) - { - SpinBox_X->SetValue(x); - SpinBox_Y->SetValue(y); - SpinBox_Z->SetValue(z); - } - else if (myEditCurrentArgument == (QWidget*)SpinBox_DX) - { - SpinBox_DX->SetValue(x - SpinBox_X->GetValue()); - SpinBox_DY->SetValue(y - SpinBox_Y->GetValue()); - SpinBox_DZ->SetValue(z - SpinBox_Z->GetValue()); - } + myNbOkElements = true; + } else { + aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, myActor->getIO(), aString); + if (aNbUnits != 1) + return; + + SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh(); + if (!aMesh) + return; + + const SMDS_MeshNode * n = aMesh->FindNode(aString.toInt()); + if (!n) + return; + + double x = n->X(); + double y = n->Y(); + double z = n->Z(); + + if (myEditCurrentArgument == (QWidget*)SpinBox_X) { + SpinBox_X->SetValue(x); + SpinBox_Y->SetValue(y); + SpinBox_Z->SetValue(z); + } else if (myEditCurrentArgument == (QWidget*)SpinBox_DX) { + SpinBox_DX->SetValue(x - SpinBox_X->GetValue()); + SpinBox_DY->SetValue(y - SpinBox_Y->GetValue()); + SpinBox_DZ->SetValue(z - SpinBox_Z->GetValue()); } - + } + myBusy = true; if (myEditCurrentArgument == (QWidget*)LineEditElements) - LineEditElements->setText( aString ); + LineEditElements->setText(aString); myBusy = false; - - // OK - if(myNbOkElements && IsAxisOk()) - { - buttonOk->setEnabled( true ); - buttonApply->setEnabled( true ); - } -} + // OK + if (myNbOkElements && IsAxisOk()) { + buttonOk->setEnabled(true); + buttonApply->setEnabled(true); + } +} //================================================================================= // function : SetEditCurrentArgument() @@ -725,44 +729,38 @@ void SMESHGUI_RevolutionDlg::SelectionIntoArgument() void SMESHGUI_RevolutionDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); - - disconnect( mySelection, 0, this, 0 ); - mySelection->ClearIObjects(); - mySelection->ClearFilters(); - - if(send == SelectElementsButton) { + + disconnect(mySelectionMgr, 0, this, 0); + mySelectionMgr->clearSelected(); + mySelectionMgr->clearFilters(); + + if (send == SelectElementsButton) { myEditCurrentArgument = (QWidget*)LineEditElements; SMESH::SetPointRepresentation(false); - if (CheckBoxMesh->isChecked()) - { - QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); - mySelection->AddFilter(myMeshOrSubMeshOrGroupFilter); - } - else - { - int aConstructorId = GetConstructorId(); - if (aConstructorId == 0) - QAD_Application::getDesktop()->SetSelectionMode( EdgeSelection, true ); - else if (aConstructorId == 1) - QAD_Application::getDesktop()->SetSelectionMode( FaceSelection, true ); - } + if (CheckBoxMesh->isChecked()) { + myViewWindow->SetSelectionMode(ActorSelection); + mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter); + } else { + int aConstructorId = GetConstructorId(); + if (aConstructorId == 0) + myViewWindow->SetSelectionMode(EdgeSelection); + else if (aConstructorId == 1) + myViewWindow->SetSelectionMode(FaceSelection); + } + } else if (send == SelectPointButton) { + myEditCurrentArgument = (QWidget*)SpinBox_X; + SMESH::SetPointRepresentation(true); + myViewWindow->SetSelectionMode(NodeSelection); + } else if (send == SelectVectorButton) { + myEditCurrentArgument = (QWidget*)SpinBox_DX; + SMESH::SetPointRepresentation(true); + myViewWindow->SetSelectionMode(NodeSelection); + } else { } - else if (send == SelectPointButton) - { - myEditCurrentArgument = (QWidget*)SpinBox_X; - SMESH::SetPointRepresentation(true); - QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true ); - } - else if (send == SelectVectorButton) - { - myEditCurrentArgument = (QWidget*)SpinBox_DX; - SMESH::SetPointRepresentation(true); - QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true ); - } - + myEditCurrentArgument->setFocus(); - connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); - SelectionIntoArgument() ; + connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + SelectionIntoArgument(); } //================================================================================= @@ -771,16 +769,15 @@ void SMESHGUI_RevolutionDlg::SetEditCurrentArgument() //================================================================================= void SMESHGUI_RevolutionDlg::DeactivateActiveDialog() { - if ( GroupConstructors->isEnabled() ) { - GroupConstructors->setEnabled(false) ; - GroupArguments->setEnabled(false) ; - GroupButtons->setEnabled(false) ; - mySMESHGUI->ResetState() ; - mySMESHGUI->SetActiveDialogBox(0) ; + if (GroupConstructors->isEnabled()) { + GroupConstructors->setEnabled(false); + GroupArguments->setEnabled(false); + GroupButtons->setEnabled(false); + mySMESHGUI->ResetState(); + mySMESHGUI->SetActiveDialogBox(0); } } - //================================================================================= // function : ActivateThisDialog() // purpose : @@ -788,134 +785,117 @@ void SMESHGUI_RevolutionDlg::DeactivateActiveDialog() void SMESHGUI_RevolutionDlg::ActivateThisDialog() { /* Emit a signal to deactivate the active dialog */ - mySMESHGUI->EmitSignalDeactivateDialog() ; - GroupConstructors->setEnabled(true) ; - GroupArguments->setEnabled(true) ; - GroupButtons->setEnabled(true) ; - - mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; + mySMESHGUI->EmitSignalDeactivateDialog(); + GroupConstructors->setEnabled(true); + GroupArguments->setEnabled(true); + GroupButtons->setEnabled(true); + + mySMESHGUI->SetActiveDialogBox((QDialog*)this); ConstructorsClicked(GetConstructorId()); SelectionIntoArgument(); } - //================================================================================= // function : enterEvent() // purpose : //================================================================================= -void SMESHGUI_RevolutionDlg::enterEvent(QEvent* e) +void SMESHGUI_RevolutionDlg::enterEvent (QEvent*) { - if ( GroupConstructors->isEnabled() ) - return ; - ActivateThisDialog() ; + if (!GroupConstructors->isEnabled()) + ActivateThisDialog(); } - //================================================================================= // function : closeEvent() // purpose : //================================================================================= -void SMESHGUI_RevolutionDlg::closeEvent( QCloseEvent* e ) +void SMESHGUI_RevolutionDlg::closeEvent (QCloseEvent*) { /* same than click on cancel button */ - this->ClickOnCancel() ; - return ; + this->ClickOnCancel(); } - //======================================================================= -//function : hideEvent -//purpose : caused by ESC key +// function : hideEvent() +// purpose : caused by ESC key //======================================================================= - -void SMESHGUI_RevolutionDlg::hideEvent ( QHideEvent * e ) +void SMESHGUI_RevolutionDlg::hideEvent (QHideEvent*) { - if ( !isMinimized() ) + if (!isMinimized()) ClickOnCancel(); } - -//================================================================================= -// function : GetConstructorId() -// purpose : -//================================================================================= -int SMESHGUI_RevolutionDlg::GetConstructorId() -{ - if ( GroupConstructors != NULL && GroupConstructors->selected() != NULL ) - return GroupConstructors->id( GroupConstructors->selected() ); - return -1; -} - - -//================================================================================= -// function : IsAxisOk() -// purpose : -//================================================================================= -bool SMESHGUI_RevolutionDlg::IsAxisOk() -{ - return (SpinBox_DX->GetValue() != 0 || - SpinBox_DY->GetValue() != 0 || - SpinBox_DZ->GetValue() != 0); -} - - -//================================================================================= -// function : onVectorChanged() -// purpose : -//================================================================================= -void SMESHGUI_RevolutionDlg::onVectorChanged() -{ - if (IsAxisOk()) - { - buttonOk->setEnabled( true ); - buttonApply->setEnabled( true ); - } - else - { - buttonOk->setEnabled( false ); - buttonApply->setEnabled( false ); - } -} - - //======================================================================= //function : onSelectMesh //purpose : //======================================================================= -void SMESHGUI_RevolutionDlg::onSelectMesh ( bool toSelectMesh ) +void SMESHGUI_RevolutionDlg::onSelectMesh (bool toSelectMesh) { if (toSelectMesh) - TextLabelElements->setText( tr( "SMESH_NAME" ) ); + TextLabelElements->setText(tr("SMESH_NAME")); else - TextLabelElements->setText( tr( "SMESH_ID_ELEMENTS" ) ); - - if (myEditCurrentArgument != LineEditElements) - { - LineEditElements->clear(); - return; - } - - mySelection->ClearFilters() ; + TextLabelElements->setText(tr("SMESH_ID_ELEMENTS")); + + if (myEditCurrentArgument != LineEditElements) { + LineEditElements->clear(); + return; + } + + mySelectionMgr->clearFilters(); SMESH::SetPointRepresentation(false); - - if (toSelectMesh) - { - QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); - mySelection->AddFilter(myMeshOrSubMeshOrGroupFilter); - LineEditElements->setReadOnly(true); - } - else - { - int aConstructorId = GetConstructorId(); - if (aConstructorId == 0) - QAD_Application::getDesktop()->SetSelectionMode( EdgeSelection, true ); - else if (aConstructorId == 0) - QAD_Application::getDesktop()->SetSelectionMode( FaceSelection, true ); - - LineEditElements->setReadOnly(false); - onTextChange(LineEditElements->text()); - } - + + if (toSelectMesh) { + myViewWindow->SetSelectionMode(ActorSelection); + mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter); + LineEditElements->setReadOnly(true); + } else { + int aConstructorId = GetConstructorId(); + if (aConstructorId == 0) + myViewWindow->SetSelectionMode(EdgeSelection); + else if (aConstructorId == 0) + myViewWindow->SetSelectionMode(FaceSelection); + + LineEditElements->setReadOnly(false); + onTextChange(LineEditElements->text()); + } + SelectionIntoArgument(); } + +//================================================================================= +// function : GetConstructorId() +// purpose : +//================================================================================= +int SMESHGUI_RevolutionDlg::GetConstructorId() +{ + if (GroupConstructors != NULL && GroupConstructors->selected() != NULL) + return GroupConstructors->id(GroupConstructors->selected()); + return -1; +} + +//================================================================================= +// function : IsAxisOk() +// purpose : +//================================================================================= +bool SMESHGUI_RevolutionDlg::IsAxisOk() +{ + return (SpinBox_DX->GetValue() != 0 || + SpinBox_DY->GetValue() != 0 || + SpinBox_DZ->GetValue() != 0); +} + +//================================================================================= +// function : onVectorChanged() +// purpose : +//================================================================================= +void SMESHGUI_RevolutionDlg::onVectorChanged() +{ + if (IsAxisOk()) { + buttonOk->setEnabled(true); + buttonApply->setEnabled(true); + } else { + buttonOk->setEnabled(false); + buttonApply->setEnabled(false); + } +} diff --git a/src/SMESHGUI/SMESHGUI_RevolutionDlg.h b/src/SMESHGUI/SMESHGUI_RevolutionDlg.h index 6b55513e3..5e35ea9da 100644 --- a/src/SMESHGUI/SMESHGUI_RevolutionDlg.h +++ b/src/SMESHGUI/SMESHGUI_RevolutionDlg.h @@ -29,8 +29,10 @@ #ifndef DIALOGBOX_REVOLUTION_H #define DIALOGBOX_REVOLUTION_H -#include "SALOME_Selection.h" +#include "SalomeApp_SelectionMgr.h" + #include "SMESH_LogicalFilter.hxx" + // QT Includes #include @@ -47,6 +49,9 @@ class SMESHGUI_SpinBox; class SMESHGUI; class SMESH_Actor; class SMESHGUI_SpinBox; +class SVTK_ViewWindow; +class SVTK_Selector; + // IDL Headers #include @@ -62,28 +67,32 @@ class SMESHGUI_RevolutionDlg : public QDialog Q_OBJECT public: - SMESHGUI_RevolutionDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); + SMESHGUI_RevolutionDlg (SMESHGUI*, + const char* name = 0, + bool modal = FALSE, + WFlags fl = 0); ~SMESHGUI_RevolutionDlg(); private: - - void Init( bool ResetControls = true ) ; - void closeEvent( QCloseEvent* e ) ; - void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */ - void hideEvent ( QHideEvent * ); /* ESC key */ + void Init (bool ResetControls = true); + void closeEvent (QCloseEvent*); + void enterEvent (QEvent*); /* mouse enter the QWidget */ + void hideEvent (QHideEvent*); /* ESC key */ int GetConstructorId(); bool IsAxisOk(); - SMESHGUI* mySMESHGUI ; /* Current SMESHGUI object */ - SALOME_Selection* mySelection ; /* User shape selection */ - int myNbOkElements ; /* to check when elements are defined */ + SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */ + SalomeApp_SelectionMgr* mySelectionMgr; /* User shape selection */ + int myNbOkElements; /* to check when elements are defined */ QString myElementsId; - QWidget* myEditCurrentArgument; /* Current argument */ + QWidget* myEditCurrentArgument; /* Current argument */ + SVTK_ViewWindow* myViewWindow; + SVTK_Selector* mySelector; bool myBusy; SMESH::SMESH_Mesh_var myMesh; SMESH_Actor* myActor; - Handle(SMESH_LogicalFilter) myMeshOrSubMeshOrGroupFilter; + SMESH_LogicalFilter* myMeshOrSubMeshOrGroupFilter; QButtonGroup* GroupConstructors; QRadioButton* RadioButton1; @@ -98,7 +107,7 @@ private: QPushButton* SelectElementsButton; QLineEdit* LineEditElements; QCheckBox* CheckBoxMesh; - + QLabel* TextLabelPoint; QPushButton* SelectPointButton; QLabel* TextLabelX; @@ -115,7 +124,7 @@ private: SMESHGUI_SpinBox* SpinBox_DY; QLabel* TextLabelDZ; SMESHGUI_SpinBox* SpinBox_DZ; - + QLabel* TextLabelAngle; SMESHGUI_SpinBox* SpinBox_Angle; QLabel* TextLabelNbSteps; @@ -123,19 +132,19 @@ private: QLabel* TextLabelTolerance; SMESHGUI_SpinBox* SpinBox_Tolerance; - private slots: +private slots: - void ConstructorsClicked(int constructorId); + void ConstructorsClicked (int constructorId); void ClickOnOk(); void ClickOnCancel(); void ClickOnApply(); - void SetEditCurrentArgument() ; - void SelectionIntoArgument() ; - void DeactivateActiveDialog() ; - void ActivateThisDialog() ; - void onTextChange(const QString&); + void SetEditCurrentArgument(); + void SelectionIntoArgument(); + void DeactivateActiveDialog(); + void ActivateThisDialog(); + void onTextChange (const QString&); + void onSelectMesh (bool toSelectMesh); void onVectorChanged(); - void onSelectMesh(bool toSelectMesh); protected: QGridLayout* SMESHGUI_RevolutionDlgLayout; diff --git a/src/SMESHGUI/SMESHGUI_RotationDlg.cxx b/src/SMESHGUI/SMESHGUI_RotationDlg.cxx index fd7253b76..6d603a53a 100644 --- a/src/SMESHGUI/SMESHGUI_RotationDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_RotationDlg.cxx @@ -1,30 +1,30 @@ // SMESH SMESHGUI : GUI for SMESH component // // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org // // // // File : SMESHGUI_RotationDlg.cxx // Author : Michael ZORIN // Module : SMESH -// $Header: +// $Header: #include "SMESHGUI_RotationDlg.h" @@ -34,15 +34,27 @@ #include "SMESHGUI_VTKUtils.h" #include "SMESHGUI_MeshUtils.h" #include "SMESHGUI_IdValidator.h" + #include "SMESH_Actor.h" #include "SMESH_TypeFilter.hxx" +#include "SMESH_LogicalFilter.hxx" #include "SMDS_Mesh.hxx" -#include "QAD_Application.h" -#include "QAD_Desktop.h" -#include "QAD_MessageBox.h" +#include "SUIT_Desktop.h" +#include "SUIT_Session.h" + +#include "SVTK_ViewModel.h" +#include "SVTK_ViewWindow.h" +#include "SVTK_Selector.h" +#include "SVTK_Selection.h" +#include "SALOME_ListIO.hxx" + #include "utilities.h" +// OCCT Includes +#include +#include + // QT Includes #include #include @@ -63,256 +75,262 @@ using namespace std; //================================================================================= // class : SMESHGUI_RotationDlg() -// purpose : +// purpose : //================================================================================= -SMESHGUI_RotationDlg::SMESHGUI_RotationDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, - bool modal, WFlags fl ) - : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | - Qt::WDestructiveClose) +SMESHGUI_RotationDlg::SMESHGUI_RotationDlg( SMESHGUI* theModule, const char* name, + bool modal, WFlags fl) + : QDialog( SMESH::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder | + WStyle_Title | WStyle_SysMenu | Qt::WDestructiveClose), + mySMESHGUI( theModule ), + mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ), + myViewWindow( SMESH::GetViewWindow( theModule ) ), + mySelector( myViewWindow->GetSelector() ) { - QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_DLG_ROTATION"))); - QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SELECT"))); + QPixmap image0 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_DLG_ROTATION"))); + QPixmap image1 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT"))); - if ( !name ) - setName( "SMESHGUI_RotationDlg" ); - resize( 303, 185 ); - setCaption( tr( "SMESH_ROTATION_TITLE" ) ); - setSizeGripEnabled( TRUE ); - SMESHGUI_RotationDlgLayout = new QGridLayout( this ); - SMESHGUI_RotationDlgLayout->setSpacing( 6 ); - SMESHGUI_RotationDlgLayout->setMargin( 11 ); + if (!name) + setName("SMESHGUI_RotationDlg"); + resize(303, 185); + setCaption(tr("SMESH_ROTATION_TITLE")); + setSizeGripEnabled(TRUE); + SMESHGUI_RotationDlgLayout = new QGridLayout(this); + SMESHGUI_RotationDlgLayout->setSpacing(6); + SMESHGUI_RotationDlgLayout->setMargin(11); /***************************************************************/ - GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); - GroupConstructors->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)0, 0, 0, GroupConstructors->sizePolicy().hasHeightForWidth() ) ); - GroupConstructors->setTitle( tr( "SMESH_ROTATION" ) ); - GroupConstructors->setExclusive( TRUE ); - GroupConstructors->setColumnLayout(0, Qt::Vertical ); - GroupConstructors->layout()->setSpacing( 0 ); - GroupConstructors->layout()->setMargin( 0 ); - GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() ); - GroupConstructorsLayout->setAlignment( Qt::AlignTop ); - GroupConstructorsLayout->setSpacing( 6 ); - GroupConstructorsLayout->setMargin( 11 ); - RadioButton1= new QRadioButton( GroupConstructors, "RadioButton1" ); - RadioButton1->setText( tr( "" ) ); - RadioButton1->setPixmap( image0 ); - RadioButton1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, RadioButton1->sizePolicy().hasHeightForWidth() ) ); - RadioButton1->setMinimumSize( QSize( 50, 0 ) ); - GroupConstructorsLayout->addWidget( RadioButton1, 0, 0 ); - QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); - GroupConstructorsLayout->addItem( spacer, 0, 1 ); - SMESHGUI_RotationDlgLayout->addWidget( GroupConstructors, 0, 0 ); - - /***************************************************************/ - GroupButtons = new QGroupBox( this, "GroupButtons" ); - GroupButtons->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, GroupButtons->sizePolicy().hasHeightForWidth() ) ); - GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); - GroupButtons->setTitle( tr( "" ) ); - GroupButtons->setColumnLayout(0, Qt::Vertical ); - GroupButtons->layout()->setSpacing( 0 ); - GroupButtons->layout()->setMargin( 0 ); - GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); - GroupButtonsLayout->setAlignment( Qt::AlignTop ); - GroupButtonsLayout->setSpacing( 6 ); - GroupButtonsLayout->setMargin( 11 ); - buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); - buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) ); - buttonCancel->setAutoDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonCancel, 0, 3 ); - buttonApply = new QPushButton( GroupButtons, "buttonApply" ); - buttonApply->setText( tr( "SMESH_BUT_APPLY" ) ); - buttonApply->setAutoDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); - QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); - GroupButtonsLayout->addItem( spacer_9, 0, 2 ); - buttonOk = new QPushButton( GroupButtons, "buttonOk" ); - buttonOk->setText( tr( "SMESH_BUT_OK" ) ); - buttonOk->setAutoDefault( TRUE ); - buttonOk->setDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); - SMESHGUI_RotationDlgLayout->addWidget( GroupButtons, 2, 0 ); + GroupConstructors = new QButtonGroup(this, "GroupConstructors"); + GroupConstructors->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)5, + (QSizePolicy::SizeType)0, 0, 0, + GroupConstructors->sizePolicy().hasHeightForWidth())); + GroupConstructors->setTitle(tr("SMESH_ROTATION")); + GroupConstructors->setExclusive(TRUE); + GroupConstructors->setColumnLayout(0, Qt::Vertical); + GroupConstructors->layout()->setSpacing(0); + GroupConstructors->layout()->setMargin(0); + GroupConstructorsLayout = new QGridLayout(GroupConstructors->layout()); + GroupConstructorsLayout->setAlignment(Qt::AlignTop); + GroupConstructorsLayout->setSpacing(6); + GroupConstructorsLayout->setMargin(11); + RadioButton1= new QRadioButton(GroupConstructors, "RadioButton1"); + RadioButton1->setText(tr("" )); + RadioButton1->setPixmap(image0); + RadioButton1->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)1, + (QSizePolicy::SizeType)0, + RadioButton1->sizePolicy().hasHeightForWidth())); + RadioButton1->setMinimumSize(QSize(50, 0)); + GroupConstructorsLayout->addWidget(RadioButton1, 0, 0); + QSpacerItem* spacer = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); + GroupConstructorsLayout->addItem(spacer, 0, 1); + SMESHGUI_RotationDlgLayout->addWidget(GroupConstructors, 0, 0); /***************************************************************/ - GroupArguments = new QGroupBox( this, "GroupArguments" ); - GroupArguments->setTitle( tr( "SMESH_ARGUMENTS" ) ); - GroupArguments->setColumnLayout(0, Qt::Vertical ); - GroupArguments->layout()->setSpacing( 0 ); - GroupArguments->layout()->setMargin( 0 ); - GroupArgumentsLayout = new QGridLayout( GroupArguments->layout() ); - GroupArgumentsLayout->setAlignment( Qt::AlignTop ); - GroupArgumentsLayout->setSpacing( 6 ); - GroupArgumentsLayout->setMargin( 11 ); + GroupButtons = new QGroupBox(this, "GroupButtons"); + GroupButtons->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)7, + (QSizePolicy::SizeType)0, 0, 0, + GroupButtons->sizePolicy().hasHeightForWidth())); + GroupButtons->setGeometry(QRect(10, 10, 281, 48)); + GroupButtons->setTitle(tr("" )); + GroupButtons->setColumnLayout(0, Qt::Vertical); + GroupButtons->layout()->setSpacing(0); + GroupButtons->layout()->setMargin(0); + GroupButtonsLayout = new QGridLayout(GroupButtons->layout()); + GroupButtonsLayout->setAlignment(Qt::AlignTop); + GroupButtonsLayout->setSpacing(6); + GroupButtonsLayout->setMargin(11); + buttonCancel = new QPushButton(GroupButtons, "buttonCancel"); + buttonCancel->setText(tr("SMESH_BUT_CLOSE")); + buttonCancel->setAutoDefault(TRUE); + GroupButtonsLayout->addWidget(buttonCancel, 0, 3); + buttonApply = new QPushButton(GroupButtons, "buttonApply"); + buttonApply->setText(tr("SMESH_BUT_APPLY")); + buttonApply->setAutoDefault(TRUE); + GroupButtonsLayout->addWidget(buttonApply, 0, 1); + QSpacerItem* spacer_9 = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); + GroupButtonsLayout->addItem(spacer_9, 0, 2); + buttonOk = new QPushButton(GroupButtons, "buttonOk"); + buttonOk->setText(tr("SMESH_BUT_OK")); + buttonOk->setAutoDefault(TRUE); + buttonOk->setDefault(TRUE); + GroupButtonsLayout->addWidget(buttonOk, 0, 0); + SMESHGUI_RotationDlgLayout->addWidget(GroupButtons, 2, 0); + + /***************************************************************/ + GroupArguments = new QGroupBox(this, "GroupArguments"); + GroupArguments->setTitle(tr("SMESH_ARGUMENTS")); + GroupArguments->setColumnLayout(0, Qt::Vertical); + GroupArguments->layout()->setSpacing(0); + GroupArguments->layout()->setMargin(0); + GroupArgumentsLayout = new QGridLayout(GroupArguments->layout()); + GroupArgumentsLayout->setAlignment(Qt::AlignTop); + GroupArgumentsLayout->setSpacing(6); + GroupArgumentsLayout->setMargin(11); // Controls for elements selection - TextLabelElements = new QLabel( GroupArguments, "TextLabelElements" ); - TextLabelElements->setText( tr( "SMESH_ID_ELEMENTS" ) ); + TextLabelElements = new QLabel(GroupArguments, "TextLabelElements"); + TextLabelElements->setText(tr("SMESH_ID_ELEMENTS" )); TextLabelElements->setFixedWidth(74); - GroupArgumentsLayout->addWidget( TextLabelElements, 0, 0 ); + GroupArgumentsLayout->addWidget(TextLabelElements, 0, 0); - SelectElementsButton = new QPushButton( GroupArguments, "SelectElementsButton" ); - SelectElementsButton->setText( tr( "" ) ); - SelectElementsButton->setPixmap( image1 ); - SelectElementsButton->setToggleButton( FALSE ); - GroupArgumentsLayout->addWidget( SelectElementsButton, 0, 1 ); + SelectElementsButton = new QPushButton(GroupArguments, "SelectElementsButton"); + SelectElementsButton->setText(tr("" )); + SelectElementsButton->setPixmap(image1); + SelectElementsButton->setToggleButton(FALSE); + GroupArgumentsLayout->addWidget(SelectElementsButton, 0, 1); - LineEditElements = new QLineEdit( GroupArguments, "LineEditElements" ); - LineEditElements->setValidator( new SMESHGUI_IdValidator( this, "validator" )); - GroupArgumentsLayout->addWidget( LineEditElements, 0, 2 ); + LineEditElements = new QLineEdit(GroupArguments, "LineEditElements"); + LineEditElements->setValidator(new SMESHGUI_IdValidator(this, "validator")); + GroupArgumentsLayout->addWidget(LineEditElements, 0, 2); // Control for the whole mesh selection - CheckBoxMesh = new QCheckBox( GroupArguments, "CheckBoxMesh" ); - CheckBoxMesh->setText( tr( "SMESH_SELECT_WHOLE_MESH" ) ); - GroupArgumentsLayout->addMultiCellWidget( CheckBoxMesh, 1, 1, 0, 2 ); - + CheckBoxMesh = new QCheckBox(GroupArguments, "CheckBoxMesh"); + CheckBoxMesh->setText(tr("SMESH_SELECT_WHOLE_MESH" )); + GroupArgumentsLayout->addMultiCellWidget(CheckBoxMesh, 1, 1, 0, 2); + // Controls for axis defining - GroupAxis = new QGroupBox( GroupArguments, "GroupAxis" ); - GroupAxis->setTitle( tr( "SMESH_AXIS" ) ); - GroupAxis->setColumnLayout(0, Qt::Vertical ); - GroupAxis->layout()->setSpacing( 0 ); - GroupAxis->layout()->setMargin( 0 ); - QGridLayout* GroupAxisLayout = new QGridLayout( GroupAxis->layout() ); - GroupAxisLayout->setAlignment( Qt::AlignTop ); - GroupAxisLayout->setSpacing( 6 ); - GroupAxisLayout->setMargin( 11 ); - - TextLabelPoint = new QLabel( GroupAxis, "TextLabelPoint" ); - TextLabelPoint->setText( tr( "SMESH_POINT" ) ); - GroupAxisLayout->addWidget( TextLabelPoint, 0, 0 ); + GroupAxis = new QGroupBox(GroupArguments, "GroupAxis"); + GroupAxis->setTitle(tr("SMESH_AXIS")); + GroupAxis->setColumnLayout(0, Qt::Vertical); + GroupAxis->layout()->setSpacing(0); + GroupAxis->layout()->setMargin(0); + QGridLayout* GroupAxisLayout = new QGridLayout(GroupAxis->layout()); + GroupAxisLayout->setAlignment(Qt::AlignTop); + GroupAxisLayout->setSpacing(6); + GroupAxisLayout->setMargin(11); - SelectPointButton = new QPushButton( GroupAxis, "SelectPointButton" ); - SelectPointButton->setPixmap( image1 ); - GroupAxisLayout->addWidget( SelectPointButton, 0, 1 ); - - TextLabelX = new QLabel( GroupAxis, "TextLabelX" ); - TextLabelX->setText( tr( "SMESH_X" ) ); - GroupAxisLayout->addWidget( TextLabelX, 0, 2 ); + TextLabelPoint = new QLabel(GroupAxis, "TextLabelPoint"); + TextLabelPoint->setText(tr("SMESH_POINT")); + GroupAxisLayout->addWidget(TextLabelPoint, 0, 0); - SpinBox_X = new SMESHGUI_SpinBox( GroupAxis, "SpinBox_X"); - GroupAxisLayout->addWidget( SpinBox_X, 0, 3 ); - - TextLabelY = new QLabel( GroupAxis, "TextLabelY" ); - TextLabelY->setText( tr( "SMESH_Y" ) ); - GroupAxisLayout->addWidget( TextLabelY, 0, 4 ); + SelectPointButton = new QPushButton(GroupAxis, "SelectPointButton"); + SelectPointButton->setPixmap(image1); + GroupAxisLayout->addWidget(SelectPointButton, 0, 1); - SpinBox_Y = new SMESHGUI_SpinBox( GroupAxis, "SpinBox_Y"); - GroupAxisLayout->addWidget( SpinBox_Y, 0, 5 ); + TextLabelX = new QLabel(GroupAxis, "TextLabelX"); + TextLabelX->setText(tr("SMESH_X")); + GroupAxisLayout->addWidget(TextLabelX, 0, 2); - TextLabelZ = new QLabel( GroupAxis, "TextLabelZ" ); - TextLabelZ->setText( tr( "SMESH_Z" ) ); - GroupAxisLayout->addWidget( TextLabelZ, 0, 6 ); - - SpinBox_Z = new SMESHGUI_SpinBox( GroupAxis, "SpinBox_Z"); - GroupAxisLayout->addWidget( SpinBox_Z, 0, 7 ); + SpinBox_X = new SMESHGUI_SpinBox(GroupAxis, "SpinBox_X"); + GroupAxisLayout->addWidget(SpinBox_X, 0, 3); - TextLabelVector = new QLabel( GroupAxis, "TextLabelVector" ); - TextLabelVector->setText( tr( "SMESH_VECTOR" ) ); - GroupAxisLayout->addWidget( TextLabelVector, 1, 0 ); - - SelectVectorButton = new QPushButton( GroupAxis, "SelectVectorButton" ); - SelectVectorButton->setPixmap( image1 ); - GroupAxisLayout->addWidget( SelectVectorButton, 1, 1 ); - - TextLabelDX = new QLabel( GroupAxis, "TextLabelDX" ); - TextLabelDX->setText( tr( "SMESH_DX" ) ); - GroupAxisLayout->addWidget( TextLabelDX, 1, 2 ); + TextLabelY = new QLabel(GroupAxis, "TextLabelY"); + TextLabelY->setText(tr("SMESH_Y")); + GroupAxisLayout->addWidget(TextLabelY, 0, 4); - SpinBox_DX = new SMESHGUI_SpinBox( GroupAxis, "SpinBox_DX"); - GroupAxisLayout->addWidget( SpinBox_DX, 1, 3 ); - - TextLabelDY = new QLabel( GroupAxis, "TextLabelDY" ); - TextLabelDY->setText( tr( "SMESH_DY" ) ); - GroupAxisLayout->addWidget( TextLabelDY, 1, 4 ); + SpinBox_Y = new SMESHGUI_SpinBox(GroupAxis, "SpinBox_Y"); + GroupAxisLayout->addWidget(SpinBox_Y, 0, 5); - SpinBox_DY = new SMESHGUI_SpinBox( GroupAxis, "SpinBox_DY"); - GroupAxisLayout->addWidget( SpinBox_DY, 1, 5 ); + TextLabelZ = new QLabel(GroupAxis, "TextLabelZ"); + TextLabelZ->setText(tr("SMESH_Z")); + GroupAxisLayout->addWidget(TextLabelZ, 0, 6); - TextLabelDZ = new QLabel( GroupAxis, "TextLabelDZ" ); - TextLabelDZ->setText( tr( "SMESH_DZ" ) ); - GroupAxisLayout->addWidget( TextLabelDZ, 1, 6 ); - - SpinBox_DZ = new SMESHGUI_SpinBox( GroupAxis, "SpinBox_DZ"); - GroupAxisLayout->addWidget( SpinBox_DZ, 1, 7 ); + SpinBox_Z = new SMESHGUI_SpinBox(GroupAxis, "SpinBox_Z"); + GroupAxisLayout->addWidget(SpinBox_Z, 0, 7); + + TextLabelVector = new QLabel(GroupAxis, "TextLabelVector"); + TextLabelVector->setText(tr("SMESH_VECTOR")); + GroupAxisLayout->addWidget(TextLabelVector, 1, 0); + + SelectVectorButton = new QPushButton(GroupAxis, "SelectVectorButton"); + SelectVectorButton->setPixmap(image1); + GroupAxisLayout->addWidget(SelectVectorButton, 1, 1); + + TextLabelDX = new QLabel(GroupAxis, "TextLabelDX"); + TextLabelDX->setText(tr("SMESH_DX")); + GroupAxisLayout->addWidget(TextLabelDX, 1, 2); + + SpinBox_DX = new SMESHGUI_SpinBox(GroupAxis, "SpinBox_DX"); + GroupAxisLayout->addWidget(SpinBox_DX, 1, 3); + + TextLabelDY = new QLabel(GroupAxis, "TextLabelDY"); + TextLabelDY->setText(tr("SMESH_DY")); + GroupAxisLayout->addWidget(TextLabelDY, 1, 4); + + SpinBox_DY = new SMESHGUI_SpinBox(GroupAxis, "SpinBox_DY"); + GroupAxisLayout->addWidget(SpinBox_DY, 1, 5); + + TextLabelDZ = new QLabel(GroupAxis, "TextLabelDZ"); + TextLabelDZ->setText(tr("SMESH_DZ")); + GroupAxisLayout->addWidget(TextLabelDZ, 1, 6); + + SpinBox_DZ = new SMESHGUI_SpinBox(GroupAxis, "SpinBox_DZ"); + GroupAxisLayout->addWidget(SpinBox_DZ, 1, 7); + + GroupArgumentsLayout->addMultiCellWidget(GroupAxis, 2, 2, 0, 2); - GroupArgumentsLayout->addMultiCellWidget( GroupAxis, 2, 2, 0, 2 ); - // Controls for angle defining - TextLabelAngle = new QLabel( GroupArguments, "TextLabelAngle" ); - TextLabelAngle->setText( tr( "SMESH_ANGLE" ) ); - GroupArgumentsLayout->addMultiCellWidget( TextLabelAngle, 3, 3, 0, 1 ); + TextLabelAngle = new QLabel(GroupArguments, "TextLabelAngle"); + TextLabelAngle->setText(tr("SMESH_ANGLE")); + GroupArgumentsLayout->addMultiCellWidget(TextLabelAngle, 3, 3, 0, 1); SpinBox_Angle = new SMESHGUI_SpinBox(GroupArguments, "SpinBox_Angle"); - GroupArgumentsLayout->addWidget( SpinBox_Angle, 3, 2 ); + GroupArgumentsLayout->addWidget(SpinBox_Angle, 3, 2); // Controls for "Create a copy" option - CheckBoxCopy = new QCheckBox( GroupArguments, "CheckBoxCopy" ); - CheckBoxCopy->setText( tr( "SMESH_CREATE_COPY" ) ); - GroupArgumentsLayout->addMultiCellWidget( CheckBoxCopy, 4, 4, 0, 2 ); - + CheckBoxCopy = new QCheckBox(GroupArguments, "CheckBoxCopy"); + CheckBoxCopy->setText(tr("SMESH_CREATE_COPY")); + GroupArgumentsLayout->addMultiCellWidget(CheckBoxCopy, 4, 4, 0, 2); + + SMESHGUI_RotationDlgLayout->addWidget(GroupArguments, 1, 0); - SMESHGUI_RotationDlgLayout->addWidget( GroupArguments, 1, 0 ); - /* Initialisations */ - SpinBox_X->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 ); - SpinBox_Y->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 ); - SpinBox_Z->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 ); - SpinBox_DX->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 ); - SpinBox_DY->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 ); - SpinBox_DZ->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 ); + SpinBox_X->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3); + SpinBox_Y->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3); + SpinBox_Z->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3); + SpinBox_DX->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3); + SpinBox_DY->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3); + SpinBox_DZ->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3); + + SpinBox_Angle->RangeStepAndValidator(-999999.999, +999999.999, 5.0, 3); - SpinBox_Angle->RangeStepAndValidator( -999999.999, +999999.999, 5.0, 3 ); - GroupArguments->show(); - myConstructorId = 0 ; - RadioButton1->setChecked( TRUE ); - mySelection = Sel; - - mySMESHGUI = SMESHGUI::GetSMESHGUI() ; - mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; + myConstructorId = 0; + RadioButton1->setChecked(TRUE); + + mySMESHGUI->SetActiveDialogBox((QDialog*)this); // Costruction of the logical filter - SMESH_ListOfFilter aListOfFilters; - Handle(SMESH_TypeFilter) aMeshOrSubMeshFilter = new SMESH_TypeFilter( MESHorSUBMESH ); - if ( !aMeshOrSubMeshFilter.IsNull() ) - aListOfFilters.Append( aMeshOrSubMeshFilter ); - Handle(SMESH_TypeFilter) aSmeshGroupFilter = new SMESH_TypeFilter( GROUP ); - if ( !aSmeshGroupFilter.IsNull() ) - aListOfFilters.Append( aSmeshGroupFilter ); - - myMeshOrSubMeshOrGroupFilter = new SMESH_LogicalFilter( aListOfFilters, SMESH_LogicalFilter::LO_OR ); - + SMESH_TypeFilter* aMeshOrSubMeshFilter = new SMESH_TypeFilter (MESHorSUBMESH); + SMESH_TypeFilter* aSmeshGroupFilter = new SMESH_TypeFilter (GROUP); + + QPtrList aListOfFilters; + if (aMeshOrSubMeshFilter) aListOfFilters.append(aMeshOrSubMeshFilter); + if (aSmeshGroupFilter) aListOfFilters.append(aSmeshGroupFilter); + + myMeshOrSubMeshOrGroupFilter = + new SMESH_LogicalFilter (aListOfFilters, SMESH_LogicalFilter::LO_OR); + Init(); + /* signals and slots connections */ - connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); - connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ; - connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) ); - connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) ); - - connect( SelectElementsButton, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; - connect( SelectPointButton, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; - connect( SelectVectorButton, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; - - connect( SpinBox_DX, SIGNAL( valueChanged( double )), this, SLOT(onVectorChanged() ) ); - connect( SpinBox_DY, SIGNAL( valueChanged( double )), this, SLOT(onVectorChanged() ) ); - connect( SpinBox_DZ, SIGNAL( valueChanged( double )), this, SLOT(onVectorChanged() ) ); - - connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; - connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel())); + connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); + connect(GroupConstructors, SIGNAL(clicked(int)), SLOT(ConstructorsClicked(int))); + + connect(SelectElementsButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument())); + connect(SelectPointButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument())); + connect(SelectVectorButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument())); + + connect(SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged())); + connect(SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged())); + connect(SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged())); + + connect(mySMESHGUI, SIGNAL (SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog())); + connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); /* to close dialog if study change */ - connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; - connect( LineEditElements, SIGNAL( textChanged( const QString& )), - SLOT( onTextChange( const QString& ))); - connect( CheckBoxMesh, SIGNAL( toggled( bool )), - SLOT( onSelectMesh( bool ))); - + connect(mySMESHGUI, SIGNAL (SignalCloseAllDialogs()), this, SLOT(ClickOnCancel())); + connect(LineEditElements, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&))); + connect(CheckBoxMesh, SIGNAL(toggled(bool)), SLOT(onSelectMesh(bool))); + /* Move widget on the botton right corner of main widget */ - int x, y ; - mySMESHGUI->DefineDlgPosition( this, x, y ) ; - this->move( x, y ) ; - this->show() ; /* displays Dialog */ + int x, y; + mySMESHGUI->DefineDlgPosition(this, x, y); + this->move(x, y); + this->show(); /* displays Dialog */ ConstructorsClicked(0); - resize(0,0); + resize(0,0); // ?? } //================================================================================= @@ -324,101 +342,92 @@ SMESHGUI_RotationDlg::~SMESHGUI_RotationDlg() // no need to delete child widgets, Qt does it all for us } - //================================================================================= // function : Init() // purpose : //================================================================================= -void SMESHGUI_RotationDlg::Init( bool ResetControls ) +void SMESHGUI_RotationDlg::Init (bool ResetControls) { myBusy = false; - + myEditCurrentArgument = (QWidget*)LineEditElements; LineEditElements->setFocus(); myElementsId = ""; - myNbOkElements = 0 ; - - buttonOk->setEnabled( false ); - buttonApply->setEnabled( false ); - - myActor = 0; + myNbOkElements = 0; + + buttonOk->setEnabled(false); + buttonApply->setEnabled(false); + + myActor = 0; myMesh = SMESH::SMESH_Mesh::_nil(); - - if( ResetControls ) - { - SpinBox_X->SetValue(0.0); - SpinBox_Y->SetValue(0.0); - SpinBox_Z->SetValue(0.0); - SpinBox_DX->SetValue(0.0); - SpinBox_DY->SetValue(0.0); - SpinBox_DZ->SetValue(0.0); - - SpinBox_Angle->SetValue(45); - - CheckBoxCopy->setChecked(false); - CheckBoxMesh->setChecked(false); - } - + + if (ResetControls) { + SpinBox_X->SetValue(0.0); + SpinBox_Y->SetValue(0.0); + SpinBox_Z->SetValue(0.0); + SpinBox_DX->SetValue(0.0); + SpinBox_DY->SetValue(0.0); + SpinBox_DZ->SetValue(0.0); + + SpinBox_Angle->SetValue(45); + + CheckBoxCopy->setChecked(false); + CheckBoxMesh->setChecked(false); + } + onSelectMesh(CheckBoxMesh->isChecked()); } - //================================================================================= // function : ConstructorsClicked() // purpose : Radio button management //================================================================================= -void SMESHGUI_RotationDlg::ConstructorsClicked(int constructorId) +void SMESHGUI_RotationDlg::ConstructorsClicked (int constructorId) { - return ; } - //================================================================================= // function : ClickOnApply() // purpose : //================================================================================= void SMESHGUI_RotationDlg::ClickOnApply() { - if (mySMESHGUI->ActiveStudyLocked()) + if (mySMESHGUI->isActiveStudyLocked()) return; - - if ( myNbOkElements && IsAxisOk()) - { - QStringList aListElementsId = QStringList::split( " ", myElementsId, false); - - SMESH::long_array_var anElementsId = new SMESH::long_array; - - anElementsId->length( aListElementsId.count() ); - for ( int i = 0; i < aListElementsId.count(); i++ ) - anElementsId[i] = aListElementsId[i].toInt(); - - SMESH::AxisStruct anAxis; - - anAxis.x = SpinBox_X->GetValue(); - anAxis.y = SpinBox_Y->GetValue(); - anAxis.z = SpinBox_Z->GetValue();; - anAxis.vx = SpinBox_DX->GetValue(); - anAxis.vy = SpinBox_DY->GetValue(); - anAxis.vz = SpinBox_DZ->GetValue(); - double anAngle = (SpinBox_Angle->GetValue())*PI/180; - bool toCreateCopy = CheckBoxCopy->isChecked(); - - try - { - SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor(); - QApplication::setOverrideCursor(Qt::waitCursor); - aMeshEditor->Rotate(anElementsId.inout(), anAxis, anAngle, toCreateCopy); - QApplication::restoreOverrideCursor(); - } - catch( ... ) - { - } - - mySelection->ClearIObjects(); - SMESH::UpdateView(); - Init( false ); + if (myNbOkElements && IsAxisOk()) { + QStringList aListElementsId = QStringList::split(" ", myElementsId, false); + + SMESH::long_array_var anElementsId = new SMESH::long_array; + + anElementsId->length(aListElementsId.count()); + for (int i = 0; i < aListElementsId.count(); i++) + anElementsId[i] = aListElementsId[i].toInt(); + + SMESH::AxisStruct anAxis; + + anAxis.x = SpinBox_X->GetValue(); + anAxis.y = SpinBox_Y->GetValue(); + anAxis.z = SpinBox_Z->GetValue();; + anAxis.vx = SpinBox_DX->GetValue(); + anAxis.vy = SpinBox_DY->GetValue(); + anAxis.vz = SpinBox_DZ->GetValue(); + + double anAngle = (SpinBox_Angle->GetValue())*PI/180; + bool toCreateCopy = CheckBoxCopy->isChecked(); + + try { + SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor(); + QApplication::setOverrideCursor(Qt::waitCursor); + aMeshEditor->Rotate(anElementsId.inout(), anAxis, anAngle, toCreateCopy); + QApplication::restoreOverrideCursor(); + } catch (...) { } + + mySelectionMgr->clearSelected(); + SMESH::UpdateView(); + Init(false); + } } //================================================================================= @@ -431,70 +440,82 @@ void SMESHGUI_RotationDlg::ClickOnOk() ClickOnCancel(); } - //================================================================================= // function : ClickOnCancel() // purpose : //================================================================================= void SMESHGUI_RotationDlg::ClickOnCancel() { - mySelection->ClearFilters(); - mySelection->ClearIObjects(); + disconnect(mySelectionMgr, 0, this, 0); + mySelectionMgr->clearFilters(); + mySelectionMgr->clearSelected(); SMESH::SetPointRepresentation(false); - QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); - disconnect( mySelection, 0, this, 0 ); - mySMESHGUI->ResetState() ; - reject() ; + myViewWindow->SetSelectionMode(ActorSelection); + mySMESHGUI->ResetState(); + reject(); } //======================================================================= -//function : onTextChange -//purpose : +// function : onTextChange() +// purpose : //======================================================================= - -void SMESHGUI_RotationDlg::onTextChange(const QString& theNewText) +void SMESHGUI_RotationDlg::onTextChange (const QString& theNewText) { QLineEdit* send = (QLineEdit*)sender(); - if ( myBusy ) return; + if (myBusy) return; myBusy = true; - + if (send == LineEditElements) myNbOkElements = 0; - - buttonOk->setEnabled( false ); - buttonApply->setEnabled( false ); - + + buttonOk->setEnabled(false); + buttonApply->setEnabled(false); + // hilight entered elements SMDS_Mesh* aMesh = 0; - if ( myActor ) + if (myActor) aMesh = myActor->GetObject()->GetMesh(); - - if ( aMesh ) { - - mySelection->ClearIObjects(); - mySelection->AddIObject( myActor->getIO() ); - - QStringList aListId = QStringList::split( " ", theNewText, false); - + + if (aMesh) { if (send == LineEditElements) { - for ( int i = 0; i < aListId.count(); i++ ) { - const SMDS_MeshElement * e = aMesh->FindElement( aListId[ i ].toInt() ); - if ( e ) { - if ( !mySelection->IsIndexSelected( myActor->getIO(), e->GetID() )) - mySelection->AddOrRemoveIndex (myActor->getIO(), e->GetID(), true); + //mySelectionMgr->clearSelected(); + //mySelectionMgr->AddIObject(myActor->getIO()); + SALOME_ListIO aList; + aList.Append(myActor->getIO()); + mySelectionMgr->setSelectedObjects(aList, false); + + TColStd_IndexedMapOfInteger selectedIndices; + TColStd_MapOfInteger newIndices; + mySelector->GetIndex( myActor->getIO(), selectedIndices); + + QStringList aListId = QStringList::split(" ", theNewText, false); + for (int i = 0; i < aListId.count(); i++) { + const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt()); + if (e) { + //if (!mySelectionMgr->IsIndexSelected(myActor->getIO(), e->GetID())) { + if (selectedIndices.Add(e->GetID())) { + //mySelectionMgr->AddOrRemoveIndex (myActor->getIO(), e->GetID(), true); + newIndices.Add(e->GetID()); + } myNbOkElements++; } } + + if (newIndices.Extent() > 0){ + mySelector->AddOrRemoveIndex( myActor->getIO(), newIndices, true ); + myViewWindow->highlight( myActor->getIO(), true, true ); + } + myElementsId = theNewText; } } - - if ( myNbOkElements && IsAxisOk()) { - buttonOk->setEnabled( true ); - buttonApply->setEnabled( true ); + + if (myNbOkElements && IsAxisOk()) { + buttonOk->setEnabled(true); + buttonApply->setEnabled(true); } - + myBusy = false; } @@ -504,34 +525,35 @@ void SMESHGUI_RotationDlg::onTextChange(const QString& theNewText) //================================================================================= void SMESHGUI_RotationDlg::SelectionIntoArgument() { - if ( myBusy ) return; - + if (myBusy) return; + // clear - myActor = 0; QString aString = ""; myBusy = true; - if (myEditCurrentArgument == (QWidget*)LineEditElements) - { - LineEditElements->setText( aString ); - myNbOkElements = 0; - buttonOk->setEnabled( false ); - buttonApply->setEnabled( false ); - } + if (myEditCurrentArgument == (QWidget*)LineEditElements) { + LineEditElements->setText(aString); + myNbOkElements = 0; + buttonOk->setEnabled(false); + buttonApply->setEnabled(false); + } myBusy = false; - - if ( !GroupButtons->isEnabled() ) // inactive + + if (!GroupButtons->isEnabled()) // inactive return; - + // get selected mesh - int nbSel = mySelection->IObjectCount(); - if(nbSel != 1) + SALOME_ListIO aList; + mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type()); + + int nbSel = aList.Extent(); + if (nbSel != 1) return; - - Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject(); - myMesh = SMESH::GetMeshByIO( mySelection->firstIObject() ); - if(myMesh->_is_nil()) + + Handle(SALOME_InteractiveObject) IO = aList.First(); + myMesh = SMESH::GetMeshByIO(IO); + if (myMesh->_is_nil()) return; myActor = SMESH::FindActorByObject(myMesh); @@ -539,118 +561,102 @@ void SMESHGUI_RotationDlg::SelectionIntoArgument() myActor = SMESH::FindActorByEntry(IO->getEntry()); if (!myActor) return; - + int aNbUnits = 0; - - if (myEditCurrentArgument == (QWidget*)LineEditElements) - { - myElementsId = ""; - - if (CheckBoxMesh->isChecked()) - { - SMESH::GetNameOfSelectedIObjects(mySelection, aString); - - if(!SMESH::IObjectToInterface(IO)->_is_nil()) //MESH - { - // get IDs from mesh - SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh(); - if (!aSMDSMesh) - return; - - for (int i = aSMDSMesh->MinElementID(); i <= aSMDSMesh->MaxElementID(); i++ ) - { - const SMDS_MeshElement * e = aSMDSMesh->FindElement( i ); - if ( e ) { - myElementsId += QString(" %1").arg(i); - aNbUnits++; - } - } - } - else if (!SMESH::IObjectToInterface(IO)->_is_nil()) //SUBMESH - { - // get submesh - SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface(IO) ; - - // get IDs from submesh - SMESH::long_array_var anElementsIds = new SMESH::long_array; - anElementsIds = aSubMesh->GetElementsId(); - for ( int i = 0; i < anElementsIds->length(); i++ ) - myElementsId += QString(" %1").arg(anElementsIds[i]); - aNbUnits = anElementsIds->length(); - } - else // GROUP - { - // get smesh group - SMESH::SMESH_GroupBase_var aGroup = - SMESH::IObjectToInterface(IO); - if (aGroup->_is_nil()) - return; - - // get IDs from smesh group - SMESH::long_array_var anElementsIds = new SMESH::long_array; - anElementsIds = aGroup->GetListOfID(); - for ( int i = 0; i < anElementsIds->length(); i++ ) - myElementsId += QString(" %1").arg(anElementsIds[i]); - aNbUnits = anElementsIds->length(); - } - } - else - { - aNbUnits = SMESH::GetNameOfSelectedElements(mySelection, aString) ; - myElementsId = aString; - } - - if(aNbUnits < 1) - return ; - - myNbOkElements = true; + + if (myEditCurrentArgument == (QWidget*)LineEditElements) { + myElementsId = ""; + + if (CheckBoxMesh->isChecked()) { + SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString); + + if (!SMESH::IObjectToInterface(IO)->_is_nil()) { //MESH + // get IDs from mesh + SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh(); + if (!aSMDSMesh) + return; + + for (int i = aSMDSMesh->MinElementID(); i <= aSMDSMesh->MaxElementID(); i++) { + const SMDS_MeshElement * e = aSMDSMesh->FindElement(i); + if (e) { + myElementsId += QString(" %1").arg(i); + aNbUnits++; + } + } + } else if (!SMESH::IObjectToInterface(IO)->_is_nil()) { //SUBMESH + // get submesh + SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface(IO); + + // get IDs from submesh + SMESH::long_array_var anElementsIds = new SMESH::long_array; + anElementsIds = aSubMesh->GetElementsId(); + for (int i = 0; i < anElementsIds->length(); i++) { + myElementsId += QString(" %1").arg(anElementsIds[i]); + } + aNbUnits = anElementsIds->length(); + } else { // GROUP + // get smesh group + SMESH::SMESH_GroupBase_var aGroup = + SMESH::IObjectToInterface(IO); + if (aGroup->_is_nil()) + return; + + // get IDs from smesh group + SMESH::long_array_var anElementsIds = new SMESH::long_array; + anElementsIds = aGroup->GetListOfID(); + for (int i = 0; i < anElementsIds->length(); i++) { + myElementsId += QString(" %1").arg(anElementsIds[i]); + } + aNbUnits = anElementsIds->length(); + } + } else { + aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, myActor->getIO(), aString); + myElementsId = aString; } - else - { - aNbUnits = SMESH::GetNameOfSelectedNodes(mySelection, aString); - if(aNbUnits != 1) - return; - - SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh(); - if (!aMesh) - return; - - const SMDS_MeshNode * n = aMesh->FindNode( aString.toInt() ); - if ( !n ) - return; - - double x = n->X(); - double y = n->Y(); - double z = n->Z(); - - if (myEditCurrentArgument == (QWidget*)SpinBox_X) - { - SpinBox_X->SetValue(x); - SpinBox_Y->SetValue(y); - SpinBox_Z->SetValue(z); - } - else if (myEditCurrentArgument == (QWidget*)SpinBox_DX) - { - SpinBox_DX->SetValue(x - SpinBox_X->GetValue()); - SpinBox_DY->SetValue(y - SpinBox_Y->GetValue()); - SpinBox_DZ->SetValue(z - SpinBox_Z->GetValue()); - } + + if (aNbUnits < 1) + return; + + myNbOkElements = true; + } else { + aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, myActor->getIO(), aString); + if (aNbUnits != 1) + return; + + SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh(); + if (!aMesh) + return; + + const SMDS_MeshNode * n = aMesh->FindNode(aString.toInt()); + if (!n) + return; + + double x = n->X(); + double y = n->Y(); + double z = n->Z(); + + if (myEditCurrentArgument == (QWidget*)SpinBox_X) { + SpinBox_X->SetValue(x); + SpinBox_Y->SetValue(y); + SpinBox_Z->SetValue(z); + } else if (myEditCurrentArgument == (QWidget*)SpinBox_DX) { + SpinBox_DX->SetValue(x - SpinBox_X->GetValue()); + SpinBox_DY->SetValue(y - SpinBox_Y->GetValue()); + SpinBox_DZ->SetValue(z - SpinBox_Z->GetValue()); } - + } + myBusy = true; if (myEditCurrentArgument == (QWidget*)LineEditElements) - LineEditElements->setText( aString ); + LineEditElements->setText(aString); myBusy = false; - - // OK - - if(myNbOkElements && IsAxisOk()) - { - buttonOk->setEnabled( true ); - buttonApply->setEnabled( true ); - } -} + // OK + if (myNbOkElements && IsAxisOk()) { + buttonOk->setEnabled(true); + buttonApply->setEnabled(true); + } +} //================================================================================= // function : SetEditCurrentArgument() @@ -659,45 +665,42 @@ void SMESHGUI_RotationDlg::SelectionIntoArgument() void SMESHGUI_RotationDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); - - disconnect( mySelection, 0, this, 0 ); - mySelection->ClearIObjects(); - mySelection->ClearFilters(); - switch (myConstructorId) + disconnect(mySelectionMgr, 0, this, 0); + mySelectionMgr->clearSelected(); + mySelectionMgr->clearFilters(); + + switch (myConstructorId) { + case 0: /* default constructor */ { - case 0: /* default constructor */ - { - if(send == SelectElementsButton) { - myEditCurrentArgument = (QWidget*)LineEditElements; - SMESH::SetPointRepresentation(false); - if (CheckBoxMesh->isChecked()) - { - QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); - mySelection->AddFilter(myMeshOrSubMeshOrGroupFilter); - } - else - QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true ); - } - else if (send == SelectPointButton) - { - myEditCurrentArgument = (QWidget*)SpinBox_X; - SMESH::SetPointRepresentation(true); - QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true ); - } - else if (send == SelectVectorButton) - { - myEditCurrentArgument = (QWidget*)SpinBox_DX; - SMESH::SetPointRepresentation(true); - QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true ); - } - break; + if (send == SelectElementsButton) { + myEditCurrentArgument = (QWidget*)LineEditElements; + SMESH::SetPointRepresentation(false); + if (CheckBoxMesh->isChecked()) { + myViewWindow->SetSelectionMode(ActorSelection); + mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter); + } else { + + myViewWindow->SetSelectionMode( CellSelection ); + } + } else if (send == SelectPointButton) { + myEditCurrentArgument = (QWidget*)SpinBox_X; + SMESH::SetPointRepresentation(true); + + myViewWindow->SetSelectionMode( NodeSelection ); + } else if (send == SelectVectorButton) { + myEditCurrentArgument = (QWidget*)SpinBox_DX; + SMESH::SetPointRepresentation(true); + + myViewWindow->SetSelectionMode( NodeSelection ); } + break; } - + } + myEditCurrentArgument->setFocus(); - connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); - SelectionIntoArgument() ; + connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + SelectionIntoArgument(); } //================================================================================= @@ -706,16 +709,15 @@ void SMESHGUI_RotationDlg::SetEditCurrentArgument() //================================================================================= void SMESHGUI_RotationDlg::DeactivateActiveDialog() { - if ( GroupConstructors->isEnabled() ) { - GroupConstructors->setEnabled(false) ; - GroupArguments->setEnabled(false) ; - GroupButtons->setEnabled(false) ; - mySMESHGUI->ResetState() ; - mySMESHGUI->SetActiveDialogBox(0) ; + if (GroupConstructors->isEnabled()) { + GroupConstructors->setEnabled(false); + GroupArguments->setEnabled(false); + GroupButtons->setEnabled(false); + mySMESHGUI->ResetState(); + mySMESHGUI->SetActiveDialogBox(0); } } - //================================================================================= // function : ActivateThisDialog() // purpose : @@ -723,116 +725,101 @@ void SMESHGUI_RotationDlg::DeactivateActiveDialog() void SMESHGUI_RotationDlg::ActivateThisDialog() { /* Emit a signal to deactivate the active dialog */ - mySMESHGUI->EmitSignalDeactivateDialog() ; - GroupConstructors->setEnabled(true) ; - GroupArguments->setEnabled(true) ; - GroupButtons->setEnabled(true) ; - - mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; + mySMESHGUI->EmitSignalDeactivateDialog(); + GroupConstructors->setEnabled(true); + GroupArguments->setEnabled(true); + GroupButtons->setEnabled(true); - QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true ); + mySMESHGUI->SetActiveDialogBox((QDialog*)this); + + myViewWindow->SetSelectionMode( CellSelection ); SelectionIntoArgument(); } - //================================================================================= // function : enterEvent() // purpose : //================================================================================= -void SMESHGUI_RotationDlg::enterEvent(QEvent* e) +void SMESHGUI_RotationDlg::enterEvent (QEvent*) { - if ( GroupConstructors->isEnabled() ) - return ; - ActivateThisDialog() ; + if (!GroupConstructors->isEnabled()) + ActivateThisDialog(); } - //================================================================================= // function : closeEvent() // purpose : //================================================================================= -void SMESHGUI_RotationDlg::closeEvent( QCloseEvent* e ) +void SMESHGUI_RotationDlg::closeEvent (QCloseEvent*) { /* same than click on cancel button */ - this->ClickOnCancel() ; + this->ClickOnCancel(); } - -//======================================================================= -//function : hideEvent -//purpose : caused by ESC key -//======================================================================= - -void SMESHGUI_RotationDlg::hideEvent ( QHideEvent * e ) +//================================================================================= +// function : hideEvent() +// purpose : caused by ESC key +//================================================================================= +void SMESHGUI_RotationDlg::hideEvent (QHideEvent*) { - if ( !isMinimized() ) + if (!isMinimized()) ClickOnCancel(); } - -//======================================================================= -//function : onSelectMesh -//purpose : -//======================================================================= -void SMESHGUI_RotationDlg::onSelectMesh ( bool toSelectMesh ) +//================================================================================= +// function : onSelectMesh() +// purpose : +//================================================================================= +void SMESHGUI_RotationDlg::onSelectMesh (bool toSelectMesh) { if (toSelectMesh) - TextLabelElements->setText( tr( "SMESH_NAME" ) ); + TextLabelElements->setText(tr("SMESH_NAME")); else - TextLabelElements->setText( tr( "SMESH_ID_ELEMENTS" ) ); - - if (myEditCurrentArgument != LineEditElements) - { - LineEditElements->clear(); - return; - } - - mySelection->ClearFilters() ; + TextLabelElements->setText(tr("SMESH_ID_ELEMENTS")); + + if (myEditCurrentArgument != LineEditElements) { + LineEditElements->clear(); + return; + } + + mySelectionMgr->clearFilters(); SMESH::SetPointRepresentation(false); - - if (toSelectMesh) - { - QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); - mySelection->AddFilter(myMeshOrSubMeshOrGroupFilter); - LineEditElements->setReadOnly(true); - } - else - { - QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true ); - LineEditElements->setReadOnly(false); - onTextChange(LineEditElements->text()); - } - + + if (toSelectMesh) { + myViewWindow->SetSelectionMode(ActorSelection); + mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter); + LineEditElements->setReadOnly(true); + } else { + myViewWindow->SetSelectionMode( CellSelection ); + LineEditElements->setReadOnly(false); + onTextChange(LineEditElements->text()); + } + SelectionIntoArgument(); } - //================================================================================= // function : IsAxisOk() -// purpose : +// purpose : //================================================================================= bool SMESHGUI_RotationDlg::IsAxisOk() { - return (SpinBox_DX->GetValue() != 0 || + return (SpinBox_DX->GetValue() != 0 || SpinBox_DY->GetValue() != 0 || - SpinBox_DZ->GetValue() != 0); + SpinBox_DZ->GetValue() != 0); } - //================================================================================= // function : onVectorChanged() -// purpose : +// purpose : //================================================================================= void SMESHGUI_RotationDlg::onVectorChanged() { - if (IsAxisOk()) - { - buttonOk->setEnabled( true ); - buttonApply->setEnabled( true ); - } - else - { - buttonOk->setEnabled( false ); - buttonApply->setEnabled( false ); - } + if (IsAxisOk()) { + buttonOk->setEnabled(true); + buttonApply->setEnabled(true); + } else { + buttonOk->setEnabled(false); + buttonApply->setEnabled(false); + } } diff --git a/src/SMESHGUI/SMESHGUI_RotationDlg.h b/src/SMESHGUI/SMESHGUI_RotationDlg.h index 7901d1ed9..1fb8ed500 100644 --- a/src/SMESHGUI/SMESHGUI_RotationDlg.h +++ b/src/SMESHGUI/SMESHGUI_RotationDlg.h @@ -29,7 +29,8 @@ #ifndef DIALOGBOX_ROTATION_H #define DIALOGBOX_ROTATION_H -#include "SALOME_Selection.h" +#include "SalomeApp_SelectionMgr.h" + #include "SMESH_LogicalFilter.hxx" // QT Includes @@ -47,6 +48,9 @@ class SMESHGUI_SpinBox; class SMESHGUI; class SMESH_Actor; class SMESHGUI_SpinBox; +class SVTK_ViewWindow; +class SVTK_Selector; + // IDL Headers #include @@ -62,29 +66,33 @@ class SMESHGUI_RotationDlg : public QDialog Q_OBJECT public: - SMESHGUI_RotationDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); + SMESHGUI_RotationDlg( SMESHGUI*, + const char* name = 0, + bool modal = FALSE, + WFlags fl = 0); ~SMESHGUI_RotationDlg(); private: - - void Init( bool ResetControls = true ) ; - void closeEvent( QCloseEvent* e ) ; - void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */ - void hideEvent ( QHideEvent * ); /* ESC key */ + void Init (bool ResetControls = true); + void closeEvent (QCloseEvent*); + void enterEvent (QEvent*); /* mouse enter the QWidget */ + void hideEvent (QHideEvent*); /* ESC key */ bool IsAxisOk(); - - SMESHGUI* mySMESHGUI ; /* Current SMESHGUI object */ - SALOME_Selection* mySelection ; /* User shape selection */ - int myNbOkElements ; /* to check when elements are defined */ + + SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */ + SalomeApp_SelectionMgr* mySelectionMgr; /* User shape selection */ + int myNbOkElements; /* to check when elements are defined */ QString myElementsId; - - QWidget* myEditCurrentArgument; /* Current LineEdit */ + SVTK_ViewWindow* myViewWindow; + SVTK_Selector* mySelector; + + QWidget* myEditCurrentArgument; /* Current LineEdit */ int myConstructorId; bool myBusy; SMESH::SMESH_Mesh_var myMesh; SMESH_Actor* myActor; - Handle(SMESH_LogicalFilter) myMeshOrSubMeshOrGroupFilter; - + SMESH_LogicalFilter* myMeshOrSubMeshOrGroupFilter; + QButtonGroup* GroupConstructors; QRadioButton* RadioButton1; QGroupBox* GroupButtons; @@ -118,19 +126,19 @@ private: QLabel* TextLabelAngle; SMESHGUI_SpinBox* SpinBox_Angle; QCheckBox* CheckBoxCopy; - - private slots: - void ConstructorsClicked(int constructorId); +private slots: + + void ConstructorsClicked (int constructorId); void ClickOnOk(); void ClickOnCancel(); void ClickOnApply(); - void SetEditCurrentArgument() ; - void SelectionIntoArgument() ; - void DeactivateActiveDialog() ; - void ActivateThisDialog() ; - void onTextChange(const QString&); - void onSelectMesh(bool toSelectMesh); + void SetEditCurrentArgument(); + void SelectionIntoArgument(); + void DeactivateActiveDialog(); + void ActivateThisDialog(); + void onTextChange (const QString&); + void onSelectMesh (bool toSelectMesh); void onVectorChanged(); protected: diff --git a/src/SMESHGUI/SMESHGUI_Selection.cxx b/src/SMESHGUI/SMESHGUI_Selection.cxx new file mode 100644 index 000000000..73f961bea --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_Selection.cxx @@ -0,0 +1,421 @@ + +#include "SMESHGUI_Selection.h" +#include "SMESHGUI_Utils.h" +#include "SMESHGUI_VTKUtils.h" +#include "SMESHGUI_MeshUtils.h" +#include "SMESHGUI_GEOMGenUtils.h" + +#include "SMESH_Type.h" +#include "SMESH_Actor.h" + +#include "SalomeApp_SelectionMgr.h" +#include "SalomeApp_Study.h" +#include "SalomeApp_VTKSelector.h" + +#include "SUIT_Session.h" + +#include "SVTK_RenderWindowInteractor.h" +#include "SVTK_ViewWindow.h" + +#include CORBA_SERVER_HEADER(SMESH_Mesh) +#include CORBA_SERVER_HEADER(SMESH_Group) + +//======================================================================= +//function : SMESHGUI_Selection +//purpose : +//======================================================================= + +SMESHGUI_Selection::SMESHGUI_Selection( const QString& client, + SalomeApp_SelectionMgr* mgr ) +{ + myPopupClient = client; + + SalomeApp_Study* appStudy = dynamic_cast + (SUIT_Session::session()->activeApplication()->activeStudy()); + + if( mgr && appStudy ) + { + _PTR(Study) study = appStudy->studyDS(); + + SUIT_DataOwnerPtrList sel; + mgr->selected( sel, client ); + myDataOwners = sel; + SUIT_DataOwnerPtrList::const_iterator anIt = sel.begin(), + aLast = sel.end(); + for( ; anIt!=aLast; anIt++ ) + { + SUIT_DataOwner* owner = ( SUIT_DataOwner* )( (*anIt ).get() ); + SalomeApp_DataOwner* sowner = dynamic_cast( owner ); + if( sowner ) + myTypes.append( typeName( type( sowner, study ) ) ); + else + myTypes.append( "Unknown" ); + } + } +} + +SMESHGUI_Selection::~SMESHGUI_Selection() +{ +} + +//======================================================================= +//function : count +//purpose : +//======================================================================= + +int SMESHGUI_Selection::count() const +{ + return myTypes.count(); +} + +//======================================================================= +//function : param +//purpose : +//======================================================================= + +QtxValue SMESHGUI_Selection::param( const int ind, const QString& p ) const +{ + QtxValue val; + if ( p=="client" ) val = QtxValue( myPopupClient ); + else if ( p=="type" ) val = QtxValue( myTypes[ind] ); + else if ( p=="elemTypes" ) val = QtxValue( elemTypes( ind ) ); + else if ( p=="numberOfNodes" ) val = QtxValue( numberOfNodes( ind ) ); + else if ( p=="labeledTypes" ) val = QtxValue( labeledTypes( ind ) ); + else if ( p=="shrinkMode" ) val = QtxValue( shrinkMode( ind ) ); + else if ( p=="entityMode" ) val = QtxValue( entityMode( ind ) ); + else if ( p=="controlMode" ) val = QtxValue( controlMode( ind ) ); + else if ( p=="displayMode" ) val = QtxValue( displayMode( ind ) ); + else if ( p=="isComputable" ) val = QtxValue( isComputable( ind ) ); + else if ( p=="hasReference" ) val = QtxValue( hasReference( ind ) ); + else if ( p=="isVisible" ) val = QtxValue( isVisible( ind ) ); + + printf( "--> param() : [%s] = %s (%s)\n", p.latin1(), val.toString().latin1(), val.typeName() ); + if ( val.type() == QVariant::List ) + cout << "size: " << val.toList().count() << endl; + return val; +} + +//======================================================================= +//function : getVtkOwner +//purpose : +//======================================================================= + +SMESH_Actor* SMESHGUI_Selection::getActor( int ind ) const +{ + if ( ind >= 0 && ind < myDataOwners.count() ) { + const SalomeApp_SVTKDataOwner* owner = + dynamic_cast ( myDataOwners[ ind ].get() ); + if ( owner ) + return dynamic_cast( owner->GetActor() ); + } + return 0; +} + +//======================================================================= +//function : elemTypes +//purpose : may return {'Edge' 'Face' 'Volume'} at most +//======================================================================= + +QValueList SMESHGUI_Selection::elemTypes( int ind ) const +{ + QValueList types; + SMESH_Actor* actor = getActor( ind ); + if ( actor ) { + TVisualObjPtr object = actor->GetObject(); + if ( object ) { + if ( object->GetNbEntities( SMDSAbs_Edge )) types.append( "Edge" ); + if ( object->GetNbEntities( SMDSAbs_Face )) types.append( "Face" ); + if ( object->GetNbEntities( SMDSAbs_Volume )) types.append( "Volume" ); + } + } + return types; +} + +//======================================================================= +//function : labeledTypes +//purpose : may return {'Point' 'Cell'} at most +//======================================================================= + +QValueList SMESHGUI_Selection::labeledTypes( int ind ) const +{ + QValueList types; + SMESH_Actor* actor = getActor( ind ); + if ( actor ) { + if ( actor->GetPointsLabeled()) types.append( "Point" ); + if ( actor->GetCellsLabeled()) types.append( "Cell" ); + } + return types; +} + +//======================================================================= +//function : displayMode +//purpose : return SMESH_Actor::EReperesent +//======================================================================= + +QString SMESHGUI_Selection::displayMode( int ind ) const +{ + SMESH_Actor* actor = getActor( ind ); + if ( actor ) { + switch( actor->GetRepresentation() ) { + case SMESH_Actor::eEdge: return "eEdge"; + case SMESH_Actor::eSurface: return "eSurface"; + case SMESH_Actor::ePoint: return "ePoint"; + default:; + } + } + return "Unknown"; +} + +//======================================================================= +//function : shrinkMode +//purpose : return either 'IsSrunk', 'IsNotShrunk' or 'IsNotShrinkable' +//======================================================================= + +QString SMESHGUI_Selection::shrinkMode( int ind ) const +{ + SMESH_Actor* actor = getActor( ind ); + if ( actor && actor->IsShrunkable() ) { + if ( actor->IsShrunk() ) + return "IsShrunk"; + return "IsNotShrunk"; + } + return "IsNotShrinkable"; +} + +//======================================================================= +//function : entityMode +//purpose : may return {'Edge' 'Face' 'Volume'} at most +//======================================================================= + +QValueList SMESHGUI_Selection::entityMode( int ind ) const +{ + QValueList types; + SMESH_Actor* actor = getActor( ind ); + if ( actor ) { + unsigned int aMode = actor->GetEntityMode(); + if ( aMode & SMESH_Actor::eVolumes) types.append( "Volume"); + if ( aMode & SMESH_Actor::eFaces ) types.append( "Face" ); + if ( aMode & SMESH_Actor::eEdges ) types.append( "Edge" ); + } + return types; +} + +//======================================================================= +//function : controlMode +//purpose : return SMESH_Actor::eControl +//======================================================================= + +QString SMESHGUI_Selection::controlMode( int ind ) const +{ + SMESH_Actor* actor = getActor( ind ); + if ( actor ) { + switch( actor->GetControlMode() ) { + case SMESH_Actor::eLength: return "eLength"; + case SMESH_Actor::eLength2D: return "eLength2D"; + case SMESH_Actor::eFreeEdges: return "eFreeEdges"; + case SMESH_Actor::eFreeBorders: return "eFreeBorders"; + case SMESH_Actor::eMultiConnection: return "eMultiConnection"; + case SMESH_Actor::eMultiConnection2D: return "eMultiConnection2D"; + case SMESH_Actor::eArea: return "eArea"; + case SMESH_Actor::eTaper: return "eTaper"; + case SMESH_Actor::eAspectRatio: return "eAspectRatio"; + case SMESH_Actor::eAspectRatio3D: return "eAspectRatio3D"; + case SMESH_Actor::eMinimumAngle: return "eMinimumAngle"; + case SMESH_Actor::eWarping: return "eWarping"; + case SMESH_Actor::eSkew: return "eSkew"; + default:; + } + } + return "eNone"; +} + +//======================================================================= +//function : numberOfNodes +//purpose : +//======================================================================= + +int SMESHGUI_Selection::numberOfNodes( int ind ) const +{ + if ( ind >= 0 && ind < myTypes.count() && myTypes[ind] != "Unknown" ) + { + CORBA::Object_var obj = + SMESH::DataOwnerToObject( static_cast( myDataOwners[ ind ].get() )); + if ( ! CORBA::is_nil( obj )) { + SMESH::SMESH_Mesh_var mesh = SMESH::SMESH_Mesh::_narrow( obj ); + if ( ! mesh->_is_nil() ) + return mesh->NbNodes(); + SMESH::SMESH_subMesh_var aSubMeshObj = SMESH::SMESH_subMesh::_narrow( obj ); + if ( !aSubMeshObj->_is_nil() ) + return aSubMeshObj->GetNumberOfNodes(true); + SMESH::SMESH_GroupBase_var aGroupObj = SMESH::SMESH_GroupBase::_narrow( obj ); + if ( !aGroupObj->_is_nil() ) + return aGroupObj->Size(); + } + } + return 0; +} + +//======================================================================= +//function : isComputable +//purpose : +//======================================================================= + +QVariant SMESHGUI_Selection::isComputable( int ind ) const +{ + if ( ind >= 0 && ind < myTypes.count() && myTypes[ind] != "Unknown" ) + { + Handle(SALOME_InteractiveObject) io = + static_cast( myDataOwners[ ind ].get() )->IO(); + if ( !io.IsNull() ) { + SMESH::SMESH_Mesh_var mesh = SMESH::GetMeshByIO(io) ; // m,sm,gr->m + if ( !mesh->_is_nil() ) { + _PTR(SObject) so = SMESH::FindSObject( mesh ); + if ( so ) { + GEOM::GEOM_Object_var shape = SMESH::GetShapeOnMeshOrSubMesh( so ); + return QVariant( !shape->_is_nil(), 0 ); + } + } + } + } + return QVariant( false, 0 ); +} + +//======================================================================= +//function : hasReference +//purpose : +//======================================================================= + +QVariant SMESHGUI_Selection::hasReference( int ind ) const +{ + if ( ind >= 0 && ind < myTypes.count() && myTypes[ind] != "Unknown" ) + { + Handle(SALOME_InteractiveObject) io = + static_cast( myDataOwners[ ind ].get() )->IO(); + if ( !io.IsNull() ) + return QVariant( io->hasReference(), 0 ); + } + return QVariant( false, 0 ); +} + +//======================================================================= +//function : isVisible +//purpose : +//======================================================================= + +QVariant SMESHGUI_Selection::isVisible( int ind ) const +{ + if ( ind >= 0 && ind < myTypes.count() && myTypes[ind] != "Unknown" ) + { + QString entry = static_cast( myDataOwners[ ind ].get() )->entry(); + SMESH_Actor* actor = SMESH::FindActorByEntry( entry.latin1() ); + if ( actor && actor->hasIO() ) { + SVTK_RenderWindowInteractor* renderInter = SMESH::GetCurrentVtkView()->getRWInteractor(); + return QVariant( renderInter->isVisible( actor->getIO() ), 0 ); + } + } + return QVariant( false, 0 ); +} + + +//======================================================================= +//function : type +//purpose : +//======================================================================= + +int SMESHGUI_Selection::type( SalomeApp_DataOwner* owner, + _PTR(Study) study ) +{ + QString entry = owner->entry(); + + _PTR(SObject) obj (study->FindObjectID(entry.latin1())); + if( !obj ) + return -1; + + _PTR(SObject) objFather = obj->GetFather(); + _PTR(SComponent) objComponent = obj->GetFatherComponent(); + + int aLevel = obj->Depth() - objComponent->Depth(), + aFTag = objFather->Tag(), + anOTag = obj->Tag(), + res = -1; + + switch( aLevel ) + { + case 1: + if( anOTag>=3 ) + res = MESH; + break; + case 2: + switch( aFTag ) + { + case 1: + res = HYPOTHESIS; + break; + case 2: + res = ALGORITHM; + break; + } + break; + case 3: + switch( aFTag ) + { + case 4: + res = SUBMESH_VERTEX; + break; + case 5: + res = SUBMESH_EDGE; + break; + case 7: + res = SUBMESH_FACE; + break; + case 9: + res = SUBMESH_SOLID; + break; + case 10: + res = SUBMESH_COMPOUND; + break; + } + if( aFTag>10 ) + res = GROUP; + + break; + } + + return res; +} + +//======================================================================= +//function : typeName +//purpose : +//======================================================================= + +QString SMESHGUI_Selection::typeName( const int t ) +{ + switch( t ) + { + case HYPOTHESIS: + return "Hypothesis"; + case ALGORITHM: + return "Algorithm"; + case MESH: + return "Mesh"; + case SUBMESH: + return "SubMesh"; + case MESHorSUBMESH: + return "Mesh or submesh"; + case SUBMESH_VERTEX: + return "Mesh vertex"; + case SUBMESH_EDGE: + return "Mesh edge"; + case SUBMESH_FACE: + return "Mesh face"; + case SUBMESH_SOLID: + return "Mesh solid"; + case SUBMESH_COMPOUND: + return "Mesh compound"; + case GROUP: + return "Group"; + default: + return "Unknown"; + } +} diff --git a/src/SMESHGUI/SMESHGUI_Selection.h b/src/SMESHGUI/SMESHGUI_Selection.h new file mode 100644 index 000000000..20e13f9bb --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_Selection.h @@ -0,0 +1,77 @@ +// SMESH SMESHGUI_Selection +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESHGUI_Selection.h +// Author : Alexander SOLOVYOV +// Module : SMESH +// $Header$ + +#ifndef SMESHGUI_SELECTION_HeaderFile +#define SMESHGUI_SELECTION_HeaderFile + +#include + +#include "SALOMEDSClient_definitions.hxx" +#include "SUIT_DataOwner.h" + +class SalomeApp_SelectionMgr; +class SALOMEDSClient_Study; +class SalomeApp_DataOwner; +class SMESH_Actor; + +class SMESHGUI_Selection : public QtxPopupMgr::Selection +{ +public: + SMESHGUI_Selection( const QString&, SalomeApp_SelectionMgr* ); + virtual ~SMESHGUI_Selection(); + + virtual QtxValue param( const int , const QString& paramName ) const; + + virtual int count() const; + + // got from object, not from actor + virtual int numberOfNodes( int ind ) const; + virtual QVariant isComputable( int ind ) const; + virtual QVariant hasReference( int ind ) const; + virtual QVariant isVisible( int ind ) const; + + // parameters got from actor return nothing if an actor is not visible + virtual QValueList elemTypes( int ind ) const; + virtual QValueList labeledTypes( int ind ) const; + virtual QString displayMode( int ind ) const; + virtual QString shrinkMode( int ind ) const; + virtual QValueList entityMode( int ind ) const; + virtual QString controlMode( int ind ) const; + + SMESH_Actor* getActor( int ind ) const; + + static int type( SalomeApp_DataOwner* owner, _PTR(Study) study); + static QString typeName( const int type); + +private: + QString myPopupClient; + QStringList myTypes; + SUIT_DataOwnerPtrList myDataOwners; +}; + +#endif diff --git a/src/SMESHGUI/SMESHGUI_SewingDlg.cxx b/src/SMESHGUI/SMESHGUI_SewingDlg.cxx index 0cfe1f643..a84e3834d 100644 --- a/src/SMESHGUI/SMESHGUI_SewingDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_SewingDlg.cxx @@ -1,30 +1,30 @@ // SMESH SMESHGUI : GUI for SMESH component // // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org // // // // File : SMESHGUI_SewingDlg.cxx // Author : Michael ZORIN // Module : SMESH -// $Header: +// $Header: #include "SMESHGUI_SewingDlg.h" @@ -32,16 +32,26 @@ #include "SMESHGUI_Utils.h" #include "SMESHGUI_VTKUtils.h" #include "SMESHGUI_IdValidator.h" + #include "SMESH_Actor.h" #include "SMDS_Mesh.hxx" -#include "GEOMBase.h" +#include "SUIT_ResourceMgr.h" +#include "SUIT_Desktop.h" +#include "SUIT_MessageBox.h" + +#include "SVTK_ViewModel.h" +#include "SVTK_ViewWindow.h" +#include "SVTK_Selector.h" +#include "SVTK_Selection.h" +#include "SALOME_ListIO.hxx" -#include "QAD_Application.h" -#include "QAD_Desktop.h" -#include "QAD_MessageBox.h" #include "utilities.h" +// OCCT Includes +#include +#include + // QT Includes #include #include @@ -58,241 +68,256 @@ using namespace std; //================================================================================= // class : SMESHGUI_SewingDlg() -// purpose : +// purpose : //================================================================================= -SMESHGUI_SewingDlg::SMESHGUI_SewingDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, - bool modal, WFlags fl ) - : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | - Qt::WDestructiveClose) +SMESHGUI_SewingDlg::SMESHGUI_SewingDlg( SMESHGUI* theModule, const char* name, + bool modal, WFlags fl) + : QDialog( SMESH::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder | + WStyle_Title | WStyle_SysMenu | Qt::WDestructiveClose), + mySMESHGUI( theModule ), + mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ), + myViewWindow( SMESH::GetViewWindow( theModule ) ), + mySelector( myViewWindow->GetSelector() ) { - QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SMESH_SEWING_FREEBORDERS"))); - QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SMESH_SEWING_CONFORM_FREEBORDERS"))); - QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SMESH_SEWING_BORDERTOSIDE"))); - QPixmap image3(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SMESH_SEWING_SIDEELEMENTS"))); - QPixmap image4(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SELECT"))); + QPixmap image0 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SMESH_SEWING_FREEBORDERS"))); + QPixmap image1 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SMESH_SEWING_CONFORM_FREEBORDERS"))); + QPixmap image2 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SMESH_SEWING_BORDERTOSIDE"))); + QPixmap image3 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SMESH_SEWING_SIDEELEMENTS"))); + QPixmap image4 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT"))); - if ( !name ) - setName( "SMESHGUI_SewingDlg" ); - resize( 303, 185 ); - setCaption( tr( "SMESH_SEWING" ) ); - setSizeGripEnabled( TRUE ); - SMESHGUI_SewingDlgLayout = new QGridLayout( this ); - SMESHGUI_SewingDlgLayout->setSpacing( 6 ); - SMESHGUI_SewingDlgLayout->setMargin( 11 ); + if (!name) + setName("SMESHGUI_SewingDlg"); + resize(303, 185); + setCaption(tr("SMESH_SEWING")); + setSizeGripEnabled(TRUE); + SMESHGUI_SewingDlgLayout = new QGridLayout(this); + SMESHGUI_SewingDlgLayout->setSpacing(6); + SMESHGUI_SewingDlgLayout->setMargin(11); /***************************************************************/ - GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); - GroupConstructors->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)0, 0, 0, GroupConstructors->sizePolicy().hasHeightForWidth() ) ); - GroupConstructors->setTitle( tr( "SMESH_SEWING" ) ); - GroupConstructors->setExclusive( TRUE ); - GroupConstructors->setColumnLayout(0, Qt::Vertical ); - GroupConstructors->layout()->setSpacing( 0 ); - GroupConstructors->layout()->setMargin( 0 ); - GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() ); - GroupConstructorsLayout->setAlignment( Qt::AlignTop ); - GroupConstructorsLayout->setSpacing( 6 ); - GroupConstructorsLayout->setMargin( 11 ); - QHBoxLayout* RBLayout = new QHBoxLayout( 0, 0, 6, "Layout2"); - RadioButton1= new QRadioButton( GroupConstructors, "RadioButton1" ); - RadioButton1->setText( tr( "" ) ); - RadioButton1->setPixmap( image0 ); - RBLayout->addWidget( RadioButton1); - RadioButton2= new QRadioButton( GroupConstructors, "RadioButton2" ); - RadioButton2->setText( tr( "" ) ); - RadioButton2->setPixmap( image1 ); - RBLayout->addWidget( RadioButton2); - RadioButton3= new QRadioButton( GroupConstructors, "RadioButton3" ); - RadioButton3->setText( tr( "" ) ); - RadioButton3->setPixmap( image2 ); - RBLayout->addWidget( RadioButton3); - RadioButton4= new QRadioButton( GroupConstructors, "RadioButton4" ); - RadioButton4->setText( tr( "" ) ); - RadioButton4->setPixmap( image3 ); - RBLayout->addWidget( RadioButton4); - GroupConstructorsLayout->addLayout( RBLayout, 0, 0 ); - SMESHGUI_SewingDlgLayout->addWidget( GroupConstructors, 0, 0 ); - - /***************************************************************/ - GroupButtons = new QGroupBox( this, "GroupButtons" ); - GroupButtons->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, GroupButtons->sizePolicy().hasHeightForWidth() ) ); - GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); - GroupButtons->setTitle( tr( "" ) ); - GroupButtons->setColumnLayout(0, Qt::Vertical ); - GroupButtons->layout()->setSpacing( 0 ); - GroupButtons->layout()->setMargin( 0 ); - GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); - GroupButtonsLayout->setAlignment( Qt::AlignTop ); - GroupButtonsLayout->setSpacing( 6 ); - GroupButtonsLayout->setMargin( 11 ); - buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); - buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) ); - buttonCancel->setAutoDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonCancel, 0, 3 ); - buttonApply = new QPushButton( GroupButtons, "buttonApply" ); - buttonApply->setText( tr( "SMESH_BUT_APPLY" ) ); - buttonApply->setAutoDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); - QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); - GroupButtonsLayout->addItem( spacer_9, 0, 2 ); - buttonOk = new QPushButton( GroupButtons, "buttonOk" ); - buttonOk->setText( tr( "SMESH_BUT_OK" ) ); - buttonOk->setAutoDefault( TRUE ); - buttonOk->setDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); - SMESHGUI_SewingDlgLayout->addWidget( GroupButtons, 2, 0 ); + GroupConstructors = new QButtonGroup(this, "GroupConstructors"); + GroupConstructors->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)5, + (QSizePolicy::SizeType)0, 0, 0, + GroupConstructors->sizePolicy().hasHeightForWidth())); + GroupConstructors->setTitle(tr("SMESH_SEWING")); + GroupConstructors->setExclusive(TRUE); + GroupConstructors->setColumnLayout(0, Qt::Vertical); + GroupConstructors->layout()->setSpacing(0); + GroupConstructors->layout()->setMargin(0); + GroupConstructorsLayout = new QGridLayout(GroupConstructors->layout()); + GroupConstructorsLayout->setAlignment(Qt::AlignTop); + GroupConstructorsLayout->setSpacing(6); + GroupConstructorsLayout->setMargin(11); + QHBoxLayout* RBLayout = new QHBoxLayout(0, 0, 6, "Layout2"); + RadioButton1= new QRadioButton(GroupConstructors, "RadioButton1"); + RadioButton1->setText(tr("" )); + RadioButton1->setPixmap(image0); + RBLayout->addWidget(RadioButton1); + RadioButton2= new QRadioButton(GroupConstructors, "RadioButton2"); + RadioButton2->setText(tr("" )); + RadioButton2->setPixmap(image1); + RBLayout->addWidget(RadioButton2); + RadioButton3= new QRadioButton(GroupConstructors, "RadioButton3"); + RadioButton3->setText(tr("" )); + RadioButton3->setPixmap(image2); + RBLayout->addWidget(RadioButton3); + RadioButton4= new QRadioButton(GroupConstructors, "RadioButton4"); + RadioButton4->setText(tr("" )); + RadioButton4->setPixmap(image3); + RBLayout->addWidget(RadioButton4); + GroupConstructorsLayout->addLayout(RBLayout, 0, 0); + SMESHGUI_SewingDlgLayout->addWidget(GroupConstructors, 0, 0); /***************************************************************/ - GroupArguments = new QGroupBox( this, "GroupArguments" ); - GroupArguments->setColumnLayout(0, Qt::Vertical ); - GroupArguments->layout()->setSpacing( 0 ); - GroupArguments->layout()->setMargin( 0 ); - GroupArgumentsLayout = new QGridLayout( GroupArguments->layout() ); - GroupArgumentsLayout->setAlignment( Qt::AlignTop ); - GroupArgumentsLayout->setSpacing( 6 ); - GroupArgumentsLayout->setMargin( 11 ); + GroupButtons = new QGroupBox(this, "GroupButtons"); + GroupButtons->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)7, + (QSizePolicy::SizeType)0, 0, 0, + GroupButtons->sizePolicy().hasHeightForWidth())); + GroupButtons->setGeometry(QRect(10, 10, 281, 48)); + GroupButtons->setTitle(tr("" )); + GroupButtons->setColumnLayout(0, Qt::Vertical); + GroupButtons->layout()->setSpacing(0); + GroupButtons->layout()->setMargin(0); + GroupButtonsLayout = new QGridLayout(GroupButtons->layout()); + GroupButtonsLayout->setAlignment(Qt::AlignTop); + GroupButtonsLayout->setSpacing(6); + GroupButtonsLayout->setMargin(11); + buttonCancel = new QPushButton(GroupButtons, "buttonCancel"); + buttonCancel->setText(tr("SMESH_BUT_CLOSE")); + buttonCancel->setAutoDefault(TRUE); + GroupButtonsLayout->addWidget(buttonCancel, 0, 3); + buttonApply = new QPushButton(GroupButtons, "buttonApply"); + buttonApply->setText(tr("SMESH_BUT_APPLY")); + buttonApply->setAutoDefault(TRUE); + GroupButtonsLayout->addWidget(buttonApply, 0, 1); + QSpacerItem* spacer_9 = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); + GroupButtonsLayout->addItem(spacer_9, 0, 2); + buttonOk = new QPushButton(GroupButtons, "buttonOk"); + buttonOk->setText(tr("SMESH_BUT_OK")); + buttonOk->setAutoDefault(TRUE); + buttonOk->setDefault(TRUE); + GroupButtonsLayout->addWidget(buttonOk, 0, 0); + SMESHGUI_SewingDlgLayout->addWidget(GroupButtons, 2, 0); + + /***************************************************************/ + GroupArguments = new QGroupBox(this, "GroupArguments"); + GroupArguments->setColumnLayout(0, Qt::Vertical); + GroupArguments->layout()->setSpacing(0); + GroupArguments->layout()->setMargin(0); + GroupArgumentsLayout = new QGridLayout(GroupArguments->layout()); + GroupArgumentsLayout->setAlignment(Qt::AlignTop); + GroupArgumentsLayout->setSpacing(6); + GroupArgumentsLayout->setMargin(11); // First subgroup - SubGroup1 = new QGroupBox( GroupArguments, "SubGroup1" ); - SubGroup1->setColumnLayout(0, Qt::Vertical ); - SubGroup1->layout()->setSpacing( 0 ); - SubGroup1->layout()->setMargin( 0 ); - QGridLayout* SubGroup1Layout = new QGridLayout( SubGroup1->layout() ); - SubGroup1Layout->setAlignment( Qt::AlignTop ); - SubGroup1Layout->setSpacing( 6 ); - SubGroup1Layout->setMargin( 11 ); - + SubGroup1 = new QGroupBox(GroupArguments, "SubGroup1"); + SubGroup1->setColumnLayout(0, Qt::Vertical); + SubGroup1->layout()->setSpacing(0); + SubGroup1->layout()->setMargin(0); + QGridLayout* SubGroup1Layout = new QGridLayout(SubGroup1->layout()); + SubGroup1Layout->setAlignment(Qt::AlignTop); + SubGroup1Layout->setSpacing(6); + SubGroup1Layout->setMargin(11); + // Controls of the first subgroup - TextLabel1 = new QLabel( SubGroup1, "TextLabel1" ); + TextLabel1 = new QLabel(SubGroup1, "TextLabel1"); TextLabel1->setFixedWidth(104); - SubGroup1Layout->addWidget( TextLabel1, 0, 0 ); - - SelectButton1 = new QPushButton( SubGroup1, "SelectButton1" ); - SelectButton1->setPixmap( image4 ); - SubGroup1Layout->addWidget( SelectButton1, 0, 1 ); - - LineEdit1 = new QLineEdit( SubGroup1, "LineEdit1" ); - SubGroup1Layout->addWidget( LineEdit1, 0, 2 ); - - TextLabel2 = new QLabel( SubGroup1, "TextLabel2" ); - SubGroup1Layout->addWidget( TextLabel2, 1, 0 ); - - SelectButton2 = new QPushButton( SubGroup1, "SelectButton2" ); - SelectButton2->setPixmap( image4 ); - SubGroup1Layout->addWidget( SelectButton2, 1, 1 ); - - LineEdit2 = new QLineEdit( SubGroup1, "LineEdit2" ); - SubGroup1Layout->addWidget( LineEdit2, 1, 2 ); + SubGroup1Layout->addWidget(TextLabel1, 0, 0); - TextLabel3 = new QLabel( SubGroup1, "TextLabel3" ); - SubGroup1Layout->addWidget( TextLabel3, 2, 0 ); - - SelectButton3 = new QPushButton( SubGroup1, "SelectButton3" ); - SelectButton3->setPixmap( image4 ); - SubGroup1Layout->addWidget( SelectButton3, 2, 1 ); - - LineEdit3 = new QLineEdit( SubGroup1, "LineEdit3" ); - SubGroup1Layout->addWidget( LineEdit3, 2, 2 ); + SelectButton1 = new QPushButton(SubGroup1, "SelectButton1"); + SelectButton1->setPixmap(image4); + SubGroup1Layout->addWidget(SelectButton1, 0, 1); + LineEdit1 = new QLineEdit(SubGroup1, "LineEdit1"); + SubGroup1Layout->addWidget(LineEdit1, 0, 2); + + TextLabel2 = new QLabel(SubGroup1, "TextLabel2"); + SubGroup1Layout->addWidget(TextLabel2, 1, 0); + + SelectButton2 = new QPushButton(SubGroup1, "SelectButton2"); + SelectButton2->setPixmap(image4); + SubGroup1Layout->addWidget(SelectButton2, 1, 1); + + LineEdit2 = new QLineEdit(SubGroup1, "LineEdit2"); + SubGroup1Layout->addWidget(LineEdit2, 1, 2); + + TextLabel3 = new QLabel(SubGroup1, "TextLabel3"); + SubGroup1Layout->addWidget(TextLabel3, 2, 0); + + SelectButton3 = new QPushButton(SubGroup1, "SelectButton3"); + SelectButton3->setPixmap(image4); + SubGroup1Layout->addWidget(SelectButton3, 2, 1); + + LineEdit3 = new QLineEdit(SubGroup1, "LineEdit3"); + SubGroup1Layout->addWidget(LineEdit3, 2, 2); // Second subgroup - SubGroup2 = new QGroupBox( GroupArguments, "SubGroup2" ); - SubGroup2->setColumnLayout(0, Qt::Vertical ); - SubGroup2->layout()->setSpacing( 0 ); - SubGroup2->layout()->setMargin( 0 ); - QGridLayout* SubGroup2Layout = new QGridLayout( SubGroup2->layout() ); - SubGroup2Layout->setAlignment( Qt::AlignTop ); - SubGroup2Layout->setSpacing( 6 ); - SubGroup2Layout->setMargin( 11 ); - + SubGroup2 = new QGroupBox(GroupArguments, "SubGroup2"); + SubGroup2->setColumnLayout(0, Qt::Vertical); + SubGroup2->layout()->setSpacing(0); + SubGroup2->layout()->setMargin(0); + QGridLayout* SubGroup2Layout = new QGridLayout(SubGroup2->layout()); + SubGroup2Layout->setAlignment(Qt::AlignTop); + SubGroup2Layout->setSpacing(6); + SubGroup2Layout->setMargin(11); + // Controls of the first subgroup - TextLabel4 = new QLabel( SubGroup2, "TextLabel4" ); - SubGroup2Layout->addWidget( TextLabel4, 0, 0 ); - - SelectButton4 = new QPushButton( SubGroup2, "SelectButton4" ); - SelectButton4->setPixmap( image4 ); - SubGroup2Layout->addWidget( SelectButton4, 0, 1 ); - - LineEdit4 = new QLineEdit( SubGroup2, "LineEdit4" ); - SubGroup2Layout->addWidget( LineEdit4, 0, 2 ); - - TextLabel5 = new QLabel( SubGroup2, "TextLabel5" ); - SubGroup2Layout->addWidget( TextLabel5, 1, 0 ); - - SelectButton5 = new QPushButton( SubGroup2, "SelectButton5" ); - SelectButton5->setPixmap( image4 ); - SubGroup2Layout->addWidget( SelectButton5, 1, 1 ); - - LineEdit5 = new QLineEdit( SubGroup2, "LineEdit5" ); - SubGroup2Layout->addWidget( LineEdit5, 1, 2 ); + TextLabel4 = new QLabel(SubGroup2, "TextLabel4"); + SubGroup2Layout->addWidget(TextLabel4, 0, 0); - TextLabel6 = new QLabel( SubGroup2, "TextLabel6" ); - SubGroup2Layout->addWidget( TextLabel6, 2, 0 ); - - SelectButton6 = new QPushButton( SubGroup2, "SelectButton6" ); - SelectButton6->setPixmap( image4 ); - SubGroup2Layout->addWidget( SelectButton6, 2, 1 ); - - LineEdit6 = new QLineEdit( SubGroup2, "LineEdit6" ); - SubGroup2Layout->addWidget( LineEdit6, 2, 2 ); + SelectButton4 = new QPushButton(SubGroup2, "SelectButton4"); + SelectButton4->setPixmap(image4); + SubGroup2Layout->addWidget(SelectButton4, 0, 1); + + LineEdit4 = new QLineEdit(SubGroup2, "LineEdit4"); + SubGroup2Layout->addWidget(LineEdit4, 0, 2); + + TextLabel5 = new QLabel(SubGroup2, "TextLabel5"); + SubGroup2Layout->addWidget(TextLabel5, 1, 0); + + SelectButton5 = new QPushButton(SubGroup2, "SelectButton5"); + SelectButton5->setPixmap(image4); + SubGroup2Layout->addWidget(SelectButton5, 1, 1); + + LineEdit5 = new QLineEdit(SubGroup2, "LineEdit5"); + SubGroup2Layout->addWidget(LineEdit5, 1, 2); + + TextLabel6 = new QLabel(SubGroup2, "TextLabel6"); + SubGroup2Layout->addWidget(TextLabel6, 2, 0); + + SelectButton6 = new QPushButton(SubGroup2, "SelectButton6"); + SelectButton6->setPixmap(image4); + SubGroup2Layout->addWidget(SelectButton6, 2, 1); + + LineEdit6 = new QLineEdit(SubGroup2, "LineEdit6"); + SubGroup2Layout->addWidget(LineEdit6, 2, 2); - // Add subgroups to the group of arguments - GroupArgumentsLayout->addWidget( SubGroup1, 0, 0 ); - GroupArgumentsLayout->addWidget( SubGroup2, 1, 0 ); + GroupArgumentsLayout->addWidget(SubGroup1, 0, 0); + GroupArgumentsLayout->addWidget(SubGroup2, 1, 0); // Control for the merging equal elements - CheckBoxMerge = new QCheckBox( GroupArguments, "CheckBoxMerge" ); - CheckBoxMerge->setText( tr( "MERGE_EQUAL_ELEMENTS" ) ); - GroupArgumentsLayout->addWidget( CheckBoxMerge, 2, 0 ); - + CheckBoxMerge = new QCheckBox(GroupArguments, "CheckBoxMerge"); + CheckBoxMerge->setText(tr("MERGE_EQUAL_ELEMENTS" )); + GroupArgumentsLayout->addWidget(CheckBoxMerge, 2, 0); - SMESHGUI_SewingDlgLayout->addWidget( GroupArguments, 1, 0 ); +// Control for the polygons creation instead of splitting + CheckBoxPolygons = new QCheckBox( GroupArguments, "CheckBoxPolygons" ); + CheckBoxPolygons->setText( tr( "CREATE_POLYGONS_INSTEAD_SPLITTING" ) ); + GroupArgumentsLayout->addWidget( CheckBoxPolygons, 3, 0 ); + // Control for the polyedres creation to obtain conform mesh + CheckBoxPolyedrs = new QCheckBox( GroupArguments, "CheckBoxPolyedrs" ); + CheckBoxPolyedrs->setText( tr( "CREATE_POLYEDRS_NEAR_BOUNDARY" ) ); + GroupArgumentsLayout->addWidget( CheckBoxPolyedrs, 4, 0 ); + + + SMESHGUI_SewingDlgLayout->addWidget(GroupArguments, 1, 0); + /* Initialisations */ GroupArguments->show(); - RadioButton1->setChecked( TRUE ); - mySelection = Sel; - - LineEdit2->setValidator( new SMESHGUI_IdValidator( this, "validator", 1)); - LineEdit3->setValidator( new SMESHGUI_IdValidator( this, "validator", 1)); - LineEdit5->setValidator( new SMESHGUI_IdValidator( this, "validator", 1)); - LineEdit6->setValidator( new SMESHGUI_IdValidator( this, "validator", 1)); - - mySMESHGUI = SMESHGUI::GetSMESHGUI() ; - mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; + RadioButton1->setChecked(TRUE); + + LineEdit2->setValidator(new SMESHGUI_IdValidator(this, "validator", 1)); + LineEdit3->setValidator(new SMESHGUI_IdValidator(this, "validator", 1)); + LineEdit5->setValidator(new SMESHGUI_IdValidator(this, "validator", 1)); + LineEdit6->setValidator(new SMESHGUI_IdValidator(this, "validator", 1)); + + mySMESHGUI->SetActiveDialogBox((QDialog*)this); Init(); + /* signals and slots connections */ - connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); - connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ; - connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) ); - connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) ); - - connect( SelectButton1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; - connect( SelectButton2, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; - connect( SelectButton3, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; - connect( SelectButton4, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; - connect( SelectButton5, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; - connect( SelectButton6, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel())); + connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); + connect(GroupConstructors, SIGNAL(clicked(int)), SLOT(ConstructorsClicked(int))); - connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; - connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + connect(SelectButton1, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument())); + connect(SelectButton2, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument())); + connect(SelectButton3, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument())); + connect(SelectButton4, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument())); + connect(SelectButton5, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument())); + connect(SelectButton6, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument())); + + connect(mySMESHGUI, SIGNAL (SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog())); + connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); /* to close dialog if study change */ - connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; + connect(mySMESHGUI, SIGNAL (SignalCloseAllDialogs()), this, SLOT(ClickOnCancel())); + + connect(LineEdit1, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&))); + connect(LineEdit2, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&))); + connect(LineEdit3, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&))); + connect(LineEdit4, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&))); + connect(LineEdit5, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&))); + connect(LineEdit6, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&))); - connect( LineEdit1, SIGNAL( textChanged( const QString& )), SLOT( onTextChange( const QString& ))); - connect( LineEdit2, SIGNAL( textChanged( const QString& )), SLOT( onTextChange( const QString& ))); - connect( LineEdit3, SIGNAL( textChanged( const QString& )), SLOT( onTextChange( const QString& ))); - connect( LineEdit4, SIGNAL( textChanged( const QString& )), SLOT( onTextChange( const QString& ))); - connect( LineEdit5, SIGNAL( textChanged( const QString& )), SLOT( onTextChange( const QString& ))); - connect( LineEdit6, SIGNAL( textChanged( const QString& )), SLOT( onTextChange( const QString& ))); - /* Move widget on the botton right corner of main widget */ - int x, y ; - mySMESHGUI->DefineDlgPosition( this, x, y ) ; - this->move( x, y ) ; - this->show() ; /* displays Dialog */ - + int x, y; + mySMESHGUI->DefineDlgPosition(this, x, y); + this->move(x, y); + this->show(); /* displays Dialog */ + ConstructorsClicked(0); resize(0,0); } @@ -306,7 +331,6 @@ SMESHGUI_SewingDlg::~SMESHGUI_SewingDlg() // no need to delete child widgets, Qt does it all for us } - //================================================================================= // function : Init() // purpose : @@ -317,21 +341,22 @@ void SMESHGUI_SewingDlg::Init() myEditCurrentArgument = LineEdit1; LineEdit1->setFocus(); - myActor = 0; + myActor = 0; myMesh = SMESH::SMESH_Mesh::_nil(); CheckBoxMerge->setChecked(false); + CheckBoxPolygons->setChecked(false); + CheckBoxPolyedrs->setChecked(false); SelectionIntoArgument(); } - //================================================================================= // function : ConstructorsClicked() // purpose : Radio button management //================================================================================= -void SMESHGUI_SewingDlg::ConstructorsClicked(int constructorId) +void SMESHGUI_SewingDlg::ConstructorsClicked (int constructorId) { - disconnect(mySelection, 0, this, 0); - mySelection->ClearIObjects(); + disconnect(mySelectionMgr, 0, this, 0); + mySelectionMgr->clearSelected(); LineEdit1->setText(""); LineEdit2->setText(""); LineEdit3->setText(""); @@ -341,99 +366,114 @@ void SMESHGUI_SewingDlg::ConstructorsClicked(int constructorId) myOk1 = myOk2 = myOk3 = myOk4 = myOk5 = myOk6 = false; myEditCurrentArgument = LineEdit1; myEditCurrentArgument->setFocus(); - - if (!TextLabel5->isEnabled()) + + if (!TextLabel5->isEnabled()) { + TextLabel5->setEnabled(true); + SelectButton5->setEnabled(true); + LineEdit5->setEnabled(true); + } else if (!TextLabel6->isEnabled()) { + TextLabel6->setEnabled(true); + SelectButton6->setEnabled(true); + LineEdit6->setEnabled(true); + } + + if (constructorId == 1 || constructorId == 3) { + if (CheckBoxPolygons->isVisible()) + CheckBoxPolygons->hide(); + if (CheckBoxPolyedrs->isVisible()) + CheckBoxPolyedrs->hide(); + } + + switch (constructorId) { + case 0: { - TextLabel5->setEnabled(true); - SelectButton5->setEnabled(true); - LineEdit5->setEnabled(true); + GroupArguments->setTitle(tr("SEW_FREE_BORDERS")); + SubGroup1->setTitle(tr("BORDER_1")); + SubGroup2->setTitle(tr("BORDER_2")); + + if (!CheckBoxPolygons->isVisible()) + CheckBoxPolygons->show(); + if (!CheckBoxPolyedrs->isVisible()) + CheckBoxPolyedrs->show(); + + + break; } - else if (!TextLabel6->isEnabled()) + case 1: { - TextLabel6->setEnabled(true); - SelectButton6->setEnabled(true); - LineEdit6->setEnabled(true); + GroupArguments->setTitle(tr("SEW_CONFORM_FREE_BORDERS")); + SubGroup1->setTitle(tr("BORDER_1")); + SubGroup2->setTitle(tr("BORDER_2")); + + TextLabel6->setEnabled(false); + SelectButton6->setEnabled(false); + LineEdit6->setEnabled(false); + + myOk6 = true; + + break; } - - switch(constructorId) + case 2: { - case 0 : - { - GroupArguments->setTitle( tr( "SEW_FREE_BORDERS" ) ); - SubGroup1->setTitle( tr( "BORDER_1" ) ); - SubGroup2->setTitle( tr( "BORDER_2" ) ); - - break; - } - case 1 : - { - GroupArguments->setTitle( tr( "SEW_CONFORM_FREE_BORDERS" ) ); - SubGroup1->setTitle( tr( "BORDER_1" ) ); - SubGroup2->setTitle( tr( "BORDER_2" ) ); - - TextLabel6->setEnabled(false); - SelectButton6->setEnabled(false); - LineEdit6->setEnabled(false); - - myOk6 = true; - - break; - } - case 2 : - { - GroupArguments->setTitle( tr( "SEW_BORDER_TO_SIDE" ) ); - SubGroup1->setTitle( tr( "BORDER" ) ); - SubGroup2->setTitle( tr( "SIDE" ) ); + GroupArguments->setTitle(tr("SEW_BORDER_TO_SIDE")); + SubGroup1->setTitle(tr("BORDER")); + SubGroup2->setTitle(tr("SIDE")); - TextLabel5->setEnabled(false); - SelectButton5->setEnabled(false); - LineEdit5->setEnabled(false); - - myOk5 = true; + TextLabel5->setEnabled(false); + SelectButton5->setEnabled(false); + LineEdit5->setEnabled(false); - break; - } - case 3 : - { - GroupArguments->setTitle( tr( "SEW_SIDE_ELEMENTS" ) ); - SubGroup1->setTitle( tr( "SIDE_1" ) ); - SubGroup2->setTitle( tr( "SIDE_2" ) ); - - TextLabel1->setText( tr( "SMESH_ID_ELEMENTS" ) ); - TextLabel2->setText( tr( "NODE1_TO_MERGE" ) ); - TextLabel3->setText( tr( "NODE2_TO_MERGE" ) ); - TextLabel4->setText( tr( "SMESH_ID_ELEMENTS" ) ); - TextLabel5->setText( tr( "NODE1_TO_MERGE" ) ); - TextLabel6->setText( tr( "NODE2_TO_MERGE" ) ); - - LineEdit1->setValidator( new SMESHGUI_IdValidator( this, "validator")); - LineEdit4->setValidator( new SMESHGUI_IdValidator( this, "validator")); - - SMESH::SetPointRepresentation(false); - QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true ); - break; - } - } - - if (constructorId != 3) - { - TextLabel1->setText( tr( "FIRST_NODE_ID" ) ); - TextLabel2->setText( tr( "SECOND_NODE_ID" ) ); - TextLabel3->setText( tr( "LAST_NODE_ID" ) ); - TextLabel4->setText( tr( "FIRST_NODE_ID" ) ); - TextLabel5->setText( tr( "SECOND_NODE_ID" ) ); - TextLabel6->setText( tr( "LAST_NODE_ID" ) ); + if (!CheckBoxPolygons->isVisible()) + CheckBoxPolygons->show(); + if (!CheckBoxPolyedrs->isVisible()) + CheckBoxPolyedrs->show(); - LineEdit1->setValidator( new SMESHGUI_IdValidator( this, "validator", 1)); - LineEdit4->setValidator( new SMESHGUI_IdValidator( this, "validator", 1)); - SMESH::SetPointRepresentation(true); - QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true ); + myOk5 = true; + + break; } - - connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); -} + case 3: + { + GroupArguments->setTitle(tr("SEW_SIDE_ELEMENTS")); + SubGroup1->setTitle(tr("SIDE_1")); + SubGroup2->setTitle(tr("SIDE_2")); + TextLabel1->setText(tr("SMESH_ID_ELEMENTS")); + TextLabel2->setText(tr("NODE1_TO_MERGE")); + TextLabel3->setText(tr("NODE2_TO_MERGE")); + TextLabel4->setText(tr("SMESH_ID_ELEMENTS")); + TextLabel5->setText(tr("NODE1_TO_MERGE")); + TextLabel6->setText(tr("NODE2_TO_MERGE")); + + LineEdit1->setValidator(new SMESHGUI_IdValidator(this, "validator")); + LineEdit4->setValidator(new SMESHGUI_IdValidator(this, "validator")); + + SMESH::SetPointRepresentation(false); + + myViewWindow->SetSelectionMode(CellSelection); + break; + } + } + + if (constructorId != 3) { + TextLabel1->setText(tr("FIRST_NODE_ID")); + TextLabel2->setText(tr("SECOND_NODE_ID")); + TextLabel3->setText(tr("LAST_NODE_ID")); + TextLabel4->setText(tr("FIRST_NODE_ID")); + TextLabel5->setText(tr("SECOND_NODE_ID")); + TextLabel6->setText(tr("LAST_NODE_ID")); + + LineEdit1->setValidator(new SMESHGUI_IdValidator(this, "validator", 1)); + LineEdit4->setValidator(new SMESHGUI_IdValidator(this, "validator", 1)); + + SMESH::SetPointRepresentation(true); + + myViewWindow->SetSelectionMode(NodeSelection); + } + + connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); +} //================================================================================= // function : ClickOnApply() @@ -441,93 +481,96 @@ void SMESHGUI_SewingDlg::ConstructorsClicked(int constructorId) //================================================================================= bool SMESHGUI_SewingDlg::ClickOnApply() { - if (mySMESHGUI->ActiveStudyLocked()) + if (mySMESHGUI->isActiveStudyLocked()) return false; - + bool aResult = false; - if ( IsValid() ) - { - bool toMerge = CheckBoxMerge->isChecked(); - - try - { - SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor(); - QApplication::setOverrideCursor(Qt::waitCursor); - - int aConstructorId = GetConstructorId(); - SMESH::SMESH_MeshEditor::Sew_Error anError; - - if (aConstructorId == 0) - anError = aMeshEditor->SewFreeBorders(LineEdit1->text().toLong(), - LineEdit2->text().toLong(), - LineEdit3->text().toLong(), - LineEdit4->text().toLong(), - LineEdit5->text().toLong(), - LineEdit6->text().toLong()); - else if (aConstructorId == 1) - anError = aMeshEditor->SewConformFreeBorders(LineEdit1->text().toLong(), - LineEdit2->text().toLong(), - LineEdit3->text().toLong(), - LineEdit4->text().toLong(), - LineEdit5->text().toLong()); - else if (aConstructorId == 2) - anError = aMeshEditor->SewBorderToSide(LineEdit1->text().toLong(), - LineEdit2->text().toLong(), - LineEdit3->text().toLong(), - LineEdit4->text().toLong(), - LineEdit6->text().toLong()); - else if (aConstructorId == 3) - { - QStringList aListElementsId1 = QStringList::split( " ", LineEdit1->text(), false); - QStringList aListElementsId2 = QStringList::split( " ", LineEdit4->text(), false); - - SMESH::long_array_var anElementsId1 = new SMESH::long_array; - SMESH::long_array_var anElementsId2 = new SMESH::long_array; - - anElementsId1->length( aListElementsId1.count() ); - anElementsId2->length( aListElementsId2.count() ); + if (IsValid()) { + bool toMerge = CheckBoxMerge->isChecked(); + bool toCreatePolygons = CheckBoxPolygons->isChecked(); + bool toCreatePolyedrs = CheckBoxPolyedrs->isChecked(); - for ( int i = 0; i < aListElementsId1.count(); i++ ) - anElementsId1[i] = aListElementsId1[i].toInt(); - for ( int i = 0; i < aListElementsId2.count(); i++ ) - anElementsId2[i] = aListElementsId2[i].toInt(); + try { + SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor(); + QApplication::setOverrideCursor(Qt::waitCursor); - anError = aMeshEditor->SewSideElements(anElementsId1.inout(), - anElementsId2.inout(), - LineEdit2->text().toLong(), - LineEdit5->text().toLong(), - LineEdit3->text().toLong(), - LineEdit6->text().toLong()); - } - aResult = ( anError == SMESH::SMESH_MeshEditor::SEW_OK ); + int aConstructorId = GetConstructorId(); + SMESH::SMESH_MeshEditor::Sew_Error anError; - if (toMerge && aResult) - aMeshEditor->MergeEqualElements(); - - QApplication::restoreOverrideCursor(); + if (aConstructorId == 0) + anError = aMeshEditor->SewFreeBorders(LineEdit1->text().toLong(), + LineEdit2->text().toLong(), + LineEdit3->text().toLong(), + LineEdit4->text().toLong(), + LineEdit5->text().toLong(), + LineEdit6->text().toLong(), + toCreatePolygons, + toCreatePolyedrs); + else if (aConstructorId == 1) + anError = aMeshEditor->SewConformFreeBorders(LineEdit1->text().toLong(), + LineEdit2->text().toLong(), + LineEdit3->text().toLong(), + LineEdit4->text().toLong(), + LineEdit5->text().toLong()); + else if (aConstructorId == 2) + anError = aMeshEditor->SewBorderToSide(LineEdit1->text().toLong(), + LineEdit2->text().toLong(), + LineEdit3->text().toLong(), + LineEdit4->text().toLong(), + LineEdit6->text().toLong(), + toCreatePolygons, + toCreatePolyedrs); + else if (aConstructorId == 3) { + QStringList aListElementsId1 = QStringList::split(" ", LineEdit1->text(), false); + QStringList aListElementsId2 = QStringList::split(" ", LineEdit4->text(), false); - if ( !aResult ) { - QString msg = tr(QString("ERROR_%1").arg(anError)); - QAD_MessageBox::warn1(QAD_Application::getDesktop(), - tr("SMESH_WRN_WARNING"),msg,tr("SMESH_BUT_OK")); - } - } - catch( ... ) - { - } - - if ( aResult ) - { - Handle(SALOME_InteractiveObject) anIO = myActor->getIO(); - mySelection->ClearIObjects(); - SMESH::UpdateView(); - mySelection->AddIObject( anIO, false ); - Init(); - ConstructorsClicked(GetConstructorId()); - } + SMESH::long_array_var anElementsId1 = new SMESH::long_array; + SMESH::long_array_var anElementsId2 = new SMESH::long_array; + + anElementsId1->length(aListElementsId1.count()); + anElementsId2->length(aListElementsId2.count()); + + for (int i = 0; i < aListElementsId1.count(); i++) + anElementsId1[i] = aListElementsId1[i].toInt(); + for (int i = 0; i < aListElementsId2.count(); i++) + anElementsId2[i] = aListElementsId2[i].toInt(); + + anError = aMeshEditor->SewSideElements(anElementsId1.inout(), + anElementsId2.inout(), + LineEdit2->text().toLong(), + LineEdit5->text().toLong(), + LineEdit3->text().toLong(), + LineEdit6->text().toLong()); + } + aResult = (anError == SMESH::SMESH_MeshEditor::SEW_OK); + + if (toMerge && aResult) + aMeshEditor->MergeEqualElements(); + + QApplication::restoreOverrideCursor(); + + if (!aResult) { + QString msg = tr(QString("ERROR_%1").arg(anError)); + SUIT_MessageBox::warn1(SMESHGUI::desktop(), tr("SMESH_WRN_WARNING"), + msg, tr("SMESH_BUT_OK")); + } + } catch (...) { } + if (aResult) { + Handle(SALOME_InteractiveObject) anIO = myActor->getIO(); + + SALOME_ListIO aList; + aList.Append(anIO); + mySelectionMgr->setSelectedObjects(aList, false); + SMESH::UpdateView(); + + Init(); + ConstructorsClicked(GetConstructorId()); + } + } + return aResult; } @@ -537,40 +580,38 @@ bool SMESHGUI_SewingDlg::ClickOnApply() //================================================================================= void SMESHGUI_SewingDlg::ClickOnOk() { - if( ClickOnApply()) - ClickOnCancel() ; + if (ClickOnApply()) + ClickOnCancel(); } - //================================================================================= // function : ClickOnCancel() // purpose : //================================================================================= void SMESHGUI_SewingDlg::ClickOnCancel() { - mySelection->ClearIObjects(); + mySelectionMgr->clearSelected(); SMESH::SetPointRepresentation(false); - QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); - disconnect( mySelection, 0, this, 0 ); - mySMESHGUI->ResetState() ; - reject() ; + myViewWindow->SetSelectionMode(ActorSelection); + disconnect(mySelectionMgr, 0, this, 0); + mySMESHGUI->ResetState(); + reject(); } //======================================================================= //function : onTextChange -//purpose : +//purpose : //======================================================================= - -void SMESHGUI_SewingDlg::onTextChange(const QString& theNewText) +void SMESHGUI_SewingDlg::onTextChange (const QString& theNewText) { QLineEdit* send = (QLineEdit*)sender(); - if ( myBusy ) return; + if (myBusy) return; myBusy = true; if (send) myEditCurrentArgument = send; - + if (send == LineEdit1) myOk1 = false; else if (send == LineEdit2) @@ -584,163 +625,179 @@ void SMESHGUI_SewingDlg::onTextChange(const QString& theNewText) else if (send == LineEdit6) myOk6 = false; - buttonOk->setEnabled( false ); - buttonApply->setEnabled( false ); - + buttonOk->setEnabled(false); + buttonApply->setEnabled(false); + // hilight entered elements/nodes SMDS_Mesh* aMesh = 0; - - if ( myActor ) + + if (myActor) aMesh = myActor->GetObject()->GetMesh(); else send->clear(); - - if ( aMesh ) { - mySelection->ClearIObjects(); - mySelection->AddIObject( myActor->getIO() ); - - if (GetConstructorId() != 3 || (send != LineEdit1 && send != LineEdit4)) - { - SMESH::SetPointRepresentation(true); - QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true ); - - const SMDS_MeshNode * n = aMesh->FindNode( theNewText.toInt() ); - if ( n ) { - if ( !mySelection->IsIndexSelected( myActor->getIO(), n->GetID() )) - mySelection->AddOrRemoveIndex (myActor->getIO(), n->GetID(), true); - - if (send == LineEdit1) - myOk1 = true; - else if (send == LineEdit2) - myOk2 = true; - else if (send == LineEdit3) - myOk3 = true; - else if (send == LineEdit4) - myOk4 = true; - else if (send == LineEdit5) - myOk5 = true; - else if (send == LineEdit6) - myOk6 = true; - } + + if (aMesh) { + //mySelectionMgr->clearSelected(); + //mySelectionMgr->AddIObject(myActor->getIO()); + SALOME_ListIO aList; + aList.Append(myActor->getIO()); + mySelectionMgr->setSelectedObjects(aList, false); + + TColStd_IndexedMapOfInteger selectedIndices; + TColStd_MapOfInteger newIndices; + mySelector->GetIndex( myActor->getIO(), selectedIndices); + + if (GetConstructorId() != 3 || (send != LineEdit1 && send != LineEdit4)) { + SMESH::SetPointRepresentation(true); + + myViewWindow->SetSelectionMode(NodeSelection); + + const SMDS_MeshNode * n = aMesh->FindNode(theNewText.toInt()); + if (n) { + //if (!mySelectionMgr->IsIndexSelected(myActor->getIO(), n->GetID())) { + if (selectedIndices.Add(n->GetID())) { + //mySelectionMgr->AddOrRemoveIndex (myActor->getIO(), n->GetID(), true); + newIndices.Add(n->GetID()); + mySelector->AddOrRemoveIndex(myActor->getIO(), newIndices, true); + myViewWindow->highlight( myActor->getIO(), true, true ); + } + + if (send == LineEdit1) + myOk1 = true; + else if (send == LineEdit2) + myOk2 = true; + else if (send == LineEdit3) + myOk3 = true; + else if (send == LineEdit4) + myOk4 = true; + else if (send == LineEdit5) + myOk5 = true; + else if (send == LineEdit6) + myOk6 = true; } - else - { - SMESH::SetPointRepresentation(false); - QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true ); - - QStringList aListId = QStringList::split( " ", theNewText, false); - - bool isEvenOneExists = false; - - for ( int i = 0; i < aListId.count(); i++ ) { - const SMDS_MeshElement * e = aMesh->FindElement( aListId[ i ].toInt() ); - if ( e ) { - if ( !mySelection->IsIndexSelected( myActor->getIO(), e->GetID() )) - mySelection->AddOrRemoveIndex (myActor->getIO(), e->GetID(), true); - if (!isEvenOneExists) - isEvenOneExists = true; - } - } - - if (isEvenOneExists) - { - if (send == LineEdit1) - myOk1 = true; - else if(send == LineEdit4) - myOk4 = true; - } - else - send->clear(); + } else { + SMESH::SetPointRepresentation(false); + + myViewWindow->SetSelectionMode(CellSelection); + + QStringList aListId = QStringList::split(" ", theNewText, false); + + bool isEvenOneExists = false; + + for (int i = 0; i < aListId.count(); i++) { + const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt()); + if (e) { + //if (!mySelectionMgr->IsIndexSelected(myActor->getIO(), e->GetID())) { + if (selectedIndices.Add(e->GetID())) { + //mySelectionMgr->AddOrRemoveIndex (myActor->getIO(), e->GetID(), true); + newIndices.Add(e->GetID()); + } + if (!isEvenOneExists) + isEvenOneExists = true; + } } + + if (newIndices.Extent() > 0) + { + mySelector->AddOrRemoveIndex(myActor->getIO(), newIndices, true); + myViewWindow->highlight( myActor->getIO(), true, true ); + } + + if (isEvenOneExists) { + if (send == LineEdit1) + myOk1 = true; + else if(send == LineEdit4) + myOk4 = true; + } else { + send->clear(); + } + } } - - if ( IsValid() ) { - buttonOk->setEnabled( true ); - buttonApply->setEnabled( true ); + + if (IsValid()) { + buttonOk->setEnabled(true); + buttonApply->setEnabled(true); } - + myBusy = false; } - //================================================================================= // function : SelectionIntoArgument() // purpose : Called when selection as changed or other case //================================================================================= -void SMESHGUI_SewingDlg::SelectionIntoArgument(bool isSelectionChanged) +void SMESHGUI_SewingDlg::SelectionIntoArgument (bool isSelectionChanged) { - if ( myBusy ) return; - + if (myBusy) return; + // clear if (isSelectionChanged) myActor = 0; - + QString aString = ""; - + myBusy = true; - myEditCurrentArgument->setText( aString ); + myEditCurrentArgument->setText(aString); myBusy = false; - - if ( !GroupButtons->isEnabled() ) // inactive + + if (!GroupButtons->isEnabled()) // inactive return; - - buttonOk->setEnabled( false ); - buttonApply->setEnabled( false ); - + + buttonOk->setEnabled(false); + buttonApply->setEnabled(false); + // get selected mesh - int nbSel = mySelection->IObjectCount(); - if(nbSel != 1) + SALOME_ListIO aList; + mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type()); + + int nbSel = aList.Extent(); + if (nbSel != 1) return; - - Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject(); - myMesh = SMESH::IObjectToInterface(IO) ; - myActor = SMESH::FindActorByEntry( mySelection->firstIObject()->getEntry() ); - + + Handle(SALOME_InteractiveObject) IO = aList.First(); + myMesh = SMESH::IObjectToInterface(IO); + myActor = SMESH::FindActorByEntry(aList.First()->getEntry()); + if (myMesh->_is_nil() || !myActor) return; - + // get selected elements/nodes - int aNbUnits = 0; - - if (GetConstructorId() != 3 || (myEditCurrentArgument != LineEdit1 && myEditCurrentArgument != LineEdit4)) - { - aNbUnits = SMESH::GetNameOfSelectedNodes(mySelection, aString); - if(aNbUnits != 1) - return; - } - else - { - aNbUnits = SMESH::GetNameOfSelectedElements(mySelection, aString); - if(aNbUnits < 1) - return; - } - + + if (GetConstructorId() != 3 || + (myEditCurrentArgument != LineEdit1 && myEditCurrentArgument != LineEdit4)) { + aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, myActor->getIO(), aString); + if (aNbUnits != 1) + return; + } else { + aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, myActor->getIO(), aString); + if (aNbUnits < 1) + return; + } + myBusy = true; - myEditCurrentArgument->setText( aString ); + myEditCurrentArgument->setText(aString); myBusy = false; - + // OK if (myEditCurrentArgument == LineEdit1) myOk1 = true; - else if(myEditCurrentArgument == LineEdit2) + else if (myEditCurrentArgument == LineEdit2) myOk2 = true; - else if(myEditCurrentArgument == LineEdit3) + else if (myEditCurrentArgument == LineEdit3) myOk3 = true; - else if(myEditCurrentArgument == LineEdit4) + else if (myEditCurrentArgument == LineEdit4) myOk4 = true; - else if(myEditCurrentArgument == LineEdit5) + else if (myEditCurrentArgument == LineEdit5) myOk5 = true; - else if(myEditCurrentArgument == LineEdit6) + else if (myEditCurrentArgument == LineEdit6) myOk6 = true; - - if(IsValid()) - { - buttonOk->setEnabled( true ); - buttonApply->setEnabled( true ); - } -} + if (IsValid()) { + buttonOk->setEnabled(true); + buttonApply->setEnabled(true); + } +} //================================================================================= // function : SetEditCurrentArgument() @@ -749,11 +806,11 @@ void SMESHGUI_SewingDlg::SelectionIntoArgument(bool isSelectionChanged) void SMESHGUI_SewingDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); - - disconnect( mySelection, 0, this, 0 ); - mySelection->ClearIObjects(); - - if(send == SelectButton1) { + + disconnect(mySelectionMgr, 0, this, 0); + mySelectionMgr->clearSelected(); + + if (send == SelectButton1) { myEditCurrentArgument = LineEdit1; myOk1 = false; } @@ -777,21 +834,20 @@ void SMESHGUI_SewingDlg::SetEditCurrentArgument() myEditCurrentArgument = LineEdit6; myOk6 = false; } - - if (GetConstructorId() != 3 || (send != SelectButton1 && send != SelectButton4)) - { - SMESH::SetPointRepresentation(true); - QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true ); - } - else - { - SMESH::SetPointRepresentation(false); - QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true ); - } - + + if (GetConstructorId() != 3 || (send != SelectButton1 && send != SelectButton4)) { + SMESH::SetPointRepresentation(true); + + myViewWindow->SetSelectionMode(NodeSelection); + + } else { + SMESH::SetPointRepresentation(false); + myViewWindow->SetSelectionMode(CellSelection); + } + myEditCurrentArgument->setFocus(); - connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); - SelectionIntoArgument(false) ; + connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + SelectionIntoArgument(false); } //================================================================================= @@ -800,16 +856,15 @@ void SMESHGUI_SewingDlg::SetEditCurrentArgument() //================================================================================= void SMESHGUI_SewingDlg::DeactivateActiveDialog() { - if ( GroupConstructors->isEnabled() ) { - GroupConstructors->setEnabled(false) ; - GroupArguments->setEnabled(false) ; - GroupButtons->setEnabled(false) ; - mySMESHGUI->ResetState() ; - mySMESHGUI->SetActiveDialogBox(0) ; + if (GroupConstructors->isEnabled()) { + GroupConstructors->setEnabled(false); + GroupArguments->setEnabled(false); + GroupButtons->setEnabled(false); + mySMESHGUI->ResetState(); + mySMESHGUI->SetActiveDialogBox(0); } } - //================================================================================= // function : ActivateThisDialog() // purpose : @@ -817,68 +872,61 @@ void SMESHGUI_SewingDlg::DeactivateActiveDialog() void SMESHGUI_SewingDlg::ActivateThisDialog() { /* Emit a signal to deactivate the active dialog */ - mySMESHGUI->EmitSignalDeactivateDialog() ; - GroupConstructors->setEnabled(true) ; - GroupArguments->setEnabled(true) ; - GroupButtons->setEnabled(true) ; - - mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; - + mySMESHGUI->EmitSignalDeactivateDialog(); + GroupConstructors->setEnabled(true); + GroupArguments->setEnabled(true); + GroupButtons->setEnabled(true); + + mySMESHGUI->SetActiveDialogBox((QDialog*)this); + ConstructorsClicked(GetConstructorId()); SelectionIntoArgument(); } - //================================================================================= // function : enterEvent() // purpose : //================================================================================= -void SMESHGUI_SewingDlg::enterEvent(QEvent* e) +void SMESHGUI_SewingDlg::enterEvent (QEvent* e) { - if ( GroupConstructors->isEnabled() ) - return ; - ActivateThisDialog() ; + if (!GroupConstructors->isEnabled()) + ActivateThisDialog(); } - //================================================================================= // function : closeEvent() // purpose : //================================================================================= -void SMESHGUI_SewingDlg::closeEvent( QCloseEvent* e ) +void SMESHGUI_SewingDlg::closeEvent (QCloseEvent*) { /* same than click on cancel button */ - this->ClickOnCancel() ; + this->ClickOnCancel(); } - //======================================================================= //function : hideEvent //purpose : caused by ESC key //======================================================================= - -void SMESHGUI_SewingDlg::hideEvent ( QHideEvent * e ) +void SMESHGUI_SewingDlg::hideEvent (QHideEvent*) { - if ( !isMinimized() ) + if (!isMinimized()) ClickOnCancel(); } - //================================================================================= // function : GetConstructorId() -// purpose : +// purpose : //================================================================================= int SMESHGUI_SewingDlg::GetConstructorId() -{ - if ( GroupConstructors != NULL && GroupConstructors->selected() != NULL ) - return GroupConstructors->id( GroupConstructors->selected() ); +{ + if (GroupConstructors != NULL && GroupConstructors->selected() != NULL) + return GroupConstructors->id(GroupConstructors->selected()); return -1; } - //================================================================================= // function : GetConstructorId() -// purpose : +// purpose : //================================================================================= bool SMESHGUI_SewingDlg::IsValid() { diff --git a/src/SMESHGUI/SMESHGUI_SewingDlg.h b/src/SMESHGUI/SMESHGUI_SewingDlg.h index b5433bb2d..695abc9b3 100644 --- a/src/SMESHGUI/SMESHGUI_SewingDlg.h +++ b/src/SMESHGUI/SMESHGUI_SewingDlg.h @@ -29,7 +29,7 @@ #ifndef DIALOGBOX_SEWING_H #define DIALOGBOX_SEWING_H -#include "SALOME_Selection.h" +#include "SalomeApp_SelectionMgr.h" // QT Includes #include @@ -44,6 +44,8 @@ class QRadioButton; class QCheckBox; class SMESHGUI; class SMESH_Actor; +class SVTK_ViewWindow; +class SVTK_Selector; // IDL Headers #include @@ -59,22 +61,26 @@ class SMESHGUI_SewingDlg : public QDialog Q_OBJECT public: - SMESHGUI_SewingDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); + SMESHGUI_SewingDlg( SMESHGUI*, + const char* name = 0, + bool modal = FALSE, + WFlags fl = 0); ~SMESHGUI_SewingDlg(); private: - void Init() ; void closeEvent( QCloseEvent* e ) ; - void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */ - void hideEvent ( QHideEvent * ); /* ESC key */ + void enterEvent ( QEvent * ); /* mouse enter the QWidget */ + void hideEvent ( QHideEvent * ); /* ESC key */ int GetConstructorId(); bool IsValid(); - SMESHGUI* mySMESHGUI ; /* Current SMESHGUI object */ - SALOME_Selection* mySelection ; /* User shape selection */ + SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */ + SalomeApp_SelectionMgr* mySelectionMgr; /* User shape selection */ int myOk1, myOk2, myOk3, myOk4, myOk5, myOk6; - QLineEdit* myEditCurrentArgument; /* Current LineEdit */ + QLineEdit* myEditCurrentArgument; /* Current LineEdit */ + SVTK_ViewWindow* myViewWindow; + SVTK_Selector* mySelector; bool myBusy; SMESH::SMESH_Mesh_var myMesh; @@ -111,7 +117,9 @@ private: QLineEdit* LineEdit5; QLineEdit* LineEdit6; QCheckBox* CheckBoxMerge; - + QCheckBox* CheckBoxPolygons; + QCheckBox* CheckBoxPolyedrs; + private slots: void ConstructorsClicked(int constructorId); diff --git a/src/SMESHGUI/SMESHGUI_SingleEditDlg.cxx b/src/SMESHGUI/SMESHGUI_SingleEditDlg.cxx index b25953d4c..cf7750be8 100755 --- a/src/SMESHGUI/SMESHGUI_SingleEditDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_SingleEditDlg.cxx @@ -1,23 +1,23 @@ // SMESH SMESHGUI : GUI for SMESH component // // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org // // // @@ -27,20 +27,31 @@ #include "SMESHGUI_SingleEditDlg.h" -#include "QAD_Desktop.h" - #include "SMESHGUI.h" #include "SMESHGUI_Utils.h" #include "SMESHGUI_VTKUtils.h" #include "SMESHGUI_MeshUtils.h" - #include "SMESHGUI_SpinBox.h" -#include "utilities.h" -#include "SALOME_Selection.h" #include "SMESH_Actor.h" #include "SMDS_Mesh.hxx" +#include "SalomeApp_SelectionMgr.h" +#include "SUIT_ResourceMgr.h" +#include "SUIT_MessageBox.h" +#include "SUIT_Desktop.h" + +#include "SVTK_Selector.h" +#include "SVTK_ViewWindow.h" +#include "SALOME_ListIO.hxx" + +#include "utilities.h" + +// OCCT Includes +#include +#include + +// QT Includes #include #include #include @@ -55,139 +66,143 @@ #define MARGIN 10 -/* - Class : SMESHGUI_DiagValidator - Description : validate munual input of edge like "id1-id2" -*/ +/*! + * Class : SMESHGUI_DiagValidator + * Description : validate munual input of edge like "id1-id2" + */ class SMESHGUI_DiagValidator: public QValidator { public: - - SMESHGUI_DiagValidator(QWidget * parent, const char * name = 0): + SMESHGUI_DiagValidator (QWidget * parent, const char * name = 0): QValidator(parent,name) {} - State validate ( QString & text, int & pos) const + State validate (QString & text, int & pos) const { text.stripWhiteSpace(); - text.replace( QRegExp("[^0-9]+"), "-" ); - if ( text == "-" ) + text.replace(QRegExp("[^0-9]+"), "-"); + if (text == "-") text = ""; - int ind = text.find( QRegExp("-[0-9]+-")); - if ( ind > 0 ) { // leave only two ids - ind = text.find( '-', ind + 1 ); - if ( ind > 0 ) - text.truncate( ind ); + int ind = text.find(QRegExp("-[0-9]+-")); + if (ind > 0) { // leave only two ids + ind = text.find('-', ind + 1); + if (ind > 0) + text.truncate(ind); } - if ( pos > text.length() ) + if (pos > text.length()) pos = text.length(); return Acceptable; } }; -/* - Class : SMESHGUI_SingleEditDlg - Description : Inversion of the diagonal of a pseudo-quadrangle formed by - 2 neighboring triangles with 1 common edge -*/ +/*! + * Class : SMESHGUI_SingleEditDlg + * Description : Inversion of the diagonal of a pseudo-quadrangle formed by + * 2 neighboring triangles with 1 common edge + */ //======================================================================= -// name : SMESHGUI_SingleEditDlg::SMESHGUI_SingleEditDlg +// name : SMESHGUI_SingleEditDlg() // Purpose : Constructor //======================================================================= -SMESHGUI_SingleEditDlg::SMESHGUI_SingleEditDlg( QWidget* theParent, - SALOME_Selection* theSelection, - const char* theName ) -: QDialog( theParent, theName, false, - WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +SMESHGUI_SingleEditDlg +::SMESHGUI_SingleEditDlg(SMESHGUI* theModule, + const char* theName): + QDialog(SMESH::GetDesktop(theModule), + theName, + false, + WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu), + mySelector(SMESH::GetViewWindow(theModule)->GetSelector()), + mySelectionMgr(SMESH::GetSelectionMgr(theModule)), + myViewWindow(SMESH::GetViewWindow(theModule)), + mySMESHGUI(theModule) { - //setCaption( tr( "CAPTION" ) ); + QVBoxLayout* aDlgLay = new QVBoxLayout(this, MARGIN, SPACING); - QVBoxLayout* aDlgLay = new QVBoxLayout( this, MARGIN, SPACING ); + QFrame* aMainFrame = createMainFrame (this); + QFrame* aBtnFrame = createButtonFrame(this); - QFrame* aMainFrame = createMainFrame ( this ); - QFrame* aBtnFrame = createButtonFrame( this ); + aDlgLay->addWidget(aMainFrame); + aDlgLay->addWidget(aBtnFrame); - aDlgLay->addWidget( aMainFrame ); - aDlgLay->addWidget( aBtnFrame ); + aDlgLay->setStretchFactor(aMainFrame, 1); - aDlgLay->setStretchFactor( aMainFrame, 1 ); - - Init( theSelection ) ; + Init(); } //======================================================================= -// name : SMESHGUI_SingleEditDlg::createMainFrame +// name : createMainFrame() // Purpose : Create frame containing dialog's input fields //======================================================================= -QFrame* SMESHGUI_SingleEditDlg::createMainFrame( QWidget* theParent ) +QFrame* SMESHGUI_SingleEditDlg::createMainFrame (QWidget* theParent) { - QGroupBox* aMainGrp = new QGroupBox( 1, Qt::Vertical, tr( "EDGE_BETWEEN" ), theParent ); + QGroupBox* aMainGrp = new QGroupBox(1, Qt::Vertical, tr("EDGE_BETWEEN"), theParent); - QPixmap aPix( QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr( "ICON_SELECT" ) ) ); - - new QLabel( tr( "SMESH_EDGE" ), aMainGrp ); - ( new QPushButton( aMainGrp ) )->setPixmap( aPix ); - myEdge = new QLineEdit( aMainGrp ); - myEdge->setValidator( new SMESHGUI_DiagValidator( this, "validator" )); + QPixmap aPix (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT"))); + + new QLabel(tr("SMESH_EDGE"), aMainGrp); + (new QPushButton(aMainGrp))->setPixmap(aPix); + myEdge = new QLineEdit(aMainGrp); + myEdge->setValidator(new SMESHGUI_DiagValidator(this, "validator")); return aMainGrp; } //======================================================================= -// name : SMESHGUI_SingleEditDlg::createButtonFrame +// name : createButtonFrame() // Purpose : Create frame containing buttons //======================================================================= -QFrame* SMESHGUI_SingleEditDlg::createButtonFrame( QWidget* theParent ) +QFrame* SMESHGUI_SingleEditDlg::createButtonFrame (QWidget* theParent) { - QFrame* aFrame = new QFrame( theParent ); - aFrame->setFrameStyle( QFrame::Box | QFrame::Sunken ); + QFrame* aFrame = new QFrame(theParent); + aFrame->setFrameStyle(QFrame::Box | QFrame::Sunken); - myOkBtn = new QPushButton( tr( "SMESH_BUT_OK" ), aFrame ); - myApplyBtn = new QPushButton( tr( "SMESH_BUT_APPLY" ), aFrame ); - myCloseBtn = new QPushButton( tr( "SMESH_BUT_CLOSE" ), aFrame ); + myOkBtn = new QPushButton(tr("SMESH_BUT_OK" ), aFrame); + myApplyBtn = new QPushButton(tr("SMESH_BUT_APPLY"), aFrame); + myCloseBtn = new QPushButton(tr("SMESH_BUT_CLOSE"), aFrame); - QSpacerItem* aSpacer = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum ); + QSpacerItem* aSpacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum); - QHBoxLayout* aLay = new QHBoxLayout( aFrame, MARGIN, SPACING ); + QHBoxLayout* aLay = new QHBoxLayout(aFrame, MARGIN, SPACING); - aLay->addWidget( myOkBtn ); - aLay->addWidget( myApplyBtn ); - aLay->addItem( aSpacer); - aLay->addWidget( myCloseBtn ); + aLay->addWidget(myOkBtn); + aLay->addWidget(myApplyBtn); + aLay->addItem(aSpacer); + aLay->addWidget(myCloseBtn); return aFrame; } //======================================================================= -// name : SMESHGUI_SingleEditDlg::isValid +// name : isValid() // Purpose : Verify validity of input data //======================================================================= -bool SMESHGUI_SingleEditDlg::isValid( const bool theMess ) const +bool SMESHGUI_SingleEditDlg::isValid (const bool theMess) const { int id1, id2; - return getNodeIds( myEdge->text(), id1, id2 ); + return getNodeIds(myEdge->text(), id1, id2); } //======================================================================= -// name : SMESHGUI_SingleEditDlg::getNodeIds +// name : getNodeIds() // Purpose : Retrieve node ids from string //======================================================================= -bool SMESHGUI_SingleEditDlg::getNodeIds( const QString& theStr, int& theId1, int& theId2 ) const +bool SMESHGUI_SingleEditDlg::getNodeIds (const QString& theStr, + int& theId1, int& theId2) const { - if ( !theStr.contains( '-' ) ) + if (!theStr.contains('-')) return false; bool ok1, ok2; - QString str1 = theStr.section( '-', 0, 0, QString::SectionSkipEmpty ); - QString str2 = theStr.section( '-', 1, 1, QString::SectionSkipEmpty ); - theId1 = str1.toInt( &ok1 ); - theId2 = str2.toInt( &ok2 ); - + QString str1 = theStr.section('-', 0, 0, QString::SectionSkipEmpty); + QString str2 = theStr.section('-', 1, 1, QString::SectionSkipEmpty); + theId1 = str1.toInt(&ok1); + theId2 = str2.toInt(&ok2); + return ok1 & ok2; } //======================================================================= -// name : SMESHGUI_SingleEditDlg::~SMESHGUI_SingleEditDlg +// name : ~SMESHGUI_SingleEditDlg() // Purpose : Destructor //======================================================================= SMESHGUI_SingleEditDlg::~SMESHGUI_SingleEditDlg() @@ -195,83 +210,78 @@ SMESHGUI_SingleEditDlg::~SMESHGUI_SingleEditDlg() } //======================================================================= -// name : SMESHGUI_SingleEditDlg::Init +// name : Init() // Purpose : Init dialog fields, connect signals and slots, show dialog //======================================================================= -void SMESHGUI_SingleEditDlg::Init( SALOME_Selection* theSelection ) +void SMESHGUI_SingleEditDlg::Init() { - mySelection = theSelection; - SMESHGUI* aSMESHGUI = SMESHGUI::GetSMESHGUI(); - aSMESHGUI->SetActiveDialogBox( ( QDialog* )this ) ; + mySMESHGUI->SetActiveDialogBox((QDialog*)this); myBusy = false; myActor = 0; - + // main buttons - connect( myOkBtn, SIGNAL( clicked() ), SLOT( onOk() ) ); - connect( myCloseBtn, SIGNAL( clicked() ), SLOT( onClose() ) ) ; - connect( myApplyBtn, SIGNAL( clicked() ), SLOT( onApply() ) ); + connect(myOkBtn, SIGNAL(clicked()), SLOT(onOk())); + connect(myCloseBtn, SIGNAL(clicked()), SLOT(onClose())); + connect(myApplyBtn, SIGNAL(clicked()), SLOT(onApply())); // selection and SMESHGUI - connect( mySelection, SIGNAL( currentSelectionChanged() ), SLOT( onSelectionDone() ) ); - connect( aSMESHGUI, SIGNAL( SignalDeactivateActiveDialog() ), SLOT( onDeactivate() ) ); - connect( aSMESHGUI, SIGNAL( SignalCloseAllDialogs() ), SLOT( onClose() ) ); - connect( myEdge, SIGNAL( textChanged(const QString&)), SLOT( onTextChange(const QString&))); + connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(onSelectionDone())); + connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), SLOT(onDeactivate())); + connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), SLOT(onClose())); + connect(myEdge, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&))); - myOkBtn->setEnabled( false ); - myApplyBtn->setEnabled( false ); - setEnabled( true ); + myOkBtn->setEnabled(false); + myApplyBtn->setEnabled(false); + setEnabled(true); - int x, y ; - aSMESHGUI->DefineDlgPosition( this, x, y ); - this->move( x, y ); - this->show(); + int x, y; + mySMESHGUI->DefineDlgPosition(this, x, y); + this->move(x, y); + this->show(); // set selection mode - QAD_Application::getDesktop()->SetSelectionMode( EdgeOfCellSelection, true ); + myViewWindow->SetSelectionMode(EdgeOfCellSelection); onSelectionDone(); - - return; } //======================================================================= -// name : SMESHGUI_SingleEditDlg::onOk -// Purpose : SLOT called when "Ok" button pressed. +// name : onOk() +// Purpose : SLOT called when "Ok" button pressed. // Assign filters VTK viewer and close dialog //======================================================================= void SMESHGUI_SingleEditDlg::onOk() { - if ( onApply() ) + if (onApply()) onClose(); } //======================================================================= -// name : SMESHGUI_SingleEditDlg::onClose +// name : onClose() // Purpose : SLOT called when "Close" button pressed. Close dialog //======================================================================= void SMESHGUI_SingleEditDlg::onClose() { - QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); - mySelection->ClearIObjects(); - disconnect( mySelection, 0, this, 0 ); - disconnect( SMESHGUI::GetSMESHGUI(), 0, this, 0 ); - SMESHGUI::GetSMESHGUI()->ResetState() ; + myViewWindow->SetSelectionMode(ActorSelection); + mySelectionMgr->clearSelected(); + disconnect(mySelectionMgr, 0, this, 0); + disconnect(mySMESHGUI, 0, this, 0); + mySMESHGUI->ResetState(); reject(); } //======================================================================= -//function : findTriangles +//function : findTriangles() //purpose : find triangles sharing theNode1-theNode2 link -// THIS IS A PIECE OF SMESH_MeshEditor.cxx -// TO DO: make it available in SMDS for ex. +// THIS IS A PIECE OF SMESH_MeshEditor.cxx +// TO DO: make it available in SMDS for ex. //======================================================================= - -static bool findTriangles(const SMDS_MeshNode * theNode1, - const SMDS_MeshNode * theNode2, - const SMDS_MeshElement*& theTria1, - const SMDS_MeshElement*& theTria2) +static bool findTriangles (const SMDS_MeshNode * theNode1, + const SMDS_MeshNode * theNode2, + const SMDS_MeshElement*& theTria1, + const SMDS_MeshElement*& theTria2) { - if ( !theNode1 || !theNode2 ) return false; + if (!theNode1 || !theNode2) return false; theTria1 = theTria2 = 0; @@ -279,266 +289,270 @@ static bool findTriangles(const SMDS_MeshNode * theNode1, SMDS_ElemIteratorPtr it = theNode1->GetInverseElementIterator(); while (it->more()) { const SMDS_MeshElement* elem = it->next(); - if ( elem->GetType() == SMDSAbs_Face && elem->NbNodes() == 3 ) - emap.insert( elem ); + if (elem->GetType() == SMDSAbs_Face && elem->NbNodes() == 3) + emap.insert(elem); } it = theNode2->GetInverseElementIterator(); while (it->more()) { const SMDS_MeshElement* elem = it->next(); - if ( elem->GetType() == SMDSAbs_Face && - emap.find( elem ) != emap.end() ) - if ( theTria1 ) { + if (elem->GetType() == SMDSAbs_Face && + emap.find(elem) != emap.end()) + if (theTria1) { theTria2 = elem; break; } else { theTria1 = elem; } } - return ( theTria1 && theTria2 ); + return (theTria1 && theTria2); } //======================================================================= -//function : onTextChange -//purpose : +//function : onTextChange() +//purpose : //======================================================================= - -void SMESHGUI_SingleEditDlg::onTextChange( const QString& theNewText ) +void SMESHGUI_SingleEditDlg::onTextChange (const QString& theNewText) { - if ( myBusy ) return; + if (myBusy) return; - myOkBtn->setEnabled( false ); - myApplyBtn->setEnabled( false ); + myOkBtn->setEnabled(false); + myApplyBtn->setEnabled(false); // hilight entered edge - SMDS_Mesh* aMesh = 0; - if ( myActor ) - aMesh = myActor->GetObject()->GetMesh(); - if ( aMesh ) { - - myBusy = true; // block onSelectionDone() - mySelection->ClearIObjects(); - mySelection->AddIObject( myActor->getIO() ); - myBusy = false; - - QStringList aListId = QStringList::split( "-", theNewText, false); - if ( aListId.count() != 2 ) - return; - const SMDS_MeshNode* a2Nodes[2]; - bool allOk = true; - int i; - for ( i = 0; i < aListId.count(); i++ ) { - const SMDS_MeshNode * n = aMesh->FindNode( aListId[ i ].toInt() ); - if ( n ) - a2Nodes[ i ] = n; - else - allOk = false; - } - - // find a triangle and an edge nb - const SMDS_MeshElement* tria[2]; - if (allOk && - a2Nodes[0] != a2Nodes[1] && - findTriangles( a2Nodes[0], - a2Nodes[1], - tria[0], - tria[1])) { + if(myActor){ + if(SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh()){ myBusy = true; // block onSelectionDone() - mySelection->AddOrRemoveIndex (myActor->getIO(), tria[0]->GetID(), true, false); - - const SMDS_MeshNode* a3Nodes [3]; - SMDS_ElemIteratorPtr it; - int edgeInd = 2; - for (i = 0, it = tria[0]->nodesIterator(); it->more(); i++ ) { - a3Nodes[ i ] = static_cast( it->next() ); - if ( i > 0 ) - if (( a3Nodes[ i ] == a2Nodes[ 0 ] && a3Nodes[ i - 1] == a2Nodes[ 1 ] ) || - ( a3Nodes[ i ] == a2Nodes[ 1 ] && a3Nodes[ i - 1] == a2Nodes[ 0 ] ) ) { - edgeInd = i - 1; - break; - } - } - - mySelection->AddOrRemoveIndex( myActor->getIO(), -edgeInd-1, true, true ); + Handle(SALOME_InteractiveObject) anIO = myActor->getIO(); + SALOME_ListIO aList; + aList.Append(anIO); + mySelectionMgr->setSelectedObjects(aList,false); + + TColStd_IndexedMapOfInteger selectedIndices; + TColStd_MapOfInteger newIndices; + mySelector->GetIndex(anIO,selectedIndices); myBusy = false; - myOkBtn->setEnabled( true ); - myApplyBtn->setEnabled( true ); + QStringList aListId = QStringList::split("-", theNewText, false); + if (aListId.count() != 2) + return; + + int i; + bool allOk = true; + const SMDS_MeshNode* a2Nodes[2]; + for (i = 0; i < aListId.count(); i++) { + if(const SMDS_MeshNode *aNode = aMesh->FindNode(aListId[ i ].toInt())) + a2Nodes[ i ] = aNode; + else + allOk = false; + } + + // find a triangle and an edge nb + const SMDS_MeshElement* tria[2]; + allOk &= a2Nodes[0] != a2Nodes[1] && findTriangles(a2Nodes[0],a2Nodes[1],tria[0],tria[1]); + if(allOk){ + myBusy = true; // block onSelectionDone() + newIndices.Add(tria[0]->GetID()); + mySelector->AddOrRemoveIndex(anIO,newIndices, true); + + const SMDS_MeshNode* a3Nodes [3]; + SMDS_ElemIteratorPtr it; + int edgeInd = 2; + for (i = 0, it = tria[0]->nodesIterator(); it->more(); i++) { + a3Nodes[ i ] = static_cast(it->next()); + if (i > 0) { + allOk = (a3Nodes[ i ] == a2Nodes[ 0 ] && a3Nodes[ i - 1] == a2Nodes[ 1 ]) || + (a3Nodes[ i ] == a2Nodes[ 1 ] && a3Nodes[ i - 1] == a2Nodes[ 0 ]); + if (allOk) { + edgeInd = i - 1; + break; + } + } + } + + newIndices.Clear(); + newIndices.Add(-edgeInd-1); + mySelector->AddOrRemoveIndex(anIO,newIndices,true); + myBusy = false; + + myOkBtn->setEnabled(true); + myApplyBtn->setEnabled(true); + } } } } + //======================================================================= -// name : SMESHGUI_SingleEditDlg::onSelectionDone +// name : onSelectionDone() // Purpose : SLOT called when selection changed //======================================================================= void SMESHGUI_SingleEditDlg::onSelectionDone() { - if ( myBusy ) return; + if (myBusy) return; int anId1 = 0, anId2 = 0; - myOkBtn->setEnabled( false ); - myApplyBtn->setEnabled( false ); + myOkBtn->setEnabled(false); + myApplyBtn->setEnabled(false); - if ( mySelection->IObjectCount() != 1 ) - { + SALOME_ListIO aList; + mySelectionMgr->selectedObjects(aList); + + if (aList.Extent() != 1) { myEdge->clear(); return; } - myActor = SMESH::FindActorByEntry( mySelection->firstIObject()->getEntry() ); - SMDS_Mesh* aMesh = 0; - if ( myActor ) - aMesh = myActor->GetObject()->GetMesh(); - if ( !aMesh ) - return; - - if (SMESH::GetEdgeNodes( mySelection, anId1, anId2 ) >= 1 ) { - QString aText = QString( "%1-%2" ).arg( anId1 ).arg( anId2 ); - myBusy = true; - myEdge->setText( aText ); - myBusy = false; - - const SMDS_MeshElement* tria[2]; - if ( findTriangles( aMesh->FindNode( anId1 ), aMesh->FindNode( anId2 ), tria[0],tria[1])) - { - myOkBtn->setEnabled( true ); - myApplyBtn->setEnabled( true ); + Handle(SALOME_InteractiveObject) anIO = aList.First(); + myActor = SMESH::FindActorByEntry(anIO->getEntry()); + if(myActor){ + TVisualObjPtr aVisualObj = myActor->GetObject(); + if(SMDS_Mesh* aMesh = aVisualObj->GetMesh()){ + if(SMESH::GetEdgeNodes(mySelector, aVisualObj, anId1, anId2) >= 1){ + QString aText = QString("%1-%2").arg(anId1).arg(anId2); + myBusy = true; + myEdge->setText(aText); + myBusy = false; + + const SMDS_MeshElement* tria[2]; + if (findTriangles(aMesh->FindNode(anId1), aMesh->FindNode(anId2), tria[0],tria[1])) { + myOkBtn->setEnabled(true); + myApplyBtn->setEnabled(true); + } + } else { + myEdge->clear(); + } } } - else - myEdge->clear(); } //======================================================================= -// name : SMESHGUI_SingleEditDlg::onDeactivate +// name : onDeactivate() // Purpose : SLOT called when dialog must be deativated //======================================================================= void SMESHGUI_SingleEditDlg::onDeactivate() { - setEnabled( false ); + setEnabled(false); } //======================================================================= -// name : SMESHGUI_SingleEditDlg::enterEvent +// name : enterEvent() // Purpose : Event filter //======================================================================= -void SMESHGUI_SingleEditDlg::enterEvent( QEvent* ) +void SMESHGUI_SingleEditDlg::enterEvent (QEvent*) { - if ( !isEnabled() ) { - SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog(); - // set selection mode - QAD_Application::getDesktop()->SetSelectionMode( EdgeOfCellSelection, true ); - setEnabled( true ); + if (!isEnabled()) { + mySMESHGUI->EmitSignalDeactivateDialog(); + myViewWindow->SetSelectionMode(EdgeOfCellSelection); + setEnabled(true); } } - //================================================================================= // function : closeEvent() // purpose : //================================================================================= -void SMESHGUI_SingleEditDlg::closeEvent( QCloseEvent* e ) +void SMESHGUI_SingleEditDlg::closeEvent (QCloseEvent*) { - onClose() ; + onClose(); } + //======================================================================= -//function : hideEvent +//function : hideEvent() //purpose : caused by ESC key //======================================================================= - -void SMESHGUI_SingleEditDlg::hideEvent ( QHideEvent * e ) +void SMESHGUI_SingleEditDlg::hideEvent (QHideEvent*) { - if ( !isMinimized() ) + if (!isMinimized()) onClose(); } //================================================================================= -// function : onApply +// function : onApply() // purpose : SLOT. Called when apply button is pressed //================================================================================= bool SMESHGUI_SingleEditDlg::onApply() { - if (SMESHGUI::GetSMESHGUI()->ActiveStudyLocked()) + if (mySMESHGUI->isActiveStudyLocked()) return false; // verify validity of input data - if ( !isValid( true ) ) + if (!isValid(true)) return false; - // get mesh, actor and nodes - SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO( mySelection->firstIObject() ); + // get mesh, actor and nodes + SALOME_ListIO aList; + mySelectionMgr->selectedObjects(aList); - if ( aMesh->_is_nil() ) - { - QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), - tr( "SMESH_ERROR" ), tr( "SMESHG_NO_MESH" ), QMessageBox::Ok ); + SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(aList.First()); + + if (aMesh->_is_nil()) { + SUIT_MessageBox::info1(SMESH::GetDesktop(mySMESHGUI), + tr("SMESH_ERROR"), + tr("SMESHG_NO_MESH"), + tr("SMESH_BUT_OK")); return false; } SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor(); int anId1= 0, anId2 = 0; - if ( aMeshEditor->_is_nil() || !getNodeIds( myEdge->text(), anId1, anId2 ) ) + if (aMeshEditor->_is_nil() || !getNodeIds(myEdge->text(), anId1, anId2)) return false; // perform operation - bool aResult = process( aMeshEditor.in(), anId1, anId2 ); + bool aResult = process(aMeshEditor.in(), anId1, anId2); // update actor - if ( aResult ) - { - Handle(SALOME_InteractiveObject) anIO = mySelection->firstIObject(); - mySelection->ClearIObjects(); + if (aResult) { + mySelectionMgr->setSelectedObjects(aList, false); SMESH::UpdateView(); - mySelection->AddIObject( anIO, false ); } return aResult; } -/* - Class : SMESHGUI_TrianglesInversionDlg - Description : Inversion of the diagonal of a pseudo-quadrangle formed by - 2 neighboring triangles with 1 common edge -*/ +/*! + * Class : SMESHGUI_TrianglesInversionDlg + * Description : Inversion of the diagonal of a pseudo-quadrangle formed by + * 2 neighboring triangles with 1 common edge + */ -SMESHGUI_TrianglesInversionDlg::SMESHGUI_TrianglesInversionDlg( QWidget* theParent, - SALOME_Selection* theSelection, - const char* theName ) -: SMESHGUI_SingleEditDlg( theParent, theSelection, theName ) +SMESHGUI_TrianglesInversionDlg +::SMESHGUI_TrianglesInversionDlg(SMESHGUI* theModule, + const char* theName) +: SMESHGUI_SingleEditDlg(theModule,theName) { - setCaption( tr( "CAPTION" ) ); + setCaption(tr("CAPTION")); } SMESHGUI_TrianglesInversionDlg::~SMESHGUI_TrianglesInversionDlg() { } -bool SMESHGUI_TrianglesInversionDlg::process( - SMESH::SMESH_MeshEditor_ptr theMeshEditor, const int theId1, const int theId2 ) +bool SMESHGUI_TrianglesInversionDlg::process (SMESH::SMESH_MeshEditor_ptr theMeshEditor, + const int theId1, const int theId2) { - return theMeshEditor->InverseDiag( theId1, theId2 ); + return theMeshEditor->InverseDiag(theId1, theId2); } -/* - Class : SMESHGUI_UnionOfTwoTrianglesDlg - Description : Construction of a quadrangle by deletion of the - common border of 2 neighboring triangles -*/ +/*! + * Class : SMESHGUI_UnionOfTwoTrianglesDlg + * Description : Construction of a quadrangle by deletion of the + * common border of 2 neighboring triangles + */ -SMESHGUI_UnionOfTwoTrianglesDlg::SMESHGUI_UnionOfTwoTrianglesDlg( QWidget* theParent, - SALOME_Selection* theSelection, - const char* theName ) -: SMESHGUI_SingleEditDlg( theParent, theSelection, theName ) +SMESHGUI_UnionOfTwoTrianglesDlg +::SMESHGUI_UnionOfTwoTrianglesDlg(SMESHGUI* theModule, + const char* theName) +: SMESHGUI_SingleEditDlg(theModule,theName) { - setCaption( tr( "CAPTION" ) ); + setCaption(tr("CAPTION")); } SMESHGUI_UnionOfTwoTrianglesDlg::~SMESHGUI_UnionOfTwoTrianglesDlg() { } -bool SMESHGUI_UnionOfTwoTrianglesDlg::process( - SMESH::SMESH_MeshEditor_ptr theMeshEditor, const int theId1, const int theId2 ) +bool SMESHGUI_UnionOfTwoTrianglesDlg::process (SMESH::SMESH_MeshEditor_ptr theMeshEditor, + const int theId1, const int theId2) { - return theMeshEditor->DeleteDiag( theId1, theId2 ); + return theMeshEditor->DeleteDiag(theId1, theId2); } - diff --git a/src/SMESHGUI/SMESHGUI_SingleEditDlg.h b/src/SMESHGUI/SMESHGUI_SingleEditDlg.h index 9aed20635..3eff1f9d3 100755 --- a/src/SMESHGUI/SMESHGUI_SingleEditDlg.h +++ b/src/SMESHGUI/SMESHGUI_SingleEditDlg.h @@ -37,93 +37,97 @@ class QFrame; class QLineEdit; class SMESHGUI_SpinBox; class QPushButton; -class SALOME_Selection; + +class SMESHGUI; class SMESH_Actor; +class SVTK_Selector; +class SVTK_ViewWindow; +class SalomeApp_SelectionMgr; -/* - Class : SMESHGUI_SingleEditDlg - Description : Base class for dialogs of diagonal inversion and - union of two neighboring triangles -*/ - +/*! + * Class : SMESHGUI_SingleEditDlg + * Description : Base class for dialogs of diagonal inversion and + * union of two neighboring triangles + */ class SMESHGUI_SingleEditDlg : public QDialog { Q_OBJECT public: - SMESHGUI_SingleEditDlg( QWidget*, SALOME_Selection*, const char* = 0 ); - virtual ~SMESHGUI_SingleEditDlg(); + SMESHGUI_SingleEditDlg(SMESHGUI* theModule, + const char* theName = 0); + virtual ~SMESHGUI_SingleEditDlg(); - void Init( SALOME_Selection* ) ; + void Init(); protected slots: + void onOk(); + virtual bool onApply(); + void onClose(); - void onOk(); - virtual bool onApply(); - void onClose(); + void onDeactivate(); - void onDeactivate(); - - void onSelectionDone(); - void onTextChange(const QString&); + void onSelectionDone(); + void onTextChange (const QString&); protected: + void closeEvent (QCloseEvent*); + void enterEvent (QEvent*); + void hideEvent (QHideEvent*); /* ESC key */ + QFrame* createButtonFrame (QWidget*); + QFrame* createMainFrame (QWidget*); + bool isValid (const bool) const; + bool getNodeIds (const QString&, int&, int&) const; + virtual bool process (SMESH::SMESH_MeshEditor_ptr, const int, const int) = 0; - void closeEvent( QCloseEvent* e ) ; - void enterEvent ( QEvent * ) ; - void hideEvent ( QHideEvent * ); /* ESC key */ - QFrame* createButtonFrame( QWidget* ); - QFrame* createMainFrame ( QWidget* ); - bool isValid( const bool ) const; - bool getNodeIds( const QString&, int&, int& ) const; - virtual bool process( SMESH::SMESH_MeshEditor_ptr, const int, const int ) = 0; - protected: + bool myBusy; + QPushButton* myOkBtn; + QPushButton* myApplyBtn; + QPushButton* myCloseBtn; + QLineEdit* myEdge; + SMESH_Actor* myActor; - bool myBusy; - QPushButton* myOkBtn; - QPushButton* myApplyBtn; - QPushButton* myCloseBtn; - QLineEdit* myEdge; - SALOME_Selection* mySelection; - SMESH_Actor* myActor; - + SalomeApp_SelectionMgr* mySelectionMgr; + SVTK_ViewWindow* myViewWindow; + SVTK_Selector* mySelector; + SMESHGUI* mySMESHGUI; }; -/* - Class : SMESHGUI_TrianglesInversionDlg - Description : Inversion of the diagonal of a pseudo-quadrangle formed by - 2 neighboring triangles with 1 common edge -*/ +/*! + * Class : SMESHGUI_TrianglesInversionDlg + * Description : Inversion of the diagonal of a pseudo-quadrangle formed by + * 2 neighboring triangles with 1 common edge + */ class SMESHGUI_TrianglesInversionDlg : public SMESHGUI_SingleEditDlg { Q_OBJECT - + public: - SMESHGUI_TrianglesInversionDlg( QWidget*, SALOME_Selection*, const char* = 0 ); - virtual ~SMESHGUI_TrianglesInversionDlg(); + SMESHGUI_TrianglesInversionDlg(SMESHGUI* theModule, + const char* theName = 0); + virtual ~SMESHGUI_TrianglesInversionDlg(); protected: - - virtual bool process( SMESH::SMESH_MeshEditor_ptr, const int, const int ); + virtual bool process (SMESH::SMESH_MeshEditor_ptr, const int, const int); }; -/* - Class : SMESHGUI_UnionOfTwoTrianglesDlg - Description : Construction of a quadrangle by deletion of the - common border of 2 neighboring triangles -*/ +/*! + * Class : SMESHGUI_UnionOfTwoTrianglesDlg + * Description : Construction of a quadrangle by deletion of the + * common border of 2 neighboring triangles + */ class SMESHGUI_UnionOfTwoTrianglesDlg : public SMESHGUI_SingleEditDlg { Q_OBJECT public: - SMESHGUI_UnionOfTwoTrianglesDlg( QWidget*, SALOME_Selection*, const char* = 0 ); - virtual ~SMESHGUI_UnionOfTwoTrianglesDlg(); + SMESHGUI_UnionOfTwoTrianglesDlg(SMESHGUI* theModule, + const char* theName = 0); + virtual ~SMESHGUI_UnionOfTwoTrianglesDlg(); protected: - - virtual bool process( SMESH::SMESH_MeshEditor_ptr, const int, const int ); + virtual bool process (SMESH::SMESH_MeshEditor_ptr, const int, const int); }; #endif diff --git a/src/SMESHGUI/SMESHGUI_SmoothingDlg.cxx b/src/SMESHGUI/SMESHGUI_SmoothingDlg.cxx index 3099baeb0..3adcb19c5 100644 --- a/src/SMESHGUI/SMESHGUI_SmoothingDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_SmoothingDlg.cxx @@ -1,48 +1,64 @@ // SMESH SMESHGUI : GUI for SMESH component // // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org // // // // File : SMESHGUI_SmoothingDlg.cxx // Author : Michael ZORIN // Module : SMESH -// $Header: +// $Header: #include "SMESHGUI_SmoothingDlg.h" #include "SMESHGUI.h" -#include "SMESHGUI_SpinBox.h" #include "SMESHGUI_Utils.h" #include "SMESHGUI_VTKUtils.h" #include "SMESHGUI_MeshUtils.h" +#include "SMESHGUI_SpinBox.h" #include "SMESHGUI_IdValidator.h" + #include "SMESH_Actor.h" #include "SMESH_TypeFilter.hxx" +#include "SMESH_NumberFilter.hxx" +#include "SMESH_LogicalFilter.hxx" + #include "SMDS_Mesh.hxx" -#include "QAD_Application.h" -#include "QAD_Desktop.h" -#include "QAD_MessageBox.h" +#include "SUIT_ResourceMgr.h" +#include "SUIT_OverrideCursor.h" +#include "SUIT_Desktop.h" +#include "SUIT_MessageBox.h" + +#include "SVTK_ViewModel.h" +#include "SVTK_Selector.h" +#include "SVTK_ViewWindow.h" +#include "SVTK_Selection.h" +#include "SALOME_ListIO.hxx" + #include "utilities.h" +// OCCT Includes +#include +#include + // QT Includes #include #include @@ -53,8 +69,8 @@ #include #include #include +#include #include -#include #include #include @@ -65,396 +81,440 @@ using namespace std; //================================================================================= -// class : SMESHGUI_SmoothingDlg() -// purpose : +// function : SMESHGUI_SmoothingDlg() +// purpose : constructor //================================================================================= -SMESHGUI_SmoothingDlg::SMESHGUI_SmoothingDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, - bool modal, WFlags fl ) - : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | - Qt::WDestructiveClose) +SMESHGUI_SmoothingDlg::SMESHGUI_SmoothingDlg( SMESHGUI* theModule, const char* name, + bool modal, WFlags fl) + : QDialog( SMESH::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder | + WStyle_Title | WStyle_SysMenu | Qt::WDestructiveClose), + mySMESHGUI( theModule ), + mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ), + myViewWindow( SMESH::GetViewWindow( theModule ) ), + mySelector( myViewWindow->GetSelector() ) { - QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_DLG_SMOOTHING"))); - QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SELECT"))); + QPixmap image0 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_DLG_SMOOTHING"))); + QPixmap image1 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT"))); - if ( !name ) - setName( "SMESHGUI_SmoothingDlg" ); - resize( 303, 185 ); - setCaption( tr( "SMESH_SMOOTHING" ) ); - setSizeGripEnabled( TRUE ); - SMESHGUI_SmoothingDlgLayout = new QGridLayout( this ); - SMESHGUI_SmoothingDlgLayout->setSpacing( 6 ); - SMESHGUI_SmoothingDlgLayout->setMargin( 11 ); + if (!name) + setName("SMESHGUI_SmoothingDlg"); + resize(303, 185); + setCaption(tr("SMESH_SMOOTHING")); + setSizeGripEnabled(TRUE); + SMESHGUI_SmoothingDlgLayout = new QGridLayout(this); + SMESHGUI_SmoothingDlgLayout->setSpacing(6); + SMESHGUI_SmoothingDlgLayout->setMargin(11); /***************************************************************/ - GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); - GroupConstructors->setTitle( tr( "SMESH_SMOOTHING" ) ); - GroupConstructors->setExclusive( TRUE ); - GroupConstructors->setColumnLayout(0, Qt::Vertical ); - GroupConstructors->layout()->setSpacing( 0 ); - GroupConstructors->layout()->setMargin( 0 ); - GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() ); - GroupConstructorsLayout->setAlignment( Qt::AlignTop ); - GroupConstructorsLayout->setSpacing( 6 ); - GroupConstructorsLayout->setMargin( 11 ); - Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" ); - Constructor1->setText( tr( "" ) ); - Constructor1->setPixmap( image0 ); - Constructor1->setChecked( TRUE ); - Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) ); - Constructor1->setMinimumSize( QSize( 50, 0 ) ); - GroupConstructorsLayout->addWidget( Constructor1, 0, 0 ); - QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); - GroupConstructorsLayout->addItem( spacer, 0, 1 ); - SMESHGUI_SmoothingDlgLayout->addWidget( GroupConstructors, 0, 0 ); - - /***************************************************************/ - GroupButtons = new QGroupBox( this, "GroupButtons" ); - GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); - GroupButtons->setTitle( tr( "" ) ); - GroupButtons->setColumnLayout(0, Qt::Vertical ); - GroupButtons->layout()->setSpacing( 0 ); - GroupButtons->layout()->setMargin( 0 ); - GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); - GroupButtonsLayout->setAlignment( Qt::AlignTop ); - GroupButtonsLayout->setSpacing( 6 ); - GroupButtonsLayout->setMargin( 11 ); - buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); - buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) ); - buttonCancel->setAutoDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonCancel, 0, 3 ); - buttonApply = new QPushButton( GroupButtons, "buttonApply" ); - buttonApply->setText( tr( "SMESH_BUT_APPLY" ) ); - buttonApply->setAutoDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); - QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); - GroupButtonsLayout->addItem( spacer_9, 0, 2 ); - buttonOk = new QPushButton( GroupButtons, "buttonOk" ); - buttonOk->setText( tr( "SMESH_BUT_OK" ) ); - buttonOk->setAutoDefault( TRUE ); - buttonOk->setDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); - SMESHGUI_SmoothingDlgLayout->addWidget( GroupButtons, 2, 0 ); + GroupConstructors = new QButtonGroup(this, "GroupConstructors"); + GroupConstructors->setTitle(tr("SMESH_SMOOTHING" )); + GroupConstructors->setExclusive(TRUE); + GroupConstructors->setColumnLayout(0, Qt::Vertical); + GroupConstructors->layout()->setSpacing(0); + GroupConstructors->layout()->setMargin(0); + GroupConstructorsLayout = new QGridLayout(GroupConstructors->layout()); + GroupConstructorsLayout->setAlignment(Qt::AlignTop); + GroupConstructorsLayout->setSpacing(6); + GroupConstructorsLayout->setMargin(11); + Constructor1 = new QRadioButton(GroupConstructors, "Constructor1"); + Constructor1->setText(tr("" )); + Constructor1->setPixmap(image0); + Constructor1->setChecked(TRUE); + Constructor1->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)1, + (QSizePolicy::SizeType)0, + Constructor1->sizePolicy().hasHeightForWidth())); + Constructor1->setMinimumSize(QSize(50, 0)); + GroupConstructorsLayout->addWidget(Constructor1, 0, 0); + QSpacerItem* spacer = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); + GroupConstructorsLayout->addItem(spacer, 0, 1); + SMESHGUI_SmoothingDlgLayout->addWidget(GroupConstructors, 0, 0); /***************************************************************/ - GroupArguments = new QGroupBox( this, "GroupArguments" ); - GroupArguments->setTitle( tr( "SMESH_ARGUMENTS" ) ); - GroupArguments->setColumnLayout(0, Qt::Vertical ); - GroupArguments->layout()->setSpacing( 0 ); - GroupArguments->layout()->setMargin( 0 ); - GroupArgumentsLayout = new QGridLayout( GroupArguments->layout() ); - GroupArgumentsLayout->setAlignment( Qt::AlignTop ); - GroupArgumentsLayout->setSpacing( 6 ); - GroupArgumentsLayout->setMargin( 11 ); + GroupButtons = new QGroupBox(this, "GroupButtons"); + GroupButtons->setGeometry(QRect(10, 10, 281, 48)); + GroupButtons->setTitle(tr("")); + GroupButtons->setColumnLayout(0, Qt::Vertical); + GroupButtons->layout()->setSpacing(0); + GroupButtons->layout()->setMargin(0); + GroupButtonsLayout = new QGridLayout(GroupButtons->layout()); + GroupButtonsLayout->setAlignment(Qt::AlignTop); + GroupButtonsLayout->setSpacing(6); + GroupButtonsLayout->setMargin(11); + buttonCancel = new QPushButton(GroupButtons, "buttonCancel"); + buttonCancel->setText(tr("SMESH_BUT_CLOSE" )); + buttonCancel->setAutoDefault(TRUE); + GroupButtonsLayout->addWidget(buttonCancel, 0, 3); + buttonApply = new QPushButton(GroupButtons, "buttonApply"); + buttonApply->setText(tr("SMESH_BUT_APPLY" )); + buttonApply->setAutoDefault(TRUE); + GroupButtonsLayout->addWidget(buttonApply, 0, 1); + QSpacerItem* spacer_9 = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); + GroupButtonsLayout->addItem(spacer_9, 0, 2); + buttonOk = new QPushButton(GroupButtons, "buttonOk"); + buttonOk->setText(tr("SMESH_BUT_OK" )); + buttonOk->setAutoDefault(TRUE); + buttonOk->setDefault(TRUE); + GroupButtonsLayout->addWidget(buttonOk, 0, 0); + SMESHGUI_SmoothingDlgLayout->addWidget(GroupButtons, 2, 0); + + /***************************************************************/ + GroupArguments = new QGroupBox(this, "GroupArguments"); + GroupArguments->setTitle(tr("SMESH_ARGUMENTS")); + GroupArguments->setColumnLayout(0, Qt::Vertical); + GroupArguments->layout()->setSpacing(0); + GroupArguments->layout()->setMargin(0); + GroupArgumentsLayout = new QGridLayout(GroupArguments->layout()); + GroupArgumentsLayout->setAlignment(Qt::AlignTop); + GroupArgumentsLayout->setSpacing(6); + GroupArgumentsLayout->setMargin(11); // Controls for elements selection - TextLabelElements = new QLabel( GroupArguments, "TextLabelElements" ); - TextLabelElements->setText( tr( "SMESH_ID_ELEMENTS" ) ); - GroupArgumentsLayout->addWidget( TextLabelElements, 0, 0 ); + TextLabelElements = new QLabel(GroupArguments, "TextLabelElements"); + TextLabelElements->setText(tr("SMESH_ID_ELEMENTS" )); + GroupArgumentsLayout->addWidget(TextLabelElements, 0, 0); - SelectElementsButton = new QPushButton( GroupArguments, "SelectElementsButton" ); - SelectElementsButton->setText( tr( "" ) ); - SelectElementsButton->setPixmap( image1 ); - SelectElementsButton->setToggleButton( FALSE ); - GroupArgumentsLayout->addWidget( SelectElementsButton, 0, 1 ); + SelectElementsButton = new QPushButton(GroupArguments, "SelectElementsButton"); + SelectElementsButton->setText(tr("" )); + SelectElementsButton->setPixmap(image1); + SelectElementsButton->setToggleButton(FALSE); + GroupArgumentsLayout->addWidget(SelectElementsButton, 0, 1); - LineEditElements = new QLineEdit( GroupArguments, "LineEditElements" ); - LineEditElements->setValidator( new SMESHGUI_IdValidator( this, "validator" )); - GroupArgumentsLayout->addWidget( LineEditElements, 0, 2 ); + LineEditElements = new QLineEdit(GroupArguments, "LineEditElements"); + LineEditElements->setValidator(new SMESHGUI_IdValidator(this, "validator")); + GroupArgumentsLayout->addWidget(LineEditElements, 0, 2); // Control for the whole mesh selection - CheckBoxMesh = new QCheckBox( GroupArguments, "CheckBoxMesh" ); - CheckBoxMesh->setText( tr( "SMESH_SELECT_WHOLE_MESH" ) ); - GroupArgumentsLayout->addMultiCellWidget( CheckBoxMesh, 1, 1, 0, 2 ); + CheckBoxMesh = new QCheckBox(GroupArguments, "CheckBoxMesh"); + CheckBoxMesh->setText(tr("SMESH_SELECT_WHOLE_MESH")); + GroupArgumentsLayout->addMultiCellWidget(CheckBoxMesh, 1, 1, 0, 2); // Controls for nodes selection - TextLabelNodes = new QLabel( GroupArguments, "TextLabelNodes" ); - TextLabelNodes->setText( tr( "FIXED_NODES_IDS" ) ); - GroupArgumentsLayout->addWidget( TextLabelNodes, 2, 0 ); + TextLabelNodes = new QLabel(GroupArguments, "TextLabelNodes"); + TextLabelNodes->setText(tr("FIXED_NODES_IDS")); + GroupArgumentsLayout->addWidget(TextLabelNodes, 2, 0); - SelectNodesButton = new QPushButton( GroupArguments, "SelectNodesButton" ); - SelectNodesButton->setText( tr( "" ) ); - SelectNodesButton->setPixmap( image1 ); - SelectNodesButton->setToggleButton( FALSE ); - GroupArgumentsLayout->addWidget( SelectNodesButton, 2, 1 ); + SelectNodesButton = new QPushButton(GroupArguments, "SelectNodesButton"); + SelectNodesButton->setText(tr("" )); + SelectNodesButton->setPixmap(image1); + SelectNodesButton->setToggleButton(FALSE); + GroupArgumentsLayout->addWidget(SelectNodesButton, 2, 1); - LineEditNodes = new QLineEdit( GroupArguments, "LineEditNodes" ); - LineEditNodes->setValidator( new SMESHGUI_IdValidator( this, "validator" )); - GroupArgumentsLayout->addWidget( LineEditNodes, 2, 2 ); + LineEditNodes = new QLineEdit(GroupArguments, "LineEditNodes"); + LineEditNodes->setValidator(new SMESHGUI_IdValidator(this, "validator")); + GroupArgumentsLayout->addWidget(LineEditNodes, 2, 2); // Controls for method selection - TextLabelMethod = new QLabel( GroupArguments, "TextLabelMethod" ); - TextLabelMethod->setText( tr( "METHOD" ) ); - GroupArgumentsLayout->addMultiCellWidget( TextLabelMethod, 3, 3, 0, 1 ); + TextLabelMethod = new QLabel(GroupArguments, "TextLabelMethod"); + TextLabelMethod->setText(tr("METHOD" )); + GroupArgumentsLayout->addMultiCellWidget(TextLabelMethod, 3, 3, 0, 1); - ComboBoxMethod = new QComboBox( GroupArguments, "ComboBoxMethod" ); - GroupArgumentsLayout->addWidget( ComboBoxMethod, 3, 2 ); + ComboBoxMethod = new QComboBox(GroupArguments, "ComboBoxMethod"); + GroupArgumentsLayout->addWidget(ComboBoxMethod, 3, 2); // Controls for iteration limit defining - TextLabelLimit = new QLabel( GroupArguments, "TextLabelLimit" ); - TextLabelLimit->setText( tr( "ITERATION_LIMIT" ) ); - GroupArgumentsLayout->addMultiCellWidget( TextLabelLimit, 4, 4, 0, 1 ); + TextLabelLimit = new QLabel(GroupArguments, "TextLabelLimit"); + TextLabelLimit->setText(tr("ITERATION_LIMIT" )); + GroupArgumentsLayout->addMultiCellWidget(TextLabelLimit, 4, 4, 0, 1); SpinBox_IterationLimit = new QSpinBox(GroupArguments, "SpinBox_IterationLimit"); - GroupArgumentsLayout->addWidget( SpinBox_IterationLimit, 4, 2 ); + GroupArgumentsLayout->addWidget(SpinBox_IterationLimit, 4, 2); // Controls for max. aspect ratio defining - TextLabelAspectRatio = new QLabel( GroupArguments, "TextLabelAspectRatio" ); - TextLabelAspectRatio->setText( tr( "MAX_ASPECT_RATIO" ) ); - GroupArgumentsLayout->addMultiCellWidget( TextLabelAspectRatio, 5, 5, 0, 1 ); + TextLabelAspectRatio = new QLabel(GroupArguments, "TextLabelAspectRatio"); + TextLabelAspectRatio->setText(tr("MAX_ASPECT_RATIO")); + GroupArgumentsLayout->addMultiCellWidget(TextLabelAspectRatio, 5, 5, 0, 1); SpinBox_AspectRatio = new SMESHGUI_SpinBox(GroupArguments, "SpinBox_AspectRatio"); - GroupArgumentsLayout->addWidget( SpinBox_AspectRatio, 5, 2 ); + GroupArgumentsLayout->addWidget(SpinBox_AspectRatio, 5, 2); + + // Check box "Is Parametric" + CheckBoxParametric = new QCheckBox( GroupArguments, "CheckBoxParametric" ); + CheckBoxParametric->setText( tr( "IS_PARAMETRIC" ) ); + GroupArgumentsLayout->addMultiCellWidget( CheckBoxParametric, 6, 6, 0, 2 ); - SMESHGUI_SmoothingDlgLayout->addWidget( GroupArguments, 1, 0 ); - + SMESHGUI_SmoothingDlgLayout->addWidget(GroupArguments, 1, 0); + /* Initialisations */ ComboBoxMethod->insertItem(tr("LAPLACIAN")); ComboBoxMethod->insertItem(tr("CENTROIDAL")); + ComboBoxMethod->setCurrentItem(0); + + CheckBoxParametric->setChecked( TRUE ); + QIntValidator* anIntValidator = new QIntValidator(SpinBox_IterationLimit); SpinBox_IterationLimit->setValidator(anIntValidator); - SpinBox_IterationLimit->setRange( 1, 999999 ); - SpinBox_AspectRatio->RangeStepAndValidator( 0.0, +999999.999, 0.1, 3 ); + SpinBox_IterationLimit->setRange(1, 999999); + SpinBox_IterationLimit->setValue(20); + SpinBox_AspectRatio->RangeStepAndValidator(0.0, +999999.999, 0.1, 3); + SpinBox_AspectRatio->SetValue(1.1); GroupArguments->show(); - myConstructorId = 0 ; - Constructor1->setChecked( TRUE ); - mySelection = Sel; + myConstructorId = 0; + Constructor1->setChecked(TRUE); - mySMESHGUI = SMESHGUI::GetSMESHGUI() ; - mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; - - // Costruction of the logical filter - SMESH_ListOfFilter aListOfFilters; - Handle(SMESH_TypeFilter) aMeshOrSubMeshFilter = new SMESH_TypeFilter( MESHorSUBMESH ); - if ( !aMeshOrSubMeshFilter.IsNull() ) - aListOfFilters.Append( aMeshOrSubMeshFilter ); - Handle(SMESH_TypeFilter) aSmeshGroupFilter = new SMESH_TypeFilter( GROUP ); - if ( !aSmeshGroupFilter.IsNull() ) - aListOfFilters.Append( aSmeshGroupFilter ); - - myMeshOrSubMeshOrGroupFilter = new SMESH_LogicalFilter( aListOfFilters, SMESH_LogicalFilter::LO_OR ); + mySMESHGUI->SetActiveDialogBox(this); + + // Costruction of the logical filter for the elements: mesh/sub-mesh/group + SMESH_TypeFilter* aMeshOrSubMeshFilter = new SMESH_TypeFilter (MESHorSUBMESH); + SMESH_TypeFilter* aSmeshGroupFilter = new SMESH_TypeFilter (GROUP); + + QPtrList aListOfFilters; + if (aMeshOrSubMeshFilter) aListOfFilters.append(aMeshOrSubMeshFilter); + if (aSmeshGroupFilter) aListOfFilters.append(aSmeshGroupFilter); + + myMeshOrSubMeshOrGroupFilter = + new SMESH_LogicalFilter (aListOfFilters, SMESH_LogicalFilter::LO_OR); Init(); - /* signals and slots connections */ - connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); - connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ; - connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) ); - connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) ); - - connect( SelectElementsButton, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; - connect( SelectNodesButton, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; - connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; - connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + + /***************************************************************/ + // signals and slots connections + connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel())); + connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); + connect(GroupConstructors, SIGNAL(clicked(int)), SLOT(ConstructorsClicked(int))); + + connect(SelectElementsButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument())); + connect(SelectNodesButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument())); + connect(mySMESHGUI, SIGNAL (SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog())); + connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); /* to close dialog if study change */ - connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; - connect( LineEditElements, SIGNAL( textChanged( const QString& )), - SLOT( onTextChange( const QString& ))); - connect( LineEditNodes, SIGNAL( textChanged( const QString& )), - SLOT( onTextChange( const QString& ))); - connect( CheckBoxMesh, SIGNAL( toggled( bool )), - SLOT( onSelectMesh( bool ))); - + connect(mySMESHGUI, SIGNAL (SignalCloseAllDialogs()), this, SLOT(ClickOnCancel())); + connect(LineEditElements, SIGNAL(textChanged(const QString&)), + SLOT(onTextChange(const QString&))); + connect(LineEditNodes, SIGNAL(textChanged(const QString&)), + SLOT(onTextChange(const QString&))); + connect(CheckBoxMesh, SIGNAL(toggled(bool)), + SLOT(onSelectMesh(bool))); + + /***************************************************************/ /* Move widget on the botton right corner of main widget */ - int x, y ; - mySMESHGUI->DefineDlgPosition( this, x, y ) ; - this->move( x, y ) ; - this->show() ; /* displays Dialog */ + int x, y; + mySMESHGUI->DefineDlgPosition(this, x, y); + this->move(x, y); + this->show(); // displays Dialog } //================================================================================= // function : ~SMESHGUI_SmoothingDlg() -// purpose : Destroys the object and frees any allocated resources +// purpose : destructor //================================================================================= SMESHGUI_SmoothingDlg::~SMESHGUI_SmoothingDlg() { // no need to delete child widgets, Qt does it all for us } - //================================================================================= // function : Init() -// purpose : +// purpose : initialization //================================================================================= void SMESHGUI_SmoothingDlg::Init() { - myBusy = false; - - ComboBoxMethod->setCurrentItem(0); - - SpinBox_IterationLimit->setValue(20); - SpinBox_AspectRatio->SetValue(1.1); - + myBusy = false; + +// ComboBoxMethod->setCurrentItem(0); + +// SpinBox_IterationLimit->setValue(20); +// SpinBox_AspectRatio->SetValue(1.1); + myEditCurrentArgument = LineEditElements; LineEditElements->setFocus(); + LineEditNodes->clear(); myElementsId = ""; - myNbOkElements = 0 ; - myNbOkNodes = 0 ; + myNbOkElements = 0; + myNbOkNodes = 0; myActor = 0; myMesh = SMESH::SMESH_Mesh::_nil(); - - CheckBoxMesh->setChecked(false); - onSelectMesh( false ); -} + CheckBoxMesh->setChecked(false); + onSelectMesh(false); +} //================================================================================= // function : ConstructorsClicked() // purpose : Radio button management //================================================================================= -void SMESHGUI_SmoothingDlg::ConstructorsClicked(int constructorId) +void SMESHGUI_SmoothingDlg::ConstructorsClicked (int constructorId) { - return ; } - //================================================================================= // function : ClickOnApply() -// purpose : +// purpose : Called when user presses button //================================================================================= void SMESHGUI_SmoothingDlg::ClickOnApply() { - if (mySMESHGUI->ActiveStudyLocked()) + if (mySMESHGUI->isActiveStudyLocked()) return; - - if ( myNbOkElements && (myNbOkNodes || LineEditNodes->text().stripWhiteSpace().isEmpty())) - { - QStringList aListElementsId = QStringList::split( " ", myElementsId, false); - QStringList aListNodesId = QStringList::split( " ", LineEditNodes->text(), false); - SMESH::long_array_var anElementsId = new SMESH::long_array; - SMESH::long_array_var aNodesId = new SMESH::long_array; + if (myNbOkElements && + (myNbOkNodes || LineEditNodes->text().stripWhiteSpace().isEmpty())) { + QStringList aListElementsId = QStringList::split(" ", myElementsId, false); + QStringList aListNodesId = QStringList::split(" ", LineEditNodes->text(), false); - anElementsId->length( aListElementsId.count() ); - for ( int i = 0; i < aListElementsId.count(); i++ ) - anElementsId[i] = aListElementsId[i].toInt(); - - if (myNbOkNodes) - { - aNodesId->length( aListNodesId.count() ); - for ( int i = 0; i < aListNodesId.count(); i++ ) - aNodesId[i] = aListNodesId[i].toInt(); - } - else - anElementsId->length(0); - - long anIterationLimit = (long)SpinBox_IterationLimit->value(); - double aMaxAspectRatio = SpinBox_AspectRatio->GetValue(); + SMESH::long_array_var anElementsId = new SMESH::long_array; + SMESH::long_array_var aNodesId = new SMESH::long_array; - SMESH::SMESH_MeshEditor::Smooth_Method aMethod = SMESH::SMESH_MeshEditor::LAPLACIAN_SMOOTH; - if (ComboBoxMethod->currentItem() > 0) - aMethod = SMESH::SMESH_MeshEditor::CENTROIDAL_SMOOTH; - - bool aResult = false; - try - { - SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor(); - QApplication::setOverrideCursor(Qt::waitCursor); - aResult = aMeshEditor->Smooth(anElementsId.inout(), aNodesId.inout(), anIterationLimit, aMaxAspectRatio, aMethod); - QApplication::restoreOverrideCursor(); - } - catch( ... ) - { - } - - if ( aResult ) - { - Handle(SALOME_InteractiveObject) anIO = myActor->getIO(); - mySelection->ClearIObjects(); - SMESH::UpdateView(); - mySelection->AddIObject( anIO, false ); - Init(); - } + anElementsId->length(aListElementsId.count()); + for (int i = 0; i < aListElementsId.count(); i++) + anElementsId[i] = aListElementsId[i].toInt(); + + if (myNbOkNodes) { + aNodesId->length(aListNodesId.count()); + for (int i = 0; i < aListNodesId.count(); i++) + aNodesId[i] = aListNodesId[i].toInt(); + } else { + aNodesId->length(0); } - + + long anIterationLimit = (long)SpinBox_IterationLimit->value(); + double aMaxAspectRatio = SpinBox_AspectRatio->GetValue(); + + SMESH::SMESH_MeshEditor::Smooth_Method aMethod = SMESH::SMESH_MeshEditor::LAPLACIAN_SMOOTH; + if (ComboBoxMethod->currentItem() > 0) + aMethod = SMESH::SMESH_MeshEditor::CENTROIDAL_SMOOTH; + + bool aResult = false; + try { + SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor(); + QApplication::setOverrideCursor(Qt::waitCursor); + if ( CheckBoxParametric->isChecked() ) + aResult = aMeshEditor->SmoothParametric(anElementsId.inout(), aNodesId.inout(), + anIterationLimit, aMaxAspectRatio, aMethod); + else + aResult = aMeshEditor->Smooth(anElementsId.inout(), aNodesId.inout(), + anIterationLimit, aMaxAspectRatio, aMethod); + QApplication::restoreOverrideCursor(); + } catch (...) { + } + + if (aResult) { + Handle(SALOME_InteractiveObject) anIO = myActor->getIO(); + + SALOME_ListIO aList; + aList.Append(anIO); + mySelectionMgr->setSelectedObjects(aList, false); + SMESH::UpdateView(); + Init(); + } + } } //================================================================================= // function : ClickOnOk() -// purpose : +// purpose : Called when user presses button //================================================================================= void SMESHGUI_SmoothingDlg::ClickOnOk() { - ClickOnApply() ; - ClickOnCancel() ; + ClickOnApply(); + ClickOnCancel(); } - //================================================================================= // function : ClickOnCancel() -// purpose : +// purpose : Called when dialog box is closed //================================================================================= void SMESHGUI_SmoothingDlg::ClickOnCancel() { - mySelection->ClearFilters(); - mySelection->ClearIObjects(); + disconnect(mySelectionMgr, 0, this, 0); + mySelectionMgr->clearFilters(); + mySelectionMgr->clearSelected(); + SMESH::SetPickable(); // ??? SMESH::SetPointRepresentation(false); - QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); - disconnect( mySelection, 0, this, 0 ); - mySMESHGUI->ResetState() ; - reject() ; + myViewWindow->SetSelectionMode(ActorSelection); + mySMESHGUI->ResetState(); + reject(); } //======================================================================= -//function : onTextChange -//purpose : +// function : onTextChange() +// purpose : //======================================================================= - -void SMESHGUI_SmoothingDlg::onTextChange(const QString& theNewText) +void SMESHGUI_SmoothingDlg::onTextChange (const QString& theNewText) { QLineEdit* send = (QLineEdit*)sender(); - if ( myBusy ) return; + // return if busy + if (myBusy) return; + + // set busy flag myBusy = true; - + if (send == LineEditElements) myNbOkElements = 0; else if (send == LineEditNodes) myNbOkNodes = 0; - - buttonOk->setEnabled( false ); - buttonApply->setEnabled( false ); - + + buttonOk->setEnabled(false); + buttonApply->setEnabled(false); + // hilight entered elements/nodes SMDS_Mesh* aMesh = 0; - if ( myActor ) + if (myActor) aMesh = myActor->GetObject()->GetMesh(); - - if ( aMesh ) { - mySelection->ClearIObjects(); - mySelection->AddIObject( myActor->getIO() ); - - QStringList aListId = QStringList::split( " ", theNewText, false); - + + if (aMesh) { + //mySelectionMgr->clearSelected(); + //mySelectionMgr->AddIObject(myActor->getIO()); + SALOME_ListIO aList; + aList.Append(myActor->getIO()); + mySelectionMgr->setSelectedObjects(aList, false); + + QStringList aListId = QStringList::split(" ", theNewText, false); + if (send == LineEditElements) { - for ( int i = 0; i < aListId.count(); i++ ) { - const SMDS_MeshElement * e = aMesh->FindElement( aListId[ i ].toInt() ); - if ( e ) { - if ( !mySelection->IsIndexSelected( myActor->getIO(), e->GetID() )) - mySelection->AddOrRemoveIndex (myActor->getIO(), e->GetID(), true); + const Handle(SALOME_InteractiveObject)& anIO = myActor->getIO(); + TColStd_IndexedMapOfInteger selectedIndices; + TColStd_MapOfInteger newIndices; + mySelector->GetIndex( anIO, selectedIndices ); + for (int i = 0; i < aListId.count(); i++) { + const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt()); + if (e) { + //if (!mySelectionMgr->IsIndexSelected(myActor->getIO(), e->GetID())) { + if (selectedIndices.Add(e->GetID())) { + //mySelectionMgr->AddOrRemoveIndex(myActor->getIO(), e->GetID(), true); + newIndices.Add(e->GetID()); + } myNbOkElements++; } } + if (newIndices.Extent() > 0) { + mySelector->AddOrRemoveIndex(anIO, newIndices, true); + myViewWindow->highlight( anIO, true, true ); + } myElementsId = theNewText; - } - else if (send == LineEditNodes) { - for ( int i = 0; i < aListId.count(); i++ ) { - const SMDS_MeshNode * n = aMesh->FindNode( aListId[ i ].toInt() ); - if ( n ) { - if ( !mySelection->IsIndexSelected( myActor->getIO(), n->GetID() )) - mySelection->AddOrRemoveIndex (myActor->getIO(), n->GetID(), true); + + } else if (send == LineEditNodes) { + TColStd_IndexedMapOfInteger selectedIndices; + TColStd_MapOfInteger newIndices; + mySelector->GetIndex(myActor->getIO(), selectedIndices); + + for (int i = 0; i < aListId.count(); i++) { + const SMDS_MeshNode * n = aMesh->FindNode(aListId[ i ].toInt()); + if (n) { + //if (!mySelectionMgr->IsIndexSelected(myActor->getIO(), n->GetID())) { + if (selectedIndices.Add(n->GetID())) { + //mySelectionMgr->AddOrRemoveIndex (myActor->getIO(), n->GetID(), true); + newIndices.Add(n->GetID()); + } myNbOkNodes++; } } + if (newIndices.Extent() > 0) + { + mySelector->AddOrRemoveIndex(myActor->getIO(), newIndices, true); + myViewWindow->highlight( myActor->getIO(), true, true ); + } } } - - if ( myNbOkElements && (myNbOkNodes || LineEditNodes->text().stripWhiteSpace().isEmpty()) ) { - buttonOk->setEnabled( true ); - buttonApply->setEnabled( true ); + + if (myNbOkElements && (myNbOkNodes || LineEditNodes->text().stripWhiteSpace().isEmpty())) { + buttonOk->setEnabled(true); + buttonApply->setEnabled(true); } - + myBusy = false; } @@ -464,125 +524,115 @@ void SMESHGUI_SmoothingDlg::onTextChange(const QString& theNewText) //================================================================================= void SMESHGUI_SmoothingDlg::SelectionIntoArgument() { - if ( myBusy ) return; + if (myBusy) return; // clear myActor = 0; QString aString = ""; myBusy = true; - if (myEditCurrentArgument == (QWidget*)LineEditElements) - { - LineEditElements->setText( aString ); - myNbOkElements = 0; - buttonOk->setEnabled( false ); - buttonApply->setEnabled( false ); - } + if (myEditCurrentArgument == (QWidget*)LineEditElements) { + LineEditElements->setText(aString); + myNbOkElements = 0; + buttonOk->setEnabled(false); + buttonApply->setEnabled(false); + } myBusy = false; - if ( !GroupButtons->isEnabled() ) // inactive + if (!GroupButtons->isEnabled()) // inactive return; - + // get selected mesh - - int nbSel = mySelection->IObjectCount(); - if(nbSel != 1) + SALOME_ListIO aList; + mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type()); + int nbSel = aList.Extent(); + if (nbSel != 1) return; - - Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject(); + + Handle(SALOME_InteractiveObject) IO = aList.First(); myMesh = SMESH::GetMeshByIO(IO); - if(myMesh->_is_nil()) + if (myMesh->_is_nil()) return; + myActor = SMESH::FindActorByObject(myMesh); if (!myActor) return; - + int aNbUnits = 0; - - if (myEditCurrentArgument == LineEditElements) - { - myElementsId = ""; - - if (CheckBoxMesh->isChecked()) - { - SMESH::GetNameOfSelectedIObjects(mySelection, aString); - - if(!SMESH::IObjectToInterface(IO)->_is_nil()) //MESH - { - // get IDs from mesh - SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh(); - if (!aSMDSMesh) - return; - - for (int i = aSMDSMesh->MinElementID(); i <= aSMDSMesh->MaxElementID(); i++ ) - { - const SMDS_MeshElement * e = aSMDSMesh->FindElement( i ); - if ( e ) { - myElementsId += QString(" %1").arg(i); - aNbUnits++; - } - } - } - else if (!SMESH::IObjectToInterface(IO)->_is_nil()) //SUBMESH - { - // get submesh - SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface(IO) ; - - // get IDs from submesh - SMESH::long_array_var anElementsIds = new SMESH::long_array; - anElementsIds = aSubMesh->GetElementsId(); - for ( int i = 0; i < anElementsIds->length(); i++ ) - myElementsId += QString(" %1").arg(anElementsIds[i]); - aNbUnits = anElementsIds->length(); - } - else // GROUP - { - // get smesh group - SMESH::SMESH_GroupBase_var aGroup - = SMESH::IObjectToInterface(IO); - if (aGroup->_is_nil()) - return; - - // get IDs from smesh group - SMESH::long_array_var anElementsIds = new SMESH::long_array; - anElementsIds = aGroup->GetListOfID(); - for ( int i = 0; i < anElementsIds->length(); i++ ) - myElementsId += QString(" %1").arg(anElementsIds[i]); - aNbUnits = anElementsIds->length(); - } - } - else - { - aNbUnits = SMESH::GetNameOfSelectedElements(mySelection, aString) ; - myElementsId = aString; - } + + if (myEditCurrentArgument == LineEditElements) { + myElementsId = ""; + + if (CheckBoxMesh->isChecked()) { + SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString); + + if (!SMESH::IObjectToInterface(IO)->_is_nil()) { //MESH + // get IDs from mesh + SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh(); + if (!aSMDSMesh) + return; + + for (int i = aSMDSMesh->MinElementID(); i <= aSMDSMesh->MaxElementID(); i++ ) { + const SMDS_MeshElement * e = aSMDSMesh->FindElement(i); + if (e) { + myElementsId += QString(" %1").arg(i); + aNbUnits++; + } + } + } else if (!SMESH::IObjectToInterface(IO)->_is_nil()) { //SUBMESH + // get submesh + SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface(IO); + + // get IDs from submesh + SMESH::long_array_var anElementsIds = new SMESH::long_array; + anElementsIds = aSubMesh->GetElementsId(); + for (int i = 0; i < anElementsIds->length(); i++) { + myElementsId += QString(" %1").arg(anElementsIds[i]); + } + aNbUnits = anElementsIds->length(); + } else { // GROUP + // get smesh group + SMESH::SMESH_GroupBase_var aGroup = + SMESH::IObjectToInterface(IO); + if (aGroup->_is_nil()) + return; + + // get IDs from smesh group + SMESH::long_array_var anElementsIds = new SMESH::long_array; + anElementsIds = aGroup->GetListOfID(); + for (int i = 0; i < anElementsIds->length(); i++) { + myElementsId += QString(" %1").arg(anElementsIds[i]); + } + aNbUnits = anElementsIds->length(); + } + } else { + aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, myActor->getIO(), aString); + myElementsId = aString; } - else if (myEditCurrentArgument == LineEditNodes && !myMesh->_is_nil() && myActor) - { - myNbOkNodes = 0; - aNbUnits = SMESH::GetNameOfSelectedNodes(mySelection, aString) ; - } - - if(aNbUnits < 1) - return ; + } else if (myEditCurrentArgument == LineEditNodes && !myMesh->_is_nil() && myActor) { + myNbOkNodes = 0; + aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, myActor->getIO(), aString); + } else { + } + + if (aNbUnits < 1) + return; myBusy = true; - myEditCurrentArgument->setText( aString ); + myEditCurrentArgument->setText(aString); myBusy = false; - + // OK if (myEditCurrentArgument == LineEditElements) myNbOkElements = true; else if (myEditCurrentArgument == LineEditNodes) myNbOkNodes = true; - - if (myNbOkElements) - { - buttonOk->setEnabled( true ); - buttonApply->setEnabled( true ); - } -} + if (myNbOkElements) { + buttonOk->setEnabled(true); + buttonApply->setEnabled(true); + } +} //================================================================================= // function : SetEditCurrentArgument() @@ -591,143 +641,127 @@ void SMESHGUI_SmoothingDlg::SelectionIntoArgument() void SMESHGUI_SmoothingDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); - - switch (myConstructorId) + + switch (myConstructorId) { + case 0: /* default constructor */ { - case 0: /* default constructor */ - { - disconnect( mySelection, 0, this, 0 ); - mySelection->ClearIObjects(); - mySelection->ClearFilters(); - - if(send == SelectElementsButton) { - myEditCurrentArgument = LineEditElements; - SMESH::SetPointRepresentation(false); - if (CheckBoxMesh->isChecked()) - { - QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); - mySelection->AddFilter(myMeshOrSubMeshOrGroupFilter); - } - else - QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true ); + disconnect(mySelectionMgr, 0, this, 0); + mySelectionMgr->clearSelected(); + mySelectionMgr->clearFilters(); + + if (send == SelectElementsButton) { + myEditCurrentArgument = LineEditElements; + SMESH::SetPointRepresentation(false); + if (CheckBoxMesh->isChecked()) { + mySelectionMgr->setSelectionModes(ActorSelection); + mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter); + } else { + myViewWindow->SetSelectionMode(CellSelection); } - else if (send == SelectNodesButton) - { - myEditCurrentArgument = LineEditNodes; - SMESH::SetPointRepresentation(true); - QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true ); - } - - myEditCurrentArgument->setFocus(); - connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); - SelectionIntoArgument() ; - break; + } else if (send == SelectNodesButton) { + myEditCurrentArgument = LineEditNodes; + SMESH::SetPointRepresentation(true); + myViewWindow->SetSelectionMode(NodeSelection); } + + myEditCurrentArgument->setFocus(); + connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + SelectionIntoArgument(); + break; } + } } //================================================================================= // function : DeactivateActiveDialog() -// purpose : +// purpose : Deactivates this dialog //================================================================================= void SMESHGUI_SmoothingDlg::DeactivateActiveDialog() { - if ( GroupConstructors->isEnabled() ) { - GroupConstructors->setEnabled(false) ; - GroupArguments->setEnabled(false) ; - GroupButtons->setEnabled(false) ; - mySMESHGUI->ResetState() ; - mySMESHGUI->SetActiveDialogBox(0) ; + if (GroupConstructors->isEnabled()) { + GroupConstructors->setEnabled(false); + GroupArguments->setEnabled(false); + GroupButtons->setEnabled(false); + mySMESHGUI->ResetState(); + mySMESHGUI->SetActiveDialogBox(0); } } - //================================================================================= // function : ActivateThisDialog() -// purpose : +// purpose : Activates this dialog //================================================================================= void SMESHGUI_SmoothingDlg::ActivateThisDialog() { - /* Emit a signal to deactivate the active dialog */ - mySMESHGUI->EmitSignalDeactivateDialog() ; - GroupConstructors->setEnabled(true) ; - GroupArguments->setEnabled(true) ; - GroupButtons->setEnabled(true) ; - - mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; + // Emit a signal to deactivate the active dialog + mySMESHGUI->EmitSignalDeactivateDialog(); + GroupConstructors->setEnabled(true); + GroupArguments->setEnabled(true); + GroupButtons->setEnabled(true); - QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true ); + mySMESHGUI->SetActiveDialogBox(this); + myViewWindow->SetSelectionMode(CellSelection); SelectionIntoArgument(); } - //================================================================================= // function : enterEvent() -// purpose : +// purpose : Mouse enter event //================================================================================= -void SMESHGUI_SmoothingDlg::enterEvent(QEvent* e) +void SMESHGUI_SmoothingDlg::enterEvent (QEvent*) { - if ( GroupConstructors->isEnabled() ) - return ; - ActivateThisDialog() ; + if (!GroupConstructors->isEnabled()) + ActivateThisDialog(); } - //================================================================================= // function : closeEvent() // purpose : //================================================================================= -void SMESHGUI_SmoothingDlg::closeEvent( QCloseEvent* e ) +void SMESHGUI_SmoothingDlg::closeEvent (QCloseEvent*) { /* same than click on cancel button */ - this->ClickOnCancel() ; + this->ClickOnCancel(); } - //======================================================================= -//function : hideEvent -//purpose : caused by ESC key +// function : hideEvent() +// purpose : caused by ESC key //======================================================================= - -void SMESHGUI_SmoothingDlg::hideEvent ( QHideEvent * e ) +void SMESHGUI_SmoothingDlg::hideEvent (QHideEvent*) { - if ( !isMinimized() ) + if (!isMinimized()) ClickOnCancel(); } - //======================================================================= -//function : onSelectMesh -//purpose : +// function : onSelectMesh() +// purpose : //======================================================================= -void SMESHGUI_SmoothingDlg::onSelectMesh ( bool toSelectMesh ) +void SMESHGUI_SmoothingDlg::onSelectMesh (bool toSelectMesh) { if (toSelectMesh) - TextLabelElements->setText( tr( "SMESH_NAME" ) ); + TextLabelElements->setText(tr("SMESH_NAME")); else - TextLabelElements->setText( tr( "SMESH_ID_ELEMENTS" ) ); - - if (myEditCurrentArgument != LineEditElements) - { - LineEditElements->clear(); - return; - } - - mySelection->ClearFilters() ; + TextLabelElements->setText(tr("SMESH_ID_ELEMENTS")); + + if (myEditCurrentArgument != LineEditElements) { + LineEditElements->clear(); + return; + } + + mySelectionMgr->clearFilters(); SMESH::SetPointRepresentation(false); - - if (toSelectMesh) - { - QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); - mySelection->AddFilter(myMeshOrSubMeshOrGroupFilter); - LineEditElements->setReadOnly(true); - } - else - { - QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true ); - LineEditElements->setReadOnly(false); - onTextChange(LineEditElements->text()); - } - + + if (toSelectMesh) { + mySelectionMgr->setSelectionModes(ActorSelection); + mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter); + LineEditElements->setReadOnly(true); + } else { + myViewWindow->SetSelectionMode(CellSelection); + LineEditElements->setReadOnly(false); + onTextChange(LineEditElements->text()); + } + SelectionIntoArgument(); } diff --git a/src/SMESHGUI/SMESHGUI_SmoothingDlg.h b/src/SMESHGUI/SMESHGUI_SmoothingDlg.h index fafade3f3..fc1fdb215 100644 --- a/src/SMESHGUI/SMESHGUI_SmoothingDlg.h +++ b/src/SMESHGUI/SMESHGUI_SmoothingDlg.h @@ -29,8 +29,10 @@ #ifndef DIALOGBOX_SMOOTHING_H #define DIALOGBOX_SMOOTHING_H -#include "SALOME_Selection.h" +#include "SalomeApp_SelectionMgr.h" + #include "SMESH_LogicalFilter.hxx" + // QT Includes #include @@ -47,6 +49,8 @@ class QSpinBox; class SMESHGUI_SpinBox; class SMESHGUI; class SMESH_Actor; +class SVTK_ViewWindow; +class SVTK_Selector; // IDL Headers @@ -63,28 +67,33 @@ class SMESHGUI_SmoothingDlg : public QDialog Q_OBJECT public: - SMESHGUI_SmoothingDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); + SMESHGUI_SmoothingDlg( SMESHGUI*, + const char* name = 0, + bool modal = FALSE, + WFlags fl = 0); ~SMESHGUI_SmoothingDlg(); private: - void Init() ; - void closeEvent( QCloseEvent* e ) ; - void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */ - void hideEvent ( QHideEvent * ); /* ESC key */ + void Init(); + void closeEvent(QCloseEvent*); + void enterEvent (QEvent*); /* mouse enter the QWidget */ + void hideEvent (QHideEvent*); /* ESC key */ - SMESHGUI* mySMESHGUI ; /* Current SMESHGUI object */ - SALOME_Selection* mySelection ; /* User shape selection */ + SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */ + SalomeApp_SelectionMgr* mySelectionMgr; /* User shape selection */ QString myElementsId; - int myNbOkElements ; /* to check when elements are defined */ - int myNbOkNodes ; /* to check when fixed nodes are defined */ - int myConstructorId ; /* Current constructor id = radio button id */ - QLineEdit* myEditCurrentArgument; /* Current LineEdit */ + int myNbOkElements; /* to check when elements are defined */ + int myNbOkNodes; /* to check when fixed nodes are defined */ + int myConstructorId; /* Current constructor id = radio button id */ + QLineEdit* myEditCurrentArgument; /* Current LineEdit */ + SVTK_ViewWindow* myViewWindow; + SVTK_Selector* mySelector; bool myBusy; SMESH::SMESH_Mesh_var myMesh; SMESH_Actor* myActor; - Handle(SMESH_LogicalFilter) myMeshOrSubMeshOrGroupFilter; + SMESH_LogicalFilter* myMeshOrSubMeshOrGroupFilter; QButtonGroup* GroupConstructors; QRadioButton* Constructor1; @@ -106,6 +115,7 @@ private: QSpinBox* SpinBox_IterationLimit; QLabel* TextLabelAspectRatio; SMESHGUI_SpinBox* SpinBox_AspectRatio; + QCheckBox * CheckBoxParametric; private slots: diff --git a/src/SMESHGUI/SMESHGUI_SpinBox.cxx b/src/SMESHGUI/SMESHGUI_SpinBox.cxx index 017b37b33..54c247a80 100644 --- a/src/SMESHGUI/SMESHGUI_SpinBox.cxx +++ b/src/SMESHGUI/SMESHGUI_SpinBox.cxx @@ -30,6 +30,7 @@ #include "SMESHGUI.h" #include +#include using namespace std; @@ -37,19 +38,18 @@ using namespace std; // class : SMESHGUI_SpinBox() // purpose : constructor of specific widget accepting floats in double precision. //================================================================================= -SMESHGUI_SpinBox::SMESHGUI_SpinBox( QWidget* parent, const char* name ) -: QAD_SpinBoxDbl( parent, name) +SMESHGUI_SpinBox::SMESHGUI_SpinBox (QWidget* parent, const char* name) + : QtxDblSpinBox(parent, name) { } - //================================================================================= // function : SetStep() [SLOT] // purpose : //================================================================================= -void SMESHGUI_SpinBox::SetStep( double newStep ) +void SMESHGUI_SpinBox::SetStep (double newStep) { - setLineStep( newStep ); + setLineStep(newStep); } //================================================================================= @@ -64,16 +64,17 @@ SMESHGUI_SpinBox::~SMESHGUI_SpinBox() // function : SetValue() // purpose : //================================================================================= -void SMESHGUI_SpinBox::SetValue( double v ) +void SMESHGUI_SpinBox::SetValue (double v) { - setValue( v ); + setValue(v); + editor()->setCursorPosition( 0 ); } //================================================================================= // function : GetValue() // purpose : returns a double //================================================================================= -double SMESHGUI_SpinBox::GetValue( ) +double SMESHGUI_SpinBox::GetValue() { return value(); } @@ -82,7 +83,7 @@ double SMESHGUI_SpinBox::GetValue( ) // function : GetString() // purpose : returns a QString //================================================================================= -QString SMESHGUI_SpinBox::GetString( ) +QString SMESHGUI_SpinBox::GetString() { return cleanText(); } @@ -91,9 +92,10 @@ QString SMESHGUI_SpinBox::GetString( ) // function : RangeStepAndValidator() // purpose : //================================================================================= -void SMESHGUI_SpinBox::RangeStepAndValidator( double min, double max, double step, unsigned short decimals ) +void SMESHGUI_SpinBox::RangeStepAndValidator + (double min, double max, double step, unsigned short decimals) { - setRange( min, max ); - setLineStep( step ); - ( ( QDoubleValidator* )validator() )->setRange( min, max, decimals ) ; + setRange(min, max); + setLineStep(step); + ((QDoubleValidator*)validator())->setRange(min, max, decimals); } diff --git a/src/SMESHGUI/SMESHGUI_SpinBox.h b/src/SMESHGUI/SMESHGUI_SpinBox.h index fab8312d2..8655e4dfb 100644 --- a/src/SMESHGUI/SMESHGUI_SpinBox.h +++ b/src/SMESHGUI/SMESHGUI_SpinBox.h @@ -26,35 +26,33 @@ // Module : SMESH // $Header$ -#ifndef SMESHSPINBOX_H -#define SMESHSPINBOX_H +#ifndef SMESH_SPINBOX_H +#define SMESH_SPINBOX_H -#include "QAD_SpinBoxDbl.h" +#include //================================================================================= // class : SMESHGUI_SpinBox -// purpose : Derivated from QAD_SpinBoxDbl class +// purpose : Derivated from QtxDblSpinBox class //================================================================================= -class SMESHGUI_SpinBox : public QAD_SpinBoxDbl +class SMESHGUI_SpinBox : public QtxDblSpinBox { Q_OBJECT -public : +public: + SMESHGUI_SpinBox (QWidget* parent, const char* name = 0); + ~SMESHGUI_SpinBox(); - SMESHGUI_SpinBox( QWidget* parent, const char* name = 0 ) ; - ~SMESHGUI_SpinBox() ; - - void RangeStepAndValidator( double min = -1000000.0, - double max = +1000000.0, - double step = 100.0, - unsigned short decimals = 3 ) ; - void SetValue( double v ) ; - double GetValue() ; - QString GetString() ; - QLineEdit* editor() { return QAD_SpinBoxDbl::editor(); } + void RangeStepAndValidator (double min = -1000000.0, + double max = +1000000.0, + double step = 100.0, + unsigned short decimals = 3); + void SetValue (double v); + double GetValue(); + QString GetString(); + QLineEdit* editor() { return QtxDblSpinBox::editor(); } public slots: - void SetStep( double newStep ); - + void SetStep (double newStep); }; -#endif // SMESHSPINBOX_H +#endif // SMESH_SPINBOX_H diff --git a/src/SMESHGUI/SMESHGUI_StandardMeshInfosDlg.cxx b/src/SMESHGUI/SMESHGUI_StandardMeshInfosDlg.cxx index 37dfbdfed..3b7916938 100644 --- a/src/SMESHGUI/SMESHGUI_StandardMeshInfosDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_StandardMeshInfosDlg.cxx @@ -1,23 +1,23 @@ // SMESH SMESHGUI : GUI for SMESH component // // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org // // // @@ -26,6 +26,26 @@ // Module : SMESH // $Header$ +#include "SMESHGUI_StandardMeshInfosDlg.h" + +#include "SMESHGUI.h" +#include "SMESHGUI_Utils.h" +#include "SMESHGUI_MeshUtils.h" + +#include "SMESH.hxx" +#include "SMESH_TypeFilter.hxx" + +#include "SALOMEDSClient_Study.hxx" +#include "SALOMEDSClient_SObject.hxx" + +#include "SUIT_Session.h" +#include "SUIT_OverrideCursor.h" + +#include "SalomeApp_SelectionMgr.h" +#include "SALOME_ListIO.hxx" + +#include "utilities.h" + // QT Includes #include #include @@ -35,139 +55,128 @@ #include #include -#include "QAD_Application.h" -#include "QAD_Desktop.h" -#include "QAD_WaitCursor.h" - -#include "SMESHGUI_StandardMeshInfosDlg.h" -#include "SMESHGUI_Utils.h" -#include "SMESHGUI_MeshUtils.h" -#include "SMESHGUI.h" - -#include "SMESH.hxx" - // IDL Headers #include "SALOMEconfig.h" #include CORBA_SERVER_HEADER(SMESH_Mesh) #include CORBA_SERVER_HEADER(SMESH_Group) #include CORBA_SERVER_HEADER(GEOM_Gen) -#include "utilities.h" - using namespace std; //================================================================================= /*! * SMESHGUI_StandardMeshInfosDlg::SMESHGUI_StandardMeshInfosDlg - * + * * Constructor */ //================================================================================= -SMESHGUI_StandardMeshInfosDlg::SMESHGUI_StandardMeshInfosDlg( QWidget* parent, const char* name, bool modal, WFlags fl ) - : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose ) +SMESHGUI_StandardMeshInfosDlg::SMESHGUI_StandardMeshInfosDlg (QWidget* parent, const char* name, + bool modal, WFlags fl) + : QDialog(parent, name, modal, WStyle_Customize | WStyle_NormalBorder | + WStyle_Title | WStyle_SysMenu | WDestructiveClose) { - if ( !name ) - setName( "SMESHGUI_StandardMeshInfosDlg" ); - setCaption( tr( "SMESH_STANDARD_MESHINFO_TITLE" ) ); - setSizeGripEnabled( TRUE ); + if (!name) + setName("SMESHGUI_StandardMeshInfosDlg"); + setCaption(tr("SMESH_STANDARD_MESHINFO_TITLE" )); + setSizeGripEnabled(TRUE); myStartSelection = true; myIsActiveWindow = true; // dialog layout - QGridLayout* aDlgLayout = new QGridLayout( this ); - aDlgLayout->setSpacing( 6 ); - aDlgLayout->setMargin( 11 ); - - // mesh group box - myMeshGroup = new QGroupBox( this, "myMeshGroup" ); - myMeshGroup->setTitle( tr( "SMESH_MESH" ) ); - myMeshGroup->setColumnLayout(0, Qt::Vertical ); - myMeshGroup->layout()->setSpacing( 0 ); - myMeshGroup->layout()->setMargin( 0 ); - QGridLayout* myMeshGroupLayout = new QGridLayout( myMeshGroup->layout() ); - myMeshGroupLayout->setAlignment( Qt::AlignTop ); - myMeshGroupLayout->setSpacing( 6 ); - myMeshGroupLayout->setMargin( 11 ); - - // select button, label and line edit with mesh name - myNameLab = new QLabel( myMeshGroup, "myNameLab" ); - myNameLab->setText( tr( "SMESH_NAME" ) ); - myMeshGroupLayout->addWidget( myNameLab, 0, 0 ); + QGridLayout* aDlgLayout = new QGridLayout(this); + aDlgLayout->setSpacing(6); + aDlgLayout->setMargin(11); - QPixmap image0( QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr( "ICON_SELECT" ) ) ); - mySelectBtn = new QPushButton( myMeshGroup, "mySelectBtn" ); - mySelectBtn->setPixmap( image0 ); - mySelectBtn->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) ); - myMeshGroupLayout->addWidget( mySelectBtn, 0, 1 ); - - myMeshLine = new QLineEdit( myMeshGroup, "myMeshLine" ); - myMeshGroupLayout->addWidget( myMeshLine, 0, 2 ); - - aDlgLayout->addWidget( myMeshGroup, 0, 0 ); + // mesh group box + myMeshGroup = new QGroupBox(this, "myMeshGroup"); + myMeshGroup->setTitle(tr("SMESH_MESH")); + myMeshGroup->setColumnLayout(0, Qt::Vertical); + myMeshGroup->layout()->setSpacing(0); + myMeshGroup->layout()->setMargin(0); + QGridLayout* myMeshGroupLayout = new QGridLayout(myMeshGroup->layout()); + myMeshGroupLayout->setAlignment(Qt::AlignTop); + myMeshGroupLayout->setSpacing(6); + myMeshGroupLayout->setMargin(11); + + // select button, label and line edit with mesh name + myNameLab = new QLabel(myMeshGroup, "myNameLab"); + myNameLab->setText(tr("SMESH_NAME" )); + myMeshGroupLayout->addWidget(myNameLab, 0, 0); + + QPixmap image0(SUIT_Session::session()->resourceMgr()->loadPixmap("SMESH",tr("ICON_SELECT"))); + mySelectBtn = new QPushButton(myMeshGroup, "mySelectBtn"); + mySelectBtn->setPixmap(image0); + mySelectBtn->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); + myMeshGroupLayout->addWidget(mySelectBtn, 0, 1); + + myMeshLine = new QLineEdit(myMeshGroup, "myMeshLine"); + myMeshGroupLayout->addWidget(myMeshLine, 0, 2); + + aDlgLayout->addWidget(myMeshGroup, 0, 0); // information group box - myInfoGroup = new QGroupBox( this, "myInfoGroup" ); - myInfoGroup->setTitle( tr( "SMESH_INFORMATION" ) ); - myInfoGroup->setColumnLayout(0, Qt::Vertical ); - myInfoGroup->layout()->setSpacing( 0 ); - myInfoGroup->layout()->setMargin( 0 ); - QGridLayout* myInfoGroupLayout = new QGridLayout( myInfoGroup->layout() ); - myInfoGroupLayout->setAlignment( Qt::AlignTop ); - myInfoGroupLayout->setSpacing( 6 ); - myInfoGroupLayout->setMargin( 11 ); - + myInfoGroup = new QGroupBox(this, "myInfoGroup"); + myInfoGroup->setTitle(tr("SMESH_INFORMATION")); + myInfoGroup->setColumnLayout(0, Qt::Vertical); + myInfoGroup->layout()->setSpacing(0); + myInfoGroup->layout()->setMargin(0); + QGridLayout* myInfoGroupLayout = new QGridLayout(myInfoGroup->layout()); + myInfoGroupLayout->setAlignment(Qt::AlignTop); + myInfoGroupLayout->setSpacing(6); + myInfoGroupLayout->setMargin(11); + // information text browser myInfo = new QTextBrowser(myInfoGroup, "myInfo"); - myInfoGroupLayout->addWidget( myInfo, 0, 0 ); + myInfoGroupLayout->addWidget(myInfo, 0, 0); - aDlgLayout->addWidget( myInfoGroup, 1, 0 ); + aDlgLayout->addWidget(myInfoGroup, 1, 0); // buttons group - myButtonsGroup = new QGroupBox( this, "myButtonsGroup" ); - myButtonsGroup->setColumnLayout(0, Qt::Vertical ); - myButtonsGroup->layout()->setSpacing( 0 ); myButtonsGroup->layout()->setMargin( 0 ); - QHBoxLayout* myButtonsGroupLayout = new QHBoxLayout( myButtonsGroup->layout() ); - myButtonsGroupLayout->setAlignment( Qt::AlignTop ); - myButtonsGroupLayout->setSpacing( 6 ); myButtonsGroupLayout->setMargin( 11 ); - + myButtonsGroup = new QGroupBox(this, "myButtonsGroup"); + myButtonsGroup->setColumnLayout(0, Qt::Vertical); + myButtonsGroup->layout()->setSpacing(0); myButtonsGroup->layout()->setMargin(0); + QHBoxLayout* myButtonsGroupLayout = new QHBoxLayout(myButtonsGroup->layout()); + myButtonsGroupLayout->setAlignment(Qt::AlignTop); + myButtonsGroupLayout->setSpacing(6); myButtonsGroupLayout->setMargin(11); + // buttons --> OK button - myOkBtn = new QPushButton( tr( "SMESH_BUT_OK" ), myButtonsGroup, "myOkBtn" ); - myOkBtn->setAutoDefault( TRUE ); myOkBtn->setDefault( TRUE ); + myOkBtn = new QPushButton(tr("SMESH_BUT_OK" ), myButtonsGroup, "myOkBtn"); + myOkBtn->setAutoDefault(TRUE); myOkBtn->setDefault(TRUE); myButtonsGroupLayout->addStretch(); - myButtonsGroupLayout->addWidget( myOkBtn ); + myButtonsGroupLayout->addWidget(myOkBtn); myButtonsGroupLayout->addStretch(); - - aDlgLayout->addWidget( myButtonsGroup, 2, 0 ); - - mySelection = SALOME_Selection::Selection( SMESHGUI::GetSMESHGUI()->GetActiveStudy()->getSelection() ); - SMESHGUI::GetSMESHGUI()->SetActiveDialogBox( this ) ; + + aDlgLayout->addWidget(myButtonsGroup, 2, 0); + + mySelectionMgr = SMESHGUI::selectionMgr(); + SMESHGUI::GetSMESHGUI()->SetActiveDialogBox(this); // connect signals - connect( myOkBtn, SIGNAL( clicked() ), this, SLOT( close() ) ); - connect( mySelectBtn, SIGNAL( clicked() ), this, SLOT( onStartSelection() ) ); - connect( SMESHGUI::GetSMESHGUI(), SIGNAL( SignalCloseAllDialogs() ), this, SLOT( close() ) ) ; - connect( SMESHGUI::GetSMESHGUI(), SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; - connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionChanged() ) ); + connect(myOkBtn, SIGNAL(clicked()), this, SLOT(close())); + connect(mySelectBtn, SIGNAL(clicked()), this, SLOT(onStartSelection())); + connect(SMESHGUI::GetSMESHGUI(), SIGNAL(SignalCloseAllDialogs()), this, SLOT(close())); + connect(SMESHGUI::GetSMESHGUI(), SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog())); + connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(onSelectionChanged())); // resize and move dialog, then show this->setMinimumSize(270, 428); int x, y; - SMESHGUI::GetSMESHGUI()->DefineDlgPosition( this, x, y ); - this->move( x, y ); + SMESHGUI::GetSMESHGUI()->DefineDlgPosition(this, x, y); + this->move(x, y); this->show(); - + // init dialog with current selection - myMeshFilter = new SMESH_TypeFilter( MESH ); - mySelection->AddFilter( myMeshFilter ); + myMeshFilter = new SMESH_TypeFilter (MESH); + mySelectionMgr->installFilter(myMeshFilter); onSelectionChanged(); } //================================================================================= /*! * SMESHGUI_StandardMeshInfosDlg::~SMESHGUI_StandardMeshInfosDlg - * + * * Destructor */ //================================================================================= @@ -182,199 +191,190 @@ SMESHGUI_StandardMeshInfosDlg::~SMESHGUI_StandardMeshInfosDlg() //================================================================================= void SMESHGUI_StandardMeshInfosDlg::DumpMeshInfos() { - QAD_WaitCursor wc; - int nbSel = mySelection->IObjectCount(); + SUIT_OverrideCursor wc; + + SALOME_ListIO aList; + mySelectionMgr->selectedObjects(aList); + + int nbSel = aList.Extent(); myInfo->clear(); - if ( nbSel == 1 ) { + if (nbSel == 1) { myStartSelection = false; - myMeshLine->setText( "" ); - SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO( mySelection->firstIObject() ); - - if ( !aMesh->_is_nil() ) { + myMeshLine->setText(""); + SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(aList.First()); + + if (!aMesh->_is_nil()) { QString aName, anInfo; - SMESH::GetNameOfSelectedIObjects(mySelection, aName); - myMeshLine->setText( aName ); + SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aName); + myMeshLine->setText(aName); int aNbNodes = (int)aMesh->NbNodes(); int aNbEdges = (int)aMesh->NbEdges(); int aNbFaces = (int)aMesh->NbFaces(); int aNbVolumes = (int)aMesh->NbVolumes(); - + int aDimension = 0; double aNbDimElements = 0; if (aNbVolumes > 0) { aNbDimElements = aNbVolumes; aDimension = 3; } - else if(aNbFaces > 0 ) { + else if(aNbFaces > 0) { aNbDimElements = aNbFaces; aDimension = 2; } - else if(aNbEdges > 0 ) { + else if(aNbEdges > 0) { aNbDimElements = aNbEdges; aDimension = 1; } - else if(aNbNodes > 0 ) { + else if(aNbNodes > 0) { aNbDimElements = aNbNodes; aDimension = 0; } - + // information about the mesh anInfo.append(QString("Nb of element of dimension %1: %2
").arg(aDimension).arg(aNbDimElements)); anInfo.append(QString("Nb of nodes: %1

").arg(aNbNodes)); // information about the groups of the mesh - SALOMEDS::Study_var aStudy = SMESH::GetActiveStudyDocument(); - SALOMEDS::SObject_var aMeshSO = aStudy->FindObjectIOR( aStudy->ConvertObjectToIOR(aMesh) ); - SALOMEDS::SObject_var anObj; - + _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); + _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh); + _PTR(SObject) anObj; + bool hasGroup = false; // info about groups on nodes - aMeshSO->FindSubObject(Tag_NodeGroups , anObj); - if ( !anObj->_is_nil() ) - { - SALOMEDS::ChildIterator_var it = aStudy->NewChildIterator(anObj); - if (it->More()) - { - anInfo.append(QString("Groups:

")); - hasGroup = true; - } - for(; it->More(); it->Next()){ - SALOMEDS::SObject_var subObj = it->Value(); - SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( subObj->GetObject() ); - if ( !aGroup->_is_nil() ) - { - anInfo.append(QString("- %1
").arg(aGroup->GetName())); - anInfo.append(QString("%1
").arg("on nodes")); - anInfo.append(QString("%1
").arg(aGroup->Size())); - // check if the group based on geometry - SMESH::SMESH_GroupOnGeom_var aGroupOnGeom = SMESH::SMESH_GroupOnGeom::_narrow(aGroup); - if ( !aGroupOnGeom->_is_nil() ) - { - GEOM::GEOM_Object_var aGroupMainShape = aGroupOnGeom->GetShape(); - QString aShapeName = ""; - SALOMEDS::SObject_var aGeomObj, aRef; - if ( subObj->FindSubObject( 1, aGeomObj ) && aGeomObj->ReferencedObject( aRef )) - aShapeName = aRef->GetName(); - anInfo.append(QString("based on %1 geometry object

").arg(aShapeName)); - } - else - anInfo.append(QString("
")); - } - } - } - + aMeshSO->FindSubObject(Tag_NodeGroups, anObj); + if (anObj) { + _PTR(ChildIterator) it = aStudy->NewChildIterator(anObj); + if (it->More()) { + anInfo.append(QString("Groups:

")); + hasGroup = true; + } + for (; it->More(); it->Next()) { + _PTR(SObject) subObj = it->Value(); + CORBA::Object_var anObject = SMESH::SObjectToObject(subObj); + SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow(anObject); + if (!aGroup->_is_nil()) { + anInfo.append(QString("- %1
").arg(aGroup->GetName())); + anInfo.append(QString("%1
").arg("on nodes")); + anInfo.append(QString("%1
").arg(aGroup->Size())); + // check if the group based on geometry + SMESH::SMESH_GroupOnGeom_var aGroupOnGeom = SMESH::SMESH_GroupOnGeom::_narrow(aGroup); + if (!aGroupOnGeom->_is_nil()) { + GEOM::GEOM_Object_var aGroupMainShape = aGroupOnGeom->GetShape(); + QString aShapeName = ""; + _PTR(SObject) aGeomObj, aRef; + if (subObj->FindSubObject(1, aGeomObj) && aGeomObj->ReferencedObject(aRef)) + aShapeName = aRef->GetName().c_str(); + anInfo.append(QString("based on %1 geometry object

").arg(aShapeName)); + } else { + anInfo.append(QString("
")); + } + } + } + } + // info about groups on edges - anObj = SALOMEDS::SObject::_nil(); - aMeshSO->FindSubObject(Tag_EdgeGroups , anObj); - if ( !anObj->_is_nil() ) - { - SALOMEDS::ChildIterator_var it = aStudy->NewChildIterator(anObj); - if (!hasGroup && it->More()) - { - anInfo.append(QString("Groups:

")); - hasGroup = true; - } - for(; it->More(); it->Next()){ - SALOMEDS::SObject_var subObj = it->Value(); - SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( subObj->GetObject() ); - if ( !aGroup->_is_nil() ) - { - anInfo.append(QString("- %1
").arg(aGroup->GetName())); - anInfo.append(QString("%1
").arg("on edges")); - anInfo.append(QString("%1
").arg(aGroup->Size())); - // check if the group based on geometry - SMESH::SMESH_GroupOnGeom_var aGroupOnGeom = SMESH::SMESH_GroupOnGeom::_narrow(aGroup); - if ( !aGroupOnGeom->_is_nil() ) - { - GEOM::GEOM_Object_var aGroupMainShape = aGroupOnGeom->GetShape(); - QString aShapeName = ""; - SALOMEDS::SObject_var aGeomObj, aRef; - if ( subObj->FindSubObject( 1, aGeomObj ) && aGeomObj->ReferencedObject( aRef )) - aShapeName = aRef->GetName(); - anInfo.append(QString("based on %1 geometry object

").arg(aShapeName)); - } - else - anInfo.append(QString("
")); - } - } + anObj.reset(); + aMeshSO->FindSubObject(Tag_EdgeGroups, anObj); + if (anObj) { + _PTR(ChildIterator) it = aStudy->NewChildIterator(anObj); + if (!hasGroup && it->More()) { + anInfo.append(QString("Groups:

")); + hasGroup = true; + } + for (; it->More(); it->Next()) { + _PTR(SObject) subObj = it->Value(); + CORBA::Object_var anObject = SMESH::SObjectToObject(subObj); + SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow(anObject); + if (!aGroup->_is_nil()) { + anInfo.append(QString("- %1
").arg(aGroup->GetName())); + anInfo.append(QString("%1
").arg("on edges")); + anInfo.append(QString("%1
").arg(aGroup->Size())); + // check if the group based on geometry + SMESH::SMESH_GroupOnGeom_var aGroupOnGeom = SMESH::SMESH_GroupOnGeom::_narrow(aGroup); + if (!aGroupOnGeom->_is_nil()) { + GEOM::GEOM_Object_var aGroupMainShape = aGroupOnGeom->GetShape(); + QString aShapeName = ""; + _PTR(SObject) aGeomObj, aRef; + if (subObj->FindSubObject(1, aGeomObj) && aGeomObj->ReferencedObject(aRef)) + aShapeName = aRef->GetName().c_str(); + anInfo.append(QString("based on %1 geometry object

").arg(aShapeName)); + } else { + anInfo.append(QString("
")); + } + } } - + } + // info about groups on faces - anObj = SALOMEDS::SObject::_nil(); + anObj.reset(); aMeshSO->FindSubObject(Tag_FaceGroups , anObj); - if ( !anObj->_is_nil() ) - { - SALOMEDS::ChildIterator_var it = aStudy->NewChildIterator(anObj); - if (!hasGroup && it->More()) - { - anInfo.append(QString("Groups:

")); - hasGroup = true; - } - for(; it->More(); it->Next()){ - SALOMEDS::SObject_var subObj = it->Value(); - SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( subObj->GetObject() ); - if ( !aGroup->_is_nil() ) - { - anInfo.append(QString("- %1
").arg(aGroup->GetName())); - anInfo.append(QString("%1
").arg("on faces")); - anInfo.append(QString("%1
").arg(aGroup->Size())); - // check if the group based on geometry - SMESH::SMESH_GroupOnGeom_var aGroupOnGeom = SMESH::SMESH_GroupOnGeom::_narrow(aGroup); - if ( !aGroupOnGeom->_is_nil() ) - { - GEOM::GEOM_Object_var aGroupMainShape = aGroupOnGeom->GetShape(); - QString aShapeName = ""; - SALOMEDS::SObject_var aGeomObj, aRef; - if ( subObj->FindSubObject( 1, aGeomObj ) && aGeomObj->ReferencedObject( aRef )) - aShapeName = aRef->GetName(); - anInfo.append(QString("based on %1 geometry object

").arg(aShapeName)); - } - else - anInfo.append(QString("
")); - } - } + if (anObj) { + _PTR(ChildIterator) it = aStudy->NewChildIterator(anObj); + if (!hasGroup && it->More()) { + anInfo.append(QString("Groups:

")); + hasGroup = true; + } + for (; it->More(); it->Next()) { + _PTR(SObject) subObj = it->Value(); + CORBA::Object_var anObject = SMESH::SObjectToObject(subObj); + SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow(anObject); + if (!aGroup->_is_nil()) { + anInfo.append(QString("- %1
").arg(aGroup->GetName())); + anInfo.append(QString("%1
").arg("on faces")); + anInfo.append(QString("%1
").arg(aGroup->Size())); + // check if the group based on geometry + SMESH::SMESH_GroupOnGeom_var aGroupOnGeom = SMESH::SMESH_GroupOnGeom::_narrow(aGroup); + if (!aGroupOnGeom->_is_nil()) { + GEOM::GEOM_Object_var aGroupMainShape = aGroupOnGeom->GetShape(); + QString aShapeName = ""; + _PTR(SObject) aGeomObj, aRef; + if (subObj->FindSubObject(1, aGeomObj) && aGeomObj->ReferencedObject(aRef)) + aShapeName = aRef->GetName().c_str(); + anInfo.append(QString("based on %1 geometry object

").arg(aShapeName)); + } else { + anInfo.append(QString("
")); + } + } } - + } + // info about groups on volumes - anObj = SALOMEDS::SObject::_nil(); - aMeshSO->FindSubObject(Tag_VolumeGroups , anObj); - if ( !anObj->_is_nil() ) - { - SALOMEDS::ChildIterator_var it = aStudy->NewChildIterator(anObj); - if (!hasGroup && it->More()) - anInfo.append(QString("Groups:
")); - for(; it->More(); it->Next()){ - SALOMEDS::SObject_var subObj = it->Value(); - SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( subObj->GetObject() ); - if ( !aGroup->_is_nil() ) - { - anInfo.append(QString("- %1
").arg(aGroup->GetName())); - anInfo.append(QString("%1
").arg("on volumes")); - anInfo.append(QString("%1
").arg(aGroup->Size())); - // check if the group based on geometry - SMESH::SMESH_GroupOnGeom_var aGroupOnGeom = SMESH::SMESH_GroupOnGeom::_narrow(aGroup); - if ( !aGroupOnGeom->_is_nil() ) - { - GEOM::GEOM_Object_var aGroupMainShape = aGroupOnGeom->GetShape(); - QString aShapeName = ""; - SALOMEDS::SObject_var aGeomObj, aRef; - if ( subObj->FindSubObject( 1, aGeomObj ) && aGeomObj->ReferencedObject( aRef )) - aShapeName = aRef->GetName(); - anInfo.append(QString("based on %1 geometry object

").arg(aShapeName)); - } - else - anInfo.append(QString("
")); - } - } + anObj.reset(); + aMeshSO->FindSubObject(Tag_VolumeGroups, anObj); + if (anObj) { + _PTR(ChildIterator) it = aStudy->NewChildIterator(anObj); + if (!hasGroup && it->More()) + anInfo.append(QString("Groups:
")); + for (; it->More(); it->Next()) { + _PTR(SObject) subObj = it->Value(); + CORBA::Object_var anObject = SMESH::SObjectToObject(subObj); + SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow(anObject); + if (!aGroup->_is_nil()) { + anInfo.append(QString("- %1
").arg(aGroup->GetName())); + anInfo.append(QString("%1
").arg("on volumes")); + anInfo.append(QString("%1
").arg(aGroup->Size())); + // check if the group based on geometry + SMESH::SMESH_GroupOnGeom_var aGroupOnGeom = SMESH::SMESH_GroupOnGeom::_narrow(aGroup); + if (!aGroupOnGeom->_is_nil()) { + GEOM::GEOM_Object_var aGroupMainShape = aGroupOnGeom->GetShape(); + QString aShapeName = ""; + _PTR(SObject) aGeomObj, aRef; + if (subObj->FindSubObject(1, aGeomObj) && aGeomObj->ReferencedObject(aRef)) + aShapeName = aRef->GetName().c_str(); + anInfo.append(QString("based on %1 geometry object

").arg(aShapeName)); + } else { + anInfo.append(QString("
")); + } + } } - + } + myInfo->setText(anInfo); return; } } - - return; } //================================================================================= @@ -383,46 +383,42 @@ void SMESHGUI_StandardMeshInfosDlg::DumpMeshInfos() //================================================================================= void SMESHGUI_StandardMeshInfosDlg::onSelectionChanged() { - if ( myStartSelection ) + if (myStartSelection) DumpMeshInfos(); } - //================================================================================= // function : closeEvent() // purpose : //================================================================================= -void SMESHGUI_StandardMeshInfosDlg::closeEvent( QCloseEvent* e ) +void SMESHGUI_StandardMeshInfosDlg::closeEvent (QCloseEvent* e) { - mySelection->ClearFilters(); + mySelectionMgr->clearFilters(); SMESHGUI::GetSMESHGUI()->ResetState(); - QDialog::closeEvent( e ); + QDialog::closeEvent(e); } - //================================================================================= // function : windowActivationChange() // purpose : called when window is activated/deactivated //================================================================================= -void SMESHGUI_StandardMeshInfosDlg::windowActivationChange( bool oldActive ) +void SMESHGUI_StandardMeshInfosDlg::windowActivationChange (bool oldActive) { - QDialog::windowActivationChange( oldActive ); - if ( isActiveWindow() && myIsActiveWindow != isActiveWindow() ) - ActivateThisDialog() ; + QDialog::windowActivationChange(oldActive); + if (isActiveWindow() && myIsActiveWindow != isActiveWindow()) + ActivateThisDialog(); myIsActiveWindow = isActiveWindow(); } - //================================================================================= // function : DeactivateActiveDialog() // purpose : //================================================================================= void SMESHGUI_StandardMeshInfosDlg::DeactivateActiveDialog() { - disconnect( mySelection, 0, this, 0 ); + disconnect(mySelectionMgr, 0, this, 0); } - //================================================================================= // function : ActivateThisDialog() // purpose : @@ -430,8 +426,8 @@ void SMESHGUI_StandardMeshInfosDlg::DeactivateActiveDialog() void SMESHGUI_StandardMeshInfosDlg::ActivateThisDialog() { /* Emit a signal to deactivate any active dialog */ - SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog() ; - connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionChanged() ) ); + SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog(); + connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(onSelectionChanged())); } //================================================================================= @@ -441,8 +437,8 @@ void SMESHGUI_StandardMeshInfosDlg::ActivateThisDialog() void SMESHGUI_StandardMeshInfosDlg::onStartSelection() { myStartSelection = true; - mySelection->AddFilter( myMeshFilter ) ; - myMeshLine->setText( tr( "Select a mesh" ) ); + mySelectionMgr->installFilter(myMeshFilter); + myMeshLine->setText(tr("Select a mesh")); onSelectionChanged(); myStartSelection = true; } diff --git a/src/SMESHGUI/SMESHGUI_StandardMeshInfosDlg.h b/src/SMESHGUI/SMESHGUI_StandardMeshInfosDlg.h index 04abee92a..857be0d4d 100644 --- a/src/SMESHGUI/SMESHGUI_StandardMeshInfosDlg.h +++ b/src/SMESHGUI/SMESHGUI_StandardMeshInfosDlg.h @@ -29,7 +29,8 @@ #ifndef SMESHGUI_STANDARDMESHINFOSDLG_H #define SMESHGUI_STANDARDMESHINFOSDLG_H -#include "SMESH_TypeFilter.hxx" +//#include "SMESH_TypeFilter.hxx" +#include "SUIT_SelectionFilter.h" // QT Includes #include @@ -39,7 +40,7 @@ class QLabel; class QPushButton; class QLineEdit; class QTextBrowser; -class SALOME_Selection; +class SalomeApp_SelectionMgr; class SMESHGUI_StandardMeshInfosDlg : public QDialog { @@ -61,11 +62,12 @@ private slots: void onStartSelection(); private: - SALOME_Selection* mySelection; - bool myStartSelection; - bool myIsActiveWindow; + SalomeApp_SelectionMgr* mySelectionMgr; + bool myStartSelection; + bool myIsActiveWindow; - Handle(SMESH_TypeFilter) myMeshFilter; + //Handle(SMESH_TypeFilter) myMeshFilter; + SUIT_SelectionFilter* myMeshFilter; QLabel* myNameLab; QPushButton* mySelectBtn; diff --git a/src/SMESHGUI/SMESHGUI_Swig.cxx b/src/SMESHGUI/SMESHGUI_Swig.cxx index b82c7b32a..6ed39d3c8 100644 --- a/src/SMESHGUI/SMESHGUI_Swig.cxx +++ b/src/SMESHGUI/SMESHGUI_Swig.cxx @@ -32,10 +32,14 @@ using namespace std; #include "Utils_ORB_INIT.hxx" #include "Utils_SINGLETON.hxx" +#include +#include + // SALOME Includes -#include "QAD_Application.h" -#include "QAD_Desktop.h" -#include "QAD_ResourceMgr.h" +#include "SUIT_ResourceMgr.h" +#include "SUIT_Session.h" + +#include "SalomeApp_Application.h" #include "utilities.h" @@ -69,20 +73,22 @@ SMESH_Swig::SMESH_Swig() void SMESH_Swig::Init(int studyID) { MESSAGE("Init"); - Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "SMESH"); - SMESH::SMESH_Gen_var CompMesh = SMESH::SMESH_Gen::_narrow(comp); + SMESH::SMESH_Gen_var CompMesh = SMESHGUI::GetSMESHGen(); + GEOM::GEOM_Gen_var CompGeom = SMESH::GetGEOMGen(); - Engines::Component_var comp1 = QAD_Application::getDesktop()->getEngine("FactoryServer", "GEOM"); - GEOM::GEOM_Gen_var CompGeom = GEOM::GEOM_Gen::_narrow(comp1); - - QAD_ResourceMgr* resMgr = QAD_Desktop::createResourceManager(); + SUIT_ResourceMgr* resMgr = SMESHGUI::resourceMgr(); if ( resMgr ) { - QString msg; + resMgr->loadLanguage( QString::null, "en" ); + /*QString msg; if (!resMgr->loadResources( "SMESH", msg )) - MESSAGE ( msg ) + MESSAGE ( msg )*/ } - CORBA::Object_var obj = QAD_Application::getDesktop()->getNameService()->Resolve("/myStudyManager"); + SalomeApp_Application* app = dynamic_cast( SUIT_Session::session()->activeApplication() ); + if( !app ) + return; + + CORBA::Object_var obj = app->namingService()->Resolve("/myStudyManager"); SALOMEDS::StudyManager_var myStudyMgr = SALOMEDS::StudyManager::_narrow(obj); myStudy = myStudyMgr->GetStudyByID(studyID); @@ -95,7 +101,7 @@ void SMESH_Swig::Init(int studyID) // See return value of SMESH::SMESH_Gen::ComponentDataType() SALOMEDS::SComponent_var father = myStudy->FindComponent("SMESH"); - + if (father->_is_nil()) { bool aLocked = myStudy->GetProperties()->IsLocked(); if (aLocked) myStudy->GetProperties()->SetLocked(false); @@ -103,7 +109,7 @@ void SMESH_Swig::Init(int studyID) anAttr = myStudyBuilder->FindOrCreateAttribute(father, "AttributeName"); aName = SALOMEDS::AttributeName::_narrow(anAttr); //NRI aName->SetValue(QObject::tr("SMESH_MEN_COMPONENT")); - aName->SetValue( QAD_Application::getDesktop()->getComponentUserName( "SMESH" ) ); + aName->SetValue( SMESHGUI::GetSMESHGUI()->moduleName() ); anAttr = myStudyBuilder->FindOrCreateAttribute(father, "AttributePixMap"); aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr); aPixmap->SetPixMap( "ICON_OBJBROWSER_SMESH" ); diff --git a/src/SMESHGUI/SMESHGUI_SymmetryDlg.cxx b/src/SMESHGUI/SMESHGUI_SymmetryDlg.cxx index 1186ce9d4..a49f6cef9 100644 --- a/src/SMESHGUI/SMESHGUI_SymmetryDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_SymmetryDlg.cxx @@ -1,48 +1,60 @@ // SMESH SMESHGUI : GUI for SMESH component // // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org // // // // File : SMESHGUI_SymmetryDlg.cxx // Author : Michael ZORIN // Module : SMESH -// $Header: +// $Header: #include "SMESHGUI_SymmetryDlg.h" #include "SMESHGUI.h" +#include "SMESHGUI_SpinBox.h" #include "SMESHGUI_Utils.h" #include "SMESHGUI_VTKUtils.h" #include "SMESHGUI_MeshUtils.h" #include "SMESHGUI_IdValidator.h" -#include "SMESHGUI_SpinBox.h" + #include "SMESH_Actor.h" #include "SMESH_TypeFilter.hxx" +#include "SMESH_LogicalFilter.hxx" #include "SMDS_Mesh.hxx" -#include "QAD_Application.h" -#include "QAD_Desktop.h" -#include "QAD_MessageBox.h" +#include "SUIT_Desktop.h" +#include "SUIT_ResourceMgr.h" + +#include "SVTK_ViewModel.h" +#include "SVTK_ViewWindow.h" +#include "SVTK_Selector.h" +#include "SVTK_Selection.h" +#include "SALOME_ListIO.hxx" + #include "utilities.h" +// OCCT Includes +#include +#include + // QT Includes #include #include @@ -63,251 +75,256 @@ using namespace std; //================================================================================= // class : SMESHGUI_SymmetryDlg() -// purpose : +// purpose : //================================================================================= -SMESHGUI_SymmetryDlg::SMESHGUI_SymmetryDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, - bool modal, WFlags fl ) - : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | - Qt::WDestructiveClose) +SMESHGUI_SymmetryDlg::SMESHGUI_SymmetryDlg( SMESHGUI* theModule, const char* name, + bool modal, WFlags fl) + : QDialog( SMESH::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder | + WStyle_Title | WStyle_SysMenu | Qt::WDestructiveClose), + mySMESHGUI( theModule ), + mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ), + myViewWindow( SMESH::GetViewWindow( theModule ) ), + mySelector( myViewWindow->GetSelector() ) { - QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SMESH_SYMMETRY_POINT"))); - QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SMESH_SYMMETRY_AXIS"))); - QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SMESH_SYMMETRY_PLANE"))); - QPixmap image3(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SELECT"))); + QPixmap image0 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SMESH_SYMMETRY_POINT"))); + QPixmap image1 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SMESH_SYMMETRY_AXIS"))); + QPixmap image2 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SMESH_SYMMETRY_PLANE"))); + QPixmap image3 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT"))); - if ( !name ) - setName( "SMESHGUI_SymmetryDlg" ); - resize( 303, 185 ); - setCaption( tr( "SMESH_SYMMETRY" ) ); - setSizeGripEnabled( TRUE ); - SMESHGUI_SymmetryDlgLayout = new QGridLayout( this ); - SMESHGUI_SymmetryDlgLayout->setSpacing( 6 ); - SMESHGUI_SymmetryDlgLayout->setMargin( 11 ); + if (!name) + setName("SMESHGUI_SymmetryDlg"); + resize(303, 185); + setCaption(tr("SMESH_SYMMETRY")); + setSizeGripEnabled(TRUE); + SMESHGUI_SymmetryDlgLayout = new QGridLayout(this); + SMESHGUI_SymmetryDlgLayout->setSpacing(6); + SMESHGUI_SymmetryDlgLayout->setMargin(11); /***************************************************************/ - GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); - GroupConstructors->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)0, 0, 0, GroupConstructors->sizePolicy().hasHeightForWidth() ) ); - GroupConstructors->setTitle( tr( "SMESH_SYMMETRY" ) ); - GroupConstructors->setExclusive( TRUE ); - GroupConstructors->setColumnLayout(0, Qt::Vertical ); - GroupConstructors->layout()->setSpacing( 0 ); - GroupConstructors->layout()->setMargin( 0 ); - GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() ); - GroupConstructorsLayout->setAlignment( Qt::AlignTop ); - GroupConstructorsLayout->setSpacing( 6 ); - GroupConstructorsLayout->setMargin( 11 ); - QHBoxLayout* RBLayout = new QHBoxLayout( 0, 0, 6, "Layout2"); - RadioButton1= new QRadioButton( GroupConstructors, "RadioButton1" ); - RadioButton1->setText( tr( "" ) ); - RadioButton1->setPixmap( image0 ); - RBLayout->addWidget( RadioButton1); - RadioButton2= new QRadioButton( GroupConstructors, "RadioButton2" ); - RadioButton2->setText( tr( "" ) ); - RadioButton2->setPixmap( image1 ); - RBLayout->addWidget( RadioButton2); - RadioButton3= new QRadioButton( GroupConstructors, "RadioButton3" ); - RadioButton3->setText( tr( "" ) ); - RadioButton3->setPixmap( image2 ); - RBLayout->addWidget( RadioButton3); - GroupConstructorsLayout->addLayout( RBLayout, 0, 0 ); - SMESHGUI_SymmetryDlgLayout->addWidget( GroupConstructors, 0, 0 ); - - /***************************************************************/ - GroupButtons = new QGroupBox( this, "GroupButtons" ); - GroupButtons->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, GroupButtons->sizePolicy().hasHeightForWidth() ) ); - GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); - GroupButtons->setTitle( tr( "" ) ); - GroupButtons->setColumnLayout(0, Qt::Vertical ); - GroupButtons->layout()->setSpacing( 0 ); - GroupButtons->layout()->setMargin( 0 ); - GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); - GroupButtonsLayout->setAlignment( Qt::AlignTop ); - GroupButtonsLayout->setSpacing( 6 ); - GroupButtonsLayout->setMargin( 11 ); - buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); - buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) ); - buttonCancel->setAutoDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonCancel, 0, 3 ); - buttonApply = new QPushButton( GroupButtons, "buttonApply" ); - buttonApply->setText( tr( "SMESH_BUT_APPLY" ) ); - buttonApply->setAutoDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); - QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); - GroupButtonsLayout->addItem( spacer_9, 0, 2 ); - buttonOk = new QPushButton( GroupButtons, "buttonOk" ); - buttonOk->setText( tr( "SMESH_BUT_OK" ) ); - buttonOk->setAutoDefault( TRUE ); - buttonOk->setDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); - SMESHGUI_SymmetryDlgLayout->addWidget( GroupButtons, 2, 0 ); + GroupConstructors = new QButtonGroup(this, "GroupConstructors"); + GroupConstructors->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)5, + (QSizePolicy::SizeType)0, 0, 0, + GroupConstructors->sizePolicy().hasHeightForWidth())); + GroupConstructors->setTitle(tr("SMESH_SYMMETRY" )); + GroupConstructors->setExclusive(TRUE); + GroupConstructors->setColumnLayout(0, Qt::Vertical); + GroupConstructors->layout()->setSpacing(0); + GroupConstructors->layout()->setMargin(0); + GroupConstructorsLayout = new QGridLayout(GroupConstructors->layout()); + GroupConstructorsLayout->setAlignment(Qt::AlignTop); + GroupConstructorsLayout->setSpacing(6); + GroupConstructorsLayout->setMargin(11); + QHBoxLayout* RBLayout = new QHBoxLayout(0, 0, 6, "Layout2"); + RadioButton1= new QRadioButton(GroupConstructors, "RadioButton1"); + RadioButton1->setText(tr("" )); + RadioButton1->setPixmap(image0); + RBLayout->addWidget(RadioButton1); + RadioButton2= new QRadioButton(GroupConstructors, "RadioButton2"); + RadioButton2->setText(tr("" )); + RadioButton2->setPixmap(image1); + RBLayout->addWidget(RadioButton2); + RadioButton3= new QRadioButton(GroupConstructors, "RadioButton3"); + RadioButton3->setText(tr("" )); + RadioButton3->setPixmap(image2); + RBLayout->addWidget(RadioButton3); + GroupConstructorsLayout->addLayout(RBLayout, 0, 0); + SMESHGUI_SymmetryDlgLayout->addWidget(GroupConstructors, 0, 0); /***************************************************************/ - GroupArguments = new QGroupBox( this, "GroupArguments" ); - GroupArguments->setTitle( tr( "SMESH_ARGUMENTS" ) ); - GroupArguments->setColumnLayout(0, Qt::Vertical ); - GroupArguments->layout()->setSpacing( 0 ); - GroupArguments->layout()->setMargin( 0 ); - GroupArgumentsLayout = new QGridLayout( GroupArguments->layout() ); - GroupArgumentsLayout->setAlignment( Qt::AlignTop ); - GroupArgumentsLayout->setSpacing( 6 ); - GroupArgumentsLayout->setMargin( 11 ); + GroupButtons = new QGroupBox(this, "GroupButtons"); + GroupButtons->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)7, + (QSizePolicy::SizeType)0, 0, 0, + GroupButtons->sizePolicy().hasHeightForWidth())); + GroupButtons->setGeometry(QRect(10, 10, 281, 48)); + GroupButtons->setTitle(tr("" )); + GroupButtons->setColumnLayout(0, Qt::Vertical); + GroupButtons->layout()->setSpacing(0); + GroupButtons->layout()->setMargin(0); + GroupButtonsLayout = new QGridLayout(GroupButtons->layout()); + GroupButtonsLayout->setAlignment(Qt::AlignTop); + GroupButtonsLayout->setSpacing(6); + GroupButtonsLayout->setMargin(11); + buttonCancel = new QPushButton(GroupButtons, "buttonCancel"); + buttonCancel->setText(tr("SMESH_BUT_CLOSE" )); + buttonCancel->setAutoDefault(TRUE); + GroupButtonsLayout->addWidget(buttonCancel, 0, 3); + buttonApply = new QPushButton(GroupButtons, "buttonApply"); + buttonApply->setText(tr("SMESH_BUT_APPLY" )); + buttonApply->setAutoDefault(TRUE); + GroupButtonsLayout->addWidget(buttonApply, 0, 1); + QSpacerItem* spacer_9 = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); + GroupButtonsLayout->addItem(spacer_9, 0, 2); + buttonOk = new QPushButton(GroupButtons, "buttonOk"); + buttonOk->setText(tr("SMESH_BUT_OK" )); + buttonOk->setAutoDefault(TRUE); + buttonOk->setDefault(TRUE); + GroupButtonsLayout->addWidget(buttonOk, 0, 0); + SMESHGUI_SymmetryDlgLayout->addWidget(GroupButtons, 2, 0); + + /***************************************************************/ + GroupArguments = new QGroupBox(this, "GroupArguments"); + GroupArguments->setTitle(tr("SMESH_ARGUMENTS")); + GroupArguments->setColumnLayout(0, Qt::Vertical); + GroupArguments->layout()->setSpacing(0); + GroupArguments->layout()->setMargin(0); + GroupArgumentsLayout = new QGridLayout(GroupArguments->layout()); + GroupArgumentsLayout->setAlignment(Qt::AlignTop); + GroupArgumentsLayout->setSpacing(6); + GroupArgumentsLayout->setMargin(11); // Controls for elements selection - TextLabelElements = new QLabel( GroupArguments, "TextLabelElements" ); - TextLabelElements->setText( tr( "SMESH_ID_ELEMENTS" ) ); + TextLabelElements = new QLabel(GroupArguments, "TextLabelElements"); + TextLabelElements->setText(tr("SMESH_ID_ELEMENTS" )); TextLabelElements->setFixedWidth(74); - GroupArgumentsLayout->addWidget( TextLabelElements, 0, 0 ); - - SelectElementsButton = new QPushButton( GroupArguments, "SelectElementsButton" ); - SelectElementsButton->setText( tr( "" ) ); - SelectElementsButton->setPixmap( image3 ); - SelectElementsButton->setToggleButton( FALSE ); - GroupArgumentsLayout->addWidget( SelectElementsButton, 0, 1 ); + GroupArgumentsLayout->addWidget(TextLabelElements, 0, 0); - LineEditElements = new QLineEdit( GroupArguments, "LineEditElements" ); - LineEditElements->setValidator( new SMESHGUI_IdValidator( this, "validator" )); - GroupArgumentsLayout->addWidget( LineEditElements, 0, 2 ); + SelectElementsButton = new QPushButton(GroupArguments, "SelectElementsButton"); + SelectElementsButton->setText(tr("" )); + SelectElementsButton->setPixmap(image3); + SelectElementsButton->setToggleButton(FALSE); + GroupArgumentsLayout->addWidget(SelectElementsButton, 0, 1); + + LineEditElements = new QLineEdit(GroupArguments, "LineEditElements"); + LineEditElements->setValidator(new SMESHGUI_IdValidator(this, "validator")); + GroupArgumentsLayout->addWidget(LineEditElements, 0, 2); // Control for the whole mesh selection - CheckBoxMesh = new QCheckBox( GroupArguments, "CheckBoxMesh" ); - CheckBoxMesh->setText( tr( "SMESH_SELECT_WHOLE_MESH" ) ); - GroupArgumentsLayout->addMultiCellWidget( CheckBoxMesh, 1, 1, 0, 2 ); - + CheckBoxMesh = new QCheckBox(GroupArguments, "CheckBoxMesh"); + CheckBoxMesh->setText(tr("SMESH_SELECT_WHOLE_MESH" )); + GroupArgumentsLayout->addMultiCellWidget(CheckBoxMesh, 1, 1, 0, 2); + // Controls for mirror selection - GroupMirror = new QGroupBox( GroupArguments, "GroupMirror" ); - GroupMirror->setColumnLayout(0, Qt::Vertical ); - GroupMirror->layout()->setSpacing( 0 ); - GroupMirror->layout()->setMargin( 0 ); - QGridLayout* GroupMirrorLayout = new QGridLayout( GroupMirror->layout() ); - GroupMirrorLayout->setAlignment( Qt::AlignTop ); - GroupMirrorLayout->setSpacing( 6 ); - GroupMirrorLayout->setMargin( 11 ); - - TextLabelPoint = new QLabel( GroupMirror, "TextLabelPoint" ); - TextLabelPoint->setText( tr( "SMESH_POINT" ) ); - GroupMirrorLayout->addWidget( TextLabelPoint, 0, 0 ); + GroupMirror = new QGroupBox(GroupArguments, "GroupMirror"); + GroupMirror->setColumnLayout(0, Qt::Vertical); + GroupMirror->layout()->setSpacing(0); + GroupMirror->layout()->setMargin(0); + QGridLayout* GroupMirrorLayout = new QGridLayout(GroupMirror->layout()); + GroupMirrorLayout->setAlignment(Qt::AlignTop); + GroupMirrorLayout->setSpacing(6); + GroupMirrorLayout->setMargin(11); - SelectPointButton = new QPushButton( GroupMirror, "SelectPointButton" ); - SelectPointButton->setPixmap( image3 ); - GroupMirrorLayout->addWidget( SelectPointButton, 0, 1 ); - - TextLabelX = new QLabel( GroupMirror, "TextLabelX" ); - TextLabelX->setText( tr( "SMESH_X" ) ); - GroupMirrorLayout->addWidget( TextLabelX, 0, 2 ); + TextLabelPoint = new QLabel(GroupMirror, "TextLabelPoint"); + TextLabelPoint->setText(tr("SMESH_POINT")); + GroupMirrorLayout->addWidget(TextLabelPoint, 0, 0); - SpinBox_X = new SMESHGUI_SpinBox( GroupMirror, "SpinBox_X"); - GroupMirrorLayout->addWidget( SpinBox_X, 0, 3 ); - - TextLabelY = new QLabel( GroupMirror, "TextLabelY" ); - TextLabelY->setText( tr( "SMESH_Y" ) ); - GroupMirrorLayout->addWidget( TextLabelY, 0, 4 ); + SelectPointButton = new QPushButton(GroupMirror, "SelectPointButton"); + SelectPointButton->setPixmap(image3); + GroupMirrorLayout->addWidget(SelectPointButton, 0, 1); - SpinBox_Y = new SMESHGUI_SpinBox( GroupMirror, "SpinBox_Y"); - GroupMirrorLayout->addWidget( SpinBox_Y, 0, 5 ); + TextLabelX = new QLabel(GroupMirror, "TextLabelX"); + TextLabelX->setText(tr("SMESH_X")); + GroupMirrorLayout->addWidget(TextLabelX, 0, 2); - TextLabelZ = new QLabel( GroupMirror, "TextLabelZ" ); - TextLabelZ->setText( tr( "SMESH_Z" ) ); - GroupMirrorLayout->addWidget( TextLabelZ, 0, 6 ); - - SpinBox_Z = new SMESHGUI_SpinBox( GroupMirror, "SpinBox_Z"); - GroupMirrorLayout->addWidget( SpinBox_Z, 0, 7 ); + SpinBox_X = new SMESHGUI_SpinBox(GroupMirror, "SpinBox_X"); + GroupMirrorLayout->addWidget(SpinBox_X, 0, 3); - TextLabelVector = new QLabel( GroupMirror, "TextLabelVector" ); - GroupMirrorLayout->addWidget( TextLabelVector, 1, 0 ); - - SelectVectorButton = new QPushButton( GroupMirror, "SelectVectorButton" ); - SelectVectorButton->setPixmap( image3 ); - GroupMirrorLayout->addWidget( SelectVectorButton, 1, 1 ); - - TextLabelDX = new QLabel( GroupMirror, "TextLabelDX" ); - TextLabelDX->setText( tr( "SMESH_DX" ) ); - GroupMirrorLayout->addWidget( TextLabelDX, 1, 2 ); + TextLabelY = new QLabel(GroupMirror, "TextLabelY"); + TextLabelY->setText(tr("SMESH_Y")); + GroupMirrorLayout->addWidget(TextLabelY, 0, 4); - SpinBox_DX = new SMESHGUI_SpinBox( GroupMirror, "SpinBox_DX"); - GroupMirrorLayout->addWidget( SpinBox_DX, 1, 3 ); - - TextLabelDY = new QLabel( GroupMirror, "TextLabelDY" ); - TextLabelDY->setText( tr( "SMESH_DY" ) ); - GroupMirrorLayout->addWidget( TextLabelDY, 1, 4 ); + SpinBox_Y = new SMESHGUI_SpinBox(GroupMirror, "SpinBox_Y"); + GroupMirrorLayout->addWidget(SpinBox_Y, 0, 5); - SpinBox_DY = new SMESHGUI_SpinBox( GroupMirror, "SpinBox_DY"); - GroupMirrorLayout->addWidget( SpinBox_DY, 1, 5 ); + TextLabelZ = new QLabel(GroupMirror, "TextLabelZ"); + TextLabelZ->setText(tr("SMESH_Z")); + GroupMirrorLayout->addWidget(TextLabelZ, 0, 6); - TextLabelDZ = new QLabel( GroupMirror, "TextLabelDZ" ); - TextLabelDZ->setText( tr( "SMESH_DZ" ) ); - GroupMirrorLayout->addWidget( TextLabelDZ, 1, 6 ); - - SpinBox_DZ = new SMESHGUI_SpinBox( GroupMirror, "SpinBox_DZ"); - GroupMirrorLayout->addWidget( SpinBox_DZ, 1, 7 ); + SpinBox_Z = new SMESHGUI_SpinBox(GroupMirror, "SpinBox_Z"); + GroupMirrorLayout->addWidget(SpinBox_Z, 0, 7); + + TextLabelVector = new QLabel(GroupMirror, "TextLabelVector"); + GroupMirrorLayout->addWidget(TextLabelVector, 1, 0); + + SelectVectorButton = new QPushButton(GroupMirror, "SelectVectorButton"); + SelectVectorButton->setPixmap(image3); + GroupMirrorLayout->addWidget(SelectVectorButton, 1, 1); + + TextLabelDX = new QLabel(GroupMirror, "TextLabelDX"); + TextLabelDX->setText(tr("SMESH_DX")); + GroupMirrorLayout->addWidget(TextLabelDX, 1, 2); + + SpinBox_DX = new SMESHGUI_SpinBox(GroupMirror, "SpinBox_DX"); + GroupMirrorLayout->addWidget(SpinBox_DX, 1, 3); + + TextLabelDY = new QLabel(GroupMirror, "TextLabelDY"); + TextLabelDY->setText(tr("SMESH_DY")); + GroupMirrorLayout->addWidget(TextLabelDY, 1, 4); + + SpinBox_DY = new SMESHGUI_SpinBox(GroupMirror, "SpinBox_DY"); + GroupMirrorLayout->addWidget(SpinBox_DY, 1, 5); + + TextLabelDZ = new QLabel(GroupMirror, "TextLabelDZ"); + TextLabelDZ->setText(tr("SMESH_DZ")); + GroupMirrorLayout->addWidget(TextLabelDZ, 1, 6); + + SpinBox_DZ = new SMESHGUI_SpinBox(GroupMirror, "SpinBox_DZ"); + GroupMirrorLayout->addWidget(SpinBox_DZ, 1, 7); + + GroupArgumentsLayout->addMultiCellWidget(GroupMirror, 2, 2, 0, 2); - GroupArgumentsLayout->addMultiCellWidget( GroupMirror, 2, 2, 0, 2 ); - // Controls for "Create a copy" option - CheckBoxCopy = new QCheckBox( GroupArguments, "CheckBoxCopy" ); - CheckBoxCopy->setText( tr( "SMESH_CREATE_COPY" ) ); - GroupArgumentsLayout->addMultiCellWidget( CheckBoxCopy, 3, 3, 0, 2 ); - + CheckBoxCopy = new QCheckBox(GroupArguments, "CheckBoxCopy"); + CheckBoxCopy->setText(tr("SMESH_CREATE_COPY")); + GroupArgumentsLayout->addMultiCellWidget(CheckBoxCopy, 3, 3, 0, 2); + + + SMESHGUI_SymmetryDlgLayout->addWidget(GroupArguments, 1, 0); - SMESHGUI_SymmetryDlgLayout->addWidget( GroupArguments, 1, 0 ); - /* Initialisations */ - SpinBox_X->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 ); - SpinBox_Y->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 ); - SpinBox_Z->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 ); - SpinBox_DX->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 ); - SpinBox_DY->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 ); - SpinBox_DZ->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 ); + SpinBox_X->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3); + SpinBox_Y->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3); + SpinBox_Z->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3); + SpinBox_DX->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3); + SpinBox_DY->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3); + SpinBox_DZ->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3); GroupArguments->show(); - RadioButton1->setChecked( TRUE ); - mySelection = Sel; - - mySMESHGUI = SMESHGUI::GetSMESHGUI() ; - mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; - + RadioButton1->setChecked(TRUE); + + mySMESHGUI->SetActiveDialogBox((QDialog*)this); + // Costruction of the logical filter - SMESH_ListOfFilter aListOfFilters; - Handle(SMESH_TypeFilter) aMeshOrSubMeshFilter = new SMESH_TypeFilter( MESHorSUBMESH ); - if ( !aMeshOrSubMeshFilter.IsNull() ) - aListOfFilters.Append( aMeshOrSubMeshFilter ); - Handle(SMESH_TypeFilter) aSmeshGroupFilter = new SMESH_TypeFilter( GROUP ); - if ( !aSmeshGroupFilter.IsNull() ) - aListOfFilters.Append( aSmeshGroupFilter ); - - myMeshOrSubMeshOrGroupFilter = new SMESH_LogicalFilter( aListOfFilters, SMESH_LogicalFilter::LO_OR ); - + SMESH_TypeFilter* aMeshOrSubMeshFilter = new SMESH_TypeFilter (MESHorSUBMESH); + SMESH_TypeFilter* aSmeshGroupFilter = new SMESH_TypeFilter (GROUP); + + QPtrList aListOfFilters; + if (aMeshOrSubMeshFilter) aListOfFilters.append(aMeshOrSubMeshFilter); + if (aSmeshGroupFilter) aListOfFilters.append(aSmeshGroupFilter); + + myMeshOrSubMeshOrGroupFilter = + new SMESH_LogicalFilter (aListOfFilters, SMESH_LogicalFilter::LO_OR); + Init(); + /* signals and slots connections */ - connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); - connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ; - connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) ); - connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) ); - - connect( SelectElementsButton, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; - connect( SelectPointButton, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; - connect( SelectVectorButton, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; - - connect( SpinBox_DX, SIGNAL( valueChanged( double )), this, SLOT(onVectorChanged() ) ); - connect( SpinBox_DY, SIGNAL( valueChanged( double )), this, SLOT(onVectorChanged() ) ); - connect( SpinBox_DZ, SIGNAL( valueChanged( double )), this, SLOT(onVectorChanged() ) ); - - connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; - connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel())); + connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); + connect(GroupConstructors, SIGNAL(clicked(int)), SLOT(ConstructorsClicked(int))); + + connect(SelectElementsButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument())); + connect(SelectPointButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument())); + connect(SelectVectorButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument())); + + connect(SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged())); + connect(SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged())); + connect(SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged())); + + connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog())); + connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); /* to close dialog if study change */ - connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; - connect( LineEditElements, SIGNAL( textChanged( const QString& )), - SLOT( onTextChange( const QString& ))); - connect( CheckBoxMesh, SIGNAL( toggled( bool )), - SLOT( onSelectMesh( bool ))); - + connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel())); + connect(LineEditElements, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&))); + connect(CheckBoxMesh, SIGNAL(toggled(bool)), SLOT(onSelectMesh(bool))); + /* Move widget on the botton right corner of main widget */ - int x, y ; - mySMESHGUI->DefineDlgPosition( this, x, y ) ; - this->move( x, y ) ; - this->show() ; /* displays Dialog */ + int x, y; + mySMESHGUI->DefineDlgPosition(this, x, y); + this->move(x, y); + this->show(); /* displays Dialog */ ConstructorsClicked(0); - resize(0,0); + resize(0,0); // ?? } //================================================================================= @@ -319,108 +336,101 @@ SMESHGUI_SymmetryDlg::~SMESHGUI_SymmetryDlg() // no need to delete child widgets, Qt does it all for us } - //================================================================================= // function : Init() // purpose : //================================================================================= -void SMESHGUI_SymmetryDlg::Init( bool ResetControls ) +void SMESHGUI_SymmetryDlg::Init (bool ResetControls) { myBusy = false; - + myEditCurrentArgument = 0; LineEditElements->clear(); myElementsId = ""; - myNbOkElements = 0 ; - - buttonOk->setEnabled( false ); - buttonApply->setEnabled( false ); - - myActor = 0; + myNbOkElements = 0; + + buttonOk->setEnabled(false); + buttonApply->setEnabled(false); + + myActor = 0; myMesh = SMESH::SMESH_Mesh::_nil(); - if( ResetControls ) - { - SpinBox_X->SetValue(0.0); - SpinBox_Y->SetValue(0.0); - SpinBox_Z->SetValue(0.0); - SpinBox_DX->SetValue(0.0); - SpinBox_DY->SetValue(0.0); - SpinBox_DZ->SetValue(0.0); - - CheckBoxCopy->setChecked(false); - CheckBoxMesh->setChecked(false); - onSelectMesh( false ); - } -} + if (ResetControls) { + SpinBox_X->SetValue(0.0); + SpinBox_Y->SetValue(0.0); + SpinBox_Z->SetValue(0.0); + SpinBox_DX->SetValue(0.0); + SpinBox_DY->SetValue(0.0); + SpinBox_DZ->SetValue(0.0); + CheckBoxCopy->setChecked(false); + CheckBoxMesh->setChecked(false); + onSelectMesh(false); + } +} //================================================================================= // function : ConstructorsClicked() // purpose : Radio button management //================================================================================= -void SMESHGUI_SymmetryDlg::ConstructorsClicked(int constructorId) +void SMESHGUI_SymmetryDlg::ConstructorsClicked (int constructorId) { - disconnect(mySelection, 0, this, 0); - - if (constructorId!=0 && !TextLabelVector->isVisible()) - { - TextLabelVector->show(); - SelectVectorButton->show(); - TextLabelDX->show(); - SpinBox_DX->show(); - TextLabelDY->show(); - SpinBox_DY->show(); - TextLabelDZ->show(); - SpinBox_DZ->show(); - } + disconnect(mySelectionMgr, 0, this, 0); - switch(constructorId) + if (constructorId != 0 && !TextLabelVector->isVisible()) { + TextLabelVector->show(); + SelectVectorButton->show(); + TextLabelDX->show(); + SpinBox_DX->show(); + TextLabelDY->show(); + SpinBox_DY->show(); + TextLabelDZ->show(); + SpinBox_DZ->show(); + } + + switch (constructorId) { + case 0: { - case 0 : - { - GroupMirror->setTitle( tr( "SMESH_POINT" ) ); - - TextLabelVector->hide(); - SelectVectorButton->hide(); - TextLabelDX->hide(); - SpinBox_DX->hide(); - TextLabelDY->hide(); - SpinBox_DY->hide(); - TextLabelDZ->hide(); - SpinBox_DZ->hide(); - break; - } - case 1 : - { - GroupMirror->setTitle( tr( "SMESH_AXIS" ) ); - TextLabelVector->setText( tr( "SMESH_VECTOR" ) ); - break; - } - case 2 : - { - GroupMirror->setTitle( tr( "SMESH_PLANE" ) ); - TextLabelVector->setText( tr( "SMESH_NORMAL" ) ); - break; - } + GroupMirror->setTitle(tr("SMESH_POINT")); + + TextLabelVector->hide(); + SelectVectorButton->hide(); + TextLabelDX->hide(); + SpinBox_DX->hide(); + TextLabelDY->hide(); + SpinBox_DY->hide(); + TextLabelDZ->hide(); + SpinBox_DZ->hide(); + break; } - - if (myEditCurrentArgument != (QWidget*)LineEditElements) + case 1: { - SMESH::SetPointRepresentation(false); - if (!CheckBoxMesh->isChecked()) - QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true ); + GroupMirror->setTitle(tr("SMESH_AXIS")); + TextLabelVector->setText(tr("SMESH_VECTOR")); + break; } - + case 2: + { + GroupMirror->setTitle(tr("SMESH_PLANE")); + TextLabelVector->setText(tr("SMESH_NORMAL")); + break; + } + } + + if (myEditCurrentArgument != (QWidget*)LineEditElements) { + SMESH::SetPointRepresentation(false); + if (!CheckBoxMesh->isChecked()) + myViewWindow->SetSelectionMode(CellSelection); + } + myEditCurrentArgument = (QWidget*)LineEditElements; LineEditElements->setFocus(); if (CheckBoxMesh->isChecked()) onSelectMesh(true); - - connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); -} + connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); +} //================================================================================= // function : ClickOnApply() @@ -428,60 +438,55 @@ void SMESHGUI_SymmetryDlg::ConstructorsClicked(int constructorId) //================================================================================= void SMESHGUI_SymmetryDlg::ClickOnApply() { - if (mySMESHGUI->ActiveStudyLocked()) + if (mySMESHGUI->isActiveStudyLocked()) return; - - if ( myNbOkElements && IsMirrorOk() ) - { - QStringList aListElementsId = QStringList::split( " ", myElementsId, false); - - SMESH::long_array_var anElementsId = new SMESH::long_array; - - anElementsId->length( aListElementsId.count() ); - for ( int i = 0; i < aListElementsId.count(); i++ ) - anElementsId[i] = aListElementsId[i].toInt(); - - SMESH::AxisStruct aMirror; - - aMirror.x = SpinBox_X->GetValue(); - aMirror.y = SpinBox_Y->GetValue(); - aMirror.z = SpinBox_Z->GetValue(); - if (GetConstructorId() == 0) - aMirror.vx = aMirror.vy = aMirror.vz = 0; - else - { - aMirror.vx = SpinBox_DX->GetValue(); - aMirror.vy = SpinBox_DY->GetValue(); - aMirror.vz = SpinBox_DZ->GetValue(); - } - - bool toCreateCopy = CheckBoxCopy->isChecked(); - SMESH::SMESH_MeshEditor::MirrorType aMirrorType; + if (myNbOkElements && IsMirrorOk()) { + QStringList aListElementsId = QStringList::split(" ", myElementsId, false); - if (GetConstructorId() == 0) - aMirrorType = SMESH::SMESH_MeshEditor::POINT; - if (GetConstructorId() == 1) - aMirrorType = SMESH::SMESH_MeshEditor::AXIS; - if (GetConstructorId() == 2) - aMirrorType = SMESH::SMESH_MeshEditor::PLANE; + SMESH::long_array_var anElementsId = new SMESH::long_array; - try - { - SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor(); - QApplication::setOverrideCursor(Qt::waitCursor); - aMeshEditor->Mirror(anElementsId, aMirror, aMirrorType, toCreateCopy); - QApplication::restoreOverrideCursor(); - } - catch( ... ) - { - } - - mySelection->ClearIObjects(); - SMESH::UpdateView(); - Init( false ); - ConstructorsClicked( GetConstructorId() ); + anElementsId->length(aListElementsId.count()); + for (int i = 0; i < aListElementsId.count(); i++) + anElementsId[i] = aListElementsId[i].toInt(); + + SMESH::AxisStruct aMirror; + + aMirror.x = SpinBox_X->GetValue(); + aMirror.y = SpinBox_Y->GetValue(); + aMirror.z = SpinBox_Z->GetValue(); + if (GetConstructorId() == 0) { + aMirror.vx = aMirror.vy = aMirror.vz = 0; + } else { + aMirror.vx = SpinBox_DX->GetValue(); + aMirror.vy = SpinBox_DY->GetValue(); + aMirror.vz = SpinBox_DZ->GetValue(); } + + bool toCreateCopy = CheckBoxCopy->isChecked(); + + SMESH::SMESH_MeshEditor::MirrorType aMirrorType; + + if (GetConstructorId() == 0) + aMirrorType = SMESH::SMESH_MeshEditor::POINT; + if (GetConstructorId() == 1) + aMirrorType = SMESH::SMESH_MeshEditor::AXIS; + if (GetConstructorId() == 2) + aMirrorType = SMESH::SMESH_MeshEditor::PLANE; + + try { + SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor(); + QApplication::setOverrideCursor(Qt::waitCursor); + aMeshEditor->Mirror(anElementsId, aMirror, aMirrorType, toCreateCopy); + QApplication::restoreOverrideCursor(); + } catch (...) { + } + + mySelectionMgr->clearSelected(); + SMESH::UpdateView(); + Init(false); + ConstructorsClicked(GetConstructorId()); + } } //================================================================================= @@ -490,74 +495,87 @@ void SMESHGUI_SymmetryDlg::ClickOnApply() //================================================================================= void SMESHGUI_SymmetryDlg::ClickOnOk() { - ClickOnApply() ; - ClickOnCancel() ; + ClickOnApply(); + ClickOnCancel(); } - //================================================================================= // function : ClickOnCancel() // purpose : //================================================================================= void SMESHGUI_SymmetryDlg::ClickOnCancel() { - mySelection->ClearFilters(); - mySelection->ClearIObjects(); + disconnect(mySelectionMgr, 0, this, 0); + mySelectionMgr->clearFilters(); + mySelectionMgr->clearSelected(); SMESH::SetPointRepresentation(false); - QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); - disconnect( mySelection, 0, this, 0 ); - mySMESHGUI->ResetState() ; - reject() ; + myViewWindow->SetSelectionMode(ActorSelection); + mySMESHGUI->ResetState(); + reject(); } //======================================================================= -//function : onTextChange -//purpose : +// function : onTextChange() +// purpose : //======================================================================= - -void SMESHGUI_SymmetryDlg::onTextChange(const QString& theNewText) +void SMESHGUI_SymmetryDlg::onTextChange (const QString& theNewText) { QLineEdit* send = (QLineEdit*)sender(); - if ( myBusy ) return; + if (myBusy) return; myBusy = true; - + if (send == LineEditElements) myNbOkElements = 0; - - buttonOk->setEnabled( false ); - buttonApply->setEnabled( false ); - + + buttonOk->setEnabled(false); + buttonApply->setEnabled(false); + // hilight entered elements SMDS_Mesh* aMesh = 0; - if ( myActor ) + if (myActor) aMesh = myActor->GetObject()->GetMesh(); - - if ( aMesh ) { - - mySelection->ClearIObjects(); - mySelection->AddIObject( myActor->getIO() ); - - QStringList aListId = QStringList::split( " ", theNewText, false); - + + if (aMesh) { + //mySelectionMgr->clearSelected(); + //mySelectionMgr->AddIObject(myActor->getIO()); + SALOME_ListIO aList; + aList.Append(myActor->getIO()); + mySelectionMgr->setSelectedObjects(aList, false); + + TColStd_IndexedMapOfInteger selectedIndices; + TColStd_MapOfInteger newIndices; + mySelector->GetIndex(myActor->getIO(), selectedIndices); + + QStringList aListId = QStringList::split(" ", theNewText, false); + if (send == LineEditElements) { - for ( int i = 0; i < aListId.count(); i++ ) { - const SMDS_MeshElement * e = aMesh->FindElement( aListId[ i ].toInt() ); - if ( e ) { - if ( !mySelection->IsIndexSelected( myActor->getIO(), e->GetID() )) - mySelection->AddOrRemoveIndex (myActor->getIO(), e->GetID(), true); + for (int i = 0; i < aListId.count(); i++) { + const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt()); + if (e) { + //if (!mySelectionMgr->IsIndexSelected(myActor->getIO(), e->GetID())) { + if (selectedIndices.Add(e->GetID())) { + //mySelectionMgr->AddOrRemoveIndex (myActor->getIO(), e->GetID(), true); + newIndices.Add(e->GetID()); + } myNbOkElements++; } } + + if (newIndices.Extent() > 0){ + mySelector->AddOrRemoveIndex( myActor->getIO(), newIndices, true ); + myViewWindow->highlight( myActor->getIO(), true, true ); + } + myElementsId = theNewText; } } - - if ( myNbOkElements && IsMirrorOk() ) { - buttonOk->setEnabled( true ); - buttonApply->setEnabled( true ); + + if (myNbOkElements && IsMirrorOk()) { + buttonOk->setEnabled(true); + buttonApply->setEnabled(true); } - + myBusy = false; } @@ -567,33 +585,34 @@ void SMESHGUI_SymmetryDlg::onTextChange(const QString& theNewText) //================================================================================= void SMESHGUI_SymmetryDlg::SelectionIntoArgument() { - if ( myBusy ) return; - + if (myBusy) return; + // clear - myActor = 0; QString aString = ""; myBusy = true; - if (myEditCurrentArgument == (QWidget*)LineEditElements) - { - LineEditElements->setText( aString ); - myNbOkElements = 0; - buttonOk->setEnabled( false ); - buttonApply->setEnabled( false ); - } + if (myEditCurrentArgument == (QWidget*)LineEditElements) { + LineEditElements->setText(aString); + myNbOkElements = 0; + buttonOk->setEnabled(false); + buttonApply->setEnabled(false); + } myBusy = false; - - if ( !GroupButtons->isEnabled() ) // inactive + + if (!GroupButtons->isEnabled()) // inactive return; - + // get selected mesh - int nbSel = mySelection->IObjectCount(); - if(nbSel != 1) + SALOME_ListIO aList; + mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type()); + + int nbSel = aList.Extent(); + if (nbSel != 1) return; - - Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject(); - myMesh = SMESH::GetMeshByIO( mySelection->firstIObject() ); + + Handle(SALOME_InteractiveObject) IO = aList.First(); + myMesh = SMESH::GetMeshByIO(IO); if(myMesh->_is_nil()) return; @@ -602,117 +621,102 @@ void SMESHGUI_SymmetryDlg::SelectionIntoArgument() myActor = SMESH::FindActorByEntry(IO->getEntry()); if (!myActor) return; - + int aNbUnits = 0; - if (myEditCurrentArgument == (QWidget*)LineEditElements) - { - myElementsId = ""; - - if (CheckBoxMesh->isChecked()) - { - SMESH::GetNameOfSelectedIObjects(mySelection, aString); - - if(!SMESH::IObjectToInterface(IO)->_is_nil()) //MESH - { - // get IDs from mesh - SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh(); - if (!aSMDSMesh) - return; - - for (int i = aSMDSMesh->MinElementID(); i <= aSMDSMesh->MaxElementID(); i++ ) - { - const SMDS_MeshElement * e = aSMDSMesh->FindElement( i ); - if ( e ) { - myElementsId += QString(" %1").arg(i); - aNbUnits++; - } - } - } - else if (!SMESH::IObjectToInterface(IO)->_is_nil()) //SUBMESH - { - // get submesh - SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface(IO) ; - - // get IDs from submesh - SMESH::long_array_var anElementsIds = new SMESH::long_array; - anElementsIds = aSubMesh->GetElementsId(); - for ( int i = 0; i < anElementsIds->length(); i++ ) - myElementsId += QString(" %1").arg(anElementsIds[i]); - aNbUnits = anElementsIds->length(); - } - else // GROUP - { - // get smesh group - SMESH::SMESH_GroupBase_var aGroup - = SMESH::IObjectToInterface(IO); - if (aGroup->_is_nil()) - return; - - // get IDs from smesh group - SMESH::long_array_var anElementsIds = new SMESH::long_array; - anElementsIds = aGroup->GetListOfID(); - for ( int i = 0; i < anElementsIds->length(); i++ ) - myElementsId += QString(" %1").arg(anElementsIds[i]); - aNbUnits = anElementsIds->length(); - } - } - else - { - aNbUnits = SMESH::GetNameOfSelectedElements(mySelection, aString) ; - myElementsId = aString; - } - - if(aNbUnits < 1) - return ; - - myNbOkElements = true; + if (myEditCurrentArgument == (QWidget*)LineEditElements) { + myElementsId = ""; + + if (CheckBoxMesh->isChecked()) { + SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString); + + if (!SMESH::IObjectToInterface(IO)->_is_nil()) { //MESH + // get IDs from mesh + SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh(); + if (!aSMDSMesh) + return; + + for (int i = aSMDSMesh->MinElementID(); i <= aSMDSMesh->MaxElementID(); i++) { + const SMDS_MeshElement * e = aSMDSMesh->FindElement(i); + if (e) { + myElementsId += QString(" %1").arg(i); + aNbUnits++; + } + } + } else if (!SMESH::IObjectToInterface(IO)->_is_nil()) { //SUBMESH + // get submesh + SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface(IO); + + // get IDs from submesh + SMESH::long_array_var anElementsIds = new SMESH::long_array; + anElementsIds = aSubMesh->GetElementsId(); + for (int i = 0; i < anElementsIds->length(); i++) { + myElementsId += QString(" %1").arg(anElementsIds[i]); + } + aNbUnits = anElementsIds->length(); + } else { // GROUP + // get smesh group + SMESH::SMESH_GroupBase_var aGroup = + SMESH::IObjectToInterface(IO); + if (aGroup->_is_nil()) + return; + + // get IDs from smesh group + SMESH::long_array_var anElementsIds = new SMESH::long_array; + anElementsIds = aGroup->GetListOfID(); + for (int i = 0; i < anElementsIds->length(); i++) { + myElementsId += QString(" %1").arg(anElementsIds[i]); + } + aNbUnits = anElementsIds->length(); + } + } else { + aNbUnits = SMESH::GetNameOfSelectedElements( mySelector, myActor->getIO(), aString); + myElementsId = aString; } - else - { - aNbUnits = SMESH::GetNameOfSelectedNodes(mySelection, aString); - if(aNbUnits != 1) - return; - - SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh(); - if (!aMesh) - return; - - const SMDS_MeshNode * n = aMesh->FindNode( aString.toInt() ); - if ( !n ) - return; - - double x = n->X(); - double y = n->Y(); - double z = n->Z(); - - if (myEditCurrentArgument == (QWidget*)SpinBox_X) - { - SpinBox_X->SetValue(x); - SpinBox_Y->SetValue(y); - SpinBox_Z->SetValue(z); - } - else if (myEditCurrentArgument == (QWidget*)SpinBox_DX) - { - SpinBox_DX->SetValue(x - SpinBox_X->GetValue()); - SpinBox_DY->SetValue(y - SpinBox_Y->GetValue()); - SpinBox_DZ->SetValue(z - SpinBox_Z->GetValue()); - } + + if (aNbUnits < 1) + return; + + myNbOkElements = true; + } else { + aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, myActor->getIO(), aString); + if (aNbUnits != 1) + return; + + SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh(); + if (!aMesh) + return; + + const SMDS_MeshNode * n = aMesh->FindNode(aString.toInt()); + if (!n) + return; + + double x = n->X(); + double y = n->Y(); + double z = n->Z(); + + if (myEditCurrentArgument == (QWidget*)SpinBox_X) { + SpinBox_X->SetValue(x); + SpinBox_Y->SetValue(y); + SpinBox_Z->SetValue(z); + } else if (myEditCurrentArgument == (QWidget*)SpinBox_DX) { + SpinBox_DX->SetValue(x - SpinBox_X->GetValue()); + SpinBox_DY->SetValue(y - SpinBox_Y->GetValue()); + SpinBox_DZ->SetValue(z - SpinBox_Z->GetValue()); } - + } + myBusy = true; if (myEditCurrentArgument == (QWidget*)LineEditElements) - LineEditElements->setText( aString ); + LineEditElements->setText(aString); myBusy = false; - - // OK - if(myNbOkElements && IsMirrorOk()) - { - buttonOk->setEnabled( true ); - buttonApply->setEnabled( true ); - } -} + // OK + if (myNbOkElements && IsMirrorOk()) { + buttonOk->setEnabled(true); + buttonApply->setEnabled(true); + } +} //================================================================================= // function : SetEditCurrentArgument() @@ -721,38 +725,35 @@ void SMESHGUI_SymmetryDlg::SelectionIntoArgument() void SMESHGUI_SymmetryDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); - - disconnect( mySelection, 0, this, 0 ); - mySelection->ClearIObjects(); - mySelection->ClearFilters(); - - if(send == SelectElementsButton) { + + disconnect(mySelectionMgr, 0, this, 0); + mySelectionMgr->clearSelected(); + mySelectionMgr->clearFilters(); + + if (send == SelectElementsButton) { myEditCurrentArgument = (QWidget*)LineEditElements; SMESH::SetPointRepresentation(false); - if (CheckBoxMesh->isChecked()) - { - QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); - mySelection->AddFilter(myMeshOrSubMeshOrGroupFilter); - } - else - QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true ); + if (CheckBoxMesh->isChecked()) { + myViewWindow->SetSelectionMode(ActorSelection); + mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter); + } else { + myViewWindow->SetSelectionMode(CellSelection); + } + } else if (send == SelectPointButton) { + myEditCurrentArgument = (QWidget*)SpinBox_X; + SMESH::SetPointRepresentation(true); + myViewWindow->SetSelectionMode(NodeSelection); + } else if (send == SelectVectorButton) { + myEditCurrentArgument = (QWidget*)SpinBox_DX; + SMESH::SetPointRepresentation(true); + + myViewWindow->SetSelectionMode(NodeSelection); + } else { } - else if (send == SelectPointButton) - { - myEditCurrentArgument = (QWidget*)SpinBox_X; - SMESH::SetPointRepresentation(true); - QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true ); - } - else if (send == SelectVectorButton) - { - myEditCurrentArgument = (QWidget*)SpinBox_DX; - SMESH::SetPointRepresentation(true); - QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true ); - } - + myEditCurrentArgument->setFocus(); - connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); - SelectionIntoArgument() ; + connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + SelectionIntoArgument(); } //================================================================================= @@ -761,16 +762,15 @@ void SMESHGUI_SymmetryDlg::SetEditCurrentArgument() //================================================================================= void SMESHGUI_SymmetryDlg::DeactivateActiveDialog() { - if ( GroupConstructors->isEnabled() ) { - GroupConstructors->setEnabled(false) ; - GroupArguments->setEnabled(false) ; - GroupButtons->setEnabled(false) ; - mySMESHGUI->ResetState() ; - mySMESHGUI->SetActiveDialogBox(0) ; + if (GroupConstructors->isEnabled()) { + GroupConstructors->setEnabled(false); + GroupArguments->setEnabled(false); + GroupButtons->setEnabled(false); + mySMESHGUI->ResetState(); + mySMESHGUI->SetActiveDialogBox(0); } } - //================================================================================= // function : ActivateThisDialog() // purpose : @@ -778,131 +778,117 @@ void SMESHGUI_SymmetryDlg::DeactivateActiveDialog() void SMESHGUI_SymmetryDlg::ActivateThisDialog() { /* Emit a signal to deactivate the active dialog */ - mySMESHGUI->EmitSignalDeactivateDialog() ; - GroupConstructors->setEnabled(true) ; - GroupArguments->setEnabled(true) ; - GroupButtons->setEnabled(true) ; - - mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; + mySMESHGUI->EmitSignalDeactivateDialog(); + GroupConstructors->setEnabled(true); + GroupArguments->setEnabled(true); + GroupButtons->setEnabled(true); - QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true ); + mySMESHGUI->SetActiveDialogBox((QDialog*)this); + + myViewWindow->SetSelectionMode(CellSelection); SelectionIntoArgument(); } - //================================================================================= // function : enterEvent() // purpose : //================================================================================= -void SMESHGUI_SymmetryDlg::enterEvent(QEvent* e) +void SMESHGUI_SymmetryDlg::enterEvent (QEvent*) { - if ( GroupConstructors->isEnabled() ) - return ; - ActivateThisDialog() ; + if (!GroupConstructors->isEnabled()) + ActivateThisDialog(); } - //================================================================================= // function : closeEvent() // purpose : //================================================================================= -void SMESHGUI_SymmetryDlg::closeEvent( QCloseEvent* e ) +void SMESHGUI_SymmetryDlg::closeEvent (QCloseEvent*) { /* same than click on cancel button */ - this->ClickOnCancel() ; + this->ClickOnCancel(); } - //======================================================================= -//function : hideEvent -//purpose : caused by ESC key +// function : hideEvent() +// purpose : caused by ESC key //======================================================================= - -void SMESHGUI_SymmetryDlg::hideEvent ( QHideEvent * e ) +void SMESHGUI_SymmetryDlg::hideEvent (QHideEvent*) { - if ( !isMinimized() ) + if (!isMinimized()) ClickOnCancel(); } - //======================================================================= //function : onSelectMesh //purpose : //======================================================================= -void SMESHGUI_SymmetryDlg::onSelectMesh ( bool toSelectMesh ) +void SMESHGUI_SymmetryDlg::onSelectMesh (bool toSelectMesh) { if (toSelectMesh) - TextLabelElements->setText( tr( "SMESH_NAME" ) ); + TextLabelElements->setText(tr("SMESH_NAME")); else - TextLabelElements->setText( tr( "SMESH_ID_ELEMENTS" ) ); - - if (myEditCurrentArgument != LineEditElements) - { - LineEditElements->clear(); - return; - } - - mySelection->ClearFilters() ; + TextLabelElements->setText(tr("SMESH_ID_ELEMENTS")); + + if (myEditCurrentArgument != LineEditElements) { + LineEditElements->clear(); + return; + } + + mySelectionMgr->clearFilters(); SMESH::SetPointRepresentation(false); - - if (toSelectMesh) - { - QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); - mySelection->AddFilter(myMeshOrSubMeshOrGroupFilter); - LineEditElements->setReadOnly(true); - } - else - { - QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true ); - LineEditElements->setReadOnly(false); - onTextChange(LineEditElements->text()); - } - + + if (toSelectMesh) { + myViewWindow->SetSelectionMode(ActorSelection); + mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter); + LineEditElements->setReadOnly(true); + } else { + myViewWindow->SetSelectionMode(CellSelection); + LineEditElements->setReadOnly(false); + onTextChange(LineEditElements->text()); + } + SelectionIntoArgument(); } - //================================================================================= // function : GetConstructorId() -// purpose : +// purpose : //================================================================================= int SMESHGUI_SymmetryDlg::GetConstructorId() -{ - if ( GroupConstructors != NULL && GroupConstructors->selected() != NULL ) - return GroupConstructors->id( GroupConstructors->selected() ); +{ + if (GroupConstructors != NULL && GroupConstructors->selected() != NULL) + return GroupConstructors->id(GroupConstructors->selected()); return -1; } - //================================================================================= -// function : IsAxisOk() -// purpose : +// function : IsMirrorOk() +// purpose : //================================================================================= bool SMESHGUI_SymmetryDlg::IsMirrorOk() { bool isOk = true; if (GetConstructorId() != 0) - isOk = SpinBox_DX->GetValue() != 0 || SpinBox_DY->GetValue() != 0 || SpinBox_DZ->GetValue() != 0; + isOk = (SpinBox_DX->GetValue() != 0 || + SpinBox_DY->GetValue() != 0 || + SpinBox_DZ->GetValue() != 0); return isOk; } - //================================================================================= // function : onVectorChanged() -// purpose : +// purpose : //================================================================================= void SMESHGUI_SymmetryDlg::onVectorChanged() { - if (IsMirrorOk()) - { - buttonOk->setEnabled( true ); - buttonApply->setEnabled( true ); - } - else - { - buttonOk->setEnabled( false ); - buttonApply->setEnabled( false ); - } + if (IsMirrorOk()) { + buttonOk->setEnabled(true); + buttonApply->setEnabled(true); + } else { + buttonOk->setEnabled(false); + buttonApply->setEnabled(false); + } } diff --git a/src/SMESHGUI/SMESHGUI_SymmetryDlg.h b/src/SMESHGUI/SMESHGUI_SymmetryDlg.h index c556b3493..97cd85605 100644 --- a/src/SMESHGUI/SMESHGUI_SymmetryDlg.h +++ b/src/SMESHGUI/SMESHGUI_SymmetryDlg.h @@ -29,7 +29,8 @@ #ifndef DIALOGBOX_SYMMETRY_H #define DIALOGBOX_SYMMETRY_H -#include "SALOME_Selection.h" +#include "SalomeApp_SelectionMgr.h" + #include "SMESH_LogicalFilter.hxx" // QT Includes @@ -47,6 +48,8 @@ class QCheckBox; class SMESHGUI_SpinBox; class SMESHGUI; class SMESH_Actor; +class SVTK_ViewWindow; +class SVTK_Selector; // IDL Headers #include @@ -62,29 +65,33 @@ class SMESHGUI_SymmetryDlg : public QDialog Q_OBJECT public: - SMESHGUI_SymmetryDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); + SMESHGUI_SymmetryDlg( SMESHGUI*, + const char* name = 0, + bool modal = FALSE, + WFlags fl = 0); ~SMESHGUI_SymmetryDlg(); private: - - void Init( bool ResetControls = true ) ; - void closeEvent( QCloseEvent* e ) ; - void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */ - void hideEvent ( QHideEvent * ); /* ESC key */ + void Init (bool ResetControls = true); + void closeEvent (QCloseEvent*); + void enterEvent (QEvent*); /* mouse enter the QWidget */ + void hideEvent (QHideEvent*); /* ESC key */ int GetConstructorId(); bool IsMirrorOk(); - - SMESHGUI* mySMESHGUI ; /* Current SMESHGUI object */ - SALOME_Selection* mySelection ; /* User shape selection */ - int myNbOkElements ; /* to check when elements are defined */ - QString myElementsId; - QWidget* myEditCurrentArgument; /* Current LineEdit */ - + SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */ + SalomeApp_SelectionMgr* mySelectionMgr; /* User shape selection */ + int myNbOkElements; /* to check when elements are defined */ + QString myElementsId; + SVTK_ViewWindow* myViewWindow; + SVTK_Selector* mySelector; + + QWidget* myEditCurrentArgument; /* Current LineEdit */ + bool myBusy; SMESH::SMESH_Mesh_var myMesh; SMESH_Actor* myActor; - Handle(SMESH_LogicalFilter) myMeshOrSubMeshOrGroupFilter; + SMESH_LogicalFilter* myMeshOrSubMeshOrGroupFilter; QButtonGroup* GroupConstructors; QRadioButton* RadioButton1; diff --git a/src/SMESHGUI/SMESHGUI_TranslationDlg.cxx b/src/SMESHGUI/SMESHGUI_TranslationDlg.cxx index 0bb568609..5ab553b22 100644 --- a/src/SMESHGUI/SMESHGUI_TranslationDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_TranslationDlg.cxx @@ -1,48 +1,60 @@ // SMESH SMESHGUI : GUI for SMESH component // // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org // // // // File : SMESHGUI_TranslationDlg.cxx // Author : Michael ZORIN // Module : SMESH -// $Header: +// $Header: #include "SMESHGUI_TranslationDlg.h" #include "SMESHGUI.h" +#include "SMESHGUI_SpinBox.h" #include "SMESHGUI_Utils.h" #include "SMESHGUI_VTKUtils.h" #include "SMESHGUI_MeshUtils.h" #include "SMESHGUI_IdValidator.h" -#include "SMESHGUI_SpinBox.h" + #include "SMESH_Actor.h" #include "SMESH_TypeFilter.hxx" +#include "SMESH_LogicalFilter.hxx" #include "SMDS_Mesh.hxx" -#include "QAD_Application.h" -#include "QAD_Desktop.h" -#include "QAD_MessageBox.h" +#include "SUIT_Desktop.h" +#include "SUIT_ResourceMgr.h" + +#include "SVTK_ViewModel.h" +#include "SVTK_Selection.h" +#include "SVTK_ViewWindow.h" +#include "SVTK_Selector.h" +#include "SALOME_ListIO.hxx" + #include "utilities.h" +// OCCT Includes +#include +#include + // QT Includes #include #include @@ -53,7 +65,7 @@ #include #include #include -#include +#include #include // IDL Headers @@ -64,230 +76,231 @@ using namespace std; //================================================================================= // class : SMESHGUI_TranslationDlg() -// purpose : +// purpose : //================================================================================= -SMESHGUI_TranslationDlg::SMESHGUI_TranslationDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, - bool modal, WFlags fl ) - : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | - Qt::WDestructiveClose) +SMESHGUI_TranslationDlg::SMESHGUI_TranslationDlg( SMESHGUI* theModule, const char* name, + bool modal, WFlags fl) + : QDialog( SMESH::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder | + WStyle_Title | WStyle_SysMenu | Qt::WDestructiveClose), + mySMESHGUI( theModule ), + mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ), + myViewWindow( SMESH::GetViewWindow( theModule ) ), + mySelector( myViewWindow->GetSelector() ) { - QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SMESH_TRANSLATION_POINTS"))); - QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SMESH_TRANSLATION_VECTOR"))); - QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SELECT"))); + QPixmap image0 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SMESH_TRANSLATION_POINTS"))); + QPixmap image1 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SMESH_TRANSLATION_VECTOR"))); + QPixmap image2 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT"))); - if ( !name ) - setName( "SMESHGUI_TranslationDlg" ); - resize( 303, 185 ); - setCaption( tr( "SMESH_TRANSLATION" ) ); - setSizeGripEnabled( TRUE ); - SMESHGUI_TranslationDlgLayout = new QGridLayout( this ); - SMESHGUI_TranslationDlgLayout->setSpacing( 6 ); - SMESHGUI_TranslationDlgLayout->setMargin( 11 ); + if (!name) + setName("SMESHGUI_TranslationDlg"); + resize(303, 185); + setCaption(tr("SMESH_TRANSLATION")); + setSizeGripEnabled(TRUE); + SMESHGUI_TranslationDlgLayout = new QGridLayout(this); + SMESHGUI_TranslationDlgLayout->setSpacing(6); + SMESHGUI_TranslationDlgLayout->setMargin(11); /***************************************************************/ - GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); - GroupConstructors->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)0, 0, 0, GroupConstructors->sizePolicy().hasHeightForWidth() ) ); - GroupConstructors->setTitle( tr( "SMESH_TRANSLATION" ) ); - GroupConstructors->setExclusive( TRUE ); - GroupConstructors->setColumnLayout(0, Qt::Vertical ); - GroupConstructors->layout()->setSpacing( 0 ); - GroupConstructors->layout()->setMargin( 0 ); - GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() ); - GroupConstructorsLayout->setAlignment( Qt::AlignTop ); - GroupConstructorsLayout->setSpacing( 6 ); - GroupConstructorsLayout->setMargin( 11 ); - RadioButton1= new QRadioButton( GroupConstructors, "RadioButton1" ); - RadioButton1->setText( tr( "" ) ); - RadioButton1->setPixmap( image0 ); - GroupConstructorsLayout->addWidget( RadioButton1, 0, 0 ); - RadioButton2= new QRadioButton( GroupConstructors, "RadioButton2" ); - RadioButton2->setText( tr( "" ) ); - RadioButton2->setPixmap( image1 ); - GroupConstructorsLayout->addWidget( RadioButton2, 0, 2 ); - SMESHGUI_TranslationDlgLayout->addWidget( GroupConstructors, 0, 0 ); - - /***************************************************************/ - GroupButtons = new QGroupBox( this, "GroupButtons" ); - GroupButtons->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, GroupButtons->sizePolicy().hasHeightForWidth() ) ); - GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); - GroupButtons->setTitle( tr( "" ) ); - GroupButtons->setColumnLayout(0, Qt::Vertical ); - GroupButtons->layout()->setSpacing( 0 ); - GroupButtons->layout()->setMargin( 0 ); - GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); - GroupButtonsLayout->setAlignment( Qt::AlignTop ); - GroupButtonsLayout->setSpacing( 6 ); - GroupButtonsLayout->setMargin( 11 ); - buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); - buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) ); - buttonCancel->setAutoDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonCancel, 0, 3 ); - buttonApply = new QPushButton( GroupButtons, "buttonApply" ); - buttonApply->setText( tr( "SMESH_BUT_APPLY" ) ); - buttonApply->setAutoDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); - QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); - GroupButtonsLayout->addItem( spacer_9, 0, 2 ); - buttonOk = new QPushButton( GroupButtons, "buttonOk" ); - buttonOk->setText( tr( "SMESH_BUT_OK" ) ); - buttonOk->setAutoDefault( TRUE ); - buttonOk->setDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); - SMESHGUI_TranslationDlgLayout->addWidget( GroupButtons, 2, 0 ); + GroupConstructors = new QButtonGroup(this, "GroupConstructors"); + GroupConstructors->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)5, (QSizePolicy::SizeType)0, 0, 0, GroupConstructors->sizePolicy().hasHeightForWidth())); + GroupConstructors->setTitle(tr("SMESH_TRANSLATION" )); + GroupConstructors->setExclusive(TRUE); + GroupConstructors->setColumnLayout(0, Qt::Vertical); + GroupConstructors->layout()->setSpacing(0); + GroupConstructors->layout()->setMargin(0); + GroupConstructorsLayout = new QGridLayout(GroupConstructors->layout()); + GroupConstructorsLayout->setAlignment(Qt::AlignTop); + GroupConstructorsLayout->setSpacing(6); + GroupConstructorsLayout->setMargin(11); + RadioButton1= new QRadioButton(GroupConstructors, "RadioButton1"); + RadioButton1->setText(tr("" )); + RadioButton1->setPixmap(image0); + GroupConstructorsLayout->addWidget(RadioButton1, 0, 0); + RadioButton2= new QRadioButton(GroupConstructors, "RadioButton2"); + RadioButton2->setText(tr("" )); + RadioButton2->setPixmap(image1); + GroupConstructorsLayout->addWidget(RadioButton2, 0, 2 ); + SMESHGUI_TranslationDlgLayout->addWidget(GroupConstructors, 0, 0); /***************************************************************/ - GroupArguments = new QGroupBox( this, "GroupArguments" ); - GroupArguments->setTitle( tr( "SMESH_ARGUMENTS" ) ); - GroupArguments->setColumnLayout(0, Qt::Vertical ); - GroupArguments->layout()->setSpacing( 0 ); - GroupArguments->layout()->setMargin( 0 ); - GroupArgumentsLayout = new QGridLayout( GroupArguments->layout() ); - GroupArgumentsLayout->setAlignment( Qt::AlignTop ); - GroupArgumentsLayout->setSpacing( 6 ); - GroupArgumentsLayout->setMargin( 11 ); + GroupButtons = new QGroupBox(this, "GroupButtons"); + GroupButtons->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, GroupButtons->sizePolicy().hasHeightForWidth())); + GroupButtons->setGeometry(QRect(10, 10, 281, 48)); + GroupButtons->setTitle(tr("" )); + GroupButtons->setColumnLayout(0, Qt::Vertical); + GroupButtons->layout()->setSpacing(0); + GroupButtons->layout()->setMargin(0); + GroupButtonsLayout = new QGridLayout(GroupButtons->layout()); + GroupButtonsLayout->setAlignment(Qt::AlignTop); + GroupButtonsLayout->setSpacing(6); + GroupButtonsLayout->setMargin(11); + buttonCancel = new QPushButton(GroupButtons, "buttonCancel"); + buttonCancel->setText(tr("SMESH_BUT_CLOSE" )); + buttonCancel->setAutoDefault(TRUE); + GroupButtonsLayout->addWidget(buttonCancel, 0, 3); + buttonApply = new QPushButton(GroupButtons, "buttonApply"); + buttonApply->setText(tr("SMESH_BUT_APPLY" )); + buttonApply->setAutoDefault(TRUE); + GroupButtonsLayout->addWidget(buttonApply, 0, 1); + QSpacerItem* spacer_9 = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); + GroupButtonsLayout->addItem(spacer_9, 0, 2); + buttonOk = new QPushButton(GroupButtons, "buttonOk"); + buttonOk->setText(tr("SMESH_BUT_OK" )); + buttonOk->setAutoDefault(TRUE); + buttonOk->setDefault(TRUE); + GroupButtonsLayout->addWidget(buttonOk, 0, 0); + SMESHGUI_TranslationDlgLayout->addWidget(GroupButtons, 2, 0); + + /***************************************************************/ + GroupArguments = new QGroupBox(this, "GroupArguments"); + GroupArguments->setTitle(tr("SMESH_ARGUMENTS")); + GroupArguments->setColumnLayout(0, Qt::Vertical); + GroupArguments->layout()->setSpacing(0); + GroupArguments->layout()->setMargin(0); + GroupArgumentsLayout = new QGridLayout(GroupArguments->layout()); + GroupArgumentsLayout->setAlignment(Qt::AlignTop); + GroupArgumentsLayout->setSpacing(6); + GroupArgumentsLayout->setMargin(11); // Controls for elements selection - TextLabelElements = new QLabel( GroupArguments, "TextLabelElements" ); - TextLabelElements->setText( tr( "SMESH_ID_ELEMENTS" ) ); + TextLabelElements = new QLabel(GroupArguments, "TextLabelElements"); + TextLabelElements->setText(tr("SMESH_ID_ELEMENTS" )); TextLabelElements->setFixedWidth(74); - GroupArgumentsLayout->addWidget( TextLabelElements, 0, 0 ); + GroupArgumentsLayout->addWidget(TextLabelElements, 0, 0); - SelectElementsButton = new QPushButton( GroupArguments, "SelectElementsButton" ); - SelectElementsButton->setText( tr( "" ) ); - SelectElementsButton->setPixmap( image2 ); - SelectElementsButton->setToggleButton( FALSE ); - GroupArgumentsLayout->addWidget( SelectElementsButton, 0, 1 ); + SelectElementsButton = new QPushButton(GroupArguments, "SelectElementsButton"); + SelectElementsButton->setText(tr("" )); + SelectElementsButton->setPixmap(image2); + SelectElementsButton->setToggleButton(FALSE); + GroupArgumentsLayout->addWidget(SelectElementsButton, 0, 1); - LineEditElements = new QLineEdit( GroupArguments, "LineEditElements" ); - LineEditElements->setValidator( new SMESHGUI_IdValidator( this, "validator" )); - GroupArgumentsLayout->addMultiCellWidget( LineEditElements, 0, 0, 2, 7 ); + LineEditElements = new QLineEdit(GroupArguments, "LineEditElements"); + LineEditElements->setValidator(new SMESHGUI_IdValidator(this, "validator")); + GroupArgumentsLayout->addMultiCellWidget(LineEditElements, 0, 0, 2, 7); // Control for the whole mesh selection - CheckBoxMesh = new QCheckBox( GroupArguments, "CheckBoxMesh" ); - CheckBoxMesh->setText( tr( "SMESH_SELECT_WHOLE_MESH" ) ); - GroupArgumentsLayout->addMultiCellWidget( CheckBoxMesh, 1, 1, 0, 7 ); - + CheckBoxMesh = new QCheckBox(GroupArguments, "CheckBoxMesh"); + CheckBoxMesh->setText(tr("SMESH_SELECT_WHOLE_MESH" )); + GroupArgumentsLayout->addMultiCellWidget(CheckBoxMesh, 1, 1, 0, 7); + // Controls for vector and points selection - TextLabel1 = new QLabel( GroupArguments, "TextLabel1" ); - GroupArgumentsLayout->addWidget( TextLabel1, 2, 0 ); + TextLabel1 = new QLabel(GroupArguments, "TextLabel1"); + GroupArgumentsLayout->addWidget(TextLabel1, 2, 0); - SelectButton1 = new QPushButton( GroupArguments, "SelectButton1" ); - SelectButton1->setText( tr( "" ) ); - SelectButton1->setPixmap( image2 ); - SelectButton1->setToggleButton( FALSE ); - GroupArgumentsLayout->addWidget( SelectButton1, 2, 1 ); + SelectButton1 = new QPushButton(GroupArguments, "SelectButton1"); + SelectButton1->setText(tr("" )); + SelectButton1->setPixmap(image2); + SelectButton1->setToggleButton(FALSE); + GroupArgumentsLayout->addWidget(SelectButton1, 2, 1); - TextLabel1_1 = new QLabel( GroupArguments, "TextLabel1_1" ); - GroupArgumentsLayout->addWidget( TextLabel1_1, 2, 2 ); + TextLabel1_1 = new QLabel(GroupArguments, "TextLabel1_1"); + GroupArgumentsLayout->addWidget(TextLabel1_1, 2, 2); SpinBox1_1 = new SMESHGUI_SpinBox(GroupArguments, "SpinBox1_1"); - GroupArgumentsLayout->addWidget( SpinBox1_1, 2, 3 ); + GroupArgumentsLayout->addWidget(SpinBox1_1, 2, 3); - TextLabel1_2 = new QLabel( GroupArguments, "TextLabel1_2" ); - GroupArgumentsLayout->addWidget( TextLabel1_2, 2, 4 ); + TextLabel1_2 = new QLabel(GroupArguments, "TextLabel1_2"); + GroupArgumentsLayout->addWidget(TextLabel1_2, 2, 4); SpinBox1_2 = new SMESHGUI_SpinBox(GroupArguments, "SpinBox1_2"); - GroupArgumentsLayout->addWidget( SpinBox1_2, 2, 5 ); + GroupArgumentsLayout->addWidget(SpinBox1_2, 2, 5); + + TextLabel1_3 = new QLabel(GroupArguments, "TextLabel1_3"); + GroupArgumentsLayout->addWidget(TextLabel1_3, 2, 6); - TextLabel1_3 = new QLabel( GroupArguments, "TextLabel1_3" ); - GroupArgumentsLayout->addWidget( TextLabel1_3, 2, 6 ); - SpinBox1_3 = new SMESHGUI_SpinBox(GroupArguments, "SpinBox1_3"); - GroupArgumentsLayout->addWidget( SpinBox1_3, 2, 7 ); - - TextLabel2 = new QLabel( GroupArguments, "TextLabel2" ); - TextLabel2->setText( tr( "SMESH_POINT_2" ) ); - GroupArgumentsLayout->addWidget( TextLabel2, 3, 0 ); + GroupArgumentsLayout->addWidget(SpinBox1_3, 2, 7); - SelectButton2 = new QPushButton( GroupArguments, "SelectButton2" ); - SelectButton2->setText( tr( "" ) ); - SelectButton2->setPixmap( image2 ); - SelectButton2->setToggleButton( FALSE ); - GroupArgumentsLayout->addWidget( SelectButton2, 3, 1 ); + TextLabel2 = new QLabel(GroupArguments, "TextLabel2"); + TextLabel2->setText(tr("SMESH_POINT_2" )); + GroupArgumentsLayout->addWidget(TextLabel2, 3, 0); + + SelectButton2 = new QPushButton(GroupArguments, "SelectButton2"); + SelectButton2->setText(tr("" )); + SelectButton2->setPixmap(image2); + SelectButton2->setToggleButton(FALSE); + GroupArgumentsLayout->addWidget(SelectButton2, 3, 1); + + TextLabel2_1 = new QLabel(GroupArguments, "TextLabel2_1"); + TextLabel2_1->setText(tr("SMESH_X" )); + GroupArgumentsLayout->addWidget(TextLabel2_1, 3, 2); - TextLabel2_1 = new QLabel( GroupArguments, "TextLabel2_1" ); - TextLabel2_1->setText( tr( "SMESH_X" ) ); - GroupArgumentsLayout->addWidget( TextLabel2_1, 3, 2 ); - SpinBox2_1 = new SMESHGUI_SpinBox(GroupArguments, "SpinBox2_1"); - GroupArgumentsLayout->addWidget( SpinBox2_1, 3, 3 ); - - TextLabel2_2 = new QLabel( GroupArguments, "TextLabel2_2" ); - TextLabel2_2->setText( tr( "SMESH_Y" ) ); - GroupArgumentsLayout->addWidget( TextLabel2_2, 3, 4 ); + GroupArgumentsLayout->addWidget(SpinBox2_1, 3, 3); + + TextLabel2_2 = new QLabel(GroupArguments, "TextLabel2_2"); + TextLabel2_2->setText(tr("SMESH_Y" )); + GroupArgumentsLayout->addWidget(TextLabel2_2, 3, 4); SpinBox2_2 = new SMESHGUI_SpinBox(GroupArguments, "SpinBox2_2"); - GroupArgumentsLayout->addWidget( SpinBox2_2, 3, 5 ); + GroupArgumentsLayout->addWidget(SpinBox2_2, 3, 5); + + TextLabel2_3 = new QLabel(GroupArguments, "TextLabel2_3"); + TextLabel2_3->setText(tr("SMESH_Z")); + GroupArgumentsLayout->addWidget(TextLabel2_3, 3, 6); - TextLabel2_3 = new QLabel( GroupArguments, "TextLabel2_3" ); - TextLabel2_3->setText( tr( "SMESH_Z" ) ); - GroupArgumentsLayout->addWidget( TextLabel2_3, 3, 6 ); - SpinBox2_3 = new SMESHGUI_SpinBox(GroupArguments, "SpinBox2_3"); - GroupArgumentsLayout->addWidget( SpinBox2_3, 3, 7 ); - - // Controls for "Create a copy" option - CheckBoxCopy = new QCheckBox( GroupArguments, "CheckBoxCopy" ); - CheckBoxCopy->setText( tr( "SMESH_CREATE_COPY" ) ); - GroupArgumentsLayout->addMultiCellWidget( CheckBoxCopy, 4, 4, 0, 2 ); - + GroupArgumentsLayout->addWidget(SpinBox2_3, 3, 7); + + // Controls for "Create a copy" option + CheckBoxCopy = new QCheckBox(GroupArguments, "CheckBoxCopy"); + CheckBoxCopy->setText(tr("SMESH_CREATE_COPY")); + GroupArgumentsLayout->addMultiCellWidget(CheckBoxCopy, 4, 4, 0, 2); + + + SMESHGUI_TranslationDlgLayout->addWidget(GroupArguments, 1, 0); - SMESHGUI_TranslationDlgLayout->addWidget( GroupArguments, 1, 0 ); - /* Initialisations */ - SpinBox1_1->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 ); - SpinBox1_2->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 ); - SpinBox1_3->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 ); - SpinBox2_1->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 ); - SpinBox2_2->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 ); - SpinBox2_3->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 ); + SpinBox1_1->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3); + SpinBox1_2->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3); + SpinBox1_3->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3); + SpinBox2_1->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3); + SpinBox2_2->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3); + SpinBox2_3->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3); GroupArguments->show(); - RadioButton1->setChecked( TRUE ); - mySelection = Sel; - - mySMESHGUI = SMESHGUI::GetSMESHGUI() ; - mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; + RadioButton1->setChecked(TRUE); + + mySMESHGUI->SetActiveDialogBox((QDialog*)this); // Costruction of the logical filter - SMESH_ListOfFilter aListOfFilters; - Handle(SMESH_TypeFilter) aMeshOrSubMeshFilter = new SMESH_TypeFilter( MESHorSUBMESH ); - if ( !aMeshOrSubMeshFilter.IsNull() ) - aListOfFilters.Append( aMeshOrSubMeshFilter ); - Handle(SMESH_TypeFilter) aSmeshGroupFilter = new SMESH_TypeFilter( GROUP ); - if ( !aSmeshGroupFilter.IsNull() ) - aListOfFilters.Append( aSmeshGroupFilter ); - - myMeshOrSubMeshOrGroupFilter = new SMESH_LogicalFilter( aListOfFilters, SMESH_LogicalFilter::LO_OR ); - + SMESH_TypeFilter* aMeshOrSubMeshFilter = new SMESH_TypeFilter (MESHorSUBMESH); + SMESH_TypeFilter* aSmeshGroupFilter = new SMESH_TypeFilter (GROUP); + + QPtrList aListOfFilters; + if (aMeshOrSubMeshFilter) aListOfFilters.append(aMeshOrSubMeshFilter); + if (aSmeshGroupFilter) aListOfFilters.append(aSmeshGroupFilter); + + myMeshOrSubMeshOrGroupFilter = + new SMESH_LogicalFilter(aListOfFilters, SMESH_LogicalFilter::LO_OR); + Init(); /* signals and slots connections */ - connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); - connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ; - connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) ); - connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) ); - - connect( SelectElementsButton, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; - connect( SelectButton1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; - connect( SelectButton2, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel())); + connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); + connect(GroupConstructors, SIGNAL(clicked(int)), SLOT(ConstructorsClicked(int))); - connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; - connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + connect(SelectElementsButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument())); + connect(SelectButton1, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument())); + connect(SelectButton2, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument())); + + connect(mySMESHGUI, SIGNAL (SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog())); + connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); /* to close dialog if study change */ - connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; - connect( LineEditElements, SIGNAL( textChanged( const QString& )), - SLOT( onTextChange( const QString& ))); - connect( CheckBoxMesh, SIGNAL( toggled( bool )), - SLOT( onSelectMesh( bool ))); - + connect(mySMESHGUI, SIGNAL (SignalCloseAllDialogs()), this, SLOT(ClickOnCancel())); + connect(LineEditElements, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&))); + connect(CheckBoxMesh, SIGNAL(toggled(bool)), SLOT(onSelectMesh(bool))); + /* Move widget on the botton right corner of main widget */ - int x, y ; - mySMESHGUI->DefineDlgPosition( this, x, y ) ; - this->move( x, y ) ; - this->show() ; /* displays Dialog */ + int x, y; + mySMESHGUI->DefineDlgPosition(this, x, y); + this->move(x, y); + this->show(); /* displays Dialog */ ConstructorsClicked(0); + resize(0,0); // ?? } //================================================================================= @@ -299,106 +312,101 @@ SMESHGUI_TranslationDlg::~SMESHGUI_TranslationDlg() // no need to delete child widgets, Qt does it all for us } - //================================================================================= // function : Init() // purpose : //================================================================================= -void SMESHGUI_TranslationDlg::Init( bool ResetControls ) +void SMESHGUI_TranslationDlg::Init (bool ResetControls) { myBusy = false; - + myEditCurrentArgument = 0; LineEditElements->clear(); myElementsId = ""; myNbOkElements = 0; - buttonOk->setEnabled( false ); - buttonApply->setEnabled( false ); - - myActor = 0; + buttonOk->setEnabled(false); + buttonApply->setEnabled(false); + + myActor = 0; myMesh = SMESH::SMESH_Mesh::_nil(); - if( ResetControls ) - { - SpinBox1_1->SetValue(0.0); - SpinBox1_2->SetValue(0.0); - SpinBox1_3->SetValue(0.0); - SpinBox2_1->SetValue(0.0); - SpinBox2_2->SetValue(0.0); - SpinBox2_3->SetValue(0.0); - - CheckBoxCopy->setChecked(false); - CheckBoxMesh->setChecked(false); - onSelectMesh( false ); - } -} + if (ResetControls) { + SpinBox1_1->SetValue(0.0); + SpinBox1_2->SetValue(0.0); + SpinBox1_3->SetValue(0.0); + SpinBox2_1->SetValue(0.0); + SpinBox2_2->SetValue(0.0); + SpinBox2_3->SetValue(0.0); + CheckBoxCopy->setChecked(false); + CheckBoxMesh->setChecked(false); + onSelectMesh(false); + } +} //================================================================================= // function : ConstructorsClicked() // purpose : Radio button management //================================================================================= -void SMESHGUI_TranslationDlg::ConstructorsClicked(int constructorId) +void SMESHGUI_TranslationDlg::ConstructorsClicked (int constructorId) { - disconnect(mySelection, 0, this, 0); - - switch(constructorId) - { - case 0 : - { - TextLabel1->setText( tr( "SMESH_POINT_1" ) ); - TextLabel1_1->setText( tr( "SMESH_X" ) ); - TextLabel1_2->setText( tr( "SMESH_Y" ) ); - TextLabel1_3->setText( tr( "SMESH_Z" ) ); + disconnect(mySelectionMgr, 0, this, 0); - SelectButton1->show(); - TextLabel2->show(); - SelectButton2->show(); - TextLabel2_1->show(); - SpinBox2_1->show(); - TextLabel2_2->show(); - SpinBox2_2->show(); - TextLabel2_3->show(); - SpinBox2_3->show(); - break; - } - case 1 : - { - TextLabel1->setText( tr( "SMESH_VECTOR" ) ); - TextLabel1_1->setText( tr( "SMESH_DX" ) ); - TextLabel1_2->setText( tr( "SMESH_DY" ) ); - TextLabel1_3->setText( tr( "SMESH_DZ" ) ); - - SelectButton1->hide(); - TextLabel2->hide(); - SelectButton2->hide(); - TextLabel2_1->hide(); - SpinBox2_1->hide(); - TextLabel2_2->hide(); - SpinBox2_2->hide(); - TextLabel2_3->hide(); - SpinBox2_3->hide(); - break; - } - } - - if (myEditCurrentArgument != (QWidget*)LineEditElements) + switch (constructorId) { + case 0: { - SMESH::SetPointRepresentation(false); - if (!CheckBoxMesh->isChecked()) - QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true ); + TextLabel1->setText(tr("SMESH_POINT_1")); + TextLabel1_1->setText(tr("SMESH_X")); + TextLabel1_2->setText(tr("SMESH_Y")); + TextLabel1_3->setText(tr("SMESH_Z")); + + SelectButton1->show(); + TextLabel2->show(); + SelectButton2->show(); + TextLabel2_1->show(); + SpinBox2_1->show(); + TextLabel2_2->show(); + SpinBox2_2->show(); + TextLabel2_3->show(); + SpinBox2_3->show(); + break; } - + case 1: + { + TextLabel1->setText(tr("SMESH_VECTOR")); + TextLabel1_1->setText(tr("SMESH_DX")); + TextLabel1_2->setText(tr("SMESH_DY")); + TextLabel1_3->setText(tr("SMESH_DZ")); + + SelectButton1->hide(); + TextLabel2->hide(); + SelectButton2->hide(); + TextLabel2_1->hide(); + SpinBox2_1->hide(); + TextLabel2_2->hide(); + SpinBox2_2->hide(); + TextLabel2_3->hide(); + SpinBox2_3->hide(); + break; + } + } + + if (myEditCurrentArgument != (QWidget*)LineEditElements) { + SMESH::SetPointRepresentation(false); + if (!CheckBoxMesh->isChecked()) + + myViewWindow->SetSelectionMode( CellSelection ); + } + myEditCurrentArgument = (QWidget*)LineEditElements; LineEditElements->setFocus(); - + if (CheckBoxMesh->isChecked()) onSelectMesh(true); - - connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); -} + connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); +} //================================================================================= // function : ClickOnApply() @@ -406,51 +414,44 @@ void SMESHGUI_TranslationDlg::ConstructorsClicked(int constructorId) //================================================================================= void SMESHGUI_TranslationDlg::ClickOnApply() { - if (mySMESHGUI->ActiveStudyLocked()) + if (mySMESHGUI->isActiveStudyLocked()) return; - - if ( myNbOkElements) - { - QStringList aListElementsId = QStringList::split( " ", myElementsId, false); - - SMESH::long_array_var anElementsId = new SMESH::long_array; - - anElementsId->length( aListElementsId.count() ); - for ( int i = 0; i < aListElementsId.count(); i++ ) - anElementsId[i] = aListElementsId[i].toInt(); - SMESH::DirStruct aVector; - if(GetConstructorId() == 0) - { - aVector.PS.x = SpinBox2_1->GetValue() - SpinBox1_1->GetValue(); - aVector.PS.y = SpinBox2_2->GetValue() - SpinBox1_2->GetValue(); - aVector.PS.z = SpinBox2_3->GetValue() - SpinBox1_3->GetValue(); - } - else if(GetConstructorId() == 1) - { - aVector.PS.x = SpinBox1_1->GetValue(); - aVector.PS.y = SpinBox1_2->GetValue(); - aVector.PS.z = SpinBox1_3->GetValue(); - } - - bool toCreateCopy = CheckBoxCopy->isChecked(); - - try - { - SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor(); - QApplication::setOverrideCursor(Qt::waitCursor); - aMeshEditor->Translate(anElementsId.inout(), aVector, toCreateCopy); - QApplication::restoreOverrideCursor(); - } - catch( ... ) - { - } - - mySelection->ClearIObjects(); - SMESH::UpdateView(); - Init( false ); - ConstructorsClicked( GetConstructorId() ); + if (myNbOkElements) { + QStringList aListElementsId = QStringList::split(" ", myElementsId, false); + + SMESH::long_array_var anElementsId = new SMESH::long_array; + + anElementsId->length(aListElementsId.count()); + for (int i = 0; i < aListElementsId.count(); i++) + anElementsId[i] = aListElementsId[i].toInt(); + + SMESH::DirStruct aVector; + if (GetConstructorId() == 0) { + aVector.PS.x = SpinBox2_1->GetValue() - SpinBox1_1->GetValue(); + aVector.PS.y = SpinBox2_2->GetValue() - SpinBox1_2->GetValue(); + aVector.PS.z = SpinBox2_3->GetValue() - SpinBox1_3->GetValue(); + } else if (GetConstructorId() == 1) { + aVector.PS.x = SpinBox1_1->GetValue(); + aVector.PS.y = SpinBox1_2->GetValue(); + aVector.PS.z = SpinBox1_3->GetValue(); } + + bool toCreateCopy = CheckBoxCopy->isChecked(); + + try { + SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor(); + QApplication::setOverrideCursor(Qt::waitCursor); + aMeshEditor->Translate(anElementsId.inout(), aVector, toCreateCopy); + QApplication::restoreOverrideCursor(); + } catch (...) { + } + + mySelectionMgr->clearSelected(); + SMESH::UpdateView(); + Init(false); + ConstructorsClicked(GetConstructorId()); + } } //================================================================================= @@ -459,73 +460,87 @@ void SMESHGUI_TranslationDlg::ClickOnApply() //================================================================================= void SMESHGUI_TranslationDlg::ClickOnOk() { - ClickOnApply() ; - ClickOnCancel() ; + ClickOnApply(); + ClickOnCancel(); } - //================================================================================= // function : ClickOnCancel() // purpose : //================================================================================= void SMESHGUI_TranslationDlg::ClickOnCancel() { - mySelection->ClearFilters(); - mySelection->ClearIObjects(); + disconnect(mySelectionMgr, 0, this, 0); + mySelectionMgr->clearFilters(); + mySelectionMgr->clearSelected(); SMESH::SetPointRepresentation(false); - QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); - disconnect( mySelection, 0, this, 0 ); - mySMESHGUI->ResetState() ; - reject() ; + myViewWindow->SetSelectionMode( ActorSelection ); + mySMESHGUI->ResetState(); + reject(); } //======================================================================= -//function : onTextChange -//purpose : +// function : onTextChange() +// purpose : //======================================================================= - -void SMESHGUI_TranslationDlg::onTextChange(const QString& theNewText) +void SMESHGUI_TranslationDlg::onTextChange (const QString& theNewText) { QLineEdit* send = (QLineEdit*)sender(); - if ( myBusy ) return; + if (myBusy) return; myBusy = true; - + if (send == LineEditElements) myNbOkElements = 0; - - buttonOk->setEnabled( false ); - buttonApply->setEnabled( false ); - + + buttonOk->setEnabled(false); + buttonApply->setEnabled(false); + // hilight entered elements SMDS_Mesh* aMesh = 0; - if ( myActor ) + if (myActor) aMesh = myActor->GetObject()->GetMesh(); - - if ( aMesh ) { - mySelection->ClearIObjects(); - mySelection->AddIObject( myActor->getIO() ); - - QStringList aListId = QStringList::split( " ", theNewText, false); - + + if (aMesh) { + //mySelectionMgr->clearSelected(); + //mySelectionMgr->AddIObject(myActor->getIO()); + SALOME_ListIO aList; + aList.Append(myActor->getIO()); + mySelectionMgr->setSelectedObjects(aList, false); + + TColStd_IndexedMapOfInteger selectedIndices; + TColStd_MapOfInteger newIndices; + mySelector->GetIndex( myActor->getIO(), selectedIndices ); + + QStringList aListId = QStringList::split(" ", theNewText, false); + if (send == LineEditElements) { - for ( int i = 0; i < aListId.count(); i++ ) { - const SMDS_MeshElement * e = aMesh->FindElement( aListId[ i ].toInt() ); - if ( e ) { - if ( !mySelection->IsIndexSelected( myActor->getIO(), e->GetID() )) - mySelection->AddOrRemoveIndex (myActor->getIO(), e->GetID(), true); + for (int i = 0; i < aListId.count(); i++) { + const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt()); + if (e) { + //if (!mySelectionMgr->IsIndexSelected(myActor->getIO(), e->GetID())) { + if (selectedIndices.Add(e->GetID())) { + //mySelectionMgr->AddOrRemoveIndex (myActor->getIO(), e->GetID(), true); + newIndices.Add(e->GetID()); + } myNbOkElements++; } } + + if (newIndices.Extent() > 0){ + mySelector->AddOrRemoveIndex( myActor->getIO(), newIndices, true ); + myViewWindow->highlight( myActor->getIO(), true, true ); + } + myElementsId = theNewText; } } - - if ( myNbOkElements ) { - buttonOk->setEnabled( true ); - buttonApply->setEnabled( true ); + + if (myNbOkElements) { + buttonOk->setEnabled(true); + buttonApply->setEnabled(true); } - + myBusy = false; } @@ -535,151 +550,138 @@ void SMESHGUI_TranslationDlg::onTextChange(const QString& theNewText) //================================================================================= void SMESHGUI_TranslationDlg::SelectionIntoArgument() { - if ( myBusy ) return; - + if (myBusy) return; + // clear myActor = 0; QString aString = ""; myBusy = true; - if (myEditCurrentArgument == (QWidget*)LineEditElements) - { - LineEditElements->setText( aString ); - myNbOkElements = 0; - buttonOk->setEnabled( false ); - buttonApply->setEnabled( false ); - } + if (myEditCurrentArgument == (QWidget*)LineEditElements) { + LineEditElements->setText(aString); + myNbOkElements = 0; + buttonOk->setEnabled(false); + buttonApply->setEnabled(false); + } myBusy = false; - - if ( !GroupButtons->isEnabled() ) // inactive + + if (!GroupButtons->isEnabled()) // inactive return; - + // get selected mesh - - int nbSel = mySelection->IObjectCount(); - if(nbSel != 1) + SALOME_ListIO aList; + mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type()); + + int nbSel = aList.Extent(); + if (nbSel != 1) return; - - Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject(); + + Handle(SALOME_InteractiveObject) IO = aList.First(); myMesh = SMESH::GetMeshByIO(IO); - if(myMesh->_is_nil()) + if (myMesh->_is_nil()) return; - + myActor = SMESH::FindActorByObject(myMesh); if (!myActor) myActor = SMESH::FindActorByEntry(IO->getEntry()); if (!myActor) return; - + int aNbUnits = 0; - - if (myEditCurrentArgument == (QWidget*)LineEditElements) - { - myElementsId = ""; - - if (CheckBoxMesh->isChecked()) - { - SMESH::GetNameOfSelectedIObjects(mySelection, aString); - - if(!SMESH::IObjectToInterface(IO)->_is_nil()) //MESH - { - // get IDs from mesh - SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh(); - if (!aSMDSMesh) - return; - - for (int i = aSMDSMesh->MinElementID(); i <= aSMDSMesh->MaxElementID(); i++ ) - { - const SMDS_MeshElement * e = aSMDSMesh->FindElement( i ); - if ( e ) { - myElementsId += QString(" %1").arg(i); - aNbUnits++; - } - } - } - else if (!SMESH::IObjectToInterface(IO)->_is_nil()) //SUBMESH - { - // get submesh - SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface(IO) ; - - // get IDs from submesh - SMESH::long_array_var anElementsIds = new SMESH::long_array; - anElementsIds = aSubMesh->GetElementsId(); - for ( int i = 0; i < anElementsIds->length(); i++ ) - myElementsId += QString(" %1").arg(anElementsIds[i]); - aNbUnits = anElementsIds->length(); - } - else // GROUP - { - // get smesh group - SMESH::SMESH_GroupBase_var aGroup = - SMESH::IObjectToInterface(IO); - if (aGroup->_is_nil()) - return; - - // get IDs from smesh group - SMESH::long_array_var anElementsIds = new SMESH::long_array; - anElementsIds = aGroup->GetListOfID(); - for ( int i = 0; i < anElementsIds->length(); i++ ) - myElementsId += QString(" %1").arg(anElementsIds[i]); - aNbUnits = anElementsIds->length(); - } - } - else - { - aNbUnits = SMESH::GetNameOfSelectedElements(mySelection, aString) ; - myElementsId = aString; - } - - if(aNbUnits < 1) - return ; - - myNbOkElements = true; + + if (myEditCurrentArgument == (QWidget*)LineEditElements) { + myElementsId = ""; + + if (CheckBoxMesh->isChecked()) { + SMESH::GetNameOfSelectedIObjects( mySelectionMgr, aString ); + + if (!SMESH::IObjectToInterface(IO)->_is_nil()) { //MESH + // get IDs from mesh + SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh(); + if (!aSMDSMesh) + return; + + for (int i = aSMDSMesh->MinElementID(); i <= aSMDSMesh->MaxElementID(); i++) { + const SMDS_MeshElement * e = aSMDSMesh->FindElement(i); + if (e) { + myElementsId += QString(" %1").arg(i); + aNbUnits++; + } + } + } else if (!SMESH::IObjectToInterface(IO)->_is_nil()) { //SUBMESH + // get submesh + SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface(IO); + + // get IDs from submesh + SMESH::long_array_var anElementsIds = new SMESH::long_array; + anElementsIds = aSubMesh->GetElementsId(); + for (int i = 0; i < anElementsIds->length(); i++) { + myElementsId += QString(" %1").arg(anElementsIds[i]); + } + aNbUnits = anElementsIds->length(); + } else { // GROUP + // get smesh group + SMESH::SMESH_GroupBase_var aGroup = + SMESH::IObjectToInterface(IO); + if (aGroup->_is_nil()) + return; + + // get IDs from smesh group + SMESH::long_array_var anElementsIds = new SMESH::long_array; + anElementsIds = aGroup->GetListOfID(); + for (int i = 0; i < anElementsIds->length(); i++) { + myElementsId += QString(" %1").arg(anElementsIds[i]); + } + aNbUnits = anElementsIds->length(); + } + } else { + aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, myActor->getIO(), aString); + myElementsId = aString; } - else { - aNbUnits = SMESH::GetNameOfSelectedNodes(mySelection, aString); - if(aNbUnits != 1) + + if (aNbUnits < 1) return; - + + myNbOkElements = true; + } else { + aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, myActor->getIO(), aString); + if (aNbUnits != 1) + return; + SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh(); if (!aMesh) return; - - const SMDS_MeshNode * n = aMesh->FindNode( aString.toInt() ); - if ( !n ) + + const SMDS_MeshNode * n = aMesh->FindNode(aString.toInt()); + if (!n) return; - + double x = n->X(); double y = n->Y(); double z = n->Z(); - - if (myEditCurrentArgument == (QWidget*)SpinBox1_1) - { - SpinBox1_1->SetValue(x); - SpinBox1_2->SetValue(y); - SpinBox2_3->SetValue(z); - } - else if (myEditCurrentArgument == (QWidget*)SpinBox2_1) - { - SpinBox2_1->SetValue(x); - SpinBox2_2->SetValue(y); - SpinBox2_3->SetValue(z); - } + + if (myEditCurrentArgument == (QWidget*)SpinBox1_1) { + SpinBox1_1->SetValue(x); + SpinBox1_2->SetValue(y); + SpinBox2_3->SetValue(z); + } else if (myEditCurrentArgument == (QWidget*)SpinBox2_1) { + SpinBox2_1->SetValue(x); + SpinBox2_2->SetValue(y); + SpinBox2_3->SetValue(z); + } } - + myBusy = true; if (myEditCurrentArgument == (QWidget*)LineEditElements) - LineEditElements->setText( aString ); + LineEditElements->setText(aString); myBusy = false; - - // OK - if(myNbOkElements) - { - buttonOk->setEnabled( true ); - buttonApply->setEnabled( true ); - } -} + // OK + if (myNbOkElements) { + buttonOk->setEnabled(true); + buttonApply->setEnabled(true); + } +} //================================================================================= // function : SetEditCurrentArgument() @@ -688,38 +690,36 @@ void SMESHGUI_TranslationDlg::SelectionIntoArgument() void SMESHGUI_TranslationDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); - - disconnect( mySelection, 0, this, 0 ); - mySelection->ClearIObjects(); - mySelection->ClearFilters(); - - if(send == SelectElementsButton) { + + disconnect(mySelectionMgr, 0, this, 0); + mySelectionMgr->clearSelected(); + mySelectionMgr->clearFilters(); + + if (send == SelectElementsButton) { myEditCurrentArgument = (QWidget*)LineEditElements; SMESH::SetPointRepresentation(false); - if (CheckBoxMesh->isChecked()) - { - QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); - mySelection->AddFilter(myMeshOrSubMeshOrGroupFilter); - } - else - QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true ); + if (CheckBoxMesh->isChecked()) { + myViewWindow->SetSelectionMode( ActorSelection ); + mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter); + } else { + + myViewWindow->SetSelectionMode( CellSelection ); + } + } else if (send == SelectButton1) { + myEditCurrentArgument = (QWidget*)SpinBox1_1; + SMESH::SetPointRepresentation(true); + + myViewWindow->SetSelectionMode( NodeSelection ); + } else if (send == SelectButton2) { + myEditCurrentArgument = (QWidget*)SpinBox2_1; + SMESH::SetPointRepresentation(true); + + myViewWindow->SetSelectionMode( NodeSelection ); } - else if (send == SelectButton1) - { - myEditCurrentArgument = (QWidget*)SpinBox1_1; - SMESH::SetPointRepresentation(true); - QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true ); - } - else if (send == SelectButton2) - { - myEditCurrentArgument = (QWidget*)SpinBox2_1; - SMESH::SetPointRepresentation(true); - QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true ); - } - + myEditCurrentArgument->setFocus(); - connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); - SelectionIntoArgument() ; + connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + SelectionIntoArgument(); } //================================================================================= @@ -728,16 +728,15 @@ void SMESHGUI_TranslationDlg::SetEditCurrentArgument() //================================================================================= void SMESHGUI_TranslationDlg::DeactivateActiveDialog() { - if ( GroupConstructors->isEnabled() ) { - GroupConstructors->setEnabled(false) ; - GroupArguments->setEnabled(false) ; - GroupButtons->setEnabled(false) ; - mySMESHGUI->ResetState() ; - mySMESHGUI->SetActiveDialogBox(0) ; + if (GroupConstructors->isEnabled()) { + GroupConstructors->setEnabled(false); + GroupArguments->setEnabled(false); + GroupButtons->setEnabled(false); + mySMESHGUI->ResetState(); + mySMESHGUI->SetActiveDialogBox(0); } } - //================================================================================= // function : ActivateThisDialog() // purpose : @@ -745,97 +744,87 @@ void SMESHGUI_TranslationDlg::DeactivateActiveDialog() void SMESHGUI_TranslationDlg::ActivateThisDialog() { /* Emit a signal to deactivate the active dialog */ - mySMESHGUI->EmitSignalDeactivateDialog() ; - GroupConstructors->setEnabled(true) ; - GroupArguments->setEnabled(true) ; - GroupButtons->setEnabled(true) ; - - mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; + mySMESHGUI->EmitSignalDeactivateDialog(); + GroupConstructors->setEnabled(true); + GroupArguments->setEnabled(true); + GroupButtons->setEnabled(true); + + mySMESHGUI->SetActiveDialogBox((QDialog*)this); + + myViewWindow->SetSelectionMode( CellSelection ); - QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true ); SelectionIntoArgument(); } - //================================================================================= // function : enterEvent() // purpose : //================================================================================= -void SMESHGUI_TranslationDlg::enterEvent(QEvent* e) +void SMESHGUI_TranslationDlg::enterEvent (QEvent*) { - if ( GroupConstructors->isEnabled() ) - return ; - ActivateThisDialog() ; + if (!GroupConstructors->isEnabled()) + ActivateThisDialog(); } - //================================================================================= // function : closeEvent() // purpose : //================================================================================= -void SMESHGUI_TranslationDlg::closeEvent( QCloseEvent* e ) +void SMESHGUI_TranslationDlg::closeEvent (QCloseEvent*) { /* same than click on cancel button */ - this->ClickOnCancel() ; + this->ClickOnCancel(); } - //======================================================================= //function : hideEvent //purpose : caused by ESC key //======================================================================= - -void SMESHGUI_TranslationDlg::hideEvent ( QHideEvent * e ) +void SMESHGUI_TranslationDlg::hideEvent (QHideEvent*) { - if ( !isMinimized() ) + if (!isMinimized()) ClickOnCancel(); } - //======================================================================= //function : onSelectMesh //purpose : //======================================================================= -void SMESHGUI_TranslationDlg::onSelectMesh ( bool toSelectMesh ) +void SMESHGUI_TranslationDlg::onSelectMesh (bool toSelectMesh) { if (toSelectMesh) - TextLabelElements->setText( tr( "SMESH_NAME" ) ); + TextLabelElements->setText(tr("SMESH_NAME")); else - TextLabelElements->setText( tr( "SMESH_ID_ELEMENTS" ) ); - - if (myEditCurrentArgument != LineEditElements) - { - LineEditElements->clear(); - return; - } - - mySelection->ClearFilters() ; + TextLabelElements->setText(tr("SMESH_ID_ELEMENTS")); + + if (myEditCurrentArgument != LineEditElements) { + LineEditElements->clear(); + return; + } + + mySelectionMgr->clearFilters(); SMESH::SetPointRepresentation(false); - - if (toSelectMesh) - { - QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); - mySelection->AddFilter(myMeshOrSubMeshOrGroupFilter); - LineEditElements->setReadOnly(true); - } - else - { - QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true ); - LineEditElements->setReadOnly(false); - onTextChange(LineEditElements->text()); - } - + + if (toSelectMesh) { + myViewWindow->SetSelectionMode( ActorSelection ); + mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter); + LineEditElements->setReadOnly(true); + } else { + myViewWindow->SetSelectionMode( CellSelection ); + LineEditElements->setReadOnly(false); + onTextChange(LineEditElements->text()); + } + SelectionIntoArgument(); } - //================================================================================= // function : GetConstructorId() -// purpose : +// purpose : //================================================================================= int SMESHGUI_TranslationDlg::GetConstructorId() -{ - if ( GroupConstructors != NULL && GroupConstructors->selected() != NULL ) - return GroupConstructors->id( GroupConstructors->selected() ); +{ + if (GroupConstructors != NULL && GroupConstructors->selected() != NULL) + return GroupConstructors->id(GroupConstructors->selected()); return -1; } diff --git a/src/SMESHGUI/SMESHGUI_TranslationDlg.h b/src/SMESHGUI/SMESHGUI_TranslationDlg.h index b53e8948f..da9c93e7d 100644 --- a/src/SMESHGUI/SMESHGUI_TranslationDlg.h +++ b/src/SMESHGUI/SMESHGUI_TranslationDlg.h @@ -29,7 +29,8 @@ #ifndef DIALOGBOX_TRANSLATION_H #define DIALOGBOX_TRANSLATION_H -#include "SALOME_Selection.h" +#include "SalomeApp_SelectionMgr.h" + #include "SMESH_LogicalFilter.hxx" // QT Includes @@ -46,6 +47,8 @@ class QCheckBox; class SMESHGUI; class SMESHGUI_SpinBox; class SMESH_Actor; +class SVTK_ViewWindow; +class SVTK_Selector; // IDL Headers #include @@ -61,28 +64,33 @@ class SMESHGUI_TranslationDlg : public QDialog Q_OBJECT public: - SMESHGUI_TranslationDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); + SMESHGUI_TranslationDlg( SMESHGUI*, + const char* name = 0, + bool modal = FALSE, + WFlags fl = 0); ~SMESHGUI_TranslationDlg(); private: - - void Init( bool ResetControls = true ) ; - void closeEvent( QCloseEvent* e ) ; - void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */ - void hideEvent ( QHideEvent * ); /* ESC key */ + void Init (bool ResetControls = true); + void closeEvent (QCloseEvent*); + void enterEvent (QEvent*); /* mouse enter the QWidget */ + void hideEvent (QHideEvent*); /* ESC key */ int GetConstructorId(); - SMESHGUI* mySMESHGUI ; /* Current SMESHGUI object */ - SALOME_Selection* mySelection ; /* User shape selection */ + SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */ + SalomeApp_SelectionMgr* mySelectionMgr; /* User shape selection */ QString myElementsId; - int myNbOkElements ; /* to check when elements are defined */ - + int myNbOkElements; /* to check when elements are defined */ + + SVTK_ViewWindow* myViewWindow; + SVTK_Selector* mySelector; + QWidget* myEditCurrentArgument; - + bool myBusy; SMESH::SMESH_Mesh_var myMesh; SMESH_Actor* myActor; - Handle(SMESH_LogicalFilter) myMeshOrSubMeshOrGroupFilter; + SMESH_LogicalFilter* myMeshOrSubMeshOrGroupFilter; QButtonGroup* GroupConstructors; QRadioButton* RadioButton1; diff --git a/src/SMESHGUI/SMESHGUI_TransparencyDlg.cxx b/src/SMESHGUI/SMESHGUI_TransparencyDlg.cxx index c7fc33a56..b121d1113 100644 --- a/src/SMESHGUI/SMESHGUI_TransparencyDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_TransparencyDlg.cxx @@ -1,23 +1,23 @@ // SMESH SMESHGUI : GUI for SMESH component // // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org // // // @@ -31,6 +31,19 @@ #include "SMESHGUI.h" #include "SMESHGUI_VTKUtils.h" +#include "SMESH_Actor.h" + +#include "SUIT_OverrideCursor.h" + +#include "SALOME_ListIO.hxx" +#include "SALOME_ListIteratorOfListIO.hxx" +#include "SALOME_InteractiveObject.hxx" + +#include "SalomeApp_Study.h" +#include "SalomeApp_SelectionMgr.h" + +#include "SVTK_ViewWindow.h" + // QT Includes #include #include @@ -38,114 +51,106 @@ #include #include -#include "VTKViewer_ViewFrame.h" -#include "QAD_RightFrame.h" -#include "QAD_WaitCursor.h" -#include "SALOME_ListIteratorOfListIO.hxx" -#include "SMESH_Actor.h" -#include "SALOME_Selection.h" -#include "SALOME_InteractiveObject.hxx" - using namespace std; //================================================================================= // class : SMESHGUI_TransparencyDlg() -// purpose : +// purpose : // //================================================================================= -SMESHGUI_TransparencyDlg::SMESHGUI_TransparencyDlg( QWidget* parent, +SMESHGUI_TransparencyDlg::SMESHGUI_TransparencyDlg (QWidget* parent, const char* name, bool modal, - WFlags fl ) - : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose ) + WFlags fl) + : QDialog(parent, name, modal, WStyle_Customize | WStyle_NormalBorder | + WStyle_Title | WStyle_SysMenu | WDestructiveClose) { - if ( !name ) - setName( "SMESHGUI_TransparencyDlg" ); - setCaption( tr( "SMESH_TRANSPARENCY_TITLE" ) ); - setSizeGripEnabled( TRUE ); - QGridLayout* SMESHGUI_TransparencyDlgLayout = new QGridLayout( this ); - SMESHGUI_TransparencyDlgLayout->setSpacing( 6 ); - SMESHGUI_TransparencyDlgLayout->setMargin( 11 ); + if (!name) + setName("SMESHGUI_TransparencyDlg"); + setCaption(tr("SMESH_TRANSPARENCY_TITLE" )); + setSizeGripEnabled(TRUE); + QGridLayout* SMESHGUI_TransparencyDlgLayout = new QGridLayout(this); + SMESHGUI_TransparencyDlgLayout->setSpacing(6); + SMESHGUI_TransparencyDlgLayout->setMargin(11); /*************************************************************************/ - QGroupBox* GroupC1 = new QGroupBox( this, "GroupC1" ); - GroupC1->setColumnLayout(0, Qt::Vertical ); - GroupC1->layout()->setSpacing( 0 ); - GroupC1->layout()->setMargin( 0 ); - QGridLayout* GroupC1Layout = new QGridLayout( GroupC1->layout() ); - GroupC1Layout->setAlignment( Qt::AlignTop ); - GroupC1Layout->setSpacing( 6 ); - GroupC1Layout->setMargin( 11 ); - - TextLabelTransparent = new QLabel( GroupC1, "TextLabelTransparent" ); - TextLabelTransparent->setText( tr( "SMESH_TRANSPARENCY_TRANSPARENT" ) ); - TextLabelTransparent->setAlignment( AlignLeft ); - GroupC1Layout->addWidget( TextLabelTransparent, 0, 0 ); - - ValueLab = new QLabel( GroupC1, "ValueLab" ); - ValueLab->setAlignment( AlignCenter ); - ValueLab->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - QFont fnt = ValueLab->font(); fnt.setBold( true ); ValueLab->setFont( fnt ); - GroupC1Layout->addWidget( ValueLab, 0, 1 ); + QGroupBox* GroupC1 = new QGroupBox(this, "GroupC1"); + GroupC1->setColumnLayout(0, Qt::Vertical); + GroupC1->layout()->setSpacing(0); + GroupC1->layout()->setMargin(0); + QGridLayout* GroupC1Layout = new QGridLayout(GroupC1->layout()); + GroupC1Layout->setAlignment(Qt::AlignTop); + GroupC1Layout->setSpacing(6); + GroupC1Layout->setMargin(11); - TextLabelOpaque = new QLabel( GroupC1, "TextLabelOpaque" ); - TextLabelOpaque->setText( tr( "SMESH_TRANSPARENCY_OPAQUE" ) ); - TextLabelOpaque->setAlignment( AlignRight ); - GroupC1Layout->addWidget( TextLabelOpaque, 0, 2 ); - - Slider1 = new QSlider( 0, 10, 1, 5, Horizontal, GroupC1, "Slider1" ); - Slider1->setFocusPolicy( QWidget::NoFocus ); - Slider1->setMinimumSize( 300, 0 ); - Slider1->setTickmarks( QSlider::Above ); - Slider1->setTickInterval( 10 ); - Slider1->setTracking( true ); - Slider1->setMinValue( 0 ) ; - Slider1->setMaxValue( 100 ); - Slider1->setLineStep( 1 ); - Slider1->setPageStep( 10 ); - GroupC1Layout->addMultiCellWidget( Slider1, 1, 1, 0, 2 ); + TextLabelTransparent = new QLabel(GroupC1, "TextLabelTransparent"); + TextLabelTransparent->setText(tr("SMESH_TRANSPARENCY_TRANSPARENT" )); + TextLabelTransparent->setAlignment(AlignLeft); + GroupC1Layout->addWidget(TextLabelTransparent, 0, 0); + + ValueLab = new QLabel(GroupC1, "ValueLab"); + ValueLab->setAlignment(AlignCenter); + ValueLab->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); + QFont fnt = ValueLab->font(); fnt.setBold(true); ValueLab->setFont(fnt); + GroupC1Layout->addWidget(ValueLab, 0, 1); + + TextLabelOpaque = new QLabel(GroupC1, "TextLabelOpaque"); + TextLabelOpaque->setText(tr("SMESH_TRANSPARENCY_OPAQUE" )); + TextLabelOpaque->setAlignment(AlignRight); + GroupC1Layout->addWidget(TextLabelOpaque, 0, 2); + + Slider1 = new QSlider(0, 10, 1, 5, Horizontal, GroupC1, "Slider1"); + Slider1->setFocusPolicy(QWidget::NoFocus); + Slider1->setMinimumSize(300, 0); + Slider1->setTickmarks(QSlider::Above); + Slider1->setTickInterval(10); + Slider1->setTracking(true); + Slider1->setMinValue(0); + Slider1->setMaxValue(100); + Slider1->setLineStep(1); + Slider1->setPageStep(10); + GroupC1Layout->addMultiCellWidget(Slider1, 1, 1, 0, 2); /*************************************************************************/ - QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" ); - GroupButtons->setColumnLayout(0, Qt::Vertical ); - GroupButtons->layout()->setSpacing( 0 ); - GroupButtons->layout()->setMargin( 0 ); - QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); - GroupButtonsLayout->setAlignment( Qt::AlignTop ); - GroupButtonsLayout->setSpacing( 6 ); - GroupButtonsLayout->setMargin( 11 ); + QGroupBox* GroupButtons = new QGroupBox(this, "GroupButtons"); + GroupButtons->setColumnLayout(0, Qt::Vertical); + GroupButtons->layout()->setSpacing(0); + GroupButtons->layout()->setMargin(0); + QGridLayout* GroupButtonsLayout = new QGridLayout(GroupButtons->layout()); + GroupButtonsLayout->setAlignment(Qt::AlignTop); + GroupButtonsLayout->setSpacing(6); + GroupButtonsLayout->setMargin(11); - buttonOk = new QPushButton( GroupButtons, "buttonOk" ); - buttonOk->setText( tr( "SMESH_BUT_CLOSE" ) ); - buttonOk->setAutoDefault( TRUE ); - buttonOk->setDefault( TRUE ); - GroupButtonsLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, 0 ); - GroupButtonsLayout->addWidget( buttonOk, 0, 1 ); - GroupButtonsLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, 2 ); + buttonOk = new QPushButton(GroupButtons, "buttonOk"); + buttonOk->setText(tr("SMESH_BUT_CLOSE")); + buttonOk->setAutoDefault(TRUE); + buttonOk->setDefault(TRUE); + GroupButtonsLayout->addItem(new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, 0); + GroupButtonsLayout->addWidget(buttonOk, 0, 1); + GroupButtonsLayout->addItem(new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, 2); - SMESHGUI_TransparencyDlgLayout->addWidget( GroupC1, 0, 0 ); - SMESHGUI_TransparencyDlgLayout->addWidget( GroupButtons, 1, 0 ); - - mySelection = SALOME_Selection::Selection( SMESHGUI::GetSMESHGUI()->GetActiveStudy()->getSelection()); + SMESHGUI_TransparencyDlgLayout->addWidget(GroupC1, 0, 0); + SMESHGUI_TransparencyDlgLayout->addWidget(GroupButtons, 1, 0); + + mySelectionMgr = SMESHGUI::selectionMgr(); // Initial state - this->onSelectionChanged() ; - + this->onSelectionChanged(); + // signals and slots connections : after ValueHasChanged() - connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); - connect( Slider1, SIGNAL( valueChanged(int) ), this, SLOT( SetTransparency() ) ); - connect( Slider1, SIGNAL( sliderMoved(int) ), this, SLOT( ValueHasChanged() ) ); - connect( SMESHGUI::GetSMESHGUI(), SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnOk() ) ) ; - connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionChanged() ) ); - + connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(Slider1, SIGNAL(valueChanged(int)), this, SLOT(SetTransparency())); + connect(Slider1, SIGNAL(sliderMoved(int)), this, SLOT(ValueHasChanged())); + connect(SMESHGUI::GetSMESHGUI(), SIGNAL (SignalCloseAllDialogs()), this, SLOT(ClickOnOk())); + connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(onSelectionChanged())); + /* Move widget on the botton right corner of main widget */ - int x, y ; - SMESHGUI::GetSMESHGUI()->DefineDlgPosition( this, x, y ) ; - this->move( x, y ) ; + int x, y; + SMESHGUI::GetSMESHGUI()->DefineDlgPosition(this, x, y); + this->move(x, y); this->show(); } - //================================================================================= // function : ~SMESHGUI_TransparencyDlg() // purpose : @@ -155,7 +160,6 @@ SMESHGUI_TransparencyDlg::~SMESHGUI_TransparencyDlg() // no need to delete child widgets, Qt does it all for us } - //======================================================================= // function : ClickOnOk() // purpose : @@ -165,7 +169,6 @@ void SMESHGUI_TransparencyDlg::ClickOnOk() close(); } - //================================================================================= // function : SetTransparency() // purpose : Called when value of slider change @@ -173,17 +176,21 @@ void SMESHGUI_TransparencyDlg::ClickOnOk() //================================================================================= void SMESHGUI_TransparencyDlg::SetTransparency() { - if ( SMESHGUI::GetSMESHGUI()->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { - QAD_WaitCursor wc; - float opacity = this->Slider1->value() / 100. ; - SALOME_ListIteratorOfListIO It( mySelection->StoredIObjects() ); - for( ;It.More(); It.Next() ) { + if (SVTK_ViewWindow* aVTKViewWindow = SMESH::GetCurrentVtkView()) { + SUIT_OverrideCursor wc; + float opacity = this->Slider1->value() / 100.; + + SALOME_ListIO aList; + mySelectionMgr->selectedObjects(aList); + + SALOME_ListIteratorOfListIO It (aList); + for (;It.More(); It.Next()) { Handle(SALOME_InteractiveObject) IOS = It.Value(); SMESH_Actor* anActor = SMESH::FindActorByEntry(IOS->getEntry()); - if ( anActor ) - anActor->SetOpacity( opacity ); + if (anActor) + anActor->SetOpacity(opacity); } - SMESHGUI::GetSMESHGUI()->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame()->Repaint(); + aVTKViewWindow->Repaint(); } ValueHasChanged(); } @@ -194,7 +201,7 @@ void SMESHGUI_TransparencyDlg::SetTransparency() //================================================================================= void SMESHGUI_TransparencyDlg::ValueHasChanged() { - ValueLab->setText( QString::number( this->Slider1->value() ) + "%" ); + ValueLab->setText(QString::number(this->Slider1->value()) + "%"); } //================================================================================= @@ -203,38 +210,42 @@ void SMESHGUI_TransparencyDlg::ValueHasChanged() //================================================================================= void SMESHGUI_TransparencyDlg::onSelectionChanged() { - if ( SMESHGUI::GetSMESHGUI()->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { + if (SVTK_ViewWindow* aVTKViewWindow = SMESH::GetCurrentVtkView()) { int opacity = 100; - if ( mySelection->IObjectCount() == 1 ) { - Handle(SALOME_InteractiveObject) FirstIOS = mySelection->firstIObject(); - if( !FirstIOS.IsNull() ) { - SMESH_Actor* anActor = SMESH::FindActorByEntry( FirstIOS->getEntry() ); - if ( anActor ) - opacity = int( anActor->GetOpacity() * 100. + 0.5 ); + + SALOME_ListIO aList; + mySelectionMgr->selectedObjects(aList); + + if (aList.Extent() == 1) { + Handle(SALOME_InteractiveObject) FirstIOS = aList.First(); + if (!FirstIOS.IsNull()) { + SMESH_Actor* anActor = SMESH::FindActorByEntry(FirstIOS->getEntry()); + if (anActor) + opacity = int(anActor->GetOpacity() * 100. + 0.5); } - } - else if ( mySelection->IObjectCount() > 1 ) { - SALOME_ListIteratorOfListIO It( mySelection->StoredIObjects() ); + } else if (aList.Extent() > 1) { + SALOME_ListIteratorOfListIO It (aList); int setOp = -1; - for ( ; It.More(); It.Next() ) { + for (; It.More(); It.Next()) { Handle(SALOME_InteractiveObject) IO = It.Value(); - if( !IO.IsNull() ) { - SMESH_Actor* anActor = SMESH::FindActorByEntry( IO->getEntry() ); - if ( anActor ) { - int op = int( anActor->GetOpacity() * 100. + 0.5 ); - if ( setOp < 0 ) + if (!IO.IsNull()) { + SMESH_Actor* anActor = SMESH::FindActorByEntry(IO->getEntry()); + if (anActor) { + int op = int(anActor->GetOpacity() * 100. + 0.5); + if (setOp < 0) setOp = op; - else if ( setOp != op ) { + else if (setOp != op) { setOp = 100; break; } } } } - if ( setOp >= 0 ) + if (setOp >= 0) opacity = setOp; + } else { } - Slider1->setValue( opacity ) ; + Slider1->setValue(opacity); } ValueHasChanged(); } diff --git a/src/SMESHGUI/SMESHGUI_TransparencyDlg.h b/src/SMESHGUI/SMESHGUI_TransparencyDlg.h index 2bc7767fa..211f06ee5 100644 --- a/src/SMESHGUI/SMESHGUI_TransparencyDlg.h +++ b/src/SMESHGUI/SMESHGUI_TransparencyDlg.h @@ -35,7 +35,7 @@ class QLabel; class QPushButton; class QSlider; -class SALOME_Selection; +class SalomeApp_SelectionMgr; //================================================================================= // class : SMESHGUI_TransparencyDlg @@ -55,7 +55,7 @@ public: private : - SALOME_Selection* mySelection; + SalomeApp_SelectionMgr* mySelectionMgr; QPushButton* buttonOk; QLabel* TextLabelOpaque; @@ -66,10 +66,9 @@ private : public slots: void ClickOnOk(); - void ValueHasChanged() ; + void ValueHasChanged(); void SetTransparency(); void onSelectionChanged(); }; #endif // DIALOGBOX_TRANSPARENCYDLG_H - diff --git a/src/SMESHGUI/SMESHGUI_Utils.cxx b/src/SMESHGUI/SMESHGUI_Utils.cxx index e55790515..3b4976ea6 100644 --- a/src/SMESHGUI/SMESHGUI_Utils.cxx +++ b/src/SMESHGUI/SMESHGUI_Utils.cxx @@ -1,20 +1,20 @@ // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org @@ -22,169 +22,233 @@ #include "SMESHGUI_Utils.h" -#include "QAD_Desktop.h" +#include "OB_Browser.h" + +#include "SUIT_Desktop.h" +#include "SUIT_Application.h" +#include "SUIT_Session.h" + +#include "SalomeApp_SelectionMgr.h" +#include "SalomeApp_Application.h" +#include "SalomeApp_Module.h" +#include "SalomeApp_Study.h" + +#include "SALOME_ListIO.hxx" #include "SALOMEconfig.h" #include CORBA_CLIENT_HEADER(GEOM_Gen) -#include CORBA_CLIENT_HEADER(SALOMEDS_Attributes) #include "utilities.h" -using namespace std; +//using namespace std; namespace SMESH{ - QAD_Study* GetActiveStudy(){ - if(QAD_Desktop* aDesktop = QAD_Application::getDesktop()) - return aDesktop->getActiveStudy(); - return NULL; + SUIT_Desktop* + GetDesktop(const CAM_Module* theModule) + { + return theModule->application()->desktop(); + } + + SalomeApp_SelectionMgr* + GetSelectionMgr(const SalomeApp_Module* theModule) + { + return theModule->getApp()->selectionMgr(); } - QAD_StudyFrame* GetActiveStudyFrame(){ - if(QAD_Study* aStudy = GetActiveStudy()) - return aStudy->getActiveStudyFrame(); - return NULL; + _PTR(Study) + GetCStudy(const SalomeApp_Study* theStudy) + { + return theStudy->studyDS(); } - - SALOMEDS::Study_var GetActiveStudyDocument(){ - if(QAD_Study* aStudy = GetActiveStudy()) - return aStudy->getStudyDocument(); - return SALOMEDS::Study::_nil(); - } - - - SALOMEDS::SObject_var FindSObject(CORBA::Object_ptr theObject){ - if(!CORBA::is_nil(theObject)){ - SALOMEDS::Study_var aStudy = GetActiveStudyDocument(); - CORBA::String_var anIOR = aStudy->ConvertObjectToIOR(theObject); - if(strcmp(anIOR.in(),"") != 0) - return aStudy->FindObjectIOR(anIOR); + CORBA::Object_var + DataOwnerToObject(const SalomeApp_DataOwnerPtr& theOwner) + { + CORBA::Object_var anObj; + if(theOwner){ + const Handle(SALOME_InteractiveObject)& anIO = theOwner->IO(); + if(!anIO.IsNull()){ + if(anIO->hasEntry()){ + _PTR(Study) aStudy = GetActiveStudyDocument(); + _PTR(SObject) aSObj = aStudy->FindObjectID(anIO->getEntry()); + anObj = SObjectToObject(aSObj,aStudy); + } + } } - return SALOMEDS::SObject::_nil(); + return anObj; } - void SetName(SALOMEDS::SObject_ptr theSObject, const char* theName){ - using namespace SALOMEDS; - Study_var aStudy = GetActiveStudyDocument(); - if(aStudy->GetProperties()->IsLocked()) + SUIT_Study* GetActiveStudy() + { + SUIT_Application* app = SUIT_Session::session()->activeApplication(); + if (app) + return app->activeStudy(); + else + return NULL; + } + + SUIT_ViewWindow* GetActiveWindow() + { + SalomeApp_Application* app = dynamic_cast + (SUIT_Session::session()->activeApplication()); + if (app && app->activeViewManager()) + return app->activeViewManager()->getActiveView(); + else + return NULL; + } + + _PTR(Study) GetActiveStudyDocument() + { + SalomeApp_Study* aStudy = dynamic_cast(GetActiveStudy()); + if (aStudy) + return aStudy->studyDS(); + else + return _PTR(Study)(); + } + + _PTR(SObject) FindSObject (CORBA::Object_ptr theObject) + { + SalomeApp_Application* app = dynamic_cast + (SUIT_Session::session()->activeApplication()); + if (app && !CORBA::is_nil(theObject)) { + if(_PTR(Study) aStudy = GetActiveStudyDocument()){ + CORBA::String_var anIOR = app->orb()->object_to_string(theObject); + if (strcmp(anIOR.in(), "") != 0) + return aStudy->FindObjectIOR(anIOR.in()); + } + } + return _PTR(SObject)(); + } + + void SetName (_PTR(SObject) theSObject, const char* theName) + { + _PTR(Study) aStudy = GetActiveStudyDocument(); + if (aStudy->GetProperties()->IsLocked()) return; - StudyBuilder_var aBuilder = aStudy->NewBuilder(); - GenericAttribute_var anAttr = aBuilder->FindOrCreateAttribute(theSObject,"AttributeName"); - AttributeName_var aName = AttributeName::_narrow(anAttr); - if(!aName->_is_nil()) + _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder(); + _PTR(GenericAttribute) anAttr = + aBuilder->FindOrCreateAttribute(theSObject, "AttributeName"); + _PTR(AttributeName) aName = anAttr; + if (aName) aName->SetValue(theName); } - void SetValue(SALOMEDS::SObject_ptr theSObject, const char* theValue){ - using namespace SALOMEDS; - Study_var aStudy = GetActiveStudyDocument(); - if(aStudy->GetProperties()->IsLocked()) + void SetValue (_PTR(SObject) theSObject, const char* theValue) + { + _PTR(Study) aStudy = GetActiveStudyDocument(); + if (aStudy->GetProperties()->IsLocked()) return; - StudyBuilder_var aBuilder = aStudy->NewBuilder(); - GenericAttribute_var anAttr = aBuilder->FindOrCreateAttribute(theSObject,"AttributeComment"); - AttributeComment_var aComment = AttributeComment::_narrow(anAttr); - if(!aComment->_is_nil()) + _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder(); + _PTR(GenericAttribute) anAttr = + aBuilder->FindOrCreateAttribute(theSObject, "AttributeComment"); + _PTR(AttributeComment) aComment = anAttr; + if (aComment) aComment->SetValue(theValue); } - - CORBA::Object_var SObjectToObject(SALOMEDS::SObject_ptr theSObject, - SALOMEDS::Study_ptr theStudy) + CORBA::Object_var SObjectToObject (_PTR(SObject) theSObject, + _PTR(Study) theStudy) { - if(!theSObject->_is_nil()){ - SALOMEDS::GenericAttribute_var anAttr; - if(theSObject->FindAttribute(anAttr, "AttributeIOR")){ - SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - CORBA::String_var aVal = anIOR->Value(); - return theStudy->ConvertIORToObject(aVal.in()); + SalomeApp_Application* app = dynamic_cast + (SUIT_Session::session()->activeApplication()); + if (theSObject) { + _PTR(GenericAttribute) anAttr; + if (theSObject->FindAttribute(anAttr, "AttributeIOR")) { + _PTR(AttributeIOR) anIOR = anAttr; + CORBA::String_var aVal = anIOR->Value().c_str(); + return app->orb()->string_to_object(aVal); } } return CORBA::Object::_nil(); } - - CORBA::Object_var SObjectToObject(SALOMEDS::SObject_ptr theSObject){ - SALOMEDS::Study_var aStudy = GetActiveStudyDocument(); + CORBA::Object_var SObjectToObject (_PTR(SObject) theSObject) + { + _PTR(Study) aStudy = GetActiveStudyDocument(); return SObjectToObject(theSObject,aStudy); } - - CORBA::Object_var IObjectToObject(const Handle(SALOME_InteractiveObject)& theIO){ - if(!theIO.IsNull()){ - if(theIO->hasEntry()){ - SALOMEDS::Study_var aStudy = GetActiveStudyDocument(); - SALOMEDS::SObject_var anObj = aStudy->FindObjectID(theIO->getEntry()); + CORBA::Object_var IObjectToObject (const Handle(SALOME_InteractiveObject)& theIO) + { + if (!theIO.IsNull()) { + if (theIO->hasEntry()) { + _PTR(Study) aStudy = GetActiveStudyDocument(); + _PTR(SObject) anObj = aStudy->FindObjectID(theIO->getEntry()); return SObjectToObject(anObj,aStudy); } } return CORBA::Object::_nil(); } - - CORBA::Object_var IORToObject(const char* theIOR){ - SALOMEDS::Study_var aStudy = GetActiveStudyDocument(); - return aStudy->ConvertIORToObject(theIOR); + CORBA::Object_var IORToObject (const char* theIOR) + { + SalomeApp_Application* app = dynamic_cast + (SUIT_Session::session()->activeApplication()); + return app->orb()->string_to_object(theIOR); } - - int GetNameOfSelectedIObjects(SALOME_Selection* theSel, QString& theName) + int GetNameOfSelectedIObjects(SalomeApp_SelectionMgr* theMgr, QString& theName) { - int aNbSel = theSel->IObjectCount(); + if (!theMgr) + return 0; + + SALOME_ListIO selected; + theMgr->selectedObjects(selected); + int aNbSel = selected.Extent(); if (aNbSel == 1) { - Handle(SALOME_InteractiveObject) anIObject = theSel->firstIObject(); + Handle(SALOME_InteractiveObject) anIObject = selected.First(); theName = anIObject->getName(); - }else{ + } else { theName = QObject::tr("SMESH_OBJECTS_SELECTED").arg(aNbSel); } return aNbSel; } - - SALOMEDS::SObject_var GetMeshOrSubmesh(SALOMEDS::SObject_ptr theSObject){ + _PTR(SObject) GetMeshOrSubmesh (_PTR(SObject) theSObject) + { GEOM::GEOM_Object_var aShape = SObjectToInterface(theSObject); - if(!aShape->_is_nil()){ //It s a shape + if (!aShape->_is_nil()){ //It s a shape return theSObject->GetFather(); } - SALOMEDS::SObject_var aSObject; - if(theSObject->ReferencedObject(aSObject)){ + _PTR(SObject) aSObject; + if (theSObject->ReferencedObject(aSObject)) { aSObject = theSObject->GetFather(); return aSObject->GetFather(); } return theSObject->GetFather(); } - - void ModifiedMesh(SALOMEDS::SObject_ptr theSObject, bool theIsRight) + void ModifiedMesh (_PTR(SObject) theSObject, bool theIsRight) { - SALOMEDS::Study_var aStudy = GetActiveStudyDocument(); - if(aStudy->GetProperties()->IsLocked()) - return ; + _PTR(Study) aStudy = GetActiveStudyDocument(); + if (aStudy->GetProperties()->IsLocked()) + return; - SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder(); - SALOMEDS::GenericAttribute_var anAttr = + _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder(); + _PTR(GenericAttribute) anAttr = aBuilder->FindOrCreateAttribute(theSObject,"AttributePixMap"); - SALOMEDS::AttributePixMap_var aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr); - if(theIsRight){ + _PTR(AttributePixMap) aPixmap = anAttr; + if (theIsRight) { aPixmap->SetPixMap("ICON_SMESH_TREE_MESH"); - }else{ + } else { aPixmap->SetPixMap("ICON_SMESH_TREE_MESH_WARN"); } - - SALOMEDS::ChildIterator_var anIter = aStudy->NewChildIterator(theSObject); + + _PTR(ChildIterator) anIter = aStudy->NewChildIterator(theSObject); for (int i = 1; anIter->More(); anIter->Next(), i++) { - SALOMEDS::SObject_var aSObj = anIter->Value(); - if(i >= 4){ - SALOMEDS::ChildIterator_var anIter1 = aStudy->NewChildIterator(aSObj); - for(; anIter1->More(); anIter1->Next()){ - SALOMEDS::SObject_var aSObj1 = anIter1->Value(); - anAttr = aBuilder->FindOrCreateAttribute(aSObj1,"AttributePixMap"); - aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr); - if(theIsRight){ + _PTR(SObject) aSObj = anIter->Value(); + if (i >= 4) { + _PTR(ChildIterator) anIter1 = aStudy->NewChildIterator(aSObj); + for (; anIter1->More(); anIter1->Next()) { + _PTR(SObject) aSObj1 = anIter1->Value(); + anAttr = aBuilder->FindOrCreateAttribute(aSObj1, "AttributePixMap"); + aPixmap = anAttr; + if (theIsRight) { aPixmap->SetPixMap("ICON_SMESH_TREE_MESH"); - }else{ + } else { aPixmap->SetPixMap("ICON_SMESH_TREE_MESH_WARN"); } } @@ -192,5 +256,12 @@ namespace SMESH{ } } - +// void UpdateObjBrowser (bool) +// { +// //SMESHGUI::activeStudy()->updateObjBrowser(true); +// //SalomeApp_Application* anApp = dynamic_cast +// // (SUIT_Session::session()->activeApplication()); +// //if (anApp) anApp->objectBrowser()->updateTree(); +// SMESHGUI::GetSMESHGUI()->updateObjBrowser(); +// } } diff --git a/src/SMESHGUI/SMESHGUI_Utils.h b/src/SMESHGUI/SMESHGUI_Utils.h index ab468bf32..15009ab95 100644 --- a/src/SMESHGUI/SMESHGUI_Utils.h +++ b/src/SMESHGUI/SMESHGUI_Utils.h @@ -1,67 +1,96 @@ // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org #ifndef SMESHGUI_Utils_HeaderFile #define SMESHGUI_Utils_HeaderFile +#include + +#include "SALOMEDSClient_definitions.hxx" #include "SALOME_InteractiveObject.hxx" +#include "SalomeApp_DataOwner.h" class QString; -class QAD_Study; -class QAD_StudyFrame; -class SALOME_Selection; +class SUIT_ViewWindow; +class SUIT_Desktop; +class SUIT_Study; -#include "SALOMEconfig.h" -#include CORBA_CLIENT_HEADER(SALOMEDS) +class CAM_Module; +class SALOMEDSClient_Study; +class SALOMEDSClient_SObject; -namespace SMESH{ +class SalomeApp_Study; +class SalomeApp_Module; +class SalomeApp_SelectionMgr; - QAD_Study* GetActiveStudy(); +namespace SMESH { - QAD_StudyFrame* GetActiveStudyFrame(); + SUIT_Desktop* + GetDesktop(const CAM_Module* theModule); - SALOMEDS::Study_var GetActiveStudyDocument(); + SalomeApp_SelectionMgr* + GetSelectionMgr(const SalomeApp_Module* theModule); - SALOMEDS::SObject_var FindSObject(CORBA::Object_ptr theObject); + SalomeApp_Study* + GetAppStudy(const CAM_Module* theModule); + _PTR(Study) + GetCStudy(const SalomeApp_Study* theStudy); - void SetName(SALOMEDS::SObject_ptr theSObject, const char* theName); - void SetValue(SALOMEDS::SObject_ptr theSObject, const char* theValue); - - - CORBA::Object_var SObjectToObject(SALOMEDS::SObject_ptr theSObject, - SALOMEDS::Study_ptr theStudy); - - CORBA::Object_var SObjectToObject(SALOMEDS::SObject_ptr theSObject); - + CORBA::Object_var DataOwnerToObject(const SalomeApp_DataOwnerPtr& theOwner); template typename TInterface::_var_type - SObjectToInterface(SALOMEDS::SObject_ptr theSObject) + DataOwnerToInterface(const SalomeApp_DataOwnerPtr& theDataOwner) + { + CORBA::Object_var anObj = DataOwnerToObject(theDataOwner); + if(!CORBA::is_nil(anObj)) + return TInterface::_narrow(anObj); + return TInterface::_nil(); + } + + + SUIT_Study* GetActiveStudy(); + + SUIT_ViewWindow* GetActiveWindow(); + + _PTR(Study) GetActiveStudyDocument(); + + _PTR(SObject) FindSObject(CORBA::Object_ptr theObject); + + void SetName (_PTR(SObject) theSObject, const char* theName); + void SetValue (_PTR(SObject) theSObject, const char* theValue); + + CORBA::Object_var SObjectToObject (_PTR(SObject) theSObject, + _PTR(Study) theStudy); + + CORBA::Object_var SObjectToObject(_PTR(SObject) theSObject); + + template typename TInterface::_var_type + SObjectToInterface(_PTR(SObject) theSObject) { CORBA::Object_var anObj = SObjectToObject(theSObject); if(!CORBA::is_nil(anObj)) return TInterface::_narrow(anObj); return TInterface::_nil(); } - CORBA::Object_var IObjectToObject(const Handle(SALOME_InteractiveObject)& theIO); @@ -73,7 +102,6 @@ namespace SMESH{ return TInterface::_narrow(anObj); return TInterface::_nil(); } - CORBA::Object_var IORToObject(const char* theIOR); @@ -85,15 +113,14 @@ namespace SMESH{ return TInterface::_narrow(anObj); return TInterface::_nil(); } - - int GetNameOfSelectedIObjects(SALOME_Selection* theSel, QString& theName); + int GetNameOfSelectedIObjects (SalomeApp_SelectionMgr*, QString& theName); - SALOMEDS::SObject_var GetMeshOrSubmesh(SALOMEDS::SObject_ptr theSObject); + _PTR(SObject) GetMeshOrSubmesh (_PTR(SObject) theSObject); - void ModifiedMesh(SALOMEDS::SObject_ptr theSObject, bool theIsRight); + void ModifiedMesh (_PTR(SObject) theSObject, bool theIsRight); +// void UpdateObjBrowser (bool); } - #endif diff --git a/src/SMESHGUI/SMESHGUI_VTKUtils.cxx b/src/SMESHGUI/SMESHGUI_VTKUtils.cxx index 89cebc3c4..f09225878 100644 --- a/src/SMESHGUI/SMESHGUI_VTKUtils.cxx +++ b/src/SMESHGUI/SMESHGUI_VTKUtils.cxx @@ -1,20 +1,20 @@ // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org @@ -27,19 +27,18 @@ #include -#include "QAD_Config.h" -#include "QAD_Desktop.h" -#include "QAD_Study.h" -#include "QAD_Settings.h" -#include "QAD_RightFrame.h" +#include +#include +#include -#include "SALOME_Selection.h" -#include "SALOME_ListIteratorOfListIO.hxx" +#include "SalomeApp_SelectionMgr.h" -#include "VTKViewer_ViewFrame.h" -#include "VTKViewer_RenderWindow.h" -#include "VTKViewer_InteractorStyleSALOME.h" -#include "VTKViewer_RenderWindowInteractor.h" +#include "SVTK_Selector.h" +#include "SVTK_ViewModel.h" +#include "SVTK_ViewWindow.h" +#include "SVTK_RenderWindow.h" +#include "SVTK_InteractorStyle.h" +#include "SVTK_RenderWindowInteractor.h" #include "utilities.h" @@ -48,11 +47,22 @@ #include CORBA_CLIENT_HEADER(SMESH_Mesh) #include CORBA_CLIENT_HEADER(SMESH_Group) #include CORBA_CLIENT_HEADER(SMESH_Hypothesis) -#include CORBA_CLIENT_HEADER(SALOMEDS_Attributes) +#include "SMESHGUI.h" #include "SMESH_Actor.h" #include "SMESH_ObjectDef.h" +#include +#include +#include + +#include +#include + +#include +#include + +#include using namespace std; namespace SMESH{ @@ -68,14 +78,15 @@ namespace SMESH{ if(anIter != VISUAL_OBJ_CONT.end()){ aVisualObj = anIter->second; }else{ - SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument(); - SALOMEDS::SObject_var aSObj = aStudy->FindObjectID(theEntry); - if(!CORBA::is_nil(aSObj)){ - SALOMEDS::GenericAttribute_var anAttr; + SalomeApp_Application* app = dynamic_cast( SMESHGUI::activeStudy()->application() ); + _PTR(Study) aStudy = SMESHGUI::activeStudy()->studyDS(); + _PTR(SObject) aSObj = aStudy->FindObjectID(theEntry); + if(aSObj){ + _PTR(GenericAttribute) anAttr; if(aSObj->FindAttribute(anAttr,"AttributeIOR")){ - SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - CORBA::String_var aVal = anIOR->Value(); - CORBA::Object_var anObj = aStudy->ConvertIORToObject(aVal.in()); + _PTR(AttributeIOR) anIOR = anAttr; + CORBA::String_var aVal = anIOR->Value().c_str(); + CORBA::Object_var anObj = app->orb()->string_to_object( aVal.in() ); if(!CORBA::is_nil(anObj)){ //Try narrow to SMESH_Mesh interafce SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow(anObj); @@ -89,16 +100,16 @@ namespace SMESH{ //Try narrow to SMESH_Group interafce SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow(anObj); if(!aGroup->_is_nil()){ - SALOMEDS::SObject_var aFatherSObj = aSObj->GetFather(); - if(aFatherSObj->_is_nil()) return aVisualObj; + _PTR(SObject) aFatherSObj = aSObj->GetFather(); + if(!aFatherSObj) return aVisualObj; aFatherSObj = aFatherSObj->GetFather(); - if(aFatherSObj->_is_nil()) return aVisualObj; - CORBA::String_var anEntry = aFatherSObj->GetID(); + if(!aFatherSObj) return aVisualObj; + CORBA::String_var anEntry = aFatherSObj->GetID().c_str(); TVisualObjPtr aVisObj = GetVisualObj(theStudyId,anEntry.in()); if(SMESH_MeshObj* aMeshObj = dynamic_cast(aVisObj.get())){ aVisualObj.reset(new SMESH_GroupObj(aGroup,aMeshObj)); aVisualObj->Update(); - TVisualObjCont::value_type aValue(aKey,aVisualObj); + TVisualObjCont::value_type aValue(aKey,aVisualObj); VISUAL_OBJ_CONT.insert(aValue); return aVisualObj; } @@ -106,16 +117,16 @@ namespace SMESH{ //Try narrow to SMESH_subMesh interafce SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow(anObj); if(!aSubMesh->_is_nil()){ - SALOMEDS::SObject_var aFatherSObj = aSObj->GetFather(); - if(aFatherSObj->_is_nil()) return aVisualObj; + _PTR(SObject) aFatherSObj = aSObj->GetFather(); + if(!aFatherSObj) return aVisualObj; aFatherSObj = aFatherSObj->GetFather(); - if(aFatherSObj->_is_nil()) return aVisualObj; - CORBA::String_var anEntry = aFatherSObj->GetID(); + if(!aFatherSObj) return aVisualObj; + CORBA::String_var anEntry = aFatherSObj->GetID().c_str(); TVisualObjPtr aVisObj = GetVisualObj(theStudyId,anEntry.in()); if(SMESH_MeshObj* aMeshObj = dynamic_cast(aVisObj.get())){ aVisualObj.reset(new SMESH_subMeshObj(aSubMesh,aMeshObj)); aVisualObj->Update(); - TVisualObjCont::value_type aValue(aKey,aVisualObj); + TVisualObjCont::value_type aValue(aKey,aVisualObj); VISUAL_OBJ_CONT.insert(aValue); return aVisualObj; } @@ -131,50 +142,72 @@ namespace SMESH{ } - VTKViewer_ViewFrame* FindVtkViewFrame(QAD_Study* theStudy, - QAD_StudyFrame* theStudyFrame) + SVTK_ViewWindow* + GetViewWindow(const SalomeApp_Module* theModule) { - QList& aStudies = - QAD_Application::getDesktop()->getActiveApp()->getStudies(); - if(aStudies.containsRef(theStudy)){ - const QList& aStudyFrames = theStudy->getStudyFrames(); - if(aStudyFrames.containsRef(theStudyFrame)){ - return GetVtkViewFrame(theStudyFrame); + if(SalomeApp_Application* anApp = theModule->getApp()){ + if(SUIT_ViewManager* aViewManager = anApp->activeViewManager()){ + if(aViewManager->getType() == SVTK_Viewer::Type()){ + if(SUIT_ViewWindow* aViewWindow = aViewManager->getActiveView()){ + return dynamic_cast(aViewWindow); + } + } } } return NULL; } - - VTKViewer_ViewFrame* GetVtkViewFrame(QAD_StudyFrame* theStudyFrame){ - QAD_ViewFrame* aViewFrame = theStudyFrame->getRightFrame()->getViewFrame(); - return dynamic_cast(aViewFrame); - } - - - VTKViewer_ViewFrame* GetCurrentVtkView(){ - return GetVtkViewFrame(GetActiveStudy()->getActiveStudyFrame()); - } - - - void RepaintViewFrame(VTKViewer_ViewFrame* theFrame) + SVTK_ViewWindow* FindVtkViewWindow( SUIT_ViewManager* theMgr, + SUIT_ViewWindow* theWindow ) { - theFrame->Repaint(); + if( !theMgr ) + return NULL; + + QPtrVector views = theMgr->getViews(); + if( views.containsRef( theWindow ) ) + return GetVtkViewWindow( theWindow ); + else + return NULL; } - void RenderViewFrame(VTKViewer_ViewFrame* theFrame) + SVTK_ViewWindow* GetVtkViewWindow(SUIT_ViewWindow* theWindow){ + return dynamic_cast(theWindow); + } + + +/* SUIT_ViewWindow* GetActiveWindow() { - theFrame->getRW()->getRenderWindow()->Render(); - theFrame->Repaint(); + SalomeApp_Application* app = dynamic_cast( SUIT_Session::session()->activeApplication() ); + if( !app ) + return NULL; + SUIT_ViewManager* mgr = app->activeViewManager(); + if( mgr ) + return mgr->getActiveView(); + else + return NULL; + }*/ + + SVTK_ViewWindow* GetCurrentVtkView(){ + return GetVtkViewWindow( GetActiveWindow() ); } + void RepaintViewWindow(SVTK_ViewWindow* theWindow) + { + theWindow->Repaint(); + } - SMESH_Actor* FindActorByEntry(QAD_StudyFrame *theStudyFrame, + void RenderViewWindow(SVTK_ViewWindow* theWindow) + { + theWindow->getRenderer()->Render(); + theWindow->Repaint(); + } + + SMESH_Actor* FindActorByEntry(SUIT_ViewWindow *theWindow, const char* theEntry) { - if(VTKViewer_ViewFrame* aViewFrame = GetVtkViewFrame(theStudyFrame)){ - vtkRenderer *aRenderer = aViewFrame->getRenderer(); + if(SVTK_ViewWindow* aViewWindow = GetVtkViewWindow(theWindow)){ + vtkRenderer *aRenderer = aViewWindow->getRenderer(); vtkActorCollection *aCollection = aRenderer->GetActors(); aCollection->InitTraversal(); while(vtkActor *anAct = aCollection->GetNextActor()){ @@ -190,20 +223,24 @@ namespace SMESH{ } return NULL; } - - + + SMESH_Actor* FindActorByEntry(const char* theEntry){ - return FindActorByEntry(GetActiveStudy()->getActiveStudyFrame(),theEntry); + return FindActorByEntry(GetActiveWindow(),theEntry); } - - + + SMESH_Actor* FindActorByObject(CORBA::Object_ptr theObject){ + SalomeApp_Application* app = dynamic_cast( SUIT_Session::session()->activeApplication() ); + if( !app ) + return NULL; + if(!CORBA::is_nil(theObject)){ - SALOMEDS::Study_var aStudy = GetActiveStudyDocument(); - CORBA::String_var anIOR = aStudy->ConvertObjectToIOR(theObject); - SALOMEDS::SObject_var aSObject = aStudy->FindObjectIOR(anIOR.in()); - if(!aSObject->_is_nil()){ - CORBA::String_var anEntry = aSObject->GetID(); + _PTR(Study) aStudy = GetActiveStudyDocument(); + CORBA::String_var anIOR = app->orb()->object_to_string( theObject ); + _PTR(SObject) aSObject = aStudy->FindObjectIOR(anIOR.in()); + if(aSObject){ + CORBA::String_var anEntry = aSObject->GetID().c_str(); return FindActorByEntry(anEntry.in()); } } @@ -211,20 +248,19 @@ namespace SMESH{ } - SMESH_Actor* CreateActor(SALOMEDS::Study_ptr theStudy, + SMESH_Actor* CreateActor(_PTR(Study) theStudy, const char* theEntry, int theIsClear) { SMESH_Actor *anActor = NULL; CORBA::Long anId = theStudy->StudyId(); if(TVisualObjPtr aVisualObj = GetVisualObj(anId,theEntry)){ - SALOMEDS::SObject_var aSObj = theStudy->FindObjectID(theEntry); - if(!aSObj->_is_nil()){ - SALOMEDS::GenericAttribute_var anAttr; + _PTR(SObject) aSObj = theStudy->FindObjectID(theEntry); + if(aSObj){ + _PTR(GenericAttribute) anAttr; if(aSObj->FindAttribute(anAttr,"AttributeName")){ - SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr); - CORBA::String_var aVal = aName->Value(); - string aNameVal = aVal.in(); + _PTR(AttributeName) aName = anAttr; + std::string aNameVal = aName->Value(); anActor = SMESH_Actor::New(aVisualObj,theEntry,aNameVal.c_str(),theIsClear); } } @@ -233,58 +269,56 @@ namespace SMESH{ } - void DisplayActor(QAD_StudyFrame *theStudyFrame, SMESH_Actor* theActor){ - if(VTKViewer_ViewFrame* aViewFrame = GetVtkViewFrame(theStudyFrame)){ - aViewFrame->AddActor(theActor); - aViewFrame->Repaint(); + void DisplayActor( SUIT_ViewWindow *theWnd, SMESH_Actor* theActor){ + if(SVTK_ViewWindow* vtkWnd = GetVtkViewWindow(theWnd)){ + vtkWnd->AddActor(theActor); + vtkWnd->Repaint(); } } - void RemoveActor(QAD_StudyFrame *theStudyFrame, SMESH_Actor* theActor){ - if(VTKViewer_ViewFrame* aViewFrame = GetVtkViewFrame(theStudyFrame)){ - aViewFrame->RemoveActor(theActor); + void RemoveActor( SUIT_ViewWindow *theWnd, SMESH_Actor* theActor){ + if(SVTK_ViewWindow* vtkWnd = GetVtkViewWindow(theWnd)){ + vtkWnd->RemoveActor(theActor); if(theActor->hasIO()){ Handle(SALOME_InteractiveObject) anIO = theActor->getIO(); if(anIO->hasEntry()){ std::string anEntry = anIO->getEntry(); - QAD_Study* aStudy = theStudyFrame->getStudy(); - int aStudyId = aStudy->getStudyId(); + SalomeApp_Study* aStudy = dynamic_cast( vtkWnd->getViewManager()->study() ); + int aStudyId = aStudy->id(); TVisualObjCont::key_type aKey(aStudyId,anEntry); VISUAL_OBJ_CONT.erase(aKey); } } theActor->Delete(); - aViewFrame->Repaint(); + vtkWnd->Repaint(); } } - + void FitAll(){ - if(VTKViewer_ViewFrame* aViewFrame = GetVtkViewFrame(GetActiveStudy()->getActiveStudyFrame())){ - aViewFrame->onViewFitAll(); - aViewFrame->Repaint(); + if(SVTK_ViewWindow* wnd = GetCurrentVtkView() ){ + wnd->onFitAll(); + wnd->Repaint(); } } - + vtkRenderer* GetCurrentRenderer(){ - if(VTKViewer_ViewFrame* aViewFrame = GetVtkViewFrame(GetActiveStudy()->getActiveStudyFrame())) - return aViewFrame->getRenderer(); + if(SVTK_ViewWindow* wnd = GetCurrentVtkView() ) + return wnd->getRenderer(); return NULL; } void RepaintCurrentView(){ - if(VTKViewer_ViewFrame* aViewFrame = GetVtkViewFrame(GetActiveStudy()->getActiveStudyFrame())){ - aViewFrame->getRW()->getRenderWindow()->Render(); - //aViewFrame->Repaint(); - } + if(SVTK_ViewWindow* wnd = GetCurrentVtkView() ) + wnd->getRenderer()->Render(); + //wnd->Repaint(); } - - - void UpdateView(QAD_StudyFrame *theStudyFrame, EDisplaing theAction, const char* theEntry) + + void UpdateView(SUIT_ViewWindow *theWnd, EDisplaing theAction, const char* theEntry) { - if(VTKViewer_ViewFrame* aViewFrame = GetVtkViewFrame(theStudyFrame)){ - vtkRenderer *aRenderer = aViewFrame->getRenderer(); + if(SVTK_ViewWindow* aViewWnd = GetVtkViewWindow(theWnd)){ + vtkRenderer *aRenderer = aViewWnd->getRenderer(); vtkActorCollection *aCollection = aRenderer->GetActors(); aCollection->InitTraversal(); switch(theAction){ @@ -305,7 +339,7 @@ namespace SMESH{ } } default: { - if(SMESH_Actor *anActor = FindActorByEntry(theStudyFrame,theEntry)){ + if(SMESH_Actor *anActor = FindActorByEntry(theWnd,theEntry)){ switch(theAction) { case eDisplay: case eDisplayOnly: @@ -319,10 +353,10 @@ namespace SMESH{ switch(theAction){ case eDisplay: case eDisplayOnly:{ - QAD_Study* aStudy = theStudyFrame->getStudy(); - SALOMEDS::Study_var aDocument = aStudy->getStudyDocument(); + SalomeApp_Study* aStudy = dynamic_cast( theWnd->getViewManager()->study() ); + _PTR(Study) aDocument = aStudy->studyDS(); if((anActor = CreateActor(aDocument,theEntry,true))) { - DisplayActor(theStudyFrame,anActor); + DisplayActor(theWnd,anActor); FitAll(); } break; @@ -336,16 +370,19 @@ namespace SMESH{ void UpdateView(EDisplaing theAction, const char* theEntry){ - QAD_Study* aStudy = GetActiveStudy(); - QAD_StudyFrame *aStudyFrame = aStudy->getActiveStudyFrame(); - UpdateView(aStudyFrame,theAction,theEntry); + SalomeApp_Study* aStudy = dynamic_cast< SalomeApp_Study* >( GetActiveStudy() ); + SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( aStudy->application() ); + SUIT_ViewWindow *aWnd = app->activeViewManager()->getActiveView(); + UpdateView(aWnd,theAction,theEntry); } - + void UpdateView(){ - if(VTKViewer_ViewFrame* aViewFrame = SMESH::GetCurrentVtkView()){ - SALOME_Selection *aSel = SALOME_Selection::Selection(GetActiveStudy()->getSelection()); - if(aSel->IObjectCount() == 0){ - vtkRenderer* aRenderer = aViewFrame->getRenderer(); + if(SVTK_ViewWindow* aWnd = SMESH::GetCurrentVtkView()){ + SalomeApp_SelectionMgr* mgr = SMESHGUI::selectionMgr(); + SALOME_ListIO selected; mgr->selectedObjects( selected ); + + if( selected.Extent() == 0){ + vtkRenderer* aRenderer = aWnd->getRenderer(); vtkActorCollection *aCollection = aRenderer->GetActors(); aCollection->InitTraversal(); while(vtkActor *anAct = aCollection->GetNextActor()){ @@ -355,7 +392,7 @@ namespace SMESH{ } } }else{ - SALOME_ListIteratorOfListIO anIter(aSel->StoredIObjects()); + SALOME_ListIteratorOfListIO anIter( selected ); for(; anIter.More(); anIter.Next()){ Handle(SALOME_InteractiveObject) anIO = anIter.Value(); Update(anIO,true); @@ -369,7 +406,7 @@ namespace SMESH{ void Update(const Handle(SALOME_InteractiveObject)& theIO, bool theDisplay) { - SALOMEDS::Study_var aStudy = GetActiveStudyDocument(); + _PTR(Study) aStudy = GetActiveStudyDocument(); CORBA::Long anId = aStudy->StudyId(); TVisualObjPtr aVisualObj = SMESH::GetVisualObj(anId,theIO->getEntry()); aVisualObj->Update(); @@ -379,115 +416,99 @@ namespace SMESH{ void UpdateSelectionProp() { - QAD_Study* aStudy = GetActiveStudy(); - QList aFrameList = aStudy->getStudyFrames(); - - QString SCr, SCg, SCb; - SCr = QAD_CONFIG->getSetting("SMESH:SettingsSelectColorRed"); - SCg = QAD_CONFIG->getSetting("SMESH:SettingsSelectColorGreen"); - SCb = QAD_CONFIG->getSetting("SMESH:SettingsSelectColorBlue"); - QColor aHiColor = Qt::white; - if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty()) - aHiColor = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt()); - - SCr = QAD_CONFIG->getSetting("SMESH:SettingsItemSelectColorRed"); - SCg = QAD_CONFIG->getSetting("SMESH:SettingsItemSelectColorGreen"); - SCb = QAD_CONFIG->getSetting("SMESH:SettingsItemSelectColorBlue"); - QColor aSelColor = Qt::yellow; - if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty()) - aSelColor = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt()); - QString SW = QAD_CONFIG->getSetting("SMESH:SettingsItemSelectWidth"); - if (SW.isEmpty()) SW = "5"; - - SCr = QAD_CONFIG->getSetting("SMESH:SettingsPreSelectColorRed"); - SCg = QAD_CONFIG->getSetting("SMESH:SettingsPreSelectColorGreen"); - SCb = QAD_CONFIG->getSetting("SMESH:SettingsPreSelectColorBlue"); - QColor aPreColor = Qt::cyan; - if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty()) - aPreColor = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt()); - QString PW = QAD_CONFIG->getSetting("SMESH:SettingsPreSelectWidth"); - if (PW.isEmpty()) PW = "5"; - - QString SP1 = QAD_CONFIG->getSetting("SMESH:SettingsNodeSelectTol"); - if (SP1.isEmpty()) SP1 = "0.025"; - QString SP2 = QAD_CONFIG->getSetting("SMESH:SettingsElementsSelectTol"); - if (SP2.isEmpty()) SP2 = "0.001"; - - for (QAD_StudyFrame* aStudyFrame = aFrameList.first(); aStudyFrame; aStudyFrame = aFrameList.next()) { - if (aStudyFrame->getTypeView() == VIEW_VTK) { - VTKViewer_ViewFrame* aVtkViewFrame = GetVtkViewFrame(aStudyFrame); - if (!aVtkViewFrame) continue; + SUIT_Study* aStudy = GetActiveStudy(); + SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( aStudy->application() ); + SUIT_ViewManager* vm = app->activeViewManager(); + QPtrVector views = vm->getViews(); + + SUIT_ResourceMgr* mgr = SMESHGUI::resourceMgr(); + + QColor aHiColor = mgr->colorValue( "SMESH", "SettingsSelectColor", Qt::white ), + aSelColor = mgr->colorValue( "SMESH", "SettingsItemSelectColor", Qt::yellow ), + aPreColor = mgr->colorValue( "SMESH", "SettingsPreSelectColor", Qt::cyan ); + + int SW = mgr->integerValue( "SMESH", "SettingsItemSelectWidth", 5 ), + PW = mgr->integerValue( "SMESH", "SettingsPreSelectWidth", 5 ); + + double SP1 = mgr->doubleValue( "SMESH", "SettingsNodeSelectTol", 0.025 ), + SP2 = mgr->doubleValue( "SMESH", "SettingsElementsSelectTol", 0.001 ); + + for ( int i=0, n=views.count(); igetRWInteractor(); + SVTK_RenderWindowInteractor* anInteractor = aVtkView->getRWInteractor(); if (anInteractor) { // mesh element selection - anInteractor->SetSelectionProp(aSelColor.red()/255., aSelColor.green()/255., - aSelColor.blue()/255., SW.toInt()); - + anInteractor->SetSelectionProp(aSelColor.red()/255., aSelColor.green()/255., + aSelColor.blue()/255., SW ); + // tolerances - anInteractor->SetSelectionTolerance(SP1.toDouble(), SP2.toDouble()); - + anInteractor->SetSelectionTolerance(SP1, SP2); + // pre-selection - VTKViewer_InteractorStyleSALOME* aStyle = anInteractor->GetInteractorStyleSALOME(); + SVTK_InteractorStyle* aStyle = + dynamic_cast( anInteractor->GetInteractorStyle() ); if (aStyle) { - aStyle->setPreselectionProp(aPreColor.red()/255., aPreColor.green()/255., - aPreColor.blue()/255., PW.toInt()); + aStyle->setPreselectionProp(aPreColor.red()/255., aPreColor.green()/255., + aPreColor.blue()/255., PW); } } // update actors - vtkRenderer* aRenderer = aVtkViewFrame->getRenderer(); + vtkRenderer* aRenderer = aVtkView->getRenderer(); vtkActorCollection *aCollection = aRenderer->GetActors(); aCollection->InitTraversal(); while(vtkActor *anAct = aCollection->GetNextActor()){ if(SMESH_Actor *anActor = dynamic_cast(anAct)){ - anActor->SetHighlightColor(aHiColor.red()/255., aHiColor.green()/255., + anActor->SetHighlightColor(aHiColor.red()/255., aHiColor.green()/255., aHiColor.blue()/255.); - anActor->SetPreHighlightColor(aPreColor.red()/255., aPreColor.green()/255., + anActor->SetPreHighlightColor(aPreColor.red()/255., aPreColor.green()/255., aPreColor.blue()/255.); } } - } } } - + //---------------------------------------------------------------------------- - VTKViewer_InteractorStyleSALOME* GetInteractorStyle(QAD_StudyFrame *theStudyFrame){ - if(VTKViewer_ViewFrame* aViewFrame = GetVtkViewFrame(theStudyFrame)){ - if(VTKViewer_RenderWindowInteractor* anInteractor = aViewFrame->getRWInteractor()){ - return anInteractor->GetInteractorStyleSALOME(); + SVTK_InteractorStyle* GetInteractorStyle(SUIT_ViewWindow *theWindow){ + if(SVTK_ViewWindow* aWnd = GetVtkViewWindow(theWindow)){ + if(SVTK_RenderWindowInteractor* anInteractor = aWnd->getRWInteractor()){ + return dynamic_cast( anInteractor->GetInteractorStyle() ); } } return NULL; } void SetFilter(const Handle(VTKViewer_Filter)& theFilter, - VTKViewer_InteractorStyleSALOME* theStyle) + SVTK_InteractorStyle* theStyle) { theStyle->SetFilter(theFilter); } - Handle(VTKViewer_Filter) GetFilter(int theId, VTKViewer_InteractorStyleSALOME* theStyle) + Handle(VTKViewer_Filter) GetFilter(int theId, SVTK_InteractorStyle* theStyle) { return theStyle->GetFilter(theId); } - bool IsFilterPresent(int theId, VTKViewer_InteractorStyleSALOME* theStyle) + bool IsFilterPresent(int theId, SVTK_InteractorStyle* theStyle) { return theStyle->IsFilterPresent(theId); } - void RemoveFilter(int theId, VTKViewer_InteractorStyleSALOME* theStyle){ + void RemoveFilter(int theId, SVTK_InteractorStyle* theStyle) + { theStyle->RemoveFilter(theId); } - void RemoveFilters(VTKViewer_InteractorStyleSALOME* theStyle){ + void RemoveFilters(SVTK_InteractorStyle* theStyle) + { for ( int id = SMESHGUI_NodeFilter; theStyle && id < SMESHGUI_LastFilter; id++ ) theStyle->RemoveFilter( id ); } bool IsValid(SALOME_Actor* theActor, int theCellId, - VTKViewer_InteractorStyleSALOME* theStyle) + SVTK_InteractorStyle* theStyle) { return theStyle->IsValid(theActor,theCellId); } @@ -495,8 +516,8 @@ namespace SMESH{ //---------------------------------------------------------------------------- void SetPointRepresentation(bool theIsVisible){ - if(VTKViewer_ViewFrame* aViewFrame = GetCurrentVtkView()){ - vtkRenderer *aRenderer = aViewFrame->getRenderer(); + if(SVTK_ViewWindow* aViewWindow = GetCurrentVtkView()){ + vtkRenderer *aRenderer = aViewWindow->getRenderer(); vtkActorCollection *aCollection = aRenderer->GetActors(); aCollection->InitTraversal(); while(vtkActor *anAct = aCollection->GetNextActor()){ @@ -512,9 +533,9 @@ namespace SMESH{ void SetPickable(SMESH_Actor* theActor){ - if(VTKViewer_ViewFrame* aViewFrame = GetCurrentVtkView()){ + if(SVTK_ViewWindow* aWnd = GetCurrentVtkView()){ int anIsAllPickable = (theActor == NULL); - vtkRenderer *aRenderer = aViewFrame->getRenderer(); + vtkRenderer *aRenderer = aWnd->getRenderer(); vtkActorCollection *aCollection = aRenderer->GetActors(); aCollection->InitTraversal(); while(vtkActor *anAct = aCollection->GetNextActor()){ @@ -531,15 +552,86 @@ namespace SMESH{ } - int GetNameOfSelectedNodes(SALOME_Selection *theSel, + //---------------------------------------------------------------------------- + int GetNameOfSelectedNodes(SVTK_Selector* theSelector, const Handle(SALOME_InteractiveObject)& theIO, QString& theName) + { + theName = ""; + TColStd_IndexedMapOfInteger aMapIndex; + theSelector->GetIndex(theIO,aMapIndex); + + for(int i = 1; i <= aMapIndex.Extent(); i++) + theName += QString(" %1").arg(aMapIndex(i)); + + return aMapIndex.Extent(); + } + + int GetNameOfSelectedElements(SVTK_Selector* theSelector, + const Handle(SALOME_InteractiveObject)& theIO, + QString& theName) + { + theName = ""; + TColStd_IndexedMapOfInteger aMapIndex; + theSelector->GetIndex(theIO,aMapIndex); + + typedef std::set TIdContainer; + TIdContainer anIdContainer; + for( int i = 1; i <= aMapIndex.Extent(); i++) + anIdContainer.insert(aMapIndex(i)); + + TIdContainer::const_iterator anIter = anIdContainer.begin(); + for(; anIter != anIdContainer.end(); anIter++) + theName += QString(" %1").arg(*anIter); + + return aMapIndex.Extent(); + } + + + int GetEdgeNodes(SVTK_Selector* theSelector, + const TVisualObjPtr& theVisualObject, + int& theId1, + int& theId2) + { + const SALOME_ListIO& selected = theSelector->StoredIObjects(); + + if ( selected.Extent() != 1 ) + return -1; + + Handle(SALOME_InteractiveObject) anIO = selected.First(); + if ( anIO.IsNull() || !anIO->hasEntry() ) + return -1; + + TColStd_IndexedMapOfInteger aMapIndex; + theSelector->GetIndex( anIO, aMapIndex ); + if ( aMapIndex.Extent() != 2 ) + return -1; + + int anObjId = -1, anEdgeNum = -1; + for ( int i = 1; i <= aMapIndex.Extent(); i++ ) { + int aVal = aMapIndex( i ); + if ( aVal > 0 ) + anObjId = aVal; + else + anEdgeNum = abs( aVal ) - 1; + } + + if ( anObjId == -1 || anEdgeNum == -1 ) + return -1; + + return theVisualObject->GetEdgeNodes( anObjId, anEdgeNum, theId1, theId2 ) ? 1 : -1; + } + + //---------------------------------------------------------------------------- + int GetNameOfSelectedNodes(SalomeApp_SelectionMgr *theMgr, + const Handle(SALOME_InteractiveObject)& theIO, + QString& theName) { theName = ""; if(theIO->hasEntry()){ if(FindActorByEntry(theIO->getEntry())){ TColStd_IndexedMapOfInteger aMapIndex; - theSel->GetIndex(theIO,aMapIndex); + theMgr->GetIndexes(theIO,aMapIndex); for(int i = 1; i <= aMapIndex.Extent(); i++){ theName += QString(" %1").arg(aMapIndex(i)); } @@ -548,28 +640,28 @@ namespace SMESH{ } return -1; } - - int GetNameOfSelectedNodes(SALOME_Selection *theSel, QString& theName){ + int GetNameOfSelectedNodes(SalomeApp_SelectionMgr *theMgr, QString& theName){ theName = ""; - if(theSel->IObjectCount() == 1){ - Handle(SALOME_InteractiveObject) anIO = theSel->firstIObject(); - return GetNameOfSelectedNodes(theSel,anIO,theName); + SALOME_ListIO selected; theMgr->selectedObjects( selected ); + if(selected.Extent() == 1){ + Handle(SALOME_InteractiveObject) anIO = selected.First(); + return GetNameOfSelectedNodes(theMgr,anIO,theName); } return -1; } - int GetNameOfSelectedElements(SALOME_Selection *theSel, - const Handle(SALOME_InteractiveObject)& theIO, + int GetNameOfSelectedElements(SalomeApp_SelectionMgr *theMgr, + const Handle(SALOME_InteractiveObject)& theIO, QString& theName) { theName = ""; if(theIO->hasEntry()){ if(FindActorByEntry(theIO->getEntry())){ TColStd_IndexedMapOfInteger aMapIndex; - theSel->GetIndex(theIO,aMapIndex); - typedef std::set TIdContainer; + theMgr->GetIndexes(theIO,aMapIndex); + typedef set TIdContainer; TIdContainer anIdContainer; for( int i = 1; i <= aMapIndex.Extent(); i++) anIdContainer.insert(aMapIndex(i)); @@ -584,40 +676,44 @@ namespace SMESH{ } - int GetNameOfSelectedElements(SALOME_Selection *theSel, QString& theName) + int GetNameOfSelectedElements(SalomeApp_SelectionMgr *theMgr, QString& theName) { theName = ""; - if(theSel->IObjectCount() == 1){ - Handle(SALOME_InteractiveObject) anIO = theSel->firstIObject(); - return GetNameOfSelectedElements(theSel,anIO,theName); + SALOME_ListIO selected; theMgr->selectedObjects( selected ); + + if( selected.Extent() == 1){ + Handle(SALOME_InteractiveObject) anIO = selected.First(); + return GetNameOfSelectedElements(theMgr,anIO,theName); } return -1; } - - int GetSelected(SALOME_Selection* theSel, - TColStd_IndexedMapOfInteger& theMap, + int GetSelected(SalomeApp_SelectionMgr* theMgr, + TColStd_IndexedMapOfInteger& theMap, const bool theIsElement) { theMap.Clear(); + SALOME_ListIO selected; theMgr->selectedObjects( selected ); - if ( theSel->IObjectCount() == 1 ) + if ( selected.Extent() == 1 ) { - Handle(SALOME_InteractiveObject) anIO = theSel->firstIObject(); + Handle(SALOME_InteractiveObject) anIO = selected.First(); if ( anIO->hasEntry() ) { - theSel->GetIndex( anIO, theMap ); + theMgr->GetIndexes( anIO, theMap ); } } return theMap.Extent(); } - int GetEdgeNodes( SALOME_Selection* theSel, int& theId1, int& theId2 ) + int GetEdgeNodes( SalomeApp_SelectionMgr* theMgr, int& theId1, int& theId2 ) { - if ( theSel->IObjectCount() != 1 ) + SALOME_ListIO selected; theMgr->selectedObjects( selected ); + + if ( selected.Extent() != 1 ) return -1; - Handle(SALOME_InteractiveObject) anIO = theSel->firstIObject(); + Handle(SALOME_InteractiveObject) anIO = selected.First(); if ( anIO.IsNull() || !anIO->hasEntry() ) return -1; @@ -626,10 +722,10 @@ namespace SMESH{ return -1; TColStd_IndexedMapOfInteger aMapIndex; - theSel->GetIndex( anIO, aMapIndex ); + theMgr->GetIndexes( anIO, aMapIndex ); if ( aMapIndex.Extent() != 2 ) return -1; - + int anObjId = -1, anEdgeNum = -1; for ( int i = 1; i <= aMapIndex.Extent(); i++ ) { int aVal = aMapIndex( i ); @@ -638,18 +734,18 @@ namespace SMESH{ else anEdgeNum = abs( aVal ); } - + if ( anObjId == -1 || anEdgeNum == -1 ) return -1; - + return anActor->GetObject()->GetEdgeNodes( anObjId, anEdgeNum, theId1, theId2 ) ? 1 : -1; } - + void SetControlsPrecision( const long theVal ) { - if( VTKViewer_ViewFrame* aViewFrame = SMESH::GetCurrentVtkView() ) + if( SVTK_ViewWindow* aWnd = SMESH::GetCurrentVtkView() ) { - vtkRenderer *aRenderer = aViewFrame->getRenderer(); + vtkRenderer *aRenderer = aWnd->getRenderer(); vtkActorCollection *aCollection = aRenderer->GetActors(); aCollection->InitTraversal(); @@ -665,20 +761,3 @@ namespace SMESH{ } } } - - - - - - - - - - - - - - - - - diff --git a/src/SMESHGUI/SMESHGUI_VTKUtils.h b/src/SMESHGUI/SMESHGUI_VTKUtils.h index 6e6fd84ed..ec68ea5b1 100644 --- a/src/SMESHGUI/SMESHGUI_VTKUtils.h +++ b/src/SMESHGUI/SMESHGUI_VTKUtils.h @@ -1,37 +1,44 @@ // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org #ifndef SMESHGUI_VTKUtils_HeaderFile #define SMESHGUI_VTKUtils_HeaderFile class QString; -class vtkRenderer; +class vtkRenderer; class TColStd_IndexedMapOfInteger; +#include "SALOMEDSClient_definitions.hxx" #include "SALOME_InteractiveObject.hxx" #include "VTKViewer_Filter.h" -class QAD_Study; -class QAD_StudyFrame; -class SALOME_Selection; -class VTKViewer_ViewFrame; -class VTKViewer_InteractorStyleSALOME; +class SALOMEDSClient_Study; + +class SUIT_Study; +class SUIT_ViewWindow; +class SUIT_ViewManager; + +class SVTK_InteractorStyle; +class SVTK_ViewWindow; +class SVTK_Selector; + +class SalomeApp_SelectionMgr; #include @@ -41,8 +48,10 @@ class VTKViewer_InteractorStyleSALOME; #include #include "SMESH_Object.h" -class SALOME_Actor; class SMESH_Actor; +class SALOME_Actor; +class SVTK_ViewWindow; +class SalomeApp_Module; namespace SMESH{ @@ -52,47 +61,39 @@ namespace SMESH{ TVisualObjPtr GetVisualObj(int theStudyId, const char* theEntry); + //---------------------------------------------------------------------------- + SVTK_ViewWindow* GetViewWindow(const SalomeApp_Module* theModule); + + SUIT_ViewWindow* GetActiveWindow(); + + SVTK_ViewWindow* FindVtkViewWindow( SUIT_ViewManager*, + SUIT_ViewWindow* ); + + SVTK_ViewWindow* GetVtkViewWindow( SUIT_ViewWindow* ); + + SVTK_ViewWindow* GetCurrentVtkView(); + + void RepaintViewWindow(SVTK_ViewWindow*); + void RenderViewWindow(SVTK_ViewWindow*); //---------------------------------------------------------------------------- - QAD_StudyFrame* GetActiveStudyFrame(); + SMESH_Actor* FindActorByEntry (SUIT_ViewWindow*, const char* theEntry); + SMESH_Actor* FindActorByEntry (const char* theEntry); - VTKViewer_ViewFrame* FindVtkViewFrame(QAD_Study* theStudy, - QAD_StudyFrame* theStudyFrame); - - VTKViewer_ViewFrame* GetVtkViewFrame(QAD_StudyFrame* theStudyFrame); - - VTKViewer_ViewFrame* GetCurrentVtkView(); - - void RepaintViewFrame(VTKViewer_ViewFrame* theFrame); - - void RenderViewFrame(VTKViewer_ViewFrame* theFrame); + SMESH_Actor* FindActorByObject (CORBA::Object_ptr theObject); //---------------------------------------------------------------------------- - SMESH_Actor* FindActorByEntry(QAD_StudyFrame *theStudyFrame, - const char* theEntry); - SMESH_Actor* FindActorByEntry(const char* theEntry); - - SMESH_Actor* FindActorByObject(CORBA::Object_ptr theObject); - - - //---------------------------------------------------------------------------- - SMESH_Actor* CreateActor(SALOMEDS::Study_ptr theStudy, - const char* theEntry, - int theIsClear = false); - - void DisplayActor(QAD_StudyFrame *theStudyFrame, - SMESH_Actor* theActor); - void RemoveActor(QAD_StudyFrame *theStudyFrame, - SMESH_Actor* theActor); - + SMESH_Actor* CreateActor (_PTR(Study), const char*, int = false); + void DisplayActor (SUIT_ViewWindow*, SMESH_Actor* theActor); + void RemoveActor (SUIT_ViewWindow*, SMESH_Actor* theActor); //---------------------------------------------------------------------------- enum EDisplaing {eDisplayAll, eDisplay, eDisplayOnly, eErase, eEraseAll}; - void UpdateView(QAD_StudyFrame *theStudyFrame, - EDisplaing theAction, - const char* theEntry = ""); - void UpdateView(EDisplaing theAction, - const char* theEntry = ""); + void UpdateView (SUIT_ViewWindow*, + EDisplaing theAction, + const char* theEntry = ""); + void UpdateView (EDisplaing theAction, + const char* theEntry = ""); void UpdateView(); @@ -117,78 +118,62 @@ namespace SMESH{ //---------------------------------------------------------------------------- - VTKViewer_InteractorStyleSALOME* - GetInteractorStyle(QAD_StudyFrame *theStudyFrame = GetActiveStudyFrame()); + SVTK_InteractorStyle* + GetInteractorStyle (SUIT_ViewWindow* = GetActiveWindow()); - void SetFilter(const Handle(VTKViewer_Filter)& theFilter, - VTKViewer_InteractorStyleSALOME* theStyle = GetInteractorStyle()); + void SetFilter (const Handle(VTKViewer_Filter)& theFilter, + SVTK_InteractorStyle* theStyle = GetInteractorStyle()); Handle(VTKViewer_Filter) - GetFilter(int theId, VTKViewer_InteractorStyleSALOME* theStyle = GetInteractorStyle()); + GetFilter (int theId, SVTK_InteractorStyle* theStyle = GetInteractorStyle()); - bool IsFilterPresent(int theId, - VTKViewer_InteractorStyleSALOME* theStyle = GetInteractorStyle()); + bool IsFilterPresent (int theId, + SVTK_InteractorStyle* theStyle = GetInteractorStyle()); - void RemoveFilter(int theId, - VTKViewer_InteractorStyleSALOME* theStyle = GetInteractorStyle()); + void RemoveFilter (int theId, + SVTK_InteractorStyle* theStyle = GetInteractorStyle()); - void RemoveFilters(VTKViewer_InteractorStyleSALOME* theStyle = GetInteractorStyle()); + void RemoveFilters (SVTK_InteractorStyle* theStyle = GetInteractorStyle()); - bool IsValid(SALOME_Actor* theActor, int theCellId, - VTKViewer_InteractorStyleSALOME* theStyle = GetInteractorStyle()); + bool IsValid (SALOME_Actor* theActor, int theCellId, + SVTK_InteractorStyle* theStyle = GetInteractorStyle()); //---------------------------------------------------------------------------- - int GetNameOfSelectedNodes(SALOME_Selection *theSel, + int GetNameOfSelectedNodes(SVTK_Selector* theSelector, const Handle(SALOME_InteractiveObject)& theIO, QString& theName); - - int GetNameOfSelectedNodes(SALOME_Selection *theSel, - QString& aName); - - int GetNameOfSelectedElements(SALOME_Selection *theSel, + + int GetNameOfSelectedElements(SVTK_Selector* theSelector, const Handle(SALOME_InteractiveObject)& theIO, QString& theName); + + int GetEdgeNodes(SVTK_Selector* theSelector, + const TVisualObjPtr& theVisualObj, + int& theId1, + int& theId2); - int GetNameOfSelectedElements(SALOME_Selection *theSel, - QString& aName); + //---------------------------------------------------------------------------- + int GetNameOfSelectedNodes (SalomeApp_SelectionMgr*, + const Handle(SALOME_InteractiveObject)& theIO, + QString& theName); - int GetSelected(SALOME_Selection* theSel, - TColStd_IndexedMapOfInteger& theMap, - const bool theIsElement = true ); + int GetNameOfSelectedNodes (SalomeApp_SelectionMgr*, + QString& aName); - int GetEdgeNodes(SALOME_Selection* theSel, int& theId1, int& theId2); + int GetNameOfSelectedElements (SalomeApp_SelectionMgr*, + const Handle(SALOME_InteractiveObject)& theIO, + QString& theName); - void SetControlsPrecision( const long theVal ); + int GetNameOfSelectedElements (SalomeApp_SelectionMgr*, + QString& aName); + int GetSelected (SalomeApp_SelectionMgr*, + TColStd_IndexedMapOfInteger& theMap, + const bool theIsElement = true ); + + int GetEdgeNodes (SalomeApp_SelectionMgr*, int& theId1, int& theId2); + + void SetControlsPrecision (const long theVal); }; - #endif - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/SMESHGUI/SMESHGUI_XmlHandler.cxx b/src/SMESHGUI/SMESHGUI_XmlHandler.cxx index 9939eb730..cf3a82c95 100644 --- a/src/SMESHGUI/SMESHGUI_XmlHandler.cxx +++ b/src/SMESHGUI/SMESHGUI_XmlHandler.cxx @@ -30,8 +30,9 @@ // QT Include #include -#include "QAD_ResourceMgr.h" -#include "QAD_Desktop.h" +#include "SMESHGUI.h" +#include "SUIT_ResourceMgr.h" +#include "SUIT_Desktop.h" #include "SMESHGUI_XmlHandler.h" #include "SMESHGUI_Hypotheses.h" @@ -92,10 +93,9 @@ bool SMESHGUI_XmlHandler::startElement (const QString&, const QString&, if (aResName != "") { MESSAGE("Loading Resources " << aResName); - QAD_ResourceMgr* resMgr = QAD_Desktop::createResourceManager(); - QString msg; - if (!resMgr->loadResources(aResName, msg)) - MESSAGE(msg); + SUIT_ResourceMgr* resMgr = SMESHGUI::resourceMgr(); + resMgr->loadTranslator("resources",aResName+"_msg_en.qm"); + resMgr->loadTranslator("resources",aResName+"_images.qm"); } } } diff --git a/src/SMESHGUI/SMESHGUI_aParameter.cxx b/src/SMESHGUI/SMESHGUI_aParameter.cxx index 7ba5e20dc..d52b641ba 100644 --- a/src/SMESHGUI/SMESHGUI_aParameter.cxx +++ b/src/SMESHGUI/SMESHGUI_aParameter.cxx @@ -1,23 +1,23 @@ // SMESH SMESHGUI : GUI for SMESH component // // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org // // // @@ -26,12 +26,12 @@ // $Header$ #include "SMESHGUI_aParameter.h" - + #include #include #include -#include "QAD_SpinBoxDbl.h" +#include SMESHGUI_aParameter::~SMESHGUI_aParameter() {} @@ -39,93 +39,96 @@ SMESHGUI_aParameter::~SMESHGUI_aParameter() {} // class : SMESHGUI_intParameter // purpose : //================================================================================= -SMESHGUI_intParameter::SMESHGUI_intParameter(const int theInitValue, - const QString& theLabel, - const int theBottom, - const int theTop) +SMESHGUI_intParameter::SMESHGUI_intParameter (const int theInitValue, + const QString& theLabel, + const int theBottom, + const int theTop) :SMESHGUI_aParameter(theLabel), - _top(theTop), _bottom(theBottom), _initValue( theInitValue ) + _top(theTop), _bottom(theBottom), _initValue(theInitValue) { } SMESHGUI_aParameter::Type SMESHGUI_intParameter::GetType() const { return SMESHGUI_aParameter::INT; } -bool SMESHGUI_intParameter::GetNewInt( int & theValue ) const +bool SMESHGUI_intParameter::GetNewInt (int & theValue) const { theValue = _newValue; return _newValue != _initValue; } -bool SMESHGUI_intParameter::GetNewDouble( double & Value ) const +bool SMESHGUI_intParameter::GetNewDouble (double & Value) const { return false; } -bool SMESHGUI_intParameter::GetNewText( QString & Value ) const +bool SMESHGUI_intParameter::GetNewText (QString & Value) const { return false; } -void SMESHGUI_intParameter::InitializeWidget( QWidget* theQWidget) const +void SMESHGUI_intParameter::InitializeWidget (QWidget* theQWidget) const { - QSpinBox * aSpin = dynamic_cast< QSpinBox *>( theQWidget ); - if ( aSpin ) { - aSpin->setMinValue( _bottom ); - aSpin->setMaxValue( _top ); - aSpin->setValue( _initValue ); + QSpinBox * aSpin = dynamic_cast< QSpinBox *>(theQWidget); + if (aSpin) { + aSpin->setMinValue(_bottom); + aSpin->setMaxValue(_top); + aSpin->setValue(_initValue); } } -void SMESHGUI_intParameter::TakeValue( QWidget* theQWidget) +void SMESHGUI_intParameter::TakeValue (QWidget* theQWidget) { - QSpinBox * aSpin = dynamic_cast< QSpinBox *>( theQWidget ); - if ( aSpin ) + QSpinBox * aSpin = dynamic_cast< QSpinBox *>(theQWidget); + if (aSpin) _newValue = aSpin->value(); } + //================================================================================= // class : SMESHGUI_doubleParameter // purpose : //================================================================================= -SMESHGUI_doubleParameter::SMESHGUI_doubleParameter(const double theInitValue, - const QString& theLabel, - const double theBottom, - const double theTop, - const double theStep, - const int theDecimals) - :SMESHGUI_aParameter( theLabel ), - _top( theTop ), _bottom( theBottom ), _step( theStep ), - _initValue( theInitValue ), _decimals( theDecimals ) +SMESHGUI_doubleParameter::SMESHGUI_doubleParameter (const double theInitValue, + const QString& theLabel, + const double theBottom, + const double theTop, + const double theStep, + const int theDecimals) + :SMESHGUI_aParameter(theLabel), + _top(theTop), _bottom(theBottom), _step(theStep), + _initValue(theInitValue), _decimals(theDecimals) { } SMESHGUI_aParameter::Type SMESHGUI_doubleParameter::GetType() const { return SMESHGUI_aParameter::DOUBLE; } -bool SMESHGUI_doubleParameter::GetNewInt( int & theValue ) const +bool SMESHGUI_doubleParameter::GetNewInt (int & theValue) const { return false; } -bool SMESHGUI_doubleParameter::GetNewDouble( double & Value ) const +bool SMESHGUI_doubleParameter::GetNewDouble (double & Value) const { Value = _newValue; return _newValue != _initValue; } -bool SMESHGUI_doubleParameter::GetNewText( QString & Value ) const +bool SMESHGUI_doubleParameter::GetNewText (QString & Value) const { return false; } -void SMESHGUI_doubleParameter::InitializeWidget( QWidget* theQWidget) const +void SMESHGUI_doubleParameter::InitializeWidget (QWidget* theQWidget) const { - QAD_SpinBoxDbl * aSpin = dynamic_cast< QAD_SpinBoxDbl *>( theQWidget ); - if ( aSpin ) { - aSpin->setPrecision( _decimals ); - aSpin->setDblPrecision( _bottom ); - aSpin->setRange( _bottom, _top ); - aSpin->setValue( _initValue ); - aSpin->setLineStep( _step ); + QtxDblSpinBox* aSpin = dynamic_cast(theQWidget); + if (aSpin) { + aSpin->setPrecision(_decimals); +#ifdef NEW_GUI + aSpin->setDblPrecision(_bottom); +#endif + aSpin->setRange(_bottom, _top); + aSpin->setValue(_initValue); + aSpin->setLineStep(_step); } } -void SMESHGUI_doubleParameter::TakeValue( QWidget* theQWidget) +void SMESHGUI_doubleParameter::TakeValue (QWidget* theQWidget) { - QAD_SpinBoxDbl * aSpin = dynamic_cast< QAD_SpinBoxDbl *>( theQWidget ); - if ( aSpin ) + QtxDblSpinBox* aSpin = dynamic_cast(theQWidget); + if (aSpin) _newValue = aSpin->value(); } @@ -133,39 +136,39 @@ void SMESHGUI_doubleParameter::TakeValue( QWidget* theQWidget) // class : SMESHGUI_strParameter // purpose : //================================================================================= -SMESHGUI_strParameter::SMESHGUI_strParameter(const QString& theInitValue, - const QString& theLabel) +SMESHGUI_strParameter::SMESHGUI_strParameter (const QString& theInitValue, + const QString& theLabel) :SMESHGUI_aParameter(theLabel), - _initValue( theInitValue ) + _initValue(theInitValue) { } SMESHGUI_aParameter::Type SMESHGUI_strParameter::GetType() const { return SMESHGUI_aParameter::TEXT; } -bool SMESHGUI_strParameter::GetNewInt( int & theValue ) const +bool SMESHGUI_strParameter::GetNewInt (int & theValue) const { return false; } -bool SMESHGUI_strParameter::GetNewDouble( double & Value ) const +bool SMESHGUI_strParameter::GetNewDouble (double & Value) const { return false; } -bool SMESHGUI_strParameter::GetNewText( QString & theValue ) const +bool SMESHGUI_strParameter::GetNewText (QString & theValue) const { theValue = _newValue; return _newValue != _initValue; } -void SMESHGUI_strParameter::InitializeWidget( QWidget* theQWidget) const +void SMESHGUI_strParameter::InitializeWidget (QWidget* theQWidget) const { - QTextEdit * anEdit = dynamic_cast< QTextEdit *>( theQWidget ); - if ( anEdit ) { - anEdit->setText( _initValue ); + QTextEdit * anEdit = dynamic_cast< QTextEdit *>(theQWidget); + if (anEdit) { + anEdit->setText(_initValue); } } -void SMESHGUI_strParameter::TakeValue( QWidget* theQWidget) +void SMESHGUI_strParameter::TakeValue (QWidget* theQWidget) { - QTextEdit * anEdit = dynamic_cast< QTextEdit *>( theQWidget ); - if ( anEdit ) + QTextEdit * anEdit = dynamic_cast< QTextEdit *>(theQWidget); + if (anEdit) _newValue = anEdit->text(); } diff --git a/src/SMESHGUI/SMESHGUI_aParameterDlg.cxx b/src/SMESHGUI/SMESHGUI_aParameterDlg.cxx index 67a11b56c..07c1ce1f9 100644 --- a/src/SMESHGUI/SMESHGUI_aParameterDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_aParameterDlg.cxx @@ -1,23 +1,23 @@ // SMESH SMESHGUI : GUI for SMESH component // // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org // // // @@ -26,15 +26,14 @@ // Module : SMESH // $Header$ -#include "QAD_Tools.h" -#include "QAD_Desktop.h" -#include "QAD_Application.h" - #include "SMESHGUI_aParameterDlg.h" #include "SMESHGUI_aParameter.h" #include "SMESHGUI.h" #include "SMESHGUI_SpinBox.h" +#include "SUIT_Tools.h" +#include "SUIT_Desktop.h" + // QT Includes #include #include @@ -46,165 +45,161 @@ using namespace std; -//====================================================================================== +//====================================================================================== // function : SMESHGUI_aParameterDlg() // // The dialog will by default be modal, unless you set 'modal' to // false when constructing dialog -// -//====================================================================================== +// +//====================================================================================== SMESHGUI_aParameterDlg::SMESHGUI_aParameterDlg (std::list params, QWidget* parent, QString title, - bool modal ) -: QDialog( parent, "MyParameterDialog", modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ), - myParamList( params ) + bool modal) +: QDialog(parent, "MyParameterDialog", modal, WStyle_Customize | + WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu), + myParamList(params) { /* creating widgets */ init(); /* title */ - setCaption( title ); + setCaption(title); /* Move widget on the botton right corner of main widget */ - QAD_Tools::centerWidget( this, parent ); + SUIT_Tools::centerWidget(this, parent); } -//====================================================================================== +//====================================================================================== // function : SMESHGUI_aParameterDlg::init() // purpose : creates dialog's layout -//====================================================================================== +//====================================================================================== void SMESHGUI_aParameterDlg::init() { - setSizeGripEnabled( TRUE ); - - QGridLayout* topLayout = new QGridLayout( this ); - topLayout->setMargin( 11 ); topLayout->setSpacing( 6 ); + setSizeGripEnabled(TRUE); + + QGridLayout* topLayout = new QGridLayout(this); + topLayout->setMargin(11); topLayout->setSpacing(6); /***************************************************************/ - QGroupBox* GroupC1 = new QGroupBox( this, "GroupC1" ); - GroupC1->setColumnLayout(0, Qt::Vertical ); - GroupC1->layout()->setSpacing( 0 ); - GroupC1->layout()->setMargin( 0 ); - QGridLayout* GroupC1Layout = new QGridLayout( GroupC1->layout() ); - GroupC1Layout->setAlignment( Qt::AlignTop ); - GroupC1Layout->setSpacing( 6 ); - GroupC1Layout->setMargin( 11 ); + QGroupBox* GroupC1 = new QGroupBox(this, "GroupC1"); + GroupC1->setColumnLayout(0, Qt::Vertical); + GroupC1->layout()->setSpacing(0); + GroupC1->layout()->setMargin(0); + QGridLayout* GroupC1Layout = new QGridLayout(GroupC1->layout()); + GroupC1Layout->setAlignment(Qt::AlignTop); + GroupC1Layout->setSpacing(6); + GroupC1Layout->setMargin(11); /* Spin boxes with labels */ list::iterator paramIt = myParamList.begin(); - for ( int row = 0; paramIt != myParamList.end(); paramIt++ , row++ ) + for (int row = 0; paramIt != myParamList.end(); paramIt++ , row++) { SMESHGUI_aParameterPtr param = (*paramIt); - QLabel * label = new QLabel( GroupC1, "TextLabel" ); - GroupC1Layout->addWidget( label, row, 0 ); - label->setText( param->Label() ); + QLabel * label = new QLabel(GroupC1, "TextLabel"); + GroupC1Layout->addWidget(label, row, 0); + label->setText(param->Label()); QWidget* aSpinWidget = 0; - switch ( param->GetType() ) { + switch (param->GetType()) { case SMESHGUI_aParameter::DOUBLE: { - SMESHGUI_SpinBox* spin = new SMESHGUI_SpinBox( GroupC1 ); + SMESHGUI_SpinBox* spin = new SMESHGUI_SpinBox(GroupC1); aSpinWidget = spin; - spin->setPrecision( 12 ); + spin->setPrecision(12); break; } case SMESHGUI_aParameter::INT: { - QSpinBox* spin = new QSpinBox( GroupC1 ); + QSpinBox* spin = new QSpinBox(GroupC1); aSpinWidget = spin; break; } case SMESHGUI_aParameter::TEXT: { - QTextEdit* edit = new QTextEdit( GroupC1 ); - edit->setWordWrap( QTextEdit::NoWrap ); - edit->setTextFormat( Qt::PlainText ); + QTextEdit* edit = new QTextEdit(GroupC1); + edit->setWordWrap(QTextEdit::NoWrap); + edit->setTextFormat(Qt::PlainText); aSpinWidget = edit; break; } default:; } - if ( aSpinWidget ) { - GroupC1Layout->addWidget( aSpinWidget, row, 1 ); - aSpinWidget->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) ); - aSpinWidget->setMinimumSize( 150, 0 ); - param->InitializeWidget( aSpinWidget ); - mySpinList.push_back( aSpinWidget ); + if (aSpinWidget) { + GroupC1Layout->addWidget(aSpinWidget, row, 1); + aSpinWidget->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum)); + aSpinWidget->setMinimumSize(150, 0); + param->InitializeWidget(aSpinWidget); + mySpinList.push_back(aSpinWidget); } } - + /***************************************************************/ - QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" ); - GroupButtons->setColumnLayout(0, Qt::Vertical ); - GroupButtons->layout()->setSpacing( 0 ); - GroupButtons->layout()->setMargin( 0 ); - QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); - GroupButtonsLayout->setAlignment( Qt::AlignTop ); - GroupButtonsLayout->setSpacing( 6 ); - GroupButtonsLayout->setMargin( 11 ); + QGroupBox* GroupButtons = new QGroupBox(this, "GroupButtons"); + GroupButtons->setColumnLayout(0, Qt::Vertical); + GroupButtons->layout()->setSpacing(0); + GroupButtons->layout()->setMargin(0); + QGridLayout* GroupButtonsLayout = new QGridLayout(GroupButtons->layout()); + GroupButtonsLayout->setAlignment(Qt::AlignTop); + GroupButtonsLayout->setSpacing(6); + GroupButtonsLayout->setMargin(11); /* Ok button */ - myButtonOk = new QPushButton( GroupButtons, "buttonOk" ); - myButtonOk->setText( tr("SMESH_BUT_OK") ); - myButtonOk->setAutoDefault( TRUE ); - myButtonOk->setDefault( TRUE ); - GroupButtonsLayout->addWidget( myButtonOk, 0, 0 ); + myButtonOk = new QPushButton(GroupButtons, "buttonOk"); + myButtonOk->setText(tr("SMESH_BUT_OK")); + myButtonOk->setAutoDefault(TRUE); + myButtonOk->setDefault(TRUE); + GroupButtonsLayout->addWidget(myButtonOk, 0, 0); /* add spacer between buttons */ - GroupButtonsLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 ); + GroupButtonsLayout->addItem(new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, 1); /* Cancel button */ - myButtonCancel = new QPushButton( GroupButtons, "buttonCancel" ); - myButtonCancel->setText( tr("SMESH_BUT_CANCEL") ); - myButtonCancel->setAutoDefault( TRUE ); - GroupButtonsLayout->addWidget( myButtonCancel, 0, 2 ); - + myButtonCancel = new QPushButton(GroupButtons, "buttonCancel"); + myButtonCancel->setText(tr("SMESH_BUT_CANCEL")); + myButtonCancel->setAutoDefault(TRUE); + GroupButtonsLayout->addWidget(myButtonCancel, 0, 2); + /***************************************************************/ - topLayout->addWidget( GroupC1, 0, 0); - topLayout->addWidget( GroupButtons, 1, 0); + topLayout->addWidget(GroupC1, 0, 0); + topLayout->addWidget(GroupButtons, 1, 0); /* signals and slots connections */ - connect( myButtonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); - connect( myButtonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); + connect(myButtonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(myButtonCancel, SIGNAL(clicked()), this, SLOT(reject())); /* Retrieve SMESHGUI */ - mySMESHGUI = SMESHGUI::GetSMESHGUI() ; + mySMESHGUI = SMESHGUI::GetSMESHGUI(); } - -//====================================================================================== +//====================================================================================== // function : ~SMESHGUI_aParameterDlg() // purpose : Destructor -//====================================================================================== -SMESHGUI_aParameterDlg::~SMESHGUI_aParameterDlg() +//====================================================================================== +SMESHGUI_aParameterDlg::~SMESHGUI_aParameterDlg() { } //======================================================================= //function : ClickOnOk -//purpose : +//purpose : //======================================================================= - void SMESHGUI_aParameterDlg::ClickOnOk() { - if ( !mySMESHGUI->ActiveStudyLocked() ) { - list::iterator paramIt = myParamList.begin(); - list::iterator widgetIt = mySpinList.begin(); - for ( ; + if (!mySMESHGUI->isActiveStudyLocked()) { + list::iterator paramIt = myParamList.begin(); + list::iterator widgetIt = mySpinList.begin(); + for (; paramIt != myParamList.end() && widgetIt != mySpinList.end(); - paramIt++ , widgetIt++ ) - (*paramIt)->TakeValue( *widgetIt ); + paramIt++ , widgetIt++) + (*paramIt)->TakeValue(*widgetIt); accept(); } } - //======================================================================= // function : Parameters() // purpose : return a list of parameters from a dialog box //======================================================================= -bool SMESHGUI_aParameterDlg::Parameters( list params, const char *aTitle) +bool SMESHGUI_aParameterDlg::Parameters (list params, + const char *aTitle) { - if ( !params.empty() ) { + if (!params.empty()) { SMESHGUI_aParameterDlg *Dialog = - new SMESHGUI_aParameterDlg(params, - QAD_Application::getDesktop(), - aTitle, - TRUE); + new SMESHGUI_aParameterDlg(params, SMESHGUI::desktop(), aTitle, TRUE); return (Dialog->exec() == QDialog::Accepted); } return false; diff --git a/src/SMESHGUI/SMESHGUI_aParameterDlg.h b/src/SMESHGUI/SMESHGUI_aParameterDlg.h index 0d7dcc399..7c9cd19aa 100644 --- a/src/SMESHGUI/SMESHGUI_aParameterDlg.h +++ b/src/SMESHGUI/SMESHGUI_aParameterDlg.h @@ -40,25 +40,24 @@ class QPushButton; class SMESHGUI; class QWidget; - //================================================================================= // class : SMESHGUI_aParameterDlg // purpose : //================================================================================= class SMESHGUI_aParameterDlg : public QDialog -{ +{ Q_OBJECT public: - SMESHGUI_aParameterDlg( std::list params, + SMESHGUI_aParameterDlg (std::list params, QWidget* parent = 0, QString title = QString::null, - bool modal = TRUE ); + bool modal = TRUE); ~SMESHGUI_aParameterDlg(); /* Parameter function */ - static bool Parameters( std::list params, const char *aTitle); + static bool Parameters (std::list params, const char *aTitle); protected: void init(); @@ -67,7 +66,7 @@ private slots: void ClickOnOk(); private: - SMESHGUI* mySMESHGUI ; + SMESHGUI* mySMESHGUI; QPushButton* myButtonOk; QPushButton* myButtonCancel; diff --git a/src/SMESHGUI/SMESH_images.po b/src/SMESHGUI/SMESH_images.po new file mode 100644 index 000000000..679a49c7f --- /dev/null +++ b/src/SMESHGUI/SMESH_images.po @@ -0,0 +1,328 @@ +# This is a Qt message file in .po format. Each msgid starts with +# a scope. This scope should *NOT* be translated - eg. "Foo::Bar" +# would be translated to "Pub", not "Foo::Pub". +msgid "" +msgstr "" +"Project-Id-Version: PROJECT VERSION\n" +"POT-Creation-Date: 2002-05-28 10:57:43 AM CEST\n" +"PO-Revision-Date: 2005-06-07 10:51+0400\n" +"Last-Translator: FULLNAME \n" +"Content-Type: text/plain; charset=iso-8859-1\n" + + +#----------------------------------------------------------- +# Divers Mesh +#----------------------------------------------------------- + +#ObjectBrowser Icon +msgid "ICON_OBJBROWSER_SMESH" +msgstr "mesh.png" + +#Select Icon +msgid "ICON_SELECT" +msgstr "select1.png" + +#Mesh Init +msgid "ICON_DLG_INIT_MESH" +msgstr "mesh_init.png" + +# +msgid "ICON_DLG_ADD_SUBMESH" +msgstr "mesh_add_sub.png" + +#Move Node +msgid "ICON_DLG_MOVE_NODE" +msgstr "mesh_move_node.png" + +#Remove Node +msgid "ICON_DLG_REM_NODE" +msgstr "mesh_rem_node.png" + +#Remove Element +msgid "ICON_DLG_REM_ELEMENT" +msgstr "mesh_rem_element.png" + +#Orientation +msgid "ICON_DLG_MESH_ORIENTATION" +msgstr "mesh_orientation.png" + +# +msgid "ICON_DLG_MESH_DIAGONAL" +msgstr "mesh_diagonal.png" + +#Connectivity +msgid "ICON_DLG_CONNECTIVITY" +msgstr "mesh_connectivity.png" + +#Smoothing +msgid "ICON_DLG_SMOOTHING" +msgstr "mesh_smoothing.png" + +#Renumbering nodes +msgid "ICON_DLG_RENUMBERING_NODES" +msgstr "mesh_renumbering_nodes.png" + +#Renumbering elements +msgid "ICON_DLG_RENUMBERING_ELEMENTS" +msgstr "mesh_renumbering_elements.png" + +#Rotation +msgid "ICON_DLG_ROTATION" +msgstr "mesh_rotation.png" + +#Translation by vector +msgid "ICON_SMESH_TRANSLATION_VECTOR" +msgstr "mesh_translation_vector.png" + +#Translation by two points +msgid "ICON_SMESH_TRANSLATION_POINTS" +msgstr "mesh_translation_points.png" + +#Symmetry by point +msgid "ICON_SMESH_SYMMETRY_POINT" +msgstr "mesh_symmetry_point.png" + +#Symmetry by axis +msgid "ICON_SMESH_SYMMETRY_AXIS" +msgstr "mesh_symmetry_axis.png" + +#Symmetry by plane +msgid "ICON_SMESH_SYMMETRY_PLANE" +msgstr "mesh_symmetry_plane.png" + +#Sew free borders +msgid "ICON_SMESH_SEWING_FREEBORDERS" +msgstr "mesh_sew_freeborders.png" + +#Sew conform free borders +msgid "ICON_SMESH_SEWING_CONFORM_FREEBORDERS" +msgstr "mesh_sew_conform_freeborders.png" + +#Sew border to side +msgid "ICON_SMESH_SEWING_BORDERTOSIDE" +msgstr "mesh_sew_bordertoside.png" + +#Sew side elements +msgid "ICON_SMESH_SEWING_SIDEELEMENTS" +msgstr "mesh_sew_sideelements.png" + +#Merge nodes +msgid "ICON_SMESH_MERGE_NODES" +msgstr "mesh_merge_nodes.png" + +#----------------------------------------------------------- +# Hypothesis +#----------------------------------------------------------- + +msgid "ICON_HYPO" +msgstr "mesh_hypo_length.png" + +#Set Algo +msgid "ICON_DLG_ADD_ALGORITHM" +msgstr "mesh_set_algo.png" + +#Set Hypo +msgid "ICON_DLG_ADD_HYPOTHESIS" +msgstr "mesh_set_hypo.png" + +#Edit Hypo. +msgid "ICON_DLG_EDIT_MESH" +msgstr "mesh_edit.png" + + +#----------------------------------------------------------- +# Elements +#----------------------------------------------------------- + +#Vertex +msgid "ICON_DLG_NODE" +msgstr "mesh_vertex.png" + +#Line +msgid "ICON_DLG_EDGE" +msgstr "mesh_line.png" + +#triangle +msgid "ICON_DLG_TRIANGLE" +msgstr "mesh_triangle.png" + +#Quadrangle +msgid "ICON_DLG_QUADRANGLE" +msgstr "mesh_quad.png" +#Polygone +msgid "ICON_DLG_POLYGON" +msgstr "mesh_polygon.png" +#triangle +msgid "ICON_DLG_TETRAS" +msgstr "mesh_tetra.png" + +#Quadrangle +msgid "ICON_DLG_HEXAS" +msgstr "mesh_hexa.png" + +#Polyhedre +msgid "ICON_DLG_POLYHEDRON" +msgstr "mesh_polyhedron.png" +#----------------------------------------------------------- +# ObjectBrowser +#----------------------------------------------------------- + +#mesh_tree_mesh +msgid "ICON_SMESH_TREE_MESH" +msgstr "mesh_tree_mesh.png" + +#mesh_tree_group +msgid "ICON_SMESH_TREE_GROUP" +msgstr "mesh_tree_group.png" + +#mesh_tree_algo +msgid "ICON_SMESH_TREE_ALGO" +msgstr "mesh_tree_algo.png" + +#mesh_tree_hypo +msgid "ICON_SMESH_TREE_HYPO" +msgstr "mesh_tree_hypo.png" + +#mesh_tree_mesh_warn +msgid "ICON_SMESH_TREE_MESH_WARN" +msgstr "mesh_tree_mesh_warn.png" + +#mesh_tree_mesh +msgid "ICON_SMESH_TREE_MESH_IMPORTED" +msgstr "mesh_tree_importedmesh.png" + + +#----------------------------------------------------------- +# Group +#----------------------------------------------------------- + +msgid "ICON_EDIT_GROUP" +msgstr "mesh_edit_group.png" + +msgid "ICON_CONSTRUCT_GROUP" +msgstr "mesh_make_group.png" + +#----------------------------------------------------------- +# Mesh pattern +#----------------------------------------------------------- + +msgid "ICON_PATTERN_2d" +msgstr "mesh_algo_mefisto.png" + +msgid "ICON_PATTERN_3d" +msgstr "mesh_algo_hexa.png" + +msgid "ICON_PATTERN_SAMPLE_2D" +msgstr "pattern_sample_2d.png" + +msgid "ICON_PATTERN_SAMPLE_3D" +msgstr "pattern_sample_3D.png" + +#----------------------------------------------------------- +# Add/Remove buttons +#----------------------------------------------------------- + +msgid "ICON_APPEND" +msgstr "mesh_add.png" + +msgid "ICON_REMOVE" + +msgid "ICON_DELETE" +msgstr "delete.png" + + +msgid "ICON_COMPUTE" +msgstr "mesh_compute.png" + +msgid "ICON_UNION" +msgstr "mesh_unionGroups.png" + +msgid "ICON_INTERSECT" +msgstr "mesh_intersectGroups.png" + +msgid "ICON_CUT" +msgstr "mesh_cutGroups.png" + +msgid "ICON_DEL_GROUP" +msgstr "mesh_deleteGroups.png" + +msgid "ICON_ADV_INFO" +msgstr "advanced_mesh_info.png" + +msgid "ICON_STD_INFO" +msgstr "standard_mesh_info.png" + +msgid "ICON_LENGTH" +msgstr "mesh_length.png" + +msgid "ICON_LENGTH_2D" +msgstr "mesh_length_2d.png" + +msgid "ICON_AREA" +msgstr "mesh_area.png" + +msgid "ICON_TAPER" +msgstr "mesh_taper.png" + +msgid "ICON_FREE_EDGE" +msgstr "mesh_free_edges.png" + +msgid "ICON_FREE_EDGE_2D" +msgstr "mesh_free_edges_2d.png" + +msgid "ICON_CONNECTION" +msgstr "mesh_multi_edges.png" + +msgid "ICON_CONNECTION_2D" +msgstr "mesh_multi_edges_2d.png" + +msgid "ICON_WIRE" +msgstr "mesh_wireframe.png" + +msgid "ICON_SHADE" +msgstr "mesh_shading.png" + +msgid "ICON_SHRINK" +msgstr "mesh_shrink.png" + +msgid "ICON_POINTS" +msgstr "mesh_points.png" + +msgid "ICON_ASPECT" +msgstr "mesh_aspect.png" + +msgid "ICON_ASPECT_3D" +msgstr "mesh_aspect_3d.png" + +msgid "ICON_ANGLE" +msgstr "mesh_angle.png" + +msgid "ICON_WRAP" +msgstr "mesh_wrap.png" + +msgid "ICON_SKEW" +msgstr "mesh_skew.png" + +msgid "ICON_UPDATE" +msgstr "mesh_update.png" + +msgid "ICON_UNIONTRI" +msgstr "mesh_uniontri.png" + +msgid "ICON_UNION2TRI" +msgstr "mesh_union2tri.png" + +msgid "ICON_CUTQUAD" +msgstr "mesh_cutquad.png" + +msgid "ICON_EXTRUSION" +msgstr "mesh_extrusion.png" + +msgid "ICON_EXTRUSION_ALONG" +msgstr "mesh_extrusionpath.png" + +msgid "ICON_REVOLUTION" +msgstr "mesh_revolution.png" + +msgid "ICON_MAP" +msgstr "mesh_pattern.png" diff --git a/src/SMESHGUI/SMESH_msg_en.po b/src/SMESHGUI/SMESH_msg_en.po index a58c6a758..3ed799abe 100644 --- a/src/SMESHGUI/SMESH_msg_en.po +++ b/src/SMESHGUI/SMESH_msg_en.po @@ -1600,7 +1600,7 @@ msgstr "Detect" msgid "SMESHGUI_MergeNodesDlg::SELECT_ALL" msgstr "Select all" -# Edit group of nodes +# Edit group of nodes msgid "SMESHGUI_MergeNodesDlg::EDIT_GROUP_OF_NODES" msgstr "Edit group of nodes" @@ -1770,17 +1770,861 @@ msgstr "There are objects selected which do not belong to %1 component." +#----------- Menu bar ----------# +#------ MEN -----# +msgid "MEN_DAT" +msgstr "DAT file" + +msgid "MEN_UNV" +msgstr "UNV file" + +msgid "MEN_MED" +msgstr "MED file" + +msgid "MEN_EXPORT_DAT" +msgstr "Export to DAT file" + +msgid "MEN_EXPORT_UNV" +msgstr "Export to UNV file" + +msgid "MEN_EXPORT_MED" +msgstr "Export to MED file" + +msgid "MEN_DELETE" +msgstr "Delete" + +msgid "MEN_SEL_FILTER_LIB" +msgstr "Selection filters library" + +msgid "MEN_CREATE_HYPO" +msgstr "Create Hypotheses" + +msgid "MEN_CREATE_ALG" +msgstr "Create Algorithms" + +msgid "MEN_COMPUTE" +msgstr "Compute" + +msgid "MEN_LOCAL_HYPO" +msgstr "Local Hypothesis" + +msgid "MEN_GLOBAL_HYPO" +msgstr "Global Hypothesis" + +msgid "MEN_EDIT" +msgstr "Edit" + +msgid "MEN_EDIT_GLOBAL_HYPO" +msgstr "Edit Global Hypothesis" + +msgid "MEN_EDIT_LOCAL_HYPO" +msgstr "Edit Local Hypothesis" + +msgid "MEN_EDIT_HYPO" +msgstr "Edit Hypothesis" + +msgid "MEN_CREATE_GROUP" +msgstr "Create Group" + +msgid "MEN_CONSTRUCT_GROUP" +msgstr "Construct Group" + +msgid "MEN_EDIT_GROUP" +msgstr "Edit Group" + +msgid "MEN_UN_GROUP" +msgstr "Union Groups" + +msgid "MEN_INT_GROUP" +msgstr "Intersect Groups" + +msgid "MEN_CUT_GROUP" +msgstr "Cut Groups" + +msgid "MEN_DEL_GROUP" +msgstr "Delete Groups" + +msgid "MEN_ADV_INFO" +msgstr "Advanced Mesh Infos" + +msgid "MEN_STD_INFO" +msgstr "Standard Mesh Infos" + +msgid "MEN_LENGTH" +msgstr "Length" + +msgid "MEN_FREE_EDGE" +msgstr "Free Edges" + +msgid "MEN_FREE_BORDER" +msgstr "Free Borders" + +msgid "MEN_CONNECTION" +msgstr "Borders at Multi-Connection" + +msgid "MEN_AREA" +msgstr "Area" + +msgid "MEN_TAPER" +msgstr "Taper" + +msgid "MEN_ASPECT" +msgstr "Aspect Ratio" + +msgid "MEN_MIN_ANG" +msgstr "Minimum Angle" + +msgid "MEN_WRAP" +msgstr "Wraping" + +msgid "MEN_SKEW" +msgstr "Skew" + +msgid "MEN_ASPECT_3D" +msgstr "Aspect Ratio 3D" + +msgid "MEN_LENGTH_2D" +msgstr "Length 2D" + +msgid "MEN_CONNECTION_2D" +msgstr "Borders at Multi-Connection 2D" + +msgid "MEN_NODE" +msgstr "Node" + +msgid "MEN_EDGE" +msgstr "Edge" + +msgid "MEN_TRIANGLE" +msgstr "Triangle" + +msgid "MEN_QUAD" +msgstr "Quadrangle" + +msgid "MEN_TETRA" +msgstr "Tetrahedron" + +msgid "MEN_HEXA" +msgstr "Hexahedron" + +msgid "MEN_NODES" +msgstr "Nodes" + +msgid "MEN_ELEMENTS" +msgstr "Elements" + +msgid "MEN_TRANS" +msgstr "Translation" + +msgid "MEN_ROT" +msgstr "Rotation" + +msgid "MEN_SYM" +msgstr "Symmetry" + +msgid "MEN_SEW" +msgstr "Sewing" + +msgid "MEN_MERGE" +msgstr "Merge nodes" + +msgid "MEN_MOVE" +msgstr "Move Node" + +msgid "MEN_INV" +msgstr "Diagonal Inversion" + +msgid "MEN_UNION2" +msgstr "Union of two triangles" + +msgid "MEN_ORIENT" +msgstr "Orientation" + +msgid "MEN_UNION" +msgstr "Union of triangles" + +msgid "MEN_CUT" +msgstr "Cutting of quadrangles" + +msgid "MEN_SMOOTH" +msgstr "Smoothing" + +msgid "MEN_EXTRUSION" +msgstr "Extrusion" + +msgid "MEN_REVOLUTION" +msgstr "Revolution" + +msgid "MEN_MAP" +msgstr "Pattern mapping" + +msgid "MEN_EXTRUSION_ALONG" +msgstr "Extrusion along a path" + +msgid "MEN_WIRE" +msgstr "Wireframe" + +msgid "MEN_SHADE" +msgstr "Shading" + +msgid "MEN_SHRINK" +msgstr "Shrink" + +msgid "MEN_AUTO_UPD" +msgstr "Automatic update" + +msgid "MEN_COLORS" +msgstr "Colors / Size" + +msgid "MEN_SCALAR_BAR" +msgstr "Scalar bar" + +msgid "MEN_SELECTION" +msgstr "Selection" + +msgid "MEN_PRECISION" +msgstr "Precision" + +msgid "MEN_DISP_ENT" +msgstr "Display entity" + +msgid "MEN_UPDATE" +msgstr "Update" + +msgid "MEN_FILE" +msgstr "File" + +msgid "MEN_TOOLS" +msgstr "Tools" + +msgid "MEN_HYPO" +msgstr "Hypotheses" + +msgid "MEN_MESH" +msgstr "Mesh" + +msgid "MEN_CTRL" +msgstr "Controls" + +msgid "MEN_MODIFY" +msgstr "Modification" + +msgid "MEN_PREF" +msgstr "Preferences" + +msgid "MEN_VIEW" +msgstr "View" + +msgid "MEN_IMPORT" +msgstr "Import" + +msgid "MEN_EXPORT" +msgstr "Export" + +msgid "MEN_ADD" +msgstr "Add" + +msgid "MEN_REMOVE" +msgstr "Remove" + +msgid "MEN_RENUM" +msgstr "Renumbering" + +msgid "MEN_NUM" +msgstr "Numbering" + +msgid "MEN_TRANSF" +msgstr "Transformation" + +msgid "MEN_DISPMODE" +msgstr "Display mode" + +msgid "MEN_QUALITY" +msgstr "Quality controls" + +msgid "MEN_RENAME" +msgstr "Rename" + +msgid "MEN_NUM_NODES" +msgstr "Display Nodes #" + +msgid "MEN_NUM_ELEMENTS" +msgstr "Display Elements #" + +msgid "MEN_RESET" +msgstr "Reset" + +msgid "MEN_SCALAR_BAR_PROP" +msgstr "Scalar bar Properties" + +msgid "MEN_EDGES" +msgstr "Edges" + +msgid "MEN_FACES" +msgstr "Faces" + +msgid "MEN_VOLUMES" +msgstr "Volumes" + +msgid "MEN_ALL" +msgstr "All" + +msgid "MEN_TRANSP" +msgstr "Transparency" + +msgid "MEN_CLIP" +msgstr "Clipping" + +msgid "MEN_DISPLAY" +msgstr "Display" + +msgid "MEN_ERASE" +msgstr "Erase" + +msgid "MEN_DISPLAY_ONLY" +msgstr "Display only" + + +#------ TOP -----# +msgid "TOP_DAT" +msgstr "Import DAT file" + +msgid "TOP_UNV" +msgstr "Import UNV file" + +msgid "TOP_MED" +msgstr "Import MED file" + +msgid "TOP_EXPORT_DAT" +msgstr "Export to DAT file" + +msgid "TOP_EXPORT_UNV" +msgstr "Export to UNV file" + +msgid "TOP_EXPORT_MED" +msgstr "Export to MED file" + +msgid "TOP_DELETE" +msgstr "Delete" + +msgid "TOP_SEL_FILTER_LIB" +msgstr "Selection filters library" + +msgid "TOP_CREATE_HYPO" +msgstr "Create Hypotheses" + +msgid "TOP_CREATE_ALG" +msgstr "Create Algorithms" + +msgid "TOP_COMPUTE" +msgstr "Compute" + +msgid "TOP_LOCAL_HYPO" +msgstr "Local Hypothesis" + +msgid "TOP_GLOBAL_HYPO" +msgstr "Global Hypothesis" + +msgid "TOP_EDIT_GLOBAL_HYPO" +msgstr "Edit Global Hypothesis" + +msgid "TOP_EDIT_LOCAL_HYPO" +msgstr "Edit Local Hypothesis" + +msgid "TOP_EDIT_HYPO" +msgstr "Edit Hypothesis" + +msgid "TOP_CREATE_GROUP" +msgstr "Create Group" + +msgid "TOP_CONSTRUCT_GROUP" +msgstr "Construct Group" + +msgid "TOP_EDIT_GROUP" +msgstr "Edit Group" + +msgid "TOP_UN_GROUP" +msgstr "Union Groups" + +msgid "TOP_INT_GROUP" +msgstr "Intersect Groups" + +msgid "TOP_CUT_GROUP" +msgstr "Cut Groups" + +msgid "TOP_DEL_GROUP" +msgstr "Delete Groups" + +msgid "TOP_ADV_INFO" +msgstr "Advanced Mesh Infos" + +msgid "TOP_STD_INDO" +msgstr "Standard Mesh Infos" + +msgid "TOP_LENGTH" +msgstr "Length" + +msgid "TOP_FREE_EDGE" +msgstr "Free Edges" + +msgid "TOP_FREE_BORDER" +msgstr "Free Borders" + +msgid "TOP_CONNECTION" +msgstr "Borders at Multi-Connection" + +msgid "TOP_AREA" +msgstr "Area" + +msgid "TOP_TAPER" +msgstr "Taper" + +msgid "TOP_ASPECT" +msgstr "Aspect Ratio" + +msgid "TOP_MIN_ANG" +msgstr "Minimum Angle" + +msgid "TOP_WARP" +msgstr "Wraping" + +msgid "TOP_SKEW" +msgstr "Skew" + +msgid "TOP_ASPECT_3D" +msgstr "Aspect Ratio 3D" + +msgid "TOP_LENGTH_2D" +msgstr "Length 2D" + +msgid "TOP_CONNECTION_2D" +msgstr "Borders at Multi-Connection 2D" + +msgid "TOP_NODE" +msgstr "Node" + +msgid "TOP_EDGE" +msgstr "Edge" + +msgid "TOP_TRIANGLE" +msgstr "Triangle" + +msgid "TOP_QUAD" +msgstr "Quadrangle" + +msgid "TOP_TETRA" +msgstr "Tetrahedron" + +msgid "TOP_HEXA" +msgstr "Hexahedron" + +msgid "TOP_NODES" +msgstr "Nodes" + +msgid "TOP_ELEMENTS" +msgstr "Elements" + +msgid "TOP_TRANS" +msgstr "Translation" + +msgid "TOP_ROT" +msgstr "Rotation" + +msgid "TOP_SYM" +msgstr "Symmetry" + +msgid "TOP_SEW" +msgstr "Sewing" + +msgid "TOP_MERGE" +msgstr "Merge nodes" + +msgid "TOP_MOVE" +msgstr "Move Node" + +msgid "TOP_INV" +msgstr "Diagonal Inversion" + +msgid "TOP_UNION2" +msgstr "Union of two triangles" + +msgid "TOP_ORIENT" +msgstr "Orientation" + +msgid "TOP_UNION" +msgstr "Union of triangles" + +msgid "TOP_CUT" +msgstr "Cutting of quadrangles" + +msgid "TOP_SMOOTH" +msgstr "Smoothing" + +msgid "TOP_EXTRUSION" +msgstr "Extrusion" + +msgid "TOP_REVOLUTION" +msgstr "Revolution" + +msgid "TOP_MAP" +msgstr "Pattern mapping" + +msgid "TOP_EXTRUSION_ALONG" +msgstr "Extrusion along a path" + +msgid "TOP_WIRE" +msgstr "Wireframe" + +msgid "TOP_SHADE" +msgstr "Shading" + +msgid "TOP_SHRINK" +msgstr "Shrink" + +msgid "TOP_AUTO_UPD" +msgstr "Automatic update" + +msgid "TOP_COLORS" +msgstr "Colors / Size" + +msgid "TOP_SCALAR_BAR" +msgstr "Scalar bar" + +msgid "TOP_SELECTION" +msgstr "Selection" + +msgid "TOP_PRECISION" +msgstr "Precision" + +msgid "TOP_DISP_ENT" +msgstr "Display entity" + +msgid "TOP_UPDATE" +msgstr "Update" + +msgid "TOP_RENAME" +msgstr "Rename" + +msgid "TOP_NUM_NODES" +msgstr "Display Nodes" + +msgid "TOP_NUM_ELEMENTS" +msgstr "Display Elements" + +msgid "TOP_RESET" +msgstr "Reset" + +msgid "TOP_SCALAR_BAR_PROP" +msgstr "Scalar bar Properties" + +msgid "TOP_EDGES" +msgstr "Edges" + +msgid "TOP_FACES" +msgstr "Faces" + +msgid "TOP_VOLUMES" +msgstr "Volumes" + +msgid "TOP_ALL" +msgstr "All" + +msgid "TOP_TRANSP" +msgstr "Transparency" + +msgid "TOP_CLIP" +msgstr "Clipping" + +msgid "TOP_DISPLAY" +msgstr "Display" + +msgid "TOP_ERASE" +msgstr "Erase" + +msgid "TOP_DISPLAY_ONLY" +msgstr "Display only" + + + + +#------ STB -----# +msgid "STB_DAT" +msgstr "Import DAT file" + +msgid "STB_UNV" +msgstr "Import UNV file" + +msgid "STB_MED" +msgstr "Import MED file" + +msgid "STB_EXPORT_DAT" +msgstr "Export to DAT file" + +msgid "STB_EXPORT_UNV" +msgstr "Export to UNV file" + +msgid "STB_EXPORT_MED" +msgstr "Export to MED file" + +msgid "STB_DELETE" +msgstr "Delete" + +msgid "STB_SEL_FILTER_LIB" +msgstr "Selection filters library" + +msgid "STB_CREATE_HYPO" +msgstr "Create Hypotheses" + +msgid "STB_CREATE_ALG" +msgstr "Create Algorithms" + +msgid "STB_COMPUTE" +msgstr "Compute" + +msgid "STB_LOCAL_HYPO" +msgstr "Local Hypothesis" + +msgid "STB_GLOBAL_HYPO" +msgstr "Global Hypothesis" + +msgid "STB_EDIT_HYPO" +msgstr "Edit Hypothesis" + +msgid "STB_CREATE_GROUP" +msgstr "Create Group" + +msgid "STB_CONSTRUCT_GROUP" +msgstr "Construct Group" + +msgid "STB_EDIT_GROUP" +msgstr "Edit Group" + +msgid "STB_UN_GROUP" +msgstr "Union Groups" + +msgid "STB_INT_GROUP" +msgstr "Intersect Groups" + +msgid "STB_CUT_GROUP" +msgstr "Cut Groups" + +msgid "STB_DEL_GROUP" +msgstr "Delete Groups" + +msgid "STB_ADV_INFO" +msgstr "Advanced Mesh Infos" + +msgid "STB_STD_INDO" +msgstr "Standard Mesh Infos" + +msgid "STB_LENGTH" +msgstr "Length" + +msgid "STB_FREE_EDGE" +msgstr "Free Edges" + +msgid "STB_FREE_BORDER" +msgstr "Free Borders" + +msgid "STB_CONNECTION" +msgstr "Borders at Multi-Connection" + +msgid "STB_AREA" +msgstr "Area" + +msgid "STB_TAPER" +msgstr "Taper" + +msgid "STB_ASPECT" +msgstr "Aspect Ratio" + +msgid "STB_MIN_ANG" +msgstr "Minimum Angle" + +msgid "STB_WARP" +msgstr "Wraping" + +msgid "STB_SKEW" +msgstr "Skew" + +msgid "STB_ASPECT_3D" +msgstr "Aspect Ratio 3D" + +msgid "STB_LENGTH_2D" +msgstr "Length 2D" + +msgid "STB_CONNECTION_2D" +msgstr "Borders at Multi-Connection 2D" + +msgid "STB_NODE" +msgstr "Node" + +msgid "STB_EDGE" +msgstr "Edge" + +msgid "STB_TRIANGLE" +msgstr "Triangle" + +msgid "STB_QUAD" +msgstr "Quadrangle" + +msgid "STB_TETRA" +msgstr "Tetrahedron" + +msgid "STB_HEXA" +msgstr "Hexahedron" + +msgid "STB_NODES" +msgstr "Nodes" + +msgid "STB_ELEMENTS" +msgstr "Elements" + +msgid "STB_TRANS" +msgstr "Translation" + +msgid "STB_ROT" +msgstr "Rotation" + +msgid "STB_SYM" +msgstr "Symmetry" + +msgid "STB_SEW" +msgstr "Sewing" + +msgid "STB_MERGE" +msgstr "Merge nodes" + +msgid "STB_MOVE" +msgstr "Move Node" + +msgid "STB_INV" +msgstr "Diagonal Inversion" + +msgid "STB_UNION2" +msgstr "Union of two triangles" + +msgid "STB_ORIENT" +msgstr "Orientation" + +msgid "STB_UNION" +msgstr "Union of triangles" + +msgid "STB_CUT" +msgstr "Cutting of quadrangles" + +msgid "STB_SMOOTH" +msgstr "Smoothing" + +msgid "STB_EXTRUSION" +msgstr "Extrusion" + +msgid "STB_REVOLUTION" +msgstr "Revolution" + +msgid "STB_MAP" +msgstr "Pattern mapping" + +msgid "STB_EXTRUSION_ALONG" +msgstr "Extrusion along a path" + +msgid "STB_WIRE" +msgstr "Wireframe" + +msgid "STB_SHADE" +msgstr "Shading" + +msgid "STB_SHRINK" +msgstr "Shrink" + +msgid "STB_AUTO_UPD" +msgstr "Automatic update" + +msgid "STB_COLORS" +msgstr "Colors / Size" + +msgid "STB_SCALAR_BAR" +msgstr "Scalar bar" + +msgid "STB_SELECTION" +msgstr "Selection" + +msgid "STB_PRECISION" +msgstr "Precision" + +msgid "STB_DISP_ENT" +msgstr "Display entity" + +msgid "STB_UPDATE" +msgstr "Update" + +msgid "STB_EDIT_GLOBAL_HYPO" +msgstr "Edit Global Hypothesis" + +msgid "STB_EDIT_LOCAL_HYPO" +msgstr "Edit Local Hypothesis" + +msgid "STB_RENAME" +msgstr "Rename" + +msgid "STB_NUM_NODES" +msgstr "Display Nodes" + +msgid "STB_NUM_ELEMENTS" +msgstr "Display Elements" + +msgid "STB_RESET" +msgstr "Reset" + +msgid "STB_SCALAR_BAR_PROP" +msgstr "Scalar bar Properties" + +msgid "STB_EDGES" +msgstr "Edges" + +msgid "STB_FACES" +msgstr "Faces" + +msgid "STB_VOLUMES" +msgstr "Volumes" + +msgid "STB_ALL" +msgstr "All" + +msgid "STB_TRANSP" +msgstr "Transparency" + +msgid "STB_CLIP" +msgstr "Clipping" + +msgid "STB_DISPLAY" +msgstr "Display" + +msgid "STB_ERASE" +msgstr "Erase" + +msgid "STB_DISPLAY_ONLY" +msgstr "Display only" +msgid "TB_MESH" +msgstr "Mesh Toolbar" +msgid "TB_HYPO" +msgstr "Hypotheses Toolbar" +msgid "TB_CTRL" +msgstr "Controls Toolbar" +msgid "TB_ADD_REMOVE" +msgstr "Add/Remove Toolbar" +msgid "TB_MODIFY" +msgstr "Modification Toolbar" - - - +msgid "TB_DISP_MODE" +msgstr "Display Mode Toolbar" diff --git a/src/SMESH_I/Makefile.in b/src/SMESH_I/Makefile.in index 700a10d33..af407e6e9 100644 --- a/src/SMESH_I/Makefile.in +++ b/src/SMESH_I/Makefile.in @@ -56,6 +56,7 @@ LIB= libSMESHEngine.la LIB_SRC = \ SMESH_Gen_i.cxx \ SMESH_Gen_i_1.cxx \ + SMESH_DumpPython.cxx \ SMESH_Mesh_i.cxx \ SMESH_MEDMesh_i.cxx \ SMESH_MEDFamily_i.cxx \ diff --git a/src/SMESH_I/SMESH_DumpPython.cxx b/src/SMESH_I/SMESH_DumpPython.cxx new file mode 100644 index 000000000..016e21639 --- /dev/null +++ b/src/SMESH_I/SMESH_DumpPython.cxx @@ -0,0 +1,683 @@ +// File : SMESH_Gen_i_DumpPython.cxx +// Created : Thu Mar 24 17:17:59 2005 +// Author : Julia DOROVSKIKH +// Module : SMESH +// $Header : $ + +#include "SMESH_PythonDump.hxx" +#include "SMESH_Gen_i.hxx" +#include "SMESH_Filter_i.hxx" + +#include +#include + + +#ifdef _DEBUG_ +static int MYDEBUG = 0; +#else +static int MYDEBUG = 0; +#endif + +static TCollection_AsciiString NotPublishedObjectName() +{ + return "__NOT__Published__Object__"; +} + +namespace SMESH +{ + + size_t TPythonDump::myCounter = 0; + + TPythonDump:: + TPythonDump() + { + ++myCounter; + } + TPythonDump:: + ~TPythonDump() + { + if(--myCounter == 0){ + SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen(); + SALOMEDS::Study_ptr aStudy = aSMESHGen->GetCurrentStudy(); + if(!aStudy->_is_nil()){ + std::string aString = myStream.str(); + TCollection_AsciiString aCollection(Standard_CString(aString.c_str())); + aSMESHGen->AddToPythonScript(aStudy->StudyId(),aCollection); + if(MYDEBUG) MESSAGE(aString); + } + } + } + + TPythonDump& + TPythonDump:: + operator<<(long int theArg){ + myStream<GetCurrentStudy(); + SALOMEDS::SObject_var aSObject = SMESH_Gen_i::ObjectToSObject(aStudy,theArg); + if(!aSObject->_is_nil()){ + aString = aSObject->GetID(); + }else if(!CORBA::is_nil(theArg)){ + aString = "smeshObj_"; + if ( aSMESHGen->CanPublishInStudy( theArg )) // not published SMESH object + aString += (int) theArg; + else + aString = NotPublishedObjectName(); + } + myStream<GetFunctorType(); + switch(aFunctorType){ + case FT_AspectRatio: + myStream<<"anAspectRatio"; + break; + case FT_AspectRatio3D: + myStream<<"anAspectRatio3D"; + break; + case FT_Warping: + myStream<<"aWarping"; + break; + case FT_MinimumAngle: + myStream<<"aMinimumAngle"; + break; + case FT_Taper: + myStream<<"aTaper"; + break; + case FT_Skew: + myStream<<"aSkew"; + break; + case FT_Area: + myStream<<"aArea"; + break; + case FT_FreeBorders: + myStream<<"aFreeBorders"; + break; + case FT_FreeEdges: + myStream<<"aFreeEdges"; + break; + case FT_MultiConnection: + myStream<<"aMultiConnection"; + break; + case FT_MultiConnection2D: + myStream<<"aMultiConnection2D"; + break; + case FT_Length: + myStream<<"aLength"; + break; + case FT_Length2D: + myStream<<"aLength"; + break; + case FT_BelongToGeom: + myStream<<"aBelongToGeom"; + break; + case FT_BelongToPlane: + myStream<<"aBelongToPlane"; + break; + case FT_BelongToCylinder: + myStream<<"aBelongToCylinder"; + break; + case FT_LyingOnGeom: + myStream<<"aLyingOnGeom"; + break; + case FT_RangeOfIds: + myStream<<"aRangeOfIds"; + break; + case FT_BadOrientedVolume: + myStream<<"aBadOrientedVolume"; + break; + case FT_LessThan: + myStream<<"aLessThan"; + break; + case FT_MoreThan: + myStream<<"aMoreThan"; + break; + case FT_EqualTo: + myStream<<"anEqualTo"; + break; + case FT_LogicalNOT: + myStream<<"aLogicalNOT"; + break; + case FT_LogicalAND: + myStream<<"aLogicalAND"; + break; + case FT_LogicalOR: + myStream<<"aLogicalOR"; + break; + case FT_Undefined: + myStream<<"anUndefined"; + break; + } + myStream<FindComponent(ComponentDataType()); + if (CORBA::is_nil(aSO)) + return new Engines::TMPFile(0); + + // Map study entries to object names + Resource_DataMapOfAsciiStringAsciiString aMap; + Resource_DataMapOfAsciiStringAsciiString aMapNames; + TCollection_AsciiString s ("qwertyuioplkjhgfdsazxcvbnmQWERTYUIOPLKJHGFDSAZXCVBNM0987654321_"); + + SALOMEDS::ChildIterator_var Itr = aStudy->NewChildIterator(aSO); + for (Itr->InitEx(true); Itr->More(); Itr->Next()) { + SALOMEDS::SObject_var aValue = Itr->Value(); + CORBA::String_var anID = aValue->GetID(); + CORBA::String_var aName = aValue->GetName(); + TCollection_AsciiString aGUIName ( (char*) aName.in() ); + TCollection_AsciiString anEnrty ( (char*) anID.in() ); + if (aGUIName.Length() > 0) { + aMapNames.Bind( anEnrty, aGUIName ); + aMap.Bind( anEnrty, aGUIName ); + } + } + + // Get trace of restored study + //SALOMEDS::SObject_var aSO = SMESH_Gen_i::ObjectToSObject(theStudy, _this()); + SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); + SALOMEDS::GenericAttribute_var anAttr = + aStudyBuilder->FindOrCreateAttribute(aSO, "AttributePythonObject"); + + char* oldValue = SALOMEDS::AttributePythonObject::_narrow(anAttr)->GetObject(); + TCollection_AsciiString aSavedTrace (oldValue); + + // Add trace of API methods calls and replace study entries by names + //TCollection_AsciiString aScript = + // SALOMEDSImpl_Study::GetDumpStudyComment("SMESH") + "\n\n" + + // DumpPython_impl(aStudy->StudyId(), aMap, aMapNames, isPublished, isValidScript, aSavedTrace); + TCollection_AsciiString aScript = + "### This file is generated by SALOME automatically by dump python functionality of SMESH component\n\n"; + aScript += DumpPython_impl(aStudy->StudyId(), aMap, aMapNames, + isPublished, isValidScript, aSavedTrace); + + int aLen = aScript.Length(); + unsigned char* aBuffer = new unsigned char[aLen+1]; + strcpy((char*)aBuffer, aScript.ToCString()); + + CORBA::Octet* anOctetBuf = (CORBA::Octet*)aBuffer; + Engines::TMPFile_var aStreamFile = new Engines::TMPFile(aLen+1, aLen+1, anOctetBuf, 1); + + bool hasNotPublishedObjects = aScript.Location( NotPublishedObjectName(), 1, aLen); + isValidScript = isValidScript && !hasNotPublishedObjects; + + return aStreamFile._retn(); +} + +//============================================================================= +/*! + * AddToPythonScript + */ +//============================================================================= +void SMESH_Gen_i::AddToPythonScript (int theStudyID, const TCollection_AsciiString& theString) +{ + if (myPythonScripts.find(theStudyID) == myPythonScripts.end()) { + myPythonScripts[theStudyID] = new TColStd_HSequenceOfAsciiString; + } + myPythonScripts[theStudyID]->Append(theString); +} + +//============================================================================= +/*! + * RemoveLastFromPythonScript + */ +//============================================================================= +void SMESH_Gen_i::RemoveLastFromPythonScript (int theStudyID) +{ + if (myPythonScripts.find(theStudyID) != myPythonScripts.end()) { + int aLen = myPythonScripts[theStudyID]->Length(); + myPythonScripts[theStudyID]->Remove(aLen); + } +} + +//======================================================================= +//function : AddToCurrentPyScript +//purpose : +//======================================================================= + +void SMESH_Gen_i::AddToCurrentPyScript (const TCollection_AsciiString& theString) +{ + SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen(); + SALOMEDS::Study_ptr aStudy = aSMESHGen->GetCurrentStudy(); + if (aStudy->_is_nil()) return; + aSMESHGen->AddToPythonScript(aStudy->StudyId(), theString); +} + + +//======================================================================= +//function : AddObject +//purpose : add object to script string +//======================================================================= + +TCollection_AsciiString& SMESH_Gen_i::AddObject(TCollection_AsciiString& theStr, + CORBA::Object_ptr theObject) +{ + TCollection_AsciiString aString("None"); + SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen(); + SALOMEDS::SObject_var aSObject = + aSMESHGen->ObjectToSObject(aSMESHGen->GetCurrentStudy(), theObject); + if ( !aSObject->_is_nil() ) { + aString = aSObject->GetID(); + } else if ( !CORBA::is_nil( theObject )) { + aString = "smeshObj_"; + if ( aSMESHGen->CanPublishInStudy( theObject )) // not published SMESH object + aString += (int) theObject; + else + aString = NotPublishedObjectName(); + } + theStr += aString; + return theStr; +} + +//======================================================================= +//function : SavePython +//purpose : +//======================================================================= +void SMESH_Gen_i::SavePython (SALOMEDS::Study_ptr theStudy) +{ + // Dump trace of API methods calls + TCollection_AsciiString aScript = GetNewPythonLines(theStudy->StudyId()); + + // Check contents of PythonObject attribute + SALOMEDS::SObject_var aSO = theStudy->FindComponent(ComponentDataType()); + //SALOMEDS::SObject_var aSO = SMESH_Gen_i::ObjectToSObject(theStudy, _this()); + SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder(); + SALOMEDS::GenericAttribute_var anAttr = + aStudyBuilder->FindOrCreateAttribute(aSO, "AttributePythonObject"); + + char* oldValue = SALOMEDS::AttributePythonObject::_narrow(anAttr)->GetObject(); + TCollection_AsciiString oldScript (oldValue); + + if (oldScript.Length() > 0) { + oldScript += "\n"; + oldScript += aScript; + } else { + oldScript = aScript; + } + + // Store in PythonObject attribute + SALOMEDS::AttributePythonObject::_narrow(anAttr)->SetObject(oldScript.ToCString(), 1); + + // Clean trace of API methods calls + CleanPythonTrace(theStudy->StudyId()); +} + + +// impl + + +//============================================================================= +/*! + * FindEntries: Returns a sequence of start/end positions of entries in the string + */ +//============================================================================= +Handle(TColStd_HSequenceOfInteger) FindEntries (TCollection_AsciiString& theString) +{ + Handle(TColStd_HSequenceOfInteger) aSeq = new TColStd_HSequenceOfInteger; + Standard_Integer aLen = theString.Length(); + Standard_Boolean isFound = Standard_False; + + char* arr = theString.ToCString(); + Standard_Integer i = 0, j; + + while(i < aLen) { + int c = (int)arr[i]; + j = i+1; + if(c >= 48 && c <= 57) { //Is digit? + + isFound = Standard_False; + while((j < aLen) && ((c >= 48 && c <= 57) || c == 58) ) { //Check if it is an entry + c = (int)arr[j++]; + if(c == 58) isFound = Standard_True; + } + + if (isFound) { + int prev = (i < 1) ? 0 : (int)arr[i - 1]; + // last char should be a diggit, + // previous char should not be '"'. + if (arr[j-2] != 58 && prev != 34) { + aSeq->Append(i+1); // +1 because AsciiString starts from 1 + aSeq->Append(j-1); + } + } + } + + i = j; + } + + return aSeq; +} + +//============================================================================= +/*! + * DumpPython + */ +//============================================================================= +TCollection_AsciiString SMESH_Gen_i::DumpPython_impl + (int theStudyID, + Resource_DataMapOfAsciiStringAsciiString& theObjectNames, + Resource_DataMapOfAsciiStringAsciiString& theNames, + bool isPublished, + bool& aValidScript, + const TCollection_AsciiString& theSavedTrace) +{ + TCollection_AsciiString aScript; + aScript = "def RebuildData(theStudy):"; + aScript += "\n\tsmesh = salome.lcc.FindOrLoadComponent(\"FactoryServer\", \"SMESH\")"; + aScript += "\n\taFilterManager = smesh.CreateFilterManager()"; + if ( isPublished ) + aScript += "\n\tsmesh.SetCurrentStudy(theStudy)"; + else + aScript += "\n\tsmesh.SetCurrentStudy(None)"; + + // Dump trace of restored study + if (theSavedTrace.Length() > 0) { + aScript += "\n"; + aScript += theSavedTrace; + } + + // Dump trace of API methods calls + TCollection_AsciiString aNewLines = GetNewPythonLines(theStudyID); + if (aNewLines.Length() > 0) { + aScript += "\n"; + aScript += aNewLines; + } + + // Find entries to be replaced by names + Handle(TColStd_HSequenceOfInteger) aSeq = FindEntries(aScript); + Standard_Integer aLen = aSeq->Length(); + + if (aLen == 0) + return aScript; + + // Replace entries by the names + GEOM::GEOM_Gen_ptr geom = GetGeomEngine(); + TColStd_SequenceOfAsciiString seqRemoved; + Resource_DataMapOfAsciiStringAsciiString mapRemoved; + Standard_Integer objectCounter = 0, aStart = 1, aScriptLength = aScript.Length(); + TCollection_AsciiString anUpdatedScript, anEntry, aName, aBaseName("smeshObj_"), + allowedChars ("qwertyuioplkjhgfdsazxcvbnmQWERTYUIOPLKJHGFDSAZXCVBNM0987654321_"); + + // Collect names of GEOM objects to exclude same names for SMESH objects + GEOM::string_array_var aGeomNames = geom->GetAllDumpNames(); + int ign = 0, nbgn = aGeomNames->length(); + for (; ign < nbgn; ign++) { + aName = aGeomNames[ign]; + theObjectNames.Bind(aName, "1"); + } + + bool importGeom = false; + for (Standard_Integer i = 1; i <= aLen; i += 2) { + anUpdatedScript += aScript.SubString(aStart, aSeq->Value(i) - 1); + anEntry = aScript.SubString(aSeq->Value(i), aSeq->Value(i + 1)); + // is a GEOM object? + aName = geom->GetDumpName( anEntry.ToCString() ); + if (aName.IsEmpty()) { + // is a SMESH object + if (theObjectNames.IsBound(anEntry)) { + // The Object is in Study + aName = theObjectNames.Find(anEntry); + // check validity of aName + bool isValidName = true; + if ( aName.IsIntegerValue() ) { // aName must not start with a digit + aName.Insert( 1, 'a' ); + isValidName = false; + } + int p, p2=1; // replace not allowed chars + while ((p = aName.FirstLocationNotInSet(allowedChars, p2, aName.Length()))) { + aName.SetValue(p, '_'); + p2=p; + isValidName = false; + } + if (theObjectNames.IsBound(aName) && anEntry != theObjectNames(aName)) { + // diff objects have same name - make a new name by appending a digit + TCollection_AsciiString aName2; + Standard_Integer i = 0; + do { + aName2 = aName + "_" + ++i; + } while (theObjectNames.IsBound(aName2) && anEntry != theObjectNames(aName2)); + aName = aName2; + isValidName = false; + } + if ( !isValidName ) + theObjectNames(anEntry) = aName; + + } else { + // Removed Object + do { + aName = aBaseName + TCollection_AsciiString(++objectCounter); + } while (theObjectNames.IsBound(aName)); + seqRemoved.Append(aName); + mapRemoved.Bind(anEntry, "1"); + theObjectNames.Bind(anEntry, aName); + } + theObjectNames.Bind(aName, anEntry); // to detect same name of diff objects + } + else + { + importGeom = true; + } + anUpdatedScript += aName; + aStart = aSeq->Value(i + 1) + 1; + } + + // set initial part of aSript + TCollection_AsciiString initPart = "import salome, SMESH, StdMeshers\n\n"; + if ( importGeom ) + { + initPart += ("import string, os, sys, re\n" + "sys.path.insert( 0, os.path.dirname(__file__) )\n" + "exec(\"from \"+re.sub(\"SMESH$\",\"GEOM\",__name__)+\" import *\")\n\n"); + } + anUpdatedScript.Insert ( 1, initPart ); + + // add final part of aScript + if (aSeq->Value(aLen) < aScriptLength) + anUpdatedScript += aScript.SubString(aSeq->Value(aLen) + 1, aScriptLength); + + // Remove removed objects + anUpdatedScript += "\n\taStudyBuilder = theStudy.NewBuilder()"; + for (int ir = 1; ir <= seqRemoved.Length(); ir++) { + anUpdatedScript += "\n\tSO = theStudy.FindObjectIOR(theStudy.ConvertObjectToIOR("; + anUpdatedScript += seqRemoved.Value(ir); + anUpdatedScript += "))\n\tif SO is not None: aStudyBuilder.RemoveObjectWithChildren(SO)"; + } + + // Set object names + anUpdatedScript += "\n\n\tisGUIMode = "; + anUpdatedScript += isPublished; + anUpdatedScript += "\n\tif isGUIMode:"; + anUpdatedScript += "\n\t\tsmeshgui = salome.ImportComponentGUI(\"SMESH\")"; + anUpdatedScript += "\n\t\tsmeshgui.Init(theStudy._get_StudyId())"; + anUpdatedScript += "\n"; + + TCollection_AsciiString aGUIName; + Resource_DataMapOfAsciiStringAsciiString mapEntries; + for (Standard_Integer i = 1; i <= aLen; i += 2) { + anEntry = aScript.SubString(aSeq->Value(i), aSeq->Value(i + 1)); + aName = geom->GetDumpName( anEntry.ToCString() ); + if (aName.IsEmpty() && // Not a GEOM object + theNames.IsBound(anEntry) && + !mapEntries.IsBound(anEntry) && // Not yet processed + !mapRemoved.IsBound(anEntry)) { // Was not removed + aName = theObjectNames.Find(anEntry); + aGUIName = theNames.Find(anEntry); + mapEntries.Bind(anEntry, aName); + anUpdatedScript += "\n\t\tsmeshgui.SetName(salome.ObjectToID("; + anUpdatedScript += aName + "), \"" + aGUIName + "\")"; + } + } + anUpdatedScript += "\n\n\t\tsalome.sg.updateObjBrowser(0)"; + + anUpdatedScript += "\n\n\tpass\n"; + + aValidScript = true; + + return anUpdatedScript; +} + +//============================================================================= +/*! + * GetNewPythonLines + */ +//============================================================================= +TCollection_AsciiString SMESH_Gen_i::GetNewPythonLines (int theStudyID) +{ + TCollection_AsciiString aScript; + + // Dump trace of API methods calls + if (myPythonScripts.find(theStudyID) != myPythonScripts.end()) { + Handle(TColStd_HSequenceOfAsciiString) aPythonScript = myPythonScripts[theStudyID]; + Standard_Integer istr, aLen = aPythonScript->Length(); + for (istr = 1; istr <= aLen; istr++) { + aScript += "\n\t"; + aScript += aPythonScript->Value(istr); + } + aScript += "\n"; + } + + return aScript; +} + +//============================================================================= +/*! + * CleanPythonTrace + */ +//============================================================================= +void SMESH_Gen_i::CleanPythonTrace (int theStudyID) +{ + TCollection_AsciiString aScript; + + // Clean trace of API methods calls + if (myPythonScripts.find(theStudyID) != myPythonScripts.end()) { + myPythonScripts[theStudyID]->Clear(); + } +} diff --git a/src/SMESH_I/SMESH_Filter_i.cxx b/src/SMESH_I/SMESH_Filter_i.cxx index 1348b83ef..05d5f3848 100644 --- a/src/SMESH_I/SMESH_Filter_i.cxx +++ b/src/SMESH_I/SMESH_Filter_i.cxx @@ -29,6 +29,7 @@ #include "SMESH_Filter_i.hxx" #include "SMESH_Gen_i.hxx" +#include "SMESH_PythonDump.hxx" #include "SMDS_Mesh.hxx" #include "SMDS_MeshNode.hxx" @@ -63,6 +64,17 @@ using namespace SMESH; using namespace SMESH::Controls; + +namespace SMESH +{ + Predicate_i* + GetPredicate( Predicate_ptr thePredicate ) + { + return DownCast(thePredicate); + } +} + + /* Class : BelongToGeom Description : Predicate for verifying whether entiy belong to @@ -74,9 +86,9 @@ Controls::BelongToGeom::BelongToGeom() myType(SMDSAbs_All) {} -void Controls::BelongToGeom::SetMesh( SMDS_Mesh* theMesh ) +void Controls::BelongToGeom::SetMesh( const SMDS_Mesh* theMesh ) { - myMeshDS = dynamic_cast(theMesh); + myMeshDS = dynamic_cast(theMesh); } void Controls::BelongToGeom::SetGeom( const TopoDS_Shape& theShape ) @@ -84,7 +96,7 @@ void Controls::BelongToGeom::SetGeom( const TopoDS_Shape& theShape ) myShape = theShape; } -static bool IsContains( SMESHDS_Mesh* theMeshDS, +static bool IsContains( const SMESHDS_Mesh* theMeshDS, const TopoDS_Shape& theShape, const SMDS_MeshElement* theElem, TopAbs_ShapeEnum theFindShapeEnum, @@ -166,7 +178,9 @@ TopoDS_Shape Controls::BelongToGeom::GetShape() return myShape; } -SMESHDS_Mesh* Controls::BelongToGeom::GetMeshDS() +const SMESHDS_Mesh* +Controls::BelongToGeom:: +GetMeshDS() const { return myMeshDS; } @@ -182,9 +196,9 @@ Controls::LyingOnGeom::LyingOnGeom() myType(SMDSAbs_All) {} -void Controls::LyingOnGeom::SetMesh( SMDS_Mesh* theMesh ) +void Controls::LyingOnGeom::SetMesh( const SMDS_Mesh* theMesh ) { - myMeshDS = dynamic_cast(theMesh); + myMeshDS = dynamic_cast(theMesh); } void Controls::LyingOnGeom::SetGeom( const TopoDS_Shape& theShape ) @@ -254,12 +268,14 @@ TopoDS_Shape Controls::LyingOnGeom::GetShape() return myShape; } -SMESHDS_Mesh* Controls::LyingOnGeom::GetMeshDS() +const SMESHDS_Mesh* +Controls::LyingOnGeom:: +GetMeshDS() const { return myMeshDS; } -bool Controls::LyingOnGeom::Contains( SMESHDS_Mesh* theMeshDS, +bool Controls::LyingOnGeom::Contains( const SMESHDS_Mesh* theMeshDS, const TopoDS_Shape& theShape, const SMDS_MeshElement* theElem, TopAbs_ShapeEnum theFindShapeEnum, @@ -301,14 +317,17 @@ bool Controls::LyingOnGeom::Contains( SMESHDS_Mesh* theMeshDS, AUXILIARY METHODS */ -static inline SMDS_Mesh* MeshPtr2SMDSMesh( SMESH_Mesh_ptr theMesh ) +inline +const SMDS_Mesh* +MeshPtr2SMDSMesh( SMESH_Mesh_ptr theMesh ) { - SMESH_Mesh_i* anImplPtr = - dynamic_cast( SMESH_Gen_i::GetServant( theMesh ).in() ); + SMESH_Mesh_i* anImplPtr = DownCast(theMesh); return anImplPtr ? anImplPtr->GetImpl().GetMeshDS() : 0; } -static inline SMESH::long_array* toArray( const TColStd_ListOfInteger& aList ) +inline +SMESH::long_array* +toArray( const TColStd_ListOfInteger& aList ) { SMESH::long_array_var anArray = new SMESH::long_array; anArray->length( aList.Extent() ); @@ -320,7 +339,9 @@ static inline SMESH::long_array* toArray( const TColStd_ListOfInteger& aList ) return anArray._retn(); } -static inline SMESH::double_array* toArray( const TColStd_ListOfReal& aList ) +inline +SMESH::double_array* +toArray( const TColStd_ListOfReal& aList ) { SMESH::double_array_var anArray = new SMESH::double_array; anArray->length( aList.Extent() ); @@ -387,13 +408,19 @@ static TopoDS_Shape getShapeByName( const char* theName ) Functor_i::Functor_i(): SALOME::GenericObj_i( SMESH_Gen_i::GetPOA() ) { - SMESH_Gen_i::GetPOA()->activate_object( this ); + PortableServer::ObjectId_var anObjectId = + SMESH_Gen_i::GetPOA()->activate_object( this ); +} + +Functor_i::~Functor_i() +{ + TPythonDump()<SetMesh( MeshPtr2SMDSMesh( theMesh ) ); - INFOS("Functor_i::SetMesh~"); + TPythonDump()<SetPrecision( thePrecision ); + TPythonDump()<GetShapeReader()->GetShape( aGEOMGen, theGeom ); myBelongToGeomPtr->SetGeom( aLocShape ); + TPythonDump()<SetType(SMDSAbs_ElementType(theType)); + TPythonDump()<SetGeom( getShapeByName( myShapeName ) ); + TPythonDump()<SetSurface( TopoDS_Shape(), (SMDSAbs_ElementType)theType ); + TPythonDump()<SetSurface( getShapeByName( myShapeName ), (SMDSAbs_ElementType)theType ); + TPythonDump()<SetTolerance( theToler ); + TPythonDump()<GetShapeReader()->GetShape( aGEOMGen, theGeom ); myLyingOnGeomPtr->SetGeom( aLocShape ); + TPythonDump()<SetType(SMDSAbs_ElementType(theType)); + TPythonDump()<SetGeom( getShapeByName( myShapeName ) ); + TPythonDump()<AddToRange( theIds[ i ] ); + TPythonDump()<SetRangeStr( TCollection_AsciiString( (Standard_CString)theRange ) ); } @@ -981,6 +1022,7 @@ char* RangeOfIds_i::GetRangeStr() void RangeOfIds_i::SetElementType( ElementType theType ) { myRangeOfIdsPtr->SetType( SMDSAbs_ElementType( theType ) ); + TPythonDump()<SetMargin( theValue ); + TPythonDump()<Destroy(); - myNumericalFunctor = dynamic_cast( SMESH_Gen_i::GetServant( theFunct ).in() ); + myNumericalFunctor = DownCast(theFunct); if ( myNumericalFunctor ) { myComparatorPtr->SetNumFunctor( myNumericalFunctor->GetNumericalFunctor() ); myNumericalFunctor->Register(); + TPythonDump()<SetTolerance( theToler ); + TPythonDump()<Destroy(); } -void LogicalNOT_i::SetPredicate( Predicate_ptr thePred ) +void LogicalNOT_i::SetPredicate( Predicate_ptr thePredicate ) { if ( myPredicate ) myPredicate->Destroy(); - myPredicate = dynamic_cast( SMESH_Gen_i::GetServant( thePred ).in() ); + myPredicate = SMESH::GetPredicate(thePredicate); if ( myPredicate ){ myLogicalNOTPtr->SetPredicate(myPredicate->GetPredicate()); myPredicate->Register(); + TPythonDump()<Destroy(); - myPredicate1 = dynamic_cast( SMESH_Gen_i::GetServant( thePredicate ).in() ); + myPredicate1 = SMESH::GetPredicate(thePredicate); if ( myPredicate1 ){ myLogicalBinaryPtr->SetPredicate1(myPredicate1->GetPredicate()); myPredicate1->Register(); + TPythonDump()<Destroy(); - myPredicate2 = dynamic_cast( SMESH_Gen_i::GetServant( thePredicate ).in() ); + myPredicate2 = SMESH::GetPredicate(thePredicate); if ( myPredicate2 ){ myLogicalBinaryPtr->SetPredicate2(myPredicate2->GetPredicate()); myPredicate2->Register(); + TPythonDump()<activate_object( this ); + PortableServer::ObjectId_var anObjectId = + SMESH_Gen_i::GetPOA()->activate_object( this ); } + +FilterManager_i::~FilterManager_i() +{ + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<Destroy(); + + if(!CORBA::is_nil(myMesh)) + myMesh->Destroy(); + + TPythonDump()<Destroy(); - myPredicate = dynamic_cast( SMESH_Gen_i::GetServant( thePredicate ).in() ); + myPredicate = SMESH::GetPredicate(thePredicate); if ( myPredicate ) { myFilter.SetPredicate( myPredicate->GetPredicate() ); myPredicate->Register(); + TPythonDump()<SetMesh( theMesh ); + if(!CORBA::is_nil(theMesh)) + theMesh->Register(); + + if(!CORBA::is_nil(myMesh)) + myMesh->Destroy(); + + myMesh = theMesh; + TPythonDump()<GetPredicate(),theSequence); +} +void +Filter_i:: +GetElementsId( Predicate_i* thePredicate, + SMESH_Mesh_ptr theMesh, + Controls::Filter::TIdSequence& theSequence ) +{ + if(const SMDS_Mesh* aMesh = MeshPtr2SMDSMesh(theMesh)) + Controls::Filter::GetElementsId(aMesh,thePredicate->GetPredicate(),theSequence); +} + +SMESH::long_array* +Filter_i:: +GetElementsId( SMESH_Mesh_ptr theMesh ) +{ SMESH::long_array_var anArray = new SMESH::long_array; - long i = 0, iEnd = aSequence.size(); - - anArray->length( iEnd ); - for ( ; i < iEnd; i++ ) - anArray[ i ] = aSequence[i]; - + if(!CORBA::is_nil(theMesh)){ + Controls::Filter::TIdSequence aSequence; + GetElementsId(myPredicate,theMesh,aSequence); + long i = 0, iEnd = aSequence.size(); + anArray->length( iEnd ); + for ( ; i < iEnd; i++ ) + anArray[ i ] = aSequence[i]; + } return anArray._retn(); } @@ -1719,12 +1845,13 @@ CORBA::Boolean Filter_i::SetCriteria( const SMESH::Filter::Criteria& theCriteria if ( myPredicate != 0 ) myPredicate->Destroy(); - SMESH::FilterManager_i* aFilter = new SMESH::FilterManager_i(); - FilterManager_ptr aFilterMgr = aFilter->_this(); - + SMESH::FilterManager_i* aFilter = new SMESH::FilterManager_i(); + FilterManager_ptr aFilterMgr = aFilter->_this(); + // CREATE two lists ( PREDICATES and LOG OP ) // Criterion + TPythonDump()<<"aCriteria = []"; std::list aPredicates; std::list aBinaries; for ( int i = 0, n = theCriteria.length(); i < n; i++ ) @@ -1738,6 +1865,10 @@ CORBA::Boolean Filter_i::SetCriteria( const SMESH::Filter::Criteria& theCriteria const char* aThresholdStr = theCriteria[ i ].ThresholdStr; ElementType aTypeOfElem = theCriteria[ i ].TypeOfElement; long aPrecision = theCriteria[ i ].Precision; + + TPythonDump()<<"aCriteria.append(SMESH.Filter.Criterion("<< + aCriterion<<","<CreateFilter(); aRes->SetCriteria( aCriteriaVar.inout() ); - + + TPythonDump()<(theFilter)) + TPythonDump()<(theFilter)) + TPythonDump()< BelongToGeomPtr; - -/* - Class : LyingOnGeom - Description : Predicate for verifying whether entiy lying or partially lying on - specified geometrical support -*/ -class LyingOnGeom: public virtual Predicate -{ -public: - LyingOnGeom(); - - virtual void SetMesh( SMDS_Mesh* theMesh ); - virtual void SetGeom( const TopoDS_Shape& theShape ); - - virtual bool IsSatisfy( long theElementId ); - - virtual void SetType( SMDSAbs_ElementType theType ); - virtual SMDSAbs_ElementType GetType() const; - - TopoDS_Shape GetShape(); - SMESHDS_Mesh* GetMeshDS(); - - virtual bool Contains( SMESHDS_Mesh* theMeshDS, - const TopoDS_Shape& theShape, - const SMDS_MeshElement* theElem, - TopAbs_ShapeEnum theFindShapeEnum, - TopAbs_ShapeEnum theAvoidShapeEnum = TopAbs_SHAPE ); -private: - TopoDS_Shape myShape; - SMESHDS_Mesh* myMeshDS; - SMDSAbs_ElementType myType; -}; -typedef boost::shared_ptr LyingOnGeomPtr; -} - -/* - FUNCTORS -*/ - -/* - Class : Functor_i - Description : An abstact class for all functors -*/ -class Functor_i: public virtual POA_SMESH::Functor, - public virtual SALOME::GenericObj_i -{ -public: - void SetMesh( SMESH_Mesh_ptr theMesh ); - Controls::FunctorPtr GetFunctor(){ return myFunctorPtr;} - ElementType GetElementType(); - -protected: - Functor_i(); -protected: - Controls::FunctorPtr myFunctorPtr; -}; - - -/* - Class : NumericalFunctor_i - Description : Base class for numerical functors -*/ -class NumericalFunctor_i: public virtual POA_SMESH::NumericalFunctor, - public virtual Functor_i -{ -public: - CORBA::Double GetValue( CORBA::Long theElementId ); - void SetPrecision( CORBA::Long thePrecision ); - CORBA::Long GetPrecision(); - Controls::NumericalFunctorPtr GetNumericalFunctor(); - -protected: - Controls::NumericalFunctorPtr myNumericalFunctorPtr; -}; - - -/* - Class : SMESH_MinimumAngleFunct - Description : Functor for calculation of minimum angle -*/ -class MinimumAngle_i: public virtual POA_SMESH::MinimumAngle, - public virtual NumericalFunctor_i -{ -public: - MinimumAngle_i(); - FunctorType GetFunctorType(); -}; - - -/* - Class : AspectRatio_i - Description : Functor for calculating aspect ratio -*/ -class AspectRatio_i: public virtual POA_SMESH::AspectRatio, - public virtual NumericalFunctor_i -{ -public: - AspectRatio_i(); - FunctorType GetFunctorType(); -}; - - -/* - Class : AspectRatio3D_i - Description : Functor for calculating aspect ratio for 3D -*/ -class AspectRatio3D_i: public virtual POA_SMESH::AspectRatio3D, - public virtual NumericalFunctor_i -{ -public: - AspectRatio3D_i(); - FunctorType GetFunctorType(); -}; - - -/* - Class : Warping_i - Description : Functor for calculating warping -*/ -class Warping_i: public virtual POA_SMESH::Warping, - public virtual NumericalFunctor_i -{ -public: - Warping_i(); - FunctorType GetFunctorType(); -}; - - -/* - Class : Taper_i - Description : Functor for calculating taper -*/ -class Taper_i: public virtual POA_SMESH::Taper, - public virtual NumericalFunctor_i -{ -public: - Taper_i(); - FunctorType GetFunctorType(); -}; - - -/* - Class : Skew_i - Description : Functor for calculating skew in degrees -*/ -class Skew_i: public virtual POA_SMESH::Skew, - public virtual NumericalFunctor_i -{ -public: - Skew_i(); - FunctorType GetFunctorType(); -}; - - -/* - Class : Area_i - Description : Functor for calculating area -*/ -class Area_i: public virtual POA_SMESH::Area, - public virtual NumericalFunctor_i -{ -public: - Area_i(); - FunctorType GetFunctorType(); -}; - - -/* - Class : Length_i - Description : Functor for calculating length of edge -*/ -class Length_i: public virtual POA_SMESH::Length, - public virtual NumericalFunctor_i -{ -public: - Length_i(); - FunctorType GetFunctorType(); -}; - -/* - Class : Length2D_i - Description : Functor for calculating length of edge -*/ -class Length2D_i: public virtual POA_SMESH::Length2D, - public virtual NumericalFunctor_i -{ -public: - Length2D_i(); - SMESH::Length2D::Values* GetValues(); - FunctorType GetFunctorType(); - -protected: - Controls::Length2DPtr myLength2DPtr; -}; - - -/* - Class : MultiConnection_i - Description : Functor for calculating number of faces conneted to the edge -*/ -class MultiConnection_i: public virtual POA_SMESH::MultiConnection, - public virtual NumericalFunctor_i -{ -public: - MultiConnection_i(); - FunctorType GetFunctorType(); -}; - -/* - Class : MultiConnection2D_i - Description : Functor for calculating number of faces conneted to the edge -*/ -class MultiConnection2D_i: public virtual POA_SMESH::MultiConnection2D, - public virtual NumericalFunctor_i -{ -public: - MultiConnection2D_i(); - SMESH::MultiConnection2D::Values* GetValues(); - FunctorType GetFunctorType(); - -protected: - Controls::MultiConnection2DPtr myMulticonnection2DPtr; -}; - - -/* - PREDICATES -*/ -/* - Class : Predicate_i - Description : Base class for all predicates -*/ -class Predicate_i: public virtual POA_SMESH::Predicate, - public virtual Functor_i -{ -public: - CORBA::Boolean IsSatisfy( CORBA::Long theElementId ); - Controls::PredicatePtr GetPredicate(); - -protected: - Controls::PredicatePtr myPredicatePtr; -}; - - -/* - Class : BadOrientedVolume_i - Description : Verify whether a mesh volume is incorrectly oriented from - the point of view of MED convention -*/ -class BadOrientedVolume_i: public virtual POA_SMESH::BadOrientedVolume, - public virtual Predicate_i -{ - public: - BadOrientedVolume_i(); - FunctorType GetFunctorType(); -}; - -/* - Class : BelongToGeom_i - Description : Predicate for selection on geometrical support -*/ -class BelongToGeom_i: public virtual POA_SMESH::BelongToGeom, - public virtual Predicate_i -{ -public: - BelongToGeom_i(); - virtual ~BelongToGeom_i(); - - void SetGeom( GEOM::GEOM_Object_ptr theGeom ); - void SetElementType( ElementType theType ); - FunctorType GetFunctorType(); - - void SetGeom( const TopoDS_Shape& theShape ); - - void SetShapeName( const char* theName ); - char* GetShapeName(); - -protected: - Controls::BelongToGeomPtr myBelongToGeomPtr; - char* myShapeName; -}; - -/* - Class : BelongToSurface_i - Description : Verify whether mesh element lie in pointed Geom planar object -*/ -class BelongToSurface_i: public virtual POA_SMESH::BelongToSurface, - public virtual Predicate_i -{ -public: - BelongToSurface_i( const Handle(Standard_Type)& ); - virtual ~BelongToSurface_i(); - - void SetSurface( GEOM::GEOM_Object_ptr theGeom, ElementType theType ); - - void SetShapeName( const char* theName, ElementType theType ); - char* GetShapeName(); - - void SetTolerance( CORBA::Double ); - CORBA::Double GetTolerance(); - -protected: - Controls::ElementsOnSurfacePtr myElementsOnSurfacePtr; - char* myShapeName; - Handle(Standard_Type) mySurfaceType; -}; - -/* - Class : BelongToPlane_i - Description : Verify whether mesh element lie in pointed Geom planar object -*/ -class BelongToPlane_i: public virtual POA_SMESH::BelongToPlane, - public virtual BelongToSurface_i -{ -public: - BelongToPlane_i(); - void SetPlane( GEOM::GEOM_Object_ptr theGeom, ElementType theType ); - FunctorType GetFunctorType(); -}; - -/* - Class : BelongToCylinder_i - Description : Verify whether mesh element lie in pointed Geom cylindrical object -*/ -class BelongToCylinder_i: public virtual POA_SMESH::BelongToCylinder, - public virtual BelongToSurface_i -{ -public: - BelongToCylinder_i(); - void SetCylinder( GEOM::GEOM_Object_ptr theGeom, ElementType theType ); - FunctorType GetFunctorType(); -}; - -/* - Class : LyingOnGeom_i - Description : Predicate for selection on geometrical support(lying or partially lying) -*/ -class LyingOnGeom_i: public virtual POA_SMESH::LyingOnGeom, - public virtual Predicate_i -{ -public: - LyingOnGeom_i(); - virtual ~LyingOnGeom_i(); + namespace Controls + { - void SetGeom( GEOM::GEOM_Object_ptr theGeom ); - void SetElementType( ElementType theType ); - FunctorType GetFunctorType(); + /* + Class : BelongToGeom + Description : Predicate for verifying whether entiy belong to + specified geometrical support + */ + class BelongToGeom: public virtual Predicate + { + public: + BelongToGeom(); + + virtual void SetMesh( const SMDS_Mesh* theMesh ); + virtual void SetGeom( const TopoDS_Shape& theShape ); + + virtual bool IsSatisfy( long theElementId ); + + virtual void SetType( SMDSAbs_ElementType theType ); + virtual SMDSAbs_ElementType GetType() const; + + TopoDS_Shape GetShape(); + const SMESHDS_Mesh* GetMeshDS() const; + + private: + TopoDS_Shape myShape; + const SMESHDS_Mesh* myMeshDS; + SMDSAbs_ElementType myType; + }; + typedef boost::shared_ptr BelongToGeomPtr; + + /* + Class : LyingOnGeom + Description : Predicate for verifying whether entiy lying or partially lying on + specified geometrical support + */ + class LyingOnGeom: public virtual Predicate + { + public: + LyingOnGeom(); + + virtual void SetMesh( const SMDS_Mesh* theMesh ); + virtual void SetGeom( const TopoDS_Shape& theShape ); + + virtual bool IsSatisfy( long theElementId ); + + virtual void SetType( SMDSAbs_ElementType theType ); + virtual SMDSAbs_ElementType GetType() const; + + TopoDS_Shape GetShape(); + const SMESHDS_Mesh* GetMeshDS() const; + + virtual bool Contains( const SMESHDS_Mesh* theMeshDS, + const TopoDS_Shape& theShape, + const SMDS_MeshElement* theElem, + TopAbs_ShapeEnum theFindShapeEnum, + TopAbs_ShapeEnum theAvoidShapeEnum = TopAbs_SHAPE ); + private: + TopoDS_Shape myShape; + const SMESHDS_Mesh* myMeshDS; + SMDSAbs_ElementType myType; + }; + typedef boost::shared_ptr LyingOnGeomPtr; + } - void SetGeom( const TopoDS_Shape& theShape ); + /* + FUNCTORS + */ - void SetShapeName( const char* theName ); - char* GetShapeName(); + /* + Class : Functor_i + Description : An abstact class for all functors + */ + class Functor_i: public virtual POA_SMESH::Functor, + public virtual SALOME::GenericObj_i + { + public: + void SetMesh( SMESH_Mesh_ptr theMesh ); + Controls::FunctorPtr GetFunctor(){ return myFunctorPtr;} + ElementType GetElementType(); + + protected: + Functor_i(); + ~Functor_i(); + protected: + Controls::FunctorPtr myFunctorPtr; + }; -protected: - Controls::LyingOnGeomPtr myLyingOnGeomPtr; - char* myShapeName; -}; - -/* - Class : FreeBorders_i - Description : Predicate for free borders -*/ -class FreeBorders_i: public virtual POA_SMESH::FreeBorders, - public virtual Predicate_i -{ -public: - FreeBorders_i(); - FunctorType GetFunctorType(); -}; - - -/* - Class : FreeEdges_i - Description : Predicate for free edges -*/ -class FreeEdges_i: public virtual POA_SMESH::FreeEdges, - public virtual Predicate_i -{ -public: - FreeEdges_i(); - SMESH::FreeEdges::Borders* GetBorders(); - FunctorType GetFunctorType(); + /* + Class : NumericalFunctor_i + Description : Base class for numerical functors + */ + class NumericalFunctor_i: public virtual POA_SMESH::NumericalFunctor, + public virtual Functor_i + { + public: + CORBA::Double GetValue( CORBA::Long theElementId ); + void SetPrecision( CORBA::Long thePrecision ); + CORBA::Long GetPrecision(); + Controls::NumericalFunctorPtr GetNumericalFunctor(); + + protected: + Controls::NumericalFunctorPtr myNumericalFunctorPtr; + }; -protected: - Controls::FreeEdgesPtr myFreeEdgesPtr; -}; - - -/* - Class : RangeOfIds_i - Description : Predicate for Range of Ids -*/ -class RangeOfIds_i: public virtual POA_SMESH::RangeOfIds, - public virtual Predicate_i -{ -public: - RangeOfIds_i(); - void SetRange( const SMESH::long_array& theIds ); - CORBA::Boolean SetRangeStr( const char* theRange ); - char* GetRangeStr(); - - void SetElementType( ElementType theType ); - FunctorType GetFunctorType(); - -protected: - Controls::RangeOfIdsPtr myRangeOfIdsPtr; -}; - -/* - Class : Comparator_i - Description : Base class for comparators -*/ -class Comparator_i: public virtual POA_SMESH::Comparator, - public virtual Predicate_i -{ -public: - virtual ~Comparator_i(); - virtual void SetMargin( CORBA::Double ); - virtual void SetNumFunctor( NumericalFunctor_ptr ); + /* + Class : SMESH_MinimumAngleFunct + Description : Functor for calculation of minimum angle + */ + class MinimumAngle_i: public virtual POA_SMESH::MinimumAngle, + public virtual NumericalFunctor_i + { + public: + MinimumAngle_i(); + FunctorType GetFunctorType(); + }; - Controls::ComparatorPtr GetComparator(); - NumericalFunctor_i* GetNumFunctor_i(); - CORBA::Double GetMargin(); -protected: - Comparator_i(); -protected: - Controls::ComparatorPtr myComparatorPtr; - NumericalFunctor_i* myNumericalFunctor; -}; - - -/* - Class : LessThan_i - Description : Comparator "<" -*/ -class LessThan_i: public virtual POA_SMESH::LessThan, - public virtual Comparator_i -{ -public: - LessThan_i(); - FunctorType GetFunctorType(); -}; - - -/* - Class : MoreThan_i - Description : Comparator ">" -*/ -class MoreThan_i: public virtual POA_SMESH::MoreThan, - public virtual Comparator_i -{ -public: - MoreThan_i(); - FunctorType GetFunctorType(); -}; - - -/* - Class : EqualTo_i - Description : Comparator "=" -*/ -class EqualTo_i: public virtual POA_SMESH::EqualTo, - public virtual Comparator_i -{ -public: - EqualTo_i(); - virtual void SetTolerance( CORBA::Double ); - CORBA::Double GetTolerance(); - FunctorType GetFunctorType(); + /* + Class : AspectRatio_i + Description : Functor for calculating aspect ratio + */ + class AspectRatio_i: public virtual POA_SMESH::AspectRatio, + public virtual NumericalFunctor_i + { + public: + AspectRatio_i(); + FunctorType GetFunctorType(); + }; + + + /* + Class : AspectRatio3D_i + Description : Functor for calculating aspect ratio for 3D + */ + class AspectRatio3D_i: public virtual POA_SMESH::AspectRatio3D, + public virtual NumericalFunctor_i + { + public: + AspectRatio3D_i(); + FunctorType GetFunctorType(); + }; -protected: - Controls::EqualToPtr myEqualToPtr; -}; - -/* - Class : LogicalNOT_i - Description : Logical NOT predicate -*/ -class LogicalNOT_i: public virtual POA_SMESH::LogicalNOT, - public virtual Predicate_i -{ -public: - LogicalNOT_i(); + /* + Class : Warping_i + Description : Functor for calculating warping + */ + class Warping_i: public virtual POA_SMESH::Warping, + public virtual NumericalFunctor_i + { + public: + Warping_i(); + FunctorType GetFunctorType(); + }; + + + /* + Class : Taper_i + Description : Functor for calculating taper + */ + class Taper_i: public virtual POA_SMESH::Taper, + public virtual NumericalFunctor_i + { + public: + Taper_i(); + FunctorType GetFunctorType(); + }; + + + /* + Class : Skew_i + Description : Functor for calculating skew in degrees + */ + class Skew_i: public virtual POA_SMESH::Skew, + public virtual NumericalFunctor_i + { + public: + Skew_i(); + FunctorType GetFunctorType(); + }; + + + /* + Class : Area_i + Description : Functor for calculating area + */ + class Area_i: public virtual POA_SMESH::Area, + public virtual NumericalFunctor_i + { + public: + Area_i(); + FunctorType GetFunctorType(); + }; + + + /* + Class : Length_i + Description : Functor for calculating length of edge + */ + class Length_i: public virtual POA_SMESH::Length, + public virtual NumericalFunctor_i + { + public: + Length_i(); + FunctorType GetFunctorType(); + }; + + /* + Class : Length2D_i + Description : Functor for calculating length of edge + */ + class Length2D_i: public virtual POA_SMESH::Length2D, + public virtual NumericalFunctor_i + { + public: + Length2D_i(); + SMESH::Length2D::Values* GetValues(); + FunctorType GetFunctorType(); + + protected: + Controls::Length2DPtr myLength2DPtr; + }; + + + /* + Class : MultiConnection_i + Description : Functor for calculating number of faces conneted to the edge + */ + class MultiConnection_i: public virtual POA_SMESH::MultiConnection, + public virtual NumericalFunctor_i + { + public: + MultiConnection_i(); + FunctorType GetFunctorType(); + }; + + /* + Class : MultiConnection2D_i + Description : Functor for calculating number of faces conneted to the edge + */ + class MultiConnection2D_i: public virtual POA_SMESH::MultiConnection2D, + public virtual NumericalFunctor_i + { + public: + MultiConnection2D_i(); + SMESH::MultiConnection2D::Values* GetValues(); + FunctorType GetFunctorType(); + + protected: + Controls::MultiConnection2DPtr myMulticonnection2DPtr; + }; + + + /* + PREDICATES + */ + /* + Class : Predicate_i + Description : Base class for all predicates + */ + class Predicate_i: public virtual POA_SMESH::Predicate, + public virtual Functor_i + { + public: + CORBA::Boolean IsSatisfy( CORBA::Long theElementId ); + Controls::PredicatePtr GetPredicate(); + + protected: + Controls::PredicatePtr myPredicatePtr; + }; + + + /* + Class : BadOrientedVolume_i + Description : Verify whether a mesh volume is incorrectly oriented from + the point of view of MED convention + */ + class BadOrientedVolume_i: public virtual POA_SMESH::BadOrientedVolume, + public virtual Predicate_i + { + public: + BadOrientedVolume_i(); + FunctorType GetFunctorType(); + }; + + /* + Class : BelongToGeom_i + Description : Predicate for selection on geometrical support + */ + class BelongToGeom_i: public virtual POA_SMESH::BelongToGeom, + public virtual Predicate_i + { + public: + BelongToGeom_i(); + virtual ~BelongToGeom_i(); + + void SetGeom( GEOM::GEOM_Object_ptr theGeom ); + void SetElementType( ElementType theType ); + FunctorType GetFunctorType(); + + void SetGeom( const TopoDS_Shape& theShape ); + + void SetShapeName( const char* theName ); + char* GetShapeName(); + + protected: + Controls::BelongToGeomPtr myBelongToGeomPtr; + char* myShapeName; + }; + + /* + Class : BelongToSurface_i + Description : Verify whether mesh element lie in pointed Geom planar object + */ + class BelongToSurface_i: public virtual POA_SMESH::BelongToSurface, + public virtual Predicate_i + { + public: + BelongToSurface_i( const Handle(Standard_Type)& ); + virtual ~BelongToSurface_i(); + + void SetSurface( GEOM::GEOM_Object_ptr theGeom, ElementType theType ); + + void SetShapeName( const char* theName, ElementType theType ); + char* GetShapeName(); + + void SetTolerance( CORBA::Double ); + CORBA::Double GetTolerance(); + + protected: + Controls::ElementsOnSurfacePtr myElementsOnSurfacePtr; + char* myShapeName; + Handle(Standard_Type) mySurfaceType; + }; + + /* + Class : BelongToPlane_i + Description : Verify whether mesh element lie in pointed Geom planar object + */ + class BelongToPlane_i: public virtual POA_SMESH::BelongToPlane, + public virtual BelongToSurface_i + { + public: + BelongToPlane_i(); + void SetPlane( GEOM::GEOM_Object_ptr theGeom, ElementType theType ); + FunctorType GetFunctorType(); + }; + + /* + Class : BelongToCylinder_i + Description : Verify whether mesh element lie in pointed Geom cylindrical object + */ + class BelongToCylinder_i: public virtual POA_SMESH::BelongToCylinder, + public virtual BelongToSurface_i + { + public: + BelongToCylinder_i(); + void SetCylinder( GEOM::GEOM_Object_ptr theGeom, ElementType theType ); + FunctorType GetFunctorType(); + }; + + /* + Class : LyingOnGeom_i + Description : Predicate for selection on geometrical support(lying or partially lying) + */ + class LyingOnGeom_i: public virtual POA_SMESH::LyingOnGeom, + public virtual Predicate_i + { + public: + LyingOnGeom_i(); + virtual ~LyingOnGeom_i(); + + void SetGeom( GEOM::GEOM_Object_ptr theGeom ); + void SetElementType( ElementType theType ); + FunctorType GetFunctorType(); + + void SetGeom( const TopoDS_Shape& theShape ); + + void SetShapeName( const char* theName ); + char* GetShapeName(); + + protected: + Controls::LyingOnGeomPtr myLyingOnGeomPtr; + char* myShapeName; + }; + + /* + Class : FreeBorders_i + Description : Predicate for free borders + */ + class FreeBorders_i: public virtual POA_SMESH::FreeBorders, + public virtual Predicate_i + { + public: + FreeBorders_i(); + FunctorType GetFunctorType(); + }; + + + /* + Class : FreeEdges_i + Description : Predicate for free edges + */ + class FreeEdges_i: public virtual POA_SMESH::FreeEdges, + public virtual Predicate_i + { + public: + FreeEdges_i(); + SMESH::FreeEdges::Borders* GetBorders(); + FunctorType GetFunctorType(); + + protected: + Controls::FreeEdgesPtr myFreeEdgesPtr; + }; + + + /* + Class : RangeOfIds_i + Description : Predicate for Range of Ids + */ + class RangeOfIds_i: public virtual POA_SMESH::RangeOfIds, + public virtual Predicate_i + { + public: + RangeOfIds_i(); + void SetRange( const SMESH::long_array& theIds ); + CORBA::Boolean SetRangeStr( const char* theRange ); + char* GetRangeStr(); + + void SetElementType( ElementType theType ); + FunctorType GetFunctorType(); + + protected: + Controls::RangeOfIdsPtr myRangeOfIdsPtr; + }; + + /* + Class : Comparator_i + Description : Base class for comparators + */ + class Comparator_i: public virtual POA_SMESH::Comparator, + public virtual Predicate_i + { + public: + virtual ~Comparator_i(); + + virtual void SetMargin( CORBA::Double ); + virtual void SetNumFunctor( NumericalFunctor_ptr ); + + Controls::ComparatorPtr GetComparator(); + NumericalFunctor_i* GetNumFunctor_i(); + CORBA::Double GetMargin(); + + protected: + Comparator_i(); + protected: + Controls::ComparatorPtr myComparatorPtr; + NumericalFunctor_i* myNumericalFunctor; + }; + + + /* + Class : LessThan_i + Description : Comparator "<" + */ + class LessThan_i: public virtual POA_SMESH::LessThan, + public virtual Comparator_i + { + public: + LessThan_i(); + FunctorType GetFunctorType(); + }; + + + /* + Class : MoreThan_i + Description : Comparator ">" + */ + class MoreThan_i: public virtual POA_SMESH::MoreThan, + public virtual Comparator_i + { + public: + MoreThan_i(); + FunctorType GetFunctorType(); + }; + + + /* + Class : EqualTo_i + Description : Comparator "=" + */ + class EqualTo_i: public virtual POA_SMESH::EqualTo, + public virtual Comparator_i + { + public: + EqualTo_i(); + virtual void SetTolerance( CORBA::Double ); + CORBA::Double GetTolerance(); + FunctorType GetFunctorType(); + + protected: + Controls::EqualToPtr myEqualToPtr; + }; + + + /* + Class : LogicalNOT_i + Description : Logical NOT predicate + */ + class LogicalNOT_i: public virtual POA_SMESH::LogicalNOT, + public virtual Predicate_i + { + public: + LogicalNOT_i(); virtual ~LogicalNOT_i(); + + virtual void SetPredicate( Predicate_ptr ); + Predicate_i* GetPredicate_i(); + FunctorType GetFunctorType(); + + protected: + Controls::LogicalNOTPtr myLogicalNOTPtr; + Predicate_i* myPredicate; + }; - virtual void SetPredicate( Predicate_ptr ); - Predicate_i* GetPredicate_i(); - FunctorType GetFunctorType(); -protected: - Controls::LogicalNOTPtr myLogicalNOTPtr; - Predicate_i* myPredicate; -}; - - -/* - Class : LogicalBinary_i - Description : Base class for binary logical predicate -*/ -class LogicalBinary_i: public virtual POA_SMESH::LogicalBinary, - public virtual Predicate_i -{ -public: - virtual ~LogicalBinary_i(); - virtual void SetMesh( SMESH_Mesh_ptr theMesh ); - virtual void SetPredicate1( Predicate_ptr ); - virtual void SetPredicate2( Predicate_ptr ); + /* + Class : LogicalBinary_i + Description : Base class for binary logical predicate + */ + class LogicalBinary_i: public virtual POA_SMESH::LogicalBinary, + public virtual Predicate_i + { + public: + virtual ~LogicalBinary_i(); + virtual void SetMesh( SMESH_Mesh_ptr theMesh ); + virtual void SetPredicate1( Predicate_ptr ); + virtual void SetPredicate2( Predicate_ptr ); + + Controls::LogicalBinaryPtr GetLogicalBinary(); + Predicate_i* GetPredicate1_i(); + Predicate_i* GetPredicate2_i(); + + protected: + LogicalBinary_i(); + protected: + Controls::LogicalBinaryPtr myLogicalBinaryPtr; + Predicate_i* myPredicate1; + Predicate_i* myPredicate2; + }; - Controls::LogicalBinaryPtr GetLogicalBinary(); - Predicate_i* GetPredicate1_i(); - Predicate_i* GetPredicate2_i(); -protected: - LogicalBinary_i(); -protected: - Controls::LogicalBinaryPtr myLogicalBinaryPtr; - Predicate_i* myPredicate1; - Predicate_i* myPredicate2; -}; - - -/* - Class : LogicalAND_i - Description : Logical AND -*/ -class LogicalAND_i: public virtual POA_SMESH::LogicalAND, - public virtual LogicalBinary_i -{ -public: - LogicalAND_i(); - FunctorType GetFunctorType(); -}; - - -/* - Class : LogicalOR_i - Description : Logical OR -*/ -class LogicalOR_i: public virtual POA_SMESH::LogicalOR, - public virtual LogicalBinary_i -{ -public: - LogicalOR_i(); - FunctorType GetFunctorType(); -}; - - -/* - FILTER -*/ -class Filter_i: public virtual POA_SMESH::Filter, - public virtual SALOME::GenericObj_i -{ -public: - Filter_i(); - virtual ~Filter_i(); + /* + Class : LogicalAND_i + Description : Logical AND + */ + class LogicalAND_i: public virtual POA_SMESH::LogicalAND, + public virtual LogicalBinary_i + { + public: + LogicalAND_i(); + FunctorType GetFunctorType(); + }; - void SetPredicate( Predicate_ptr ); - void SetMesh( SMESH_Mesh_ptr ); - - long_array* GetElementsId( SMESH_Mesh_ptr ); - ElementType GetElementType(); - - CORBA::Boolean GetCriteria( SMESH::Filter::Criteria_out theCriteria ); - CORBA::Boolean SetCriteria( const SMESH::Filter::Criteria& theCriteria ); - Predicate_ptr GetPredicate(); - Predicate_i* GetPredicate_i(); - -private: - Controls::Filter myFilter; - Predicate_i* myPredicate; -}; - - -/* - FILTER LIBRARY -*/ -class FilterLibrary_i: public virtual POA_SMESH::FilterLibrary, - public virtual SALOME::GenericObj_i -{ -public: - FilterLibrary_i( const char* theFileName ); - FilterLibrary_i(); - ~FilterLibrary_i(); - - Filter_ptr Copy( const char* theFilterName ); - - CORBA::Boolean Add ( const char* theFilterName, Filter_ptr theFilter ); - CORBA::Boolean AddEmpty( const char* theFilterName, ElementType theType ); - CORBA::Boolean Delete ( const char* theFilterName ); - CORBA::Boolean Replace ( const char* theFilterName, - const char* theNewName, - Filter_ptr theFilter ); - - CORBA::Boolean Save(); - CORBA::Boolean SaveAs( const char* aFileName ); + /* + Class : LogicalOR_i + Description : Logical OR + */ + class LogicalOR_i: public virtual POA_SMESH::LogicalOR, + public virtual LogicalBinary_i + { + public: + LogicalOR_i(); + FunctorType GetFunctorType(); + }; - CORBA::Boolean IsPresent( const char* aFilterName ); - CORBA::Long NbFilters( ElementType ); - string_array* GetNames( ElementType ); - string_array* GetAllNames(); - void SetFileName( const char* theFileName ); - char* GetFileName(); - -private: - char* myFileName; - LDOM_Document myDoc; - FilterManager_var myFilterMgr; -}; - - -/* - FILTER MANAGER -*/ - -class FilterManager_i: public virtual POA_SMESH::FilterManager, - public virtual SALOME::GenericObj_i -{ -public: - FilterManager_i(); - MinimumAngle_ptr CreateMinimumAngle(); - AspectRatio_ptr CreateAspectRatio(); - AspectRatio3D_ptr CreateAspectRatio3D(); - Warping_ptr CreateWarping(); - Taper_ptr CreateTaper(); - Skew_ptr CreateSkew(); - Area_ptr CreateArea(); - Length_ptr CreateLength(); - Length2D_ptr CreateLength2D(); - MultiConnection_ptr CreateMultiConnection(); - MultiConnection2D_ptr CreateMultiConnection2D(); - BelongToGeom_ptr CreateBelongToGeom(); - BelongToPlane_ptr CreateBelongToPlane(); - BelongToCylinder_ptr CreateBelongToCylinder(); + /* + FILTER + */ + class Filter_i: public virtual POA_SMESH::Filter, + public virtual SALOME::GenericObj_i + { + public: + Filter_i(); + ~Filter_i(); + + virtual + void + SetPredicate( Predicate_ptr ); - LyingOnGeom_ptr CreateLyingOnGeom(); + virtual + void + SetMesh( SMESH_Mesh_ptr ); - FreeBorders_ptr CreateFreeBorders(); - FreeEdges_ptr CreateFreeEdges(); + virtual + SMESH::long_array* + GetIDs(); + + static + void + GetElementsId( Predicate_i*, + const SMDS_Mesh*, + Controls::Filter::TIdSequence& ); + static + void + GetElementsId( Predicate_i*, + SMESH_Mesh_ptr, + Controls::Filter::TIdSequence& ); + + virtual + long_array* + GetElementsId( SMESH_Mesh_ptr ); - RangeOfIds_ptr CreateRangeOfIds(); + virtual + ElementType + GetElementType(); + + virtual + CORBA::Boolean + GetCriteria( SMESH::Filter::Criteria_out theCriteria ); - BadOrientedVolume_ptr CreateBadOrientedVolume(); + virtual + CORBA::Boolean + SetCriteria( const SMESH::Filter::Criteria& theCriteria ); + + virtual + Predicate_ptr + GetPredicate(); - LessThan_ptr CreateLessThan(); - MoreThan_ptr CreateMoreThan(); - EqualTo_ptr CreateEqualTo(); + Predicate_i* GetPredicate_i(); + + private: + Controls::Filter myFilter; + Predicate_i* myPredicate; + SMESH_Mesh_var myMesh; + }; - LogicalNOT_ptr CreateLogicalNOT(); - LogicalAND_ptr CreateLogicalAND(); - LogicalOR_ptr CreateLogicalOR(); + + /* + FILTER LIBRARY + */ + class FilterLibrary_i: public virtual POA_SMESH::FilterLibrary, + public virtual SALOME::GenericObj_i + { + public: + FilterLibrary_i( const char* theFileName ); + FilterLibrary_i(); + ~FilterLibrary_i(); + + Filter_ptr Copy( const char* theFilterName ); + + CORBA::Boolean Add ( const char* theFilterName, Filter_ptr theFilter ); + CORBA::Boolean AddEmpty( const char* theFilterName, ElementType theType ); + CORBA::Boolean Delete ( const char* theFilterName ); + CORBA::Boolean Replace ( const char* theFilterName, + const char* theNewName, + Filter_ptr theFilter ); + + CORBA::Boolean Save(); + CORBA::Boolean SaveAs( const char* aFileName ); + + CORBA::Boolean IsPresent( const char* aFilterName ); + CORBA::Long NbFilters( ElementType ); + string_array* GetNames( ElementType ); + string_array* GetAllNames(); + void SetFileName( const char* theFileName ); + char* GetFileName(); + + private: + char* myFileName; + LDOM_Document myDoc; + FilterManager_var myFilterMgr; + }; + + + /* + FILTER MANAGER + */ + + class FilterManager_i: public virtual POA_SMESH::FilterManager, + public virtual SALOME::GenericObj_i + { + public: + FilterManager_i(); + ~FilterManager_i(); - Filter_ptr CreateFilter(); - - FilterLibrary_ptr LoadLibrary( const char* aFileName ); - FilterLibrary_ptr CreateLibrary(); - CORBA::Boolean DeleteLibrary( const char* aFileName ); -}; - - - -}; + MinimumAngle_ptr CreateMinimumAngle(); + AspectRatio_ptr CreateAspectRatio(); + AspectRatio3D_ptr CreateAspectRatio3D(); + Warping_ptr CreateWarping(); + Taper_ptr CreateTaper(); + Skew_ptr CreateSkew(); + Area_ptr CreateArea(); + Length_ptr CreateLength(); + Length2D_ptr CreateLength2D(); + MultiConnection_ptr CreateMultiConnection(); + MultiConnection2D_ptr CreateMultiConnection2D(); + + BelongToGeom_ptr CreateBelongToGeom(); + BelongToPlane_ptr CreateBelongToPlane(); + BelongToCylinder_ptr CreateBelongToCylinder(); + + LyingOnGeom_ptr CreateLyingOnGeom(); + + FreeBorders_ptr CreateFreeBorders(); + FreeEdges_ptr CreateFreeEdges(); + + RangeOfIds_ptr CreateRangeOfIds(); + + BadOrientedVolume_ptr CreateBadOrientedVolume(); + + LessThan_ptr CreateLessThan(); + MoreThan_ptr CreateMoreThan(); + EqualTo_ptr CreateEqualTo(); + + LogicalNOT_ptr CreateLogicalNOT(); + LogicalAND_ptr CreateLogicalAND(); + LogicalOR_ptr CreateLogicalOR(); + + Filter_ptr CreateFilter(); + + FilterLibrary_ptr LoadLibrary( const char* aFileName ); + FilterLibrary_ptr CreateLibrary(); + CORBA::Boolean DeleteLibrary( const char* aFileName ); + }; + + + Predicate_i* + GetPredicate( SMESH::Predicate_ptr thePredicate ); +} #endif diff --git a/src/SMESH_I/SMESH_Gen_i.cxx b/src/SMESH_I/SMESH_Gen_i.cxx index 9eb0f79ff..1817f0e23 100644 --- a/src/SMESH_I/SMESH_Gen_i.cxx +++ b/src/SMESH_I/SMESH_Gen_i.cxx @@ -472,12 +472,24 @@ SMESH::SMESH_Hypothesis_ptr SMESH_Gen_i::CreateHypothesis( const char* theHypNam SMESH::SMESH_Hypothesis_var hyp = this->createHypothesis( theHypName, theLibName ); // Publish hypothesis/algorithm in the study - if ( CanPublishInStudy( hyp ) ) - PublishHypothesis( myCurrentStudy, hyp ); + if ( CanPublishInStudy( hyp ) ) { + SALOMEDS::SObject_var aSO = PublishHypothesis( myCurrentStudy, hyp ); + if ( !aSO->_is_nil() ) { + // Update Python script + TCollection_AsciiString aStr (aSO->GetID()); + aStr += " = smesh.CreateHypothesis(\""; + aStr += Standard_CString(theHypName); + aStr += "\", \""; + aStr += Standard_CString(theLibName); + aStr += "\")"; + + AddToCurrentPyScript(aStr); + } + } return hyp._retn(); } - + //============================================================================= /*! * SMESH_Gen_i::CreateMesh @@ -497,13 +509,23 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::CreateMesh( GEOM::GEOM_Object_ptr theShapeObj SMESH_Mesh_i* meshServant = dynamic_cast( GetServant( mesh ).in() ); ASSERT( meshServant ); meshServant->SetShape( theShapeObject ); + // publish mesh in the study - if( CanPublishInStudy( mesh ) ){ + if ( CanPublishInStudy( mesh ) ) { SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder(); aStudyBuilder->NewCommand(); // There is a transaction - PublishMesh( myCurrentStudy, mesh.in() ); + SALOMEDS::SObject_var aSO = PublishMesh( myCurrentStudy, mesh.in() ); aStudyBuilder->CommitCommand(); + if ( !aSO->_is_nil() ) { + // Update Python script + TCollection_AsciiString aStr (aSO->GetID()); + aStr += " = smesh.CreateMesh("; + SMESH_Gen_i::AddObject(aStr, theShapeObject) += ")"; + + AddToCurrentPyScript(aStr); + } } + return mesh._retn(); } @@ -524,11 +546,20 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::CreateMeshesFromUNV( const char* theFileName SMESH::SMESH_Mesh_var aMesh = createMesh(); string aFileName; // = boost::filesystem::path(theFileName).leaf(); // publish mesh in the study - if ( CanPublishInStudy( aMesh ) ){ + if ( CanPublishInStudy( aMesh ) ) { SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder(); aStudyBuilder->NewCommand(); // There is a transaction - PublishMesh( myCurrentStudy, aMesh.in(), aFileName.c_str() ); + SALOMEDS::SObject_var aSO = PublishMesh( myCurrentStudy, aMesh.in(), aFileName.c_str() ); aStudyBuilder->CommitCommand(); + if ( !aSO->_is_nil() ) { + // Update Python script + TCollection_AsciiString aStr (aSO->GetID()); + aStr += " = smesh.CreateMeshesFromUNV(\""; + aStr += Standard_CString(theFileName); + aStr += "\")"; + + AddToCurrentPyScript(aStr); + } } SMESH_Mesh_i* aServant = dynamic_cast( GetServant( aMesh ).in() ); @@ -552,6 +583,9 @@ SMESH::mesh_array* SMESH_Gen_i::CreateMeshesFromMED( const char* theFileName, Unexpect aCatch(SALOME_SalomeException); if(MYDEBUG) MESSAGE( "SMESH_Gen_i::CreateMeshFromMED" ); + // Python Dump + TCollection_AsciiString aStr ("(["); + // Retrieve mesh names from the file DriverMED_R_SMESHDS_Mesh myReader; myReader.SetFile( theFileName ); @@ -560,22 +594,33 @@ SMESH::mesh_array* SMESH_Gen_i::CreateMeshesFromMED( const char* theFileName, list aNames = myReader.GetMeshNames(aStatus); SMESH::mesh_array_var aResult = new SMESH::mesh_array(); theStatus = (SMESH::DriverMED_ReadStatus)aStatus; - if(theStatus == SMESH::DRS_OK){ + if (theStatus == SMESH::DRS_OK) { SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder(); aStudyBuilder->NewCommand(); // There is a transaction - aResult->length( aNames.size() ); int i = 0; - + // Iterate through all meshes and create mesh objects for ( list::iterator it = aNames.begin(); it != aNames.end(); it++ ) { + // Python Dump + if (i > 0) aStr += ", "; + // create mesh SMESH::SMESH_Mesh_var mesh = createMesh(); // publish mesh in the study + SALOMEDS::SObject_var aSO; if ( CanPublishInStudy( mesh ) ) - PublishMesh( myCurrentStudy, mesh.in(), (*it).c_str() ); - + aSO = PublishMesh( myCurrentStudy, mesh.in(), (*it).c_str() ); + if ( !aSO->_is_nil() ) { + // Python Dump + aStr += aSO->GetID(); + } else { + // Python Dump + aStr += "mesh_"; + aStr += TCollection_AsciiString(i); + } + // Read mesh data (groups are published automatically by ImportMEDFile()) SMESH_Mesh_i* meshServant = dynamic_cast( GetServant( mesh ).in() ); ASSERT( meshServant ); @@ -588,6 +633,14 @@ SMESH::mesh_array* SMESH_Gen_i::CreateMeshesFromMED( const char* theFileName, } aStudyBuilder->CommitCommand(); } + + // Update Python script + aStr += "], status) = smesh.CreateMeshesFromMED(\""; + aStr += Standard_CString(theFileName); + aStr += "\")"; + + AddToCurrentPyScript(aStr); + return aResult._retn(); } @@ -608,11 +661,21 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::CreateMeshesFromSTL( const char* theFileName SMESH::SMESH_Mesh_var aMesh = createMesh(); string aFileName; // = boost::filesystem::path(theFileName).leaf(); // publish mesh in the study - if( CanPublishInStudy( aMesh ) ){ + if ( CanPublishInStudy( aMesh ) ) { SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder(); aStudyBuilder->NewCommand(); // There is a transaction - PublishInStudy( myCurrentStudy, SALOMEDS::SObject::_nil(), aMesh.in(), aFileName.c_str() ); + SALOMEDS::SObject_var aSO = PublishInStudy + ( myCurrentStudy, SALOMEDS::SObject::_nil(), aMesh.in(), aFileName.c_str() ); aStudyBuilder->CommitCommand(); + if ( !aSO->_is_nil() ) { + // Update Python script + TCollection_AsciiString aStr (aSO->GetID()); + aStr += " = smesh.CreateMeshesFromSTL(\""; + aStr += Standard_CString(theFileName); + aStr += "\")"; + + AddToCurrentPyScript(aStr); + } } SMESH_Mesh_i* aServant = dynamic_cast( GetServant( aMesh ).in() ); @@ -760,6 +823,17 @@ CORBA::Boolean SMESH_Gen_i::Compute( SMESH::SMESH_Mesh_ptr theMesh, THROW_SALOME_CORBA_EXCEPTION( "bad Mesh reference", SALOME::BAD_PARAM ); + // Update Python script + TCollection_AsciiString aStr ("isDone = smesh.Compute("); + SMESH_Gen_i::AddObject(aStr, theMesh) += ", "; + SMESH_Gen_i::AddObject(aStr, theShapeObject) += ")"; + + AddToCurrentPyScript(aStr); + + aStr = "if isDone == 0: print \"Mesh "; + SMESH_Gen_i::AddObject(aStr, theMesh) += " computation failed\""; + AddToCurrentPyScript(aStr); + try { // get mesh servant SMESH_Mesh_i* meshServant = dynamic_cast( GetServant( theMesh ).in() ); @@ -801,6 +875,9 @@ SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent, theComponent->GetStudy()->StudyId() != myCurrentStudy->StudyId() ) SetCurrentStudy( theComponent->GetStudy() ); + // Store study contents as a set of python commands + SavePython(myCurrentStudy); + StudyContext* myStudyContext = GetCurrentStudyContext(); // Declare a byte stream diff --git a/src/SMESH_I/SMESH_Gen_i.hxx b/src/SMESH_I/SMESH_Gen_i.hxx index a93301653..152edb6ce 100644 --- a/src/SMESH_I/SMESH_Gen_i.hxx +++ b/src/SMESH_I/SMESH_Gen_i.hxx @@ -45,7 +45,12 @@ #include "SMESH_Gen.hxx" #include "GEOM_Client.hxx" +#include +#include +#include + #include +#include class SMESH_Mesh_i; class SALOME_LifeCycleCORBA; @@ -273,6 +278,56 @@ public: return aResultSO._retn(); } + // ============ + // Dump python + // ============ + + virtual Engines::TMPFile* DumpPython(CORBA::Object_ptr theStudy, + CORBA::Boolean isPublished, + CORBA::Boolean& isValidScript); + + void AddToPythonScript (int theStudyID, const TCollection_AsciiString& theString); + + void RemoveLastFromPythonScript (int theStudyID); + + static void AddToCurrentPyScript (const TCollection_AsciiString& theString); + + void SavePython (SALOMEDS::Study_ptr theStudy); + + TCollection_AsciiString DumpPython_impl (int theStudyID, + Resource_DataMapOfAsciiStringAsciiString& theObjectNames, + Resource_DataMapOfAsciiStringAsciiString& theNames, + bool isPublished, + bool& aValidScript, + const TCollection_AsciiString& theSavedTrace); + + TCollection_AsciiString GetNewPythonLines (int theStudyID); + + void CleanPythonTrace (int theStudyID); + + // Dump python comfort methods + + static TCollection_AsciiString& AddObject(TCollection_AsciiString& theStr, + CORBA::Object_ptr theObject); + // add object to script string + + template + static TCollection_AsciiString& AddArray(TCollection_AsciiString& theStr, + const _array & array) + // put array contents into theStr like this: "[ 1, 2, 5 ]" + { + ostringstream sout; // can convert long int, and TCollection_AsciiString cant + sout << "[ "; + for (int i = 1; i <= array.length(); i++) { + sout << array[i-1]; + if ( i < array.length() ) + sout << ", "; + } + sout << " ]"; + theStr += (char*) sout.str().c_str(); + return theStr; + } + // ***************************************** // Internal methods // ***************************************** @@ -369,6 +424,21 @@ private: GEOM_Client* myShapeReader; // Shape reader SALOMEDS::Study_var myCurrentStudy; // Current study + + // Dump Python: trace of API methods calls + std::map < int, Handle(TColStd_HSequenceOfAsciiString) > myPythonScripts; }; + +namespace SMESH +{ + template + T + DownCast(CORBA::Object_ptr theArg) + { + return dynamic_cast(SMESH_Gen_i::GetServant(theArg).in()); + } +} + + #endif diff --git a/src/SMESH_I/SMESH_Group_i.cxx b/src/SMESH_I/SMESH_Group_i.cxx index 78ca52898..47236abcc 100644 --- a/src/SMESH_I/SMESH_Group_i.cxx +++ b/src/SMESH_I/SMESH_Group_i.cxx @@ -33,8 +33,14 @@ #include "SMESHDS_Group.hxx" #include "SMESHDS_GroupOnGeom.hxx" #include "SMDSAbs_ElementType.hxx" + +#include "SMESH_Filter_i.hxx" +#include "SMESH_PythonDump.hxx" + #include "utilities.h" +using namespace SMESH; + //============================================================================= /*! * @@ -113,6 +119,14 @@ SMESHDS_GroupBase* SMESH_GroupBase_i::GetGroupDS() const void SMESH_GroupBase_i::SetName( const char* theName ) { + // Update Python script + TCollection_AsciiString aStr, aStrName ((char*)theName); + SMESH_Gen_i::AddObject(aStr, _this()) += ".SetName(\""; + aStr += aStrName + "\")"; + + SMESH_Gen_i::AddToCurrentPyScript(aStr); + + // Perform renaming ::SMESH_Group* aGroup = GetSmeshGroup(); if (aGroup) { aGroup->SetName(theName); @@ -204,6 +218,13 @@ CORBA::Boolean SMESH_GroupBase_i::IsEmpty() void SMESH_Group_i::Clear() { + // Update Python script + TCollection_AsciiString aStr; + SMESH_Gen_i::AddObject(aStr, _this()) += ".Clear()"; + + SMESH_Gen_i::AddToCurrentPyScript(aStr); + + // Clear the group SMESHDS_Group* aGroupDS = dynamic_cast( GetGroupDS() ); if (aGroupDS) { aGroupDS->Clear(); @@ -235,6 +256,14 @@ CORBA::Boolean SMESH_GroupBase_i::Contains( CORBA::Long theID ) CORBA::Long SMESH_Group_i::Add( const SMESH::long_array& theIDs ) { + // Update Python script + TCollection_AsciiString aStr ("nbAdd = "); + SMESH_Gen_i::AddObject(aStr, _this()) += ".Add("; + SMESH_Gen_i::AddArray(aStr, theIDs) += ")"; + + SMESH_Gen_i::AddToCurrentPyScript(aStr); + + // Add elements to the group SMESHDS_Group* aGroupDS = dynamic_cast( GetGroupDS() ); if (aGroupDS) { int nbAdd = 0; @@ -255,6 +284,86 @@ CORBA::Long SMESH_Group_i::Add( const SMESH::long_array& theIDs ) */ //============================================================================= +CORBA::Long SMESH_Group_i::Remove( const SMESH::long_array& theIDs ) +{ + // Update Python script + TCollection_AsciiString aStr ("nbDel = "); + SMESH_Gen_i::AddObject(aStr, _this()) += ".Remove("; + SMESH_Gen_i::AddArray(aStr, theIDs) += ")"; + + SMESH_Gen_i::AddToCurrentPyScript(aStr); + + // Remove elements from the group + SMESHDS_Group* aGroupDS = dynamic_cast( GetGroupDS() ); + if (aGroupDS) { + int nbDel = 0; + for (int i = 0; i < theIDs.length(); i++) { + int anID = (int) theIDs[i]; + if (aGroupDS->Remove(anID)) + nbDel++; + } + return nbDel; + } + MESSAGE("attempt to remove elements from a vague group"); + return 0; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +typedef bool (SMESHDS_Group::*TFunChangeGroup)(const int); + +CORBA::Long +ChangeByPredicate( SMESH::Predicate_i* thePredicate, + SMESHDS_GroupBase* theGroupBase, + TFunChangeGroup theFun) +{ + CORBA::Long aNb = 0; + if(SMESHDS_Group* aGroupDS = dynamic_cast(theGroupBase)){ + SMESH::Controls::Filter::TIdSequence aSequence; + const SMDS_Mesh* aMesh = theGroupBase->GetMesh(); + SMESH::Filter_i::GetElementsId(thePredicate,aMesh,aSequence); + + CORBA::Long i = 0, iEnd = aSequence.size(); + for(; i < iEnd; i++) + if((aGroupDS->*theFun)(aSequence[i])) + aNb++; + return aNb; + } + return aNb; +} + +CORBA::Long +SMESH_Group_i:: +AddByPredicate( SMESH::Predicate_ptr thePredicate ) +{ + if(SMESH::Predicate_i* aPredicate = SMESH::GetPredicate(thePredicate)){ + TPythonDump()<<_this()<<".AddByPredicate("<( GetGroupDS() ); - if (aGroupDS) { - int nbDel = 0; - for (int i = 0; i < theIDs.length(); i++) { - int anID = (int) theIDs[i]; - if (aGroupDS->Remove(anID)) - nbDel++; - } - return nbDel; - } - MESSAGE("attempt to remove elements from a vague group"); - return 0; -} - //============================================================================= /*! * diff --git a/src/SMESH_I/SMESH_Group_i.hxx b/src/SMESH_I/SMESH_Group_i.hxx index 48fb1c036..e9801b258 100644 --- a/src/SMESH_I/SMESH_Group_i.hxx +++ b/src/SMESH_I/SMESH_Group_i.hxx @@ -37,7 +37,7 @@ #include "SALOME_GenericObj_i.hh" class SMESH_Mesh_i; -class ::SMESH_Group; +class SMESH_Group; class SMESHDS_GroupBase; // =========== @@ -70,7 +70,7 @@ class SMESH_GroupBase_i: // Internal C++ interface int GetLocalID() const { return myLocalID; } SMESH_Mesh_i* GetMeshServant() const { return myMeshServant; } - ::SMESH_Group* GetSmeshGroup() const; + SMESH_Group* GetSmeshGroup() const; SMESHDS_GroupBase* GetGroupDS() const; private: @@ -93,6 +93,9 @@ class SMESH_Group_i: void Clear(); CORBA::Long Add( const SMESH::long_array& theIDs ); CORBA::Long Remove( const SMESH::long_array& theIDs ); + + CORBA::Long AddByPredicate( SMESH::Predicate_ptr thePredicate ); + CORBA::Long RemoveByPredicate( SMESH::Predicate_ptr thePredicate ); }; // ========================= diff --git a/src/SMESH_I/SMESH_MEDFamily_i.hxx b/src/SMESH_I/SMESH_MEDFamily_i.hxx index e48a49626..e60379c04 100644 --- a/src/SMESH_I/SMESH_MEDFamily_i.hxx +++ b/src/SMESH_I/SMESH_MEDFamily_i.hxx @@ -61,8 +61,8 @@ public : // IDL Methods void setProtocol(SALOME::TypeOfCommunication typ) {} void release() {} - SALOME::Sender_ptr getSenderForNumber(long int) {return SALOME::Sender::_nil();} - SALOME::Sender_ptr getSenderForNumberIndex() {return SALOME::Sender::_nil();} + SALOME::SenderInt_ptr getSenderForNumber(long int) {return SALOME::SenderInt::_nil();} + SALOME::SenderInt_ptr getSenderForNumberIndex() {return SALOME::SenderInt::_nil();} CORBA::Long getIdentifier() throw (SALOME::SALOME_Exception); diff --git a/src/SMESH_I/SMESH_MEDMesh_i.hxx b/src/SMESH_I/SMESH_MEDMesh_i.hxx index e8e82f17b..3e8fe7a35 100644 --- a/src/SMESH_I/SMESH_MEDMesh_i.hxx +++ b/src/SMESH_I/SMESH_MEDMesh_i.hxx @@ -77,8 +77,8 @@ class SMESH_MEDMesh_i: // IDL Methods void setProtocol(SALOME::TypeOfCommunication typ) {} void release() {} - SALOME::Sender_ptr getSenderForCoordinates(long int) {return SALOME::Sender::_nil();} - SALOME::Sender_ptr getSenderForConnectivity(long int, long int, long int, long int) {return SALOME::Sender::_nil();} + SALOME::SenderDouble_ptr getSenderForCoordinates(long int) {return SALOME::SenderDouble::_nil();} + SALOME::SenderInt_ptr getSenderForConnectivity(long int, long int, long int, long int) {return SALOME::SenderInt::_nil();} char *getName() throw(SALOME::SALOME_Exception); CORBA::Long getSpaceDimension() throw(SALOME::SALOME_Exception); @@ -216,6 +216,8 @@ class SMESH_MEDMesh_i: SALOME_MED::MESH::meshInfos * getMeshGlobal() throw (SALOME::SALOME_Exception); + bool areEquals(SALOME_MED::MESH_ptr other) { return false;}; + SALOME_MED::MESH::coordinateInfos * getCoordGlobal() throw (SALOME::SALOME_Exception); diff --git a/src/SMESH_I/SMESH_MeshEditor_i.cxx b/src/SMESH_I/SMESH_MeshEditor_i.cxx index 6a4799a73..2c444819c 100644 --- a/src/SMESH_I/SMESH_MeshEditor_i.cxx +++ b/src/SMESH_I/SMESH_MeshEditor_i.cxx @@ -43,8 +43,28 @@ #include #include +#include + using namespace std; +//======================================================================= +//function : addAxis +//purpose : +//======================================================================= + +static TCollection_AsciiString& addAxis(TCollection_AsciiString& theStr, + const SMESH::AxisStruct & theAxis) +{ + theStr += "SMESH.AxisStruct( "; + theStr += TCollection_AsciiString( theAxis.x ) + ", "; + theStr += TCollection_AsciiString( theAxis.y ) + ", "; + theStr += TCollection_AsciiString( theAxis.z ) + ", "; + theStr += TCollection_AsciiString( theAxis.vx ) + ", "; + theStr += TCollection_AsciiString( theAxis.vy ) + ", "; + theStr += TCollection_AsciiString( theAxis.vz ) + " )"; + return theStr; +} + //============================================================================= /*! * @@ -62,14 +82,23 @@ SMESH_MeshEditor_i::SMESH_MeshEditor_i(SMESH_Mesh* theMesh) */ //============================================================================= -CORBA::Boolean SMESH_MeshEditor_i::RemoveElements(const SMESH:: - long_array & IDsOfElements) +CORBA::Boolean + SMESH_MeshEditor_i::RemoveElements(const SMESH::long_array & IDsOfElements) { ::SMESH_MeshEditor anEditor( _myMesh ); list< int > IdList; + for (int i = 0; i < IDsOfElements.length(); i++) IdList.push_back( IDsOfElements[i] ); + // Update Python script + TCollection_AsciiString str ("isDone = mesh_editor.RemoveElements("); + SMESH_Gen_i::AddArray( str, IDsOfElements ) += ")"; + SMESH_Gen_i::AddToCurrentPyScript( str ); +#ifdef _DEBUG_ + SMESH_Gen_i::AddToCurrentPyScript( "print \"RemoveElements: \", isDone" ); +#endif + // Remove Elements return anEditor.Remove( IdList, false ); }; @@ -87,6 +116,14 @@ CORBA::Boolean SMESH_MeshEditor_i::RemoveNodes(const SMESH:: for (int i = 0; i < IDsOfNodes.length(); i++) IdList.push_back( IDsOfNodes[i] ); + // Update Python script + TCollection_AsciiString str ("isDone = mesh_editor.RemoveNodes("); + SMESH_Gen_i::AddArray( str, IDsOfNodes ) += ")"; + SMESH_Gen_i::AddToCurrentPyScript( str ); +#ifdef _DEBUG_ + SMESH_Gen_i::AddToCurrentPyScript( "print \"RemoveNodes: \", isDone" ); +#endif + return anEditor.Remove( IdList, true ); }; @@ -98,14 +135,20 @@ CORBA::Boolean SMESH_MeshEditor_i::RemoveNodes(const SMESH:: CORBA::Boolean SMESH_MeshEditor_i::AddEdge(const SMESH::long_array & IDsOfNodes) { - int NbNodes = IDsOfNodes.length(); - if (NbNodes == 2) - { - CORBA::Long index1 = IDsOfNodes[0]; - CORBA::Long index2 = IDsOfNodes[1]; - GetMeshDS()->AddEdge(GetMeshDS()->FindNode(index1), GetMeshDS()->FindNode(index2)); - } - return true; + int NbNodes = IDsOfNodes.length(); + if (NbNodes == 2) + { + CORBA::Long index1 = IDsOfNodes[0]; + CORBA::Long index2 = IDsOfNodes[1]; + GetMeshDS()->AddEdge(GetMeshDS()->FindNode(index1), GetMeshDS()->FindNode(index2)); + + // Update Python script + TCollection_AsciiString str ("isDone = mesh_editor.AddEdge(["); + str += TCollection_AsciiString((int) index1) + ", "; + str += TCollection_AsciiString((int) index2) + " ])"; + SMESH_Gen_i::AddToCurrentPyScript( str ); + } + return true; } //============================================================================= @@ -115,33 +158,60 @@ CORBA::Boolean SMESH_MeshEditor_i::AddEdge(const SMESH::long_array & IDsOfNodes) //============================================================================= CORBA::Boolean SMESH_MeshEditor_i::AddNode(CORBA::Double x, - CORBA::Double y, CORBA::Double z) + CORBA::Double y, CORBA::Double z) { - MESSAGE(" AddNode " << x << " , " << y << " , " << z) - int idNode = GetMeshDS()->AddNode(x, y, z)->GetID(); - MESSAGE(" idNode " << idNode) return true; + GetMeshDS()->AddNode(x, y, z); + + // Update Python script + TCollection_AsciiString str ("isDone = mesh_editor.AddNode("); + str += TCollection_AsciiString( x ) + ", "; + str += TCollection_AsciiString( y ) + ", "; + str += TCollection_AsciiString( z ) + " )"; + SMESH_Gen_i::AddToCurrentPyScript( str ); + + return true; } //============================================================================= /*! - * + * AddFace */ //============================================================================= CORBA::Boolean SMESH_MeshEditor_i::AddFace(const SMESH::long_array & IDsOfNodes) { - int NbNodes = IDsOfNodes.length(); - const SMDS_MeshNode* nodes[4]; - for(int i=0;iFindNode(IDsOfNodes[i]); - if (NbNodes == 3) - { - GetMeshDS()->AddFace(nodes[0], nodes[1], nodes[2]); - } - else if (NbNodes == 4) - { - GetMeshDS()->AddFace(nodes[0], nodes[1], nodes[2], nodes[3]); - } - return true; + int NbNodes = IDsOfNodes.length(); + if (NbNodes < 3) + { + return false; + } + + std::vector nodes (NbNodes); + for (int i = 0; i < NbNodes; i++) + nodes[i] = GetMeshDS()->FindNode(IDsOfNodes[i]); + + if (NbNodes == 3) + { + GetMeshDS()->AddFace(nodes[0], nodes[1], nodes[2]); + } + else if (NbNodes == 4) + { + GetMeshDS()->AddFace(nodes[0], nodes[1], nodes[2], nodes[3]); + } + else + { + GetMeshDS()->AddPolygonalFace(nodes); + } + + // Update Python script + TCollection_AsciiString str ("isDone = mesh_editor.AddFace("); + SMESH_Gen_i::AddArray( str, IDsOfNodes ) += ")"; + SMESH_Gen_i::AddToCurrentPyScript( str ); +#ifdef _DEBUG_ + SMESH_Gen_i::AddToCurrentPyScript( "print \"AddFace: \", isDone" ); +#endif + + return true; }; //============================================================================= @@ -151,20 +221,97 @@ CORBA::Boolean SMESH_MeshEditor_i::AddFace(const SMESH::long_array & IDsOfNodes) //============================================================================= CORBA::Boolean SMESH_MeshEditor_i::AddVolume(const SMESH:: - long_array & IDsOfNodes) + long_array & IDsOfNodes) { - int NbNodes = IDsOfNodes.length(); - const SMDS_MeshNode* n[8]; - for(int i=0;iFindNode(IDsOfNodes[i]); + int NbNodes = IDsOfNodes.length(); + vector< const SMDS_MeshNode*> n(NbNodes); + for(int i=0;iFindNode(IDsOfNodes[i]); - switch(NbNodes) - { - case 4:GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3]); break; - case 5:GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3],n[4]); break; - case 6:GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3],n[4],n[5]); break; - case 8:GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7]); break; - } - return true; + switch(NbNodes) + { + case 4:GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3]); break; + case 5:GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3],n[4]); break; + case 6:GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3],n[4],n[5]); break; + case 8:GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7]); break; + } + // Update Python script + TCollection_AsciiString str ("isDone = mesh_editor.AddVolume("); + SMESH_Gen_i::AddArray( str, IDsOfNodes ) += ")"; + SMESH_Gen_i::AddToCurrentPyScript( str ); +#ifdef _DEBUG_ + SMESH_Gen_i::AddToCurrentPyScript( "print \"AddVolume: \", isDone" ); +#endif + + return true; +}; + +//============================================================================= +/*! + * AddPolyhedralVolume + */ +//============================================================================= +CORBA::Boolean SMESH_MeshEditor_i::AddPolyhedralVolume + (const SMESH::long_array & IDsOfNodes, + const SMESH::long_array & Quantities) +{ + int NbNodes = IDsOfNodes.length(); + std::vector n (NbNodes); + for (int i = 0; i < NbNodes; i++) + n[i] = GetMeshDS()->FindNode(IDsOfNodes[i]); + + int NbFaces = Quantities.length(); + std::vector q (NbFaces); + for (int j = 0; j < NbFaces; j++) + q[j] = Quantities[j]; + + GetMeshDS()->AddPolyhedralVolume(n, q); + + // Update Python script + TCollection_AsciiString str ("isDone = mesh_editor.AddPolyhedralVolume("); + SMESH_Gen_i::AddArray( str, IDsOfNodes ) += ", "; + SMESH_Gen_i::AddArray( str, Quantities ) += ")"; + SMESH_Gen_i::AddToCurrentPyScript( str ); +#ifdef _DEBUG_ + SMESH_Gen_i::AddToCurrentPyScript( "print \"AddPolyhedralVolume: \", isDone" ); +#endif + + return true; +}; + +//============================================================================= +/*! + * AddPolyhedralVolumeByFaces + */ +//============================================================================= +CORBA::Boolean SMESH_MeshEditor_i::AddPolyhedralVolumeByFaces + (const SMESH::long_array & IdsOfFaces) +{ + int NbFaces = IdsOfFaces.length(); + std::vector poly_nodes; + std::vector quantities (NbFaces); + + for (int i = 0; i < NbFaces; i++) { + const SMDS_MeshElement* aFace = GetMeshDS()->FindElement(IdsOfFaces[i]); + quantities[i] = aFace->NbNodes(); + + SMDS_ElemIteratorPtr It = aFace->nodesIterator(); + while (It->more()) { + poly_nodes.push_back(static_cast(It->next())); + } + } + + GetMeshDS()->AddPolyhedralVolume(poly_nodes, quantities); + + // Update Python script + TCollection_AsciiString str ("isDone = mesh_editor.AddPolyhedralVolumeByFaces("); + SMESH_Gen_i::AddArray( str, IdsOfFaces ) += ")"; + SMESH_Gen_i::AddToCurrentPyScript( str ); +#ifdef _DEBUG_ + SMESH_Gen_i::AddToCurrentPyScript( "print \"AddPolyhedralVolume: \", isDone" ); +#endif + + return true; }; //============================================================================= @@ -184,6 +331,14 @@ CORBA::Boolean SMESH_MeshEditor_i::MoveNode(CORBA::Long NodeID, GetMeshDS()->MoveNode(node, x, y, z); + // Update Python script + TCollection_AsciiString str ("isDone = mesh_editor.MoveNode("); + str += TCollection_AsciiString((Standard_Integer) NodeID) + ", "; + str += TCollection_AsciiString((Standard_Real) x) + ", "; + str += TCollection_AsciiString((Standard_Real) y) + ", "; + str += TCollection_AsciiString((Standard_Real) z) + " )"; + SMESH_Gen_i::AddToCurrentPyScript( str ); + return true; } @@ -201,6 +356,12 @@ CORBA::Boolean SMESH_MeshEditor_i::InverseDiag(CORBA::Long NodeID1, if ( !n1 || !n2 ) return false; + // Update Python script + TCollection_AsciiString str ("isDone = mesh_editor.InverseDiag("); + str += TCollection_AsciiString((Standard_Integer) NodeID1) + ", "; + str += TCollection_AsciiString((Standard_Integer) NodeID2) + " )"; + SMESH_Gen_i::AddToCurrentPyScript( str ); + ::SMESH_MeshEditor aMeshEditor( _myMesh ); return aMeshEditor.InverseDiag ( n1, n2 ); } @@ -219,6 +380,12 @@ CORBA::Boolean SMESH_MeshEditor_i::DeleteDiag(CORBA::Long NodeID1, if ( !n1 || !n2 ) return false; + // Update Python script + TCollection_AsciiString str ("isDone = mesh_editor.DeleteDiag("); + str += TCollection_AsciiString((Standard_Integer) NodeID1) + ", "; + str += TCollection_AsciiString((Standard_Integer) NodeID2) + " )"; + SMESH_Gen_i::AddToCurrentPyScript( str ); + ::SMESH_MeshEditor aMeshEditor( _myMesh ); return aMeshEditor.DeleteDiag ( n1, n2 ); } @@ -239,6 +406,11 @@ CORBA::Boolean SMESH_MeshEditor_i::Reorient(const SMESH::long_array & IDsOfEleme if ( elem ) anEditor.Reorient( elem ); } + // Update Python script + TCollection_AsciiString str ("isDone = mesh_editor.Reorient("); + SMESH_Gen_i::AddArray( str, IDsOfElements ) += ")"; + SMESH_Gen_i::AddToCurrentPyScript( str ); + return true; } @@ -252,7 +424,18 @@ CORBA::Boolean SMESH_MeshEditor_i::Reorient(const SMESH::long_array & IDsOfEleme CORBA::Boolean SMESH_MeshEditor_i::ReorientObject(SMESH::SMESH_IDSource_ptr theObject) { SMESH::long_array_var anElementsId = theObject->GetIDs(); - return Reorient(anElementsId); + CORBA::Boolean isDone = Reorient(anElementsId); + + // Clear python line, created by Reorient() + SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen(); + aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID()); + + // Update Python script + TCollection_AsciiString str ("isDone = mesh_editor.ReorientObject("); + SMESH_Gen_i::AddObject( str, theObject ) += ")"; + SMESH_Gen_i::AddToCurrentPyScript( str ); + + return isDone; } //============================================================================= @@ -282,6 +465,15 @@ CORBA::Boolean else aCrit = aNumericalFunctor->GetNumericalFunctor(); + // Update Python script + TCollection_AsciiString str ("isDone = mesh_editor.TriToQuad("); + SMESH_Gen_i::AddArray( str, IDsOfElements ) += ", None, "; + str += (Standard_Real) MaxAngle; + SMESH_Gen_i::AddToCurrentPyScript( str + ")" ); +#ifdef _DEBUG_ + SMESH_Gen_i::AddToCurrentPyScript( "print \"TriToQuad: \", isDone" ); +#endif + ::SMESH_MeshEditor anEditor( _myMesh ); return anEditor.TriToQuad( faces, aCrit, MaxAngle ); } @@ -298,7 +490,25 @@ CORBA::Boolean CORBA::Double MaxAngle) { SMESH::long_array_var anElementsId = theObject->GetIDs(); - return TriToQuad(anElementsId, Criterion, MaxAngle); + CORBA::Boolean isDone = TriToQuad(anElementsId, Criterion, MaxAngle); + + // Clear python line(s), created by TriToQuad() + SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen(); + aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID()); +#ifdef _DEBUG_ + aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID()); +#endif + + // Update Python script + TCollection_AsciiString str ("isDone = mesh_editor.TriToQuadObject("); + SMESH_Gen_i::AddObject( str, theObject ) += ", None, "; + str += (Standard_Real) MaxAngle; + SMESH_Gen_i::AddToCurrentPyScript( str + ")" ); +#ifdef _DEBUG_ + SMESH_Gen_i::AddToCurrentPyScript( "print \"TriToQuadObject: \", isDone" ); +#endif + + return isDone; } //============================================================================= @@ -327,6 +537,15 @@ CORBA::Boolean else aCrit = aNumericalFunctor->GetNumericalFunctor(); + + // Update Python script + TCollection_AsciiString str ("isDone = mesh_editor.QuadToTri("); + SMESH_Gen_i::AddArray( str, IDsOfElements ) += ", None ), "; + SMESH_Gen_i::AddToCurrentPyScript( str ); +#ifdef _DEBUG_ + SMESH_Gen_i::AddToCurrentPyScript( "print \"QuadToTri: \", isDone" ); +#endif + ::SMESH_MeshEditor anEditor( _myMesh ); return anEditor.QuadToTri( faces, aCrit ); } @@ -350,6 +569,15 @@ CORBA::Boolean faces.insert( elem ); } + // Update Python script + TCollection_AsciiString str ("isDone = mesh_editor.SplitQuad("); + SMESH_Gen_i::AddArray( str, IDsOfElements ) += ", "; + str += TCollection_AsciiString( Diag13 ); + SMESH_Gen_i::AddToCurrentPyScript( str + ")" ); +#ifdef _DEBUG_ + SMESH_Gen_i::AddToCurrentPyScript( "print \"SplitQuad: \", isDone" ); +#endif + ::SMESH_MeshEditor anEditor( _myMesh ); return anEditor.QuadToTri( faces, Diag13 ); } @@ -365,7 +593,89 @@ CORBA::Boolean CORBA::Boolean Diag13) { SMESH::long_array_var anElementsId = theObject->GetIDs(); - return SplitQuad(anElementsId, Diag13); + CORBA::Boolean isDone = SplitQuad(anElementsId, Diag13); + + // Clear python line(s), created by SplitQuad() + SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen(); + aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID()); +#ifdef _DEBUG_ + aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID()); +#endif + + // Update Python script + TCollection_AsciiString str ("isDone = mesh_editor.SplitQuadObject("); + SMESH_Gen_i::AddObject( str, theObject ) += ", "; + str += TCollection_AsciiString( Diag13 ) + ")"; + SMESH_Gen_i::AddToCurrentPyScript( str ); +#ifdef _DEBUG_ + SMESH_Gen_i::AddToCurrentPyScript( "print \"SplitQuadObject: \", isDone" ); +#endif + + return isDone; +} + +//======================================================================= +//function : Smooth +//purpose : +//======================================================================= + +CORBA::Boolean + SMESH_MeshEditor_i::Smooth(const SMESH::long_array & IDsOfElements, + const SMESH::long_array & IDsOfFixedNodes, + CORBA::Long MaxNbOfIterations, + CORBA::Double MaxAspectRatio, + SMESH::SMESH_MeshEditor::Smooth_Method Method) +{ + return smooth( IDsOfElements, IDsOfFixedNodes, MaxNbOfIterations, + MaxAspectRatio, Method, false ); +} + +//======================================================================= +//function : SmoothParametric +//purpose : +//======================================================================= + +CORBA::Boolean + SMESH_MeshEditor_i::SmoothParametric(const SMESH::long_array & IDsOfElements, + const SMESH::long_array & IDsOfFixedNodes, + CORBA::Long MaxNbOfIterations, + CORBA::Double MaxAspectRatio, + SMESH::SMESH_MeshEditor::Smooth_Method Method) +{ + return smooth( IDsOfElements, IDsOfFixedNodes, MaxNbOfIterations, + MaxAspectRatio, Method, true ); +} + +//======================================================================= +//function : SmoothObject +//purpose : +//======================================================================= + +CORBA::Boolean + SMESH_MeshEditor_i::SmoothObject(SMESH::SMESH_IDSource_ptr theObject, + const SMESH::long_array & IDsOfFixedNodes, + CORBA::Long MaxNbOfIterations, + CORBA::Double MaxAspectRatio, + SMESH::SMESH_MeshEditor::Smooth_Method Method) +{ + return smoothObject (theObject, IDsOfFixedNodes, MaxNbOfIterations, + MaxAspectRatio, Method, false); +} + +//======================================================================= +//function : SmoothParametricObject +//purpose : +//======================================================================= + +CORBA::Boolean + SMESH_MeshEditor_i::SmoothParametricObject(SMESH::SMESH_IDSource_ptr theObject, + const SMESH::long_array & IDsOfFixedNodes, + CORBA::Long MaxNbOfIterations, + CORBA::Double MaxAspectRatio, + SMESH::SMESH_MeshEditor::Smooth_Method Method) +{ + return smoothObject (theObject, IDsOfFixedNodes, MaxNbOfIterations, + MaxAspectRatio, Method, true); } //============================================================================= @@ -375,11 +685,12 @@ CORBA::Boolean //============================================================================= CORBA::Boolean - SMESH_MeshEditor_i::Smooth(const SMESH::long_array & IDsOfElements, + SMESH_MeshEditor_i::smooth(const SMESH::long_array & IDsOfElements, const SMESH::long_array & IDsOfFixedNodes, CORBA::Long MaxNbOfIterations, CORBA::Double MaxAspectRatio, - SMESH::SMESH_MeshEditor::Smooth_Method Method) + SMESH::SMESH_MeshEditor::Smooth_Method Method, + bool IsParametric) { SMESHDS_Mesh* aMesh = GetMeshDS(); @@ -402,10 +713,30 @@ CORBA::Boolean } ::SMESH_MeshEditor::SmoothMethod method = ::SMESH_MeshEditor::LAPLACIAN; if ( Method != SMESH::SMESH_MeshEditor::LAPLACIAN_SMOOTH ) - method = ::SMESH_MeshEditor::CENTROIDAL; + method = ::SMESH_MeshEditor::CENTROIDAL; ::SMESH_MeshEditor anEditor( _myMesh ); - anEditor.Smooth( elements, fixedNodes, method, MaxNbOfIterations, MaxAspectRatio ); + anEditor.Smooth(elements, fixedNodes, method, + MaxNbOfIterations, MaxAspectRatio, IsParametric ); + + // Update Python script + TCollection_AsciiString str ("isDone = mesh_editor."); + str += (char*) (IsParametric ? "SmoothParametric( " : "Smooth( "); + SMESH_Gen_i::AddArray( str, IDsOfElements ) += ", "; + SMESH_Gen_i::AddArray( str, IDsOfFixedNodes ) += ", "; + str += (Standard_Integer) MaxNbOfIterations; + str += ", "; + str += (Standard_Real) MaxAspectRatio; + if ( method == ::SMESH_MeshEditor::CENTROIDAL ) + str += ", SMESH.SMESH_MeshEditor.CENTROIDAL_SMOOTH, "; + else + str += ", SMESH.SMESH_MeshEditor.LAPLACIAN_SMOOTH, "; + str += IsParametric; + str += " )"; + SMESH_Gen_i::AddToCurrentPyScript( str ); +#ifdef _DEBUG_ + SMESH_Gen_i::AddToCurrentPyScript( "print \"Smooth: \", isDone" ); +#endif return true; } @@ -417,14 +748,44 @@ CORBA::Boolean //============================================================================= CORBA::Boolean - SMESH_MeshEditor_i::SmoothObject(SMESH::SMESH_IDSource_ptr theObject, + SMESH_MeshEditor_i::smoothObject(SMESH::SMESH_IDSource_ptr theObject, const SMESH::long_array & IDsOfFixedNodes, CORBA::Long MaxNbOfIterations, CORBA::Double MaxAspectRatio, - SMESH::SMESH_MeshEditor::Smooth_Method Method) + SMESH::SMESH_MeshEditor::Smooth_Method Method, + bool IsParametric) { SMESH::long_array_var anElementsId = theObject->GetIDs(); - return Smooth(anElementsId, IDsOfFixedNodes, MaxNbOfIterations, MaxAspectRatio, Method); + CORBA::Boolean isDone = smooth (anElementsId, IDsOfFixedNodes, MaxNbOfIterations, + MaxAspectRatio, Method, IsParametric); + + // Clear python line(s), created by Smooth() + SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen(); + aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID()); +#ifdef _DEBUG_ + aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID()); +#endif + + // Update Python script + TCollection_AsciiString str ("isDone = mesh_editor."); + str += (char*) (IsParametric ? "SmoothParametricObject( " : "SmoothObject( "); + SMESH_Gen_i::AddObject( str, theObject ) += ", "; + SMESH_Gen_i::AddArray( str, IDsOfFixedNodes ) += ", "; + str += (Standard_Integer) MaxNbOfIterations; + str += ", "; + str += (Standard_Real) MaxAspectRatio; + if ( Method == ::SMESH_MeshEditor::CENTROIDAL ) + str += ", SMESH.SMESH_MeshEditor.CENTROIDAL_SMOOTH, "; + else + str += ", SMESH.SMESH_MeshEditor.LAPLACIAN_SMOOTH, "; + str += IsParametric; + str += " )"; + SMESH_Gen_i::AddToCurrentPyScript( str ); +#ifdef _DEBUG_ + SMESH_Gen_i::AddToCurrentPyScript( "print \"SmoothObject: \", isDone" ); +#endif + + return isDone; } //============================================================================= @@ -435,6 +796,9 @@ CORBA::Boolean void SMESH_MeshEditor_i::RenumberNodes() { + // Update Python script + SMESH_Gen_i::AddToCurrentPyScript( "mesh_editor.RenumberNodes()" ); + GetMeshDS()->Renumber( true ); } @@ -446,6 +810,9 @@ void SMESH_MeshEditor_i::RenumberNodes() void SMESH_MeshEditor_i::RenumberElements() { + // Update Python script + SMESH_Gen_i::AddToCurrentPyScript( "mesh_editor.RenumberElements()" ); + GetMeshDS()->Renumber( false ); } @@ -455,7 +822,7 @@ void SMESH_MeshEditor_i::RenumberElements() //======================================================================= void SMESH_MeshEditor_i::RotationSweep(const SMESH::long_array & theIDsOfElements, - const SMESH::AxisStruct & theAxis, + const SMESH::AxisStruct & theAxis, CORBA::Double theAngleInRadians, CORBA::Long theNbOfSteps, CORBA::Double theTolerance) @@ -476,6 +843,17 @@ void SMESH_MeshEditor_i::RotationSweep(const SMESH::long_array & theIDsOfElement ::SMESH_MeshEditor anEditor( _myMesh ); anEditor.RotationSweep (elements, Ax1, theAngleInRadians, theNbOfSteps, theTolerance); + + // Update Python script + TCollection_AsciiString str = "axis = "; + addAxis( str, theAxis ); + SMESH_Gen_i::AddToCurrentPyScript( str ); + str = "mesh_editor.RotationSweep("; + SMESH_Gen_i::AddArray( str, theIDsOfElements ) += ", axis, "; + str += TCollection_AsciiString( theAngleInRadians ) + ", "; + str += TCollection_AsciiString( (int)theNbOfSteps ) + ", "; + str += TCollection_AsciiString( theTolerance ) + " )"; + SMESH_Gen_i::AddToCurrentPyScript( str ); } //======================================================================= @@ -491,6 +869,18 @@ void SMESH_MeshEditor_i::RotationSweepObject(SMESH::SMESH_IDSource_ptr theObject { SMESH::long_array_var anElementsId = theObject->GetIDs(); RotationSweep(anElementsId, theAxis, theAngleInRadians, theNbOfSteps, theTolerance); + + // Clear python line, created by RotationSweep() + SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen(); + aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID()); + + // Update Python script + TCollection_AsciiString str ("mesh_editor.RotationSweepObject("); + SMESH_Gen_i::AddObject( str, theObject ) += ", axis, "; + str += TCollection_AsciiString( theAngleInRadians ) + ", "; + str += TCollection_AsciiString( (int)theNbOfSteps ) + ", "; + str += TCollection_AsciiString( theTolerance ) + " )"; + SMESH_Gen_i::AddToCurrentPyScript( str ); } //======================================================================= @@ -499,7 +889,7 @@ void SMESH_MeshEditor_i::RotationSweepObject(SMESH::SMESH_IDSource_ptr theObject //======================================================================= void SMESH_MeshEditor_i::ExtrusionSweep(const SMESH::long_array & theIDsOfElements, - const SMESH::DirStruct & theStepVector, + const SMESH::DirStruct & theStepVector, CORBA::Long theNbOfSteps) { SMESHDS_Mesh* aMesh = GetMeshDS(); @@ -517,6 +907,17 @@ void SMESH_MeshEditor_i::ExtrusionSweep(const SMESH::long_array & theIDsOfElemen ::SMESH_MeshEditor anEditor( _myMesh ); anEditor.ExtrusionSweep (elements, stepVec, theNbOfSteps); + + // Update Python script + TCollection_AsciiString str = "stepVector = SMESH.DirStruct( SMESH.PointStruct ( "; + str += (TCollection_AsciiString) stepVec.X() + ", "; + str += (TCollection_AsciiString) stepVec.Y() + ", "; + str += (TCollection_AsciiString) stepVec.Z() + " ))"; + SMESH_Gen_i::AddToCurrentPyScript( str ); + str = ("mesh_editor.ExtrusionSweep("); + SMESH_Gen_i::AddArray( str, theIDsOfElements ) += ", stepVector, "; + str += TCollection_AsciiString((int)theNbOfSteps) + " )"; + SMESH_Gen_i::AddToCurrentPyScript( str ); } @@ -531,8 +932,17 @@ void SMESH_MeshEditor_i::ExtrusionSweepObject(SMESH::SMESH_IDSource_ptr theObjec { SMESH::long_array_var anElementsId = theObject->GetIDs(); ExtrusionSweep(anElementsId, theStepVector, theNbOfSteps); -} + // Clear python line, created by ExtrusionSweep() + SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen(); + aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID()); + + // Update Python script + TCollection_AsciiString str ("mesh_editor.ExtrusionSweepObject("); + SMESH_Gen_i::AddObject( str, theObject ) += ", stepVector, "; + str += TCollection_AsciiString((int)theNbOfSteps) + " )"; + SMESH_Gen_i::AddToCurrentPyScript( str ); +} //======================================================================= //function : ExtrusionSweepObject1D //purpose : @@ -653,6 +1063,22 @@ SMESH::SMESH_MeshEditor::Extrusion_Error gp_Pnt refPnt( theRefPoint.x, theRefPoint.y, theRefPoint.z ); + // Update Python script + TCollection_AsciiString str = "refPoint = SMESH.PointStruct( "; + str += (TCollection_AsciiString) refPnt.X() + ", "; + str += (TCollection_AsciiString) refPnt.Y() + ", "; + str += (TCollection_AsciiString) refPnt.Z() + " )"; + SMESH_Gen_i::AddToCurrentPyScript( str ); + str = ("error = mesh_editor.ExtrusionAlongPath("); + SMESH_Gen_i::AddArray ( str, theIDsOfElements ) += ", "; + SMESH_Gen_i::AddObject( str, thePathMesh ) += ", "; + SMESH_Gen_i::AddObject( str, thePathShape ) += ", "; + str += TCollection_AsciiString( (int)theNodeStart ) + ", "; + str += TCollection_AsciiString( (int)theHasAngles ) + ", "; + SMESH_Gen_i::AddArray ( str, theAngles ) += ", "; + str += (TCollection_AsciiString) theHasRefPoint + ", refPoint )"; + SMESH_Gen_i::AddToCurrentPyScript( str ); + ::SMESH_MeshEditor anEditor( _myMesh ); return convExtrError( anEditor.ExtrusionAlongTrack( elements, aSubMesh, nodeStart, theHasAngles, angles, theHasRefPoint, refPnt ) ); } @@ -673,7 +1099,26 @@ SMESH::SMESH_MeshEditor::Extrusion_Error const SMESH::PointStruct & theRefPoint) { SMESH::long_array_var anElementsId = theObject->GetIDs(); - return ExtrusionAlongPath( anElementsId, thePathMesh, thePathShape, theNodeStart, theHasAngles, theAngles, theHasRefPoint, theRefPoint ); + SMESH::SMESH_MeshEditor::Extrusion_Error error = ExtrusionAlongPath + (anElementsId, thePathMesh, thePathShape, theNodeStart, + theHasAngles, theAngles, theHasRefPoint, theRefPoint); + + // Clear python line, created by ExtrusionAlongPath() + SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen(); + aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID()); + + // Update Python script + TCollection_AsciiString str ("error = mesh_editor.ExtrusionAlongPathObject("); + SMESH_Gen_i::AddObject( str, theObject ) += ", "; + SMESH_Gen_i::AddObject( str, thePathMesh ) += ", "; + SMESH_Gen_i::AddObject( str, thePathShape ) += ", "; + str += TCollection_AsciiString( (int)theNodeStart ) + ", "; + str += TCollection_AsciiString( theHasAngles ) + ", "; + SMESH_Gen_i::AddArray ( str, theAngles ) += ", "; + str += TCollection_AsciiString( theHasRefPoint ) + ", refPoint )"; + SMESH_Gen_i::AddToCurrentPyScript( str ); + + return error; } //======================================================================= @@ -682,7 +1127,7 @@ SMESH::SMESH_MeshEditor::Extrusion_Error //======================================================================= void SMESH_MeshEditor_i::Mirror(const SMESH::long_array & theIDsOfElements, - const SMESH::AxisStruct & theAxis, + const SMESH::AxisStruct & theAxis, SMESH::SMESH_MeshEditor::MirrorType theMirrorType, CORBA::Boolean theCopy) { @@ -700,17 +1145,29 @@ void SMESH_MeshEditor_i::Mirror(const SMESH::long_array & theIDsOfElem gp_Vec V ( theAxis.vx, theAxis.vy, theAxis.vz ); gp_Trsf aTrsf; + TCollection_AsciiString typeStr, copyStr( theCopy ); switch ( theMirrorType ) { case SMESH::SMESH_MeshEditor::POINT: aTrsf.SetMirror( P ); + typeStr = "SMESH.SMESH_MeshEditor.POINT"; break; case SMESH::SMESH_MeshEditor::AXIS: aTrsf.SetMirror( gp_Ax1( P, V )); + typeStr = "SMESH.SMESH_MeshEditor.AXIS"; break; default: aTrsf.SetMirror( gp_Ax2( P, V )); + typeStr = "SMESH.SMESH_MeshEditor.PLANE"; } + // Update Python script + TCollection_AsciiString str ("mesh_editor.Mirror("); + SMESH_Gen_i::AddArray( str, theIDsOfElements ) += ", "; + addAxis( str, theAxis ) += ", "; + str += typeStr + ", "; + str += copyStr + " )"; + SMESH_Gen_i::AddToCurrentPyScript( str ); + ::SMESH_MeshEditor anEditor( _myMesh ); anEditor.Transform (elements, aTrsf, theCopy); } @@ -727,6 +1184,29 @@ void SMESH_MeshEditor_i::MirrorObject(SMESH::SMESH_IDSource_ptr theObj { SMESH::long_array_var anElementsId = theObject->GetIDs(); Mirror(anElementsId, theAxis, theMirrorType, theCopy); + + // Clear python line, created by Mirror() + SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen(); + aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID()); + + // Update Python script + TCollection_AsciiString typeStr, copyStr( theCopy ); + switch ( theMirrorType ) { + case SMESH::SMESH_MeshEditor::POINT: + typeStr = "SMESH.SMESH_MeshEditor.POINT"; + break; + case SMESH::SMESH_MeshEditor::AXIS: + typeStr = "SMESH.SMESH_MeshEditor.AXIS"; + break; + default: + typeStr = "SMESH.SMESH_MeshEditor.PLANE"; + } + + TCollection_AsciiString str ("mesh_editor.MirrorObject("); + SMESH_Gen_i::AddObject( str, theObject ) += ", "; + addAxis( str, theAxis ) += ", "; + str += typeStr + ", " + copyStr + " )"; + SMESH_Gen_i::AddToCurrentPyScript( str ); } //======================================================================= @@ -735,7 +1215,7 @@ void SMESH_MeshEditor_i::MirrorObject(SMESH::SMESH_IDSource_ptr theObj //======================================================================= void SMESH_MeshEditor_i::Translate(const SMESH::long_array & theIDsOfElements, - const SMESH::DirStruct & theVector, + const SMESH::DirStruct & theVector, CORBA::Boolean theCopy) { SMESHDS_Mesh* aMesh = GetMeshDS(); @@ -754,6 +1234,17 @@ void SMESH_MeshEditor_i::Translate(const SMESH::long_array & theIDsOfElements, ::SMESH_MeshEditor anEditor( _myMesh ); anEditor.Transform (elements, aTrsf, theCopy); + + // Update Python script + TCollection_AsciiString str = "vector = SMESH.DirStruct( SMESH.PointStruct ( "; + str += (TCollection_AsciiString) P->x + ", "; + str += (TCollection_AsciiString) P->y + ", "; + str += (TCollection_AsciiString) P->z + " ))"; + SMESH_Gen_i::AddToCurrentPyScript( str ); + str = ("mesh_editor.Translate("); + SMESH_Gen_i::AddArray( str, theIDsOfElements ) += ", vector, "; + str += (TCollection_AsciiString) theCopy + " )"; + SMESH_Gen_i::AddToCurrentPyScript( str ); } //======================================================================= @@ -767,6 +1258,16 @@ void SMESH_MeshEditor_i::TranslateObject(SMESH::SMESH_IDSource_ptr theObject, { SMESH::long_array_var anElementsId = theObject->GetIDs(); Translate(anElementsId, theVector, theCopy); + + // Clear python line, created by Translate() + SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen(); + aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID()); + + // Update Python script + TCollection_AsciiString str ("mesh_editor.TranslateObject("); + SMESH_Gen_i::AddObject( str, theObject ) += ", vector, "; + str += TCollection_AsciiString( theCopy ) + " )"; + SMESH_Gen_i::AddToCurrentPyScript( str ); } //======================================================================= @@ -775,7 +1276,7 @@ void SMESH_MeshEditor_i::TranslateObject(SMESH::SMESH_IDSource_ptr theObject, //======================================================================= void SMESH_MeshEditor_i::Rotate(const SMESH::long_array & theIDsOfElements, - const SMESH::AxisStruct & theAxis, + const SMESH::AxisStruct & theAxis, CORBA::Double theAngle, CORBA::Boolean theCopy) { @@ -795,9 +1296,18 @@ void SMESH_MeshEditor_i::Rotate(const SMESH::long_array & theIDsOfElements, gp_Trsf aTrsf; aTrsf.SetRotation( gp_Ax1( P, V ), theAngle); - ::SMESH_MeshEditor anEditor( _myMesh ); anEditor.Transform (elements, aTrsf, theCopy); + + // Update Python script + TCollection_AsciiString str ("axis = "); + addAxis( str, theAxis ); + SMESH_Gen_i::AddToCurrentPyScript( str ); + str = ("mesh_editor.Rotate("); + SMESH_Gen_i::AddArray( str, theIDsOfElements ) += ", axis, "; + str += (TCollection_AsciiString) theAngle + ", "; + str += (TCollection_AsciiString) theCopy + " )"; + SMESH_Gen_i::AddToCurrentPyScript( str ); } //======================================================================= @@ -812,6 +1322,17 @@ void SMESH_MeshEditor_i::RotateObject(SMESH::SMESH_IDSource_ptr theObject, { SMESH::long_array_var anElementsId = theObject->GetIDs(); Rotate(anElementsId, theAxis, theAngle, theCopy); + + // Clear python line, created by Rotate() + SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen(); + aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID()); + + // Update Python script + TCollection_AsciiString str ("mesh_editor.RotateObject("); + SMESH_Gen_i::AddObject( str, theObject ) += ", axis, "; + str += TCollection_AsciiString( theAngle ) + ", "; + str += TCollection_AsciiString( theCopy ) + " )"; + SMESH_Gen_i::AddToCurrentPyScript( str ); } //======================================================================= @@ -850,8 +1371,8 @@ void SMESH_MeshEditor_i::MergeNodes (const SMESH::array_of_long_array& GroupsOfN { SMESHDS_Mesh* aMesh = GetMeshDS(); + TCollection_AsciiString str( "mesh_editor.MergeNodes([" ); ::SMESH_MeshEditor::TListOfListOfNodes aListOfListOfNodes; - list elements; for (int i = 0; i < GroupsOfNodes.length(); i++) { const SMESH::long_array& aNodeGroup = GroupsOfNodes[ i ]; @@ -866,9 +1387,16 @@ void SMESH_MeshEditor_i::MergeNodes (const SMESH::array_of_long_array& GroupsOfN } if ( aListOfNodes.size() < 2 ) aListOfListOfNodes.pop_back(); + + if ( i > 0 ) + str += ","; + SMESH_Gen_i::AddArray( str, aNodeGroup ); } ::SMESH_MeshEditor anEditor( _myMesh ); anEditor.MergeNodes( aListOfListOfNodes ); + + // Update Python script + SMESH_Gen_i::AddToCurrentPyScript( str + "])" ); } //======================================================================= @@ -880,6 +1408,9 @@ void SMESH_MeshEditor_i::MergeEqualElements() { ::SMESH_MeshEditor anEditor( _myMesh ); anEditor.MergeEqualElements(); + + // Update Python script + SMESH_Gen_i::AddToCurrentPyScript( "mesh_editor.MergeEqualElements()" ); } //======================================================================= @@ -917,7 +1448,9 @@ SMESH::SMESH_MeshEditor::Sew_Error CORBA::Long LastNodeID1, CORBA::Long FirstNodeID2, CORBA::Long SecondNodeID2, - CORBA::Long LastNodeID2) + CORBA::Long LastNodeID2, + CORBA::Boolean CreatePolygons, + CORBA::Boolean CreatePolyedrs) { SMESHDS_Mesh* aMesh = GetMeshDS(); @@ -937,6 +1470,18 @@ SMESH::SMESH_MeshEditor::Sew_Error !aSide2ThirdNode) return SMESH::SMESH_MeshEditor::SEW_BORDER2_NOT_FOUND; + // Update Python script + TCollection_AsciiString str ("error = mesh_editor.SewFreeBorders( "); + str += TCollection_AsciiString( (int) FirstNodeID1 ) + ", "; + str += TCollection_AsciiString( (int) SecondNodeID1 ) + ", "; + str += TCollection_AsciiString( (int) LastNodeID1 ) + ", "; + str += TCollection_AsciiString( (int) FirstNodeID2 ) + ", "; + str += TCollection_AsciiString( (int) SecondNodeID2 ) + ", "; + str += TCollection_AsciiString( (int) LastNodeID2 ) + ", "; + str += TCollection_AsciiString( CreatePolygons ) + ", "; + str += TCollection_AsciiString( CreatePolyedrs ) + ") "; + SMESH_Gen_i::AddToCurrentPyScript( str ); + ::SMESH_MeshEditor anEditor( _myMesh ); return convError( anEditor.SewFreeBorder (aBorderFirstNode, aBorderSecondNode, @@ -944,7 +1489,9 @@ SMESH::SMESH_MeshEditor::Sew_Error aSide2FirstNode, aSide2SecondNode, aSide2ThirdNode, - true)); + true, + CreatePolygons, + CreatePolyedrs) ); } //======================================================================= @@ -976,6 +1523,15 @@ SMESH::SMESH_MeshEditor::Sew_Error !aSide2SecondNode) return SMESH::SMESH_MeshEditor::SEW_BORDER2_NOT_FOUND; + // Update Python script + TCollection_AsciiString str ("error = mesh_editor.SewConformFreeBorders( "); + str += TCollection_AsciiString( (int) FirstNodeID1 ) + ", "; + str += TCollection_AsciiString( (int) SecondNodeID1 ) + ", "; + str += TCollection_AsciiString( (int) LastNodeID1 ) + ", "; + str += TCollection_AsciiString( (int) FirstNodeID2 ) + ", "; + str += TCollection_AsciiString( (int) SecondNodeID2 ) + ")"; + SMESH_Gen_i::AddToCurrentPyScript( str ); + ::SMESH_MeshEditor anEditor( _myMesh ); return convError( anEditor.SewFreeBorder (aBorderFirstNode, aBorderSecondNode, @@ -983,7 +1539,8 @@ SMESH::SMESH_MeshEditor::Sew_Error aSide2FirstNode, aSide2SecondNode, aSide2ThirdNode, - true )); + true, + false, false) ); } //======================================================================= @@ -996,7 +1553,9 @@ SMESH::SMESH_MeshEditor::Sew_Error CORBA::Long SecondNodeIDOnFreeBorder, CORBA::Long LastNodeIDOnFreeBorder, CORBA::Long FirstNodeIDOnSide, - CORBA::Long LastNodeIDOnSide) + CORBA::Long LastNodeIDOnSide, + CORBA::Boolean CreatePolygons, + CORBA::Boolean CreatePolyedrs) { SMESHDS_Mesh* aMesh = GetMeshDS(); @@ -1015,6 +1574,17 @@ SMESH::SMESH_MeshEditor::Sew_Error !aSide2SecondNode) return SMESH::SMESH_MeshEditor::SEW_BAD_SIDE_NODES; + // Update Python script + TCollection_AsciiString str ("error = mesh_editor.SewBorderToSide( "); + str += TCollection_AsciiString( (int) FirstNodeIDOnFreeBorder ) + ", "; + str += TCollection_AsciiString( (int) SecondNodeIDOnFreeBorder ) + ", "; + str += TCollection_AsciiString( (int) LastNodeIDOnFreeBorder ) + ", "; + str += TCollection_AsciiString( (int) FirstNodeIDOnSide ) + ", "; + str += TCollection_AsciiString( (int) LastNodeIDOnSide ) + ", "; + str += TCollection_AsciiString( CreatePolygons ) + ", "; + str += TCollection_AsciiString( CreatePolyedrs ) + ") "; + SMESH_Gen_i::AddToCurrentPyScript( str ); + ::SMESH_MeshEditor anEditor( _myMesh ); return convError( anEditor.SewFreeBorder (aBorderFirstNode, aBorderSecondNode, @@ -1022,7 +1592,9 @@ SMESH::SMESH_MeshEditor::Sew_Error aSide2FirstNode, aSide2SecondNode, aSide2ThirdNode, - false)); + false, + CreatePolygons, + CreatePolyedrs) ); } //======================================================================= @@ -1067,6 +1639,16 @@ SMESH::SMESH_MeshEditor::Sew_Error if ( elem ) aSide2Elems.insert( elem ); } + // Update Python script + TCollection_AsciiString str ("error = mesh_editor.SewSideElements( "); + SMESH_Gen_i::AddArray( str, IDsOfSide1Elements ) += ", "; + SMESH_Gen_i::AddArray( str, IDsOfSide2Elements ) += ", "; + str += TCollection_AsciiString( (int) NodeID1OfSide1ToMerge ) + ", "; + str += TCollection_AsciiString( (int) NodeID1OfSide2ToMerge ) + ", "; + str += TCollection_AsciiString( (int) NodeID2OfSide1ToMerge ) + ", "; + str += TCollection_AsciiString( (int) NodeID2OfSide2ToMerge ) + ")"; + SMESH_Gen_i::AddToCurrentPyScript( str ); + ::SMESH_MeshEditor anEditor( _myMesh ); return convError( anEditor.SewSideElements (aSide1Elems, aSide2Elems, aFirstNode1ToMerge, diff --git a/src/SMESH_I/SMESH_MeshEditor_i.hxx b/src/SMESH_I/SMESH_MeshEditor_i.hxx index 941c51937..9aba3bb4f 100644 --- a/src/SMESH_I/SMESH_MeshEditor_i.hxx +++ b/src/SMESH_I/SMESH_MeshEditor_i.hxx @@ -51,6 +51,11 @@ class SMESH_MeshEditor_i: public POA_SMESH::SMESH_MeshEditor CORBA::Boolean AddEdge(const SMESH::long_array & IDsOfNodes); CORBA::Boolean AddFace(const SMESH::long_array & IDsOfNodes); CORBA::Boolean AddVolume(const SMESH::long_array & IDsOfNodes); + + CORBA::Boolean AddPolyhedralVolume(const SMESH::long_array & IDsOfNodes, + const SMESH::long_array & Quantities); + CORBA::Boolean AddPolyhedralVolumeByFaces(const SMESH::long_array & IdsOfFaces); + CORBA::Boolean MoveNode(CORBA::Long NodeID, CORBA::Double x, CORBA::Double y, CORBA::Double z); @@ -82,7 +87,28 @@ class SMESH_MeshEditor_i: public POA_SMESH::SMESH_MeshEditor CORBA::Long MaxNbOfIterations, CORBA::Double MaxAspectRatio, SMESH::SMESH_MeshEditor::Smooth_Method Method); - + CORBA::Boolean SmoothParametric(const SMESH::long_array & IDsOfElements, + const SMESH::long_array & IDsOfFixedNodes, + CORBA::Long MaxNbOfIterations, + CORBA::Double MaxAspectRatio, + SMESH::SMESH_MeshEditor::Smooth_Method Method); + CORBA::Boolean SmoothParametricObject(SMESH::SMESH_IDSource_ptr theObject, + const SMESH::long_array & IDsOfFixedNodes, + CORBA::Long MaxNbOfIterations, + CORBA::Double MaxAspectRatio, + SMESH::SMESH_MeshEditor::Smooth_Method Method); + CORBA::Boolean smooth(const SMESH::long_array & IDsOfElements, + const SMESH::long_array & IDsOfFixedNodes, + CORBA::Long MaxNbOfIterations, + CORBA::Double MaxAspectRatio, + SMESH::SMESH_MeshEditor::Smooth_Method Method, + bool IsParametric); + CORBA::Boolean smoothObject(SMESH::SMESH_IDSource_ptr theObject, + const SMESH::long_array & IDsOfFixedNodes, + CORBA::Long MaxNbOfIterations, + CORBA::Double MaxAspectRatio, + SMESH::SMESH_MeshEditor::Smooth_Method Method, + bool IsParametric); void RenumberNodes(); void RenumberElements(); @@ -165,7 +191,9 @@ class SMESH_MeshEditor_i: public POA_SMESH::SMESH_MeshEditor CORBA::Long LastNodeID1, CORBA::Long FirstNodeID2, CORBA::Long SecondNodeID2, - CORBA::Long LastNodeID2); + CORBA::Long LastNodeID2, + CORBA::Boolean CreatePolygons, + CORBA::Boolean CreatePolyedrs); SMESH::SMESH_MeshEditor::Sew_Error SewConformFreeBorders(CORBA::Long FirstNodeID1, CORBA::Long SecondNodeID1, @@ -177,7 +205,9 @@ class SMESH_MeshEditor_i: public POA_SMESH::SMESH_MeshEditor CORBA::Long SecondNodeIDOnFreeBorder, CORBA::Long LastNodeIDOnFreeBorder, CORBA::Long FirstNodeIDOnSide, - CORBA::Long LastNodeIDOnSide); + CORBA::Long LastNodeIDOnSide, + CORBA::Boolean CreatePolygons, + CORBA::Boolean CreatePolyedrs); SMESH::SMESH_MeshEditor::Sew_Error SewSideElements(const SMESH::long_array& IDsOfSide1Elements, const SMESH::long_array& IDsOfSide2Elements, diff --git a/src/SMESH_I/SMESH_Mesh_i.cxx b/src/SMESH_I/SMESH_Mesh_i.cxx index 0fa06e040..d41a1f4f2 100644 --- a/src/SMESH_I/SMESH_Mesh_i.cxx +++ b/src/SMESH_I/SMESH_Mesh_i.cxx @@ -76,7 +76,7 @@ SMESH_Mesh_i::SMESH_Mesh_i( PortableServer::POA_ptr thePOA, CORBA::Long studyId ) : SALOME::GenericObj_i( thePOA ) { - INFOS("SMESH_Mesh_i; this = "<::iterator it; for ( it = _mapGroups.begin(); it != _mapGroups.end(); it++ ) { SMESH_GroupBase_i* aGroup = dynamic_cast( SMESH_Gen_i::GetServant( it->second ).in() ); @@ -337,6 +337,14 @@ SMESH::Hypothesis_Status SMESH_Mesh_i::AddHypothesis(GEOM::GEOM_Object_ptr aSubS if(MYDEBUG) MESSAGE( " AddHypothesis(): status = " << status ); + // Update Python script + TCollection_AsciiString aStr ("status = "); + SMESH_Gen_i::AddObject(aStr, _this()) += ".AddHypothesis("; + SMESH_Gen_i::AddObject(aStr, aSubShapeObject) += ", "; + SMESH_Gen_i::AddObject(aStr, anHyp) += ")"; + + SMESH_Gen_i::AddToCurrentPyScript(aStr); + return ConvertHypothesisStatus(status); } @@ -401,6 +409,14 @@ SMESH::Hypothesis_Status SMESH_Mesh_i::RemoveHypothesis(GEOM::GEOM_Object_ptr aS _gen_i->RemoveHypothesisFromShape(_gen_i->GetCurrentStudy(), _this(), aSubShapeObject, anHyp ); + // Update Python script + TCollection_AsciiString aStr ("status = "); + SMESH_Gen_i::AddObject(aStr, _this()) += ".RemoveHypothesis("; + SMESH_Gen_i::AddObject(aStr, aSubShapeObject) += ", "; + SMESH_Gen_i::AddObject(aStr, anHyp) += ")"; + + SMESH_Gen_i::AddToCurrentPyScript(aStr); + return ConvertHypothesisStatus(status); } @@ -509,9 +525,22 @@ SMESH::SMESH_subMesh_ptr SMESH_Mesh_i::GetSubMesh(GEOM::GEOM_Object_ptr aSubShap if ( subMesh->_is_nil() ) subMesh = createSubMesh( aSubShapeObject ); - if ( _gen_i->CanPublishInStudy( subMesh )) - _gen_i->PublishSubMesh (_gen_i->GetCurrentStudy(), aMesh, - subMesh, aSubShapeObject, theName ); + if ( _gen_i->CanPublishInStudy( subMesh )) { + SALOMEDS::SObject_var aSO = + _gen_i->PublishSubMesh(_gen_i->GetCurrentStudy(), aMesh, + subMesh, aSubShapeObject, theName ); + if ( !aSO->_is_nil()) { + // Update Python script + TCollection_AsciiString aStr (aSO->GetID()); + aStr += " = "; + SMESH_Gen_i::AddObject(aStr, _this()) += ".GetSubMesh("; + SMESH_Gen_i::AddObject(aStr, aSubShapeObject) += ", \""; + aStr += (char*)theName; + aStr += "\")"; + + SMESH_Gen_i::AddToCurrentPyScript(aStr); + } + } } catch(SALOME_Exception & S_ex) { THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM); @@ -544,12 +573,49 @@ void SMESH_Mesh_i::RemoveSubMesh( SMESH::SMESH_subMesh_ptr theSubMesh ) aSubShapeObject = GEOM::GEOM_Object::_narrow( aRef->GetObject() ); aStudy->NewBuilder()->RemoveObjectWithChildren( anSO ); + + // Update Python script + TCollection_AsciiString aStr; + SMESH_Gen_i::AddObject(aStr, _this()) += ".RemoveSubMesh("; + aStr += anSO->GetID(); + aStr += ")"; + + SMESH_Gen_i::AddToCurrentPyScript(aStr); } } removeSubMesh( theSubMesh, aSubShapeObject.in() ); } +//============================================================================= +/*! + * ElementTypeString + */ +//============================================================================= +inline TCollection_AsciiString ElementTypeString (SMESH::ElementType theElemType) +{ + TCollection_AsciiString aStr; + switch (theElemType) { + case SMESH::ALL: + aStr = "SMESH.ALL"; + break; + case SMESH::NODE: + aStr = "SMESH.NODE"; + break; + case SMESH::EDGE: + aStr = "SMESH.EDGE"; + break; + case SMESH::FACE: + aStr = "SMESH.FACE"; + break; + case SMESH::VOLUME: + aStr = "SMESH.VOLUME"; + break; + default: + break; + } + return aStr; +} //============================================================================= /*! @@ -565,8 +631,20 @@ SMESH::SMESH_Group_ptr SMESH_Mesh_i::CreateGroup( SMESH::ElementType theElemType SMESH::SMESH_Group_var aNewGroup = SMESH::SMESH_Group::_narrow( createGroup( theElemType, theName )); - _gen_i->PublishGroup( _gen_i->GetCurrentStudy(), _this(), - aNewGroup, GEOM::GEOM_Object::_nil(), theName); + if ( _gen_i->CanPublishInStudy( aNewGroup ) ) { + SALOMEDS::SObject_var aSO = + _gen_i->PublishGroup(_gen_i->GetCurrentStudy(), _this(), + aNewGroup, GEOM::GEOM_Object::_nil(), theName); + if ( !aSO->_is_nil()) { + // Update Python script + TCollection_AsciiString aStr (aSO->GetID()); + aStr += " = "; + SMESH_Gen_i::AddObject(aStr, _this()) += ".CreateGroup("; + aStr += ElementTypeString(theElemType) + ", \"" + (char*)theName + "\")"; + + SMESH_Gen_i::AddToCurrentPyScript(aStr); + } + } return aNewGroup._retn(); } @@ -577,9 +655,9 @@ SMESH::SMESH_Group_ptr SMESH_Mesh_i::CreateGroup( SMESH::ElementType theElemType * */ //============================================================================= -SMESH::SMESH_GroupOnGeom_ptr SMESH_Mesh_i::CreateGroupFromGEOM( SMESH::ElementType theElemType, - const char* theName, - GEOM::GEOM_Object_ptr theGeomObj) +SMESH::SMESH_GroupOnGeom_ptr SMESH_Mesh_i::CreateGroupFromGEOM (SMESH::ElementType theElemType, + const char* theName, + GEOM::GEOM_Object_ptr theGeomObj) throw(SALOME::SALOME_Exception) { Unexpect aCatch(SALOME_SalomeException); @@ -589,13 +667,26 @@ SMESH::SMESH_GroupOnGeom_ptr SMESH_Mesh_i::CreateGroupFromGEOM( SMESH::ElementTy if ( !aShape.IsNull() ) { aNewGroup = SMESH::SMESH_GroupOnGeom::_narrow ( createGroup( theElemType, theName, aShape )); - if ( _gen_i->CanPublishInStudy( aNewGroup ) ) - _gen_i->PublishGroup( _gen_i->GetCurrentStudy(), _this(), - aNewGroup, theGeomObj, theName ); + if ( _gen_i->CanPublishInStudy( aNewGroup ) ) { + SALOMEDS::SObject_var aSO = + _gen_i->PublishGroup(_gen_i->GetCurrentStudy(), _this(), + aNewGroup, theGeomObj, theName); + if ( !aSO->_is_nil()) { + // Update Python script + TCollection_AsciiString aStr (aSO->GetID()); + aStr += " = "; + SMESH_Gen_i::AddObject(aStr, _this()) += ".CreateGroupFromGEOM("; + aStr += ElementTypeString(theElemType) + ", \"" + (char*)theName + "\", "; + SMESH_Gen_i::AddObject(aStr, theGeomObj) += ")"; + + SMESH_Gen_i::AddToCurrentPyScript(aStr); + } + } } return aNewGroup._retn(); } + //============================================================================= /*! * @@ -615,10 +706,20 @@ void SMESH_Mesh_i::RemoveGroup( SMESH::SMESH_GroupBase_ptr theGroup ) SALOMEDS::Study_ptr aStudy = _gen_i->GetCurrentStudy(); if ( !aStudy->_is_nil() ) { - // Remove group's SObject SALOMEDS::SObject_var aGroupSO = _gen_i->ObjectToSObject( aStudy, theGroup ); - if ( !aGroupSO->_is_nil() ) + + if ( !aGroupSO->_is_nil() ) { + // Update Python script + TCollection_AsciiString aStr; + SMESH_Gen_i::AddObject(aStr, _this()) += ".RemoveGroup("; + aStr += aGroupSO->GetID(); + aStr += ")"; + + SMESH_Gen_i::AddToCurrentPyScript(aStr); + + // Remove group's SObject aStudy->NewBuilder()->RemoveObject( aGroupSO ); + } } // Remove the group from SMESH data structures @@ -643,13 +744,26 @@ void SMESH_Mesh_i::RemoveGroupWithContents( SMESH::SMESH_GroupBase_ptr theGroup SMESH::long_array_var anIds = aGroup->GetListOfID(); SMESH::SMESH_MeshEditor_var aMeshEditor = SMESH_Mesh_i::GetMeshEditor(); - + + // Update Python script + TCollection_AsciiString aStr; + SMESH_Gen_i::AddObject(aStr, _this()) += ".RemoveGroupWithContents("; + SMESH_Gen_i::AddObject(aStr, theGroup) += ")"; + + SMESH_Gen_i::AddToCurrentPyScript(aStr); + + // Remove contents if ( aGroup->GetType() == SMESH::NODE ) aMeshEditor->RemoveNodes( anIds ); else aMeshEditor->RemoveElements( anIds ); - + + // Remove group RemoveGroup( theGroup ); + + // Clear python lines, created by RemoveNodes/Elements() and RemoveGroup() + _gen_i->RemoveLastFromPythonScript(_gen_i->GetCurrentStudy()->StudyId()); + _gen_i->RemoveLastFromPythonScript(_gen_i->GetCurrentStudy()->StudyId()); } //============================================================================= @@ -665,13 +779,12 @@ SMESH::SMESH_Group_ptr SMESH_Mesh_i::UnionGroups( SMESH::SMESH_GroupBase_ptr the { try { - SMESH::SMESH_Group_var aResGrp; - if ( theGroup1->_is_nil() || theGroup2->_is_nil() || theGroup1->GetType() != theGroup2->GetType() ) return SMESH::SMESH_Group::_nil(); - aResGrp = CreateGroup( theGroup1->GetType(), theName ); + // Create Union + SMESH::SMESH_Group_var aResGrp = CreateGroup( theGroup1->GetType(), theName ); if ( aResGrp->_is_nil() ) return SMESH::SMESH_Group::_nil(); @@ -696,6 +809,21 @@ SMESH::SMESH_Group_ptr SMESH_Mesh_i::UnionGroups( SMESH::SMESH_GroupBase_ptr the aResGrp->Add( aResIds ); + // Clear python lines, created by CreateGroup() and Add() + SALOMEDS::Study_ptr aStudy = _gen_i->GetCurrentStudy(); + _gen_i->RemoveLastFromPythonScript(aStudy->StudyId()); + _gen_i->RemoveLastFromPythonScript(aStudy->StudyId()); + + // Update Python script + TCollection_AsciiString aStr; + SMESH_Gen_i::AddObject(aStr, aResGrp) += " = "; + SMESH_Gen_i::AddObject(aStr, _this()) += ".UnionGroups("; + SMESH_Gen_i::AddObject(aStr, theGroup1) += ", "; + SMESH_Gen_i::AddObject(aStr, theGroup2) += ", \""; + aStr += TCollection_AsciiString((char*)theName) + "\")"; + + SMESH_Gen_i::AddToCurrentPyScript(aStr); + return aResGrp._retn(); } catch( ... ) @@ -715,21 +843,20 @@ SMESH::SMESH_Group_ptr SMESH_Mesh_i::IntersectGroups( SMESH::SMESH_GroupBase_ptr const char* theName ) throw (SALOME::SALOME_Exception) { - SMESH::SMESH_Group_var aResGrp; - if ( theGroup1->_is_nil() || theGroup2->_is_nil() || theGroup1->GetType() != theGroup2->GetType() ) - return aResGrp; - - aResGrp = CreateGroup( theGroup1->GetType(), theName ); + return SMESH::SMESH_Group::_nil(); + + // Create Intersection + SMESH::SMESH_Group_var aResGrp = CreateGroup( theGroup1->GetType(), theName ); if ( aResGrp->_is_nil() ) return aResGrp; - + SMESH::long_array_var anIds1 = theGroup1->GetListOfID(); SMESH::long_array_var anIds2 = theGroup2->GetListOfID(); - + TColStd_MapOfInteger aMap1; - + for ( int i1 = 0, n1 = anIds1->length(); i1 < n1; i1++ ) aMap1.Add( anIds1[ i1 ] ); @@ -738,15 +865,30 @@ SMESH::SMESH_Group_ptr SMESH_Mesh_i::IntersectGroups( SMESH::SMESH_GroupBase_ptr for ( int i2 = 0, n2 = anIds2->length(); i2 < n2; i2++ ) if ( aMap1.Contains( anIds2[ i2 ] ) ) aSeq.Append( anIds2[ i2 ] ); - + SMESH::long_array_var aResIds = new SMESH::long_array; aResIds->length( aSeq.Length() ); - + for ( int resI = 0, resN = aSeq.Length(); resI < resN; resI++ ) aResIds[ resI ] = aSeq( resI + 1 ); - + aResGrp->Add( aResIds ); - + + // Clear python lines, created by CreateGroup() and Add() + SALOMEDS::Study_ptr aStudy = _gen_i->GetCurrentStudy(); + _gen_i->RemoveLastFromPythonScript(aStudy->StudyId()); + _gen_i->RemoveLastFromPythonScript(aStudy->StudyId()); + + // Update Python script + TCollection_AsciiString aStr; + SMESH_Gen_i::AddObject(aStr, aResGrp) += " = "; + SMESH_Gen_i::AddObject(aStr, _this()) += ".IntersectGroups("; + SMESH_Gen_i::AddObject(aStr, theGroup1) += ", "; + SMESH_Gen_i::AddObject(aStr, theGroup2) += ", \""; + aStr += TCollection_AsciiString((char*)theName) + "\")"; + + SMESH_Gen_i::AddToCurrentPyScript(aStr); + return aResGrp._retn(); } @@ -761,21 +903,20 @@ SMESH::SMESH_Group_ptr SMESH_Mesh_i::CutGroups( SMESH::SMESH_GroupBase_ptr theGr const char* theName ) throw (SALOME::SALOME_Exception) { - SMESH::SMESH_Group_var aResGrp; - if ( theGroup1->_is_nil() || theGroup2->_is_nil() || theGroup1->GetType() != theGroup2->GetType() ) - return aResGrp; - - aResGrp = CreateGroup( theGroup1->GetType(), theName ); + return SMESH::SMESH_Group::_nil(); + + // Perform Cutting + SMESH::SMESH_Group_var aResGrp = CreateGroup( theGroup1->GetType(), theName ); if ( aResGrp->_is_nil() ) return aResGrp; - + SMESH::long_array_var anIds1 = theGroup1->GetListOfID(); SMESH::long_array_var anIds2 = theGroup2->GetListOfID(); - + TColStd_MapOfInteger aMap2; - + for ( int i2 = 0, n2 = anIds2->length(); i2 < n2; i2++ ) aMap2.Add( anIds2[ i2 ] ); @@ -790,9 +931,24 @@ SMESH::SMESH_Group_ptr SMESH_Mesh_i::CutGroups( SMESH::SMESH_GroupBase_ptr theGr for ( int resI = 0, resN = aSeq.Length(); resI < resN; resI++ ) aResIds[ resI ] = aSeq( resI + 1 ); - + aResGrp->Add( aResIds ); - + + // Clear python lines, created by CreateGroup() and Add() + SALOMEDS::Study_ptr aStudy = _gen_i->GetCurrentStudy(); + _gen_i->RemoveLastFromPythonScript(aStudy->StudyId()); + _gen_i->RemoveLastFromPythonScript(aStudy->StudyId()); + + // Update Python script + TCollection_AsciiString aStr; + SMESH_Gen_i::AddObject(aStr, aResGrp) += " = "; + SMESH_Gen_i::AddObject(aStr, _this()) += ".CutGroups("; + SMESH_Gen_i::AddObject(aStr, theGroup1) += ", "; + SMESH_Gen_i::AddObject(aStr, theGroup2) += ", \""; + aStr += TCollection_AsciiString((char*)theName) + "\")"; + + SMESH_Gen_i::AddToCurrentPyScript(aStr); + return aResGrp._retn(); } @@ -1051,24 +1207,51 @@ void SMESH_Mesh_i::SetImpl(::SMESH_Mesh * impl) SMESH::SMESH_MeshEditor_ptr SMESH_Mesh_i::GetMeshEditor() { - SMESH_MeshEditor_i *aMeshEditor = new SMESH_MeshEditor_i( _impl ); - SMESH::SMESH_MeshEditor_var aMesh = aMeshEditor->_this(); - return aMesh._retn(); + // Update Python script + TCollection_AsciiString aStr ("mesh_editor = "); + SMESH_Gen_i::AddObject(aStr, _this()) += ".GetMeshEditor()"; + + SMESH_Gen_i::AddToCurrentPyScript(aStr); + + // Create MeshEditor + SMESH_MeshEditor_i *aMeshEditor = new SMESH_MeshEditor_i( _impl ); + SMESH::SMESH_MeshEditor_var aMesh = aMeshEditor->_this(); + return aMesh._retn(); } //============================================================================= /*! - * + * Export in different formats */ //============================================================================= -void SMESH_Mesh_i::ExportToMED( const char* file, +void SMESH_Mesh_i::ExportToMED (const char* file, CORBA::Boolean auto_groups, - SMESH::MED_VERSION theVersion ) + SMESH::MED_VERSION theVersion) throw(SALOME::SALOME_Exception) { Unexpect aCatch(SALOME_SalomeException); - + + // Update Python script + TCollection_AsciiString aStr; + SMESH_Gen_i::AddObject(aStr, _this()) += ".ExportToMED(\""; + aStr += TCollection_AsciiString((char*)file) + "\", "; + aStr += TCollection_AsciiString((int)auto_groups) + ", "; + switch (theVersion) { + case SMESH::MED_V2_1: + aStr += "SMESH.MED_V2_1)"; + break; + case SMESH::MED_V2_2: + aStr += "SMESH.MED_V2_2)"; + break; + default: + aStr += TCollection_AsciiString(theVersion) + ")"; + break; + } + + SMESH_Gen_i::AddToCurrentPyScript(aStr); + + // Perform Export char* aMeshName = "Mesh"; SALOMEDS::Study_ptr aStudy = _gen_i->GetCurrentStudy(); if ( !aStudy->_is_nil() ) { @@ -1100,27 +1283,59 @@ void SMESH_Mesh_i::ExportToMED( const char* file, _impl->ExportMED( file, aMeshName, auto_groups, theVersion ); } -void SMESH_Mesh_i::ExportMED( const char* file, +void SMESH_Mesh_i::ExportMED (const char* file, CORBA::Boolean auto_groups) throw(SALOME::SALOME_Exception) { ExportToMED(file,auto_groups,SMESH::MED_V2_1); } -void SMESH_Mesh_i::ExportDAT(const char *file) throw(SALOME::SALOME_Exception) +void SMESH_Mesh_i::ExportDAT (const char *file) + throw(SALOME::SALOME_Exception) { Unexpect aCatch(SALOME_SalomeException); + + // Update Python script + TCollection_AsciiString aStr; + SMESH_Gen_i::AddObject(aStr, _this()) += ".ExportDAT(\""; + aStr += TCollection_AsciiString((char*)file) + "\")"; + + SMESH_Gen_i::AddToCurrentPyScript(aStr); + + // Perform Export _impl->ExportDAT(file); } -void SMESH_Mesh_i::ExportUNV(const char *file) throw(SALOME::SALOME_Exception) + +void SMESH_Mesh_i::ExportUNV (const char *file) + throw(SALOME::SALOME_Exception) { Unexpect aCatch(SALOME_SalomeException); + + // Update Python script + TCollection_AsciiString aStr; + SMESH_Gen_i::AddObject(aStr, _this()) += ".ExportUNV(\""; + aStr += TCollection_AsciiString((char*)file) + "\")"; + + SMESH_Gen_i::AddToCurrentPyScript(aStr); + + // Perform Export _impl->ExportUNV(file); } -void SMESH_Mesh_i::ExportSTL(const char *file, const bool isascii) throw(SALOME::SALOME_Exception) +void SMESH_Mesh_i::ExportSTL (const char *file, const bool isascii) + throw(SALOME::SALOME_Exception) { Unexpect aCatch(SALOME_SalomeException); + + // Update Python script + TCollection_AsciiString aStr; + SMESH_Gen_i::AddObject(aStr, _this()) += ".ExportToMED(\""; + aStr += TCollection_AsciiString((char*)file) + "\", "; + aStr += TCollection_AsciiString((int)isascii) + ")"; + + SMESH_Gen_i::AddToCurrentPyScript(aStr); + + // Perform Export _impl->ExportSTL(file, isascii); } @@ -1194,6 +1409,12 @@ CORBA::Long SMESH_Mesh_i::NbQuadrangles()throw(SALOME::SALOME_Exception) return _impl->NbQuadrangles(); } +CORBA::Long SMESH_Mesh_i::NbPolygons()throw(SALOME::SALOME_Exception) +{ + Unexpect aCatch(SALOME_SalomeException); + return _impl->NbPolygons(); +} + //============================================================================= /*! * @@ -1229,6 +1450,12 @@ CORBA::Long SMESH_Mesh_i::NbPrisms()throw(SALOME::SALOME_Exception) return _impl->NbPrisms(); } +CORBA::Long SMESH_Mesh_i::NbPolyhedrons()throw(SALOME::SALOME_Exception) +{ + Unexpect aCatch(SALOME_SalomeException); + return _impl->NbPolyhedrons(); +} + //============================================================================= /*! * diff --git a/src/SMESH_I/SMESH_Mesh_i.hxx b/src/SMESH_I/SMESH_Mesh_i.hxx index 3035c1ad3..dc3d06c57 100644 --- a/src/SMESH_I/SMESH_Mesh_i.hxx +++ b/src/SMESH_I/SMESH_Mesh_i.hxx @@ -164,16 +164,16 @@ public: SALOME_MED::MESH_ptr GetMEDMesh() throw (SALOME::SALOME_Exception); - + CORBA::Long NbNodes() throw (SALOME::SALOME_Exception); - + CORBA::Long NbElements() throw (SALOME::SALOME_Exception); - + CORBA::Long NbEdges() throw (SALOME::SALOME_Exception); - + CORBA::Long NbFaces() throw (SALOME::SALOME_Exception); @@ -182,7 +182,10 @@ public: CORBA::Long NbQuadrangles() throw (SALOME::SALOME_Exception); - + + CORBA::Long NbPolygons() + throw (SALOME::SALOME_Exception); + CORBA::Long NbVolumes() throw (SALOME::SALOME_Exception); @@ -191,13 +194,16 @@ public: CORBA::Long NbHexas() throw (SALOME::SALOME_Exception); - + CORBA::Long NbPyramids() throw (SALOME::SALOME_Exception); - + CORBA::Long NbPrisms() throw (SALOME::SALOME_Exception); - + + CORBA::Long NbPolyhedrons() + throw (SALOME::SALOME_Exception); + CORBA::Long NbSubMesh() throw (SALOME::SALOME_Exception); diff --git a/src/SMESH_I/SMESH_Pattern_i.cxx b/src/SMESH_I/SMESH_Pattern_i.cxx index d0b8bd216..e8da5c8d1 100644 --- a/src/SMESH_I/SMESH_Pattern_i.cxx +++ b/src/SMESH_I/SMESH_Pattern_i.cxx @@ -42,10 +42,22 @@ #include #include -// ============================================================================= +//======================================================================= +//function : dumpErrorCode +//purpose : +//======================================================================= + +static void addErrorCode(const char* thePyCommand) +{ + SMESH_Gen_i::AddToCurrentPyScript("if (isDone != 1):"); + TCollection_AsciiString str ("\tprint \""); + str += (char*) thePyCommand; + str += ":\", pattern.GetErrorCode()"; + SMESH_Gen_i::AddToCurrentPyScript( str ); +} + //============================================================================= /*! -// ============================================================================= * SMESH_Gen_i::GetPattern * * Create pattern mapper @@ -54,6 +66,9 @@ SMESH::SMESH_Pattern_ptr SMESH_Gen_i::GetPattern() { + // Update Python script + SMESH_Gen_i::AddToCurrentPyScript( "pattern = smesh.GetPattern()" ); + SMESH_Pattern_i* i = new SMESH_Pattern_i( this ); SMESH::SMESH_Pattern_var anObj = i->_this(); return anObj._retn(); @@ -91,6 +106,12 @@ SMESH_Pattern_i::SMESH_Pattern_i( SMESH_Gen_i* theGen_i ): CORBA::Boolean SMESH_Pattern_i::LoadFromFile(const char* theFileContents) { + // Update Python script + TCollection_AsciiString str( "isDone = pattern.LoadFromFile(" ); + str += TCollection_AsciiString( (char*) theFileContents ) + ")"; + SMESH_Gen_i::AddToCurrentPyScript( str ); + addErrorCode( "LoadFromFile" ); + return myPattern.Load( theFileContents ); } @@ -114,6 +135,14 @@ CORBA::Boolean SMESH_Pattern_i::LoadFromFace(SMESH::SMESH_Mesh_ptr theMesh, if ( aFace.IsNull() ) return false; + // Update Python script + TCollection_AsciiString str( "isDone = pattern.LoadFromFace( " ); + SMESH_Gen_i::AddObject( str, theMesh ) += ", "; + SMESH_Gen_i::AddObject( str, theFace ) += ", "; + str += TCollection_AsciiString( theProject ) + " )"; + SMESH_Gen_i::AddToCurrentPyScript( str ); + addErrorCode( "LoadFromFace" ); + return myPattern.Load( aMesh, aFace, theProject ); } @@ -140,6 +169,13 @@ CORBA::Boolean SMESH_Pattern_i::LoadFrom3DBlock(SMESH::SMESH_Mesh_ptr theMesh, if ( !exp.More() ) return false; + // Update Python script + TCollection_AsciiString str( "isDone = pattern.LoadFrom3DBlock( " ); + SMESH_Gen_i::AddObject( str, theMesh ) += ", "; + SMESH_Gen_i::AddObject( str, theBlock ) += " )"; + SMESH_Gen_i::AddToCurrentPyScript( str ); + addErrorCode( "LoadFrom3DBlock" ); + return myPattern.Load( aMesh, TopoDS::Shell( exp.Current() )); } @@ -172,6 +208,13 @@ SMESH::point_array* SMESH_Pattern_i::ApplyToFace(GEOM::GEOM_Object_ptr theFace, } } + // Update Python script + TCollection_AsciiString str( "pattern.ApplyToFace( " ); + SMESH_Gen_i::AddObject( str, theFace ) += ", "; + SMESH_Gen_i::AddObject( str, theVertexOnKeyPoint1 ) += ", "; + str += TCollection_AsciiString( theReverse ) + " )"; + SMESH_Gen_i::AddToCurrentPyScript( str ); + return points._retn(); } @@ -208,6 +251,13 @@ SMESH::point_array* SMESH_Pattern_i::ApplyTo3DBlock(GEOM::GEOM_Object_ptr theBlo } } + // Update Python script + TCollection_AsciiString str( "pattern.ApplyTo3DBlock( " ); + SMESH_Gen_i::AddObject( str, theBlock ) += ", "; + SMESH_Gen_i::AddObject( str, theVertex000 ) += ", "; + SMESH_Gen_i::AddObject( str, theVertex001 ) += " )"; + SMESH_Gen_i::AddToCurrentPyScript( str ); + return points._retn(); } @@ -248,6 +298,14 @@ SMESH::point_array* } } + // Update Python script + TCollection_AsciiString str( "pattern.ApplyToMeshFaces( " ); + SMESH_Gen_i::AddObject( str, theMesh ) += ", "; + SMESH_Gen_i::AddArray( str, theFacesIDs ) += ", "; + str += TCollection_AsciiString( (int)theNodeIndexOnKeyPoint1 ) + ", "; + str += TCollection_AsciiString( theReverse ) + " )"; + SMESH_Gen_i::AddToCurrentPyScript( str ); + return points._retn(); } @@ -288,6 +346,14 @@ SMESH::point_array* } } + // Update Python script + TCollection_AsciiString str( "pattern.ApplyToHexahedrons( " ); + SMESH_Gen_i::AddObject( str, theMesh ) += ", "; + SMESH_Gen_i::AddArray( str, theVolumesIDs ) += ", "; + str += TCollection_AsciiString( (int)theNode000Index ) + ", "; + str += TCollection_AsciiString( (int)theNode001Index ) + " )"; + SMESH_Gen_i::AddToCurrentPyScript( str ); + return points._retn(); } @@ -296,13 +362,23 @@ SMESH::point_array* //purpose : //======================================================================= -CORBA::Boolean SMESH_Pattern_i::MakeMesh(SMESH::SMESH_Mesh_ptr theMesh) +CORBA::Boolean SMESH_Pattern_i::MakeMesh (SMESH::SMESH_Mesh_ptr theMesh, + const CORBA::Boolean CreatePolygons, + const CORBA::Boolean CreatePolyedrs) { ::SMESH_Mesh* aMesh = getMesh( theMesh ); if ( !aMesh ) return false; - return myPattern.MakeMesh( aMesh ); + // Update Python script + TCollection_AsciiString str( "isDone = pattern.MakeMesh( " ); + SMESH_Gen_i::AddObject( str, theMesh ) += ", "; + str += TCollection_AsciiString( CreatePolygons ) + ", "; + str += TCollection_AsciiString( CreatePolyedrs ) + " )"; + SMESH_Gen_i::AddToCurrentPyScript( str ); + addErrorCode( "MakeMesh" ); + + return myPattern.MakeMesh( aMesh, CreatePolygons, CreatePolyedrs ); } //======================================================================= diff --git a/src/SMESH_I/SMESH_Pattern_i.hxx b/src/SMESH_I/SMESH_Pattern_i.hxx index d0a9656bd..29b5084cd 100644 --- a/src/SMESH_I/SMESH_Pattern_i.hxx +++ b/src/SMESH_I/SMESH_Pattern_i.hxx @@ -75,7 +75,9 @@ class SMESH_Pattern_i: CORBA::Long theNode000Index, CORBA::Long theNode001Index); - CORBA::Boolean MakeMesh(SMESH::SMESH_Mesh_ptr theMesh); + CORBA::Boolean MakeMesh (SMESH::SMESH_Mesh_ptr theMesh, + const CORBA::Boolean CreatePolygons, + const CORBA::Boolean CreatePolyedrs); SMESH::SMESH_Pattern::ErrorCode GetErrorCode(); diff --git a/src/SMESH_I/SMESH_PythonDump.hxx b/src/SMESH_I/SMESH_PythonDump.hxx new file mode 100644 index 000000000..86133cf8a --- /dev/null +++ b/src/SMESH_I/SMESH_PythonDump.hxx @@ -0,0 +1,85 @@ +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org + +#ifndef _SMESH_PYTHONDUMP_HXX_ +#define _SMESH_PYTHONDUMP_HXX_ + +#include +#include CORBA_SERVER_HEADER(SMESH_Mesh) + +#include + +namespace SMESH +{ + class FilterLibrary_i; + class FilterManager_i; + class Filter_i; + class Functor_i; + + class TPythonDump + { + std::ostringstream myStream; + static size_t myCounter; + public: + TPythonDump(); + virtual ~TPythonDump(); + + TPythonDump& + operator<<(long int theArg); + + TPythonDump& + operator<<(int theArg); + + TPythonDump& + operator<<(double theArg); + + TPythonDump& + operator<<(float theArg); + + TPythonDump& + operator<<(const void* theArg); + + TPythonDump& + operator<<(const char* theArg); + + TPythonDump& + operator<<(const SMESH::ElementType& theArg); + + TPythonDump& + operator<<(const SMESH::long_array& theArg); + + TPythonDump& + operator<<(CORBA::Object_ptr theArg); + + TPythonDump& + operator<<(SMESH::FilterLibrary_i* theArg); + + TPythonDump& + operator<<(SMESH::FilterManager_i* theArg); + + TPythonDump& + operator<<(SMESH::Filter_i* theArg); + + TPythonDump& + operator<<(SMESH::Functor_i* theArg); + }; +} + + +#endif diff --git a/src/SMESH_SWIG/Makefile.in b/src/SMESH_SWIG/Makefile.in index 03edab751..a6c0165aa 100644 --- a/src/SMESH_SWIG/Makefile.in +++ b/src/SMESH_SWIG/Makefile.in @@ -114,6 +114,6 @@ EXPORT_SHAREDPYSCRIPTS=SMESH_shared_modules.py CPPFLAGS+=$(QT_INCLUDES) $(PYTHON_INCLUDES) $(OCC_INCLUDES) $(VTK_INCLUDES) $(OGL_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome -DHAVE_CONFIG_H LIBS+= $(PYTHON_LIBS) -LDFLAGS+= -lSMESHGUI -L${KERNEL_ROOT_DIR}/lib/salome -lSalomeGenericObj +LDFLAGS+= -lSMESH -L${KERNEL_ROOT_DIR}/lib/salome -lSalomeGenericObj @CONCLUDE@ diff --git a/src/StdMeshers/StdMeshers_Quadrangle_2D.cxx b/src/StdMeshers/StdMeshers_Quadrangle_2D.cxx index 913f5a129..da6b6a2e4 100644 --- a/src/StdMeshers/StdMeshers_Quadrangle_2D.cxx +++ b/src/StdMeshers/StdMeshers_Quadrangle_2D.cxx @@ -136,7 +136,16 @@ bool StdMeshers_Quadrangle_2D::Compute (SMESH_Mesh& aMesh, int nbhoriz = Min(nbdown, nbup); int nbvertic = Min(nbright, nbleft); + int nbVertices = nbhoriz * nbvertic; + int nbQuad = (nbhoriz - 1) * (nbvertic - 1); + //SCRUTE(nbVertices); + //SCRUTE(nbQuad); + + // const TopoDS_Face& FF = TopoDS::Face(aShape); + // bool faceIsForward = (FF.Orientation() == TopAbs_FORWARD); + // TopoDS_Face F = TopoDS::Face(FF.Oriented(TopAbs_FORWARD)); const TopoDS_Face& F = TopoDS::Face(aShape); + bool faceIsForward = (F.Orientation() == TopAbs_FORWARD); Handle(Geom_Surface) S = BRep_Tool::Surface(F); // internal mesh nodes @@ -511,18 +520,26 @@ FaceQuadStruct *StdMeshers_Quadrangle_2D::CheckAnd2Dcompute (SMESH_Mesh & aMesh, const TopoDS_Shape & aShape) throw(SALOME_Exception) { Unexpect aCatch(SalomeException); +// MESSAGE("StdMeshers_Quadrangle_2D::CheckAnd2Dcompute"); - //SMESH_subMesh *theSubMesh = aMesh.GetSubMesh(aShape); + SMESH_subMesh *theSubMesh = aMesh.GetSubMesh(aShape); + // const TopoDS_Face& FF = TopoDS::Face(aShape); + // bool faceIsForward = (FF.Orientation() == TopAbs_FORWARD); + // TopoDS_Face F = TopoDS::Face(FF.Oriented(TopAbs_FORWARD)); const TopoDS_Face & F = TopoDS::Face(aShape); + bool faceIsForward = (F.Orientation() == TopAbs_FORWARD); // verify 1 wire only, with 4 edges if (NumberOfWires(F) != 1) { - INFOS("only 1 wire by face (quadrangles)"); + MESSAGE("only 1 wire by face (quadrangles)"); return 0; + //throw SALOME_Exception(LOCALIZED("only 1 wire by face (quadrangles)")); } + // const TopoDS_Wire WW = BRepTools::OuterWire(F); + // TopoDS_Wire W = TopoDS::Wire(WW.Oriented(TopAbs_FORWARD)); const TopoDS_Wire& W = BRepTools::OuterWire(F); BRepTools_WireExplorer wexp (W, F); @@ -534,6 +551,8 @@ FaceQuadStruct *StdMeshers_Quadrangle_2D::CheckAnd2Dcompute int nbEdges = 0; for (wexp.Init(W, F); wexp.More(); wexp.Next()) { + // const TopoDS_Edge& EE = wexp.Current(); + // TopoDS_Edge E = TopoDS::Edge(EE.Oriented(TopAbs_FORWARD)); const TopoDS_Edge& E = wexp.Current(); int nb = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes(); if (nbEdges < 4) @@ -546,11 +565,26 @@ FaceQuadStruct *StdMeshers_Quadrangle_2D::CheckAnd2Dcompute if (nbEdges != 4) { - INFOS("face must have 4 edges /quadrangles"); + MESSAGE("face must have 4 edges /quadrangles"); QuadDelete(quad); return 0; + //throw SALOME_Exception(LOCALIZED("face must have 4 edges /quadrangles")); } +// if (quad->nbPts[0] != quad->nbPts[2]) { +// MESSAGE("different point number-opposed edge"); +// QuadDelete(quad); +// return 0; +// //throw SALOME_Exception(LOCALIZED("different point number-opposed edge")); +// } +// +// if (quad->nbPts[1] != quad->nbPts[3]) { +// MESSAGE("different point number-opposed edge"); +// QuadDelete(quad); +// return 0; +// //throw SALOME_Exception(LOCALIZED("different point number-opposed edge")); +// } + // set normalized grid on unit square in parametric domain SetNormalizedGrid(aMesh, F, quad); @@ -626,11 +660,10 @@ void StdMeshers_Quadrangle_2D::SetNormalizedGrid (SMESH_Mesh & aMesh, quad->isEdgeForward[i] = false; } - double l0f1 = pl[0].SquareDistance(pf[1]); - double l0l1 = pl[0].SquareDistance(pl[1]); - double f0f1 = pf[0].SquareDistance(pf[1]); - double f0l1 = pf[0].SquareDistance(pl[1]); - if ( Min( l0f1, l0l1 ) < Min ( f0f1, f0l1 )) + double eps2d = 1.e-3; // *** utiliser plutot TopExp::CommonVertex, puis + // distances si piece fausse +// int i = 0; + if ((pf[1].Distance(pl[0]) < eps2d) || (pl[1].Distance(pl[0]) < eps2d)) { quad->isEdgeForward[0] = true; } else { @@ -640,11 +673,10 @@ void StdMeshers_Quadrangle_2D::SetNormalizedGrid (SMESH_Mesh & aMesh, pf[0] = c2d[0]->Value(quad->first[0]); pl[0] = c2d[0]->Value(quad->last[0]); } + for (int i = 1; i < 4; i++) { - l0l1 = pl[i - 1].SquareDistance(pl[i]); - l0f1 = pl[i - 1].SquareDistance(pf[i]); - quad->isEdgeForward[i] = ( l0f1 < l0l1 ); + quad->isEdgeForward[i] = (pf[i].Distance(pl[i - 1]) < eps2d); if (!quad->isEdgeForward[i]) { double tmp = quad->first[i]; @@ -652,8 +684,19 @@ void StdMeshers_Quadrangle_2D::SetNormalizedGrid (SMESH_Mesh & aMesh, quad->last[i] = tmp; pf[i] = c2d[i]->Value(quad->first[i]); pl[i] = c2d[i]->Value(quad->last[i]); + //SCRUTE(pf[i].Distance(pl[i-1])); + ASSERT(pf[i].Distance(pl[i - 1]) < eps2d); } } + //SCRUTE(pf[0].Distance(pl[3])); + ASSERT(pf[0].Distance(pl[3]) < eps2d); + +// for (int i=0; i<4; i++) +// { +// SCRUTE(quad->isEdgeForward[i]); +// MESSAGE(" -first "<uv_edges[i] = LoadEdgePoints(aMesh, F, quad->edge[i], quad->first[i], quad->last[i]); if (!quad->uv_edges[i]) loadOk = false; + // quad->isEdgeForward[i]); } for (int i = 2; i < 4; i++) @@ -670,19 +714,23 @@ void StdMeshers_Quadrangle_2D::SetNormalizedGrid (SMESH_Mesh & aMesh, quad->uv_edges[i] = LoadEdgePoints(aMesh, F, quad->edge[i], quad->last[i], quad->first[i]); if (!quad->uv_edges[i]) loadOk = false; + // !quad->isEdgeForward[i]); } if (!loadOk) { - INFOS("StdMeshers_Quadrangle_2D::SetNormalizedGrid - LoadEdgePoints failed"); +// MESSAGE("StdMeshers_Quadrangle_2D::SetNormalizedGrid - LoadEdgePoints failed"); QuadDelete( quad ); quad = 0; return; } // 3 --- 2D normalized values on unit square [0..1][0..1] +// int nbdown = quad->nbPts[0]; +// int nbright = quad->nbPts[1]; int nbhoriz = Min(quad->nbPts[0], quad->nbPts[2]); int nbvertic = Min(quad->nbPts[1], quad->nbPts[3]); +// MESSAGE("nbhoriz, nbvertic = " << nbhoriz << nbvertic); quad->isEdgeOut[0] = (quad->nbPts[0] > quad->nbPts[2]); quad->isEdgeOut[1] = (quad->nbPts[1] > quad->nbPts[3]); @@ -798,6 +846,8 @@ void StdMeshers_Quadrangle_2D::SetNormalizedGrid (SMESH_Mesh & aMesh, uv_grid[ij].u = u; uv_grid[ij].v = v; + + //MESSAGE("-uv- "< @@ -98,7 +98,7 @@ void StdMeshersGUI_HypothesisCreator::CreateHypothesis { if ( StdMeshersGUI_Parameters::HasParameters( myHypType )) // Show Dialog for hypothesis creation - StdMeshersGUI_CreateStdHypothesisDlg *aDlg = + //StdMeshersGUI_CreateStdHypothesisDlg *aDlg = new StdMeshersGUI_CreateStdHypothesisDlg(myHypType, parent, ""); else SMESH::CreateHypothesis(myHypType, aHypName, isAlgo); // without GUI @@ -115,9 +115,8 @@ void StdMeshersGUI_HypothesisCreator::EditHypothesis { MESSAGE("StdMeshersGUI_HypothesisCreator::EditHypothesis"); - SALOMEDS::Study::ListOfSObject_var listSOmesh = - SMESH::GetMeshesUsingAlgoOrHypothesis(theHyp); - + SMESH::SObjectList listSOmesh = SMESH::GetMeshesUsingAlgoOrHypothesis(theHyp); + list paramList; StdMeshersGUI_Parameters::GetParameters( theHyp, paramList ); @@ -129,22 +128,22 @@ void StdMeshersGUI_HypothesisCreator::EditHypothesis //set new Attribute Comment for hypothesis which parameters were modified QString aParams = ""; StdMeshersGUI_Parameters::GetParameters( theHyp, paramList, aParams ); - SALOMEDS::SObject_var SHyp = SMESH::FindSObject(theHyp); - if (!SHyp->_is_nil()) + _PTR(SObject) SHyp = SMESH::FindSObject(theHyp); + if (SHyp) if (!aParams.isEmpty()) { SMESH::SetValue(SHyp, aParams); //mySMESHGUI->GetActiveStudy()->updateObjBrowser(true); } - - if ( listSOmesh->length() > 0 ) { - SALOMEDS::SObject_var submSO = listSOmesh[0]; + + if ( listSOmesh.size() > 0 ) { + _PTR(SObject) submSO = listSOmesh[0]; SMESH::SMESH_Mesh_var aMesh = SMESH::SObjectToInterface(submSO); SMESH::SMESH_subMesh_var aSubMesh = SMESH::SObjectToInterface(submSO); if ( !aSubMesh->_is_nil() ) aMesh = aSubMesh->GetFather(); - SALOMEDS::SObject_var meshSO = SMESH::FindSObject( aMesh ); + _PTR(SObject) meshSO = SMESH::FindSObject( aMesh ); SMESH::ModifiedMesh( meshSO, false); } } diff --git a/src/StdMeshersGUI/StdMeshersGUI_CreateHypothesisDlg.cxx b/src/StdMeshersGUI/StdMeshersGUI_CreateHypothesisDlg.cxx index e14857008..b68b6d24c 100644 --- a/src/StdMeshersGUI/StdMeshersGUI_CreateHypothesisDlg.cxx +++ b/src/StdMeshersGUI/StdMeshersGUI_CreateHypothesisDlg.cxx @@ -35,13 +35,16 @@ #include "SMESHGUI_HypothesesUtils.h" #include "SMESHGUI_Utils.h" -#include "QAD_Application.h" -#include "QAD_Desktop.h" +#include "SUIT_Application.h" +#include "SUIT_Desktop.h" +#include "SUIT_MessageBox.h" +#include "SUIT_OverrideCursor.h" #include "utilities.h" -#include "SALOMEGUI_QtCatchCorbaException.hxx" -#include "QAD_MessageBox.h" -#include "QAD_WaitCursor.h" +#include "SalomeApp_Tools.h" +#include "SalomeApp_Application.h" + +#include "OB_Browser.h" // QT Includes #include @@ -227,7 +230,7 @@ void StdMeshersGUI_CreateHypothesisDlg::Init() /* Move widget on the botton right corner of main widget */ int x, y ; mySMESHGUI->DefineDlgPosition( this, x, y ) ; - this->move( x, y ) ; + this->move( x, y ) ; this->show() ; /* displays Dialog */ } @@ -248,17 +251,17 @@ void StdMeshersGUI_CreateHypothesisDlg::ClickOnOk() //================================================================================= bool StdMeshersGUI_CreateHypothesisDlg::ClickOnApply() { - if ( !mySMESHGUI || mySMESHGUI->ActiveStudyLocked() ) + if ( !mySMESHGUI || mySMESHGUI->isActiveStudyLocked() ) return false; QString myHypName = LineEdit_NameHypothesis->text().stripWhiteSpace(); if ( myHypName.isEmpty() ) { - QAD_MessageBox::warn1 (this, tr( "SMESH_WRN_WARNING" ), + SUIT_MessageBox::warn1 (this, tr( "SMESH_WRN_WARNING" ), tr( "SMESH_WRN_EMPTY_NAME" ), tr( "SMESH_BUT_OK" ) ); return false; } - QAD_WaitCursor wc; + SUIT_OverrideCursor wc; try { SMESH::SMESH_Hypothesis_var Hyp = SMESH::SMESH_Hypothesis::_narrow @@ -278,16 +281,16 @@ bool StdMeshersGUI_CreateHypothesisDlg::ClickOnApply() //set new Attribute Comment for hypothesis which parameters were set QString aParams = ""; StdMeshersGUI_Parameters::GetParameters( Hyp.in(), myParamList, aParams ); - SALOMEDS::SObject_var SHyp = SMESH::FindSObject(Hyp.in()); - if (!SHyp->_is_nil()) + _PTR(SObject) SHyp = SMESH::FindSObject(Hyp.in()); + if (SHyp) if (!aParams.isEmpty()) { SMESH::SetValue(SHyp, aParams); - mySMESHGUI->GetActiveStudy()->updateObjBrowser(true); - } + mySMESHGUI->getApp()->objectBrowser()->updateTree(); + } } catch (const SALOME::SALOME_Exception& S_ex) { - wc.stop(); - QtCatchCorbaException(S_ex); + wc.suspend(); + SalomeApp_Tools::QtCatchCorbaException(S_ex); return false; } return true; diff --git a/src/StdMeshersGUI/StdMeshersGUI_CreateStdHypothesisDlg.cxx b/src/StdMeshersGUI/StdMeshersGUI_CreateStdHypothesisDlg.cxx index 32aa02df3..5cc014eea 100644 --- a/src/StdMeshersGUI/StdMeshersGUI_CreateStdHypothesisDlg.cxx +++ b/src/StdMeshersGUI/StdMeshersGUI_CreateStdHypothesisDlg.cxx @@ -35,10 +35,10 @@ using namespace std; #include "utilities.h" -#include "SALOMEGUI_QtCatchCorbaException.hxx" -#include "QAD_MessageBox.h" -#include "QAD_WaitCursor.h" -#include "QAD_Desktop.h" +#include "SUIT_MessageBox.h" +#include "SUIT_ResourceMgr.h" +#include "SUIT_OverrideCursor.h" +#include "SUIT_Desktop.h" //================================================================================= // class : StdMeshersGUI_CreateStdHypothesisDlg() @@ -72,9 +72,9 @@ StdMeshersGUI_CreateStdHypothesisDlg::StdMeshersGUI_CreateStdHypothesisDlg (cons QString caption( tr ( QString( "SMESH_%1_TITLE" ).arg( hypTypeStr ))); QString hypTypeName( tr ( QString( "SMESH_%1_HYPOTHESIS" ).arg( hypTypeStr ))); QString hypIconName( tr ( QString( "ICON_DLG_%1" ).arg( hypTypeStr ))); - - CreateDlgLayout(caption, - QAD_Desktop::getResourceManager()->loadPixmap( "SMESH", hypIconName ), + + CreateDlgLayout(caption, + SMESHGUI::resourceMgr()->loadPixmap( "SMESH", hypIconName ), hypTypeName); } diff --git a/src/StdMeshersGUI/StdMeshers_images.po b/src/StdMeshersGUI/StdMeshers_images.po new file mode 100644 index 000000000..64fe98459 --- /dev/null +++ b/src/StdMeshersGUI/StdMeshers_images.po @@ -0,0 +1,113 @@ +# This is a Qt message file in .po format. Each msgid starts with +# a scope. This scope should *NOT* be translated - eg. "Foo::Bar" +# would be translated to "Pub", not "Foo::Pub". +msgid "" +msgstr "" +"Project-Id-Version: PROJECT VERSION\n" +"POT-Creation-Date: 2002-05-28 10:57:43 AM CEST\n" +"PO-Revision-Date: YYYY-MM-DD\n" +"Last-Translator: FULLNAME \n" +"Content-Type: text/plain; charset=iso-8859-1\n" + + +#Select Icon +msgid "ICON_SELECT" +msgstr "select1.png" + + +#----------------------------------------------------------- +# Hypothesis +#----------------------------------------------------------- + +#Hypo Local Length +msgid "ICON_DLG_LOCAL_LENGTH" +msgstr "mesh_hypo_length.png" + +#Hypo Nb Segments +msgid "ICON_DLG_NB_SEGMENTS" +msgstr "mesh_hypo_segment.png" + +#Hypo Max Area +msgid "ICON_DLG_MAX_ELEMENT_AREA" +msgstr "mesh_hypo_area.png" + +#Hypo Max Volume +msgid "ICON_DLG_MAX_ELEMENT_VOLUME" +msgstr "mesh_hypo_volume.png" + +#Hypo Start End Length +msgid "ICON_DLG_START_END_LENGTH" +msgstr "mesh_hypo_length.png" + +#Hypo deflection 1D +msgid "ICON_DLG_DEFLECTION1D" +msgstr "mesh_hypo_length.png" + +#Hypo Geometric 1D +msgid "ICON_DLG_GEOMETRIC_1D" +msgstr "mesh_hypo_length.png" + +#Hypo Arithmetic 1D +msgid "ICON_DLG_ARITHMETIC_1D" +msgstr "mesh_hypo_length.png" + + +#----------------------------------------------------------- +# ObjectBrowser +#----------------------------------------------------------- + +#mesh_tree_algo_regular +msgid "ICON_SMESH_TREE_ALGO_Regular_1D" +msgstr "mesh_tree_algo_regular.png" + +#mesh_tree_algo_hexa +msgid "ICON_SMESH_TREE_ALGO_Hexa_3D" +msgstr "mesh_tree_algo_hexa.png" + +#mesh_tree_algo_mefisto +msgid "ICON_SMESH_TREE_ALGO_MEFISTO_2D" +msgstr "mesh_tree_algo_mefisto.png" + +#mesh_tree_algo_quad +msgid "ICON_SMESH_TREE_ALGO_Quadrangle_2D" +msgstr "mesh_tree_algo_quad.png" + +#mesh_tree_hypo_area +msgid "ICON_SMESH_TREE_HYPO_MaxElementArea" +msgstr "mesh_tree_hypo_area.png" + +#mesh_tree_hypo_length +msgid "ICON_SMESH_TREE_HYPO_LocalLength" +msgstr "mesh_tree_hypo_length.png" + +#mesh_tree_hypo_segment +msgid "ICON_SMESH_TREE_HYPO_NumberOfSegments" +msgstr "mesh_tree_hypo_segment.png" + +#mesh_tree_hypo_volume +msgid "ICON_SMESH_TREE_HYPO_MaxElementVolume" +msgstr "mesh_tree_hypo_volume.png" + +#mesh_tree_hypo_length +msgid "ICON_SMESH_TREE_HYPO_LengthFromEdges" +msgstr "mesh_tree_hypo_length.png" + +#mesh_tree_hypo_nonconform +msgid "ICON_SMESH_TREE_HYPO_NotConformAllowed" +msgstr "mesh_tree_hypo_length.png" + +#mesh_tree_hypo_start_end_length +msgid "ICON_SMESH_TREE_HYPO_StartEndLength" +msgstr "mesh_tree_hypo_length.png" + +#mesh_tree_hypo_deflection1d +msgid "ICON_SMESH_TREE_HYPO_Deflection1D" +msgstr "mesh_tree_hypo_length.png" + +#mesh_tree_hypo_Arithmetic1d +msgid "ICON_SMESH_TREE_HYPO_Arithmetic1D" +msgstr "mesh_tree_hypo_length.png" + +#mesh_tree_hypo_propagation +msgid "ICON_SMESH_TREE_HYPO_Propagation" +msgstr "mesh_tree_hypo_length.png" diff --git a/src/StdMeshers_I/StdMeshers_Arithmetic1D_i.cxx b/src/StdMeshers_I/StdMeshers_Arithmetic1D_i.cxx index aad7d1e39..9c142aab8 100644 --- a/src/StdMeshers_I/StdMeshers_Arithmetic1D_i.cxx +++ b/src/StdMeshers_I/StdMeshers_Arithmetic1D_i.cxx @@ -28,11 +28,14 @@ using namespace std; #include "StdMeshers_Arithmetic1D_i.hxx" +#include "SMESH_Gen_i.hxx" #include "SMESH_Gen.hxx" #include "Utils_CorbaException.hxx" #include "utilities.h" +#include + //============================================================================= /*! * StdMeshers_Arithmetic1D_i::StdMeshers_Arithmetic1D_i @@ -87,6 +90,13 @@ void StdMeshers_Arithmetic1D_i::SetLength(CORBA::Double theLength, THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM ); } + + // Update Python script + TCollection_AsciiString aStr, aStrLen ((double)theLength), aStrFlag ((int)theIsStart); + SMESH_Gen_i::AddObject(aStr, _this()) += ".SetLength("; + aStr += aStrLen + ", " + aStrFlag + ")"; + + SMESH_Gen_i::AddToCurrentPyScript(aStr); } //============================================================================= diff --git a/src/StdMeshers_I/StdMeshers_Deflection1D_i.cxx b/src/StdMeshers_I/StdMeshers_Deflection1D_i.cxx index 84ef5e96d..78ef384cc 100644 --- a/src/StdMeshers_I/StdMeshers_Deflection1D_i.cxx +++ b/src/StdMeshers_I/StdMeshers_Deflection1D_i.cxx @@ -29,11 +29,14 @@ using namespace std; #include "StdMeshers_Deflection1D_i.hxx" +#include "SMESH_Gen_i.hxx" #include "SMESH_Gen.hxx" #include "Utils_CorbaException.hxx" #include "utilities.h" +#include + //============================================================================= /*! * StdMeshers_Deflection1D_i::StdMeshers_Deflection1D_i @@ -87,6 +90,13 @@ void StdMeshers_Deflection1D_i::SetDeflection( CORBA::Double theValue ) THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM ); } + + // Update Python script + TCollection_AsciiString aStr, aStrVal ((double)theValue); + SMESH_Gen_i::AddObject(aStr, _this()) += ".SetDeflection("; + aStr += aStrVal + ")"; + + SMESH_Gen_i::AddToCurrentPyScript(aStr); } //============================================================================= diff --git a/src/StdMeshers_I/StdMeshers_LocalLength_i.cxx b/src/StdMeshers_I/StdMeshers_LocalLength_i.cxx index 15b3eb79f..fe694f7f7 100644 --- a/src/StdMeshers_I/StdMeshers_LocalLength_i.cxx +++ b/src/StdMeshers_I/StdMeshers_LocalLength_i.cxx @@ -29,11 +29,14 @@ using namespace std; #include "StdMeshers_LocalLength_i.hxx" +#include "SMESH_Gen_i.hxx" #include "SMESH_Gen.hxx" #include "Utils_CorbaException.hxx" #include "utilities.h" +#include + //============================================================================= /*! * StdMeshers_LocalLength_i::StdMeshers_LocalLength_i @@ -87,6 +90,13 @@ void StdMeshers_LocalLength_i::SetLength( CORBA::Double theLength ) THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM ); } + + // Update Python script + TCollection_AsciiString aStr, aStrLen ((double)theLength); + SMESH_Gen_i::AddObject(aStr, _this()) += ".SetLength("; + aStr += aStrLen + ")"; + + SMESH_Gen_i::AddToCurrentPyScript(aStr); } //============================================================================= diff --git a/src/StdMeshers_I/StdMeshers_MaxElementArea_i.cxx b/src/StdMeshers_I/StdMeshers_MaxElementArea_i.cxx index 51810e0a7..09544be6b 100644 --- a/src/StdMeshers_I/StdMeshers_MaxElementArea_i.cxx +++ b/src/StdMeshers_I/StdMeshers_MaxElementArea_i.cxx @@ -29,11 +29,14 @@ using namespace std; #include "StdMeshers_MaxElementArea_i.hxx" +#include "SMESH_Gen_i.hxx" #include "SMESH_Gen.hxx" #include "Utils_CorbaException.hxx" #include "utilities.h" +#include + //============================================================================= /*! * StdMeshers_MaxElementArea_i::StdMeshers_MaxElementArea_i @@ -87,6 +90,13 @@ void StdMeshers_MaxElementArea_i::SetMaxElementArea( CORBA::Double theArea ) THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM ); } + + // Update Python script + TCollection_AsciiString aStr, aStrArea ((double)theArea); + SMESH_Gen_i::AddObject(aStr, _this()) += ".SetMaxElementArea("; + aStr += aStrArea + ")"; + + SMESH_Gen_i::AddToCurrentPyScript(aStr); } //============================================================================= diff --git a/src/StdMeshers_I/StdMeshers_MaxElementVolume_i.cxx b/src/StdMeshers_I/StdMeshers_MaxElementVolume_i.cxx index eb071b664..f571bab82 100644 --- a/src/StdMeshers_I/StdMeshers_MaxElementVolume_i.cxx +++ b/src/StdMeshers_I/StdMeshers_MaxElementVolume_i.cxx @@ -29,11 +29,14 @@ using namespace std; #include "StdMeshers_MaxElementVolume_i.hxx" +#include "SMESH_Gen_i.hxx" #include "SMESH_Gen.hxx" #include "Utils_CorbaException.hxx" #include "utilities.h" +#include + //============================================================================= /*! * StdMeshers_MaxElementVolume_i::StdMeshers_MaxElementVolume_i @@ -87,6 +90,13 @@ void StdMeshers_MaxElementVolume_i::SetMaxElementVolume( CORBA::Double theVolume THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM ); } + + // Update Python script + TCollection_AsciiString aStr, aStrVol ((double)theVolume); + SMESH_Gen_i::AddObject(aStr, _this()) += ".SetMaxElementVolume("; + aStr += aStrVol + ")"; + + SMESH_Gen_i::AddToCurrentPyScript(aStr); } //============================================================================= diff --git a/src/StdMeshers_I/StdMeshers_NumberOfSegments_i.cxx b/src/StdMeshers_I/StdMeshers_NumberOfSegments_i.cxx index bf326bdf3..356d19ad3 100644 --- a/src/StdMeshers_I/StdMeshers_NumberOfSegments_i.cxx +++ b/src/StdMeshers_I/StdMeshers_NumberOfSegments_i.cxx @@ -29,11 +29,14 @@ using namespace std; #include "StdMeshers_NumberOfSegments_i.hxx" +#include "SMESH_Gen_i.hxx" #include "SMESH_Gen.hxx" #include "Utils_CorbaException.hxx" #include "utilities.h" +#include + //============================================================================= /*! * StdMeshers_NumberOfSegments_i::StdMeshers_NumberOfSegments_i @@ -87,6 +90,13 @@ void StdMeshers_NumberOfSegments_i::SetNumberOfSegments( CORBA::Long theSegments THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM ); } + + // Update Python script + TCollection_AsciiString aStr, aStrNb ((int)theSegmentsNumber); + SMESH_Gen_i::AddObject(aStr, _this()) += ".SetNumberOfSegments("; + aStr += aStrNb + ")"; + + SMESH_Gen_i::AddToCurrentPyScript(aStr); } //============================================================================= diff --git a/src/StdMeshers_I/StdMeshers_StartEndLength_i.cxx b/src/StdMeshers_I/StdMeshers_StartEndLength_i.cxx index 08ffa4c81..1d175ea63 100644 --- a/src/StdMeshers_I/StdMeshers_StartEndLength_i.cxx +++ b/src/StdMeshers_I/StdMeshers_StartEndLength_i.cxx @@ -29,11 +29,14 @@ using namespace std; #include "StdMeshers_StartEndLength_i.hxx" +#include "SMESH_Gen_i.hxx" #include "SMESH_Gen.hxx" #include "Utils_CorbaException.hxx" #include "utilities.h" +#include + //============================================================================= /*! * StdMeshers_StartEndLength_i::StdMeshers_StartEndLength_i @@ -88,6 +91,13 @@ void StdMeshers_StartEndLength_i::SetLength(CORBA::Double theLength, THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM ); } + + // Update Python script + TCollection_AsciiString aStr, aStrLen ((double)theLength), aStrFlag ((int)theIsStart); + SMESH_Gen_i::AddObject(aStr, _this()) += ".SetLength("; + aStr += aStrLen + ", " + aStrFlag + ")"; + + SMESH_Gen_i::AddToCurrentPyScript(aStr); } //=============================================================================