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());
}
}
-void CurveCreator_TreeView::pointsSwapped( int theSection, int thePointNum, int theOffset )
-{
- CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(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<int>& theList )
{
CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(model());
}
}
-void CurveCreator_TreeView::setSelectedPoints( const QList< QPair<int, int> >& thePointsList )
-{
- CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(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<int,int> &s1, const QPair<int,int> &s2)
{
if( s1.first < s2.first )
return s1.second < s2.second;
}
-QList< QPair< int, int > > CurveCreator_TreeView::getSelectedPoints() const
-{
- QList< QPair< int, int > > aPoints;
- CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(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<int,int>( 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<CurveCreator_TreeViewModel*>(model());
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 )
explicit CurveCreator_TreeView( CurveCreator_ICurve* theCurve, QWidget *parent = 0);
SelectionType getSelectionType() const;
QList<int> 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);
void sectionsSwapped( int theSection, int theOffset );
void setSelectedSections( const QList<int>& theList );
- void setSelectedPoints( const QList< QPair<int, int> >& thePointsList );
void setCurve( CurveCreator_ICurve* theCurve );
signals:
void selectionChanged();
void sectionEntered(int);
- void pointEntered(int,int);
-public slots:
+
protected slots:
void onActivated( QModelIndex theIndx );
protected:
if ( removeEnabled() )
anEnabledAct << REMOVE_ID;
QList<int> aSelSections = mySectionView->getSelectedSections();
- QList< QPair< int, int > > aSelPoints = mySectionView->getSelectedPoints();
CurveCreator_TreeView::SelectionType aSelType = mySectionView->getSelectionType();
switch( aSelType ){
case CurveCreator_TreeView::ST_NOSEL:{
if( aSelSection.size() > 0 ){
mySection = aSelSection[0];
}
- else{
- QList< QPair<int,int> > aSelPoints = mySectionView->getSelectedPoints();
- if( aSelPoints.size() > 0 ){
- mySection = aSelPoints[0].first;
- myPointNum = aSelPoints[0].second + 1;
- }
- }
// emit subOperationStarted( myNewPointEditor );
}
myCurve->join( aMainSect, aSectNum );
mySectionView->sectionsRemoved( aSectNum );
}
- int aNewSectSize = myCurve->getNbPoints(aMainSect);
- if( aNewSectSize != aMainSectSize )
- mySectionView->pointsAdded( aMainSect, aMainSectSize, aNewSectSize-aMainSectSize );
updateUndoRedo();
}
return mySectionView->getSelectedSections();
}
-QList< QPair< int, int > > CurveCreator_Widget::getSelectedPoints()
-{
- return mySectionView->getSelectedPoints();
-}
-
/**
* According to the widget state, performs the remove action
*/
{
stopActionMode();
- QList< QPair<int,int> > 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<int> aSections = mySectionView->getSelectedSections();
for( int i = 0 ; i < aSections.size() ; i++ ){
int aSectNum = aSections[i] - (i);
}
int aSection = aSections[0];
myCurve->addPoints(theCoords, aSection); // add to the end of section
- mySectionView->pointsAdded( aSection, myCurve->getNbPoints( aSection ) );
updateActionsStates();
updateUndoRedo();
}
anInsertPos = aPoint1Id < aPoint2Id ? aPoint1Id + 1 : aPoint2Id + 1;
myCurve->addPoints( aCoords, aSectionId, anInsertPos );
- mySectionView->pointsAdded( aSectionId, myCurve->getNbPoints( aSectionId ) );
finishCurveModification( aSelPoints );
void setCurve( CurveCreator_ICurve* theCurve );
QList<int> getSelectedSections();
- QList< QPair< int, int > > getSelectedPoints();
void removeSelected();
bool removeEnabled();
return myEditorWidget->getSelectedSections();
}
-QList< QPair< int, int > > HYDROGUI_PolylineDlg::getSelectedPoints()
-{
- return myEditorWidget->getSelectedPoints();
-}
-
/**
* Redirect the delete action to editor widget
*/
void reset();
QList<int> getSelectedSections();
- QList< QPair< int, int > > getSelectedPoints();
void deleteSelected();
bool deleteEnabled();
return myEditorWidget->getSelectedSections();
}
-QList< QPair< int, int > > HYDROGUI_ProfileDlg::getSelectedPoints()
-{
- return myEditorWidget->getSelectedPoints();
-}
-
/**
* Redirect the delete action to editor widget
*/
void reset();
QList<int> getSelectedSections();
- QList< QPair< int, int > > getSelectedPoints();
void deleteSelected();
bool deleteEnabled();