1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: SketcherPrs_Coincident.cpp
4 // Created: 12 February 2015
5 // Author: Vitaly SMETANNIKOV
7 #include "SketcherPrs_Coincident.h"
8 #include "SketcherPrs_Tools.h"
10 #include <ModelAPI_AttributeRefAttr.h>
11 #include <GeomDataAPI_Point2D.h>
12 #include <GeomDataAPI_Dir.h>
13 #include <GeomDataAPI_Point.h>
15 #include <GeomAPI_XYZ.h>
16 #include <GeomAPI_Dir.h>
17 #include <GeomAPI_Pnt2d.h>
19 #include <Events_Error.h>
21 #include <SketchPlugin_Constraint.h>
23 #include <Graphic3d_AspectMarker3d.hxx>
24 #include <Graphic3d_ArrayOfPoints.hxx>
25 #include <Prs3d_PointAspect.hxx>
26 #include <Prs3d_Root.hxx>
27 #include <SelectMgr_EntityOwner.hxx>
28 #include <SelectMgr_Selection.hxx>
29 #include <Select3D_SensitivePoint.hxx>
32 IMPLEMENT_STANDARD_HANDLE(SketcherPrs_Coincident, AIS_InteractiveObject);
33 IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_Coincident, AIS_InteractiveObject);
35 SketcherPrs_Coincident::SketcherPrs_Coincident(ModelAPI_Feature* theConstraint,
36 const std::shared_ptr<GeomAPI_Ax3>& thePlane)
37 : AIS_InteractiveObject(), myConstraint(theConstraint), myPlane(thePlane)
44 void SketcherPrs_Coincident::Compute(const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
45 const Handle(Prs3d_Presentation)& thePresentation,
46 const Standard_Integer theMode)
48 // Get point of the presentation
49 std::shared_ptr<GeomAPI_Pnt2d> aPnt = SketcherPrs_Tools::getPoint(myConstraint,
50 SketchPlugin_Constraint::ENTITY_A());
51 if (aPnt.get() == NULL)
52 aPnt = SketcherPrs_Tools::getPoint(myConstraint, SketchPlugin_Constraint::ENTITY_B());
53 if (aPnt.get() == NULL) {
54 Events_Error::throwException("An empty AIS presentation: SketcherPrs_Coincident");
57 std::shared_ptr<GeomAPI_Pnt> aPoint = myPlane->to3D(aPnt->x(), aPnt->y());
58 myPoint = aPoint->impl<gp_Pnt>();
60 static Handle(Graphic3d_AspectMarker3d) aPtA;
62 aPtA = new Graphic3d_AspectMarker3d ();
64 // Create the presentation as a combination of standard point markers
66 // The external yellow contour
67 aPtA->SetType(Aspect_TOM_RING3);
69 aPtA->SetColor(Quantity_NOC_YELLOW);
71 Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup(thePresentation);
72 aGroup->SetPrimitivesAspect(aPtA);
73 Handle(Graphic3d_ArrayOfPoints) aPntArray = new Graphic3d_ArrayOfPoints(1);
74 aPntArray->AddVertex (aPoint->x(), aPoint->y(), aPoint->z());
75 aGroup->AddPrimitiveArray (aPntArray);
77 // Make a black mid ring
78 aPtA->SetType(Aspect_TOM_RING1);
80 aPtA->SetColor(Quantity_NOC_BLACK);
81 aGroup->SetPrimitivesAspect(aPtA);
82 aGroup->AddPrimitiveArray (aPntArray);
84 // Make an internal ring
85 aPtA->SetType(Aspect_TOM_POINT);
87 aGroup->SetPrimitivesAspect(aPtA);
88 aGroup->AddPrimitiveArray (aPntArray);
92 void SketcherPrs_Coincident::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
93 const Standard_Integer aMode)
95 // There is no selection of coincident - a point is selected instead of coincidence
98 void SketcherPrs_Coincident::SetColor(const Quantity_NameOfColor aCol)
100 SetColor(Quantity_Color(aCol));
103 void SketcherPrs_Coincident::SetColor(const Quantity_Color &aCol)
105 hasOwnColor=Standard_True;