]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
refs #30 - Sketch base GUI: create, draw lines
authornds <natalia.donis@opencascade.com>
Tue, 6 May 2014 13:04:53 +0000 (17:04 +0400)
committernds <natalia.donis@opencascade.com>
Tue, 6 May 2014 13:04:53 +0000 (17:04 +0400)
Give V3d_view to the operation to calculate correctly a projection to sketch plane.

src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_OperationEditLine.cpp
src/PartSet/PartSet_OperationEditLine.h
src/PartSet/PartSet_OperationSketchBase.cpp
src/PartSet/PartSet_OperationSketchBase.h
src/PartSet/PartSet_OperationSketchLine.cpp
src/PartSet/PartSet_OperationSketchLine.h

index d77c02df5a5fd8f0dd339123b9de6bf492ac3915..0939b57fe7a371673b623d07d00a56a11ed7d672 100644 (file)
@@ -5,7 +5,6 @@
 #include <ModuleBase_Operation.h>
 #include <ModuleBase_OperationDescription.h>
 #include <PartSet_Listener.h>
-#include <PartSet_Tools.h>
 
 #include <ModuleBase_Operation.h>
 
@@ -150,9 +149,7 @@ void PartSet_Module::onMousePressed(QMouseEvent* theEvent)
                                        myWorkshop->operationMgr()->currentOperation());
   if (aPreviewOp)
   {
-    gp_Pnt aPnt = PartSet_Tools::ConvertClickToPoint(theEvent->pos(),
-                                                     myWorkshop->viewer()->activeView());
-    aPreviewOp->mousePressed(aPnt, theEvent);
+    aPreviewOp->mousePressed(theEvent, myWorkshop->viewer()->activeView());
   }
 }
 
@@ -162,9 +159,7 @@ void PartSet_Module::onMouseReleased(QMouseEvent* theEvent)
                                        myWorkshop->operationMgr()->currentOperation());
   if (aPreviewOp)
   {
-    gp_Pnt aPnt = PartSet_Tools::ConvertClickToPoint(theEvent->pos(),
-                                                     myWorkshop->viewer()->activeView());
-    aPreviewOp->mouseReleased(aPnt, theEvent);
+    aPreviewOp->mouseReleased(theEvent, myWorkshop->viewer()->activeView());
   }
 }
 
@@ -174,9 +169,7 @@ void PartSet_Module::onMouseMoved(QMouseEvent* theEvent)
                                        myWorkshop->operationMgr()->currentOperation());
   if (aPreviewOp)
   {
-    gp_Pnt aPnt = PartSet_Tools::ConvertClickToPoint(theEvent->pos(),
-                                                     myWorkshop->viewer()->activeView());
-    aPreviewOp->mouseMoved(aPnt, theEvent);
+    aPreviewOp->mouseMoved(theEvent, myWorkshop->viewer()->activeView());
   }
 }
 
index 7841945757e335b9f7c0955075537b1bc4ec9925..1085f2d334f5c78ed88c801624abd1d20f2efe7b 100644 (file)
@@ -12,6 +12,8 @@
 
 #include <SketchPlugin_Line.h>
 
+#include <V3d_View.hxx>
+
 #ifdef _DEBUG
 #include <QDebug>
 #endif
@@ -49,14 +51,15 @@ void PartSet_OperationEditLine::init(boost::shared_ptr<ModelAPI_Feature> theFeat
   setFeature(theFeature);
 }
 
-void PartSet_OperationEditLine::mousePressed(const gp_Pnt& thePoint, QMouseEvent* theEvent)
+void PartSet_OperationEditLine::mousePressed(QMouseEvent* theEvent, Handle(V3d_View) theView)
 {
   if (!(theEvent->buttons() &  Qt::LeftButton))
     return;
-  myCurPressed = thePoint;
+  gp_Pnt aPoint = PartSet_Tools::ConvertClickToPoint(theEvent->pos(), theView);
+  myCurPressed = aPoint;
 }
 
