X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSketcherPrs%2FSketcherPrs_SensitivePoint.cpp;h=753cff52ddb87012102ed44529acf4b593bfc0fe;hb=97c06c5cd9fc736f9b5a1dacde369a9d7b5be703;hp=ac89d78a6b0f842d32bc1955300da516b5443785;hpb=b05d0edf992d5f35dcbda636f6ca821a32792114;p=modules%2Fshaper.git diff --git a/src/SketcherPrs/SketcherPrs_SensitivePoint.cpp b/src/SketcherPrs/SketcherPrs_SensitivePoint.cpp index ac89d78a6..753cff52d 100644 --- a/src/SketcherPrs/SketcherPrs_SensitivePoint.cpp +++ b/src/SketcherPrs/SketcherPrs_SensitivePoint.cpp @@ -1,124 +1,104 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D - -// File: SketcherPrs_SensitivePoint.cpp -// Created: 24 March 2015 -// Author: Vitaly SMETANNIKOV - +// Copyright (C) 2014-2019 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// #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) +SketcherPrs_SensitivePoint::SketcherPrs_SensitivePoint( + const Handle(SelectBasics_EntityOwner)& anOwner, 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()) + if (!theMgr.Overlaps (aPnt, aDepth)) { + thePickResult = SelectBasics_PickResult (aDepth, aDistToCOG); return Standard_False; } - Standard_Real aDepth = ComputeDepth (thePickArgs.PickLine()); - if (thePickArgs.IsClipped (aDepth)) - { - 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"<