From: nds Date: Wed, 4 Dec 2013 08:03:34 +0000 (+0000) Subject: TableView number rows is limited by 20 rows. X-Git-Tag: BR_hydro_v_0_4~61 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=af38df5f512628d93c9850d284e03d037ca98b48;p=modules%2Fhydro.git TableView number rows is limited by 20 rows. --- diff --git a/src/HYDROCurveCreator/CurveCreator_Utils.cxx b/src/HYDROCurveCreator/CurveCreator_Utils.cxx index 5e39c625..2a29176e 100644 --- a/src/HYDROCurveCreator/CurveCreator_Utils.cxx +++ b/src/HYDROCurveCreator/CurveCreator_Utils.cxx @@ -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 CurveCreator_Utils::getSelectedPoints( Handle(AIS_InteractiveContext) theContext ) { std::list aSelectedPoints; gp_Pnt aPnt; + std::map 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() ); diff --git a/src/HYDROCurveCreator/CurveCreator_Widget.cxx b/src/HYDROCurveCreator/CurveCreator_Widget.cxx index bbf25b99..37a4c782 100644 --- a/src/HYDROCurveCreator/CurveCreator_Widget.cxx +++ b/src/HYDROCurveCreator/CurveCreator_Widget.cxx @@ -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 aSelectedList = CurveCreator_Utils::getSelectedPoints( aContext ); + int aNbPoints = aSelectedList.size()/3; + bool isRowLimit = aNbPoints > myLocalPointRowLimit; + myLocalPointView->setVisible( !isRowLimit ); + if ( isRowLimit ) + return; std::list::const_iterator anIt = aSelectedList.begin(), aLast = aSelectedList.end(); diff --git a/src/HYDROCurveCreator/CurveCreator_Widget.h b/src/HYDROCurveCreator/CurveCreator_Widget.h index fcb6cc34..5e714532 100644 --- a/src/HYDROCurveCreator/CurveCreator_Widget.h +++ b/src/HYDROCurveCreator/CurveCreator_Widget.h @@ -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;