ModuleBase_ActionInfo.h
ModuleBase_Definitions.h
ModuleBase_DoubleSpinBox.h
+ ModuleBase_Events.h
ModuleBase_Filter.h
ModuleBase_FilterFactory.h
ModuleBase_FilterValidated.h
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: ModuleBase_Events.h
+// Created: 21 June 2016
+// Author: Natalia Ermolaeva
+
+#ifndef ModuleBase_Events_H
+#define ModuleBase_Events_H
+
+#include "ModuleBase.h"
+
+static const char * EVENT_UPDATE_BY_WIDGET_SELECTION = "SelectionUpdatedByWidget";
+
+#endif
myVisualizedObjects.clear();
// store hidden result features
- std::list<ResultPtr> aResults = aFeature->results();
+ std::list<ResultPtr> aResults;
+ ModelAPI_Tools::allResults(aFeature, aResults);
std::list<ResultPtr>::const_iterator aIt;
for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
ObjectPtr anObject = *aIt;
return;
// store hidden result features
- std::list<ResultPtr> aResults = aFeature->results();
+ std::list<ResultPtr> aResults;
+ ModelAPI_Tools::allResults(aFeature, aResults);
std::list<ResultPtr>::const_iterator aIt;
for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
ObjectPtr anObject = *aIt;
if (aFeature) {
if (aFeature == theObj)
return true;
- std::list<ResultPtr> aResults = aFeature->results();
+ std::list<ResultPtr> aResults;
+ ModelAPI_Tools::allResults(aFeature, aResults);
std::list<ResultPtr>::const_iterator aIt;
for (aIt = aResults.cbegin(); aIt != aResults.cend(); ++aIt) {
- if (theObj == (*aIt))
- return true;
+ ResultPtr aResult = *aIt;
+ if (theObj == aResult)
+ return true;
}
#ifdef DEBUG_DO_NOT_ACTIVATE_SUB_FEATURE
if (aFeature->isMacro()) {
if (aFeature) {
QList<ModuleBase_ViewerPrsPtr> aSelected = theSelection->getSelected(ModuleBase_ISelection::AllControls);
- std::list<ResultPtr> aResults = aFeature->results();
+ std::list<ResultPtr> aResults;
+ ModelAPI_Tools::allResults(aFeature, aResults);
QObjectPtrList aResList;
std::list<ResultPtr>::const_iterator aIt;
for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt)
#include <AIS_Selection.hxx>
#include <TColStd_ListIteratorOfListOfInteger.hxx>
#include <Graphic3d_AspectMarker3d.hxx>
+#include <TopExp_Explorer.hxx>
IMPLEMENT_STANDARD_HANDLE(ModuleBase_BRepOwner, StdSelect_BRepOwner);
IMPLEMENT_STANDARD_RTTIEXT(ModuleBase_BRepOwner, StdSelect_BRepOwner);
ModuleBase_ResultPrs::ModuleBase_ResultPrs(ResultPtr theResult)
- : ViewerData_AISShape(TopoDS_Shape()), myResult(theResult)
+ : ViewerData_AISShape(TopoDS_Shape()), myResult(theResult), myAdditionalSelectionPriority(0)
{
std::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(theResult);
TopoDS_Shape aShape = aShapePtr->impl<TopoDS_Shape>();
ModuleBase_Tools::setPointBallHighlighting(this);
}
+void ModuleBase_ResultPrs::setAdditionalSelectionPriority(const int thePriority)
+{
+ myAdditionalSelectionPriority = thePriority;
+}
+
void ModuleBase_ResultPrs::Compute(const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
const Handle(Prs3d_Presentation)& thePresentation,
const Standard_Integer theMode)
// In order to avoid using custom selection modes
return;
+ // TODO: OCCT issue should be created for the COMPOUND processing
+ // before it is fixed, the next workaround in necessary
+ if (aMode == AIS_Shape::SelectionMode(TopAbs_COMPOUND)) {
+ const TopoDS_Shape& aShape = Shape();
+ TopExp_Explorer aCompExp(aShape, TopAbs_COMPOUND);
+ // do not activate in compound mode shapes which do not contain compounds
+ if (!aCompExp.More())
+ return;
+ }
+
if (aMode == AIS_Shape::SelectionMode(TopAbs_COMPSOLID)) {
// Limit selection area only by actual object (Shape)
ResultCompSolidPtr aCompSolid = ModelAPI_Tools::compSolidOwner(myResult);
//AIS_Shape::ComputeSelection(aSelection, 0);
}
AIS_Shape::ComputeSelection(aSelection, aMode);
+
+ if (myAdditionalSelectionPriority > 0) {
+ for (aSelection->Init(); aSelection->More(); aSelection->Next()) {
+ Handle(SelectBasics_EntityOwner) aBasicsOwner = aSelection->Sensitive()->BaseSensitive()->OwnerId();
+ if (!aBasicsOwner.IsNull())
+ aBasicsOwner->Set(aBasicsOwner->Priority() + myAdditionalSelectionPriority);
+ }
+ }
}
void ModuleBase_ResultPrs::appendWiresSelection(const Handle(SelectMgr_Selection)& theSelection,
#include <Standard_DefineHandle.hxx>
#include <StdSelect_BRepOwner.hxx>
+#include <QMap>
+
DEFINE_STANDARD_HANDLE(ModuleBase_BRepOwner, StdSelect_BRepOwner)
/**
/// Returns result object
Standard_EXPORT ResultPtr getResult() const { return myResult; }
+ /// Returns selection priorities that will be added to created selection owner
+ /// \return integer value
+ Standard_EXPORT int getAdditionalSelectionPriority() const { return myAdditionalSelectionPriority; }
+
+ /// Appends a special priority for the mode of selection
+ /// \param theSelectionMode a mode of selection, used in ComputeSelection
+ /// \param thePriority a new priority value
+ Standard_EXPORT void setAdditionalSelectionPriority(const int thePriority);
+
DEFINE_STANDARD_RTTI(ModuleBase_ResultPrs)
protected:
/// Redefinition of virtual function
/// Original shape of the result object
TopoDS_Shape myOriginalShape;
+ /// selection priority that will be added to the standard selection priority of the selection entity
+ int myAdditionalSelectionPriority;
};
if (!aShapePrs.IsNull()) {
const TopoDS_Shape& aShape = aShapePrs->Shape();
- if (aShape.IsNull())
- Events_Error::throwException("An empty AIS presentation");
+ if (aShape.IsNull()) {
+ //Events_Error::throwException("An empty AIS presentation");
+ }
else
anInfo += QString(", shape type: %1").arg(getShapeTypeInfo(aShape.ShapeType()));
}
if (!BROwnr.IsNull() && BROwnr->HasShape()) {
const TopoDS_Shape& aShape = BROwnr->Shape();
- if (aShape.IsNull())
- Events_Error::throwException("An empty AIS presentation");
+ if (aShape.IsNull()) {
+ //Events_Error::throwException("An empty AIS presentation");
+ }
else
anInfo += QString(", shape type: %1").arg(getShapeTypeInfo(aShape.ShapeType()));
}
(theAttribute);
aShape = aSelectAttr->value();
}
+ else // Geom2D point processing
+ aShape = theWorkshop->module()->findShape(theAttribute);
return aShape;
}
//**************************************************************
-bool isSubOfComposite(const ObjectPtr& theObject)
+/*bool isSubOfComposite(const ObjectPtr& theObject)
{
bool isSub = false;
std::set<FeaturePtr> aRefFeatures;
isSub = isSubOfComposite(theObject, *anIt);
}
return isSub;
-}
+}*/
//**************************************************************
-bool isSubOfComposite(const ObjectPtr& theObject, const FeaturePtr& theFeature)
+/*bool isSubOfComposite(const ObjectPtr& theObject, const FeaturePtr& theFeature)
{
bool isSub = false;
CompositeFeaturePtr aComposite = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(theFeature);
}
}
return isSub;
-}
+}*/
//**************************************************************
ResultPtr firstResult(const ObjectPtr& theObject)
/// \param theObject a candidate to be a sub object
/// \param theFeature a candidate to be a composite feature
/// \return a boolean value
-bool MODULEBASE_EXPORT isSubOfComposite(const ObjectPtr& theObject, const FeaturePtr& theFeature);
+//bool MODULEBASE_EXPORT isSubOfComposite(const ObjectPtr& theObject, const FeaturePtr& theFeature);
/// Returns true if the result is a sub object of some composite object
/// \param theObject a result object
/// \returns boolean value
-bool MODULEBASE_EXPORT isSubOfComposite(const ObjectPtr& theObject);
+//bool MODULEBASE_EXPORT isSubOfComposite(const ObjectPtr& theObject);
/// Returns first result of the feature: the object itself if it is a result of
#include <ModuleBase_IModule.h>
#include <ModuleBase_ViewerPrs.h>
#include <ModuleBase_IconFactory.h>
+#include <ModuleBase_Events.h>
#include <ModelAPI_Data.h>
#include <ModelAPI_Object.h>
#include <ModelAPI_AttributeRefList.h>
#include <ModelAPI_AttributeRefAttrList.h>
#include <ModelAPI_Tools.h>
+#include <ModelAPI_Events.h>
#include <Config_WidgetAPI.h>
if (aValid) {
if (myFeature) {
// We can not select a result of our feature
- const std::list<ResultPtr>& aResList = myFeature->results();
+ std::list<ResultPtr> aResults;
+ ModelAPI_Tools::allResults(myFeature, aResults);
std::list<ResultPtr>::const_iterator aIt;
bool isSkipSelf = false;
- for (aIt = aResList.cbegin(); aIt != aResList.cend(); ++aIt) {
+ for (aIt = aResults.cbegin(); aIt != aResults.cend(); ++aIt) {
if ((*aIt) == aResult) {
isSkipSelf = true;
break;
{
if (!myIsNeutralPointClear) {
QList<ModuleBase_ViewerPrsPtr> aSelected = getFilteredSelected();
- if (aSelected.size() == 0)
- return;
+ // do not clear selected object
+ if (aSelected.size() == 0) {
+ if (!getAttributeSelection().empty()) {
+ // Restore selection in the viewer by the attribute selection list
+ // it should be postponed to exit from the selectionChanged processing
+ static Events_ID anEvent = Events_Loop::eventByName(EVENT_UPDATE_BY_WIDGET_SELECTION);
+ ModelAPI_EventCreator::get()->sendUpdated(myFeature, anEvent);
+ }
+ }
}
ModuleBase_WidgetSelector::onSelectionChanged();
}
#include <ModuleBase_IModule.h>
#include <ModuleBase_ResultPrs.h>
#include <ModuleBase_ViewerPrs.h>
+#include <ModuleBase_Events.h>
#include <ModelAPI_ResultConstruction.h>
+#include <ModelAPI_Events.h>
#include <TopoDS_Iterator.hxx>
activateSelectionAndFilters(true);
// Restore selection in the viewer by the attribute selection list
- myWorkshop->setSelected(getAttributeSelection());
+ // it should be postponed to have current widget as active to validate restored selection
+ static Events_ID anEvent = Events_Loop::eventByName(EVENT_UPDATE_BY_WIDGET_SELECTION);
+ ModelAPI_EventCreator::get()->sendUpdated(myFeature, anEvent);
}
//********************************************************************
/// The methiod called when widget is deactivated
virtual void deactivate();
+ /// Return the attribute values wrapped in a list of viewer presentations
+ /// \return a list of viewer presentations, which contains an attribute result and
+ /// a shape. If the attribute do not uses the shape, it is empty
+ virtual QList<std::shared_ptr<ModuleBase_ViewerPrs>> getAttributeSelection() const;
+
protected slots:
/// Slot which is called on selection event
virtual void onSelectionChanged();
// NDS: has body is temporary
virtual void updateFocus() {};
- /// Return the attribute values wrapped in a list of viewer presentations
- /// \return a list of viewer presentations, which contains an attribute result and
- /// a shape. If the attribute do not uses the shape, it is empty
- // NDS: has body is temporary
- virtual QList<std::shared_ptr<ModuleBase_ViewerPrs>> getAttributeSelection() const;
-
/// Retunrs a list of possible shape types
/// \return a list of shapes
QIntList getShapeTypes() const;
#include <ModelAPI_ResultBody.h>
#include <ModelAPI_AttributeString.h>
#include <ModelAPI_AttributeSelectionList.h>
+#include <ModelAPI_Tools.h>
#include <GeomDataAPI_Point2D.h>
#include <GeomDataAPI_Point.h>
// the objects of the current operation should be deactivated
QObjectPtrList anObjects;
anObjects.append(aFeature);
- std::list<ResultPtr> aResults = aFeature->results();
+ std::list<ResultPtr> aResults;
+ ModelAPI_Tools::allResults(aFeature, aResults);
std::list<ResultPtr>::const_iterator aIt;
for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
anObjects.append(*aIt);
{
bool aCustomized = false;
- if (theResult.get())
- return aCustomized;
-
XGUI_Workshop* aWorkshop = getWorkshop();
XGUI_Displayer* aDisplayer = aWorkshop->displayer();
ObjectPtr anObject = aDisplayer->getObject(thePrs);
- if (anObject.get()) {
+ if (!anObject)
+ return aCustomized;
+
+ if (!theResult.get()) {
bool isConflicting = myOverconstraintListener->isConflictingObject(anObject);
// customize sketch symbol presentation
if (thePrs.get()) {
aCustomized = thePrs->setColor(aColor[0], aColor[1], aColor[2]);
}
}
-
- // customize dimentional constrains
- sketchMgr()->customizePresentation(anObject);
}
+ // customize dimentional constrains
+ sketchMgr()->customizePresentation(anObject);
return aCustomized;
}
#include <ModelAPI_Validator.h>
#include <ModelAPI_Session.h>
#include <ModelAPI_ResultCompSolid.h>
+#include <ModelAPI_Tools.h>
#include <Events_InfoMessage.h>
#include <Events_Loop.h>
XGUI_Displayer* aDisplayer = XGUI_Tools::workshop(theWorkshop)->displayer();
- std::list<ResultPtr> aFeatureResults = theFeature->results();
- std::list<ResultPtr>::const_iterator aRIt = aFeatureResults.begin(),
- aRLast = aFeatureResults.end();
+ std::list<ResultPtr> aResults;
+ ModelAPI_Tools::allResults(theFeature, aResults);
+ std::list<ResultPtr>::const_iterator aRIt = aResults.begin(),
+ aRLast = aResults.end();
for (; aRIt != aRLast; aRIt++) {
ResultPtr aResult = *aRIt;
GeomShapePtr aGeomShape = aResult->shape();
#include <ModuleBase_WidgetEditor.h>
#include <ModuleBase_ViewerPrs.h>
#include <ModuleBase_Tools.h>
+#include <ModuleBase_ResultPrs.h>
#include <GeomDataAPI_Point2D.h>
return;
Handle(AIS_InteractiveContext) aContext = aViewer->AISContext();
- if (!aContext.IsNull()) {
- // MoveTo in order to highlight current object
- aContext->MoveTo(theEvent->x(), theEvent->y(), theWnd->v3dView());
- ModuleBase_Tools::selectionInfo(aContext, "PartSet_SketcherMgr::onMousePressed -- MoveTo");
- }
// Remember highlighted objects for editing
ModuleBase_ISelection* aSelect = aWorkshop->selection();
myPreviousDrawModeEnabled = aViewer->enableDrawMode(false);
- // this is temporary commented in order to avoid the following wrong case:
- // Distance constraint is under edition, double click on the digit -> nothing happens
- // because QApplication::processEvents() calls onMouseDoubleClick, which try to show editor
- // but as the prev edit is commited an new one is not started, editor is not shown.
- // This is necessary in order to finalize previous operation
- //QApplication::processEvents();
launchEditing();
+ restoreSelection();
}
}
}
qDebug("stopNestedSketch() : None");
#endif
}
+ /// improvement to deselect automatically all eventual selected objects, when
+ // returning to the neutral point of the Sketcher
+ workshop()->selector()->clearSelection();
}
void PartSet_SketcherMgr::commitNestedSketch(ModuleBase_Operation* theOperation)
if (aFOperation && (PartSet_SketcherMgr::isSketchOperation(aFOperation) ||
PartSet_SketcherMgr::isNestedSketchOperation(aFOperation)))
SketcherPrs_Tools::sendExpressionShownEvent(myIsConstraintsShown[PartSet_Tools::Expressions]);
+
+ // update entities selection priorities
+ FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
+ if (aFeature.get() && PartSet_SketcherMgr::isEntity(aFeature->getKind())) {
+ // update priority for feature
+ updateSelectionPriority(aFeature, aFeature);
+ // update priority for results of the feature
+ std::list<ResultPtr> aResults = aFeature->results();
+ std::list<ResultPtr>::const_iterator anIt = aResults.begin(), aLastIt = aResults.end();
+ for (; anIt != aLastIt; anIt++)
+ updateSelectionPriority(*anIt, aFeature);
+ }
}
ModuleBase_Operation* PartSet_SketcherMgr::getCurrentOperation() const
}
}
+void PartSet_SketcherMgr::updateSelectionPriority(ObjectPtr theObject,
+ FeaturePtr theFeature)
+{
+ if (!theObject.get() || !theFeature.get())
+ return;
+
+ AISObjectPtr anAIS = workshop()->displayer()->getAISObject(theObject);
+ Handle(AIS_InteractiveObject) anAISIO;
+ if (anAIS.get() != NULL) {
+ anAISIO = anAIS->impl<Handle(AIS_InteractiveObject)>();
+ }
+
+ if (!anAISIO.IsNull()) { // the presentation for the object is visualized
+ int anAdditionalPriority = 0;
+ // current feature
+ std::shared_ptr<SketchPlugin_Feature> aSPFeature =
+ std::dynamic_pointer_cast<SketchPlugin_Feature>(theFeature);
+ if (aSPFeature.get() != NULL) {
+ // 1. Vertices
+ // 2. Simple segments
+ // 3. External objects (violet color)
+ // 4. Auxiliary segments (dotted)
+ // StdSelect_BRepSelectionTool::Load uses priority calculating:
+ // Standard_Integer aPriority = (thePriority == -1) ? GetStandardPriority (theShape, theType) : thePriority;
+ // Priority of Vertex is 8, edge(segment) is 7.
+ // It might be not corrected as provides the condition above.
+ bool isExternal = aSPFeature->isExternal();
+ bool isAuxiliary = PartSet_Tools::isAuxiliarySketchEntity(aSPFeature);
+ // current feature
+ if (!isExternal && !isAuxiliary)
+ anAdditionalPriority = 30;
+ // external feature
+ if (isExternal)
+ anAdditionalPriority = 20;
+ // auxiliary feature
+ if (isAuxiliary) {
+ anAdditionalPriority = 10; /// auxiliary objects should have less priority that
+ // edges/vertices of local selection on not-sketch objects
+ }
+ Handle(ModuleBase_ResultPrs) aResult = Handle(ModuleBase_ResultPrs)::DownCast(anAISIO);
+ if (!aResult.IsNull()) {
+ aResult->setAdditionalSelectionPriority(anAdditionalPriority);
+ }
+ }
+ }
+}
+
XGUI_Workshop* PartSet_SketcherMgr::workshop() const
{
ModuleBase_IWorkshop* anIWorkshop = myModule->workshop();
const bool isToDisplay, const bool isFlushRedisplay = true);
private:
+ /// Updates selection priority of the presentation
+ /// \param theObject object to find a presentation which will be corrected
+ /// \param theFeature a feature of the presentation
+ void updateSelectionPriority(ObjectPtr theObject, FeaturePtr theFeature);
/// Returns current workshop
XGUI_Workshop* workshop() const;
/// Returns operation manager
class QLabel;
class PartSet_Module;
-class ModelAPI_Tools;
class ModuleBase_Operation;
class ModuleBase_IWorkshop;
class PartSet_PreviewPlanes;
virtual bool customisePresentation(ResultPtr theResult, AISObjectPtr thePrs,
std::shared_ptr<GeomAPI_ICustomPrs> theDefaultPrs)
{
- bool isCustomized = false;
+ //bool isCustomized = false;
+ bool isCustomized = theDefaultPrs.get() != NULL &&
+ theDefaultPrs->customisePresentation(theResult, thePrs, theDefaultPrs);
int aShapeType = thePrs->getShapeType();
// a compound is processed like the edge because the arc feature uses the compound for presentable AIS
if (aShapeType != 6/*an edge*/ && aShapeType != 7/*a vertex*/ && aShapeType != 0/*compound*/)
//#define MyTextHeight 20
-/// Message that document (Part, PartSet) was created
+/// Message that style of visualization of parameter is changed. It will be shown as expression or value
class SketcherPrs_ParameterStyleMessage : public Events_Message
{
public:
}
aCustomized = !aColor.empty() && thePrs->setColor(aColor[0], aColor[1], aColor[2]);
}
- else {
- if (!aCustomized) {
- ModuleBase_IModule* aModule = myWorkshop->module();
- aCustomized = aModule->customisePresentation(theResult, thePrs, theCustomPrs);
- }
- }
+ ModuleBase_IModule* aModule = myWorkshop->module();
+ aCustomized = aModule->customisePresentation(theResult, thePrs, theCustomPrs) || aCustomized;
return aCustomized;
}
//#define DEBUG_OCCT_SHAPE_SELECTION
-#define WORKAROUND_UNTIL_27523_IS_FIXED
+//#define WORKAROUND_UNTIL_27523_IS_FIXED
void displayedObjects(const Handle(AIS_InteractiveContext)& theAIS, AIS_ListOfInteractive& theList)
{
if (!aVisible) {
// check if all results of the feature are visible
FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
- std::list<ResultPtr> aResults = aFeature->results();
+ std::list<ResultPtr> aResults;
+ ModelAPI_Tools::allResults(aFeature, aResults);
std::list<ResultPtr>::const_iterator aIt;
aVisible = !aResults.empty();
for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
aContext->ActivatedModes(anAIS, aModes);
return aModes.Extent() > 0;
}
+
+
void XGUI_Displayer::setSelected(const QList<ModuleBase_ViewerPrsPtr>& theValues, bool theUpdateViewer)
{
Handle(AIS_InteractiveContext) aContext = AISContext();
if (aContext->HasOpenedContext()) {
aContext->UnhilightSelected(false);
aContext->ClearSelected(false);
- NCollection_Map<TopoDS_Shape> aShapesToBeSelected;
+ NCollection_DataMap<TopoDS_Shape, NCollection_Map<Handle(AIS_InteractiveObject)>> aShapesToBeSelected;
foreach (ModuleBase_ViewerPrsPtr aPrs, theValues) {
const GeomShapePtr& aGeomShape = aPrs->shape();
if (aGeomShape.get() && !aGeomShape->isNull()) {
const TopoDS_Shape& aShape = aGeomShape->impl<TopoDS_Shape>();
#ifdef DEBUG_OCCT_SHAPE_SELECTION
+ // problem 1: performance
+ // problem 2: IO is not specified, so the first found owner is selected, as a result
+ // it might belong to another result
aContext->AddOrRemoveSelected(aShape, false);
#else
- aShapesToBeSelected.Add(aShape);
+ NCollection_Map<Handle(AIS_InteractiveObject)> aPresentations;
+ if (aShapesToBeSelected.IsBound(aShape))
+ aPresentations = aShapesToBeSelected.Find(aShape);
+ ObjectPtr anObject = aPrs->object();
+ getPresentations(anObject, aPresentations);
+
+ aShapesToBeSelected.Bind(aShape, aPresentations);
#endif
} else {
ObjectPtr anObject = aPrs->object();
arg(aContent.join("\n")).toStdString().c_str();
}
+void XGUI_Displayer::getPresentations(const ObjectPtr& theObject,
+ NCollection_Map<Handle(AIS_InteractiveObject)>& thePresentations)
+{
+ ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
+ if (aResult.get()) {
+ AISObjectPtr aAISObj = getAISObject(aResult);
+ if (aAISObj.get() != NULL) {
+ Handle(AIS_InteractiveObject) anAIS = aAISObj->impl<Handle(AIS_InteractiveObject)>();
+ if (!anAIS.IsNull() && !thePresentations.Contains(anAIS))
+ thePresentations.Add(anAIS);
+ }
+ }
+ else {
+ FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theObject);
+ // find presentation of the feature
+ AISObjectPtr aAISObj = getAISObject(aFeature);
+ if (aAISObj.get() != NULL) {
+ Handle(AIS_InteractiveObject) anAIS = aAISObj->impl<Handle(AIS_InteractiveObject)>();
+ if (!anAIS.IsNull() && !thePresentations.Contains(anAIS))
+ thePresentations.Add(anAIS);
+ }
+ // find presentations of the feature results
+ std::list<ResultPtr> aResults;
+ ModelAPI_Tools::allResults(aFeature, aResults);
+ std::list<ResultPtr>::const_iterator anIt = aResults.begin(), aLast = aResults.end();
+ for (; anIt != aLast; ++anIt) {
+ AISObjectPtr aAISObj = getAISObject(*anIt);
+ if (aAISObj.get() != NULL) {
+ Handle(AIS_InteractiveObject) anAIS = aAISObj->impl<Handle(AIS_InteractiveObject)>();
+ if (!anAIS.IsNull() && !thePresentations.Contains(anAIS))
+ thePresentations.Add(anAIS);
+ }
+ }
+ }
+}
+
void XGUI_Displayer::activateTrihedron(bool theIsActive)
{
myIsTrihedronActive = theIsActive;
}
void XGUI_Displayer::AddOrRemoveSelectedShapes(Handle(AIS_InteractiveContext) theContext,
- const NCollection_Map<TopoDS_Shape>& theShapesToBeSelected)
+ const NCollection_DataMap<TopoDS_Shape,
+ NCollection_Map<Handle(AIS_InteractiveObject)>>& theShapesToBeSelected)
{
Handle(AIS_LocalContext) aLContext = theContext->LocalContext();
TCollection_AsciiString aSelectionName = aLContext->SelectionName();
aLContext->UnhilightPicked(Standard_False);
- NCollection_Map<TopoDS_Shape> aShapesSelected;
-
NCollection_List<Handle(SelectBasics_EntityOwner)> anActiveOwners;
aLContext->MainSelector()->ActiveOwners(anActiveOwners);
NCollection_List<Handle(SelectBasics_EntityOwner)>::Iterator anOwnersIt (anActiveOwners);
for (; anOwnersIt.More(); anOwnersIt.Next()) {
anOwner = Handle(SelectMgr_EntityOwner)::DownCast (anOwnersIt.Value());
Handle(StdSelect_BRepOwner) BROwnr = Handle(StdSelect_BRepOwner)::DownCast(anOwner);
- if (!BROwnr.IsNull() && BROwnr->HasShape() && theShapesToBeSelected.Contains(BROwnr->Shape())) {
- if (aShapesSelected.Contains(BROwnr->Shape()))
- continue;
- AIS_Selection::Selection(aSelectionName.ToCString())->Select(anOwner);
- anOwner->SetSelected (Standard_True);
- aShapesSelected.Add(BROwnr->Shape());
+ if (!BROwnr.IsNull() && BROwnr->HasShape()) {
+ const TopoDS_Shape& aShape = BROwnr->Shape();
+ if (!aShape.IsNull() && theShapesToBeSelected.IsBound(aShape)) {
+ Handle(AIS_InteractiveObject) anOwnerPresentation =
+ Handle(AIS_InteractiveObject)::DownCast(anOwner->Selectable());
+ NCollection_Map<Handle(AIS_InteractiveObject)> aPresentations =
+ theShapesToBeSelected.Find(aShape);
+ if (aPresentations.Contains(anOwnerPresentation)) {
+ AIS_Selection::Selection(aSelectionName.ToCString())->Select(anOwner);
+ anOwner->SetSelected (Standard_True);
+ }
+ }
}
}
aLContext->HilightPicked(Standard_False);
#include <TopoDS_Shape.hxx>
#include <AIS_InteractiveObject.hxx>
#include <AIS_InteractiveContext.hxx>
-#include <NCollection_List.hxx>
+#include <NCollection_Map.hxx>
+#include <NCollection_DataMap.hxx>
#include <ModelAPI_Result.h>
/// \return a string representation
std::string getResult2AISObjectMapInfo() const;
+ /// Returns container of visible presentations for the object. For a feature object,
+ /// the feature results are processed also. The presentations map is not cleared inside.
+ /// \param theObject a feature or result
+ /// \param thePresentations result map of presentations
+ void getPresentations(const ObjectPtr& theObject,
+ NCollection_Map<Handle(AIS_InteractiveObject)>& thePresentations);
+
/// Sets the shapes selected in the context. It contains logic of the similar method
/// in OCCT but improved for performance. The modification is to iterates by a list
/// of owners in the context only once.
/// \param theShapesToBeSelected a map of shapes. Owner's shape is searched in the map and the owner
/// is selected if it is found there. Only first owner is processed(according to OCCT logic)
static void AddOrRemoveSelectedShapes(Handle(AIS_InteractiveContext) theContext,
- const NCollection_Map<TopoDS_Shape>& theShapesToBeSelected);
+ const NCollection_DataMap<TopoDS_Shape,
+ NCollection_Map<Handle(AIS_InteractiveObject)>>& theShapesToBeSelected);
+
+ //const NCollection_Map<TopoDS_Shape>& theShapesToBeSelected);
protected:
/// Reference to workshop
#include <ModuleBase_PageWidget.h>
#include <ModuleBase_WidgetFactory.h>
#include <ModuleBase_OperationDescription.h>
+#include <ModuleBase_Events.h>
+
+#include <Events_Loop.h>
#include <ModelAPI_Session.h>
#include <ModelAPI_Validator.h>
theWidget->activate();
}
myActiveWidget = theWidget;
+ static Events_ID anEvent = Events_Loop::eventByName(EVENT_UPDATE_BY_WIDGET_SELECTION);
+ Events_Loop::loop()->flush(anEvent);
+
return true;
}
if (aFeature.get()) { // feature may be not created (plugin load fail)
if (myDisplayer->isVisible(aFeature) && !myDisplayer->isActive(aFeature))
anObjects.append(aFeature);
- std::list<ResultPtr> aResults = aFeature->results();
+ std::list<ResultPtr> aResults;
+ ModelAPI_Tools::allResults(aFeature, aResults);
std::list<ResultPtr>::const_iterator aIt;
for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
ResultPtr anObject = *aIt;
// The order of appending features of the part and the part itself is important
// Append features from a part feature
- foreach (const ResultPtr& aResult, aFeature->results()) {
+ std::list<ResultPtr> aResults;
+ ModelAPI_Tools::allResults(aFeature, aResults);
+ foreach (const ResultPtr& aResult, aResults) {
ResultPartPtr aResultPart =
std::dynamic_pointer_cast<ModelAPI_ResultPart>(aResult);
if (aResultPart.get() && aResultPart->partDoc().get()) {
foreach(ObjectPtr aObj, theObjects) {
aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aObj);
if (aFeature.get()) {
- aResList = aFeature->results();
+ std::list<ResultPtr> aResults;
+ ModelAPI_Tools::allResults(aFeature, aResults);
std::list<std::shared_ptr<ModelAPI_Result> >::const_iterator aIt;
for(aIt = aResList.cbegin(); aIt != aResList.cend(); aIt++) {
aHasHidden |= (*aIt)->isConcealed();
#endif
#include <ModuleBase_IModule.h>
+#include <ModuleBase_Events.h>
#include <ModelAPI_Object.h>
#include <ModelAPI_Events.h>
#include <ModuleBase_Tools.h>
#include <ModuleBase_IViewer.h>
#include <ModuleBase_FilterFactory.h>
+#include <ModuleBase_WidgetSelector.h>
#include <Config_FeatureMessage.h>
#include <Config_PointerMessage.h>
aLoop->registerListener(this, Events_Loop::eventByName(EVENT_UPDATE_VIEWER_BLOCKED));
aLoop->registerListener(this, Events_Loop::eventByName(EVENT_UPDATE_VIEWER_UNBLOCKED));
aLoop->registerListener(this, Events_Loop::eventByName(EVENT_EMPTY_AIS_PRESENTATION));
+ aLoop->registerListener(this, Events_Loop::eventByName(EVENT_UPDATE_BY_WIDGET_SELECTION));
}
//******************************************************
std::shared_ptr<ModelAPI_ObjectUpdatedMessage> aUpdMsg =
std::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
onFeatureEmptyPresentationMsg(aUpdMsg);
+ } else if (theMessage->eventID() == Events_Loop::eventByName(EVENT_UPDATE_BY_WIDGET_SELECTION)) {
+ ModuleBase_ModelWidget* aWidget = workshop()->propertyPanel()->activeWidget();
+ if (aWidget) {
+ ModuleBase_WidgetSelector* aWidgetSelector = dynamic_cast<ModuleBase_WidgetSelector*>(aWidget);
+ if (aWidgetSelector)
+ myWorkshop->setSelected(aWidgetSelector->getAttributeSelection());
+ }
}
+
//Update property panel on corresponding message. If there is no current operation (no
//property panel), or received message has different feature to the current - do nothing.
else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_UPDATED)) {