X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROGUI%2FHYDROGUI_ChannelOp.cxx;h=8c3e73e469f05fa438f03d039ef3e31990548a51;hb=9d74e559cfe55dea14f7bfdb6957c61829e98cf3;hp=71714929ed70681d4b79fb3ad459d350272b4e1b;hpb=4d6a148db0bc353370c3635c1fae774e89bdcd19;p=modules%2Fhydro.git diff --git a/src/HYDROGUI/HYDROGUI_ChannelOp.cxx b/src/HYDROGUI/HYDROGUI_ChannelOp.cxx index 71714929..8c3e73e4 100644 --- a/src/HYDROGUI/HYDROGUI_ChannelOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ChannelOp.cxx @@ -24,6 +24,7 @@ #include "HYDROGUI_Module.h" #include "HYDROGUI_Shape.h" #include "HYDROGUI_Tool.h" +#include "HYDROGUI_Tool2.h" #include "HYDROGUI_UpdateFlags.h" #include @@ -62,15 +63,17 @@ void HYDROGUI_ChannelOp::startOperation() aPanel->reset(); - myEditedObject.Nullify(); + if ( isApplyAndClose() ) + myEditedObject.Nullify(); QString aSelectedGuideLine, aSelectedProfile; QString anObjectName = HYDROGUI_Tool::GenerateObjectName( module(), tr( "DEFAULT_CHANNEL_NAME" ) ); if ( myIsEdit ) { - myEditedObject = - Handle(HYDROData_Channel)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) ); + if ( isApplyAndClose() ) + myEditedObject = + Handle(HYDROData_Channel)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) ); if ( !myEditedObject.IsNull() ) { anObjectName = myEditedObject->GetName(); @@ -115,6 +118,11 @@ void HYDROGUI_ChannelOp::startOperation() aPanel->setGuideLineName( aSelectedGuideLine ); aPanel->setProfileName( aSelectedProfile ); + if( !myEditedObject.IsNull() ) + aPanel->setEquiDistance( myEditedObject->GetEquiDistance() ); + else + aPanel->setEquiDistance( 1.0 ); + aPanel->blockSignals( false ); onCreatePreview(); @@ -173,29 +181,44 @@ bool HYDROGUI_ChannelOp::processApply( int& theUpdateFlags, if ( !myIsEdit ) { - myEditedObject->SetFillingColor( getDefaultFillingColor() ); - myEditedObject->SetBorderColor( getDefaultBorderColor() ); + myEditedObject->SetFillingColor( myEditedObject->DefaultFillingColor() ); + myEditedObject->SetBorderColor( myEditedObject->DefaultBorderColor() ); } QString aGuideLineName = aPanel->getGuideLineName(); QString aProfileName = aPanel->getProfileName(); - if ( aGuideLineName.isEmpty() || aProfileName.isEmpty() ) + /*if ( aGuideLineName.isEmpty() || aProfileName.isEmpty() ) { myEditedObject->RemoveGuideLine(); myEditedObject->RemoveProfile(); } - else + else*/ { Handle(HYDROData_Polyline3D) aGuideLine = Handle(HYDROData_Polyline3D)::DownCast( HYDROGUI_Tool::FindObjectByName( module(), aGuideLineName, KIND_POLYLINE ) ); + if ( aGuideLine.IsNull() ) + { + theErrorMsg = tr( "GUIDE_LINE_IS_NOT_SELECTED" ); + return false; + } + + myEditedObject->RemoveGuideLine(); myEditedObject->SetGuideLine( aGuideLine ); 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->SetEquiDistance( aPanel->getEquiDistance() ); } - if ( myEditedObject->IsMustBeUpdated() ) + if ( myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_2d ) ) myEditedObject->Update(); erasePreview(); @@ -219,16 +242,6 @@ Handle(HYDROData_Channel) HYDROGUI_ChannelOp::createNewObject() const return Handle(HYDROData_Channel)::DownCast( doc()->CreateObject( KIND_CHANNEL ) ); } -QColor HYDROGUI_ChannelOp::getDefaultFillingColor() const -{ - return HYDROData_Channel::DefaultFillingColor(); -} - -QColor HYDROGUI_ChannelOp::getDefaultBorderColor() const -{ - return HYDROData_Channel::DefaultBorderColor(); -} - void HYDROGUI_ChannelOp::onCreatePreview() { HYDROGUI_ChannelDlg* aPanel = ::qobject_cast( inputPanel() ); @@ -261,8 +274,8 @@ void HYDROGUI_ChannelOp::onCreatePreview() { myPreviewPrs = new HYDROGUI_Shape( aCtx, NULL, getPreviewZLayer() ); - QColor aFillingColor = getDefaultFillingColor(); - QColor aBorderColor = getDefaultBorderColor(); + QColor aFillingColor = Qt::blue; + QColor aBorderColor = Qt::transparent; if ( !myEditedObject.IsNull() ) { aFillingColor = myEditedObject->GetFillingColor(); @@ -285,7 +298,7 @@ void HYDROGUI_ChannelOp::onCreatePreview() HYDROGUI_Tool::FindObjectByName( module(), aProfileName, KIND_PROFILE ) ); HYDROData_Channel::PrsDefinition aPrsDef; - if ( !HYDROData_Channel::CreatePresentations( aGuideLine, aProfile, aPrsDef ) ) + if ( !HYDROData_Channel::CreatePresentations( aGuideLine, aProfile, aPrsDef, aPanel->getEquiDistance() ) ) { erasePreview(); return;