removeShape3D();
}
-void HYDROData_Object::SetBathymetry( const Handle(HYDROData_Bathymetry)& theBathymetry )
+bool HYDROData_Object::SetBathymetry( const Handle(HYDROData_Bathymetry)& theBathymetry )
{
+ if ( theBathymetry.IsNull() )
+ return false;
+
+ Handle(HYDROData_Bathymetry) aPrevBathymetry = GetBathymetry();
+ if ( IsEqual( aPrevBathymetry, theBathymetry ) )
+ return true;
+
SetReferenceObject( theBathymetry, DataTag_Bathymetry );
+
+ // Indicate model of the need to update object
SetToUpdate( true );
+
+ return true;
}
+
Handle(HYDROData_Bathymetry) HYDROData_Object::GetBathymetry() const
{
return Handle(HYDROData_Bathymetry)::DownCast(
void HYDROData_Object::RemoveBathymetry()
{
+ Handle(HYDROData_Bathymetry) aPrevBathymetry = GetBathymetry();
+ if ( aPrevBathymetry.IsNull() )
+ return;
+
ClearReferenceObjects( DataTag_Bathymetry );
+
+ // Indicate model of the need to update object
SetToUpdate( true );
}
/**
* Set reference bathymetry object for geometry object.
*/
- HYDRODATA_EXPORT virtual void SetBathymetry( const Handle(HYDROData_Bathymetry)& theBathymetry );
+ HYDRODATA_EXPORT virtual bool SetBathymetry( const Handle(HYDROData_Bathymetry)& theBathymetry );
/**
* Returns reference bathymetry object of geometry object.
#include "HYDROData_Polyline3D.h"
+#include "HYDROData_Bathymetry.h"
#include "HYDROData_Document.h"
#include "HYDROData_PolylineXY.h"
#include "HYDROData_ProfileUZ.h"
return getShape3D();
}
+HYDROData_IPolyline::PointsList generateProfileUZPoints(
+ const Handle(HYDROData_PolylineXY)& thePolyline,
+ const Handle(HYDROData_Bathymetry)& theBathymetry )
+{
+ HYDROData_IPolyline::PointsList aPointsList;
+ if ( thePolyline.IsNull() || theBathymetry.IsNull() )
+ return aPointsList;
+
+ bool anIsSectionClosed = thePolyline->IsClosedSection( 0 );
+ HYDROData_IPolyline::SectionType aSectionType = thePolyline->GetSectionType( 0 );
+ HYDROData_IPolyline::PointsList aPolylinePoints = thePolyline->GetPoints( 0 );
+ if ( aPolylinePoints.IsEmpty() )
+ return aPointsList;
+
+ for ( int i = 1, aNbPoints = aPolylinePoints.Size(); i <= aNbPoints; ++i )
+ {
+ const HYDROData_PolylineXY::Point& aSectPoint = aPolylinePoints.Value( i );
+
+ double aPointDistance = thePolyline->GetDistance( 0, i - 1 );
+ double aPointDepth = theBathymetry->GetAltitudeForPoint( aSectPoint );
+
+ HYDROData_IPolyline::Point anAltitudePoint( aPointDistance, aPointDepth );
+ aPointsList.Append( anAltitudePoint );
+ }
+
+ return aPointsList;
+}
+
void HYDROData_Polyline3D::Update()
{
HYDROData_Object::Update();
Handle(HYDROData_PolylineXY) aPolylineXY = GetPolylineXY();
- Handle(HYDROData_ProfileUZ) aProfileUZ = GetProfileUZ();
- if ( aPolylineXY.IsNull() || aProfileUZ.IsNull() )
+ if ( aPolylineXY.IsNull() )
return;
bool anIsSectionClosed = aPolylineXY->IsClosedSection( 0 );
HYDROData_IPolyline::SectionType aSectionType = aPolylineXY->GetSectionType( 0 );
HYDROData_IPolyline::PointsList aPolylinePoints = aPolylineXY->GetPoints( 0 );
- HYDROData_IPolyline::PointsList aProfilePoints = aProfileUZ->GetPoints();
- if ( aPolylinePoints.IsEmpty() || aProfilePoints.IsEmpty() )
+ if ( aPolylinePoints.IsEmpty() )
+ return;
+
+ HYDROData_IPolyline::PointsList aProfilePoints;
+
+ Handle(HYDROData_ProfileUZ) aProfileUZ = GetProfileUZ();
+ Handle(HYDROData_Bathymetry) aBathymetry = GetBathymetry();
+
+ if ( !aProfileUZ.IsNull() )
+ {
+ aProfilePoints = aProfileUZ->GetPoints();
+ }
+ else if ( !aBathymetry.IsNull() )
+ {
+ aProfilePoints = generateProfileUZPoints( aPolylineXY, aBathymetry );
+ }
+
+ if ( aProfilePoints.IsEmpty() )
return;
const HYDROData_IPolyline::Point& aFirstPoint = aPolylinePoints.First();
double aDistance = aPolylineXY->GetDistance( 0, i - 1 );
double aParLen = ( aDistance / aPolylineCommonDist ) * aParCommonDist;
- double aDepth = aProfileUZ->GetDepthFromDistance( aParLen );
+ double aDepth = HYDROData_ProfileUZ::GetDepthFromDistance( aProfilePoints, aParLen );
Polyline3DPoint aCompPoint( aPolylinePoint.X(), aPolylinePoint.Y(), aDepth );
aResPoints.Append( aCompPoint );
SetReferenceObject( theProfile, DataTag_ProfileUZ );
+ // Remove the bathymetry, because one altitude object can be presented at time
+ RemoveBathymetry();
+
// Indicate model of the need to update the polyline presentation
SetToUpdate( true );
SetToUpdate( true );
}
+
+bool HYDROData_Polyline3D::SetBathymetry( const Handle(HYDROData_Bathymetry)& theBathymetry )
+{
+ if ( !HYDROData_Object::SetBathymetry( theBathymetry ) )
+ return false;
+
+ // Remove the u,z profile, because one altitude object can be presented at time
+ RemoveProfileUZ();
+
+ return true;
+}
+
enum DataTag
{
DataTag_First = HYDROData_Object::DataTag_First + 100, ///< first tag, to reserve
- DataTag_PolylineXY, ///< reference hydraulic axis
- DataTag_ProfileUZ, ///< reference profiles
+ DataTag_PolylineXY, ///< reference hydraulic axis
+ DataTag_ProfileUZ, ///< reference profile
};
public:
HYDRODATA_EXPORT virtual void RemoveProfileUZ();
+ /**
+ * Set reference bathymetry object for geometry object.
+ * Reimplemented to remove reference u,z profile.
+ */
+ HYDRODATA_EXPORT virtual bool SetBathymetry( const Handle(HYDROData_Bathymetry)& theBathymetry );
+
+
protected:
/**
return TopoDS_Shape();
}
-double HYDROData_ProfileUZ::GetDepthFromDistance( const double& theDistance ) const
+double HYDROData_ProfileUZ::GetDepthFromDistance( const PointsList& thePoints,
+ const double& theDistance )
{
double aResDepth = 0.0;
- HYDROData_IPolyline::PointsList aPoints = GetPoints();
- int aNbPoints = aPoints.Size();
+ int aNbPoints = thePoints.Size();
if ( aNbPoints < 2 )
return aResDepth;
double aCompDist = 0.0;
- HYDROData_IPolyline::Point aPrevPoint = aPoints.First();
+ HYDROData_IPolyline::Point aPrevPoint = thePoints.First();
for ( int i = 2; i <= aNbPoints; ++i )
{
- const Point& aCurPoint = aPoints.Value( i );
+ const Point& aCurPoint = thePoints.Value( i );
double aPntDist = gp_Pnt2d( aPrevPoint.X(), 0 ).Distance( gp_Pnt2d( aCurPoint.X(), 0 ) );
if ( theDistance < aCompDist )
{
- double aComPntDist = gp_Pnt2d( aPoints.First().X(), 0 ).Distance( gp_Pnt2d( aPrevPoint.X(), 0 ) );
+ double aComPntDist = gp_Pnt2d( thePoints.First().X(), 0 ).Distance( gp_Pnt2d( aPrevPoint.X(), 0 ) );
double aFindDist = theDistance - aComPntDist;
double aRatio = aFindDist / ( aPntDist - aFindDist );
HYDRODATA_EXPORT virtual TopoDS_Shape GetShape();
/**
- * Returns the 3D presentation of all points.
+ * Returns the depth for given distance.
*/
- HYDRODATA_EXPORT virtual double GetDepthFromDistance( const double& theDistance ) const;
+ HYDRODATA_EXPORT static double GetDepthFromDistance( const PointsList& thePoints,
+ const double& theDistance );
/**
QString aPolyName, aProfileName, aBathName;
if( myIsEdit && !myEditedObject.IsNull() )
{
- Handle(HYDROData_Entity) aProfile = myEditedObject->GetProfileUZ()->GetFatherObject();
- if( !aProfile.IsNull() )
- aProfileName = aProfile->GetName();
+ Handle(HYDROData_ProfileUZ) aProfileUZ = myEditedObject->GetProfileUZ();
+ if( !aProfileUZ.IsNull() )
+ {
+ Handle(HYDROData_Entity) aProfile = aProfileUZ->GetFatherObject();
+ if ( !aProfile.IsNull() )
+ aProfileName = aProfile->GetName();
+ }
Handle(HYDROData_Entity) aPoly = myEditedObject->GetPolylineXY();
if( !aPoly.IsNull() )
aPolyName = aPoly->GetName();
- //TODO: use bathymetry from data model
+ Handle(HYDROData_Bathymetry) aBathymetry = myEditedObject->GetBathymetry();
+ if( !aBathymetry.IsNull() )
+ aBathName = aBathymetry->GetName();
aPanel->setSelectedObjects( aPolyName, aProfileName, aBathName );
}
}
}
- Handle(HYDROData_Entity) aProfileEnt =
- HYDROGUI_Tool::FindObjectByName( module(), aProfileName, KIND_PROFILE ) ;
- Handle(HYDROData_Entity) aPolyEnt =
- HYDROGUI_Tool::FindObjectByName( module(), aPolyName, KIND_POLYLINEXY );
- Handle(HYDROData_Entity) aBathEnt =
- HYDROGUI_Tool::FindObjectByName( module(), aBathName, KIND_BATHYMETRY );
-
- if( aPolyEnt.IsNull() || ( aPolyEnt.IsNull() && aBathEnt.IsNull() ) )
- return false;
-
- Handle(HYDROData_Profile) aProfile = Handle(HYDROData_Profile)::DownCast( aProfileEnt );
- Handle(HYDROData_Bathymetry) aBath = Handle(HYDROData_Bathymetry)::DownCast( aBathEnt );
- Handle(HYDROData_PolylineXY) aPolyline = Handle(HYDROData_PolylineXY)::DownCast( aPolyEnt );
-
- if( aProfile.IsNull() || ( aPolyline.IsNull() && aBath.IsNull() ) )
- return false;
+ Handle(HYDROData_Profile) aProfile = Handle(HYDROData_Profile)::DownCast(
+ HYDROGUI_Tool::FindObjectByName( module(), aProfileName, KIND_PROFILE ) );
+ Handle(HYDROData_PolylineXY) aPolyline = Handle(HYDROData_PolylineXY)::DownCast(
+ HYDROGUI_Tool::FindObjectByName( module(), aPolyName, KIND_POLYLINEXY ) );
+ Handle(HYDROData_Bathymetry) aBath = Handle(HYDROData_Bathymetry)::DownCast(
+ HYDROGUI_Tool::FindObjectByName( module(), aBathName, KIND_BATHYMETRY ) );
- Handle(HYDROData_ProfileUZ) aProfileUZ = aProfile->GetProfileUZ();
- if( aProfileUZ.IsNull() )
+ if ( aPolyline.IsNull() || ( aProfile.IsNull() && aBath.IsNull() ) )
return false;
Handle(HYDROData_Polyline3D) aResult;
aResult = myEditedObject;
aResult->RemoveProfileUZ();
aResult->RemovePolylineXY();
+ aResult->RemoveBathymetry();
}
else
{
return false;
aResult->SetName( aResultName );
- aResult->SetProfileUZ( aProfileUZ );
+
+ if ( !aProfile.IsNull() )
+ {
+ Handle(HYDROData_ProfileUZ) aProfileUZ = aProfile->GetProfileUZ();
+ if( aProfileUZ.IsNull() )
+ return false;
+
+ aResult->SetProfileUZ( aProfileUZ );
+ }
+ else
+ {
+ aResult->SetBathymetry( aBath );
+ }
+
aResult->SetPolylineXY( aPolyline );
- //TODO: set bathymetry
if( !myIsEdit )
{