EgtGraphics 1.5j7 :
- aggiunta Scene::GetGridSnapPointZ.
This commit is contained in:
Binary file not shown.
@@ -121,6 +121,7 @@ class Scene : public IEGrScene
|
||||
virtual bool ResetWinRect( void) ;
|
||||
// Snap
|
||||
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) ;
|
||||
|
||||
public :
|
||||
// Basic
|
||||
@@ -159,11 +160,10 @@ class Scene : public IEGrScene
|
||||
bool DrawGeoLine( void) ;
|
||||
bool DrawWinRect( void) ;
|
||||
// Snap
|
||||
bool GetGridSnapPoint( int nSnap, const Point3d& ptWin, Point3d& ptSel) ;
|
||||
bool GetGridSnapPoint( bool bSketch, const Point3d& ptWin, Point3d& ptSel) ;
|
||||
bool GetSelectedSnapPoint( int nSnap, const Point3d& ptWin, int nW, int nH, Point3d& ptSel) ;
|
||||
bool VerifySnapPoint( const Point3d& ptP, const Point3d& ptWin, double& dMinSqDist) ;
|
||||
|
||||
|
||||
private :
|
||||
HDC m_hDC ; // Device Context
|
||||
HGLRC m_hRC ; // OpenGL Rendering Context
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@
|
||||
using namespace std ;
|
||||
|
||||
//--------------------------- Constants --------------------------------------
|
||||
static const double MIN_EXTENSION = 50 ;
|
||||
static const double MIN_EXTENSION = 250 ;
|
||||
static const double MIN_W_H = 0.01 ;
|
||||
static const double MIN_ZCLIP_EXT = 5000 ;
|
||||
|
||||
|
||||
+35
-6
@@ -31,7 +31,7 @@ Scene::GetGraphicSnapPoint( int nSnap, const Point3d& ptWin, int nW, int nH, Poi
|
||||
{
|
||||
// se Snap Sketch o Grid, devo trovare il punto sulla griglia
|
||||
if ( nSnap == SP_SKETCH || nSnap == SP_GRID)
|
||||
return GetGridSnapPoint( nSnap, ptWin, ptSel) ;
|
||||
return GetGridSnapPoint( ( nSnap == SP_SKETCH), ptWin, ptSel) ;
|
||||
// altrimenti devo trovare il punto dall'entità inquadrata
|
||||
else
|
||||
return GetSelectedSnapPoint( nSnap, ptWin, nW, nH, ptSel) ;
|
||||
@@ -39,7 +39,7 @@ Scene::GetGraphicSnapPoint( int nSnap, const Point3d& ptWin, int nW, int nH, Poi
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Scene::GetGridSnapPoint( int nSnap, const Point3d& ptWin, Point3d& ptSel)
|
||||
Scene::GetGridSnapPoint( bool bSketch, const Point3d& ptWin, Point3d& ptSel)
|
||||
{
|
||||
// calcolo un punto e la direzione della linea di mira
|
||||
Point3d ptLine ;
|
||||
@@ -57,7 +57,7 @@ Scene::GetGridSnapPoint( int nSnap, const Point3d& ptWin, Point3d& ptSel)
|
||||
// porto il punto sul piano di griglia
|
||||
ptSel.ToLoc( m_frGrid) ;
|
||||
// se punto grid, devo arrotondare al nodo di griglia più vicino
|
||||
if ( nSnap == SP_GRID) {
|
||||
if ( ! bSketch) {
|
||||
ptSel.x = floor( ptSel.x / m_dSnapStep + 0.5) * m_dSnapStep ;
|
||||
ptSel.y = floor( ptSel.y / m_dSnapStep + 0.5) * m_dSnapStep ;
|
||||
}
|
||||
@@ -68,13 +68,42 @@ Scene::GetGridSnapPoint( int nSnap, const Point3d& ptWin, Point3d& ptSel)
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Scene::GetGridSnapPointZ( bool bSketch, const Point3d& ptWin, const Point3d& ptGrid, Point3d& ptSel)
|
||||
{
|
||||
// calcolo un punto e la direzione della linea di mira
|
||||
Point3d ptLine ;
|
||||
if ( ! UnProject( ptWin, ptLine))
|
||||
return false ;
|
||||
Vector3d vtLine = - m_vtDirCamera ;
|
||||
|
||||
// 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() ;
|
||||
if ( ! vtNorm.Normalize())
|
||||
return false ;
|
||||
|
||||
// determino l'intersezione della linea di mira con il piano di elevazione
|
||||
double dDenom = vtLine * vtNorm ;
|
||||
if ( fabs( dDenom) < COS_ORTO_ANG_SMALL)
|
||||
return false ;
|
||||
double dU = ( ( ptGrid - ptLine) * vtNorm) / dDenom ;
|
||||
Point3d ptNear = ptLine + dU * vtLine ;
|
||||
|
||||
// proietto il punto sulla linea di elevazione
|
||||
double dDeltaZ = ( ptNear - ptGrid) * m_frGrid.VersZ() ;
|
||||
if ( ! bSketch)
|
||||
dDeltaZ = floor( dDeltaZ / m_dSnapStep + 0.5) * m_dSnapStep ;
|
||||
ptSel = ptGrid + dDeltaZ * m_frGrid.VersZ() ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Scene::GetSelectedSnapPoint( int nSnap, const Point3d& ptWin, int nW, int nH, Point3d& ptSel)
|
||||
{
|
||||
// se Snap Sketch o Grid, devo trovare il punto sulla griglia
|
||||
if ( nSnap == SP_SKETCH || nSnap == SP_GRID)
|
||||
return GetGridSnapPoint( nSnap, ptWin, ptSel) ;
|
||||
// verifico siano state selezionate delle entità
|
||||
int nSel ;
|
||||
Select( ptWin, nW, nH, nSel) ;
|
||||
|
||||
Reference in New Issue
Block a user