]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
refs #30 - Sketch base GUI: create, draw lines
authornds <natalia.donis@opencascade.com>
Wed, 21 May 2014 07:02:41 +0000 (11:02 +0400)
committernds <natalia.donis@opencascade.com>
Wed, 21 May 2014 07:02:41 +0000 (11:02 +0400)
According to the document, the start position of line should be changed by the mouse cursor move.

src/PartSet/PartSet_OperationSketchLine.cpp
src/PartSet/PartSet_OperationSketchLine.h

index dc67cae98597bc69e3eb376851b9f01fa54b9dcd..36c969305b60f69ecbb67385904e4b44cd379514 100644 (file)
@@ -147,9 +147,7 @@ void PartSet_OperationSketchLine::mouseReleased(QMouseEvent* theEvent, Handle(V3
     break;
     case SM_SecondPoint: {
       setLinePoint(feature(), aX, anY, LINE_ATTR_END);
-      commit();
-      emit featureConstructed(feature(), FM_Deactivation);
-      emit launchOperation(PartSet_OperationSketchLine::Type(), feature());
+      myPointSelectionMode = SM_DonePoint;
     }
     break;
     default:
@@ -161,12 +159,26 @@ void PartSet_OperationSketchLine::mouseMoved(QMouseEvent* theEvent, Handle(V3d_V
 {
   switch (myPointSelectionMode)
   {
+    case SM_FirstPoint: {
+      double aX, anY;
+      gp_Pnt aPoint = PartSet_Tools::ConvertClickToPoint(theEvent->pos(), theView);
+      PartSet_Tools::ConvertTo2D(aPoint, sketch(), theView, aX, anY);
+      setLinePoint(feature(), aX, anY, LINE_ATTR_START);
+      setLinePoint(feature(), aX, anY, LINE_ATTR_END);
+    }
+    break;
     case SM_SecondPoint:
     {
       gp_Pnt aPoint = PartSet_Tools::ConvertClickToPoint(theEvent->pos(), theView);
       setLinePoint(aPoint, theView, LINE_ATTR_END);
     }
     break;
+    case SM_DonePoint:
+    {
+      commit();
+      emit featureConstructed(feature(), FM_Deactivation);
+      emit launchOperation(PartSet_OperationSketchLine::Type(), feature());
+    }
     default:
       break;
   }
@@ -176,7 +188,13 @@ void PartSet_OperationSketchLine::keyReleased(const int theKey)
 {
   switch (theKey) {
     case Qt::Key_Return: {
-      abort();
+      if (myPointSelectionMode == SM_DonePoint)
+      {
+        commit();
+        emit featureConstructed(feature(), FM_Deactivation);
+      }
+      else
+        abort();
       emit launchOperation(PartSet_OperationSketchLine::Type(), boost::shared_ptr<ModelAPI_Feature>());
     }
     break;
index e6cabaa88094279333330d2e6a6bf8ac42df1ce3..09c33f6f452621540d8d17e9ede546f703c417e7 100644 (file)
@@ -128,7 +128,7 @@ protected:
 
 protected:
   ///< Structure to lists the possible types of point selection modes
-  enum PointSelectionMode {SM_FirstPoint, SM_SecondPoint};
+  enum PointSelectionMode {SM_FirstPoint, SM_SecondPoint, SM_DonePoint};
 
 private:
   boost::shared_ptr<ModelAPI_Feature> mySketch; ///< the sketch feature