]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Correction of SHAPER for OCCT Issue #27958 (Visualization, AIS_Trihedron - add Shadin...
authornds <nds@opencascade.com>
Fri, 10 Mar 2017 12:19:36 +0000 (15:19 +0300)
committernds <nds@opencascade.com>
Fri, 10 Mar 2017 12:19:36 +0000 (15:19 +0300)
src/ModuleBase/ModuleBase_ViewerFilters.cpp
src/SketchPlugin/SketchPlugin_ConstraintSplit.cpp
src/XGUI/XGUI.h
src/XGUI/XGUI_Displayer.cpp
src/XGUI/XGUI_Selection.cpp
src/XGUI/XGUI_Selection.h
src/XGUI/XGUI_Workshop.cpp

index eddfc51cb4c6b1885ab0e51b2d0e4d380e461ef9..03d24a4693071b58352a3828cabaca3ca25f6a16 100644 (file)
 
 #include <AIS_InteractiveObject.hxx>
 #include <AIS_Shape.hxx>
+#ifdef BEFORE_TRIHEDRON_PATCH
 #include <AIS_Axis.hxx>
 #include <AIS_Point.hxx>
 #include <AIS_Plane.hxx>
+#else
+#include <AIS_Trihedron.hxx>
+#include <AIS_TrihedronOwner.hxx>
+#include <Geom_Axis2Placement.hxx>
+#endif
 #include <Geom_Point.hxx>
 #include <Geom_Line.hxx>
 #include <Geom_Plane.hxx>
@@ -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;
       }
index 08be7f1694d1690931c2880b027b822a01cc5584..38a0c067a1a59a4afcef4c11de5b3098e57cfecd 100755 (executable)
@@ -45,6 +45,8 @@
 
 #include <cmath>
 
+//#define CREATE_CONSTRAINTS
+
 //#define DEBUG_SPLIT
 #ifdef DEBUG_SPLIT
 #include <iostream>
@@ -885,6 +887,7 @@ void SketchPlugin_ConstraintSplit::splitLine(FeaturePtr& theSplitFeature,
     thePoints.insert(std::dynamic_pointer_cast<GeomDataAPI_Point2D>
                                        (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(
index a0e77cd64bdc2d5f86d5faac9c4abe948a9c6447..316e5ac903a6b5a8dc070077ca26f274fdd77893 100644 (file)
@@ -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 )
index f51ac398f15f5984aac3be0fedcbb94415538eb0..004f9a96772d5d3354fd824c10dd37eec914d242 100644 (file)
@@ -49,9 +49,11 @@ static bool VInspector_FirstCall = true;
 #include <AIS_Shape.hxx>
 #include <AIS_Dimension.hxx>
 #include <AIS_Trihedron.hxx>
+#ifdef BEFORE_TRIHEDRON_PATCH
 #include <AIS_Axis.hxx>
 #include <AIS_Plane.hxx>
 #include <AIS_Point.hxx>
+#endif
 #include <AIS_Selection.hxx>
 #include <TColStd_ListIteratorOfListOfInteger.hxx>
 #include <SelectMgr_ListOfFilter.hxx>
@@ -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();
   }
index 5af4ea4c3f4739988c0d331433bb58b6507f1b20..e16cccf831651b9cf03b2a8702180d17c5a4bb71 100644 (file)
 #include <ModelAPI_ResultConstruction.h>
 
 #include <AIS_InteractiveContext.hxx>
+#ifdef BEFORE_TRIHEDRON_PATCH
 #include <AIS_Axis.hxx>
 #include <AIS_Point.hxx>
+#else
+#include <AIS_TrihedronOwner.hxx>
+#endif
 #include <Geom_Line.hxx>
 #include <BRep_Builder.hxx>
 #include <TopoDS_Edge.hxx>
@@ -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<GeomAPI_Shape> 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<ModelAPI_ResultConstruction>(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
index cf9fec382307e3618a69c7151bff4f499c3a253c..c6c31d32c14538c74c044f33337114b6d40c3414 100644 (file)
@@ -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;
index 527d4423e2d22002bbc3d1ab9afa6c2826499db6..a88f5a4caffc90bbe7f72ba6780264f25dcb322c 100755 (executable)
 #include <SUIT_ResourceMgr.h>
 
 #include <AIS_Trihedron.hxx>
+#ifdef BEFORE_TRIHEDRON_PATCH
 #include <AIS_Point.hxx>
 #include <AIS_Axis.hxx>
+#endif
 
 #include <QApplication>
 #include <QFileDialog>
@@ -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();
 }