]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
The abstract interface added for altitude objects.
authoradv <adv@opencascade.com>
Tue, 29 Oct 2013 08:25:58 +0000 (08:25 +0000)
committeradv <adv@opencascade.com>
Tue, 29 Oct 2013 08:25:58 +0000 (08:25 +0000)
The class for Altitude object has been added.

src/HYDROData/CMakeLists.txt
src/HYDROData/HYDROData_AltitudeObject.cxx [new file with mode: 0644]
src/HYDROData/HYDROData_AltitudeObject.h [new file with mode: 0644]
src/HYDROData/HYDROData_Bathymetry.cxx
src/HYDROData/HYDROData_Bathymetry.h
src/HYDROData/HYDROData_Document.cxx
src/HYDROData/HYDROData_Entity.h
src/HYDROData/HYDROData_IAltitudeObject.cxx [new file with mode: 0644]
src/HYDROData/HYDROData_IAltitudeObject.h [new file with mode: 0644]
src/HYDROData/HYDROData_Iterator.cxx

index 1e5e2a7b6b64ca7fa7292c59bfbbe91277fb41f1..78eae8e3a20ec510a0f2b30cda19bf9ca9236b01 100644 (file)
@@ -2,6 +2,7 @@ include(../../CMake/Common.cmake)
 
 set(PROJECT_HEADERS
     HYDROData.h
+    HYDROData_AltitudeObject.h
     HYDROData_Application.h
     HYDROData_ArtificialObject.h
     HYDROData_Bathymetry.h
@@ -9,6 +10,7 @@ set(PROJECT_HEADERS
     HYDROData_Calculation.h
     HYDROData_Document.h
     HYDROData_Entity.h
+    HYDROData_IAltitudeObject.h
     HYDROData_Image.h
     HYDROData_ImmersibleZone.h
     HYDROData_Iterator.h
@@ -25,6 +27,7 @@ set(PROJECT_HEADERS
 )
 
 set(PROJECT_SOURCES 
+    HYDROData_AltitudeObject.cxx
     HYDROData_Application.cxx
     HYDROData_ArtificialObject.cxx
     HYDROData_Bathymetry.cxx
@@ -32,6 +35,7 @@ set(PROJECT_SOURCES
     HYDROData_Calculation.cxx
     HYDROData_Document.cxx
     HYDROData_Entity.cxx
+    HYDROData_IAltitudeObject.cxx
     HYDROData_Image.cxx
     HYDROData_ImmersibleZone.cxx
     HYDROData_Iterator.cxx
diff --git a/src/HYDROData/HYDROData_AltitudeObject.cxx b/src/HYDROData/HYDROData_AltitudeObject.cxx
new file mode 100644 (file)
index 0000000..4a5bea0
--- /dev/null
@@ -0,0 +1,52 @@
+
+#include "HYDROData_AltitudeObject.h"
+#include "HYDROData_Document.h"
+
+#include <QStringList>
+
+#define PYTHON_ALTITUDE_ID "KIND_ALTITUDE"
+
+
+IMPLEMENT_STANDARD_HANDLE(HYDROData_AltitudeObject, HYDROData_IAltitudeObject)
+IMPLEMENT_STANDARD_RTTIEXT(HYDROData_AltitudeObject, HYDROData_IAltitudeObject)
+
+HYDROData_AltitudeObject::HYDROData_AltitudeObject()
+: HYDROData_IAltitudeObject()
+{
+}
+
+HYDROData_AltitudeObject::~HYDROData_AltitudeObject()
+{
+}
+
+QStringList HYDROData_AltitudeObject::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const
+{
+  QStringList aResList;
+
+  Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( this );
+  if ( aDocument.IsNull() )
+    return aResList;
+                             
+  QString aDocName = aDocument->GetDocPyName();
+  QString anAltitudeName = GetName();
+
+  aResList << QString( "%1 = %2.CreateObject( %3 );" )
+              .arg( anAltitudeName ).arg( aDocName ).arg( PYTHON_ALTITUDE_ID );
+  aResList << QString( "%1.SetName( \"%2\" );" )
+              .arg( anAltitudeName ).arg( anAltitudeName );
+
+  // TODO
+
+  return aResList;
+}
+
+double HYDROData_AltitudeObject::GetAltitudeForPoint( const gp_XY& thePoint ) const
+{
+  double aResAltitude = GetInvalidAltitude();
+
+  return aResAltitude;
+}
+
+
+
+
diff --git a/src/HYDROData/HYDROData_AltitudeObject.h b/src/HYDROData/HYDROData_AltitudeObject.h
new file mode 100644 (file)
index 0000000..ef0be8c
--- /dev/null
@@ -0,0 +1,70 @@
+
+#ifndef HYDROData_AltitudeObject_HeaderFile
+#define HYDROData_AltitudeObject_HeaderFile
+
+
+#include "HYDROData_IAltitudeObject.h"
+
+
+DEFINE_STANDARD_HANDLE(HYDROData_AltitudeObject, HYDROData_IAltitudeObject)
+
+
+/**\class HYDROData_AltitudeObject
+ * \brief Class that stores/retreives information about the Altitude.
+ *
+ */
+class HYDROData_AltitudeObject : public HYDROData_IAltitudeObject
+{
+protected:
+
+  /**
+   * Enumeration of tags corresponding to the persistent object parameters.
+   */
+  enum DataTag
+  {
+    DataTag_First = HYDROData_IAltitudeObject::DataTag_First + 100, ///< first tag, to reserve
+  };
+
+public:
+
+  DEFINE_STANDARD_RTTI(HYDROData_AltitudeObject);
+
+  /**
+   * Returns the kind of this object. 
+   */
+  HYDRODATA_EXPORT virtual const ObjectKind GetKind() const { return KIND_ALTITUDE; }
+
+
+  /**
+   * Dump Altitude object to Python script representation.
+   */
+  HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
+
+public:      
+
+  // Public methods to work with altitudes.
+
+  /**
+   * Returns altitude for given point.
+   * \param thePoint the point to examine
+   * \return altitude value
+   */
+  HYDRODATA_EXPORT virtual double           GetAltitudeForPoint( const gp_XY& thePoint ) const;
+
+protected:
+
+  friend class HYDROData_Iterator;
+
+  /**
+   * Creates new object in the internal data structure. Use higher level objects 
+   * to create objects with real content.
+   */
+  HYDROData_AltitudeObject();
+
+  /**
+   * Destructs properties of the object and object itself, removes it from the document.
+   */
+  ~HYDROData_AltitudeObject();
+};
+
+#endif
index 29ec179c98d3bd39f68ad33b8506f889d816631e..66223a3a37d2c0d2fa9daa34e82472903eef2bc1 100644 (file)
 #include <QPolygonF>
 #include <QStringList>
 
-#define INVALID_ALTITUDE_VALUE -9999.0
 #define PYTHON_BATHYMETRY_ID "KIND_BATHYMETRY"
 
 
-IMPLEMENT_STANDARD_HANDLE(HYDROData_Bathymetry, HYDROData_Entity)
-IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Bathymetry, HYDROData_Entity)
+IMPLEMENT_STANDARD_HANDLE(HYDROData_Bathymetry, HYDROData_IAltitudeObject)
+IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Bathymetry, HYDROData_IAltitudeObject)
 
 HYDROData_Bathymetry::HYDROData_Bathymetry()
-: HYDROData_Entity()
+: HYDROData_IAltitudeObject()
 {
 }
 
@@ -61,11 +60,6 @@ QStringList HYDROData_Bathymetry::DumpToPython( MapOfTreatedObjects& theTreatedO
   return aResList;
 }
 
-double HYDROData_Bathymetry::GetInvalidAltitude()
-{
-  return INVALID_ALTITUDE_VALUE;
-}
-
 void HYDROData_Bathymetry::SetAltitudePoints( const AltitudePoints& thePoints )
 {
   RemoveAltitudePoints();
@@ -174,15 +168,9 @@ void interpolateAltitudeForPoints( const gp_XY&                               th
   theResPoint.SetZ( aResVal );
 }
 
-double HYDROData_Bathymetry::GetAltitudeForPoint( const QPointF& thePoint ) const
-{
-  gp_XY aGpPoint( thePoint.x(), thePoint.y() );
-  return GetAltitudeForPoint( aGpPoint );
-}
-
 double HYDROData_Bathymetry::GetAltitudeForPoint( const gp_XY& thePoint ) const
 {
-  double aResAltitude = -9999.90;
+  double aResAltitude = GetInvalidAltitude();
   
   AltitudePoints anAltitudePoints = GetAltitudePoints();
   if ( anAltitudePoints.isEmpty() )
@@ -194,10 +182,10 @@ double HYDROData_Bathymetry::GetAltitudeForPoint( const gp_XY& thePoint ) const
   // [ 0 (top-left) ]          [ 1 (top-right) ]
   //                  thePoint
   // [ 2 (bot-left) ]          [ 3 (bot-right) ] 
-  AltitudePoint aBounds[ 4 ] = { AltitudePoint( -DBL_MAX, -DBL_MAX, INVALID_ALTITUDE_VALUE ),
-                                 AltitudePoint(  DBL_MAX, -DBL_MAX, INVALID_ALTITUDE_VALUE ),
-                                 AltitudePoint( -DBL_MAX,  DBL_MAX, INVALID_ALTITUDE_VALUE ),
-                                 AltitudePoint(  DBL_MAX,  DBL_MAX, INVALID_ALTITUDE_VALUE ) }; 
+  AltitudePoint aBounds[ 4 ] = { AltitudePoint( -DBL_MAX, -DBL_MAX, GetInvalidAltitude() ),
+                                 AltitudePoint(  DBL_MAX, -DBL_MAX, GetInvalidAltitude() ),
+                                 AltitudePoint( -DBL_MAX,  DBL_MAX, GetInvalidAltitude() ),
+                                 AltitudePoint(  DBL_MAX,  DBL_MAX, GetInvalidAltitude() ) }; 
 
   AltitudePoints::const_iterator aListItBeg = anAltitudePoints.constBegin();
   AltitudePoints::const_iterator aListItEnd = anAltitudePoints.constEnd();
@@ -285,7 +273,7 @@ double HYDROData_Bathymetry::GetAltitudeForPoint( const gp_XY& thePoint ) const
 
   // Check if requested point is inside of our bounding rectangle
   if ( !aBoundingRect.boundingRect().contains( thePoint.X(), thePoint.Y() ) )
-    return INVALID_ALTITUDE_VALUE;
+    return aResAltitude;
 
   // Calculate result altitude for point
   AltitudePoint aFirstPoint( aBounds[ 0 ] ), aSecPoint( aBounds[ 1 ] );
index 7c60181f1f0a7ff1220ea1d88ebe4104a390dc67..f7bc599fa5dddbed8880f0bc829121ed00e0d87d 100644 (file)
@@ -2,14 +2,12 @@
 #ifndef HYDROData_Bathymetry_HeaderFile
 #define HYDROData_Bathymetry_HeaderFile
 
-#include <HYDROData_Entity.h>
+#include "HYDROData_IAltitudeObject.h"
 
-class gp_XY;
-class gp_XYZ;
-class QPointF;
 class QFile;
+class gp_XYZ;
 
-DEFINE_STANDARD_HANDLE(HYDROData_Bathymetry, HYDROData_Entity)
+DEFINE_STANDARD_HANDLE(HYDROData_Bathymetry, HYDROData_IAltitudeObject)
 
 
 /**\class HYDROData_Bathymetry
@@ -17,7 +15,7 @@ DEFINE_STANDARD_HANDLE(HYDROData_Bathymetry, HYDROData_Entity)
  *
  * The Bathymetry represents measurement of the altitude of points on the terrain.
  */
-class HYDROData_Bathymetry : public HYDROData_Entity
+class HYDROData_Bathymetry : public HYDROData_IAltitudeObject
 {
 public:
 
@@ -31,7 +29,7 @@ protected:
    */
   enum DataTag
   {
-    DataTag_First = HYDROData_Entity::DataTag_First + 100, ///< first tag, to reserve
+    DataTag_First = HYDROData_IAltitudeObject::DataTag_First + 100, ///< first tag, to reserve
     DataTag_AltitudePoints, ///< altitude points, array of reals
     DataTag_FilePath        ///< bathymetry imported file path
   };
@@ -54,12 +52,6 @@ public:
 public:      
   // Public methods to work with Bathymetry altitudes.
 
-  /**
-   * Returns altitude points list.
-   * \return points list
-   */
-  HYDRODATA_EXPORT static double            GetInvalidAltitude();
-
   /**
    * Replace current altitude points by new one.
    * \param thePoints the altitude points list
@@ -77,13 +69,6 @@ public:
    */
   HYDRODATA_EXPORT virtual void             RemoveAltitudePoints();
 
-  /**
-   * Returns altitude for given point.
-   * \param thePoint the point to examine
-   * \return altitude value
-   */
-  HYDRODATA_EXPORT virtual double           GetAltitudeForPoint( const QPointF& thePoint ) const;
-
   /**
    * Returns altitude for given point.
    * \param thePoint the point to examine
@@ -91,6 +76,8 @@ public:
    */
   HYDRODATA_EXPORT virtual double           GetAltitudeForPoint( const gp_XY& thePoint ) const;
 
+  using HYDROData_IAltitudeObject::GetAltitudeForPoint;  
+
 
 public:
   // Public methods to work with files.
index 43ce2a1fecf84593123eb7aca3b570a8aa62996d..cc119abec3d9fa1731702aae3cf747cd8dd78f28 100644 (file)
@@ -197,6 +197,7 @@ bool HYDROData_Document::DumpToPython( const QString& theFileName ) const
   aRes = aRes && dumpPartitionToPython( aFile, aTreatedObjects, KIND_IMAGE      );
   aRes = aRes && dumpPartitionToPython( aFile, aTreatedObjects, KIND_POLYLINE   );
   aRes = aRes && dumpPartitionToPython( aFile, aTreatedObjects, KIND_BATHYMETRY );
+  aRes = aRes && dumpPartitionToPython( aFile, aTreatedObjects, KIND_ALTITUDE );
   aRes = aRes && dumpPartitionToPython( aFile, aTreatedObjects, KIND_IMMERSIBLE_ZONE );
   aRes = aRes && dumpPartitionToPython( aFile, aTreatedObjects, KIND_CALCULATION );
 
index 79f4f5c0a88ea8514cfaea44df54da4ebe806834..0aa6a492b7615e1f2f775aa57bc4e6c1e48772f7 100644 (file)
@@ -24,13 +24,14 @@ const ObjectKind KIND_UNKNOWN         = 0; ///! Unrecognized object
 const ObjectKind KIND_IMAGE           = 1;
 const ObjectKind KIND_POLYLINE        = 2;
 const ObjectKind KIND_BATHYMETRY      = 3;
-const ObjectKind KIND_IMMERSIBLE_ZONE = 4;
-const ObjectKind KIND_GUIDE_LINE      = 5;
-const ObjectKind KIND_PROFILE         = 6;
-const ObjectKind KIND_CALCULATION     = 7;
-const ObjectKind KIND_ZONE            = 8;
-const ObjectKind KIND_REGION          = 9;
-const ObjectKind KIND_VISUAL_STATE    = 10;
+const ObjectKind KIND_ALTITUDE        = 4;
+const ObjectKind KIND_IMMERSIBLE_ZONE = 5;
+const ObjectKind KIND_GUIDE_LINE      = 6;
+const ObjectKind KIND_PROFILE         = 7;
+const ObjectKind KIND_CALCULATION     = 8;
+const ObjectKind KIND_ZONE            = 9;
+const ObjectKind KIND_REGION          = 10;
+const ObjectKind KIND_VISUAL_STATE    = 11;
 const ObjectKind KIND_LAST            = KIND_VISUAL_STATE;
 
 DEFINE_STANDARD_HANDLE(HYDROData_Entity, MMgt_TShared)
diff --git a/src/HYDROData/HYDROData_IAltitudeObject.cxx b/src/HYDROData/HYDROData_IAltitudeObject.cxx
new file mode 100644 (file)
index 0000000..2dc967a
--- /dev/null
@@ -0,0 +1,34 @@
+
+#include "HYDROData_IAltitudeObject.h"
+
+#include <gp_XY.hxx>
+
+#include <QPointF>
+
+#define INVALID_ALTITUDE_VALUE -9999.0
+
+IMPLEMENT_STANDARD_HANDLE(HYDROData_IAltitudeObject, HYDROData_Entity)
+IMPLEMENT_STANDARD_RTTIEXT(HYDROData_IAltitudeObject, HYDROData_Entity)
+
+HYDROData_IAltitudeObject::HYDROData_IAltitudeObject()
+: HYDROData_Entity()
+{
+}
+
+HYDROData_IAltitudeObject::~HYDROData_IAltitudeObject()
+{
+}
+
+double HYDROData_IAltitudeObject::GetInvalidAltitude()
+{
+  return INVALID_ALTITUDE_VALUE;
+}
+
+double HYDROData_IAltitudeObject::GetAltitudeForPoint( const QPointF& thePoint ) const
+{
+  gp_XY aGpPoint( thePoint.x(), thePoint.y() );
+  return GetAltitudeForPoint( aGpPoint );
+}
+
+
+
diff --git a/src/HYDROData/HYDROData_IAltitudeObject.h b/src/HYDROData/HYDROData_IAltitudeObject.h
new file mode 100644 (file)
index 0000000..ba76126
--- /dev/null
@@ -0,0 +1,76 @@
+
+#ifndef HYDROData_IAltitudeObject_HeaderFile
+#define HYDROData_IAltitudeObject_HeaderFile
+
+#include "HYDROData_Entity.h"
+
+class gp_XY;
+class QPointF;
+
+DEFINE_STANDARD_HANDLE(HYDROData_IAltitudeObject, HYDROData_Entity)
+
+
+/**\class HYDROData_IAltitudeObject
+ * \briefThe base class for all altitude objects in the HYDRO module.
+ *
+ */
+class HYDROData_IAltitudeObject : public HYDROData_Entity
+{
+protected:
+
+  /**
+   * Enumeration of tags corresponding to the persistent object parameters.
+   */
+  enum DataTag
+  {
+    DataTag_First = HYDROData_Entity::DataTag_First + 100, ///< first tag, to reserve
+  };
+
+public:
+
+  DEFINE_STANDARD_RTTI(HYDROData_IAltitudeObject);
+
+  /**
+   * Returns the kind of this object. Must be redefined in all objects of known type.
+   */
+  HYDRODATA_EXPORT virtual const ObjectKind GetKind() const = 0;
+
+public:      
+  // Public methods to work with altitudes.
+
+  /**
+   * Returns altitude points list.
+   * \return points list
+   */
+  HYDRODATA_EXPORT static double            GetInvalidAltitude();
+
+  /**
+   * Returns altitude for given point.
+   * \param thePoint the point to examine
+   * \return altitude value
+   */
+  HYDRODATA_EXPORT virtual double           GetAltitudeForPoint( const QPointF& thePoint ) const;
+
+  /**
+   * Returns altitude for given point.
+   * \param thePoint the point to examine
+   * \return altitude value
+   */
+  HYDRODATA_EXPORT virtual double           GetAltitudeForPoint( const gp_XY& thePoint ) const = 0;
+
+
+protected:
+
+  /**
+   * Creates new object in the internal data structure. Use higher level objects 
+   * to create objects with real content.
+   */
+  HYDROData_IAltitudeObject();
+
+  /**
+   * Destructs properties of the object and object itself, removes it from the document.
+   */
+  ~HYDROData_IAltitudeObject();
+};
+
+#endif
index a9486d07ff96d7e74402af371f34e50fefce2a00..43ab980c2160ac02064a835ec6eaabb96588caa1 100644 (file)
@@ -1,6 +1,7 @@
 
 #include "HYDROData_Iterator.h"
 
+#include "HYDROData_AltitudeObject.h"
 #include "HYDROData_Bathymetry.h"
 #include "HYDROData_Calculation.h"
 #include "HYDROData_Image.h"
@@ -102,6 +103,9 @@ Handle(HYDROData_Entity) HYDROData_Iterator::Object( const TDF_Label& theLabel )
     case KIND_BATHYMETRY:
       aResult = new HYDROData_Bathymetry();
       break;
+    case KIND_ALTITUDE:
+      aResult = new HYDROData_AltitudeObject();
+      break;
     case KIND_IMMERSIBLE_ZONE:
       aResult = new HYDROData_ImmersibleZone();
       break;