Salome HOME
Meet the coding style (line length <= 100)
[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 #define DEBUG_SENSITIVE_TO_BE_CORRECTED
14
15 IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_SensitivePoint, Select3D_SensitiveEntity);
16
17 SketcherPrs_SensitivePoint::SketcherPrs_SensitivePoint(
18   const Handle(SelectBasics_EntityOwner)& anOwner, int theId)
19 :Select3D_SensitiveEntity(anOwner), myId(theId)
20 {
21   SetSensitivityFactor(12);
22 }
23
24 Standard_Boolean SketcherPrs_SensitivePoint::Matches(SelectBasics_SelectingVolumeManager& theMgr,
25                                                    SelectBasics_PickResult& thePickResult)
26 {
27   Standard_Real aDepth      = RealLast();
28   Standard_Real aDistToCOG  = RealLast();
29   gp_Pnt aPnt = Point();
30   if (!theMgr.Overlaps (aPnt, aDepth))
31   {
32     thePickResult = SelectBasics_PickResult (aDepth, aDistToCOG);
33     return Standard_False;
34   }
35
36   aDistToCOG = aDepth;
37   thePickResult = SelectBasics_PickResult (aDepth, aDistToCOG);
38   return Standard_True;
39 }
40
41 gp_Pnt SketcherPrs_SensitivePoint::Point() const
42 {
43   const Handle(SelectMgr_EntityOwner)& anOwner =
44     Handle(SelectMgr_EntityOwner)::DownCast(OwnerId());
45   const Handle(SketcherPrs_SymbolPrs)& aSymbPrs =
46     Handle(SketcherPrs_SymbolPrs)::DownCast(anOwner->Selectable());
47   return aSymbPrs->pointsArray()->Vertice(myId);
48 }
49
50 Handle(Select3D_SensitiveEntity) SketcherPrs_SensitivePoint::GetConnected()
51 {
52   Handle(SketcherPrs_SensitivePoint) aNewEntity = new SketcherPrs_SensitivePoint (myOwnerId, myId);
53   return aNewEntity;
54 }
55
56 gp_Pnt SketcherPrs_SensitivePoint::CenterOfGeometry() const
57 {
58 #ifdef DEBUG_SENSITIVE_TO_BE_CORRECTED
59   const Handle(SelectMgr_EntityOwner)& anOwner =
60     Handle(SelectMgr_EntityOwner)::DownCast(OwnerId());
61   const Handle(SketcherPrs_SymbolPrs)& aSymbPrs =
62     Handle(SketcherPrs_SymbolPrs)::DownCast(anOwner->Selectable());
63   if (aSymbPrs->pointsArray()->VertexNumber() < myId)
64     return gp_Pnt();
65 #endif
66   return Point();
67 }
68
69 Select3D_BndBox3d SketcherPrs_SensitivePoint::BoundingBox()
70 {
71 #ifdef DEBUG_SENSITIVE_TO_BE_CORRECTED
72   const Handle(SelectMgr_EntityOwner)& anOwner =
73     Handle(SelectMgr_EntityOwner)::DownCast(OwnerId());
74   const Handle(SketcherPrs_SymbolPrs)& aSymbPrs =
75     Handle(SketcherPrs_SymbolPrs)::DownCast(anOwner->Selectable());
76   if (aSymbPrs->pointsArray()->VertexNumber() < myId)
77     return Select3D_BndBox3d();
78 #endif
79   gp_Pnt aPnt = Point();
80   return Select3D_BndBox3d (SelectMgr_Vec3 (aPnt.X(), aPnt.Y(), aPnt.Z()),
81                             SelectMgr_Vec3 (aPnt.X(), aPnt.Y(), aPnt.Z()));
82 }
83
84 Standard_Integer SketcherPrs_SensitivePoint::NbSubElements()
85 {
86   return 1;
87 }
88
89 void SketcherPrs_SensitivePoint::Clear()
90 {
91   return;
92 }