0024623: Visualization - improve selection mechanism
[occt.git] / src / Select3D / Select3D_SensitivePoint.cxx
CommitLineData
b311480e 1// Created on: 1995-03-10
2// Created by: Mister rmi
3// Copyright (c) 1995-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 8// This library is free software; you can redistribute it and/or modify it under
9// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 10// by the Free Software Foundation, with special exception defined in the file
11// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12// distribution for complete text of the license and disclaimer of any warranty.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
7fd59977 16
f751596e 17#include <Select3D_SensitivePoint.hxx>
7fd59977 18
f751596e 19#include <TopLoc_Location.hxx>
7fd59977 20
f751596e 21IMPLEMENT_STANDARD_HANDLE (Select3D_SensitivePoint, Select3D_SensitiveEntity)
22IMPLEMENT_STANDARD_RTTIEXT(Select3D_SensitivePoint, Select3D_SensitiveEntity)
7fd59977 23
24//==================================================
f751596e 25// Function: Creation
7fd59977 26// Purpose :
27//==================================================
f751596e 28Select3D_SensitivePoint::Select3D_SensitivePoint (const Handle(SelectBasics_EntityOwner)& theOwner,
29 const gp_Pnt& thePoint)
30: Select3D_SensitiveEntity (theOwner)
7fd59977 31{
f751596e 32 SetSensitivityFactor (12.0);
33 myPoint = thePoint;
7fd59977 34}
35
7fd59977 36//==================================================
ac04d101 37// Function: Matches
7fd59977 38// Purpose :
39//==================================================
f751596e 40Standard_Boolean Select3D_SensitivePoint::Matches (SelectBasics_SelectingVolumeManager& theMgr,
41 SelectBasics_PickResult& thePickResult)
7fd59977 42{
f751596e 43 Standard_Real aDepth = RealLast();
44 Standard_Real aDistToCOG = RealLast();
45 Standard_Boolean isMatched = theMgr.Overlaps (myPoint, aDepth);
46 if (isMatched)
47 aDistToCOG = aDepth;
4269bd1b 48
f751596e 49 thePickResult = SelectBasics_PickResult (aDepth, aDistToCOG);
ac04d101 50
f751596e 51 return isMatched;
7fd59977 52}
53
7fd59977 54//=======================================================================
f751596e 55//function : Point
aec37c15 56//purpose :
7fd59977 57//=======================================================================
f751596e 58gp_Pnt Select3D_SensitivePoint::Point() const
aec37c15 59{
f751596e 60 return myPoint;
7fd59977 61}
62
7fd59977 63//=======================================================================
f751596e 64//function : GetConnected
aec37c15 65//purpose :
7fd59977 66//=======================================================================
f751596e 67Handle(Select3D_SensitiveEntity) Select3D_SensitivePoint::GetConnected()
68{
69 Handle(Select3D_SensitivePoint) aNewEntity = new Select3D_SensitivePoint (myOwnerId, myPoint);
70 return aNewEntity;
71}
7fd59977 72
73//=======================================================================
f751596e 74// function : CenterOfGeometry
75// purpose : Returns center of point. If location transformation
76// is set, it will be applied
7fd59977 77//=======================================================================
f751596e 78gp_Pnt Select3D_SensitivePoint::CenterOfGeometry() const
7fd59977 79{
f751596e 80 return myPoint;
7fd59977 81}
82
7fd59977 83//=======================================================================
f751596e 84// function : BoundingBox
85// purpose : Returns bounding box of the point. If location
86// transformation is set, it will be applied
7fd59977 87//=======================================================================
f751596e 88Select3D_BndBox3d Select3D_SensitivePoint::BoundingBox()
7fd59977 89{
f751596e 90 return Select3D_BndBox3d (SelectMgr_Vec3 (myPoint.X(), myPoint.Y(), myPoint.Z()),
91 SelectMgr_Vec3 (myPoint.X(), myPoint.Y(), myPoint.Z()));
7fd59977 92}
93
94//=======================================================================
f751596e 95// function : NbSubElements
96// purpose : Returns the amount of sub-entities in sensitive
7fd59977 97//=======================================================================
f751596e 98Standard_Integer Select3D_SensitivePoint::NbSubElements()
7fd59977 99{
f751596e 100 return 1;
7fd59977 101}