]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
Calculation object first implementation (Feature #10).
authoradv <adv@opencascade.com>
Thu, 12 Sep 2013 10:36:30 +0000 (10:36 +0000)
committeradv <adv@opencascade.com>
Thu, 12 Sep 2013 10:36:30 +0000 (10:36 +0000)
src/HYDROData/CMakeLists.txt
src/HYDROData/HYDROData.vcproj
src/HYDROData/HYDROData_Calculation.cxx [new file with mode: 0644]
src/HYDROData/HYDROData_Calculation.h [new file with mode: 0644]
src/HYDROData/HYDROData_Document.cxx
src/HYDROData/HYDROData_Iterator.cxx
src/HYDROData/HYDROData_Object.h
src/HYDROData/test_HYDROData_Calculation.cxx [new file with mode: 0755]
src/HYDROData/test_HYDROData_Calculation.h [new file with mode: 0755]

index ee1f877c34fc2f91548f37abd9d7a2e509ae8476..624372aec64839503c176b5fe44dca00534ee801 100644 (file)
@@ -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
   )
index 3b659e3f86405ee1babf274fd6526a811aa209d0..7ea57957746e50085094e9217e67d9f7992e12f2 100644 (file)
                                RelativePath=".\HYDROData_Bathymetry.cxx"
                                >
                        </File>
+                       <File
+                               RelativePath=".\HYDROData_Calculation.cxx"
+                               >
+                       </File>
                        <File
                                RelativePath=".\HYDROData_Document.cxx"
                                >
                                RelativePath=".\HYDROData_Bathymetry.h"
                                >
                        </File>
+                       <File
+                               RelativePath=".\HYDROData_Calculation.h"
+                               >
+                       </File>
                        <File
                                RelativePath=".\HYDROData_Document.h"
                                >
diff --git a/src/HYDROData/HYDROData_Calculation.cxx b/src/HYDROData/HYDROData_Calculation.cxx
new file mode 100644 (file)
index 0000000..d56296f
--- /dev/null
@@ -0,0 +1,40 @@
+
+#include "HYDROData_Calculation.h"
+
+#include "HYDROData_Document.h"
+
+#include <QStringList>
+
+#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 (file)
index 0000000..1f9a771
--- /dev/null
@@ -0,0 +1,68 @@
+
+#ifndef HYDROData_HYDROData_Calculation
+#define HYDROData_HYDROData_Calculation
+
+#include <HYDROData_Object.h>
+
+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 \93Zone of water\94
+ */
+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
index a92695f82fd47b95615a1ad4a9c7240badefbb11..ec413b43e9f50f6281504761c55eca5605a5afb0 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_CALCULATION );
 
   return aRes;
 }
index 40e8322cc70b41ff12f4198feed6924bab9e6eba..2a3d2a778723a4f06acd3517e852cdd762a2c1a4 100644 (file)
@@ -4,6 +4,7 @@
 #include <HYDROData_Polyline.h>
 #include <HYDROData_VisualState.h>
 #include <HYDROData_Bathymetry.h>
+#include <HYDROData_Calculation.h>
 
 #include <TDataStd_Name.hxx>
 #include <NCollection_DataMap.hxx>
@@ -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;
 }
index 7ea49e6b1c46daa92c2d930981e8e4854a031190..680b858136905a4c2cec898ae3703fa2ee2de873 100644 (file)
@@ -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 (executable)
index 0000000..312b2f8
--- /dev/null
@@ -0,0 +1,4 @@
+#include <test_HYDROData_Calculation.h>
+
+#include <HYDROData_Calculation.h>
+
diff --git a/src/HYDROData/test_HYDROData_Calculation.h b/src/HYDROData/test_HYDROData_Calculation.h
new file mode 100755 (executable)
index 0000000..36858d5
--- /dev/null
@@ -0,0 +1,20 @@
+
+#include <cppunit/extensions/HelperMacros.h>
+
+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");