ModuleBase_WidgetValue.h
ModuleBase_WidgetValueFeature.h
ModuleBase_Definitions.h
- ModuleBase_ViewSelectionValidator.h
+ ModuleBase_SelectionValidator.h
+ ModuleBase_ISelection.h
+ ModuleBase_ViewerPrs.h
)
SET(PROJECT_SOURCES
--- /dev/null
+// File: ModuleBase_ISelection.h
+// Created: 2 June 2014
+// Author: Vitaly Smetannikov
+
+#ifndef ModuleBase_ISelection_H
+#define ModuleBase_ISelection_H
+
+#include "ModuleBase.h"
+#include "ModuleBase_Definitions.h"
+#include "ModuleBase_ViewerPrs.h"
+
+#include <QModelIndexList>
+#include <AIS_ListOfInteractive.hxx>
+#include <NCollection_List.hxx>
+#include <TopoDS_Shape.hxx>
+
+#include <list>
+
+class ModuleBase_ISelection
+{
+public:
+
+ /// Returns a list of viewer selected presentations
+ /// \param theShapeTypeToSkip the shapes with this type will be skipped during the result list build
+ /// \return list of presentations
+ virtual std::list<ModuleBase_ViewerPrs> getSelected(int theShapeTypeToSkip = -1) const = 0;
+
+ /// Returns a list of viewer highlited presentations
+ /// \param theShapeTypeToSkip the shapes with this type will be skipped during the result list build
+ /// \return list of presentations
+ virtual std::list<ModuleBase_ViewerPrs> getHighlighted(int theShapeTypeToSkip = -1) const = 0;
+
+ /**
+ * Returns list of features currently selected in 3d viewer
+ */
+ virtual QFeatureList selectedFeatures() const = 0;
+
+ //! Returns list of currently selected QModelIndexes
+ virtual QModelIndexList selectedIndexes() const = 0;
+
+ //! Returns list of currently selected AIS objects
+ virtual void selectedAISObjects(AIS_ListOfInteractive& theList) const = 0;
+
+ //! Returns list of currently selected shapes
+ virtual void selectedShapes(NCollection_List<TopoDS_Shape>& theList) const = 0;
+
+};
+
+#endif
\ No newline at end of file
--- /dev/null
+// File: ModuleBase_SelectionValidator.h
+// Created: 8 Jul 2014
+// Author: Vitaly SMETANNIKOV
+
+#ifndef ModuleBase_SelectionValidator_H
+#define ModuleBase_SelectionValidator_H
+
+#include "ModuleBase.h"
+#include "ModuleBase_ISelection.h"
+
+#include <ModelAPI_Validator.h>
+
+
+class MODULEBASE_EXPORT ModuleBase_SelectionValidator: public ModelAPI_Validator
+{
+public:
+ virtual bool isValid(const ModuleBase_ISelection* theSelection) const = 0;
+};
+
+#endif
+++ /dev/null
-// File: ModuleBase_ViewSelectionValidator.h
-// Created: 8 Jul 2014
-// Author: Vitaly SMETANNIKOV
-
-#ifndef ModuleBase_ViewSelectionValidator_H
-#define ModuleBase_ViewSelectionValidator_H
-
-#include "ModuleBase.h"
-
-#include <ModelAPI_Validator.h>
-
-class MODULEBASE_EXPORT ModuleBase_ViewSelectionValidator: public ModelAPI_Validator
-{
-public:
- virtual bool isValid(const Handle(AIS_InteractiveContext)& theContext) const = 0;
-};
-
-#endif
--- /dev/null
+// File: ModuleBase_ViewerPrs.h
+// Created: 20 Apr 2014
+// Author: Natalia ERMOLAEVA
+
+#ifndef ModuleBase_ViewerPrs_H
+#define ModuleBase_ViewerPrs_H
+
+#include "ModuleBase.h"
+
+#include <boost/shared_ptr.hpp>
+#include <TopoDS_Shape.hxx>
+#include <SelectMgr_EntityOwner.hxx>
+
+#include <ModelAPI_Feature.h>
+
+/**\class ModuleBase_ViewerPrs
+ * \ingroup Module base
+ * \brief Presentation. Provides container to have feature, shape and/or selection owner.
+ */
+class ModuleBase_ViewerPrs
+{
+public:
+ /// Constructor
+ ModuleBase_ViewerPrs() {}
+
+ /// Constructor
+ /// \param theFeature a model feature
+ /// \param theShape a viewer shape
+ /// \param theOwner a selection owner
+ ModuleBase_ViewerPrs(FeaturePtr theFeature,
+ const TopoDS_Shape& theShape,
+ Handle_SelectMgr_EntityOwner theOwner)
+ : myFeature(theFeature), myShape(theShape), myOwner(theOwner) {}
+
+ /// Destructor
+ virtual ~ModuleBase_ViewerPrs() {}
+
+ /// Sets the feature.
+ /// \param theFeature a feature instance
+ void setFeature(FeaturePtr theFeature) { myFeature = theFeature; }
+
+ /// Returns the feature.
+ /// \return a feature instance
+ FeaturePtr feature() const { return myFeature; }
+
+ /// Returns the presentation owner
+ /// \param the owner
+ void setOwner(Handle_SelectMgr_EntityOwner theOwner) { myOwner = theOwner; }
+
+ /// Returns the presentation owner
+ /// \return an owner
+ Handle_SelectMgr_EntityOwner owner() const { return myOwner; }
+
+ /// Sets the shape
+ /// \param theShape a shape instance
+ void setShape(const TopoDS_Shape& theShape) { myShape = theShape; }
+
+ /// Returns the shape
+ /// \return a shape instance
+ const TopoDS_Shape& shape() const { return myShape; }
+
+ bool operator==(const ModuleBase_ViewerPrs& thePrs)
+ {
+ bool aFeature = (myFeature.get() == thePrs.feature().get());
+ bool aOwner = (myOwner.Access() == thePrs.owner().Access());
+ bool aShape = myShape.IsEqual(thePrs.shape());
+ return aFeature && aOwner && aShape;
+ }
+
+private:
+ FeaturePtr myFeature; /// the feature
+ Handle(SelectMgr_EntityOwner) myOwner; /// the selection owner
+ TopoDS_Shape myShape; /// the shape
+};
+
+#endif
#include <XGUI_Workshop.h>
#include <XGUI_OperationMgr.h>
#include <XGUI_SelectionMgr.h>
+#include <XGUI_Selection.h>
#include <XGUI_ViewPort.h>
#include <XGUI_ActionsMgr.h>
#include <XGUI_ViewerProxy.h>
ModuleBase_Operation* anOperation = createOperation(theCmdId.toStdString());
PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
if (aPreviewOp) {
- XGUI_Displayer* aDisplayer = myWorkshop->displayer();
+ XGUI_Selection* aSelection = myWorkshop->selector()->selection();
// Initialise operation with preliminary selection
- std::list<XGUI_ViewerPrs> aSelected = aDisplayer->getSelected();
- std::list<XGUI_ViewerPrs> aHighlighted = aDisplayer->getHighlighted();
+ std::list<ModuleBase_ViewerPrs> aSelected = aSelection->getSelected();
+ std::list<ModuleBase_ViewerPrs> aHighlighted = aSelection->getHighlighted();
aPreviewOp->initSelection(aSelected, aHighlighted);
}
sendOperation(anOperation);
void PartSet_Module::onContextMenuCommand(const QString& theId, bool isChecked)
{
- QFeatureList aFeatures = myWorkshop->selector()->selectedFeatures();
+ QFeatureList aFeatures = myWorkshop->selector()->selection()->selectedFeatures();
if (theId == "EDIT_CMD" && (aFeatures.size() > 0)) {
editFeature(aFeatures.first());
}
PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(
myWorkshop->operationMgr()->currentOperation());
if (aPreviewOp) {
- XGUI_Displayer* aDisplayer = myWorkshop->displayer();
- std::list<XGUI_ViewerPrs> aSelected = aDisplayer->getSelected();
- std::list<XGUI_ViewerPrs> aHighlighted = aDisplayer->getHighlighted();
+ XGUI_Selection* aSelection = myWorkshop->selector()->selection();
+ // Initialise operation with preliminary selection
+ std::list<ModuleBase_ViewerPrs> aSelected = aSelection->getSelected();
+ std::list<ModuleBase_ViewerPrs> aHighlighted = aSelection->getHighlighted();
aPreviewOp->mousePressed(theEvent, myWorkshop->viewer()->activeView(), aSelected, aHighlighted);
}
myWorkshop->operationMgr()->currentOperation());
if (aPreviewOp)
{
- XGUI_Displayer* aDisplayer = myWorkshop->displayer();
- std::list<XGUI_ViewerPrs> aSelected = aDisplayer->getSelected();
- std::list<XGUI_ViewerPrs> aHighlighted = aDisplayer->getHighlighted();
+ XGUI_Selection* aSelection = myWorkshop->selector()->selection();
+ // Initialise operation with preliminary selection
+ std::list<ModuleBase_ViewerPrs> aSelected = aSelection->getSelected();
+ std::list<ModuleBase_ViewerPrs> aHighlighted = aSelection->getHighlighted();
aPreviewOp->mouseReleased(theEvent, myWorkshop->viewer()->activeView(), aSelected, aHighlighted);
}
myWorkshop->operationMgr()->currentOperation());
if (aPreviewOp)
{
- XGUI_Displayer* aDisplayer = myWorkshop->displayer();
- std::list<XGUI_ViewerPrs> aSelected = aDisplayer->getSelected();
- std::list<XGUI_ViewerPrs> aHighlighted = aDisplayer->getHighlighted();
+ XGUI_Selection* aSelection = myWorkshop->selector()->selection();
+ // Initialise operation with preliminary selection
+ std::list<ModuleBase_ViewerPrs> aSelected = aSelection->getSelected();
+ std::list<ModuleBase_ViewerPrs> aHighlighted = aSelection->getHighlighted();
aPreviewOp->mouseDoubleClick(theEvent, myWorkshop->viewer()->activeView(), aSelected,
aHighlighted);
}
PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
if (aPreviewOp)
{
- XGUI_Displayer* aDisplayer = myWorkshop->displayer();
- // refill the features list with avoiding of the features, obtained only by vertex shape (TODO)
- std::list<XGUI_ViewerPrs> aSelected = aDisplayer->getSelected();
- std::list<XGUI_ViewerPrs> aHighlighted = aDisplayer->getHighlighted();
+ XGUI_Selection* aSelection = myWorkshop->selector()->selection();
+ // Initialise operation with preliminary selection
+ std::list<ModuleBase_ViewerPrs> aSelected = aSelection->getSelected();
+ std::list<ModuleBase_ViewerPrs> aHighlighted = aSelection->getHighlighted();
aPreviewOp->initFeature(theFeature);
aPreviewOp->initSelection(aSelected, aHighlighted);
} else {
#include <ModuleBase_OperationDescription.h>
#include <ModuleBase_WidgetPoint2D.h>
#include <ModuleBase_WidgetValueFeature.h>
+#include <ModuleBase_ViewerPrs.h>
-#include <XGUI_ViewerPrs.h>
#include <XGUI_Constants.h>
#include <V3d_View.hxx>
return aModes;
}
-void PartSet_OperationFeatureCreate::initSelection(const std::list<XGUI_ViewerPrs>& theSelected,
- const std::list<XGUI_ViewerPrs>& /*theHighlighted*/)
+void PartSet_OperationFeatureCreate::initSelection(const std::list<ModuleBase_ViewerPrs>& theSelected,
+ const std::list<ModuleBase_ViewerPrs>& /*theHighlighted*/)
{
myPreSelection = theSelected;
}
}
void PartSet_OperationFeatureCreate::mouseReleased(QMouseEvent* theEvent, Handle(V3d_View) theView,
- const std::list<XGUI_ViewerPrs>& theSelected,
- const std::list<XGUI_ViewerPrs>& /*theHighlighted*/)
+ const std::list<ModuleBase_ViewerPrs>& theSelected,
+ const std::list<ModuleBase_ViewerPrs>& /*theHighlighted*/)
{
if (canBeCommitted())
{
PartSet_Tools::convertTo2D(aPoint, sketch(), theView, aX, anY);
}
else {
- XGUI_ViewerPrs aPrs = theSelected.front();
+ ModuleBase_ViewerPrs aPrs = theSelected.front();
const TopoDS_Shape& aShape = aPrs.shape();
if (!aShape.IsNull()) // the point is selected
{
}
FeaturePtr aFeature;
if (!theSelected.empty()) {
- XGUI_ViewerPrs aPrs = theSelected.front();
+ ModuleBase_ViewerPrs aPrs = theSelected.front();
aFeature = aPrs.feature();
}
else
{
myActiveWidget = theWidget;
if ((myPreSelection.size() > 0) && myActiveWidget) {
- const XGUI_ViewerPrs& aPrs = myPreSelection.front();
+ const ModuleBase_ViewerPrs& aPrs = myPreSelection.front();
ModuleBase_WidgetValueFeature aValue;
aValue.setFeature(aPrs.feature());
if (myActiveWidget->setValue(&aValue)) {
/// Initialisation of operation with preliminary selection
/// \param theSelected the list of selected presentations
/// \param theHighlighted the list of highlighted presentations
- virtual void initSelection(const std::list<XGUI_ViewerPrs>& theSelected,
- const std::list<XGUI_ViewerPrs>& theHighlighted);
+ virtual void initSelection(const std::list<ModuleBase_ViewerPrs>& theSelected,
+ const std::list<ModuleBase_ViewerPrs>& theHighlighted);
/// Returns the operation sketch feature
/// \returns the sketch instance
/// \param theSelected the list of selected presentations
/// \param theHighlighted the list of highlighted presentations
virtual void mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView,
- const std::list<XGUI_ViewerPrs>& theSelected,
- const std::list<XGUI_ViewerPrs>& theHighlighted);
+ const std::list<ModuleBase_ViewerPrs>& theSelected,
+ const std::list<ModuleBase_ViewerPrs>& theHighlighted);
/// Gives the current mouse point in the viewer
/// \param thePoint a point clicked in the viewer
/// \param theEvent the mouse event
ModuleBase_ModelWidget* myActiveWidget; ///< the active widget
- std::list<XGUI_ViewerPrs> myPreSelection;
+ std::list<ModuleBase_ViewerPrs> myPreSelection;
};
#endif
#include <ModuleBase_OperationDescription.h>
#include <ModuleBase_WidgetEditor.h>
-#include <ModelAPI_Events.h>
+#include <ModuleBase_ViewerPrs.h>
-#include <XGUI_ViewerPrs.h>
+#include <ModelAPI_Events.h>
#include <SketchPlugin_Feature.h>
#include <GeomDataAPI_Point2D.h>
}
void PartSet_OperationFeatureEdit::mousePressed(QMouseEvent* theEvent, Handle(V3d_View) theView,
- const std::list<XGUI_ViewerPrs>& theSelected,
- const std::list<XGUI_ViewerPrs>& theHighlighted)
+ const std::list<ModuleBase_ViewerPrs>& theSelected,
+ const std::list<ModuleBase_ViewerPrs>& theHighlighted)
{
FeaturePtr aFeature;
if (!theHighlighted.empty())
}
void PartSet_OperationFeatureEdit::mouseReleased(QMouseEvent* theEvent, Handle(V3d_View) theView,
- const std::list<XGUI_ViewerPrs>& /*theSelected*/,
- const std::list<XGUI_ViewerPrs>& /*theHighlighted*/)
+ const std::list<ModuleBase_ViewerPrs>& /*theSelected*/,
+ const std::list<ModuleBase_ViewerPrs>& /*theHighlighted*/)
{
blockSelection(false);
}
void PartSet_OperationFeatureEdit::mouseDoubleClick(QMouseEvent* theEvent, Handle_V3d_View theView,
- const std::list<XGUI_ViewerPrs>& theSelected,
- const std::list<XGUI_ViewerPrs>& theHighlighted)
+ const std::list<ModuleBase_ViewerPrs>& theSelected,
+ const std::list<ModuleBase_ViewerPrs>& theHighlighted)
{
// TODO the functionality is important only for constraint feature. Should be moved in another place
if (!theSelected.empty()) {
- XGUI_ViewerPrs aFeaturePrs = theSelected.front();
+ ModuleBase_ViewerPrs aFeaturePrs = theSelected.front();
if (!aFeaturePrs.owner().IsNull()) {
Handle(AIS_DimensionOwner) anOwner = Handle(AIS_DimensionOwner)::DownCast(aFeaturePrs.owner());
if (!anOwner.IsNull() && anOwner->SelectionMode() == AIS_DSM_Text) {
/// \param theSelected the list of selected presentations
/// \param theHighlighted the list of highlighted presentations
virtual void mousePressed(QMouseEvent* theEvent, Handle_V3d_View theView,
- const std::list<XGUI_ViewerPrs>& theSelected,
- const std::list<XGUI_ViewerPrs>& theHighlighted);
+ const std::list<ModuleBase_ViewerPrs>& theSelected,
+ const std::list<ModuleBase_ViewerPrs>& theHighlighted);
/// Gives the current mouse point in the viewer
/// \param theEvent the mouse event
/// \param theView a viewer to have the viewer the eye position
/// \param theSelected the list of selected presentations
/// \param theHighlighted the list of highlighted presentations
virtual void mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView,
- const std::list<XGUI_ViewerPrs>& theSelected,
- const std::list<XGUI_ViewerPrs>& theHighlighted);
+ const std::list<ModuleBase_ViewerPrs>& theSelected,
+ const std::list<ModuleBase_ViewerPrs>& theHighlighted);
/// Processes the mouse double click in the point
/// \param theEvent the mouse event
/// \param theSelected the list of selected presentations
/// \param theHighlighted the list of highlighted presentations
virtual void mouseDoubleClick(QMouseEvent* theEvent, Handle_V3d_View theView,
- const std::list<XGUI_ViewerPrs>& theSelected,
- const std::list<XGUI_ViewerPrs>& theHighlighted);
+ const std::list<ModuleBase_ViewerPrs>& theSelected,
+ const std::list<ModuleBase_ViewerPrs>& theHighlighted);
protected:
/// \brief Virtual method called when operation is started
/// Virtual method called when operation started (see start() method for more description)
#include <PartSet_OperationSketch.h>
#include <ModuleBase_OperationDescription.h>
-#include <ModelAPI_Events.h>
+#include <ModuleBase_ViewerPrs.h>
-#include <XGUI_ViewerPrs.h>
+#include <ModelAPI_Events.h>
#include <SketchPlugin_Feature.h>
#include <GeomDataAPI_Point2D.h>
return theOperation->getDescription()->operationId().toStdString() == PartSet_OperationSketch::Type();
}
-void PartSet_OperationFeatureEditMulti::initSelection(const std::list<XGUI_ViewerPrs>& theSelected,
- const std::list<XGUI_ViewerPrs>& theHighlighted)
+void PartSet_OperationFeatureEditMulti::initSelection(const std::list<ModuleBase_ViewerPrs>& theSelected,
+ const std::list<ModuleBase_ViewerPrs>& theHighlighted)
{
if (!theHighlighted.empty()) {
// if there is highlighted object, we check whether it is in the list of selected objects
// the hightlighted object should moved and the selection is skipped. The skipped selection will be
// deselected in the viewer by blockSelection signal in the startOperation method.
bool isSelected = false;
- std::list<XGUI_ViewerPrs>::const_iterator anIt = theSelected.begin(), aLast = theSelected.end();
+ std::list<ModuleBase_ViewerPrs>::const_iterator anIt = theSelected.begin(), aLast = theSelected.end();
for (; anIt != aLast && !isSelected; anIt++) {
isSelected = (*anIt).feature() == feature();
}
}
void PartSet_OperationFeatureEditMulti::mousePressed(QMouseEvent* theEvent, Handle(V3d_View) theView,
- const std::list<XGUI_ViewerPrs>& /*theSelected*/,
- const std::list<XGUI_ViewerPrs>& theHighlighted)
+ const std::list<ModuleBase_ViewerPrs>& /*theSelected*/,
+ const std::list<ModuleBase_ViewerPrs>& theHighlighted)
{
}
boost::dynamic_pointer_cast<SketchPlugin_Feature>(feature());
aSketchFeature->move(aDeltaX, aDeltaY);
- std::list<XGUI_ViewerPrs>::const_iterator anIt = myFeatures.begin(), aLast = myFeatures.end();
+ std::list<ModuleBase_ViewerPrs>::const_iterator anIt = myFeatures.begin(), aLast = myFeatures.end();
for (; anIt != aLast; anIt++) {
FeaturePtr aFeature = (*anIt).feature();
if (!aFeature || aFeature == feature())
}
void PartSet_OperationFeatureEditMulti::mouseReleased(QMouseEvent* theEvent, Handle(V3d_View) theView,
- const std::list<XGUI_ViewerPrs>& /*theSelected*/,
- const std::list<XGUI_ViewerPrs>& /*theHighlighted*/)
+ const std::list<ModuleBase_ViewerPrs>& /*theSelected*/,
+ const std::list<ModuleBase_ViewerPrs>& /*theHighlighted*/)
{
- std::list<XGUI_ViewerPrs> aFeatures = myFeatures;
+ std::list<ModuleBase_ViewerPrs> aFeatures = myFeatures;
commit();
- std::list<XGUI_ViewerPrs>::const_iterator anIt = aFeatures.begin(), aLast = aFeatures.end();
+ std::list<ModuleBase_ViewerPrs>::const_iterator anIt = aFeatures.begin(), aLast = aFeatures.end();
for (; anIt != aLast; anIt++) {
FeaturePtr aFeature = (*anIt).feature();
if (aFeature) {
myIsBlockedSelection = isBlocked;
QFeatureList aFeatureList;
- std::list<XGUI_ViewerPrs>::const_iterator anIt = myFeatures.begin(),
+ std::list<ModuleBase_ViewerPrs>::const_iterator anIt = myFeatures.begin(),
aLast = myFeatures.end();
for(; anIt != aLast; anIt++)
aFeatureList.append((*anIt).feature());
static Events_ID anEvent = Events_Loop::eventByName(EVENT_FEATURE_MOVED);
std::list<FeaturePtr > aFeatures;
- std::list<XGUI_ViewerPrs>::const_iterator anIt = myFeatures.begin(), aLast = myFeatures.end();
+ std::list<ModuleBase_ViewerPrs>::const_iterator anIt = myFeatures.begin(), aLast = myFeatures.end();
for (; anIt != aLast; anIt++) {
FeaturePtr aFeature = (*anIt).feature();
if (!aFeature)
/// Initialisation of operation with preliminary selection
/// \param theSelected the list of selected presentations
/// \param theHighlighted the list of highlighted presentations
- virtual void initSelection(const std::list<XGUI_ViewerPrs>& theSelected,
- const std::list<XGUI_ViewerPrs>& theHighlighted);
+ virtual void initSelection(const std::list<ModuleBase_ViewerPrs>& theSelected,
+ const std::list<ModuleBase_ViewerPrs>& theHighlighted);
/// Returns the operation sketch feature
/// \returns the sketch instance
/// \param theSelected the list of selected presentations
/// \param theHighlighted the list of highlighted presentations
virtual void mousePressed(QMouseEvent* theEvent, Handle_V3d_View theView,
- const std::list<XGUI_ViewerPrs>& theSelected,
- const std::list<XGUI_ViewerPrs>& theHighlighted);
+ const std::list<ModuleBase_ViewerPrs>& theSelected,
+ const std::list<ModuleBase_ViewerPrs>& theHighlighted);
/// Gives the current mouse point in the viewer
/// \param theEvent the mouse event
/// \param theView a viewer to have the viewer the eye position
/// \param theSelected the list of selected presentations
/// \param theHighlighted the list of highlighted presentations
virtual void mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView,
- const std::list<XGUI_ViewerPrs>& theSelected,
- const std::list<XGUI_ViewerPrs>& theHighlighted);
+ const std::list<ModuleBase_ViewerPrs>& theSelected,
+ const std::list<ModuleBase_ViewerPrs>& theHighlighted);
protected:
/// \brief Virtual method called when operation is started
/// Virtual method called when operation started (see start() method for more description)
private:
FeaturePtr mySketch; ///< the sketch feature
- std::list<XGUI_ViewerPrs> myFeatures; ///< the features to apply the edit operation
+ std::list<ModuleBase_ViewerPrs> myFeatures; ///< the features to apply the edit operation
Point myCurPoint; ///< the current 3D point clicked or moved
bool myIsBlockedSelection; ///< the state of the last state of selection blocked signal
};
#include <GeomDataAPI_Dir.h>
#include <GeomAPI_XYZ.h>
-#include <XGUI_ViewerPrs.h>
+#include <ModuleBase_ViewerPrs.h>
#include <AIS_Shape.hxx>
#include <AIS_ListOfInteractive.hxx>
}
void PartSet_OperationSketch::mousePressed(QMouseEvent* theEvent, Handle_V3d_View theView,
- const std::list<XGUI_ViewerPrs>& theSelected,
- const std::list<XGUI_ViewerPrs>& theHighlighted)
+ const std::list<ModuleBase_ViewerPrs>& theSelected,
+ const std::list<ModuleBase_ViewerPrs>& theHighlighted)
{
if (!hasSketchPlane()) {
if (!theHighlighted.empty()) {
- XGUI_ViewerPrs aPrs = theHighlighted.front();
+ ModuleBase_ViewerPrs aPrs = theHighlighted.front();
const TopoDS_Shape& aShape = aPrs.shape();
if (!aShape.IsNull())
setSketchPlane(aShape);
}
void PartSet_OperationSketch::mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView,
- const std::list<XGUI_ViewerPrs>& theSelected,
- const std::list<XGUI_ViewerPrs>& theHighlighted)
+ const std::list<ModuleBase_ViewerPrs>& theSelected,
+ const std::list<ModuleBase_ViewerPrs>& theHighlighted)
{
if (!hasSketchPlane()) {
}
/// \param theSelected the list of selected presentations
/// \param theHighlighted the list of highlighted presentations
virtual void mousePressed(QMouseEvent* theEvent, Handle_V3d_View theView,
- const std::list<XGUI_ViewerPrs>& theSelected,
- const std::list<XGUI_ViewerPrs>& theHighlighted);
+ const std::list<ModuleBase_ViewerPrs>& theSelected,
+ const std::list<ModuleBase_ViewerPrs>& theHighlighted);
/// Processes the mouse release in the point
/// \param theEvent the mouse event
/// \param theView a viewer to have the viewer the eye position
/// \param theSelected the list of selected presentations
/// \param theHighlighted the list of highlighted presentations
virtual void mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView,
- const std::list<XGUI_ViewerPrs>& theSelected,
- const std::list<XGUI_ViewerPrs>& theHighlighted);
+ const std::list<ModuleBase_ViewerPrs>& theSelected,
+ const std::list<ModuleBase_ViewerPrs>& theHighlighted);
/// Gives the current mouse point in the viewer
/// \param thePoint a point clicked in the viewer
void setSketchPlane(const TopoDS_Shape& theShape);
private:
- std::list<XGUI_ViewerPrs> myFeatures; ///< the features to apply the edit operation
+ std::list<ModuleBase_ViewerPrs> myFeatures; ///< the features to apply the edit operation
};
#endif
void PartSet_OperationSketchBase::mousePressed(QMouseEvent* theEvent, Handle_V3d_View theView,
- const std::list<XGUI_ViewerPrs>& theSelected,
- const std::list<XGUI_ViewerPrs>& theHighlighted)
+ const std::list<ModuleBase_ViewerPrs>& theSelected,
+ const std::list<ModuleBase_ViewerPrs>& theHighlighted)
{
}
void PartSet_OperationSketchBase::mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView,
- const std::list<XGUI_ViewerPrs>& theSelected,
- const std::list<XGUI_ViewerPrs>& theHighlighted)
+ const std::list<ModuleBase_ViewerPrs>& theSelected,
+ const std::list<ModuleBase_ViewerPrs>& theHighlighted)
{
}
void PartSet_OperationSketchBase::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView)
{
}
void PartSet_OperationSketchBase::mouseDoubleClick(QMouseEvent* theEvent, Handle_V3d_View theView,
- const std::list<XGUI_ViewerPrs>& theSelected,
- const std::list<XGUI_ViewerPrs>& theHighlighted)
+ const std::list<ModuleBase_ViewerPrs>& theSelected,
+ const std::list<ModuleBase_ViewerPrs>& theHighlighted)
{
}
class Handle_V3d_View;
class QMouseEvent;
class GeomAPI_Shape;
-class XGUI_ViewerPrs;
+class ModuleBase_ViewerPrs;
/*!
\class PartSet_OperationSketchBase
/// Initialisation of operation with preliminary selection
/// \param theSelected the list of selected presentations
/// \param theHighlighted the list of highlighted presentations
- virtual void initSelection(const std::list<XGUI_ViewerPrs>& theSelected,
- const std::list<XGUI_ViewerPrs>& theHighlighted) {}
+ virtual void initSelection(const std::list<ModuleBase_ViewerPrs>& theSelected,
+ const std::list<ModuleBase_ViewerPrs>& theHighlighted) {}
/// Returns the operation sketch feature
/// \returns the sketch instance
/// \param theSelected the list of selected presentations
/// \param theHighlighted the list of highlighted presentations
virtual void mousePressed(QMouseEvent* theEvent, Handle_V3d_View theView,
- const std::list<XGUI_ViewerPrs>& theSelected,
- const std::list<XGUI_ViewerPrs>& theHighlighted);
+ const std::list<ModuleBase_ViewerPrs>& theSelected,
+ const std::list<ModuleBase_ViewerPrs>& theHighlighted);
/// Processes the mouse release in the point
/// \param theEvent the mouse event
/// \param theSelected the list of selected presentations
/// \param theHighlighted the list of highlighted presentations
virtual void mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView,
- const std::list<XGUI_ViewerPrs>& theSelected,
- const std::list<XGUI_ViewerPrs>& theHighlighted);
+ const std::list<ModuleBase_ViewerPrs>& theSelected,
+ const std::list<ModuleBase_ViewerPrs>& theHighlighted);
/// Processes the mouse move in the point
/// \param theEvent the mouse event
/// \param theSelected the list of selected presentations
/// \param theHighlighted the list of highlighted presentations
virtual void mouseDoubleClick(QMouseEvent* theEvent, Handle_V3d_View theView,
- const std::list<XGUI_ViewerPrs>& theSelected,
- const std::list<XGUI_ViewerPrs>& theHighlighted);
+ const std::list<ModuleBase_ViewerPrs>& theSelected,
+ const std::list<ModuleBase_ViewerPrs>& theHighlighted);
/// Processes the key pressed in the view
/// \param theKey a key value
int theMode);
/// Signal about the features should be selected
/// \param theSelected the list of selected presentations
- void featureSelected(const std::list<XGUI_ViewerPrs>& theSelected);
+ void featureSelected(const std::list<ModuleBase_ViewerPrs>& theSelected);
/// signal to enable/disable multi selection in the viewer
/// \param theEnabled the boolean state
void multiSelectionEnabled(bool theEnabled);
#include <XGUI_Workshop.h>
#include <XGUI_OperationMgr.h>
#include <XGUI_Displayer.h>
-#include <XGUI_ViewerPrs.h>
#include <XGUI_ViewerProxy.h>
#include <PartSet_Tools.h>
#include <PartSet_OperationSketchBase.h>
+#include <ModuleBase_ViewerPrs.h>
#include <ModelAPI_Feature.h>
#include <SketchPlugin_Line.h>
#include <SketchPlugin_ConstraintRadius.h>
#include <SketchPlugin_Constraint.h>
-#include <XGUI_ViewerPrs.h>
+#include <ModuleBase_ViewerPrs.h>
#include <V3d_View.hxx>
#include <gp_Pln.hxx>
FeaturePtr PartSet_Tools::nearestFeature(QPoint thePoint, Handle_V3d_View theView,
FeaturePtr theSketch,
- const std::list<XGUI_ViewerPrs>& theFeatures)
+ const std::list<ModuleBase_ViewerPrs>& theFeatures)
{
double aX, anY;
gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(thePoint, theView);
PartSet_Tools::convertTo2D(aPoint, theSketch, theView, aX, anY);
FeaturePtr aFeature;
- std::list<XGUI_ViewerPrs>::const_iterator anIt = theFeatures.begin(), aLast = theFeatures.end();
+ std::list<ModuleBase_ViewerPrs>::const_iterator anIt = theFeatures.begin(), aLast = theFeatures.end();
FeaturePtr aDeltaFeature;
double aMinDelta = -1;
- XGUI_ViewerPrs aPrs;
+ ModuleBase_ViewerPrs aPrs;
for (; anIt != aLast; anIt++) {
aPrs = *anIt;
if (!aPrs.feature())
#include <list>
class Handle_V3d_View;
-class XGUI_ViewerPrs;
+class ModuleBase_ViewerPrs;
class GeomDataAPI_Point2D;
class GeomAPI_Pln;
class GeomAPI_Pnt2d;
/// \param theSketch the sketch feature
/// \param theFeatures the list of selected presentations
static FeaturePtr nearestFeature(QPoint thePoint, Handle_V3d_View theView, FeaturePtr theSketch,
- const std::list<XGUI_ViewerPrs>& theFeatures);
+ const std::list<ModuleBase_ViewerPrs>& theFeatures);
/// Returns pointer to the root document.
static boost::shared_ptr<ModelAPI_Document> document();
ModuleBase_Operation* aOperation = theMgr->currentOperation();
if (aOperation->inherits("PartSet_OperationSketch")) {
PartSet_OperationSketch* aSketchOpe = static_cast<PartSet_OperationSketch*>(aOperation);
+ updateLabel(aSketchOpe);
connect(aSketchOpe, SIGNAL(planeSelected(double, double, double)),
this, SLOT(onPlaneSelected()));
}
void PartSet_WidgetSketchLabel::onPlaneSelected()
{
PartSet_OperationSketch* aSketchOpe = static_cast<PartSet_OperationSketch*>(sender());
- if (aSketchOpe->hasSketchPlane()) {
+ updateLabel(aSketchOpe);
+}
+
+void PartSet_WidgetSketchLabel::updateLabel(PartSet_OperationSketch* theSketchOpe)
+{
+ if (theSketchOpe->hasSketchPlane()) {
myLabel->setText("");
myLabel->setToolTip("");
} else {
myLabel->setText(myText);
myLabel->setToolTip(myTooltip);
}
-}
+}
\ No newline at end of file
class QLabel;
class XGUI_OperationMgr;
+class PartSet_OperationSketch;
class PARTSET_EXPORT PartSet_WidgetSketchLabel : public ModuleBase_ModelWidget
{
void onPlaneSelected();
private:
+ void updateLabel(PartSet_OperationSketch* theSketchOpe);
+
QLabel* myLabel;
QString myText;
QString myTooltip;
XGUI_ErrorDialog.h
XGUI_SalomeViewer.h
XGUI_ViewerProxy.h
- XGUI_ViewerPrs.h
XGUI_PropertyPanel.h
XGUI_ContextMenuMgr.h
XGUI_ModuleConnector.h
+ XGUI_Selection.h
)
SET(PROJECT_AUTOMOC
XGUI_ActionsMgr.cpp
XGUI_ErrorDialog.cpp
XGUI_ViewerProxy.cpp
- XGUI_ViewerPrs.cpp
XGUI_PropertyPanel.cpp
XGUI_ContextMenuMgr.cpp
XGUI_ModuleConnector.cpp
+ XGUI_Selection.cpp
)
SET(PROJECT_RESOURCES
#include "XGUI_Displayer.h"
#include "XGUI_MainWindow.h"
#include "XGUI_ViewerProxy.h"
+#include "XGUI_Selection.h"
#include "PartSetPlugin_Part.h"
{
QMenu* aMenu = new QMenu();
XGUI_SelectionMgr* aSelMgr = myWorkshop->selector();
- QFeatureList aFeatures = aSelMgr->selectedFeatures();
+ QFeatureList aFeatures = aSelMgr->selection()->selectedFeatures();
if (aFeatures.size() == 1) {
PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
FeaturePtr aFeature = aFeatures.first();
void XGUI_ContextMenuMgr::addViewerItems(QMenu* theMenu) const
{
XGUI_SelectionMgr* aSelMgr = myWorkshop->selector();
- QFeatureList aFeatures = aSelMgr->selectedFeatures();
+ QFeatureList aFeatures = aSelMgr->selection()->selectedFeatures();
if (aFeatures.size() > 0) {
if (aFeatures.size() == 1)
theMenu->addAction(action("EDIT_CMD"));
}
-std::list<XGUI_ViewerPrs> XGUI_Displayer::getSelected(const int theShapeTypeToSkip)
-{
- std::set<FeaturePtr > aPrsFeatures;
- std::list<XGUI_ViewerPrs> aPresentations;
-
- Handle(AIS_InteractiveContext) aContext = AISContext();
- for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) {
- Handle(AIS_InteractiveObject) anIO = aContext->SelectedInteractive();
- TopoDS_Shape aShape = aContext->SelectedShape();
-
- if (theShapeTypeToSkip >= 0 && !aShape.IsNull() && aShape.ShapeType() == theShapeTypeToSkip)
- continue;
-
- FeaturePtr aFeature = getFeature(anIO);
- if (aPrsFeatures.find(aFeature) != aPrsFeatures.end())
- continue;
- Handle(SelectMgr_EntityOwner) anOwner = aContext->SelectedOwner();
- aPresentations.push_back(XGUI_ViewerPrs(aFeature, aShape, anOwner));
- aPrsFeatures.insert(aFeature);
- }
- return aPresentations;
-}
-
-QFeatureList XGUI_Displayer::selectedFeatures() const
-{
- QFeatureList aSelectedList;
-
- Handle(AIS_InteractiveContext) aContext = AISContext();
- for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) {
- Handle(AIS_InteractiveObject) anIO = aContext->SelectedInteractive();
- FeaturePtr aFeature = getFeature(anIO);
- if (aFeature)
- aSelectedList.append(aFeature);
- }
- return aSelectedList;
-}
-
-
-std::list<XGUI_ViewerPrs> XGUI_Displayer::getHighlighted(const int theShapeTypeToSkip)
-{
- std::set<FeaturePtr > aPrsFeatures;
- std::list<XGUI_ViewerPrs> aPresentations;
-
- Handle(AIS_InteractiveContext) aContext = AISContext();
- for (aContext->InitDetected(); aContext->MoreDetected(); aContext->NextDetected()) {
- Handle(AIS_InteractiveObject) anIO = aContext->DetectedInteractive();
- TopoDS_Shape aShape = aContext->DetectedShape();
- if (theShapeTypeToSkip >= 0 && !aShape.IsNull() && aShape.ShapeType() == theShapeTypeToSkip)
- continue;
-
- FeaturePtr aFeature = getFeature(anIO);
- if (aPrsFeatures.find(aFeature) != aPrsFeatures.end())
- continue;
- aPresentations.push_back(XGUI_ViewerPrs(aFeature, aShape, NULL));
- aPrsFeatures.insert(aFeature);
- }
-
- return aPresentations;
-}
void XGUI_Displayer::erase(FeaturePtr theFeature,
const bool isUpdateViewer)
#define XGUI_Displayer_H
#include "XGUI.h"
-#include <ModuleBase_Definitions.h>
#include <QString>
#include <boost/shared_ptr.hpp>
#include <ModelAPI_Feature.h>
-#include <XGUI_ViewerPrs.h>
+#include <ModuleBase_Definitions.h>
+#include <ModuleBase_ViewerPrs.h>
#include <map>
#include <vector>
/// Returns true if the Feature succesfully displayed
bool display(FeaturePtr theFeature, boost::shared_ptr<GeomAPI_AISObject> theAIS, bool isUpdateViewer = true);
- /// Returns a list of viewer selected presentations
- /// \param theShapeTypeToSkip the shapes with this type will be skipped during the result list build
- /// \return list of presentations
- std::list<XGUI_ViewerPrs> getSelected(const int theShapeTypeToSkip = -1);
-
- /**
- * Returns list of features currently selected in 3d viewer
- */
- QFeatureList selectedFeatures() const;
-
- /// Returns a list of viewer highlited presentations
- /// \param theShapeTypeToSkip the shapes with this type will be skipped during the result list build
- /// \return list of presentations
- std::list<XGUI_ViewerPrs> getHighlighted(const int theShapeTypeToSkip = -1);
-
/// Display the shape and activate selection of sub-shapes
/// \param theFeature a feature instance
/// \param theAIS an AIS object
/// \return theIO an interactive object
boost::shared_ptr<GeomAPI_AISObject> getAISObject(FeaturePtr theFeature) const;
-protected:
/// Searches the feature by interactive object
/// \param theIO an interactive object
/// \return feature the feature or NULL if it not visualized
FeaturePtr getFeature(Handle(AIS_InteractiveObject) theIO) const;
+
+protected:
/// Deactivate local selection
/// \param isUpdateViewer the state wether the viewer should be updated immediatelly
void closeAllContexts(const bool isUpdateViewer);
#include "XGUI_Workshop.h"
#include "XGUI_ViewerProxy.h"
#include "XGUI_SelectionMgr.h"
+#include "XGUI_Selection.h"
QFeatureList XGUI_ModuleConnector::selectedFeatures() const
{
- return myWorkshop->selector()->selectedFeatures();
+ return myWorkshop->selector()->selection()->selectedFeatures();
}
ModuleBase_IModule* XGUI_ModuleConnector::module() const
--- /dev/null
+// File: XGUI_Selection.cpp
+// Created: 8 July 2014
+// Author: Vitaly SMETANNIKOV
+
+#include "XGUI_Selection.h"
+#include "XGUI_Workshop.h"
+#include "XGUI_Displayer.h"
+#include "XGUI_ViewerProxy.h"
+#include "XGUI_ObjectsBrowser.h"
+
+#include <ModelAPI_Feature.h>
+
+#include <AIS_InteractiveContext.hxx>
+
+#include <set>
+
+
+XGUI_Selection::XGUI_Selection(XGUI_Workshop* theWorkshop)
+: myWorkshop(theWorkshop)
+{
+}
+
+std::list<ModuleBase_ViewerPrs> XGUI_Selection::getSelected(int theShapeTypeToSkip) const
+{
+ std::set<FeaturePtr> aPrsFeatures;
+ std::list<ModuleBase_ViewerPrs> aPresentations;
+
+ Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
+ for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) {
+ Handle(AIS_InteractiveObject) anIO = aContext->SelectedInteractive();
+ TopoDS_Shape aShape = aContext->SelectedShape();
+
+ if (theShapeTypeToSkip >= 0 && !aShape.IsNull() && aShape.ShapeType() == theShapeTypeToSkip)
+ continue;
+
+ FeaturePtr aFeature = myWorkshop->displayer()->getFeature(anIO);
+ if (aPrsFeatures.find(aFeature) != aPrsFeatures.end())
+ continue;
+ Handle(SelectMgr_EntityOwner) anOwner = aContext->SelectedOwner();
+ aPresentations.push_back(ModuleBase_ViewerPrs(aFeature, aShape, anOwner));
+ aPrsFeatures.insert(aFeature);
+ }
+ return aPresentations;
+}
+
+std::list<ModuleBase_ViewerPrs> XGUI_Selection::getHighlighted(int theShapeTypeToSkip) const
+{
+ std::set<FeaturePtr > aPrsFeatures;
+ std::list<ModuleBase_ViewerPrs> aPresentations;
+
+ Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
+ for (aContext->InitDetected(); aContext->MoreDetected(); aContext->NextDetected()) {
+ Handle(AIS_InteractiveObject) anIO = aContext->DetectedInteractive();
+ TopoDS_Shape aShape = aContext->DetectedShape();
+ if (theShapeTypeToSkip >= 0 && !aShape.IsNull() && aShape.ShapeType() == theShapeTypeToSkip)
+ continue;
+
+ FeaturePtr aFeature = myWorkshop->displayer()->getFeature(anIO);
+ if (aPrsFeatures.find(aFeature) != aPrsFeatures.end())
+ continue;
+ aPresentations.push_back(ModuleBase_ViewerPrs(aFeature, aShape, NULL));
+ aPrsFeatures.insert(aFeature);
+ }
+
+ return aPresentations;
+}
+
+QFeatureList XGUI_Selection::selectedFeatures() const
+{
+ return myWorkshop->objectBrowser()->selectedFeatures();
+ //QFeatureList aSelectedList;
+
+ //Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
+ //for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) {
+ // Handle(AIS_InteractiveObject) anIO = aContext->SelectedInteractive();
+ // FeaturePtr aFeature = myWorkshop->displayer()->getFeature(anIO);
+ // if (aFeature)
+ // aSelectedList.append(aFeature);
+ //}
+ //return aSelectedList;
+}
+
+
+//**************************************************************
+QModelIndexList XGUI_Selection::selectedIndexes() const
+{
+ return myWorkshop->objectBrowser()->selectedIndexes();
+}
+
+//**************************************************************
+void XGUI_Selection::selectedAISObjects(AIS_ListOfInteractive& theList) const
+{
+ Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
+ theList.Clear();
+ for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected())
+ theList.Append(aContext->SelectedInteractive());
+}
+
+//**************************************************************
+void XGUI_Selection::selectedShapes(NCollection_List<TopoDS_Shape>& theList) const
+{
+ theList.Clear();
+ Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
+ for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) {
+ TopoDS_Shape aShape = aContext->SelectedShape();
+ if (!aShape.IsNull())
+ theList.Append(aShape);
+ }
+}
--- /dev/null
+// File: XGUI_Selection.h
+// Created: 8 July 2014
+// Author: Vitaly SMETANNIKOV
+
+#ifndef XGUI_Selection_H
+#define XGUI_Selection_H
+
+#include "XGUI.h"
+
+#include <ModuleBase_ViewerPrs.h>
+#include <ModuleBase_Definitions.h>
+#include <ModuleBase_ISelection.h>
+
+#include <QModelIndexList>
+#include <AIS_ListOfInteractive.hxx>
+#include <NCollection_List.hxx>
+#include <TopoDS_Shape.hxx>
+
+#include <list>
+
+class XGUI_Workshop;
+
+class XGUI_EXPORT XGUI_Selection: public ModuleBase_ISelection
+{
+public:
+ XGUI_Selection(XGUI_Workshop* theWorkshop);
+
+ /// Returns a list of viewer selected presentations
+ /// \param theShapeTypeToSkip the shapes with this type will be skipped during the result list build
+ /// \return list of presentations
+ std::list<ModuleBase_ViewerPrs> getSelected(int theShapeTypeToSkip = -1) const;
+
+ /// Returns a list of viewer highlited presentations
+ /// \param theShapeTypeToSkip the shapes with this type will be skipped during the result list build
+ /// \return list of presentations
+ std::list<ModuleBase_ViewerPrs> getHighlighted(int theShapeTypeToSkip = -1) const;
+
+ /**
+ * Returns list of features currently selected in 3d viewer
+ */
+ QFeatureList selectedFeatures() const;
+
+ //! Returns list of currently selected QModelIndexes
+ QModelIndexList selectedIndexes() const;
+
+ //! Returns list of currently selected AIS objects
+ void selectedAISObjects(AIS_ListOfInteractive& theList) const;
+
+ //! Returns list of currently selected shapes
+ void selectedShapes(NCollection_List<TopoDS_Shape>& theList) const;
+
+private:
+ XGUI_Workshop* myWorkshop;
+};
+
+#endif
\ No newline at end of file
#include "XGUI_SalomeConnector.h"
#include "XGUI_ViewerProxy.h"
#include "XGUI_Displayer.h"
+#include "XGUI_Selection.h"
#include <ModelAPI_Feature.h>
#include <ModelAPI_PluginManager.h>
XGUI_SelectionMgr::XGUI_SelectionMgr(XGUI_Workshop* theParent) :
QObject(theParent), myWorkshop(theParent)
{
+ mySelection = new XGUI_Selection(myWorkshop);
}
XGUI_SelectionMgr::~XGUI_SelectionMgr()
{
+ delete mySelection;
}
//**************************************************************
//**************************************************************
void XGUI_SelectionMgr::onObjectBrowserSelection()
{
- QFeatureList aFeatures = selectedFeatures();
+ QFeatureList aFeatures = myWorkshop->objectBrowser()->selectedFeatures();
XGUI_Displayer* aDisplayer = myWorkshop->displayer();
aDisplayer->setSelected(aFeatures);
-
emit selectionChanged();
}
//**************************************************************
void XGUI_SelectionMgr::onViewerSelection()
{
- XGUI_Displayer* aDisplayer = myWorkshop->displayer();
- QFeatureList aFeatures = aDisplayer->selectedFeatures();
+ QFeatureList aFeatures;
+ Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
+ for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) {
+ Handle(AIS_InteractiveObject) anIO = aContext->SelectedInteractive();
+ FeaturePtr aFeature = myWorkshop->displayer()->getFeature(anIO);
+ if (aFeature)
+ aFeatures.append(aFeature);
+ }
myWorkshop->objectBrowser()->setFeaturesSelected(aFeatures);
emit selectionChanged();
}
//**************************************************************
-QFeatureList XGUI_SelectionMgr::selectedFeatures() const
+/*QFeatureList XGUI_SelectionMgr::selectedFeatures() const
{
return myWorkshop->objectBrowser()->selectedFeatures();
}
if (!aShape.IsNull())
theList.Append(aShape);
}
-}
+}*/
class XGUI_Workshop;
class XGUI_ObjectsBrowser;
+class XGUI_Selection;
/**\class XGUI_SelectionMgr
* \ingroup GUI
XGUI_SelectionMgr(XGUI_Workshop* theParent);
virtual ~XGUI_SelectionMgr();
+ XGUI_Selection* selection() const { return mySelection; }
+
//! Returns list of currently selected data objects
- QFeatureList selectedFeatures() const;
+ //QFeatureList selectedFeatures() const;
//! Returns list of currently selected QModelIndexes
- QModelIndexList selectedIndexes() const;
+ //QModelIndexList selectedIndexes() const;
//! Returns list of currently selected AIS objects
- void selectedAISObjects(AIS_ListOfInteractive& theList) const;
+ //void selectedAISObjects(AIS_ListOfInteractive& theList) const;
//! Returns list of currently selected shapes
- void selectedShapes(NCollection_List<TopoDS_Shape>& theList) const;
+ //void selectedShapes(NCollection_List<TopoDS_Shape>& theList) const;
//! Connects the manager to all viewers accessible by Workshop
void connectViewers();
void onViewerSelection();
private:
-
XGUI_Workshop* myWorkshop;
+ XGUI_Selection* mySelection;
};
#endif
+++ /dev/null
-// File: XGUI_ViewerPrs.cpp
-// Created: 20 Apr 2014
-// Author: Natalia ERMOLAEVA
-
-#include "XGUI_ViewerPrs.h"
-
-#include "SelectMgr_EntityOwner.hxx"
-
-XGUI_ViewerPrs::XGUI_ViewerPrs()
-{
-}
-
-XGUI_ViewerPrs::XGUI_ViewerPrs(FeaturePtr theFeature,
- const TopoDS_Shape& theShape,
- Handle(SelectMgr_EntityOwner) theOwner)
-: myFeature(theFeature), myShape(theShape), myOwner(theOwner)
-{
-}
-
-XGUI_ViewerPrs::~XGUI_ViewerPrs()
-{
-}
-
-void XGUI_ViewerPrs::setFeature(FeaturePtr theFeature)
-{
- myFeature = theFeature;
-}
-
-FeaturePtr XGUI_ViewerPrs::feature() const
-{
- return myFeature;
-}
-
-void XGUI_ViewerPrs::setOwner(Handle(SelectMgr_EntityOwner) theOwner)
-{
- myOwner = theOwner;
-}
-
-Handle(SelectMgr_EntityOwner) XGUI_ViewerPrs::owner() const
-{
- return myOwner;
-}
-
-void XGUI_ViewerPrs::setShape(const TopoDS_Shape& theShape)
-{
- myShape = theShape;
-}
-
-const TopoDS_Shape& XGUI_ViewerPrs::shape() const
-{
- return myShape;
-}
-
-bool XGUI_ViewerPrs::operator==(const XGUI_ViewerPrs& thePrs)
-{
- bool aFeature = (myFeature.get() == thePrs.feature().get());
- bool aOwner = (myOwner.Access() == thePrs.owner().Access());
- bool aShape = myShape.IsEqual(thePrs.shape());
- return aFeature && aOwner && aShape;
-}
+++ /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>
-#include <SelectMgr_EntityOwner.hxx>
-
-#include <ModelAPI_Feature.h>
-
-/**\class XGUI_ViewerPrs
- * \ingroup GUI
- * \brief Presentation. Provides container to have feature, shape and/or selection owner.
- */
-class XGUI_EXPORT XGUI_ViewerPrs
-{
-public:
- /// Constructor
- XGUI_ViewerPrs();
- /// Constructor
- /// \param theFeature a model feature
- /// \param theShape a viewer shape
- /// \param theOwner a selection owner
- XGUI_ViewerPrs(FeaturePtr theFeature,
- const TopoDS_Shape& theShape,
- Handle_SelectMgr_EntityOwner theOwner);
- /// Destructor
- virtual ~XGUI_ViewerPrs();
-
- /// Sets the feature.
- /// \param theFeature a feature instance
- void setFeature(FeaturePtr theFeature);
-
- /// Returns the feature.
- /// \return a feature instance
- FeaturePtr feature() const;
-
- /// Returns the presentation owner
- /// \param the owner
- void setOwner(Handle_SelectMgr_EntityOwner theOwner);
-
- /// Returns the presentation owner
- /// \return an owner
- Handle_SelectMgr_EntityOwner owner() const;
-
- /// Sets the shape
- /// \param theShape a shape instance
- void setShape(const TopoDS_Shape& theShape);
-
- /// Returns the shape
- /// \return a shape instance
- const TopoDS_Shape& shape() const;
-
- bool operator==(const XGUI_ViewerPrs&);
-
-private:
- FeaturePtr myFeature; /// the feature
- Handle(SelectMgr_EntityOwner) myOwner; /// the selection owner
- TopoDS_Shape myShape; /// the shape
-};
-
-#endif
#include "XGUI_Viewer.h"
#include "ModuleBase_WidgetFactory.h"
#include "XGUI_SelectionMgr.h"
+#include "XGUI_Selection.h"
#include "XGUI_ObjectsBrowser.h"
#include "XGUI_Displayer.h"
#include "XGUI_OperationMgr.h"
#include <ModuleBase_Operation.h>
#include <ModuleBase_Operation.h>
#include <ModuleBase_OperationDescription.h>
-#include <ModuleBase_ViewSelectionValidator.h>
+#include <ModuleBase_SelectionValidator.h>
#include <Config_Common.h>
#include <Config_FeatureMessage.h>
//**************************************************************
void XGUI_Workshop::onContextMenuCommand(const QString& theId, bool isChecked)
{
- QFeatureList aFeatures = mySelector->selectedFeatures();
+ QFeatureList aFeatures = mySelector->selection()->selectedFeatures();
if ((theId == "ACTIVATE_PART_CMD") && (aFeatures.size() > 0))
activatePart(aFeatures.first());
else if (theId == "DEACTIVATE_PART_CMD")
{
PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
- Handle(AIS_InteractiveContext) aContext = viewer()->AISContext();
+ XGUI_Selection* aSelection = mySelector->selection();
QList<QAction*> aActions = getModuleCommands();
foreach(QAction* aAction, aActions) {
QString aId = aAction->data().toString();
const ModelAPI_Validator* aValidator = aFactory->validator(aId.toStdString());
if (aValidator) {
- const ModuleBase_ViewSelectionValidator* aSelValidator =
- dynamic_cast<const ModuleBase_ViewSelectionValidator*>(aValidator);
+ const ModuleBase_SelectionValidator* aSelValidator =
+ dynamic_cast<const ModuleBase_SelectionValidator*>(aValidator);
if (aSelValidator) {
- aAction->setEnabled(aSelValidator->isValid(aContext));
+ aAction->setEnabled(aSelValidator->isValid(aSelection));
}
}
}