]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
Bug #186: Profile point drag and drop catching the neighbour point.
authormzn <mzn@opencascade.com>
Fri, 6 Dec 2013 10:44:31 +0000 (10:44 +0000)
committermzn <mzn@opencascade.com>
Fri, 6 Dec 2013 10:44:31 +0000 (10:44 +0000)
src/HYDROCurveCreator/CurveCreator_Curve.cxx
src/HYDROCurveCreator/CurveCreator_Curve.hxx
src/HYDROCurveCreator/CurveCreator_ICurve.hxx
src/HYDROCurveCreator/CurveCreator_Profile.cxx
src/HYDROCurveCreator/CurveCreator_Profile.hxx
src/HYDROCurveCreator/CurveCreator_Widget.cxx

index 0c6c45be4b9bb85032d42816ef96cd575d0aabac..8e3a432827f0d91f158a97c411904e283382aa58 100644 (file)
@@ -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
 {
index 3c41e711c760d2e8428d70f54395ba9bf45b69e0..ab073b7b0a7fd665a31b1d4fad8859c652e6d510 100644 (file)
@@ -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
index 40696e9bebe51e741207ff1852a71f72a42c7830..229256ce082e333c8e9d92b9fe42bd84886b871c 100644 (file)
@@ -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              ***/
index c9b349f834aed41eb46b29a02ba0831db1d14039..28cccbe9418ad7daa39ef004b29a149ae7a10a29 100644 (file)
@@ -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
index 947c36a08c85c4ea7f52135c1ea176c3c3d2eb8f..3d08001131926873bda910faedcf9658b66f7613 100644 (file)
@@ -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
index 581ce1491ac4d3d3fa7480689b854584f88cc151..5883262f41a3640b332d8c19eb2ab8912f6abcfc 100644 (file)
@@ -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<float> 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 {