-void PartSet_OperationEditLine::mouseMoved(const gp_Pnt& thePoint, QMouseEvent* theEvent)
+void PartSet_OperationEditLine::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView)
 {
   if (!(theEvent->buttons() &  Qt::LeftButton))
     return;
@@ -65,14 +68,15 @@ void PartSet_OperationEditLine::mouseMoved(const gp_Pnt& thePoint, QMouseEvent*
   PartSet_Tools::ConvertTo2D(myCurPressed, mySketch, aCurX, aCurY);
 
   double aX, anY;
-  PartSet_Tools::ConvertTo2D(thePoint, mySketch, aX, anY);
+  gp_Pnt aPoint = PartSet_Tools::ConvertClickToPoint(theEvent->pos(), theView);
+  PartSet_Tools::ConvertTo2D(aPoint, mySketch, aX, anY);
 
   double aDeltaX = aX - aCurX;
   double aDeltaY = anY - aCurY;
 
   moveLinePoint(aDeltaX, aDeltaY, LINE_ATTR_START);
   moveLinePoint(aDeltaX, aDeltaY, LINE_ATTR_END);
-  myCurPressed = thePoint;
+  myCurPressed = aPoint;
 }
 
 void PartSet_OperationEditLine::setSelected(boost::shared_ptr<ModelAPI_Feature> theFeature,
index 28ae00298202162d6157785adea0bb640d7399e8..01a705386ccaf5d89919cbd8d3c8f426a58cf238 100644 (file)
@@ -49,11 +49,11 @@ public:
   /// Processes the mouse pressed in the point
   /// \param thePoint a point clicked in the viewer
   /// \param theEvent the mouse event
-  virtual void mousePressed(const gp_Pnt& thePoint, QMouseEvent* theEvent);
+  virtual void mousePressed(QMouseEvent* theEvent, Handle_V3d_View theView);
   /// Gives the current mouse point in the viewer
   /// \param thePoint a point clicked in the viewer
   /// \param theEvent the mouse event
-  virtual void mouseMoved(const gp_Pnt& thePoint, QMouseEvent* theEvent);
+  virtual void mouseMoved(QMouseEvent* theEvent, Handle_V3d_View theView);
 
   /// Gives the current selected objects to be processed by the operation
   /// \param theFeature the selected feature
index d424849b1364f96560a8dadced238af6cc30b4a8..08e7435721d17c2dfe2fc5675b0e778e532ecfda 100644 (file)
@@ -6,6 +6,8 @@
 
 #include <SketchPlugin_Feature.h>
 
+#include <V3d_View.hxx>
+
 #ifdef _DEBUG
 #include <QDebug>
 #endif
@@ -36,3 +38,14 @@ boost::shared_ptr<ModelAPI_Feature> PartSet_OperationSketchBase::createFeature()
   emit featureConstructed(aFeature, FM_Activation);
   return aFeature;
 }
+
+
+void PartSet_OperationSketchBase::mousePressed(QMouseEvent* theEvent, Handle_V3d_View theView)
+{
+}
+void PartSet_OperationSketchBase::mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView)
+{
+}
+void PartSet_OperationSketchBase::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView)
+{
+}
index a7bcf789a42d06dcdd525c8f16fd041c2de870ce..45a6b77d4d0c18cdbe390610a4a5dc3f30ef2b3e 100644 (file)
@@ -15,8 +15,8 @@
 #include <ModuleBase_Operation.h>
 #include <QObject>
 
+class Handle_V3d_View;
 class QMouseEvent;
