From 43e1db36fa438e07466a72406da4dcddd07b28fe Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Thu, 2 Jan 2020 08:26:55 +0000 Subject: [PATCH] EgtGraphics : - gestione punti notevoli delle quotature. --- Scene.h | 7 +++- SceneSelect.cpp | 44 ++++++++++++++++++++ SceneSnap.cpp | 105 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 154 insertions(+), 2 deletions(-) diff --git a/Scene.h b/Scene.h index 45a5758..4d51b20 100644 --- a/Scene.h +++ b/Scene.h @@ -1,7 +1,7 @@ //---------------------------------------------------------------------------- -// EgalTech 2013-2014 +// EgalTech 2014-2020 //---------------------------------------------------------------------------- -// File : Scene.h Data : 03.02.14 Versione : 1.5b1 +// File : Scene.h Data : 02.01.20 Versione : 2.2a1 // Contenuto : Dichiarazione della classe gestione scena. // // @@ -26,6 +26,7 @@ class ISurfTriMesh ; class ISurfFlatRegion ; class IVolZmap ; class IExtText ; +class IExtDimension ; class ObjEGrGraphics ; //---------------------------------------------------------------------------- @@ -269,6 +270,8 @@ class Scene : public IEGrScene const IVolZmap* pVzm, double& dMinSqDist) ; bool FindTextSnapPoint( int nSnap, const Point3d& ptWin, int nId, const Frame3d& frEnt, const IExtText* pTxt, double& dMinSqDist) ; + bool FindDimensionSnapPoint( int nSnap, const Point3d& ptWin, int nId, const Frame3d& frEnt, + const IExtDimension* pDim, double& dMinSqDist) ; private : // Basic diff --git a/SceneSelect.cpp b/SceneSelect.cpp index d476d85..5f3837c 100644 --- a/SceneSelect.cpp +++ b/SceneSelect.cpp @@ -25,6 +25,7 @@ #include "/EgtDev/Include/EGkSurfTriMesh.h" #include "/EgtDev/Include/EGkSurfFlatRegion.h" #include "/EgtDev/Include/EGkExtText.h" +#include "/EgtDev/Include/EGkExtDimension.h" #include "/EgtDev/Include/EGkIntersLinePlane.h" #include "/EgtDev/Include/EGkIntersLineSurfTm.h" #include "/EgtDev/Include/EGkGdbConst.h" @@ -458,5 +459,48 @@ Scene::GetPointFromSelect( int nSelId, const Point3d& ptView, Point3d& ptSel, in ptSel = ptP ; } } + // se quotatura + else if ( pGObj->GetType() == EXT_DIMENSION) { + // recupero la quotatura + const IExtDimension* pDim = GetExtDimension( pGObj) ; + // verifico sia valida + if ( pDim->IsValid()) { + // cerco il punto + double dMinSqDist = INFINITO * INFINITO ; + Point3d ptP ; + // punto iniziale + ptP = pDim->GetStart() ; + ptP.ToGlob( frEnt) ; + if ( VerifySnapPoint( ptP, ptView, dMinSqDist)) + ptSel = ptP ; + // punto sopra iniziale + ptP = pDim->GetOverStart() ; + ptP.ToGlob( frEnt) ; + if ( VerifySnapPoint( ptP, ptView, dMinSqDist)) + ptSel = ptP ; + // punto finale + ptP = pDim->GetEnd() ; + ptP.ToGlob( frEnt) ; + if ( VerifySnapPoint( ptP, ptView, dMinSqDist)) + ptSel = ptP ; + // punto sopra finale + ptP = pDim->GetOverEnd() ; + ptP.ToGlob( frEnt) ; + if ( VerifySnapPoint( ptP, ptView, dMinSqDist)) + ptSel = ptP ; + // punto medio + if ( pDim->GetMidPoint( ptP)) { + ptP.ToGlob( frEnt) ; + if ( VerifySnapPoint( ptP, ptView, dMinSqDist)) + ptSel = ptP ; + } + // centro + if ( pDim->GetCenterPoint( ptP)) { + ptP.ToGlob( frEnt) ; + if ( VerifySnapPoint( ptP, ptView, dMinSqDist)) + ptSel = ptP ; + } + } + } return true ; } diff --git a/SceneSnap.cpp b/SceneSnap.cpp index 8fc29c9..4c32d84 100644 --- a/SceneSnap.cpp +++ b/SceneSnap.cpp @@ -27,6 +27,7 @@ #include "/EgtDev/Include/EGkSurfFlatRegion.h" #include "/EgtDev/Include/EGkVolZmap.h" #include "/EgtDev/Include/EGkExtText.h" +#include "/EgtDev/Include/EGkExtDimension.h" #include "/EgtDev/Include/EgkIntersCurves.h" #include "/EgtDev/Include/EGkIntersLinePlane.h" #include "/EgtDev/Include/EGkIntersLineSurfTm.h" @@ -358,6 +359,14 @@ Scene::FindSelectedSnapPoint( int nSnap, const Point3d& ptWin, int nW, int nH) if ( FindTextSnapPoint( nSnap, ptWin, nId, frEnt, pTxt, dMinSqDist)) bFound = true ; } + // se quotatura + else if ( pGObj->GetType() == EXT_DIMENSION) { + // recupero la quotatura + const IExtDimension* pDim = GetExtDimension( pGObj) ; + // verifico i punti notevoli della quotatura + if ( FindDimensionSnapPoint( nSnap, ptWin, nId, frEnt, pDim, dMinSqDist)) + bFound = true ; + } } return bFound ; } @@ -1191,6 +1200,102 @@ Scene::FindTextSnapPoint( int nSnap, const Point3d& ptWin, int nId, const Frame3 return bFound ; } +//---------------------------------------------------------------------------- +bool +Scene::FindDimensionSnapPoint( int nSnap, const Point3d& ptWin, int nId, const Frame3d& frEnt, + const IExtDimension* pDim, double& dMinSqDist) +{ + // cerco il punto + bool bFound = false ; + Point3d ptP ; + switch ( nSnap) { + case SP_END : + // punto iniziale + if ( pDim->IsValid()) { + ptP = pDim->GetStart() ; + ptP.ToGlob( frEnt) ; + if ( VerifySnapPoint( ptP, ptWin, dMinSqDist)) { + bFound = true ; + m_nLastSnapId = nId ; + m_ptLastSnapPnt = ptP ; + m_bLastSnapDirOk = true ; + m_vtLastSnapDir = pDim->GetNormVersor() ; + m_vtLastSnapDir.ToGlob( frEnt) ; + } + } + // punto sopra iniziale + if ( pDim->IsValid()) { + ptP = pDim->GetOverStart() ; + ptP.ToGlob( frEnt) ; + if ( VerifySnapPoint( ptP, ptWin, dMinSqDist)) { + bFound = true ; + m_nLastSnapId = nId ; + m_ptLastSnapPnt = ptP ; + m_bLastSnapDirOk = true ; + m_vtLastSnapDir = pDim->GetNormVersor() ; + m_vtLastSnapDir.ToGlob( frEnt) ; + } + } + // punto finale + if ( pDim->IsValid()) { + ptP = pDim->GetEnd() ; + ptP.ToGlob( frEnt) ; + if ( VerifySnapPoint( ptP, ptWin, dMinSqDist)) { + bFound = true ; + m_nLastSnapId = nId ; + m_ptLastSnapPnt = ptP ; + m_bLastSnapDirOk = true ; + m_vtLastSnapDir = pDim->GetNormVersor() ; + m_vtLastSnapDir.ToGlob( frEnt) ; + } + } + // punto sopra finale + if ( pDim->IsValid()) { + ptP = pDim->GetOverEnd() ; + ptP.ToGlob( frEnt) ; + if ( VerifySnapPoint( ptP, ptWin, dMinSqDist)) { + bFound = true ; + m_nLastSnapId = nId ; + m_ptLastSnapPnt = ptP ; + m_bLastSnapDirOk = true ; + m_vtLastSnapDir = pDim->GetNormVersor() ; + m_vtLastSnapDir.ToGlob( frEnt) ; + } + } + break ; + case SP_MID : + // punto medio + if ( pDim->GetMidPoint( ptP)) { + ptP.ToGlob( frEnt) ; + if ( VerifySnapPoint( ptP, ptWin, dMinSqDist)) { + bFound = true ; + m_nLastSnapId = nId ; + m_ptLastSnapPnt = ptP ; + m_bLastSnapDirOk = true ; + m_vtLastSnapDir = pDim->GetNormVersor() ; + m_vtLastSnapDir.ToGlob( frEnt) ; + } + } + break ; + case SP_CENTER : + case SP_CENTROID : + // centro + if ( pDim->GetCenterPoint( ptP)) { + ptP.ToGlob( frEnt) ; + if ( VerifySnapPoint( ptP, ptWin, dMinSqDist)) { + bFound = true ; + m_nLastSnapId = nId ; + m_ptLastSnapPnt = ptP ; + m_bLastSnapDirOk = true ; + m_vtLastSnapDir = pDim->GetNormVersor() ; + m_vtLastSnapDir.ToGlob( frEnt) ; + } + } + break ; + } + return bFound ; +} + //---------------------------------------------------------------------------- bool Scene::GetPlaneSnapPoint( const Point3d& ptWin, const Plane3d& plPlane, Point3d& ptSel) const