]> SALOME platform Git repositories - modules/shaper.git/blob - src/PartSet/PartSet_OperationPrs.cpp
Salome HOME
Issue #591 - Highlight of the first argument of constraints
[modules/shaper.git] / src / PartSet / PartSet_OperationPrs.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        PartSet_OperationPrs.cpp
4 // Created:     01 Jul 2015
5 // Author:      Natalia ERMOLAEVA
6
7 #include "PartSet_OperationPrs.h"
8
9 #include <ModelAPI_Tools.h>
10 #include <ModelAPI_ResultConstruction.h>
11 #include <GeomAPI_PlanarEdges.h>
12
13 #include <BRep_Builder.hxx>
14 #include <Prs3d_IsoAspect.hxx>
15 #include <TopoDS_Builder.hxx>
16
17 IMPLEMENT_STANDARD_HANDLE(PartSet_OperationPrs, ViewerData_AISShape);
18 IMPLEMENT_STANDARD_RTTIEXT(PartSet_OperationPrs, ViewerData_AISShape);
19
20 PartSet_OperationPrs::PartSet_OperationPrs(FeaturePtr theFeature)
21   : ViewerData_AISShape(TopoDS_Shape()), myFeature(theFeature)
22 {
23 /*  std::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(theResult);
24   std::shared_ptr<GeomAPI_PlanarEdges> aWirePtr = 
25     std::dynamic_pointer_cast<GeomAPI_PlanarEdges>(aShapePtr);
26   if (aWirePtr) {
27     if (aWirePtr->hasPlane() ) {
28       // If this is a wire with plane defined thin it is a sketch-like object
29       // It must have invisible faces
30       myIsSketchMode = true;
31     }
32   }
33   Set(aShapePtr->impl<TopoDS_Shape>());
34 */
35 }
36
37
38 /*#include <TopExp_Explorer.hxx>
39 #include <TopoDS_Vertex.hxx>
40 #include <StdPrs_ShadedShape.hxx>
41 #include <StdPrs_WFDeflectionShape.hxx>
42 */
43 void PartSet_OperationPrs::Compute(const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
44                                    const Handle(Prs3d_Presentation)& thePresentation, 
45                                    const Standard_Integer theMode)
46 {
47 /*  std::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(myResult);
48   if (!aShapePtr)
49     return;
50   if (myIsSketchMode) {
51     myFacesList.clear();
52     ResultConstructionPtr aConstruction = 
53       std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(myResult);
54     if (aConstruction.get()) {
55       int aFacesNum = aConstruction->facesNum();
56       for(int aFaceIndex = 0; aFaceIndex < aFacesNum; aFaceIndex++) {
57         myFacesList.push_back(aConstruction->face(aFaceIndex));
58       }
59     }
60   }
61   myOriginalShape = aShapePtr->impl<TopoDS_Shape>();
62   if (!myOriginalShape.IsNull()) {
63     Set(myOriginalShape);
64
65     AIS_Shape::Compute(thePresentationManager, thePresentation, theMode);
66     /*
67     TopExp_Explorer anExp(myOriginalShape, TopAbs_VERTEX);
68     Handle(Prs3d_Drawer) aDrawer = Attributes();
69     for (; anExp.More(); anExp.Next()) {
70       const TopoDS_Vertex& aVertex = (const TopoDS_Vertex&)anExp.Current();
71       StdPrs_WFDeflectionShape::Add(thePresentation, aVertex, aDrawer);
72     }*|/
73   }*/
74 }
75
76
77 void PartSet_OperationPrs::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
78                                             const Standard_Integer aMode)
79 {
80 /*  if (aMode > TopAbs_SHAPE)
81     // In order to avoid using custom selection modes
82     return;
83
84   if (myIsSketchMode) {
85     if (aMode == TopAbs_FACE) {
86       BRep_Builder aBuilder;
87       TopoDS_Compound aComp;
88       aBuilder.MakeCompound(aComp);
89       aBuilder.Add(aComp, myOriginalShape);
90       std::list<std::shared_ptr<GeomAPI_Shape>>::const_iterator aIt;
91       for (aIt = myFacesList.cbegin(); aIt != myFacesList.cend(); ++aIt) {
92         TopoDS_Shape aFace = (*aIt)->impl<TopoDS_Shape>();
93         aBuilder.Add(aComp, aFace);
94       }
95       Set(aComp);
96     } else {
97       Set(myOriginalShape);
98     }
99   }*/
100   AIS_Shape::ComputeSelection(aSelection, aMode);
101 }