Salome HOME
Base implementation of Zone data object (Feature #31).
authoradv <adv@opencascade.com>
Tue, 17 Sep 2013 13:15:19 +0000 (13:15 +0000)
committeradv <adv@opencascade.com>
Tue, 17 Sep 2013 13:15:19 +0000 (13:15 +0000)
src/HYDROData/HYDROData.vcproj
src/HYDROData/HYDROData_Calculation.cxx
src/HYDROData/HYDROData_Image.cxx
src/HYDROData/HYDROData_Image.h
src/HYDROData/HYDROData_Iterator.h
src/HYDROData/HYDROData_Object.cxx
src/HYDROData/HYDROData_Object.h
src/HYDROData/HYDROData_Polyline.cxx
src/HYDROData/HYDROData_Polyline.h
src/HYDROData/HYDROData_Zone.cxx [new file with mode: 0644]
src/HYDROData/HYDROData_Zone.h [new file with mode: 0644]

index 7ea57957746e50085094e9217e67d9f7992e12f2..bacb345f878f8978c7c276e8ceb2413097b91a6c 100644 (file)
                                RelativePath=".\HYDROData_VisualState.cxx"
                                >
                        </File>
+                       <File
+                               RelativePath=".\HYDROData_Zone.cxx"
+                               >
+                       </File>
                        <Filter
                                Name="Link"
                                >
                                RelativePath=".\HYDROData_VisualState.h"
                                >
                        </File>
+                       <File
+                               RelativePath=".\HYDROData_Zone.h"
+                               >
+                       </File>
                        <Filter
                                Name="Operations"
                                >
index e22f7a575c00af47958f6ec196aa4f6a69e84081..c836f54882b85ee58a9a883cc39e917d1b6a6e31 100644 (file)
@@ -45,29 +45,11 @@ QStringList HYDROData_Calculation::DumpToPython( MapOfTreatedObjects& theTreated
 
 void HYDROData_Calculation::SetBoundaryPolyline( const Handle(HYDROData_Polyline)& thePolyline )
 {
-  Handle(TDataStd_ReferenceList) aRefs;
-  myLab.FindChild( DataTag_BoundaryPolyline ).FindAttribute( TDataStd_ReferenceList::GetID(), aRefs );
-  if ( aRefs.IsNull() )
-    aRefs = TDataStd_ReferenceList::Set( myLab.FindChild( DataTag_BoundaryPolyline ) );
-
-  aRefs->Clear();
-
-  if ( thePolyline.IsNull() )
-    return;
-
-  aRefs->Append( thePolyline->Label() );
+  SetReferenceObject( thePolyline, DataTag_BoundaryPolyline );
 }
 
 Handle(HYDROData_Polyline) HYDROData_Calculation::GetBoundaryPolyline() const
 {
-  Handle(HYDROData_Polyline) aRes;
-
-  Handle(TDataStd_ReferenceList) aRefs;
-  myLab.FindChild( DataTag_BoundaryPolyline ).FindAttribute( TDataStd_ReferenceList::GetID(), aRefs );
-  if ( !aRefs.IsNull() && !aRefs->IsEmpty() )
-  {
-    aRes = Handle(HYDROData_Polyline)::DownCast( HYDROData_Iterator::Object( aRefs->First() ) );
-  }
-
-  return aRes;
+  return Handle(HYDROData_Polyline)::DownCast( 
+           GetReferenceObject( DataTag_BoundaryPolyline ) );
 }
index 5fe12bb06bb5eed219a510286f0fbee89d20b804..362e151577e0dcf24ad2ba85377567fe0c440756 100644 (file)
@@ -1,9 +1,9 @@
 
 #include "HYDROData_Image.h"
 
-#include "HYDROData_Iterator.h"
-#include "HYDROOperations_Factory.h"
+#include "HYDROData_Document.h"
 #include "HYDROData_Tool.h"
+#include "HYDROOperations_Factory.h"
 
 #include <TDataStd_RealArray.hxx>
 #include <TDataStd_ByteArray.hxx>
@@ -12,7 +12,6 @@
 #include <TDataStd_Name.hxx>
 #include <TDataStd_UAttribute.hxx>
 #include <TDataStd_AsciiString.hxx>
-#include <TDF_ListIteratorOfLabelList.hxx>
 
 #include <ImageComposer_Operator.h>
 #include <ImageComposer_MetaTypes.h>
@@ -382,77 +381,35 @@ bool HYDROData_Image::HasTrsfPoints() const
   return myLab.FindChild(DataTag_TrsfPoints).FindAttribute(TDataStd_RealArray::GetID(), anArray);
 }
 
-void HYDROData_Image::AppendReference(Handle(HYDROData_Object) theReferenced)
+void HYDROData_Image::AppendReference( const Handle(HYDROData_Object)& theReferenced )
 {
-  Handle(TDataStd_ReferenceList) aRefs;
-  if (!myLab.FindAttribute(TDataStd_ReferenceList::GetID(), aRefs))
-    aRefs = TDataStd_ReferenceList::Set(myLab);
-  aRefs->Append(theReferenced->Label());
+  AddReferenceObject( theReferenced, 0 );
 }
 
 int HYDROData_Image::NbReferences() const
 {
-  Handle(TDataStd_ReferenceList) aRefs;
-  if (!myLab.FindAttribute(TDataStd_ReferenceList::GetID(), aRefs))
-    return 0;
-  return aRefs->Extent();
+  return NbReferenceObjects( 0 );
 }
 
-Handle(HYDROData_Object) HYDROData_Image::Reference(const int theIndex) const
+Handle(HYDROData_Object) HYDROData_Image::Reference( const int theIndex ) const
 {
-  Handle(TDataStd_ReferenceList) aRefs;
-  if (!myLab.FindAttribute(TDataStd_ReferenceList::GetID(), aRefs))
-    return Handle(HYDROData_Object)();
-  if (theIndex < 0 || theIndex >= aRefs->Extent())
-    return Handle(HYDROData_Object)();
-
-  TDF_ListIteratorOfLabelList anIter(aRefs->List());
-  for(int anIndex = 0; anIndex != theIndex; anIter.Next(), anIndex++);
-  const TDF_Label& aRefLab = anIter.Value();
-  return Handle(HYDROData_Object)::DownCast(HYDROData_Iterator::Object(aRefLab));
+  return GetReferenceObject( 0, theIndex );
 }
 
 void HYDROData_Image::ChangeReference(
     const int theIndex, Handle(HYDROData_Object) theReferenced)
 {
-  Handle(TDataStd_ReferenceList) aRefs;
-  if (!myLab.FindAttribute(TDataStd_ReferenceList::GetID(), aRefs))
-    aRefs = TDataStd_ReferenceList::Set(myLab);
-  if (theIndex >= aRefs->Extent()) { // for too big index append it just to the end
-    AppendReference(theReferenced);
-  } else { // remove and insert new
-    TDF_ListIteratorOfLabelList anIter(aRefs->List());
-    int anIndex = 0;
-    for(; anIndex != theIndex; anIter.Next(), anIndex++);
-    const TDF_Label& aRemovedLab = anIter.Value();
-    anIter.Next();
-    aRefs->Remove(aRemovedLab);
-    if (anIter.More()) 
-      aRefs->InsertBefore(theReferenced->Label(), anIter.Value());
-    else 
-      aRefs->Append(theReferenced->Label());
-  }
+  SetReferenceObject( theReferenced, 0, theIndex );
 }
 
 void HYDROData_Image::RemoveReference(const int theIndex)
 {
-  Handle(TDataStd_ReferenceList) aRefs;
-  if (!myLab.FindAttribute(TDataStd_ReferenceList::GetID(), aRefs))
-    return; // no references, nothing to remove
-  if (aRefs->Extent() == 1 && theIndex == 0) { // remove all if only one
-    ClearReferences();
-    return;
-  }
-  TDF_ListIteratorOfLabelList anIter(aRefs->List());
-  int anIndex = 0;
-  for(; anIndex != theIndex && anIter.More(); anIter.Next(), anIndex++);
-  if (anIter.More())
-    aRefs->Remove(anIter.Value());
+  RemoveReferenceObject( 0, theIndex );
 }
 
 void HYDROData_Image::ClearReferences()
 {
-  myLab.ForgetAttribute(TDataStd_ReferenceList::GetID());
+  ClearReferenceObjects( 0 );
 }
 
 void HYDROData_Image::SetOperatorName(const QString theOpName)
index 134a5b2e04929c92e62ebd8d0c740d0d692ef843..16a691a64b23afd3e0ab956a0b8ab69657cf0ef0 100644 (file)
@@ -134,7 +134,7 @@ public:
    * Appends reference to other object (image or polyline).
    * \param theReferenced the object referenced by this
    */
-  HYDRODATA_EXPORT void AppendReference(Handle(HYDROData_Object) theReferenced);
+  HYDRODATA_EXPORT void AppendReference( const Handle(HYDROData_Object)& theReferenced );
 
   /**
    * Returns the number of referenced objects
index 8fc27f833e0f749e2f108a2e6c2081093840a0c3..746366a64d9d8c230c3cb1d7e45e9bd7671ebe4c 100644 (file)
@@ -42,8 +42,7 @@ public:
 protected:
 
   friend class HYDROData_Document;
-  friend class HYDROData_Image;
-  friend class HYDROData_Calculation;
+  friend class HYDROData_Object;
 
   /**
    * Creates object in the document, call HYDROData_Document method to create 
index 46d5b3a59c819bde53d467624d687d52b17cb8ca..1be3985a854702b26b2b9339a9e2dead81fe6972 100644 (file)
@@ -1,4 +1,7 @@
-#include <HYDROData_Object.h>
+
+#include "HYDROData_Object.h"
+
+#include "HYDROData_Iterator.h"
 
 #include <TDataStd_Name.hxx>
 #include <TDataStd_ByteArray.hxx>
@@ -6,7 +9,10 @@
 #include <TDataStd_IntegerArray.hxx>
 #include <TDataStd_BooleanArray.hxx>
 #include <TDataStd_RealArray.hxx>
+#include <TDataStd_ReferenceList.hxx>
+
 #include <TDF_CopyLabel.hxx>
+#include <TDF_ListIteratorOfLabelList.hxx>
 
 #include <QString>
 #include <QStringList>
@@ -117,3 +123,130 @@ const char* HYDROData_Object::ByteArray(const int theTag, int& theLen) const
     return (const char*)(&(aData->InternalArray()->ChangeArray1().ChangeValue(1)));
   return NULL;
 }
+
+int HYDROData_Object::NbReferenceObjects( const int theTag ) const
+{
+  Handle(TDataStd_ReferenceList) aRefs = getReferenceList( theTag, false );
+  return aRefs.IsNull() ? 0 : aRefs->Extent();
+}
+
+void HYDROData_Object::AddReferenceObject( const Handle_HYDROData_Object& theObj,
+                                           const int                      theTag )
+{
+  if ( theObj.IsNull() )
+    return;
+
+  Handle(TDataStd_ReferenceList) aRefs = getReferenceList( theTag, true );
+  aRefs->Append( theObj->Label() );
+}
+
+void HYDROData_Object::SetReferenceObject( const Handle_HYDROData_Object& theObj,
+                                           const int                      theTag,
+                                           const int                      theIndex )
+{
+  if ( theObj.IsNull() )
+    return;
+
+  Handle(TDataStd_ReferenceList) aRefs = getReferenceList( theTag, true );
+
+  if ( theIndex >= aRefs->Extent() )
+  {
+    aRefs->Append( theObj->Label() );
+  }
+  else if ( theIndex < 0 )
+  {
+    aRefs->Prepend( theObj->Label() );
+  }
+  else
+  {
+    RemoveReferenceObject( theTag, theIndex );
+
+    Handle(HYDROData_Object) aBeforeObj = GetReferenceObject( theTag, theIndex );
+
+    aRefs = getReferenceList( theTag, true ); // because reference list can be removed
+    if ( !aBeforeObj.IsNull() )
+      aRefs->InsertBefore( theObj->Label(), aBeforeObj->Label() );
+    else 
+      aRefs->Append( theObj->Label() );
+  }
+}
+
+Handle(HYDROData_Object) HYDROData_Object::GetReferenceObject( const int theTag,
+                                                               const int theIndex ) const
+{
+  Handle(HYDROData_Object) aRes;
+
+  Handle(TDataStd_ReferenceList) aRefs = getReferenceList( theTag, false );
+  if ( aRefs.IsNull() || theIndex < 0 || theIndex >= aRefs->Extent() )
+    return aRes;
+
+  TDF_ListIteratorOfLabelList anIter( aRefs->List() );
+  for ( int anIndex = 0; anIndex != theIndex && anIter.More(); anIter.Next(), ++anIndex );
+
+  const TDF_Label& aRefLabel = anIter.Value();
+  aRes = HYDROData_Iterator::Object( aRefLabel );
+
+  return aRes;
+}
+
+HYDROData_SequenceOfObjects HYDROData_Object::GetReferenceObjects( const int theTag ) const
+{
+  HYDROData_SequenceOfObjects aRes;
+
+  Handle(TDataStd_ReferenceList) aRefs = getReferenceList( theTag, false );
+  if ( aRefs.IsNull() )
+    return aRes;
+
+  TDF_ListIteratorOfLabelList anIter( aRefs->List() );
+  for ( ; anIter.More(); anIter.Next() )
+  {
+    const TDF_Label& aRefLabel = anIter.Value();
+
+    Handle(HYDROData_Object) aRefObject = HYDROData_Iterator::Object( aRefLabel );
+    if ( aRefObject.IsNull() )
+      continue;
+
+    aRes.Append( aRefObject );
+  }
+
+  return aRes;
+}
+
+void HYDROData_Object::RemoveReferenceObject( const int theTag,
+                                              const int theIndex )
+{
+  Handle(TDataStd_ReferenceList) aRefs = getReferenceList( theTag, false );
+  if ( aRefs.IsNull() )
+    return;
+
+  if ( aRefs->Extent() == 1 && theIndex == 0 )
+  { 
+    // remove all if only one
+    ClearReferenceObjects( theTag );
+    return;
+  }
+
+  Handle(HYDROData_Object) aRemovedObj = GetReferenceObject( theTag, theIndex );
+  if ( aRemovedObj.IsNull() )
+    return;
+
+  aRefs->Remove( aRemovedObj->Label() );
+}
+
+void HYDROData_Object::ClearReferenceObjects( const int theTag )
+{
+  TDF_Label aSetLabel = theTag == 0 ? myLab : myLab.FindChild( theTag );
+  aSetLabel.ForgetAttribute( TDataStd_ReferenceList::GetID() );
+}
+
+Handle(TDataStd_ReferenceList) HYDROData_Object::getReferenceList( const int theTag,
+                                                                   const bool theIsCreate ) const
+{
+  TDF_Label aLabel = theTag == 0 ? myLab : myLab.FindChild( theTag );
+
+  Handle(TDataStd_ReferenceList) aRefs;
+  if ( !aLabel.FindAttribute( TDataStd_ReferenceList::GetID(), aRefs ) && theIsCreate )
+    aRefs = TDataStd_ReferenceList::Set( aLabel );
+
+  return aRefs;
+}
index 595c6f9a359a89c1f4b370cbd6fcb3ee8a035484..04e83ed99649a275f942dacc065f26d9be85a3bb 100644 (file)
 class QString;
 class QVariant;
 class QStringList;
+class Handle(TDataStd_ReferenceList);
+class Handle_HYDROData_Object;
 
 ///! Kind of an object in a document
 typedef int ObjectKind;
 ///! Unrecognized object
-const ObjectKind KIND_UNKNOWN = 0;
-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;
+const ObjectKind KIND_UNKNOWN        = 0;
+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;
+const ObjectKind KIND_PROFILE        = 6;
+const ObjectKind KIND_PROFILES_GROUP = 7;
+const ObjectKind KIND_GUIDE_LINE     = 8;
+const ObjectKind KIND_ZONE           = 9;
 
 DEFINE_STANDARD_HANDLE(HYDROData_Object, MMgt_TShared)
 
 typedef QMap<QString,Handle(Standard_Transient)> MapOfTreatedObjects;
 
+typedef NCollection_Sequence<Handle_HYDROData_Object> HYDROData_SequenceOfObjects;
+
+
 /**\class HYDROData_Object
  * \brief Generic class of any object in the data model.
  *
@@ -149,13 +158,70 @@ protected:
    */
   const char* ByteArray(const int theTag, int& theLen) const;
 
+  /**
+   * Internal method that used to store the reference object label attribute
+   * \param theObj pointer to reference object
+   * \param theTag tag of a label to store attribute (for 0 this is myLab)
+   */
+  int NbReferenceObjects( const int theTag = 0 ) const;
+
+  /**
+   * Internal method that used to store the reference object label attribute
+   * \param theObj pointer to reference object
+   * \param theTag tag of a label to store attribute (for 0 this is myLab)
+   */
+  void AddReferenceObject( const Handle_HYDROData_Object& theObj,
+                           const int                      theTag = 0 );
+
+  /**
+   * Internal method that used to store the reference object label attribute
+   * \param theObj pointer to reference object
+   * \param theTag tag of a label to store attribute (for 0 this is myLab)
+   * \param theIndex index in the list of references 
+             - if more that len then just append it to the end of list
+             - if less than zero then prepend to the list
+             - indexing starts from 0
+   */
+  void SetReferenceObject( const Handle_HYDROData_Object& theObj,
+                           const int                      theTag = 0,
+                           const int                      theIndex = 0 );
+
+  /**
+   * Internal method that used to retreive the reference object(s) attribute
+   * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
+   * \param theIndex index in the list of references 
+   *        - indexing starts from 0
+   * \returns pointer to reference object or NULL if label is not set
+   */
+  Handle_HYDROData_Object GetReferenceObject( const int theTag   = 0,
+                                              const int theIndex = 0 ) const;
+
+  HYDROData_SequenceOfObjects GetReferenceObjects( const int theTag = 0 ) const;
+
+  /**
+   * Internal method that used to remove the reference object attribute
+   * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
+   * \param theIndex index in the list of references 
+   *        - indexing starts from 0
+   */
+  void RemoveReferenceObject( const int theTag = 0, const int theIndex = 0 );
+
+  /**
+   * Internal method that used to clear list of the reference objects attribute
+   * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
+   */
+  void ClearReferenceObjects( const int theTag = 0 );
+
+protected:
+
+  Handle(TDataStd_ReferenceList) getReferenceList( const int  theTag,
+                                                   const bool theIsCreate ) const;
+
 protected:
   /// Array of pointers to the properties of this object; index in this array is returned by \a AddProperty.
   TDF_Label myLab; ///< label of this object
 };
 
