From: adv Date: Thu, 12 Sep 2013 10:36:30 +0000 (+0000) Subject: Calculation object first implementation (Feature #10). X-Git-Tag: BR_hydro_v_0_1~34 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=1c5e5ce146491c870ecaf7fbffa48d43254aed88;p=modules%2Fhydro.git Calculation object first implementation (Feature #10). --- diff --git a/src/HYDROData/CMakeLists.txt b/src/HYDROData/CMakeLists.txt index ee1f877c..624372ae 100644 --- a/src/HYDROData/CMakeLists.txt +++ b/src/HYDROData/CMakeLists.txt @@ -4,6 +4,7 @@ set(PROJECT_HEADERS HYDROData.h HYDROData_Application.h HYDROData_Bathymetry.h + HYDROData_Calculation.h HYDROData_Document.h HYDROData_Lambert93.h HYDROData_Image.h @@ -19,6 +20,7 @@ set(PROJECT_HEADERS set(PROJECT_SOURCES HYDROData_Application.cxx HYDROData_Bathymetry.cxx + HYDROData_Calculation.cxx HYDROData_Document.cxx HYDROData_Image.cxx HYDROData_Iterator.cxx @@ -59,6 +61,7 @@ if(CPPUNIT_IS_OK) test_HYDROData_Image.h test_HYDROData_Polyline.h test_HYDROData_Bathymetry.h + test_HYDROData_Calculation.h test_HYDROOperations_BSpline.h test_HYDROOperations_Factory.h ) @@ -71,6 +74,7 @@ if(CPPUNIT_IS_OK) test_HYDROData_Image.cxx test_HYDROData_Polyline.cxx test_HYDROData_Bathymetry.cxx + test_HYDROData_Calculation.cxx test_HYDROOperations_BSpline.cxx test_HYDROOperations_Factory.cxx ) diff --git a/src/HYDROData/HYDROData.vcproj b/src/HYDROData/HYDROData.vcproj index 3b659e3f..7ea57957 100644 --- a/src/HYDROData/HYDROData.vcproj +++ b/src/HYDROData/HYDROData.vcproj @@ -133,6 +133,10 @@ RelativePath=".\HYDROData_Bathymetry.cxx" > + + @@ -206,6 +210,10 @@ RelativePath=".\HYDROData_Bathymetry.h" > + + diff --git a/src/HYDROData/HYDROData_Calculation.cxx b/src/HYDROData/HYDROData_Calculation.cxx new file mode 100644 index 00000000..d56296fa --- /dev/null +++ b/src/HYDROData/HYDROData_Calculation.cxx @@ -0,0 +1,40 @@ + +#include "HYDROData_Calculation.h" + +#include "HYDROData_Document.h" + +#include + +#define PYTHON_BATHYMETRY_ID "KIND_CALCULATION" + +IMPLEMENT_STANDARD_HANDLE(HYDROData_Calculation, HYDROData_Object) +IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Calculation, HYDROData_Object) + +HYDROData_Calculation::HYDROData_Calculation() +{ +} + +HYDROData_Calculation::~HYDROData_Calculation() +{ +} + +QStringList HYDROData_Calculation::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const +{ + QStringList aResList; + + Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( this ); + if ( aDocument.IsNull() ) + return aResList; + + QString aDocName = aDocument->GetDocPyName(); + QString aCalculName = GetName(); + + aResList << QString( "%1 = %2.CreateObject( %3 );" ) + .arg( aCalculName ).arg( aDocName ).arg( PYTHON_BATHYMETRY_ID ); + aResList << QString( "%1.SetName( \"%2\" );" ) + .arg( aCalculName ).arg( aCalculName ); + + // TO_IMPLEMENT + + return aResList; +} diff --git a/src/HYDROData/HYDROData_Calculation.h b/src/HYDROData/HYDROData_Calculation.h new file mode 100644 index 00000000..1f9a7716 --- /dev/null +++ b/src/HYDROData/HYDROData_Calculation.h @@ -0,0 +1,68 @@ + +#ifndef HYDROData_HYDROData_Calculation +#define HYDROData_HYDROData_Calculation + +#include + +class gp_XY; +class gp_XYZ; +class QPointF; +class QFile; + +DEFINE_STANDARD_HANDLE(HYDROData_Calculation, HYDROData_Object) + + +/**\class HYDROData_Calculation + * \brief Class that stores/retreives information about the Calculation case. + * + * Calculation case is defined by selection of Geometry objects with or without “Zone of water”. + */ +class HYDROData_Calculation : public HYDROData_Object +{ + +protected: + + /** + * Enumeration of tags corresponding to the persistent object parameters. + */ + enum DataTag + { + DataTag_First = HYDROData_Object::DataTag_First + 100, ///< first tag, to reserve + }; + +public: + + DEFINE_STANDARD_RTTI(HYDROData_Calculation); + + /** + * Returns the kind of this object. Must be redefined in all objects of known type. + */ + HYDRODATA_EXPORT virtual const ObjectKind GetKind() const { return KIND_CALCULATION; } + + + /** + * Dump Calculation object to Python script representation. + */ + HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const; + +public: + // Public methods to work with Calculation + + +protected: + + friend class HYDROData_Iterator; + + /** + * Creates new object in the internal data structure. Use higher level objects + * to create objects with real content. + */ + HYDROData_Calculation(); + + /** + * Destructs properties of the object and object itself, removes it from the document. + */ + ~HYDROData_Calculation(); +}; + +#endif diff --git a/src/HYDROData/HYDROData_Document.cxx b/src/HYDROData/HYDROData_Document.cxx index a92695f8..ec413b43 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_CALCULATION ); return aRes; } diff --git a/src/HYDROData/HYDROData_Iterator.cxx b/src/HYDROData/HYDROData_Iterator.cxx index 40e8322c..2a3d2a77 100644 --- a/src/HYDROData/HYDROData_Iterator.cxx +++ b/src/HYDROData/HYDROData_Iterator.cxx @@ -4,6 +4,7 @@ #include #include #include +#include #include #include @@ -49,11 +50,13 @@ Handle_HYDROData_Object HYDROData_Iterator::CreateObject( return Object(aNewLab); } -Handle_HYDROData_Object HYDROData_Iterator::Object(const TDF_Label theLabel) +Handle_HYDROData_Object HYDROData_Iterator::Object( const TDF_Label theLabel ) { ObjectKind aKind = theLabel.Father().Tag(); + Handle(HYDROData_Object) aResult; - switch(aKind) { + switch( aKind ) + { case KIND_IMAGE: aResult = new HYDROData_Image(); break; @@ -66,8 +69,13 @@ Handle_HYDROData_Object HYDROData_Iterator::Object(const TDF_Label theLabel) case KIND_BATHYMETRY: aResult = new HYDROData_Bathymetry(); break; + case KIND_CALCULATION: + aResult = new HYDROData_Calculation(); + break; } - if (!aResult.IsNull()) - aResult->SetLabel(theLabel); + + if ( !aResult.IsNull() ) + aResult->SetLabel( theLabel ); + return aResult; } diff --git a/src/HYDROData/HYDROData_Object.h b/src/HYDROData/HYDROData_Object.h index 7ea49e6b..680b8581 100644 --- a/src/HYDROData/HYDROData_Object.h +++ b/src/HYDROData/HYDROData_Object.h @@ -19,6 +19,7 @@ const ObjectKind KIND_IMAGE = 1; const ObjectKind KIND_POLYLINE = 2; const ObjectKind KIND_VISUAL_STATE = 3; const ObjectKind KIND_BATHYMETRY = 4; +const ObjectKind KIND_CALCULATION = 5; DEFINE_STANDARD_HANDLE(HYDROData_Object, MMgt_TShared) diff --git a/src/HYDROData/test_HYDROData_Calculation.cxx b/src/HYDROData/test_HYDROData_Calculation.cxx new file mode 100755 index 00000000..312b2f8e --- /dev/null +++ b/src/HYDROData/test_HYDROData_Calculation.cxx @@ -0,0 +1,4 @@ +#include + +#include + diff --git a/src/HYDROData/test_HYDROData_Calculation.h b/src/HYDROData/test_HYDROData_Calculation.h new file mode 100755 index 00000000..36858d5d --- /dev/null +++ b/src/HYDROData/test_HYDROData_Calculation.h @@ -0,0 +1,20 @@ + +#include + +class Handle_HYDROData_Calculation; +class QString; + +class HYDROData_Calculation : public CppUnit::TestFixture { + CPPUNIT_TEST_SUITE(test_HYDROData_Calculation); + CPPUNIT_TEST_SUITE_END(); + +public: + + void setUp() {} + + void tearDown() {} + +}; + +CPPUNIT_TEST_SUITE_REGISTRATION(test_HYDROData_Calculation); +CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(test_HYDROData_Calculation, "HYDROData_Calculation");