From 8ee0062ee47663a84c56a706de068799a4d3fc1d Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Thu, 12 Mar 2015 15:48:14 +0000 Subject: [PATCH] =?UTF-8?q?EgtGraphics=201.6c1=20:=20-=20aggiunta=20possib?= =?UTF-8?q?ilit=C3=A0=20di=20filtro=20su=20tipo=20di=20entit=C3=A0=20per?= =?UTF-8?q?=20snap=20-=20in=20snap=20superfici=20trasparenti=20sempre=20co?= =?UTF-8?q?me=20in=20wireframe.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- EgtGraphics.rc | Bin 11580 -> 11580 bytes Scene.h | 2 ++ SceneBasic.cpp | 1 + SceneSnap.cpp | 61 ++++++++++++++++++++++++++++++++++--------------- 4 files changed, 46 insertions(+), 18 deletions(-) diff --git a/EgtGraphics.rc b/EgtGraphics.rc index e561f8782fdae20b88a345b8db872180832f1d16..1da4be1b1539a49fcb89902b7453608d1af073ee 100644 GIT binary patch delta 120 zcmdlJwI^!BH#Syd1|0^&&4qIO%*@FQhLa1qbT@BM^kCfF#BIV1m)y@Zxk@kxreN|1 Y$rGFJ32nk9zxjh?4GUZ^ioreH0F^N#jsO4v delta 120 zcmdlJwI^!BH#Sxy1|0^A&4qIO%*;s)7LyCPbT@BM^kCfF#BIV1m)y@Zxk@kxreN|1 Y$rGFJ32nk9zxjh?4GUZ^ioreH0H5t6z5oCK diff --git a/Scene.h b/Scene.h index 8b525ec..253df8f 100644 --- a/Scene.h +++ b/Scene.h @@ -147,6 +147,7 @@ class Scene : public IEGrScene virtual bool SetWinRect( const Point3d& ptWinRectP1, const Point3d& ptWinRectP2) ; virtual bool ResetWinRect( void) ; // Snap + virtual bool SetObjFilterForSnap( bool bZerodim, bool bCurve, bool bSurf, bool bVolume, bool bExtra) ; virtual bool GetGraphicSnapPoint( int nSnap, const Point3d& ptWin, int nW, int nH, Point3d& ptSel) ; virtual bool GetGridSnapPointZ( bool bSketch, const Point3d& ptWin, const Point3d& ptGrid, Point3d& ptSel) ; virtual int GetLastSnapId( void) @@ -252,6 +253,7 @@ class Scene : public IEGrScene static const int DIM_SEL_BUF = 32768 ; SelRec m_nSelBuff[DIM_SEL_BUF] ; // buffer per selezione con OpenGL // Snap + int m_nObjFilterForSnap ; // tipi di oggetti che possono essere sorgenti di snap point int m_nLastSnapId ; // Id dell'entità generatrice dell'ultimo punto snap Point3d m_ptLastSnapPnt ; // ultimo punto di snap bool m_bLastSnapDirOk ; // flag validità direzione associata a ultimo punto snap diff --git a/SceneBasic.cpp b/SceneBasic.cpp index 27b52ce..4ea4f9c 100644 --- a/SceneBasic.cpp +++ b/SceneBasic.cpp @@ -63,6 +63,7 @@ Scene::Scene( void) m_Unsel.reserve( 50) ; m_nSelCurr = - 1 ; // Snap Punti + m_nObjFilterForSnap = GEO_ZERODIM | GEO_CURVE | GEO_SURF | GEO_VOLUME | GEO_EXTRA ; m_nLastSnapId = GDB_ID_NULL ; m_bLastSnapDirOk = false ; // GeomData diff --git a/SceneSnap.cpp b/SceneSnap.cpp index c6bee61..a56a163 100644 --- a/SceneSnap.cpp +++ b/SceneSnap.cpp @@ -32,6 +32,24 @@ using namespace std ; +//---------------------------------------------------------------------------- +bool +Scene::SetObjFilterForSnap( bool bZerodim, bool bCurve, bool bSurf, bool bVolume, bool bExtra) +{ + m_nObjFilterForSnap = 0 ; + if ( bZerodim) + m_nObjFilterForSnap |= GEO_ZERODIM ; + if ( bCurve) + m_nObjFilterForSnap |= GEO_CURVE ; + if ( bSurf) + m_nObjFilterForSnap |= GEO_SURF ; + if ( bVolume) + m_nObjFilterForSnap |= GEO_VOLUME ; + if ( bExtra) + m_nObjFilterForSnap |= GEO_EXTRA ; + return true ; +} + //---------------------------------------------------------------------------- bool Scene::GetGraphicSnapPoint( int nSnap, const Point3d& ptWin, int nW, int nH, Point3d& ptSel) @@ -221,8 +239,8 @@ Scene::FindSelectedSnapPoint( int nSnap, const Point3d& ptWin, int nW, int nH) Frame3d frEnt ; if ( ! m_pGeomDB->GetGlobFrame( nId, frEnt)) continue ; - // se punto - if ( pGObj->GetType() == GEO_PNT3D) { + // se punto e abilitato + if ( pGObj->GetType() == GEO_PNT3D && ( m_nObjFilterForSnap & GEO_ZERODIM) != 0) { // recupero il geo-punto const IGeoPoint3d* pGP = GetGeoPoint3d( pGObj) ; // recupero il punto @@ -235,8 +253,8 @@ Scene::FindSelectedSnapPoint( int nSnap, const Point3d& ptWin, int nW, int nH) m_bLastSnapDirOk = false ; } } - // se vettore - else if ( pGObj->GetType() == GEO_VECT3D) { + // se vettore e abilitato + else if ( pGObj->GetType() == GEO_VECT3D && ( m_nObjFilterForSnap & GEO_ZERODIM) != 0) { // recupero il geo-vettore const IGeoVector3d* pGV = GetGeoVector3d( pGObj) ; // recupero il punto base @@ -251,8 +269,8 @@ Scene::FindSelectedSnapPoint( int nSnap, const Point3d& ptWin, int nW, int nH) m_vtLastSnapDir.ToGlob( frEnt) ; } } - // se frame - else if ( pGObj->GetType() == GEO_FRAME3D) { + // se frame e abilitato + else if ( pGObj->GetType() == GEO_FRAME3D && ( m_nObjFilterForSnap & GEO_ZERODIM) != 0) { // recupero il geo-frame const IGeoFrame3d* pGF = GetGeoFrame3d( pGObj) ; // recupero l'origine del riferimento @@ -265,32 +283,32 @@ Scene::FindSelectedSnapPoint( int nSnap, const Point3d& ptWin, int nW, int nH) m_bLastSnapDirOk = false ; } } - // se curva composita - else if ( pGObj->GetType() == CRV_COMPO) { + // se curva composita e abilitata + else if ( pGObj->GetType() == CRV_COMPO && ( m_nObjFilterForSnap & GEO_CURVE) != 0) { // recupero la curva composita const ICurveComposite* pCrvCompo = GetCurveComposite( pGObj) ; // verifico i punti notevoli della curva composita if ( FindCurveCompoSnapPoint( nSnap, ptWin, nId, frEnt, pCrvCompo, dMinSqDist)) bFound = true ; } - // se curva semplice - else if ( ( pGObj->GetType() & GEO_CURVE) != 0) { + // se curva semplice e abilitata + else if ( ( pGObj->GetType() & GEO_CURVE) != 0 && ( m_nObjFilterForSnap & GEO_CURVE) != 0) { // recupero la curva const ICurve* pCrv = GetCurve( pGObj) ; // verifico i punti notevoli della curva if ( FindCurveSnapPoint( nSnap, ptWin, nId, frEnt, pCrv, dMinSqDist)) bFound = true ; } - // se superficie trimesh - else if ( pGObj->GetType() == SRF_TRIMESH) { + // se superficie trimesh e abilitata + else if ( pGObj->GetType() == SRF_TRIMESH && ( m_nObjFilterForSnap & GEO_SURF) != 0) { // recupero la superficie const ISurfTriMesh* pStm = GetSurfTriMesh( pGObj) ; // verifico i punti notevoli della superficie if ( FindSurfTMSnapPoint( nSnap, ptWin, nId, frEnt, pStm, dMinSqDist)) bFound = true ; } - // se testo - else if ( pGObj->GetType() == EXT_TEXT) { + // se testo e abilitato + else if ( pGObj->GetType() == EXT_TEXT && ( m_nObjFilterForSnap & GEO_EXTRA) != 0) { // recupero il testo const IExtText* pTxt = GetExtText( pGObj) ; // verifico i punti notevoli del testo @@ -565,6 +583,10 @@ Scene::FindSurfTMSnapPoint( int nSnap, const Point3d& ptWin, int nId, const Fram Point3d ptMir = ptRef - vtDir * 2 * dBlRad ; double dLenMir = 4 * dBlRad ; + // determino se oggetto trasparente + Color cCol ; + bool bAlpha = ( m_pGeomDB->GetCalcMaterial( nId, cCol) && cCol.GetIntAlpha() <= ALPHA_LIM) ; + // se richiesto il centro di gravità (baricentro, centroide) if ( nSnap == SP_CENTROID) { Point3d ptP ; @@ -583,6 +605,9 @@ Scene::FindSurfTMSnapPoint( int nSnap, const Point3d& ptWin, int nId, const Fram m_bLastSnapDirOk = false ; } } + // se trovato e modalità shading o hiddenline, la favorisco perchè davanti alle possibili successive + if ( bFound && ! ( bAlpha || m_nShowMode == SM_WIREFRAME)) + dMinSqDist = 0 ; return bFound ; } @@ -597,7 +622,7 @@ Scene::FindSurfTMSnapPoint( int nSnap, const Point3d& ptWin, int nId, const Fram case SP_END : { // con wireframe devo provare tutti i triangoli intersecati, con shading e hiddenline solo il primo - int nTtot = (( m_nShowMode == SM_WIREFRAME) ? int( vInfo.size()) : 1) ; + int nTtot = (( bAlpha || m_nShowMode == SM_WIREFRAME) ? int( vInfo.size()) : 1) ; for ( int i = 0 ; i < nTtot ; ++ i) { // punto di intersezione Point3d ptInt = vInfo[i].ptI ; @@ -627,7 +652,7 @@ Scene::FindSurfTMSnapPoint( int nSnap, const Point3d& ptWin, int nId, const Fram case SP_MID : { // con wireframe devo provare tutti i triangoli intersecati, con shading e hiddenline solo il primo - int nTtot = (( m_nShowMode == SM_WIREFRAME) ? int( vInfo.size()) : 1) ; + int nTtot = (( bAlpha || m_nShowMode == SM_WIREFRAME) ? int( vInfo.size()) : 1) ; for ( int i = 0 ; i < nTtot ; ++ i) { // punto di intersezione Point3d ptInt = vInfo[i].ptI ; @@ -657,7 +682,7 @@ Scene::FindSurfTMSnapPoint( int nSnap, const Point3d& ptWin, int nId, const Fram case SP_CENTER : { // con wireframe devo provare tutti i triangoli intersecati, con shading e hiddenline solo il primo - int nTtot = (( m_nShowMode == SM_WIREFRAME) ? int( vInfo.size()) : 1) ; + int nTtot = (( bAlpha || m_nShowMode == SM_WIREFRAME) ? int( vInfo.size()) : 1) ; for ( int i = 0 ; i < nTtot ; ++ i) { // centro più vicino int nF = pStm->GetFacetFromTria( vInfo[i].nT) ; @@ -716,7 +741,7 @@ Scene::FindSurfTMSnapPoint( int nSnap, const Point3d& ptWin, int nId, const Fram } // se trovato e modalità shading o hiddenline, la favorisco perchè davanti alle possibili successive - if ( bFound && m_nShowMode != SM_WIREFRAME) + if ( bFound && ! ( bAlpha || m_nShowMode == SM_WIREFRAME)) dMinSqDist = 0 ; return bFound ;