]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
TableView number rows is limited by 20 rows.
authornds <nds@opencascade.com>
Wed, 4 Dec 2013 08:03:34 +0000 (08:03 +0000)
committernds <nds@opencascade.com>
Wed, 4 Dec 2013 08:03:34 +0000 (08:03 +0000)
src/HYDROCurveCreator/CurveCreator_Utils.cxx
src/HYDROCurveCreator/CurveCreator_Widget.cxx
src/HYDROCurveCreator/CurveCreator_Widget.h

index 5e39c62504b5425c24ce6268e71dec910bb0c809..2a29176e94c899b25fc16fff340a6ac7352b3fba 100644 (file)
@@ -153,44 +153,45 @@ void CurveCreator_Utils::constructShape( const CurveCreator_ICurve* theCurve,
   theShape = aComp;
 }
 
+class ComparePnt
+{
+public:
+  ComparePnt( const gp_Pnt& thePoint ) : myPoint( thePoint) {};
+  ~ComparePnt() {}
+
+  bool operator < ( const ComparePnt& theOtherPoint ) const
+  {
+    bool isLess = myPoint.X() < theOtherPoint.myPoint.X();
+    if ( !isLess && myPoint.X() == theOtherPoint.myPoint.X() ) {
+      isLess = myPoint.Y() < theOtherPoint.myPoint.Y();
+      if ( !isLess && myPoint.Y() == theOtherPoint.myPoint.Y() )
+        isLess = myPoint.Z() < theOtherPoint.myPoint.Z();
+    }
+    return isLess;
+  }
+private:
+  gp_Pnt myPoint;
+};
 
 std::list<float> CurveCreator_Utils::getSelectedPoints( Handle(AIS_InteractiveContext) theContext )
 {
   std::list<float> aSelectedPoints;
 
   gp_Pnt aPnt;
+  std::map<ComparePnt, int> aPntMap;
+
   for ( theContext->InitSelected(); theContext->MoreSelected(); theContext->NextSelected() ) {
     TopoDS_Vertex aVertex;
     TopoDS_Shape aShape = theContext->SelectedShape();
     if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX )
       aVertex = TopoDS::Vertex( theContext->SelectedShape() );
-    else {
-      Handle(SelectMgr_EntityOwner) anOwner = theContext->SelectedOwner();
-      if ( !anOwner.IsNull() ) {
-        Handle(AIS_InteractiveObject) anAIS = Handle(AIS_InteractiveObject)::DownCast( anOwner->Selectable() );
-        if ( !anAIS.IsNull() ) {
-          Handle(AIS_Point) aPoint = Handle(AIS_Point)::DownCast( anAIS);
-          if ( !aPoint.IsNull() )
-            aVertex = TopoDS::Vertex( aPoint->Vertex() );
-        }
-        if ( aVertex.IsNull() ) {
-          // the following happens if there are no points in the current curve, there is only a shape
-          /*Handle(StdSelect_BRepOwner) aBrepOwner = Handle(StdSelect_BRepOwner)::DownCast(anOwner);
-          if ( aBrepOwner.IsNull() )
-            continue;
-          if ( aBrepOwner->HasShape() ) {
-            const TopoDS_Shape& aShape = aBrepOwner->Shape();
-            if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX )
-            {
-              aVertex = TopoDS::Vertex( aShape );
-            }
-          }*/
-        }
-      }
-    }
+
     if ( aVertex.IsNull() )
       continue;
     aPnt = BRep_Tool::Pnt( aVertex );
+    if ( aPntMap.find( aPnt ) != aPntMap.end() )
+      continue;
+    aPntMap[aPnt] = 0;
     aSelectedPoints.push_back( aPnt.X() );
     aSelectedPoints.push_back( aPnt.Y() );
     aSelectedPoints.push_back( aPnt.Z() );
index bbf25b998de005c583f30e98f5f3f0933c3ab5c0..37a4c78279bf0a7c9d205c4b9f37038c2c1ef90b 100644 (file)
@@ -106,10 +106,11 @@ const double LOCAL_SELECTION_TOLERANCE = 0.0001;
 
 CurveCreator_Widget::CurveCreator_Widget(QWidget* parent,
                                          CurveCreator_ICurve *theCurve,
-                                         Qt::WindowFlags fl)
+                                         Qt::WindowFlags fl,
+                                         int theLocalPointRowLimit )
 : QWidget(parent), myNewSectionEditor(NULL), myCurve(theCurve), mySection(0),
   myDragStarted( false ), myDragInteractionStyle( SUIT_ViewModel::STANDARD ),
-  myOCCViewer( 0 )
+  myOCCViewer( 0 ), myLocalPointRowLimit( theLocalPointRowLimit )
 {
   myNewSectionEditor = new CurveCreator_NewSectionDlg( this );
   myNewSectionEditor->hide();
@@ -1253,6 +1254,11 @@ void CurveCreator_Widget::updateLocalPointView()
     return;
 
   std::list<float> aSelectedList = CurveCreator_Utils::getSelectedPoints( aContext );
+  int aNbPoints = aSelectedList.size()/3;
+  bool isRowLimit = aNbPoints > myLocalPointRowLimit;
+  myLocalPointView->setVisible( !isRowLimit );
+  if ( isRowLimit )
+    return;
 
   std::list<float>::const_iterator anIt = aSelectedList.begin(), aLast = aSelectedList.end();
 
index fcb6cc34cd7bf8cfa6dd13b49ee591a0775bd899..5e714532bd1c984bde2b487c31d237481f5089f9 100644 (file)
@@ -54,7 +54,8 @@ class CURVECREATOR_EXPORT CurveCreator_Widget : public QWidget
 public:
   explicit CurveCreator_Widget( QWidget* parent,
                                 CurveCreator_ICurve *theCurve,
-                                Qt::WindowFlags fl=0 );
+                                Qt::WindowFlags fl=0,
+                                int theLocalPointRowLimit = 20);
 
   // OCC viewer manipulation
   void setOCCViewer( OCCViewer_Viewer* theViewer );
@@ -192,6 +193,7 @@ private:
   CurveCreator_TableView*     myLocalPointView;
   CurveCreator_NewSectionDlg* myNewSectionEditor;
   OCCViewer_Viewer*           myOCCViewer;
+  int                         myLocalPointRowLimit;
   int                         mySection;
   int                         myPointNum;
   bool                        myDragStarted;