// Get/create the edited object
if( myIsEdit ) {
myEditedObject = Handle(HYDROData_Stream)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) );
+ if ( !myEditedObject.IsNull() && myEditedObject->IsMustBeUpdated() ) {
+ myEditedObject->Update();
+ }
} else {
myEditedObject = Handle(HYDROData_Stream)::DownCast( doc()->CreateObject( KIND_STREAM ) );
}
// Set the object name
myEditedObject->SetName( anObjectName );
+ if ( !myIsEdit )
+ {
+ myEditedObject->SetFillingColor( HYDROData_Stream::DefaultFillingColor() );
+ myEditedObject->SetBorderColor( HYDROData_Stream::DefaultBorderColor() );
+ }
+
// Erase preview
erasePreview();
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;
}
}
if ( myPreviewPrs ) {
- myPreviewPrs->update();
+ myPreviewPrs->update( true, true );
}
}
Handle(HYDROData_Profile)::DownCast( aVerifiedProfiles.Value( i ) );
myEditedObject->AddProfile( aProfile );
}
- myEditedObject->Update();
+ myEditedObject->UpdatePrs();
// Update the panel
updatePanelData();
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->UpdatePrs();
- // 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 ( !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();
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();
+ }
}
}
} else {
// Set axis
myEditedObject->SetHydraulicAxis( anAxis );
- myEditedObject->Update();
+ myEditedObject->UpdatePrs();
// Update the panel
updatePanelData();
void HYDROGUI_StreamOp::updatePanelData()
{
HYDROGUI_StreamDlg* aPanel = ::qobject_cast<HYDROGUI_StreamDlg*>( inputPanel() );
- if ( !aPanel ) {
+ if ( !aPanel || myEditedObject.IsNull() ) {
return;
}