From 15ba08856f0c39d49e92d37bcd97d1f6ec40c577 Mon Sep 17 00:00:00 2001 From: nds Date: Fri, 10 Mar 2017 15:19:36 +0300 Subject: [PATCH] Correction of SHAPER for OCCT Issue #27958 (Visualization, AIS_Trihedron - add Shading display mode) --- src/ModuleBase/ModuleBase_ViewerFilters.cpp | 31 ++++++++++++++ .../SketchPlugin_ConstraintSplit.cpp | 8 ++++ src/XGUI/XGUI.h | 2 + src/XGUI/XGUI_Displayer.cpp | 5 ++- src/XGUI/XGUI_Selection.cpp | 42 +++++++++++++++++++ src/XGUI/XGUI_Selection.h | 2 + src/XGUI/XGUI_Workshop.cpp | 5 ++- 7 files changed, 93 insertions(+), 2 deletions(-) diff --git a/src/ModuleBase/ModuleBase_ViewerFilters.cpp b/src/ModuleBase/ModuleBase_ViewerFilters.cpp index eddfc51cb..03d24a469 100644 --- a/src/ModuleBase/ModuleBase_ViewerFilters.cpp +++ b/src/ModuleBase/ModuleBase_ViewerFilters.cpp @@ -17,9 +17,15 @@ #include #include +#ifdef BEFORE_TRIHEDRON_PATCH #include #include #include +#else +#include +#include +#include +#endif #include #include #include @@ -109,6 +115,7 @@ Standard_Boolean ModuleBase_ShapeInPlaneFilter::IsOk( // Check Trihedron sub-objects Handle(SelectMgr_SelectableObject) aSelObj = theOwner->Selectable(); Handle(Standard_Type) aType = aSelObj->DynamicType(); +#ifdef BEFORE_TRIHEDRON_PATCH if (aType == STANDARD_TYPE(AIS_Axis)) { Handle(AIS_Axis) aAxis = Handle(AIS_Axis)::DownCast(aSelObj); gp_Lin aLine = aAxis->Component()->Lin(); @@ -123,6 +130,30 @@ Standard_Boolean ModuleBase_ShapeInPlaneFilter::IsOk( gp_Pln aPln = aAisPlane->Component()->Pln(); return aPlane.Distance(aPln) < Precision::Confusion(); } +#else + if (aType == STANDARD_TYPE(AIS_Trihedron)) { + Handle(AIS_Trihedron) aTrihedron = Handle(AIS_Trihedron)::DownCast(aSelObj); + Handle(AIS_TrihedronOwner) aTrOwner = Handle(AIS_TrihedronOwner)::DownCast(theOwner); + if (!aTrOwner.IsNull()) + { + const Prs3d_DatumParts& aPart = aTrOwner->DatumPart(); + if (aPart >= Prs3d_DP_XAxis && aPart <= Prs3d_DP_ZAxis) + { + Handle(Prs3d_Drawer) aDrawer = aTrihedron->Attributes(); + Handle(Prs3d_DatumAspect) aDatumAspect = aDrawer->DatumAspect(); + Handle(Graphic3d_ArrayOfPrimitives) aPrimitives = + aDatumAspect->ArrayOfPrimitives(aPart); + Standard_Real aX1, anY1, aZ1, aX2, anY2, aZ2; + aPrimitives->Vertice(1, aX1, anY1, aZ1); + aPrimitives->Vertice(2, aX2, anY2, aZ2); + gp_Pnt aPnt1(aX1, anY1, aZ1); + gp_Pnt aPnt2(aX2, anY2, aZ2); + gp_Lin aLine(aPnt1, gp_Dir(gp_Vec(aPnt1, aPnt2))); + return aPlane.Contains(aLine, Precision::Confusion(), Precision::Angular()); + } + } + } +#endif // This is not object controlled by the filter aValid = Standard_True; } diff --git a/src/SketchPlugin/SketchPlugin_ConstraintSplit.cpp b/src/SketchPlugin/SketchPlugin_ConstraintSplit.cpp index 08be7f169..38a0c067a 100755 --- a/src/SketchPlugin/SketchPlugin_ConstraintSplit.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintSplit.cpp @@ -45,6 +45,8 @@ #include +//#define CREATE_CONSTRAINTS + //#define DEBUG_SPLIT #ifdef DEBUG_SPLIT #include @@ -885,6 +887,7 @@ void SketchPlugin_ConstraintSplit::splitLine(FeaturePtr& theSplitFeature, thePoints.insert(std::dynamic_pointer_cast (theSplitFeature->attribute(SketchPlugin_Line::START_ID()))); +#ifdef CREATE_CONSTRAINTS // additional constraints between split and base features aConstraintFeature = createConstraintForObjects(SketchPlugin_ConstraintParallel::ID(), getFeatureResult(aBaseFeature), @@ -896,6 +899,7 @@ void SketchPlugin_ConstraintSplit::splitLine(FeaturePtr& theSplitFeature, getFeatureResult(theAfterFeature)); theCreatedFeatures.insert(aConstraintFeature); } +#endif } void SketchPlugin_ConstraintSplit::splitArc(FeaturePtr& theSplitFeature, @@ -1021,6 +1025,7 @@ void SketchPlugin_ConstraintSplit::splitArc(FeaturePtr& theSplitFeature, (theSplitFeature->attribute(SketchPlugin_Arc::START_ID()))); // additional constraints between split and base features +#ifdef CREATE_CONSTRAINTS aConstraintFeature = createConstraintForObjects(SketchPlugin_ConstraintEqual::ID(), getFeatureResult(aBaseFeature), getFeatureResult(theSplitFeature)); @@ -1039,6 +1044,7 @@ void SketchPlugin_ConstraintSplit::splitArc(FeaturePtr& theSplitFeature, getFeatureResult(theAfterFeature)); theCreatedFeatures.insert(aConstraintFeature); } +#endif } void SketchPlugin_ConstraintSplit::splitCircle(FeaturePtr& theSplitFeature, @@ -1102,10 +1108,12 @@ void SketchPlugin_ConstraintSplit::splitCircle(FeaturePtr& theSplitFeature, theSplitFeature->attribute(SketchPlugin_Arc::START_ID())); theCreatedFeatures.insert(aConstraintFeature); +#ifdef CREATE_CONSTRAINTS aConstraintFeature = createConstraintForObjects(SketchPlugin_ConstraintTangent::ID(), getFeatureResult(theSplitFeature), getFeatureResult(theBaseFeatureModified)); theCreatedFeatures.insert(aConstraintFeature); +#endif } void SketchPlugin_ConstraintSplit::arrangePointsOnLine( diff --git a/src/XGUI/XGUI.h b/src/XGUI/XGUI.h index a0e77cd64..316e5ac90 100644 --- a/src/XGUI/XGUI.h +++ b/src/XGUI/XGUI.h @@ -3,6 +3,8 @@ #ifndef XGUI_H #define XGUI_H +//#define BEFORE_TRIHEDRON_PATCH + #if defined XGUI_EXPORTS #if defined WIN32 #define XGUI_EXPORT __declspec( dllexport ) diff --git a/src/XGUI/XGUI_Displayer.cpp b/src/XGUI/XGUI_Displayer.cpp index f51ac398f..004f9a967 100644 --- a/src/XGUI/XGUI_Displayer.cpp +++ b/src/XGUI/XGUI_Displayer.cpp @@ -49,9 +49,11 @@ static bool VInspector_FirstCall = true; #include #include #include +#ifdef BEFORE_TRIHEDRON_PATCH #include #include #include +#endif #include #include #include @@ -767,6 +769,7 @@ void XGUI_Displayer::deactivateTrihedron(const bool theUpdateViewer) const ); /// #1136 hidden axis are selected in sketch +#ifdef BEFORE_TRIHEDRON_PATCH deactivateObject(aContext, aTrie->XAxis() #ifdef VINSPECTOR , getCallBack() @@ -803,7 +806,7 @@ void XGUI_Displayer::deactivateTrihedron(const bool theUpdateViewer) const , getCallBack() #endif ); - +#endif if (theUpdateViewer) updateViewer(); } diff --git a/src/XGUI/XGUI_Selection.cpp b/src/XGUI/XGUI_Selection.cpp index 5af4ea4c3..e16cccf83 100644 --- a/src/XGUI/XGUI_Selection.cpp +++ b/src/XGUI/XGUI_Selection.cpp @@ -19,8 +19,12 @@ #include #include +#ifdef BEFORE_TRIHEDRON_PATCH #include #include +#else +#include +#endif #include #include #include @@ -135,9 +139,11 @@ void XGUI_Selection::fillPresentation(ModuleBase_ViewerPrsPtr& thePrs, // the located method is called in the context to obtain the shape by the SelectedShape() // method, so the shape is located by the same rules TopoDS_Shape aShape = aBRO->Shape().Located (aBRO->Location() * aBRO->Shape().Location()); +#ifdef BEFORE_TRIHEDRON_PATCH #ifndef DEBUG_DELIVERY if (aShape.IsNull()) aShape = findAxisShape(anIO); +#endif #endif if (!aShape.IsNull()) { std::shared_ptr aGeomShape = @@ -148,6 +154,7 @@ void XGUI_Selection::fillPresentation(ModuleBase_ViewerPrsPtr& thePrs, } else { #ifdef DEBUG_DELIVERY // Fill by trihedron shapes +#ifdef BEFORE_TRIHEDRON_PATCH Handle(AIS_Axis) aAxis = Handle(AIS_Axis)::DownCast(anIO); DocumentPtr aDoc = ModelAPI_Session::get()->moduleDocument(); int aSize = aDoc->size(ModelAPI_ResultConstruction::group()); @@ -197,6 +204,39 @@ void XGUI_Selection::fillPresentation(ModuleBase_ViewerPrsPtr& thePrs, } } } +#else + /// find axis direction + Handle(AIS_TrihedronOwner) aTrihedronOwner = Handle(AIS_TrihedronOwner)::DownCast(theOwner); + if (!aTrihedronOwner.IsNull()) { + const Prs3d_DatumParts& aPart = aTrihedronOwner->DatumPart(); + std::string aName; + switch (aPart) { + case Prs3d_DP_Origin: aName = "Origin"; break; + case Prs3d_DP_XAxis: aName = "OX"; break; + case Prs3d_DP_YAxis: aName = "OY"; break; + case Prs3d_DP_ZAxis: aName = "OZ"; break; + default: break; + } + if (aName.length() > 0) { + DocumentPtr aDoc = ModelAPI_Session::get()->moduleDocument(); + int aSize = aDoc->size(ModelAPI_ResultConstruction::group()); + ObjectPtr aObj; + ResultPtr aResult; + for (int i = 0; i < aSize; i++) { + aObj = aDoc->object(ModelAPI_ResultConstruction::group(), i); + if (aObj->data()->name() == aName) { + aResult = std::dynamic_pointer_cast(aObj); + break; + } + } + if (aResult.get()) { + thePrs->setObject(aResult); + thePrs->setShape(aResult->shape()); + return; + } + } + } +#endif #endif } @@ -348,6 +388,7 @@ void XGUI_Selection::entityOwners(const Handle(AIS_InteractiveObject)& theObject } //************************************************************** +#ifdef BEFORE_TRIHEDRON_PATCH TopoDS_Shape XGUI_Selection::findAxisShape(Handle(AIS_InteractiveObject) theIO) const { TopoDS_Shape aShape; @@ -378,3 +419,4 @@ TopoDS_Shape XGUI_Selection::findAxisShape(Handle(AIS_InteractiveObject) theIO) } return aShape; } +#endif diff --git a/src/XGUI/XGUI_Selection.h b/src/XGUI/XGUI_Selection.h index cf9fec382..c6c31d32c 100644 --- a/src/XGUI/XGUI_Selection.h +++ b/src/XGUI/XGUI_Selection.h @@ -106,7 +106,9 @@ protected: /// Generates a vertex or edge by the give IO if it is an AIS created on trihedron /// \param theIO a selected object /// \return created shape or empty shape +#ifdef BEFORE_TRIHEDRON_PATCH TopoDS_Shape findAxisShape(Handle(AIS_InteractiveObject) theIO) const; +#endif private: XGUI_Workshop* myWorkshop; diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 527d4423e..a88f5a4ca 100755 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -85,8 +85,10 @@ #include #include +#ifdef BEFORE_TRIHEDRON_PATCH #include #include +#endif #include #include @@ -341,13 +343,14 @@ void XGUI_Workshop::deactivateModule() Standard_Integer aMode = itr.Value(); aContext->Deactivate(aTrihedron, aMode); } +#ifdef BEFORE_TRIHEDRON_PATCH /// Trihedron problem: objects stayed in the viewer, should be removed manually /// otherwise in SALOME happens crash by HideAll in the viewer aContext->Remove(aTrihedron->Position(), true); aContext->Remove(aTrihedron->Axis(), true); aContext->Remove(aTrihedron->XAxis(), true); aContext->Remove(aTrihedron->YAxis(), true); - +#endif myOperationMgr->deactivate(); } -- 2.39.2