]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
Bug #167 - Crash in polyline dialog
authornds <nds@opencascade.com>
Wed, 4 Dec 2013 18:12:30 +0000 (18:12 +0000)
committernds <nds@opencascade.com>
Wed, 4 Dec 2013 18:12:30 +0000 (18:12 +0000)
src/HYDROCurveCreator/CurveCreator_Curve.cxx
src/HYDROCurveCreator/CurveCreator_Curve.hxx
src/HYDROCurveCreator/CurveCreator_Displayer.cxx
src/HYDROCurveCreator/CurveCreator_Displayer.h
src/HYDROCurveCreator/CurveCreator_ICurve.hxx
src/HYDROCurveCreator/CurveCreator_Profile.cxx
src/HYDROCurveCreator/CurveCreator_UtilsICurve.hxx
src/HYDROCurveCreator/CurveCreator_Widget.cxx
src/HYDROGUI/HYDROGUI_PolylineOp.cxx
src/HYDROGUI/HYDROGUI_ProfileOp.cxx

index 1ce68e6c1fef900fa5998c6527b09f0e19c042ac..3f88a8b2bddda6622673f0070e50d193fa438794 100644 (file)
@@ -29,6 +29,7 @@
 #include "CurveCreator_Utils.h"
 
 #include <AIS_Shape.hxx>
+#include <AIS_InteractiveObject.hxx>
 #include <Geom_CartesianPoint.hxx>
 #include <gp_Pnt.hxx>
 #include <gp_Lin.hxx>
@@ -244,9 +245,10 @@ void CurveCreator_Curve::getCoordinates( int theISection, int theIPoint, double&
 void CurveCreator_Curve::redisplayCurve()
 {
   if( myDisplayer ) {
-    myDisplayer->erase( false );
+    myDisplayer->eraseAll( false );
     myAISShape = NULL;
-    myDisplayer->display( constructWire(), true );
+
+    myDisplayer->display( getAISObject( true ), true );
   }
 }
 
@@ -365,7 +367,7 @@ bool CurveCreator_Curve::clearInternal()
 {
   // erase curve from the viewer
   if( myDisplayer ) {
-    myDisplayer->erase( true );
+    myDisplayer->eraseAll( true );
     myAISShape = NULL;
   }
   // Delete all allocated data.
@@ -939,27 +941,19 @@ CurveCreator::Coordinates CurveCreator_Curve::getPoints( const int theISection )
   return aCoords;
 }
 
-
-/***********************************************/
-/***       Presentation methods              ***/
-/***********************************************/
-std::vector<Handle_AIS_InteractiveObject> CurveCreator_Curve::constructWire()
+void CurveCreator_Curve::constructAISObject()
 {
-  std::vector<Handle_AIS_InteractiveObject> aCurveRepresentation;
-
   TopoDS_Shape aShape;
   CurveCreator_Utils::constructShape( this, aShape );
 
   myAISShape = new AIS_Shape( aShape );
-  aCurveRepresentation.push_back( myAISShape );
-  return aCurveRepresentation;
 }
 
-//=======================================================================
-// function: getAISObject
-// purpose:
-//=======================================================================
-Handle_AIS_InteractiveObject CurveCreator_Curve::getAISObject() const
+Handle(AIS_InteractiveObject) CurveCreator_Curve::getAISObject( const bool theNeedToBuild ) const
 {
+  if ( !myAISShape && theNeedToBuild ) {
+    CurveCreator_Curve* aCurve = (CurveCreator_Curve*)this;
+    aCurve->constructAISObject();
+  }
   return myAISShape;
 }
\ No newline at end of file
index ffa89c9c1439a120e64636fc99c1c3b0aa217e9b..24a216cf6d0a4f2f06aada35384b9ca330dc3b9f 100644 (file)
 #include "CurveCreator.hxx"
 #include "CurveCreator_Diff.hxx"
 
-#include <AIS_InteractiveObject.hxx>
-
 #include <list>
 #include <map>
 
 struct CurveCreator_Section;
 class CurveCreator_Displayer;
 class AIS_Shape;
+class Handle_AIS_InteractiveObject;
 
 /**
  *  The CurveCreator_Curve object is represented as one or more sets of
@@ -262,19 +261,19 @@ public:
   /***********************************************/
   /***       Presentation methods              ***/
   /***********************************************/
-  virtual ListAISObjects constructWire();
-
   /**
    *  Get the curve AIS object
    */
-  virtual Handle_AIS_InteractiveObject getAISObject() const;
+  virtual Handle_AIS_InteractiveObject getAISObject( const bool theNeedToBuild = false ) const;
+
+protected:
+  virtual void constructAISObject();
 
 public:
   bool                            myIsLocked;
   CurveCreator::Sections          mySections;   //!< curve data
   CurveCreator::Dimension         myDimension;  //!< curve dimension
   CurveCreator_Displayer*         myDisplayer;  //!< curve displayer
-  AIS_Shape*                      myAISShape;   //!< AIS shape
 
 private:
 
@@ -284,6 +283,7 @@ private:
   ListDiff                        myListDiffs;
   int                             myUndoDepth;
   int                             myOpLevel;
+  AIS_Shape*                      myAISShape;   //!< AIS shape
 };
 
 #endif
