Salome HOME
Access methods for object groups added.
[modules/hydro.git] / src / HYDROData / HYDROData_Polyline3D.cxx
index 0507b2e8bcba9ce1396bdbbdb563a0561e1da307..d5a9425ef1d42dcb1fca13ec4a9a14a0960ce878 100644 (file)
@@ -1,7 +1,7 @@
 
 #include "HYDROData_Polyline3D.h"
 
-#include "HYDROData_Bathymetry.h"
+#include "HYDROData_IAltitudeObject.h"
 #include "HYDROData_Document.h"
 #include "HYDROData_PolylineXY.h"
 #include "HYDROData_Profile.h"
@@ -18,8 +18,6 @@
 #include <QColor>
 #include <QStringList>
 
-#define PYTHON_POLYLINE_ID "KIND_POLYLINE"
-
 IMPLEMENT_STANDARD_HANDLE(HYDROData_Polyline3D,HYDROData_Object)
 IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Polyline3D,HYDROData_Object)
 
@@ -35,21 +33,21 @@ HYDROData_Polyline3D::~HYDROData_Polyline3D()
 
 QStringList HYDROData_Polyline3D::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const
 {
-  QStringList aResList;
+  QStringList aResList = dumpObjectCreation( theTreatedObjects );
+  QString aName = GetObjPyName();
 
-  Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
-  if ( aDocument.IsNull() )
-    return aResList;
+  Handle(HYDROData_PolylineXY) aRefPolyline = GetPolylineXY();
+  setPythonReferenceObject( theTreatedObjects, aResList, aRefPolyline, "SetPolylineXY" );
 
-  QString aDocName = aDocument->GetDocPyName();
-  QString aPolylineName = GetName();
+  Handle(HYDROData_ProfileUZ) aRefProfile = GetProfileUZ();
+  setPythonReferenceObject( theTreatedObjects, aResList, aRefProfile, "SetProfileUZ" );
 
-  aResList << QString( "%1 = %2.CreateObject( %3 );" )
-              .arg( aPolylineName ).arg( aDocName ).arg( PYTHON_POLYLINE_ID );
-  aResList << QString( "%1.SetName( \"%1\" );" ).arg( aPolylineName );
-  aResList << QString( "" );
+  Handle(HYDROData_IAltitudeObject) aRefBathymetry = GetAltitudeObject();
+  setPythonReferenceObject( theTreatedObjects, aResList, aRefBathymetry, "SetAltitudeObject" );
 
-  // TODO
+  aResList << QString( "" );
+  aResList << QString( "%1.Update();" ).arg( aName );
+  aResList << QString( "" );
 
   return aResList;
 }
@@ -99,8 +97,8 @@ void HYDROData_Polyline3D::Update()
 
   Handle(HYDROData_ProfileUZ) aProfileUZ = GetProfileUZ();
 
-  Handle(HYDROData_Bathymetry) aBathymetry = GetBathymetry();
-  if ( !aBathymetry.IsNull() )
+  Handle(HYDROData_IAltitudeObject) anAltitude = GetAltitudeObject();
+  if ( !anAltitude.IsNull() )
     aProfileUZ = GetChildProfileUZ();
 
   if ( aProfileUZ.IsNull() )
@@ -217,7 +215,7 @@ bool HYDROData_Polyline3D::SetProfileUZ( const Handle(HYDROData_ProfileUZ)& theP
   SetReferenceObject( theProfile, DataTag_ProfileUZ );
 
   // Remove the bathymetry, because one altitude object can be presented at time
-  RemoveBathymetry();
+  RemoveAltitudeObject();
 
   // Indicate model of the need to update the polyline presentation
   SetToUpdate( true );
@@ -243,14 +241,15 @@ void HYDROData_Polyline3D::RemoveProfileUZ()
   SetToUpdate( true );
 }
 
