From: asl Date: Wed, 20 May 2015 07:11:00 +0000 (+0300) Subject: refs #517: using not-georeferenced profiles in the channel/digue X-Git-Tag: v1.4.1~27 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=4d6a148db0bc353370c3635c1fae774e89bdcd19;p=modules%2Fhydro.git refs #517: using not-georeferenced profiles in the channel/digue --- diff --git a/src/HYDROData/HYDROData_Profile.cxx b/src/HYDROData/HYDROData_Profile.cxx index 9cc693cc..47418cdf 100755 --- a/src/HYDROData/HYDROData_Profile.cxx +++ b/src/HYDROData/HYDROData_Profile.cxx @@ -156,23 +156,32 @@ TopoDS_Shape HYDROData_Profile::GetTopShape() const TopoDS_Shape HYDROData_Profile::GetShape3D() const { - return getShape3D(); + TopoDS_Shape aShape = getShape3D(); + if( aShape.IsNull() ) + aShape = CreateProfileWire( true ); + return aShape; } -void HYDROData_Profile::Update() +TopoDS_Shape HYDROData_Profile::CreateProfileWire( bool canUseDefaultPoints ) const { - HYDROData_Object::Update(); - TopoDS_Wire aWire; Handle(HYDROData_ProfileUZ) aProfile = GetProfileUZ( false ); if ( !aProfile.IsNull() ) { - ProfilePoints aProfilePoints = GetProfilePoints( false ); + ProfilePoints aProfilePoints = GetProfilePoints( false, canUseDefaultPoints ); HYDROData_IPolyline::SectionType aSectionType = aProfile->GetSectionType( 0 ); aWire = HYDROData_PolylineXY::BuildWire( aSectionType, false, aProfilePoints ); } - SetShape3D( aWire ); + return aWire; +} + +void HYDROData_Profile::Update() +{ + HYDROData_Object::Update(); + + TopoDS_Shape aShape = CreateProfileWire( false ); + SetShape3D( aShape ); } QColor HYDROData_Profile::DefaultFillingColor() @@ -226,16 +235,29 @@ void HYDROData_Profile::SetLeftPoint( const gp_XY& theGPoint, bool IsConvertFrom SetToUpdate( true ); } -bool HYDROData_Profile::GetLeftPoint( gp_XY& thePoint, bool IsConvertToGlobal ) const +bool HYDROData_Profile::GetLeftPoint( gp_XY& thePoint, bool IsConvertToGlobal, + bool CanUseDefault ) const { + HYDROData_ProfileUZ::PointsList aParametricPoints = GetParametricPoints(); + if ( aParametricPoints.Length() < 2 ) + return false; + + thePoint = GetParametricPoints().First(); + + thePoint.SetX( 0 ); + thePoint.SetY( 0 ); //default left point of not-georeferenced profile TDF_Label aLabel = myLab.FindChild( DataTag_FirstPoint, false ); if ( aLabel.IsNull() ) - return false; + { + return CanUseDefault; + } Handle(HYDROData_Document) aDoc = HYDROData_Document::Document( myLab ); Handle(TDataStd_RealArray) anArray; if ( !aLabel.FindAttribute( TDataStd_RealArray::GetID(), anArray ) ) - return false; + { + return CanUseDefault; + } thePoint.SetX( anArray->Value( 0 ) ); thePoint.SetY( anArray->Value( 1 ) ); @@ -265,16 +287,27 @@ void HYDROData_Profile::SetRightPoint( const gp_XY& theGPoint, bool IsConvertFro SetToUpdate( true ); } -bool HYDROData_Profile::GetRightPoint( gp_XY& thePoint, bool IsConvertToGlobal ) const +bool HYDROData_Profile::GetRightPoint( gp_XY& thePoint, bool IsConvertToGlobal, + bool CanUseDefault ) const { + HYDROData_ProfileUZ::PointsList aParametricPoints = GetParametricPoints(); + if ( aParametricPoints.Length() < 2 ) + return false; + + thePoint = GetParametricPoints().First(); + TDF_Label aLabel = myLab.FindChild( DataTag_LastPoint, false ); if ( aLabel.IsNull() ) - return false; + { + return CanUseDefault; + } Handle(HYDROData_Document) aDoc = HYDROData_Document::Document( myLab ); Handle(TDataStd_RealArray) anArray; if ( !aLabel.FindAttribute( TDataStd_RealArray::GetID(), anArray ) ) - return false; + { + return CanUseDefault; + } thePoint.SetX( anArray->Value( 0 ) ); thePoint.SetY( anArray->Value( 1 ) ); @@ -385,13 +418,14 @@ void HYDROData_Profile::SetProfilePoints( const ProfilePoints& thePoints, bool I SetRightPoint( aLastPoint, false ); } -HYDROData_Profile::ProfilePoints HYDROData_Profile::GetProfilePoints( bool IsConvertToGlobal ) const +HYDROData_Profile::ProfilePoints HYDROData_Profile::GetProfilePoints + ( bool IsConvertToGlobal, bool CanUseDefaultLeftRight ) const { ProfilePoints aResPoints; gp_XY aFirstPoint, aLastPoint; - if ( !GetLeftPoint( aFirstPoint, IsConvertToGlobal ) || - !GetRightPoint( aLastPoint, IsConvertToGlobal ) ) + if ( !GetLeftPoint( aFirstPoint, IsConvertToGlobal, CanUseDefaultLeftRight ) || + !GetRightPoint( aLastPoint, IsConvertToGlobal, CanUseDefaultLeftRight ) ) return aResPoints; HYDROData_ProfileUZ::PointsList aParametricPoints = GetParametricPoints(); diff --git a/src/HYDROData/HYDROData_Profile.h b/src/HYDROData/HYDROData_Profile.h index 22cd5cd2..0c3ab048 100644 --- a/src/HYDROData/HYDROData_Profile.h +++ b/src/HYDROData/HYDROData_Profile.h @@ -125,7 +125,8 @@ public: * \param thePoint[out] profile first point * \return true if point has been set */ - HYDRODATA_EXPORT bool GetLeftPoint( gp_XY& thePoint, bool IsConvertToGlobal = false ) const; + HYDRODATA_EXPORT bool GetLeftPoint( gp_XY& thePoint, bool IsConvertToGlobal = false, + bool CanUseDefault = false ) const; /** * Set last(right) point for profile. @@ -138,8 +139,8 @@ public: * \param thePoint[out] profile last point * \return true if point has been set */ - HYDRODATA_EXPORT bool GetRightPoint( gp_XY& thePoint, bool IsConvertToGlobal = false ) const; - + HYDRODATA_EXPORT bool GetRightPoint( gp_XY& thePoint, bool IsConvertToGlobal = false, + bool CanUseDefault = false ) const; /** * Returns object which store parametric presentation of profile points. @@ -185,7 +186,8 @@ public: * Empty sequence is returned if first or last point was not set. * \return profile points list */ - HYDRODATA_EXPORT ProfilePoints GetProfilePoints( bool IsConvertToGlobal = false ) const; + HYDRODATA_EXPORT ProfilePoints GetProfilePoints( bool IsConvertToGlobal = false, + bool CanUseDefaultLeftRight = false ) const; /** @@ -256,6 +258,7 @@ protected: */ HYDRODATA_EXPORT virtual void checkAndSetObject3D() {} + TopoDS_Shape CreateProfileWire( bool canUseDefaultPoints ) const; protected: diff --git a/src/HYDROGUI/HYDROGUI_ChannelOp.cxx b/src/HYDROGUI/HYDROGUI_ChannelOp.cxx index afeff419..71714929 100644 --- a/src/HYDROGUI/HYDROGUI_ChannelOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ChannelOp.cxx @@ -105,7 +105,7 @@ void HYDROGUI_ChannelOp::startOperation() } // collect information about existing profiles - QStringList aProfiles = HYDROGUI_Tool::FindExistingObjectsNames( doc(), KIND_PROFILE, true ); + QStringList aProfiles = HYDROGUI_Tool::FindExistingObjectsNames( doc(), KIND_PROFILE, false ); aPanel->setObjectName( anObjectName );