index f0c5463d8e32d348eb19a10ee6ccdfe3493e0470..5872e3f8add2a5b701fc1050e3a89557951526e2 100644 (file)
@@ -8,48 +8,33 @@ CurveCreator_Displayer::CurveCreator_Displayer( Handle_AIS_InteractiveContext th
 
 CurveCreator_Displayer::~CurveCreator_Displayer(void)
 {
-  erase( true );
+  eraseAll( true );
   for( int i = 0 ; i < myObjects.size() ; i++ ){
     myObjects[i].Nullify();
   }
   myObjects.clear();
 }
 
-void CurveCreator_Displayer::display( AISObjectsList theCurveObjects, bool isUpdate )
+void CurveCreator_Displayer::display( const Handle(AIS_InteractiveObject)& theObject, bool isUpdate )
 {
-  myObjects = theCurveObjects;
-  if(myObjects.empty())
+  if ( theObject.IsNull() )
     return;
-  for( int i = 0 ; i < myObjects.size() ; i++ ){
-    myContext->Display(myObjects[i], Standard_False);
-  }
+
+  myObjects.push_back( theObject );
+  myContext->Display( theObject, Standard_False );
+
   if( isUpdate )
     myContext->UpdateCurrentViewer();
 }
 
-void CurveCreator_Displayer::erase( bool isUpdate )
+void CurveCreator_Displayer::eraseAll( bool isUpdate )
 {
   if(myObjects.empty())
     return;
   for( int i = 0 ; i < myObjects.size() ; i++ ){
     myContext->Erase(myObjects[i], Standard_False);
   }
-  if( isUpdate )
-    myContext->UpdateCurrentViewer();
-}
-
-void CurveCreator_Displayer::displayAIS( Handle(AIS_InteractiveObject) theObject, bool isUpdate )
-{
-  myContext->Display( theObject, Standard_False );
-
-  if( isUpdate )
-    myContext->UpdateCurrentViewer();
-}
-
-void CurveCreator_Displayer::redisplayAIS( Handle(AIS_InteractiveObject) theObject, bool isUpdate )
-{
-  myContext->Redisplay( theObject, Standard_False );
-
+  myObjects.clear();
   if( isUpdate )
     myContext->UpdateCurrentViewer();
 }
@@ -62,7 +47,7 @@ Quantity_Color CurveCreator_Displayer::getActiveColor( bool isHL )
   return Quantity_Color( 0., 1., 0., Quantity_TOC_RGB );
 }
 
-void CurveCreator_Displayer::highlight( const AISObjectsList& theObjects, bool isHL )
+/*void CurveCreator_Displayer::highlight( const AISObjectsList& theObjects, bool isHL )
 {
   return;
   //TODO:
@@ -72,4 +57,4 @@ void CurveCreator_Displayer::highlight( const AISObjectsList& theObjects, bool i
     myContext->Display(theObjects[i], Standard_False);
   }
   myContext->UpdateCurrentViewer();
-}
+}*/
index fba268bc88093df90595d25722865cca6b74523e..ad762b7fa7210143031eb0819b66f32ef68b5125 100644 (file)
@@ -16,15 +16,9 @@ public:
   CurveCreator_Displayer(Handle_AIS_InteractiveContext theContext );
   ~CurveCreator_Displayer(void);
 
-  //TODO: remove
-  Handle_AIS_InteractiveContext getAISContext() { return myContext; }
-
-  void display( AISObjectsList theCurveObjects, bool isUpdate );
-  void erase( bool isUpdate );
-  void highlight( const AISObjectsList& theObjects, bool isHL );
-
-  void displayAIS( Handle_AIS_InteractiveObject theObject, bool isUpdate );
-  void redisplayAIS( Handle_AIS_InteractiveObject theObject, bool isUpdate );
+  void display( const Handle_AIS_InteractiveObject& theObject, bool isUpdate );
+  void eraseAll( bool isUpdate );
+  //void highlight( const AISObjectsList& theObjects, bool isHL );
 
 protected:
   Quantity_Color getActiveColor( bool isHL );
index ed6b3c2e42270bdfafb57b330dd4e85b17dace9c..fa0317469d6b13278ba4876d4923e18795d1aa63 100644 (file)
@@ -27,7 +27,7 @@
 #include <deque>
 #include <vector>
 
