From e53354ef01af8360be76548c42fb15d46a471e0d Mon Sep 17 00:00:00 2001 From: nds Date: Fri, 16 May 2014 18:26:05 +0400 Subject: [PATCH] refs #30 - Sketch base GUI: create, draw lines 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 | 8 +++----- src/PartSet/PartSet_OperationEditLine.cpp | 3 +-- src/PartSet/PartSet_OperationEditLine.h | 4 +--- src/PartSet/PartSet_OperationSketch.cpp | 16 +++++++++++----- src/PartSet/PartSet_OperationSketch.h | 11 ++++++++--- src/PartSet/PartSet_OperationSketchBase.cpp | 6 +++--- src/PartSet/PartSet_OperationSketchBase.h | 15 +++++++++++---- src/PartSet/PartSet_OperationSketchLine.cpp | 3 +-- src/PartSet/PartSet_OperationSketchLine.h | 4 +--- 9 files changed, 40 insertions(+), 30 deletions(-) diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index b68326fce..08b5bf2b6 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -128,7 +128,8 @@ void PartSet_Module::onMousePressed(QMouseEvent* theEvent) myWorkshop->operationMgr()->currentOperation()); if (aPreviewOp) { - aPreviewOp->mousePressed(theEvent, myWorkshop->viewer()->activeView()); + std::list 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( myWorkshop->operationMgr()->currentOperation()); if (aPreviewOp) - { - std::list aPresentations = myWorkshop->displayer()->GetViewerPrs(); - aPreviewOp->mouseMoved(theEvent, myWorkshop->viewer()->activeView(), aPresentations); - } + aPreviewOp->mouseMoved(theEvent, myWorkshop->viewer()->activeView()); } void PartSet_Module::onKeyRelease(QKeyEvent* theEvent) diff --git a/src/PartSet/PartSet_OperationEditLine.cpp b/src/PartSet/PartSet_OperationEditLine.cpp index ee98295b5..5486ffff0 100644 --- a/src/PartSet/PartSet_OperationEditLine.cpp +++ b/src/PartSet/PartSet_OperationEditLine.cpp @@ -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& theSelected) +void PartSet_OperationEditLine::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView) { if (!(theEvent->buttons() & Qt::LeftButton)) return; diff --git a/src/PartSet/PartSet_OperationEditLine.h b/src/PartSet/PartSet_OperationEditLine.h index 58b911b26..0c225f2f2 100644 --- a/src/PartSet/PartSet_OperationEditLine.h +++ b/src/PartSet/PartSet_OperationEditLine.h @@ -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& 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 diff --git a/src/PartSet/PartSet_OperationSketch.cpp b/src/PartSet/PartSet_OperationSketch.cpp index d96ddc4ac..be977401b 100644 --- a/src/PartSet/PartSet_OperationSketch.cpp +++ b/src/PartSet/PartSet_OperationSketch.cpp @@ -53,6 +53,12 @@ std::list PartSet_OperationSketch::getSelectionModes(boost::shared_ptr& theSelected) +{ + myFeatures = theSelected; +} + void PartSet_OperationSketch::mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView, const std::list& 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& 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 aFeature = PartSet_Tools::NearestFeature(theEvent->pos(), - theView, feature(), theSelected); + theView, feature(), myFeatures); if (aFeature) emit launchOperation(PartSet_OperationEditLine::Type(), aFeature); } diff --git a/src/PartSet/PartSet_OperationSketch.h b/src/PartSet/PartSet_OperationSketch.h index 3f8215ac9..162627c56 100644 --- a/src/PartSet/PartSet_OperationSketch.h +++ b/src/PartSet/PartSet_OperationSketch.h @@ -34,6 +34,12 @@ public: /// \return the selection mode virtual std::list getSelectionModes(boost::shared_ptr 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& 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& 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 myFeatures; ///< the features to apply the edit operation }; #endif diff --git a/src/PartSet/PartSet_OperationSketchBase.cpp b/src/PartSet/PartSet_OperationSketchBase.cpp index daa0211b1..9eac6c82a 100644 --- a/src/PartSet/PartSet_OperationSketchBase.cpp +++ b/src/PartSet/PartSet_OperationSketchBase.cpp @@ -46,14 +46,14 @@ boost::shared_ptr 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& theSelected) { } void PartSet_OperationSketchBase::mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView, const std::list& theSelected) { } -void PartSet_OperationSketchBase::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView, - const std::list& theSelected) +void PartSet_OperationSketchBase::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView) { } diff --git a/src/PartSet/PartSet_OperationSketchBase.h b/src/PartSet/PartSet_OperationSketchBase.h index ad6886c33..62de3116b 100644 --- a/src/PartSet/PartSet_OperationSketchBase.h +++ b/src/PartSet/PartSet_OperationSketchBase.h @@ -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& 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& 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 theFeature, int theMode); + /// Signal about the features should be selected + /// \param theSelected the list of selected presentations + void featureSelected(const std::list& 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 diff --git a/src/PartSet/PartSet_OperationSketchLine.cpp b/src/PartSet/PartSet_OperationSketchLine.cpp index 5d456d875..5fb594a32 100644 --- a/src/PartSet/PartSet_OperationSketchLine.cpp +++ b/src/PartSet/PartSet_OperationSketchLine.cpp @@ -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& /*theSelected*/) +void PartSet_OperationSketchLine::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView) { switch (myPointSelectionMode) { diff --git a/src/PartSet/PartSet_OperationSketchLine.h b/src/PartSet/PartSet_OperationSketchLine.h index f6a281c63..cc5af926c 100644 --- a/src/PartSet/PartSet_OperationSketchLine.h +++ b/src/PartSet/PartSet_OperationSketchLine.h @@ -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& 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); -- 2.39.2