Salome HOME
Comments moved.
[modules/hydro.git] / src / HYDROData / HYDROData_IPolyline.cxx
index 20fe2099ea3e0d96f04f8cf927a3ac8707ecde4b..73675538bb3a92c17c3f2ffe59b4bfe31d698b43 100755 (executable)
@@ -3,8 +3,18 @@
 
 #include <gp_XY.hxx>
 
+#include <TDataStd_BooleanList.hxx>
+#include <TDataStd_ExtStringList.hxx>
+#include <TDataStd_IntegerList.hxx>
 #include <TDataStd_RealList.hxx>
 
+#include <TopoDS_Shape.hxx>
+
+#include <TNaming_Builder.hxx>
+#include <TNaming_NamedShape.hxx>
+
+#include <QColor>
+
 IMPLEMENT_STANDARD_HANDLE(HYDROData_IPolyline, HYDROData_Entity)
 IMPLEMENT_STANDARD_RTTIEXT(HYDROData_IPolyline, HYDROData_Entity)
 
@@ -17,11 +27,81 @@ HYDROData_IPolyline::~HYDROData_IPolyline()
 {
 }
 
+void HYDROData_IPolyline::SetWireColor( const QColor& theColor )
+{
+  SetColor( theColor, DataTag_WireColor );
+}
+
+QColor HYDROData_IPolyline::GetWireColor() const
+{
+  return GetColor( DefaultWireColor(), DataTag_WireColor );
+}
+
+QColor HYDROData_IPolyline::DefaultWireColor()
+{
+  return QColor( Qt::black );
+}
+
 int HYDROData_IPolyline::NbPoints( const int theSectionIndex ) const
 {
   return GetPoints( theSectionIndex ).Length();
 }
 
+TopoDS_Shape HYDROData_IPolyline::getPolylineShape() const
+{
+  TDF_Label aShapeLabel = myLab.FindChild( DataTag_PolylineShape, false );
+  if ( !aShapeLabel.IsNull() )
+  {
+    Handle(TNaming_NamedShape) aNamedShape;
+    if ( aShapeLabel.FindAttribute( TNaming_NamedShape::GetID(), aNamedShape ) )
+      return aNamedShape->Get();
+  }
+  return TopoDS_Shape();
+}
+
+void HYDROData_IPolyline::setPolylineShape( const TopoDS_Shape& theShape )
+{
+  TNaming_Builder aBuilder( myLab.FindChild( DataTag_PolylineShape ) );
+  aBuilder.Generated( theShape );
+}
+
+void HYDROData_IPolyline::removePolylineShape()
+{
+  TDF_Label aShapeLabel = myLab.FindChild( DataTag_PolylineShape, false );
+  if ( !aShapeLabel.IsNull() )
+    aShapeLabel.ForgetAllAttributes();
+}
+
+void HYDROData_IPolyline::getSectionsLists( Handle(TDataStd_ExtStringList)& theNamesList,
+                                            Handle(TDataStd_IntegerList)&   theTypesList,
+                                            Handle(TDataStd_BooleanList)&   theClosuresList,
+                                            const bool                      theIsCreate ) const
+{
+  theNamesList.Nullify();
+  theTypesList.Nullify();
+  theClosuresList.Nullify();
+
+  TDF_Label aSectLabel = myLab.FindChild( DataTag_Sections, theIsCreate );
+  if ( aSectLabel.IsNull() )
+    return;
+
+  if ( !aSectLabel.FindAttribute( TDataStd_ExtStringList::GetID(), theNamesList ) && theIsCreate )
+    theNamesList = TDataStd_ExtStringList::Set( aSectLabel );
+
+  if ( !aSectLabel.FindAttribute( TDataStd_IntegerList::GetID(), theTypesList ) && theIsCreate )
+    theTypesList = TDataStd_IntegerList::Set( aSectLabel );
+
+  if ( !aSectLabel.FindAttribute( TDataStd_BooleanList::GetID(), theClosuresList ) && theIsCreate )
+    theClosuresList = TDataStd_BooleanList::Set( aSectLabel );
+}
+
+void HYDROData_IPolyline::removeSectionsLists()
+{
+  TDF_Label aSectsLabel = myLab.FindChild( DataTag_Sections, false );
+  if ( !aSectsLabel.IsNull() )
+    aSectsLabel.ForgetAllAttributes();
+}
+
 void HYDROData_IPolyline::getPointsLists( const int                  theSectionIndex,
                                           Handle(TDataStd_RealList)& theListX,
                                           Handle(TDataStd_RealList)& theListY,
@@ -59,7 +139,14 @@ void HYDROData_IPolyline::removePointsLists( const int theSectionIndex ) const
   if ( aLabel.IsNull() )
     return;
 
-  TDF_Label aSectLabel = aLabel.FindChild( theSectionIndex, false );
-  if ( !aSectLabel.IsNull() )
-    aSectLabel.ForgetAllAttributes();
+  if ( theSectionIndex < 0 )
+  {
+    aLabel.ForgetAllAttributes();
+  }
+  else
+  {
+    TDF_Label aSectLabel = aLabel.FindChild( theSectionIndex, false );
+    if ( !aSectLabel.IsNull() )
+      aSectLabel.ForgetAllAttributes();
+  }
 }