From bdc5180a07545c7ec07641a41753add63d08ba36 Mon Sep 17 00:00:00 2001 From: adv Date: Tue, 29 Oct 2013 08:25:58 +0000 Subject: [PATCH] The abstract interface added for altitude objects. The class for Altitude object has been added. --- src/HYDROData/CMakeLists.txt | 4 ++ src/HYDROData/HYDROData_AltitudeObject.cxx | 52 ++++++++++++++ src/HYDROData/HYDROData_AltitudeObject.h | 70 +++++++++++++++++++ src/HYDROData/HYDROData_Bathymetry.cxx | 30 +++----- src/HYDROData/HYDROData_Bathymetry.h | 27 ++------ src/HYDROData/HYDROData_Document.cxx | 1 + src/HYDROData/HYDROData_Entity.h | 15 ++-- src/HYDROData/HYDROData_IAltitudeObject.cxx | 34 +++++++++ src/HYDROData/HYDROData_IAltitudeObject.h | 76 +++++++++++++++++++++ src/HYDROData/HYDROData_Iterator.cxx | 4 ++ 10 files changed, 265 insertions(+), 48 deletions(-) create mode 100644 src/HYDROData/HYDROData_AltitudeObject.cxx create mode 100644 src/HYDROData/HYDROData_AltitudeObject.h create mode 100644 src/HYDROData/HYDROData_IAltitudeObject.cxx create mode 100644 src/HYDROData/HYDROData_IAltitudeObject.h diff --git a/src/HYDROData/CMakeLists.txt b/src/HYDROData/CMakeLists.txt index 1e5e2a7b..78eae8e3 100644 --- a/src/HYDROData/CMakeLists.txt +++ b/src/HYDROData/CMakeLists.txt @@ -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 index 00000000..4a5bea01 --- /dev/null +++ b/src/HYDROData/HYDROData_AltitudeObject.cxx @@ -0,0 +1,52 @@ + +#include "HYDROData_AltitudeObject.h" +#include "HYDROData_Document.h" + +#include + +#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 index 00000000..ef0be8c5 --- /dev/null +++ b/src/HYDROData/HYDROData_AltitudeObject.h @@ -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 diff --git a/src/HYDROData/HYDROData_Bathymetry.cxx b/src/HYDROData/HYDROData_Bathymetry.cxx index 29ec179c..66223a3a 100644 --- a/src/HYDROData/HYDROData_Bathymetry.cxx +++ b/src/HYDROData/HYDROData_Bathymetry.cxx @@ -15,15 +15,14 @@ #include #include -#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 ] ); diff --git a/src/HYDROData/HYDROData_Bathymetry.h b/src/HYDROData/HYDROData_Bathymetry.h index 7c60181f..f7bc599f 100644 --- a/src/HYDROData/HYDROData_Bathymetry.h +++ b/src/HYDROData/HYDROData_Bathymetry.h @@ -2,14 +2,12 @@ #ifndef HYDROData_Bathymetry_HeaderFile #define HYDROData_Bathymetry_HeaderFile -#include +#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. diff --git a/src/HYDROData/HYDROData_Document.cxx b/src/HYDROData/HYDROData_Document.cxx index 43ce2a1f..cc119abe 100644 --- a/src/HYDROData/HYDROData_Document.cxx +++ b/src/HYDROData/HYDROData_Document.cxx @@ -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 ); diff --git a/src/HYDROData/HYDROData_Entity.h b/src/HYDROData/HYDROData_Entity.h index 79f4f5c0..0aa6a492 100644 --- a/src/HYDROData/HYDROData_Entity.h +++ b/src/HYDROData/HYDROData_Entity.h @@ -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 index 00000000..2dc967a5 --- /dev/null +++ b/src/HYDROData/HYDROData_IAltitudeObject.cxx @@ -0,0 +1,34 @@ + +#include "HYDROData_IAltitudeObject.h" + +#include + +#include + +#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 index 00000000..ba76126b --- /dev/null +++ b/src/HYDROData/HYDROData_IAltitudeObject.h @@ -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 diff --git a/src/HYDROData/HYDROData_Iterator.cxx b/src/HYDROData/HYDROData_Iterator.cxx index a9486d07..43ab980c 100644 --- a/src/HYDROData/HYDROData_Iterator.cxx +++ b/src/HYDROData/HYDROData_Iterator.cxx @@ -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; -- 2.39.2