From a357df9cd0ab890d948d1d64b02d71dfaf59b8f9 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Sat, 4 Jan 2025 13:02:31 +0100 Subject: [PATCH] =?UTF-8?q?EgtGraphics=20:=20-=20piccola=20modifica=20in?= =?UTF-8?q?=20Snap=20Punto=20Intersezione=20(si=20preferisce=20il=20punto?= =?UTF-8?q?=20sull'eventuale=20entit=C3=A0=20selezionata).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SceneSnap.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/SceneSnap.cpp b/SceneSnap.cpp index 37cfbcb..aa0ce97 100644 --- a/SceneSnap.cpp +++ b/SceneSnap.cpp @@ -150,6 +150,8 @@ bool Scene::FindSelectedIntersectionPoint( const Point3d& ptWin, int nW, int nH) { // --- l'intersezione viene calcolata nel piano della griglia --- + // salvo eventuale ultima entità precedentemente selezionata + int nPrevSel = GetFirstSelectedObj() ; // verifico siano state selezionate delle entità int nSel ; Select( ptWin, nW, nH, nSel) ; @@ -158,17 +160,19 @@ Scene::FindSelectedIntersectionPoint( const Point3d& ptWin, int nW, int nH) // cerco le prime due curve inquadrate con i loro riferimenti const ICurve* pCrv[2] ; Frame3d frEnt[2] ; + int nIds[2] ; double dWinZ = 0 ; int nCrvNum = 0 ; - for ( int i = GetFirstSelectedObj() ; i != GDB_ID_NULL && nCrvNum < 2 ; i = GetNextSelectedObj()) { + for ( int nObjId = GetFirstSelectedObj() ; nObjId != GDB_ID_NULL && nCrvNum < 2 ; nObjId = GetNextSelectedObj()) { // se non è entità geometrica const IGeoObj* pGObj ; - if ( ( pGObj = m_pGeomDB->GetGeoObj( i)) == nullptr) + if ( ( pGObj = m_pGeomDB->GetGeoObj( nObjId)) == nullptr) continue ; if ( ( pGObj->GetType() & GEO_CURVE) != 0) { pCrv[nCrvNum] = GetCurve( pGObj) ; - if ( ! m_pGeomDB->GetGlobFrame( i, frEnt[nCrvNum])) + if ( ! m_pGeomDB->GetGlobFrame( nObjId, frEnt[nCrvNum])) return false ; + nIds[nCrvNum] = nObjId ; dWinZ += 0.5 * GetSelectedObjWinZ() ; ++ nCrvNum ; } @@ -199,7 +203,9 @@ Scene::FindSelectedIntersectionPoint( const Point3d& ptWin, int nW, int nH) SelfIntersCurve sintC( *pCrv[0]) ; if ( ! sintC.GetIntersPointNearTo( ptNear, m_ptLastSnapPnt)) return false ; + m_nLastSnapId = nIds[0] ; m_ptLastSnapPnt.ToGlob( frGrid) ; + m_bLastSnapDirOk = false ; return true ; } // altrimenti due curve, procedo normalmente @@ -231,9 +237,11 @@ Scene::FindSelectedIntersectionPoint( const Point3d& ptWin, int nW, int nH) ptNear.ToLoc( frGrid) ; // calcolo il punto di intersezione sulla prima curva più vicino al punto di riferimento IntersCurveCurve intCC( *pCrv[0], *pCrv[1], true) ; - if ( ! intCC.GetIntersPointNearTo( 0, ptNear, m_ptLastSnapPnt)) + if ( ! intCC.GetIntersPointNearTo( ( nPrevSel == nIds[1] ? 1 : 0), ptNear, m_ptLastSnapPnt)) return false ; + m_nLastSnapId = nIds[0] ; m_ptLastSnapPnt.ToGlob( frGrid) ; + m_bLastSnapDirOk = false ; return true ; }