-#include <AIS_InteractiveObject.hxx>
+class Handle_AIS_InteractiveObject;
 
 namespace CurveCreator
 {
@@ -57,8 +57,6 @@ namespace CurveCreator
 class CURVECREATOR_EXPORT CurveCreator_ICurve
 {
 public:
-  typedef std::vector<Handle_AIS_InteractiveObject> ListAISObjects;
-
   typedef std::pair<int,int> SectionToPoint;
   typedef std::deque<SectionToPoint> SectionToPointList;
 
@@ -179,9 +177,12 @@ public:
   /***********************************************/
   /***       Presentation methods              ***/
   /***********************************************/
-  virtual ListAISObjects constructWire() = 0;
 
-  virtual Handle_AIS_InteractiveObject getAISObject() const = 0;
+  virtual Handle_AIS_InteractiveObject getAISObject( const bool theNeedToBuild = false ) const = 0;
+
+protected:
+  virtual void constructAISObject() = 0;
+
 };
 
 #endif
index 0a13021c493a908647f6316ab731bfea25b3180a..d34695d9688de31e6d2dbe484715c8e92330c0c7 100644 (file)
@@ -68,7 +68,7 @@ bool CurveCreator_Profile::clearInternal()
 {
   // erase curve from the viewer
   if( myDisplayer )
-    myDisplayer->erase( true );
+    myDisplayer->eraseAll( true );
 
   // Delete all allocated data.
   mySections[ 0 ]->myPoints.clear();
index 60e78683d12faa54607a5af23685b8b41819c8b7..96b4e454ba76d7e104dfa0d39e36a9081f547056 100644 (file)
@@ -24,6 +24,8 @@
 
 #include "CurveCreator_ICurve.hxx"
 
+#include <gp_Pnt.hxx>
+
 #include <QMap>
 #include <QList>
 
index 60a024d262c550e60cd0b7cf5e4e4bc62398a580..0e7936e5e8b28e6e03f99e129fe576593149dfd6 100644 (file)
@@ -1075,8 +1075,6 @@ void CurveCreator_Widget::insertPointToSelectedSegment( const int theX,
     return;
   gp_Pnt aPoint;
   gp_Pnt aPoint1, aPoint2;
-  //bool isFoundPoint = CurveCreator_Utils::getNeighbourPoints( aContext, aView, theX, theY,
-  //                                                            aPoint, aPoint1, aPoint2 );
   Handle(AIS_InteractiveObject) anAISObject = myCurve->getAISObject();
   bool isFoundPoint = CurveCreator_Utils::pointOnObject( aView, anAISObject, theX, theY,
                                                          aPoint, aPoint1, aPoint2 );
index 7ad2b2f6c9c746fa22d722e042fcd7bdca8342ed..889a13362e7eae9e44834a5c49302c1c91246ca1 100755 (executable)
@@ -291,7 +291,8 @@ void HYDROGUI_PolylineOp::onEditorSelectionChanged()
   //QList<int> aSelSections = aPanel->getSelectedSections();
   bool aIsHl = false;
   //if( aSelSections.contains(i) ){
-    aDisplayer->highlight( myCurve->constructWire(), aIsHl );
+  // TODO
+  //aDisplayer->highlight( myCurve->getAISObject(), aIsHl );
   //}
 }
 
@@ -306,7 +307,7 @@ void HYDROGUI_PolylineOp::displayPreview()
       {
         CurveCreator_Displayer* aDisplayer = new CurveCreator_Displayer( aCtx );
         myCurve->setDisplayer( aDisplayer );
-        aDisplayer->display( myCurve->constructWire(), true );
+        aDisplayer->display( myCurve->getAISObject( true ), true );
       }
     }
   }
@@ -322,7 +323,7 @@ void HYDROGUI_PolylineOp::erasePreview()
       Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext();
       if( !aCtx.IsNull() )
       {
-        aDisplayer->erase( true );
+        aDisplayer->eraseAll( true );
       }
     }
   }
index db4cd7baf4601d6a4ae1d38dc83809cfefb3949a..6ed7bd15e3ef70f706ab2d69bc2b83024056b2fb 100644 (file)
@@ -217,7 +217,7 @@ void HYDROGUI_ProfileOp::displayPreview()
     {
       CurveCreator_Displayer* aDisplayer = new CurveCreator_Displayer( aCtx );
       myProfile->setDisplayer( aDisplayer );
-      aDisplayer->display( myProfile->constructWire(), true );
+      aDisplayer->display( myProfile->getAISObject( true ), true );
     }
   }
 }
@@ -231,7 +231,7 @@ void HYDROGUI_ProfileOp::erasePreview()
     Handle(AIS_InteractiveContext) aCtx = aPanel->getAISContext();
     if( !aCtx.IsNull() )
     {
-      aDisplayer->erase( true );
+      aDisplayer->eraseAll( true );
     }
   }
 }