return QColor( Qt::transparent );
}
+bool HYDROData_Stream::IsValidAsAxis( const Handle(HYDROData_PolylineXY)& theHydAxis )
+{
+ if ( theHydAxis.IsNull() )
+ return false;
+
+ TopoDS_Shape aHydraulicShape = theHydAxis->GetShape();
+ if ( aHydraulicShape.IsNull() ||
+ aHydraulicShape.ShapeType() != TopAbs_WIRE ||
+ BRep_Tool::IsClosed( aHydraulicShape ) )
+ return false; // The polyline must be a single not closed wire
+
+ return true;
+}
+
QColor HYDROData_Stream::getDefaultFillingColor() const
{
return DefaultFillingColor();
bool HYDROData_Stream::SetHydraulicAxis( const Handle(HYDROData_PolylineXY)& theAxis )
{
- Handle(HYDROData_PolylineXY) aPrevAxis = GetHydraulicAxis();
-
- if ( theAxis.IsNull() )
- {
- RemoveHydraulicAxis();
- return !aPrevAxis.IsNull();
- }
-
- if ( IsEqual( aPrevAxis, theAxis ) )
+ if ( !IsValidAsAxis( theAxis ) )
return false;
- TopoDS_Wire aHydraulicWire = TopoDS::Wire( theAxis->GetShape() );
- if ( aHydraulicWire.IsNull() )
- return false; // The polyline must be a single wire
+ Handle(HYDROData_PolylineXY) aPrevAxis = GetHydraulicAxis();
+ if ( IsEqual( aPrevAxis, theAxis ) )
+ return true;
SetReferenceObject( theAxis, DataTag_HydraulicAxis );
const TopoDS_Face& thePlane,
Standard_Real& outPar)
{
- if ( theProfile.IsNull() || theHydAxis.IsNull() )
+ if ( theProfile.IsNull() || !IsValidAsAxis( theHydAxis ) )
return false;
TopoDS_Wire aHydraulicWire = TopoDS::Wire( theHydAxis->GetShape() ); //guide line
InsertReferenceObject( theProfile, DataTag_Profile, theBeforeIndex );
}
-bool HYDROData_Stream::BuildFace( const Handle(HYDROData_PolylineXY)& theHydAxis, TopoDS_Face& thePlane) const
+bool HYDROData_Stream::BuildFace( const Handle(HYDROData_PolylineXY)& theHydAxis,
+ TopoDS_Face& thePlane ) const
{
- if ( theHydAxis.IsNull() ) return false;
+ if ( !IsValidAsAxis( theHydAxis ) )
+ return false;
+
TopoDS_Wire aHydraulicWire = TopoDS::Wire( theHydAxis->GetShape() );
- if(aHydraulicWire.IsNull()) return false;
+
gp_Ax2 aX2(gp::XOY());
gp_Ax3 aX3(aX2);
gp_Pln aPln(aX3);
// Prepare data for intersection check
TopoDS_Face aPlane;
- if ( anAxis.IsNull() || !myEditedObject->BuildFace(anAxis, 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