EgtGraphics 1.6v7 :

- migliorie varie per overload e const
- aggiunta GetPlaneSnapPoint.
This commit is contained in:
Dario Sassi
2016-10-29 15:48:19 +00:00
parent 415f15f71c
commit cde25533e7
9 changed files with 147 additions and 127 deletions
BIN
View File
Binary file not shown.
+102 -101
View File
@@ -66,120 +66,121 @@ class Scene : public IEGrScene
{
public :
// Basic
virtual ~Scene( void) ;
virtual bool Init( IGeomDB* pGeomDB) ;
virtual bool CreateContext( HDC hDC, int nDriver, bool b2Buff, int nColorBits, int nDepthBits) ;
virtual bool IsValid( void)
{ return ( m_hDC != nullptr && m_hRC != nullptr) ; }
virtual std::string GetOpenGLInfo( void) ;
virtual std::string GetGLSLInfo( void) ;
virtual std::string GetPixelFormatInfo( void) ;
virtual IGeomDB* GetGeomDB( void)
{ return m_pGeomDB ; }
virtual bool RedrawWindow( void) ;
virtual bool Resize( int nW, int nH) ;
virtual bool SetBackground( Color colBackTop, Color colBackBottom) ;
virtual bool Draw( void) ;
virtual bool Project( const Point3d& ptWorld, Point3d& ptView) ;
virtual bool UnProject( const Point3d& ptView, Point3d& ptWorld) ;
virtual void Destroy( void) ;
~Scene( void) override ;
bool Init( IGeomDB* pGeomDB) override ;
bool CreateContext( HDC hDC, int nDriver, bool b2Buff, int nColorBits, int nDepthBits) override ;
bool IsValid( void) const override
{ return ( m_hDC != nullptr && m_hRC != nullptr) ; }
std::string GetOpenGLInfo( void) const override ;
std::string GetGLSLInfo( void) const override ;
std::string GetPixelFormatInfo( void) const override ;
IGeomDB* GetGeomDB( void) const override
{ return m_pGeomDB ; }
bool RedrawWindow( void) override ;
bool Resize( int nW, int nH) override ;
bool SetBackground( Color colBackTop, Color colBackBottom) override ;
bool Draw( void) override ;
bool Project( const Point3d& ptWorld, Point3d& ptView) const override ;
bool UnProject( const Point3d& ptView, Point3d& ptWorld) const override ;
void Destroy( void) override ;
// Camera
virtual bool SetCenter( const Point3d& ptCenter) ;
virtual bool SetCamera( double dAngVertDeg, double dAngOrizzDeg, double dDist) ;
virtual bool SetCamera( int nDir, double dDist = 0) ;
virtual const Point3d& GetCenter( void)
{ return m_ptCenter ; }
virtual Point3d GetProjectedCenter( void) ;
virtual void GetCamera( double* pdAngVertDeg, double* pdAngOrizzDeg, double* pdDist = nullptr) ;
virtual int GetCameraDir( void) ;
virtual bool PanCamera( const Point3d& ptWinOld, const Point3d& ptWinNew) ;
virtual bool RotateCamera( const Point3d& ptWinOld, const Point3d& ptWinNew) ;
virtual bool ZoomAll( void) ;
virtual bool ZoomRadius( double dRadius) ;
virtual bool ZoomChange( double dCoeff) ;
virtual bool ZoomOnPoint( const Point3d& ptWin, double dCoeff) ;
virtual bool ZoomWin( const Point3d& ptWin1, const Point3d& ptWin2) ;
bool SetCenter( const Point3d& ptCenter) override ;
bool SetCamera( double dAngVertDeg, double dAngOrizzDeg, double dDist) override ;
bool SetCamera( int nDir, double dDist = 0) override ;
const Point3d& GetCenter( void) const override
{ return m_ptCenter ; }
Point3d GetProjectedCenter( void) const override ;
void GetCamera( double* pdAngVertDeg, double* pdAngOrizzDeg, double* pdDist = nullptr) const override ;
int GetCameraDir( void) const override ;
bool PanCamera( const Point3d& ptWinOld, const Point3d& ptWinNew) override ;
bool RotateCamera( const Point3d& ptWinOld, const Point3d& ptWinNew) override ;
bool ZoomAll( void) override ;
bool ZoomRadius( double dRadius) override ;
bool ZoomChange( double dCoeff) override ;
bool ZoomOnPoint( const Point3d& ptWin, double dCoeff) override ;
bool ZoomWin( const Point3d& ptWin1, const Point3d& ptWin2) override ;
// ShowMode
virtual bool SetShowMode( int nShowMode)
{ if ( nShowMode != SM_WIREFRAME &&
nShowMode != SM_HIDDENLINE &&
nShowMode != SM_SHADING)
return false ;
m_nShowMode = nShowMode ;
return true ; }
virtual int GetShowMode( void)
{ return m_nShowMode ; }
virtual void SetShowCurveDirection( bool bShow)
{ m_bShowCurveDirection = bShow ; }
virtual bool GetShowCurveDirection( void)
{ return m_bShowCurveDirection ; }
virtual void SetShowTriaAdvanced( bool bAdvanced)
{ m_bShowTriaAdvanced = bAdvanced ; }
virtual bool GetShowTriaAdvanced( void)
{ return m_bShowTriaAdvanced ; }
virtual void SetShowZmap( int nMode)
{ m_nShowZmap = nMode ; }
virtual int GetShowZmap( void)
bool SetShowMode( int nShowMode) override
{ if ( nShowMode != SM_WIREFRAME &&
nShowMode != SM_HIDDENLINE &&
nShowMode != SM_SHADING)
return false ;
m_nShowMode = nShowMode ;
return true ; }
int GetShowMode( void) const override
{ return m_nShowMode ; }
void SetShowCurveDirection( bool bShow) override
{ m_bShowCurveDirection = bShow ; }
bool GetShowCurveDirection( void) const override
{ return m_bShowCurveDirection ; }
void SetShowTriaAdvanced( bool bAdvanced) override
{ m_bShowTriaAdvanced = bAdvanced ; }
bool GetShowTriaAdvanced( void) const override
{ return m_bShowTriaAdvanced ; }
void SetShowZmap( int nMode) override
{ m_nShowZmap = nMode ; }
int GetShowZmap( void) const override
{ return m_nShowZmap ; }
// Geometry
virtual bool SetExtension( const BBox3d& b3Ext) ;
virtual bool UpdateExtension( void) ;
virtual bool SetMark( Color colMark) ;
virtual bool SetSelSurf( Color colSelSurf) ;
bool SetExtension( const BBox3d& b3Ext) override ;
bool UpdateExtension( void) override ;
bool SetMark( Color colMark) override ;
bool SetSelSurf( Color colSelSurf) override ;
// Grid
virtual bool SetGridShow( bool bShowGrid, bool bShowFrame) ;
virtual bool SetGridGeo( double dSnapStep, int nMinLineSstep, int nMajLineSstep, int nExtSstep) ;
virtual bool SetGridColor( Color colMinLine, Color colMajLine) ;
bool SetGridShow( bool bShowGrid, bool bShowFrame) override ;
bool SetGridGeo( double dSnapStep, int nMinLineSstep, int nMajLineSstep, int nExtSstep) override ;
bool SetGridColor( Color colMinLine, Color colMajLine) override ;
// Glob Frame
virtual bool SetGlobFrameShow( bool bShow) ;
bool SetGlobFrameShow( bool bShow) override ;
// Direct
virtual bool SetGeoLineAttribs( Color GLcol) ;
virtual bool SetGeoLine( const Point3d& ptP1, const Point3d& ptP2) ;
virtual bool ResetGeoLine( void) ;
virtual bool SetGeoTriaAttribs( Color GTcol) ;
virtual bool SetGeoTria( const Point3d& ptP1, const Point3d& ptP2, const Point3d& ptP3) ;
virtual bool ResetGeoTria( void) ;
virtual bool SetWinRectAttribs( bool bOutline, Color WRcol) ;
virtual bool SetWinRect( const Point3d& ptWinRectP1, const Point3d& ptWinRectP2) ;
virtual bool ResetWinRect( void) ;
bool SetGeoLineAttribs( Color GLcol) override ;
bool SetGeoLine( const Point3d& ptP1, const Point3d& ptP2) override ;
bool ResetGeoLine( void) override ;
bool SetGeoTriaAttribs( Color GTcol) override ;
bool SetGeoTria( const Point3d& ptP1, const Point3d& ptP2, const Point3d& ptP3) override ;
bool ResetGeoTria( void) override ;
bool SetWinRectAttribs( bool bOutline, Color WRcol) override ;
bool SetWinRect( const Point3d& ptWinRectP1, const Point3d& ptWinRectP2) override ;
bool ResetWinRect( void) override ;
// Select
virtual bool Select( const Point3d& ptView, int nW, int nH, int& nSel) ;
virtual bool SetObjFilterForSelect( bool bZerodim, bool bCurve, bool bSurf, bool bVolume, bool bExtra) ;
virtual bool UnselectableAdd( int nId) ;
virtual bool UnselectableRemove( int nId) ;
virtual bool UnselectableClearAll( void) ;
virtual bool UnselectableFind( int nId) ;
virtual bool GetSelectedObjs( INTVECTOR& nIds) ;
virtual int GetFirstSelectedObj( void) ;
virtual int GetNextSelectedObj( void) ;
virtual double GetSelectedObjWinZ( int nSel = - 1) ;
virtual double GetSelectedObjMinWinZ( int nSel = - 1) ;
virtual bool GetPointFromSelect( int nSelId, const Point3d& ptView, Point3d& ptSel, int& nAux) ;
bool Select( const Point3d& ptView, int nW, int nH, int& nSel) override ;
bool SetObjFilterForSelect( bool bZerodim, bool bCurve, bool bSurf, bool bVolume, bool bExtra) override ;
bool UnselectableAdd( int nId) override ;
bool UnselectableRemove( int nId) override ;
bool UnselectableClearAll( void) override ;
bool UnselectableFind( int nId) override ;
bool GetSelectedObjs( INTVECTOR& nIds) const override ;
int GetFirstSelectedObj( void) override ;
int GetNextSelectedObj( void) override ;
double GetSelectedObjWinZ( int nSel = - 1) const override ;
double GetSelectedObjMinWinZ( int nSel = - 1) const override ;
bool GetPointFromSelect( int nSelId, const Point3d& ptView, Point3d& ptSel, int& nAux) override ;
// Snap
// anche per lo snap valgono SetObjFilterForSelect e Unselectable*
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)
{ return m_nLastSnapId ; }
virtual bool GetLastSnapDir( Vector3d& vtDir)
{ if ( ! m_bLastSnapDirOk)
return false ;
vtDir = m_vtLastSnapDir ;
return true ; }
bool GetGraphicSnapPoint( int nSnap, const Point3d& ptWin, int nW, int nH, Point3d& ptSel) override ;
bool GetGridSnapPointZ( bool bSketch, const Point3d& ptWin, const Point3d& ptGrid, Point3d& ptSel) const override ;
int GetLastSnapId( void) const override
{ return m_nLastSnapId ; }
bool GetLastSnapDir( Vector3d& vtDir) const override
{ if ( ! m_bLastSnapDirOk)
return false ;
vtDir = m_vtLastSnapDir ;
return true ; }
bool GetPlaneSnapPoint( const Point3d& ptWin, const Plane3d& plPlane, Point3d& ptSel) const override ;
// Texture
virtual bool LoadTexture( const std::string& sName, const std::string& sFile,
double dMMxPix, double dDimX, double dDimY, int nRepeat) ;
virtual bool UnloadTexture( const std::string& sName) ;
virtual bool UnloadAllTextures( void) ;
virtual bool ExistsTexture( const std::string& sName) ;
virtual bool GetTexturePixels( const std::string& sName, int& nWidth, int& nHeight) ;
virtual bool GetTextureDimensions( const std::string& sName, double& dDimX, double& dDimY) ;
virtual bool ChangeTextureDimensions( const std::string& sName, double dDimX, double dDimY) ;
bool LoadTexture( const std::string& sName, const std::string& sFile,
double dMMxPix, double dDimX, double dDimY, int nRepeat) override ;
bool UnloadTexture( const std::string& sName) override ;
bool UnloadAllTextures( void) override ;
bool ExistsTexture( const std::string& sName) const override ;
bool GetTexturePixels( const std::string& sName, int& nWidth, int& nHeight) const override ;
bool GetTextureDimensions( const std::string& sName, double& dDimX, double& dDimY) const override ;
bool ChangeTextureDimensions( const std::string& sName, double dDimX, double dDimY) override ;
public :
// Basic
Scene( void) ;
bool MakeCurrent( void) ;
bool MakeCurrent( void) const ;
GLEWContext* glewGetContext( void)
{ return &m_glewc ; }
int GetOpenGLver( void)
@@ -212,7 +213,7 @@ class Scene : public IEGrScene
bool DrawAlphaSurfVector( void) ;
bool DeleteObjGraphicsGroup( int nId) ;
// Grid
const Frame3d& GetGridFrame( void)
const Frame3d& GetGridFrame( void) const
{ if ( m_pGeomDB != nullptr)
return m_pGeomDB->GetGridFrame() ;
static Frame3d frGrid ;
@@ -231,7 +232,7 @@ class Scene : public IEGrScene
bool FindSelectedSnapPoint( int nSnap, const Point3d& ptWin, int nW, int nH) ;
bool FindCurveSnapPoint( int nSnap, const Point3d& ptWin, int nId, const Frame3d& frEnt,
const ICurve* pCrv, double& dMinSqDist) ;
bool VerifySnapPoint( const Point3d& ptP, const Point3d& ptWin, double& dMinSqDist) ;
bool VerifySnapPoint( const Point3d& ptP, const Point3d& ptWin, double& dMinSqDist) const ;
bool AdjustForCurveExtr( const Point3d& ptWin, const Frame3d& frEnt, const ICurve* pCrv, Point3d& ptP) ;
bool FindCurveCompoSnapPoint( int nSnap, const Point3d& ptWin, int nId, const Frame3d& frEnt,
const ICurveComposite* pCrvCompo, double& dMinSqDist) ;
+6 -6
View File
@@ -273,7 +273,7 @@ Scene::ChooseGenPixelFormat( int nPfd, bool b2Buff, int nColorBits, int nDepthBi
//----------------------------------------------------------------------------
bool
Scene::MakeCurrent( void)
Scene::MakeCurrent( void) const
{
// se RC della scena non è definito, errore
if ( m_hRC == nullptr)
@@ -289,7 +289,7 @@ Scene::MakeCurrent( void)
//----------------------------------------------------------------------------
string
Scene::GetOpenGLInfo( void)
Scene::GetOpenGLInfo( void) const
{
string sInfo = "OpenGL " ;
@@ -316,7 +316,7 @@ Scene::GetOpenGLInfo( void)
//----------------------------------------------------------------------------
string
Scene::GetGLSLInfo( void)
Scene::GetGLSLInfo( void) const
{
string sInfo = "GLSL " ;
@@ -338,7 +338,7 @@ Scene::GetGLSLInfo( void)
//----------------------------------------------------------------------------
string
Scene::GetPixelFormatInfo( void)
Scene::GetPixelFormatInfo( void) const
{
string sInfo = "PixFmt " ;
@@ -819,7 +819,7 @@ Scene::Draw( void)
/*------------------------------------------------------------------------------------------*/
bool
Scene::Project( const Point3d& ptWorld, Point3d& ptView)
Scene::Project( const Point3d& ptWorld, Point3d& ptView) const
{
if ( ! MakeCurrent())
return false ;
@@ -845,7 +845,7 @@ Scene::Project( const Point3d& ptWorld, Point3d& ptView)
/*------------------------------------------------------------------------------------------*/
bool
Scene::UnProject( const Point3d& ptView, Point3d& ptWorld)
Scene::UnProject( const Point3d& ptView, Point3d& ptWorld) const
{
if ( ! MakeCurrent())
return false ;
+3 -3
View File
@@ -128,7 +128,7 @@ Scene::VerifyCamera( void)
//----------------------------------------------------------------------------
void
Scene::GetCamera( double* pdAngVertDeg, double* pdAngOrizzDeg, double* pdDist)
Scene::GetCamera( double* pdAngVertDeg, double* pdAngOrizzDeg, double* pdDist) const
{
double dAngVertDeg ;
double dAngOrizzDeg ;
@@ -155,7 +155,7 @@ Scene::GetCamera( double* pdAngVertDeg, double* pdAngOrizzDeg, double* pdDist)
//----------------------------------------------------------------------------
int
Scene::GetCameraDir( void)
Scene::GetCameraDir( void) const
{
if ( m_vtDirCamera.IsZplus())
return CT_TOP ;
@@ -183,7 +183,7 @@ Scene::GetCameraDir( void)
//----------------------------------------------------------------------------
Point3d
Scene::GetProjectedCenter( void)
Scene::GetProjectedCenter( void) const
{
Point3d ptVCen ;
if ( ! Project( m_ptCenter, ptVCen))
+3 -3
View File
@@ -129,7 +129,7 @@ Scene::SetObjFilterForSelect( bool bZerodim, bool bCurve, bool bSurf, bool bVolu
//----------------------------------------------------------------------------
bool
Scene::GetSelectedObjs( INTVECTOR& nIds)
Scene::GetSelectedObjs( INTVECTOR& nIds) const
{
// inizializzo vettore Id
nIds.clear() ;
@@ -162,7 +162,7 @@ Scene::GetNextSelectedObj( void)
//----------------------------------------------------------------------------
double
Scene::GetSelectedObjWinZ( int nSel)
Scene::GetSelectedObjWinZ( int nSel) const
{
if ( nSel < 0)
nSel = m_nSelCurr ;
@@ -173,7 +173,7 @@ Scene::GetSelectedObjWinZ( int nSel)
//----------------------------------------------------------------------------
double
Scene::GetSelectedObjMinWinZ( int nSel)
Scene::GetSelectedObjMinWinZ( int nSel) const
{
if ( nSel < 0)
nSel = m_nSelCurr ;
+22 -3
View File
@@ -70,7 +70,7 @@ Scene::GetGraphicSnapPoint( int nSnap, const Point3d& ptWin, int nW, int nH, Poi
//----------------------------------------------------------------------------
bool
Scene::GetGridSnapPointZ( bool bSketch, const Point3d& ptWin, const Point3d& ptGrid, Point3d& ptSel)
Scene::GetGridSnapPointZ( bool bSketch, const Point3d& ptWin, const Point3d& ptGrid, Point3d& ptSel) const
{
// recupero il riferimento di griglia
Frame3d frGrid = GetGridFrame() ;
@@ -468,7 +468,7 @@ Scene::FindCurveSnapPoint( int nSnap, const Point3d& ptWin, int nId, const Frame
//----------------------------------------------------------------------------
bool
Scene::VerifySnapPoint( const Point3d& ptP, const Point3d& ptWin, double& dMinSqDist)
Scene::VerifySnapPoint( const Point3d& ptP, const Point3d& ptWin, double& dMinSqDist) const
{
// il punto di riferimento deriva da XY su viewport e Z minima (più vicina a osservatore) da selezione
Point3d ptWinZ( ptWin.x, ptWin.y, GetSelectedObjMinWinZ()) ;
@@ -962,4 +962,23 @@ Scene::FindTextSnapPoint( int nSnap, const Point3d& ptWin, int nId, const Frame3
break ;
}
return bFound ;
}
}
//----------------------------------------------------------------------------
bool
Scene::GetPlaneSnapPoint( const Point3d& ptWin, const Plane3d& plPlane, Point3d& ptSel) const
{
// calcolo un punto e la direzione della linea di mira
Point3d ptLine ;
if ( ! UnProject( ptWin, ptLine))
return false ;
Vector3d vtLine = - m_vtDirCamera ;
// determino l'intersezione di questa linea con il piano
double dDenom = vtLine * plPlane.vtN ;
if ( fabs( dDenom) < COS_ORTO_ANG_ZERO)
return false ;
double dU = ( plPlane.dDist - ( ptLine - ORIG) * plPlane.vtN) / dDenom ;
ptSel = ptLine + dU * vtLine ;
return true ;
}
+3 -3
View File
@@ -41,21 +41,21 @@ Scene::UnloadAllTextures( void)
//----------------------------------------------------------------------------
bool
Scene::ExistsTexture( const string& sName)
Scene::ExistsTexture( const string& sName) const
{
return m_TextMgr.Exists( sName) ;
}
//----------------------------------------------------------------------------
bool
Scene::GetTexturePixels( const string& sName, int& nWidth, int& nHeight)
Scene::GetTexturePixels( const string& sName, int& nWidth, int& nHeight) const
{
return m_TextMgr.GetPixels( sName, nWidth, nHeight) ;
}
//----------------------------------------------------------------------------
bool
Scene::GetTextureDimensions( const string& sName, double& dDimX, double& dDimY)
Scene::GetTextureDimensions( const string& sName, double& dDimX, double& dDimY) const
{
return m_TextMgr.GetDimensions( sName, dDimX, dDimY) ;
}
+4 -4
View File
@@ -249,7 +249,7 @@ TextureMgr::UnloadTexture( const string& sName)
//----------------------------------------------------------------------------
bool
TextureMgr::Exists( const string& sName)
TextureMgr::Exists( const string& sName) const
{
// ricerca della texture di nome dato
auto iIter = m_umTextData.find( sName) ;
@@ -258,7 +258,7 @@ TextureMgr::Exists( const string& sName)
//----------------------------------------------------------------------------
bool
TextureMgr::GetPixels( const string& sName, int& nWidth, int& nHeight)
TextureMgr::GetPixels( const string& sName, int& nWidth, int& nHeight) const
{
// ricerca della texture di nome dato
auto iIter = m_umTextData.find( sName) ;
@@ -272,7 +272,7 @@ TextureMgr::GetPixels( const string& sName, int& nWidth, int& nHeight)
//----------------------------------------------------------------------------
bool
TextureMgr::GetDimensions( const string& sName, double& dDimX, double& dDimY)
TextureMgr::GetDimensions( const string& sName, double& dDimX, double& dDimY) const
{
// ricerca della texture di nome dato
auto iIter = m_umTextData.find( sName) ;
@@ -300,7 +300,7 @@ TextureMgr::ChangeDimensions( const string& sName, double dDimX, double dDimY)
//----------------------------------------------------------------------------
bool
TextureMgr::GetTextureData( const string& sName, unsigned int& nId, double& dDimX, double& dDimY)
TextureMgr::GetTextureData( const string& sName, unsigned int& nId, double& dDimX, double& dDimY) const
{
// ricerca della texture di nome dato
auto iIter = m_umTextData.find( sName) ;
+4 -4
View File
@@ -50,12 +50,12 @@ class TextureMgr
bool Clear( void) ;
bool LoadTexture( const std::string& sName, const std::string& sPath,
double dMMxPix, double dDimX, double dDimY, int nRepeat) ;
bool Exists( const std::string& sName) ;
bool GetPixels( const std::string& sName, int& nWidth, int& nHeight) ;
bool GetDimensions( const std::string& sName, double& dDimX, double& dDimY) ;
bool Exists( const std::string& sName) const ;
bool GetPixels( const std::string& sName, int& nWidth, int& nHeight) const ;
bool GetDimensions( const std::string& sName, double& dDimX, double& dDimY) const ;
bool ChangeDimensions( const std::string& sName, double dDimX, double dDimY) ;
bool UnloadTexture( const std::string& sName) ;
bool GetTextureData( const std::string& sName, unsigned int& nId, double& dDimX, double& dDimY) ;
bool GetTextureData( const std::string& sName, unsigned int& nId, double& dDimX, double& dDimY) const ;
private :
bool LoadCalcTexture( const std::string& sName,