EgtGraphics 1.5l1 :
- aggiornamento a VS2013 - curve marcate ora hanno spessore 2 e evidenziate 4. - gestione riferimento griglia (CPlane) spostata in EgtGeomKernel - aggiunta possibilità di visualizzare piccolo riferimento globale in basso a sinistra. - migliorato snap a intersezione di curve.
This commit is contained in:
+50
-33
@@ -35,6 +35,9 @@ Scene::GetGraphicSnapPoint( int nSnap, const Point3d& ptWin, int nW, int nH, Poi
|
||||
// reset dati associati a ultimo punto snap
|
||||
m_nLastSnapId = GDB_ID_NULL ;
|
||||
m_bLastSnapDirOk = false ;
|
||||
// verifico validità GDB
|
||||
if ( m_pGeomDB == nullptr)
|
||||
return false ;
|
||||
// se Snap Sketch o Grid, devo trovare il punto sulla griglia
|
||||
if ( nSnap == SP_SKETCH || nSnap == SP_GRID)
|
||||
return GetGridSnapPoint( ( nSnap == SP_SKETCH), ptWin, ptSel) ;
|
||||
@@ -50,6 +53,9 @@ Scene::GetGraphicSnapPoint( int nSnap, const Point3d& ptWin, int nW, int nH, Poi
|
||||
bool
|
||||
Scene::GetGridSnapPoint( bool bSketch, const Point3d& ptWin, Point3d& ptSel)
|
||||
{
|
||||
// recupero il riferimento di griglia
|
||||
Frame3d frGrid = GetGridFrame() ;
|
||||
|
||||
// calcolo un punto e la direzione della linea di mira
|
||||
Point3d ptLine ;
|
||||
if ( ! UnProject( ptWin, ptLine))
|
||||
@@ -57,14 +63,14 @@ Scene::GetGridSnapPoint( bool bSketch, const Point3d& ptWin, Point3d& ptSel)
|
||||
Vector3d vtLine = - m_vtDirCamera ;
|
||||
|
||||
// determino l'intersezione di questa linea con il piano della griglia
|
||||
double dDenom = vtLine * m_frGrid.VersZ() ;
|
||||
double dDenom = vtLine * frGrid.VersZ() ;
|
||||
if ( fabs( dDenom) < COS_ORTO_ANG_SMALL)
|
||||
return false ;
|
||||
double dU = ( ( m_frGrid.Orig() - ptLine) * m_frGrid.VersZ()) / dDenom ;
|
||||
double dU = ( ( frGrid.Orig() - ptLine) * frGrid.VersZ()) / dDenom ;
|
||||
ptSel = ptLine + dU * vtLine ;
|
||||
|
||||
// porto il punto sul piano di griglia
|
||||
ptSel.ToLoc( m_frGrid) ;
|
||||
ptSel.ToLoc( frGrid) ;
|
||||
// se punto grid, devo arrotondare al nodo di griglia più vicino
|
||||
if ( ! bSketch) {
|
||||
ptSel.x = floor( ptSel.x / m_dSnapStep + 0.5) * m_dSnapStep ;
|
||||
@@ -73,7 +79,7 @@ Scene::GetGridSnapPoint( bool bSketch, const Point3d& ptWin, Point3d& ptSel)
|
||||
// il punto deve stare sulla griglia
|
||||
ptSel.z = 0 ;
|
||||
// lo riporto in globale
|
||||
ptSel.ToGlob( m_frGrid) ;
|
||||
ptSel.ToGlob( frGrid) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
@@ -81,6 +87,9 @@ Scene::GetGridSnapPoint( bool bSketch, const Point3d& ptWin, Point3d& ptSel)
|
||||
bool
|
||||
Scene::GetGridSnapPointZ( bool bSketch, const Point3d& ptWin, const Point3d& ptGrid, Point3d& ptSel)
|
||||
{
|
||||
// recupero il riferimento di griglia
|
||||
Frame3d frGrid = GetGridFrame() ;
|
||||
|
||||
// calcolo un punto e la direzione della linea di mira
|
||||
Point3d ptLine ;
|
||||
if ( ! UnProject( ptWin, ptLine))
|
||||
@@ -89,7 +98,7 @@ Scene::GetGridSnapPointZ( bool bSketch, const Point3d& ptWin, const Point3d& ptG
|
||||
|
||||
// piano di elevazione :
|
||||
// per il punto di griglia, contenente la perp. alla griglia e più perp. possibile alla direzione di mira
|
||||
Vector3d vtNorm = vtLine - ( vtLine * m_frGrid.VersZ()) * m_frGrid.VersZ() ;
|
||||
Vector3d vtNorm = vtLine - ( vtLine * frGrid.VersZ()) * frGrid.VersZ() ;
|
||||
if ( ! vtNorm.Normalize())
|
||||
return false ;
|
||||
|
||||
@@ -101,10 +110,10 @@ Scene::GetGridSnapPointZ( bool bSketch, const Point3d& ptWin, const Point3d& ptG
|
||||
Point3d ptNear = ptLine + dU * vtLine ;
|
||||
|
||||
// proietto il punto sulla linea di elevazione
|
||||
double dDeltaZ = ( ptNear - ptGrid) * m_frGrid.VersZ() ;
|
||||
double dDeltaZ = ( ptNear - ptGrid) * frGrid.VersZ() ;
|
||||
if ( ! bSketch)
|
||||
dDeltaZ = floor( dDeltaZ / m_dSnapStep + 0.5) * m_dSnapStep ;
|
||||
ptSel = ptGrid + dDeltaZ * m_frGrid.VersZ() ;
|
||||
ptSel = ptGrid + dDeltaZ * frGrid.VersZ() ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
@@ -180,13 +189,25 @@ Scene::GetSelectedSnapPoint( int nSnap, const Point3d& ptWin, int nW, int nH, Po
|
||||
const ICurveComposite* pCrvCompo = GetCurveComposite( pGObj) ;
|
||||
// il punto di riferimento deriva da XY su viewport e Z da selezione
|
||||
Point3d ptWinZ( ptWin.x, ptWin.y, GetSelectedObjWinZ()) ;
|
||||
// determino la curva elementare più vicina al punto di riferimento
|
||||
int nCrv = - 1 ;
|
||||
Point3d ptRef ;
|
||||
if ( UnProject( ptWinZ, ptRef)) {
|
||||
double dPar ;
|
||||
int nFlag ;
|
||||
if ( DistPointCurve( ptRef, *pCrvCompo).GetParamAtMinDistPoint( 0, dPar, nFlag))
|
||||
nCrv = static_cast<int>( dPar) ;
|
||||
}
|
||||
// ciclo sulle curve elementari
|
||||
int nCont = 0 ;
|
||||
const ICurve* pCrv = pCrvCompo->GetFirstCurve() ;
|
||||
while ( pCrv != nullptr) {
|
||||
// verifico i punti notevoli della curva
|
||||
if ( TestCurveSnapPoints( nSnap, ptWinZ, nId, frEnt, pCrv, dMinSqDist, ptSel))
|
||||
if ( nCont == nCrv &&
|
||||
TestCurveSnapPoints( nSnap, ptWinZ, nId, frEnt, pCrv, dMinSqDist, ptSel))
|
||||
bFound = true ;
|
||||
// passo alla successiva
|
||||
++ nCont ;
|
||||
pCrv = pCrvCompo->GetNextCurve() ;
|
||||
}
|
||||
}
|
||||
@@ -480,66 +501,62 @@ Scene::VerifySnapPoint( const Point3d& ptP, const Point3d& ptWin, double& dMinSq
|
||||
bool
|
||||
Scene::GetSelectedIntersectionPoint( const Point3d& ptWin, int nW, int nH, Point3d& ptSel)
|
||||
{
|
||||
// l'intersezione viene calcolata nel piano della griglia
|
||||
// --- l'intersezione viene calcolata nel piano della griglia ---
|
||||
// verifico siano state selezionate delle entità
|
||||
int nSel ;
|
||||
Select( ptWin, nW, nH, nSel) ;
|
||||
if ( nSel <= 0)
|
||||
return false ;
|
||||
// recupero le entità selezionate
|
||||
INTVECTOR nIds ;
|
||||
GetSelectedObjs( nIds) ;
|
||||
// cerco le prime due curve inquadrate
|
||||
// cerco le prime due curve inquadrate con i loro riferimenti
|
||||
const ICurve* pCrv[2] ;
|
||||
Frame3d frEnt[2] ;
|
||||
double dWinZ = 0 ;
|
||||
int nCrvNum = 0 ;
|
||||
int nId[2] = { GDB_ID_NULL, GDB_ID_NULL} ;
|
||||
const ICurve* pCrv[2] = { nullptr, nullptr} ;
|
||||
for ( size_t i = 0 ; i < nIds.size() && nCrvNum < 2 ; ++ i) {
|
||||
for ( int i = GetFirstSelectedObj() ; i != GDB_ID_NULL && nCrvNum < 2 ; i = GetNextSelectedObj()) {
|
||||
// se non è entità geometrica
|
||||
const IGeoObj* pGObj ;
|
||||
if ( ( pGObj = m_pGeomDB->GetGeoObj( nIds[i])) == nullptr)
|
||||
if ( ( pGObj = m_pGeomDB->GetGeoObj( i)) == nullptr)
|
||||
continue ;
|
||||
if ( ( pGObj->GetType() & GEO_CURVE) != 0) {
|
||||
nId[nCrvNum] = nIds[i] ;
|
||||
pCrv[nCrvNum] = GetCurve( pGObj) ;
|
||||
if ( ! m_pGeomDB->GetGlobFrame( i, frEnt[nCrvNum]))
|
||||
return false ;
|
||||
dWinZ += 0.5 * GetSelectedObjWinZ() ;
|
||||
++ nCrvNum ;
|
||||
}
|
||||
}
|
||||
if ( nCrvNum < 2)
|
||||
return false ;
|
||||
// recupero i riferimenti in cui sono immerse
|
||||
Frame3d frEnt[2] ;
|
||||
if ( ! m_pGeomDB->GetGlobFrame( nId[0], frEnt[0]))
|
||||
return false ;
|
||||
if ( ! m_pGeomDB->GetGlobFrame( nId[1], frEnt[1]))
|
||||
if ( nCrvNum != 2)
|
||||
return false ;
|
||||
// recupero il riferimento di griglia
|
||||
Frame3d frGrid = GetGridFrame() ;
|
||||
// se il riferimento della seconda curva è diverso da quello della griglia, devo trasformarla
|
||||
PtrOwner<ICurve> crvTrans0( nullptr) ;
|
||||
if ( ! AreSameFrame( frEnt[0], m_frGrid)) {
|
||||
if ( ! AreSameFrame( frEnt[0], frGrid)) {
|
||||
crvTrans0.Set( pCrv[0]->Clone()) ;
|
||||
if ( IsNull( crvTrans0))
|
||||
return false ;
|
||||
crvTrans0->LocToLoc( frEnt[0],m_frGrid) ;
|
||||
crvTrans0->LocToLoc( frEnt[0], frGrid) ;
|
||||
pCrv[0] = ::Get( crvTrans0) ;
|
||||
}
|
||||
// se il riferimento della seconda curva è diverso da quello della griglia, devo trasformarla
|
||||
PtrOwner<ICurve> crvTrans1( nullptr) ;
|
||||
if ( ! AreSameFrame( frEnt[1], m_frGrid)) {
|
||||
if ( ! AreSameFrame( frEnt[1], frGrid)) {
|
||||
crvTrans1.Set( pCrv[1]->Clone()) ;
|
||||
if ( IsNull( crvTrans1))
|
||||
return false ;
|
||||
crvTrans1->LocToLoc( frEnt[1], m_frGrid) ;
|
||||
crvTrans1->LocToLoc( frEnt[1], frGrid) ;
|
||||
pCrv[1] = ::Get( crvTrans1) ;
|
||||
}
|
||||
// uso il punto sketch come punto vicino e lo porto nel riferimento della griglia
|
||||
Point3d ptWinZ( ptWin.x, ptWin.y, dWinZ) ;
|
||||
Point3d ptNear ;
|
||||
if ( ! GetGridSnapPoint( true, ptWin, ptNear) ||
|
||||
! UnProject( ptWin, ptNear))
|
||||
if ( ! UnProject( ptWinZ, ptNear))
|
||||
ptNear = ORIG ;
|
||||
ptNear.ToLoc( m_frGrid) ;
|
||||
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, ptSel))
|
||||
return false ;
|
||||
ptSel.ToGlob( m_frGrid) ;
|
||||
ptSel.ToGlob( frGrid) ;
|
||||
return true ;
|
||||
}
|
||||
Reference in New Issue
Block a user