Salome HOME
Drawing of zones in OCC view improved.
[modules/hydro.git] / src / HYDROData / HYDROData_Polyline.cxx
index 7db4062a086416dfdf5294cb1da2fc97f127bfbe..fb723700621300e61e47ae44f4acbaadfd280279 100755 (executable)
@@ -1,6 +1,8 @@
 #include <HYDROData_Polyline.h>
 #include <HYDROData_Iterator.h>
 
+#include <ImageComposer_MetaTypes.h>
+
 #include <TDataStd_Name.hxx>
 #include <TDataStd_Integer.hxx>
 #include <TDataStd_ByteArray.hxx>
 #include <TDataStd_UAttribute.hxx>
 #include <TDF_ListIteratorOfLabelList.hxx>
 
-#include <QPainterPath>
 #include <QStringList>
 
 // tage of the child of my label that contains information about the operator
 static const Standard_GUID GUID_MUST_BE_UPDATED("6647e1f7-1971-4c5a-86c7-11ff0291452d");
 
-#define PYTHON_POLYLINE_ID "2"
+#define PYTHON_POLYLINE_ID "KIND_POLYLINE"
 
 IMPLEMENT_STANDARD_HANDLE(HYDROData_Polyline, HYDROData_Object)
 IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Polyline, HYDROData_Object)
@@ -104,6 +105,16 @@ QStringList HYDROData_Polyline::DumpToPython( MapOfTreatedObjects& theTreatedObj
   return aResList;
 }
 
+QVariant HYDROData_Polyline::GetDataVariant()
+{
+  QPainterPath aPath = painterPath();
+
+  QVariant aVarData;
+  aVarData.setValue<QPainterPath>( aPath );
+  
+  return aVarData;
+}
+
 /**
  * Return polyline dimension
  * \return polyline dimension. 2 or 3 is valid. 0 is invalid.
@@ -251,6 +262,28 @@ HYDROData_Polyline::PolylineData HYDROData_Polyline::getPolylineData() const
   return aRes;
 }
 
+/**
+ * Returns true if polyline is closed
+ */
+bool HYDROData_Polyline::isClosed() const
+{
+  int aDim = getDimension();
+  PolylineData aPolylineData = getPolylineData();
+
+  if ( aDim == 0 || aPolylineData.isEmpty() )
+    return false;
+
+  PolylineData::const_iterator anIt = aPolylineData.constBegin();
+  for ( ; anIt != aPolylineData.constEnd(); ++anIt )
+  {
+    const PolylineSection& aSection = *anIt;
+    if ( !aSection.myIsClosed )
+      return false;
+  }
+
+  return true;
+}
+
 /**
  * Remove all polyline attributes except dimension.
  */
@@ -275,7 +308,7 @@ void HYDROData_Polyline::removeAll()
  * is ignored section type.
  * \return polyline painter path.
  */
-QPainterPath HYDROData_Polyline::painterPath()
+QPainterPath HYDROData_Polyline::painterPath() const
 {
   QPainterPath aPath;
   int aDim = getDimension();