Salome HOME
refs #651: wrapping land cover map by Python
[modules/hydro.git] / src / HYDROData / HYDROData_ShapeFile.h
index e23c9d6e15f856d62b0ac18027bc634b2c191a3a..eb381ceecc4263f62dd29f22ea4fde06464eaf74 100644 (file)
 class gp_XYZ;
 class Handle_HYDROData_PolylineXY;
 class Handle_HYDROData_Polyline3D;
-class Handle_HYDROData_LandCover;
 class Handle(HYDROData_Document);
 class TopTools_SequenceOfShape;
 class TopoDS_Face;
 class Handle_HYDROData_Entity;
+class Handle_HYDROData_LandCoverMap;
 
 class HYDROData_ShapeFile 
 {
 
+public:
+
 enum ShapeType
 {
   ShapeType_Polyline,
   ShapeType_Polygon
 };
 
+enum DBF_FieldType
+{
+  DBF_FieldType_None,
+  DBF_FieldType_String,
+  DBF_FieldType_Integer, 
+  DBF_FieldType_Double,
+  DBF_FieldType_Invalid
+};
+
+
+struct DBF_AttrValue
+{
+  DBF_AttrValue() 
+  {
+    myIntVal = -1;
+    myDoubleVal = -1.0;
+    myIsNull = true;
+    myFieldType = DBF_FieldType_None;
+  }
+  QString myStrVal;
+  int myIntVal;
+  double myDoubleVal;
+  std::string myRawValue;
+  DBF_FieldType myFieldType;
+  bool myIsNull;
+};
+
 public:
   HYDRODATA_EXPORT HYDROData_ShapeFile(  );
   virtual HYDRODATA_EXPORT ~HYDROData_ShapeFile();
@@ -58,11 +87,11 @@ public:
   HYDRODATA_EXPORT void Export(const QString& aFileName, 
                                NCollection_Sequence<Handle_HYDROData_PolylineXY> aPolyXYSeq,
                                NCollection_Sequence<Handle_HYDROData_Polyline3D> aPoly3DSeq,
-                               NCollection_Sequence<Handle_HYDROData_LandCover> aLCSeq,
+                               const Handle_HYDROData_LandCoverMap& aLCSeq,
                                QStringList& aNonExpList);
   int WriteObjectPolyXY(SHPHandle theShpHandle, Handle_HYDROData_PolylineXY thePoly );
   int WriteObjectPoly3D(SHPHandle theShpHandle, Handle_HYDROData_Polyline3D thePoly );
-  int WriteObjectLC(SHPHandle theShpHandle, Handle_HYDROData_LandCover theLC );
+  //TODO:int WriteObjectLC(SHPHandle theShpHandle, Handle_HYDROData_LandCover theLC );
   //Import
   bool Parse(SHPHandle theHandle, ShapeType theType, int& theShapeTypeOfFile);
   //Import Landcover
@@ -77,12 +106,27 @@ public:
   HYDRODATA_EXPORT int ImportPolylines(Handle(HYDROData_Document) theDocument, const QString& theFileName, 
                        NCollection_Sequence<Handle_HYDROData_Entity>& theEntities, int& theShapeTypeOfFile);
   HYDRODATA_EXPORT QString GetShapeTypeName(int theType);
+
+  //DBF I/O Methods
+  bool CheckDBFFileExisting(const QString& theSHPFilePath, QString& thePathToDBFFile);
+  bool DBF_OpenDBF(const QString& thePathToDBFFile);
+  int DBF_GetNbFields();
+  QStringList DBF_GetFieldList();
+  void DBF_GetFieldTypeList(std::vector<DBF_FieldType>& FTVect);
+  int DBF_GetNbRecords();
+  void DBF_CloseDBF();
+  void DBF_GetAttributeList(int theIndexOfField, std::vector<DBF_AttrValue>& theAttrV);
+  bool DBF_WriteFieldAndValues(const QString& theFileName, const QString& theFieldName, DBF_FieldType theType, const std::vector<DBF_AttrValue>& theAttrV, bool bUseStrValue);
+
 private:
   void ProcessFace(TopoDS_Face theFace, SHPHandle theShpHandle);
   int TryOpenShapeFile(QString theFileName);
 private:
   std::vector<SHPObject*> mySHPObjects;
   SHPHandle myHSHP;
+  DBFHandle    myHDBF;
+
+  friend class test_HYDROData_ShapeFile;
 };
 
 #endif