]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
HYDRO / refs #1334
authorisn <isn@opencascade.com>
Wed, 18 Oct 2017 17:24:10 +0000 (20:24 +0300)
committerisn <isn@opencascade.com>
Mon, 30 Oct 2017 18:59:08 +0000 (21:59 +0300)
src/CurveCreator/CurveCreator_Curve.cxx
src/CurveCreator/CurveCreator_Curve.hxx
src/CurveCreator/CurveCreator_Displayer.cxx
src/CurveCreator/CurveCreator_Displayer.hxx

index fb85db9d86b1594a961b19ca3f6bea5294481bd1..a2add5ddbb423249ac56a6c1e618893d54526341 100644 (file)
@@ -56,7 +56,10 @@ CurveCreator_Curve::CurveCreator_Curve( const CurveCreator::Dimension theDimensi
   myNbRedos   (0),
   myUndoDepth (-1),
   myOpLevel(0),
-  mySkipSorting(false)
+  mySkipSorting(false),
+  myPointAspectColor (Quantity_NOC_ROYALBLUE4), 
+  myCurveColor (Quantity_NOC_RED),
+  myLineWidth(1)
 {
 }
 
@@ -249,13 +252,16 @@ void CurveCreator_Curve::getCoordinates( int theISection, int theIPoint, double&
   }
 }
 
-void CurveCreator_Curve::redisplayCurve()
+void CurveCreator_Curve::redisplayCurve(bool preEraseAllObjects)
 {
   //DEBTRACE("redisplayCurve");
-  if( myDisplayer ) {
-    myDisplayer->eraseAll( false );
+  if( myDisplayer ) 
+  {
+    if (preEraseAllObjects)
+      myDisplayer->eraseAll( false );
+    else
+      myDisplayer->erase( myAISShape, false);
     myAISShape = NULL;
-
     myDisplayer->display( getAISObject( true ), true );
   }
 }
@@ -422,7 +428,7 @@ bool CurveCreator_Curve::joinInternal( const std::list<int>& theSections )
       break;
   }
 
-  redisplayCurve();
+  redisplayCurve(false);
   return res;
 }
 
@@ -465,7 +471,7 @@ int CurveCreator_Curve::addSectionInternal
   aSection->myIsClosed = theIsClosed;
   aSection->myPoints   = thePoints;
   mySections.push_back(aSection);
-  redisplayCurve();
+  redisplayCurve(false);
   return mySections.size()-1;
 }
 
@@ -525,7 +531,7 @@ bool CurveCreator_Curve::removeSectionInternal( const int theISection )
     delete *anIterRm;
     mySections.erase(anIterRm);
   }
-  redisplayCurve();
+  redisplayCurve(false);
   return true;
 }
   
@@ -616,14 +622,14 @@ bool CurveCreator_Curve::setClosedInternal( const int theISection,
       aSection = (CurveCreator_Section*)getSection( i );
       if( aSection ) {
         aSection->myIsClosed = theIsClosed;
-        redisplayCurve();
+        redisplayCurve(false);
       }
     }
   } else {
     aSection = (CurveCreator_Section*)getSection( theISection );
     if ( aSection ) {
       aSection->myIsClosed = theIsClosed;
-      redisplayCurve();
+      redisplayCurve(false);
     }
   }
   return true;
@@ -706,12 +712,12 @@ bool CurveCreator_Curve::setSectionTypeInternal( const int theISection,
       if ( aSection )
         aSection->myType = theType;
     }
-    redisplayCurve();
+    redisplayCurve(false);
   } else {
     aSection = (CurveCreator_Section*)getSection( theISection );
     if ( aSection && aSection->myType != theType ){
       aSection->myType = theType;
-      redisplayCurve();
+      redisplayCurve(false);
     }
   }
   return true;
@@ -772,7 +778,7 @@ bool CurveCreator_Curve::addPointsInternal( const CurveCreator::SectionsMap &the
     }
   }
   if(res)
-    redisplayCurve();
+    redisplayCurve(false);
   return res;
 }
 
@@ -830,7 +836,7 @@ bool CurveCreator_Curve::setPointInternal( const CurveCreator::SectionsMap &theS
     }
   }
   if(res)
-    redisplayCurve();
+    redisplayCurve(false);
   
   return res;
 }
@@ -914,7 +920,7 @@ bool CurveCreator_Curve::removePointsInternal( const SectionToPointList &thePoin
     aRes = removeSectionPoints(aSectionId, anIt->second);
   }
   if( aRes)
-    redisplayCurve();
+    redisplayCurve(false);
 
   return aRes;
 }
