IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Profile, HYDROData_Object)
HYDROData_Profile::HYDROData_Profile()
-: HYDROData_Object()
+: HYDROData_Object( Geom_3d )
{
}
TopoDS_Shape HYDROData_Profile::GetShape3D() const
{
- TopoDS_Shape aShape = getShape3D();
+ TopoDS_Shape aShape = HYDROData_Object::GetShape3D();
if( aShape.IsNull() )
aShape = CreateProfileWire( true );
return aShape;
{
HYDROData_Object::Update();
- TopoDS_Shape aShape = CreateProfileWire( false );
+ TopoDS_Shape aShape = CreateProfileWire( true );
SetShape3D( aShape );
}
-QColor HYDROData_Profile::DefaultFillingColor()
+QColor HYDROData_Profile::DefaultFillingColor() const
{
return QColor( Qt::transparent );
}
-QColor HYDROData_Profile::DefaultBorderColor()
+QColor HYDROData_Profile::DefaultBorderColor() const
{
return QColor( Qt::black );
}
-QColor HYDROData_Profile::getDefaultFillingColor() const
-{
- return DefaultFillingColor();
-}
-
-QColor HYDROData_Profile::getDefaultBorderColor() const
-{
- return DefaultBorderColor();
-}
-
bool HYDROData_Profile::IsValid() const
{
gp_XY aFirstPoint, aLastPoint;
anArray->SetValue( 0, aLPoint.X() );
anArray->SetValue( 1, aLPoint.Y() );
- SetToUpdate( true );
+ Changed( Geom_3d );
}
bool HYDROData_Profile::GetLeftPoint( gp_XY& thePoint, bool IsConvertToGlobal,
thePoint = GetParametricPoints().First();
- thePoint.SetX( 0 );
+ //thePoint.SetX( 0 );
thePoint.SetY( 0 ); //default left point of not-georeferenced profile
TDF_Label aLabel = myLab.FindChild( DataTag_FirstPoint, false );
if ( aLabel.IsNull() )
anArray->SetValue( 0, aLPoint.X() );
anArray->SetValue( 1, aLPoint.Y() );
- SetToUpdate( true );
+ Changed( Geom_3d );
}
bool HYDROData_Profile::GetRightPoint( gp_XY& thePoint, bool IsConvertToGlobal,
return false;
thePoint = GetParametricPoints().Last();
+ thePoint.SetY( 0 );
TDF_Label aLabel = myLab.FindChild( DataTag_LastPoint, false );
if ( aLabel.IsNull() )
if ( !aLastLabel.IsNull() )
aLastLabel.ForgetAllAttributes();
- SetToUpdate( true );
+ Changed( Geom_3d );
}
Handle(HYDROData_ProfileUZ) HYDROData_Profile::GetProfileUZ( const bool theIsCreate ) const
if ( !aProfileUZ.IsNull() )
{
aProfileUZ->RemoveSections();
- SetToUpdate( true );
+ Changed( Geom_3d );
}
}
aProfileUZ->AddPoint( 0, aPoint );
}
- SetToUpdate( true );
+ Changed( Geom_3d );
}
HYDROData_ProfileUZ::PointsList HYDROData_Profile::GetParametricPoints() const
const HYDROData_ProfileUZ::Point& aFirstParPoint = aParametricPoints.First();
const HYDROData_ProfileUZ::Point& aLastParPoint = aParametricPoints.Last();
- double aGeoDistance = gp_Pnt2d( aFirstPoint ).Distance( aLastPoint );
- double aParCommonDist = gp_Pnt2d( aFirstParPoint.X(), 0 ).Distance( gp_Pnt2d( aLastParPoint.X(), 0 ) );
+ double aFullLength = aLastPoint.X() - aFirstPoint.X();
+ double aParFullLength = aLastParPoint.X() - aFirstParPoint.X();
// Add first point as is
aResPoints.Append( ProfilePoint( aFirstPoint.X(), aFirstPoint.Y(), aFirstParPoint.Y() ) );
{
const HYDROData_ProfileUZ::Point& aParPoint = aParametricPoints.Value( i );
- double aParPointDist = gp_Pnt2d( aFirstParPoint.X(), 0 ).Distance( gp_Pnt2d( aParPoint.X(), 0 ) );
-
- double aParLen = ( aParPointDist / aParCommonDist ) * aGeoDistance;
-
- double aRatio = aParLen / ( aGeoDistance - aParLen );
+ double aParPointDist = aParPoint.X() - aFirstParPoint.X();
+ double aRatio = aParPointDist / aParFullLength;
- double aParX = ( aFirstPoint.X() + aRatio * aLastPoint.X() ) / ( 1 + aRatio );
- double aParY = ( aFirstPoint.Y() + aRatio * aLastPoint.Y() ) / ( 1 + aRatio );
+ double aParX = aFirstPoint.X() * (1-aRatio) + aLastPoint.X() * aRatio;
+ double aParY = aFirstPoint.Y() * (1-aRatio) + aLastPoint.Y() * aRatio;
ProfilePoint aCompPoint( aParX, aParY, aParPoint.Y() );
aResPoints.Append( aCompPoint );
aProfile->SetFilePath( theFileName );
- aProfile->SetBorderColor( HYDROData_Profile::DefaultBorderColor() );
+ aProfile->SetBorderColor( aProfile->DefaultBorderColor() );
}
return aCreatedProfiles.Length();
return aBottom;
}
- HYDROData_Profile::ProfilePoint HYDROData_Profile::GetMiddlePoint() const
+ HYDROData_Profile::ProfilePoint HYDROData_Profile::GetMiddlePoint( bool CanUseDefault ) const
{
ProfilePoint aMiddlePoint;
gp_XY aLeftPnt, aRightPnt;
- if ( GetLeftPoint( aLeftPnt, false ) && GetRightPoint( aRightPnt, false ) ) {
+ if ( GetLeftPoint( aLeftPnt, true, CanUseDefault ) && GetRightPoint( aRightPnt, true, CanUseDefault ) ) {
gp_XYZ aPnt1( aLeftPnt.X(), aLeftPnt.Y(), 0. );
gp_XYZ aPnt2( aRightPnt.X(), aRightPnt.Y(), 0. );
gp_Pnt aMiddlePoint2d( 0.5 * ( aPnt1 + aPnt2 ) );