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