-
 class GeomAPI_Shape;
 
 /*!
@@ -60,17 +60,17 @@ public:
   /// Processes the mouse pressed in the point
   /// \param thePoint a point clicked in the viewer
   /// \param theEvent the mouse event
-  virtual void mousePressed(const gp_Pnt& thePoint, QMouseEvent* theEvent) {};
+  virtual void mousePressed(QMouseEvent* theEvent, Handle_V3d_View theView);
 
   /// Processes the mouse release in the point
   /// \param thePoint a point clicked in the viewer
   /// \param theEvent the mouse event
-  virtual void mouseReleased(const gp_Pnt& thePoint, QMouseEvent* theEvent) {};
+  virtual void mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView);
 
   /// Processes the mouse move in the point
   /// \param thePoint a 3D point clicked in the viewer
   /// \param theEvent the mouse event
-  virtual void mouseMoved(const gp_Pnt& thePoint, QMouseEvent* theEvent) {};
+  virtual void mouseMoved(QMouseEvent* theEvent, Handle_V3d_View theView);
 
   /// Processes the key pressed in the view
   /// \param theKey a key value
index cc4c02ede5a11459a634871571c04774dbadb17c..a0ab16944dccf4adb1b251849df9405b39846d20 100644 (file)
 
 #include <SketchPlugin_Line.h>
 
+#include <V3d_View.hxx>
+
 #ifdef _DEBUG
 #include <QDebug>
 #endif
 
+#include <QMouseEvent>
+
 using namespace std;
 
 PartSet_OperationSketchLine::PartSet_OperationSketchLine(const QString& theId,
@@ -50,17 +54,18 @@ void PartSet_OperationSketchLine::init(boost::shared_ptr<ModelAPI_Feature> theFe
   myInitPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(LINE_ATTR_END));
 }
 
-void PartSet_OperationSketchLine::mouseReleased(const gp_Pnt& thePoint, QMouseEvent* /*theEvent*/)
+void PartSet_OperationSketchLine::mouseReleased(QMouseEvent* theEvent, Handle(V3d_View) theView)
 {
+  gp_Pnt aPoint = PartSet_Tools::ConvertClickToPoint(theEvent->pos(), theView);
   switch (myPointSelectionMode)
   {
     case SM_FirstPoint: {
-      setLinePoint(thePoint, LINE_ATTR_START);
+      setLinePoint(aPoint, LINE_ATTR_START);
       myPointSelectionMode = SM_SecondPoint;
     }
     break;
     case SM_SecondPoint: {
-      setLinePoint(thePoint, LINE_ATTR_END);
+      setLinePoint(aPoint, LINE_ATTR_END);
       commit();
       emit featureConstructed(feature(), FM_Deactivation);
       emit launchOperation(PartSet_OperationSketchLine::Type(), feature());
@@ -71,13 +76,16 @@ void PartSet_OperationSketchLine::mouseReleased(const gp_Pnt& thePoint, QMouseEv
   }
 }
 
-void PartSet_OperationSketchLine::mouseMoved(const gp_Pnt& thePoint, QMouseEvent* /*theEvent*/)
+void PartSet_OperationSketchLine::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView)
 {
   switch (myPointSelectionMode)
   {
     case SM_SecondPoint:
-      setLinePoint(thePoint, LINE_ATTR_END);
-      break;
+    {
+      gp_Pnt aPoint = PartSet_Tools::ConvertClickToPoint(theEvent->pos(), theView);
+      setLinePoint(aPoint, LINE_ATTR_END);
+    }
+    break;
     default:
       break;
   }
index 044e739ffd777c2c9b0e36df862780c35417ae06..e979034ddbc46c74f878143b5631025c37389d6c 100644 (file)
@@ -51,11 +51,11 @@ public:
   /// Gives the current selected objects to be processed by the operation
   /// \param thePoint a point clicked in the viewer
   /// \param theEvent the mouse event
-  virtual void mouseReleased(const gp_Pnt& thePoint, QMouseEvent* theEvent);
+  virtual void mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView);
   /// Gives the current mouse point in the viewer
   /// \param thePoint a point clicked in the viewer
   /// \param theEvent the mouse event
-  virtual void mouseMoved(const gp_Pnt& thePoint, QMouseEvent* theEvent);
+  virtual void mouseMoved(QMouseEvent* theEvent, Handle_V3d_View theView);
   /// Processes the key pressed in the view
   /// \param theKey a key value
   virtual void keyReleased(const int theKey);