]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
refs #30 - Sketch base GUI: create, draw lines
authornds <natalia.donis@opencascade.com>
Fri, 16 May 2014 14:26:05 +0000 (18:26 +0400)
committernds <natalia.donis@opencascade.com>
Fri, 16 May 2014 14:26:05 +0000 (18:26 +0400)
Move the calculating of the list of selected objects from the mouseMoved to mousePressed method in order to provide better performance.

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

index b68326fce668d0472901811ab5851c8841161ca6..08b5bf2b66300052cd2a920d498e0d3f78ab64ca 100644 (file)
@@ -128,7 +128,8 @@ void PartSet_Module::onMousePressed(QMouseEvent* theEvent)
                                        myWorkshop->operationMgr()->currentOperation());
   if (aPreviewOp)
   {
-    aPreviewOp->mousePressed(theEvent, myWorkshop->viewer()->activeView());
+    std::list<XGUI_ViewerPrs> aPresentations = myWorkshop->displayer()->GetViewerPrs();
+    aPreviewOp->mousePressed(theEvent, myWorkshop->viewer()->activeView(), aPresentations);
   }
 }
 
@@ -148,10 +149,7 @@ void PartSet_Module::onMouseMoved(QMouseEvent* theEvent)
   PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(
                                        myWorkshop->operationMgr()->currentOperation());
   if (aPreviewOp)
-  {
-    std::list<XGUI_ViewerPrs> aPresentations = myWorkshop->displayer()->GetViewerPrs();
-    aPreviewOp->mouseMoved(theEvent, myWorkshop->viewer()->activeView(), aPresentations);
-  }
+    aPreviewOp->mouseMoved(theEvent, myWorkshop->viewer()->activeView());
 }
 
 void PartSet_Module::onKeyRelease(QKeyEvent* theEvent)
index ee98295b559a7ecd20acfae51997448bf5174143..5486ffff028ff7ddc4aa93668172e25c2163746d 100644 (file)
@@ -63,8 +63,7 @@ void PartSet_OperationEditLine::mousePressed(QMouseEvent* theEvent, Handle(V3d_V
   myCurPoint.setPoint(aPoint);
 }
 
-void PartSet_OperationEditLine::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView,
-                                           const std::list<XGUI_ViewerPrs>& theSelected)
+void PartSet_OperationEditLine::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView)
 {
   if (!(theEvent->buttons() &  Qt::LeftButton))
     return;
index 58b911b261e0663b0dbe67c48b8b2de456edd1e5..0c225f2f2b0fd2661e66aef6d94941c6d3a7833d 100644 (file)
@@ -82,9 +82,7 @@ public:
   /// Gives the current mouse point in the viewer
   /// \param thePoint a point clicked in the viewer
   /// \param theEvent the mouse event
-  /// \param theSelected the list of selected presentations
-  virtual void mouseMoved(QMouseEvent* theEvent, Handle_V3d_View theView,
-                          const std::list<XGUI_ViewerPrs>& theSelected);
+  virtual void mouseMoved(QMouseEvent* theEvent, Handle_V3d_View theView);
   /// Gives the current selected objects to be processed by the operation
   /// \param thePoint a point clicked in the viewer
   /// \param theEvent the mouse event
index d96ddc4ac7013029f350eea6f459aee2a2045f0e..be977401bd73b9edfdc20fb388831a478145678c 100644 (file)
@@ -53,6 +53,12 @@ std::list<int> PartSet_OperationSketch::getSelectionModes(boost::shared_ptr<Mode
   return aModes;
 }
 
+void PartSet_OperationSketch::mousePressed(QMouseEvent* theEvent, Handle_V3d_View theView,
+                                           const std::list<XGUI_ViewerPrs>& theSelected)
+{
+  myFeatures = theSelected;
+}
+
 void PartSet_OperationSketch::mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView,
                                             const std::list<XGUI_ViewerPrs>& theSelected)
 {
@@ -74,17 +80,17 @@ void PartSet_OperationSketch::mouseReleased(QMouseEvent* theEvent, Handle_V3d_Vi
         emit launchOperation(PartSet_OperationEditLine::Type(), aFeature);
     }
   }
+  myFeatures.clear();
 }
 
-void PartSet_OperationSketch::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView,
-                                         const std::list<XGUI_ViewerPrs>& theSelected)
+void PartSet_OperationSketch::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView)
 {
-  if (!myIsEditMode || !(theEvent->buttons() &  Qt::LeftButton) || theSelected.empty())
+  if (!myIsEditMode || !(theEvent->buttons() &  Qt::LeftButton) || myFeatures.empty())
     return;
 
-  if (theSelected.size() != 1) {
+  if (myFeatures.size() != 1) {
     boost::shared_ptr<ModelAPI_Feature> aFeature = PartSet_Tools::NearestFeature(theEvent->pos(),
-                                                                theView, feature(), theSelected);
+                                                                theView, feature(), myFeatures);
     if (aFeature)
       emit launchOperation(PartSet_OperationEditLine::Type(), aFeature);
   }
index 3f8215ac953f30f081ebfbdb80720a2ac6e014b2..162627c5623a4e350585943c8873663f9f484849 100644 (file)
@@ -34,6 +34,12 @@ public:
   /// \return the selection mode
   virtual std::list<int> getSelectionModes(boost::shared_ptr<ModelAPI_Feature> theFeature) const;
 
+  /// Processes the mouse pressed in the point
+  /// \param thePoint a point clicked in the viewer
+  /// \param theEvent the mouse event
+  /// \param theSelected the list of selected presentations
+  virtual void mousePressed(QMouseEvent* theEvent, Handle_V3d_View theView,
+                            const std::list<XGUI_ViewerPrs>& theSelected);
   /// Processes the mouse release in the point
   /// \param thePoint a point clicked in the viewer
   /// \param theEvent the mouse event
@@ -43,9 +49,7 @@ public:
   /// Gives the current mouse point in the viewer
   /// \param thePoint a point clicked in the viewer
   /// \param theEvent the mouse event
-  /// \param theSelected the list of selected presentations
-  virtual void mouseMoved(QMouseEvent* theEvent, Handle_V3d_View theView,
-                          const std::list<XGUI_ViewerPrs>& theSelected);
+  virtual void mouseMoved(QMouseEvent* theEvent, Handle_V3d_View theView);
 
   /// Returns the map of the operation previews including the nested feature previews
   /// \return the map of feature to the feature preview
@@ -65,6 +69,7 @@ protected:
 
 private:
   bool myIsEditMode; /// the edit mode of this operation
+  std::list<XGUI_ViewerPrs> myFeatures; ///< the features to apply the edit operation
 };
 
 #endif
