From 801a1d027cd6cd7b864d90c30ca6d409f8cb9b2f Mon Sep 17 00:00:00 2001 From: vsv Date: Thu, 12 Nov 2015 18:08:50 +0300 Subject: [PATCH] Deactivate selection of trihedron functionality and take it into account in shape plane filter --- src/ModuleBase/ModuleBase_ViewerFilters.cpp | 25 ++++++++++++++++++++- src/XGUI/XGUI_Displayer.cpp | 20 ++++++++++++++--- 2 files changed, 41 insertions(+), 4 deletions(-) diff --git a/src/ModuleBase/ModuleBase_ViewerFilters.cpp b/src/ModuleBase/ModuleBase_ViewerFilters.cpp index a3d20fce7..8ee95af0c 100644 --- a/src/ModuleBase/ModuleBase_ViewerFilters.cpp +++ b/src/ModuleBase/ModuleBase_ViewerFilters.cpp @@ -15,6 +15,12 @@ #include #include +#include +#include +#include +#include +#include +#include #include @@ -74,11 +80,11 @@ Standard_Boolean ModuleBase_ShapeInPlaneFilter::IsOk(const Handle(SelectMgr_Enti if (myPlane.get()) { aValid = Standard_False; if (theOwner->HasSelectable()) { + gp_Pln aPlane = myPlane->impl(); Handle(StdSelect_BRepOwner) aShapeOwner = Handle(StdSelect_BRepOwner)::DownCast(theOwner); if (!aShapeOwner.IsNull() && aShapeOwner->HasShape()) { TopoDS_Shape aShape = aShapeOwner->Shape(); TopAbs_ShapeEnum aType = aShape.ShapeType(); - gp_Pln aPlane = myPlane->impl(); switch (aType) { case TopAbs_VERTEX: { @@ -105,6 +111,23 @@ Standard_Boolean ModuleBase_ShapeInPlaneFilter::IsOk(const Handle(SelectMgr_Enti break; } } else { + // Check Trihedron sub-objects + Handle(SelectMgr_SelectableObject) aSelObj = theOwner->Selectable(); + Handle(Standard_Type) aType = aSelObj->DynamicType(); + if (aType == STANDARD_TYPE(AIS_Axis)) { + Handle(AIS_Axis) aAxis = Handle(AIS_Axis)::DownCast(aSelObj); + gp_Lin aLine = aAxis->Component()->Lin(); + return aPlane.Contains(aLine, Precision::Confusion(), Precision::Angular()); + + } else if (aType == STANDARD_TYPE(AIS_Point)) { + Handle(AIS_Point) aPoint = Handle(AIS_Point)::DownCast(aSelObj); + return aPlane.Distance(aPoint->Component()->Pnt()) < Precision::Confusion(); + + } else if (aType == STANDARD_TYPE(AIS_Plane)) { + Handle(AIS_Plane) aAisPlane = Handle(AIS_Plane)::DownCast(aSelObj); + gp_Pln aPln = aAisPlane->Component()->Pln(); + return aPlane.Distance(aPln) < Precision::Confusion(); + } // This is not object controlled by the filter aValid = Standard_True; } diff --git a/src/XGUI/XGUI_Displayer.cpp b/src/XGUI/XGUI_Displayer.cpp index 6c1387077..5e27a844a 100644 --- a/src/XGUI/XGUI_Displayer.cpp +++ b/src/XGUI/XGUI_Displayer.cpp @@ -471,7 +471,7 @@ void XGUI_Displayer::activateObjects(const QIntList& theModes, const QObjectPtrL } if (!aTrihedron.IsNull()) { foreach(int aMode, myActiveSelectionModes) - aContext->SetSelectionSensitivity(aTrihedron, aMode, 15); + aContext->SetSelectionSensitivity(aTrihedron, aMode, 20); } // VSV It seems that there is no necessity to update viewer on activation //if (theUpdateViewer && isActivationChanged) @@ -573,11 +573,24 @@ bool XGUI_Displayer::eraseAll(const bool theUpdateViewer) return aErased; } +#define DEACTVATE_COMP(TheComp) \ + if (!TheComp.IsNull()) \ + aContext->Deactivate(TheComp); + void XGUI_Displayer::deactivateTrihedron() const { Handle(AIS_InteractiveObject) aTrihedron = getTrihedron(); if (!aTrihedron.IsNull()) { - deactivateAIS(aTrihedron); + Handle(AIS_Trihedron) aTrie = Handle(AIS_Trihedron)::DownCast(aTrihedron); + Handle(AIS_InteractiveContext) aContext = AISContext(); + aContext->Deactivate(aTrie); + DEACTVATE_COMP(aTrie->XAxis()); + DEACTVATE_COMP(aTrie->YAxis()); + DEACTVATE_COMP(aTrie->Axis()); + DEACTVATE_COMP(aTrie->Position()); + DEACTVATE_COMP(aTrie->XYPlane()); + DEACTVATE_COMP(aTrie->XZPlane()); + DEACTVATE_COMP(aTrie->YZPlane()); } } @@ -1126,6 +1139,7 @@ std::string XGUI_Displayer::getResult2AISObjectMapInfo() const void XGUI_Displayer::activateTrihedron(bool theIsActive) { myIsTrihedronActive = theIsActive; - if (!myIsTrihedronActive) + if (!myIsTrihedronActive) { deactivateTrihedron(); + } } -- 2.30.2