X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROGUI%2FHYDROGUI_StreamOp.cxx;h=bd7085f4efd7aa086b947998ae6fbd69c69bdfdb;hb=a1431f03eac1d1aed4203d0568d987c41ce939b3;hp=a800239dbec50f754fffc06e6e6aed8661766eed;hpb=fafee81650721287cc577a7f26c2e6e640f58a89;p=modules%2Fhydro.git diff --git a/src/HYDROGUI/HYDROGUI_StreamOp.cxx b/src/HYDROGUI/HYDROGUI_StreamOp.cxx index a800239d..bd7085f4 100755 --- a/src/HYDROGUI/HYDROGUI_StreamOp.cxx +++ b/src/HYDROGUI/HYDROGUI_StreamOp.cxx @@ -42,7 +42,16 @@ #include #include #include - +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include HYDROGUI_StreamOp::HYDROGUI_StreamOp( HYDROGUI_Module* theModule, bool theIsEdit ) : HYDROGUI_Operation( theModule ), myIsEdit( theIsEdit ), @@ -139,7 +148,7 @@ bool HYDROGUI_StreamOp::processApply( int& theUpdateFlags, } // Check that there are no other objects with the same name in the document - if( !myIsEdit || ( !myEditedObject.IsNull() && myEditedObject->GetName() != anObjectName ) ) + if( myEditedObject->GetName() != anObjectName ) { Handle(HYDROData_Entity) anObject = HYDROGUI_Tool::FindObjectByName( module(), anObjectName ); if( !anObject.IsNull() ) { @@ -165,6 +174,12 @@ bool HYDROGUI_StreamOp::processApply( int& theUpdateFlags, // Set the object name myEditedObject->SetName( anObjectName ); + if ( !myIsEdit ) + { + myEditedObject->SetFillingColor( HYDROData_Stream::DefaultFillingColor() ); + myEditedObject->SetBorderColor( HYDROData_Stream::DefaultBorderColor() ); + } + // Erase preview erasePreview(); @@ -173,8 +188,10 @@ bool HYDROGUI_StreamOp::processApply( int& theUpdateFlags, module()->setObjectVisible( HYDROGUI_Tool::GetActiveOCCViewId( module() ), myEditedObject, true ); } + module()->setIsToUpdate( myEditedObject ); + // Set update flags - theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced; + theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer; return true; } @@ -236,7 +253,14 @@ void HYDROGUI_StreamOp::onAddProfiles() QStringList anInvalidProfiles, anExistingProfiles, aHasNoIntersectionProfiles; HYDROData_SequenceOfObjects aVerifiedProfiles; - HYDROData_SequenceOfObjects aSelectedProfiles = HYDROGUI_Tool::GetSelectedObjects( module() ); + HYDROData_SequenceOfObjects aSelectedProfiles = HYDROGUI_Tool::GetSelectedObjects( module() ); + Handle(HYDROData_PolylineXY) aHydAxis = myEditedObject->GetHydraulicAxis(); + if ( aHydAxis.IsNull() ) + return; + TopoDS_Face aPlane; + if(!myEditedObject->BuildFace(aHydAxis, aPlane)) + return; + Standard_Real aPar(.0); for( int i = 1, n = aSelectedProfiles.Length(); i <= n; i++ ) { Handle(HYDROData_Profile) aProfile = Handle(HYDROData_Profile)::DownCast( aSelectedProfiles.Value( i ) ); @@ -248,7 +272,7 @@ void HYDROGUI_StreamOp::onAddProfiles() anInvalidProfiles << aProfileName; } else if ( aCurrentProfiles.contains( aProfileName ) ) { // check whether the profile is already added anExistingProfiles << aProfileName; - } else if ( !myEditedObject->HasIntersection( aProfile ) ) { // check whether the profile has intersection + } else if ( !myEditedObject->HasIntersection( aProfile, aPlane, aPar ) ) { // check whether the profile has intersection aHasNoIntersectionProfiles << aProfileName; } else { aVerifiedProfiles.Append( aProfile ); @@ -257,7 +281,8 @@ void HYDROGUI_StreamOp::onAddProfiles() } // Show message box with the ignored profiles - if ( aVerifiedProfiles.Length() < aSelectedProfiles.Length() ) { + if ( !anInvalidProfiles.isEmpty() || !anExistingProfiles.isEmpty() || + !aHasNoIntersectionProfiles.isEmpty() ) { QString aMessage = tr( "IGNORED_PROFILES" ); if ( !anInvalidProfiles.isEmpty() ) { aMessage.append( "\n\n" ); @@ -296,19 +321,39 @@ void HYDROGUI_StreamOp::onRemoveProfiles( const QStringList& theProfilesToRemove return; } + bool isRemoved = false; + + // Take the Object Browser selection into account + HYDROData_SequenceOfObjects aSelectedObjects = HYDROGUI_Tool::GetSelectedObjects( module() ); + for( int i = 1, n = aSelectedObjects.Length(); i <= n; i++ ) { + Handle(HYDROData_Profile) aProfile = + Handle(HYDROData_Profile)::DownCast( aSelectedObjects.Value( i ) ); + if ( !aProfile.IsNull() && !theProfilesToRemove.contains(aProfile->GetName()) ) { + if ( myEditedObject->RemoveProfile( aProfile ) ) { + isRemoved = true; + } + } + } + // Remove profiles foreach( const QString& aProfileName, theProfilesToRemove ) { Handle(HYDROData_Profile) aProfile = Handle(HYDROData_Profile)::DownCast( HYDROGUI_Tool::FindObjectByName( module(), aProfileName, KIND_PROFILE ) ); - myEditedObject->RemoveProfile( aProfile ); + if ( myEditedObject->RemoveProfile( aProfile ) ) { + isRemoved = true; + } } - myEditedObject->Update(); - // Update the panel - updatePanelData(); + if ( isRemoved ) { + // Update the edited stream object + myEditedObject->Update(); - // Update preview - createPreview(); + // Update the panel + updatePanelData(); + + // Update preview + createPreview(); + } } void HYDROGUI_StreamOp::onAxisChanged( const QString& theNewAxis ) @@ -321,6 +366,19 @@ void HYDROGUI_StreamOp::onAxisChanged( const QString& theNewAxis ) Handle(HYDROData_PolylineXY) anAxis = Handle(HYDROData_PolylineXY)::DownCast( HYDROGUI_Tool::FindObjectByName( module(), theNewAxis, KIND_POLYLINEXY ) ); + // Prepare data for intersection check + TopoDS_Face aPlane; + if ( !myEditedObject->BuildFace(anAxis, aPlane) ) { + SUIT_MessageBox::critical( module()->getApp()->desktop(), + tr( "BAD_SELECTED_POLYLINE_TLT" ), + tr( "BAD_SELECTED_POLYLINE_MSG" ).arg( theNewAxis ) ); + // To restore the old axis + updatePanelData(); + return; + } + + Standard_Real aPar(.0); + // Get list of profiles which do not intersect the axis QStringList aHasNoIntersectionProfiles; HYDROData_SequenceOfObjects aCurrentProfiles = myEditedObject->GetProfiles(); @@ -328,7 +386,9 @@ void HYDROGUI_StreamOp::onAxisChanged( const QString& theNewAxis ) Handle(HYDROData_Profile) aProfile = Handle(HYDROData_Profile)::DownCast( aCurrentProfiles.Value( anIndex ) ); if ( !aProfile.IsNull() ) { - // TODO check intersection + if ( !HYDROData_Stream::HasIntersection( anAxis, aProfile, aPlane, aPar ) ) { + aHasNoIntersectionProfiles << aProfile->GetName(); + } } }