From: isn Date: Mon, 21 Jan 2019 17:38:54 +0000 (+0300) Subject: lot 13 - GUI/VISUAL part X-Git-Tag: SH_V2_2_0~99^2~34 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=cc8a7c69f63e12ebcef8de6dbb5431b8009ed59b;p=modules%2Fhydro.git lot 13 - GUI/VISUAL part --- diff --git a/src/HYDROData/HYDROData_Channel.cxx b/src/HYDROData/HYDROData_Channel.cxx index d4645ea4..f489e803 100644 --- a/src/HYDROData/HYDROData_Channel.cxx +++ b/src/HYDROData/HYDROData_Channel.cxx @@ -27,6 +27,7 @@ #include "HYDROData_ShapesTool.h" #include "HYDROData_Stream.h" #include "HYDROData_Tool.h" +#include "HYDROData_ChannelAltitude.h" #include @@ -124,7 +125,8 @@ HYDROData_SequenceOfObjects HYDROData_Channel::GetAllReferenceObjects() const bool HYDROData_Channel::CreatePresentations( const Handle(HYDROData_Polyline3D)& theGuideLine, const Handle(HYDROData_Profile)& theProfile, PrsDefinition& thePrs, - double theEquiDistance ) + double theEquiDistance, + bool ReverseXCoord) { // Check input parameters if ( theGuideLine.IsNull() || theProfile.IsNull() ) { @@ -132,7 +134,11 @@ bool HYDROData_Channel::CreatePresentations( const Handle(HYDROData_Polyline3D)& } TopoDS_Wire aPathWire = TopoDS::Wire( theGuideLine->GetShape3D() ); - TopoDS_Wire aProfileWire = TopoDS::Wire( theProfile->GetShape3D() ); + TopoDS_Wire aProfileWire; + if (!ReverseXCoord) + aProfileWire = TopoDS::Wire( theProfile->GetShape3D(true, false) ); //temp force rebuild + else + aProfileWire = TopoDS::Wire( theProfile->GetShape3D(true, true)); if ( aPathWire.IsNull() || aProfileWire.IsNull() ) { return false; } @@ -313,7 +319,14 @@ void HYDROData_Channel::Update() PrsDefinition aResultPrs; double anEquiDistance = GetEquiDistance(); - if ( !CreatePresentations( aGuideLine, aProfile, aResultPrs, anEquiDistance ) ) + + bool invDirection = false; + Handle(HYDROData_IAltitudeObject) anObjAltitude = GetAltitudeObject(); + Handle(HYDROData_ChannelAltitude) aChannelAlt = Handle(HYDROData_ChannelAltitude)::DownCast(anObjAltitude); + if (!aChannelAlt.IsNull()) + invDirection = aChannelAlt->GetInvertDirection(); + + if ( !CreatePresentations( aGuideLine, aProfile, aResultPrs, anEquiDistance, invDirection ) ) return; SetShape3D( aResultPrs.myPrs3D ); diff --git a/src/HYDROData/HYDROData_Channel.h b/src/HYDROData/HYDROData_Channel.h index 3ba6e2c9..914718e8 100644 --- a/src/HYDROData/HYDROData_Channel.h +++ b/src/HYDROData/HYDROData_Channel.h @@ -68,7 +68,8 @@ public: HYDRODATA_EXPORT static bool CreatePresentations( const Handle(HYDROData_Polyline3D)& theGuideLine, const Handle(HYDROData_Profile)& theProfile, PrsDefinition& thePrs, - double theEquiDistance ); + double theEquiDistance, + bool ReverseXCoord = false); public: diff --git a/src/HYDROData/HYDROData_ChannelAltitude.cxx b/src/HYDROData/HYDROData_ChannelAltitude.cxx index d3c0008e..214c6bf1 100644 --- a/src/HYDROData/HYDROData_ChannelAltitude.cxx +++ b/src/HYDROData/HYDROData_ChannelAltitude.cxx @@ -26,6 +26,7 @@ #include "HYDROData_PolylineXY.h" #include "HYDROData_ProfileUZ.h" #include "HYDROData_Profile.h" +#include #define _DEVDEBUG_ #include "HYDRO_trace.hxx" @@ -287,7 +288,10 @@ double HYDROData_ChannelAltitude::GetAltitudeForPoint( const gp_XY& thePoint, distance *= aSign; DEBTRACE("distance to guideline " << distance); - + + if (GetInvertDirection()) + distance*=-1; + // get delta altitude on section (supposed symmetric) from guideline distance (aParam) double delta = 0; int i1 = 0; @@ -313,7 +317,7 @@ double HYDROData_ChannelAltitude::GetAltitudeForPoint( const gp_XY& thePoint, } if ((i1 == 0) && (i2 == 0)) { - DEBTRACE("Projection aborted: non centered profile"); + DEBTRACE("Projection aborted : non centered profile"); return aResAltitude; } else if (i1 == 0) // distance < - profile width @@ -346,5 +350,27 @@ double HYDROData_ChannelAltitude::GetAltitudeForPoint( const gp_XY& thePoint, } +void HYDROData_ChannelAltitude::SetInvertDirection(bool IsInverted) +{ + if ( GetInvertDirection() == IsInverted ) + return; + + TDataStd_Integer::Set( myLab.FindChild( DataTag_InvertDirection ), (Standard_Integer)IsInverted ); +} + +bool HYDROData_ChannelAltitude::GetInvertDirection() const +{ + bool aRes = false; + + TDF_Label aLabel = myLab.FindChild( DataTag_InvertDirection, false ); + if ( !aLabel.IsNull() ) + { + Handle(TDataStd_Integer) anIntVal; + if ( aLabel.FindAttribute( TDataStd_Integer::GetID(), anIntVal ) ) + aRes = (bool)anIntVal->Get(); + } + + return aRes; +} diff --git a/src/HYDROData/HYDROData_ChannelAltitude.h b/src/HYDROData/HYDROData_ChannelAltitude.h index d65582e5..93fabb49 100644 --- a/src/HYDROData/HYDROData_ChannelAltitude.h +++ b/src/HYDROData/HYDROData_ChannelAltitude.h @@ -38,6 +38,7 @@ protected: enum DataTag { DataTag_First = HYDROData_IAltitudeObject::DataTag_First + 100, ///< first tag, to reserve + DataTag_InvertDirection, ///< flag for inversion of direction }; public: @@ -61,6 +62,10 @@ public: HYDRODATA_EXPORT virtual double GetAltitudeForPoint( const gp_XY& thePoint, int theMethod =0) const; + HYDRODATA_EXPORT void SetInvertDirection(bool IsInverted); + + HYDRODATA_EXPORT bool GetInvertDirection() const; + protected: friend class HYDROData_Iterator; diff --git a/src/HYDROData/HYDROData_Profile.cxx b/src/HYDROData/HYDROData_Profile.cxx index cd8bd084..ae79ef48 100644 --- a/src/HYDROData/HYDROData_Profile.cxx +++ b/src/HYDROData/HYDROData_Profile.cxx @@ -162,15 +162,17 @@ TopoDS_Shape HYDROData_Profile::GetTopShape() const return aWire; } -TopoDS_Shape HYDROData_Profile::GetShape3D() const +TopoDS_Shape HYDROData_Profile::GetShape3D(bool forceRebuild, bool reverseXCoord) const { + if (forceRebuild) + return CreateProfileWire( true, reverseXCoord ); TopoDS_Shape aShape = HYDROData_Object::GetShape3D(); if( aShape.IsNull() ) - aShape = CreateProfileWire( true ); + aShape = CreateProfileWire( true, reverseXCoord ); return aShape; } -TopoDS_Shape HYDROData_Profile::CreateProfileWire( bool canUseDefaultPoints ) const +TopoDS_Shape HYDROData_Profile::CreateProfileWire( bool canUseDefaultPoints, bool reverseXCoord ) const { TopoDS_Wire aWire; Handle(HYDROData_ProfileUZ) aProfile = GetProfileUZ( false ); @@ -178,7 +180,14 @@ TopoDS_Shape HYDROData_Profile::CreateProfileWire( bool canUseDefaultPoints ) co { ProfilePoints aProfilePoints = GetProfilePoints( false, canUseDefaultPoints ); HYDROData_IPolyline::SectionType aSectionType = aProfile->GetSectionType( 0 ); - + if (reverseXCoord) + { + for ( int i = 1; i <= aProfilePoints.Size() ; i++ ) + { + gp_XYZ& aPoint = aProfilePoints.ChangeValue(i); + aPoint.ChangeCoord(1) = -aPoint.X(); + } + } aWire = HYDROData_PolylineXY::BuildWire( aSectionType, false, aProfilePoints ); } return aWire; diff --git a/src/HYDROData/HYDROData_Profile.h b/src/HYDROData/HYDROData_Profile.h index 79f24185..94ca5bb2 100644 --- a/src/HYDROData/HYDROData_Profile.h +++ b/src/HYDROData/HYDROData_Profile.h @@ -72,7 +72,7 @@ public: /** * Returns the 3d shape of the object. */ - HYDRODATA_EXPORT virtual TopoDS_Shape GetShape3D() const; + HYDRODATA_EXPORT virtual TopoDS_Shape GetShape3D(bool forceRebuild = false, bool reverseXCoord = false) const; /** * Updates profile 3D presentation. @@ -261,7 +261,7 @@ protected: */ HYDRODATA_EXPORT virtual void checkAndSetObject3D() {} - TopoDS_Shape CreateProfileWire( bool canUseDefaultPoints ) const; + TopoDS_Shape CreateProfileWire( bool canUseDefaultPoints, bool reverseXCoord = false) const; static void ProjectProfilePoints( ProfilePoints& thePoints ); diff --git a/src/HYDROGUI/HYDROGUI_ChannelDlg.cxx b/src/HYDROGUI/HYDROGUI_ChannelDlg.cxx index 9c8513ca..d2c66807 100644 --- a/src/HYDROGUI/HYDROGUI_ChannelDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_ChannelDlg.cxx @@ -25,6 +25,7 @@ #include #include #include +#include #include HYDROGUI_ChannelDlg::HYDROGUI_ChannelDlg( HYDROGUI_Module* theModule, const QString& theTitle ) @@ -57,6 +58,9 @@ HYDROGUI_ChannelDlg::HYDROGUI_ChannelDlg( HYDROGUI_Module* theModule, const QStr myEquiDistance->setValue( 1.0 ); myEquiDistance->setSingleStep( 1.0 ); + myInvertDirection = new QCheckBox(aParamGroup); + myInvertDirection->setChecked(false); + QGridLayout* aParamsLayout = new QGridLayout( aParamGroup ); aParamsLayout->setMargin( 5 ); aParamsLayout->setSpacing( 5 ); @@ -66,6 +70,8 @@ HYDROGUI_ChannelDlg::HYDROGUI_ChannelDlg( HYDROGUI_Module* theModule, const QStr aParamsLayout->addWidget( myProfiles, 1, 1 ); aParamsLayout->addWidget( new QLabel( tr( "EQUI_DISTANCE" ), aParamGroup ), 2, 0 ); aParamsLayout->addWidget( myEquiDistance, 2, 1 ); + aParamsLayout->addWidget( new QLabel( tr( "INVERT_DIRECTION" ), aParamGroup ), 3, 0 ); + aParamsLayout->addWidget( myInvertDirection, 3, 1 ); // Common addWidget( myObjectNameGroup ); @@ -179,3 +185,14 @@ void HYDROGUI_ChannelDlg::setEquiDistance( double theValue ) { myEquiDistance->setValue( theValue ); } + +bool HYDROGUI_ChannelDlg::getInvertDirection() const +{ + return myInvertDirection->isChecked(); +} + +void HYDROGUI_ChannelDlg::setInvertDirection( bool isChecked ) +{ + myInvertDirection->setChecked(isChecked); +} + diff --git a/src/HYDROGUI/HYDROGUI_ChannelDlg.h b/src/HYDROGUI/HYDROGUI_ChannelDlg.h index e01a9f5e..1501dc2f 100644 --- a/src/HYDROGUI/HYDROGUI_ChannelDlg.h +++ b/src/HYDROGUI/HYDROGUI_ChannelDlg.h @@ -25,6 +25,7 @@ class QComboBox; class QGroupBox; class QLineEdit; +class QCheckBox; class QtxDoubleSpinBox; class HYDROGUI_ChannelDlg : public HYDROGUI_InputPanel @@ -50,6 +51,10 @@ public: double getEquiDistance() const; void setEquiDistance( double ); + + bool getInvertDirection() const; + void setInvertDirection( bool isChecked ); + signals: void CreatePreview(); @@ -66,6 +71,7 @@ protected: QComboBox* myProfiles; QtxDoubleSpinBox* myEquiDistance; + QCheckBox* myInvertDirection; }; #endif diff --git a/src/HYDROGUI/HYDROGUI_ChannelOp.cxx b/src/HYDROGUI/HYDROGUI_ChannelOp.cxx index 8c3e73e4..a0a699c0 100644 --- a/src/HYDROGUI/HYDROGUI_ChannelOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ChannelOp.cxx @@ -36,6 +36,7 @@ #include #include +#include #include @@ -123,6 +124,18 @@ void HYDROGUI_ChannelOp::startOperation() else aPanel->setEquiDistance( 1.0 ); + if( !myEditedObject.IsNull() ) + { + bool invDirection = false; + Handle(HYDROData_IAltitudeObject) anObjAltitude = myEditedObject->GetAltitudeObject(); + Handle(HYDROData_ChannelAltitude) aChannelAlt = Handle(HYDROData_ChannelAltitude)::DownCast(anObjAltitude); + if (!aChannelAlt.IsNull()) + invDirection = aChannelAlt->GetInvertDirection(); + aPanel->setInvertDirection( invDirection ); + } + else + aPanel->setInvertDirection( false ); + aPanel->blockSignals( false ); onCreatePreview(); @@ -216,6 +229,11 @@ bool HYDROGUI_ChannelOp::processApply( int& theUpdateFlags, myEditedObject->RemoveProfile(); myEditedObject->SetProfile( aProfile ); myEditedObject->SetEquiDistance( aPanel->getEquiDistance() ); + /// + Handle(HYDROData_IAltitudeObject) anObjAltitude = myEditedObject->GetAltitudeObject(); + Handle(HYDROData_ChannelAltitude) aChannelAlt = Handle(HYDROData_ChannelAltitude)::DownCast(anObjAltitude); + if (!aChannelAlt.IsNull()) + aChannelAlt->SetInvertDirection(aPanel->getInvertDirection()); } if ( myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_2d ) ) diff --git a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts index 48bfb0a4..e938a9e0 100755 --- a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts +++ b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts @@ -3099,6 +3099,10 @@ Polyline should consist from one not closed curve. EQUI_DISTANCE Equidistance + + INVERT_DIRECTION + Invert direction +