]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
Ref #259 - Regression: the number of point is not updated during polyline creation
authornds <nds@opencascade.com>
Thu, 19 Dec 2013 11:31:51 +0000 (11:31 +0000)
committernds <nds@opencascade.com>
Thu, 19 Dec 2013 11:31:51 +0000 (11:31 +0000)
Get back the removed update for the view if number of points is changed.

src/HYDROCurveCreator/CurveCreator_TreeView.cxx
src/HYDROCurveCreator/CurveCreator_TreeView.h
src/HYDROCurveCreator/CurveCreator_Widget.cxx

index ce580d5357ee720a045f3b2ceed086832bba7add..36d1dfcfb5dfc3c85f68468445cfdf826ae61514 100755 (executable)
@@ -252,6 +252,39 @@ QList<int> CurveCreator_TreeView::getSelectedSections() const
   return aSect;
 }
 
+void CurveCreator_TreeView::pointsAdded( int theSection, int thePoint, int thePointsCnt )
+{
+  CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(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<CurveCreator_TreeViewModel*>(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<CurveCreator_TreeViewModel*>(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<CurveCreator_TreeViewModel*>(model());
index b96f2b1a031e76ad563b0bf01f031b774c315797..be00a75d3c9d9a2d79a9a402d26b329a7c3cc632 100755 (executable)
@@ -63,6 +63,10 @@ public:
   SelectionType getSelectionType() const;
   QList<int> 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 );
index e997fe69fe3fc1e9bab18fbe1ee083c040a3e9c2..7680ac148fbac5022b33b67b0a40deaa508ad713 100644 (file)
@@ -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<int>::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 );