From: mzn Date: Fri, 6 Dec 2013 10:44:31 +0000 (+0000) Subject: Bug #186: Profile point drag and drop catching the neighbour point. X-Git-Tag: BR_hydro_v_0_4~9 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=59cb079ea66fc8a85a75a24e4f7674b3fc099a17;p=modules%2Fhydro.git Bug #186: Profile point drag and drop catching the neighbour point. --- diff --git a/src/HYDROCurveCreator/CurveCreator_Curve.cxx b/src/HYDROCurveCreator/CurveCreator_Curve.cxx index 0c6c45be..8e3a4328 100644 --- a/src/HYDROCurveCreator/CurveCreator_Curve.cxx +++ b/src/HYDROCurveCreator/CurveCreator_Curve.cxx @@ -51,7 +51,8 @@ CurveCreator_Curve::CurveCreator_Curve( const CurveCreator::Dimension theDimensi myNbUndos (0), myNbRedos (0), myUndoDepth (-1), - myOpLevel(0) + myOpLevel(0), + mySkipSorting(false) { } @@ -540,6 +541,16 @@ int CurveCreator_Curve::getNbPoints( const int theISection ) const return aNbCoords/myDimension; } +void CurveCreator_Curve::setSkipSorting( const bool theIsToSkip ) +{ + mySkipSorting = theIsToSkip; +} + +bool CurveCreator_Curve::canPointsBeSorted() +{ + return false; +} + //! Get "closed" flag of the specified section bool CurveCreator_Curve::isClosed( const int theISection ) const { diff --git a/src/HYDROCurveCreator/CurveCreator_Curve.hxx b/src/HYDROCurveCreator/CurveCreator_Curve.hxx index 3c41e711..ab073b7b 100644 --- a/src/HYDROCurveCreator/CurveCreator_Curve.hxx +++ b/src/HYDROCurveCreator/CurveCreator_Curve.hxx @@ -254,6 +254,15 @@ public: */ virtual int getNbPoints( const int theISection ) const; + /** + * Set skip sorting flag. If the flag is true - points sorting will be skipped. + */ + virtual void setSkipSorting( const bool theIsToSkip ); + + /** + * Indicates whether the points can be sorted. + */ + virtual bool canPointsBeSorted(); /***********************************************/ /*** Presentation methods ***/ @@ -283,6 +292,9 @@ protected: protected: virtual void constructAISObject(); +protected: + bool mySkipSorting; + public: bool myIsLocked; CurveCreator::Sections mySections; //!< curve data diff --git a/src/HYDROCurveCreator/CurveCreator_ICurve.hxx b/src/HYDROCurveCreator/CurveCreator_ICurve.hxx index 40696e9b..229256ce 100644 --- a/src/HYDROCurveCreator/CurveCreator_ICurve.hxx +++ b/src/HYDROCurveCreator/CurveCreator_ICurve.hxx @@ -174,6 +174,15 @@ public: */ virtual int getNbPoints( const int theISection ) const = 0; + /** + * Set skip sorting flag. If the flag is true - points sorting will be skipped. + */ + virtual void setSkipSorting( const bool ) = 0; + + /** + * Indicates whether the points can be sorted. + */ + virtual bool canPointsBeSorted() = 0; /***********************************************/ /*** Presentation methods ***/ diff --git a/src/HYDROCurveCreator/CurveCreator_Profile.cxx b/src/HYDROCurveCreator/CurveCreator_Profile.cxx index c9b349f8..28cccbe9 100644 --- a/src/HYDROCurveCreator/CurveCreator_Profile.cxx +++ b/src/HYDROCurveCreator/CurveCreator_Profile.cxx @@ -218,6 +218,10 @@ bool CurveCreator_Profile::setPointInternal( const CurveCreator::SectionsMap &th { bool aRes = false; + if ( mySkipSorting ) { + return CurveCreator_Curve::setPointInternal( theSectionsMap ); + } + int anISection = 0; CurveCreator_Section* aSection = mySections.at( anISection ); if( !aSection ) @@ -253,3 +257,8 @@ void CurveCreator_Profile::convert( const CurveCreator::PosPointsList& thePoints theConvPoints.push_back( anIPnt ); } } + +bool CurveCreator_Profile::canPointsBeSorted() +{ + return true; +} \ No newline at end of file diff --git a/src/HYDROCurveCreator/CurveCreator_Profile.hxx b/src/HYDROCurveCreator/CurveCreator_Profile.hxx index 947c36a0..3d080011 100644 --- a/src/HYDROCurveCreator/CurveCreator_Profile.hxx +++ b/src/HYDROCurveCreator/CurveCreator_Profile.hxx @@ -122,6 +122,11 @@ public: //! For internal use only! Undo/Redo are not used here. virtual bool setPointInternal( const CurveCreator::SectionsMap &theSectionsMap ); + /** + * Indicates whether the points can be sorted. + */ + virtual bool canPointsBeSorted(); + protected: /** * Converts the list of custom point position objects into a list of point indices diff --git a/src/HYDROCurveCreator/CurveCreator_Widget.cxx b/src/HYDROCurveCreator/CurveCreator_Widget.cxx index 581ce149..5883262f 100644 --- a/src/HYDROCurveCreator/CurveCreator_Widget.cxx +++ b/src/HYDROCurveCreator/CurveCreator_Widget.cxx @@ -975,12 +975,38 @@ void CurveCreator_Widget::onMouseRelease( SUIT_ViewWindow*, QMouseEvent* theEven aDraggedPoints = myDragPoints; setDragStarted( false ); - // if the drag of some points has happened, restore the drag selection - if ( aDraggedPoints.size() > 0 ) - { - START_MEASURE_TIME; - setSelectedPoints( aDraggedPoints ); - END_MEASURE_TIME( "drop" ); + + if ( aDraggedPoints.size() > 0 ) { + if ( myCurve->canPointsBeSorted() ) { + // Apply points sorting + CurveCreator_ICurve::SectionToPointList aPoints; + startCurveModification( aPoints, false ); + + myCurve->setSkipSorting( false ); + + CurveCreator_ICurve::SectionToPointCoordsList aCoordList; + CurveCreator_ICurve::SectionToPointList::const_iterator anIt = aDraggedPoints.begin(), + aLast = aDraggedPoints.end(); + for ( ; anIt != aLast; anIt++ ) { + int aSectionId = anIt->first; + int aPointId = anIt->second; + std::deque aPos = myCurve->getPoint( aSectionId, aPointId ); + + aCoordList.push_back( + std::make_pair( std::make_pair( aSectionId, aPointId ), aPos ) ); + } + + myCurve->setSeveralPoints( aCoordList ); + + finishCurveModification( aDraggedPoints ); + } else { + // if the drag of some points has happened, restore the drag selection + if ( aDraggedPoints.size() > 0 ) { + START_MEASURE_TIME; + setSelectedPoints( aDraggedPoints ); + END_MEASURE_TIME( "drop" ); + } + } } } else // check whether the segment is clicked an a new point should be added to the segment @@ -1235,6 +1261,7 @@ void CurveCreator_Widget::updateLocalPointView() CurveCreator_Utils::getSelectedPoints( aContext, myCurve, myLocalPoints ); int aNbPoints = myLocalPoints.size(); + bool isRowLimit = aNbPoints > myLocalPointRowLimit; myLocalPointView->setVisible( getActionMode() == ModificationMode && !isRowLimit ); @@ -1269,11 +1296,13 @@ void CurveCreator_Widget::setDragStarted( const bool theState, const QPoint& the { if ( theState ) { getSelectedPoints( myDragPoints ); + myDragStarted = myDragPoints.size(); myDragStartPosition = thePoint; if ( myDragStarted ) { // change a viewer interaction style in order to avoid a select rectangle build myDragInteractionStyle = changeInteractionStyle( SUIT_ViewModel::KEY_FREE ); + myCurve->setSkipSorting( true ); } } else {