EgtGraphics 1.6c1 :

- aggiunta possibilità di filtro su tipo di entità per snap
- in snap superfici trasparenti sempre come in wireframe.
This commit is contained in:
Dario Sassi
2015-03-12 15:48:14 +00:00
parent 9c22e23f8f
commit 8ee0062ee4
4 changed files with 46 additions and 18 deletions
+43 -18
View File
@@ -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 ;