From: nds Date: Thu, 19 Dec 2013 11:31:51 +0000 (+0000) Subject: Ref #259 - Regression: the number of point is not updated during polyline creation X-Git-Tag: BR_hydro_v_0_6~23 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=24ba8169352d66362d0a33732e9e9fe75e388896;p=modules%2Fhydro.git Ref #259 - Regression: the number of point is not updated during polyline creation Get back the removed update for the view if number of points is changed. --- diff --git a/src/HYDROCurveCreator/CurveCreator_TreeView.cxx b/src/HYDROCurveCreator/CurveCreator_TreeView.cxx index ce580d53..36d1dfcf 100755 --- a/src/HYDROCurveCreator/CurveCreator_TreeView.cxx +++ b/src/HYDROCurveCreator/CurveCreator_TreeView.cxx @@ -252,6 +252,39 @@ QList CurveCreator_TreeView::getSelectedSections() const return aSect; } +void CurveCreator_TreeView::pointsAdded( int theSection, int thePoint, int thePointsCnt ) +{ + CurveCreator_TreeViewModel* aModel = dynamic_cast(model()); + if( aModel ){ + QModelIndex aSectIndx = aModel->sectionIndex( theSection ); + rowsInserted(aSectIndx, thePoint, thePoint + thePointsCnt - 1 ); +// expand( aSectIndx ); + update( aModel->nbPointsIndex( theSection ) ); + } +} + +void CurveCreator_TreeView::pointDataChanged( int theSection, int thePoint ) +{ + CurveCreator_TreeViewModel* aModel = dynamic_cast(model()); + if( aModel ){ + QModelIndex aPointIndx = aModel->pointIndex( theSection, thePoint ); + dataChanged( aPointIndx, aPointIndx ); + } +} + +void CurveCreator_TreeView::pointsRemoved( int theSection, int thePoint, int thePointsCnt ) +{ + CurveCreator_TreeViewModel* aModel = dynamic_cast(model()); + if( aModel ){ + for( int i = 0 ; i < thePointsCnt ; i++ ){ + QModelIndex aSectIndx = aModel->pointIndex(theSection, thePoint + i); + selectionModel()->select(aSectIndx,QItemSelectionModel::Deselect); + } + QModelIndex aSectIndx = aModel->sectionIndex( theSection ); + rowsRemoved(aSectIndx, thePoint, thePoint + thePointsCnt - 1 ); + } +} + void CurveCreator_TreeView::sectionAdded( int theSection ) { CurveCreator_TreeViewModel* aModel = dynamic_cast(model()); diff --git a/src/HYDROCurveCreator/CurveCreator_TreeView.h b/src/HYDROCurveCreator/CurveCreator_TreeView.h index b96f2b1a..be00a75d 100755 --- a/src/HYDROCurveCreator/CurveCreator_TreeView.h +++ b/src/HYDROCurveCreator/CurveCreator_TreeView.h @@ -63,6 +63,10 @@ public: SelectionType getSelectionType() const; QList getSelectedSections() const; + void pointsAdded( int theSection, int thePoint, int thePointsCnt=1 ); + void pointDataChanged( int theSection, int thePoint ); + void pointsRemoved(int theSection, int thePoint, int thePointsCnt=1 ); + void sectionAdded( int theSection ); void sectionChanged(int theSection , int aSectCnt = 1); void sectionsRemoved( int theSection, int theSectionCnt=1 ); diff --git a/src/HYDROCurveCreator/CurveCreator_Widget.cxx b/src/HYDROCurveCreator/CurveCreator_Widget.cxx index e997fe69..7680ac14 100644 --- a/src/HYDROCurveCreator/CurveCreator_Widget.cxx +++ b/src/HYDROCurveCreator/CurveCreator_Widget.cxx @@ -669,13 +669,22 @@ void CurveCreator_Widget::onJoin() for( int i = 0; i < aSections.size() ; i++ ){ aSectionsToJoin.push_back( aSections[i] ); } - + //int aMainSect = aSectionsToJoin.front(); + //int aMainSectSize = myCurve->getNbPoints(aMainSect); if ( myCurve->join( aSectionsToJoin ) ) { - for( int i = 0, aSectionsSize = aSectionsToJoin.size(); i < aSectionsSize; i++ ) - mySectionView->sectionsRemoved( i ); + std::list::const_iterator anIt = aSectionsToJoin.begin(), + aLast = aSectionsToJoin.end(); + // the first section should be skipped. It is not removed, but is modified + anIt++; + for ( ; anIt != aLast; anIt++ ) + mySectionView->sectionsRemoved( *anIt ); } + /* The update for the points of the main section + int aNewSectSize = myCurve->getNbPoints(aMainSect); + if( aNewSectSize != aMainSectSize ) + mySectionView->pointsAdded( aMainSect, aMainSectSize, aNewSectSize-aMainSectSize );*/ updateUndoRedo(); } @@ -1155,6 +1164,7 @@ void CurveCreator_Widget::addNewPoint(const CurveCreator::Coordinates& theCoords } int aSection = aSections[0]; myCurve->addPoints(theCoords, aSection); // add to the end of section + mySectionView->pointsAdded( aSection, myCurve->getNbPoints( aSection ) ); updateActionsStates(); updateUndoRedo(); } @@ -1217,6 +1227,7 @@ void CurveCreator_Widget::insertPointToSelectedSegment( const int theX, anInsertPos = aPoint1Id < aPoint2Id ? aPoint1Id + 1 : aPoint2Id + 1; myCurve->addPoints( aCoords, aSectionId, anInsertPos ); + mySectionView->pointsAdded( aSectionId, myCurve->getNbPoints( aSectionId ) ); finishCurveModification( aSelPoints );