From 3a18ec73b8f92e150d5f4c772bf122ed2ca1ecef Mon Sep 17 00:00:00 2001 From: nds Date: Wed, 18 Dec 2013 07:15:28 +0000 Subject: [PATCH] refs #249 - Undo after Join selected sections operation works not properly The points manipulation remove from the sections tree view --- .../CurveCreator_TreeView.cxx | 77 ------------------- src/HYDROCurveCreator/CurveCreator_TreeView.h | 10 +-- src/HYDROCurveCreator/CurveCreator_Widget.cxx | 31 -------- src/HYDROCurveCreator/CurveCreator_Widget.h | 1 - src/HYDROGUI/HYDROGUI_PolylineDlg.cxx | 5 -- src/HYDROGUI/HYDROGUI_PolylineDlg.h | 1 - src/HYDROGUI/HYDROGUI_ProfileDlg.cxx | 5 -- src/HYDROGUI/HYDROGUI_ProfileDlg.h | 1 - 8 files changed, 1 insertion(+), 130 deletions(-) diff --git a/src/HYDROCurveCreator/CurveCreator_TreeView.cxx b/src/HYDROCurveCreator/CurveCreator_TreeView.cxx index c48eb510..9280713a 100755 --- a/src/HYDROCurveCreator/CurveCreator_TreeView.cxx +++ b/src/HYDROCurveCreator/CurveCreator_TreeView.cxx @@ -253,39 +253,6 @@ 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()); @@ -365,16 +332,6 @@ void CurveCreator_TreeView::sectionsSwapped( int theSection, int theOffset ) } } -void CurveCreator_TreeView::pointsSwapped( int theSection, int thePointNum, int theOffset ) -{ - CurveCreator_TreeViewModel* aModel = dynamic_cast(model()); - if( aModel ){ - QModelIndex aFirstIndex = aModel->pointIndex( theSection, thePointNum ); - QModelIndex aSecondIndex = aModel->pointIndex( theSection, thePointNum + theOffset ); - swapIndexes( aFirstIndex, aSecondIndex ); - } -} - void CurveCreator_TreeView::setSelectedSections( const QList& theList ) { CurveCreator_TreeViewModel* aModel = dynamic_cast(model()); @@ -387,18 +344,6 @@ void CurveCreator_TreeView::setSelectedSections( const QList& theList ) } } -void CurveCreator_TreeView::setSelectedPoints( const QList< QPair >& thePointsList ) -{ - CurveCreator_TreeViewModel* aModel = dynamic_cast(model()); - if( aModel ){ - selectionModel()->clearSelection(); - for( int i = 0 ; i < thePointsList.size() ; i++ ){ - QModelIndex aSectIndx = aModel->pointIndex( thePointsList[i].first, thePointsList[i].second ); - selectionModel()->select(aSectIndx, QItemSelectionModel::Select ); - } - } -} - bool pointLessThan(const QPair &s1, const QPair &s2) { if( s1.first < s2.first ) @@ -408,25 +353,6 @@ bool pointLessThan(const QPair &s1, const QPair &s2) return s1.second < s2.second; } -QList< QPair< int, int > > CurveCreator_TreeView::getSelectedPoints() const -{ - QList< QPair< int, int > > aPoints; - CurveCreator_TreeViewModel* aModel = dynamic_cast(model()); - if( !aModel ) - return aPoints; - QModelIndexList anIndxs = selectionModel()->selectedIndexes(); - for( int i = 0 ; i < anIndxs.size() ; i++ ){ - if( !aModel->isSection( anIndxs[i] ) ){ - int aSect = aModel->getSection(anIndxs[i]); - int aPointNum = aModel->getPoint(anIndxs[i]); - QPair< int, int > aPoint = QPair( aSect, aPointNum ); - aPoints.push_back( aPoint ); - } - } - qSort( aPoints.begin(), aPoints.end(), pointLessThan ); - return aPoints; -} - CurveCreator_TreeView::SelectionType CurveCreator_TreeView::getSelectionType() const { CurveCreator_TreeViewModel* aModel = dynamic_cast(model()); @@ -474,10 +400,7 @@ void CurveCreator_TreeView::onActivated( QModelIndex theIndx ) int aSect = aModel->getSection(theIndx); if( aModel->isSection(theIndx) ){ emit sectionEntered( aSect ); - return; } - int aPointNum = aModel->getPoint( theIndx ); - emit pointEntered( aSect, aPointNum ); } void CurveCreator_TreeView::setCurve( CurveCreator_ICurve* theCurve ) diff --git a/src/HYDROCurveCreator/CurveCreator_TreeView.h b/src/HYDROCurveCreator/CurveCreator_TreeView.h index ee0260c7..b96f2b1a 100755 --- a/src/HYDROCurveCreator/CurveCreator_TreeView.h +++ b/src/HYDROCurveCreator/CurveCreator_TreeView.h @@ -62,12 +62,6 @@ public: explicit CurveCreator_TreeView( CurveCreator_ICurve* theCurve, QWidget *parent = 0); SelectionType getSelectionType() const; QList getSelectedSections() const; - QList< QPair< int, int > > getSelectedPoints() 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 pointsSwapped( int theSection, int thePointNum, int theOffset ); void sectionAdded( int theSection ); void sectionChanged(int theSection , int aSectCnt = 1); @@ -75,7 +69,6 @@ public: void sectionsSwapped( int theSection, int theOffset ); void setSelectedSections( const QList& theList ); - void setSelectedPoints( const QList< QPair >& thePointsList ); void setCurve( CurveCreator_ICurve* theCurve ); @@ -84,8 +77,7 @@ public: signals: void selectionChanged(); void sectionEntered(int); - void pointEntered(int,int); -public slots: + protected slots: void onActivated( QModelIndex theIndx ); protected: diff --git a/src/HYDROCurveCreator/CurveCreator_Widget.cxx b/src/HYDROCurveCreator/CurveCreator_Widget.cxx index a808b140..42bbaf6c 100644 --- a/src/HYDROCurveCreator/CurveCreator_Widget.cxx +++ b/src/HYDROCurveCreator/CurveCreator_Widget.cxx @@ -343,7 +343,6 @@ void CurveCreator_Widget::updateActionsStates() if ( removeEnabled() ) anEnabledAct << REMOVE_ID; QList aSelSections = mySectionView->getSelectedSections(); - QList< QPair< int, int > > aSelPoints = mySectionView->getSelectedPoints(); CurveCreator_TreeView::SelectionType aSelType = mySectionView->getSelectionType(); switch( aSelType ){ case CurveCreator_TreeView::ST_NOSEL:{ @@ -455,13 +454,6 @@ void CurveCreator_Widget::onAdditionMode(bool checked) if( aSelSection.size() > 0 ){ mySection = aSelSection[0]; } - else{ - QList< QPair > aSelPoints = mySectionView->getSelectedPoints(); - if( aSelPoints.size() > 0 ){ - mySection = aSelPoints[0].first; - myPointNum = aSelPoints[0].second + 1; - } - } // emit subOperationStarted( myNewPointEditor ); } @@ -680,9 +672,6 @@ void CurveCreator_Widget::onJoin() myCurve->join( aMainSect, aSectNum ); mySectionView->sectionsRemoved( aSectNum ); } - int aNewSectSize = myCurve->getNbPoints(aMainSect); - if( aNewSectSize != aMainSectSize ) - mySectionView->pointsAdded( aMainSect, aMainSectSize, aNewSectSize-aMainSectSize ); updateUndoRedo(); } @@ -873,11 +862,6 @@ QList CurveCreator_Widget::getSelectedSections() return mySectionView->getSelectedSections(); } -QList< QPair< int, int > > CurveCreator_Widget::getSelectedPoints() -{ - return mySectionView->getSelectedPoints(); -} - /** * According to the widget state, performs the remove action */ @@ -1124,19 +1108,6 @@ void CurveCreator_Widget::removeSection() { stopActionMode(); - QList< QPair > aSelPoints = mySectionView->getSelectedPoints(); - int aCurrSect=-1; - int aRemoveCnt = 0; - for( int i = 0 ; i < aSelPoints.size() ; i++ ){ - if( aCurrSect != aSelPoints[i].first ){ - aRemoveCnt = 0; - aCurrSect = aSelPoints[i].first; - } - int aPntIndx = aSelPoints[i].second - aRemoveCnt; - myCurve->removePoint( aCurrSect, aPntIndx ); - mySectionView->pointsRemoved( aCurrSect, aPntIndx ); - aRemoveCnt++; - } QList aSections = mySectionView->getSelectedSections(); for( int i = 0 ; i < aSections.size() ; i++ ){ int aSectNum = aSections[i] - (i); @@ -1174,7 +1145,6 @@ 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(); } @@ -1237,7 +1207,6 @@ 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 ); diff --git a/src/HYDROCurveCreator/CurveCreator_Widget.h b/src/HYDROCurveCreator/CurveCreator_Widget.h index 2d8a3e02..7ab17331 100644 --- a/src/HYDROCurveCreator/CurveCreator_Widget.h +++ b/src/HYDROCurveCreator/CurveCreator_Widget.h @@ -78,7 +78,6 @@ public: void setCurve( CurveCreator_ICurve* theCurve ); QList getSelectedSections(); - QList< QPair< int, int > > getSelectedPoints(); void removeSelected(); bool removeEnabled(); diff --git a/src/HYDROGUI/HYDROGUI_PolylineDlg.cxx b/src/HYDROGUI/HYDROGUI_PolylineDlg.cxx index 6e5f2b89..abbd6ae4 100755 --- a/src/HYDROGUI/HYDROGUI_PolylineDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_PolylineDlg.cxx @@ -117,11 +117,6 @@ QList HYDROGUI_PolylineDlg::getSelectedSections() return myEditorWidget->getSelectedSections(); } -QList< QPair< int, int > > HYDROGUI_PolylineDlg::getSelectedPoints() -{ - return myEditorWidget->getSelectedPoints(); -} - /** * Redirect the delete action to editor widget */ diff --git a/src/HYDROGUI/HYDROGUI_PolylineDlg.h b/src/HYDROGUI/HYDROGUI_PolylineDlg.h index aa78a5c6..95d93eaa 100755 --- a/src/HYDROGUI/HYDROGUI_PolylineDlg.h +++ b/src/HYDROGUI/HYDROGUI_PolylineDlg.h @@ -49,7 +49,6 @@ public: void reset(); QList getSelectedSections(); - QList< QPair< int, int > > getSelectedPoints(); void deleteSelected(); bool deleteEnabled(); diff --git a/src/HYDROGUI/HYDROGUI_ProfileDlg.cxx b/src/HYDROGUI/HYDROGUI_ProfileDlg.cxx index 1dc3901f..e4725a2a 100644 --- a/src/HYDROGUI/HYDROGUI_ProfileDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_ProfileDlg.cxx @@ -154,11 +154,6 @@ QList HYDROGUI_ProfileDlg::getSelectedSections() return myEditorWidget->getSelectedSections(); } -QList< QPair< int, int > > HYDROGUI_ProfileDlg::getSelectedPoints() -{ - return myEditorWidget->getSelectedPoints(); -} - /** * Redirect the delete action to editor widget */ diff --git a/src/HYDROGUI/HYDROGUI_ProfileDlg.h b/src/HYDROGUI/HYDROGUI_ProfileDlg.h index 253e26eb..7c9e0d46 100644 --- a/src/HYDROGUI/HYDROGUI_ProfileDlg.h +++ b/src/HYDROGUI/HYDROGUI_ProfileDlg.h @@ -53,7 +53,6 @@ public: void reset(); QList getSelectedSections(); - QList< QPair< int, int > > getSelectedPoints(); void deleteSelected(); bool deleteEnabled(); -- 2.39.2