]> SALOME platform Git repositories - modules/shaper.git/blob - src/SketcherPrs/SketcherPrs_Coincident.cpp
Salome HOME
Exclude links to SketchPlugin
[modules/shaper.git] / src / SketcherPrs / SketcherPrs_Coincident.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        SketcherPrs_Coincident.cpp
4 // Created:     12 February 2015
5 // Author:      Vitaly SMETANNIKOV
6
7 #include "SketcherPrs_Coincident.h"
8 #include "SketcherPrs_Tools.h"
9
10 #include <ModelAPI_AttributeRefAttr.h>
11 #include <GeomDataAPI_Point2D.h>
12 #include <GeomDataAPI_Dir.h>
13 #include <GeomDataAPI_Point.h>
14
15 #include <GeomAPI_XYZ.h>
16 #include <GeomAPI_Dir.h>
17 #include <GeomAPI_Pnt2d.h>
18
19 #include <SketchPlugin_Constraint.h>
20
21 #include <AIS_Drawer.hxx>
22 #include <Graphic3d_AspectMarker3d.hxx>
23 #include <Graphic3d_ArrayOfPoints.hxx>
24 #include <Prs3d_PointAspect.hxx>
25 #include <Prs3d_Root.hxx>
26
27
28 IMPLEMENT_STANDARD_HANDLE(SketcherPrs_Coincident, AIS_InteractiveObject);
29 IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_Coincident, AIS_InteractiveObject);
30
31 SketcherPrs_Coincident::SketcherPrs_Coincident(ModelAPI_Feature* theConstraint, 
32                                                const std::shared_ptr<GeomAPI_Ax3>& thePlane) 
33  : AIS_InteractiveObject(), myConstraint(theConstraint), myPlane(thePlane)
34 {
35 }  
36
37
38
39 void SketcherPrs_Coincident::Compute(const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
40                                    const Handle(Prs3d_Presentation)& thePresentation, 
41                                    const Standard_Integer theMode)
42 {
43   std::shared_ptr<GeomAPI_Pnt2d> aPnt = SketcherPrs_Tools::getPoint(myConstraint, 
44                                                                     SketchPlugin_Constraint::ENTITY_A());
45   if (aPnt.get() == NULL)
46     return;
47
48   std::shared_ptr<GeomAPI_Pnt> aPoint = myPlane->to3D(aPnt->x(), aPnt->y());
49
50   static Handle(Graphic3d_AspectMarker3d) aPtA = new Graphic3d_AspectMarker3d ();
51   aPtA->SetType(Aspect_TOM_RING1);
52   aPtA->SetScale(2.);
53   aPtA->SetColor(myOwnColor);
54   Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup(thePresentation);
55   aGroup->SetPrimitivesAspect(aPtA);
56   Handle(Graphic3d_ArrayOfPoints) aPntArray = new Graphic3d_ArrayOfPoints(1);
57   aPntArray->AddVertex (aPoint->x(), aPoint->y(), aPoint->z());
58   aGroup->AddPrimitiveArray (aPntArray);
59 }
60
61
62 void SketcherPrs_Coincident::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
63                                             const Standard_Integer aMode)
64 {
65 }
66
67 void SketcherPrs_Coincident::SetColor(const Quantity_NameOfColor aCol)
68 {
69   SetColor(Quantity_Color(aCol));
70 }
71
72 void SketcherPrs_Coincident::SetColor(const Quantity_Color &aCol)
73 {
74   hasOwnColor=Standard_True;
75   myOwnColor=aCol;
76 }