Salome HOME
26e5d6b5169265cde144a5c87caf8733e34728b3
[modules/shaper.git] / src / SketcherPrs / SketcherPrs_SensitivePoint.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        SketcherPrs_SensitivePoint.cpp
4 // Created:     24 March 2015
5 // Author:      Vitaly SMETANNIKOV
6
7
8 #include "SketcherPrs_SensitivePoint.h"
9
10 #include <Graphic3d_ArrayOfPoints.hxx>
11 #include "SketcherPrs_SymbolPrs.h"
12
13 IMPLEMENT_STANDARD_HANDLE(SketcherPrs_SensitivePoint, Select3D_SensitiveEntity);
14 IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_SensitivePoint, Select3D_SensitiveEntity);
15
16 SketcherPrs_SensitivePoint::SketcherPrs_SensitivePoint(const Handle(SelectBasics_EntityOwner)& anOwner,
17                                                        int theId)
18 :Select3D_SensitiveEntity(anOwner), myId(theId)
19 {
20   SetSensitivityFactor(12.);
21 }
22
23 Standard_Boolean SketcherPrs_SensitivePoint::Matches (SelectBasics_SelectingVolumeManager& theMgr,
24                                                    SelectBasics_PickResult& thePickResult)
25 {
26   Standard_Real aDepth      = RealLast();
27   Standard_Real aDistToCOG  = RealLast();
28   gp_Pnt aPnt = Point();
29   if (!theMgr.Overlaps (aPnt, aDepth))
30   {
31     thePickResult = SelectBasics_PickResult (aDepth, aDistToCOG);
32     return Standard_False;
33   }
34
35   aDistToCOG = aDepth;
36   thePickResult = SelectBasics_PickResult (aDepth, aDistToCOG);
37   return Standard_True;
38 }
39
40 gp_Pnt SketcherPrs_SensitivePoint::Point() const
41 {
42   gp_Pnt aPoint(0, 0, 0);
43   const Handle(SelectMgr_EntityOwner)& anOwner =
44     Handle(SelectMgr_EntityOwner)::DownCast(OwnerId());
45   if (!anOwner.IsNull()) {
46     const Handle(SketcherPrs_SymbolPrs)& aSymbPrs =
47       Handle(SketcherPrs_SymbolPrs)::DownCast(anOwner->Selectable());
48     aPoint = aSymbPrs->pointsArray()->Vertice(myId);
49   }
50   return aPoint;
51 }
52
53 Handle(Select3D_SensitiveEntity) SketcherPrs_SensitivePoint::GetConnected()
54 {
55   Handle(SketcherPrs_SensitivePoint) aNewEntity = new SketcherPrs_SensitivePoint (myOwnerId, myId);
56   return aNewEntity;
57 }
58
59 gp_Pnt SketcherPrs_SensitivePoint::CenterOfGeometry() const
60 {
61   return Point();
62 }
63
64 Select3D_BndBox3d SketcherPrs_SensitivePoint::BoundingBox()
65 {
66   gp_Pnt aPnt = Point();
67   return Select3D_BndBox3d (SelectMgr_Vec3 (aPnt.X(), aPnt.Y(), aPnt.Z()),
68                             SelectMgr_Vec3 (aPnt.X(), aPnt.Y(), aPnt.Z()));
69 }
70
71 Standard_Integer SketcherPrs_SensitivePoint::NbSubElements()
72 {
73   return 1;
74 }