if (!aPreviewOp)
return;
- if (isDisplay)
- myWorkshop->displayer()->Display(anOperation->feature(), aPreviewOp->preview());
- else
+ if (isDisplay) {
+ myWorkshop->displayer()->LocalSelection(anOperation->feature(), aPreviewOp->preview(),
+ aPreviewOp->getSelectionMode());
+ }
+ else {
+ myWorkshop->displayer()->GlobalSelection(false);
myWorkshop->displayer()->Erase(anOperation->feature(), aPreviewOp->preview());
+ }
}
{
return false;
}
+
+int PartSet_OperationSketch::getSelectionMode() const
+{
+ return TopAbs_FACE;
+}
/// The sketch can not be created immediately, firstly a plane should be set
virtual bool isPerformedImmediately() const;
+
+ /// Returns the operation local selection mode
+ /// \return the selection mode
+ virtual int getSelectionMode() const;
};
#endif
boost::dynamic_pointer_cast<SketchPlugin_Feature>(feature());
return aFeature->preview()->impl<TopoDS_Shape>();
}
+
+int PartSet_OperationSketchBase::getSelectionMode() const
+{
+ return 0;
+}
/// Returns the feature preview shape
const TopoDS_Shape& preview() const;
+
+ /// Returns the operation local selection mode
+ /// \return the selection mode
+ virtual int getSelectionMode() const;
};
#endif
#include <ModelAPI_Document.h>
#include <AIS_InteractiveContext.hxx>
+#include <AIS_ListOfInteractive.hxx>
+
#include <AIS_Shape.hxx>
XGUI_Displayer::XGUI_Displayer(XGUI_Viewer* theViewer)
{
}
-void XGUI_Displayer::Display(boost::shared_ptr<ModelAPI_Feature> theFeature)
+void XGUI_Displayer::Display(boost::shared_ptr<ModelAPI_Feature> theFeature,
+ const bool isUpdateViewer)
{
}
void XGUI_Displayer::Display(boost::shared_ptr<ModelAPI_Feature> theFeature,
- const TopoDS_Shape& theShape)
+ const TopoDS_Shape& theShape, const bool isUpdateViewer)
{
Handle(AIS_InteractiveContext) aContext = myViewer->AISContext();
Handle(AIS_Shape) anAIS = new AIS_Shape(theShape);
aContext->Display(anAIS, Standard_False);
- aContext->UpdateCurrentViewer();
+ if (isUpdateViewer)
+ aContext->UpdateCurrentViewer();
}
void XGUI_Displayer::Erase(boost::shared_ptr<ModelAPI_Feature> theFeature,
- const TopoDS_Shape& theShape)
+ const TopoDS_Shape& theShape, const bool isUpdateViewer)
{
Handle(AIS_InteractiveContext) aContext = myViewer->AISContext();
aContext->EraseAll();
+ if (isUpdateViewer)
+ aContext->UpdateCurrentViewer();
}
+
+void XGUI_Displayer::LocalSelection(boost::shared_ptr<ModelAPI_Feature> theFeature,
+ const TopoDS_Shape& theShape,
+ const int theMode, const bool isUpdateViewer)
+{
+ Handle(AIS_InteractiveContext) aContext = myViewer->AISContext();
+
+ Handle(AIS_Shape) anAIS = new AIS_Shape(theShape);
+ aContext->Display(anAIS, Standard_False);
+ AIS_ListOfInteractive anAISList;
+ anAISList.Append(anAIS);
+ myViewer->setLocalSelection(anAISList, theMode, true);
+}
+
+void XGUI_Displayer::GlobalSelection(const bool isUpdateViewer)
+{
+ myViewer->setGlobalSelection(true);
+}
+
/// Display the feature. Obtain the visualized object from the feature.
/// \param theFeature a feature instance
- void Display(boost::shared_ptr<ModelAPI_Feature> theFeature);
+ /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
+ void Display(boost::shared_ptr<ModelAPI_Feature> theFeature, const bool isUpdateViewer = true);
/// Display the feature and a shape. This shape would be associated to the given feature
/// \param theFeature a feature instance
- /// \param theFeature a shape
- void Display(boost::shared_ptr<ModelAPI_Feature> theFeature, const TopoDS_Shape& theShape);
+ /// \param theShape a shape
+ /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
+ void Display(boost::shared_ptr<ModelAPI_Feature> theFeature, const TopoDS_Shape& theShape,
+ const bool isUpdateViewer = true);
+
+ /// Display the shape and activate selection of sub-shapes
+ /// \param theFeature a feature instance
+ /// \param theShape a shape
+ /// \param theMode a local selection mode
+ /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
+ void LocalSelection(boost::shared_ptr<ModelAPI_Feature> theFeature, const TopoDS_Shape& theShape,
+ const int theMode, const bool isUpdateViewer = true);
/// Erase the feature and a shape.
/// \param theFeature a feature instance
/// \param theFeature a shape
- void Erase(boost::shared_ptr<ModelAPI_Feature> theFeature, const TopoDS_Shape& theShape);
+ /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
+ void Erase(boost::shared_ptr<ModelAPI_Feature> theFeature, const TopoDS_Shape& theShape,
+ const bool isUpdateViewer = true);
+
+ /// Deactivates selection of sub-shapes
+ /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
+ void GlobalSelection(const bool isUpdateViewer = true);
protected:
XGUI_Viewer* myViewer; ///< the viewer where the objects should be visualized
#include <V3d_View.hxx>
#include <Visual3d_View.hxx>
#include <AIS_ListOfInteractive.hxx>
+#include <AIS_ListIteratorOfListOfInteractive.hxx>
+#include <AIS_Shape.hxx>
#include <QMouseEvent>
return aWnd;
}
+void XGUI_Viewer::setLocalSelection(const AIS_ListOfInteractive& theAISObjects, const int theMode,
+ const bool isUpdateViewer)
+{
+ Handle(AIS_InteractiveContext) ic = AISContext();
+
+ // Open local context if there is no one
+ bool allObjects = false; // calculate by AIS shape
+ if (!ic->HasOpenedContext()) {
+ ic->ClearCurrents(false);
+ ic->OpenLocalContext(allObjects, true, true);
+ }
+
+ // Activate selection of objects from prs
+ AIS_ListIteratorOfListOfInteractive aIter(theAISObjects);
+ for (; aIter.More(); aIter.Next()) {
+ Handle(AIS_InteractiveObject) anAIS = aIter.Value();
+ if (!anAIS.IsNull()) {
+ if (anAIS->IsKind(STANDARD_TYPE(AIS_Shape))) {
+ ic->Load(anAIS, -1, false);
+ ic->Activate(anAIS, AIS_Shape::SelectionMode((TopAbs_ShapeEnum)theMode));
+ }
+ else if (anAIS->DynamicType() != STANDARD_TYPE(AIS_Trihedron)) {
+ ic->Load(anAIS, -1, false);
+ ic->Activate(anAIS, theMode);
+ }
+ }
+ }
+ if (isUpdateViewer)
+ ic->UpdateCurrentViewer();
+}
+
+void XGUI_Viewer::setGlobalSelection(const bool isUpdateViewer)
+{
+ Handle(AIS_InteractiveContext) ic = AISContext();
+ if (!ic.IsNull()) {
+ ic->CloseAllContexts(false);
+ if (isUpdateViewer)
+ ic->UpdateCurrentViewer();
+ }
+}
+
/*! Sets hot button
*\param theOper - hot operation
*\param theState - adding state to state map operations.
class QMouseEvent;
class QKeyEvent;
+class AIS_ListOfInteractive;
+
/**\class XGUI_Viewer
* \ingroup GUI
* \brief Represents a 3d viewer. The viewer manages 3d scene and a set of view windows
return myAISContext;
}
+ //! Activate local selection
+ //! \param theAIS the list of objects
+ //! \param theMode the selection mode
+ //! \param isUpdateViewer the state wether the viewer should be updated immediatelly
+ void setLocalSelection(const AIS_ListOfInteractive& theAISObjects, const int theMode,
+ const bool isUpdateViewer);
+ //! Deactivate local selection
+ //! \param isUpdateViewer the state wether the viewer should be updated immediatelly
+ void setGlobalSelection(const bool isUpdateViewer);
+
//! Trihedron 3d object shown in the viewer
Handle(AIS_Trihedron) trihedron() const
{