Move the calculating of the list of selected objects from the mouseMoved to mousePressed method in order to provide better performance.
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);
}
}
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)
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;
/// 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
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)
{
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);
}
/// \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
/// 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
private:
bool myIsEditMode; /// the edit mode of this operation
+ std::list<XGUI_ViewerPrs> myFeatures; ///< the features to apply the edit operation
};
#endif
}
-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)
{
}
/// 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
/// 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
/// \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
/// \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
}
}
-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)
{
/// 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);