Mouse released is processed as the selection change.
connect(anOperationMgr, SIGNAL(operationStopped(ModuleBase_Operation*)),
this, SLOT(onOperationStopped(ModuleBase_Operation*)));
- connect(myWorkshop->selector(), SIGNAL(selectionChanged()),
- this, SLOT(onSelectionChanged()));
connect(myWorkshop->viewer(), SIGNAL(mousePress(QMouseEvent*)),
this, SLOT(onMousePressed(QMouseEvent*)));
connect(myWorkshop->viewer(), SIGNAL(mouseRelease(QMouseEvent*)),
}
}
-void PartSet_Module::onSelectionChanged()
-{
- ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
- PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
- if (aPreviewOp) {
- XGUI_SelectionMgr* aSelector = myWorkshop->selector();
- if (aSelector) {
- NCollection_List<TopoDS_Shape> aList;
- aSelector->selectedShapes(aList);
-
- XGUI_Displayer* aDisplayer = myWorkshop->displayer();
- boost::shared_ptr<ModelAPI_Feature> aFeature;
- // only first selected shape is processed
- if (!aList.IsEmpty()) {
- aFeature = aDisplayer->GetFeature(aList.First());
- }
- aPreviewOp->setSelected(aFeature, !aList.IsEmpty() ? aList.First() : TopoDS_Shape());
- }
- }
-}
-
void PartSet_Module::onMousePressed(QMouseEvent* theEvent)
{
PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(
myWorkshop->operationMgr()->currentOperation());
if (aPreviewOp)
{
- aPreviewOp->mouseReleased(theEvent, myWorkshop->viewer()->activeView());
+ XGUI_SelectionMgr* aSelector = myWorkshop->selector();
+ std::list<XGUI_ViewerPrs> aPresentations;
+ if (aSelector) {
+ NCollection_List<TopoDS_Shape> aList;
+ aSelector->selectedShapes(aList);
+
+ aPresentations = myWorkshop->displayer()->GetViewerPrs(aList);
+ }
+ aPreviewOp->mouseReleased(theEvent, myWorkshop->viewer()->activeView(), aPresentations);
}
}
/// by the operation start
void onOperationStopped(ModuleBase_Operation* theOperation);
- /// SLOT, that is called by the selection in the viewer is changed.
- /// The selection is sent to the current operation if it listens selection.
- void onSelectionChanged();
/// SLOT, that is called by mouse press in the viewer.
/// The mouse released point is sent to the current operation to be processed.
/// \param theEvent the mouse event
#include <PartSet_OperationEditLine.h>
#include <PartSet_Tools.h>
+#include <XGUI_ViewerPrs.h>
+
#include <SketchPlugin_Feature.h>
#include <GeomDataAPI_Point2D.h>
#include <ModelAPI_Data.h>
myCurPressed = aPoint;
}
-void PartSet_OperationEditLine::setSelected(boost::shared_ptr<ModelAPI_Feature> theFeature,
- const TopoDS_Shape& theShape)
+void PartSet_OperationEditLine::mouseReleased(QMouseEvent* theEvent, Handle(V3d_View) theView,
+ const std::list<XGUI_ViewerPrs>& theSelected)
{
- if (theFeature == feature())
+ boost::shared_ptr<ModelAPI_Feature> aFeature;
+ if (!theSelected.empty())
+ aFeature = theSelected.front().feature();
+
+ if (aFeature == feature())
return;
-
+
commit();
-
- if (theFeature)
- emit launchOperation(PartSet_OperationEditLine::Type(), theFeature);
+ if (aFeature)
+ emit launchOperation(PartSet_OperationEditLine::Type(), aFeature);
}
void PartSet_OperationEditLine::startOperation()
/// \param thePoint a point clicked in the viewer
/// \param theEvent the mouse event
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
- /// \param theShape the selected shape
- virtual void setSelected(boost::shared_ptr<ModelAPI_Feature> theFeature,
- const TopoDS_Shape& theShape);
-
+ /// \param thePoint a point clicked in the viewer
+ /// \param theEvent the mouse event
+ /// \param theSelected the list of selected presentations
+ virtual void mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView,
+ const std::list<XGUI_ViewerPrs>& theSelected);
protected:
/// \brief Virtual method called when operation is started
/// Virtual method called when operation started (see start() method for more description)
#include <GeomDataAPI_Point.h>
#include <GeomDataAPI_Dir.h>
+#include <XGUI_ViewerPrs.h>
+
#include <AIS_Shape.hxx>
#include <AIS_ListOfInteractive.hxx>
+#include <V3d_View.hxx>
#ifdef _DEBUG
#include <QDebug>
return aModes;
}
-void PartSet_OperationSketch::setSelected(boost::shared_ptr<ModelAPI_Feature> theFeature,
- const TopoDS_Shape& theShape)
+void PartSet_OperationSketch::mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView,
+ const std::list<XGUI_ViewerPrs>& theSelected)
{
- if (theShape.IsNull())
+ if (theSelected.empty())
return;
+ XGUI_ViewerPrs aPrs = theSelected.front();
if (!myIsEditMode) {
- setSketchPlane(theShape);
- myIsEditMode = true;
+ const TopoDS_Shape& aShape = aPrs.shape();
+ if (!aShape.IsNull()) {
+ setSketchPlane(aShape);
+ myIsEditMode = true;
+ }
+ }
+ else {
+ if (aPrs.feature())
+ emit launchOperation(PartSet_OperationEditLine::Type(), aPrs.feature());
}
- else if (theFeature)
- emit launchOperation(PartSet_OperationEditLine::Type(), theFeature);
}
void PartSet_OperationSketch::setSketchPlane(const TopoDS_Shape& theShape)
/// \return the selection mode
virtual std::list<int> getSelectionModes(boost::shared_ptr<ModelAPI_Feature> theFeature) const;
- /// Gives the current selected objects to be processed by the operation
- /// \param theFeature the selected feature
- /// \param theShape the selected shape
- virtual void setSelected(boost::shared_ptr<ModelAPI_Feature> theFeature,
- const TopoDS_Shape& theShape);
+ /// Processes the mouse release 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 mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView,
+ const std::list<XGUI_ViewerPrs>& theSelected);
signals:
/// signal about the sketch plane is selected
void PartSet_OperationSketchBase::mousePressed(QMouseEvent* theEvent, Handle_V3d_View theView)
{
}
-void PartSet_OperationSketchBase::mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView)
+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)
class Handle_V3d_View;
class QMouseEvent;
class GeomAPI_Shape;
+class XGUI_ViewerPrs;
/*!
\class PartSet_OperationSketchBase
/// \param theFeature the feature
virtual void init(boost::shared_ptr<ModelAPI_Feature> theFeature) {}
- /// Gives the current selected objects to be processed by the operation
- /// \param theFeature the selected feature
- /// \param theShape the selected shape
- virtual void setSelected(boost::shared_ptr<ModelAPI_Feature> theFeature,
- const TopoDS_Shape& theShape) {};
-
/// Processes the mouse pressed in the point
/// \param thePoint a point clicked in the viewer
/// \param theEvent the mouse event
/// Processes the mouse release in the point
/// \param thePoint a point clicked in the viewer
/// \param theEvent the mouse event
- virtual void mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView);
+ /// \param theSelected the list of selected presentations
+ virtual void mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView,
+ const std::list<XGUI_ViewerPrs>& theSelected);
/// Processes the mouse move in the point
/// \param thePoint a 3D point clicked in the viewer
myInitPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(LINE_ATTR_END));
}
-void PartSet_OperationSketchLine::mouseReleased(QMouseEvent* theEvent, Handle(V3d_View) theView)
+void PartSet_OperationSketchLine::mouseReleased(QMouseEvent* theEvent, Handle(V3d_View) theView,
+ const std::list<XGUI_ViewerPrs>& theSelected)
{
gp_Pnt aPoint = PartSet_Tools::ConvertClickToPoint(theEvent->pos(), theView);
switch (myPointSelectionMode)
/// 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(QMouseEvent* theEvent, Handle_V3d_View theView);
+ /// \param theSelected the list of selected presentations
+ virtual void mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView,
+ const std::list<XGUI_ViewerPrs>& theSelected);
/// Gives the current mouse point in the viewer
/// \param thePoint a point clicked in the viewer
/// \param theEvent the mouse event
XGUI_ErrorDialog.h
XGUI_SalomeViewer.h
XGUI_ViewerProxy.h
+ XGUI_ViewerPrs.h
XGUI_PropertyPanel.h
)
XGUI_ActionsMgr.cpp
XGUI_ErrorDialog.cpp
XGUI_ViewerProxy.cpp
+ XGUI_ViewerPrs.cpp
XGUI_PropertyPanel.cpp
)
return aFeature;
}
+std::list<XGUI_ViewerPrs> XGUI_Displayer::GetViewerPrs
+ (const NCollection_List<TopoDS_Shape>& theShapes)
+{
+ std::list<XGUI_ViewerPrs> aPresentations;
+ if (theShapes.IsEmpty())
+ return aPresentations;
+
+ NCollection_List<TopoDS_Shape>::Iterator anIt(theShapes);
+ for (; anIt.More(); anIt.Next()) {
+ const TopoDS_Shape& aShape = anIt.Value();
+ if (aShape.IsNull())
+ continue;
+ boost::shared_ptr<ModelAPI_Feature> aFeature = GetFeature(aShape);
+ aPresentations.push_back(XGUI_ViewerPrs(aFeature, aShape));
+ }
+
+ return aPresentations;
+}
+
void XGUI_Displayer::Erase(boost::shared_ptr<ModelAPI_Feature> theFeature,
const bool isUpdateViewer)
{
#include <TopoDS_Shape.hxx>
#include <AIS_InteractiveObject.hxx>
#include <AIS_InteractiveContext.hxx>
+#include <NCollection_List.hxx>
+
+#include <XGUI_ViewerPrs.h>
#include <map>
#include <vector>
/// Returns the feature, that was displayed with this shape
/// \param theShape a shape
- boost::shared_ptr<ModelAPI_Feature> GetFeature( const TopoDS_Shape& theShape );
+ boost::shared_ptr<ModelAPI_Feature> GetFeature(const TopoDS_Shape& theShape);
+
+ /// Returns a list of viewer presentations
+ /// \param theShapes list of shapes to find corresponded features
+ /// \return list of presentations
+ std::list<XGUI_ViewerPrs> GetViewerPrs(const NCollection_List<TopoDS_Shape>& theShapes);
/// Display the shape and activate selection of sub-shapes
/// \param theFeature a feature instance
--- /dev/null
+// File: XGUI_ViewerPrs.cpp
+// Created: 20 Apr 2014
+// Author: Natalia ERMOLAEVA
+
+#include "XGUI_ViewerPrs.h"
+
+XGUI_ViewerPrs::XGUI_ViewerPrs()
+{
+}
+
+XGUI_ViewerPrs::XGUI_ViewerPrs(boost::shared_ptr<ModelAPI_Feature> theFeature,
+ const TopoDS_Shape& theShape)
+: myFeature(theFeature), myShape(theShape)
+{
+}
+
+XGUI_ViewerPrs::~XGUI_ViewerPrs()
+{
+}
+
+void XGUI_ViewerPrs::setFeature(boost::shared_ptr<ModelAPI_Feature> theFeature)
+{
+ myFeature = theFeature;
+}
+
+void XGUI_ViewerPrs::setShape(const TopoDS_Shape& theShape)
+{
+ myShape = theShape;
+}
+
+boost::shared_ptr<ModelAPI_Feature> XGUI_ViewerPrs::feature() const
+{
+ return myFeature;
+}
+
+const TopoDS_Shape& XGUI_ViewerPrs::shape() const
+{
+ return myShape;
+}
--- /dev/null
+// File: XGUI_ViewerPrs.h
+// Created: 20 Apr 2014
+// Author: Natalia ERMOLAEVA
+
+#ifndef XGUI_ViewerPrs_H
+#define XGUI_ViewerPrs_H
+
+#include "XGUI.h"
+
+#include <boost/shared_ptr.hpp>
+#include <TopoDS_Shape.hxx>
+
+class ModelAPI_Feature;
+
+/**\class XGUI_ViewerPrs
+ * \ingroup GUI
+ * \brief Presentation. Provides container to have feature and the shape
+ */
+class XGUI_EXPORT XGUI_ViewerPrs
+{
+public:
+ /// Constructor
+ XGUI_ViewerPrs();
+ /// Constructor
+ XGUI_ViewerPrs(boost::shared_ptr<ModelAPI_Feature> theFeature,
+ const TopoDS_Shape& theShape);
+ /// Destructor
+ virtual ~XGUI_ViewerPrs();
+
+ /// Sets the feature.
+ /// \param theFeature a feature instance
+ void setFeature(boost::shared_ptr<ModelAPI_Feature> theFeature);
+
+ /// Sets the shape
+ /// \param theShape a shape instance
+ void setShape(const TopoDS_Shape& theShape);
+
+ /// Returns the feature.
+ /// \return a feature instance
+ boost::shared_ptr<ModelAPI_Feature> feature() const;
+
+ /// Returns the shape
+ /// \return a shape instance
+ const TopoDS_Shape& shape() const;
+
+private:
+ boost::shared_ptr<ModelAPI_Feature> myFeature; /// the feature
+ TopoDS_Shape myShape; /// the shape
+};
+
+#endif