-typedef NCollection_Sequence<Handle_HYDROData_Object> HYDROData_SequenceOfObjects;
-
 ///! Is Equal for HYDROData_Object mapping
 HYDRODATA_EXPORT bool IsEqual(const Handle_HYDROData_Object& theObj1, const Handle_HYDROData_Object& theObj2);
 
index 64ae5f201373ee3477dd27b216bac2131cc53232..fb723700621300e61e47ae44f4acbaadfd280279 100755 (executable)
@@ -262,6 +262,28 @@ HYDROData_Polyline::PolylineData HYDROData_Polyline::getPolylineData() const
   return aRes;
 }
 
+/**
+ * Returns true if polyline is closed
+ */
+bool HYDROData_Polyline::isClosed() const
+{
+  int aDim = getDimension();
+  PolylineData aPolylineData = getPolylineData();
+
+  if ( aDim == 0 || aPolylineData.isEmpty() )
+    return false;
+
+  PolylineData::const_iterator anIt = aPolylineData.constBegin();
+  for ( ; anIt != aPolylineData.constEnd(); ++anIt )
+  {
+    const PolylineSection& aSection = *anIt;
+    if ( !aSection.myIsClosed )
+      return false;
+  }
+
+  return true;
+}
+
 /**
  * Remove all polyline attributes except dimension.
  */
@@ -286,7 +308,7 @@ void HYDROData_Polyline::removeAll()
  * is ignored section type.
  * \return polyline painter path.
  */
-QPainterPath HYDROData_Polyline::painterPath()
+QPainterPath HYDROData_Polyline::painterPath() const
 {
   QPainterPath aPath;
   int aDim = getDimension();
index cd7928c873029e6f2cec984367a9675370ece2ba..3906ac5321178f2b6b58676ff6162be212056750 100755 (executable)
@@ -79,6 +79,11 @@ public:
    */
   HYDRODATA_EXPORT PolylineData getPolylineData() const;
    
+  /**
+   * Returns true if polyline is closed
+   */
+  HYDRODATA_EXPORT bool isClosed() const;
+
   /**
    * Return polyline dimension
    * \return polyline dimension (2 or 3)
@@ -100,7 +105,7 @@ public:
   /**
    * Returns the painter path. The painter path is construct by lines
    */
-  HYDRODATA_EXPORT QPainterPath painterPath();
+  HYDRODATA_EXPORT QPainterPath painterPath() const;
 
 
 protected:
diff --git a/src/HYDROData/HYDROData_Zone.cxx b/src/HYDROData/HYDROData_Zone.cxx
new file mode 100644 (file)
index 0000000..f872345
--- /dev/null
@@ -0,0 +1,126 @@
+
+#include "HYDROData_Zone.h"
+
+#include "HYDROData_Bathymetry.h"
+#include "HYDROData_Document.h"
+#include "HYDROData_Polyline.h"
+#include "HYDROData_Iterator.h"
+
+#include <TDataStd_IntegerArray.hxx>
+
+#include <QColor>
+#include <QStringList>
+
+#define PYTHON_POLYLINE_ID "KIND_ZONE"
+
+IMPLEMENT_STANDARD_HANDLE(HYDROData_Zone, HYDROData_Object)
+IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Zone, HYDROData_Object)
+
+HYDROData_Zone::HYDROData_Zone()
+{
+}
+
+HYDROData_Zone::~HYDROData_Zone()
+{
+}
+
+QStringList HYDROData_Zone::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const
+{
+  QStringList aResList;
+
+  Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( this );
+  if ( aDocument.IsNull() )
+    return aResList;
+
+  return aResList;
+}
+
+void HYDROData_Zone::SetColor( const QColor& theColor )
+{
+  Handle(TDataStd_IntegerArray) aColorArray;
+  if ( !myLab.FindChild( DataTag_Color ).FindAttribute( TDataStd_IntegerArray::GetID(), aColorArray ) )
+    aColorArray = TDataStd_IntegerArray::Set( myLab.FindChild( DataTag_Color ), 1, 4 );
+
+  aColorArray->SetValue( 1, theColor.red()   );
+  aColorArray->SetValue( 2, theColor.green() );
+  aColorArray->SetValue( 3, theColor.blue()  );
+  aColorArray->SetValue( 4, theColor.alpha() );
+}
+
+QColor HYDROData_Zone::GetColor() const
+{
+  QColor aResColor( Qt::green );
+
+  Handle(TDataStd_IntegerArray) aColorArray;
+  if ( myLab.FindChild( DataTag_Color ).FindAttribute( TDataStd_IntegerArray::GetID(), aColorArray ) )
+  {
+    aResColor.setRed(   aColorArray->Value( 1 ) );
+    aResColor.setGreen( aColorArray->Value( 2 ) );
+    aResColor.setBlue(  aColorArray->Value( 3 ) );
+    aResColor.setAlpha( aColorArray->Value( 4 ) );
+  }
+
+  return aResColor;
+}
+
+void HYDROData_Zone::SetPolyline( const Handle(HYDROData_Polyline)& thePolyline )
+{
+  SetReferenceObject( thePolyline, DataTag_Polyline );
+}
+
+Handle(HYDROData_Polyline) HYDROData_Zone::GetPolyline() const
+{
+  return Handle(HYDROData_Polyline)::DownCast( 
+           GetReferenceObject( DataTag_Polyline ) );
+}
+
+void HYDROData_Zone::RemovePolyline()
+{
+  ClearReferenceObjects( DataTag_Polyline );
+}
+
+int HYDROData_Zone::NbBathymetries() const
+{
+  return NbReferenceObjects( DataTag_Bathymetry );
+}
+
+void HYDROData_Zone::AddBathymetry( const Handle(HYDROData_Bathymetry)& theBathymetry )
+{
+  AddReferenceObject( theBathymetry, DataTag_Bathymetry );
+}
+
+void HYDROData_Zone::SetBathymetry( const int                           theIndex,
+                                    const Handle(HYDROData_Bathymetry)& theBathymetry )
+{
+  SetReferenceObject( theBathymetry, DataTag_Bathymetry, theIndex );
+}
+
+Handle(HYDROData_Bathymetry) HYDROData_Zone::GetBathymetry( const int theIndex ) const
+{
+  return Handle(HYDROData_Bathymetry)::DownCast( 
+           GetReferenceObject( DataTag_Bathymetry, theIndex ) );
+}
+
+HYDROData_SequenceOfObjects HYDROData_Zone::GetBathymetries() const
+{
+  return GetReferenceObjects( DataTag_Bathymetry );
+}
+
+void HYDROData_Zone::RemoveBathymetries()
+{
+  ClearReferenceObjects( DataTag_Bathymetry );
+}
+
+QPainterPath HYDROData_Zone::GetPainterPath() const
+{
+  QPainterPath aPath;
+
+  Handle(HYDROData_Polyline) aPolyline = GetPolyline();
+  if ( !aPolyline.IsNull() )
+  {
+    aPath = aPolyline->painterPath();
+  }
+
+  return aPath;
+}
+
diff --git a/src/HYDROData/HYDROData_Zone.h b/src/HYDROData/HYDROData_Zone.h
new file mode 100644 (file)
index 0000000..e9ad3ba
--- /dev/null
@@ -0,0 +1,135 @@
+
+#ifndef HYDROData_Zone_HeaderFile
+#define HYDROData_Zone_HeaderFile
+
+#include <HYDROData_Object.h>
+
+#include <QPointF>
+#include <QPainterPath>
+#include <QList>
+
+class Handle(HYDROData_Bathymetry);
+class Handle(HYDROData_Polyline);
+
+DEFINE_STANDARD_HANDLE(HYDROData_Zone, HYDROData_Object)
+
+
+/**\class HYDROData_Zone
+ * \brief Class that stores/retreives information about the 2d face.
+ */
+class HYDROData_Zone : 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
+    DataTag_Bathymetry, ///< reference bathymetries
+    DataTag_Polyline,   ///< reference polyline
+    DataTag_Color       ///< color of zone
+  };
+
+public:
+  DEFINE_STANDARD_RTTI(HYDROData_Zone);
+
+  /**
+   * Returns the kind of this object. Must be redefined in all objects of known type.
+   */
+  HYDRODATA_EXPORT virtual const ObjectKind GetKind() const {return KIND_ZONE;}
+
+  /**
+   * Dump object to Python script representation.
+   */
+  HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
+
+
+  /**
+   * Sets color for zone.
+   */
+  HYDRODATA_EXPORT virtual void SetColor( const QColor& theColor );
+
+  /**
+   * Returns color of zone.
+   */
+  HYDRODATA_EXPORT virtual QColor GetColor() const;
+
+
+  /**
+   * Sets reference polyline object for zone.
+   */
+  HYDRODATA_EXPORT virtual void SetPolyline( const Handle(HYDROData_Polyline)& thePolyline );
+
+  /**
+   * Returns reference polyline object of zone.
+   */
+  HYDRODATA_EXPORT virtual Handle(HYDROData_Polyline) GetPolyline() const;
+
+  /**
+   * Remove reference polyline object of zone.
+   */
+  HYDRODATA_EXPORT virtual void RemovePolyline();
+
+
+  /**
+   * Returns number of bathymetry objects for zone.
+   */
+  HYDRODATA_EXPORT virtual int NbBathymetries() const;
+
+  /**
+   * Add reference bathymetry object for zone.
+   */
+  HYDRODATA_EXPORT virtual void AddBathymetry( const Handle(HYDROData_Bathymetry)& theBathymetry );
+
+  /**
+   * Change reference bathymetry object with given index for zone.
+   */
+  HYDRODATA_EXPORT virtual void SetBathymetry( const int                           theIndex,
+                                               const Handle(HYDROData_Bathymetry)& theBathymetry );
+
+  /**
+   * Returns reference bathymetry object of zone by it index.
+   */
+  HYDRODATA_EXPORT virtual Handle(HYDROData_Bathymetry) GetBathymetry( const int theIndex ) const;
+
+  /**
+   * Returns list of all reference bathymetry objects of zone.
+   */
+  HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects  GetBathymetries() const;
+
+  /**
+   * Clear list of bathymetry objects of zone.
+   */
+  HYDRODATA_EXPORT virtual void RemoveBathymetries();
+
+  /**
+   * Returns data of object wrapped to QVariant.
+   * Reimplemented to wrap and return saved 2d polyline.
+   */
+  //HYDRODATA_EXPORT virtual QVariant GetDataVariant();
+
+  /**
+   * Returns the painter path. The painter path is construct by polyline
+   */
+  HYDRODATA_EXPORT QPainterPath GetPainterPath() 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_Zone();
+
+  /**
+   * Destructs properties of the object and object itself, removes it from the document.
+   */
+  ~HYDROData_Zone();
+};
+
+#endif