From: isn Date: Wed, 27 Mar 2019 15:20:03 +0000 (+0300) Subject: refs# 1917 + protection against null shapes wires in GetMiddlePoint() X-Git-Tag: SH_V2_2_0~99^2~26^2~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=bf43e7f40bfb4de772c00d372241335b5f85bc47;p=modules%2Fhydro.git refs# 1917 + protection against null shapes wires in GetMiddlePoint() --- diff --git a/src/HYDROData/HYDROData_Profile.cxx b/src/HYDROData/HYDROData_Profile.cxx index 3ec51658..f8f8ba20 100644 --- a/src/HYDROData/HYDROData_Profile.cxx +++ b/src/HYDROData/HYDROData_Profile.cxx @@ -796,7 +796,10 @@ HYDROData_Profile::ProfilePoint HYDROData_Profile::GetBottomPoint(bool IsConvert gp_Lin aMidLin( aMiddlePoint2d, gp::DZ() ); TopoDS_Edge aMidEdge = BRepLib_MakeEdge( aMidLin ); - TopoDS_Iterator anIt( TopoDS::Wire( GetShape3D() ) ); + const TopoDS_Wire& aProf = TopoDS::Wire( GetShape3D() ); + if (aProf.IsNull()) + return aMiddlePoint; + TopoDS_Iterator anIt( aProf ); for ( ; anIt.More(); anIt.Next()) { const TopoDS_Edge& anEdge = TopoDS::Edge( anIt.Value() ); diff --git a/src/HYDROGUI/HYDROGUI_ChannelDlg.cxx b/src/HYDROGUI/HYDROGUI_ChannelDlg.cxx index cf106701..59741704 100644 --- a/src/HYDROGUI/HYDROGUI_ChannelDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_ChannelDlg.cxx @@ -82,7 +82,7 @@ HYDROGUI_ChannelDlg::HYDROGUI_ChannelDlg( HYDROGUI_Module* theModule, const QStr myProfileLabel = new QLabel( tr( "CHANNEL_PROFILE" ), aParamGroup); myProfileModeButton = new QRadioButton( tr( "VIA_PROFILE" ), myObjectNameGroup ); - QRadioButton* ProfileModeButton2 = new QRadioButton( tr( "PREDEF" ), myObjectNameGroup ); + myProfileModeButton2 = new QRadioButton( tr( "PREDEF" ), myObjectNameGroup ); QGridLayout* aParamsLayout = new QGridLayout( aParamGroup ); aParamsLayout->setMargin( 5 ); @@ -91,7 +91,7 @@ HYDROGUI_ChannelDlg::HYDROGUI_ChannelDlg( HYDROGUI_Module* theModule, const QStr aParamsLayout->addWidget( myGuideLines, 0, 1 ); aParamsLayout->addWidget( myProfileModeButton, 1, 0 ); - aParamsLayout->addWidget( ProfileModeButton2, 1, 1 ); + aParamsLayout->addWidget( myProfileModeButton2, 1, 1 ); aParamsLayout->addWidget( myProfileLabel, 2, 0 ); aParamsLayout->addWidget( myProfiles, 2, 1 ); @@ -256,6 +256,12 @@ bool HYDROGUI_ChannelDlg::getProfileMode() return myProfileModeButton->isChecked(); } +void HYDROGUI_ChannelDlg::setProfileMode(bool mode) +{ + myProfileModeButton->setChecked(mode); + myProfileModeButton2->setChecked(!mode); +} + double HYDROGUI_ChannelDlg::getEquiDistance() const { return myEquiDistance->value(); diff --git a/src/HYDROGUI/HYDROGUI_ChannelDlg.h b/src/HYDROGUI/HYDROGUI_ChannelDlg.h index 5af01f6a..59742717 100644 --- a/src/HYDROGUI/HYDROGUI_ChannelDlg.h +++ b/src/HYDROGUI/HYDROGUI_ChannelDlg.h @@ -58,6 +58,8 @@ public: void setInvertDirection( bool isChecked ); bool getProfileMode(); + void setProfileMode(bool); + double getLCValue() const; void setLCValue( double ); @@ -96,6 +98,8 @@ protected: QtxDoubleSpinBox* myCoteZVal; QRadioButton* myProfileModeButton; + QRadioButton* myProfileModeButton2; + }; #endif diff --git a/src/HYDROGUI/HYDROGUI_ChannelOp.cxx b/src/HYDROGUI/HYDROGUI_ChannelOp.cxx index 2a1ede23..60059a2b 100644 --- a/src/HYDROGUI/HYDROGUI_ChannelOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ChannelOp.cxx @@ -68,6 +68,8 @@ void HYDROGUI_ChannelOp::startOperation() myEditedObject.Nullify(); QString aSelectedGuideLine, aSelectedProfile; + bool profile_mode = true; + QString anObjectName = HYDROGUI_Tool::GenerateObjectName( module(), tr( "DEFAULT_CHANNEL_NAME" ) ); if ( myIsEdit ) @@ -86,6 +88,8 @@ void HYDROGUI_ChannelOp::startOperation() Handle(HYDROData_Profile) aRefProfile = myEditedObject->GetProfile(); if ( !aRefProfile.IsNull() ) aSelectedProfile = aRefProfile->GetName(); + + profile_mode = myEditedObject->GetProfileMode(); } } @@ -120,7 +124,15 @@ void HYDROGUI_ChannelOp::startOperation() aPanel->setProfileName( aSelectedProfile ); if( !myEditedObject.IsNull() ) + { aPanel->setEquiDistance( myEditedObject->GetEquiDistance() ); + if (!profile_mode) //predef + { + aPanel->setLCValue( myEditedObject->GetLCValue() ); + aPanel->setCoteZValue( myEditedObject->GetCoteZValue() ); + aPanel->setDeltaZValue( myEditedObject->GetDeltaZValue() ); + } + } else aPanel->setEquiDistance( 1.0 ); @@ -137,6 +149,7 @@ void HYDROGUI_ChannelOp::startOperation() aPanel->setInvertDirection( false ); aPanel->blockSignals( false ); + aPanel->setProfileMode(profile_mode); onCreatePreview(); }