-bool HYDROData_Polyline3D::SetBathymetry( const Handle(HYDROData_Bathymetry)& theBathymetry )
+bool HYDROData_Polyline3D::SetAltitudeObject( 
+  const Handle(HYDROData_IAltitudeObject)& theAltitude )
 {
-  Handle(HYDROData_Bathymetry) aPrevBathymetry = GetBathymetry();
+  Handle(HYDROData_IAltitudeObject) aPrevAltitude = GetAltitudeObject();
 
-  if ( !HYDROData_Object::SetBathymetry( theBathymetry ) )
+  if ( !HYDROData_Object::SetAltitudeObject( theAltitude ) )
     return false;
 
-  if ( IsEqual( aPrevBathymetry, theBathymetry ) )
+  if ( IsEqual( aPrevAltitude, theAltitude ) )
     return true;
 
   // Remove the u,z profile, because one altitude object can be presented at time
@@ -263,9 +262,9 @@ bool HYDROData_Polyline3D::SetBathymetry( const Handle(HYDROData_Bathymetry)& th
 }
 
 
-void HYDROData_Polyline3D::RemoveBathymetry()
+void HYDROData_Polyline3D::RemoveAltitudeObject()
 {
-  HYDROData_Object::RemoveBathymetry();
+  HYDROData_Object::RemoveAltitudeObject();
 
   // Remove the child profile object 
   removeChildProfileUZ();
@@ -292,18 +291,18 @@ Handle(HYDROData_ProfileUZ) HYDROData_Polyline3D::GetChildProfileUZ( const bool
 
   aProfileUZ = aProfile->GetProfileUZ();
 
-  Handle(HYDROData_Polyline3D) me = this;
+  HYDROData_Polyline3D* me = const_cast<HYDROData_Polyline3D*>( this ); // Temporary to be revised
   me->SetReferenceObject( aProfileUZ, DataTag_ChildProfileUZ );
 
   return aProfileUZ;
 }
 
 HYDROData_IPolyline::PointsList generateProfileUZPoints(
-  const Handle(HYDROData_PolylineXY)& thePolyline,
-  const Handle(HYDROData_Bathymetry)& theBathymetry )
+  const Handle(HYDROData_PolylineXY)&      thePolyline,
+  const Handle(HYDROData_IAltitudeObject)& theAltitude )
 {
   HYDROData_IPolyline::PointsList aPointsList;
-  if ( thePolyline.IsNull() || theBathymetry.IsNull() )
+  if ( thePolyline.IsNull() || theAltitude.IsNull() )
     return aPointsList;
 
   bool anIsSectionClosed = thePolyline->IsClosedSection( 0 );
@@ -317,7 +316,9 @@ HYDROData_IPolyline::PointsList generateProfileUZPoints(
     const HYDROData_PolylineXY::Point& aSectPoint = aPolylinePoints.Value( i );
 
     double aPointDistance = thePolyline->GetDistance( 0, i - 1 );
-    double aPointDepth = theBathymetry->GetAltitudeForPoint( aSectPoint );
+    double aPointDepth = theAltitude->GetAltitudeForPoint( aSectPoint );
+    if( aPointDepth == theAltitude->GetInvalidAltitude() )
+      aPointDepth = 0.0;
 
     HYDROData_IPolyline::Point anAltitudePoint( aPointDistance, aPointDepth );
     aPointsList.Append( anAltitudePoint );
@@ -328,8 +329,8 @@ HYDROData_IPolyline::PointsList generateProfileUZPoints(
 
 void HYDROData_Polyline3D::updateChildProfilePoints()
 {
-  Handle(HYDROData_Bathymetry) aBathymetry = GetBathymetry();
-  if ( aBathymetry.IsNull() )
+  Handle(HYDROData_IAltitudeObject) anAltitude = GetAltitudeObject();
+  if ( anAltitude.IsNull() )
     return;
 
   Handle(HYDROData_ProfileUZ) aChildProfileUZ = GetChildProfileUZ();
@@ -342,7 +343,7 @@ void HYDROData_Polyline3D::updateChildProfilePoints()
     return;
 
   HYDROData_IPolyline::PointsList aProfilePoints = 
-    generateProfileUZPoints( GetPolylineXY(), GetBathymetry() );
+    generateProfileUZPoints( GetPolylineXY(), anAltitude );
   aProfile->SetParametricPoints( aProfilePoints );
 
   aProfile->Update();