Salome HOME
lot 10 - warnings for DTM - untested
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_CurveCreatorProfile.cxx
index ee8e3f990bb23e7dec1aac7e51c4bfe4650c939d..88d6f7c75746b0d82bb8879254b3b9f02fecd1b3 100644 (file)
@@ -1,8 +1,4 @@
-// Copyright (C) 2007-2015  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
-//
+// Copyright (C) 2014-2015  EDF-R&D
 // 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
 #include <HYDROGUI_CurveCreatorProfile.h>
 #include <CurveCreator_Displayer.hxx>
 #include <CurveCreator_Section.hxx>
+#include <QVector>
+#include <TopoDS_Shape.hxx>
+#include <CurveCreator_Utils.hxx>
+#include <AIS_Shape.hxx>
+#include <Prs3d_PointAspect.hxx>
 
 HYDROGUI_CurveCreatorProfile::HYDROGUI_CurveCreatorProfile()
 : CurveCreator_Curve( CurveCreator::Dim2d )
@@ -31,8 +32,10 @@ HYDROGUI_CurveCreatorProfile::HYDROGUI_CurveCreatorProfile()
   aSection->myName     = getUniqSectionName();
   aSection->myType     = CurveCreator::Polyline;
   aSection->myIsClosed = false;
+  myCurveColor = Quantity_NOC_RED;
 
   mySections.push_back( aSection );
+  mySkipSorting = true;
 }
 
 HYDROGUI_CurveCreatorProfile::~HYDROGUI_CurveCreatorProfile()
@@ -58,7 +61,7 @@ bool HYDROGUI_CurveCreatorProfile::clearInternal()
     myDisplayer->eraseAll( true );
 
   // Delete all allocated data.
-  CurveCreator_Section* aSection = getSection( 0 );
+  CurveCreator_Section* aSection = (CurveCreator_Section*)getSection( 0 );
   if ( aSection )
     aSection->myPoints.clear();
 
@@ -122,7 +125,7 @@ bool HYDROGUI_CurveCreatorProfile::addPointsInternal( const CurveCreator::Sectio
 {
   bool res = false;
 
-  CurveCreator_Section* aSection = getSection( 0 );
+  CurveCreator_Section* aSection = (CurveCreator_Section*)getSection( 0 );
   if( !aSection )
     return res;
 
@@ -181,7 +184,7 @@ bool HYDROGUI_CurveCreatorProfile::addPointsInternal( const CurveCreator::Sectio
   }
 
   if ( res )
-    redisplayCurve();
+    redisplayCurve(false);
 
   return res;
 }
@@ -196,7 +199,7 @@ bool HYDROGUI_CurveCreatorProfile::setPointInternal( const CurveCreator::Section
   }
 
   int anISection = 0;
-  CurveCreator_Section* aSection = getSection( anISection );
+  CurveCreator_Section* aSection = (CurveCreator_Section*)getSection( anISection );
   if( !aSection )
     return aRes;
 
@@ -212,7 +215,7 @@ bool HYDROGUI_CurveCreatorProfile::setPointInternal( const CurveCreator::Section
 
   aRes = addPointsInternal( theSectionsMap );
   if ( aRes )
-    redisplayCurve();
+    redisplayCurve(false);
 
   return aRes;
 }
@@ -233,7 +236,7 @@ void HYDROGUI_CurveCreatorProfile::convert( const CurveCreator::PosPointsList& t
 
 bool HYDROGUI_CurveCreatorProfile::canPointsBeSorted()
 {
-  return true;
+  return false;
 }
 
 /**
@@ -263,3 +266,41 @@ bool HYDROGUI_CurveCreatorProfile::addPoints( const CurveCreator::Coordinates& t
   
   return CurveCreator_Curve::addPoints( theCoords, theISection, anIPnt );
 }
+
+bool ULess( const gp_Pnt& p1, const gp_Pnt& p2 )
+{
+  return p1.X() < p2.X();
+}
+
+Handle(TColgp_HArray1OfPnt) HYDROGUI_CurveCreatorProfile::GetDifferentPoints( int theISection ) const
+{
+  Handle(TColgp_HArray1OfPnt) points = CurveCreator_Curve::GetDifferentPoints( theISection );
+  if( points.IsNull() )
+    return points;
+
+  QVector<gp_Pnt> vpoints( points->Size() );
+  for( int i=points->Lower(), j=0, n=points->Upper(); i<=n; i++, j++ )
+    vpoints[j] = points->Value( i );
+
+  qSort( vpoints.begin(), vpoints.end(), ULess );
+
+  for( int i=points->Lower(), j=0, n=points->Upper(); i<=n; i++, j++ )
+    points->SetValue( i, vpoints[j] );
+
+  return points;
+}
+/*
+void HYDROGUI_CurveCreatorProfile::constructAISObject()
+{
+  TopoDS_Shape aShape;
+  CurveCreator_Utils::constructShape( this, aShape );
+  myAISShape = new AIS_Shape( aShape );  
+  myAISShape->SetColor( myCurveColor );
+  myAISShape->SetWidth( myLineWidth );
+  Handle(Prs3d_PointAspect) anAspect = myAISShape->Attributes()->PointAspect();
+  anAspect->SetScale( 3.0 );
+  anAspect->SetTypeOfMarker(Aspect_TOM_O_POINT);
+  anAspect->SetColor(myPointAspectColor);
+  myAISShape->Attributes()->SetPointAspect( anAspect );
+}*/
+