// Set the object name
myEditedObject->SetName( anObjectName );
+ if ( !myIsEdit )
+ {
+ myEditedObject->SetFillingColor( HYDROData_Stream::DefaultFillingColor() );
+ myEditedObject->SetBorderColor( HYDROData_Stream::DefaultBorderColor() );
+ }
+
// Erase preview
erasePreview();
QStringList anInvalidProfiles, anExistingProfiles, aHasNoIntersectionProfiles;
HYDROData_SequenceOfObjects aVerifiedProfiles;
- HYDROData_SequenceOfObjects aSelectedProfiles = HYDROGUI_Tool::GetSelectedObjects( module() );
- gp_Ax2 aX2(gp::XOY());
- gp_Ax3 aX3(aX2);
- gp_Pln aPln(aX3);
- BRepBuilderAPI_MakeFace aMkr(aPln);
- if(!aMkr.IsDone()) return;
- const TopoDS_Face& aPlane = TopoDS::Face(aMkr.Shape());
+ 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 =
}
// 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" );
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 )
Handle(HYDROData_PolylineXY) anAxis = Handle(HYDROData_PolylineXY)::DownCast(
HYDROGUI_Tool::FindObjectByName( module(), theNewAxis, KIND_POLYLINEXY ) );
+ // Prepare data for intersection check
+ TopoDS_Face aPlane;
+ if ( anAxis.IsNull() || !myEditedObject->BuildFace(anAxis, aPlane) ) {
+ // 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();
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();
+ }
}
}