index daa0211b1d8b0656ccaf4f0162af8357a5057598..9eac6c82afb55df6867d81a97dffc5918aa593a7 100644 (file)
@@ -46,14 +46,14 @@ boost::shared_ptr<ModelAPI_Feature> PartSet_OperationSketchBase::createFeature()
 }
 
 
-void PartSet_OperationSketchBase::mousePressed(QMouseEvent* theEvent, Handle_V3d_View theView)
+void PartSet_OperationSketchBase::mousePressed(QMouseEvent* theEvent, Handle_V3d_View theView,
+                                               const std::list<XGUI_ViewerPrs>& theSelected)
 {
 }
 void PartSet_OperationSketchBase::mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView,
                                                 const std::list<XGUI_ViewerPrs>& theSelected)
 {
 }
-void PartSet_OperationSketchBase::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView,
-                                             const std::list<XGUI_ViewerPrs>& theSelected)
+void PartSet_OperationSketchBase::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView)
 {
 }
index ad6886c330a9e951974e860d7814240797429d39..62de3116be461513ee152639edc724378ec645e6 100644 (file)
@@ -63,7 +63,9 @@ public:
   /// Processes the mouse pressed in the point
   /// \param thePoint a point clicked in the viewer
   /// \param theEvent the mouse event
-  virtual void mousePressed(QMouseEvent* theEvent, Handle_V3d_View theView);
+  /// \param theSelected the list of selected presentations
+  virtual void mousePressed(QMouseEvent* theEvent, Handle_V3d_View theView,
+                            const std::list<XGUI_ViewerPrs>& theSelected);
 
   /// Processes the mouse release in the point
   /// \param thePoint a point clicked in the viewer
@@ -75,9 +77,7 @@ public:
   /// Processes the mouse move in the point
   /// \param thePoint a 3D point clicked in the viewer
   /// \param theEvent the mouse event
-  /// \param theSelected the list of selected presentations
-  virtual void mouseMoved(QMouseEvent* theEvent, Handle_V3d_View theView,
-                          const std::list<XGUI_ViewerPrs>& theSelected);
+  virtual void mouseMoved(QMouseEvent* theEvent, Handle_V3d_View theView);
 
   /// Processes the key pressed in the view
   /// \param theKey a key value
@@ -89,6 +89,9 @@ signals:
   /// \param theMode the mode of the feature modification
   void featureConstructed(boost::shared_ptr<ModelAPI_Feature> theFeature,
                           int theMode);
+  /// Signal about the features should be selected
+  /// \param theSelected the list of selected presentations
+  void featureSelected(const std::list<XGUI_ViewerPrs>& theSelected);
   /// signal about the request to launch operation
   /// theName the operation name
   /// theFeature the operation argument
@@ -97,6 +100,10 @@ signals:
   /// \param theEnabled the boolean state
   void multiSelectionEnabled(bool theEnabled);
 
+  /// signal to enable/disable usual selection in the viewer
+  /// \param theEnabled the boolean state
+  void selectionEnabled(bool theEnabled);
+
 protected:
   /// Creates an operation new feature
   /// In addition to the default realization it appends the created line feature to
index 5d456d875352b8678095b66598dbf35b2b32ebb8..5fb594a3264d2f03df6971fa6954e18f9fb79ecf 100644 (file)
@@ -150,8 +150,7 @@ void PartSet_OperationSketchLine::mouseReleased(QMouseEvent* theEvent, Handle(V3
   }
 }
 
-void PartSet_OperationSketchLine::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView,
-                                             const std::list<XGUI_ViewerPrs>& /*theSelected*/)
+void PartSet_OperationSketchLine::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView)
 {
   switch (myPointSelectionMode)
   {
index f6a281c6391c7438e04bf1390a59fe7dd3b127d1..cc5af926c2bbf2522397b2e38f2d667a9a9295a3 100644 (file)
@@ -59,9 +59,7 @@ public:
   /// Gives the current mouse point in the viewer
   /// \param thePoint a point clicked in the viewer
   /// \param theEvent the mouse event
-  /// \param theSelected the list of selected presentations
-  virtual void mouseMoved(QMouseEvent* theEvent, Handle_V3d_View theView,
-                          const std::list<XGUI_ViewerPrs>& theSelected);
+  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);