From 1ca58327ab17010a733d2ab0a5f6aae73a9115b6 Mon Sep 17 00:00:00 2001 From: isn Date: Tue, 5 Feb 2019 21:35:18 +0300 Subject: [PATCH] lot 12 p.2 --- src/HYDROData/HYDROData_Channel.cxx | 119 ++++++++++++++++++++++++--- src/HYDROData/HYDROData_Channel.h | 38 ++++++++- src/HYDROGUI/HYDROGUI_ChannelDlg.cxx | 33 ++++++++ src/HYDROGUI/HYDROGUI_ChannelDlg.h | 11 ++- src/HYDROGUI/HYDROGUI_ChannelOp.cxx | 61 ++++++++++++-- 5 files changed, 240 insertions(+), 22 deletions(-) diff --git a/src/HYDROData/HYDROData_Channel.cxx b/src/HYDROData/HYDROData_Channel.cxx index f489e803..1a08a52d 100644 --- a/src/HYDROData/HYDROData_Channel.cxx +++ b/src/HYDROData/HYDROData_Channel.cxx @@ -30,6 +30,7 @@ #include "HYDROData_ChannelAltitude.h" #include +#include #include #include @@ -127,18 +128,61 @@ bool HYDROData_Channel::CreatePresentations( const Handle(HYDROData_Polyline3D)& PrsDefinition& thePrs, double theEquiDistance, bool ReverseXCoord) +{ + return internalCreatePresentations( true, theGuideLine, theProfile, TopoDS_Wire(), gp_Pnt(), thePrs, theEquiDistance, ReverseXCoord); +} + +bool HYDROData_Channel::CreatePresentations( const Handle(HYDROData_Polyline3D)& theGuideLine, + double LC, + double deltaZ, + double coteZ, + PrsDefinition& thePrs, + double theEquiDistance, + bool ReverseXCoord) +{ + Handle(HYDROData_Profile) theProfile; + TopoDS_Wire W; + gp_Pnt MP; + + gp_Pnt2d A1(-0.75*LC, coteZ-LC/2.0), A2(0.75*LC, coteZ -LC/2.0), B1(-LC/2.0, coteZ), B2(LC/2.0, coteZ), C(0, coteZ+deltaZ); + gp_Pnt A1_3d(A1.X(), 0, A1.Y()), A2_3d(A2.X(), 0, A2.Y()), B1_3d(B1.X(), 0, B1.Y()), B2_3d(B2.X(), 0, B2.Y()), C_3d(C.X(), 0, C.Y()); + BRepLib_MakePolygon PM; + PM.Add(A1_3d); + PM.Add(B1_3d); + PM.Add(C_3d); + PM.Add(B2_3d); + PM.Add(A2_3d); + W = PM.Wire(); + return internalCreatePresentations( false, theGuideLine, theProfile, W, MP, thePrs, theEquiDistance, ReverseXCoord); +} + +bool HYDROData_Channel::internalCreatePresentations( bool mode, + const Handle(HYDROData_Polyline3D)& theGuideLine, + const Handle(HYDROData_Profile)& theProfile, + const TopoDS_Wire& theProfWire, + const gp_Pnt& theMiddlePnt, + PrsDefinition& thePrs, + double theEquiDistance, + bool ReverseXCoord) { // Check input parameters - if ( theGuideLine.IsNull() || theProfile.IsNull() ) { + if ( theGuideLine.IsNull() ) + { return false; } + if (mode && theProfile.IsNull() || !mode && theProfWire.IsNull() ) + return false; TopoDS_Wire aPathWire = TopoDS::Wire( theGuideLine->GetShape3D() ); - TopoDS_Wire aProfileWire; - if (!ReverseXCoord) - aProfileWire = TopoDS::Wire( theProfile->GetShape3D(true, false) ); //temp force rebuild - else - aProfileWire = TopoDS::Wire( theProfile->GetShape3D(true, true)); + TopoDS_Wire aProfileWire = theProfWire; + //ignore ReverseXCoord if mode is false + if (mode) + { + 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; } @@ -231,7 +275,11 @@ bool HYDROData_Channel::CreatePresentations( const Handle(HYDROData_Polyline3D)& } // Get the profile middle point ( 3D ) - gp_Pnt aMiddlePoint( theProfile->GetMiddlePoint( true ) ); + gp_Pnt aMiddlePoint = theMiddlePnt; + if (mode) + { + aMiddlePoint = theProfile->GetMiddlePoint( true ); + } // Translate the profile to each point on the guide line ( 3D ) Handle(TColgp_HArray1OfPnt) anArrayOfFPnt = new TColgp_HArray1OfPnt(1, aNbPoints ); @@ -315,7 +363,6 @@ void HYDROData_Channel::Update() HYDROData_ArtificialObject::Update(); Handle(HYDROData_Polyline3D) aGuideLine = GetGuideLine(); - Handle(HYDROData_Profile) aProfile = GetProfile(); PrsDefinition aResultPrs; double anEquiDistance = GetEquiDistance(); @@ -326,8 +373,20 @@ void HYDROData_Channel::Update() if (!aChannelAlt.IsNull()) invDirection = aChannelAlt->GetInvertDirection(); - if ( !CreatePresentations( aGuideLine, aProfile, aResultPrs, anEquiDistance, invDirection ) ) - return; + if (GetProfileMode()) + { + Handle(HYDROData_Profile) aProfile = GetProfile(); + if ( !CreatePresentations( aGuideLine, aProfile, aResultPrs, anEquiDistance, invDirection ) ) + return; + } + else + { + double lc = GetLCValue(); + double deltaz = GetDeltaZValue(); + double cotez = GetCoteZValue(); + if ( !CreatePresentations( aGuideLine, lc, deltaz, cotez, aResultPrs, anEquiDistance, invDirection ) ) + return; + } SetShape3D( aResultPrs.myPrs3D ); SetTopShape( aResultPrs.myPrs2D ); @@ -496,3 +555,43 @@ double HYDROData_Channel::GetEquiDistance() const { return GetDouble( DataTag_EquiDistance, 1.0 ); } + +void HYDROData_Channel::SetLCValue( double val ) +{ + SetDouble( DataTag_LC, val ); +} + +double HYDROData_Channel::GetLCValue() const +{ + return GetDouble( DataTag_LC, 1.0 ); +} + +void HYDROData_Channel::SetDeltaZValue( double val ) +{ + SetDouble( DataTag_DeltaZ, val ); +} + +double HYDROData_Channel::GetDeltaZValue() const +{ + return GetDouble( DataTag_DeltaZ, 1.0 ); +} + +void HYDROData_Channel::SetCoteZValue( double val ) +{ + SetDouble( DataTag_CoteZ, val ); +} + +double HYDROData_Channel::GetCoteZValue() const +{ + return GetDouble( DataTag_CoteZ, 1.0 ); +} + +void HYDROData_Channel::SetProfileMode( bool mode ) +{ + SetInteger( DataTag_ProfileMode, (bool)mode ); +} + +bool HYDROData_Channel::GetProfileMode() const +{ + return (bool)GetInteger( DataTag_ProfileMode, 1 ); +} diff --git a/src/HYDROData/HYDROData_Channel.h b/src/HYDROData/HYDROData_Channel.h index 914718e8..36cd5062 100644 --- a/src/HYDROData/HYDROData_Channel.h +++ b/src/HYDROData/HYDROData_Channel.h @@ -55,6 +55,10 @@ protected: DataTag_GuideLine, DataTag_Profile, DataTag_EquiDistance, + DataTag_ProfileMode, + DataTag_LC, + DataTag_DeltaZ, + DataTag_CoteZ }; public: @@ -65,12 +69,31 @@ public: /** * Creates the presentations(2D and 3D) by given guide line and profile. */ + HYDRODATA_EXPORT static bool CreatePresentations( const Handle(HYDROData_Polyline3D)& theGuideLine, const Handle(HYDROData_Profile)& theProfile, PrsDefinition& thePrs, - double theEquiDistance, + double theEquiDistance, + bool ReverseXCoord = false); + + HYDRODATA_EXPORT static bool CreatePresentations( const Handle(HYDROData_Polyline3D)& theGuideLine, + double LC, + double deltaZ, + double coteZ, + PrsDefinition& thePrs, + double theEquiDistance, bool ReverseXCoord = false); +protected: + static bool internalCreatePresentations( bool mode, + const Handle(HYDROData_Polyline3D)& theGuideLine, + const Handle(HYDROData_Profile)& theProfile, + const TopoDS_Wire& theProfWire, + const gp_Pnt& theMiddlePnt, + PrsDefinition& thePrs, + double theEquiDistance, + bool ReverseXCoord); + public: /** @@ -158,6 +181,19 @@ public: HYDRODATA_EXPORT void SetEquiDistance( double ); HYDRODATA_EXPORT double GetEquiDistance() const; + + HYDRODATA_EXPORT void SetLCValue( double ); + HYDRODATA_EXPORT double GetLCValue() const; + + HYDRODATA_EXPORT void SetDeltaZValue( double ); + HYDRODATA_EXPORT double GetDeltaZValue() const; + + HYDRODATA_EXPORT void SetCoteZValue( double ); + HYDRODATA_EXPORT double GetCoteZValue() const; + + HYDRODATA_EXPORT void SetProfileMode( bool ); + HYDRODATA_EXPORT bool GetProfileMode() const; + protected: /** * Returns the type of child altitude object. diff --git a/src/HYDROGUI/HYDROGUI_ChannelDlg.cxx b/src/HYDROGUI/HYDROGUI_ChannelDlg.cxx index c8fa95f3..cf106701 100644 --- a/src/HYDROGUI/HYDROGUI_ChannelDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_ChannelDlg.cxx @@ -122,6 +122,10 @@ HYDROGUI_ChannelDlg::HYDROGUI_ChannelDlg( HYDROGUI_Module* theModule, const QStr connect( myGuideLines, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onChannelDefChanged() ) ); connect( myProfiles, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onChannelDefChanged() ) ); + connect( myLCVal, SIGNAL( valueChanged( double ) ), this, SLOT( onChannelDefChanged() ) ); + connect( myDeltaZVal, SIGNAL( valueChanged( double ) ), this, SLOT( onChannelDefChanged() ) ); + connect( myCoteZVal, SIGNAL( valueChanged( double ) ), this, SLOT( onChannelDefChanged() ) ); + connect( myProfileModeButton, SIGNAL( toggled( bool ) ), this, SLOT( onProfileModeChanged( bool ) ) ); myProfileModeButton->setChecked(true); } @@ -244,6 +248,7 @@ void HYDROGUI_ChannelDlg::onProfileModeChanged(bool mode) myCoteZValLabel->setVisible(true); myCoteZVal->setVisible(true); } + emit CreatePreview(); } bool HYDROGUI_ChannelDlg::getProfileMode() @@ -271,3 +276,31 @@ void HYDROGUI_ChannelDlg::setInvertDirection( bool isChecked ) myInvertDirection->setChecked(isChecked); } +double HYDROGUI_ChannelDlg::getLCValue() const +{ + return myLCVal->value(); +} + +void HYDROGUI_ChannelDlg::setLCValue( double val ) +{ + myLCVal->setValue( val ); +} + +double HYDROGUI_ChannelDlg::getDeltaZValue() const +{ + return myDeltaZVal->value(); +} + +void HYDROGUI_ChannelDlg::setDeltaZValue( double val ) +{ + myDeltaZVal->setValue( val ); +} +double HYDROGUI_ChannelDlg::getCoteZValue() const +{ + return myCoteZVal->value(); +} + +void HYDROGUI_ChannelDlg::setCoteZValue( double val ) +{ + myCoteZVal->setValue( val ); +} \ No newline at end of file diff --git a/src/HYDROGUI/HYDROGUI_ChannelDlg.h b/src/HYDROGUI/HYDROGUI_ChannelDlg.h index d651c446..5af01f6a 100644 --- a/src/HYDROGUI/HYDROGUI_ChannelDlg.h +++ b/src/HYDROGUI/HYDROGUI_ChannelDlg.h @@ -58,8 +58,15 @@ public: void setInvertDirection( bool isChecked ); bool getProfileMode(); - - + + double getLCValue() const; + void setLCValue( double ); + + double getDeltaZValue() const; + void setDeltaZValue( double ); + + double getCoteZValue() const; + void setCoteZValue( double ); signals: void CreatePreview(); diff --git a/src/HYDROGUI/HYDROGUI_ChannelOp.cxx b/src/HYDROGUI/HYDROGUI_ChannelOp.cxx index a0a699c0..2a1ede23 100644 --- a/src/HYDROGUI/HYDROGUI_ChannelOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ChannelOp.cxx @@ -199,7 +199,23 @@ bool HYDROGUI_ChannelOp::processApply( int& theUpdateFlags, } QString aGuideLineName = aPanel->getGuideLineName(); - QString aProfileName = aPanel->getProfileName(); + + bool profileMode = aPanel->getProfileMode(); + QString aProfileName; + double lc=0, deltaz=0, cotez=0; + + if (profileMode) + { + aProfileName = aPanel->getProfileName(); + } + else + { + lc = aPanel->getLCValue(); + deltaz = aPanel->getDeltaZValue(); + cotez = aPanel->getCoteZValue(); + } + + /*if ( aGuideLineName.isEmpty() || aProfileName.isEmpty() ) { myEditedObject->RemoveGuideLine(); @@ -218,16 +234,31 @@ bool HYDROGUI_ChannelOp::processApply( int& theUpdateFlags, myEditedObject->RemoveGuideLine(); myEditedObject->SetGuideLine( aGuideLine ); - Handle(HYDROData_Profile) aProfile = Handle(HYDROData_Profile)::DownCast( - HYDROGUI_Tool::FindObjectByName( module(), aProfileName, KIND_PROFILE ) ); - if ( aProfile.IsNull() ) + myEditedObject->SetProfileMode(profileMode); + + if (profileMode) { - theErrorMsg = tr( "PROFILE_IS_NOT_SELECTED" ); - return false; + Handle(HYDROData_Profile) aProfile = Handle(HYDROData_Profile)::DownCast( + HYDROGUI_Tool::FindObjectByName( module(), aProfileName, KIND_PROFILE ) ); + if ( aProfile.IsNull() ) + { + theErrorMsg = tr( "PROFILE_IS_NOT_SELECTED" ); + return false; + } + myEditedObject->RemoveProfile(); + myEditedObject->SetProfile( aProfile ); + myEditedObject->SetLCValue(0); + myEditedObject->SetDeltaZValue(0); + myEditedObject->SetCoteZValue(0); + } + else + { + myEditedObject->RemoveProfile(); + myEditedObject->SetLCValue(lc); + myEditedObject->SetDeltaZValue(deltaz); + myEditedObject->SetCoteZValue(cotez); } - myEditedObject->RemoveProfile(); - myEditedObject->SetProfile( aProfile ); myEditedObject->SetEquiDistance( aPanel->getEquiDistance() ); /// Handle(HYDROData_IAltitudeObject) anObjAltitude = myEditedObject->GetAltitudeObject(); @@ -315,8 +346,20 @@ void HYDROGUI_ChannelOp::onCreatePreview() Handle(HYDROData_Profile) aProfile = Handle(HYDROData_Profile)::DownCast( HYDROGUI_Tool::FindObjectByName( module(), aProfileName, KIND_PROFILE ) ); + bool aProfMode = aPanel->getProfileMode(); HYDROData_Channel::PrsDefinition aPrsDef; - if ( !HYDROData_Channel::CreatePresentations( aGuideLine, aProfile, aPrsDef, aPanel->getEquiDistance() ) ) + bool stat = false; + double eqDist = aPanel->getEquiDistance(); + if (aProfMode) + stat = HYDROData_Channel::CreatePresentations( aGuideLine, aProfile, aPrsDef, eqDist); + else + { + double lc = aPanel->getLCValue(); + double deltaz = aPanel->getDeltaZValue(); + double cotez = aPanel->getCoteZValue(); + stat = HYDROData_Channel::CreatePresentations( aGuideLine, lc, deltaz, cotez, aPrsDef, eqDist); + } + if ( !stat ) { erasePreview(); return; -- 2.39.2