@@ -989,20 +995,21 @@ void CurveCreator_Curve::constructAISObject()
   //DEBTRACE("constructAISObject");
   TopoDS_Shape aShape;
   CurveCreator_Utils::constructShape( this, aShape );
-
-  myAISShape = new AIS_Shape( 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(Quantity_NOC_ROYALBLUE4);
+  anAspect->SetColor(myPointAspectColor);
   myAISShape->Attributes()->SetPointAspect( anAspect );
-
 }
 
 Handle(AIS_InteractiveObject) CurveCreator_Curve::getAISObject( const bool theNeedToBuild ) const
 {
   //DEBTRACE("getAISObject");
-  if ( !myAISShape && theNeedToBuild ) {
+  if ( !myAISShape && theNeedToBuild ) 
+  {
     CurveCreator_Curve* aCurve = (CurveCreator_Curve*)this;
     aCurve->constructAISObject();
   }
index 5763d1fff57e7520af938da14d6995aef934d3be..7a4cbb9ec537e47c62e7e495ac74b63bdc3b6b51 100644 (file)
@@ -36,6 +36,7 @@ struct CurveCreator_Section;
 class CurveCreator_Displayer;
 class AIS_Shape;
 class AIS_InteractiveObject;
+class Quantity_Color;
 
 /**
  *  The CurveCreator_Curve object is represented as one or more sets of
@@ -108,7 +109,7 @@ protected:
 public: // TODO: remove public
   void getCoordinates( int theISection, int theIPoint, double& theX, double& theY, double& theZ ) const;
 protected:  // TODO: remove public
-  void redisplayCurve();
+  void redisplayCurve(bool preEraseAllObjects = true);
 
 public:
   /************   Implementation of INTERFACE methods   ************/
@@ -294,7 +295,7 @@ public:
   /**
    *  Get the curve AIS object
    */
-  virtual Handle(AIS_InteractiveObject) getAISObject( const bool theNeedToBuild = false ) const;
+  virtual Handle(AIS_InteractiveObject) getAISObject( const bool theNeedToBuild = false) const;
 
 protected:
   /**
@@ -324,6 +325,9 @@ public:
   CurveCreator::Sections          mySections;   //!< curve data
   CurveCreator::Dimension         myDimension;  //!< curve dimension
   CurveCreator_Displayer*         myDisplayer;  //!< curve displayer
+  Quantity_Color myPointAspectColor;
+  Quantity_Color myCurveColor;
+  double myLineWidth;
 
 private:
 
index 61285c96297437177147d53022a4c678289b6580..4ac2e0450c8cd90950c71da118acfb8c75eefd30 100644 (file)
@@ -54,14 +54,22 @@ void CurveCreator_Displayer::eraseAll( bool isUpdate )
 {
   if(myObjects.empty())
     return;
-  for( int i = 0 ; i < myObjects.size() ; i++ ){
+  for( int i = 0 ; i < myObjects.size() ; i++ )
     myContext->Erase(myObjects[i], Standard_False);
-  }
   myObjects.clear();
   if( isUpdate )
     myContext->UpdateCurrentViewer();
 }
 
+void CurveCreator_Displayer::erase( const Handle(AIS_InteractiveObject)& theObject, bool isUpdate )
+{
+  if(theObject.IsNull())
+    return;
+  myContext->Erase(theObject, Standard_False);
+  if( isUpdate )
+    myContext->UpdateCurrentViewer();
+}
+
 Quantity_Color CurveCreator_Displayer::getActiveColor( bool isHL )
 {
   if( isHL ){
@@ -70,6 +78,13 @@ Quantity_Color CurveCreator_Displayer::getActiveColor( bool isHL )
   return Quantity_Color( 0., 1., 0., Quantity_TOC_RGB );
 }
 
+void CurveCreator_Displayer::Update()
+{
+  for( int i = 0 ; i < myObjects.size() ; i++ )
+    myContext->Update(myObjects[i], Standard_True);
+  myContext->UpdateCurrentViewer();
+}
+
 /*void CurveCreator_Displayer::highlight( const AISObjectsList& theObjects, bool isHL )
 {
   return;
index d78b2a2f26d7fe5779638795b75da3613dea39e4..9528c8616240cd2d70f322dd92c1f024b9d891ae 100644 (file)
@@ -38,6 +38,8 @@ public:
 
   void display( const Handle(AIS_InteractiveObject)& theObject, bool isUpdate );
   void eraseAll( bool isUpdate );
+  void erase( const Handle(AIS_InteractiveObject)& theObject, bool isUpdate );
+  void Update();
   //void highlight( const AISObjectsList& theObjects, bool isHL );
 
 protected: