]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
The data model has been redesigned to new format.
authoradv <adv@opencascade.com>
Thu, 24 Oct 2013 11:23:30 +0000 (11:23 +0000)
committeradv <adv@opencascade.com>
Thu, 24 Oct 2013 11:23:30 +0000 (11:23 +0000)
127 files changed:
src/HYDROData/CMakeLists.txt
src/HYDROData/HYDROData.vcproj
src/HYDROData/HYDROData_ArtificialObject.cxx [new file with mode: 0644]
src/HYDROData/HYDROData_ArtificialObject.h [new file with mode: 0644]
src/HYDROData/HYDROData_BSplineOperation.cxx [new file with mode: 0644]
src/HYDROData/HYDROData_BSplineOperation.h [new file with mode: 0644]
src/HYDROData/HYDROData_Bathymetry.cxx
src/HYDROData/HYDROData_Bathymetry.h
src/HYDROData/HYDROData_Calculation.cxx
src/HYDROData/HYDROData_Calculation.h
src/HYDROData/HYDROData_Document.cxx
src/HYDROData/HYDROData_Document.h
src/HYDROData/HYDROData_Domain.cxx [deleted file]
src/HYDROData/HYDROData_Domain.h [deleted file]
src/HYDROData/HYDROData_Entity.cxx [new file with mode: 0644]
src/HYDROData/HYDROData_Entity.h [new file with mode: 0644]
src/HYDROData/HYDROData_Image.cxx
src/HYDROData/HYDROData_Image.h
src/HYDROData/HYDROData_ImmersibleZone.cxx [new file with mode: 0644]
src/HYDROData/HYDROData_ImmersibleZone.h [new file with mode: 0644]
src/HYDROData/HYDROData_Iterator.cxx
src/HYDROData/HYDROData_Iterator.h
src/HYDROData/HYDROData_NaturalObject.cxx [new file with mode: 0644]
src/HYDROData/HYDROData_NaturalObject.h [new file with mode: 0644]
src/HYDROData/HYDROData_Object.cxx
src/HYDROData/HYDROData_Object.h
src/HYDROData/HYDROData_OperationsFactory.cxx [new file with mode: 0644]
src/HYDROData/HYDROData_OperationsFactory.h [new file with mode: 0644]
src/HYDROData/HYDROData_Polyline.cxx
src/HYDROData/HYDROData_Polyline.h
src/HYDROData/HYDROData_Region.cxx
src/HYDROData/HYDROData_Region.h
src/HYDROData/HYDROData_SplitToZonesTool.cxx [new file with mode: 0644]
src/HYDROData/HYDROData_SplitToZonesTool.h [new file with mode: 0644]
src/HYDROData/HYDROData_Tool.cxx
src/HYDROData/HYDROData_Tool.h
src/HYDROData/HYDROData_VisualState.cxx
src/HYDROData/HYDROData_VisualState.h
src/HYDROData/HYDROData_Zone.cxx
src/HYDROData/HYDROData_Zone.h
src/HYDROData/HYDROOperations_BSpline.cxx [deleted file]
src/HYDROData/HYDROOperations_BSpline.h [deleted file]
src/HYDROData/HYDROOperations_Factory.cxx [deleted file]
src/HYDROData/HYDROOperations_Factory.h [deleted file]
src/HYDROData/test_HYDROData_BSplineOperation.cxx [new file with mode: 0644]
src/HYDROData/test_HYDROData_BSplineOperation.h [new file with mode: 0644]
src/HYDROData/test_HYDROData_OperationsFactory.cxx [new file with mode: 0644]
src/HYDROData/test_HYDROData_OperationsFactory.h [new file with mode: 0644]
src/HYDROData/test_HYDROOperations_BSpline.cxx [deleted file]
src/HYDROData/test_HYDROOperations_BSpline.h [deleted file]
src/HYDROData/test_HYDROOperations_Factory.cxx [deleted file]
src/HYDROData/test_HYDROOperations_Factory.h [deleted file]
src/HYDROGUI/CMakeLists.txt
src/HYDROGUI/HYDROGUI.vcproj
src/HYDROGUI/HYDROGUI_AISCurve.cxx
src/HYDROGUI/HYDROGUI_CalculationDlg.cxx
src/HYDROGUI/HYDROGUI_CalculationDlg.h
src/HYDROGUI/HYDROGUI_CalculationOp.cxx
src/HYDROGUI/HYDROGUI_CalculationOp.h
src/HYDROGUI/HYDROGUI_DataModel.cxx
src/HYDROGUI/HYDROGUI_DataModel.h
src/HYDROGUI/HYDROGUI_DataObject.cxx
src/HYDROGUI/HYDROGUI_DataObject.h
src/HYDROGUI/HYDROGUI_DeleteOp.cxx
src/HYDROGUI/HYDROGUI_Displayer.cxx
src/HYDROGUI/HYDROGUI_Displayer.h
src/HYDROGUI/HYDROGUI_GVSelector.cxx
src/HYDROGUI/HYDROGUI_ImmersibleZoneDlg.cxx [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_ImmersibleZoneDlg.h [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_ImmersibleZoneOp.cxx [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_ImmersibleZoneOp.h [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_ImportBathymetryOp.cxx
src/HYDROGUI/HYDROGUI_ImportImageOp.cxx
src/HYDROGUI/HYDROGUI_Module.cxx
src/HYDROGUI/HYDROGUI_Module.h
src/HYDROGUI/HYDROGUI_OCCDisplayer.cxx
src/HYDROGUI/HYDROGUI_OCCDisplayer.h
src/HYDROGUI/HYDROGUI_OCCSelector.cxx
src/HYDROGUI/HYDROGUI_ObjSelector.cxx
src/HYDROGUI/HYDROGUI_Operations.cxx
src/HYDROGUI/HYDROGUI_Operations.h
src/HYDROGUI/HYDROGUI_PolylineOp.cxx
src/HYDROGUI/HYDROGUI_Prs.cxx
src/HYDROGUI/HYDROGUI_Prs.h
src/HYDROGUI/HYDROGUI_PrsDriver.cxx
src/HYDROGUI/HYDROGUI_PrsDriver.h
src/HYDROGUI/HYDROGUI_PrsImage.cxx
src/HYDROGUI/HYDROGUI_PrsImage.h
src/HYDROGUI/HYDROGUI_PrsImageDriver.cxx
src/HYDROGUI/HYDROGUI_PrsImageDriver.h
src/HYDROGUI/HYDROGUI_PrsPolyline.cxx
src/HYDROGUI/HYDROGUI_PrsPolyline.h
src/HYDROGUI/HYDROGUI_PrsPolylineDriver.cxx
src/HYDROGUI/HYDROGUI_PrsPolylineDriver.h
src/HYDROGUI/HYDROGUI_PrsZone.cxx
src/HYDROGUI/HYDROGUI_PrsZone.h
src/HYDROGUI/HYDROGUI_PrsZoneDriver.cxx
src/HYDROGUI/HYDROGUI_PrsZoneDriver.h
src/HYDROGUI/HYDROGUI_Shape.cxx
src/HYDROGUI/HYDROGUI_Shape.h
src/HYDROGUI/HYDROGUI_ShowHideOp.cxx
src/HYDROGUI/HYDROGUI_SplitZonesTool.cxx [deleted file]
src/HYDROGUI/HYDROGUI_SplitZonesTool.h [deleted file]
src/HYDROGUI/HYDROGUI_Tool.cxx
src/HYDROGUI/HYDROGUI_Tool.h
src/HYDROGUI/HYDROGUI_TwoImagesOp.cxx
src/HYDROGUI/HYDROGUI_VisualStateOp.cxx
src/HYDROGUI/HYDROGUI_ZoneDlg.cxx [deleted file]
src/HYDROGUI/HYDROGUI_ZoneDlg.h [deleted file]
src/HYDROGUI/HYDROGUI_ZoneOp.cxx [deleted file]
src/HYDROGUI/HYDROGUI_ZoneOp.h [deleted file]
src/HYDROGUI/resources/HYDROGUI_msg_en.ts
src/HYDROPy/HYDROData.sip
src/HYDROPy/HYDROData_ArtificialObject.sip [new file with mode: 0644]
src/HYDROPy/HYDROData_Bathymetry.sip
src/HYDROPy/HYDROData_Calculation.sip
src/HYDROPy/HYDROData_Document.sip
src/HYDROPy/HYDROData_Domain.sip [deleted file]
src/HYDROPy/HYDROData_Entity.sip [new file with mode: 0644]
src/HYDROPy/HYDROData_Image.sip
src/HYDROPy/HYDROData_ImmersibleZone.sip [new file with mode: 0644]
src/HYDROPy/HYDROData_NaturalObject.sip [new file with mode: 0644]
src/HYDROPy/HYDROData_Object.sip
src/HYDROPy/HYDROData_Polyline.sip
src/HYDROPy/HYDROData_Region.sip
src/HYDROPy/HYDROData_Zone.sip
src/HYDROPy/HYDROPy.vcproj

index fed28edf8d0a4f858c3241a3e17a87bb6805212d..5e96806857217798c6a03ac9c85e947800d1a181 100644 (file)
@@ -1,42 +1,50 @@
 include(../../CMake/Common.cmake)
 
-set(PROJECT_HEADERS 
+set(PROJECT_HEADERS
     HYDROData.h
     HYDROData_Application.h
+    HYDROData_ArtificialObject.h
     HYDROData_Bathymetry.h
+    HYDROData_BSplineOperation.h
     HYDROData_Calculation.h
     HYDROData_Document.h
-    HYDROData_Domain.h
+    HYDROData_Entity.h
     HYDROData_Image.h
+    HYDROData_ImmersibleZone.h
     HYDROData_Iterator.h
     HYDROData_Lambert93.h
+    HYDROData_NaturalObject.h
     HYDROData_Object.h
+    HYDROData_OperationsFactory.h
     HYDROData_Polyline.h
     HYDROData_Region.h
+    HYDROData_SplitToZonesTool.h
     HYDROData_Tool.h
     HYDROData_VisualState.h
     HYDROData_Zone.h
-    HYDROOperations_BSpline.h
-    HYDROOperations_Factory.h
 )
 
 set(PROJECT_SOURCES 
     HYDROData_Application.cxx
+    HYDROData_ArtificialObject.cxx
     HYDROData_Bathymetry.cxx
+    HYDROData_BSplineOperation.cxx
     HYDROData_Calculation.cxx
     HYDROData_Document.cxx
-    HYDROData_Domain.cxx
+    HYDROData_Entity.cxx
     HYDROData_Image.cxx
+    HYDROData_ImmersibleZone.cxx
     HYDROData_Iterator.cxx
     HYDROData_Lambert93.cxx
+    HYDROData_NaturalObject.cxx
     HYDROData_Object.cxx
+    HYDROData_OperationsFactory.cxx
     HYDROData_Polyline.cxx
     HYDROData_Region.cxx
+    HYDROData_SplitToZonesTool.cxx
     HYDROData_Tool.cxx
     HYDROData_VisualState.cxx
     HYDROData_Zone.cxx
-    HYDROOperations_BSpline.cxx
-    HYDROOperations_Factory.cxx
 )
 
 add_definitions(
@@ -69,8 +77,8 @@ if(CPPUNIT_IS_OK)
     test_HYDROData_Polyline.h
     test_HYDROData_Bathymetry.h
     test_HYDROData_Calculation.h
-    test_HYDROOperations_BSpline.h
-    test_HYDROOperations_Factory.h
+    test_HYDROData_BSplineOperation.h
+    test_HYDROData_OperationsFactory.h
   )
 
   set(TEST_SOURCES 
@@ -82,8 +90,8 @@ if(CPPUNIT_IS_OK)
     test_HYDROData_Polyline.cxx
     test_HYDROData_Bathymetry.cxx
     test_HYDROData_Calculation.cxx
-    test_HYDROOperations_BSpline.cxx
-    test_HYDROOperations_Factory.cxx
+    test_HYDROData_BSplineOperation.cxx
+    test_HYDROData_OperationsFactory.cxx
   )
   
   set(TEST_EXE test_HYDROData)
index 318ffca1e2fb2f27eacba2de1c0b7a2c448c97c3..1c6c06655f8eda401048189d332a38292c4b0173 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="windows-1251"?>
 <VisualStudioProject
        ProjectType="Visual C++"
-       Version="9,00"
+       Version="9.00"
        Name="HYDROData"
        ProjectGUID="{EB7B7816-4EA0-4E7D-A88A-1417DEB0FC1C}"
        RootNamespace="HYDROData"
                                RelativePath=".\HYDROData_Application.cxx"
                                >
                        </File>
+                       <File
+                               RelativePath=".\HYDROData_ArtificialObject.cxx"
+                               >
+                       </File>
                        <File
                                RelativePath=".\HYDROData_Bathymetry.cxx"
                                >
                                >
                        </File>
                        <File
-                               RelativePath=".\HYDROData_Domain.cxx"
+                               RelativePath=".\HYDROData_Entity.cxx"
                                >
                        </File>
                        <File
                                RelativePath=".\HYDROData_Image.cxx"
                                >
                        </File>
+                       <File
+                               RelativePath=".\HYDROData_ImmersibleZone.cxx"
+                               >
+                       </File>
                        <File
                                RelativePath=".\HYDROData_Iterator.cxx"
                                >
                                RelativePath=".\HYDROData_Lambert93.cxx"
                                >
                        </File>
+                       <File
+                               RelativePath=".\HYDROData_NaturalObject.cxx"
+                               >
+                       </File>
                        <File
                                RelativePath=".\HYDROData_Object.cxx"
                                >
                                </File>
                        </Filter>
                        <Filter
-                               Name="Operations"
+                               Name="Tools"
                                >
                                <File
-                                       RelativePath=".\HYDROOperations_BSpline.cxx"
+                                       RelativePath=".\HYDROData_BSplineOperation.cxx"
+                                       >
+                               </File>
+                               <File
+                                       RelativePath=".\HYDROData_OperationsFactory.cxx"
                                        >
                                </File>
                                <File
-                                       RelativePath=".\HYDROOperations_Factory.cxx"
+                                       RelativePath=".\HYDROData_SplitToZonesTool.cxx"
                                        >
                                </File>
                        </Filter>
                                RelativePath=".\HYDROData_Application.h"
                                >
                        </File>
+                       <File
+                               RelativePath=".\HYDROData_ArtificialObject.h"
+                               >
+                       </File>
                        <File
                                RelativePath=".\HYDROData_Bathymetry.h"
                                >
                                >
                        </File>
                        <File
-                               RelativePath=".\HYDROData_Domain.h"
+                               RelativePath=".\HYDROData_Entity.h"
                                >
                        </File>
                        <File
                                RelativePath=".\HYDROData_Image.h"
                                >
                        </File>
+                       <File
+                               RelativePath=".\HYDROData_ImmersibleZone.h"
+                               >
+                       </File>
                        <File
                                RelativePath=".\HYDROData_Iterator.h"
                                >
                                RelativePath=".\HYDROData_Lambert93.h"
                                >
                        </File>
+                       <File
+                               RelativePath=".\HYDROData_NaturalObject.h"
+                               >
+                       </File>
                        <File
                                RelativePath=".\HYDROData_Object.h"
                                >
                                >
                        </File>
                        <Filter
-                               Name="Operations"
+                               Name="Tools"
                                >
                                <File
-                                       RelativePath=".\HYDROOperations_BSpline.h"
+                                       RelativePath=".\HYDROData_BSplineOperation.h"
+                                       >
+                               </File>
+                               <File
+                                       RelativePath=".\HYDROData_OperationsFactory.h"
                                        >
                                </File>
                                <File
-                                       RelativePath=".\HYDROOperations_Factory.h"
+                                       RelativePath=".\HYDROData_SplitToZonesTool.h"
                                        >
                                </File>
                        </Filter>
diff --git a/src/HYDROData/HYDROData_ArtificialObject.cxx b/src/HYDROData/HYDROData_ArtificialObject.cxx
new file mode 100644 (file)
index 0000000..8a71a5b
--- /dev/null
@@ -0,0 +1,16 @@
+
+#include "HYDROData_ArtificialObject.h"
+
+IMPLEMENT_STANDARD_HANDLE(HYDROData_ArtificialObject,HYDROData_Object)
+IMPLEMENT_STANDARD_RTTIEXT(HYDROData_ArtificialObject,HYDROData_Object)
+
+HYDROData_ArtificialObject::HYDROData_ArtificialObject()
+: HYDROData_Object()
+{
+}
+
+HYDROData_ArtificialObject::~HYDROData_ArtificialObject()
+{
+}
+
+
diff --git a/src/HYDROData/HYDROData_ArtificialObject.h b/src/HYDROData/HYDROData_ArtificialObject.h
new file mode 100644 (file)
index 0000000..34d786b
--- /dev/null
@@ -0,0 +1,42 @@
+
+#ifndef HYDROData_ArtificialObject_HeaderFile
+#define HYDROData_ArtificialObject_HeaderFile
+
+#include <HYDROData_Object.h>
+
+DEFINE_STANDARD_HANDLE(HYDROData_ArtificialObject, HYDROData_Object)
+
+
+/**\class HYDROData_ArtificialObject
+ * \brief The artificial objects are objects created or planned for creation by human.
+ *
+ */
+class HYDROData_ArtificialObject : 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_ArtificialObject);
+
+protected:
+
+  /**
+   * Creates new object in the internal data structure. Use higher level objects 
+   * to create objects with real content.
+   */
+  HYDRODATA_EXPORT HYDROData_ArtificialObject();
+
+  /**
+   * Destructs properties of the object and object itself, removes it from the document.
+   */
+  virtual HYDRODATA_EXPORT ~HYDROData_ArtificialObject();
+};
+
+#endif
diff --git a/src/HYDROData/HYDROData_BSplineOperation.cxx b/src/HYDROData/HYDROData_BSplineOperation.cxx
new file mode 100644 (file)
index 0000000..df0b2e4
--- /dev/null
@@ -0,0 +1,61 @@
+#include<HYDROData_BSplineOperation.h>
+
+#include<TColgp_HArray1OfPnt.hxx>
+#include<GeomAPI_Interpolate.hxx>
+#include<GeomConvert_BSplineCurveToBezierCurve.hxx>
+#include<Geom_BezierCurve.hxx>
+
+HYDROData_BSplineOperation::HYDROData_BSplineOperation(
+  const QList<double>& thePoints,
+  const double theZValue,
+  const bool theIsClosed)
+{
+  // fill array for algorithm by the received coordinates
+  int aLen = thePoints.size() / 2;
+  Handle(TColgp_HArray1OfPnt) aHCurvePoints = new TColgp_HArray1OfPnt (1, aLen);
+  QList<double>::const_iterator aListIter = thePoints.begin();
+  for (int ind = 1; ind <= aLen; ind++) {
+    gp_Pnt aPnt(gp::Origin());
+    aPnt.SetX(*aListIter);
+    aListIter++;
+    aPnt.SetY(*aListIter);
+    aListIter++;
+    aPnt.SetZ(theZValue);
+    aHCurvePoints->SetValue(ind, aPnt);
+  }
+  // compute BSpline
+  GeomAPI_Interpolate aGBC(aHCurvePoints, theIsClosed, gp::Resolution());
+  aGBC.Perform();
+  if (aGBC.IsDone()) {
+    myCurve = aGBC.Curve();
+  }
+}
+
+QPainterPath HYDROData_BSplineOperation::ComputePath() const
+{
+  QPainterPath aResult;
+  if (myCurve.IsNull()) // returns an empty Path if original curve is invalid
+    return aResult;
+  GeomConvert_BSplineCurveToBezierCurve aConverter(myCurve);
+  int a, aNumArcs = aConverter.NbArcs();
+  for(a = 1; a <= aNumArcs; a++) {
+    Handle(Geom_BezierCurve) anArc = aConverter.Arc(a);
+    if (a == 1) { // set a start point
+      gp_Pnt aStart = anArc->StartPoint();
+      aResult.moveTo(aStart.X(), aStart.Y());
+    }
+    gp_Pnt anEnd = anArc->EndPoint();
+    if (anArc->NbPoles() == 3) { // quadric segment in the path (pole 1 is start, pole 3 is end)
+      gp_Pnt aPole = anArc->Pole(2);
+      aResult.quadTo(aPole.X(), aPole.Y(), anEnd.X(), anEnd.Y());
+    } else if (anArc->NbPoles() == 4) { // cubic segment (usually this is used)
+      gp_Pnt aPole1 = anArc->Pole(2);
+      gp_Pnt aPole2 = anArc->Pole(3);
+      aResult.cubicTo(
+        aPole1.X(), aPole1.Y(), aPole2.X(), aPole2.Y(), anEnd.X(), anEnd.Y());
+    } else { // error, another number of poles is not supported
+      return QPainterPath();
+    }
+  }
+  return aResult;
+}
diff --git a/src/HYDROData/HYDROData_BSplineOperation.h b/src/HYDROData/HYDROData_BSplineOperation.h
new file mode 100644 (file)
index 0000000..96be8d0
--- /dev/null
@@ -0,0 +1,40 @@
+#ifndef HYDROData_BSplineOperation_HeaderFile
+#define HYDROData_BSplineOperation_HeaderFile
+
+#include <HYDROData.h>
+#include <QList>
+#include <QPainterPath>
+#include <Geom_BSplineCurve.hxx>
+
+/**\class HYDROData_BSplineOperation
+ *
+ * \brief Allows to work with splines: create, convert to Qt ToolPath.
+ *
+ * Uses GEOM module for creation of BSplines, OCCT algorithms for 
+ * manipulation and conversion.
+ */
+
+class HYDRODATA_EXPORT HYDROData_BSplineOperation
+{
+public:
+
+  //! Creates a spline by list of coordinates: pairs X and Y
+  //! \param thePoints coordinates in format X1, Y1, X2, Y2, etc. must be even number of elements
+  //! \param theZValue constant value of the spline Z coordinate
+  //! \param theIsClosed flag indicating that the result spline should be closed
+  HYDROData_BSplineOperation(const QList<double>& thePoints,
+                          const double theZValue,
+                          const bool theIsClosed);
+  
+  //! Returns the BSpline curve passing through the points
+  //! \returns Null if Computation of BSpline was failed
+  Handle(Geom_BSplineCurve) Curve() const {return myCurve;}
+  
+  //! Performs conversion from BSpline curve to QPainterPath made from Bezier curves
+  //! \returns computed PainterPath, not stored in this class, so calling of this method is not fast
+  QPainterPath ComputePath() const;
+private:
+  Handle(Geom_BSplineCurve) myCurve; ///< resulting BSpline, null if something is wrong
+};
+
+#endif
index 43b2b1056a822638cd6af8667a51e792b8f80809..29ec179c98d3bd39f68ad33b8506f889d816631e 100644 (file)
 #define PYTHON_BATHYMETRY_ID "KIND_BATHYMETRY"
 
 
-IMPLEMENT_STANDARD_HANDLE(HYDROData_Bathymetry, HYDROData_Object)
-IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Bathymetry, HYDROData_Object)
+IMPLEMENT_STANDARD_HANDLE(HYDROData_Bathymetry, HYDROData_Entity)
+IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Bathymetry, HYDROData_Entity)
 
 HYDROData_Bathymetry::HYDROData_Bathymetry()
+: HYDROData_Entity()
 {
 }
 
index 68d08aac30e9df066810065d22255781bbd45d4b..7c60181f1f0a7ff1220ea1d88ebe4104a390dc67 100644 (file)
@@ -2,14 +2,14 @@
 #ifndef HYDROData_Bathymetry_HeaderFile
 #define HYDROData_Bathymetry_HeaderFile
 
-#include <HYDROData_Object.h>
+#include <HYDROData_Entity.h>
 
 class gp_XY;
 class gp_XYZ;
 class QPointF;
 class QFile;
 
-DEFINE_STANDARD_HANDLE(HYDROData_Bathymetry, HYDROData_Object)
+DEFINE_STANDARD_HANDLE(HYDROData_Bathymetry, HYDROData_Entity)
 
 
 /**\class HYDROData_Bathymetry
@@ -17,7 +17,7 @@ DEFINE_STANDARD_HANDLE(HYDROData_Bathymetry, HYDROData_Object)
  *
  * The Bathymetry represents measurement of the altitude of points on the terrain.
  */
-class HYDROData_Bathymetry : public HYDROData_Object
+class HYDROData_Bathymetry : public HYDROData_Entity
 {
 public:
 
@@ -31,7 +31,7 @@ protected:
    */
   enum DataTag
   {
-    DataTag_First = HYDROData_Object::DataTag_First + 100, ///< first tag, to reserve
+    DataTag_First = HYDROData_Entity::DataTag_First + 100, ///< first tag, to reserve
     DataTag_AltitudePoints, ///< altitude points, array of reals
     DataTag_FilePath        ///< bathymetry imported file path
   };
index 9514bcbd5945ca2f2df3295d0979e1f327c3b410..33e91daf957c75ede0b5111e544585a8e8a3cbb3 100644 (file)
@@ -3,20 +3,21 @@
 
 #include "HYDROData_Document.h"
 #include "HYDROData_Iterator.h"
-#include "HYDROData_Polyline.h"
-#include "HYDROData_Zone.h"
+#include "HYDROData_Object.h"
+#include "HYDROData_SplitToZonesTool.h"
 #include "HYDROData_Region.h"
-
-#include <TDataStd_ReferenceList.hxx>
+#include "HYDROData_Tool.h"
+#include "HYDROData_Zone.h"
 
 #include <QStringList>
 
 #define PYTHON_CALCULATION_ID "KIND_CALCULATION"
 
-IMPLEMENT_STANDARD_HANDLE(HYDROData_Calculation, HYDROData_Object)
-IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Calculation, HYDROData_Object)
+IMPLEMENT_STANDARD_HANDLE(HYDROData_Calculation, HYDROData_Entity)
+IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Calculation, HYDROData_Entity)
 
 HYDROData_Calculation::HYDROData_Calculation()
+: HYDROData_Entity()
 {
 }
 
@@ -41,85 +42,141 @@ QStringList HYDROData_Calculation::DumpToPython( MapOfTreatedObjects& theTreated
               .arg( aCalculName ).arg( aCalculName );
   aResList << QString( "" );
 
-  Handle(HYDROData_Polyline) aBoundaryPolyline = GetBoundaryPolyline();
-  setPythonReferenceObject( theTreatedObjects, aResList, aBoundaryPolyline, "SetBoundaryPolyline" );
-  aResList << QString( "" );
-
-  HYDROData_SequenceOfObjects aZones = GetZones();
-  HYDROData_SequenceOfObjects::Iterator anIter( aZones );
+  HYDROData_SequenceOfObjects aGeomObjects = GetGeometryObjects();
+  HYDROData_SequenceOfObjects::Iterator anIter( aGeomObjects );
   for ( ; anIter.More(); anIter.Next() )
   {
-    Handle(HYDROData_Zone) aRefZone =
-      Handle(HYDROData_Zone)::DownCast( anIter.Value() );
-    if ( !aRefZone.IsNull() )
-      setPythonReferenceObject( theTreatedObjects, aResList, aRefZone, "AddZone" );
+    Handle(HYDROData_Object) aRefGeomObj =
+      Handle(HYDROData_Object)::DownCast( anIter.Value() );
+    if ( !aRefGeomObj.IsNull() )
+      setPythonReferenceObject( theTreatedObjects, aResList, aRefGeomObj, "AddGeometryObject" );
   }
   aResList << QString( "" );
 
-  aZones = GetRegions();
-  anIter.Init( aZones );
+  aResList << QString( "%1.SplitGeometryObjects();" ).arg( aCalculName );
+  aResList << QString( "" );
+
+  // Now we restore the regions and zones order
+  HYDROData_SequenceOfObjects aRegions = GetRegions();
+  anIter.Init( aRegions );
   for ( ; anIter.More(); anIter.Next() )
   {
     Handle(HYDROData_Region) aRegion =
       Handle(HYDROData_Region)::DownCast( anIter.Value() );
-    if ( !aRegion.IsNull() )
-      setPythonReferenceObject( theTreatedObjects, aResList, aRegion, "AddRegion" );
+    if ( aRegion.IsNull() )
+      continue;
+
+    QString aRegionName = aRegion->GetName();
+    // TODO
   }
 
   return aResList;
 }
 
-void HYDROData_Calculation::SetBoundaryPolyline( const Handle(HYDROData_Polyline)& thePolyline )
+void HYDROData_Calculation::SplitGeometryObjects()
 {
-  SetReferenceObject( thePolyline, DataTag_BoundaryPolyline );
+  // At first we remove previously created regions
+  RemoveRegions();
+  RemoveChildRegions();
+
+  Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( this );
+  if ( aDocument.IsNull() )
+    return;
+
+  HYDROData_SequenceOfObjects aGeomObjects = GetGeometryObjects();
+  if ( aGeomObjects.IsEmpty() )
+    return;
+
+  HYDROData_SplitToZonesTool::SplitDataList aSplitedZones =
+    HYDROData_SplitToZonesTool::SplitToZones( aGeomObjects );
+  if ( aSplitedZones.isEmpty() )
+    return;
+
+  // Create result regions for case, by default one zone for one region
+  HYDROData_SplitToZonesTool::SplitDataListIterator anIter( aSplitedZones );
+  while( anIter.hasNext() )
+  {
+    const HYDROData_SplitToZonesTool::SplitData& aSplitData = anIter.next();
+
+    // Create new region
+    Handle(HYDROData_Region) aRegion = AddNewRegion();
+    AddRegion( aRegion );
+
+    QString aRegionName = HYDROData_Tool::GenerateObjectName( aDocument, "Region" );
+    aRegion->SetName( aRegionName );
+
+    // Add the zone for region
+    Handle(HYDROData_Zone) aRegionZone = aRegion->AddNewZone();
+    aRegion->AddZone( aRegionZone );
+
+    QString aZoneName = HYDROData_Tool::GenerateObjectName( aDocument, "Zone" );
+    aRegionZone->SetName( aZoneName );
+
+    aRegionZone->SetShape( aSplitData.Face() );
+
+    // Add the reference object for zone
+    for ( int i = 0, n = aSplitData.ObjectNames.length(); i < n; ++i )
+    {
+      const QString& anObjName = aSplitData.ObjectNames.at( i );
+      
+      Handle(HYDROData_Object) aRefObject = Handle(HYDROData_Object)::DownCast(
+        HYDROData_Tool::FindObjectByName( aDocument, anObjName ) );
+      if ( aRefObject.IsNull() )
+        continue;
+
+      aRegionZone->AddGeometryObject( aRefObject );
+    }
+  }
 }
 
-Handle(HYDROData_Polyline) HYDROData_Calculation::GetBoundaryPolyline() const
+int HYDROData_Calculation::NbGeometryObjects() const
 {
-  return Handle(HYDROData_Polyline)::DownCast( 
-           GetReferenceObject( DataTag_BoundaryPolyline ) );
+  return NbReferenceObjects( DataTag_GeometryObject );
 }
 
-void HYDROData_Calculation::RemoveBoundaryPolyline()
+void HYDROData_Calculation::AddGeometryObject( const Handle(HYDROData_Object)& theObject )
 {
-  ClearReferenceObjects( DataTag_BoundaryPolyline );
+  AddReferenceObject( theObject, DataTag_GeometryObject );
 }
 
-int HYDROData_Calculation::NbZones() const
+void HYDROData_Calculation::SetGeometryObject( const int                       theIndex,
+                                               const Handle(HYDROData_Object)& theObject )
 {
-  return NbReferenceObjects( DataTag_Zone );
+  SetReferenceObject( theObject, DataTag_GeometryObject, theIndex );
 }
 
-void HYDROData_Calculation::AddZone( const Handle(HYDROData_Zone)& theZone )
+void HYDROData_Calculation::SetGeometryObjects( const HYDROData_SequenceOfObjects& theObjects )
 {
-  AddReferenceObject( theZone, DataTag_Zone );
+  SetReferenceObjects( theObjects, DataTag_GeometryObject );
 }
 
-void HYDROData_Calculation::SetZone( const int                     theIndex,
-                                     const Handle(HYDROData_Zone)& theZone )
+Handle(HYDROData_Object) HYDROData_Calculation::GetGeometryObject( const int theIndex ) const
 {
-  SetReferenceObject( theZone, DataTag_Zone, theIndex );
+  return Handle(HYDROData_Object)::DownCast( 
+           GetReferenceObject( DataTag_GeometryObject, theIndex ) );
 }
 
-void HYDROData_Calculation::SetZones( const HYDROData_SequenceOfObjects& theZones )
+HYDROData_SequenceOfObjects HYDROData_Calculation::GetGeometryObjects() const
 {
-  SetReferenceObjects( theZones, DataTag_Zone );
+  return GetReferenceObjects( DataTag_GeometryObject );
 }
 
-Handle(HYDROData_Zone) HYDROData_Calculation::GetZone( const int theIndex ) const
+void HYDROData_Calculation::RemoveGeometryObjects()
 {
-  return Handle(HYDROData_Zone)::DownCast( 
-           GetReferenceObject( DataTag_Zone, theIndex ) );
+  ClearReferenceObjects( DataTag_GeometryObject );
 }
 
-HYDROData_SequenceOfObjects HYDROData_Calculation::GetZones() const
+Handle(HYDROData_Region) HYDROData_Calculation::AddNewRegion()
 {
-  return GetReferenceObjects( DataTag_Zone );
+  TDF_Label aNewLab = myLab.FindChild( ChildTag_Region ).NewChild();
+
+  return Handle(HYDROData_Region)::DownCast(
+    HYDROData_Iterator::CreateObject( aNewLab, KIND_REGION ) );
 }
 
-void HYDROData_Calculation::RemoveZones()
+void HYDROData_Calculation::RemoveChildRegions()
 {
-  ClearReferenceObjects( DataTag_Zone );
+  myLab.FindChild( ChildTag_Region ).ForgetAllAttributes( true );
 }
 
 int HYDROData_Calculation::NbRegions() const
@@ -138,6 +195,12 @@ void HYDROData_Calculation::SetRegion( const int                       theIndex,
   SetReferenceObject( theRegion, DataTag_Region, theIndex );
 }
 
+void HYDROData_Calculation::InsertRegion( const int                       theBeforeIndex,
+                                          const Handle(HYDROData_Region)& theRegion )
+{
+  InsertReferenceObject( theRegion, DataTag_Region, theBeforeIndex );
+}
+
 void HYDROData_Calculation::SetRegions( const HYDROData_SequenceOfObjects& theRegions )
 {
   SetReferenceObjects( theRegions, DataTag_Region );
@@ -154,8 +217,20 @@ HYDROData_SequenceOfObjects HYDROData_Calculation::GetRegions() const
   return GetReferenceObjects( DataTag_Region );
 }
 
+void HYDROData_Calculation::RemoveRegion( const Handle(HYDROData_Region)& theRegion )
+{
+  if ( theRegion.IsNull() )
+    return;
+
+  RemoveReferenceObject( theRegion->Label(), DataTag_Region );
+}
+
+void HYDROData_Calculation::RemoveRegion( const int theIndex )
+{
+  RemoveReferenceObject( DataTag_Region, theIndex );
+}
+
 void HYDROData_Calculation::RemoveRegions()
 {
   ClearReferenceObjects( DataTag_Region );
 }
-  
index a5b72c0fdc91155acb03244d23f4ef9bd4b04bde..60acfb8d33286078d6735e5b3b1d54d77f42ab18 100644 (file)
@@ -1,27 +1,21 @@
 
-#ifndef HYDROData_HYDROData_Calculation
-#define HYDROData_HYDROData_Calculation
 
-#include <HYDROData_Object.h>
+#ifndef HYDROData_Calculation_HeaderFile
+#define HYDROData_Calculation_HeaderFile
 
-class gp_XY;
-class gp_XYZ;
-class QPointF;
-class QFile;
+#include <HYDROData_Entity.h>
 
-class Handle(HYDROData_Polyline);
-class Handle(HYDROData_Zone);
+class Handle(HYDROData_Object);
 class Handle(HYDROData_Region);
 
-DEFINE_STANDARD_HANDLE(HYDROData_Calculation, HYDROData_Object)
+DEFINE_STANDARD_HANDLE(HYDROData_Calculation, HYDROData_Entity)
 
 
 /**\class HYDROData_Calculation
- * \brief Class that stores/retreives information about the Calculation case.
+ * \brief Calculation case is defined by selection of Geometry objects with or without \93Zone of water\94.
  *
- * Calculation case is defined by selection of Geometry objects with or without \93Zone of water\94
  */
-class HYDROData_Calculation : public HYDROData_Object
+class HYDROData_Calculation : public HYDROData_Entity
 {
 
 protected:
@@ -31,10 +25,18 @@ protected:
    */
   enum DataTag
   {
-    DataTag_First = HYDROData_Object::DataTag_First + 100, ///< first tag, to reserve
-    DataTag_BoundaryPolyline,    ///< reference boundary polyline
-    DataTag_Zone,                ///< reference zones
-    DataTag_Region               ///< reference regions
+    DataTag_First = HYDROData_Entity::DataTag_First + 100, ///< first tag, to reserve
+    DataTag_GeometryObject,   ///< reference geometry objects
+    DataTag_Region            ///< reference regions
+  };
+
+  /**
+   * Enumeration of tags corresponding to the child sub-objects of object.
+   */
+  enum ChildTag
+  {
+    ChildTag_First = HYDROData_Entity::ChildTag_First + 100, ///< first tag, to reserve
+    ChildTag_Region      ///< child regions
   };
 
 public:
@@ -56,91 +58,109 @@ public:
   // Public methods to work with Calculation
 
   /**
-   * Sets boundary polyline for calculation case.
+   * Split reference geometry objects to non-intersected regions.
    */
-  HYDRODATA_EXPORT virtual void SetBoundaryPolyline( const Handle(HYDROData_Polyline)& thePolyline );
+  HYDRODATA_EXPORT virtual void SplitGeometryObjects();
+
 
   /**
-   * Returns boundary polyline of calculation case.
+   * Returns number of geometry objects for calculation case.
    */
-  HYDRODATA_EXPORT virtual Handle(HYDROData_Polyline) GetBoundaryPolyline() const;
+  HYDRODATA_EXPORT virtual int NbGeometryObjects() const;
 
   /**
-   * Removes boundary polyline of calculation case.
+   * Add new one geometry object for calculation case.
    */
-  HYDRODATA_EXPORT virtual void RemoveBoundaryPolyline();
-
+  HYDRODATA_EXPORT virtual void AddGeometryObject( const Handle(HYDROData_Object)& theObject );
 
   /**
-   * Returns number of refrence zones for calculation case.
+   * Replace the geometry object for calculation case.
    */
-  HYDRODATA_EXPORT virtual int NbZones() const;
+  HYDRODATA_EXPORT virtual void SetGeometryObject( const int                       theIndex,
+                                                   const Handle(HYDROData_Object)& theObject );
 
   /**
-   * Add new one refrence zone for calculation case.
+   * Sets the geometry object for calculation case.
    */
-  HYDRODATA_EXPORT virtual void AddZone( const Handle(HYDROData_Zone)& theZone );
+  HYDRODATA_EXPORT virtual void SetGeometryObjects( const HYDROData_SequenceOfObjects& theObjects );
 
   /**
-   * Replace the refrence zone for calculation case.
+   * Returns geometry object of calculation case by index.
    */
-  HYDRODATA_EXPORT virtual void SetZone( const int                     theIndex,
-                                         const Handle(HYDROData_Zone)& theZone );
+  HYDRODATA_EXPORT virtual Handle(HYDROData_Object) GetGeometryObject( const int theIndex ) const;
 
   /**
-   * Sets the refrence zones for calculation case.
+   * Returns all geometry objects of calculation case.
    */
-  HYDRODATA_EXPORT virtual void SetZones( const HYDROData_SequenceOfObjects& theZones );
+  HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetGeometryObjects() const;
 
   /**
-   * Returns refrence zone of calculation case by index.
+   * Removes all geometry objects from calculation case.
    */
-  HYDRODATA_EXPORT virtual Handle(HYDROData_Zone) GetZone( const int theIndex ) const;
+  HYDRODATA_EXPORT virtual void RemoveGeometryObjects();
+
 
   /**
-   * Returns all refrence zone of calculation case.
+   * Add new one region for calculation case.
+   * The new region is not added into the list of reference regions.
    */
-  HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetZones() const;
+  HYDRODATA_EXPORT virtual Handle(HYDROData_Region) AddNewRegion();
 
   /**
-   * Removes all refrence zone of calculation case.
+   * Removes all child regions from calculation case.
    */
-  HYDRODATA_EXPORT virtual void RemoveZones();
+  HYDRODATA_EXPORT virtual void RemoveChildRegions();
 
 
   /**
-   * Returns number of regions for calculation case.
+   * Returns number of reference regions of calculation case.
    */
-  HYDRODATA_EXPORT virtual int NbRegions() const;
+  int NbRegions() const;
 
   /**
-   * Add new one region for calculation case.
+   * Add new one reference region for calculation case.
    */
   HYDRODATA_EXPORT virtual void AddRegion( const Handle(HYDROData_Region)& theRegion );
 
   /**
-   * Replace the region for calculation case.
+   * Replace the reference region for calculation case.
    */
   HYDRODATA_EXPORT virtual void SetRegion( const int                       theIndex,
                                            const Handle(HYDROData_Region)& theRegion );
 
   /**
-   * Sets the refrence region for calculation case.
+   * Inserts the reference region for calculation case before given index.
+   */
+  HYDRODATA_EXPORT virtual void InsertRegion( const int                       theBeforeIndex,
+                                              const Handle(HYDROData_Region)& theRegion );
+
+  /**
+   * Sets reference regions for calculation case.
    */
   HYDRODATA_EXPORT virtual void SetRegions( const HYDROData_SequenceOfObjects& theRegions );
 
   /**
-   * Returns region of calculation case by index.
+   * Returns reference region of calculation case by index.
    */
   HYDRODATA_EXPORT virtual Handle(HYDROData_Region) GetRegion( const int theIndex ) const;
 
   /**
-   * Returns all regions of calculation case.
+   * Returns all reference regions of calculation case.
    */
   HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetRegions() const;
 
   /**
-   * Removes all regions of calculation case.
+   * Removes reference region from calculation case.
+   */
+  HYDRODATA_EXPORT virtual void RemoveRegion( const Handle(HYDROData_Region)& theRegion );
+
+  /**
+   * Removes reference region from calculation case by it index.
+   */
+  HYDRODATA_EXPORT virtual void RemoveRegion( const int theIndex );
+
+  /**
+   * Removes all reference regions from calculation case.
    */
   HYDRODATA_EXPORT virtual void RemoveRegions();
 
index 7c43e53ead4cf8bd2d402453862cfa801e5f1644..43ce2a1fecf84593123eb7aca3b570a8aa62996d 100644 (file)
@@ -38,7 +38,7 @@ Handle(HYDROData_Document) HYDROData_Document::Document(const int theStudyID)
 }
 
 Handle(HYDROData_Document) HYDROData_Document::Document(
-  const Handle(HYDROData_Object)& theObject )
+  const Handle(HYDROData_Entity)& theObject )
 {
   Handle(HYDROData_Document) aResDoc;
   if ( theObject.IsNull() )
@@ -197,7 +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_ZONE );
+  aRes = aRes && dumpPartitionToPython( aFile, aTreatedObjects, KIND_IMMERSIBLE_ZONE );
   aRes = aRes && dumpPartitionToPython( aFile, aTreatedObjects, KIND_CALCULATION );
 
   return aRes;
@@ -250,7 +250,7 @@ bool HYDROData_Document::dumpPartitionToPython( QFile&               theFile,
   HYDROData_Iterator anIterator( this, theObjectKind );
   for( ; anIterator.More(); anIterator.Next() )
   {
-    Handle(HYDROData_Object) anObject = anIterator.Current();
+    Handle(HYDROData_Entity) anObject = anIterator.Current();
     if ( anObject.IsNull() )
       continue;
 
@@ -352,7 +352,7 @@ void HYDROData_Document::Redo()
   myTransactionsAfterSave++;
 }
 
-Handle_HYDROData_Object HYDROData_Document::CreateObject(const ObjectKind theKind)
+Handle(HYDROData_Entity) HYDROData_Document::CreateObject(const ObjectKind theKind)
 {
   return HYDROData_Iterator::CreateObject(this, theKind);
 }
index 0701b884e9a353675ccc8c7a4ac8c8d57fb99f22..a702b03c52f8d45e81ca764a49e2fea297ecca5a 100644 (file)
@@ -2,7 +2,7 @@
 #define HYDROData_Document_HeaderFile
 
 #include <HYDROData.h>
-#include <HYDROData_Object.h>
+#include <HYDROData_Entity.h>
 
 #include <TDocStd_Document.hxx>
 
@@ -43,7 +43,7 @@ public:
 
   //! Returns the document by object
   HYDRODATA_EXPORT static Handle(HYDROData_Document) Document( 
-    const Handle(HYDROData_Object)& theObject );
+    const Handle(HYDROData_Entity)& theObject );
 
   //! Returns true if data model contains document for this study
   HYDRODATA_EXPORT static bool HasDocument(const int theStudyID);
@@ -110,7 +110,7 @@ public:
   //! Creates and locates in the document a new object
   //! \param theKind kind of the created object, can not be UNKNOWN
   //! \returns the created object
-  HYDRODATA_EXPORT Handle_HYDROData_Object CreateObject(const ObjectKind theKind);
+  HYDRODATA_EXPORT Handle(HYDROData_Entity) CreateObject(const ObjectKind theKind);
 
 protected:
 
diff --git a/src/HYDROData/HYDROData_Domain.cxx b/src/HYDROData/HYDROData_Domain.cxx
deleted file mode 100644 (file)
index 8491c19..0000000
+++ /dev/null
@@ -1,128 +0,0 @@
-
-#include "HYDROData_Domain.h"
-
-#include "HYDROData_Bathymetry.h"
-#include "HYDROData_Document.h"
-#include "HYDROData_Iterator.h"
-
-#include <TDataStd_IntegerArray.hxx>
-
-#include <QColor>
-#include <QStringList>
-
-IMPLEMENT_STANDARD_HANDLE(HYDROData_Domain, HYDROData_Object)
-IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Domain, HYDROData_Object)
-
-HYDROData_Domain::HYDROData_Domain()
-{
-}
-
-HYDROData_Domain::~HYDROData_Domain()
-{
-}
-
-QStringList HYDROData_Domain::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const
-{
-  QStringList aResList;
-
-  Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( this );
-  if ( aDocument.IsNull() )
-    return aResList;
-
-  QString aDocName = aDocument->GetDocPyName();
-  QString aZoneName = GetName();
-
-  aResList << QString( "%1 = %2.CreateObject( %3 );" )
-              .arg( aZoneName ).arg( aDocName ).arg( getPythonKindId() );
-  aResList << QString( "%1.SetName( \"%2\" );" )
-              .arg( aZoneName ).arg( aZoneName );
-  aResList << QString( "" );
-
-  QColor aFillingColor = GetFillingColor();
-  aResList << QString( "filling_color = QColor( %1, %2, %3, %4 );" )
-              .arg( aFillingColor.red()  ).arg( aFillingColor.green() )
-              .arg( aFillingColor.blue() ).arg( aFillingColor.alpha() );
-  aResList << QString( "%1.SetFillingColor( filling_color );" ).arg( aZoneName );
-  aResList << QString( "" );
-
-  QColor aBorderColor = GetBorderColor();
-  aResList << QString( "border_color = QColor( %1, %2, %3, %4 );" )
-              .arg( aBorderColor.red()  ).arg( aBorderColor.green() )
-              .arg( aBorderColor.blue() ).arg( aBorderColor.alpha() );
-  aResList << QString( "%1.SetBorderColor( border_color );" ).arg( aZoneName );
-  aResList << QString( "" );
-
-  HYDROData_SequenceOfObjects aZoneBaths = GetBathymetries();
-  HYDROData_SequenceOfObjects::Iterator aBathsIter( aZoneBaths );
-  for ( ; aBathsIter.More(); aBathsIter.Next() )
-  {
-    Handle(HYDROData_Bathymetry) aRefBath =
-      Handle(HYDROData_Bathymetry)::DownCast( aBathsIter.Value() );
-    if ( !aRefBath.IsNull() )
-      setPythonReferenceObject( theTreatedObjects, aResList, aRefBath, "AddBathymetry" );
-  }
-
-  return aResList;
-}
-
-QColor HYDROData_Domain::DefaultFillingColor()
-{
-  return QColor( Qt::green );
-}
-
-void HYDROData_Domain::SetFillingColor( const QColor& theColor )
-{
-  return SetColor( theColor, DataTag_FillingColor );
-}
-
-QColor HYDROData_Domain::GetFillingColor() const
-{
-  return GetColor( DefaultFillingColor(), DataTag_FillingColor );
-}
-
-QColor HYDROData_Domain::DefaultBorderColor()
-{
-  return QColor( Qt::transparent );
-}
-
-void HYDROData_Domain::SetBorderColor( const QColor& theColor )
-{
-  return SetColor( theColor, DataTag_BorderColor );
-}
-
-QColor HYDROData_Domain::GetBorderColor() const
-{
-  return GetColor( DefaultBorderColor(), DataTag_BorderColor );
-}
-
-int HYDROData_Domain::NbBathymetries() const
-{
-  return NbReferenceObjects( DataTag_Bathymetry );
-}
-
-void HYDROData_Domain::AddBathymetry( const Handle(HYDROData_Bathymetry)& theBathymetry )
-{
-  AddReferenceObject( theBathymetry, DataTag_Bathymetry );
-}
-
-void HYDROData_Domain::SetBathymetry( const int                           theIndex,
-                                    const Handle(HYDROData_Bathymetry)& theBathymetry )
-{
-  SetReferenceObject( theBathymetry, DataTag_Bathymetry, theIndex );
-}
-
-Handle(HYDROData_Bathymetry) HYDROData_Domain::GetBathymetry( const int theIndex ) const
-{
-  return Handle(HYDROData_Bathymetry)::DownCast( 
-           GetReferenceObject( DataTag_Bathymetry, theIndex ) );
-}
-
-HYDROData_SequenceOfObjects HYDROData_Domain::GetBathymetries() const
-{
-  return GetReferenceObjects( DataTag_Bathymetry );
-}
-
-void HYDROData_Domain::RemoveBathymetries()
-{
-  ClearReferenceObjects( DataTag_Bathymetry );
-}
diff --git a/src/HYDROData/HYDROData_Domain.h b/src/HYDROData/HYDROData_Domain.h
deleted file mode 100644 (file)
index ac1a910..0000000
+++ /dev/null
@@ -1,144 +0,0 @@
-
-#ifndef HYDROData_Domain_HeaderFile
-#define HYDROData_Domain_HeaderFile
-
-#include <HYDROData_Object.h>
-
-#include <TopoDS_Face.hxx>
-
-#include <QPointF>
-#include <QList>
-
-class Handle(HYDROData_Bathymetry);
-
-DEFINE_STANDARD_HANDLE(HYDROData_Domain, HYDROData_Object)
-
-
-/**\class HYDROData_Domain
- * \brief Class that stores/retreives information about the 2d surface.
- */
-class HYDROData_Domain : 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_FillingColor, ///< filling color of zone
-    DataTag_BorderColor,  ///< border color of zone
-  };
-
-public:
-  DEFINE_STANDARD_RTTI(HYDROData_Domain);
-
-  /**
-   * Returns the kind of this object. Must be redefined in all objects of known type.
-   */
-  HYDRODATA_EXPORT virtual const ObjectKind GetKind() const = 0;
-
-  /**
-   * Dump object to Python script representation.
-   */
-  HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
-
-
-  /**
-   * Returns default filling color for new zone.
-   */
-  HYDRODATA_EXPORT static QColor DefaultFillingColor();
-
-  /**
-   * Sets filling color for zone.
-   */
-  HYDRODATA_EXPORT virtual void SetFillingColor( const QColor& theColor );
-
-  /**
-   * Returns filling color of zone.
-   */
-  HYDRODATA_EXPORT virtual QColor GetFillingColor() const;
-
-
-  /**
-   * Returns default border color for new zone.
-   */
-  HYDRODATA_EXPORT static QColor DefaultBorderColor();
-
-  /**
-   * Sets border color for zone.
-   */
-  HYDRODATA_EXPORT virtual void SetBorderColor( const QColor& theColor );
-
-  /**
-   * Returns border color of zone.
-   */
-  HYDRODATA_EXPORT virtual QColor GetBorderColor() const;
-
-
-  /**
-   * 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 shape of the the object.
-   */
-  HYDRODATA_EXPORT virtual TopoDS_Face Face() const = 0;
-
-protected:
-
-  friend class HYDROData_Iterator;
-
-  /**
-   * Creates new object in the internal data structure. Use higher level objects 
-   * to create objects with real content.
-   */
-  HYDROData_Domain();
-
-  /**
-   * Destructs properties of the object and object itself, removes it from the document.
-   */
-  ~HYDROData_Domain();
-
-  /**
-   * Returns id for creation of object in python scripting.
-   */
-  virtual QString getPythonKindId() const = 0;
-};
-
-#endif
diff --git a/src/HYDROData/HYDROData_Entity.cxx b/src/HYDROData/HYDROData_Entity.cxx
new file mode 100644 (file)
index 0000000..be8a51e
--- /dev/null
@@ -0,0 +1,392 @@
+
+#include "HYDROData_Entity.h"
+
+#include "HYDROData_Iterator.h"
+
+#include <TDataStd_Name.hxx>
+#include <TDataStd_ByteArray.hxx>
+#include <TDataStd_UAttribute.hxx>
+#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 <QColor>
+#include <QString>
+#include <QStringList>
+#include <QVariant>
+
+IMPLEMENT_STANDARD_HANDLE(HYDROData_Entity,MMgt_TShared)
+IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Entity,MMgt_TShared)
+
+// is equal function for unique object mapping
+bool IsEqual(const Handle_HYDROData_Entity& theObj1, const Handle_HYDROData_Entity& theObj2)
+{
+  if ( !theObj1.IsNull() && !theObj2.IsNull() )
+    return theObj1->ID() == theObj2->ID();
+  return false;
+}
+
+QString HYDROData_Entity::GetName() const
+{
+  Handle(TDataStd_Name) aName;
+  if (myLab.FindAttribute(TDataStd_Name::GetID(), aName)) {
+    TCollection_AsciiString aStr(aName->Get());
+    return QString(aStr.ToCString());
+  }
+  return QString();
+}
+
+void HYDROData_Entity::SetName(const QString& theName)
+{
+  TDataStd_Name::Set(myLab, TCollection_ExtendedString(theName.toLatin1().constData()));
+}
+
+QStringList HYDROData_Entity::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const
+{
+  QStringList anEmptyList;
+  return anEmptyList;
+}
+
+void HYDROData_Entity::Update( const bool theIsForce )
+{
+}
+
+QVariant HYDROData_Entity::GetDataVariant()
+{
+  return QVariant();
+}
+
+bool HYDROData_Entity::IsRemoved() const
+{
+  return !myLab.HasAttribute();
+}
+
+void HYDROData_Entity::Remove()
+{
+  return myLab.ForgetAllAttributes( true );
+}
+
+HYDROData_Entity::HYDROData_Entity()
+{
+}
+
+HYDROData_Entity::~HYDROData_Entity()
+{
+}
+
+void HYDROData_Entity::CopyTo(Handle_HYDROData_Entity theDestination) const
+{
+  TDF_CopyLabel aCopy(myLab, theDestination->Label());
+  aCopy.Perform();
+}
+
+void HYDROData_Entity::SetLabel(TDF_Label theLabel)
+{
+  myLab = theLabel;
+}
+
+void HYDROData_Entity::SaveByteArray(const int theTag, 
+  const char* theData, const int theLen)
+{
+  TDF_Label aLab = theTag == 0 ? myLab : myLab.FindChild(theTag);
+  // array is empty, remove the attribute
+  if (theLen <= 0) {
+    aLab.ForgetAttribute(TDataStd_ByteArray::GetID());
+    return;
+  }
+  // store data of image in byte array
+  Handle(TDataStd_ByteArray) aData;
+  if (!aLab.FindAttribute(TDataStd_ByteArray::GetID(), aData)) {
+    aData = TDataStd_ByteArray::Set(aLab, 1, theLen);
+  }
+  // copy bytes one by one
+  if (aData->Length() != theLen) {
+    Handle(TColStd_HArray1OfByte) aNewData = new TColStd_HArray1OfByte(1, theLen);
+    for(int a = 0; a < theLen; a++)
+      aNewData->SetValue(a + 1, theData[a]);
+    aData->ChangeArray(aNewData);
+  } else {
+    for(int a = 0; a < theLen; a++)
+      aData->SetValue(a + 1, theData[a]);
+  }
+}
+
+const char* HYDROData_Entity::ByteArray(const int theTag, int& theLen) const
+{
+  TDF_Label aLab = theTag == 0 ? myLab : myLab.FindChild(theTag);
+  Handle(TDataStd_ByteArray) aData;
+  if (!aLab.FindAttribute(TDataStd_ByteArray::GetID(), aData))
+    return NULL; // return empty image if there is no array
+  theLen = aData->Length();
+  if (theLen)
+    return (const char*)(&(aData->InternalArray()->ChangeArray1().ChangeValue(1)));
+  return NULL;
+}
+
+int HYDROData_Entity::NbReferenceObjects( const int theTag ) const
+{
+  Handle(TDataStd_ReferenceList) aRefs = getReferenceList( theTag, false );
+  return aRefs.IsNull() ? 0 : aRefs->Extent();
+}
+
+void HYDROData_Entity::AddReferenceObject( const Handle_HYDROData_Entity& theObj,
+                                           const int                      theTag )
+{
+  if ( theObj.IsNull() )
+    return;
+
+  Handle(TDataStd_ReferenceList) aRefs = getReferenceList( theTag, true );
+  aRefs->Append( theObj->Label() );
+}
+
+void HYDROData_Entity::SetReferenceObject( const Handle_HYDROData_Entity& theObj,
+                                           const int                      theTag,
+                                           const int                      theIndex )
+{
+  if ( theObj.IsNull() )
+  {
+    RemoveReferenceObject( theTag, theIndex );
+    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_Entity) 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() );
+  }
+}
+
+void HYDROData_Entity::InsertReferenceObject( const Handle_HYDROData_Entity& theObj,
+                                              const int                      theTag,
+                                              const int                      theBeforeIndex )
+{
+  if ( theObj.IsNull() )
+    return;
+
+  Handle(TDataStd_ReferenceList) aRefs = getReferenceList( theTag, true );
+
+  if ( theBeforeIndex >= aRefs->Extent() )
+  {
+    aRefs->Append( theObj->Label() );
+  }
+  else if ( theBeforeIndex < 0 )
+  {
+    aRefs->Prepend( theObj->Label() );
+  }
+  else
+  {
+    Handle(HYDROData_Entity) aBeforeObj = GetReferenceObject( theTag, theBeforeIndex );
+    if ( !aBeforeObj.IsNull() )
+      aRefs->InsertBefore( theObj->Label(), aBeforeObj->Label() );
+    else 
+      aRefs->Append( theObj->Label() );
+  }
+}
+
+void HYDROData_Entity::SetReferenceObjects( const HYDROData_SequenceOfObjects& theObjects,
+                                            const int                          theTag )
+{
+  ClearReferenceObjects( theTag );
+  if ( theObjects.IsEmpty() )
+    return;
+
+  HYDROData_SequenceOfObjects::Iterator anIter( theObjects );
+  for ( ; anIter.More(); anIter.Next() )
+    AddReferenceObject( anIter.Value(), theTag );
+}
+
+Handle(HYDROData_Entity) HYDROData_Entity::GetReferenceObject( const int theTag,
+                                                               const int theIndex ) const
+{
+  Handle(HYDROData_Entity) 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_Entity::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_Entity) aRefObject = HYDROData_Iterator::Object( aRefLabel );
+    if ( aRefObject.IsNull() )
+      continue;
+
+    aRes.Append( aRefObject );
+  }
+
+  return aRes;
+}
+
+void HYDROData_Entity::RemoveReferenceObject( const TDF_Label& theRefLabel,
+                                              const int        theTag )
+{
+  Handle(TDataStd_ReferenceList) aRefs = getReferenceList( theTag, false );
+  if ( aRefs.IsNull() )
+    return;
+
+  if ( aRefs->Extent() == 1 )
+  { 
+    // remove all if only one
+    ClearReferenceObjects( theTag );
+    return;
+  }
+
+  aRefs->Remove( theRefLabel );
+}
+
+void HYDROData_Entity::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;
+  }
+
+  int anIndex = 0;
+  TDF_ListIteratorOfLabelList anIter( aRefs->List() );
+  for ( ; anIndex != theIndex && anIter.More(); anIter.Next(), ++anIndex );
+
+  if ( anIndex != theIndex || !anIter.More() )
+    return;
+
+  const TDF_Label& aRefLabel = anIter.Value();
+  aRefs->Remove( aRefLabel );
+}
+
+void HYDROData_Entity::ClearReferenceObjects( const int theTag )
+{
+  TDF_Label aSetLabel = theTag == 0 ? myLab : myLab.FindChild( theTag );
+  aSetLabel.ForgetAttribute( TDataStd_ReferenceList::GetID() );
+}
+
+Handle(TDataStd_ReferenceList) HYDROData_Entity::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;
+}
+
+void HYDROData_Entity::SetColor( const QColor& theColor,
+                                 const int     theTag )
+{
+  TDF_Label aLabel = theTag == 0 ? myLab : myLab.FindChild( theTag );
+
+  Handle(TDataStd_IntegerArray) aColorArray;
+  if ( !aLabel.FindAttribute( TDataStd_IntegerArray::GetID(), aColorArray ) )
+    aColorArray = TDataStd_IntegerArray::Set( aLabel, 1, 4 );
+
+  aColorArray->SetValue( 1, theColor.red()   );
+  aColorArray->SetValue( 2, theColor.green() );
+  aColorArray->SetValue( 3, theColor.blue()  );
+  aColorArray->SetValue( 4, theColor.alpha() );
+}
+
+QColor HYDROData_Entity::GetColor( const QColor& theDefColor,
+                                   const int     theTag ) const
+{
+  QColor aResColor = theDefColor;
+
+  TDF_Label aLabel = theTag == 0 ? myLab : myLab.FindChild( theTag );
+
+  Handle(TDataStd_IntegerArray) aColorArray;
+  if ( aLabel.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_Entity::setPythonReferenceObject( MapOfTreatedObjects&            theTreatedObjects,
+                                                 QStringList&                    theScript,
+                                                 const Handle(HYDROData_Entity)& theRefObject,
+                                                 const QString&                  theMethod ) const
+{
+  if ( theRefObject.IsNull() )
+    return;
+
+  QString aRefObjName = theRefObject->GetName();
+  if ( aRefObjName.isEmpty() )
+    return;
+
+  bool anIsToSetObject = true;
+
+  // The definition of reference object must be dumped before this
+  if ( !theTreatedObjects.contains( aRefObjName ) )
+  {
+    // Write definition of reference polyline
+    QStringList aRefObjDump = theRefObject->DumpToPython( theTreatedObjects );
+    if ( ( anIsToSetObject = !aRefObjDump.isEmpty() ) )
+    {
+      QStringList aTmpList = theScript;
+      theScript = aRefObjDump;
+
+      theScript << QString( "" );
+      theScript << aTmpList;
+
+      theTreatedObjects.insert( aRefObjName, theRefObject );
+    }
+  }
+
+  if ( anIsToSetObject )
+  {
+    theScript << QString( "%1.%2( %3 );" )
+                 .arg( GetName() ).arg( theMethod ).arg( aRefObjName );
+  }
+}
+
+
diff --git a/src/HYDROData/HYDROData_Entity.h b/src/HYDROData/HYDROData_Entity.h
new file mode 100644 (file)
index 0000000..ca4ac50
--- /dev/null
@@ -0,0 +1,295 @@
+
+#ifndef HYDROData_Entity_HeaderFile
+#define HYDROData_Entity_HeaderFile
+
+#include "HYDROData.h"
+
+#include <NCollection_Sequence.hxx>
+
+#include <TDF_Label.hxx>
+
+#include <QMap>
+
+class QColor;
+class QString;
+class QVariant;
+class QStringList;
+class Handle(TDataStd_ReferenceList);
+class Handle_HYDROData_Entity;
+
+///! Kind of an object in a document
+typedef int ObjectKind;
+
+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_LAST            = KIND_VISUAL_STATE;
+
+DEFINE_STANDARD_HANDLE(HYDROData_Entity, MMgt_TShared)
+
+typedef QMap<QString,Handle(Standard_Transient)> MapOfTreatedObjects;
+
+typedef NCollection_Sequence<Handle_HYDROData_Entity> HYDROData_SequenceOfObjects;
+
+
+/**\class HYDROData_Entity
+ * \brief Generic class of any object in the data model.
+ *
+ * Interface for getting access to the object that belong to the data model.
+ * Managed by Document. Provides access to the common properties: 
+ * kind of an object, name.
+ */
+class HYDROData_Entity : public MMgt_TShared
+{
+
+protected:
+
+  /**
+   * Enumeration of tags corresponding to the persistent object parameters.
+   */
+  enum DataTag
+  {
+    DataTag_First = 0     ///< first tag, to reserve
+    // ...
+  };
+
+  /**
+   * Enumeration of tags corresponding to the child sub-objects of object.
+   */
+  enum ChildTag
+  {
+    ChildTag_First = 0    ///< first tag, to reserve
+    // ...
+  };
+
+public:
+  DEFINE_STANDARD_RTTI(HYDROData_Entity);
+
+  /**
+   * Returns the kind of this object. Must be redefined in all objects of known type.
+   */
+  HYDRODATA_EXPORT virtual const ObjectKind GetKind() const { return KIND_UNKNOWN; }
+
+  /**
+   * Returns the name of this object.
+   */
+  HYDRODATA_EXPORT QString GetName() const;
+
+  /**
+   * Updates the name of this object.
+   */
+  HYDRODATA_EXPORT void SetName(const QString& theName);
+
+  /**
+   * Dump object to Python script representation.
+   * Base implementation returns empty list,
+   * You should reimplement this function in your derived class if it
+   * has Python API and can be imported/exported from/to Python script.
+   */
+  HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
+
+  /**
+   * Updates object state.
+   * Base implementation dose nothing.
+   * \param theIsForce force reupdating of data object
+   */
+  HYDRODATA_EXPORT virtual void Update( const bool theIsForce = true );
+
+  /**
+   * Returns data of object wrapped to QVariant.
+   * Base implementation returns null value.
+   */
+  HYDRODATA_EXPORT virtual QVariant GetDataVariant();
+
+  /**
+   * Checks is object exists in the data structure.
+   * \returns true is object is not exists in the data model
+   */
+  HYDRODATA_EXPORT bool IsRemoved() const;
+
+  /**
+   * Removes object and it child sub-objects from the data structure.
+   */
+  HYDRODATA_EXPORT virtual void Remove();
+
+  /**
+   * Returns unique integer identifier of the object (may be used for ordering of objects)
+   */
+  HYDRODATA_EXPORT inline int ID() const {return myLab.Tag();}
+
+  /**
+   * Copies all properties of this to the destinated object.
+   * Objects must be the same type.
+   * \param theDestination initialized object (from any document) - target of copying
+   */
+  HYDRODATA_EXPORT void CopyTo(Handle_HYDROData_Entity theDestination) const;
+
+  /**
+   * Returns the label of this object.
+   */
+  HYDRODATA_EXPORT TDF_Label& Label() {return myLab;}
+
+protected:
+
+  friend class HYDROData_Iterator;
+
+  /**
+   * Creates new object in the internal data structure. Use higher level objects 
+   * to create objects with real content.
+   */
+  HYDRODATA_EXPORT HYDROData_Entity();
+
+  /**
+   * Destructs properties of the object and object itself, removes it from the document.
+   */
+  virtual HYDRODATA_EXPORT ~HYDROData_Entity();
+
+  /**
+   * Put the object to the label of the document.
+   * \param theLabel new label of the object
+   */
+  HYDRODATA_EXPORT virtual void SetLabel(TDF_Label theLabel);
+
+  /**
+   * Internal method that used to store the byte array attribute
+   * \param theTag tag of a label to store attribute (for 0 this is myLab)
+   * \param theData pointer to bytes array
+   * \param theLen number of bytes in byte array that must be stored
+   */
+  void SaveByteArray(const int theTag, const char* theData, const int theLen);
+
+  /**
+   * Internal method that used to retreive the content of byte array attribute
+   * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
+   * \param theLen number of bytes in byte array
+   * \returns pointer to the internal data structure wit harray content, 
+   *          or NULL if array size is zero
+   */
+  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_Entity& 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_Entity& theObj,
+                           const int                      theTag = 0,
+                           const int                      theIndex = 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 theBeforeIndex 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 InsertReferenceObject( const Handle_HYDROData_Entity& theObj,
+                              const int                      theTag = 0,
+                              const int                      theBeforeIndex = 0 );
+
+  /**
+   * Internal method that used to store the reference object label attribute
+   * \param theObjects sequence with pointers to reference objects
+   * \param theTag tag of a label to store attribute (for 0 this is myLab)
+   */
+  void SetReferenceObjects( const HYDROData_SequenceOfObjects& theObjects,
+                            const int                          theTag = 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_Entity 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 theRefLabel reference object label to remove
+   * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
+   */
+  void RemoveReferenceObject( const TDF_Label& theRefLabel, const int theTag = 0 );
+
+  /**
+   * 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 );
+
+  /**
+   * Internal method that used to store the color attribute
+   * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
+   * \param theColor color to save
+   */
+  void SetColor( const QColor& theColor, const int theTag = 0 );
+
+  /**
+   * Internal method that used to retreive the color attribute
+   * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
+   * \param theDefColor default color to return if attribute has not been set before
+   */
+  QColor GetColor( const QColor& theDefColor, const int theTag = 0 ) const;
+
+protected:
+
+  void setPythonReferenceObject( MapOfTreatedObjects&            theTreatedObjects,
+                                 QStringList&                    theScript,
+                                 const Handle(HYDROData_Entity)& theRefObject,
+                                 const QString&                  theMethod ) const;
+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
+};
+
+///! Is Equal for HYDROData_Entity mapping
+HYDRODATA_EXPORT bool IsEqual(const Handle_HYDROData_Entity& theObj1, const Handle_HYDROData_Entity& theObj2);
+
+#endif
index 8a94d751075b9b40b1b998b154324aee01b03ce9..ca01c6555c646d0b7083e3a118b7a871688941f8 100644 (file)
@@ -3,7 +3,7 @@
 
 #include "HYDROData_Document.h"
 #include "HYDROData_Tool.h"
-#include "HYDROOperations_Factory.h"
+#include "HYDROData_OperationsFactory.h"
 
 #include <TDataStd_RealArray.hxx>
 #include <TDataStd_ByteArray.hxx>
@@ -24,10 +24,11 @@ static const Standard_GUID GUID_SELF_SPLITTED("997995aa-5c19-40bf-9a60-ab4b70ad0
 
 #define PYTHON_IMAGE_ID "KIND_IMAGE"
 
-IMPLEMENT_STANDARD_HANDLE(HYDROData_Image, HYDROData_Object)
-IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Image, HYDROData_Object)
+IMPLEMENT_STANDARD_HANDLE(HYDROData_Image, HYDROData_Entity)
+IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Image, HYDROData_Entity)
 
 HYDROData_Image::HYDROData_Image()
+: HYDROData_Entity()
 {
 }
 
@@ -126,7 +127,7 @@ QStringList HYDROData_Image::DumpToPython( MapOfTreatedObjects& theTreatedObject
       aResList << QString( "%1.SetOperatorName( \"%2\" );" )
                   .arg( anImageName ).arg( anOperatorName );
 
-      ImageComposer_Operator* anImageOp = HYDROOperations_Factory::Factory()->Operator( this );
+      ImageComposer_Operator* anImageOp = HYDROData_OperationsFactory::Factory()->Operator( this );
       if ( anImageOp )
       {
         // Dump operation arguments
@@ -166,7 +167,7 @@ QStringList HYDROData_Image::DumpToPython( MapOfTreatedObjects& theTreatedObject
 
 void HYDROData_Image::Update( const bool theIsForce )
 {
-  HYDROOperations_Factory* aFactory = HYDROOperations_Factory::Factory();
+  HYDROData_OperationsFactory* aFactory = HYDROData_OperationsFactory::Factory();
 
   // Update image only if there is an operation
   ImageComposer_Operator* anOp = aFactory->Operator( OperatorName() );
@@ -179,7 +180,7 @@ void HYDROData_Image::Update( const bool theIsForce )
     if ( aNbReferences > 0 )
     {
       // First referenced object
-      Handle(HYDROData_Object) aRefObj = Reference( 0 );
+      Handle(HYDROData_Entity) aRefObj = Reference( 0 );
       if ( !aRefObj.IsNull() )
       {
         anObj1 = aRefObj->GetDataVariant();
@@ -195,7 +196,7 @@ void HYDROData_Image::Update( const bool theIsForce )
     if ( aNbReferences > 1 )
     {
       // Second referenced object
-      Handle(HYDROData_Object) aRefObj = Reference( 1 );
+      Handle(HYDROData_Entity) aRefObj = Reference( 1 );
       if ( !aRefObj.IsNull() )
         anObj2 = aRefObj->GetDataVariant();
     }
@@ -399,7 +400,7 @@ int HYDROData_Image::TrsfMode() const
   return 0;
 }
 
-void HYDROData_Image::AppendReference( const Handle(HYDROData_Object)& theReferenced )
+void HYDROData_Image::AppendReference( const Handle(HYDROData_Entity)& theReferenced )
 {
   AddReferenceObject( theReferenced, 0 );
 }
@@ -409,13 +410,13 @@ int HYDROData_Image::NbReferences() const
   return NbReferenceObjects( 0 );
 }
 
-Handle(HYDROData_Object) HYDROData_Image::Reference( const int theIndex ) const
+Handle(HYDROData_Entity) HYDROData_Image::Reference( const int theIndex ) const
 {
   return GetReferenceObject( 0, theIndex );
 }
 
 void HYDROData_Image::ChangeReference(
-    const int theIndex, Handle(HYDROData_Object) theReferenced)
+    const int theIndex, Handle(HYDROData_Entity) theReferenced)
 {
   SetReferenceObject( theReferenced, 0, theIndex );
 }
index ad5984128e3c8c4d3e1d03a28b7a7b0cf6ea8a5b..382cd817c4853c8c78277d8c327dfeaae682f194 100644 (file)
@@ -1,12 +1,13 @@
+
 #ifndef HYDROData_Image_HeaderFile
 #define HYDROData_Image_HeaderFile
 
-#include <HYDROData_Object.h>
+#include <HYDROData_Entity.h>
 
 #include <QImage>
 #include <QTransform>
 
-DEFINE_STANDARD_HANDLE(HYDROData_Image, HYDROData_Object)
+DEFINE_STANDARD_HANDLE(HYDROData_Image, HYDROData_Entity)
 
 /**\class HYDROData_Image
  * \brief Class that stores/retreives information about the image.
@@ -14,7 +15,7 @@ DEFINE_STANDARD_HANDLE(HYDROData_Image, HYDROData_Object)
  * Keeps image as binary array, transformation and other properties
  * of image with correspondent API for forkind wit hthese properties.
  */
-class HYDROData_Image : public HYDROData_Object
+class HYDROData_Image : public HYDROData_Entity
 {
 protected:
   /**
@@ -22,7 +23,7 @@ protected:
    */
   enum DataTag
   {
-    DataTag_First = HYDROData_Object::DataTag_First + 100, ///< first tag, to reserve
+    DataTag_First = HYDROData_Entity::DataTag_First + 100, ///< first tag, to reserve
     DataTag_Operator,    ///< name of the operator that must be executed for image update
     DataTag_TrsfMode,    ///< transformation mode (0 - Lambert93, 1 - Cartesian)
     DataTag_TrsfPoints,  ///< image transformation points (3 input + 3 output lambert + 3 output cartesian)
@@ -156,24 +157,24 @@ public:
    */
   HYDRODATA_EXPORT int TrsfMode() const;
 
-  /**
-   * Appends reference to other object (image or polyline).
-   * \param theReferenced the object referenced by this
-   */
-  HYDRODATA_EXPORT void AppendReference( const Handle(HYDROData_Object)& theReferenced );
-
   /**
    * Returns the number of referenced objects
    * \return zero if there is no references
    */
   HYDRODATA_EXPORT int NbReferences() const;
 
+  /**
+   * Appends reference to other object (image or polyline).
+   * \param theReferenced the object referenced by this
+   */
+  HYDRODATA_EXPORT void AppendReference( const Handle(HYDROData_Entity)& theReferenced );
+
   /**
    * Returns reference by index.
    * \param theIndex number of reference [0; NbReference)
    * \returns the referenced object, or Null if index is invalid
    */
-  HYDRODATA_EXPORT Handle(HYDROData_Object) Reference(const int theIndex) const;
+  HYDRODATA_EXPORT Handle(HYDROData_Entity) Reference(const int theIndex) const;
 
   /**
    * Updates reference by index. If index is one-bigger than \a NbReferences, 
@@ -182,7 +183,7 @@ public:
    * \param theReferenced the object referenced by this
    */
   HYDRODATA_EXPORT void ChangeReference(
-    const int theIndex, Handle(HYDROData_Object) theReferenced);
+    const int theIndex, Handle(HYDROData_Entity) theReferenced);
 
   /**
    * Removes reference by index
diff --git a/src/HYDROData/HYDROData_ImmersibleZone.cxx b/src/HYDROData/HYDROData_ImmersibleZone.cxx
new file mode 100644 (file)
index 0000000..62e34e5
--- /dev/null
@@ -0,0 +1,159 @@
+
+#include "HYDROData_ImmersibleZone.h"
+
+#include "HYDROData_Bathymetry.h"
+#include "HYDROData_Document.h"
+#include "HYDROData_Polyline.h"
+
+#include <BRepBuilderAPI_MakeFace.hxx>
+
+#include <TopoDS.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopoDS_Wire.hxx>
+
+#include <QColor>
+#include <QStringList>
+
+#define PYTHON_IMMERSIBLE_ZONE_ID "KIND_IMMERSIBLE_ZONE"
+
+IMPLEMENT_STANDARD_HANDLE(HYDROData_ImmersibleZone,HYDROData_NaturalObject)
+IMPLEMENT_STANDARD_RTTIEXT(HYDROData_ImmersibleZone,HYDROData_NaturalObject)
+
+
+HYDROData_ImmersibleZone::HYDROData_ImmersibleZone()
+: HYDROData_NaturalObject()
+{
+}
+
+HYDROData_ImmersibleZone::~HYDROData_ImmersibleZone()
+{
+}
+
+QStringList HYDROData_ImmersibleZone::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const
+{
+  QStringList aResList;
+
+  Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( this );
+  if ( aDocument.IsNull() )
+    return aResList;
+
+  QString aDocName = aDocument->GetDocPyName();
+  QString aZoneName = GetName();
+
+  aResList << QString( "%1 = %2.CreateObject( %3 );" )
+              .arg( aZoneName ).arg( aDocName ).arg( PYTHON_IMMERSIBLE_ZONE_ID );
+  aResList << QString( "%1.SetName( \"%2\" );" )
+              .arg( aZoneName ).arg( aZoneName );
+  aResList << QString( "" );
+
+  QColor aFillingColor = GetFillingColor();
+  aResList << QString( "filling_color = QColor( %1, %2, %3, %4 );" )
+              .arg( aFillingColor.red()  ).arg( aFillingColor.green() )
+              .arg( aFillingColor.blue() ).arg( aFillingColor.alpha() );
+  aResList << QString( "%1.SetFillingColor( filling_color );" ).arg( aZoneName );
+  aResList << QString( "" );
+
+  QColor aBorderColor = GetBorderColor();
+  aResList << QString( "border_color = QColor( %1, %2, %3, %4 );" )
+              .arg( aBorderColor.red()  ).arg( aBorderColor.green() )
+              .arg( aBorderColor.blue() ).arg( aBorderColor.alpha() );
+  aResList << QString( "%1.SetBorderColor( border_color );" ).arg( aZoneName );
+  aResList << QString( "" );
+
+  aResList << QString( "" );
+
+  Handle(HYDROData_Bathymetry) aRefBathymetry = GetBathymetry();
+  setPythonReferenceObject( theTreatedObjects, aResList, aRefBathymetry, "SetBathymetry" );
+
+  Handle(HYDROData_Polyline) aRefPolyline = GetPolyline();
+  setPythonReferenceObject( theTreatedObjects, aResList, aRefPolyline, "SetPolyline" );
+
+  return aResList;
+}
+
+TopoDS_Shape HYDROData_ImmersibleZone::GetTopShape() const
+{
+  Handle(HYDROData_Polyline) aPolyline = GetPolyline();
+  if( !aPolyline.IsNull() )
+  {
+    TopoDS_Wire aPolylineWire = TopoDS::Wire( aPolyline->GetTopShape() );
+    if( !aPolylineWire.IsNull() )
+    {
+      BRepBuilderAPI_MakeFace aMakeFace( aPolylineWire, Standard_True );
+      aMakeFace.Build();
+      if( aMakeFace.IsDone() )
+        return aMakeFace.Face();
+    }
+  }
+  return TopoDS_Face();
+}
+
+TopoDS_Shape HYDROData_ImmersibleZone::GetShape3D() const
+{
+  // TODO
+  return getTopShape();
+}
+
+QColor HYDROData_ImmersibleZone::DefaultFillingColor()
+{
+  return QColor( Qt::green );
+}
+
+void HYDROData_ImmersibleZone::SetFillingColor( const QColor& theColor )
+{
+  return SetColor( theColor, DataTag_FillingColor );
+}
+
+QColor HYDROData_ImmersibleZone::GetFillingColor() const
+{
+  return GetColor( DefaultFillingColor(), DataTag_FillingColor );
+}
+
+QColor HYDROData_ImmersibleZone::DefaultBorderColor()
+{
+  return QColor( Qt::transparent );
+}
+
+void HYDROData_ImmersibleZone::SetBorderColor( const QColor& theColor )
+{
+  return SetColor( theColor, DataTag_BorderColor );
+}
+
+QColor HYDROData_ImmersibleZone::GetBorderColor() const
+{
+  return GetColor( DefaultBorderColor(), DataTag_BorderColor );
+}
+
+void HYDROData_ImmersibleZone::SetPolyline( const Handle(HYDROData_Polyline)& thePolyline )
+{
+  SetReferenceObject( thePolyline, DataTag_Polyline );
+}
+
+Handle(HYDROData_Polyline) HYDROData_ImmersibleZone::GetPolyline() const
+{
+  return Handle(HYDROData_Polyline)::DownCast( 
+           GetReferenceObject( DataTag_Polyline ) );
+}
+
+void HYDROData_ImmersibleZone::RemovePolyline()
+{
+  ClearReferenceObjects( DataTag_Polyline );
+}
+
+void HYDROData_ImmersibleZone::SetBathymetry( const Handle(HYDROData_Bathymetry)& theBathymetry )
+{
+  SetReferenceObject( theBathymetry, DataTag_Bathymetry );
+}
+
+Handle(HYDROData_Bathymetry) HYDROData_ImmersibleZone::GetBathymetry() const
+{
+  return Handle(HYDROData_Bathymetry)::DownCast( 
+           GetReferenceObject( DataTag_Bathymetry ) );
+}
+
+void HYDROData_ImmersibleZone::RemoveBathymetry()
+{
+  ClearReferenceObjects( DataTag_Bathymetry );
+}
+
+
diff --git a/src/HYDROData/HYDROData_ImmersibleZone.h b/src/HYDROData/HYDROData_ImmersibleZone.h
new file mode 100644 (file)
index 0000000..883b2fd
--- /dev/null
@@ -0,0 +1,134 @@
+
+#ifndef HYDROData_ImmersibleZone_HeaderFile
+#define HYDROData_ImmersibleZone_HeaderFile
+
+#include <HYDROData_NaturalObject.h>
+
+DEFINE_STANDARD_HANDLE(HYDROData_ImmersibleZone, HYDROData_NaturalObject)
+
+class Handle(HYDROData_Bathymetry);
+class Handle(HYDROData_Polyline);
+
+/**\class HYDROData_ImmersibleZone
+ * \brief 
+ *
+ */
+class HYDROData_ImmersibleZone : public HYDROData_NaturalObject
+{
+protected:
+  /**
+   * Enumeration of tags corresponding to the persistent object parameters.
+   */
+  enum DataTag
+  {
+    DataTag_First = HYDROData_NaturalObject::DataTag_First + 100, ///< first tag, to reserve
+    DataTag_FillingColor, ///< filling color of immersible zone
+    DataTag_BorderColor,  ///< border color of immersible zone
+    DataTag_Polyline,     ///< reference polyline
+    DataTag_Bathymetry,   ///< reference bathymetry
+};
+
+public:
+  DEFINE_STANDARD_RTTI(HYDROData_ImmersibleZone);
+
+  /**
+   * Returns the kind of this object. Must be redefined in all objects of known type.
+   */
+  HYDRODATA_EXPORT virtual const ObjectKind GetKind() const {return KIND_IMMERSIBLE_ZONE;}
+
+  /**
+   * Dump object to Python script representation.
+   */
+  HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
+
+  /**
+   * Returns the top shape of the object.
+   */
+  HYDRODATA_EXPORT virtual TopoDS_Shape GetTopShape() const;
+
+  /**
+   * Returns the 3d shape of the object.
+   */
+  HYDRODATA_EXPORT virtual TopoDS_Shape GetShape3D() const;
+
+
+  /**
+   * Returns default filling color for new zone.
+   */
+  HYDRODATA_EXPORT static QColor DefaultFillingColor();
+
+  /**
+   * Sets filling color for zone.
+   */
+  HYDRODATA_EXPORT virtual void SetFillingColor( const QColor& theColor );
+
+  /**
+   * Returns filling color of zone.
+   */
+  HYDRODATA_EXPORT virtual QColor GetFillingColor() const;
+
+
+  /**
+   * Returns default border color for new zone.
+   */
+  HYDRODATA_EXPORT static QColor DefaultBorderColor();
+
+  /**
+   * Sets border color for zone.
+   */
+  HYDRODATA_EXPORT virtual void SetBorderColor( const QColor& theColor );
+
+  /**
+   * Returns border color of zone.
+   */
+  HYDRODATA_EXPORT virtual QColor GetBorderColor() 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();
+
+
+  /**
+   * Set reference bathymetry object for zone.
+   */
+  HYDRODATA_EXPORT virtual void SetBathymetry( const Handle(HYDROData_Bathymetry)& theBathymetry );
+
+  /**
+   * Returns reference bathymetry object of zone.
+   */
+  HYDRODATA_EXPORT virtual Handle(HYDROData_Bathymetry) GetBathymetry() const;
+
+  /**
+   * Clear the bathymetry object for zone.
+   */
+  HYDRODATA_EXPORT virtual void RemoveBathymetry();
+
+protected:
+
+  friend class HYDROData_Iterator;
+
+  /**
+   * Creates new object in the internal data structure. Use higher level objects 
+   * to create objects with real content.
+   */
+  HYDRODATA_EXPORT HYDROData_ImmersibleZone();
+
+  /**
+   * Destructs properties of the object and object itself, removes it from the document.
+   */
+  virtual HYDRODATA_EXPORT ~HYDROData_ImmersibleZone();
+};
+
+#endif
index 254c530a395517aa1bee745d274ecc4667eadb1b..04ad41dd899879777e00b31caa5b5433f8f47da3 100644 (file)
@@ -1,14 +1,18 @@
-#include <HYDROData_Iterator.h>
 
-#include <HYDROData_Image.h>
-#include <HYDROData_Polyline.h>
-#include <HYDROData_VisualState.h>
-#include <HYDROData_Bathymetry.h>
-#include <HYDROData_Calculation.h>
-#include <HYDROData_Zone.h>
-#include <HYDROData_Region.h>
+#include "HYDROData_Iterator.h"
+
+#include "HYDROData_Bathymetry.h"
+#include "HYDROData_Calculation.h"
+#include "HYDROData_Image.h"
+#include "HYDROData_ImmersibleZone.h"
+#include "HYDROData_Polyline.h"
+#include "HYDROData_VisualState.h"
+#include "HYDROData_Region.h"
+#include "HYDROData_Zone.h"
 
 #include <TDataStd_Name.hxx>
+#include <TDataStd_NamedData.hxx>
+
 #include <NCollection_DataMap.hxx>
 
 //! Returns label by root objects kind and the kind of the object
@@ -28,7 +32,7 @@ void HYDROData_Iterator::Next()
 {
   myIter.Next();
   // omit the properties iteration in case of UNKNOWN kind filtering
-  while(myIter.More() && myIter.Value()->Label().Depth() != 4) 
+  while ( myIter.More() && myIter.Value()->Label().Depth() < 4 )
     myIter.Next();
 }
 
@@ -37,49 +41,77 @@ bool HYDROData_Iterator::More() const
   return myIter.More();
 }
 
-Handle(HYDROData_Object) HYDROData_Iterator::Current()
+Handle(HYDROData_Entity) HYDROData_Iterator::Current()
 {
   return Object(myIter.Value()->Label());
 }
 
-Handle_HYDROData_Object HYDROData_Iterator::CreateObject(
-  Handle(HYDROData_Document) theDoc, ObjectKind theKind)
+Handle(HYDROData_Entity) HYDROData_Iterator::CreateObject(
+  const Handle(HYDROData_Document)& theDoc,
+  const ObjectKind&                 theObjectKind )
+{
+  TDF_Label aNewLab = 
+    GetLabelByKind( theDoc->LabelOfObjects(), theObjectKind ).FindChild( theDoc->NewID() );
+  return CreateObject( aNewLab, theObjectKind );
+}
+
+Handle(HYDROData_Entity) HYDROData_Iterator::CreateObject( TDF_Label&        theNewLabel, 
+                                                           const ObjectKind& theObjectKind )
 {
-  TDF_Label aNewLab = GetLabelByKind(theDoc->LabelOfObjects(), theKind).
-    FindChild(theDoc->NewID());
-  // object exists if there is name attribute
-  TDataStd_Name::Set(aNewLab, TCollection_ExtendedString(""));
-  return Object(aNewLab);
+  // Object exists if there is a name attribute
+  TDataStd_Name::Set( theNewLabel, "" );
+
+  // Store the type of object in data label
+  TDataStd_NamedData::Set( theNewLabel );
+
+  Handle(TDataStd_NamedData) aNamedData;
+  theNewLabel.FindAttribute( TDataStd_NamedData::GetID(), aNamedData );
+  aNamedData->SetInteger( "ObjectKind", theObjectKind );
+
+  return Object( theNewLabel );
 }
 
-Handle_HYDROData_Object HYDROData_Iterator::Object( const TDF_Label theLabel )
+Handle(HYDROData_Entity) HYDROData_Iterator::Object( const TDF_Label theLabel )
 {
-  ObjectKind aKind = theLabel.Father().Tag();
+  ObjectKind aKind = KIND_UNKNOWN;
+
+  // Retrieve the type of object from label
+  Handle(TDataStd_NamedData) aNamedData;
+  if ( theLabel.FindAttribute( TDataStd_NamedData::GetID(), aNamedData ) )
+    aKind = aNamedData->GetInteger( "ObjectKind" );
+
+  if ( aKind == KIND_UNKNOWN )
+    aKind = theLabel.Father().Tag(); // Try to get type from father label
   
-  Handle(HYDROData_Object) aResult;
+  Handle(HYDROData_Entity) aResult;
   switch( aKind )
   {
-  case KIND_IMAGE:
-    aResult = new HYDROData_Image();
-    break;
-  case KIND_POLYLINE:
-    aResult = new HYDROData_Polyline();
-    break;
-  case KIND_VISUAL_STATE:
-    aResult = new HYDROData_VisualState();
-    break;
-  case KIND_BATHYMETRY:
-    aResult = new HYDROData_Bathymetry();
-    break;
-  case KIND_CALCULATION:
-    aResult = new HYDROData_Calculation();
-    break;
-  case KIND_ZONE:
-    aResult = new HYDROData_Zone();
-    break;
-  case KIND_REGION:
-    aResult = new HYDROData_Region();
-    break;
+    case KIND_IMAGE:
+      aResult = new HYDROData_Image();
+      break;
+    case KIND_POLYLINE:
+      aResult = new HYDROData_Polyline();
+      break;
+    case KIND_BATHYMETRY:
+      aResult = new HYDROData_Bathymetry();
+      break;
+    case KIND_IMMERSIBLE_ZONE:
+      aResult = new HYDROData_ImmersibleZone();
+      break;
+    case KIND_CALCULATION:
+      aResult = new HYDROData_Calculation();
+      break;
+    case KIND_REGION:
+      aResult = new HYDROData_Region();
+      break;
+    case KIND_ZONE:
+      aResult = new HYDROData_Zone();
+      break;
+    case KIND_VISUAL_STATE:
+      aResult = new HYDROData_VisualState();
+      break;
+    default:
+      break;
   }
 
   if ( !aResult.IsNull() )
index 746366a64d9d8c230c3cb1d7e45e9bd7671ebe4c..64728dd2c6bc55fb62a9be6b75055d70e1ac0824 100644 (file)
@@ -1,8 +1,8 @@
+
 #ifndef HYDROData_Iterator_HeaderFile
 #define HYDROData_Iterator_HeaderFile
 
-#include <HYDROData_Object.h>
-#include <HYDROData_Document.h>
+#include "HYDROData_Document.h"
 
 #include <TDF_ChildIDIterator.hxx>
 
@@ -37,12 +37,22 @@ public:
   /**
    * Returns the current object of the iterator.
    */
-  HYDRODATA_EXPORT Handle(HYDROData_Object) Current();
+  HYDRODATA_EXPORT Handle(HYDROData_Entity) Current();
+
+public:
+
+  /**
+   * Creates object in the document on the given label
+   * \param theDoc document where object will be located
+   * \param theKind kind of the new object, can not be UNKNOWN
+   */
+  static Handle(HYDROData_Entity) CreateObject( TDF_Label&        theNewLabel, 
+                                                const ObjectKind& theObjectKind );
 
 protected:
 
   friend class HYDROData_Document;
-  friend class HYDROData_Object;
+  friend class HYDROData_Entity;
 
   /**
    * Creates object in the document, call HYDROData_Document method to create 
@@ -50,13 +60,14 @@ protected:
    * \param theDoc document where object will be located
    * \param theKind kind of the new object, can not be UNKNOWN
    */
-  static Handle_HYDROData_Object CreateObject(
-    Handle_HYDROData_Document theDoc, ObjectKind theKind);
+  static Handle(HYDROData_Entity) CreateObject(
+    const Handle(HYDROData_Document)& theDoc,
+    const ObjectKind&                 theObjectKind );
 
   /**
    * Returns object associated to the given label.
    */
-  static Handle_HYDROData_Object Object(const TDF_Label theLabel);
+  static Handle(HYDROData_Entity) Object(const TDF_Label theLabel);
 
   TDF_ChildIDIterator myIter; ///< iterator by the objects in the document
 };
diff --git a/src/HYDROData/HYDROData_NaturalObject.cxx b/src/HYDROData/HYDROData_NaturalObject.cxx
new file mode 100644 (file)
index 0000000..8b482a7
--- /dev/null
@@ -0,0 +1,16 @@
+
+#include "HYDROData_NaturalObject.h"
+
+IMPLEMENT_STANDARD_HANDLE(HYDROData_NaturalObject,HYDROData_Object)
+IMPLEMENT_STANDARD_RTTIEXT(HYDROData_NaturalObject,HYDROData_Object)
+
+HYDROData_NaturalObject::HYDROData_NaturalObject()
+: HYDROData_Object()
+{
+}
+
+HYDROData_NaturalObject::~HYDROData_NaturalObject()
+{
+}
+
+
diff --git a/src/HYDROData/HYDROData_NaturalObject.h b/src/HYDROData/HYDROData_NaturalObject.h
new file mode 100644 (file)
index 0000000..7971180
--- /dev/null
@@ -0,0 +1,42 @@
+
+#ifndef HYDROData_NaturalObject_HeaderFile
+#define HYDROData_NaturalObject_HeaderFile
+
+#include <HYDROData_Object.h>
+
+DEFINE_STANDARD_HANDLE(HYDROData_NaturalObject, HYDROData_Object)
+
+
+/**\class HYDROData_NaturalObject
+ * \brief The natural objects are objects of environment not created by human.
+ *
+ */
+class HYDROData_NaturalObject : 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_NaturalObject);
+
+protected:
+
+  /**
+   * Creates new object in the internal data structure. Use higher level objects 
+   * to create objects with real content.
+   */
+  HYDRODATA_EXPORT HYDROData_NaturalObject();
+
+  /**
+   * Destructs properties of the object and object itself, removes it from the document.
+   */
+  virtual HYDRODATA_EXPORT ~HYDROData_NaturalObject();
+};
+
+#endif
index 2ee9bd7ec4788fab611f7367eaebf3bf9173df72..ee54ec62e3dc52805eb4a832ef155be8b92d0962 100644 (file)
@@ -1,74 +1,16 @@
 
 #include "HYDROData_Object.h"
 
-#include "HYDROData_Iterator.h"
+#include <TNaming_Builder.hxx>
+#include <TNaming_NamedShape.hxx>
 
-#include <TDataStd_Name.hxx>
-#include <TDataStd_ByteArray.hxx>
-#include <TDataStd_UAttribute.hxx>
-#include <TDataStd_IntegerArray.hxx>
-#include <TDataStd_BooleanArray.hxx>
-#include <TDataStd_RealArray.hxx>
-#include <TDataStd_ReferenceList.hxx>
+#include <TopoDS_Shape.hxx>
 
-#include <TDF_CopyLabel.hxx>
-#include <TDF_ListIteratorOfLabelList.hxx>
-
-#include <QColor>
-#include <QString>
-#include <QStringList>
-#include <QVariant>
-
-IMPLEMENT_STANDARD_HANDLE(HYDROData_Object,MMgt_TShared)
-IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Object,MMgt_TShared)
-
-// is equal function for unique object mapping
-bool IsEqual(const Handle_HYDROData_Object& theObj1, const Handle_HYDROData_Object& theObj2)
-{
-  return (theObj1->ID() == theObj2->ID());
-}
-
-QString HYDROData_Object::GetName() const
-{
-  Handle(TDataStd_Name) aName;
-  if (myLab.FindAttribute(TDataStd_Name::GetID(), aName)) {
-    TCollection_AsciiString aStr(aName->Get());
-    return QString(aStr.ToCString());
-  }
-  return QString();
-}
-
-void HYDROData_Object::SetName(const QString& theName)
-{
-  TDataStd_Name::Set(myLab, TCollection_ExtendedString(theName.toLatin1().constData()));
-}
-
-QStringList HYDROData_Object::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const
-{
-  QStringList anEmptyList;
-  return anEmptyList;
-}
-
-void HYDROData_Object::Update( const bool theIsForce )
-{
-}
-
-QVariant HYDROData_Object::GetDataVariant()
-{
-  return QVariant();
-}
-
-bool HYDROData_Object::IsRemoved() const
-{
-  return !myLab.HasAttribute();
-}
-
-void HYDROData_Object::Remove()
-{
-  return myLab.ForgetAllAttributes(Standard_True);
-}
+IMPLEMENT_STANDARD_HANDLE(HYDROData_Object,HYDROData_Entity)
+IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Object,HYDROData_Entity)
 
 HYDROData_Object::HYDROData_Object()
+: HYDROData_Entity()
 {
 }
 
@@ -76,271 +18,31 @@ HYDROData_Object::~HYDROData_Object()
 {
 }
 
-void HYDROData_Object::CopyTo(Handle_HYDROData_Object theDestination) const
-{
-  TDF_CopyLabel aCopy(myLab, theDestination->Label());
-  aCopy.Perform();
-}
-
-void HYDROData_Object::SetLabel(TDF_Label theLabel)
-{
-  myLab = theLabel;
-}
-
-void HYDROData_Object::SaveByteArray(const int theTag, 
-  const char* theData, const int theLen)
-{
-  TDF_Label aLab = theTag == 0 ? myLab : myLab.FindChild(theTag);
-  // array is empty, remove the attribute
-  if (theLen <= 0) {
-    aLab.ForgetAttribute(TDataStd_ByteArray::GetID());
-    return;
-  }
-  // store data of image in byte array
-  Handle(TDataStd_ByteArray) aData;
-  if (!aLab.FindAttribute(TDataStd_ByteArray::GetID(), aData)) {
-    aData = TDataStd_ByteArray::Set(aLab, 1, theLen);
-  }
-  // copy bytes one by one
-  if (aData->Length() != theLen) {
-    Handle(TColStd_HArray1OfByte) aNewData = new TColStd_HArray1OfByte(1, theLen);
-    for(int a = 0; a < theLen; a++)
-      aNewData->SetValue(a + 1, theData[a]);
-    aData->ChangeArray(aNewData);
-  } else {
-    for(int a = 0; a < theLen; a++)
-      aData->SetValue(a + 1, theData[a]);
-  }
-}
-
-const char* HYDROData_Object::ByteArray(const int theTag, int& theLen) const
-{
-  TDF_Label aLab = theTag == 0 ? myLab : myLab.FindChild(theTag);
-  Handle(TDataStd_ByteArray) aData;
-  if (!aLab.FindAttribute(TDataStd_ByteArray::GetID(), aData))
-    return NULL; // return empty image if there is no array
-  theLen = aData->Length();
-  if (theLen)
-    return (const char*)(&(aData->InternalArray()->ChangeArray1().ChangeValue(1)));
-  return NULL;
-}
-
-int HYDROData_Object::NbReferenceObjects( const int theTag ) const
+void HYDROData_Object::SetTopShape( const TopoDS_Shape& theShape )
 {
-  Handle(TDataStd_ReferenceList) aRefs = getReferenceList( theTag, false );
-  return aRefs.IsNull() ? 0 : aRefs->Extent();
+  TNaming_Builder aBuilder( myLab.FindChild( DataTag_TopShape ) );
+  aBuilder.Generated( theShape );
 }
 
-void HYDROData_Object::AddReferenceObject( const Handle_HYDROData_Object& theObj,
-                                           const int                      theTag )
+void HYDROData_Object::SetShape3D( const TopoDS_Shape& theShape )
 {
-  if ( theObj.IsNull() )
-    return;
-
-  Handle(TDataStd_ReferenceList) aRefs = getReferenceList( theTag, true );
-  aRefs->Append( theObj->Label() );
+  TNaming_Builder aBuilder( myLab.FindChild( DataTag_Shape3D ) );
+  aBuilder.Generated( theShape );
 }
 
-void HYDROData_Object::SetReferenceObject( const Handle_HYDROData_Object& theObj,
-                                           const int                      theTag,
-                                           const int                      theIndex )
+TopoDS_Shape HYDROData_Object::getTopShape() const
 {
-  if ( theObj.IsNull() )
-  {
-    RemoveReferenceObject( theTag, theIndex );
-    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(TNaming_NamedShape) aNamedShape;
+  if( myLab.FindChild( DataTag_TopShape ).FindAttribute( TNaming_NamedShape::GetID(), aNamedShape ) )
+    return aNamedShape->Get();
+  return TopoDS_Shape();
 }
 
-void HYDROData_Object::SetReferenceObjects( const HYDROData_SequenceOfObjects& theObjects,
-                                            const int                          theTag )
+TopoDS_Shape HYDROData_Object::getShape3D() const
 {
-  ClearReferenceObjects( theTag );
-  if ( theObjects.IsEmpty() )
-    return;
-
-  HYDROData_SequenceOfObjects::Iterator anIter( theObjects );
-  for ( ; anIter.More(); anIter.Next() )
-    AddReferenceObject( anIter.Value(), theTag );
+  Handle(TNaming_NamedShape) aNamedShape;
+  if( myLab.FindChild( DataTag_Shape3D ).FindAttribute( TNaming_NamedShape::GetID(), aNamedShape ) )
+    return aNamedShape->Get();
+  return TopoDS_Shape();
 }
 
-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;
-  }
-
-  int anIndex = 0;
-  TDF_ListIteratorOfLabelList anIter( aRefs->List() );
-  for ( ; anIndex != theIndex && anIter.More(); anIter.Next(), ++anIndex );
-
-  if ( anIndex != theIndex )
-    return;
-
-  const TDF_Label& aRefLabel = anIter.Value();
-  aRefs->Remove( aRefLabel );
-}
-
-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;
-}
-
-void HYDROData_Object::SetColor( const QColor& theColor,
-                                 const int     theTag )
-{
-  TDF_Label aLabel = theTag == 0 ? myLab : myLab.FindChild( theTag );
-
-  Handle(TDataStd_IntegerArray) aColorArray;
-  if ( !aLabel.FindAttribute( TDataStd_IntegerArray::GetID(), aColorArray ) )
-    aColorArray = TDataStd_IntegerArray::Set( aLabel, 1, 4 );
-
-  aColorArray->SetValue( 1, theColor.red()   );
-  aColorArray->SetValue( 2, theColor.green() );
-  aColorArray->SetValue( 3, theColor.blue()  );
-  aColorArray->SetValue( 4, theColor.alpha() );
-}
-
-QColor HYDROData_Object::GetColor( const QColor& theDefColor,
-                                   const int     theTag ) const
-{
-  QColor aResColor = theDefColor;
-
-  TDF_Label aLabel = theTag == 0 ? myLab : myLab.FindChild( theTag );
-
-  Handle(TDataStd_IntegerArray) aColorArray;
-  if ( aLabel.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_Object::setPythonReferenceObject( MapOfTreatedObjects&            theTreatedObjects,
-                                                 QStringList&                    theScript,
-                                                 const Handle(HYDROData_Object)& theRefObject,
-                                                 const QString&                  theMethod ) const
-{
-  if ( theRefObject.IsNull() )
-    return;
-
-  QString aRefObjName = theRefObject->GetName();
-  if ( aRefObjName.isEmpty() )
-    return;
-
-  bool anIsToSetObject = true;
-
-  // The definition of reference polyline must be dumped before this
-  if ( !theTreatedObjects.contains( aRefObjName ) )
-  {
-    // Write definition of reference polyline
-    QStringList aRefObjDump = theRefObject->DumpToPython( theTreatedObjects );
-    if ( ( anIsToSetObject = !aRefObjDump.isEmpty() ) )
-    {
-      QStringList aTmpList = theScript;
-      theScript = aRefObjDump;
-
-      theScript << QString( "" );
-      theScript << aTmpList;
-
-      theTreatedObjects.insert( aRefObjName, theRefObject );
-    }
-  }
-
-  if ( anIsToSetObject )
-  {
-    theScript << QString( "%1.%2( %3 );" )
-                 .arg( GetName() ).arg( theMethod ).arg( aRefObjName );
-  }
-}
-
-
index e8669db7fecd44428e47d65c15836e6156acc8d2..805b593f34368136435b3052cbd4189787fa1b18 100644 (file)
@@ -1,50 +1,19 @@
+
 #ifndef HYDROData_Object_HeaderFile
 #define HYDROData_Object_HeaderFile
 
-#include <HYDROData.h>
-
-#include <NCollection_Sequence.hxx>
-#include <TDF_Label.hxx>
-#include <QMap>
-
-class QColor;
-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_PROFILE        = 6;
-const ObjectKind KIND_PROFILES_GROUP = 7;
-const ObjectKind KIND_GUIDE_LINE     = 8;
-const ObjectKind KIND_ZONE           = 9;
-const ObjectKind KIND_REGION         = 10;
-const ObjectKind KIND_LAST           = KIND_REGION;
-
-DEFINE_STANDARD_HANDLE(HYDROData_Object, MMgt_TShared)
+#include <HYDROData_Entity.h>
 
-typedef QMap<QString,Handle(Standard_Transient)> MapOfTreatedObjects;
+class TopoDS_Shape;
 
-typedef NCollection_Sequence<Handle_HYDROData_Object> HYDROData_SequenceOfObjects;
+DEFINE_STANDARD_HANDLE(HYDROData_Object, HYDROData_Entity)
 
 
 /**\class HYDROData_Object
- * \brief Generic class of any object in the data model.
+ * \brief The base class for all geometrical objects in the HYDRO module.
  *
- * Interface for getting access to the object that belong to the data model.
- * Managed by Document. Provides access to the common properties: 
- * kind of an object, name.
  */
-class HYDROData_Object : public MMgt_TShared
+class HYDROData_Object : public HYDROData_Entity
 {
 protected:
   /**
@@ -52,81 +21,44 @@ protected:
    */
   enum DataTag
   {
-    DataTag_First = 0     ///< first tag, to reserve
-    // ...
+    DataTag_First = HYDROData_Entity::DataTag_First + 100, ///< first tag, to reserve
+    DataTag_TopShape,
+    DataTag_Shape3D,
   };
 
-public:
-  DEFINE_STANDARD_RTTI(HYDROData_Object);
-
-  /**
-   * Returns the kind of this object. Must be redefined in all objects of known type.
-   */
-  HYDRODATA_EXPORT virtual const ObjectKind GetKind() const {return KIND_UNKNOWN;}
-
-  /**
-   * Returns the name of this object.
-   */
-  HYDRODATA_EXPORT QString GetName() const;
-
   /**
-   * Updates the name of this object.
+   * Enumeration of tags corresponding to the child sub-objects of object.
    */
-  HYDRODATA_EXPORT void SetName(const QString& theName);
-
-  /**
-   * Dump object to Python script representation.
-   * Base implementation returns empty list,
-   * You should reimplement this function in your derived class if it
-   * has Python API and can be imported/exported from/to Python script.
-   */
-  HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
-
-  /**
-   * Updates object state.
-   * Base implementation dose nothing.
-   * \param theIsForce force reupdating of data object
-   */
-  HYDRODATA_EXPORT virtual void Update( const bool theIsForce = true );
-
-  /**
-   * Returns data of object wrapped to QVariant.
-   * Base implementation returns null value.
-   */
-  HYDRODATA_EXPORT virtual QVariant GetDataVariant();
+  enum ChildTag
+  {
+    ChildTag_First = HYDROData_Entity::ChildTag_First + 100, ///< first tag, to reserve
+  };
 
-  /**
-   * Checks is object exists in the data structure.
-   * \returns true is object is not exists in the data model
-   */
-  HYDRODATA_EXPORT bool IsRemoved() const;
+public:
+  DEFINE_STANDARD_RTTI(HYDROData_Object);
 
   /**
-   * Removes object from the data structure.
+   * Sets the top(2d projection) shape of the object.
    */
-  HYDRODATA_EXPORT void Remove();
+  HYDRODATA_EXPORT virtual void SetTopShape( const TopoDS_Shape& theShape );
 
   /**
-   * Returns unique integer identifier of the object (may be used for ordering of objects)
+   * Returns the top shape of the object.
    */
-  HYDRODATA_EXPORT inline int ID() const {return myLab.Tag();}
+  HYDRODATA_EXPORT virtual TopoDS_Shape GetTopShape() const = 0;
 
   /**
-   * Copies all properties of this to the destinated object.
-   * Objects must be the same type.
-   * \param theDestination initialized object (from any document) - target of copying
+   * Sets the 3d shape of the object.
    */
-  HYDRODATA_EXPORT void CopyTo(Handle_HYDROData_Object theDestination) const;
+  HYDRODATA_EXPORT virtual void SetShape3D( const TopoDS_Shape& theShape );
 
   /**
-   * Returns the label of this object.
+   * Returns the 3d shape of the object.
    */
-  HYDRODATA_EXPORT TDF_Label& Label() {return myLab;}
+  HYDRODATA_EXPORT virtual TopoDS_Shape GetShape3D() const = 0;
 
 protected:
 
-  friend class HYDROData_Iterator;
-
   /**
    * Creates new object in the internal data structure. Use higher level objects 
    * to create objects with real content.
@@ -138,124 +70,18 @@ protected:
    */
   virtual HYDRODATA_EXPORT ~HYDROData_Object();
 
-  /**
-   * Put the object to the label of the document.
-   * \param theLabel new label of the object
-   */
-  HYDRODATA_EXPORT virtual void SetLabel(TDF_Label theLabel);
-
-  /**
-   * Internal method that used to store the byte array attribute
-   * \param theTag tag of a label to store attribute (for 0 this is myLab)
-   * \param theData pointer to bytes array
-   * \param theLen number of bytes in byte array that must be stored
-   */
-  void SaveByteArray(const int theTag, const char* theData, const int theLen);
-
-  /**
-   * Internal method that used to retreive the content of byte array attribute
-   * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
-   * \param theLen number of bytes in byte array
-   * \returns pointer to the internal data structure wit harray content, 
-   *          or NULL if array size is zero
-   */
-  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 store the reference object label attribute
-   * \param theObjects sequence with pointers to reference objects
-   * \param theTag tag of a label to store attribute (for 0 this is myLab)
-   */
-  void SetReferenceObjects( const HYDROData_SequenceOfObjects& theObjects,
-                            const int                          theTag = 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:
 
   /**
-   * Internal method that used to store the color attribute
-   * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
-   * \param theColor color to save
+   * Retrieve the top shape of the object from data label.
    */
-  void SetColor( const QColor& theColor, const int theTag = 0 );
+  HYDRODATA_EXPORT TopoDS_Shape getTopShape() const;
 
   /**
-   * Internal method that used to retreive the color attribute
-   * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
-   * \param theDefColor default color to return if attribute has not been set before
+   * Retrieve the 3d shape of the object from data label.
    */
-  QColor GetColor( const QColor& theDefColor, const int theTag = 0 ) const;
+  HYDRODATA_EXPORT TopoDS_Shape getShape3D() const;
 
-protected:
-
-  void setPythonReferenceObject( MapOfTreatedObjects&            theTreatedObjects,
-                                 QStringList&                    theScript,
-                                 const Handle(HYDROData_Object)& theRefObject,
-                                 const QString&                  theMethod ) const;
-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
 };
 
-///! Is Equal for HYDROData_Object mapping
-HYDRODATA_EXPORT bool IsEqual(const Handle_HYDROData_Object& theObj1, const Handle_HYDROData_Object& theObj2);
-
 #endif
diff --git a/src/HYDROData/HYDROData_OperationsFactory.cxx b/src/HYDROData/HYDROData_OperationsFactory.cxx
new file mode 100644 (file)
index 0000000..cd96855
--- /dev/null
@@ -0,0 +1,73 @@
+#include<HYDROData_OperationsFactory.h>
+
+#include<HYDROData_Document.h>
+#include<HYDROData_Iterator.h>
+
+#include<ImageComposer_ColorMaskOperator.h>
+#include<ImageComposer_CropOperator.h>
+#include<ImageComposer_CutOperator.h>
+#include<ImageComposer_FuseOperator.h>
+
+#include <typeinfo>
+
+// global instance
+HYDROData_OperationsFactory* FACTORY = 0;
+
+HYDROData_OperationsFactory* HYDROData_OperationsFactory::Factory()
+{
+  if (!FACTORY) {
+    FACTORY = new HYDROData_OperationsFactory;
+    // default operations
+    REGISTER_HYDRO_OPERATION(ImageComposer_ColorMaskOperator)
+    REGISTER_HYDRO_OPERATION(ImageComposer_CropOperator)
+    REGISTER_HYDRO_OPERATION(ImageComposer_CutOperator)
+    REGISTER_HYDRO_OPERATION(ImageComposer_FuseOperator)
+  }
+  return FACTORY;
+}
+
+void HYDROData_OperationsFactory::Register(
+  ImageComposer_Operator* theOperator)
+{
+  if ( !theOperator )
+    return;
+
+  FACTORY->myOps[ theOperator->name() ] = theOperator;
+}
+
+HYDROData_OperationsFactory::HYDROData_OperationsFactory()
+{
+}
+
+ImageComposer_Operator* HYDROData_OperationsFactory::Operator(
+  Handle(HYDROData_Image) theImage ) const
+{
+  // retreive operator instance by name
+  ImageComposer_Operator* anOp = Operator( theImage->OperatorName() );
+  if ( !anOp )
+    return anOp;
+
+  // fill arguments of the operator from theImage
+  anOp->setBinArgs( theImage->Args() );
+
+  return anOp;
+}
+
+ImageComposer_Operator* HYDROData_OperationsFactory::Operator(const QString theName) const
+{
+  return myOps.contains( theName ) ? myOps[ theName ] : NULL;
+}
+
+Handle(HYDROData_Image) HYDROData_OperationsFactory::CreateImage(
+  Handle(HYDROData_Document) theDoc, const ImageComposer_Operator* theOperator)
+{
+  // create an object
+  Handle(HYDROData_Image) anImage = 
+    Handle(HYDROData_Image)::DownCast(theDoc->CreateObject(KIND_IMAGE));
+  // get data from operation
+  if (theOperator) {
+    anImage->SetOperatorName( theOperator->name() );
+    anImage->SetArgs( theOperator->getBinArgs() );
+  }
+  return anImage;
+}
diff --git a/src/HYDROData/HYDROData_OperationsFactory.h b/src/HYDROData/HYDROData_OperationsFactory.h
new file mode 100644 (file)
index 0000000..5eae036
--- /dev/null
@@ -0,0 +1,83 @@
+#ifndef HYDROData_OperationsFactory_HeaderFile
+#define HYDROData_OperationsFactory_HeaderFile
+
+#include <HYDROData.h>
+#include <HYDROData_Image.h>
+#include <QMap>
+
+class ImageComposer_Operator;
+class Handle_HYDROData_Document;
+
+/**\class HYDROData_OperationsFactory
+ *
+ * \brief This class provides the unified management of operations on images.
+ *
+ * Object is created as one global instance and allows to register and launch
+ * all registered operations in general way. To register a new operation just
+ * call REGISTER_HYDRO_OPERATION(operation_name) in some method implementation.
+ * This macro will call constructor of this operation (it must inherit
+ * ImageComposer_Operator) and factory will set up arguments and call this 
+ * operator by demand.
+ */
+
+class HYDROData_OperationsFactory
+{
+public:
+
+  //! Returns the global factory
+  HYDRODATA_EXPORT static HYDROData_OperationsFactory* Factory();
+  
+  /**
+   * Registers the operator by the name, used by REGISTER_HYDRO_OPERATION macro
+   * \param theOperator new instance of the operator that will be used for
+   *                    processing of operation with such kind
+   */
+  HYDRODATA_EXPORT static void Register(
+    ImageComposer_Operator* theOperator);
+  
+  /**
+   * Creates a new Image object in the data structure by the operator data.
+   * \param theDoc document where it must be created
+   * \param theOperator base operator for this Image: will be used in "Update" to recompute the image
+   * \returns created object related to the data structure
+   */
+  HYDRODATA_EXPORT Handle(HYDROData_Image) CreateImage(
+    Handle_HYDROData_Document theDoc, const ImageComposer_Operator* theOperator);
+
+  /**
+   * Returns the operator, initialized by the properties of theImage
+   * \param theImage data structures object, that contains all arguments 
+   *                 required for creation of operation
+   * \returns NULL if operator type is unknown
+   */
+  HYDRODATA_EXPORT ImageComposer_Operator* Operator(
+    Handle(HYDROData_Image) theImage) const;
+
+  /**
+   * Returns the appropriate operator by the name
+   * \param theName name of the operator, equals to the operation_name constructor
+   * \returns NULL if operator with such name is not registered yet
+   */
+  HYDRODATA_EXPORT ImageComposer_Operator* Operator(const QString theName) const;
+
+protected:
+
+  //! Not public constructor that creates only one, global instance of this factory.
+  HYDROData_OperationsFactory();  
+
+private:
+  //! Map that stores all operators, isentified by strings
+  typedef QMap<QString, ImageComposer_Operator*> FactoryOperators;
+  
+  FactoryOperators myOps; ///< all operators stored by a factory
+};
+
+/**
+ * Macro that is used for registered operators, see C++ of this class to see
+ * example of hte registration.
+ */
+#define REGISTER_HYDRO_OPERATION(operation_name) \
+  HYDROData_OperationsFactory::Factory()->Register(new operation_name);
+
+#endif
index e133ee3e4724c8182ff728408aee34ea3d2a90af..abac653b3d138eecfc95ddddebfaf99e4d32bf60 100755 (executable)
@@ -1,7 +1,7 @@
 #include <HYDROData_Polyline.h>
 #include <HYDROData_Iterator.h>
 
-#include <HYDROOperations_BSpline.h>
+#include <HYDROData_BSplineOperation.h>
 
 #include <ImageComposer_MetaTypes.h>
 
@@ -35,6 +35,7 @@ IMPLEMENT_STANDARD_HANDLE(HYDROData_Polyline, HYDROData_Object)
 IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Polyline, HYDROData_Object)
 
 HYDROData_Polyline::HYDROData_Polyline()
+: HYDROData_Object()
 {
 }
 
@@ -42,6 +43,18 @@ HYDROData_Polyline::~HYDROData_Polyline()
 {
 }
 
+TopoDS_Shape HYDROData_Polyline::GetTopShape() const
+{
+  // TODO
+  return getTopShape();
+}
+
+TopoDS_Shape HYDROData_Polyline::GetShape3D() const
+{
+  // TODO
+  return getTopShape();
+}
+
 /**
  * Dump object to Python script representation.
  */
@@ -64,13 +77,13 @@ QStringList HYDROData_Polyline::DumpToPython( MapOfTreatedObjects& theTreatedObj
 
   aResList << QString( "" );
 
-  int aDim = getDimension();
+  int aDim = GetDimension();
   aResList << QString( "%1.setDimension( %2 );" )
               .arg( aPolylineName ).arg( aDim );
 
   // Set polilyne data
 
-  PolylineData aPolylineData = getPolylineData();
+  PolylineData aPolylineData = GetPolylineData();
   if ( !aPolylineData.isEmpty() )
   {
     QString aPolylineDataName = "polyline_data";
@@ -118,7 +131,7 @@ QStringList HYDROData_Polyline::DumpToPython( MapOfTreatedObjects& theTreatedObj
 
 QVariant HYDROData_Polyline::GetDataVariant()
 {
-  QPainterPath aPath = painterPath();
+  QPainterPath aPath = GetPainterPath();
 
   QVariant aVarData;
   aVarData.setValue<QPainterPath>( aPath );
@@ -126,44 +139,18 @@ QVariant HYDROData_Polyline::GetDataVariant()
   return aVarData;
 }
 
-/**
- * Return polyline dimension
- * \return polyline dimension. 2 or 3 is valid. 0 is invalid.
- */
-int HYDROData_Polyline::getDimension() const
-{
-    Handle(TDataStd_Integer) aDim;
-    if(!myLab.FindAttribute(TDataStd_Integer::GetID(), aDim))
-      return 0;
-    return aDim->Get();
-}
-
-/**
- * Set polyline dimension. Should be 2 or 3.
- * \param theDimension the polyline dimension
- */
-void HYDROData_Polyline::setDimension( int theDimension )
-{
-    removeAll();
-    int aDim=0;
-    if( theDimension == 2 || theDimension == 3){
-        aDim = theDimension;
-    }
-    TDataStd_Integer::Set(myLab, aDim);
-}
-
 /**
  * Replace current polyline data by new sections list
  * \param theSections the sections list
  */
-void HYDROData_Polyline::setPolylineData( const PolylineData& theSections )
+void HYDROData_Polyline::SetPolylineData( const PolylineData& theSections )
 {
 //Keep dimension
-  int aDim = getDimension();
+  int aDim = GetDimension();
   if( aDim == 0 )
       return;
-  removeAll();
-  setDimension(aDim);
+  RemoveAll();
+  SetDimension(aDim);
 
   if( theSections.size() == 0 )
     return;
@@ -218,7 +205,7 @@ void HYDROData_Polyline::setPolylineData( const PolylineData& theSections )
  * Return polyline data
  * \return polyline section list
  */
-HYDROData_Polyline::PolylineData HYDROData_Polyline::getPolylineData() const
+HYDROData_Polyline::PolylineData HYDROData_Polyline::GetPolylineData() const
 {
   int aSectCnt;
   PolylineData aRes;
@@ -278,10 +265,10 @@ HYDROData_Polyline::PolylineData HYDROData_Polyline::getPolylineData() const
 /**
  * Returns true if polyline is closed
  */
-bool HYDROData_Polyline::isClosed() const
+bool HYDROData_Polyline::IsClosed() const
 {
-  int aDim = getDimension();
-  PolylineData aPolylineData = getPolylineData();
+  int aDim = GetDimension();
+  PolylineData aPolylineData = GetPolylineData();
 
   if ( aDim == 0 || aPolylineData.isEmpty() )
     return false;
@@ -297,10 +284,36 @@ bool HYDROData_Polyline::isClosed() const
   return true;
 }
 
+/**
+ * Return polyline dimension
+ * \return polyline dimension. 2 or 3 is valid. 0 is invalid.
+ */
+int HYDROData_Polyline::GetDimension() const
+{
+    Handle(TDataStd_Integer) aDim;
+    if(!myLab.FindAttribute(TDataStd_Integer::GetID(), aDim))
+      return 0;
+    return aDim->Get();
+}
+
+/**
+ * Set polyline dimension. Should be 2 or 3.
+ * \param theDimension the polyline dimension
+ */
+void HYDROData_Polyline::SetDimension( int theDimension )
+{
+    RemoveAll();
+    int aDim=0;
+    if( theDimension == 2 || theDimension == 3){
+        aDim = theDimension;
+    }
+    TDataStd_Integer::Set(myLab, aDim);
+}
+
 /**
  * Remove all polyline attributes except dimension.
  */
-void HYDROData_Polyline::removeAll()
+void HYDROData_Polyline::RemoveAll()
 {
 //Remove only section data
   TDF_Label aLab = myLab.FindChild( DataTag_SectionsSize );
@@ -321,14 +334,14 @@ void HYDROData_Polyline::removeAll()
  * Note: currently only the first section of the polyline data is taken into account.
  * \return polyline painter path.
  */
-QPainterPath HYDROData_Polyline::painterPath() const
+QPainterPath HYDROData_Polyline::GetPainterPath() const
 {
   QPainterPath aPath;
-  int aDim = getDimension();
+  int aDim = GetDimension();
   if( aDim != 2 && aDim != 3 )
     return aPath;
 
-  PolylineData aSects = getPolylineData();
+  PolylineData aSects = GetPolylineData();
   if( aSects.isEmpty() )
     return aPath;
 
@@ -356,7 +369,7 @@ QPainterPath HYDROData_Polyline::painterPath() const
       int anIndex = i * aDim;
       aPoints << aSection.myCoords[ anIndex ] << aSection.myCoords[ anIndex + 1 ];
     }
-    HYDROOperations_BSpline aBSpline( aPoints, 0, anIsSectionClosed );
+    HYDROData_BSplineOperation aBSpline( aPoints, 0, anIsSectionClosed );
     aPath = aBSpline.ComputePath();
   }
   return aPath;
@@ -375,25 +388,11 @@ double HYDROData_Polyline::ZValue() const
   return 0;
 }
 
-void HYDROData_Polyline::SetWire( const TopoDS_Wire& theWire )
-{
-  TNaming_Builder aBuilder( myLab );
-  aBuilder.Generated( theWire );
-}
-
-TopoDS_Wire HYDROData_Polyline::Wire() const
-{
-  Handle(TNaming_NamedShape) aNamedShape;
-  if( myLab.FindAttribute( TNaming_NamedShape::GetID(), aNamedShape ) )
-    return TopoDS::Wire( aNamedShape->Get() );
-  return TopoDS_Wire();
-}
-
 void HYDROData_Polyline::UpdateWire( const PolylineData& theSections )
 {
   BRepBuilderAPI_MakeWire aMakeWire;
 
-  int aDim = getDimension();
+  int aDim = GetDimension();
 
   double aZValue = ZValue();
 
@@ -439,7 +438,7 @@ void HYDROData_Polyline::UpdateWire( const PolylineData& theSections )
           aPoints << x << y;
         }
 
-        HYDROOperations_BSpline aBSpline( aPoints, aZValue, anIsSectionClosed );
+        HYDROData_BSplineOperation aBSpline( aPoints, aZValue, anIsSectionClosed );
         TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge( aBSpline.Curve() ).Edge();
         aMakeSectionWire.Add( anEdge );
       }
@@ -449,5 +448,5 @@ void HYDROData_Polyline::UpdateWire( const PolylineData& theSections )
   }
 
   TopoDS_Wire aWire = aMakeWire.Wire();
-  SetWire( aWire );
+  SetTopShape( aWire );
 }
index b5ce157efc26ef3f4c4113b3ac79d5882ee3d196..78f8736efaf44a97d8a7e7f8ccad45d298af2546 100755 (executable)
@@ -48,7 +48,6 @@ protected:
     DataTag_SectionsClosed,
     DataTag_SectionsSize,
     DataTag_SectionsType,
-    DataTag_Wire,
     DataTag_ZValue
   };
 
@@ -60,6 +59,16 @@ public:
    */
   HYDRODATA_EXPORT virtual const ObjectKind GetKind() const {return KIND_POLYLINE;}
 
+  /**
+   * Returns the top shape of the object.
+   */
+  HYDRODATA_EXPORT virtual TopoDS_Shape GetTopShape() const;
+
+  /**
+   * Returns the 3d shape of the object.
+   */
+  HYDRODATA_EXPORT virtual TopoDS_Shape GetShape3D() const;
+
   /**
    * Dump object to Python script representation.
    */
@@ -75,56 +84,47 @@ public:
    * Replace current polyline data by new sections list
    * \param theSections the sections list
    */
-  HYDRODATA_EXPORT void setPolylineData( const PolylineData& theSections );
+  HYDRODATA_EXPORT void SetPolylineData( const PolylineData& theSections );
 
   /**
    * Return polyline data
    * \return polyline section list
    */
-  HYDRODATA_EXPORT PolylineData getPolylineData() const;
+  HYDRODATA_EXPORT PolylineData GetPolylineData() const;
    
   /**
    * Returns true if polyline is closed
    */
-  HYDRODATA_EXPORT bool isClosed() const;
+  HYDRODATA_EXPORT bool IsClosed() const;
 
   /**
    * Return polyline dimension
    * \return polyline dimension (2 or 3)
    */
-  HYDRODATA_EXPORT int getDimension() const;
+  HYDRODATA_EXPORT int GetDimension() const;
 
   /**
    * Set polyline dimension (2 or 3)
    * \param theDimension the polyline dimension
    */
-  HYDRODATA_EXPORT void setDimension( int theDimension );
+  HYDRODATA_EXPORT void SetDimension( int theDimension );
 
   /**
    * Remove all sections from polyline
    */
-  HYDRODATA_EXPORT void removeAll();
+  HYDRODATA_EXPORT void RemoveAll();
 
   /**
    * Returns the painter path.
    * Note: currently only the first section of the polyline data is taken into account.
    */
-  HYDRODATA_EXPORT QPainterPath painterPath() const;
+  HYDRODATA_EXPORT QPainterPath GetPainterPath() const;
 
-  HYDRODATA_EXPORT void SetZValue( const double theZValue );
+  HYDRODATA_EXPORT void   SetZValue( const double theZValue );
   HYDRODATA_EXPORT double ZValue() const;
 
-  /**
-   * Sets the wire contour of the object.
-   */
-  HYDRODATA_EXPORT void SetWire( const TopoDS_Wire& theWire );
-
-  /**
-   * Returns the wire contour of the object.
-   */
-  HYDRODATA_EXPORT TopoDS_Wire Wire() const;
-
 protected:
+
   /**
    * Update the wire contour on the basis of the polyline data.
    */
index 166806535995977ecdb0d576de304e449544c235..3a1c59acfcf819ef7f0666576b45d9c4fe20640e 100644 (file)
@@ -1,17 +1,16 @@
 
 #include "HYDROData_Region.h"
 
-#include <TNaming_Builder.hxx>
-#include <TNaming_NamedShape.hxx>
-#include <TopoDS.hxx>
+#include "HYDROData_Document.h"
+#include "HYDROData_Iterator.h"
+#include "HYDROData_Zone.h"
 
-#include <QString>
+#include <QStringList>
 
 #define PYTHON_REGION_ID "KIND_REGION"
 
-
-IMPLEMENT_STANDARD_HANDLE(HYDROData_Region, HYDROData_Domain)
-IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Region, HYDROData_Domain)
+IMPLEMENT_STANDARD_HANDLE(HYDROData_Region, HYDROData_Entity)
+IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Region, HYDROData_Entity)
 
 
 HYDROData_Region::HYDROData_Region()
@@ -22,24 +21,104 @@ HYDROData_Region::~HYDROData_Region()
 {
 }
 
-void HYDROData_Region::SetFace( const TopoDS_Face& theFace )
+QStringList HYDROData_Region::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const
+{
+  QStringList aResList;
+
+  Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( this );
+  if ( aDocument.IsNull() )
+    return aResList;
+
+  QString aDocName = aDocument->GetDocPyName();
+  QString aRegionName = GetName();
+
+  aResList << QString( "%1 = %2.CreateObject( %3 );" )
+              .arg( aRegionName ).arg( aDocName ).arg( PYTHON_REGION_ID );
+  aResList << QString( "%1.SetName( \"%2\" );" )
+              .arg( aRegionName ).arg( aRegionName );
+  aResList << QString( "" );
+
+  HYDROData_SequenceOfObjects aZones = GetZones();
+  HYDROData_SequenceOfObjects::Iterator anIter( aZones );
+  for ( ; anIter.More(); anIter.Next() )
+  {
+    Handle(HYDROData_Zone) aRefZone =
+      Handle(HYDROData_Zone)::DownCast( anIter.Value() );
+    if ( !aRefZone.IsNull() )
+      setPythonReferenceObject( theTreatedObjects, aResList, aRefZone, "AddZone" );
+  }
+  aResList << QString( "" );
+
+  return aResList;
+}
+
+Handle(HYDROData_Zone) HYDROData_Region::AddNewZone()
+{
+  TDF_Label aNewLab = myLab.FindChild( ChildTag_Zone ).NewChild();
+
+  return Handle(HYDROData_Zone)::DownCast(
+    HYDROData_Iterator::CreateObject( aNewLab, KIND_ZONE ) );
+}
+
+void HYDROData_Region::RemoveChildZones()
+{
+  myLab.FindChild( ChildTag_Zone ).ForgetAllAttributes( true );
+}
+
+int HYDROData_Region::NbZones() const
+{
+  return NbReferenceObjects( DataTag_Zone );
+}
+
+void HYDROData_Region::AddZone( const Handle(HYDROData_Zone)& theZone )
 {
-  TNaming_Builder aBuilder( myLab );
-  aBuilder.Generated( theFace );
+  AddReferenceObject( theZone, DataTag_Zone );
 }
 
-TopoDS_Face HYDROData_Region::Face() const
+void HYDROData_Region::SetZone( const int                     theIndex,
+                                const Handle(HYDROData_Zone)& theZone )
 {
-  Handle(TNaming_NamedShape) aNamedShape;
-  if( myLab.FindAttribute( TNaming_NamedShape::GetID(), aNamedShape ) )
-    return TopoDS::Face( aNamedShape->Get() );
-  return TopoDS_Face();
+  SetReferenceObject( theZone, DataTag_Zone, theIndex );
 }
 
-QString HYDROData_Region::getPythonKindId() const
+void HYDROData_Region::InsertZone( const int                     theBeforeIndex,
+                                   const Handle(HYDROData_Zone)& theZone )
 {
-  return QString( PYTHON_REGION_ID );
+  InsertReferenceObject( theZone, DataTag_Zone, theBeforeIndex );
 }
 
+void HYDROData_Region::SetZones( const HYDROData_SequenceOfObjects& theZones )
+{
+  SetReferenceObjects( theZones, DataTag_Zone );
+}
+
+Handle(HYDROData_Zone) HYDROData_Region::GetZone( const int theIndex ) const
+{
+  return Handle(HYDROData_Zone)::DownCast( 
+           GetReferenceObject( DataTag_Zone, theIndex ) );
+}
+
+HYDROData_SequenceOfObjects HYDROData_Region::GetZones() const
+{
+  return GetReferenceObjects( DataTag_Zone );
+}
+
+void HYDROData_Region::RemoveZone( const Handle(HYDROData_Zone)& theZone )
+{
+  if ( theZone.IsNull() )
+    return;
+
+  RemoveReferenceObject( theZone->Label(), DataTag_Zone );
+}
+
+void HYDROData_Region::RemoveZone( const int theIndex )
+{
+  RemoveReferenceObject( DataTag_Zone, theIndex );
+}
+
+void HYDROData_Region::RemoveZones()
+{
+  ClearReferenceObjects( DataTag_Zone );
+}
 
 
index 23cd0d6232fa9be8dc418b896def1d46ff685df4..1579be6ccc93834093a6612d9add305a0330de56 100644 (file)
@@ -2,26 +2,37 @@
 #ifndef HYDROData_Region_HeaderFile
 #define HYDROData_Region_HeaderFile
 
-#include <HYDROData_Domain.h>
+#include "HYDROData_Entity.h"
 
 
-DEFINE_STANDARD_HANDLE(HYDROData_Region, HYDROData_Domain)
+DEFINE_STANDARD_HANDLE(HYDROData_Region, HYDROData_Entity)
 
+class Handle(HYDROData_Zone);
 
-/**\class HYDROData_Domain
- * \brief Class that stores/retreives information about the 2d surface.
+/**\class HYDROData_Region
+ * \brief Regions are groups (lists) of zones, they can include one or several zones.
  */
-class HYDROData_Region : public HYDROData_Domain
+class HYDROData_Region : public HYDROData_Entity
 {
 
 protected:
+
   /**
    * Enumeration of tags corresponding to the persistent object parameters.
    */
   enum DataTag
   {
-    DataTag_First = HYDROData_Domain::DataTag_First + 100, ///< first tag, to reserve
-    DataTag_Face
+    DataTag_First = HYDROData_Entity::DataTag_First + 100, ///< first tag, to reserve
+    DataTag_Zone    ///< reference zones
+  };
+
+  /**
+   * Enumeration of tags corresponding to the child sub-objects of object.
+   */
+  enum ChildTag
+  {
+    ChildTag_First = HYDROData_Entity::ChildTag_First + 100, ///< first tag, to reserve
+    ChildTag_Zone      ///< child zones
   };
 
 public:
@@ -33,17 +44,79 @@ public:
   HYDRODATA_EXPORT virtual const ObjectKind GetKind() const { return KIND_REGION; }
 
   /**
-   * Sets the shape of the object.
+   * Dump object to Python script representation.
+   */
+  HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
+
+
+  /**
+   * Create new one reference zone for region on child label.
+   * The new zone is not added into the list of reference zones.
+   */
+  HYDRODATA_EXPORT virtual Handle(HYDROData_Zone) AddNewZone();
+
+  /**
+   * Removes all child zones from region.
+   */
+  HYDRODATA_EXPORT virtual void RemoveChildZones();
+
+
+  /**
+   * Returns number of reference zones of region.
+   */
+  int NbZones() const;
+
+  /**
+   * Add new one reference zone for region.
+   */
+  HYDRODATA_EXPORT virtual void AddZone( const Handle(HYDROData_Zone)& theZone );
+
+  /**
+   * Replace the reference zone for region.
    */
-  HYDRODATA_EXPORT void SetFace( const TopoDS_Face& theFace );
+  HYDRODATA_EXPORT virtual void SetZone( const int                     theIndex,
+                                         const Handle(HYDROData_Zone)& theZone );
 
   /**
-   * Returns the shape of the the object (redefined method).
+   * Inserts the reference zone for region before given index.
    */
-  HYDRODATA_EXPORT virtual TopoDS_Face Face() const;
+  HYDRODATA_EXPORT virtual void InsertZone( const int                     theBeforeIndex,
+                                            const Handle(HYDROData_Zone)& theZone );
+
+  /**
+   * Sets reference zones for calculation region.
+   */
+  HYDRODATA_EXPORT virtual void SetZones( const HYDROData_SequenceOfObjects& theZones );
+
+  /**
+   * Returns reference zone of region by index.
+   */
+  HYDRODATA_EXPORT virtual Handle(HYDROData_Zone) GetZone( const int theIndex ) const;
+
+  /**
+   * Returns all reference zone of region.
+   */
+  HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetZones() const;
+
+  /**
+   * Removes reference zone from region.
+   */
+  HYDRODATA_EXPORT virtual void RemoveZone( const Handle(HYDROData_Zone)& theZone );
+
+  /**
+   * Removes reference zone from region by it index.
+   */
+  HYDRODATA_EXPORT virtual void RemoveZone( const int theIndex );
+
+  /**
+   * Removes all reference zones from region.
+   */
+  HYDRODATA_EXPORT virtual void RemoveZones();
+
 
 protected:
 
+  friend class HYDROData_Calculation;
   friend class HYDROData_Iterator;
 
   /**
@@ -56,11 +129,6 @@ protected:
    * Destructs properties of the object and object itself, removes it from the document.
    */
   ~HYDROData_Region();
-
-  /**
-   * Returns id for creation of object in python scripting.
-   */
-  virtual QString getPythonKindId() const;
 };
 
 #endif
diff --git a/src/HYDROData/HYDROData_SplitToZonesTool.cxx b/src/HYDROData/HYDROData_SplitToZonesTool.cxx
new file mode 100644 (file)
index 0000000..dfd60b7
--- /dev/null
@@ -0,0 +1,187 @@
+
+#include "HYDROData_SplitToZonesTool.h"
+
+#include "HYDROData_Object.h"
+
+#include <BRepAlgoAPI_Common.hxx>
+#include <BRepAlgoAPI_Cut.hxx>
+#include <BRepBuilderAPI_MakeFace.hxx>
+
+#include <TopExp_Explorer.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Iterator.hxx>
+#include <TopoDS_Wire.hxx>
+
+TopoDS_Face HYDROData_SplitToZonesTool::SplitData::Face() const
+{
+  TopoDS_Face aResFace;
+
+  if( !Shape.IsNull() )
+  {
+    if ( Shape.ShapeType() == TopAbs_FACE )
+    {
+      aResFace = TopoDS::Face( Shape );
+    }
+    else if ( Shape.ShapeType() == TopAbs_WIRE )
+    {
+      BRepBuilderAPI_MakeFace aMakeFace( TopoDS::Wire( Shape ), Standard_True );
+      aMakeFace.Build();
+      if( aMakeFace.IsDone() )
+        aResFace = aMakeFace.Face();
+    }
+  }
+
+  return aResFace;
+}
+
+HYDROData_SplitToZonesTool::SplitDataList
+HYDROData_SplitToZonesTool::SplitToZones( const HYDROData_SequenceOfObjects& theObjectList )
+{
+  SplitDataList anOutputSplitDataList;
+
+  // Preparation. Collect the object shapes to split.
+  SplitDataList anInputSplitDataList;
+  for( int anIndex = 1, aLength = theObjectList.Length(); anIndex <= aLength; anIndex++ )
+  {
+    Handle(HYDROData_Object) aGeomObj = 
+      Handle(HYDROData_Object)::DownCast( theObjectList.Value( anIndex ) );
+    if( !aGeomObj.IsNull() )
+    {
+      SplitData aSplitData( aGeomObj->GetTopShape(), aGeomObj->GetName() );
+      anInputSplitDataList.append( aSplitData );
+    }
+  }
+
+  // Step 1. Split the paths.
+  SplitDataListIterator anInputIter( anInputSplitDataList );
+  while( anInputIter.hasNext() )
+  {
+    const SplitData& anInputSplitData = anInputIter.next();
+    if( anOutputSplitDataList.isEmpty() )
+      anOutputSplitDataList.append( anInputSplitData );
+    else
+    {
+      SplitDataList aSplitDataList;
+
+      SplitDataList aSrcSplitDataList;
+      aSrcSplitDataList.append( anInputSplitData );
+
+      SplitDataList aDestSplitDataList = anOutputSplitDataList;
+      anOutputSplitDataList.clear();
+
+      while( !aDestSplitDataList.isEmpty() )
+      {
+        SplitData aSrcSplitData = aSrcSplitDataList.last();
+
+        SplitData aDestSplitData = aDestSplitDataList.first();
+        aDestSplitDataList.pop_front();
+
+        SplitData aData1Subtracted, aData2Subtracted, aDataIntersected;
+        if( SplitTwoData( aSrcSplitData, aDestSplitData,
+                          aData1Subtracted, aData2Subtracted, aDataIntersected ) )
+          anOutputSplitDataList.append( aDataIntersected );
+        anOutputSplitDataList.append( aData2Subtracted );
+        aSrcSplitDataList.append( aData1Subtracted );
+      }
+
+      if( !aSrcSplitDataList.isEmpty() )
+        anOutputSplitDataList.append( aSrcSplitDataList.last() );
+    }
+  }
+
+  // Step 2. Take into account the boundary polyline.
+  /*
+  if( !thePolyline.IsNull() )
+  {
+    TopoDS_Wire aWire = TopoDS::Wire( thePolyline->GetTopShape() );
+    if( !aWire.IsNull() )
+    {
+      BRepBuilderAPI_MakeFace aMakeFace( aWire, Standard_True );
+      aMakeFace.Build();
+      if( aMakeFace.IsDone() )
+      {
+        SplitData aBoundarySplitData( aMakeFace.Face(), "" );
+
+        SplitDataList aCutSplitDataList;
+        SplitDataListIterator anOutputIter( anOutputSplitDataList );
+        while( anOutputIter.hasNext() )
+        {
+          const SplitData& anOutputSplitData = anOutputIter.next();
+
+          SplitData aData1Subtracted, aData2Subtracted, aDataIntersected;
+          if( SplitTwoData( anOutputSplitData, aBoundarySplitData,
+                            aData1Subtracted, aData2Subtracted, aDataIntersected ) )
+            aCutSplitDataList.append( aDataIntersected );
+        }
+        anOutputSplitDataList = aCutSplitDataList;
+      }
+    }
+  }
+  */
+
+  // Step 3. Extract the separate regions.
+  SplitDataList anExtractedSplitDataList;
+  SplitDataListIterator anOutputIter( anOutputSplitDataList );
+  while( anOutputIter.hasNext() )
+  {
+    const SplitData& anOutputSplitData = anOutputIter.next();
+    anExtractedSplitDataList.append( ExtractSeparateData( anOutputSplitData ) );
+  }
+
+  return anExtractedSplitDataList;
+}
+
+bool HYDROData_SplitToZonesTool::SplitTwoData( const SplitData& theData1,
+                                               const SplitData& theData2,
+                                               SplitData& theData1Subtracted,
+                                               SplitData& theData2Subtracted,
+                                               SplitData& theDataIntersected )
+{
+  const TopoDS_Shape& aShape1 = theData1.Shape;
+  const TopoDS_Shape& aShape2 = theData2.Shape;
+
+  const QStringList& anObjectNames1 = theData1.ObjectNames;
+  const QStringList& anObjectNames2 = theData2.ObjectNames;
+
+  BRepAlgoAPI_Common aCommon( aShape1, aShape2 );
+  TopoDS_Shape aCommonShape = aCommon.Shape();
+  if( aCommonShape.IsNull() )
+  {
+    theData1Subtracted = theData1;
+    theData2Subtracted = theData2;
+    return false;
+  }
+
+  BRepAlgoAPI_Cut aCut1( aShape1, aShape2 );
+  TopoDS_Shape aCut1Shape = aCut1.Shape();
+
+  BRepAlgoAPI_Cut aCut2( aShape2, aShape1 );
+  TopoDS_Shape aCut2Shape = aCut2.Shape();
+
+  theData1Subtracted = SplitData( aCut1Shape, anObjectNames1 );
+  theData2Subtracted = SplitData( aCut2Shape, anObjectNames2 );
+  theDataIntersected = SplitData( aCommonShape, anObjectNames1 + anObjectNames2 );
+
+  return true;
+}
+
+HYDROData_SplitToZonesTool::SplitDataList
+HYDROData_SplitToZonesTool::ExtractSeparateData( const SplitData& theData )
+{
+  SplitDataList aSplitDataList;
+  TopExp_Explorer anExp( theData.Shape, TopAbs_FACE );
+  for( ; anExp.More(); anExp.Next() )
+  {
+    TopoDS_Shape aShape = anExp.Current();
+    if( aShape.ShapeType() == TopAbs_FACE )
+    {
+      TopoDS_Face aFace = TopoDS::Face( aShape );
+      if( !aFace.IsNull() )
+      {
+        SplitData aSplitData( aFace, theData.ObjectNames );
+        aSplitDataList.append( aSplitData );
+      }
+    }
+  }
+  return aSplitDataList;
+}
diff --git a/src/HYDROData/HYDROData_SplitToZonesTool.h b/src/HYDROData/HYDROData_SplitToZonesTool.h
new file mode 100644 (file)
index 0000000..dd70ed4
--- /dev/null
@@ -0,0 +1,58 @@
+
+#ifndef HYDROData_SplitToZonesTool_H
+#define HYDROData_SplitToZonesTool_H
+
+#include <HYDROData_Object.h>
+
+#include <TopoDS_Face.hxx>
+
+#include <QStringList>
+
+class Handle(HYDROData_Polyline);
+
+/**
+ * \class HYDROData_SplitToZonesTool
+ * \brief This class contains methods used for splitting geometry objects
+ *        into non-intersected regions.
+ */
+class HYDRODATA_EXPORT HYDROData_SplitToZonesTool
+{
+public:
+  struct HYDRODATA_EXPORT SplitData
+  {
+    TopoDS_Shape Shape;
+    QStringList  ObjectNames;
+
+    SplitData() {}
+    
+    SplitData( const TopoDS_Shape& theShape,
+               const QStringList& theObjectNames ) :
+      Shape( theShape ), ObjectNames( theObjectNames ) {}
+
+    SplitData( const TopoDS_Shape& theShape,
+               const QString& theObjectNames ) :
+      Shape( theShape ), ObjectNames( theObjectNames ) {}
+
+    TopoDS_Face Face() const;
+  };
+
+  typedef QList        <SplitData> SplitDataList;
+  typedef QListIterator<SplitData> SplitDataListIterator;
+
+public:
+
+  static SplitDataList       SplitToZones( const HYDROData_SequenceOfObjects& theObjectList );
+
+private:
+
+  static bool                SplitTwoData( const SplitData& theData1,
+                                           const SplitData& theData2,
+                                           SplitData& theData1Subtracted,
+                                           SplitData& theData2Subtracted,
+                                           SplitData& theDataIntersected );
+
+  static SplitDataList       ExtractSeparateData( const SplitData& theData );
+
+};
+
+#endif
index 58511d16cea71b587a10df916512f4b35cc7e28b..fda98c6134bb9807f150190aaac67f7f445e8ced 100644 (file)
@@ -24,7 +24,7 @@ void HYDROData_Tool::WriteStringsToFile( QFile&             theFile,
 }
 
 void HYDROData_Tool::SetMustBeUpdatedImages(
-  Handle_HYDROData_Document theDoc)
+  const Handle(HYDROData_Document)& theDoc  )
 {
   bool aChanged = true;
 
@@ -55,3 +55,90 @@ void HYDROData_Tool::SetMustBeUpdatedImages(
     }
   }
 }
+
+QString HYDROData_Tool::GenerateObjectName( const Handle(HYDROData_Document)& theDoc,
+                                            const QString&                    thePrefix,
+                                            const QStringList&                theUsedNames )
+{
+  QStringList aNamesList( theUsedNames );
+
+  // Collect all used names in the document
+  HYDROData_Iterator anIter( theDoc );
+  for( ; anIter.More(); anIter.Next() )
+  {
+    Handle(HYDROData_Entity) anObject = anIter.Current();
+    if( anObject.IsNull() )
+      continue;
+
+    QString anObjName = anObject->GetName();
+    if ( anObjName.isEmpty() )
+      continue;
+
+    aNamesList.append( anObjName );
+  }
+
+  QString aName;
+
+  int anId = 1;
+  while( anId < 1000 )
+  {
+    aName = QString( "%1_%2" ).arg( thePrefix ).arg( QString::number( anId++ ) );
+
+    // check that there are no other objects with the same name in the document
+    if ( !aNamesList.contains( aName ) )
+      break;
+  }
+
+  return aName;
+}
+
+Handle(HYDROData_Entity) HYDROData_Tool::FindObjectByName( const Handle(HYDROData_Document)& theDoc,
+                                                           const QString&                    theName,
+                                                           const ObjectKind                  theObjectKind )
+{
+  Handle(HYDROData_Entity) anObject;
+  if ( theName.isEmpty() || theDoc.IsNull() )
+    return anObject;
+
+  QStringList aNamesList;
+  aNamesList << theName;
+
+  HYDROData_SequenceOfObjects aSeqOfObjs = FindObjectsByNames( theDoc, aNamesList, theObjectKind );
+  if( aSeqOfObjs.IsEmpty() )
+    return anObject;
+  
+  anObject = aSeqOfObjs.First();
+  return anObject;
+}
+
+HYDROData_SequenceOfObjects HYDROData_Tool::FindObjectsByNames( const Handle(HYDROData_Document)& theDoc,
+                                                                const QStringList&                theNames,
+                                                                const ObjectKind                  theObjectKind )
+{
+  HYDROData_SequenceOfObjects aResSeq;
+  if( theDoc.IsNull() )
+    return aResSeq;
+
+  QStringList aNamesList = theNames;
+
+  HYDROData_Iterator anIter( theDoc, theObjectKind );
+  for( ; anIter.More(); anIter.Next() )
+  {
+    Handle(HYDROData_Entity) anObject = anIter.Current();
+    if( anObject.IsNull() )
+      continue;
+
+    QString anObjName = anObject->GetName();
+    if ( anObjName.isEmpty() || !aNamesList.contains( anObjName ) )
+      continue;
+
+    aResSeq.Append( anObject );
+
+    aNamesList.removeAll( anObjName );
+    if ( aNamesList.isEmpty() )
+      break;
+  }
+
+  return aResSeq;
+}
+
index 85824d6ef10f7cf5bec3358bf7b0ccfc0e0e8f62..04835c87ea0f3fba014aec73f3e32adae583f5bb 100644 (file)
@@ -2,15 +2,18 @@
 #ifndef HYDROData_Tool_HeaderFile
 #define HYDROData_Tool_HeaderFile
 
+#include "HYDROData.h"
+#include "HYDROData_Entity.h"
+
 #include <Precision.hxx>
 
 #include <QString>
+#include <QStringList>
 
 class QFile;
-class QStringList;
-class Handle_HYDROData_Document;
+class Handle(HYDROData_Document);
 
-class HYDROData_Tool {
+class HYDRODATA_EXPORT HYDROData_Tool {
 
 public:
 
@@ -22,8 +25,40 @@ public:
    * Enables "MustBeUpdated" flag for Images that are depended on "MustBeUpdated" images.
    * \param theDoc document where this operation is performed
    */
-  static void                           SetMustBeUpdatedImages( Handle_HYDROData_Document theDoc );
+  static void                           SetMustBeUpdatedImages( const Handle(HYDROData_Document)& theDoc );
 
+  /**
+   * \brief Generate name for new object.
+   * \param theModule module
+   * \param thePrefix name prefix
+   * \param theUsedNames list of already used names
+   * \return generated name
+   */
+  static QString                        GenerateObjectName( const Handle(HYDROData_Document)& theDoc,
+                                                            const QString&                    thePrefix,
+                                                            const QStringList&                theUsedNames = QStringList() );
+
+  /**
+   * \brief Find the data object with the specified name.
+   * \param theModule module
+   * \param theName name
+   * \param theObjectKind kind of object
+   * \return data object
+   */
+  static Handle(HYDROData_Entity)       FindObjectByName( const Handle(HYDROData_Document)& theDoc,
+                                                          const QString&                    theName,
+                                                          const ObjectKind                  theObjectKind = KIND_UNKNOWN );
+
+  /**
+   * \brief Find the data objects with the specified names.
+   * \param theModule module
+   * \param theNames list of names
+   * \param theObjectKind kind of object
+   * \return list of data objects
+   */
+  static HYDROData_SequenceOfObjects    FindObjectsByNames( const Handle(HYDROData_Document)& theDoc,
+                                                            const QStringList&                theNames,
+                                                            const ObjectKind                  theObjectKind = KIND_UNKNOWN );
 };
 
 inline bool ValuesEquals( const double& theFirst, const double& theSecond )
index e3e064130a898311a8154da49b43430ae1a353cf..6c081bcfc7301fcb322f8a4c72830dde9d7dc9c2 100644 (file)
@@ -1,11 +1,13 @@
+
 #include <HYDROData_VisualState.h>
 
 #include <TDataStd_AsciiString.hxx>
 
-IMPLEMENT_STANDARD_HANDLE(HYDROData_VisualState, HYDROData_Object)
-IMPLEMENT_STANDARD_RTTIEXT(HYDROData_VisualState, HYDROData_Object)
+IMPLEMENT_STANDARD_HANDLE(HYDROData_VisualState, HYDROData_Entity)
+IMPLEMENT_STANDARD_RTTIEXT(HYDROData_VisualState, HYDROData_Entity)
 
 HYDROData_VisualState::HYDROData_VisualState()
+: HYDROData_Entity()
 {
 }
 
index 6a53c44caa835d03841f82265a3b3b692910a836..72b8f2c783b2168a131e5bee6ea30d1e3107dd1f 100644 (file)
@@ -1,18 +1,19 @@
+
 #ifndef HYDROData_VisualState_HeaderFile
 #define HYDROData_VisualState_HeaderFile
 
-#include <HYDROData_Object.h>
+#include <HYDROData_Entity.h>
 
 #include <QString>
 
-DEFINE_STANDARD_HANDLE(HYDROData_VisualState, HYDROData_Object)
+DEFINE_STANDARD_HANDLE(HYDROData_VisualState, HYDROData_Entity)
 
 /**\class HYDROData_VisualState
  * \brief Class that stores/retreives information about the visual state.
  *
  * Keeps the visual state as encoded text string.
  */
-class HYDROData_VisualState : public HYDROData_Object
+class HYDROData_VisualState : public HYDROData_Entity
 {
 protected:
   /**
@@ -20,7 +21,7 @@ protected:
    */
   enum DataTag
   {
-    DataTag_First = HYDROData_Object::DataTag_First + 100, ///< first tag, to reserve
+    DataTag_First = HYDROData_Entity::DataTag_First + 100, ///< first tag, to reserve
     DataTag_State ///< encoded visual state
   };
 
index 3af90622deec733c285953a517d81db4c80b5332..36b13d65629b20eb2edd5293622947deb8edf647 100644 (file)
@@ -1,24 +1,24 @@
 
 #include "HYDROData_Zone.h"
 
-#include "HYDROData_Bathymetry.h"
 #include "HYDROData_Document.h"
-#include "HYDROData_Polyline.h"
-#include "HYDROData_Iterator.h"
+#include "HYDROData_Object.h"
 
-#include <BRepBuilderAPI_MakeFace.hxx>
-#include <TDataStd_IntegerArray.hxx>
-#include <TopoDS_Wire.hxx>
+#include <TNaming_Builder.hxx>
+#include <TNaming_NamedShape.hxx>
+
+#include <TopoDS_Shape.hxx>
 
-#include <QColor>
 #include <QStringList>
 
 #define PYTHON_ZONE_ID "KIND_ZONE"
 
-IMPLEMENT_STANDARD_HANDLE(HYDROData_Zone, HYDROData_Domain)
-IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Zone, HYDROData_Domain)
+IMPLEMENT_STANDARD_HANDLE(HYDROData_Zone, HYDROData_Entity)
+IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Zone, HYDROData_Entity)
+
 
 HYDROData_Zone::HYDROData_Zone()
+: HYDROData_Entity()
 {
 }
 
@@ -28,55 +28,88 @@ HYDROData_Zone::~HYDROData_Zone()
 
 QStringList HYDROData_Zone::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const
 {
-  QStringList aResList = HYDROData_Domain::DumpToPython( theTreatedObjects );
-  if ( aResList.isEmpty() )
+  QStringList aResList;
+
+  Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( this );
+  if ( aDocument.IsNull() )
     return aResList;
 
+  QString aDocName = aDocument->GetDocPyName();
+  QString aZoneName = GetName();
+
+  aResList << QString( "%1 = %2.CreateObject( %3 );" )
+              .arg( aZoneName ).arg( aDocName ).arg( PYTHON_ZONE_ID );
+  aResList << QString( "%1.SetName( \"%2\" );" )
+              .arg( aZoneName ).arg( aZoneName );
   aResList << QString( "" );
 
-  Handle(HYDROData_Polyline) aRefPolyline = GetPolyline();
-  setPythonReferenceObject( theTreatedObjects, aResList, aRefPolyline, "SetPolyline" );
+  HYDROData_SequenceOfObjects aGeomObjects = GetGeometryObjects();
+  HYDROData_SequenceOfObjects::Iterator aGeomObjsIter( aGeomObjects );
+  for ( ; aGeomObjsIter.More(); aGeomObjsIter.Next() )
+  {
+    Handle(HYDROData_Object) aRefGeomObj =
+      Handle(HYDROData_Object)::DownCast( aGeomObjsIter.Value() );
+    if ( !aRefGeomObj.IsNull() )
+      setPythonReferenceObject( theTreatedObjects, aResList, aRefGeomObj, "AddGeometryObject" );
+  }
+
+  // How can we get the shape? Mb Update() method to intersect the shapes of reference objects?
+  // TODO:  TopoDS_Shape aRefShape = GetShape();
 
   return aResList;
 }
 
-void HYDROData_Zone::SetPolyline( const Handle(HYDROData_Polyline)& thePolyline )
+void HYDROData_Zone::SetShape( const TopoDS_Shape& theShape )
 {
-  SetReferenceObject( thePolyline, DataTag_Polyline );
+  TNaming_Builder aBuilder( myLab.FindChild( DataTag_Shape ) );
+  aBuilder.Generated( theShape );
 }
 
-Handle(HYDROData_Polyline) HYDROData_Zone::GetPolyline() const
+TopoDS_Shape HYDROData_Zone::GetShape() const
 {
-  return Handle(HYDROData_Polyline)::DownCast( 
-           GetReferenceObject( DataTag_Polyline ) );
+  Handle(TNaming_NamedShape) aNamedShape;
+  if( myLab.FindChild( DataTag_Shape ).FindAttribute( TNaming_NamedShape::GetID(), aNamedShape ) )
+    return aNamedShape->Get();
+  return TopoDS_Shape();
 }
 
-void HYDROData_Zone::RemovePolyline()
+int HYDROData_Zone::NbGeometryObjects() const
 {
-  ClearReferenceObjects( DataTag_Polyline );
+  return NbReferenceObjects( DataTag_GeometryObject );
 }
 
-TopoDS_Face HYDROData_Zone::Face() const
+void HYDROData_Zone::AddGeometryObject( const Handle(HYDROData_Object)& theObject )
 {
-  Handle(HYDROData_Polyline) aPolyline = GetPolyline();
-  if( !aPolyline.IsNull() )
-  {
-    TopoDS_Wire aWire = aPolyline->Wire();
-    if( !aWire.IsNull() )
-    {
-      BRepBuilderAPI_MakeFace aMakeFace( aWire, Standard_True );
-      aMakeFace.Build();
-      if( aMakeFace.IsDone() )
-        return aMakeFace.Face();
-    }
-  }
-  return TopoDS_Face();
+  AddReferenceObject( theObject, DataTag_GeometryObject );
+}
+
+void HYDROData_Zone::SetGeometryObject( const int                       theIndex,
+                                        const Handle(HYDROData_Object)& theObject )
+{
+  SetReferenceObject( theObject, DataTag_GeometryObject, theIndex );
+}
+
+void HYDROData_Zone::SetGeometryObjects( const HYDROData_SequenceOfObjects& theObjects )
+{
+  SetReferenceObjects( theObjects, DataTag_GeometryObject );
 }
 
-QString HYDROData_Zone::getPythonKindId() const
+Handle(HYDROData_Object) HYDROData_Zone::GetGeometryObject( const int theIndex ) const
 {
-  return QString( PYTHON_ZONE_ID );
+  return Handle(HYDROData_Object)::DownCast( 
+           GetReferenceObject( DataTag_GeometryObject, theIndex ) );
 }
 
+HYDROData_SequenceOfObjects HYDROData_Zone::GetGeometryObjects() const
+{
+  return GetReferenceObjects( DataTag_GeometryObject );
+}
+
+void HYDROData_Zone::RemoveGeometryObjects()
+{
+  ClearReferenceObjects( DataTag_GeometryObject );
+}
+
+
 
 
index b9a86cbf7681ec49bfb297ebea9f681e9b3c75b8..4ef2dd9c96afd54099705526b7642196ee2fd112 100644 (file)
@@ -2,17 +2,18 @@
 #ifndef HYDROData_Zone_HeaderFile
 #define HYDROData_Zone_HeaderFile
 
-#include <HYDROData_Domain.h>
+#include <HYDROData_Entity.h>
 
-class Handle(HYDROData_Polyline);
+class Handle(HYDROData_Object);
+class TopoDS_Shape;
 
-DEFINE_STANDARD_HANDLE(HYDROData_Zone, HYDROData_Domain)
+DEFINE_STANDARD_HANDLE(HYDROData_Zone, HYDROData_Entity)
 
 
 /**\class HYDROData_Zone
  * \brief Class that stores/retreives information about the 2d face.
  */
-class HYDROData_Zone : public HYDROData_Domain
+class HYDROData_Zone : public HYDROData_Entity
 {
 
 protected:
@@ -21,8 +22,9 @@ protected:
    */
   enum DataTag
   {
-    DataTag_First = HYDROData_Domain::DataTag_First + 100, ///< first tag, to reserve
-    DataTag_Polyline,     ///< reference polyline
+    DataTag_First = HYDROData_Entity::DataTag_First + 100, ///< first tag, to reserve
+    DataTag_Shape,            ///< reference shape
+    DataTag_GeometryObject,   ///< reference geometry objects
   };
 
 public:
@@ -40,34 +42,56 @@ public:
 
 
   /**
-   * Sets reference polyline object for zone.
+   * Sets the shape of the zone.
    */
-  HYDRODATA_EXPORT virtual void SetPolyline( const Handle(HYDROData_Polyline)& thePolyline );
+  HYDRODATA_EXPORT virtual void SetShape( const TopoDS_Shape& theShape );
 
   /**
-   * Returns reference polyline object of zone.
+   * Returns the shape of the zone.
    */
-  HYDRODATA_EXPORT virtual Handle(HYDROData_Polyline) GetPolyline() const;
+  HYDRODATA_EXPORT virtual TopoDS_Shape GetShape() const;
+
+
+  /**
+   * Returns number of geometry objects for zone.
+   */
+  HYDRODATA_EXPORT virtual int NbGeometryObjects() const;
 
   /**
-   * Remove reference polyline object of zone.
+   * Add new one geometry object for zone.
    */
-  HYDRODATA_EXPORT virtual void RemovePolyline();
+  HYDRODATA_EXPORT virtual void AddGeometryObject( const Handle(HYDROData_Object)& theObject );
 
+  /**
+   * Replace the geometry object for zone.
+   */
+  HYDRODATA_EXPORT virtual void SetGeometryObject( const int                       theIndex,
+                                                   const Handle(HYDROData_Object)& theObject );
 
   /**
-   * Returns data of object wrapped to QVariant.
-   * Reimplemented to wrap and return saved 2d polyline.
+   * Sets the geometry object for zone.
    */
-  //HYDRODATA_EXPORT virtual QVariant GetDataVariant();
+  HYDRODATA_EXPORT virtual void SetGeometryObjects( const HYDROData_SequenceOfObjects& theObjects );
 
   /**
-   * Returns the shape of the the object (redefined method).
+   * Returns geometry object of zone by index.
    */
-  HYDRODATA_EXPORT TopoDS_Face Face() const;
+  HYDRODATA_EXPORT virtual Handle(HYDROData_Object) GetGeometryObject( const int theIndex ) const;
+
+  /**
+   * Returns all geometry objects of zone.
+   */
+  HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetGeometryObjects() const;
+
+  /**
+   * Removes all geometry objects from zone.
+   */
+  HYDRODATA_EXPORT virtual void RemoveGeometryObjects();
+
 
 protected:
 
+  friend class HYDROData_Region;
   friend class HYDROData_Iterator;
 
   /**
@@ -81,10 +105,6 @@ protected:
    */
   ~HYDROData_Zone();
 
-  /**
-   * Returns id for creation of object in python scripting.
-   */
-  virtual QString getPythonKindId() const;
 };
 
 #endif
diff --git a/src/HYDROData/HYDROOperations_BSpline.cxx b/src/HYDROData/HYDROOperations_BSpline.cxx
deleted file mode 100644 (file)
index 419788e..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-#include<HYDROOperations_BSpline.h>
-
-#include<TColgp_HArray1OfPnt.hxx>
-#include<GeomAPI_Interpolate.hxx>
-#include<GeomConvert_BSplineCurveToBezierCurve.hxx>
-#include<Geom_BezierCurve.hxx>
-
-HYDROOperations_BSpline::HYDROOperations_BSpline(
-  const QList<double>& thePoints,
-  const double theZValue,
-  const bool theIsClosed)
-{
-  // fill array for algorithm by the received coordinates
-  int aLen = thePoints.size() / 2;
-  Handle(TColgp_HArray1OfPnt) aHCurvePoints = new TColgp_HArray1OfPnt (1, aLen);
-  QList<double>::const_iterator aListIter = thePoints.begin();
-  for (int ind = 1; ind <= aLen; ind++) {
-    gp_Pnt aPnt(gp::Origin());
-    aPnt.SetX(*aListIter);
-    aListIter++;
-    aPnt.SetY(*aListIter);
-    aListIter++;
-    aPnt.SetZ(theZValue);
-    aHCurvePoints->SetValue(ind, aPnt);
-  }
-  // compute BSpline
-  GeomAPI_Interpolate aGBC(aHCurvePoints, theIsClosed, gp::Resolution());
-  aGBC.Perform();
-  if (aGBC.IsDone()) {
-    myCurve = aGBC.Curve();
-  }
-}
-
-QPainterPath HYDROOperations_BSpline::ComputePath() const
-{
-  QPainterPath aResult;
-  if (myCurve.IsNull()) // returns an empty Path if original curve is invalid
-    return aResult;
-  GeomConvert_BSplineCurveToBezierCurve aConverter(myCurve);
-  int a, aNumArcs = aConverter.NbArcs();
-  for(a = 1; a <= aNumArcs; a++) {
-    Handle(Geom_BezierCurve) anArc = aConverter.Arc(a);
-    if (a == 1) { // set a start point
-      gp_Pnt aStart = anArc->StartPoint();
-      aResult.moveTo(aStart.X(), aStart.Y());
-    }
-    gp_Pnt anEnd = anArc->EndPoint();
-    if (anArc->NbPoles() == 3) { // quadric segment in the path (pole 1 is start, pole 3 is end)
-      gp_Pnt aPole = anArc->Pole(2);
-      aResult.quadTo(aPole.X(), aPole.Y(), anEnd.X(), anEnd.Y());
-    } else if (anArc->NbPoles() == 4) { // cubic segment (usually this is used)
-      gp_Pnt aPole1 = anArc->Pole(2);
-      gp_Pnt aPole2 = anArc->Pole(3);
-      aResult.cubicTo(
-        aPole1.X(), aPole1.Y(), aPole2.X(), aPole2.Y(), anEnd.X(), anEnd.Y());
-    } else { // error, another number of poles is not supported
-      return QPainterPath();
-    }
-  }
-  return aResult;
-}
diff --git a/src/HYDROData/HYDROOperations_BSpline.h b/src/HYDROData/HYDROOperations_BSpline.h
deleted file mode 100644 (file)
index 01df602..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-#ifndef HYDROOperations_BSpline_HeaderFile
-#define HYDROOperations_BSpline_HeaderFile
-
-#include <HYDROData.h>
-#include <QList>
-#include <QPainterPath>
-#include <Geom_BSplineCurve.hxx>
-
-/**\class HYDROOperations_BSpline
- *
- * \brief Allows to work with splines: create, convert to Qt ToolPath.
- *
- * Uses GEOM module for creation of BSplines, OCCT algorithms for 
- * manipulation and conversion.
- */
-
-class HYDRODATA_EXPORT HYDROOperations_BSpline
-{
-public:
-
-  //! Creates a spline by list of coordinates: pairs X and Y
-  //! \param thePoints coordinates in format X1, Y1, X2, Y2, etc. must be even number of elements
-  //! \param theZValue constant value of the spline Z coordinate
-  //! \param theIsClosed flag indicating that the result spline should be closed
-  HYDROOperations_BSpline(const QList<double>& thePoints,
-                          const double theZValue,
-                          const bool theIsClosed);
-  
-  //! Returns the BSpline curve passing through the points
-  //! \returns Null if Computation of BSpline was failed
-  Handle(Geom_BSplineCurve) Curve() const {return myCurve;}
-  
-  //! Performs conversion from BSpline curve to QPainterPath made from Bezier curves
-  //! \returns computed PainterPath, not stored in this class, so calling of this method is not fast
-  QPainterPath ComputePath() const;
-private:
-  Handle(Geom_BSplineCurve) myCurve; ///< resulting BSpline, null if something is wrong
-};
-
-#endif
diff --git a/src/HYDROData/HYDROOperations_Factory.cxx b/src/HYDROData/HYDROOperations_Factory.cxx
deleted file mode 100644 (file)
index ffe38aa..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-#include<HYDROOperations_Factory.h>
-
-#include<HYDROData_Document.h>
-#include<HYDROData_Iterator.h>
-
-#include<ImageComposer_ColorMaskOperator.h>
-#include<ImageComposer_CropOperator.h>
-#include<ImageComposer_CutOperator.h>
-#include<ImageComposer_FuseOperator.h>
-
-#include <typeinfo>
-
-// global instance
-HYDROOperations_Factory* FACTORY = 0;
-
-HYDROOperations_Factory* HYDROOperations_Factory::Factory()
-{
-  if (!FACTORY) {
-    FACTORY = new HYDROOperations_Factory;
-    // default operations
-    REGISTER_HYDRO_OPERATION(ImageComposer_ColorMaskOperator)
-    REGISTER_HYDRO_OPERATION(ImageComposer_CropOperator)
-    REGISTER_HYDRO_OPERATION(ImageComposer_CutOperator)
-    REGISTER_HYDRO_OPERATION(ImageComposer_FuseOperator)
-  }
-  return FACTORY;
-}
-
-void HYDROOperations_Factory::Register(
-  ImageComposer_Operator* theOperator)
-{
-  if ( !theOperator )
-    return;
-
-  FACTORY->myOps[ theOperator->name() ] = theOperator;
-}
-
-HYDROOperations_Factory::HYDROOperations_Factory()
-{
-}
-
-ImageComposer_Operator* HYDROOperations_Factory::Operator(
-  Handle(HYDROData_Image) theImage ) const
-{
-  // retreive operator instance by name
-  ImageComposer_Operator* anOp = Operator( theImage->OperatorName() );
-  if ( !anOp )
-    return anOp;
-
-  // fill arguments of the operator from theImage
-  anOp->setBinArgs( theImage->Args() );
-
-  return anOp;
-}
-
-ImageComposer_Operator* HYDROOperations_Factory::Operator(const QString theName) const
-{
-  return myOps.contains( theName ) ? myOps[ theName ] : NULL;
-}
-
-Handle(HYDROData_Image) HYDROOperations_Factory::CreateImage(
-  Handle(HYDROData_Document) theDoc, const ImageComposer_Operator* theOperator)
-{
-  // create an object
-  Handle(HYDROData_Image) anImage = 
-    Handle(HYDROData_Image)::DownCast(theDoc->CreateObject(KIND_IMAGE));
-  // get data from operation
-  if (theOperator) {
-    anImage->SetOperatorName( theOperator->name() );
-    anImage->SetArgs( theOperator->getBinArgs() );
-  }
-  return anImage;
-}
diff --git a/src/HYDROData/HYDROOperations_Factory.h b/src/HYDROData/HYDROOperations_Factory.h
deleted file mode 100644 (file)
index 310280a..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-#ifndef HYDROOperations_Factory_HeaderFile
-#define HYDROOperations_Factory_HeaderFile
-
-#include <HYDROData.h>
-#include <HYDROData_Image.h>
-#include <QMap>
-
-class ImageComposer_Operator;
-class Handle_HYDROData_Document;
-
-/**\class HYDROOperations_Factory
- *
- * \brief This class provides the unified management of operations on images.
- *
- * Object is created as one global instance and allows to register and launch
- * all registered operations in general way. To register a new operation just
- * call REGISTER_HYDRO_OPERATION(operation_name) in some method implementation.
- * This macro will call constructor of this operation (it must inherit
- * ImageComposer_Operator) and factory will set up arguments and call this 
- * operator by demand.
- */
-
-class HYDROOperations_Factory
-{
-public:
-
-  //! Returns the global factory
-  HYDRODATA_EXPORT static HYDROOperations_Factory* Factory();
-  
-  /**
-   * Registers the operator by the name, used by REGISTER_HYDRO_OPERATION macro
-   * \param theOperator new instance of the operator that will be used for
-   *                    processing of operation with such kind
-   */
-  HYDRODATA_EXPORT static void Register(
-    ImageComposer_Operator* theOperator);
-  
-  /**
-   * Creates a new Image object in the data structure by the operator data.
-   * \param theDoc document where it must be created
-   * \param theOperator base operator for this Image: will be used in "Update" to recompute the image
-   * \returns created object related to the data structure
-   */
-  HYDRODATA_EXPORT Handle(HYDROData_Image) CreateImage(
-    Handle_HYDROData_Document theDoc, const ImageComposer_Operator* theOperator);
-
-  /**
-   * Returns the operator, initialized by the properties of theImage
-   * \param theImage data structures object, that contains all arguments 
-   *                 required for creation of operation
-   * \returns NULL if operator type is unknown
-   */
-  HYDRODATA_EXPORT ImageComposer_Operator* Operator(
-    Handle(HYDROData_Image) theImage) const;
-
-  /**
-   * Returns the appropriate operator by the name
-   * \param theName name of the operator, equals to the operation_name constructor
-   * \returns NULL if operator with such name is not registered yet
-   */
-  HYDRODATA_EXPORT ImageComposer_Operator* Operator(const QString theName) const;
-
-protected:
-
-  //! Not public constructor that creates only one, global instance of this factory.
-  HYDROOperations_Factory();  
-
-private:
-  //! Map that stores all operators, isentified by strings
-  typedef QMap<QString, ImageComposer_Operator*> FactoryOperators;
-  
-  FactoryOperators myOps; ///< all operators stored by a factory
-};
-
-/**
- * Macro that is used for registered operators, see C++ of this class to see
- * example of hte registration.
- */
-#define REGISTER_HYDRO_OPERATION(operation_name) \
-  HYDROOperations_Factory::Factory()->Register(new operation_name);
-
-#endif
diff --git a/src/HYDROData/test_HYDROData_BSplineOperation.cxx b/src/HYDROData/test_HYDROData_BSplineOperation.cxx
new file mode 100644 (file)
index 0000000..3365876
--- /dev/null
@@ -0,0 +1,64 @@
+#include<test_HYDROData_BSplineOperation.h>
+
+#include <HYDROData_BSplineOperation.h>
+#include <gp_Pnt.hxx>
+#include <QTransform>
+
+void test_HYDROData_BSplineOperation::testCurve()
+{
+  // prepare points: function of sin(x)
+  QList<double> aPoints;
+  double x;
+  for(x = 0; x < 6.28; x += 0.1)
+    aPoints<<x<<sin(x);
+  // compute BSpline
+  HYDROData_BSplineOperation aBSpline(aPoints, 0, false);
+  Handle(Geom_BSplineCurve) aBS = aBSpline.Curve();
+  CPPUNIT_ASSERT(!aBS.IsNull());
+  CPPUNIT_ASSERT(!aBS->IsClosed());
+  CPPUNIT_ASSERT_EQUAL(aBS->Continuity(), GeomAbs_C2);
+  // check that values of BSpline are not far from original "sin" function
+  // in all points of the curve
+  for(x = 0; x < 6.29; x += 0.001) {
+    double aDiff = aBS->Value(x).Y() - sin(aBS->Value(x).X());
+    if (aDiff < 0) aDiff = -aDiff;
+    CPPUNIT_ASSERT(aDiff < 3.e-6); // this number is found manually
+  }
+}
+
+void test_HYDROData_BSplineOperation::testPath()
+{
+  // prepare points: function of sin(x)
+  static const double aScale = 10000000.;
+  QList<double> aPoints;
+  double x;
+  for(x = 0; x < 6.28; x += 0.1)
+    aPoints<<x*aScale<<sin(x) * aScale;
+  // convert to QPainterPath
+  HYDROData_BSplineOperation aBSpline(aPoints, 0, false);
+  CPPUNIT_ASSERT(!aBSpline.Curve().IsNull());
+  QPainterPath aPath = aBSpline.ComputePath();
+  CPPUNIT_ASSERT(!aPath.isEmpty());
+  
+  /*
+  QImage aPic(1300, 600, QImage::Format_RGB32);
+  QPainter aPainter(&aPic);
+  aPainter.setBrush(QBrush(Qt::white));
+  aPainter.drawPath(aPath);
+  aPic.save("pic.bmp");
+  */
+     
+  // check that values of Path are not far from original "sin" function
+  // in all points of the curve
+  QList<QPolygonF> aPolyF = aPath.toSubpathPolygons(QTransform());
+  QList<QPolygonF>::iterator aFIter = aPolyF.begin();
+  for(; aFIter != aPolyF.end();aFIter++) {
+    QPolygon aPoly = aFIter->toPolygon();
+    QPolygon::iterator aPoints = aPoly.begin();
+    for(; aPoints != aPoly.end(); aPoints++) {
+      double aDiff = aPoints->y() / aScale - sin(aPoints->x() / aScale);
+      if (aDiff < 0) aDiff = -aDiff;
+      CPPUNIT_ASSERT(aDiff < 4.e-6); // this number is found manually
+    }
+  }
+}
diff --git a/src/HYDROData/test_HYDROData_BSplineOperation.h b/src/HYDROData/test_HYDROData_BSplineOperation.h
new file mode 100644 (file)
index 0000000..c7d8aa8
--- /dev/null
@@ -0,0 +1,26 @@
+#include <cppunit/extensions/HelperMacros.h>
+
+class test_HYDROData_BSplineOperation : public CppUnit::TestFixture {
+  CPPUNIT_TEST_SUITE(test_HYDROData_BSplineOperation);
+  CPPUNIT_TEST(testCurve);
+  CPPUNIT_TEST(testPath);
+  CPPUNIT_TEST_SUITE_END();
+
+private:
+
+public:
+
+  void setUp() {}
+
+  void tearDown() {}
+
+  // checks generation of BSpline curve by points
+  void testCurve();
+
+  // checks generation of QPainterPath
+  void testPath();
+
+};
+
+CPPUNIT_TEST_SUITE_REGISTRATION(test_HYDROData_BSplineOperation);
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(test_HYDROData_BSplineOperation, "HYDROData_BSplineOperation");
diff --git a/src/HYDROData/test_HYDROData_OperationsFactory.cxx b/src/HYDROData/test_HYDROData_OperationsFactory.cxx
new file mode 100644 (file)
index 0000000..bea1c98
--- /dev/null
@@ -0,0 +1,86 @@
+#include <test_HYDROData_OperationsFactory.h>
+
+#include <HYDROData_Document.h>
+#include <HYDROData_Image.h>
+#include <HYDROData_Polyline.h>
+#include <HYDROData_OperationsFactory.h>
+
+#include <ImageComposer_CropOperator.h>
+
+#include <QPainter>
+
+void test_HYDROData_OperationsFactory::testCreate()
+{
+  Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+  
+  HYDROData_OperationsFactory* aFactory = HYDROData_OperationsFactory::Factory();
+  CPPUNIT_ASSERT(aFactory);
+  Handle(HYDROData_Image) anImage = aFactory->CreateImage(aDoc, NULL);
+  CPPUNIT_ASSERT(!anImage.IsNull());
+  CPPUNIT_ASSERT(anImage->Image().isNull());
+  
+  aDoc->Close();
+}
+
+static QImage TestImage() {
+  QImage aPic(50, 40, QImage::Format_RGB32);
+  aPic.fill(Qt::white);
+  QPainter aPainter(&aPic);
+  aPainter.drawEllipse(6, 7, 38, 30);
+  aPainter.drawLine(0, 40, 10, 0);
+  aPainter.drawLine(10, 0, 25, 35);
+  aPainter.drawLine(25, 35, 40, 0);
+  aPainter.drawLine(40, 0, 50, 40);
+  return aPic;
+}
+
+void test_HYDROData_OperationsFactory::testCrop()
+{
+  Handle(HYDROData_Document) aDoc = HYDROData_Document::Document( 1 );
+  HYDROData_OperationsFactory* aFactory = HYDROData_OperationsFactory::Factory();
+  
+  // prepare the original image and crop-path
+  Handle(HYDROData_Image) anOriImage = 
+    Handle(HYDROData_Image)::DownCast( aDoc->CreateObject( KIND_IMAGE ) );
+
+  QImage aTestImage = TestImage();
+  anOriImage->SetImage( aTestImage );
+
+  Handle(HYDROData_Polyline) aCropPolyline = 
+    Handle(HYDROData_Polyline)::DownCast( aDoc->CreateObject( KIND_POLYLINE ) );
+
+  HYDROData_Polyline::PolylineData aPolylineData;
+
+  PolylineSection aPolylineSect;
+
+  aPolylineSect.myCoords << 25 <<  0 << 0;
+  aPolylineSect.myCoords <<  0 << 20 << 0;
+  aPolylineSect.myCoords << 25 << 40 << 0;
+  aPolylineSect.myCoords << 50 << 20 << 0;
+
+  aPolylineData << aPolylineSect;
+
+  aCropPolyline->setPolylineData( aPolylineData );
+
+  // prepare Composer Operation
+  ImageComposer_Operator* aCropOp = 
+    aFactory->Operator( ImageComposer_CropOperator::Type() );
+  
+  CPPUNIT_ASSERT( aCropOp );
+
+  aCropOp->setArgs( Qt::red );
+
+  // create crop - image 
+  Handle(HYDROData_Image) aCropImage = aFactory->CreateImage( aDoc, aCropOp );
+  CPPUNIT_ASSERT( !aCropImage.IsNull() );
+
+  aCropImage->AppendReference( anOriImage );
+  aCropImage->AppendReference( aCropPolyline );
+  aCropImage->Update();
+
+  // check crop operation was performed
+  CPPUNIT_ASSERT( !aCropImage->Image().isNull() );
+  CPPUNIT_ASSERT( aCropImage->Image() != aTestImage );
+  
+  aDoc->Close();
+}
diff --git a/src/HYDROData/test_HYDROData_OperationsFactory.h b/src/HYDROData/test_HYDROData_OperationsFactory.h
new file mode 100644 (file)
index 0000000..7c033a9
--- /dev/null
@@ -0,0 +1,25 @@
+#include <cppunit/extensions/HelperMacros.h>
+
+class test_HYDROData_OperationsFactory : public CppUnit::TestFixture {
+  CPPUNIT_TEST_SUITE(test_HYDROData_OperationsFactory);
+  CPPUNIT_TEST(testCreate);
+  CPPUNIT_TEST(testCrop);
+  CPPUNIT_TEST_SUITE_END();
+
+private:
+
+public:
+
+  void setUp() {}
+
+  void tearDown() {}
+
+  // checks creation of images using null operators
+  void testCreate();
+
+  // checks creation of images using crop operator
+  void testCrop();
+};
+
+CPPUNIT_TEST_SUITE_REGISTRATION(test_HYDROData_OperationsFactory);
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(test_HYDROData_OperationsFactory, "HYDROData_OperationsFactory");
diff --git a/src/HYDROData/test_HYDROOperations_BSpline.cxx b/src/HYDROData/test_HYDROOperations_BSpline.cxx
deleted file mode 100644 (file)
index d889abb..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-#include<test_HYDROOperations_BSpline.h>
-
-#include <HYDROOperations_BSpline.h>
-#include <gp_Pnt.hxx>
-#include <QTransform>
-
-void test_HYDROOperations_BSpline::testCurve()
-{
-  // prepare points: function of sin(x)
-  QList<double> aPoints;
-  double x;
-  for(x = 0; x < 6.28; x += 0.1)
-    aPoints<<x<<sin(x);
-  // compute BSpline
-  HYDROOperations_BSpline aBSpline(aPoints, 0, false);
-  Handle(Geom_BSplineCurve) aBS = aBSpline.Curve();
-  CPPUNIT_ASSERT(!aBS.IsNull());
-  CPPUNIT_ASSERT(!aBS->IsClosed());
-  CPPUNIT_ASSERT_EQUAL(aBS->Continuity(), GeomAbs_C2);
-  // check that values of BSpline are not far from original "sin" function
-  // in all points of the curve
-  for(x = 0; x < 6.29; x += 0.001) {
-    double aDiff = aBS->Value(x).Y() - sin(aBS->Value(x).X());
-    if (aDiff < 0) aDiff = -aDiff;
-    CPPUNIT_ASSERT(aDiff < 3.e-6); // this number is found manually
-  }
-}
-
-void test_HYDROOperations_BSpline::testPath()
-{
-  // prepare points: function of sin(x)
-  static const double aScale = 10000000.;
-  QList<double> aPoints;
-  double x;
-  for(x = 0; x < 6.28; x += 0.1)
-    aPoints<<x*aScale<<sin(x) * aScale;
-  // convert to QPainterPath
-  HYDROOperations_BSpline aBSpline(aPoints, 0, false);
-  CPPUNIT_ASSERT(!aBSpline.Curve().IsNull());
-  QPainterPath aPath = aBSpline.ComputePath();
-  CPPUNIT_ASSERT(!aPath.isEmpty());
-  
-  /*
-  QImage aPic(1300, 600, QImage::Format_RGB32);
-  QPainter aPainter(&aPic);
-  aPainter.setBrush(QBrush(Qt::white));
-  aPainter.drawPath(aPath);
-  aPic.save("pic.bmp");
-  */
-     
-  // check that values of Path are not far from original "sin" function
-  // in all points of the curve
-  QList<QPolygonF> aPolyF = aPath.toSubpathPolygons(QTransform());
-  QList<QPolygonF>::iterator aFIter = aPolyF.begin();
-  for(; aFIter != aPolyF.end();aFIter++) {
-    QPolygon aPoly = aFIter->toPolygon();
-    QPolygon::iterator aPoints = aPoly.begin();
-    for(; aPoints != aPoly.end(); aPoints++) {
-      double aDiff = aPoints->y() / aScale - sin(aPoints->x() / aScale);
-      if (aDiff < 0) aDiff = -aDiff;
-      CPPUNIT_ASSERT(aDiff < 4.e-6); // this number is found manually
-    }
-  }
-}
diff --git a/src/HYDROData/test_HYDROOperations_BSpline.h b/src/HYDROData/test_HYDROOperations_BSpline.h
deleted file mode 100644 (file)
index 6eb1105..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-#include <cppunit/extensions/HelperMacros.h>
-
-class test_HYDROOperations_BSpline : public CppUnit::TestFixture {
-  CPPUNIT_TEST_SUITE(test_HYDROOperations_BSpline);
-  CPPUNIT_TEST(testCurve);
-  CPPUNIT_TEST(testPath);
-  CPPUNIT_TEST_SUITE_END();
-
-private:
-
-public:
-
-  void setUp() {}
-
-  void tearDown() {}
-
-  // checks generation of BSpline curve by points
-  void testCurve();
-
-  // checks generation of QPainterPath
-  void testPath();
-
-};
-
-CPPUNIT_TEST_SUITE_REGISTRATION(test_HYDROOperations_BSpline);
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(test_HYDROOperations_BSpline, "HYDROOperations_BSpline");
diff --git a/src/HYDROData/test_HYDROOperations_Factory.cxx b/src/HYDROData/test_HYDROOperations_Factory.cxx
deleted file mode 100644 (file)
index f09794d..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-#include <test_HYDROOperations_Factory.h>
-
-#include <HYDROData_Document.h>
-#include <HYDROData_Image.h>
-#include <HYDROData_Polyline.h>
-#include <HYDROOperations_Factory.h>
-
-#include <ImageComposer_CropOperator.h>
-
-#include <QPainter>
-
-void test_HYDROOperations_Factory::testCreate()
-{
-  Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
-  
-  HYDROOperations_Factory* aFactory = HYDROOperations_Factory::Factory();
-  CPPUNIT_ASSERT(aFactory);
-  Handle(HYDROData_Image) anImage = aFactory->CreateImage(aDoc, NULL);
-  CPPUNIT_ASSERT(!anImage.IsNull());
-  CPPUNIT_ASSERT(anImage->Image().isNull());
-  
-  aDoc->Close();
-}
-
-static QImage TestImage() {
-  QImage aPic(50, 40, QImage::Format_RGB32);
-  aPic.fill(Qt::white);
-  QPainter aPainter(&aPic);
-  aPainter.drawEllipse(6, 7, 38, 30);
-  aPainter.drawLine(0, 40, 10, 0);
-  aPainter.drawLine(10, 0, 25, 35);
-  aPainter.drawLine(25, 35, 40, 0);
-  aPainter.drawLine(40, 0, 50, 40);
-  return aPic;
-}
-
-void test_HYDROOperations_Factory::testCrop()
-{
-  Handle(HYDROData_Document) aDoc = HYDROData_Document::Document( 1 );
-  HYDROOperations_Factory* aFactory = HYDROOperations_Factory::Factory();
-  
-  // prepare the original image and crop-path
-  Handle(HYDROData_Image) anOriImage = 
-    Handle(HYDROData_Image)::DownCast( aDoc->CreateObject( KIND_IMAGE ) );
-
-  QImage aTestImage = TestImage();
-  anOriImage->SetImage( aTestImage );
-
-  Handle(HYDROData_Polyline) aCropPolyline = 
-    Handle(HYDROData_Polyline)::DownCast( aDoc->CreateObject( KIND_POLYLINE ) );
-
-  HYDROData_Polyline::PolylineData aPolylineData;
-
-  PolylineSection aPolylineSect;
-
-  aPolylineSect.myCoords << 25 <<  0 << 0;
-  aPolylineSect.myCoords <<  0 << 20 << 0;
-  aPolylineSect.myCoords << 25 << 40 << 0;
-  aPolylineSect.myCoords << 50 << 20 << 0;
-
-  aPolylineData << aPolylineSect;
-
-  aCropPolyline->setPolylineData( aPolylineData );
-
-  // prepare Composer Operation
-  ImageComposer_Operator* aCropOp = 
-    aFactory->Operator( ImageComposer_CropOperator::Type() );
-  
-  CPPUNIT_ASSERT( aCropOp );
-
-  aCropOp->setArgs( Qt::red );
-
-  // create crop - image 
-  Handle(HYDROData_Image) aCropImage = aFactory->CreateImage( aDoc, aCropOp );
-  CPPUNIT_ASSERT( !aCropImage.IsNull() );
-
-  aCropImage->AppendReference( anOriImage );
-  aCropImage->AppendReference( aCropPolyline );
-  aCropImage->Update();
-
-  // check crop operation was performed
-  CPPUNIT_ASSERT( !aCropImage->Image().isNull() );
-  CPPUNIT_ASSERT( aCropImage->Image() != aTestImage );
-  
-  aDoc->Close();
-}
diff --git a/src/HYDROData/test_HYDROOperations_Factory.h b/src/HYDROData/test_HYDROOperations_Factory.h
deleted file mode 100644 (file)
index fa7e917..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-#include <cppunit/extensions/HelperMacros.h>
-
-class test_HYDROOperations_Factory : public CppUnit::TestFixture {
-  CPPUNIT_TEST_SUITE(test_HYDROOperations_Factory);
-  CPPUNIT_TEST(testCreate);
-  CPPUNIT_TEST(testCrop);
-  CPPUNIT_TEST_SUITE_END();
-
-private:
-
-public:
-
-  void setUp() {}
-
-  void tearDown() {}
-
-  // checks creation of images using null operators
-  void testCreate();
-
-  // checks creation of images using crop operator
-  void testCrop();
-};
-
-CPPUNIT_TEST_SUITE_REGISTRATION(test_HYDROOperations_Factory);
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(test_HYDROOperations_Factory, "HYDROOperations_Factory");
index 0a8e21c8c9bccb73c689d0ce489d73ee74542098..7db85c3707e928c96bfe6b4680d90246b80231db 100644 (file)
@@ -14,6 +14,8 @@ set(PROJECT_HEADERS
     HYDROGUI_Displayer.h
     HYDROGUI_ExportImageOp.h
     HYDROGUI_GVSelector.h
+    HYDROGUI_ImmersibleZoneDlg.h
+    HYDROGUI_ImmersibleZoneOp.h
     HYDROGUI_ImportBathymetryDlg.h
     HYDROGUI_ImportBathymetryOp.h
     HYDROGUI_ImportImageDlg.h
@@ -46,8 +48,6 @@ set(PROJECT_HEADERS
     HYDROGUI_UpdateFlags.h
     HYDROGUI_UpdateImageOp.h
     HYDROGUI_VisualStateOp.h
-    HYDROGUI_ZoneDlg.h
-    HYDROGUI_ZoneOp.h
 )
 
 QT4_WRAP_CPP(PROJECT_HEADERS_MOC ${PROJECT_HEADERS})
@@ -64,6 +64,8 @@ set(PROJECT_SOURCES
     HYDROGUI_Displayer.cxx
     HYDROGUI_ExportImageOp.cxx
     HYDROGUI_GVSelector.cxx
+    HYDROGUI_ImmersibleZoneDlg.cxx
+    HYDROGUI_ImmersibleZoneOp.cxx
     HYDROGUI_ImportBathymetryDlg.cxx
     HYDROGUI_ImportBathymetryOp.cxx
     HYDROGUI_ImportImageDlg.cxx
@@ -95,8 +97,6 @@ set(PROJECT_SOURCES
     HYDROGUI_TwoImagesOp.cxx
     HYDROGUI_UpdateImageOp.cxx
     HYDROGUI_VisualStateOp.cxx
-    HYDROGUI_ZoneDlg.cxx
-    HYDROGUI_ZoneOp.cxx
 )
 
 add_definitions(
index c5cbe2e53aff1b93fd57db246e60a469520a67eb..6e037af8fa645c913bbaf8e78e159b5ea3678bbc 100644 (file)
                                RelativePath=".\HYDROGUI_GVSelector.cxx"
                                >
                        </File>
+                       <File
+                               RelativePath=".\HYDROGUI_ImmersibleZoneDlg.cxx"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\HYDROGUI_ImmersibleZoneOp.cxx"
+                               >
+                       </File>
                        <File
                                RelativePath=".\HYDROGUI_ImportBathymetryDlg.cxx"
                                >
                                RelativePath=".\HYDROGUI_ShowHideOp.cxx"
                                >
                        </File>
-                       <File
-                               RelativePath=".\HYDROGUI_SplitZonesTool.cxx"
-                               >
-                       </File>
                        <File
                                RelativePath=".\HYDROGUI_Tool.cxx"
                                >
                                RelativePath=".\HYDROGUI_VisualStateOp.cxx"
                                >
                        </File>
-                       <File
-                               RelativePath=".\HYDROGUI_ZoneDlg.cxx"
-                               >
-                       </File>
-                       <File
-                               RelativePath=".\HYDROGUI_ZoneOp.cxx"
-                               >
-                       </File>
                        <Filter
                                Name="Link"
                                >
                                        />
                                </FileConfiguration>
                        </File>
+                       <File
+                               RelativePath=".\HYDROGUI_ImmersibleZoneDlg.h"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCustomBuildTool"
+                                               Description="Generating moc_$(InputName).cxx"
+                                               CommandLine="$(QTDIR)\bin\moc.exe $(InputPath) -o moc\moc_$(InputName).cxx&#x0D;&#x0A;"
+                                               Outputs="moc/moc_$(InputName).cxx"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath=".\HYDROGUI_ImmersibleZoneOp.h"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCustomBuildTool"
+                                               Description="Generating moc_$(InputName).cxx"
+                                               CommandLine="$(QTDIR)\bin\moc.exe $(InputPath) -o moc\moc_$(InputName).cxx&#x0D;&#x0A;"
+                                               Outputs="moc/moc_$(InputName).cxx"
+                                       />
+                               </FileConfiguration>
+                       </File>
                        <File
                                RelativePath=".\HYDROGUI_ImportBathymetryDlg.h"
                                >
                                        <Tool
                                                Name="VCCustomBuildTool"
                                                Description="Generating moc_$(InputName).cxx"
-                                               CommandLine="$(QTDIR)\bin\moc.exe $(InputPath) -o moc\moc_$(InputName).cxx"
+                                               CommandLine="$(QTDIR)\bin\moc.exe $(InputPath) -o moc\moc_$(InputName).cxx&#x0D;&#x0A;"
                                                Outputs="moc/moc_$(InputName).cxx"
                                        />
                                </FileConfiguration>
                                        />
                                </FileConfiguration>
                        </File>
-                       <File
-                               RelativePath=".\HYDROGUI_SplitZonesTool.h"
-                               >
-                       </File>
                        <File
                                RelativePath=".\HYDROGUI_Tool.h"
                                >
                                        />
                                </FileConfiguration>
                        </File>
-                       <File
-                               RelativePath=".\HYDROGUI_ZoneDlg.h"
-                               >
-                               <FileConfiguration
-                                       Name="Debug|Win32"
-                                       >
-                                       <Tool
-                                               Name="VCCustomBuildTool"
-                                               Description="Generating moc_$(InputName).cxx"
-                                               CommandLine="$(QTDIR)\bin\moc.exe $(InputPath) -o moc\moc_$(InputName).cxx&#x0D;&#x0A;"
-                                               Outputs="moc/moc_$(InputName).cxx"
-                                       />
-                               </FileConfiguration>
-                       </File>
-                       <File
-                               RelativePath=".\HYDROGUI_ZoneOp.h"
-                               >
-                               <FileConfiguration
-                                       Name="Debug|Win32"
-                                       >
-                                       <Tool
-                                               Name="VCCustomBuildTool"
-                                               Description="Generating moc_$(InputName).cxx"
-                                               CommandLine="$(QTDIR)\bin\moc.exe $(InputPath) -o moc\moc_$(InputName).cxx&#x0D;&#x0A;"
-                                               Outputs="moc/moc_$(InputName).cxx"
-                                       />
-                               </FileConfiguration>
-                       </File>
                </Filter>
                <Filter
                        Name="Resource Files"
                                RelativePath=".\moc\moc_HYDROGUI_GVSelector.cxx"
                                >
                        </File>
+                       <File
+                               RelativePath=".\moc\moc_HYDROGUI_ImmersibleZoneDlg.cxx"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\moc\moc_HYDROGUI_ImmersibleZoneOp.cxx"
+                               >
+                       </File>
                        <File
                                RelativePath=".\moc\moc_HYDROGUI_ImportBathymetryDlg.cxx"
                                >
                                RelativePath=".\moc\moc_HYDROGUI_VisualStateOp.cxx"
                                >
                        </File>
-                       <File
-                               RelativePath=".\moc\moc_HYDROGUI_ZoneDlg.cxx"
-                               >
-                       </File>
-                       <File
-                               RelativePath=".\moc\moc_HYDROGUI_ZoneOp.cxx"
-                               >
-                       </File>
                </Filter>
        </Files>
        <Globals>
index 75d90586a78836113eeb8afad80f6107dd1c97d1..16364e6f8c2da028bc89eba840d4271d59555924 100755 (executable)
@@ -1,6 +1,6 @@
 #include "HYDROGUI_AISCurve.h"
 
-#include <HYDROOperations_BSpline.h>
+#include <HYDROData_BSplineOperation.h>
 
 #include <CurveCreator_Curve.hxx>
 
@@ -106,7 +106,7 @@ void HYDROGUI_AISCurveSection::buildSection()
 
     if( aSectSize > 1 )
     {
-      HYDROOperations_BSpline aBSpline( aPoints, 0, aSectIsClosed );
+      HYDROData_BSplineOperation aBSpline( aPoints, 0, aSectIsClosed );
       TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge( aBSpline.Curve() ).Edge();
 
       TopoDS_Wire aWire = BRepBuilderAPI_MakeWire( anEdge ).Wire();
index 57e38659b0d6bb21e68438a5ffb6f8f03ba17e4e..1fc70566b5b18fae5ae0877080424680fe0d1972 100644 (file)
@@ -52,56 +52,24 @@ HYDROGUI_CalculationDlg::HYDROGUI_CalculationDlg( HYDROGUI_Module* theModule, co
   aNameLayout->addWidget( new QLabel( tr( "NAME" ), myObjectNameGroup ) );
   aNameLayout->addWidget( myObjectName );
 
-  
-  // Calculation boundary line
-  QGroupBox* aBndGroup = new QGroupBox( tr( "CALCULATION_BOUNDARY" ), mainFrame() );
-
-  myBndPolyline = new HYDROGUI_ObjSelector( theModule, KIND_POLYLINE, aBndGroup );
-
-  QBoxLayout* aBndLayout = new QHBoxLayout( aBndGroup );
-  aBndLayout->setMargin( 5 );
-  aBndLayout->setSpacing( 5 );
-  aBndLayout->addWidget( new QLabel( tr( "BOUNDARY_POLYLINE" ), aBndGroup ) );
-  aBndLayout->addWidget( myBndPolyline );
-
-
   // Calculation zones
-  QGroupBox* aZonesGroup = new QGroupBox( tr( "CALCULATION_ZONES" ), mainFrame() );
-
-  myZones = new QListWidget( aZonesGroup );
-  myZones->setSelectionMode( QListWidget::SingleSelection );
-  myZones->setEditTriggers( QListWidget::NoEditTriggers );
-  myZones->setViewMode( QListWidget::ListMode );
-
-  myRegions = new QListWidget( aZonesGroup );
-  myRegions->setSelectionMode( QListWidget::SingleSelection );
-  myRegions->setEditTriggers( QListWidget::NoEditTriggers );
-  myRegions->setViewMode( QListWidget::ListMode );
+  QFrame* anObjectsFrame = new QFrame( mainFrame() );
 
-  mySplittedZonesPrefix = new QLineEdit( aZonesGroup );
+  myGeomObjects = new QListWidget( anObjectsFrame );
+  myGeomObjects->setSelectionMode( QListWidget::SingleSelection );
+  myGeomObjects->setEditTriggers( QListWidget::NoEditTriggers );
+  myGeomObjects->setViewMode( QListWidget::ListMode );
 
-  QPushButton* aSplitBtn = new QPushButton( tr( "SPLIT_REFERENCE_ZONES" ), aZonesGroup );
-
-  QGridLayout* aZonesLayout = new QGridLayout( aZonesGroup );
+  QGridLayout* aZonesLayout = new QGridLayout( anObjectsFrame );
   aZonesLayout->setMargin( 5 );
   aZonesLayout->setSpacing( 5 );
-  aZonesLayout->addWidget( new QLabel( tr( "CALCULATION_REFERENCE_ZONES" ), aZonesGroup ), 0, 0, 1, 2 );
-  aZonesLayout->addWidget( myZones, 1, 0, 1, 2 );
-  aZonesLayout->addWidget( new QLabel( tr( "CALCULATION_REGIONS" ), aZonesGroup ), 2, 0, 1, 2 );
-  aZonesLayout->addWidget( myRegions, 3, 0, 1, 2 );
-  aZonesLayout->addWidget( new QLabel( tr( "PREFIX_REGIONS" ), aZonesGroup ), 4, 0 );
-  aZonesLayout->addWidget( mySplittedZonesPrefix, 4, 1 );
-  aZonesLayout->addWidget( aSplitBtn, 5, 0, 1, 2 );
+  aZonesLayout->addWidget( new QLabel( tr( "CALCULATION_REFERENCE_OBJECTS" ), myGeomObjects ), 0, 0 );
+  aZonesLayout->addWidget( myGeomObjects, 0, 1 );
 
   // Common
   addWidget( myObjectNameGroup );
-  addWidget( aBndGroup );
-  addWidget( aZonesGroup );
+  addWidget( anObjectsFrame );
   addStretch();
-
-
-  // Connect signals and slots
-  connect( aSplitBtn, SIGNAL( clicked( bool ) ), this, SIGNAL( SplitZones() ) );
 }
 
 HYDROGUI_CalculationDlg::~HYDROGUI_CalculationDlg()
@@ -112,12 +80,7 @@ void HYDROGUI_CalculationDlg::reset()
 {
   myObjectName->clear();
 
-  myBndPolyline->Clear();
-
-  myZones->clear();
-  myRegions->clear();
-
-  setSplitZonesPrefix( tr( "DEFAULT_PREFIX_REGIONS" ) );
+  myGeomObjects->clear();
 }
 
 void HYDROGUI_CalculationDlg::setObjectName( const QString& theName )
@@ -130,106 +93,38 @@ QString HYDROGUI_CalculationDlg::getObjectName() const
   return myObjectName->text();
 }
 
-void HYDROGUI_CalculationDlg::setPolylineName( const QString& theName )
-{
-  myBndPolyline->SetName( theName );
-}
-
-QString HYDROGUI_CalculationDlg::getPolylineName() const
-{
-  return myBndPolyline->GetName();
-}
-
-void HYDROGUI_CalculationDlg::setZones( const QStringList& theZones )
-{
-  myZones->clear();
-
-  for ( int i = 0, n = theZones.length(); i < n; ++i )
-  {
-    QString aZoneName = theZones.at( i );
-
-    QListWidgetItem* aListItem = new QListWidgetItem( aZoneName, myZones );
-    aListItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable );
-    aListItem->setCheckState( Qt::Unchecked );
-  }
-}
-
-void HYDROGUI_CalculationDlg::setSelectedZones( const QStringList& theZones )
+void HYDROGUI_CalculationDlg::setGeomObjects( const QStringList& theObjects )
 {
-  for ( int i = 0, n = theZones.length(); i < n; ++i )
-  {
-    QString aZoneName = theZones.at( i );
-
-    QList<QListWidgetItem *> anItems = 
-      myZones->findItems( aZoneName, Qt::MatchFixedString | Qt::MatchCaseSensitive );
-    if ( anItems.isEmpty() )
-      continue;
-
-    QListWidgetItem* aListItem = anItems.first();
-    if ( !aListItem )
-      continue;
-
-    aListItem->setCheckState( Qt::Checked );
-  }
-}
-
-QStringList HYDROGUI_CalculationDlg::getSelectedZones() const
-{
-  QStringList aResList;
-
-  for ( int i = 0, n = myZones->count(); i < n; ++i )
-  {
-    QListWidgetItem* aListItem = myZones->item( i );
-    if ( !aListItem || aListItem->checkState() != Qt::Checked )
-      continue;
-
-    QString aSelZoneName = aListItem->text();
-    aResList.append( aSelZoneName );
-  }
-
-  return aResList;
 }
 
-void HYDROGUI_CalculationDlg::setRegions( const QStringList& theRegions )
+void HYDROGUI_CalculationDlg::setSelectedGeomObjects( const QStringList& theObjects )
 {
-  myRegions->clear();
+  myGeomObjects->clear();
 
-  for ( int i = 0, n = theRegions.length(); i < n; ++i )
+  for ( int i = 0, n = theObjects.length(); i < n; ++i )
   {
-    QString aRegionName = theRegions.at( i );
+    QString anObjName = theObjects.at( i );
 
-    QListWidgetItem* aListItem = new QListWidgetItem( aRegionName, myRegions );
+    QListWidgetItem* aListItem = new QListWidgetItem( anObjName, myGeomObjects );
     aListItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable );
   }
 }
 
-QStringList HYDROGUI_CalculationDlg::getRegions() const
+QStringList HYDROGUI_CalculationDlg::getSelectedGeomObjects() const
 {
   QStringList aResList;
 
-  for ( int i = 0, n = myRegions->count(); i < n; ++i )
+  for ( int i = 0, n = myGeomObjects->count(); i < n; ++i )
   {
-    QListWidgetItem* aListItem = myRegions->item( i );
+    QListWidgetItem* aListItem = myGeomObjects->item( i );
     if ( !aListItem )
       continue;
 
-    QString aRegionName = aListItem->text();
-    aResList.append( aRegionName );
+    QString aSelObjName = aListItem->text();
+    aResList.append( aSelObjName );
   }
 
   return aResList;
 }
 
-void HYDROGUI_CalculationDlg::setSplitZonesPrefix( const QString& theName )
-{
-  mySplittedZonesPrefix->setText( theName );
-}
-
-QString HYDROGUI_CalculationDlg::getSplitZonesPrefix() const
-{
-  QString aPrefix = mySplittedZonesPrefix->text();
-  if ( aPrefix.isEmpty() )
-    aPrefix = tr( "DEFAULT_PREFIX_REGIONS" );
-  return aPrefix;
-}
 
index c63fffa51aafe390f669b0a72d1941b621d7a110..8ab1c4106207a550e0cd983f152fbbc1026a4d0b 100644 (file)
@@ -43,31 +43,15 @@ public:
   void                       setObjectName( const QString& theName );
   QString                    getObjectName() const;
 
-  void                       setPolylineName( const QString& theName );
-  QString                    getPolylineName() const;
-
-  void                       setZones( const QStringList& theZones );
-  void                       setSelectedZones( const QStringList& theZones );
-  QStringList                getSelectedZones() const;
-
-  void                       setRegions( const QStringList& theRegions );
-  QStringList                getRegions() const;
-
-  void                       setSplitZonesPrefix( const QString& theName );
-  QString                    getSplitZonesPrefix() const;
-
-signals:
-  void                       SplitZones();
+  void                       setGeomObjects( const QStringList& theObjects );
+  void                       setSelectedGeomObjects( const QStringList& theObjects );
+  QStringList                getSelectedGeomObjects() const;
 
 private:
   QGroupBox*                 myObjectNameGroup;
   QLineEdit*                 myObjectName;
 
-  HYDROGUI_ObjSelector*      myBndPolyline;
-
-  QListWidget*               myZones;
-  QListWidget*               myRegions;
-  QLineEdit*                 mySplittedZonesPrefix;
+  QListWidget*               myGeomObjects;
 };
 
 #endif
index fd48bc169f2a73f5f80a6feb9beaa1e4c6394b30..ff036a4ffec0c4d11c774f0e9f0277e91e1ccf67 100644 (file)
@@ -30,7 +30,7 @@
 
 #include <HYDROData_Polyline.h>
 #include <HYDROData_Iterator.h>
-#include <HYDROData_Zone.h>
+#include <HYDROData_ImmersibleZone.h>
 
 #include <OCCViewer_ViewManager.h>
 #include <OCCViewer_ViewModel.h>
@@ -69,7 +69,7 @@ void HYDROGUI_CalculationOp::startOperation()
 
   QString anObjectName = HYDROGUI_Tool::GenerateObjectName( module(), "Case" );
 
-  QStringList aSelectedZones, aRegions;
+  QStringList aSelectedObjects;
 
   myEditedObject.Nullify();
   if ( myIsEdit )
@@ -79,82 +79,26 @@ void HYDROGUI_CalculationOp::startOperation()
     {
       anObjectName = myEditedObject->GetName();
 
-      Handle(HYDROData_Polyline) aBoundaryPolyline = myEditedObject->GetBoundaryPolyline();
-      if ( !aBoundaryPolyline.IsNull() )
-      {
-        QString aPolylineName = aBoundaryPolyline->GetName();
-        aPanel->setPolylineName( aPolylineName );
-      }
-
-      HYDROData_SequenceOfObjects aRefZones = myEditedObject->GetZones();
-      HYDROData_SequenceOfObjects::Iterator anIter( aRefZones );
-      for ( ; anIter.More(); anIter.Next() )
-      {
-        Handle(HYDROData_Zone) aRefZone = 
-          Handle(HYDROData_Zone)::DownCast( anIter.Value() );
-        if ( aRefZone.IsNull() )
-          continue;
-
-        QString aRefZoneName = aRefZone->GetName();
-        if ( aRefZoneName.isEmpty() )
-          continue;
-
-        aSelectedZones.append( aRefZoneName );
-      }
-
-      HYDROData_SequenceOfObjects aDataRegions = myEditedObject->GetRegions();
-      anIter.Init( aDataRegions );
+      HYDROData_SequenceOfObjects aRefObjects = myEditedObject->GetGeometryObjects();
+      HYDROData_SequenceOfObjects::Iterator anIter( aRefObjects );
       for ( ; anIter.More(); anIter.Next() )
       {
-        Handle(HYDROData_Region) aDataRegion = 
-          Handle(HYDROData_Region)::DownCast( anIter.Value() );
-        if ( aDataRegion.IsNull() )
+        Handle(HYDROData_Object) aRefbject = 
+          Handle(HYDROData_Object)::DownCast( anIter.Value() );
+        if ( aRefbject.IsNull() )
           continue;
 
-        QString aRegionName = aDataRegion->GetName();
-        if ( aRegionName.isEmpty() )
+        QString aRefObjectName = aRefbject->GetName();
+        if ( aRefObjectName.isEmpty() )
           continue;
 
-        Region aRegion;
-        aRegion.SplitData.Shape = aDataRegion->Face();
-
-        aRegion.FillingColor = aDataRegion->GetFillingColor();
-        aRegion.BorderColor  = aDataRegion->GetBorderColor();
-
-        aRegion.RegionName = aRegionName;
-
-        aRegion.DataRegion = aDataRegion;
-
-        myRegionsList.append( aRegion );
-
-        aRegions.append( aRegionName );
+        aSelectedObjects.append( aRefObjectName );
       }
     }
   }
 
-  // collect information about existing zones
-  QStringList aZones;
-
-  HYDROData_Iterator anIter( doc(), KIND_ZONE );
-  for ( ; anIter.More(); anIter.Next() )
-  {
-    Handle(HYDROData_Zone) aZoneObj = 
-      Handle(HYDROData_Zone)::DownCast( anIter.Current() );
-    if ( aZoneObj.IsNull() )
-      continue;
-
-    QString aZoneName = aZoneObj->GetName();
-    if ( aZoneName.isEmpty() )
-      continue;
-
-    aZones.append( aZoneName );
-  }
-
   aPanel->setObjectName( anObjectName );
-
-  aPanel->setZones( aZones );
-  aPanel->setSelectedZones( aSelectedZones );
-  aPanel->setRegions( aRegions );
+  aPanel->setSelectedGeomObjects( aSelectedObjects );
 
   createPreview();
 }
@@ -178,7 +122,6 @@ HYDROGUI_InputPanel* HYDROGUI_CalculationOp::createInputPanel() const
   HYDROGUI_CalculationDlg* aPanel = new HYDROGUI_CalculationDlg( module(), getName() );
 
   // Connect signals and slots
-  connect( aPanel, SIGNAL( SplitZones() ), this, SLOT( onSplitZones() ) );
 
   return aPanel;
 }
@@ -201,7 +144,7 @@ bool HYDROGUI_CalculationOp::processApply( int&     theUpdateFlags,
   // check that there are no other objects with the same name in the document
   if( !myIsEdit || ( !myEditedObject.IsNull() && myEditedObject->GetName() != anObjectName ) )
   {
-    Handle(HYDROData_Object) anObject = HYDROGUI_Tool::FindObjectByName( module(), anObjectName );
+    Handle(HYDROData_Entity) anObject = HYDROGUI_Tool::FindObjectByName( module(), anObjectName );
     if ( !anObject.IsNull() )
     {
       theErrorMsg = tr( "OBJECT_EXISTS_IN_DOCUMENT" ).arg( anObjectName );
@@ -218,48 +161,11 @@ bool HYDROGUI_CalculationOp::processApply( int&     theUpdateFlags,
 
   aCalculObj->SetName( anObjectName );
 
-  QString aPolylineName = aPanel->getPolylineName();
-  Handle(HYDROData_Polyline) aBndPolyline = Handle(HYDROData_Polyline)::DownCast(
-      HYDROGUI_Tool::FindObjectByName( module(), aPolylineName, KIND_POLYLINE ) );
-
-  aCalculObj->SetBoundaryPolyline( aBndPolyline );
-
-  QStringList aRefZoneNames = aPanel->getSelectedZones();
-  HYDROData_SequenceOfObjects aRefZones = 
-    HYDROGUI_Tool::FindObjectsByNames( module(), aRefZoneNames, KIND_ZONE );
-
-  aCalculObj->SetZones( aRefZones );
-
-  HYDROData_SequenceOfObjects aRegions;
-
-  RegionsList::iterator anIter = myRegionsList.begin();
-  for ( ; anIter != myRegionsList.end(); ++anIter )
-  {
-    const Region& aRegion = *anIter;
-
-    if ( !aRegion.DataRegion.IsNull() )
-    {
-      //No need to create new but use old zone
-      aRegions.Append( aRegion.DataRegion );
-      continue;
-    }
-
-    Handle(HYDROData_Region) aDataRegion =
-      Handle(HYDROData_Region)::DownCast( aDocument->CreateObject( KIND_REGION ) );
-    if( aDataRegion.IsNull() )
-      continue;
-
-    // Fill the zone data
-    aDataRegion->SetFace( aRegion.SplitData.Face() );
+  QStringList aRefObjectNames = aPanel->getSelectedGeomObjects();
+  HYDROData_SequenceOfObjects aGeomObjects = 
+    HYDROGUI_Tool::FindObjectsByNames( module(), aRefObjectNames );
 
-    aDataRegion->SetName( aRegion.RegionName );
-    aDataRegion->SetBorderColor( aRegion.BorderColor );
-    aDataRegion->SetFillingColor( aRegion.FillingColor );
-
-    aRegions.Append( aDataRegion );
-  }
-
-  aCalculObj->SetRegions( aRegions );
+  aCalculObj->SetGeometryObjects( aGeomObjects );
 
   theUpdateFlags = UF_Model;
 
@@ -277,32 +183,27 @@ void HYDROGUI_CalculationOp::onSplitZones()
 
   QApplication::setOverrideCursor( Qt::WaitCursor );
 
-  QString aPolylineName = aPanel->getPolylineName();
-  Handle(HYDROData_Polyline) aBndPolyline = Handle(HYDROData_Polyline)::DownCast(
-      HYDROGUI_Tool::FindObjectByName( module(), aPolylineName, KIND_POLYLINE ) );
-
-  QStringList aZoneNames = aPanel->getSelectedZones();
-  HYDROData_SequenceOfObjects aZones = 
-    HYDROGUI_Tool::FindObjectsByNames( module(), aZoneNames, KIND_ZONE );
+  QStringList aGeomObjectNames = aPanel->getSelectedGeomObjects();
+  HYDROData_SequenceOfObjects aGeomObjects = 
+    HYDROGUI_Tool::FindObjectsByNames( module(), aGeomObjectNames );
 
   QStringList aResSplittedZones;
 
-  HYDROGUI_SplitZonesTool::SplitDataList aSplittedZones =
-    HYDROGUI_SplitZonesTool::SplitZones( aZones, aBndPolyline );
+  HYDROData_SplitToZonesTool::SplitDataList aSplittedZones =
+    HYDROData_SplitToZonesTool::SplitToZones( aGeomObjects );
 
-  QString aSplitZonesPrefix = aPanel->getSplitZonesPrefix();
   QStringList aUsedNames;
 
-  HYDROGUI_SplitZonesTool::SplitDataListIterator anIter( aSplittedZones );
+  HYDROData_SplitToZonesTool::SplitDataListIterator anIter( aSplittedZones );
   while( anIter.hasNext() )
   {
     Region aRegion;
     aRegion.SplitData = anIter.next();
 
-    aRegion.FillingColor = HYDROGUI_Tool::GenerateFillingColor( module(), aRegion.SplitData.ZoneNames );
-    aRegion.BorderColor  = QColor( HYDROData_Zone::DefaultBorderColor() );
+    aRegion.FillingColor = HYDROGUI_Tool::GenerateFillingColor( module(), aRegion.SplitData.ObjectNames );
+    aRegion.BorderColor  = QColor( HYDROData_ImmersibleZone::DefaultBorderColor() );
 
-    aRegion.RegionName = HYDROGUI_Tool::GenerateObjectName( module(), aSplitZonesPrefix, aUsedNames );
+    aRegion.RegionName = HYDROGUI_Tool::GenerateObjectName( module(), "Region", aUsedNames );
 
     aUsedNames.append( aRegion.RegionName );
 
@@ -310,8 +211,6 @@ void HYDROGUI_CalculationOp::onSplitZones()
 
     myRegionsList.append( aRegion );
   }
-
-  aPanel->setRegions( aResSplittedZones );
   
   createPreview();
 
index 17cebaff607581ea15f04bfbe34c0df16c1a16aa..394afcd9bc306ae1b074cb869d5bcedc4ce6d79c 100644 (file)
@@ -25,7 +25,7 @@
 
 #include "HYDROGUI_Operation.h"
 
-#include "HYDROGUI_SplitZonesTool.h"
+#include "HYDROData_SplitToZonesTool.h"
 #include "HYDROGUI_Shape.h"
 
 #include <HYDROData_Calculation.h>
@@ -43,7 +43,7 @@ class HYDROGUI_CalculationOp : public HYDROGUI_Operation
     QString                            RegionName;
     QColor                             FillingColor;
     QColor                             BorderColor;
-    HYDROGUI_SplitZonesTool::SplitData SplitData;
+    HYDROData_SplitToZonesTool::SplitData SplitData;
     HYDROGUI_Shape*                    Shape;
     Handle(HYDROData_Region)           DataRegion;
 
index ba15923855300b568f22dfb160d1ca30602d7581..180b2dd861fae6d8588d44b9fadfc0099b57cc39 100644 (file)
@@ -30,6 +30,7 @@
 #include <HYDROData_Calculation.h>
 #include <HYDROData_Document.h>
 #include <HYDROData_Image.h>
+#include <HYDROData_ImmersibleZone.h>
 #include <HYDROData_Iterator.h>
 #include <HYDROData_Polyline.h>
 #include <HYDROData_VisualState.h>
@@ -243,17 +244,6 @@ void HYDROGUI_DataModel::update( const int theStudyId )
       createObject( aBathymetryRootObj, aBathymetryObj );
   }
 
-  LightApp_DataObject* aCalculRootObj = createObject( aRootObj, partitionName( KIND_CALCULATION ) );
-
-  anIterator = HYDROData_Iterator( aDocument, KIND_CALCULATION );
-  for( ; anIterator.More(); anIterator.Next() )
-  {
-    Handle(HYDROData_Calculation) aCalculObj =
-      Handle(HYDROData_Calculation)::DownCast( anIterator.Current() );
-    if( !aCalculObj.IsNull() )
-      createObject( aCalculRootObj, aCalculObj );
-  }
-
   LightApp_DataObject* aPolylineRootObj = createObject( aRootObj, partitionName( KIND_POLYLINE ) );
 
   anIterator = HYDROData_Iterator( aDocument, KIND_POLYLINE );
@@ -265,17 +255,28 @@ void HYDROGUI_DataModel::update( const int theStudyId )
       createObject( aPolylineRootObj, aPolylineObj );
   }
 
-  LightApp_DataObject* aZonesRootObj = createObject( aRootObj, partitionName( KIND_ZONE ) );
+  LightApp_DataObject* aZonesRootObj = createObject( aRootObj, partitionName( KIND_IMMERSIBLE_ZONE ) );
 
-  anIterator = HYDROData_Iterator( aDocument, KIND_ZONE );
+  anIterator = HYDROData_Iterator( aDocument, KIND_IMMERSIBLE_ZONE );
   for( ; anIterator.More(); anIterator.Next() )
   {
-    Handle(HYDROData_Zone) aZoneObj =
-      Handle(HYDROData_Zone)::DownCast( anIterator.Current() );
+    Handle(HYDROData_ImmersibleZone) aZoneObj =
+      Handle(HYDROData_ImmersibleZone)::DownCast( anIterator.Current() );
     if( !aZoneObj.IsNull() )
       createObject( aZonesRootObj, aZoneObj );
   }
 
+  LightApp_DataObject* aCalculRootObj = createObject( aRootObj, partitionName( KIND_CALCULATION ) );
+
+  anIterator = HYDROData_Iterator( aDocument, KIND_CALCULATION );
+  for( ; anIterator.More(); anIterator.Next() )
+  {
+    Handle(HYDROData_Calculation) aCalculObj =
+      Handle(HYDROData_Calculation)::DownCast( anIterator.Current() );
+    if( !aCalculObj.IsNull() )
+      createObject( aCalculRootObj, aCalculObj );
+  }
+
   LightApp_DataObject* aVisualStateRootObj = createObject( aRootObj, partitionName( KIND_VISUAL_STATE ) );
 
   anIterator = HYDROData_Iterator( aDocument, KIND_VISUAL_STATE );
@@ -294,7 +295,7 @@ void HYDROGUI_DataModel::update( const int theStudyId )
   }
 }
 
-HYDROGUI_DataObject* HYDROGUI_DataModel::getDataObject( const Handle(HYDROData_Object)& theModelObject )
+HYDROGUI_DataObject* HYDROGUI_DataModel::getDataObject( const Handle(HYDROData_Entity)& theModelObject )
 {
   return NULL; // to do if necessary
 }
@@ -333,7 +334,7 @@ void HYDROGUI_DataModel::updateModel()
     update( aModule->getStudyId() );
 }
 
-Handle(HYDROData_Object) HYDROGUI_DataModel::objectByEntry( const QString& theEntry,
+Handle(HYDROData_Entity) HYDROGUI_DataModel::objectByEntry( const QString& theEntry,
                                                             const ObjectKind theObjectKind )
 {
   QString anEntry = theEntry;
@@ -346,7 +347,7 @@ Handle(HYDROData_Object) HYDROGUI_DataModel::objectByEntry( const QString& theEn
     HYDROData_Iterator anIterator( aDocument, theObjectKind );
     for( ; anIterator.More(); anIterator.Next() )
     {
-      Handle(HYDROData_Object) anObject = anIterator.Current();
+      Handle(HYDROData_Entity) anObject = anIterator.Current();
       if( !anObject.IsNull() )
       {
         QString anEntryRef = HYDROGUI_DataObject::dataObjectEntry( anObject );
@@ -426,7 +427,7 @@ bool HYDROGUI_DataModel::canCopy()
   if( aSeq.Length() != 1 )
     return false;
 
-  Handle(HYDROData_Object) anObject = aSeq.First();
+  Handle(HYDROData_Entity) anObject = aSeq.First();
   if( anObject.IsNull() )
     return false;
 
@@ -443,7 +444,7 @@ bool HYDROGUI_DataModel::canPaste()
 {
   for( int anIndex = 1, aLength = myCopyingObjects.Length(); anIndex <= aLength; anIndex++ )
   {
-    Handle(HYDROData_Object) anObject = myCopyingObjects.Value( anIndex );
+    Handle(HYDROData_Entity) anObject = myCopyingObjects.Value( anIndex );
     if( !anObject.IsNull() && !anObject->IsRemoved() )
       return true;
   }
@@ -462,11 +463,11 @@ bool HYDROGUI_DataModel::paste()
   bool anIsChanged = false;
   for( int anIndex = 1, aLength = myCopyingObjects.Length(); anIndex <= aLength; anIndex++ )
   {
-    Handle(HYDROData_Object) anObject = myCopyingObjects.Value( anIndex );
+    Handle(HYDROData_Entity) anObject = myCopyingObjects.Value( anIndex );
     if( !anObject.IsNull() && !anObject->IsRemoved() )
     {
       ObjectKind aKind = anObject->GetKind();
-      Handle(HYDROData_Object) aClone = getDocument()->CreateObject( aKind );
+      Handle(HYDROData_Entity) aClone = getDocument()->CreateObject( aKind );
       if( !aClone.IsNull() )
       {
         anObject->CopyTo( aClone );
@@ -504,12 +505,12 @@ QString HYDROGUI_DataModel::partitionName( const ObjectKind theObjectKind )
 {
   switch( theObjectKind )
   {
-    case KIND_IMAGE:        return "IMAGES";
-    case KIND_POLYLINE:     return "POLYLINES";
-    case KIND_VISUAL_STATE: return "VISUAL_STATES";
-    case KIND_BATHYMETRY:   return "BATHYMETRIES";
-    case KIND_CALCULATION:  return "CALCULATION_CASES";
-    case KIND_ZONE:         return "ZONES";
+    case KIND_IMAGE:           return "IMAGES";
+    case KIND_POLYLINE:        return "POLYLINES";
+    case KIND_VISUAL_STATE:    return "VISUAL_STATES";
+    case KIND_BATHYMETRY:      return "BATHYMETRIES";
+    case KIND_CALCULATION:     return "CALCULATION_CASES";
+    case KIND_IMMERSIBLE_ZONE: return "IMMERSIBLE_ZONES";
     default: break;
   }
   return QString();
@@ -522,7 +523,7 @@ Handle(HYDROData_Document) HYDROGUI_DataModel::getDocument() const
 }
 
 LightApp_DataObject* HYDROGUI_DataModel::createObject( SUIT_DataObject*         theParent,
-                                                       Handle(HYDROData_Object) theModelObject,
+                                                       Handle(HYDROData_Entity) theModelObject,
                                                        const QString&           theParentEntry,
                                                        const bool               theIsBuildTree )
 {
@@ -552,7 +553,7 @@ void HYDROGUI_DataModel::buildObjectTree( SUIT_DataObject* theParent,
   if ( !aGuiObj )
     return;
 
-  Handle(HYDROData_Object) aDataObj = aGuiObj->modelObject();
+  Handle(HYDROData_Entity) aDataObj = aGuiObj->modelObject();
   if ( aDataObj.IsNull() )
     return;
 
@@ -564,15 +565,15 @@ void HYDROGUI_DataModel::buildObjectTree( SUIT_DataObject* theParent,
       Handle(HYDROData_Image)::DownCast( aDataObj );
     for ( int anIndex = 0, aNbRef = anImageObj->NbReferences(); anIndex < aNbRef; anIndex++ )
     {
-      Handle(HYDROData_Object) aRefObj = anImageObj->Reference( anIndex );
+      Handle(HYDROData_Entity) aRefObj = anImageObj->Reference( anIndex );
       if ( !aRefObj.IsNull() && !aRefObj->IsRemoved() )
         createObject( aGuiObj, aRefObj, aGuiObj->entry(), false );
     }
   }
-  else if ( anObjectKind == KIND_ZONE )
+  else if ( anObjectKind == KIND_IMMERSIBLE_ZONE )
   {
-    Handle(HYDROData_Zone) aZoneObj =
-      Handle(HYDROData_Zone)::DownCast( aDataObj );
+    Handle(HYDROData_ImmersibleZone) aZoneObj =
+      Handle(HYDROData_ImmersibleZone)::DownCast( aDataObj );
 
     LightApp_DataObject* aPolylineSect = 
       createObject( aGuiObj, tr( "ZONE_POLYLINE" ), aGuiObj->entry() );
@@ -581,55 +582,44 @@ void HYDROGUI_DataModel::buildObjectTree( SUIT_DataObject* theParent,
     if ( !aPolyline.IsNull() && !aPolyline->IsRemoved() )
       createObject( aPolylineSect, aPolyline, aGuiObj->entry(), false );
 
-    LightApp_DataObject* aBathsSect = 
-      createObject( aGuiObj, tr( "ZONE_BATHYMETRIES" ), aGuiObj->entry() );
+    LightApp_DataObject* aBathSect = 
+      createObject( aGuiObj, tr( "ZONE_BATHYMETRY" ), aGuiObj->entry() );
 
-    HYDROData_SequenceOfObjects aZoneBaths = aZoneObj->GetBathymetries();
-    HYDROData_SequenceOfObjects::Iterator aBathsIter( aZoneBaths );
-    for ( ; aBathsIter.More(); aBathsIter.Next() )
-    {
-      Handle(HYDROData_Bathymetry) aRefBath =
-        Handle(HYDROData_Bathymetry)::DownCast( aBathsIter.Value() );
-      if( !aRefBath.IsNull() && !aRefBath->IsRemoved() )
-        createObject( aBathsSect, aRefBath, aGuiObj->entry(), false );
-    }
+    Handle(HYDROData_Bathymetry) aBathymetry = aZoneObj->GetBathymetry();
+    if ( !aBathymetry.IsNull() && !aBathymetry->IsRemoved() )
+      createObject( aBathSect, aBathymetry, aGuiObj->entry(), false );
   }
   else if ( anObjectKind == KIND_CALCULATION )
   {
     Handle(HYDROData_Calculation) aCaseObj =
       Handle(HYDROData_Calculation)::DownCast( aDataObj );
 
-    LightApp_DataObject* aPolylineSect = 
-      createObject( aGuiObj, tr( "CASE_BND_POLYLINE" ), aGuiObj->entry() );
-
-    Handle(HYDROData_Polyline) aPolyline = aCaseObj->GetBoundaryPolyline();
-    if ( !aPolyline.IsNull() && !aPolyline->IsRemoved() )
-      createObject( aPolylineSect, aPolyline, aGuiObj->entry(), false );
-
-    LightApp_DataObject* aRefZonesSect = 
-      createObject( aGuiObj, tr( "CASE_REFERENCE_ZONES" ), aGuiObj->entry() );
-
-    HYDROData_SequenceOfObjects aRefZones = aCaseObj->GetZones();
-    HYDROData_SequenceOfObjects::Iterator anIter( aRefZones );
-    for ( ; anIter.More(); anIter.Next() )
-    {
-      Handle(HYDROData_Zone) aRefZone =
-        Handle(HYDROData_Zone)::DownCast( anIter.Value() );
-      if( !aRefZone.IsNull() && !aRefZone->IsRemoved() )
-        createObject( aRefZonesSect, aRefZone, aGuiObj->entry(), false );
-    }
-
     LightApp_DataObject* aCaseRegionsSect = 
       createObject( aGuiObj, tr( "CASE_REGIONS" ), aGuiObj->entry() );
 
     HYDROData_SequenceOfObjects aCaseRegions = aCaseObj->GetRegions();
-    anIter.Init( aCaseRegions );
+    HYDROData_SequenceOfObjects::Iterator anIter( aCaseRegions );
     for ( ; anIter.More(); anIter.Next() )
     {
       Handle(HYDROData_Region) aCaseRegion =
         Handle(HYDROData_Region)::DownCast( anIter.Value() );
       if( !aCaseRegion.IsNull() && !aCaseRegion->IsRemoved() )
-        createObject( aCaseRegionsSect, aCaseRegion, aGuiObj->entry(), false );
+        createObject( aCaseRegionsSect, aCaseRegion, aGuiObj->entry(), true );
+    }
+  }
+  else if ( anObjectKind == KIND_REGION )
+  {
+    Handle(HYDROData_Region) aRegionObj =
+      Handle(HYDROData_Region)::DownCast( aDataObj );
+
+    HYDROData_SequenceOfObjects aRegionZones = aRegionObj->GetZones();
+    HYDROData_SequenceOfObjects::Iterator anIter( aRegionZones );
+    for ( ; anIter.More(); anIter.Next() )
+    {
+      Handle(HYDROData_Zone) aRegionZone =
+        Handle(HYDROData_Zone)::DownCast( anIter.Value() );
+      if( !aRegionZone.IsNull() && !aRegionZone->IsRemoved() )
+        createObject( aGuiObj, aRegionZone, aGuiObj->entry(), true );
     }
   }
 }
index 1f2f3fb23f1a472254eb4afd28109ae29ddb7247..1a3b12da99a717548c98b64f45bb2d46bcd4ee74 100644 (file)
@@ -24,7 +24,7 @@
 #define HYDROGUI_DATAMODEL_H
 
 #include <HYDROData_Document.h>
-#include <HYDROData_Object.h>
+#include <HYDROData_Entity.h>
 
 #include <QMap>
 #include <LightApp_DataModel.h>
@@ -111,7 +111,7 @@ public:
    * \param the data model object
    * \return the only one object referenced to the given data model object, or null if not found
    */
-  virtual HYDROGUI_DataObject* getDataObject( const Handle(HYDROData_Object)& theModelObject );
+  virtual HYDROGUI_DataObject* getDataObject( const Handle(HYDROData_Entity)& theModelObject );
 
   /**
    * Returns a data object referenced to the given data object.
@@ -147,7 +147,7 @@ public:
   /**
    * Find a data object by the specified entry and kind
    */
-  Handle(HYDROData_Object) objectByEntry( const QString& theEntry,
+  Handle(HYDROData_Entity) objectByEntry( const QString& theEntry,
                                           const ObjectKind theObjectKind = KIND_UNKNOWN );
 
   /**
@@ -235,7 +235,7 @@ protected:
    * \param theParentEntry entry of parent object
    */
   LightApp_DataObject* createObject( SUIT_DataObject*         theParent,
-                                     Handle(HYDROData_Object) theModelObject,
+                                     Handle(HYDROData_Entity) theModelObject,
                                      const QString&           theParentEntry = QString(),
                                      const bool               theIsBuildTree = true );
 
index b2b4d05e971784599368176c4f5a6ed448ce1dc7..0b293cd2912df58e67fb56d336cfad6606565e3b 100644 (file)
@@ -29,7 +29,7 @@
 #include <TDF_Tool.hxx>
 
 HYDROGUI_DataObject::HYDROGUI_DataObject( SUIT_DataObject* theParent, 
-                                          Handle(HYDROData_Object) theData,
+                                          Handle(HYDROData_Entity) theData,
                                           const QString& theParentEntry )
 : CAM_DataObject( theParent ),
   LightApp_DataObject( theParent ),
@@ -72,7 +72,7 @@ QFont HYDROGUI_DataObject::font( const int theId ) const
   return aFont;
 }
 
-QString HYDROGUI_DataObject::dataObjectEntry( const Handle(HYDROData_Object)& theObject,
+QString HYDROGUI_DataObject::dataObjectEntry( const Handle(HYDROData_Entity)& theObject,
                                               const bool theWithPrefix )
 {
   QString aEntryStr = QString::null;
index 69693349d7fd1e519cdd089f8824c86d17890966..e8814367a8afe01c55bc4ba613bae4a2ba8d08cf 100644 (file)
@@ -23,7 +23,7 @@
 #ifndef HYDROGUI_DATAOBJECT_H
 #define HYDROGUI_DATAOBJECT_H
 
-#include <HYDROData_Object.h>
+#include <HYDROData_Entity.h>
 
 #include <LightApp_DataObject.h>
 
@@ -50,7 +50,7 @@ public:
    * \param theParentEntry entry of the parent data object (for reference objects)
    */
   HYDROGUI_DataObject( SUIT_DataObject* theParent,
-                       Handle(HYDROData_Object) theData,
+                       Handle(HYDROData_Entity) theData,
                        const QString& theParentEntry );
     
   /**
@@ -76,12 +76,12 @@ public:
   /**
    * Returns the model data object.
    */
-  const Handle(HYDROData_Object)& modelObject() const { return myData; }
+  const Handle(HYDROData_Entity)& modelObject() const { return myData; }
 
   /**
    * Redefines the object.
    */
-  void setObject( Handle(HYDROData_Object) theObject ) { myData = theObject; }
+  void setObject( const Handle(HYDROData_Entity)& theObject ) { myData = theObject; }
 
   /**
    * Returns the entry prefix for all HYDRO data objects.
@@ -91,11 +91,11 @@ public:
   /**
    * Returns the full entry for the specified data object.
    */
-  static QString dataObjectEntry( const Handle(HYDROData_Object)& theObject,
+  static QString dataObjectEntry( const Handle(HYDROData_Entity)& theObject,
                                   const bool theWithPrefix = true );
 
 protected:
-  Handle(HYDROData_Object) myData; ///< object from data model
+  Handle(HYDROData_Entity) myData; ///< object from data model
   QString myParentEntry;
 };
 
index 8df9ef26cf8cccff6f0b0d8acc4ddfe2ac75f260..704fa4e34d8b55b88748fa0e440cb34c39cf03f4 100644 (file)
@@ -55,7 +55,7 @@ void HYDROGUI_DeleteOp::startOperation()
   {
     for( Standard_Integer anIndex = 1, aLength = aSeq.Length(); anIndex <= aLength; anIndex++ )
     {
-      Handle(HYDROData_Object) anObject = aSeq.Value( anIndex );
+      Handle(HYDROData_Entity) anObject = aSeq.Value( anIndex );
       if( !anObject.IsNull() )
       {
         aFullSeq.Append( anObject );
@@ -93,7 +93,7 @@ void HYDROGUI_DeleteOp::startOperation()
   startDocOperation();
   for( Standard_Integer anIndex = 1, aLength = aFullSeq.Length(); anIndex <= aLength; anIndex++ )
   {
-    Handle(HYDROData_Object) anObject = aFullSeq.Value( anIndex );
+    Handle(HYDROData_Entity) anObject = aFullSeq.Value( anIndex );
     if( !anObject.IsNull() && !anObject->IsRemoved() )
       anObject->Remove();
   }
index 7f91a6a9afbbab095a16aa958099b0528bd331a4..c28de63f9e4b7cf0926fc03c70b5148b00a24961 100644 (file)
@@ -56,7 +56,7 @@ void HYDROGUI_Displayer::SetToUpdate( const HYDROData_SequenceOfObjects& theObjs
   GraphicsView_ObjectList anObjectList = aViewPort->getObjects();
   for( int i = 1, n = theObjs.Length(); i <= n; i++ )
   {
-    Handle(HYDROData_Object) anObj = theObjs.Value( i );
+    Handle(HYDROData_Entity) anObj = theObjs.Value( i );
     if( anObj.IsNull() )
       continue;
 
@@ -115,7 +115,7 @@ void HYDROGUI_Displayer::Update( const HYDROData_SequenceOfObjects& theObjs,
 
   for( int i = 1, n = theObjs.Length(); i <= n; i++ )
   {
-    const Handle(HYDROData_Object)& anObj = theObjs.Value( i );
+    const Handle(HYDROData_Entity)& anObj = theObjs.Value( i );
     if( anObj.IsNull() )
       anObjectsToErase.Append( anObj );
     else
@@ -146,7 +146,7 @@ void HYDROGUI_Displayer::Erase( const HYDROData_SequenceOfObjects& theObjs,
     for( int i = 1, n = theObjs.Length(); i <= n; i++ )
     {
       // the object may be null or dead
-      const Handle(HYDROData_Object)& anObj = theObjs.Value( i );
+      const Handle(HYDROData_Entity)& anObj = theObjs.Value( i );
       if( HYDROGUI_Prs* aPrs = HYDROGUI_Tool::GetPresentation( anObj, anObjectList ) )
       {
         aViewPort->removeItem( aPrs );
@@ -172,7 +172,7 @@ void HYDROGUI_Displayer::Display( const HYDROData_SequenceOfObjects& theObjs,
   GraphicsView_ObjectList anObjectList = aViewPort->getObjects();
   for( int i = 1, n = theObjs.Length(); i <= n; i++ )
   {
-    Handle(HYDROData_Object) anObj = theObjs.Value( i );
+    Handle(HYDROData_Entity) anObj = theObjs.Value( i );
     if( anObj.IsNull() )
       continue;
 
@@ -214,7 +214,7 @@ void HYDROGUI_Displayer::purgeObjects( const int theViewerId )
   {
     if( HYDROGUI_Prs* aPrs = dynamic_cast<HYDROGUI_Prs*>( anIter.next() ) )
     {
-      Handle(HYDROData_Object) anObject = aPrs->getObject();
+      Handle(HYDROData_Entity) anObject = aPrs->getObject();
       if( !anObject.IsNull() && anObject->IsRemoved() )
       {
         aViewPort->removeItem( aPrs );
@@ -224,7 +224,7 @@ void HYDROGUI_Displayer::purgeObjects( const int theViewerId )
   }
 }
 
-HYDROGUI_PrsDriver* HYDROGUI_Displayer::getDriver( const Handle(HYDROData_Object)& theObj )
+HYDROGUI_PrsDriver* HYDROGUI_Displayer::getDriver( const Handle(HYDROData_Entity)& theObj )
 {
   HYDROGUI_PrsDriver* aDriver = NULL;
   ObjectKind aKind = theObj->GetKind();
index f39d9c2f98146688cb5bdb5e1354bd3584f28848..bc01eb9017ca8a7593da0964df54945c01345136 100644 (file)
@@ -23,7 +23,7 @@
 #ifndef HYDROGUI_DISPLAYER_H
 #define HYDROGUI_DISPLAYER_H
 
-#include <HYDROData_Object.h>
+#include <HYDROData_Entity.h>
 
 #include <QMap>
 
@@ -123,7 +123,7 @@ private:
    * \brief Get the presentation driver for the specified data object.
    * \param theObj data object
    */
-  HYDROGUI_PrsDriver*             getDriver( const Handle(HYDROData_Object)& theObj );
+  HYDROGUI_PrsDriver*             getDriver( const Handle(HYDROData_Entity)& theObj );
 
 private:
   HYDROGUI_Module*                myModule;
index 95f72cdcb19af04865a0dccc2b15c0f8857730cd..b1ac06cf6d66144f18fd898d5eb899f575eed06a 100644 (file)
@@ -76,7 +76,7 @@ void HYDROGUI_GVSelector::setSelection( const SUIT_DataOwnerPtrList& theList )
       if ( anOwner )
       {
         QString anEntry = anOwner->entry();
-        Handle(HYDROData_Object) aModelObject = aModel->objectByEntry( anEntry );
+        Handle(HYDROData_Entity) aModelObject = aModel->objectByEntry( anEntry );
         if( !aModelObject.IsNull() )
         {
           if( HYDROGUI_Prs* aPrs = HYDROGUI_Tool::GetPresentation( aModelObject, anObjectList ) )
diff --git a/src/HYDROGUI/HYDROGUI_ImmersibleZoneDlg.cxx b/src/HYDROGUI/HYDROGUI_ImmersibleZoneDlg.cxx
new file mode 100644 (file)
index 0000000..b5f8a05
--- /dev/null
@@ -0,0 +1,274 @@
+// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "HYDROGUI_ImmersibleZoneDlg.h"
+
+#include "HYDROGUI_ColorWidget.h"
+#include "HYDROGUI_Tool.h"
+
+#include <QComboBox>
+#include <QGroupBox>
+#include <QLabel>
+#include <QLayout>
+#include <QLineEdit>
+#include <QListWidget>
+#include <QRadioButton>
+
+HYDROGUI_ImmersibleZoneDlg::HYDROGUI_ImmersibleZoneDlg( HYDROGUI_Module* theModule, const QString& theTitle )
+: HYDROGUI_InputPanel( theModule, theTitle )
+{
+  // Zone name
+  myObjectNameGroup = new QGroupBox( tr( "ZONE_NAME" ), mainFrame() );
+
+  myObjectName = new QLineEdit( myObjectNameGroup );
+
+  QBoxLayout* aNameLayout = new QHBoxLayout( myObjectNameGroup );
+  aNameLayout->setMargin( 5 );
+  aNameLayout->setSpacing( 5 );
+  aNameLayout->addWidget( new QLabel( tr( "NAME" ), myObjectNameGroup ) );
+  aNameLayout->addWidget( myObjectName );
+
+
+  QGroupBox* aParamGroup = new QGroupBox( tr( "ZONE_PARAMETERS" ), mainFrame() );
+
+  QFrame* aPolylineFrame = new QFrame( aParamGroup );
+
+  myPolylines = new QComboBox( aPolylineFrame );
+  myPolylines->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+
+  QBoxLayout* aPolyLayout = new QHBoxLayout( aPolylineFrame );
+  aPolyLayout->setMargin( 0 );
+  aPolyLayout->setSpacing( 5 );
+  aPolyLayout->addWidget( new QLabel( tr( "ZONE_POLYLINE" ), aPolylineFrame ) );
+  aPolyLayout->addWidget( myPolylines );
+
+
+  QFrame* aFillingFrame = new QFrame( aParamGroup );
+  QLabel* aFillingLabel = new QLabel( tr( "FILLING_COLOR" ), aFillingFrame );
+  myFillingTransparent = new QRadioButton( tr( "TRANSPARENT" ), aFillingFrame );
+  myFillingTransparent->setChecked( true );
+  myFillingColor = new QRadioButton( tr( "COLOR" ), aFillingFrame );
+  myFillingColorBox = new HYDROGUI_ColorWidget( aFillingFrame );
+
+  QGridLayout* aFillingLayout = new QGridLayout( aFillingFrame );
+  aFillingLayout->setMargin( 0 );
+  aFillingLayout->setSpacing( 5 );
+  aFillingLayout->addWidget( aFillingLabel, 0, 0, 2, 1 );
+  aFillingLayout->addWidget( myFillingTransparent, 0, 1 );
+  aFillingLayout->addWidget( myFillingColor,       1, 1 );
+  aFillingLayout->addWidget( myFillingColorBox,    1, 2 );
+
+
+  myBorderColorGroup = new QGroupBox( tr( "BORDER_COLOR" ), mainFrame() );
+  myBorderColorGroup->setCheckable( true );
+
+  myBorderColorBox = new HYDROGUI_ColorWidget( myBorderColorGroup );
+
+  QBoxLayout* aBorderColorLayout = new QHBoxLayout( myBorderColorGroup );
+  aBorderColorLayout->setMargin( 5 );
+  aBorderColorLayout->setSpacing( 5 );
+  aBorderColorLayout->addWidget( new QLabel( tr( "COLOR" ), myBorderColorGroup ) );
+  aBorderColorLayout->addWidget( myBorderColorBox );
+
+
+  QBoxLayout* aParamLayout = new QVBoxLayout( aParamGroup );
+  aParamLayout->setMargin( 5 );
+  aParamLayout->setSpacing( 5 );
+  aParamLayout->addWidget( aPolylineFrame );
+  aParamLayout->addWidget( aFillingFrame );
+  aParamLayout->addWidget( myBorderColorGroup );
+
+
+  QGroupBox* aBathGroup = new QGroupBox( tr( "ZONE_BATHYMETRY" ), mainFrame() );
+
+  myBathymetries = new QComboBox( aPolylineFrame );
+  myBathymetries->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+
+  QBoxLayout* aBathLayout = new QHBoxLayout( aBathGroup );
+  aBathLayout->setMargin( 5 );
+  aBathLayout->setSpacing( 5 );
+  aBathLayout->addWidget( myBathymetries );
+
+
+  // Common
+  addWidget( myObjectNameGroup );
+  addWidget( aParamGroup );
+  addWidget( aBathGroup );
+
+  addStretch();
+
+
+  // Connect signals and slots
+  connect( myPolylines, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onZoneDefChanged() ) );
+  connect( myFillingTransparent, SIGNAL( toggled( bool ) ), this, SLOT( onZoneDefChanged() ) );
+  connect( myFillingColor, SIGNAL( toggled( bool ) ), this, SLOT( onZoneDefChanged() ) );
+  connect( myFillingColorBox, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( onFillingColorChanged() ) );
+  connect( myBorderColorGroup, SIGNAL( toggled( bool ) ), this, SLOT( onZoneDefChanged() ) );
+  connect( myBorderColorBox, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( onZoneDefChanged() ) );
+}
+
+HYDROGUI_ImmersibleZoneDlg::~HYDROGUI_ImmersibleZoneDlg()
+{
+}
+
+void HYDROGUI_ImmersibleZoneDlg::reset()
+{
+  bool isBlocked = blockSignals( true );
+
+  myObjectName->clear();
+
+  myPolylines->clear();
+  myBathymetries->clear();
+
+  myFillingTransparent->setChecked( true );
+  myFillingColorBox->resetColor();
+
+  myBorderColorGroup->setChecked( false );
+  myBorderColorBox->resetColor();
+
+  blockSignals( isBlocked );
+
+  onZoneDefChanged();
+}
+
+void HYDROGUI_ImmersibleZoneDlg::setObjectName( const QString& theName )
+{
+  myObjectName->setText( theName );
+}
+
+QString HYDROGUI_ImmersibleZoneDlg::getObjectName() const
+{
+  return myObjectName->text();
+}
+
+void HYDROGUI_ImmersibleZoneDlg::setPolylineNames( const QStringList& thePolylines )
+{
+  bool isBlocked = blockSignals( true );
+
+  myPolylines->clear();
+  myPolylines->addItems( thePolylines );
+
+  blockSignals( isBlocked );
+}
+
+void HYDROGUI_ImmersibleZoneDlg::setPolylineName( const QString& theName )
+{
+  int aNewIdx = myPolylines->findText( theName );
+  if ( aNewIdx != myPolylines->currentIndex() )
+  {
+    myPolylines->setCurrentIndex( aNewIdx );
+  }
+  else
+  {
+    onZoneDefChanged();
+  }
+}
+
+QString HYDROGUI_ImmersibleZoneDlg::getPolylineName() const
+{
+  return myPolylines->currentText();
+}
+
+void HYDROGUI_ImmersibleZoneDlg::setBathymetryNames( const QStringList& theBathymetries )
+{
+  bool isBlocked = blockSignals( true );
+
+  myBathymetries->clear();
+  myBathymetries->addItems( theBathymetries );
+
+  blockSignals( isBlocked );
+}
+
+void HYDROGUI_ImmersibleZoneDlg::setBathymetryName( const QString& theName )
+{
+  int aNewIdx = myBathymetries->findText( theName );
+  myBathymetries->setCurrentIndex( aNewIdx );
+}
+
+QString HYDROGUI_ImmersibleZoneDlg::getBathymetryName() const
+{
+  return myBathymetries->currentText();
+}
+
+void HYDROGUI_ImmersibleZoneDlg::setFillingColor( const QColor& theColor )
+{
+  bool isBlocked = blockSignals( true );
+
+  if( theColor.alpha() == 0 ) // transparent
+    myFillingTransparent->setChecked( true );
+  else
+    myFillingColor->setChecked( true );
+
+  myFillingColorBox->setColor( theColor );
+
+  blockSignals( isBlocked );
+
+  onZoneDefChanged();
+}
+
+QColor HYDROGUI_ImmersibleZoneDlg::getFillingColor() const
+{
+  QColor aColor( 255, 255, 255, 0 ); // transparent
+  if( myFillingColor->isChecked() )
+    aColor = myFillingColorBox->color();
+  return aColor;
+}
+
+void HYDROGUI_ImmersibleZoneDlg::setBorderColor( const QColor& theColor )
+{
+  bool isBlocked = blockSignals( true );
+
+  bool isTransparent = theColor.alpha() == 0;
+  myBorderColorGroup->setChecked( !isTransparent );
+  myBorderColorBox->setColor( !isTransparent ? theColor : QColor( Qt::black ) );
+
+  blockSignals( isBlocked );
+
+  onZoneDefChanged();
+}
+
+QColor HYDROGUI_ImmersibleZoneDlg::getBorderColor() const
+{
+  QColor aColor( Qt::transparent ); // transparent
+  if( myBorderColorGroup->isChecked() )
+    aColor = myBorderColorBox->color();
+  return aColor;
+}
+
+void HYDROGUI_ImmersibleZoneDlg::onFillingColorChanged()
+{
+  if ( !myFillingColor->isChecked() )
+    return;
+
+  onZoneDefChanged();
+}
+
+void HYDROGUI_ImmersibleZoneDlg::onZoneDefChanged()
+{
+  if ( signalsBlocked() )
+    return;
+
+  QString aPolylineName = getPolylineName();
+  emit CreatePreview( aPolylineName );
+}
+
+
diff --git a/src/HYDROGUI/HYDROGUI_ImmersibleZoneDlg.h b/src/HYDROGUI/HYDROGUI_ImmersibleZoneDlg.h
new file mode 100644 (file)
index 0000000..548580e
--- /dev/null
@@ -0,0 +1,85 @@
+// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef HYDROGUI_ImmersibleZoneDlg_H
+#define HYDROGUI_ImmersibleZoneDlg_H
+
+#include "HYDROGUI_InputPanel.h"
+
+class HYDROGUI_ColorWidget;
+class QComboBox;
+class QGroupBox;
+class QLineEdit;
+class QListWidget;
+class QRadioButton;
+
+class HYDROGUI_ImmersibleZoneDlg : public HYDROGUI_InputPanel
+{
+  Q_OBJECT
+
+public:
+  HYDROGUI_ImmersibleZoneDlg( HYDROGUI_Module* theModule, const QString& theTitle );
+  virtual ~HYDROGUI_ImmersibleZoneDlg();
+
+  void                       reset();
+
+  void                       setObjectName( const QString& theName );
+  QString                    getObjectName() const;
+
+  void                       setPolylineNames( const QStringList& thePolylines );
+  void                       setPolylineName( const QString& thePolyline );
+  QString                    getPolylineName() const;
+
+  void                       setBathymetryNames( const QStringList& theBathymetries );
+  void                       setBathymetryName( const QString& theBathymetry );
+  QString                    getBathymetryName() const;
+
+  void                       setFillingColor( const QColor& theColor );
+  QColor                     getFillingColor() const;
+
+  void                       setBorderColor( const QColor& theColor );
+  QColor                     getBorderColor() const;
+
+signals:
+  void                       CreatePreview( const QString& thePolylineName );
+
+private slots:
+  void                       onZoneDefChanged();
+  void                       onFillingColorChanged();
+
+private:
+
+  QGroupBox*                 myObjectNameGroup;
+  QLineEdit*                 myObjectName;
+
+  QComboBox*                 myPolylines;
+  QComboBox*                 myBathymetries;
+
+  QRadioButton*              myFillingTransparent;
+  QRadioButton*              myFillingColor;
+  HYDROGUI_ColorWidget*      myFillingColorBox;
+
+  QGroupBox*                 myBorderColorGroup;
+  HYDROGUI_ColorWidget*      myBorderColorBox;
+};
+
+#endif
diff --git a/src/HYDROGUI/HYDROGUI_ImmersibleZoneOp.cxx b/src/HYDROGUI/HYDROGUI_ImmersibleZoneOp.cxx
new file mode 100644 (file)
index 0000000..56ef1cd
--- /dev/null
@@ -0,0 +1,281 @@
+// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "HYDROGUI_ImmersibleZoneOp.h"
+
+#include "HYDROGUI_DataModel.h"
+#include "HYDROGUI_ImmersibleZoneDlg.h"
+#include "HYDROGUI_Module.h"
+#include "HYDROGUI_Shape.h"
+#include "HYDROGUI_Tool.h"
+#include "HYDROGUI_UpdateFlags.h"
+
+#include <HYDROData_Bathymetry.h>
+#include <HYDROData_Iterator.h>
+#include <HYDROData_Polyline.h>
+
+#include <OCCViewer_ViewManager.h>
+#include <OCCViewer_ViewModel.h>
+
+#include <LightApp_Application.h>
+#include <LightApp_UpdateFlags.h>
+
+#include <TopoDS.hxx>
+#include <TopoDS_Wire.hxx>
+
+HYDROGUI_ImmersibleZoneOp::HYDROGUI_ImmersibleZoneOp( HYDROGUI_Module* theModule,
+                                                      const bool theIsEdit )
+: HYDROGUI_Operation( theModule ),
+  myIsEdit( theIsEdit ),
+  myViewManager( 0 ),
+  myPreviewPrs( 0 )
+{
+  setName( theIsEdit ? tr( "EDIT_IMMERSIBLE_ZONE" ) : tr( "CREATE_IMMERSIBLE_ZONE" ) );
+}
+
+HYDROGUI_ImmersibleZoneOp::~HYDROGUI_ImmersibleZoneOp()
+{
+  closePreview();
+}
+
+void HYDROGUI_ImmersibleZoneOp::startOperation()
+{
+  HYDROGUI_Operation::startOperation();
+
+  HYDROGUI_ImmersibleZoneDlg* aPanel = ::qobject_cast<HYDROGUI_ImmersibleZoneDlg*>( inputPanel() );
+  if ( !aPanel )
+    return;
+
+  aPanel->blockSignals( true );
+
+  aPanel->reset();
+
+  QString anObjectName = HYDROGUI_Tool::GenerateObjectName( module(), "Zone" );
+
+  QColor      aFillingColor( HYDROData_ImmersibleZone::DefaultFillingColor() );
+  QColor      aBorderColor( HYDROData_ImmersibleZone::DefaultBorderColor() );
+  QString     aSelectedPolyline, aSelectedBathymetry;
+  QStringList aSelectedBathymetries;
+
+  if ( myIsEdit )
+  {
+    myEditedObject = Handle(HYDROData_ImmersibleZone)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) );
+    if( !myEditedObject.IsNull() )
+    {
+      anObjectName = myEditedObject->GetName();
+
+      aFillingColor = myEditedObject->GetFillingColor();
+      aBorderColor = myEditedObject->GetBorderColor();
+
+      Handle(HYDROData_Polyline) aRefPolyline = myEditedObject->GetPolyline();
+      if ( !aRefPolyline.IsNull() )
+        aSelectedPolyline = aRefPolyline->GetName();
+
+      Handle(HYDROData_Bathymetry) aRefBathymetry = myEditedObject->GetBathymetry();
+      if ( !aRefBathymetry.IsNull() )
+        aSelectedBathymetry = aRefBathymetry->GetName();
+    }
+  }
+
+  // collect information about existing closed polylines
+  QStringList aPolylines;
+
+  HYDROData_Iterator anIter( doc(), KIND_POLYLINE );
+  for ( ; anIter.More(); anIter.Next() )
+  {
+    Handle(HYDROData_Polyline) aPolylineObj = 
+      Handle(HYDROData_Polyline)::DownCast( anIter.Current() );
+    if ( aPolylineObj.IsNull() || !aPolylineObj->IsClosed() )
+      continue;
+
+    QString aPolylineName = aPolylineObj->GetName();
+    if ( aPolylineName.isEmpty() )
+      continue;
+
+    aPolylines.append( aPolylineName );
+  }
+
+  // collect information about existing bathymetries
+  QStringList aBathymetries;
+
+  anIter = HYDROData_Iterator( doc(), KIND_BATHYMETRY );
+  for ( ; anIter.More(); anIter.Next() )
+  {
+    Handle(HYDROData_Bathymetry) aBathymetryObj = 
+      Handle(HYDROData_Bathymetry)::DownCast( anIter.Current() );
+    if ( aBathymetryObj.IsNull() )
+      continue;
+
+    QString aBathymetryName = aBathymetryObj->GetName();
+    if ( aBathymetryName.isEmpty() )
+      continue;
+
+    aBathymetries.append( aBathymetryName );
+  }
+  
+  aPanel->setObjectName( anObjectName );
+  
+  aPanel->setFillingColor( aFillingColor );
+  aPanel->setBorderColor( aBorderColor );
+
+  aPanel->setPolylineNames( aPolylines );
+  aPanel->setBathymetryNames( aBathymetries );
+
+  aPanel->blockSignals( false );
+
+  aPanel->setPolylineName( aSelectedPolyline );
+  aPanel->setBathymetryName( aSelectedBathymetry );
+}
+
+void HYDROGUI_ImmersibleZoneOp::abortOperation()
+{
+  closePreview();
+
+  HYDROGUI_Operation::abortOperation();
+}
+
+void HYDROGUI_ImmersibleZoneOp::commitOperation()
+{
+  closePreview();
+
+  HYDROGUI_Operation::commitOperation();
+}
+
+HYDROGUI_InputPanel* HYDROGUI_ImmersibleZoneOp::createInputPanel() const
+{
+  HYDROGUI_ImmersibleZoneDlg* aPanel = new HYDROGUI_ImmersibleZoneDlg( module(), getName() );
+  connect( aPanel, SIGNAL( CreatePreview( const QString& ) ),
+           this,   SLOT( onCreatePreview( const QString& ) ) );
+  return aPanel;
+}
+
+bool HYDROGUI_ImmersibleZoneOp::processApply( int& theUpdateFlags,
+                                              QString& theErrorMsg )
+{
+  HYDROGUI_ImmersibleZoneDlg* aPanel = ::qobject_cast<HYDROGUI_ImmersibleZoneDlg*>( inputPanel() );
+  if ( !aPanel )
+    return false;
+
+  QString anObjectName = aPanel->getObjectName().simplified();
+  if ( anObjectName.isEmpty() )
+  {
+    theErrorMsg = tr( "INCORRECT_OBJECT_NAME" );
+    return false;
+  }
+
+  if( !myIsEdit || ( !myEditedObject.IsNull() && myEditedObject->GetName() != anObjectName ) )
+  {
+    // check that there are no other objects with the same name in the document
+    Handle(HYDROData_Entity) anObject = HYDROGUI_Tool::FindObjectByName( module(), anObjectName );
+    if( !anObject.IsNull() )
+    {
+      theErrorMsg = tr( "OBJECT_EXISTS_IN_DOCUMENT" ).arg( anObjectName );
+      return false;
+    }
+  }
+
+  Handle(HYDROData_ImmersibleZone) aZoneObj = myIsEdit ? myEditedObject :
+    Handle(HYDROData_ImmersibleZone)::DownCast( doc()->CreateObject( KIND_IMMERSIBLE_ZONE ) );
+  if ( aZoneObj.IsNull() )
+    return false;
+
+  Handle(HYDROData_Polyline) aZonePolyline;
+  Handle(HYDROData_Bathymetry) aZoneBathymetry;
+
+  QString aPolylineName = aPanel->getPolylineName();
+  if ( !aPolylineName.isEmpty() )
+  {
+    aZonePolyline = Handle(HYDROData_Polyline)::DownCast(
+      HYDROGUI_Tool::FindObjectByName( module(), aPolylineName, KIND_POLYLINE ) );
+  }
+
+  QString aBathymetryName = aPanel->getBathymetryName();
+  if ( !aBathymetryName.isEmpty() )
+  {
+    aZoneBathymetry = Handle(HYDROData_Bathymetry)::DownCast(
+      HYDROGUI_Tool::FindObjectByName( module(), aBathymetryName, KIND_BATHYMETRY ) );
+  }
+
+  aZoneObj->SetName( anObjectName );
+
+  aZoneObj->SetFillingColor( aPanel->getFillingColor() );
+  aZoneObj->SetBorderColor( aPanel->getBorderColor() );
+
+  aZoneObj->SetPolyline( aZonePolyline );
+  aZoneObj->SetBathymetry( aZoneBathymetry );
+
+  closePreview();
+
+  if( !myIsEdit )
+    module()->setObjectVisible( HYDROGUI_Tool::GetActiveOCCViewId( module() ), aZoneObj, true );
+
+  theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced;
+
+  return true;
+}
+
+void HYDROGUI_ImmersibleZoneOp::onCreatePreview( const QString& thePolylineName )
+{
+  HYDROGUI_ImmersibleZoneDlg* aPanel = ::qobject_cast<HYDROGUI_ImmersibleZoneDlg*>( inputPanel() );
+  if ( !aPanel )
+    return;
+
+  TopoDS_Wire aWire;
+
+  Handle(HYDROData_Polyline) aPolyline = Handle(HYDROData_Polyline)::DownCast(
+    HYDROGUI_Tool::FindObjectByName( module(), thePolylineName, KIND_POLYLINE ) );
+  if ( !aPolyline.IsNull() )
+  {
+    aWire = TopoDS::Wire( aPolyline->GetTopShape() );
+  }
+
+  LightApp_Application* anApp = module()->getApp();
+  if ( !myViewManager )
+    myViewManager = ::qobject_cast<OCCViewer_ViewManager*>( 
+      anApp->getViewManager( OCCViewer_Viewer::Type(), true ) );
+
+  if ( myViewManager && !myPreviewPrs )
+  {
+    if ( OCCViewer_Viewer* aViewer = myViewManager->getOCCViewer() )
+    {
+      Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext();
+      if ( !aCtx.IsNull() )
+        myPreviewPrs = new HYDROGUI_Shape( aCtx, NULL );
+    }
+  }
+
+  if ( !myViewManager || !myPreviewPrs )
+    return;
+
+  myPreviewPrs->setFillingColor( aPanel->getFillingColor(), false, false );
+  myPreviewPrs->setBorderColor( aPanel->getBorderColor(), false, false );
+  myPreviewPrs->setFace( aWire );
+}
+
+void HYDROGUI_ImmersibleZoneOp::closePreview()
+{
+  if( myPreviewPrs )
+  {
+    delete myPreviewPrs;
+    myPreviewPrs = 0;
+  }
+}
diff --git a/src/HYDROGUI/HYDROGUI_ImmersibleZoneOp.h b/src/HYDROGUI/HYDROGUI_ImmersibleZoneOp.h
new file mode 100644 (file)
index 0000000..ba4410b
--- /dev/null
@@ -0,0 +1,66 @@
+// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef HYDROGUI_ImmersibleZoneOp_H
+#define HYDROGUI_ImmersibleZoneOp_H
+
+#include "HYDROGUI_Operation.h"
+
+#include <HYDROData_ImmersibleZone.h>
+
+class OCCViewer_ViewManager;
+
+class HYDROGUI_Shape;
+
+class HYDROGUI_ImmersibleZoneOp : public HYDROGUI_Operation
+{
+  Q_OBJECT
+
+public:
+  HYDROGUI_ImmersibleZoneOp( HYDROGUI_Module* theModule, const bool theIsEdit );
+  virtual ~HYDROGUI_ImmersibleZoneOp();
+
+protected:
+  virtual void               startOperation();
+  virtual void               abortOperation();
+  virtual void               commitOperation();
+
+  virtual HYDROGUI_InputPanel* createInputPanel() const;
+
+  virtual bool               processApply( int& theUpdateFlags, QString& theErrorMsg );
+
+protected slots:
+  void                       onCreatePreview( const QString& thePolylineName );
+
+private:
+  void                       closePreview();
+
+private:
+  bool                             myIsEdit;
+  Handle(HYDROData_ImmersibleZone) myEditedObject;
+
+  OCCViewer_ViewManager*           myViewManager;
+
+  HYDROGUI_Shape*                  myPreviewPrs;
+};
+
+#endif
index d902c7d397bd0317de7103334d3f7852741bb9ec..2654523a0c8b6a0f4ec1a566d6a6a5a01f293576 100644 (file)
@@ -106,7 +106,7 @@ bool HYDROGUI_ImportBathymetryOp::processApply( int& theUpdateFlags,
   }
 
   // check that there are no other objects with the same name in the document
-  Handle(HYDROData_Object) anObject = HYDROGUI_Tool::FindObjectByName( module(), anObjectName );
+  Handle(HYDROData_Entity) anObject = HYDROGUI_Tool::FindObjectByName( module(), anObjectName );
   if ( !anObject.IsNull() )
   {
     theErrorMsg = tr( "OBJECT_EXISTS_IN_DOCUMENT" ).arg( anObjectName );
index 8e6cc2311c6c822ba545550c46e35093e3c95979..6db630212db27aff3c2232f8e92191543b4839d5 100644 (file)
@@ -32,7 +32,7 @@
 #include <HYDROData_Iterator.h>
 #include <HYDROData_Lambert93.h>
 
-#include <HYDROOperations_Factory.h>
+#include <HYDROData_OperationsFactory.h>
 
 #include <GraphicsView_ViewManager.h>
 #include <GraphicsView_ViewPort.h>
@@ -126,7 +126,7 @@ void HYDROGUI_ImportImageOp::startOperation()
     Handle(HYDROData_Image) anImageObj = Handle(HYDROData_Image)::DownCast( anIterator.Current() );
     if( !anImageObj.IsNull() )
     {
-      if( myIsEdit && HYDROGUI_Tool::IsEqual( anImageObj, myEditedObject ) )
+      if( myIsEdit && IsEqual( anImageObj, myEditedObject ) )
         continue;
 
       QPoint aPointA1, aPointB1, aPointC1;
@@ -193,7 +193,7 @@ bool HYDROGUI_ImportImageOp::processApply( int& theUpdateFlags,
   if( !myIsEdit || ( !myEditedObject.IsNull() && myEditedObject->GetName() != anImageName ) )
   {
     // check that there are no other objects with the same name in the document
-    Handle(HYDROData_Object) anObject = HYDROGUI_Tool::FindObjectByName( module(), anImageName );
+    Handle(HYDROData_Entity) anObject = HYDROGUI_Tool::FindObjectByName( module(), anImageName );
     if( !anObject.IsNull() )
     {
       theErrorMsg = tr( "OBJECT_EXISTS_IN_DOCUMENT" ).arg( anImageName );
index cb2cd1c7564d79ad315971940c7d5c00085f4b9e..986dce2d55a4fbe05289291e97d8d25ff8030184 100644 (file)
@@ -39,7 +39,7 @@
 #include <HYDROData_Image.h>
 #include <HYDROData_Lambert93.h>
 
-#include <HYDROOperations_Factory.h>
+#include <HYDROData_OperationsFactory.h>
 
 #include <GraphicsView_ViewFrame.h>
 #include <GraphicsView_ViewManager.h>
@@ -206,14 +206,14 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
   bool anIsMustBeUpdatedImage = false;
   bool anIsPolyline = false;
   bool anIsCalculation = false;
-  bool anIsZone = false;
+  bool anIsImmersibleZone = false;
   bool anIsVisualState = false;
 
   // check the selected data model objects
   HYDROData_SequenceOfObjects aSeq = HYDROGUI_Tool::GetSelectedObjects( this );
   for( Standard_Integer anIndex = 1, aLength = aSeq.Length(); anIndex <= aLength; anIndex++ )
   {
-    Handle(HYDROData_Object) anObject = aSeq.Value( anIndex );
+    Handle(HYDROData_Entity) anObject = aSeq.Value( anIndex );
     if( !anObject.IsNull() )
     {
       anIsSelectedDataObjects = true;
@@ -230,7 +230,7 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
         {
           anIsImportedImage = anImage->HasTrsfPoints() && !anImage->IsSelfSplitted();
           anIsCompositeImage = anImage->NbReferences() > 0;
-          if( HYDROOperations_Factory* aFactory = HYDROOperations_Factory::Factory() )
+          if( HYDROData_OperationsFactory* aFactory = HYDROData_OperationsFactory::Factory() )
           {
             if( ImageComposer_Operator* anOperator = aFactory->Operator( anImage ) )
             {
@@ -250,8 +250,8 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
         anIsPolyline = true;
       else if( anObject->GetKind() == KIND_CALCULATION )
         anIsCalculation = true;
-      else if( anObject->GetKind() == KIND_ZONE )
-        anIsZone = true;
+      else if( anObject->GetKind() == KIND_IMMERSIBLE_ZONE )
+        anIsImmersibleZone = true;
       else if( anObject->GetKind() == KIND_VISUAL_STATE )
         anIsVisualState = true;
     }
@@ -280,8 +280,8 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
         case KIND_CALCULATION:
           theMenu->addAction( action( CreateCalculationId ) );
           break;
-        case KIND_ZONE:
-          theMenu->addAction( action( CreateZoneId ) );
+        case KIND_IMMERSIBLE_ZONE:
+          theMenu->addAction( action( CreateImmersibleZoneId ) );
           break;
       }
       theMenu->addSeparator();
@@ -329,9 +329,9 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
       theMenu->addAction( action( EditCalculationId ) );
       theMenu->addSeparator();
     }
-    else if( anIsZone )
+    else if( anIsImmersibleZone )
     {
-      theMenu->addAction( action( EditZoneId ) );
+      theMenu->addAction( action( EditImmersibleZoneId ) );
       theMenu->addSeparator();
     }
     else if( anIsVisualState && anIsObjectBrowser )
@@ -348,7 +348,7 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
     theMenu->addSeparator();
   }
 
-  if( anIsSelectedDataObjects && ( anIsImage || anIsPolyline || anIsZone ) )
+  if( anIsSelectedDataObjects && ( anIsImage || anIsPolyline || anIsImmersibleZone ) )
   {
     if( anIsHiddenInSelection )
       theMenu->addAction( action( ShowId ) );
@@ -508,7 +508,7 @@ void HYDROGUI_Module::setViewManagerRole( SUIT_ViewManager* theViewManager,
 }
 
 bool HYDROGUI_Module::isObjectVisible( const int theViewId,
-                                       const Handle(HYDROData_Object)& theObject ) const
+                                       const Handle(HYDROData_Entity)& theObject ) const
 {
   if( theObject.IsNull() )
     return false;
@@ -528,7 +528,7 @@ bool HYDROGUI_Module::isObjectVisible( const int theViewId,
 }
 
 void HYDROGUI_Module::setObjectVisible( const int theViewId,
-                                        const Handle(HYDROData_Object)& theObject,
+                                        const Handle(HYDROData_Entity)& theObject,
                                         const bool theState )
 {
   if( !theObject.IsNull() )
@@ -540,7 +540,7 @@ void HYDROGUI_Module::setObjectVisible( const int theViewId,
 }
 
 HYDROGUI_Shape* HYDROGUI_Module::getObjectShape( const int                       theViewId,
-                                                 const Handle(HYDROData_Object)& theObject ) const
+                                                 const Handle(HYDROData_Entity)& theObject ) const
 {
   HYDROGUI_Shape* aResShape = NULL;
   if( theObject.IsNull() )
@@ -563,7 +563,7 @@ HYDROGUI_Shape* HYDROGUI_Module::getObjectShape( const int
 }
 
 void HYDROGUI_Module::setObjectShape( const int                       theViewId,
-                                      const Handle(HYDROData_Object)& theObject,
+                                      const Handle(HYDROData_Entity)& theObject,
                                       HYDROGUI_Shape*                 theShape )
 {
   if( theObject.IsNull() )
@@ -574,7 +574,7 @@ void HYDROGUI_Module::setObjectShape( const int                       theViewId,
 }
 
 void HYDROGUI_Module::removeObjectShape( const int                       theViewId,
-                                         const Handle(HYDROData_Object)& theObject )
+                                         const Handle(HYDROData_Entity)& theObject )
 {
   if ( !myShapesMap.contains( theViewId ) )
     return;
index c4c1317e0357977bb9d6ac57812beb361a6a89c1..3561ed1c9b82048d45cbaa6b356db06ac36592d8 100644 (file)
@@ -23,7 +23,7 @@
 #ifndef HYDROGUI_MODULE_H
 #define HYDROGUI_MODULE_H
 
-#include <HYDROData_Object.h>
+#include <HYDROData_Entity.h>
 
 #include <LightApp_Module.h>
 
@@ -111,19 +111,19 @@ public:
                                                       const ViewManagerRole theRole );
 
   bool                            isObjectVisible( const int theViewId,
-                                                   const Handle(HYDROData_Object)& theObject ) const;
+                                                   const Handle(HYDROData_Entity)& theObject ) const;
   void                            setObjectVisible( const int theViewId,
-                                                    const Handle(HYDROData_Object)& theObject,
+                                                    const Handle(HYDROData_Entity)& theObject,
                                                     const bool theState );
 
   HYDROGUI_Shape*                 getObjectShape( const int                       theViewId,
-                                                  const Handle(HYDROData_Object)& theObject ) const;
+                                                  const Handle(HYDROData_Entity)& theObject ) const;
   void                            setObjectShape( const int                       theViewId,
-                                                  const Handle(HYDROData_Object)& theObject,
+                                                  const Handle(HYDROData_Entity)& theObject,
                                                   HYDROGUI_Shape*                 theShape );
   void                            removeViewShapes( const int                       theViewId );
   void                            removeObjectShape( const int                       theViewId,
-                                                     const Handle(HYDROData_Object)& theObject );
+                                                     const Handle(HYDROData_Entity)& theObject );
 
 protected:
   CAM_DataModel*                  createDataModel();
index 8be446e4555cf90efa0fb637b9aaec86989e9f9b..0ab14c6b371f66d70a64f6ee6d576946275db8ca 100644 (file)
@@ -55,7 +55,7 @@ void HYDROGUI_OCCDisplayer::SetToUpdate( const HYDROData_SequenceOfObjects& theO
 
   for ( int i = 1, n = theObjs.Length(); i <= n; i++ )
   {
-    Handle(HYDROData_Object) anObj = theObjs.Value( i );
+    Handle(HYDROData_Entity) anObj = theObjs.Value( i );
     if( anObj.IsNull() )
       continue;
 
@@ -106,7 +106,7 @@ void HYDROGUI_OCCDisplayer::Update( const HYDROData_SequenceOfObjects& theObjs,
 
   for( int i = 1, n = theObjs.Length(); i <= n; i++ )
   {
-    const Handle(HYDROData_Object)& anObj = theObjs.Value( i );
+    const Handle(HYDROData_Entity)& anObj = theObjs.Value( i );
     if( anObj.IsNull() )
       anObjectsToErase.Append( anObj );
     else
@@ -128,7 +128,7 @@ void HYDROGUI_OCCDisplayer::Erase( const HYDROData_SequenceOfObjects& theObjs,
 
   for ( int i = 1, n = theObjs.Length(); i <= n; i++ )
   {
-    Handle(HYDROData_Object) anObj = theObjs.Value( i );
+    Handle(HYDROData_Entity) anObj = theObjs.Value( i );
     if( anObj.IsNull() )
       continue;
 
@@ -138,7 +138,7 @@ void HYDROGUI_OCCDisplayer::Erase( const HYDROData_SequenceOfObjects& theObjs,
 
 HYDROGUI_Shape* HYDROGUI_OCCDisplayer::createShape( const int                             theViewerId,
                                                     const Handle(AIS_InteractiveContext)& theContext,
-                                                    const Handle(HYDROData_Object)&       theObject )
+                                                    const Handle(HYDROData_Entity)&       theObject )
 {
   HYDROGUI_Shape* aResShape = NULL;
   if ( theContext.IsNull() || theObject.IsNull() )
@@ -147,6 +147,8 @@ HYDROGUI_Shape* HYDROGUI_OCCDisplayer::createShape( const int
   ObjectKind anObjectKind = theObject->GetKind();
   if ( anObjectKind != KIND_IMAGE &&
        anObjectKind != KIND_POLYLINE &&
+       anObjectKind != KIND_IMMERSIBLE_ZONE &&
+       anObjectKind != KIND_REGION &&
        anObjectKind != KIND_ZONE )
     return aResShape;
 
@@ -170,7 +172,7 @@ void HYDROGUI_OCCDisplayer::Display( const HYDROData_SequenceOfObjects& theObjs,
 
   for ( int i = 1, n = theObjs.Length(); i <= n; i++ )
   {
-    Handle(HYDROData_Object) anObj = theObjs.Value( i );
+    Handle(HYDROData_Entity) anObj = theObjs.Value( i );
     if ( anObj.IsNull() || anObj->IsRemoved() )
       continue;
 
@@ -226,8 +228,8 @@ void HYDROGUI_OCCDisplayer::purgeObjects( const int theViewerId )
     if ( aPrsObj.IsNull() )
       continue;
 
-    Handle(HYDROData_Object) anOwnerObj = 
-      Handle(HYDROData_Object)::DownCast( aPrsObj->GetOwner() );
+    Handle(HYDROData_Entity) anOwnerObj = 
+      Handle(HYDROData_Entity)::DownCast( aPrsObj->GetOwner() );
     if ( !anOwnerObj.IsNull() && anOwnerObj->IsRemoved() )
       myModule->removeObjectShape( (size_t)aViewer, anOwnerObj );
   }
index f4c013bb869da6d21c3ac78f75c9c1088c6e321c..f8d1ea13b14c7aea5d6611a92b892a0da426e3d3 100644 (file)
@@ -23,7 +23,7 @@
 #ifndef HYDROGUI_OCCDISPLAYER_H
 #define HYDROGUI_OCCDISPLAYER_H
 
-#include <HYDROData_Object.h>
+#include <HYDROData_Entity.h>
 
 class HYDROGUI_Module;
 class HYDROGUI_Shape;
@@ -125,7 +125,7 @@ private:
    */
   HYDROGUI_Shape*                 createShape( const int                             theViewerId,
                                                const Handle(AIS_InteractiveContext)& theContext,
-                                               const Handle(HYDROData_Object)&       theObject );
+                                               const Handle(HYDROData_Entity)&       theObject );
 
 private:
   HYDROGUI_Module*                myModule;
index 24d8975b400479ec392eba562dd2b6658f671015..3abc6754e1b23a83c62d5cc3108eaac288a347d0 100644 (file)
@@ -70,8 +70,8 @@ QString HYDROGUI_OCCSelector::entry( const Handle(AIS_InteractiveObject)& anAIS
   if ( anAIS.IsNull() || !anAIS->HasOwner() )
     return aRes;
 
-  Handle(HYDROData_Object) anObj = 
-    Handle(HYDROData_Object)::DownCast( anAIS->GetOwner() );
+  Handle(HYDROData_Entity) anObj = 
+    Handle(HYDROData_Entity)::DownCast( anAIS->GetOwner() );
   if ( !anObj.IsNull() )
     aRes = HYDROGUI_DataObject::dataObjectEntry( anObj );
 
index a79c1f6b2d1cea3102cc98d318992090a2396f54..19ddb76ec31d5b748bccaf6063817fc9a7315983 100644 (file)
@@ -99,7 +99,7 @@ void HYDROGUI_ObjSelector::OnSelectionChanged()
     return;
 
   QString anObjName;
-  Handle(HYDROData_Object) anObject = HYDROGUI_Tool::GetSelectedObject( myModule );
+  Handle(HYDROData_Entity) anObject = HYDROGUI_Tool::GetSelectedObject( myModule );
   if( !anObject.IsNull() )
     if( myObjectKind == KIND_UNKNOWN || myObjectKind == anObject->GetKind() )
       anObjName = anObject->GetName();
index 706d9b75c56787c6f0b020ca62fee5c9606b023a..31a9f34ae4aa37671151d323742e3090b24faacd 100644 (file)
 #include "HYDROGUI_ObserveImageOp.h"
 #include "HYDROGUI_PolylineOp.h"
 #include "HYDROGUI_ShowHideOp.h"
-#include "HYDROGUI_SplitZonesTool.h"
+#include "HYDROData_SplitToZonesTool.h"
 #include "HYDROGUI_TwoImagesOp.h"
 #include "HYDROGUI_UpdateFlags.h"
 #include "HYDROGUI_UpdateImageOp.h"
 #include "HYDROGUI_VisualStateOp.h"
-#include "HYDROGUI_ZoneOp.h"
+#include "HYDROGUI_ImmersibleZoneOp.h"
 
 #include <CAM_Application.h>
 
@@ -88,8 +88,8 @@ void HYDROGUI_Module::createActions()
 
   createAction( ImportBathymetryId, "IMPORT_BATHYMETRY", "", Qt::CTRL + Qt::Key_B );
 
-  createAction( CreateZoneId, "CREATE_ZONE" );
-  createAction( EditZoneId, "EDIT_ZONE" );
+  createAction( CreateImmersibleZoneId, "CREATE_IMMERSIBLE_ZONE" );
+  createAction( EditImmersibleZoneId, "EDIT_ZONE" );
 
   createAction( CreateCalculationId, "CREATE_CALCULATION" );
   createAction( EditCalculationId, "EDIT_CALCULATION" );
@@ -131,7 +131,7 @@ void HYDROGUI_Module::createMenus()
   createMenu( ImportImageId, aHydroId, -1, -1 );
   createMenu( ImportBathymetryId, aHydroId, -1, -1 );
   createMenu( CreatePolylineId, aHydroId, -1, -1 );
-  createMenu( CreateZoneId, aHydroId, -1, -1 );
+  createMenu( CreateImmersibleZoneId, aHydroId, -1, -1 );
   createMenu( CreateCalculationId, aHydroId, -1, -1 );
   createMenu( separator(), aHydroId );
   createMenu( FuseImagesId, aHydroId, -1, -1 );
@@ -277,9 +277,9 @@ LightApp_Operation* HYDROGUI_Module::createOperation( const int theId ) const
   case ImportBathymetryId:
     anOp = new HYDROGUI_ImportBathymetryOp( aModule );
     break;
-  case CreateZoneId:
-  case EditZoneId:
-    anOp = new HYDROGUI_ZoneOp( aModule, theId == EditZoneId );
+  case CreateImmersibleZoneId:
+  case EditImmersibleZoneId:
+    anOp = new HYDROGUI_ImmersibleZoneOp( aModule, theId == EditImmersibleZoneId );
     break;
   case CreateCalculationId:
   case EditCalculationId:
index c8b8309f6829fdebf6b271bec7ed3e700a81a044..959286e8400b7c2438ecb8064af7a6f0edb1a8e4 100644 (file)
@@ -48,8 +48,8 @@ enum OperationId
   ImportBathymetryId,
   EditImportedBathymetryId,
 
-  CreateZoneId,
-  EditZoneId,
+  CreateImmersibleZoneId,
+  EditImmersibleZoneId,
 
   CreateCalculationId,
   EditCalculationId,
index b1fc1e8507a3d7135040e0c4d2a956c4dd538116..66a3ca9f49a9d449d8ef6f8b7aaa8cfda263f260 100755 (executable)
@@ -75,12 +75,12 @@ void HYDROGUI_PolylineOp::startOperation()
   myEditedObject = Handle(HYDROData_Polyline)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) );
   if( !myEditedObject.IsNull() )
   {
-    int anIntDim = myEditedObject->getDimension();
+    int anIntDim = myEditedObject->GetDimension();
     CurveCreator::Dimension aDim = CurveCreator::Dim3d;
     if( anIntDim == 2 )
       aDim = CurveCreator::Dim2d;
     myCurve = new CurveCreator_Curve(aDim);
-    QList<PolylineSection> aPolylineData = myEditedObject->getPolylineData();
+    QList<PolylineSection> aPolylineData = myEditedObject->GetPolylineData();
 
     CurveCreator_CurveEditor* anEdit = new CurveCreator_CurveEditor(myCurve);
     for( int i = 0 ; i < aPolylineData.size() ; i++ ){
@@ -165,7 +165,7 @@ bool HYDROGUI_PolylineOp::processApply( int& theUpdateFlags,
   int aDimInt = 3;
   if( myCurve->getDimension() == CurveCreator::Dim2d )
     aDimInt = 2;
-  aPolylineObj->setDimension(aDimInt);
+  aPolylineObj->SetDimension(aDimInt);
   QList<PolylineSection> aPolylineData;
   for( int i=0 ; i < myCurve->getNbSections() ; i++ ){
     PolylineSection aSect;
@@ -181,7 +181,7 @@ bool HYDROGUI_PolylineOp::processApply( int& theUpdateFlags,
     }
     aPolylineData << aSect;
   }
-  aPolylineObj->setPolylineData(aPolylineData);
+  aPolylineObj->SetPolylineData(aPolylineData);
 
   theUpdateFlags = UF_Model;
   module()->setObjectVisible( HYDROGUI_Tool::GetActiveGraphicsViewId( module() ), aPolylineObj, true );
index 1ed451e396862313757ae2473dd21b5b6f8a558a..d2f43b784582c21c4dc6e63087ccf21ae94025e5 100644 (file)
@@ -30,7 +30,7 @@
 // name    : HYDROGUI_Prs
 // Purpose : Constructor
 //=======================================================================
-HYDROGUI_Prs::HYDROGUI_Prs( const Handle(HYDROData_Object)& theObject )
+HYDROGUI_Prs::HYDROGUI_Prs( const Handle(HYDROData_Entity)& theObject )
 : GraphicsView_Object(),
   myObject( theObject ),
   myIsToUpdate( false )
index 6219f48b14d2dc2c57b149c9f5f86ed796577e00..871e30faf7078dd570ec0808f16d47dc2c85336b 100644 (file)
@@ -23,7 +23,7 @@
 #ifndef HYDROGUI_PRS_H
 #define HYDROGUI_PRS_H
 
-#include <HYDROData_Object.h>
+#include <HYDROData_Entity.h>
 
 #include <GraphicsView_Object.h>
 
 class HYDROGUI_Prs : public GraphicsView_Object
 {
 public:
-  HYDROGUI_Prs( const Handle(HYDROData_Object)& theObject );
+  HYDROGUI_Prs( const Handle(HYDROData_Entity)& theObject );
   virtual ~HYDROGUI_Prs();
 
 public:
-  Handle(HYDROData_Object)        getObject() const { return myObject; }
+  Handle(HYDROData_Entity)        getObject() const { return myObject; }
 
   bool                            getIsToUpdate() const { return myIsToUpdate; }
   void                            setIsToUpdate( bool theState ) { myIsToUpdate = theState; }
@@ -51,7 +51,7 @@ protected:
   QCursor*                        getHighlightCursor() const { return myHighlightCursor; }
 
 private:
-  Handle(HYDROData_Object)        myObject;
+  Handle(HYDROData_Entity)        myObject;
   bool                            myIsToUpdate;
 
 private:
index 4e13c1c5b8549d197fcda4e9ff67b8b0202600f1..38d8908d78987ce4b8661b63be7866a9f76fd99e 100644 (file)
@@ -32,7 +32,7 @@ HYDROGUI_PrsDriver::~HYDROGUI_PrsDriver()
 {
 }
 
-bool HYDROGUI_PrsDriver::Update( const Handle(HYDROData_Object)& theObj,
+bool HYDROGUI_PrsDriver::Update( const Handle(HYDROData_Entity)& theObj,
                                  HYDROGUI_Prs*& thePrs )
 {
   if ( thePrs )
index f73c00819180507a885f0ddbb88667f2fba68948..5356e464d492b85b1d4ba9f22dec34609782aca8 100644 (file)
@@ -23,7 +23,7 @@
 #ifndef HYDROGUI_PRSDRIVER_H
 #define HYDROGUI_PRSDRIVER_H
 
-#include <HYDROData_Object.h>
+#include <HYDROData_Entity.h>
 
 class HYDROGUI_Prs;
 
@@ -53,7 +53,7 @@ public:
    * \param thePrs presentation
    * \return status of the operation
    */
-  virtual bool Update( const Handle(HYDROData_Object)& theObj,
+  virtual bool Update( const Handle(HYDROData_Entity)& theObj,
                        HYDROGUI_Prs*& thePrs );
 };
 
index 4a4ee5bb37fd997fa0685b80e10ff857ca6f8cf6..9e7be1425bceb3b3ad0d459d8e889020f2e24f0a 100644 (file)
@@ -32,7 +32,7 @@
 // name    : HYDROGUI_PrsImage
 // Purpose : Constructor
 //=======================================================================
-HYDROGUI_PrsImage::HYDROGUI_PrsImage( const Handle(HYDROData_Object)& theObject )
+HYDROGUI_PrsImage::HYDROGUI_PrsImage( const Handle(HYDROData_Entity)& theObject )
 : HYDROGUI_Prs( theObject ),
   myPixmapItem( 0 ),
   myCaptionItem( 0 ),
index c59218ff40401b430137f14eb7f2cd58b721771f..c5d57981ad8c57084b82adb4f98e829d99d06b15 100644 (file)
@@ -46,7 +46,7 @@ public:
   typedef QMapIterator< int, TransformationPoint > TransformationPointMapIterator;
 
 public:
-  HYDROGUI_PrsImage( const Handle(HYDROData_Object)& theObject );
+  HYDROGUI_PrsImage( const Handle(HYDROData_Entity)& theObject );
   virtual ~HYDROGUI_PrsImage();
 
 public:
index cac25c915f425ead2327f4a166de987eb1b3e91c..ace705505ddd18bc5db17dc4cb2cfbe91e1f30e8 100644 (file)
@@ -35,7 +35,7 @@ HYDROGUI_PrsImageDriver::~HYDROGUI_PrsImageDriver()
 {
 }
 
-bool HYDROGUI_PrsImageDriver::Update( const Handle(HYDROData_Object)& theObj,
+bool HYDROGUI_PrsImageDriver::Update( const Handle(HYDROData_Entity)& theObj,
                                       HYDROGUI_Prs*& thePrs )
 {
   HYDROGUI_PrsDriver::Update( theObj, thePrs );
index 5da63d5baa3ab2cb950f11e65757be88da209a47..4b369ed2be5cc7da1a6cecc1be9a583a8acdcfca 100644 (file)
@@ -49,7 +49,7 @@ public:
    * \param thePrs presentation
    * \return status of the operation
    */
-  virtual bool Update( const Handle(HYDROData_Object)& theObj,
+  virtual bool Update( const Handle(HYDROData_Entity)& theObj,
                        HYDROGUI_Prs*& thePrs );
 };
 
index 57748202ae32bb03eafeeb6732dadf2ad08078c5..19fa5330f56d7f8a94704171ba0784ba0a9215af 100644 (file)
@@ -28,7 +28,7 @@
 // name    : HYDROGUI_PrsPolyline
 // Purpose : Constructor
 //=======================================================================
-HYDROGUI_PrsPolyline::HYDROGUI_PrsPolyline( const Handle(HYDROData_Object)& theObject )
+HYDROGUI_PrsPolyline::HYDROGUI_PrsPolyline( const Handle(HYDROData_Entity)& theObject )
 : HYDROGUI_Prs( theObject ),
   myPolylineItem( 0 )
 {
index 47dc3b23789a87d5ac657f8128adde63c91a847c..a01359ec317bcad51ce1ddd630886005aa170ba9 100644 (file)
@@ -32,7 +32,7 @@
 class HYDROGUI_PrsPolyline : public HYDROGUI_Prs
 {
 public:
-  HYDROGUI_PrsPolyline( const Handle(HYDROData_Object)& theObject );
+  HYDROGUI_PrsPolyline( const Handle(HYDROData_Entity)& theObject );
   virtual ~HYDROGUI_PrsPolyline();
 
 public:
index 54a75540eb9eee6d2205f6843e4faf85ceb29c46..5bb2ba290b1b0f799da5cd2b7e1cf2409b64958d 100644 (file)
@@ -35,7 +35,7 @@ HYDROGUI_PrsPolylineDriver::~HYDROGUI_PrsPolylineDriver()
 {
 }
 
-bool HYDROGUI_PrsPolylineDriver::Update( const Handle(HYDROData_Object)& theObj,
+bool HYDROGUI_PrsPolylineDriver::Update( const Handle(HYDROData_Entity)& theObj,
                                          HYDROGUI_Prs*& thePrs )
 {
   HYDROGUI_PrsDriver::Update( theObj, thePrs );
@@ -53,7 +53,7 @@ bool HYDROGUI_PrsPolylineDriver::Update( const Handle(HYDROData_Object)& theObj,
   HYDROGUI_PrsPolyline* aPrsPolyline = (HYDROGUI_PrsPolyline*)thePrs;
 
   aPrsPolyline->setName( aPolyline->GetName() );
-  aPrsPolyline->setPath( aPolyline->painterPath() );
+  aPrsPolyline->setPath( aPolyline->GetPainterPath() );
 
   aPrsPolyline->compute();
 
index de6dde194d6037c05a3aec6f2a5beea4919e0026..9160ff5c7ebe090b19d0ecb83b078c512a66554f 100644 (file)
@@ -49,7 +49,7 @@ public:
    * \param thePrs presentation
    * \return status of the operation
    */
-  virtual bool Update( const Handle(HYDROData_Object)& theObj,
+  virtual bool Update( const Handle(HYDROData_Entity)& theObj,
                        HYDROGUI_Prs*& thePrs );
 };
 
index fc85724517b3184947a7a62fb0d7a84e0fa2e52f..61661a7389f7eacb30395485eb26e4b57b351525 100644 (file)
@@ -29,7 +29,7 @@
 // name    : HYDROGUI_PrsZone
 // Purpose : Constructor
 //=======================================================================
-HYDROGUI_PrsZone::HYDROGUI_PrsZone( const Handle(HYDROData_Object)& theObject )
+HYDROGUI_PrsZone::HYDROGUI_PrsZone( const Handle(HYDROData_Entity)& theObject )
 : HYDROGUI_Prs( theObject ),
   myZoneItem( 0 ),
   myFillingColor( Qt::transparent ),
index 3c21dc39aa88a1e820a890da9222ca3af53bb7eb..586eb6f39e1510882e6749d985932e817d7cc058 100644 (file)
@@ -32,7 +32,7 @@
 class HYDROGUI_PrsZone : public HYDROGUI_Prs
 {
 public:
-  HYDROGUI_PrsZone( const Handle(HYDROData_Object)& theObject );
+  HYDROGUI_PrsZone( const Handle(HYDROData_Entity)& theObject );
   virtual ~HYDROGUI_PrsZone();
 
 public:
index 6d6aca2e52f0d9b370cb5e0ace122adc47363b0d..ef2e4e2659aad65f5b8df994600f4faf8217ca36 100644 (file)
@@ -24,7 +24,7 @@
 
 #include "HYDROGUI_PrsZone.h"
 
-#include <HYDROData_Zone.h>
+#include <HYDROData_ImmersibleZone.h>
 
 HYDROGUI_PrsZoneDriver::HYDROGUI_PrsZoneDriver()
 :HYDROGUI_PrsDriver()
@@ -35,7 +35,7 @@ HYDROGUI_PrsZoneDriver::~HYDROGUI_PrsZoneDriver()
 {
 }
 
-bool HYDROGUI_PrsZoneDriver::Update( const Handle(HYDROData_Object)& theObj,
+bool HYDROGUI_PrsZoneDriver::Update( const Handle(HYDROData_Entity)& theObj,
                                      HYDROGUI_Prs*& thePrs )
 {
   HYDROGUI_PrsDriver::Update( theObj, thePrs );
@@ -43,7 +43,8 @@ bool HYDROGUI_PrsZoneDriver::Update( const Handle(HYDROData_Object)& theObj,
   if ( theObj.IsNull() )
     return false;
 
-  Handle(HYDROData_Zone) aZone = Handle(HYDROData_Zone)::DownCast( theObj );
+  Handle(HYDROData_ImmersibleZone) aZone = 
+    Handle(HYDROData_ImmersibleZone)::DownCast( theObj );
   if ( aZone.IsNull() )
     return false;
 
index 0eb5dbc31ba73a6d5bf8e0162fb98b58836bfee5..ef4b559ee3fceeb7c09f9b9451ab06f961f16630 100644 (file)
@@ -49,7 +49,7 @@ public:
    * \param thePrs presentation
    * \return status of the operation
    */
-  virtual bool Update( const Handle(HYDROData_Object)& theObj,
+  virtual bool Update( const Handle(HYDROData_Entity)& theObj,
                        HYDROGUI_Prs*& thePrs );
 };
 
index 9d7ca4da573d55b4bf232d9a0a3162a404dff001..4eaecc5163153195a3025225e1ae463682acbad9 100644 (file)
 #include <Graphic3d_AspectFillArea3d.hxx>
 #include <Graphic3d_MaterialAspect.hxx>
 
-#include <HYDROData_Domain.h>
+#include <HYDROData_Document.h>
 #include <HYDROData_Image.h>
+#include <HYDROData_ImmersibleZone.h>
 #include <HYDROData_Polyline.h>
+#include <HYDROData_Region.h>
+#include <HYDROData_Zone.h>
 
+#include <TopoDS.hxx>
 #include <TopoDS_Wire.hxx>
 #include <TopoDS_Face.hxx>
 
@@ -53,7 +57,7 @@
 #include <QFile>
 
 HYDROGUI_Shape::HYDROGUI_Shape( const Handle(AIS_InteractiveContext)& theContext,
-                                const Handle(HYDROData_Object)&       theObject )
+                                const Handle(HYDROData_Entity)&       theObject )
 : myContext( theContext ),
   myObject( theObject ),
   myIsHighlight( false ),
@@ -102,28 +106,64 @@ void HYDROGUI_Shape::update( const bool theIsUpdateViewer )
   // Try to retrieve information from object
   if ( !myObject.IsNull() )
   {
-    if ( myObject->IsKind( STANDARD_TYPE(HYDROData_Domain) ) )
+    Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myObject );
+  
+    if ( myObject->IsKind( STANDARD_TYPE(HYDROData_ImmersibleZone) ) )
     {
-      Handle(HYDROData_Domain) aDomainObj =
-        Handle(HYDROData_Domain)::DownCast( myObject );
+      Handle(HYDROData_ImmersibleZone) aZoneObj =
+        Handle(HYDROData_ImmersibleZone)::DownCast( myObject );
 
-      QColor aFillingColor = aDomainObj->GetFillingColor();
-      QColor aBorderColor = aDomainObj->GetBorderColor();
-      TopoDS_Face aDomainFace = aDomainObj->Face();
+      QColor aFillingColor = aZoneObj->GetFillingColor();
+      QColor aBorderColor = aZoneObj->GetBorderColor();
+      TopoDS_Face aZoneFace = TopoDS::Face( aZoneObj->GetTopShape() );
 
       setFillingColor( aFillingColor, false, false );
       setBorderColor( aBorderColor, false, false );
-      setFace( aDomainFace, false, false );
+      setFace( aZoneFace, false, false );
     }
     else if ( myObject->IsKind( STANDARD_TYPE(HYDROData_Polyline) ) )
     {
       Handle(HYDROData_Polyline) aPolyline =
         Handle(HYDROData_Polyline)::DownCast( myObject );
 
-      TopoDS_Wire aPolylineWire = aPolyline->Wire();
+      TopoDS_Wire aPolylineWire = TopoDS::Wire( aPolyline->GetTopShape() );
 
       setWire( aPolylineWire, false, false );
     }
+    else if ( myObject->IsKind( STANDARD_TYPE(HYDROData_Region) ) )
+    {
+      Handle(HYDROData_Region) aRegion =
+        Handle(HYDROData_Region)::DownCast( myObject );
+    }
+    else if ( myObject->IsKind( STANDARD_TYPE(HYDROData_Zone) ) )
+    {
+      Handle(HYDROData_Zone) aZone =
+        Handle(HYDROData_Zone)::DownCast( myObject );
+
+      TopoDS_Face aZoneFace = TopoDS::Face( aZone->GetShape() );
+
+      // Generate the filling color for zone
+      QStringList aGeomObjectsNames;
+
+      HYDROData_SequenceOfObjects aRefObjects = aZone->GetGeometryObjects();
+      HYDROData_SequenceOfObjects::Iterator anIter( aRefObjects );
+      for ( ; anIter.More(); anIter.Next() )
+      {
+        Handle(HYDROData_Object) aRefbject = 
+          Handle(HYDROData_Object)::DownCast( anIter.Value() );
+        if ( aRefbject.IsNull() )
+          continue;
+
+        QString aRefObjectName = aRefbject->GetName();
+        if ( aRefObjectName.isEmpty() )
+          continue;
+
+        aGeomObjectsNames.append( aRefObjectName );
+      }
+       
+      setFace( aZoneFace, false, false );
+      setFillingColor( HYDROGUI_Tool::GenerateFillingColor( aDocument, aGeomObjectsNames ) );
+    }
     else if ( myObject->IsKind( STANDARD_TYPE(HYDROData_Image) ) )
     {
       Handle(HYDROData_Image) anImageObj =
@@ -441,7 +481,7 @@ void HYDROGUI_Shape::colorShapeBorder( const QColor& theColor )
   }
 }
 
-QString HYDROGUI_Shape::generateTextureFileName( const Handle(HYDROData_Object)& theImageObj )
+QString HYDROGUI_Shape::generateTextureFileName( const Handle(HYDROData_Entity)& theImageObj )
 {
   QString aResult;
   if( !theImageObj.IsNull() )
index 6757079efce6467b2722cedd1b44d24ffb7273ef..007c3e52d20cecdbae30b027f805739d99686b51 100644 (file)
@@ -26,7 +26,7 @@
 #include <AIS_InteractiveContext.hxx>
 #include <AIS_TexturedShape.hxx>
 
-#include <HYDROData_Object.h>
+#include <HYDROData_Entity.h>
 
 #include <QColor>
 #include <QImage>
@@ -38,7 +38,7 @@ class HYDROGUI_Shape
 {
 public:
   HYDROGUI_Shape( const Handle(AIS_InteractiveContext)& theContext,
-                  const Handle(HYDROData_Object)&       theObject );
+                  const Handle(HYDROData_Entity)&       theObject );
   ~HYDROGUI_Shape();
 
 public:
@@ -48,7 +48,7 @@ public:
   virtual void               highlight( bool theIsHighlight );
   virtual bool               isHighlighted() const;
 
-  Handle(HYDROData_Object)   getObject() const { return myObject; }
+  Handle(HYDROData_Entity)   getObject() const { return myObject; }
 
   virtual void               update( const bool theIsUpdateViewer = true );
 
@@ -99,14 +99,14 @@ private:
   static double              getQuantityColorVal( const int theColorVal );
   void                       colorShapeBorder( const QColor& theColor );
 
-  static QString             generateTextureFileName( const Handle(HYDROData_Object)& theImageObj );
+  static QString             generateTextureFileName( const Handle(HYDROData_Entity)& theImageObj );
   void                       removeTextureFile() const;
 
   static QImage              reduceTexture( const QImage& theImage, const int theSizeLimit );
 
 private:
   Handle(AIS_InteractiveContext) myContext;
-  Handle(HYDROData_Object)       myObject;
+  Handle(HYDROData_Entity)       myObject;
   Handle(AIS_TexturedShape)      myShape;
 
   bool                           myIsToUpdate;
index 064d7785d9cc12862a6953d49286650be30720cb..0fefdfae2fc3ba43046a7cf061cb8b22f856eb7b 100644 (file)
@@ -30,7 +30,7 @@
 #include "HYDROGUI_UpdateFlags.h"
 
 #include <HYDROData_Iterator.h>
-#include <HYDROData_Object.h>
+#include <HYDROData_Entity.h>
 
 #include <LightApp_Application.h>
 
@@ -72,7 +72,7 @@ void HYDROGUI_ShowHideOp::startOperation()
     HYDROData_Iterator anIterator( doc() );
     for( ; anIterator.More(); anIterator.Next() )
     {
-      Handle(HYDROData_Object) anObject = anIterator.Current();
+      Handle(HYDROData_Entity) anObject = anIterator.Current();
       if( !anObject.IsNull() )
         module()->setObjectVisible( aViewId, anObject, aVisibility );
     }
@@ -86,7 +86,7 @@ void HYDROGUI_ShowHideOp::startOperation()
     bool aVisibility = myId == ShowId || myId == ShowOnlyId;
     for( Standard_Integer anIndex = 1, aLength = aSeq.Length(); anIndex <= aLength; anIndex++ )
     {
-      Handle(HYDROData_Object) anObject = aSeq.Value( anIndex );
+      Handle(HYDROData_Entity) anObject = aSeq.Value( anIndex );
       if( !anObject.IsNull() )
         module()->setObjectVisible( aViewId, anObject, aVisibility );
     }
diff --git a/src/HYDROGUI/HYDROGUI_SplitZonesTool.cxx b/src/HYDROGUI/HYDROGUI_SplitZonesTool.cxx
deleted file mode 100644 (file)
index 1a20f39..0000000
+++ /dev/null
@@ -1,190 +0,0 @@
-// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-#include "HYDROGUI_SplitZonesTool.h"
-
-#include <HYDROData_Polyline.h>
-#include <HYDROData_Zone.h>
-
-#include <BRepAlgoAPI_Common.hxx>
-#include <BRepAlgoAPI_Cut.hxx>
-#include <BRepBuilderAPI_MakeFace.hxx>
-#include <TopExp_Explorer.hxx>
-#include <TopoDS.hxx>
-#include <TopoDS_Iterator.hxx>
-#include <TopoDS_Wire.hxx>
-
-TopoDS_Face HYDROGUI_SplitZonesTool::SplitData::Face() const
-{
-  if( !Shape.IsNull() && Shape.ShapeType() == TopAbs_FACE )
-    return TopoDS::Face( Shape );
-  return TopoDS_Face();
-}
-
-HYDROGUI_SplitZonesTool::SplitDataList
-HYDROGUI_SplitZonesTool::SplitZones( const HYDROData_SequenceOfObjects& theZoneList,
-                                     const Handle(HYDROData_Polyline)& thePolyline )
-{
-  SplitDataList anOutputSplitDataList;
-
-  // Preparation. Collect the zone paths to split.
-  SplitDataList anInputSplitDataList;
-  for( int anIndex = 1, aLength = theZoneList.Length(); anIndex <= aLength; anIndex++ )
-  {
-    Handle(HYDROData_Zone) aZone = Handle(HYDROData_Zone)::DownCast( theZoneList.Value( anIndex ) );
-    if( !aZone.IsNull() )
-    {
-      SplitData aSplitData( aZone->Face(), aZone->GetName() );
-      anInputSplitDataList.append( aSplitData );
-    }
-  }
-
-  // Step 1. Split the paths.
-  SplitDataListIterator anInputIter( anInputSplitDataList );
-  while( anInputIter.hasNext() )
-  {
-    const SplitData& anInputSplitData = anInputIter.next();
-    if( anOutputSplitDataList.isEmpty() )
-      anOutputSplitDataList.append( anInputSplitData );
-    else
-    {
-      SplitDataList aSplitDataList;
-
-      SplitDataList aSrcSplitDataList;
-      aSrcSplitDataList.append( anInputSplitData );
-
-      SplitDataList aDestSplitDataList = anOutputSplitDataList;
-      anOutputSplitDataList.clear();
-
-      while( !aDestSplitDataList.isEmpty() )
-      {
-        SplitData aSrcSplitData = aSrcSplitDataList.last();
-
-        SplitData aDestSplitData = aDestSplitDataList.first();
-        aDestSplitDataList.pop_front();
-
-        SplitData aData1Subtracted, aData2Subtracted, aDataIntersected;
-        if( SplitTwoData( aSrcSplitData, aDestSplitData,
-                          aData1Subtracted, aData2Subtracted, aDataIntersected ) )
-          anOutputSplitDataList.append( aDataIntersected );
-        anOutputSplitDataList.append( aData2Subtracted );
-        aSrcSplitDataList.append( aData1Subtracted );
-      }
-
-      if( !aSrcSplitDataList.isEmpty() )
-        anOutputSplitDataList.append( aSrcSplitDataList.last() );
-    }
-  }
-
-  // Step 2. Take into account the boundary polyline.
-  if( !thePolyline.IsNull() )
-  {
-    const TopoDS_Wire& aWire = thePolyline->Wire();
-    if( !aWire.IsNull() )
-    {
-      BRepBuilderAPI_MakeFace aMakeFace( aWire, Standard_True );
-      aMakeFace.Build();
-      if( aMakeFace.IsDone() )
-      {
-        SplitData aBoundarySplitData( aMakeFace.Face(), "" );
-
-        SplitDataList aCutSplitDataList;
-        SplitDataListIterator anOutputIter( anOutputSplitDataList );
-        while( anOutputIter.hasNext() )
-        {
-          const SplitData& anOutputSplitData = anOutputIter.next();
-
-          SplitData aData1Subtracted, aData2Subtracted, aDataIntersected;
-          if( SplitTwoData( anOutputSplitData, aBoundarySplitData,
-                            aData1Subtracted, aData2Subtracted, aDataIntersected ) )
-            aCutSplitDataList.append( aDataIntersected );
-        }
-        anOutputSplitDataList = aCutSplitDataList;
-      }
-    }
-  }
-
-  // Step 3. Extract the separate regions.
-  SplitDataList anExtractedSplitDataList;
-  SplitDataListIterator anOutputIter( anOutputSplitDataList );
-  while( anOutputIter.hasNext() )
-  {
-    const SplitData& anOutputSplitData = anOutputIter.next();
-    anExtractedSplitDataList.append( ExtractSeparateData( anOutputSplitData ) );
-  }
-  return anExtractedSplitDataList;
-}
-
-bool HYDROGUI_SplitZonesTool::SplitTwoData( const SplitData& theData1,
-                                            const SplitData& theData2,
-                                            SplitData& theData1Subtracted,
-                                            SplitData& theData2Subtracted,
-                                            SplitData& theDataIntersected )
-{
-  const TopoDS_Shape& aShape1 = theData1.Shape;
-  const TopoDS_Shape& aShape2 = theData2.Shape;
-
-  const QStringList& aZoneNames1 = theData1.ZoneNames;
-  const QStringList& aZoneNames2 = theData2.ZoneNames;
-
-  BRepAlgoAPI_Common aCommon( aShape1, aShape2 );
-  TopoDS_Shape aCommonShape = aCommon.Shape();
-  if( aCommonShape.IsNull() )
-  {
-    theData1Subtracted = theData1;
-    theData2Subtracted = theData2;
-    return false;
-  }
-
-  BRepAlgoAPI_Cut aCut1( aShape1, aShape2 );
-  TopoDS_Shape aCut1Shape = aCut1.Shape();
-
-  BRepAlgoAPI_Cut aCut2( aShape2, aShape1 );
-  TopoDS_Shape aCut2Shape = aCut2.Shape();
-
-  theData1Subtracted = SplitData( aCut1Shape, aZoneNames1 );
-  theData2Subtracted = SplitData( aCut2Shape, aZoneNames2 );
-  theDataIntersected = SplitData( aCommonShape, aZoneNames1 + aZoneNames2 );
-
-  return true;
-}
-
-HYDROGUI_SplitZonesTool::SplitDataList
-HYDROGUI_SplitZonesTool::ExtractSeparateData( const SplitData& theData )
-{
-  SplitDataList aSplitDataList;
-  TopExp_Explorer anExp( theData.Shape, TopAbs_FACE );
-  for( ; anExp.More(); anExp.Next() )
-  {
-    TopoDS_Shape aShape = anExp.Current();
-    if( aShape.ShapeType() == TopAbs_FACE )
-    {
-      TopoDS_Face aFace = TopoDS::Face( aShape );
-      if( !aFace.IsNull() )
-      {
-        SplitData aSplitData( aFace, theData.ZoneNames );
-        aSplitDataList.append( aSplitData );
-      }
-    }
-  }
-  return aSplitDataList;
-}
diff --git a/src/HYDROGUI/HYDROGUI_SplitZonesTool.h b/src/HYDROGUI/HYDROGUI_SplitZonesTool.h
deleted file mode 100644 (file)
index ca74d3c..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-#ifndef HYDROGUI_SPLITZONESTOOL_H
-#define HYDROGUI_SPLITZONESTOOL_H
-
-#include <HYDROData_Object.h>
-
-#include <TopoDS_Face.hxx>
-
-#include <QStringList>
-
-class Handle(HYDROData_Polyline);
-
-/**
- * \class HYDROGUI_SplitZonesTool
- * \brief This class contains methods used for splitting zones
- *        into non-intersected regions.
- */
-class HYDROGUI_SplitZonesTool
-{
-public:
-  struct SplitData
-  {
-    TopoDS_Shape Shape;
-    QStringList  ZoneNames;
-
-    SplitData() {}
-    
-    SplitData( const TopoDS_Shape& theShape,
-               const QStringList& theZoneNames ) :
-      Shape( theShape ), ZoneNames( theZoneNames ) {}
-
-    SplitData( const TopoDS_Shape& theShape,
-               const QString& theZoneName ) :
-      Shape( theShape ), ZoneNames( theZoneName ) {}
-
-    TopoDS_Face Face() const;
-  };
-
-  typedef QList        <SplitData> SplitDataList;
-  typedef QListIterator<SplitData> SplitDataListIterator;
-
-public:
-  static SplitDataList       SplitZones( const HYDROData_SequenceOfObjects& theZoneList,
-                                         const Handle(HYDROData_Polyline)& thePolyline );
-
-private:
-  static bool                SplitTwoData( const SplitData& theData1,
-                                           const SplitData& theData2,
-                                           SplitData& theData1Subtracted,
-                                           SplitData& theData2Subtracted,
-                                           SplitData& theDataIntersected );
-
-  static SplitDataList       ExtractSeparateData( const SplitData& theData );
-};
-
-#endif
index 67abb1566df46c6dc27fb5e626be8b773ac87073..6fa0a831763a9d609337a80d3af710112010d522 100644 (file)
@@ -29,7 +29,8 @@
 
 #include <HYDROData_Document.h>
 #include <HYDROData_Iterator.h>
-#include <HYDROData_Zone.h>
+#include <HYDROData_ImmersibleZone.h>
+#include <HYDROData_Tool.h>
 
 #include <GraphicsView_Viewer.h>
 
@@ -185,14 +186,6 @@ QString HYDROGUI_Tool::GetTempDir( const bool theToCreate )
   return aRes;
 }
 
-bool HYDROGUI_Tool::IsEqual( const Handle(HYDROData_Object)& theObj1,
-                             const Handle(HYDROData_Object)& theObj2 )
-{
-  if( !theObj1.IsNull() && !theObj2.IsNull() )
-    return theObj1->Label() == theObj2->Label(); //ouv: check that the names can be used here
-  return false;
-}
-
 void HYDROGUI_Tool::SetActiveViewManager( HYDROGUI_Module* theModule,
                                           SUIT_ViewManager* theViewManager )
 {
@@ -213,7 +206,7 @@ void HYDROGUI_Tool::GetPrsSubObjects( HYDROGUI_Module* theModule,
   HYDROData_Iterator anIterator( aDocument, KIND_IMAGE );
   for( ; anIterator.More(); anIterator.Next() )
   {
-    Handle(HYDROData_Object) anObject = anIterator.Current();
+    Handle(HYDROData_Entity) anObject = anIterator.Current();
     if( !anObject.IsNull() )
       theSeq.Append( anObject );
   }
@@ -221,21 +214,21 @@ void HYDROGUI_Tool::GetPrsSubObjects( HYDROGUI_Module* theModule,
   anIterator = HYDROData_Iterator( aDocument, KIND_POLYLINE );
   for( ; anIterator.More(); anIterator.Next() )
   {
-    Handle(HYDROData_Object) anObject = anIterator.Current();
+    Handle(HYDROData_Entity) anObject = anIterator.Current();
     if( !anObject.IsNull() )
       theSeq.Append( anObject );
   }
 
-  anIterator = HYDROData_Iterator( aDocument, KIND_ZONE );
+  anIterator = HYDROData_Iterator( aDocument, KIND_IMMERSIBLE_ZONE );
   for( ; anIterator.More(); anIterator.Next() )
   {
-    Handle(HYDROData_Object) anObject = anIterator.Current();
+    Handle(HYDROData_Entity) anObject = anIterator.Current();
     if( !anObject.IsNull() )
       theSeq.Append( anObject );
   }
 }
 
-HYDROGUI_Prs* HYDROGUI_Tool::GetPresentation( const Handle(HYDROData_Object)& theObj,
+HYDROGUI_Prs* HYDROGUI_Tool::GetPresentation( const Handle(HYDROData_Entity)& theObj,
                                               const GraphicsView_ObjectList& theObjects )
 {
   if( !theObj.IsNull() )
@@ -245,7 +238,7 @@ HYDROGUI_Prs* HYDROGUI_Tool::GetPresentation( const Handle(HYDROData_Object)& th
     {
       if( HYDROGUI_Prs* aPrs = dynamic_cast<HYDROGUI_Prs*>( anIter.next() ) )
       {
-        Handle(HYDROData_Object) anObj = aPrs->getObject();
+        Handle(HYDROData_Entity) anObj = aPrs->getObject();
         if( IsEqual( anObj, theObj ) )
           return aPrs;
       }
@@ -282,7 +275,7 @@ HYDROData_SequenceOfObjects HYDROGUI_Tool::GetSelectedObjects( HYDROGUI_Module*
   {
     if( LightApp_DataOwner* anOwner = dynamic_cast<LightApp_DataOwner*>( aSUITOwner ) )
     {
-      Handle(HYDROData_Object) anObject = aModel->objectByEntry( anOwner->entry() );
+      Handle(HYDROData_Entity) anObject = aModel->objectByEntry( anOwner->entry() );
       if( !anObject.IsNull() )
       {
         QString aName = anObject->GetName();
@@ -297,7 +290,7 @@ HYDROData_SequenceOfObjects HYDROGUI_Tool::GetSelectedObjects( HYDROGUI_Module*
   return aSeq;
 }
 
-Handle(HYDROData_Object) HYDROGUI_Tool::GetSelectedObject( HYDROGUI_Module* theModule )
+Handle(HYDROData_Entity) HYDROGUI_Tool::GetSelectedObject( HYDROGUI_Module* theModule )
 {
   HYDROData_SequenceOfObjects aSeq = GetSelectedObjects( theModule );
   if( !aSeq.IsEmpty() )
@@ -331,79 +324,28 @@ ObjectKind HYDROGUI_Tool::GetSelectedPartition( HYDROGUI_Module* theModule )
   return KIND_UNKNOWN;
 }
 
-Handle(HYDROData_Object) HYDROGUI_Tool::FindObjectByName( HYDROGUI_Module* theModule,
+Handle(HYDROData_Entity) HYDROGUI_Tool::FindObjectByName( HYDROGUI_Module* theModule,
                                                           const QString&   theName,
                                                           const ObjectKind theObjectKind )
 {
-  Handle(HYDROData_Object) anObject;
-  if ( theName.isEmpty() )
-    return anObject;
-
-  QStringList aNamesList;
-  aNamesList << theName;
-
-  HYDROData_SequenceOfObjects aSeqOfObjs = FindObjectsByNames( theModule, aNamesList, theObjectKind );
-  if( aSeqOfObjs.IsEmpty() )
-    return anObject;
-  
-  anObject = aSeqOfObjs.First();
-  return anObject;
+  Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( theModule->getStudyId() );
+  return HYDROData_Tool::FindObjectByName( aDocument, theName, theObjectKind );
 }
 
 HYDROData_SequenceOfObjects HYDROGUI_Tool::FindObjectsByNames( HYDROGUI_Module*   theModule,
                                                                const QStringList& theNames,
                                                                const ObjectKind   theObjectKind )
 {
-  HYDROData_SequenceOfObjects aResSeq;
-  if ( theNames.isEmpty() )
-    return aResSeq;
-
   Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( theModule->getStudyId() );
-  if( aDocument.IsNull() )
-    return aResSeq;
-
-  QStringList aNamesList = theNames;
-
-  HYDROData_Iterator anIter( aDocument, theObjectKind );
-  for( ; anIter.More(); anIter.Next() )
-  {
-    Handle(HYDROData_Object) anObjectRef = anIter.Current();
-    if( anObjectRef.IsNull() )
-      continue;
-
-    QString anObjName = anObjectRef->GetName();
-    if ( anObjName.isEmpty() || !aNamesList.contains( anObjName ) )
-      continue;
-
-    aResSeq.Append( anObjectRef );
-
-    aNamesList.removeAll( anObjName );
-    if ( aNamesList.isEmpty() )
-      break;
-  }
-
-  return aResSeq;
+  return HYDROData_Tool::FindObjectsByNames( aDocument, theNames, theObjectKind );
 }
 
 QString HYDROGUI_Tool::GenerateObjectName( HYDROGUI_Module*   theModule,
                                            const QString&     thePrefix,
                                            const QStringList& theUsedNames )
 {
-  QString aName;
-  int anId = 1;
-  while( anId < 100 )
-  {
-    aName = QString( "%1_%2" ).arg( thePrefix ).arg( QString::number( anId++ ) );
-
-    if ( theUsedNames.contains( aName ) )
-      continue;
-
-    // check that there are no other objects with the same name in the document
-    Handle(HYDROData_Object) anObject = FindObjectByName( theModule, aName, KIND_UNKNOWN );
-    if( anObject.IsNull() )
-      break;
-  }
-  return aName;
+  Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( theModule->getStudyId() );
+  return HYDROData_Tool::GenerateObjectName( aDocument, thePrefix, theUsedNames );
 }
 
 size_t HYDROGUI_Tool::GetActiveViewId( HYDROGUI_Module* theModule,
@@ -466,7 +408,7 @@ void HYDROGUI_Tool::GetObjectReferences( const Handle(HYDROData_Image)& theImage
 
   for( int anIndex = 0, aNbRef = theImage->NbReferences(); anIndex < aNbRef; anIndex++ )
   {
-    Handle(HYDROData_Object) aRefObj = theImage->Reference( anIndex );
+    Handle(HYDROData_Entity) aRefObj = theImage->Reference( anIndex );
     if( !aRefObj.IsNull() && !aRefObj->IsRemoved() )
     {
       QString aName = aRefObj->GetName();
@@ -486,7 +428,7 @@ void HYDROGUI_Tool::GetObjectReferences( const Handle(HYDROData_Image)& theImage
 }
 
 void HYDROGUI_Tool::GetObjectBackReferences( HYDROGUI_Module* theModule,
-                                             const Handle(HYDROData_Object)& theObj,
+                                             const Handle(HYDROData_Entity)& theObj,
                                              HYDROData_SequenceOfObjects& theBackRefObjects,
                                              QStringList& theBackRefNames )
 {
@@ -536,7 +478,14 @@ QDockWidget* HYDROGUI_Tool::WindowDock( QWidget* wid )
 QColor HYDROGUI_Tool::GenerateFillingColor( HYDROGUI_Module*   theModule,
                                             const QStringList& theZoneNames )
 {
-  QColor aFillingColor( HYDROData_Zone::DefaultFillingColor() );
+  Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( theModule->getStudyId() );
+  return GenerateFillingColor( aDocument, theZoneNames );
+}
+
+QColor HYDROGUI_Tool::GenerateFillingColor( const Handle(HYDROData_Document)& theDoc,
+                                            const QStringList&                theZoneNames )
+{
+  QColor aFillingColor( HYDROData_ImmersibleZone::DefaultFillingColor() );
 
   int aCounter = 0;
   int aR = 0, aG = 0, aB = 0;
@@ -544,8 +493,9 @@ QColor HYDROGUI_Tool::GenerateFillingColor( HYDROGUI_Module*   theModule,
   while( aZoneNameIter.hasNext() )
   {
     const QString& aZoneName = aZoneNameIter.next();
-    Handle(HYDROData_Zone) aRefZone = Handle(HYDROData_Zone)::DownCast(
-      FindObjectByName( theModule, aZoneName, KIND_ZONE ) );
+    Handle(HYDROData_ImmersibleZone) aRefZone = 
+      Handle(HYDROData_ImmersibleZone)::DownCast(
+        HYDROData_Tool::FindObjectByName( theDoc, aZoneName, KIND_IMMERSIBLE_ZONE ) );
     if( !aRefZone.IsNull() )
     {
       QColor aRefColor = aRefZone->GetFillingColor();
index 869dd4d23f52afe1ff087675f6bb1f50ebe187b1..1874513a871a2a6302b32b4c9b9644e94e2786ce 100644 (file)
@@ -40,6 +40,7 @@ class HYDROGUI_Module;
 class HYDROGUI_Prs;
 
 class QDockWidget;
+class Handle(HYDROData_Document);
 
 /**
  * \class HYDROGUI_Tool
@@ -101,14 +102,6 @@ public:
    */
   static QString                  GetTempDir( const bool theToCreate );
 
-  /**
-   * \brief Check that the specified objects are equal.
-   * \param theObj1 first object
-   * \param theObj2 second object
-   */
-  static bool                     IsEqual( const Handle(HYDROData_Object)& theObj1,
-                                           const Handle(HYDROData_Object)& theObj2 );
-
   /**
    * \brief Set the specified view manager to be active on the desktop.
    * \param theModule module
@@ -131,7 +124,7 @@ public:
    * \param theObjects list of existing presentations
    * \return presentation
    */
-  static HYDROGUI_Prs*            GetPresentation( const Handle(HYDROData_Object)& theObj,
+  static HYDROGUI_Prs*            GetPresentation( const Handle(HYDROData_Entity)& theObj,
                                                    const GraphicsView_ObjectList& theObjects );
 
   /**
@@ -153,7 +146,7 @@ public:
    * \param theModule module
    * \return selected data object
    */
-  static Handle(HYDROData_Object) GetSelectedObject( HYDROGUI_Module* theModule );
+  static Handle(HYDROData_Entity) GetSelectedObject( HYDROGUI_Module* theModule );
 
   /**
    * \brief Get kind of objects the selected partition contains.
@@ -169,7 +162,7 @@ public:
    * \param theObjectKind kind of object
    * \return data object
    */
-  static Handle(HYDROData_Object) FindObjectByName( HYDROGUI_Module* theModule,
+  static Handle(HYDROData_Entity) FindObjectByName( HYDROGUI_Module* theModule,
                                                     const QString& theName,
                                                     const ObjectKind theObjectKind = KIND_UNKNOWN );
 
@@ -249,7 +242,7 @@ public:
    * \param theBackRefNames list of back-reference object names
    */
   static void                     GetObjectBackReferences( HYDROGUI_Module* theModule,
-                                                           const Handle(HYDROData_Object)& theObj,
+                                                           const Handle(HYDROData_Entity)& theObj,
                                                            HYDROData_SequenceOfObjects& theBackRefObjects,
                                                            QStringList& theBackRefNames );
 
@@ -269,6 +262,15 @@ public:
   static QColor                   GenerateFillingColor( HYDROGUI_Module*   theModule,
                                                         const QStringList& theZoneNames );
 
+  /*
+   * \brief Generates the filling color for intersected zone
+   * \param theDoc model document
+   * \param theZoneNames list of intersected zones
+   * \return result color
+   */
+  static QColor                   GenerateFillingColor( const Handle(HYDROData_Document)& theDoc,
+                                                        const QStringList&                theZoneNames );
+
 };
 
 #endif
index d946766c8e1b781d66f2e304ed05fac26e6279b5..38375491e69589af4e8b15b80029f11cfd1affd1 100644 (file)
@@ -31,7 +31,7 @@
 #include <HYDROData_Image.h>
 #include <HYDROData_Polyline.h>
 
-#include <HYDROOperations_Factory.h>
+#include <HYDROData_OperationsFactory.h>
 
 #include <ImageComposer_CutOperator.h>
 #include <ImageComposer_CropOperator.h>
@@ -103,19 +103,19 @@ void HYDROGUI_TwoImagesOp::startOperation()
   {
     if( myEditedObject->NbReferences() > 0 )
     {
-      Handle(HYDROData_Object) anObject1 = myEditedObject->Reference( 0 );
+      Handle(HYDROData_Entity) anObject1 = myEditedObject->Reference( 0 );
       if( !anObject1.IsNull() )
         aSelectedName1 = anObject1->GetName();
     }
     if( myEditedObject->NbReferences() > 1 )
     {
-      Handle(HYDROData_Object) anObject2 = myEditedObject->Reference( 1 );
+      Handle(HYDROData_Entity) anObject2 = myEditedObject->Reference( 1 );
       if( !anObject2.IsNull() )
         aSelectedName2 = anObject2->GetName();
     }
     aPanel->setSelectedObjects( aSelectedName1, aSelectedName2 );
 
-    HYDROOperations_Factory* aFactory = HYDROOperations_Factory::Factory();
+    HYDROData_OperationsFactory* aFactory = HYDROData_OperationsFactory::Factory();
     if( ImageComposer_Operator* anOperator = aFactory->Operator( myEditedObject ) )
     {
       QColor aColor;
@@ -154,7 +154,7 @@ bool HYDROGUI_TwoImagesOp::processApply( int& theUpdateFlags,
       ( !myIsEdit || ( !myEditedObject.IsNull() && myEditedObject->GetName() != anImageName ) ) )
   {
     // check that there are no other objects with the same name in the document
-    Handle(HYDROData_Object) anObject = HYDROGUI_Tool::FindObjectByName( module(), anImageName );
+    Handle(HYDROData_Entity) anObject = HYDROGUI_Tool::FindObjectByName( module(), anImageName );
     if( !anObject.IsNull() )
     {
       theErrorMsg = tr( "OBJECT_EXISTS_IN_DOCUMENT" ).arg( anImageName );
@@ -162,14 +162,14 @@ bool HYDROGUI_TwoImagesOp::processApply( int& theUpdateFlags,
     }
   }
 
-  Handle(HYDROData_Object) anObject1 = Handle(HYDROData_Object)::DownCast(
-    HYDROGUI_Tool::FindObjectByName( module(), aSelectedName1, KIND_UNKNOWN ) );
-  Handle(HYDROData_Object) anObject2 = Handle(HYDROData_Object)::DownCast(
-    HYDROGUI_Tool::FindObjectByName( module(), aSelectedName2, KIND_UNKNOWN ) );
+  Handle(HYDROData_Entity) anObject1 =
+    HYDROGUI_Tool::FindObjectByName( module(), aSelectedName1, KIND_UNKNOWN ) ;
+  Handle(HYDROData_Entity) anObject2 =
+    HYDROGUI_Tool::FindObjectByName( module(), aSelectedName2, KIND_UNKNOWN );
   if( anObject1.IsNull() || anObject2.IsNull() )
     return false;
 
-  HYDROOperations_Factory* aFactory = HYDROOperations_Factory::Factory();
+  HYDROData_OperationsFactory* aFactory = HYDROData_OperationsFactory::Factory();
 
   Handle(HYDROData_Image) aResult;
   ImageComposer_Operator* anOperator = 0;
index 90a798286e873c0dc126226fd1588e4ec939a109..0cb4447b63fa29a2659a6730fdc3ec4b7b23793f 100644 (file)
@@ -137,7 +137,7 @@ bool HYDROGUI_VisualStateOp::saveVisualState()
 
         for( int anObjIndex = 1, aLength = aSeq.Length(); anObjIndex <= aLength; anObjIndex++ )
         {
-          Handle(HYDROData_Object) anObject = aSeq.Value( anObjIndex );
+          Handle(HYDROData_Entity) anObject = aSeq.Value( anObjIndex );
           if( !anObject.IsNull() )
           {
             // Format: "Name|Visibility[|CoordX|CoordY]"
@@ -243,7 +243,7 @@ bool HYDROGUI_VisualStateOp::loadVisualState()
 
         for( int anObjIndex = 1, aLength = aSeq.Length(); anObjIndex <= aLength; anObjIndex++ )
         {
-          Handle(HYDROData_Object) anObject = aSeq.Value( anObjIndex );
+          Handle(HYDROData_Entity) anObject = aSeq.Value( anObjIndex );
           if( !anObject.IsNull() )
           {
             QString aName = anObject->GetName();
diff --git a/src/HYDROGUI/HYDROGUI_ZoneDlg.cxx b/src/HYDROGUI/HYDROGUI_ZoneDlg.cxx
deleted file mode 100644 (file)
index 1806765..0000000
+++ /dev/null
@@ -1,305 +0,0 @@
-// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-#include "HYDROGUI_ZoneDlg.h"
-
-#include "HYDROGUI_ColorWidget.h"
-#include "HYDROGUI_Tool.h"
-
-#include <QComboBox>
-#include <QGroupBox>
-#include <QLabel>
-#include <QLayout>
-#include <QLineEdit>
-#include <QListWidget>
-#include <QRadioButton>
-
-HYDROGUI_ZoneDlg::HYDROGUI_ZoneDlg( HYDROGUI_Module* theModule, const QString& theTitle )
-: HYDROGUI_InputPanel( theModule, theTitle )
-{
-  // Zone name
-  myObjectNameGroup = new QGroupBox( tr( "ZONE_NAME" ), mainFrame() );
-
-  myObjectName = new QLineEdit( myObjectNameGroup );
-
-  QBoxLayout* aNameLayout = new QHBoxLayout( myObjectNameGroup );
-  aNameLayout->setMargin( 5 );
-  aNameLayout->setSpacing( 5 );
-  aNameLayout->addWidget( new QLabel( tr( "NAME" ), myObjectNameGroup ) );
-  aNameLayout->addWidget( myObjectName );
-
-
-  QGroupBox* aParamGroup = new QGroupBox( tr( "ZONE_PARAMETERS" ), mainFrame() );
-
-  QFrame* aPolylineFrame = new QFrame( aParamGroup );
-
-  myPolylines = new QComboBox( aPolylineFrame );
-  myPolylines->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
-
-  QBoxLayout* aPolyLayout = new QHBoxLayout( aPolylineFrame );
-  aPolyLayout->setMargin( 0 );
-  aPolyLayout->setSpacing( 5 );
-  aPolyLayout->addWidget( new QLabel( tr( "ZONE_POLYLINE" ), aPolylineFrame ) );
-  aPolyLayout->addWidget( myPolylines );
-
-
-  QFrame* aFillingFrame = new QFrame( aParamGroup );
-  QLabel* aFillingLabel = new QLabel( tr( "FILLING_COLOR" ), aFillingFrame );
-  myFillingTransparent = new QRadioButton( tr( "TRANSPARENT" ), aFillingFrame );
-  myFillingTransparent->setChecked( true );
-  myFillingColor = new QRadioButton( tr( "COLOR" ), aFillingFrame );
-  myFillingColorBox = new HYDROGUI_ColorWidget( aFillingFrame );
-
-  QGridLayout* aFillingLayout = new QGridLayout( aFillingFrame );
-  aFillingLayout->setMargin( 0 );
-  aFillingLayout->setSpacing( 5 );
-  aFillingLayout->addWidget( aFillingLabel, 0, 0, 2, 1 );
-  aFillingLayout->addWidget( myFillingTransparent, 0, 1 );
-  aFillingLayout->addWidget( myFillingColor,       1, 1 );
-  aFillingLayout->addWidget( myFillingColorBox,    1, 2 );
-
-
-  myBorderColorGroup = new QGroupBox( tr( "BORDER_COLOR" ), mainFrame() );
-  myBorderColorGroup->setCheckable( true );
-
-  myBorderColorBox = new HYDROGUI_ColorWidget( myBorderColorGroup );
-
-  QBoxLayout* aBorderColorLayout = new QHBoxLayout( myBorderColorGroup );
-  aBorderColorLayout->setMargin( 5 );
-  aBorderColorLayout->setSpacing( 5 );
-  aBorderColorLayout->addWidget( new QLabel( tr( "COLOR" ), myBorderColorGroup ) );
-  aBorderColorLayout->addWidget( myBorderColorBox );
-
-
-  QBoxLayout* aParamLayout = new QVBoxLayout( aParamGroup );
-  aParamLayout->setMargin( 5 );
-  aParamLayout->setSpacing( 5 );
-  aParamLayout->addWidget( aPolylineFrame );
-  aParamLayout->addWidget( aFillingFrame );
-  aParamLayout->addWidget( myBorderColorGroup );
-
-
-  QGroupBox* aBathGroup = new QGroupBox( tr( "ZONE_BATHYMETRIES" ), mainFrame() );
-
-  myBathymetries = new QListWidget( aBathGroup );
-  myBathymetries->setSelectionMode( QListWidget::SingleSelection );
-  myBathymetries->setEditTriggers( QListWidget::NoEditTriggers );
-  myBathymetries->setViewMode( QListWidget::ListMode );
-
-  QBoxLayout* aBathLayout = new QHBoxLayout( aBathGroup );
-  aBathLayout->setMargin( 5 );
-  aBathLayout->setSpacing( 5 );
-  aBathLayout->addWidget( myBathymetries );
-
-
-  // Common
-  addWidget( myObjectNameGroup );
-  addWidget( aParamGroup );
-  addWidget( aBathGroup );
-
-  addStretch();
-
-
-  // Connect signals and slots
-  connect( myPolylines, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onZoneDefChanged() ) );
-  connect( myFillingTransparent, SIGNAL( toggled( bool ) ), this, SLOT( onZoneDefChanged() ) );
-  connect( myFillingColor, SIGNAL( toggled( bool ) ), this, SLOT( onZoneDefChanged() ) );
-  connect( myFillingColorBox, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( onFillingColorChanged() ) );
-  connect( myBorderColorGroup, SIGNAL( toggled( bool ) ), this, SLOT( onZoneDefChanged() ) );
-  connect( myBorderColorBox, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( onZoneDefChanged() ) );
-}
-
-HYDROGUI_ZoneDlg::~HYDROGUI_ZoneDlg()
-{
-}
-
-void HYDROGUI_ZoneDlg::reset()
-{
-  bool isBlocked = blockSignals( true );
-
-  myObjectName->clear();
-
-  myPolylines->clear();
-  myBathymetries->clear();
-
-  myFillingTransparent->setChecked( true );
-  myFillingColorBox->resetColor();
-
-  myBorderColorGroup->setChecked( false );
-  myBorderColorBox->resetColor();
-
-  blockSignals( isBlocked );
-
-  onZoneDefChanged();
-}
-
-void HYDROGUI_ZoneDlg::setObjectName( const QString& theName )
-{
-  myObjectName->setText( theName );
-}
-
-QString HYDROGUI_ZoneDlg::getObjectName() const
-{
-  return myObjectName->text();
-}
-
-void HYDROGUI_ZoneDlg::setPolylineNames( const QStringList& thePolylines )
-{
-  bool isBlocked = blockSignals( true );
-
-  myPolylines->clear();
-  myPolylines->addItems( thePolylines );
-
-  blockSignals( isBlocked );
-}
-
-void HYDROGUI_ZoneDlg::setPolylineName( const QString& theName )
-{
-  int aNewIdx = myPolylines->findText( theName );
-  if ( aNewIdx != myPolylines->currentIndex() )
-  {
-    myPolylines->setCurrentIndex( aNewIdx );
-  }
-  else
-  {
-    onZoneDefChanged();
-  }
-}
-
-QString HYDROGUI_ZoneDlg::getPolylineName() const
-{
-  return myPolylines->currentText();
-}
-
-void HYDROGUI_ZoneDlg::setBathymetries( const QStringList& theBathymetries )
-{
-  myBathymetries->clear();
-
-  for ( int i = 0, n = theBathymetries.length(); i < n; ++i )
-  {
-    QString aBathymetryName = theBathymetries.at( i );
-
-    QListWidgetItem* aListItem = new QListWidgetItem( aBathymetryName, myBathymetries );
-    aListItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable );
-    aListItem->setCheckState( Qt::Unchecked );
-  }
-}
-
-void HYDROGUI_ZoneDlg::setSelectedBathymetries( const QStringList& theBathymetries )
-{
-  for ( int i = 0, n = theBathymetries.length(); i < n; ++i )
-  {
-    QString aBathymetryName = theBathymetries.at( i );
-
-    QList<QListWidgetItem *> anItems = 
-      myBathymetries->findItems( aBathymetryName, Qt::MatchFixedString | Qt::MatchCaseSensitive );
-    if ( anItems.isEmpty() )
-      continue;
-
-    QListWidgetItem* aListItem = anItems.first();
-    if ( !aListItem )
-      continue;
-
-    aListItem->setCheckState( Qt::Checked );
-  }
-}
-
-QStringList HYDROGUI_ZoneDlg::getSelectedBathymetries() const
-{
-  QStringList aResList;
-
-  for ( int i = 0, n = myBathymetries->count(); i < n; ++i )
-  {
-    QListWidgetItem* aListItem = myBathymetries->item( i );
-    if ( !aListItem || aListItem->checkState() != Qt::Checked )
-      continue;
-
-    QString aSelBathName = aListItem->text();
-    aResList.append( aSelBathName );
-  }
-
-  return aResList;
-}
-
-void HYDROGUI_ZoneDlg::setFillingColor( const QColor& theColor )
-{
-  bool isBlocked = blockSignals( true );
-
-  if( theColor.alpha() == 0 ) // transparent
-    myFillingTransparent->setChecked( true );
-  else
-    myFillingColor->setChecked( true );
-
-  myFillingColorBox->setColor( theColor );
-
-  blockSignals( isBlocked );
-
-  onZoneDefChanged();
-}
-
-QColor HYDROGUI_ZoneDlg::getFillingColor() const
-{
-  QColor aColor( 255, 255, 255, 0 ); // transparent
-  if( myFillingColor->isChecked() )
-    aColor = myFillingColorBox->color();
-  return aColor;
-}
-
-void HYDROGUI_ZoneDlg::setBorderColor( const QColor& theColor )
-{
-  bool isBlocked = blockSignals( true );
-
-  bool isTransparent = theColor.alpha() == 0;
-  myBorderColorGroup->setChecked( !isTransparent );
-  myBorderColorBox->setColor( !isTransparent ? theColor : QColor( Qt::black ) );
-
-  blockSignals( isBlocked );
-
-  onZoneDefChanged();
-}
-
-QColor HYDROGUI_ZoneDlg::getBorderColor() const
-{
-  QColor aColor( Qt::transparent ); // transparent
-  if( myBorderColorGroup->isChecked() )
-    aColor = myBorderColorBox->color();
-  return aColor;
-}
-
-void HYDROGUI_ZoneDlg::onFillingColorChanged()
-{
-  if ( !myFillingColor->isChecked() )
-    return;
-
-  onZoneDefChanged();
-}
-
-void HYDROGUI_ZoneDlg::onZoneDefChanged()
-{
-  if ( signalsBlocked() )
-    return;
-
-  QString aPolylineName = getPolylineName();
-  emit CreatePreview( aPolylineName );
-}
-
-
diff --git a/src/HYDROGUI/HYDROGUI_ZoneDlg.h b/src/HYDROGUI/HYDROGUI_ZoneDlg.h
deleted file mode 100644 (file)
index ad70cb5..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-#ifndef HYDROGUI_ZONEDLG_H
-#define HYDROGUI_ZONEDLG_H
-
-#include "HYDROGUI_InputPanel.h"
-
-class HYDROGUI_ColorWidget;
-class QComboBox;
-class QGroupBox;
-class QLineEdit;
-class QListWidget;
-class QRadioButton;
-
-class HYDROGUI_ZoneDlg : public HYDROGUI_InputPanel
-{
-  Q_OBJECT
-
-public:
-  HYDROGUI_ZoneDlg( HYDROGUI_Module* theModule, const QString& theTitle );
-  virtual ~HYDROGUI_ZoneDlg();
-
-  void                       reset();
-
-  void                       setObjectName( const QString& theName );
-  QString                    getObjectName() const;
-
-  void                       setPolylineNames( const QStringList& thePolylines );
-  void                       setPolylineName( const QString& thePolyline );
-  QString                    getPolylineName() const;
-
-  void                       setBathymetries( const QStringList& theBathymetries );
-  void                       setSelectedBathymetries( const QStringList& theBathymetries );
-  QStringList                getSelectedBathymetries() const;
-
-  void                       setFillingColor( const QColor& theColor );
-  QColor                     getFillingColor() const;
-
-  void                       setBorderColor( const QColor& theColor );
-  QColor                     getBorderColor() const;
-
-signals:
-  void                       CreatePreview( const QString& thePolylineName );
-
-private slots:
-  void                       onZoneDefChanged();
-  void                       onFillingColorChanged();
-
-private:
-
-  QGroupBox*                 myObjectNameGroup;
-  QLineEdit*                 myObjectName;
-
-  QComboBox*                 myPolylines;
-  QListWidget*               myBathymetries;
-
-  QRadioButton*              myFillingTransparent;
-  QRadioButton*              myFillingColor;
-  HYDROGUI_ColorWidget*      myFillingColorBox;
-
-  QGroupBox*                 myBorderColorGroup;
-  HYDROGUI_ColorWidget*      myBorderColorBox;
-};
-
-#endif
diff --git a/src/HYDROGUI/HYDROGUI_ZoneOp.cxx b/src/HYDROGUI/HYDROGUI_ZoneOp.cxx
deleted file mode 100644 (file)
index e6daf5f..0000000
+++ /dev/null
@@ -1,303 +0,0 @@
-// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-#include "HYDROGUI_ZoneOp.h"
-
-#include "HYDROGUI_DataModel.h"
-#include "HYDROGUI_ZoneDlg.h"
-#include "HYDROGUI_Module.h"
-#include "HYDROGUI_Shape.h"
-#include "HYDROGUI_Tool.h"
-#include "HYDROGUI_UpdateFlags.h"
-
-#include <HYDROData_Bathymetry.h>
-#include <HYDROData_Iterator.h>
-#include <HYDROData_Polyline.h>
-
-#include <OCCViewer_ViewManager.h>
-#include <OCCViewer_ViewModel.h>
-
-#include <LightApp_Application.h>
-#include <LightApp_UpdateFlags.h>
-
-#include <TopoDS_Wire.hxx>
-
-HYDROGUI_ZoneOp::HYDROGUI_ZoneOp( HYDROGUI_Module* theModule,
-                                  const bool theIsEdit )
-: HYDROGUI_Operation( theModule ),
-  myIsEdit( theIsEdit ),
-  myViewManager( 0 ),
-  myPreviewPrs( 0 )
-{
-  setName( theIsEdit ? tr( "EDIT_ZONE" ) : tr( "CREATE_ZONE" ) );
-}
-
-HYDROGUI_ZoneOp::~HYDROGUI_ZoneOp()
-{
-  closePreview();
-}
-
-void HYDROGUI_ZoneOp::startOperation()
-{
-  HYDROGUI_Operation::startOperation();
-
-  HYDROGUI_ZoneDlg* aPanel = ::qobject_cast<HYDROGUI_ZoneDlg*>( inputPanel() );
-  if ( !aPanel )
-    return;
-
-  aPanel->blockSignals( true );
-
-  aPanel->reset();
-
-  QString anObjectName = HYDROGUI_Tool::GenerateObjectName( module(), "Zone" );
-
-  QColor      aFillingColor( HYDROData_Zone::DefaultFillingColor() );
-  QColor      aBorderColor( HYDROData_Zone::DefaultBorderColor() );
-  QString     aSelectedPolyline;
-  QStringList aSelectedBathymetries;
-
-  if ( myIsEdit )
-  {
-    myEditedObject = Handle(HYDROData_Zone)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) );
-    if( !myEditedObject.IsNull() )
-    {
-      anObjectName = myEditedObject->GetName();
-
-      aFillingColor = myEditedObject->GetFillingColor();
-      aBorderColor = myEditedObject->GetBorderColor();
-
-      Handle(HYDROData_Polyline) aRefPolyline = myEditedObject->GetPolyline();
-      if ( !aRefPolyline.IsNull() )
-        aSelectedPolyline = aRefPolyline->GetName();
-
-      HYDROData_SequenceOfObjects aRefBathymetries = myEditedObject->GetBathymetries();
-      HYDROData_SequenceOfObjects::Iterator anIter( aRefBathymetries );
-      for ( ; anIter.More(); anIter.Next() )
-      {
-        Handle(HYDROData_Bathymetry) aRefBathymetry = 
-          Handle(HYDROData_Bathymetry)::DownCast( anIter.Value() );
-        if ( aRefBathymetry.IsNull() )
-          continue;
-
-        QString aRefBathymetryName = aRefBathymetry->GetName();
-        if ( aRefBathymetryName.isEmpty() )
-          continue;
-
-        aSelectedBathymetries.append( aRefBathymetryName );
-      }
-    }
-  }
-
-  // collect information about existing closed polylines
-  QStringList aPolylines;
-
-  HYDROData_Iterator anIter( doc(), KIND_POLYLINE );
-  for ( ; anIter.More(); anIter.Next() )
-  {
-    Handle(HYDROData_Polyline) aPolylineObj = 
-      Handle(HYDROData_Polyline)::DownCast( anIter.Current() );
-    if ( aPolylineObj.IsNull() || !aPolylineObj->isClosed() )
-      continue;
-
-    QString aPolylineName = aPolylineObj->GetName();
-    if ( aPolylineName.isEmpty() )
-      continue;
-
-    aPolylines.append( aPolylineName );
-  }
-
-  // collect information about existing bathymetries
-  QStringList aBathymetries;
-
-  anIter = HYDROData_Iterator( doc(), KIND_BATHYMETRY );
-  for ( ; anIter.More(); anIter.Next() )
-  {
-    Handle(HYDROData_Bathymetry) aBathymetryObj = 
-      Handle(HYDROData_Bathymetry)::DownCast( anIter.Current() );
-    if ( aBathymetryObj.IsNull() )
-      continue;
-
-    QString aBathymetryName = aBathymetryObj->GetName();
-    if ( aBathymetryName.isEmpty() )
-      continue;
-
-    aBathymetries.append( aBathymetryName );
-  }
-  
-  aPanel->setObjectName( anObjectName );
-  
-  aPanel->setFillingColor( aFillingColor );
-  aPanel->setBorderColor( aBorderColor );
-
-  aPanel->setPolylineNames( aPolylines );
-
-  aPanel->setBathymetries( aBathymetries );
-  aPanel->setSelectedBathymetries( aSelectedBathymetries );
-
-  aPanel->blockSignals( false );
-
-  aPanel->setPolylineName( aSelectedPolyline );
-
-}
-
-void HYDROGUI_ZoneOp::abortOperation()
-{
-  closePreview();
-
-  HYDROGUI_Operation::abortOperation();
-}
-
-void HYDROGUI_ZoneOp::commitOperation()
-{
-  closePreview();
-
-  HYDROGUI_Operation::commitOperation();
-}
-
-HYDROGUI_InputPanel* HYDROGUI_ZoneOp::createInputPanel() const
-{
-  HYDROGUI_ZoneDlg* aPanel = new HYDROGUI_ZoneDlg( module(), getName() );
-  connect( aPanel, SIGNAL( CreatePreview( const QString& ) ),
-           this,   SLOT( onCreatePreview( const QString& ) ) );
-  return aPanel;
-}
-
-bool HYDROGUI_ZoneOp::processApply( int& theUpdateFlags,
-                                    QString& theErrorMsg )
-{
-  HYDROGUI_ZoneDlg* aPanel = ::qobject_cast<HYDROGUI_ZoneDlg*>( inputPanel() );
-  if ( !aPanel )
-    return false;
-
-  QString anObjectName = aPanel->getObjectName().simplified();
-  if ( anObjectName.isEmpty() )
-  {
-    theErrorMsg = tr( "INCORRECT_OBJECT_NAME" );
-    return false;
-  }
-
-  if( !myIsEdit || ( !myEditedObject.IsNull() && myEditedObject->GetName() != anObjectName ) )
-  {
-    // check that there are no other objects with the same name in the document
-    Handle(HYDROData_Object) anObject = HYDROGUI_Tool::FindObjectByName( module(), anObjectName );
-    if( !anObject.IsNull() )
-    {
-      theErrorMsg = tr( "OBJECT_EXISTS_IN_DOCUMENT" ).arg( anObjectName );
-      return false;
-    }
-  }
-
-  Handle(HYDROData_Zone) aZoneObj = myIsEdit ? myEditedObject :
-    Handle(HYDROData_Zone)::DownCast( doc()->CreateObject( KIND_ZONE ) );
-  if ( aZoneObj.IsNull() )
-    return false;
-
-  aZoneObj->SetName( anObjectName );
-
-  aZoneObj->SetFillingColor( aPanel->getFillingColor() );
-  aZoneObj->SetBorderColor( aPanel->getBorderColor() );
-
-  Handle(HYDROData_Polyline) aZonePolyline;
-
-  QString aPolylineName = aPanel->getPolylineName();
-  if ( !aPolylineName.isEmpty() )
-  {
-    aZonePolyline = Handle(HYDROData_Polyline)::DownCast(
-      HYDROGUI_Tool::FindObjectByName( module(), aPolylineName, KIND_POLYLINE ) );
-  }
-
-  aZoneObj->SetPolyline( aZonePolyline );
-
-
-  aZoneObj->RemoveBathymetries();
-
-  QStringList aBathymetries = aPanel->getSelectedBathymetries();
-  for ( int i = 0; i < aBathymetries.length(); ++i )
-  {
-    const QString& aBathymetryName = aBathymetries.at( i );
-    if ( aBathymetryName.isEmpty() )
-      continue;
-
-    Handle(HYDROData_Bathymetry) aBathymetry = Handle(HYDROData_Bathymetry)::DownCast(
-        HYDROGUI_Tool::FindObjectByName( module(), aBathymetryName, KIND_BATHYMETRY ) );
-    if ( aBathymetry.IsNull() )
-      continue;
-
-    aZoneObj->AddBathymetry( aBathymetry );
-  }
-
-  closePreview();
-
-  if( !myIsEdit )
-    module()->setObjectVisible( HYDROGUI_Tool::GetActiveOCCViewId( module() ), aZoneObj, true );
-
-  theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced;
-
-  return true;
-}
-
-void HYDROGUI_ZoneOp::onCreatePreview( const QString& thePolylineName )
-{
-  HYDROGUI_ZoneDlg* aPanel = ::qobject_cast<HYDROGUI_ZoneDlg*>( inputPanel() );
-  if ( !aPanel )
-    return;
-
-  TopoDS_Wire aWire;
-
-  Handle(HYDROData_Polyline) aPolyline = Handle(HYDROData_Polyline)::DownCast(
-    HYDROGUI_Tool::FindObjectByName( module(), thePolylineName, KIND_POLYLINE ) );
-  if ( !aPolyline.IsNull() )
-  {
-    aWire = aPolyline->Wire();
-  }
-
-  LightApp_Application* anApp = module()->getApp();
-  if ( !myViewManager )
-    myViewManager = ::qobject_cast<OCCViewer_ViewManager*>( 
-      anApp->getViewManager( OCCViewer_Viewer::Type(), true ) );
-
-  if ( myViewManager && !myPreviewPrs )
-  {
-    if ( OCCViewer_Viewer* aViewer = myViewManager->getOCCViewer() )
-    {
-      Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext();
-      if ( !aCtx.IsNull() )
-        myPreviewPrs = new HYDROGUI_Shape( aCtx, NULL );
-    }
-  }
-
-  if ( !myViewManager || !myPreviewPrs )
-    return;
-
-  myPreviewPrs->setFillingColor( aPanel->getFillingColor(), false, false );
-  myPreviewPrs->setBorderColor( aPanel->getBorderColor(), false, false );
-  myPreviewPrs->setFace( aWire );
-}
-
-void HYDROGUI_ZoneOp::closePreview()
-{
-  if( myPreviewPrs )
-  {
-    delete myPreviewPrs;
-    myPreviewPrs = 0;
-  }
-}
diff --git a/src/HYDROGUI/HYDROGUI_ZoneOp.h b/src/HYDROGUI/HYDROGUI_ZoneOp.h
deleted file mode 100644 (file)
index 85760aa..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-#ifndef HYDROGUI_ZONEOP_H
-#define HYDROGUI_ZONEOP_H
-
-#include "HYDROGUI_Operation.h"
-
-#include <HYDROData_Zone.h>
-
-class OCCViewer_ViewManager;
-
-class HYDROGUI_Shape;
-
-class HYDROGUI_ZoneOp : public HYDROGUI_Operation
-{
-  Q_OBJECT
-
-public:
-  HYDROGUI_ZoneOp( HYDROGUI_Module* theModule, const bool theIsEdit );
-  virtual ~HYDROGUI_ZoneOp();
-
-protected:
-  virtual void               startOperation();
-  virtual void               abortOperation();
-  virtual void               commitOperation();
-
-  virtual HYDROGUI_InputPanel* createInputPanel() const;
-
-  virtual bool               processApply( int& theUpdateFlags, QString& theErrorMsg );
-
-protected slots:
-  void                       onCreatePreview( const QString& thePolylineName );
-
-private:
-  void                       closePreview();
-
-private:
-  bool                       myIsEdit;
-  Handle(HYDROData_Zone)     myEditedObject;
-
-  OCCViewer_ViewManager*     myViewManager;
-
-  HYDROGUI_Shape*            myPreviewPrs;
-};
-
-#endif
index 63f72ab8453d2166d2455da1e350e2c42a0478b0..ae546f69ebf0e1357c4293f4d12a1fec2e246802 100644 (file)
@@ -7,10 +7,6 @@
       <source>BATHYMETRY_FILTER</source>
       <translation>Bathymetry files (*.xyz);;All files (*.* *)</translation>
     </message>
-    <message>
-      <source>CASE_BND_POLYLINE</source>
-      <translation>Boundary polyline</translation>
-    </message>
     <message>
       <source>CASE_REFERENCE_ZONES</source>
       <translation>Reference zones</translation>
@@ -61,53 +57,25 @@ does not exist or you have not enough permissions to open it.</translation>
       <translation>Polyline</translation>
     </message>
     <message>
-      <source>ZONE_BATHYMETRIES</source>
-      <translation>Bathymetries</translation>
+      <source>ZONE_BATHYMETRY</source>
+      <translation>Bathymetry</translation>
     </message>
   </context>
 
   <context>
     <name>HYDROGUI_CalculationDlg</name>
-    <message>
-      <source>BOUNDARY_POLYLINE</source>
-      <translation>Polyline</translation>
-    </message>
-    <message>
-      <source>CALCULATION_BOUNDARY</source>
-      <translation>Domain of calculation case</translation>
-    </message>
     <message>
       <source>CALCULATION_NAME</source>
       <translation>Calculation case name</translation>
     </message>
     <message>
-      <source>CALCULATION_REFERENCE_ZONES</source>
-      <translation>Reference zones</translation>
-    </message>
-    <message>
-      <source>CALCULATION_REGIONS</source>
-      <translation>Regions</translation>
-    </message>
-    <message>
-      <source>CALCULATION_ZONES</source>
-      <translation>Case zones</translation>
-    </message>
-    <message>
-      <source>DEFAULT_PREFIX_REGIONS</source>
-      <translation>Region</translation>
+      <source>CALCULATION_REFERENCE_OBJECTS</source>
+      <translation>Objects</translation>
     </message>
     <message>
       <source>NAME</source>
       <translation>Name</translation>
     </message>
-    <message>
-      <source>PREFIX_REGIONS</source>
-      <translation>Prefix for regions</translation>
-    </message>
-    <message>
-      <source>SPLIT_REFERENCE_ZONES</source>
-      <translation>Split zones</translation>
-    </message>
   </context>
 
   <context>
@@ -324,12 +292,12 @@ file cannot be correctly imported for a Bathymetry definition.</translation>
       <translation>Create polyline</translation>
     </message>
     <message>
-      <source>DSK_CREATE_ZONE</source>
-      <translation>Create zone</translation>
+      <source>DSK_CREATE_IMMERSIBLE_ZONE</source>
+      <translation>Create immersible zone</translation>
     </message>
     <message>
-      <source>DSK_EDIT_ZONE</source>
-      <translation>Edit zone</translation>
+      <source>DSK_EDIT_IMMERSIBLE_ZONE</source>
+      <translation>Edit immersible zone</translation> 
     </message>
     <message>
       <source>DSK_COPY</source>
@@ -448,12 +416,12 @@ file cannot be correctly imported for a Bathymetry definition.</translation>
       <translation>Create zone</translation>
     </message>
     <message>
-      <source>MEN_EDIT_ZONE</source>
-      <translation>Edit zone</translation>
+      <source>MEN_CREATE_IMMERSIBLE_ZONE</source>
+      <translation>Create immersible zone</translation>
     </message>
     <message>
-      <source>MEN_COPY</source>
-      <translation>Copy</translation>
+      <source>MEN_EDIT_IMMERSIBLE_ZONE</source>
+      <translation>Edit immersible zone</translation>
     </message>
     <message>
       <source>MEN_CUT_IMAGES</source>
@@ -568,12 +536,12 @@ file cannot be correctly imported for a Bathymetry definition.</translation>
       <translation>Create polyline</translation>
     </message>
     <message>
-      <source>STB_CREATE_ZONE</source>
-      <translation>Create zone</translation>
+      <source>STB_CREATE_IMMERSIBLE_ZONE</source>
+      <translation>Create immersible zone</translation>
     </message>
     <message>
-      <source>STB_EDIT_ZONE</source>
-      <translation>Edit zone</translation>
+      <source>STB_EDIT_IMMERSIBLE_ZONE</source>
+      <translation>Edit immersible zone</translation>
     </message>
     <message>
       <source>STB_COPY</source>
@@ -846,7 +814,7 @@ file cannot be correctly imported for a Bathymetry definition.</translation>
   </context>
 
   <context>
-    <name>HYDROGUI_ZoneDlg</name>
+    <name>HYDROGUI_ImmersibleZoneDlg</name>
     <message>
       <source>BORDER_COLOR</source>
       <translation>Border</translation>
@@ -868,8 +836,8 @@ file cannot be correctly imported for a Bathymetry definition.</translation>
       <translation>Transparent</translation>
     </message>
     <message>
-      <source>ZONE_BATHYMETRIES</source>
-      <translation>Bathymetries</translation>
+      <source>ZONE_BATHYMETRY</source>
+      <translation>Bathymetry</translation>
     </message>
     <message>
       <source>ZONE_NAME</source>
@@ -886,14 +854,14 @@ file cannot be correctly imported for a Bathymetry definition.</translation>
   </context>
 
   <context>
-    <name>HYDROGUI_ZoneOp</name>
+    <name>HYDROGUI_ImmersibleZoneOp</name>
     <message>
-      <source>CREATE_ZONE</source>
-      <translation>Create zone</translation>
+      <source>CREATE_IMMERSIBLE_ZONE</source>
+      <translation>Create immersible zone</translation>
     </message>
     <message>
-      <source>EDIT_ZONE</source>
-      <translation>Edit zone</translation>
+      <source>EDIT_IMMERSIBLE_ZONE</source>
+      <translation>Edit immersible zone</translation>
     </message>
   </context>
 
index 97fd2024467fc2495e2debc64fa7ebb47ea31456..c4c8ca3dc3bbc1a3316f04b6286dde71d6e9ed8a 100644 (file)
@@ -52,11 +52,14 @@ See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 
 %Import QtGui/QtGuimod.sip
 
+%Include HYDROData_Entity.sip
 %Include HYDROData_Object.sip
+%Include HYDROData_ArtificialObject.sip
+%Include HYDROData_NaturalObject.sip
 %Include HYDROData_Image.sip
 %Include HYDROData_Polyline.sip
 %Include HYDROData_Bathymetry.sip
-%Include HYDROData_Domain.sip
+%Include HYDROData_ImmersibleZone.sip
 %Include HYDROData_Zone.sip
 %Include HYDROData_Region.sip
 %Include HYDROData_Calculation.sip
diff --git a/src/HYDROPy/HYDROData_ArtificialObject.sip b/src/HYDROPy/HYDROData_ArtificialObject.sip
new file mode 100644 (file)
index 0000000..dc301f8
--- /dev/null
@@ -0,0 +1,64 @@
+// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+
+%ExportedHeaderCode
+#include <HYDROData_ArtificialObject.h>
+%End
+
+class HYDROData_ArtificialObject : HYDROData_Object /Abstract/
+{
+%TypeHeaderCode
+#include <HYDROData_ArtificialObject.h>
+%End
+
+%ConvertToSubClassCode
+    // HYDROData_ArtificialObject sub-classes provide a unique kind ID.
+    switch ( sipCpp->GetKind() )
+    {
+      case KIND_UNKNOWN:
+        sipClass = sipClass_HYDROData_ArtificialObject;
+        break;
+
+      default:
+        // We don't recognise the type.
+        sipClass = NULL;
+    }
+%End
+
+public:
+
+
+protected:
+
+  /**
+   * Creates new object in the internal data structure. Use higher level objects 
+   * to create objects with real content.
+   */
+  HYDROData_ArtificialObject();
+
+  /**
+   * Destructs properties of the object and object itself, removes it from the document.
+   */
+  virtual ~HYDROData_ArtificialObject();
+  
+};
index 8666ba56f60e203520e7a1469649e20a79aab00c..f26ec885a553c5b853f647e335073d58263659f5 100644 (file)
@@ -32,14 +32,20 @@ HYDROData_Bathymetry::AltitudePoints convertFromPythonAltitudeList( PyObject* th
 
 %End
 
-class HYDROData_Bathymetry : HYDROData_Object
+class HYDROData_Bathymetry : HYDROData_Entity
 {
 
 %ConvertToSubClassCode
-    if ( !Handle(HYDROData_Bathymetry)::DownCast( sipCpp ).IsNull() )
-      sipClass = sipClass_HYDROData_Bathymetry;
-    else
-      sipClass = NULL;
+    switch ( sipCpp->GetKind() )
+    {
+      case KIND_BATHYMETRY:
+        sipClass = sipClass_HYDROData_Bathymetry;
+        break;
+
+      default:
+        // We don't recognise the type.
+        sipClass = NULL;
+    }
 %End
 
 %TypeHeaderCode
@@ -95,12 +101,6 @@ HYDROData_Bathymetry::AltitudePoints convertFromPythonAltitudeList( PyObject* th
 
 %End
 
-
-public:
-
-  const ObjectKind          GetKind() const;
-
-
 public:      
   // Public methods to work with Bathymetry altitudes.
 
index 15d026ec15bea646d299d597a606f9ba40f24709..2ca69234bd1a71922d42e03f337c0f57a7fb03a4 100644 (file)
@@ -32,143 +32,131 @@ class HYDROData_Calculation : HYDROData_Object
 %End
 
 %ConvertToSubClassCode
-    if ( !Handle(HYDROData_Calculation)::DownCast( sipCpp ).IsNull() )
-      sipClass = sipClass_HYDROData_Calculation;
-    else
-      sipClass = NULL;
-%End
-
-public:
-
-  const ObjectKind          GetKind() const;
-
-public:      
-
-  /**
-   * Sets boundary polyline for calculation case.
-   */
-  void SetBoundaryPolyline( HYDROData_Polyline thePolyline ) [void (const Handle_HYDROData_Polyline&)];
-  %MethodCode
-
-    Handle(HYDROData_Polyline) aRefPolyline =
-      Handle(HYDROData_Polyline)::DownCast( createHandle( a0 ) );
-    if ( !aRefPolyline.IsNull() )
+    switch ( sipCpp->GetKind() )
     {
-      Py_BEGIN_ALLOW_THREADS
-      sipSelfWasArg ? sipCpp->HYDROData_Calculation::SetBoundaryPolyline( aRefPolyline ) : 
-                      sipCpp->SetBoundaryPolyline( aRefPolyline );
-      Py_END_ALLOW_THREADS
-    }
-
-  %End
+      case KIND_CALCULATION:
+        sipClass = sipClass_HYDROData_Calculation;
+        break;
 
-  /**
-   * Returns boundary polyline of calculation case.
-   */
-  HYDROData_Polyline GetBoundaryPolyline() const [Handle_HYDROData_Polyline ()];
-  %MethodCode
+      default:
+        // We don't recognise the type.
+        sipClass = NULL;
+    }
+%End
 
-    Handle(HYDROData_Polyline) aRefPolyline;
-    
-    Py_BEGIN_ALLOW_THREADS
-    aRefPolyline = sipSelfWasArg ? sipCpp->HYDROData_Calculation::GetBoundaryPolyline() : 
-                                   sipCpp->GetBoundaryPolyline();
-    Py_END_ALLOW_THREADS
-    
-    sipRes = (HYDROData_Polyline*)createPointer( aRefPolyline );
-  
-  %End
+public:      
 
   /**
-   * Removes boundary polyline of calculation case.
+   * Split reference geometry objects to non-intersected regions.
    */
-  void RemoveBoundaryPolyline();
-
-
+  void SplitGeometryObjects();
 
   /**
-   * Returns number of refrence zones for calculation case.
+   * Returns number of geometry objects for calculation case.
    */
-  int NbZones() const;
+  int NbGeometryObjects() const;
 
   /**
-   * Add new one refrence zone for calculation case.
+   * dd new one geometry object for calculation case.
    */
-  void AddZone( HYDROData_Zone theZone ) [void (const Handle_HYDROData_Zone&)];
+  void AddGeometryObject( HYDROData_Object theRegion ) [void (const Handle_HYDROData_Object&)];
   %MethodCode
 
-    Handle(HYDROData_Zone) aRefZone =
-      Handle(HYDROData_Zone)::DownCast( createHandle( a0 ) );
-    if ( !aRefZone.IsNull() )
+    Handle(HYDROData_Object) aGeomObj =
+      Handle(HYDROData_Object)::DownCast( createHandle( a0 ) );
+    if ( !aGeomObj.IsNull() )
     {
       Py_BEGIN_ALLOW_THREADS
-      sipSelfWasArg ? sipCpp->HYDROData_Calculation::AddZone( aRefZone ) : 
-                      sipCpp->AddZone( aRefZone );
+      sipSelfWasArg ? sipCpp->HYDROData_Calculation::AddGeometryObject( aGeomObj ) : 
+                      sipCpp->AddGeometryObject( aGeomObj );
       Py_END_ALLOW_THREADS
     }
 
   %End
 
   /**
-   * Replace the refrence zone for calculation case.
+   * Replace the geometry object for calculation case.
    */
-  void SetZone( const int      theIndex, 
-                HYDROData_Zone theZone ) [void (const int, const Handle_HYDROData_Zone&)];
+  void SetGeometryObject( const int        theIndex, 
+                          HYDROData_Object theObject ) [void (const int, const Handle_HYDROData_Object&)];
   %MethodCode
 
-    Handle(HYDROData_Zone) aRefZone =
-      Handle(HYDROData_Zone)::DownCast( createHandle( a1 ) );
-    if ( !aRefZone.IsNull() )
+    Handle(HYDROData_Object) aGeomObj =
+      Handle(HYDROData_Object)::DownCast( createHandle( a1 ) );
+    if ( !aGeomObj.IsNull() )
     {
       Py_BEGIN_ALLOW_THREADS
-      sipSelfWasArg ? sipCpp->HYDROData_Calculation::SetZone( a0, aRefZone ) : 
-                      sipCpp->SetZone( a0, aRefZone );
+      sipSelfWasArg ? sipCpp->HYDROData_Calculation::SetGeometryObject( a0, aGeomObj ) : 
+                      sipCpp->SetGeometryObject( a0, aGeomObj );
       Py_END_ALLOW_THREADS
     }
 
   %End
 
   /**
-   * Sets the refrence zones for calculation case.
+   * Sets the geometry object for calculation case.
    */
-  //void SetZones( const HYDROData_SequenceOfObjects& theZones );
+  //void SetGeometryObjects( const HYDROData_SequenceOfObjects& theObjects );
 
   /**
-   * Returns refrence zone of calculation case by index.
+   * Returns geometry object of calculation case by index.
    */
-  HYDROData_Zone GetZone( const int theIndex ) const [Handle_HYDROData_Zone (const int)];
+  HYDROData_Object GetGeometryObject( const int theIndex ) const [Handle_HYDROData_Object (const int)];
   %MethodCode
 
-    Handle(HYDROData_Zone) aRefZone;
+    Handle(HYDROData_Object) aGeomObj;
     
     Py_BEGIN_ALLOW_THREADS
-    aRefZone = sipSelfWasArg ? sipCpp->HYDROData_Calculation::GetZone( a0 ) : 
-                               sipCpp->GetZone( a0 );
+    aGeomObj = sipSelfWasArg ? sipCpp->HYDROData_Calculation::GetGeometryObject( a0 ) : 
+                               sipCpp->GetGeometryObject( a0 );
     Py_END_ALLOW_THREADS
     
-    sipRes = (HYDROData_Zone*)createPointer( aRefZone );
+    sipRes = (HYDROData_Object*)createPointer( aGeomObj );
   
   %End
 
   /**
-   * Returns all refrence zone of calculation case.
+   * Returns all geometry objects of calculation case.
    */
-  //HYDROData_SequenceOfObjects GetZones() const;
+  //HYDROData_SequenceOfObjects GetGeometryObjects() const;
 
   /**
-   * Removes all refrence zone of calculation case.
+   * Removes all geometry objects from calculation case.
    */
-  void RemoveZones();
+  void RemoveGeometryObjects();
+
+
+  /**
+   * Add new one region for calculation case.
+   * The new region is not added into the list of reference regions.
+   */
+  HYDROData_Region AddNewRegion() [Handle_HYDROData_Region ()];
+  %MethodCode
+
+    Handle(HYDROData_Region) aNewRegion;
+    
+    Py_BEGIN_ALLOW_THREADS
+    aNewRegion = sipSelfWasArg ? sipCpp->HYDROData_Calculation::AddNewRegion() : 
+                                 sipCpp->AddNewRegion();
+    Py_END_ALLOW_THREADS
+    
+    sipRes = (HYDROData_Region*)createPointer( aNewRegion );
 
+  %End
+
+  /**
+   * Removes all child regions from calculation case.
+   */
+  void RemoveChildRegions();
 
 
   /**
-   * Returns number of regions for calculation case.
+   * Returns number of reference regions for calculation case.
    */
   int NbRegions() const;
 
   /**
-   * Add new one region for calculation case.
+   * Add new one reference region for calculation case.
    */
   void AddRegion( HYDROData_Region theRegion ) [void (const Handle_HYDROData_Region&)];
   %MethodCode
@@ -186,7 +174,7 @@ public:
   %End
 
   /**
-   * Replace the region for calculation case.
+   * Replace the reference region for calculation case.
    */
   void SetRegion( const int        theIndex, 
                   HYDROData_Region theRegion ) [void (const int, const Handle_HYDROData_Region&)];
@@ -205,34 +193,76 @@ public:
   %End
 
   /**
-   * Sets the refrence region for calculation case.
+   * Inserts the reference region for calculation case before given index.
+   */
+  void InsertRegion( const int        theBeforeIndex, 
+                     HYDROData_Region theRegion ) [void (const int, const Handle_HYDROData_Region&)];
+  %MethodCode
+
+    Handle(HYDROData_Region) aRegion =
+      Handle(HYDROData_Region)::DownCast( createHandle( a1 ) );
+    if ( !aRegion.IsNull() )
+    {
+      Py_BEGIN_ALLOW_THREADS
+      sipSelfWasArg ? sipCpp->HYDROData_Calculation::InsertRegion( a0, aRegion ) : 
+                      sipCpp->InsertRegion( a0, aRegion );
+      Py_END_ALLOW_THREADS
+    }
+
+  %End
+
+  /**
+   * Sets reference regions for calculation case.
    */
   //void SetRegions( const HYDROData_SequenceOfObjects& theRegions );
 
   /**
-   * Returns region of calculation case by index.
+   * Returns reference region of calculation case by index.
    */
   HYDROData_Region GetRegion( const int theIndex ) const [Handle_HYDROData_Region (const int)];
   %MethodCode
 
-    Handle(HYDROData_Region) aRegion;
+    Handle(HYDROData_Region) aRefRegion;
     
     Py_BEGIN_ALLOW_THREADS
-    aRegion = sipSelfWasArg ? sipCpp->HYDROData_Calculation::GetRegion( a0 ) : 
-                              sipCpp->GetRegion( a0 );
+    aRefRegion = sipSelfWasArg ? sipCpp->HYDROData_Region::GetRegion( a0 ) : 
+                                 sipCpp->GetRegion( a0 );
     Py_END_ALLOW_THREADS
     
-    sipRes = (HYDROData_Region*)createPointer( aRegion );
+    sipRes = (HYDROData_Region*)createPointer( aRefRegion );
   
   %End
 
   /**
-   * Returns all regions of calculation case.
+   * Returns all reference regions of calculation case.
+   */
+  //void HYDROData_SequenceOfObjects GetRegions() const;
+
+  /**
+   * Removes reference region from calculation case.
+   */
+  void RemoveRegion( HYDROData_Region theRegion ) const [void (const Handle_HYDROData_Region&)];
+  %MethodCode
+
+    Handle(HYDROData_Region) aRegion =
+      Handle(HYDROData_Region)::DownCast( createHandle( a0 ) );
+    if ( !aRegion.IsNull() )
+    {
+      Py_BEGIN_ALLOW_THREADS
+      sipSelfWasArg ? sipCpp->HYDROData_Calculation::RemoveRegion( aRegion ) : 
+                      sipCpp->RemoveRegion( aRegion );
+      Py_END_ALLOW_THREADS
+    }
+
+  %End
+
+  /**
+   * Removes region from calculation case by it index.
    */
-  //HYDROData_SequenceOfObjects GetRegions() const;
+  void RemoveRegion( const int theIndex );
 
   /**
-   * Removes all regions of calculation case.
+   * Removes all reference regions from calculation case.
    */
   void RemoveRegions();
 
index e79e16d57bf4a30e85c59e058acede435534ee7b..539d91cb03d7c3ca93faf1fac213067b6fb7d2f1 100644 (file)
@@ -25,9 +25,9 @@
 %End
 
 %ModuleHeaderCode
-HYDROData_Object* copyObject( HYDROData_Object* theObject );
-Handle(HYDROData_Object) createHandle( HYDROData_Object* theObject );
-HYDROData_Object* createPointer( const Handle(HYDROData_Object)& theObject );
+HYDROData_Entity* copyObject( HYDROData_Entity* theObject );
+Handle(HYDROData_Entity) createHandle( HYDROData_Entity* theObject );
+HYDROData_Entity* createPointer( const Handle(HYDROData_Entity)& theObject );
 %End
 
 enum Data_DocError {
@@ -54,9 +54,9 @@ class HYDROData_Document
 
 %TypeCode
 
-  HYDROData_Object* copyObject( HYDROData_Object* theObject )
+  HYDROData_Entity* copyObject( HYDROData_Entity* theObject )
   {
-    HYDROData_Object* aRes = NULL;
+    HYDROData_Entity* aRes = NULL;
     if ( theObject == NULL )
       return aRes;
 
@@ -77,14 +77,14 @@ class HYDROData_Document
         aRes = new HYDROData_Bathymetry( *dynamic_cast<HYDROData_Bathymetry*>( theObject ) );
         break;
       }
-      case KIND_CALCULATION:
+      case KIND_IMMERSIBLE_ZONE:
       {
-        aRes = new HYDROData_Calculation( *dynamic_cast<HYDROData_Calculation*>( theObject ) );
+        aRes = new HYDROData_ImmersibleZone( *dynamic_cast<HYDROData_ImmersibleZone*>( theObject ) );
         break;
       }
-      case KIND_ZONE:
+      case KIND_CALCULATION:
       {
-        aRes = new HYDROData_Zone( *dynamic_cast<HYDROData_Zone*>( theObject ) );
+        aRes = new HYDROData_Calculation( *dynamic_cast<HYDROData_Calculation*>( theObject ) );
         break;
       }
       case KIND_REGION:
@@ -92,20 +92,25 @@ class HYDROData_Document
         aRes = new HYDROData_Region( *dynamic_cast<HYDROData_Region*>( theObject ) );
         break;
       }
+      case KIND_ZONE:
+      {
+        aRes = new HYDROData_Zone( *dynamic_cast<HYDROData_Zone*>( theObject ) );
+        break;
+      }
     }
     
     return aRes;
   }
   
-  Handle(HYDROData_Object) createHandle( HYDROData_Object* theObject )
+  Handle(HYDROData_Entity) createHandle( HYDROData_Entity* theObject )
   {
-    Handle(HYDROData_Object) aRes = copyObject( theObject );
+    Handle(HYDROData_Entity) aRes = copyObject( theObject );
     return aRes;
   }
   
-  HYDROData_Object* createPointer( const Handle(HYDROData_Object)& theObject )
+  HYDROData_Entity* createPointer( const Handle(HYDROData_Entity)& theObject )
   {
-    HYDROData_Object* aRes = NULL;
+    HYDROData_Entity* aRes = NULL;
     
     if ( !theObject.IsNull() )
       aRes = copyObject( theObject.operator->() );
@@ -192,10 +197,10 @@ public:
   //! Creates and locates in the document a new object
   //! \param theKind kind of the created object, can not be UNKNOWN
   //! \returns the created object
-  HYDROData_Object CreateObject( const ObjectKind theKind ) [Handle_HYDROData_Object (const ObjectKind)] ;
+  HYDROData_Entity CreateObject( const ObjectKind theKind ) [Handle_HYDROData_Entity (const ObjectKind)] ;
   %MethodCode
 
-    Handle(HYDROData_Object) anObject;
+    Handle(HYDROData_Entity) anObject;
     Py_BEGIN_ALLOW_THREADS
     anObject =  sipSelfWasArg ? sipCpp->HYDROData_Document::CreateObject( a0 ) :
                                 sipCpp->CreateObject( a0 );
diff --git a/src/HYDROPy/HYDROData_Domain.sip b/src/HYDROPy/HYDROData_Domain.sip
deleted file mode 100644 (file)
index 083c3a3..0000000
+++ /dev/null
@@ -1,161 +0,0 @@
-// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-%ExportedHeaderCode
-#include <HYDROData_Domain.h>
-%End
-
-class HYDROData_Domain : HYDROData_Object /Abstract/
-{
-
-%TypeHeaderCode
-#include <HYDROData_Domain.h>
-%End
-
-%ConvertToSubClassCode
-    // HYDROData_Object sub-classes provide a unique kind ID.
-    switch ( sipCpp->GetKind() )
-    {
-      case KIND_REGION:
-        sipClass = sipClass_HYDROData_Region;
-        break;
-
-      case KIND_ZONE:
-        sipClass = sipClass_HYDROData_Zone;
-        break;
-
-      case KIND_UNKNOWN:
-        sipClass = sipClass_HYDROData_Object;
-        break;
-
-      default:
-        // We don't recognise the type.
-        sipClass = NULL;
-    }
-%End
-
-public:      
-
-  /**
-   * Sets filling color for zone.
-   */
-  void SetFillingColor( const QColor& theColor );
-
-  /**
-   * Returns filling color of zone.
-   */
-  QColor GetFillingColor() const;
-
-  /**
-   * Sets border color for zone.
-   */
-  void SetBorderColor( const QColor& theColor );
-
-  /**
-   * Returns border color of zone.
-   */
-  QColor GetBorderColor() const;
-
-  /**
-   * Returns number of bathymetry objects for zone.
-   */
-  int NbBathymetries() const;
-
-  /**
-   * Add reference bathymetry object for zone.
-   */
-  void AddBathymetry( HYDROData_Bathymetry theBathymetry ) [void (const Handle_HYDROData_Bathymetry&)];
-  %MethodCode
-
-    Handle(HYDROData_Bathymetry) aRefBath =
-      Handle(HYDROData_Bathymetry)::DownCast( createHandle( a0 ) );
-    if ( !aRefBath.IsNull() )
-    {
-      Py_BEGIN_ALLOW_THREADS
-      sipSelfWasArg ? sipCpp->HYDROData_Domain::AddBathymetry( aRefBath ) : 
-                      sipCpp->AddBathymetry( aRefBath );
-      Py_END_ALLOW_THREADS
-    }
-
-  %End
-
-  /**
-   * Change reference bathymetry object with given index for zone.
-   */
-  void SetBathymetry( const int            theIndex, 
-                      HYDROData_Bathymetry theBathymetry ) [void (const int, const Handle_HYDROData_Bathymetry&)];
-  %MethodCode
-
-    Handle(HYDROData_Bathymetry) aRefBath =
-      Handle(HYDROData_Bathymetry)::DownCast( createHandle( a1 ) );
-    if ( !aRefBath.IsNull() )
-    {
-      Py_BEGIN_ALLOW_THREADS
-      sipSelfWasArg ? sipCpp->HYDROData_Domain::SetBathymetry( a0, aRefBath ) : 
-                      sipCpp->SetBathymetry( a0, aRefBath );
-      Py_END_ALLOW_THREADS
-    }
-
-  %End
-
-  /**
-   * Returns reference bathymetry object of zone by it index.
-   */
-  HYDROData_Bathymetry GetBathymetry( const int theIndex ) const [Handle_HYDROData_Bathymetry (const int)];
-  %MethodCode
-
-    Handle(HYDROData_Bathymetry) aRefBath;
-    
-    Py_BEGIN_ALLOW_THREADS
-    aRefBath = sipSelfWasArg ? sipCpp->HYDROData_Domain::GetBathymetry( a0 ) : 
-                               sipCpp->GetBathymetry( a0 );
-    Py_END_ALLOW_THREADS
-    
-    sipRes = (HYDROData_Bathymetry*)createPointer( aRefBath );
-  
-  %End
-
-  /**
-   * Returns list of all reference bathymetry objects of zone.
-   */
-  //HYDROData_SequenceOfObjects GetBathymetries() const;
-
-  /**
-   * Clear list of bathymetry objects of zone.
-   */
-  void RemoveBathymetries();
-
-protected:
-
-  /**
-   * Creates new object in the internal data structure. Use higher level objects 
-   * to create objects with real content.
-   */
-  HYDROData_Domain();
-
-  /**
-   * Destructs properties of the object and object itself, removes it from the document.
-   */
-  ~HYDROData_Domain();
-};
-
-
diff --git a/src/HYDROPy/HYDROData_Entity.sip b/src/HYDROPy/HYDROData_Entity.sip
new file mode 100644 (file)
index 0000000..20ab25c
--- /dev/null
@@ -0,0 +1,148 @@
+// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+
+%ExportedHeaderCode
+#include <HYDROData_Entity.h>
+%End
+
+typedef int ObjectKind;
+
+const ObjectKind KIND_UNKNOWN;
+const ObjectKind KIND_IMAGE;
+const ObjectKind KIND_POLYLINE;
+const ObjectKind KIND_BATHYMETRY;
+const ObjectKind KIND_IMMERSIBLE_ZONE;
+const ObjectKind KIND_CALCULATION;
+const ObjectKind KIND_ZONE;
+const ObjectKind KIND_REGION;
+
+class HYDROData_Entity
+{
+%TypeHeaderCode
+#include <HYDROData_Entity.h>
+%End
+
+%ConvertToSubClassCode
+    // HYDROData_Entity sub-classes provide a unique kind ID.
+    switch ( sipCpp->GetKind() )
+    {
+      case KIND_IMAGE:
+        sipClass = sipClass_HYDROData_Image;
+        break;
+
+      case KIND_POLYLINE:
+        sipClass = sipClass_HYDROData_Polyline;
+        break;
+
+      case KIND_BATHYMETRY:
+        sipClass = sipClass_HYDROData_Bathymetry;
+        break;
+
+      case KIND_IMMERSIBLE_ZONE:
+        sipClass = sipClass_HYDROData_ImmersibleZone;
+        break;
+        
+      case KIND_CALCULATION:
+        sipClass = sipClass_HYDROData_Calculation;
+        break;
+
+      case KIND_REGION:
+        sipClass = sipClass_HYDROData_Region;
+        break;
+
+      case KIND_ZONE:
+        sipClass = sipClass_HYDROData_Zone;
+        break;
+
+      case KIND_UNKNOWN:
+        sipClass = sipClass_HYDROData_Entity;
+        break;
+
+      default:
+        // We don't recognise the type.
+        sipClass = NULL;
+    }
+%End
+
+public:
+
+  /**
+   * Returns the kind of this object. Must be redefined in all objects of known type.
+   */
+  const ObjectKind GetKind() const;
+
+  /**
+   * Returns the name of this object.
+   */
+  QString GetName() const;
+
+  /**
+   * Updates the name of this object.
+   */
+  void SetName(const QString& theName);
+
+  /**
+   * Updates object state.
+   * \param theIsForce force reupdating of data object
+   */
+  void Update(const bool theIsForce);
+
+  /**
+   * Checks is object exists in the data structure.
+   * \returns true is object is not exists in the data model
+   */
+  bool IsRemoved() const;
+
+  /**
+   * Removes object from the data structure.
+   */
+  void Remove();
+
+  /**
+   * Returns unique integer identifier of the object (may be used for ordering of objects)
+   */
+  int ID() const;
+
+  /**
+   * Copies all properties of this to the destinated object.
+   * Objects must be the same type.
+   * \param theDestination initialized object (from any document) - target of copying
+   */
+  /*
+  void CopyTo( HYDROData_Entity theDestination ) const;
+  */
+
+protected:
+
+  /**
+   * Creates new object in the internal data structure. Use higher level objects 
+   * to create objects with real content.
+   */
+  HYDROData_Entity();
+
+  /**
+   * Destructs properties of the object and object itself, removes it from the document.
+   */
+  virtual ~HYDROData_Entity();
+  
+};
index b79f0f74dad1c4b50ce1861fb6130983b0383a18..860fcc753e42d78feb8728e116e2fab68d5b02d3 100644 (file)
 #include <HYDROData_Image.h>
 %End
 
-class HYDROData_Image : HYDROData_Object
+class HYDROData_Image : HYDROData_Entity
 {
 
 %ConvertToSubClassCode
-    if ( !Handle(HYDROData_Image)::DownCast( sipCpp ).IsNull() )
-      sipClass = sipClass_HYDROData_Image;
-    else
-      sipClass = NULL;
+    switch ( sipCpp->GetKind() )
+    {
+      case KIND_IMAGE:
+        sipClass = sipClass_HYDROData_Image;
+        break;
+
+      default:
+        // We don't recognise the type.
+        sipClass = NULL;
+    }
 %End
 
 %TypeHeaderCode
 #include <HYDROData_Image.h>
 %End
 
-public:
-
-  const ObjectKind           GetKind() const;
-
 public:      
 
   /**
@@ -104,14 +106,20 @@ public:
                                          QPointF& thePointBOut,
                                          QPointF& thePointCOut );
 
+  /**
+   * Returns the number of referenced images
+   * \return zero if there is no references
+   */
+  int                        NbReferences();
+
   /**
    * Appends reference to other image.
    * \param theReferenced the image referenced by this
    */
-  void AppendReference( HYDROData_Object theReferenced ) [void (Handle_HYDROData_Object)];
+  void AppendReference( HYDROData_Entity theReferenced ) [void (Handle_HYDROData_Entity)];
   %MethodCode
 
-    Handle(HYDROData_Object) aRefObj = createHandle( a0 );
+    Handle(HYDROData_Entity) aRefObj = createHandle( a0 );
     if ( !aRefObj.IsNull() )
     {
       Py_BEGIN_ALLOW_THREADS
@@ -122,21 +130,15 @@ public:
 
   %End
 
-  /**
-   * Returns the number of referenced images
-   * \return zero if there is no references
-   */
-  int                        NbReferences();
-
   /**
    * Returns reference by index.
    * \param theIndex number of reference [0; NbReference)
    * \returns the referenced image, or Null if index is invalid
    */
-  HYDROData_Object Reference( const int theIndex ) const [Handle_HYDROData_Object (const int)];
+  HYDROData_Entity Reference( const int theIndex ) const [Handle_HYDROData_Entity (const int)];
   %MethodCode
 
-    Handle(HYDROData_Object) aRefObj;
+    Handle(HYDROData_Entity) aRefObj;
     
     Py_BEGIN_ALLOW_THREADS
     aRefObj = sipSelfWasArg ? sipCpp->HYDROData_Image::Reference( a0 ) : 
@@ -153,10 +155,10 @@ public:
    * \param theIndex number of reference [0; NbReference]
    * \param theReferenced the image referenced by this
    */
-  void ChangeReference( const int theIndex, HYDROData_Object theReferenced ) [void (const int, Handle_HYDROData_Object)];
+  void ChangeReference( const int theIndex, HYDROData_Entity theReferenced ) [void (const int, Handle_HYDROData_Entity)];
   %MethodCode
 
-    Handle(HYDROData_Object) aRefObj = createHandle( a1 );
+    Handle(HYDROData_Entity) aRefObj = createHandle( a1 );
     if ( !aRefObj.IsNull() )
     {
       Py_BEGIN_ALLOW_THREADS
diff --git a/src/HYDROPy/HYDROData_ImmersibleZone.sip b/src/HYDROPy/HYDROData_ImmersibleZone.sip
new file mode 100644 (file)
index 0000000..5346eb3
--- /dev/null
@@ -0,0 +1,163 @@
+// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+%ExportedHeaderCode
+#include <HYDROData_ImmersibleZone.h>
+%End
+
+class HYDROData_ImmersibleZone : HYDROData_NaturalObject
+{
+
+%TypeHeaderCode
+#include <HYDROData_ImmersibleZone.h>
+%End
+
+%ConvertToSubClassCode
+    switch ( sipCpp->GetKind() )
+    {
+      case KIND_IMMERSIBLE_ZONE:
+        sipClass = sipClass_HYDROData_ImmersibleZone;
+        break;
+
+      default:
+        // We don't recognise the type.
+        sipClass = NULL;
+    }
+%End
+
+public:      
+
+  /**
+   * Sets filling color for zone.
+   */
+  void SetFillingColor( const QColor& theColor );
+
+  /**
+   * Returns filling color of zone.
+   */
+  QColor GetFillingColor() const;
+
+  /**
+   * Sets border color for zone.
+   */
+  void SetBorderColor( const QColor& theColor );
+
+  /**
+   * Returns border color of zone.
+   */
+  QColor GetBorderColor() const;
+
+  /**
+   * Sets reference polyline object for zone.
+   */
+  void SetPolyline( HYDROData_Polyline thePolyline ) [void (const Handle_HYDROData_Polyline&)];
+  %MethodCode
+
+    Handle(HYDROData_Polyline) aRefPolyline =
+      Handle(HYDROData_Polyline)::DownCast( createHandle( a0 ) );
+    if ( !aRefPolyline.IsNull() )
+    {
+      Py_BEGIN_ALLOW_THREADS
+      sipSelfWasArg ? sipCpp->HYDROData_ImmersibleZone::SetPolyline( aRefPolyline ) : 
+                      sipCpp->SetPolyline( aRefPolyline );
+      Py_END_ALLOW_THREADS
+    }
+
+  %End
+
+  /**
+   * Returns reference polyline object of zone.
+   */
+  HYDROData_Polyline GetPolyline() const [Handle_HYDROData_Polyline ()];
+  %MethodCode
+
+    Handle(HYDROData_Polyline) aRefPolyline;
+    
+    Py_BEGIN_ALLOW_THREADS
+    aRefPolyline = sipSelfWasArg ? sipCpp->HYDROData_ImmersibleZone::GetPolyline() : 
+                                   sipCpp->GetPolyline();
+    Py_END_ALLOW_THREADS
+    
+    sipRes = (HYDROData_Polyline*)createPointer( aRefPolyline );
+  
+  %End
+
+  /**
+   * Remove reference polyline object of zone.
+   */
+  void RemovePolyline();
+
+  /**
+   * Set reference bathymetry object for zone.
+   */
+  void SetBathymetry( HYDROData_Bathymetry theBathymetry ) [void (const Handle_HYDROData_Bathymetry&)];
+  %MethodCode
+
+    Handle(HYDROData_Bathymetry) aRefBath =
+      Handle(HYDROData_Bathymetry)::DownCast( createHandle( a0 ) );
+    if ( !aRefBath.IsNull() )
+    {
+      Py_BEGIN_ALLOW_THREADS
+      sipSelfWasArg ? sipCpp->HYDROData_ImmersibleZone::SetBathymetry( aRefBath ) : 
+                      sipCpp->SetBathymetry( aRefBath );
+      Py_END_ALLOW_THREADS
+    }
+
+  %End
+
+  /**
+   * Returns reference bathymetry object of zone.
+   */
+  HYDROData_Bathymetry GetBathymetry() const [Handle_HYDROData_Bathymetry ()];
+  %MethodCode
+
+    Handle(HYDROData_Bathymetry) aRefBath;
+    
+    Py_BEGIN_ALLOW_THREADS
+    aRefBath = sipSelfWasArg ? sipCpp->HYDROData_ImmersibleZone::GetBathymetry() : 
+                               sipCpp->GetBathymetry();
+    Py_END_ALLOW_THREADS
+    
+    sipRes = (HYDROData_Bathymetry*)createPointer( aRefBath );
+  
+  %End
+
+  /**
+   * Clear the bathymetry object for zone.
+   */
+  void RemoveBathymetry();
+
+protected:
+
+  /**
+   * Creates new object in the internal data structure. Use higher level objects 
+   * to create objects with real content.
+   */
+  HYDROData_ImmersibleZone();
+
+  /**
+   * Destructs properties of the object and object itself, removes it from the document.
+   */
+  ~HYDROData_ImmersibleZone();
+};
+
+
diff --git a/src/HYDROPy/HYDROData_NaturalObject.sip b/src/HYDROPy/HYDROData_NaturalObject.sip
new file mode 100644 (file)
index 0000000..d0ec930
--- /dev/null
@@ -0,0 +1,68 @@
+// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+
+%ExportedHeaderCode
+#include <HYDROData_NaturalObject.h>
+%End
+
+class HYDROData_NaturalObject : HYDROData_Object /Abstract/
+{
+%TypeHeaderCode
+#include <HYDROData_NaturalObject.h>
+%End
+
+%ConvertToSubClassCode
+    // HYDROData_NaturalObject sub-classes provide a unique kind ID.
+    switch ( sipCpp->GetKind() )
+    {
+      case KIND_IMMERSIBLE_ZONE:
+        sipClass = sipClass_HYDROData_ImmersibleZone;
+        break;
+
+      case KIND_UNKNOWN:
+        sipClass = sipClass_HYDROData_NaturalObject;
+        break;
+
+      default:
+        // We don't recognise the type.
+        sipClass = NULL;
+    }
+%End
+
+public:
+
+
+protected:
+
+  /**
+   * Creates new object in the internal data structure. Use higher level objects 
+   * to create objects with real content.
+   */
+  HYDROData_NaturalObject();
+
+  /**
+   * Destructs properties of the object and object itself, removes it from the document.
+   */
+  virtual ~HYDROData_NaturalObject();
+  
+};
index 1d67675dd6e7791121d7d116d5389df865f3105a..85322fc900db3498964b16e5f869a69db469cb51 100644 (file)
 #include <HYDROData_Object.h>
 %End
 
-typedef int ObjectKind;
-
-const ObjectKind KIND_UNKNOWN;
-const ObjectKind KIND_IMAGE;
-const ObjectKind KIND_POLYLINE;
-const ObjectKind KIND_VISUAL_STATE;
-const ObjectKind KIND_BATHYMETRY;
-const ObjectKind KIND_CALCULATION;
-const ObjectKind KIND_ZONE;
-const ObjectKind KIND_REGION;
-
-class HYDROData_Object
+class HYDROData_Object : HYDROData_Entity /Abstract/
 {
 %TypeHeaderCode
 #include <HYDROData_Object.h>
 %End
 
 %ConvertToSubClassCode
-    // HYDROData_Object sub-classes provide a unique kind ID.
-    switch ( sipCpp->GetKind() )
+    if ( !Handle(HYDROData_ArtificialObject)::DownCast( sipCpp ).IsNull() )
+      sipClass = sipClass_HYDROData_ArtificialObject;
+    else if ( !Handle(HYDROData_NaturalObject)::DownCast( sipCpp ).IsNull() )
+      sipClass = sipClass_HYDROData_NaturalObject;
+    else
     {
-      case KIND_IMAGE:
-        sipClass = sipClass_HYDROData_Image;
-        break;
-
-      case KIND_POLYLINE:
-        sipClass = sipClass_HYDROData_Polyline;
-        break;
-
-      case KIND_BATHYMETRY:
-        sipClass = sipClass_HYDROData_Bathymetry;
-        break;
-
-      case KIND_CALCULATION:
-        sipClass = sipClass_HYDROData_Calculation;
-        break;
-
-      case KIND_ZONE:
-        sipClass = sipClass_HYDROData_Zone;
-        break;
-
-      case KIND_REGION:
-        sipClass = sipClass_HYDROData_Region;
-        break;
-
-      case KIND_UNKNOWN:
-        sipClass = sipClass_HYDROData_Object;
-        break;
-
-      default:
-        // We don't recognise the type.
-        sipClass = NULL;
+      // HYDROData_Object sub-classes provide a unique kind ID.
+      switch ( sipCpp->GetKind() )
+      {
+        case KIND_POLYLINE:
+          sipClass = sipClass_HYDROData_Polyline;
+          break;
+
+        case KIND_UNKNOWN:
+          sipClass = sipClass_HYDROData_Object;
+          break;
+
+        default:
+          // We don't recognise the type.
+          sipClass = NULL;
+      }
     }
 %End
 
 public:
 
-  /**
-   * Returns the kind of this object. Must be redefined in all objects of known type.
-   */
-  const ObjectKind GetKind() const;
-
-  /**
-   * Returns the name of this object.
-   */
-  QString GetName() const;
-
-  /**
-   * Updates the name of this object.
-   */
-  void SetName(const QString& theName);
-
-  /**
-   * Updates object state.
-   * \param theIsForce force reupdating of data object
-   */
-  void Update(const bool theIsForce);
-
-  /**
-   * Checks is object exists in the data structure.
-   * \returns true is object is not exists in the data model
-   */
-  bool IsRemoved() const;
-
-  /**
-   * Removes object from the data structure.
-   */
-  void Remove();
-
-  /**
-   * Returns unique integer identifier of the object (may be used for ordering of objects)
-   */
-  int ID() const;
-
-  /**
-   * Copies all properties of this to the destinated object.
-   * Objects must be the same type.
-   * \param theDestination initialized object (from any document) - target of copying
-   */
-  /*
-  void CopyTo( HYDROData_Object theDestination ) const;
-  */
 
 protected:
 
index d0a8b1ce5a6a3c96025f35c7805dce5e77d58048..0798d97e8f5104f0e267a904945d92cc5b0c3cdb 100644 (file)
@@ -63,56 +63,69 @@ class HYDROData_Polyline : HYDROData_Object
 {
 
 %ConvertToSubClassCode
-    if ( !Handle(HYDROData_Polyline)::DownCast( sipCpp ).IsNull() )
-      sipClass = sipClass_HYDROData_Polyline;
-    else
-      sipClass = NULL;
+    switch ( sipCpp->GetKind() )
+    {
+      case KIND_POLYLINE:
+        sipClass = sipClass_HYDROData_Polyline;
+        break;
+
+      default:
+        // We don't recognise the type.
+        sipClass = NULL;
+    }
 %End
 
 public:
 
   typedef QList<PolylineSection> PolylineData;
 
-public:
-
-  const ObjectKind          GetKind() const;
-
 public:      
 
   /**
    * Replace current polyline data by new sections list
    * \param theSections the sections list
    */
-  void setPolylineData( const PolylineData& theSections );
+  void SetPolylineData( const PolylineData& theSections );
 
   /**
    * Return polyline data
    * \return polyline section list
    */
-  PolylineData getPolylineData();
+  PolylineData GetPolylineData();
    
   /**
    * Return polyline dimension
    * \return polyline dimension (2 or 3)
    */
-  int getDimension() const;
+  int GetDimension() const;
 
   /**
    * Set polyline dimension (2 or 3)
    * \param theDimension the polyline dimension
    */
-  void setDimension( int theDimension );
+  void SetDimension( int theDimension );
 
   /**
    * Remove all sections from polyline
    */
-  void removeAll();
+  void RemoveAll();
 
 
   /**
    * Returns the painter path. The painter path is construct by lines
    */
-  QPainterPath painterPath();
+  QPainterPath GetPainterPath();
+
+
+  /**
+   * Sets the z value for polyline.
+   */
+  void SetZValue( const double theZValue );
+  
+  /**
+   * Returns the z value for polyline.
+   */
+  double ZValue() const;
 
 protected:
 
index 3199acc2e8fa46f1861e406fe646c7553d2180c5..8c2017cbb81fbaa1ab820114dbf8125a15a81d17 100644 (file)
@@ -24,7 +24,7 @@
 #include <HYDROData_Region.h>
 %End
 
-class HYDROData_Region : HYDROData_Domain
+class HYDROData_Region : HYDROData_Entity
 {
 
 %TypeHeaderCode
@@ -32,15 +32,160 @@ class HYDROData_Region : HYDROData_Domain
 %End
 
 %ConvertToSubClassCode
-    if ( !Handle(HYDROData_Region)::DownCast( sipCpp ).IsNull() )
-      sipClass = sipClass_HYDROData_Region;
-    else
-      sipClass = NULL;
+    switch ( sipCpp->GetKind() )
+    {
+      case KIND_REGION:
+        sipClass = sipClass_HYDROData_Region;
+        break;
+
+      default:
+        // We don't recognise the type.
+        sipClass = NULL;
+    }
 %End
 
-public:
+public:      
+
+  /**
+   * Create new one reference zone for region on child label.
+   * The new zone is not added into the list of reference zones.
+   */
+  HYDROData_Zone AddNewZone() [Handle_HYDROData_Zone ()];
+  %MethodCode
+
+    Handle(HYDROData_Zone) aNewZone;
+    
+    Py_BEGIN_ALLOW_THREADS
+    aNewZone = sipSelfWasArg ? sipCpp->HYDROData_Region::AddNewZone() : 
+                               sipCpp->AddNewZone();
+    Py_END_ALLOW_THREADS
+    
+    sipRes = (HYDROData_Zone*)createPointer( aNewZone );
+
+  %End
+
+  /**
+   * Removes all child zones from region.
+   */
+  void RemoveChildZones();
+
+
+  /**
+   * Returns number of reference zones of region.
+   */
+  int NbZones() const;
+
+  /**
+   * Add new one reference zone for region.
+   */
+  void AddZone( HYDROData_Zone theZone ) [void (const Handle_HYDROData_Zone&)];
+  %MethodCode
+
+    Handle(HYDROData_Zone) aZone =
+      Handle(HYDROData_Zone)::DownCast( createHandle( a0 ) );
+    if ( !aZone.IsNull() )
+    {
+      Py_BEGIN_ALLOW_THREADS
+      sipSelfWasArg ? sipCpp->HYDROData_Region::AddZone( aZone ) : 
+                      sipCpp->AddZone( aZone );
+      Py_END_ALLOW_THREADS
+    }
+
+  %End
+
+  /**
+   * Replace the reference zone for region.
+   */
+  void SetZone( const int      theIndex, 
+                HYDROData_Zone theZone ) [void (const int, const Handle_HYDROData_Zone&)];
+  %MethodCode
+
+    Handle(HYDROData_Zone) aZone =
+      Handle(HYDROData_Zone)::DownCast( createHandle( a1 ) );
+    if ( !aZone.IsNull() )
+    {
+      Py_BEGIN_ALLOW_THREADS
+      sipSelfWasArg ? sipCpp->HYDROData_Region::SetZone( a0, aZone ) : 
+                      sipCpp->SetZone( a0, aZone );
+      Py_END_ALLOW_THREADS
+    }
+
+  %End
+
+  /**
+   * Inserts the reference zone for region before given index.
+   */
+  void InsertZone( const int      theBeforeIndex, 
+                   HYDROData_Zone theZone ) [void (const int, const Handle_HYDROData_Zone&)];
+  %MethodCode
+
+    Handle(HYDROData_Zone) aZone =
+      Handle(HYDROData_Zone)::DownCast( createHandle( a1 ) );
+    if ( !aZone.IsNull() )
+    {
+      Py_BEGIN_ALLOW_THREADS
+      sipSelfWasArg ? sipCpp->HYDROData_Region::InsertZone( a0, aZone ) : 
+                      sipCpp->InsertZone( a0, aZone );
+      Py_END_ALLOW_THREADS
+    }
+
+  %End
+
+  /**
+   * Sets reference zones for calculation region.
+   */
+  //void SetZones( const HYDROData_SequenceOfObjects& theZones );
+
+  /**
+   * Returns reference zone of region by index.
+   */
+  HYDROData_Zone GetZone( const int theIndex ) const [Handle_HYDROData_Zone (const int)];
+  %MethodCode
+
+    Handle(HYDROData_Zone) aRefZone;
+    
+    Py_BEGIN_ALLOW_THREADS
+    aRefZone = sipSelfWasArg ? sipCpp->HYDROData_Region::GetZone( a0 ) : 
+                               sipCpp->GetZone( a0 );
+    Py_END_ALLOW_THREADS
+    
+    sipRes = (HYDROData_Zone*)createPointer( aRefZone );
+  
+  %End
+
+  /**
+   * Returns all reference zone of region.
+   */
+  //void HYDROData_SequenceOfObjects GetZones() const;
+
+  /**
+   * Removes reference zone from region.
+   */
+  void RemoveZone( HYDROData_Zone theZone ) const [void (const Handle_HYDROData_Zone&)];
+  %MethodCode
+
+    Handle(HYDROData_Zone) aZone =
+      Handle(HYDROData_Zone)::DownCast( createHandle( a0 ) );
+    if ( !aZone.IsNull() )
+    {
+      Py_BEGIN_ALLOW_THREADS
+      sipSelfWasArg ? sipCpp->HYDROData_Region::RemoveZone( aZone ) : 
+                      sipCpp->RemoveZone( aZone );
+      Py_END_ALLOW_THREADS
+    }
+
+  %End
+
+  /**
+   * Removes reference zone from region by it index.
+   */
+  void RemoveZone( const int theIndex );
+
+  /**
+   * Removes all reference zones from region.
+   */
+  void RemoveZones();
 
-  const ObjectKind          GetKind() const;
 
 protected:
 
index c7c4bb7e7818cd75367ec5a300b96de705bc26ee..e70baae0e675e3027ea0f6e301355abc9089e74b 100644 (file)
@@ -24,7 +24,7 @@
 #include <HYDROData_Zone.h>
 %End
 
-class HYDROData_Zone : HYDROData_Domain
+class HYDROData_Zone : HYDROData_Entity
 {
 
 %TypeHeaderCode
@@ -32,62 +32,93 @@ class HYDROData_Zone : HYDROData_Domain
 %End
 
 %ConvertToSubClassCode
-    if ( !Handle(HYDROData_Zone)::DownCast( sipCpp ).IsNull() )
-      sipClass = sipClass_HYDROData_Zone;
-    else
-      sipClass = NULL;
+    switch ( sipCpp->GetKind() )
+    {
+      case KIND_ZONE:
+        sipClass = sipClass_HYDROData_Zone;
+        break;
+
+      default:
+        // We don't recognise the type.
+        sipClass = NULL;
+    }
 %End
 
-public:
+public:      
 
-  const ObjectKind          GetKind() const;
+  /**
+   * Returns number of geometry objects for zone.
+   */
+  int NbGeometryObjects() const;
 
-public:      
+  /**
+   * dd new one geometry object for zone.
+   */
+  void AddGeometryObject( HYDROData_Object theRegion ) [void (const Handle_HYDROData_Object&)];
+  %MethodCode
+
+    Handle(HYDROData_Object) aGeomObj =
+      Handle(HYDROData_Object)::DownCast( createHandle( a0 ) );
+    if ( !aGeomObj.IsNull() )
+    {
+      Py_BEGIN_ALLOW_THREADS
+      sipSelfWasArg ? sipCpp->HYDROData_Zone::AddGeometryObject( aGeomObj ) : 
+                      sipCpp->AddGeometryObject( aGeomObj );
+      Py_END_ALLOW_THREADS
+    }
+
+  %End
 
   /**
-   * Sets reference polyline object for zone.
+   * Replace the geometry object for zone.
    */
-  void SetPolyline( HYDROData_Polyline thePolyline ) [void (const Handle_HYDROData_Polyline&)];
+  void SetGeometryObject( const int        theIndex, 
+                          HYDROData_Object theObject ) [void (const int, const Handle_HYDROData_Object&)];
   %MethodCode
 
-    Handle(HYDROData_Polyline) aRefPolyline =
-      Handle(HYDROData_Polyline)::DownCast( createHandle( a0 ) );
-    if ( !aRefPolyline.IsNull() )
+    Handle(HYDROData_Object) aGeomObj =
+      Handle(HYDROData_Object)::DownCast( createHandle( a1 ) );
+    if ( !aGeomObj.IsNull() )
     {
       Py_BEGIN_ALLOW_THREADS
-      sipSelfWasArg ? sipCpp->HYDROData_Zone::SetPolyline( aRefPolyline ) : 
-                      sipCpp->SetPolyline( aRefPolyline );
+      sipSelfWasArg ? sipCpp->HYDROData_Zone::SetGeometryObject( a0, aGeomObj ) : 
+                      sipCpp->SetGeometryObject( a0, aGeomObj );
       Py_END_ALLOW_THREADS
     }
 
   %End
 
   /**
-   * Returns reference polyline object of zone.
+   * Sets the geometry object for zone.
+   */
+  //void SetGeometryObjects( const HYDROData_SequenceOfObjects& theObjects );
+
+  /**
+   * Returns geometry object of zone by index.
    */
-  HYDROData_Polyline GetPolyline() const [Handle_HYDROData_Polyline ()];
+  HYDROData_Object GetGeometryObject( const int theIndex ) const [Handle_HYDROData_Object (const int)];
   %MethodCode
 
-    Handle(HYDROData_Polyline) aRefPolyline;
+    Handle(HYDROData_Object) aGeomObj;
     
     Py_BEGIN_ALLOW_THREADS
-    aRefPolyline = sipSelfWasArg ? sipCpp->HYDROData_Zone::GetPolyline() : 
-                                   sipCpp->GetPolyline();
+    aGeomObj = sipSelfWasArg ? sipCpp->HYDROData_Zone::GetGeometryObject( a0 ) : 
+                               sipCpp->GetGeometryObject( a0 );
     Py_END_ALLOW_THREADS
     
-    sipRes = (HYDROData_Polyline*)createPointer( aRefPolyline );
+    sipRes = (HYDROData_Object*)createPointer( aGeomObj );
   
   %End
 
   /**
-   * Remove reference polyline object of zone.
+   * Returns all geometry objects of zone.
    */
-  void RemovePolyline();
+  //HYDROData_SequenceOfObjects GetGeometryObjects() const;
 
   /**
-   * Returns the painter path. The painter path is construct by polyline
+   * Removes all geometry objects from zone.
    */
-  QPainterPath GetPainterPath() const;
+  void RemoveGeometryObjects();
 
 protected:
 
index bb69aa65aed2ce2216257cf38231668b0a34145b..e2282ee6ed4d04b30b6c9a47a46524f483f2e5bd 100644 (file)
                                RelativePath=".\HYDROData.sip"
                                >
                        </File>
+                       <File
+                               RelativePath=".\HYDROData_ArtificialObject.sip"
+                               >
+                       </File>
                        <File
                                RelativePath=".\HYDROData_Bathymetry.sip"
                                >
                                >
                        </File>
                        <File
-                               RelativePath=".\HYDROData_Domain.sip"
+                               RelativePath=".\HYDROData_Entity.sip"
                                >
                        </File>
                        <File
                                RelativePath=".\HYDROData_Image.sip"
                                >
                        </File>
+                       <File
+                               RelativePath=".\HYDROData_ImmersibleZone.sip"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\HYDROData_NaturalObject.sip"
+                               >
+                       </File>
                        <File
                                RelativePath=".\HYDROData_Object.sip"
                                >