X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROCurveCreator%2FCurveCreator_Widget.cxx;h=56ae6c123358bb31b87f131dac788d00fccb8e93;hb=a8213a40ae36460055057f09e3e0828a01e27123;hp=b054e983fbdcb7ce31105719a243489e44eeb7d6;hpb=e2620a4887a3ecff0ce4f5f2264bba74b4f7e8b4;p=modules%2Fhydro.git diff --git a/src/HYDROCurveCreator/CurveCreator_Widget.cxx b/src/HYDROCurveCreator/CurveCreator_Widget.cxx index b054e983..56ae6c12 100644 --- a/src/HYDROCurveCreator/CurveCreator_Widget.cxx +++ b/src/HYDROCurveCreator/CurveCreator_Widget.cxx @@ -25,6 +25,7 @@ //#include "CurveCreator_NewPointDlg.h" #include "CurveCreator_NewSectionDlg.h" #include "CurveCreator_Utils.h" +#include "CurveCreator_TableView.h" #include #include @@ -75,8 +76,6 @@ const int POINT_INDEX_COLUMN_WIDTH = 40; const int SCENE_PIXEL_TOLERANCE = 10; -//#define USE_SEVERAL_POINTS - CurveCreator_Widget::CurveCreator_Widget(QWidget* parent, CurveCreator_ICurve *theCurve, Qt::WindowFlags fl) @@ -98,6 +97,7 @@ CurveCreator_Widget::CurveCreator_Widget(QWidget* parent, connect( mySectionView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(onContextMenu(QPoint)) ); myLocalPointView = new QTableWidget(); + myLocalPointView->setItemDelegate( new CurveCreator_TableItemDelegate( myLocalPointView ) ); myLocalPointView->setVisible( false ); myLocalPointView->setColumnCount( 4 ); myLocalPointView->setColumnWidth( 0, SECTION_NAME_COLUMN_WIDTH ); @@ -573,9 +573,14 @@ void CurveCreator_Widget::onModifySection() bool isClosed = myNewSectionEditor->isClosed(); CurveCreator::SectionType aSectType = myNewSectionEditor->getSectionType(); // myCurve->startOperation(); - myCurve->setClosed( isClosed, mySection ); - myCurve->setSectionName( mySection , aName.toStdString() ); - myCurve->setSectionType( mySection, aSectType ); + if( myCurve->getSectionName(mySection) != aName.toStdString() ) + myCurve->setSectionName( mySection , aName.toStdString() ); + + if( myCurve->getSectionType(mySection) != aSectType ) + myCurve->setSectionType( mySection, aSectType ); + + if( myCurve->isClosed(mySection) != isClosed ) + myCurve->setClosed( mySection, isClosed ); // myCurve->finishOperation(); mySectionView->sectionChanged(mySection); updateUndoRedo(); @@ -708,7 +713,7 @@ void CurveCreator_Widget::onCloseSections() // myCurve->startOperation(); QList aSelSections = mySectionView->getSelectedSections(); for( int i = 0 ; i < aSelSections.size() ; i++ ){ - myCurve->setClosed(true, aSelSections[i]); + myCurve->setClosed(aSelSections[i], true); mySectionView->sectionChanged(aSelSections[i]); } // myCurve->finishOperation(); @@ -722,7 +727,7 @@ void CurveCreator_Widget::onUncloseSections() // myCurve->startOperation(); QList aSelSections = mySectionView->getSelectedSections(); for( int i = 0 ; i < aSelSections.size() ; i++ ){ - myCurve->setClosed(false, aSelSections[i]); + myCurve->setClosed(aSelSections[i], false); mySectionView->sectionChanged(aSelSections[i]); } // myCurve->finishOperation(); @@ -739,7 +744,6 @@ void CurveCreator_Widget::onUndo() myCurve->undo(); finishCurveModification(); mySectionView->reset(); - updateUndoRedo(); } void CurveCreator_Widget::onRedo() @@ -751,7 +755,6 @@ void CurveCreator_Widget::onRedo() myCurve->redo(); finishCurveModification(); mySectionView->reset(); - updateUndoRedo(); } void CurveCreator_Widget::updateUndoRedo() @@ -973,8 +976,8 @@ void CurveCreator_Widget::onCellChanged( int theRow, int theColumn ) SectionToPointList aSelPoints; startCurveModification( aSelPoints ); - double aX = myLocalPointView->item( theRow, 2 )->text().toDouble(); - double anY = myLocalPointView->item( theRow, 3 )->text().toDouble(); + double aX = myLocalPointView->item( theRow, 2 )->data( Qt::UserRole ).toDouble(); + double anY = myLocalPointView->item( theRow, 3 )->data( Qt::UserRole ).toDouble(); std::deque aChangedPos; aChangedPos.push_back( aX ); aChangedPos.push_back( anY ); @@ -1026,26 +1029,7 @@ void CurveCreator_Widget::removePoint() SectionToPointList aSelPoints; startCurveModification( aSelPoints, false ); -#ifdef USE_SEVERAL_POINTS myCurve->removeSeveralPoints( aPoints ); -#else - // the points should be removed in a decreased order - QMap > aConvPoints; - convert( aPoints, aConvPoints ); - QMap >::const_iterator anIt = aConvPoints.begin(), - aLast = aConvPoints.end(); - for ( ; anIt != aLast; anIt++ ) { - int aSectionId = anIt.key(); - - QList aSectionPoints = anIt.value(); - qSort( aSectionPoints ); - for( int i = aSectionPoints.size()-1; i >= 0; i-- ){ - int aPntIndx = aSectionPoints[i]; - myCurve->removePoint( aSectionId, aPntIndx ); - mySectionView->pointsRemoved( aSectionId, aPntIndx ); - } - } -#endif finishCurveModification( SectionToPointList() ); } @@ -1118,7 +1102,6 @@ void CurveCreator_Widget::insertPointToSelectedSegment( const int theX, finishCurveModification( aSelPoints ); setSelectedPonts(); - updateUndoRedo(); } void CurveCreator_Widget::moveSelectedPoints( const int theXPosition, @@ -1145,18 +1128,19 @@ void CurveCreator_Widget::moveSelectedPoints( const int theXPosition, std::deque aChangedPos; SectionToPointList::const_iterator anIt = myDragPoints.begin(), aLast = myDragPoints.end(); for ( ; anIt != aLast; anIt++ ) { - aChangedPos = myCurve->getPoint( anIt->first, anIt->second ); + int aSectionId = anIt->first; + int aPointId = anIt->second; + aChangedPos = myCurve->getPoint( aSectionId, aPointId ); if ( aChangedPos.size() < 2 ) continue; aChangedPos[0] = aChangedPos[0] - aXDelta; aChangedPos[1] = aChangedPos[1] - anYDelta; -#ifndef USE_SEVERAL_POINTS - myCurve->setPoint( anIt->first, anIt->second, aChangedPos ); -#endif + + aCoordList.push_back( + std::make_pair(std::make_pair( aSectionId, aPointId ), + aChangedPos )); } -#ifdef USE_SEVERAL_POINTS myCurve->setSeveralPoints( aCoordList ); -#endif myDragged = true; finishCurveModification( myDragPoints ); @@ -1432,6 +1416,7 @@ void CurveCreator_Widget::finishCurveModification( if ( getActionMode() == ModificationMode ) setLocalPointContext( true ); setSelectedPonts( thePoints ); + updateUndoRedo(); } /**