X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSketcherPrs%2FSketcherPrs_SensitivePoint.cpp;h=417a6a0c8b1ab21a68d2fda0b59b17695c5619c1;hb=551524964a46d4af95f0c27fb093545a3b1d4730;hp=ac89d78a6b0f842d32bc1955300da516b5443785;hpb=a24b7e6f4d112d5e7889fd76f030298fc428cd01;p=modules%2Fshaper.git diff --git a/src/SketcherPrs/SketcherPrs_SensitivePoint.cpp b/src/SketcherPrs/SketcherPrs_SensitivePoint.cpp index ac89d78a6..417a6a0c8 100644 --- a/src/SketcherPrs/SketcherPrs_SensitivePoint.cpp +++ b/src/SketcherPrs/SketcherPrs_SensitivePoint.cpp @@ -7,118 +7,87 @@ #include "SketcherPrs_SensitivePoint.h" -#include -#include -#include -#include -#include -#include +#include +#include "SketcherPrs_SymbolPrs.h" + +#define DEBUG_SENSITIVE_TO_BE_CORRECTED IMPLEMENT_STANDARD_HANDLE(SketcherPrs_SensitivePoint, Select3D_SensitiveEntity); IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_SensitivePoint, Select3D_SensitiveEntity); SketcherPrs_SensitivePoint::SketcherPrs_SensitivePoint(const Handle(SelectBasics_EntityOwner)& anOwner, - const Handle(Graphic3d_ArrayOfPoints)& thePntArray, - int theId) -:Select3D_SensitiveEntity(anOwner), myId(theId), myPntArray(thePntArray) + int theId) +:Select3D_SensitiveEntity(anOwner), myId(theId) { - SetSensitivityFactor(4.); + SetSensitivityFactor(12); } -void SketcherPrs_SensitivePoint::Project (const Handle(Select3D_Projector)& aProj) +Standard_Boolean SketcherPrs_SensitivePoint::Matches (SelectBasics_SelectingVolumeManager& theMgr, + SelectBasics_PickResult& thePickResult) { - gp_Pnt2d aPoint2d; + Standard_Real aDepth = RealLast(); + Standard_Real aDistToCOG = RealLast(); gp_Pnt aPnt = Point(); - if(!HasLocation()) - aProj->Project(aPnt, aPoint2d); - else - { - gp_Pnt aP(aPnt.X(), aPnt.Y(), aPnt.Z()); - aProj->Project(aP.Transformed(Location().Transformation()), aPoint2d); - } - myprojpt = aPoint2d; -} - -void SketcherPrs_SensitivePoint::Areas(SelectBasics_ListOfBox2d& boxes) -{ - Bnd_Box2d abox; - abox.Set(myprojpt); - boxes.Append(abox); -} - -Standard_Boolean SketcherPrs_SensitivePoint::Matches(const SelectBasics_PickArgs& thePickArgs, - Standard_Real& theMatchDMin, - Standard_Real& theMatchDepth) -{ - // check coordinate matching - Standard_Real aDist = gp_Pnt2d (thePickArgs.X(), thePickArgs.Y()).Distance (myprojpt); - if (aDist > thePickArgs.Tolerance() * SensitivityFactor()) - { - return Standard_False; - } - - Standard_Real aDepth = ComputeDepth (thePickArgs.PickLine()); - if (thePickArgs.IsClipped (aDepth)) + if (!theMgr.Overlaps (aPnt, aDepth)) { + thePickResult = SelectBasics_PickResult (aDepth, aDistToCOG); return Standard_False; } - theMatchDMin = aDist; - theMatchDepth = aDepth; + aDistToCOG = aDepth; + thePickResult = SelectBasics_PickResult (aDepth, aDistToCOG); return Standard_True; } -Standard_Boolean SketcherPrs_SensitivePoint::Matches(const Standard_Real XMin, - const Standard_Real YMin, - const Standard_Real XMax, - const Standard_Real YMax, - const Standard_Real aTol) +gp_Pnt SketcherPrs_SensitivePoint::Point() const { - Bnd_Box2d B; - B.Update(Min(XMin,XMax),Min(YMin,YMax),Max(XMin,XMax),Max(YMin,YMax)); - B.Enlarge(aTol); - return !B.IsOut(myprojpt); + const Handle(SelectMgr_EntityOwner)& anOwner = + Handle(SelectMgr_EntityOwner)::DownCast(OwnerId()); + const Handle(SketcherPrs_SymbolPrs)& aSymbPrs = + Handle(SketcherPrs_SymbolPrs)::DownCast(anOwner->Selectable()); + return aSymbPrs->pointsArray()->Vertice(myId); } -Standard_Boolean SketcherPrs_SensitivePoint::Matches(const TColgp_Array1OfPnt2d& aPoly, - const Bnd_Box2d& aBox, - const Standard_Real aTol) +Handle(Select3D_SensitiveEntity) SketcherPrs_SensitivePoint::GetConnected() { - Standard_Real Umin,Vmin,Umax,Vmax; - aBox.Get(Umin,Vmin,Umax,Vmax); - CSLib_Class2d aClassifier2d(aPoly,aTol,aTol,Umin,Vmin,Umax,Vmax); - - Standard_Integer RES = aClassifier2d.SiDans(myprojpt); - if(RES==1) return Standard_True; - - return Standard_False; + Handle(SketcherPrs_SensitivePoint) aNewEntity = new SketcherPrs_SensitivePoint (myOwnerId, myId); + return aNewEntity; } -gp_Pnt SketcherPrs_SensitivePoint::Point() const +gp_Pnt SketcherPrs_SensitivePoint::CenterOfGeometry() const { - return myPntArray->Vertice(myId); +#ifdef DEBUG_SENSITIVE_TO_BE_CORRECTED + const Handle(SelectMgr_EntityOwner)& anOwner = + Handle(SelectMgr_EntityOwner)::DownCast(OwnerId()); + const Handle(SketcherPrs_SymbolPrs)& aSymbPrs = + Handle(SketcherPrs_SymbolPrs)::DownCast(anOwner->Selectable()); + if (aSymbPrs->pointsArray()->VertexNumber() < myId) + return gp_Pnt(); +#endif + return Point(); } -Handle(Select3D_SensitiveEntity) SketcherPrs_SensitivePoint::GetConnected(const TopLoc_Location& aLoc) +Select3D_BndBox3d SketcherPrs_SensitivePoint::BoundingBox() { - Handle(SketcherPrs_SensitivePoint) NiouEnt = new SketcherPrs_SensitivePoint(myOwnerId,myPntArray,myId); - if(HasLocation()) NiouEnt->SetLocation(Location()); - NiouEnt->UpdateLocation(aLoc); - return NiouEnt; +#ifdef DEBUG_SENSITIVE_TO_BE_CORRECTED + const Handle(SelectMgr_EntityOwner)& anOwner = + Handle(SelectMgr_EntityOwner)::DownCast(OwnerId()); + const Handle(SketcherPrs_SymbolPrs)& aSymbPrs = + Handle(SketcherPrs_SymbolPrs)::DownCast(anOwner->Selectable()); + if (aSymbPrs->pointsArray()->VertexNumber() < myId) + return Select3D_BndBox3d(); +#endif + gp_Pnt aPnt = Point(); + return Select3D_BndBox3d (SelectMgr_Vec3 (aPnt.X(), aPnt.Y(), aPnt.Z()), + SelectMgr_Vec3 (aPnt.X(), aPnt.Y(), aPnt.Z())); } -void SketcherPrs_SensitivePoint::Dump(Standard_OStream& S,const Standard_Boolean /*FullDump*/) const +Standard_Integer SketcherPrs_SensitivePoint::NbSubElements() { - gp_Pnt aPnt = Point(); - S<<"\tSensitivePoint 3D :"; - if(HasLocation()) - S<<"\t\tExisting Location"<