22 Commits

Author SHA1 Message Date
Dario Sassi 4081ff7830 EgtGraphics 2.5l6 :
- aggiunta gestione disegno grid asimmetrica, impostabile con SetGridGeoAdv.
2024-01-09 18:30:04 +01:00
Dario Sassi fec352f37b EgtGraphics 2.5l2 :
- tolta una inutile rotazione di 180° attorno a Z nella vista da sotto.
2023-12-29 13:03:10 +01:00
Dario Sassi 199fbf25d8 EgtGraphics 2.5l1 :
- ricompilazione con cambio versione.
2023-12-01 16:44:48 +01:00
Dario Sassi 8611f15893 EgtGraphics :
- aggiunta possibilità di forzare in ogni caso la visualizzazione di parti custom di un oggetto.
2023-11-22 20:22:10 +01:00
Dario Sassi 69e7dab720 EgtGraphics 2.5k1 :
- ricompilazione con cambio versione.
2023-11-03 17:23:28 +01:00
Dario Sassi 43daacac9a EgtGraphics 2.5j1 :
- ricompilazione con cambio versione.
2023-10-09 13:03:37 +02:00
Dario Sassi e51b4d5750 EgtGraphics 2.5i5 :
- ricompilazione a 64bit con Enable Enhanced Instruction Set = Not Set.
2023-09-21 15:25:25 +02:00
Dario Sassi eaa964eca2 EgtGraphics :
- in visualizzazione Zmap si verifica se single-dexel o tri-dexel per normale singola o tripla ai triangoli.
2023-09-12 16:02:03 +02:00
Dario Sassi 000db07d85 EgtGraphics 2.5i1 :
- ricompilazione con cambio versione.
2023-09-11 10:40:26 +02:00
Dario Sassi 14ffb16d79 EgtGraphics 2.5h1 :
- migliorata distribuzione connessioni tra sopra e sotto di curve per spessore.
2023-08-23 16:47:39 +02:00
DarioS 00a81d6e04 EgtGraphics 2.5g1 :
- aggiunta gestione Stipple per GeoPoint3d, GeoVector3d e GeoCurve.
2023-07-10 11:16:17 +02:00
DarioS 1704b40c17 EgtGraphics 2.5f1 :
- ricompilazione con cambio versione.
2023-06-19 08:00:55 +02:00
DarioS 30b56dbfc8 EgtGraphics 2.5e5 :
- migliorato controllo gestione chiave di rete.
2023-05-30 10:24:50 +02:00
DarioS 59ddf02887 EgtGraphics 2.5d4 :
- gli oggetti Frame3d ora sono visualizzati con assi lunghi 40 (contro i 10 di prima).
2023-04-20 16:15:03 +02:00
DarioS 9384f8f0df EgtGraphics 2.5d3 :
- ricompilazione con cambio versione.
2023-04-11 19:36:35 +02:00
DarioS 327e8bcf2a EgtGraphics 2.5c1 :
- ricompilazione con cambio versione.
2023-03-23 10:05:22 +01:00
DarioS 1a393126f3 EgtGraphics 2.5b3 :
- ricompilazione con cambio versione.
2023-02-27 08:16:29 +01:00
DarioS 7fd9bae8fc EgtGraphics 2.5b2 :
- ricompilazione con cambio versione.
2023-02-20 09:15:51 +01:00
DarioS 8b47da0588 EgtGraphics 2.5b1 :
- ricompilazione con cambio versione.
2023-02-09 10:18:32 +01:00
DarioS 9fd623cf9e EgtGraphics 2.5a1 :
- ricompilazione con cambio versione.
2023-01-03 08:54:53 +01:00
DarioS f37aeb5892 EgtGraphics 2.4k1 :
- ricompilazione con cambio versione.
2022-11-02 15:14:00 +01:00
Riccardo Elitropi cd77324145 Merge commit '76d7496e2e1983d8fa1a95f4a029689ad9d7d59d' 2022-10-20 16:16:48 +02:00
17 changed files with 441 additions and 220 deletions
+3 -2
View File
@@ -1,7 +1,7 @@
//----------------------------------------------------------------------------
// EgalTech 2013-2013
// EgalTech 2013-2023
//----------------------------------------------------------------------------
// File : DllMain.h Data : 17.02.14 Versione : 1.5b3
// File : DllMain.h Data : 30.05.23 Versione : 2.5e5
// Contenuto : Prototipi funzioni per uso locale della DLL.
//
//
@@ -21,3 +21,4 @@
ILogger* GetEGrLogger( void) ;
const std::string& GetEGrKey( void) ;
bool GetEGrNetHwKey( void) ;
bool VerifyKey( int nKeyOpt) ;
+30 -2
View File
@@ -1,7 +1,7 @@
//----------------------------------------------------------------------------
// EgalTech 2014-2014
// EgalTech 2014-2023
//----------------------------------------------------------------------------
// File : EGrDllMain.cpp Data : 13.02.14 Versione : 1.5b1
// File : EGrDllMain.cpp Data : 30.05.23 Versione : 2.5e
// Contenuto : Inizializzazione della DLL.
//
//
@@ -16,6 +16,7 @@
#include "DllMain.h"
#include "/EgtDev/Include/EGrDllMain.h"
#include "/EgtDev/Include/EGnGetModuleVer.h"
#include "/EgtDev/Include/EGnGetKeyData.h"
#include "/EgtDev/Include/EgtTrace.h"
//--------------------------- Costanti ----------------------------------------
@@ -118,3 +119,30 @@ GetEGrNetHwKey( void)
{
return s_bNetHwKey ;
}
//-----------------------------------------------------------------------------
bool
VerifyKey( int nKeyOpt)
{
// Controllo della licenza
unsigned int nOpt1, nOpt2 ;
int nOptExpDays ;
int nRet = GetEGnKeyOptions( KEY_BASELIB_PROD, KEY_BASELIB_VER, KEY_BASELIB_LEV,
nOpt1, nOpt2, nOptExpDays) ;
if ( ! GetEGrNetHwKey())
nRet = GetKeyOptions( GetEGrKey(), KEY_BASELIB_PROD, KEY_BASELIB_VER, KEY_BASELIB_LEV,
nOpt1, nOpt2, nOptExpDays) ;
if ( nRet != KEY_OK) {
std::string sErr = "Error on Key (GRC/" + ToString( nRet) + ")" ;
LOG_ERROR( GetEGrLogger(), sErr.c_str()) ;
return false ;
}
if ( ( nOpt1 & KEYOPT_EGR_BASE) == 0 ||
( nKeyOpt != 0 && ( nOpt1 & nKeyOpt) == 0) ||
nOptExpDays < GetCurrDay()) {
std::string sErr = "Warning on Key (GRC/OPT)" ;
LOG_ERROR( GetEGrLogger(), sErr.c_str()) ;
return false ;
}
return true ;
}
BIN
View File
Binary file not shown.
+4 -2
View File
@@ -22,7 +22,7 @@
<ProjectGuid>{4EC970B1-B4D9-4088-8A31-B462CF72116E}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>EgtGraphics</RootNamespace>
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion>10.0.20348.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
@@ -108,6 +108,7 @@
<CompileAs>CompileAsCpp</CompileAs>
<DisableSpecificWarnings>
</DisableSpecificWarnings>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@@ -170,6 +171,7 @@ copy $(TargetPath) \EgtProg\DllD64</Command>
<EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
<EnableParallelCodeGeneration>true</EnableParallelCodeGeneration>
<PrecompiledHeader>Use</PrecompiledHeader>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@@ -203,7 +205,7 @@ copy $(TargetPath) \EgtProg\Dll32</Command>
<DisableSpecificWarnings>
</DisableSpecificWarnings>
<OmitFramePointers>true</OmitFramePointers>
<EnableEnhancedInstructionSet>AdvancedVectorExtensions2</EnableEnhancedInstructionSet>
<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
<EnableFiberSafeOptimizations>false</EnableFiberSafeOptimizations>
<EnableParallelCodeGeneration>true</EnableParallelCodeGeneration>
<CompileAs>CompileAsCpp</CompileAs>
+2 -4
View File
@@ -29,10 +29,8 @@ IEgrImageMgr*
CreateEgrImageMgr( void)
{
// verifico la chiave e le opzioni
if ( ! GetEGrNetHwKey()) {
if ( ! TestKeyForEGr( GetEGrKey(), 0, GetEGrLogger()))
return nullptr ;
}
if ( ! VerifyKey( 0))
return nullptr ;
// creo l'oggetto
return static_cast<IEgrImageMgr*> ( new(nothrow) ImageMgr) ;
}
+3 -2
View File
@@ -1,7 +1,7 @@
//----------------------------------------------------------------------------
// EgalTech 2014-2014
// EgalTech 2014-2023
//----------------------------------------------------------------------------
// File : ObjEGrGraphics.h Data : 13.02.14 Versione : 1.5b2
// File : ObjEGrGraphics.h Data : 08.07.23 Versione : 2.5g1
// Contenuto : Dichiarazione della classe grafica di un oggetto geometrico.
//
//
@@ -37,6 +37,7 @@ class ObjEGrGraphics : public IObjGraphics
virtual bool AddMaterial( const Color& colAmb, const Color& colDiff,
const Color& colSpec, float fShin) = 0 ;
virtual bool AddBackMaterial( const Color& colAmbDiff) = 0 ;
virtual bool AddLineStipple( int nFactor, int nPattern) = 0 ;
virtual bool AddPoint( const Point3d& ptP, bool bAux = false) = 0 ;
virtual bool AddPoints( const PNTVECTOR& vPnt, bool bAux = false) = 0 ;
virtual bool AddLines( const PNTVECTOR& vPnt, bool bAux = false) = 0 ;
+9
View File
@@ -105,6 +105,15 @@ ObjMultiGraphics::AddBackMaterial( const Color& colAmbDiff)
return m_vOEGR[m_nCurr]->AddBackMaterial( colAmbDiff) ;
}
//----------------------------------------------------------------------------
bool
ObjMultiGraphics::AddLineStipple( int nFactor, int nPattern)
{
if ( m_nCurr < 0 || m_nCurr >= int( m_vOEGR.size()))
return false ;
return m_vOEGR[m_nCurr]->AddLineStipple( nFactor, nPattern) ;
}
//----------------------------------------------------------------------------
bool
ObjMultiGraphics::AddPoint( const Point3d& ptP, bool bAux)
+1
View File
@@ -36,6 +36,7 @@ class ObjMultiGraphics : public ObjEGrGraphics
bool AddMaterial( const Color& colAmb, const Color& colDiff,
const Color& colSpec, float fShin) override ;
bool AddBackMaterial( const Color& colAmbDiff) override ;
bool AddLineStipple( int nFactor, int nPattern) override ;
bool AddPoint( const Point3d& ptP, bool bAux = false) override ;
bool AddPoints( const PNTVECTOR& vPnt, bool bAux = false) override ;
bool AddLines( const PNTVECTOR& vPnt, bool bAux = false) override ;
+87 -47
View File
@@ -1,7 +1,7 @@
//----------------------------------------------------------------------------
// EgalTech 2014-2014
// EgalTech 2014-2023
//----------------------------------------------------------------------------
// File : ObjNewGraphics.cpp Data : 23.04.14 Versione : 1.5d5
// File : ObjNewGraphics.cpp Data : 08.07.23 Versione : 2.5g1
// Contenuto : Implementazione della classe grafica di un oggetto geometrico.
//
//
@@ -19,7 +19,7 @@
#include "/EgtDev/Include/EGkPolyLine.h"
#include "/EgtDev/Include/EGkGdbConst.h"
#include "/EgtDev/Include/EGkTriangle3d.h"
#include "/EgtDev/Include/EgtNumUtils.h"
//--------------------------- Macro e Costanti -------------------------------
// Dimensioni flag per edge di triangoli
@@ -27,6 +27,7 @@ const size_t SIZEFLAG = sizeof( unsigned char) ;
// Dimensioni record del buffer ( vertice + normale + flag)
const size_t SIZEVNF = ( 2 * SIZEV3F + SIZEFLAG) ;
//----------------------------------------------------------------------------
ObjNewGraphics::~ObjNewGraphics( void)
{
@@ -55,7 +56,7 @@ ObjNewGraphics::Clear( void)
bool
ObjNewGraphics::AddColor( const Color& colC)
{
return AddColor( colC.GetRed(), colC.GetGreen(), colC.GetBlue(), colC.GetAlpha()) ;
return AddNgaColor( colC.GetRed(), colC.GetGreen(), colC.GetBlue(), colC.GetAlpha()) ;
}
//----------------------------------------------------------------------------
@@ -63,21 +64,28 @@ bool
ObjNewGraphics::AddMaterial( const Color& colAmb, const Color& colDiff,
const Color& colSpec, float fShin)
{
return AddMaterial( NgAtom::MAT_A, colAmb.GetRed(), colAmb.GetGreen(),
colAmb.GetBlue(), colDiff.GetAlpha()) &&
AddMaterial( NgAtom::MAT_D, colDiff.GetRed(), colDiff.GetGreen(),
colDiff.GetBlue(), colDiff.GetAlpha()) &&
AddMaterial( NgAtom::MAT_S, colSpec.GetRed(), colSpec.GetGreen(),
colSpec.GetBlue(), colDiff.GetAlpha()) &&
AddMaterial( NgAtom::MAT_SH, fShin, 0, 0, 0) ;
return AddNgaMaterial( NgAtom::MAT_A, colAmb.GetRed(), colAmb.GetGreen(),
colAmb.GetBlue(), colDiff.GetAlpha()) &&
AddNgaMaterial( NgAtom::MAT_D, colDiff.GetRed(), colDiff.GetGreen(),
colDiff.GetBlue(), colDiff.GetAlpha()) &&
AddNgaMaterial( NgAtom::MAT_S, colSpec.GetRed(), colSpec.GetGreen(),
colSpec.GetBlue(), colDiff.GetAlpha()) &&
AddNgaMaterial( NgAtom::MAT_SH, fShin, 0, 0, 0) ;
}
//----------------------------------------------------------------------------
bool
ObjNewGraphics::AddBackMaterial( const Color& colAmbDiff)
{
return AddMaterial( NgAtom::MAT_B, colAmbDiff.GetRed(), colAmbDiff.GetGreen(),
colAmbDiff.GetBlue(), colAmbDiff.GetAlpha()) ;
return AddNgaMaterial( NgAtom::MAT_B, colAmbDiff.GetRed(), colAmbDiff.GetGreen(),
colAmbDiff.GetBlue(), colAmbDiff.GetAlpha()) ;
}
//----------------------------------------------------------------------------
bool
ObjNewGraphics::AddLineStipple( int nFactor, int nPattern)
{
return AddNgaLineStipple( nFactor, nPattern) ;
}
//----------------------------------------------------------------------------
@@ -109,7 +117,7 @@ ObjNewGraphics::AddPoint( const Point3d& ptP, bool bAux)
glEnableClientState( GL_VERTEX_ARRAY) ;
glBindVertexArray( 0) ;
// aggiungo i dati in lista
AddVerts( GL_POINTS, nCount, nVaoId, nVboId, bAux) ;
AddNgaVerts( GL_POINTS, nCount, nVaoId, nVboId, bAux) ;
// dichiaro valida la grafica
m_bValid = true ;
@@ -148,7 +156,7 @@ ObjNewGraphics::AddPoints( const PNTVECTOR& vPnt, bool bAux)
glEnableClientState( GL_VERTEX_ARRAY) ;
glBindVertexArray( 0) ;
// aggiungo i dati in lista
AddVerts( GL_POINTS, nCount, nVaoId, nVboId, bAux) ;
AddNgaVerts( GL_POINTS, nCount, nVaoId, nVboId, bAux) ;
// dichiaro valida la grafica
m_bValid = true ;
@@ -187,7 +195,7 @@ ObjNewGraphics::AddLines( const PNTVECTOR& vPnt, bool bAux)
glEnableClientState( GL_VERTEX_ARRAY) ;
glBindVertexArray( 0) ;
// aggiungo i dati in lista
AddVerts( GL_LINES, nCount, nVaoId, nVboId, bAux) ;
AddNgaVerts( GL_LINES, nCount, nVaoId, nVboId, bAux) ;
// dichiaro valida la grafica
m_bValid = true ;
@@ -228,7 +236,7 @@ ObjNewGraphics::AddPolyLine( const PolyLine& PL, bool bAux)
glEnableClientState( GL_VERTEX_ARRAY) ;
glBindVertexArray( 0) ;
// aggiungo i dati in lista
AddVerts( GL_LINE_STRIP, nCount, nVaoId, nVboId, bAux) ;
AddNgaVerts( GL_LINE_STRIP, nCount, nVaoId, nVboId, bAux) ;
// dichiaro valida la grafica
m_bValid = true ;
@@ -261,7 +269,7 @@ ObjNewGraphics::StartTriangles( int nNum, bool bAux)
// NumTria * 3 * dimensione( vertice+normale+flag)
glBufferData( GL_ARRAY_BUFFER, nNum * 3 * SIZEVNF, NULL, GL_STATIC_DRAW) ;
// aggiungo i dati in lista
AddVerts( GL_TRIANGLES, 0, nVaoId, nVboId, bAux) ;
AddNgaVerts( GL_TRIANGLES, 0, nVaoId, nVboId, bAux) ;
// dichiaro modo triangoli
m_nCurrMode = GL_TRIANGLES ;
return true ;
@@ -329,8 +337,8 @@ ObjNewGraphics::EndTriangles( void)
}
//----------------------------------------------------------------------------
static float*
AdjustColor( float fCol[4], bool bDark)
static const float*
AdjustColor( const float fCol[4], bool bDark)
{
if ( ! bDark) {
return fCol ;
@@ -399,42 +407,58 @@ ObjNewGraphics::Draw( int nStat, int nMark, bool bSurfSha, bool bSurf, int nAlph
}
// ciclo di disegno
for ( auto iIter = m_ngaVect.begin() ; iIter != m_ngaVect.end() ; ++ iIter) {
switch ( iIter->m_nType) {
bool bLineStipple = false ;
for ( const auto& Nga : m_ngaVect) {
switch ( Nga.m_nType) {
case NgAtom::VERTS :
if ( iIter->m_nCount > 0 && iIter->m_nVaoId != 0) {
glBindVertexArray( iIter->m_nVaoId) ;
glDrawArrays( iIter->m_nMode, 0, iIter->m_nCount) ;
if ( Nga.m_nCount > 0 && Nga.m_nVaoId != 0) {
glBindVertexArray( Nga.m_nVaoId) ;
glDrawArrays( Nga.m_nMode, 0, Nga.m_nCount) ;
glBindVertexArray( 0) ;
}
break ;
case NgAtom::VERTS_A :
if ( bShowAux && iIter->m_nCount > 0 && iIter->m_nVaoId != 0) {
glBindVertexArray( iIter->m_nVaoId) ;
glDrawArrays( iIter->m_nMode, 0, iIter->m_nCount) ;
if ( bShowAux && Nga.m_nCount > 0 && Nga.m_nVaoId != 0) {
glBindVertexArray( Nga.m_nVaoId) ;
glDrawArrays( Nga.m_nMode, 0, Nga.m_nCount) ;
glBindVertexArray( 0) ;
}
break ;
case NgAtom::COLOR :
glColor4fv( ( bStdCol ? AdjustColor( iIter->m_fCol, bDark) : fSelMarkCol)) ;
glColor4fv( ( bStdCol ? AdjustColor( Nga.m_fCol, bDark) : fSelMarkCol)) ;
break ;
case NgAtom::MAT_A :
glMaterialfv( GL_FRONT, GL_AMBIENT, ( bStdCol ? iIter->m_fCol : fSelMarkCol)) ;
glMaterialfv( GL_FRONT, GL_AMBIENT, ( bStdCol ? Nga.m_fCol : fSelMarkCol)) ;
break ;
case NgAtom::MAT_D :
glMaterialfv( GL_FRONT, GL_DIFFUSE, ( bStdCol ? iIter->m_fCol : fSelMarkCol)) ;
glMaterialfv( GL_FRONT, GL_DIFFUSE, ( bStdCol ? Nga.m_fCol : fSelMarkCol)) ;
break ;
case NgAtom::MAT_S :
glMaterialfv( GL_FRONT, GL_SPECULAR, ( bStdCol ? iIter->m_fCol : fSelMarkCol)) ;
glMaterialfv( GL_FRONT, GL_SPECULAR, ( bStdCol ? Nga.m_fCol : fSelMarkCol)) ;
break ;
case NgAtom::MAT_SH :
glMaterialf( GL_FRONT, GL_SHININESS, iIter->m_fCol[0]) ;
glMaterialf( GL_FRONT, GL_SHININESS, Nga.m_fCol[0]) ;
break ;
case NgAtom::MAT_B :
glMaterialfv( GL_BACK, GL_AMBIENT_AND_DIFFUSE, ( bStdCol ? iIter->m_fCol : fSelMarkBackCol)) ;
glMaterialfv( GL_BACK, GL_AMBIENT_AND_DIFFUSE, ( bStdCol ? Nga.m_fCol : fSelMarkBackCol)) ;
break ;
case NgAtom::LINE_STIPPLE :
if ( Nga.m_nMode > 0) {
bLineStipple = true ;
glLineStipple( Clamp( Nga.m_nFactor, 1, 256), Clamp( Nga.m_nPattern, 0, 65535)) ;
glEnable( GL_LINE_STIPPLE) ;
}
else {
bLineStipple = false ;
glDisable( GL_LINE_STIPPLE) ;
}
break ;
}
}
if ( bLineStipple) {
bLineStipple = false ;
glDisable( GL_LINE_STIPPLE) ;
}
// se marcato e non superficie in shading, disegno halo
if ( nMark == GDB_MK_ON && ! bSurfSha) {
@@ -450,25 +474,41 @@ ObjNewGraphics::Draw( int nStat, int nMark, bool bSurfSha, bool bSurf, int nAlph
glColor4f( colMark.GetRed(), colMark.GetGreen(), colMark.GetBlue(), colMark.GetAlpha()) ;
// ciclo di disegno
for ( auto iIter = m_ngaVect.begin() ; iIter != m_ngaVect.end() ; ++ iIter) {
switch ( iIter->m_nType) {
bool bLineStipple = false ;
for ( const auto& Nga : m_ngaVect) {
switch ( Nga.m_nType) {
case NgAtom::VERTS :
if ( iIter->m_nCount > 0 && iIter->m_nVaoId != 0) {
glBindVertexArray( iIter->m_nVaoId) ;
glDrawArrays( iIter->m_nMode, 0, iIter->m_nCount) ;
if ( Nga.m_nCount > 0 && Nga.m_nVaoId != 0) {
glBindVertexArray( Nga.m_nVaoId) ;
glDrawArrays( Nga.m_nMode, 0, Nga.m_nCount) ;
glBindVertexArray( 0) ;
}
break ;
case NgAtom::VERTS_A :
if ( bShowAux && iIter->m_nCount > 0 && iIter->m_nVaoId != 0) {
glBindVertexArray( iIter->m_nVaoId) ;
glDrawArrays( iIter->m_nMode, 0, iIter->m_nCount) ;
if ( bShowAux && Nga.m_nCount > 0 && Nga.m_nVaoId != 0) {
glBindVertexArray( Nga.m_nVaoId) ;
glDrawArrays( Nga.m_nMode, 0, Nga.m_nCount) ;
glBindVertexArray( 0) ;
}
break ;
// non si impostano i colori, si usa quello di marcatura
case NgAtom::LINE_STIPPLE :
if ( Nga.m_nMode > 0) {
bLineStipple = true ;
glLineStipple( Clamp( Nga.m_nFactor, 1, 256), Clamp( Nga.m_nPattern, 0, 65535)) ;
glEnable( GL_LINE_STIPPLE) ;
}
else {
bLineStipple = false ;
glDisable( GL_LINE_STIPPLE) ;
}
break ;
}
}
if ( bLineStipple) {
bLineStipple = false ;
glDisable( GL_LINE_STIPPLE) ;
}
// ripristino test di depth
glDepthFunc( GL_LEQUAL) ;
}
@@ -490,13 +530,13 @@ ObjNewGraphics::DeleteVaoVbo( void)
return false ;
// ciclo di cancellazione VAO/VBO
for ( auto iIter = m_ngaVect.begin() ; iIter != m_ngaVect.end() ; ++ iIter) {
if ( iIter->m_nType == NgAtom::VERTS && iIter->m_nCount > 0) {
for ( auto& Nga : m_ngaVect) {
if ( Nga.m_nType == NgAtom::VERTS && Nga.m_nCount > 0) {
glBindBuffer( GL_ARRAY_BUFFER, 0) ;
glDeleteBuffers( 1, &iIter->m_nVboId) ;
glDeleteBuffers( 1, &Nga.m_nVboId) ;
glBindVertexArray( 0) ;
glDeleteVertexArrays( 1, &iIter->m_nVaoId) ;
iIter->m_nCount = 0 ;
glDeleteVertexArrays( 1, &Nga.m_nVaoId) ;
Nga.m_nCount = 0 ;
}
}
+15 -4
View File
@@ -24,7 +24,7 @@ class NgAtom {
public :
enum GrType { NONE = 0, VERTS = 1, VERTS_A = 2, COLOR = 3,
MAT_A = 4, MAT_D = 5, MAT_S = 6, MAT_SH = 7, MAT_B = 8} ;
MAT_A = 4, MAT_D = 5, MAT_S = 6, MAT_SH = 7, MAT_B = 8, LINE_STIPPLE = 9} ;
public :
GrType m_nType ;
@@ -42,6 +42,10 @@ class NgAtom {
float m_fAlpha ;
} ;
float m_fCol[4] ;
struct {
int m_nFactor ;
int m_nPattern ;
} ;
} ;
} ;
@@ -70,6 +74,7 @@ class ObjNewGraphics : public ObjEGrGraphics
bool AddMaterial( const Color& colAmb, const Color& colDiff,
const Color& colSpec, float fShin) override ;
bool AddBackMaterial( const Color& colAmbDiff) override ;
bool AddLineStipple( int nFactor, int nPattern) override ;
bool AddPoint( const Point3d& ptP, bool bAux = false) override ;
bool AddPoints( const PNTVECTOR& vPnt, bool bAux = false) override ;
bool AddLines( const PNTVECTOR& vPnt, bool bAux = false) override ;
@@ -90,22 +95,28 @@ class ObjNewGraphics : public ObjEGrGraphics
{ try { m_ngaVect.push_back( nga) ; }
catch(...) { return false ; }
return true ; }
bool AddVerts( int nMode, int nCount, unsigned int nVaoId, unsigned int nVboId, bool bAux = false)
bool AddNgaVerts( int nMode, int nCount, unsigned int nVaoId, unsigned int nVboId, bool bAux = false)
{ NgAtom nga ;
nga.m_nType = ( bAux ? NgAtom::VERTS_A : NgAtom::VERTS) ;
nga.m_nMode = nMode ; nga.m_nCount = nCount ;
nga.m_nVaoId = nVaoId ; nga.m_nVboId = nVboId ;
return AddNgAtom( nga) ; }
bool AddColor( float fRed, float fGreen, float fBlue, float fAlpha = 1)
bool AddNgaColor( float fRed, float fGreen, float fBlue, float fAlpha = 1)
{ NgAtom nga ;
nga.m_nType = NgAtom::COLOR ;
nga.m_fRed = fRed ; nga.m_fGreen = fGreen ; nga.m_fBlue = fBlue ; nga.m_fAlpha = fAlpha ;
return AddNgAtom( nga) ; }
bool AddMaterial( NgAtom::GrType nMat, float fRed, float fGreen, float fBlue, float fAlpha = 1)
bool AddNgaMaterial( NgAtom::GrType nMat, float fRed, float fGreen, float fBlue, float fAlpha = 1)
{ NgAtom nga ;
nga.m_nType = nMat ;
nga.m_fRed = fRed ; nga.m_fGreen = fGreen ; nga.m_fBlue = fBlue ; nga.m_fAlpha = fAlpha ;
return AddNgAtom( nga) ; }
bool AddNgaLineStipple( int nFactor, int nPattern)
{ NgAtom nga ;
nga.m_nType = NgAtom::LINE_STIPPLE ;
nga.m_nFactor = nFactor ;
nga.m_nPattern = nPattern ;
return AddNgAtom( nga) ; }
private :
Scene* m_pScene ; // puntatore alla scena
+91 -51
View File
@@ -1,7 +1,7 @@
//----------------------------------------------------------------------------
// EgalTech 2014-2014
// EgalTech 2014-2023
//----------------------------------------------------------------------------
// File : ObjOldGraphics.cpp Data : 23.04.14 Versione : 1.5d5
// File : ObjOldGraphics.cpp Data : 08.07.23 Versione : 2.5g1
// Contenuto : Implementazione della classe grafica di un oggetto geometrico.
//
//
@@ -19,8 +19,9 @@
#include "/EgtDev/Include/EGkPolyLine.h"
#include "/EgtDev/Include/EGkGdbConst.h"
#include "/EgtDev/Include/EGkTriangle3d.h"
#include "/EgtDev/Include/EgtNumUtils.h"
//----------------------------------------------------------------------------
//--------------------------- Macro e Costanti -------------------------------
const int VECT_HEAP = 20 ;
@@ -51,7 +52,7 @@ ObjOldGraphics::Clear( void)
bool
ObjOldGraphics::AddColor( const Color& colC)
{
return AddColor( colC.GetRed(), colC.GetGreen(), colC.GetBlue(), colC.GetAlpha()) ;
return AddOgaColor( colC.GetRed(), colC.GetGreen(), colC.GetBlue(), colC.GetAlpha()) ;
}
//----------------------------------------------------------------------------
@@ -59,21 +60,28 @@ bool
ObjOldGraphics::AddMaterial( const Color& colAmb, const Color& colDiff,
const Color& colSpec, float fShin)
{
return AddMaterial( OgAtom::MAT_A, colAmb.GetRed(), colAmb.GetGreen(),
colAmb.GetBlue(), colDiff.GetAlpha()) &&
AddMaterial( OgAtom::MAT_D, colDiff.GetRed(), colDiff.GetGreen(),
colDiff.GetBlue(), colDiff.GetAlpha()) &&
AddMaterial( OgAtom::MAT_S, colSpec.GetRed(), colSpec.GetGreen(),
colSpec.GetBlue(), colDiff.GetAlpha()) &&
AddMaterial( OgAtom::MAT_SH, fShin, 0, 0, 0) ;
return AddOgaMaterial( OgAtom::MAT_A, colAmb.GetRed(), colAmb.GetGreen(),
colAmb.GetBlue(), colDiff.GetAlpha()) &&
AddOgaMaterial( OgAtom::MAT_D, colDiff.GetRed(), colDiff.GetGreen(),
colDiff.GetBlue(), colDiff.GetAlpha()) &&
AddOgaMaterial( OgAtom::MAT_S, colSpec.GetRed(), colSpec.GetGreen(),
colSpec.GetBlue(), colDiff.GetAlpha()) &&
AddOgaMaterial( OgAtom::MAT_SH, fShin, 0, 0, 0) ;
}
//----------------------------------------------------------------------------
bool
ObjOldGraphics::AddBackMaterial( const Color& colAmbDiff)
{
return AddMaterial( OgAtom::MAT_B, colAmbDiff.GetRed(), colAmbDiff.GetGreen(),
colAmbDiff.GetBlue(), colAmbDiff.GetAlpha()) ;
return AddOgaMaterial( OgAtom::MAT_B, colAmbDiff.GetRed(), colAmbDiff.GetGreen(),
colAmbDiff.GetBlue(), colAmbDiff.GetAlpha()) ;
}
//----------------------------------------------------------------------------
bool
ObjOldGraphics::AddLineStipple( int nFactor, int nPattern)
{
return AddOgaLineStipple( nFactor, nPattern) ;
}
//----------------------------------------------------------------------------
@@ -84,13 +92,13 @@ ObjOldGraphics::AddPoint( const Point3d& ptP, bool bAux)
if ( m_nCurrMode != GL_NONE)
return false ;
// start
AddStart( GL_POINTS, bAux) ;
AddOgaStart( GL_POINTS, bAux) ;
// inserisco il nuovo vertice
AddVert3f( ptP) ;
AddOgaVert3f( ptP) ;
// aggiorno bbox
m_b3Loc.Add( ptP) ;
// fine
AddEnd() ;
AddOgaEnd() ;
// dichiaro valida la grafica
m_bValid = true ;
@@ -105,14 +113,14 @@ ObjOldGraphics::AddPoints( const PNTVECTOR& vPnt, bool bAux)
if ( m_nCurrMode != GL_NONE)
return false ;
// start
AddStart( GL_POINTS, bAux) ;
AddOgaStart( GL_POINTS, bAux) ;
// inserisco i vertici + aggiorno bbox
for ( int i = 0 ; i < int( vPnt.size()) ; ++ i) {
AddVert3f( vPnt[i]) ;
AddOgaVert3f( vPnt[i]) ;
m_b3Loc.Add( vPnt[i]) ;
}
// fine
AddEnd() ;
AddOgaEnd() ;
// dichiaro valida la grafica
m_bValid = true ;
@@ -129,14 +137,14 @@ ObjOldGraphics::AddLines( const PNTVECTOR& vPnt, bool bAux)
// riservo memoria per vettore
m_ogaVect.reserve( VECT_HEAP + vPnt.size()) ;
// start
AddStart( GL_LINES, bAux) ;
AddOgaStart( GL_LINES, bAux) ;
// inserisco i vertici + aggiorno bbox
for ( int i = 0 ; i < int( vPnt.size()) ; ++ i) {
AddVert3f( vPnt[i]) ;
AddOgaVert3f( vPnt[i]) ;
m_b3Loc.Add( vPnt[i]) ;
}
// fine
AddEnd() ;
AddOgaEnd() ;
// dichiaro valida la grafica
m_bValid = true ;
@@ -153,15 +161,15 @@ ObjOldGraphics::AddPolyLine( const PolyLine& PL, bool bAux)
// riservo memoria per vettore
m_ogaVect.reserve( VECT_HEAP + PL.GetPointNbr()) ;
// start
AddStart( GL_LINE_STRIP, bAux) ;
AddOgaStart( GL_LINE_STRIP, bAux) ;
// inserisco i nuovi vertici + aggiorno bbox
Point3d ptP ;
for ( bool bFound = PL.GetFirstPoint( ptP) ; bFound ; bFound = PL.GetNextPoint( ptP)) {
AddVert3f( ptP) ;
AddOgaVert3f( ptP) ;
m_b3Loc.Add( ptP) ;
}
// fine
AddEnd() ;
AddOgaEnd() ;
// dichiaro valida la grafica
m_bValid = true ;
@@ -178,7 +186,7 @@ ObjOldGraphics::StartTriangles( int nNum, bool bAux)
// riservo memoria per vettore
m_ogaVect.reserve( VECT_HEAP + 3 * nNum) ;
// inizio emissione triangoli
AddStart( GL_TRIANGLES, bAux) ;
AddOgaStart( GL_TRIANGLES, bAux) ;
m_nCurrMode = GL_TRIANGLES ;
return true ;
}
@@ -192,9 +200,9 @@ ObjOldGraphics::AddTriangle( const Triangle3d& Tria, const TriFlags3d& TFlags, c
return false ;
// emetto i flag, le normali e i vertici del triangolo + aggiorno bbox
for ( int i = 0 ; i < 3 ; ++ i) {
AddBndFlag( TFlags.bFlag[i]) ;
AddNormal3f( TNrms.vtN[i]) ;
AddVert3f( Tria.GetP( i)) ;
AddOgaBndFlag( TFlags.bFlag[i]) ;
AddOgaNormal3f( TNrms.vtN[i]) ;
AddOgaVert3f( Tria.GetP( i)) ;
m_b3Loc.Add( Tria.GetP( i)) ;
}
return true ;
@@ -208,7 +216,7 @@ ObjOldGraphics::EndTriangles( void)
if ( m_nCurrMode != GL_TRIANGLES)
return false ;
// termino il modo triangoli
AddEnd() ;
AddOgaEnd() ;
m_nCurrMode = GL_NONE ;
// dichiaro valida la grafica
m_bValid = true ;
@@ -217,8 +225,8 @@ ObjOldGraphics::EndTriangles( void)
}
//----------------------------------------------------------------------------
static float*
AdjustColor( float fCol[4], bool bDark)
static const float*
AdjustColor( const float fCol[4], bool bDark)
{
if ( ! bDark) {
return fCol ;
@@ -285,15 +293,16 @@ ObjOldGraphics::Draw( int nStat, int nMark, bool bSurfSha, bool bSurf, int nAlph
// ciclo di disegno
bool bStartA = false ;
for ( auto iIter = m_ogaVect.begin() ; iIter != m_ogaVect.end() ; ++ iIter) {
switch ( iIter->m_nType) {
bool bLineStipple = false ;
for ( const auto& Oga : m_ogaVect) {
switch ( Oga.m_nType) {
case OgAtom::START :
glBegin( iIter->m_nMode) ;
glBegin( Oga.m_nMode) ;
bStartA = false ;
break ;
case OgAtom::START_A :
if ( bShowAux)
glBegin( iIter->m_nMode) ;
glBegin( Oga.m_nMode) ;
bStartA = true ;
break ;
case OgAtom::END :
@@ -303,36 +312,51 @@ ObjOldGraphics::Draw( int nStat, int nMark, bool bSurfSha, bool bSurf, int nAlph
break ;
case OgAtom::VERT :
if ( ! bStartA || bShowAux)
glVertex3fv( iIter->m_fVal) ;
glVertex3fv( Oga.m_fVal) ;
break ;
case OgAtom::BND_FLAG :
if ( ! bStartA || bShowAux)
glEdgeFlag( iIter->m_nFlag) ;
glEdgeFlag( Oga.m_nFlag) ;
break ;
case OgAtom::NORMAL :
if ( ! bStartA || bShowAux)
glNormal3fv( iIter->m_fVal) ;
glNormal3fv( Oga.m_fVal) ;
break ;
case OgAtom::COLOR :
glColor4fv( ( bStdCol ? AdjustColor( iIter->m_fVal, bDark) : fSelMarkCol)) ;
glColor4fv( ( bStdCol ? AdjustColor( Oga.m_fVal, bDark) : fSelMarkCol)) ;
break ;
case OgAtom::MAT_A :
glMaterialfv( GL_FRONT, GL_AMBIENT, ( bStdCol ? iIter->m_fVal : fSelMarkCol)) ;
glMaterialfv( GL_FRONT, GL_AMBIENT, ( bStdCol ? Oga.m_fVal : fSelMarkCol)) ;
break ;
case OgAtom::MAT_D :
glMaterialfv( GL_FRONT, GL_DIFFUSE, ( bStdCol ? iIter->m_fVal : fSelMarkCol)) ;
glMaterialfv( GL_FRONT, GL_DIFFUSE, ( bStdCol ? Oga.m_fVal : fSelMarkCol)) ;
break ;
case OgAtom::MAT_S :
glMaterialfv( GL_FRONT, GL_SPECULAR, ( bStdCol ? iIter->m_fVal : fSelMarkCol)) ;
glMaterialfv( GL_FRONT, GL_SPECULAR, ( bStdCol ? Oga.m_fVal : fSelMarkCol)) ;
break ;
case OgAtom::MAT_SH :
glMaterialf( GL_FRONT, GL_SHININESS, iIter->m_fVal[0]) ;
glMaterialf( GL_FRONT, GL_SHININESS, Oga.m_fVal[0]) ;
break ;
case OgAtom::MAT_B :
glMaterialfv( GL_BACK, GL_AMBIENT_AND_DIFFUSE, ( bStdCol ? iIter->m_fVal : fSelMarkBackCol)) ;
glMaterialfv( GL_BACK, GL_AMBIENT_AND_DIFFUSE, ( bStdCol ? Oga.m_fVal : fSelMarkBackCol)) ;
break ;
case OgAtom::LINE_STIPPLE :
if ( Oga.m_nMode > 0) {
bLineStipple = true ;
glLineStipple( Clamp( Oga.m_nFactor, 1, 256), Clamp( Oga.m_nPattern, 0, 65535)) ;
glEnable( GL_LINE_STIPPLE) ;
}
else {
bLineStipple = false ;
glDisable( GL_LINE_STIPPLE) ;
}
break ;
}
}
if ( bLineStipple) {
bLineStipple = false ;
glDisable( GL_LINE_STIPPLE) ;
}
// se marcato e non superficie in shading, disegno halo
if ( nMark == GDB_MK_ON && ! bSurfSha) {
@@ -349,15 +373,16 @@ ObjOldGraphics::Draw( int nStat, int nMark, bool bSurfSha, bool bSurf, int nAlph
// ciclo di disegno
bool bStartA = false ;
for ( auto iIter = m_ogaVect.begin() ; iIter != m_ogaVect.end() ; ++ iIter) {
switch ( iIter->m_nType) {
bool bLineStipple = false ;
for ( const auto& Oga : m_ogaVect) {
switch ( Oga.m_nType) {
case OgAtom::START :
glBegin( iIter->m_nMode) ;
glBegin( Oga.m_nMode) ;
bStartA = false ;
break ;
case OgAtom::START_A :
if ( bShowAux)
glBegin( iIter->m_nMode) ;
glBegin( Oga.m_nMode) ;
bStartA = true ;
break ;
case OgAtom::END :
@@ -367,16 +392,31 @@ ObjOldGraphics::Draw( int nStat, int nMark, bool bSurfSha, bool bSurf, int nAlph
break ;
case OgAtom::VERT :
if ( ! bStartA || bShowAux)
glVertex3fv( iIter->m_fVal) ;
glVertex3fv( Oga.m_fVal) ;
break ;
case OgAtom::BND_FLAG :
if ( ! bStartA || bShowAux)
glEdgeFlag( iIter->m_nFlag) ;
glEdgeFlag( Oga.m_nFlag) ;
break ;
// non si imposta la normale sono solo curve
// non si impostano i colori, si usa quello di marcatura
case OgAtom::LINE_STIPPLE :
if ( Oga.m_nMode > 0) {
bLineStipple = true ;
glLineStipple( Clamp( Oga.m_nFactor, 1, 256), Clamp( Oga.m_nPattern, 0, 65535)) ;
glEnable( GL_LINE_STIPPLE) ;
}
else {
bLineStipple = false ;
glDisable( GL_LINE_STIPPLE) ;
}
break ;
}
}
if ( bLineStipple) {
bLineStipple = false ;
glDisable( GL_LINE_STIPPLE) ;
}
// ripristino test di depth
glDepthFunc( GL_LEQUAL) ;
}
+21 -10
View File
@@ -1,7 +1,7 @@
//----------------------------------------------------------------------------
// EgalTech 2014-2014
// EgalTech 2014-2023
//----------------------------------------------------------------------------
// File : ObjOldGraphics.h Data : 13.02.14 Versione : 1.5b1
// File : ObjOldGraphics.h Data : 08.07.23 Versione : 2.5g1
// Contenuto : Dichiarazione della classe grafica di un oggetto geometrico.
//
//
@@ -27,7 +27,7 @@ class OgAtom {
public :
enum GrType { NONE = 0, START = 1, START_A = 2, END = 3, VERT = 4, BND_FLAG = 5, NORMAL = 6,
COLOR = 7, MAT_A = 8, MAT_D = 9, MAT_S = 10, MAT_SH = 11, MAT_B = 12} ;
COLOR = 7, MAT_A = 8, MAT_D = 9, MAT_S = 10, MAT_SH = 11, MAT_B = 12, LINE_STIPPLE = 13} ;
public :
GrType m_nType ;
@@ -47,6 +47,10 @@ class OgAtom {
float m_fAlpha ;
} ;
float m_fVal[4] ;
struct {
int m_nFactor ;
int m_nPattern ;
} ;
} ;
} ;
@@ -75,6 +79,7 @@ class ObjOldGraphics : public ObjEGrGraphics
bool AddMaterial( const Color& colAmb, const Color& colDiff,
const Color& colSpec, float fShin) override ;
bool AddBackMaterial( const Color& colAmbDiff) override ;
bool AddLineStipple( int nFactor, int nPattern) override ;
bool AddPoint( const Point3d& ptP, bool bAux = false) override ;
bool AddPoints( const PNTVECTOR& vPnt, bool bAux = false) override ;
bool AddLines( const PNTVECTOR& vPnt, bool bAux = false) override ;
@@ -94,40 +99,46 @@ class ObjOldGraphics : public ObjEGrGraphics
{ try { m_ogaVect.push_back( oga) ; }
catch(...) { return false ; }
return true ; }
bool AddStart( int nMode, bool bAux = false)
bool AddOgaStart( int nMode, bool bAux = false)
{ OgAtom oga ;
oga.m_nType = ( bAux ? OgAtom::START_A : OgAtom::START) ;
oga.m_nMode = nMode ;
return AddOgAtom( oga) ; }
bool AddEnd( void)
bool AddOgaEnd( void)
{ OgAtom oga ;
oga.m_nType = OgAtom::END ;
return AddOgAtom( oga) ; }
bool AddVert3f( const Point3d& ptP)
bool AddOgaVert3f( const Point3d& ptP)
{ OgAtom oga ;
oga.m_nType = OgAtom::VERT ;
oga.m_fX = float( ptP.x) ; oga.m_fY = float( ptP.y) ; oga.m_fZ = float( ptP.z) ;
return AddOgAtom( oga) ; }
bool AddBndFlag( bool bFlag)
bool AddOgaBndFlag( bool bFlag)
{ OgAtom oga ;
oga.m_nType = OgAtom::BND_FLAG ;
oga.m_nFlag = ( bFlag ? TRUE : FALSE) ;
return AddOgAtom( oga) ; }
bool AddNormal3f( const Vector3d& vtN)
bool AddOgaNormal3f( const Vector3d& vtN)
{ OgAtom oga ;
oga.m_nType = OgAtom::NORMAL ;
oga.m_fX = float( vtN.x) ; oga.m_fY = float( vtN.y) ; oga.m_fZ = float( vtN.z) ;
return AddOgAtom( oga) ; }
bool AddColor( float fRed, float fGreen, float fBlue, float fAlpha = 1)
bool AddOgaColor( float fRed, float fGreen, float fBlue, float fAlpha = 1)
{ OgAtom oga ;
oga.m_nType = OgAtom::COLOR ;
oga.m_fRed = fRed ; oga.m_fGreen = fGreen ; oga.m_fBlue = fBlue ; oga.m_fAlpha = fAlpha ;
return AddOgAtom( oga) ; }
bool AddMaterial( OgAtom::GrType nMat, float fRed, float fGreen, float fBlue, float fAlpha = 1)
bool AddOgaMaterial( OgAtom::GrType nMat, float fRed, float fGreen, float fBlue, float fAlpha = 1)
{ OgAtom nga ;
nga.m_nType = nMat ;
nga.m_fRed = fRed ; nga.m_fGreen = fGreen ; nga.m_fBlue = fBlue ; nga.m_fAlpha = fAlpha ;
return AddOgAtom( nga) ; }
bool AddOgaLineStipple( int nFactor, int nPattern)
{ OgAtom oga ;
oga.m_nType = OgAtom::LINE_STIPPLE ;
oga.m_nFactor = nFactor ;
oga.m_nPattern = nPattern ;
return AddOgAtom( oga) ; }
private :
Scene* m_pScene ; // puntatore alla scena
+18 -12
View File
@@ -1,7 +1,7 @@
//----------------------------------------------------------------------------
// EgalTech 2014-2020
// EgalTech 2014-2024
//----------------------------------------------------------------------------
// File : Scene.h Data : 02.01.20 Versione : 2.2a1
// File : Scene.h Data : 09.01.24 Versione : 2.5l7
// Contenuto : Dichiarazione della classe gestione scena.
//
//
@@ -142,6 +142,8 @@ class Scene : public IEGrScene
// Grid
bool SetGridShow( bool bShowGrid, bool bShowFrame) override ;
bool SetGridGeo( double dSnapStep, int nMinLineSstep, int nMajLineSstep, int nExtSstep) override ;
bool SetGridGeoAdv( double dSnapStep, int nMinLineSstep, int nMajLineSstep,
double dXmin, double dXmax, double dYmin, double dYmax) override ;
bool SetGridColor( Color colMinLine, Color colMajLine) override ;
void GetGridParam( double& dSnapStep, int& nExtStep) const override ;
bool GetShowGrid() override ;
@@ -204,26 +206,26 @@ class Scene : public IEGrScene
int GetOpenGLver( void)
{ return m_nOglVer ; }
// PointSize - LineWidth
double GetPointSize( void)
double GetPointSize( void) const
{ return m_dPointSize ; }
double GetSelPointSize( void)
double GetSelPointSize( void) const
{ return m_dSelPointSize ; }
double GetMarkPointSize( void)
double GetMarkPointSize( void) const
{ return m_dMarkPointSize ; }
double GetLineWidth( void)
double GetLineWidth( void) const
{ return m_dLineWidth ; }
double GetSelLineWidth( void)
double GetSelLineWidth( void) const
{ return m_dSelLineWidth ; }
double GetMarkLineWidth( void)
double GetMarkLineWidth( void) const
{ return m_dMarkLineWidth ; }
double GetGridLineWidth( void)
double GetGridLineWidth( void) const
{ return m_dGridLineWidth ; }
double GetFrameLineWidth( void)
double GetFrameLineWidth( void) const
{ return m_dFrameLineWidth ; }
// Geometry
Color GetMark( void)
Color GetMark( void) const
{ return m_colMark ; }
Color GetSelSurf( void)
Color GetSelSurf( void) const
{ return m_colSelSurf ; }
private :
@@ -355,6 +357,10 @@ class Scene : public IEGrScene
int m_nMinLineSstep ; // interasse tra due linee minori come numero di passi di snap
int m_nMajLineSstep ; // interasse tra due linee maggiori come numero di passi di snap
int m_nExtSstep ; // estensione della griglia come numero di passi di snap
double m_dGridMinX ; // minima estensione in X della griglia
double m_dGridMaxX ; // massima estensione in X della griglia
double m_dGridMinY ; // minima estensione in Y della griglia
double m_dGridMaxY ; // massima estensione in Y della griglia
Color m_colMinLine ; // colore delle linee minori
Color m_colMajLine ; // colore delle linee maggiori
// Glob Frame
+10 -9
View File
@@ -32,16 +32,13 @@ static const double MIN_EXTENSION = 250 ;
static const double MIN_W_H = 0.01 ;
static const double MIN_ZCLIP_EXT = 25000 ;
//----------------------------------------------------------------------------
IEGrScene*
CreateEGrScene( void)
{
// verifico la chiave e le opzioni
if ( ! GetEGrNetHwKey()) {
if ( ! TestKeyForEGr( GetEGrKey(), 0, GetEGrLogger()))
return nullptr ;
}
if ( ! VerifyKey( 0))
return nullptr ;
// creo l'oggetto
return static_cast<IEGrScene*> ( new(nothrow) Scene) ;
}
@@ -100,10 +97,14 @@ Scene::Scene( void)
// Grid
m_bShowGrid = false ;
m_bShowFrame = false ;
m_dSnapStep = 1 ;
m_nMinLineSstep = 10 ;
m_nMajLineSstep = 100 ;
m_nExtSstep = 500 ;
m_dSnapStep = 10 ;
m_nMinLineSstep = 1 ;
m_nMajLineSstep = 10 ;
m_nExtSstep = 100 ;
m_dGridMinX = -INFINITO ;
m_dGridMaxX = INFINITO ;
m_dGridMinY = -INFINITO ;
m_dGridMaxY = INFINITO ;
m_colMinLine.Set( 160, 160, 160) ;
m_colMajLine.Set( 160, 160, 160) ;
// Global Frame
+2 -6
View File
@@ -202,12 +202,8 @@ Scene::CalcDirUp( void)
// direzione perpendicolare giacente nel piano XY
// ( m_vtDirCamera è opposta alla direzione in cui si guarda)
Vector3d vtPerpXY = m_vtDirCamera ^ Z_AX ;
if ( ! vtPerpXY.Normalize()) {
if ( m_vtDirCamera.z < 0)
vtPerpXY = X_AX ;
else
vtPerpXY = - X_AX ;
}
if ( ! vtPerpXY.Normalize())
vtPerpXY = -X_AX ;
// direzione Up
m_vtUp = vtPerpXY ^ m_vtDirCamera ;
m_bUpOk = m_vtUp.Normalize() ;
+25 -16
View File
@@ -276,6 +276,9 @@ Scene::DrawGeoObj( const IGdbIterator& iIter, int nPass, const MdStMkCol& siObj)
// calcolo la grafica
pGraphics->Clear() ;
pGraphics->AddColor( siObj.colObj) ;
int nFactor, nPattern ;
if ( iIter.GetStipple( nFactor, nPattern) && nFactor != 0)
pGraphics->AddLineStipple( nFactor, nPattern) ;
PolyLine PL ;
if ( pVector->GetDrawWithArrowHead( 0.1, 10, PL))
pGraphics->AddPolyLine(PL) ;
@@ -291,6 +294,9 @@ Scene::DrawGeoObj( const IGdbIterator& iIter, int nPass, const MdStMkCol& siObj)
// calcolo la grafica
pGraphics->Clear() ;
pGraphics->AddColor( siObj.colObj) ;
int nFactor, nPattern ;
if ( iIter.GetStipple( nFactor, nPattern) && nFactor != 0)
pGraphics->AddLineStipple( nFactor, nPattern) ;
pGraphics->AddPoint( pPoint->GetPoint()) ;
}
// se riferimento
@@ -301,7 +307,7 @@ Scene::DrawGeoObj( const IGdbIterator& iIter, int nPass, const MdStMkCol& siObj)
return false ;
// aggiorno la grafica (colori speciali)
PolyLine plX, plY, plZ ;
pFrame->GetDrawWithArrowHeads( 10, 0.1, plX, plY, plZ) ;
pFrame->GetDrawWithArrowHeads( 40, 0.1, plX, plY, plZ) ;
pGraphics->Clear() ;
pGraphics->AddColor( RED) ;
pGraphics->AddPolyLine( plX) ;
@@ -321,6 +327,9 @@ Scene::DrawGeoObj( const IGdbIterator& iIter, int nPass, const MdStMkCol& siObj)
pCurve->ApproxWithLines( EPS_SMALL, ANG_TOL_GRAPH_DEG, ICurve::APL_SPECIAL, PL) ;
pGraphics->Clear() ;
pGraphics->AddColor( siObj.colObj) ;
int nFactor, nPattern ;
if ( iIter.GetStipple( nFactor, nPattern) && nFactor != 0)
pGraphics->AddLineStipple( nFactor, nPattern) ;
pGraphics->AddPolyLine( PL) ;
// eventuali segni ausiliari (mark, frecce, ...)
Vector3d vtRef ;
@@ -456,6 +465,8 @@ Scene::DrawGeoObj( const IGdbIterator& iIter, int nPass, const MdStMkCol& siObj)
int nCount = 0 ;
// numero di colori
const int ZMAP_COL = 2 ;
// indicazione se tridexel
bool bIsTriDexel = pZmap->IsTriDexel() ;
// se triangoli da disegnare
if ( ( m_nShowZmap & ZSM_SURF) != 0) {
// definizione materiali
@@ -515,7 +526,7 @@ Scene::DrawGeoObj( const IGdbIterator& iIter, int nPass, const MdStMkCol& siObj)
for ( const auto& Tria : vTria) {
if ( ( j == 0 && Tria.GetGrade() != 0) || ( j == 1 && Tria.GetGrade() == 0))
continue ;
if ( m_bShowTriaAdvanced)
if ( m_bShowTriaAdvanced && bIsTriDexel)
pGraphics->AddTriangle( Tria, Tria.GetTriFlags(), Tria.GetTriNormals()) ;
else
pGraphics->AddTriangle( Tria, TriFlags3d(), TriNormals3d( Tria.GetN())) ;
@@ -637,7 +648,7 @@ Scene::DrawGeoObj( const IGdbIterator& iIter, int nPass, const MdStMkCol& siObj)
POLYLINELIST lstPL ;
if ( pUserObj->GetDrawPolyLines( lstPL)) {
for ( const auto& PL : lstPL)
pGraphics->AddPolyLine( PL, true) ;
pGraphics->AddPolyLine( PL, ( PL.GetTempProp() == 0)) ;
}
}
}
@@ -725,17 +736,15 @@ Scene::DrawGeoObj( const IGdbIterator& iIter, int nPass, const MdStMkCol& siObj)
Frame3d frTxr ;
iIter.GetTextureFrame( frTxr) ;
// creo piano per la S
GLfloat PlaneS[4] ;
PlaneS[0] = GLfloat( frTxr.VersX().x / dTextDimS) ;
PlaneS[1] = GLfloat( frTxr.VersX().y / dTextDimS) ;
PlaneS[2] = GLfloat( frTxr.VersX().z / dTextDimS) ;
PlaneS[3] = GLfloat( - frTxr.VersX() * ( frTxr.Orig() - ORIG) / dTextDimS) ;
GLfloat PlaneS[4] { GLfloat( frTxr.VersX().x / dTextDimS),
GLfloat( frTxr.VersX().y / dTextDimS),
GLfloat( frTxr.VersX().z / dTextDimS),
GLfloat( -frTxr.VersX() * ( frTxr.Orig() - ORIG) / dTextDimS)} ;
// creo piano per la T
GLfloat PlaneT[4] ;
PlaneT[0] = GLfloat( frTxr.VersY().x / dTextDimT) ;
PlaneT[1] = GLfloat( frTxr.VersY().y / dTextDimT) ;
PlaneT[2] = GLfloat( frTxr.VersY().z / dTextDimT) ;
PlaneT[3] = GLfloat( - frTxr.VersY() * ( frTxr.Orig() - ORIG) / dTextDimT) ;
GLfloat PlaneT[4] { GLfloat( frTxr.VersY().x / dTextDimT),
GLfloat( frTxr.VersY().y / dTextDimT),
GLfloat( frTxr.VersY().z / dTextDimT),
GLfloat( -frTxr.VersY() * ( frTxr.Orig() - ORIG) / dTextDimT)} ;
// setto generazione automatica coordinate S e T per texture
glTexGeni( GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR) ;
glTexGeni( GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR) ;
@@ -965,18 +974,18 @@ static bool
CalcCurveConnectingLines( const PolyLine& plCrv, const Vector3d& vtTh, bool bDense, PNTVECTOR& vPnt)
{
// assegno coefficiente
double dDelta = ( bDense ? 0.25 : 1) ;
double dDelta = ( bDense ? 0.25 : 0.5) ;
// ciclo per creare i segmenti di raccordo
double dU, dUprev = - dDelta ;
vPnt.reserve( 5) ;
for ( bool bFound = plCrv.GetFirstU( dU) ; bFound ; bFound = plCrv.GetNextU( dU)) {
if ( ( dU - dUprev) > dDelta - EPS_PARAM) {
if ( ( dU - dUprev) > dDelta - EPS_PARAM || fmod( dU, 1.) < EPS_PARAM) {
Point3d ptP ;
plCrv.GetCurrPoint( ptP) ;
vPnt.push_back( ptP) ;
ptP += vtTh ;
vPnt.push_back( ptP) ;
dUprev += dDelta ;
dUprev = dU ;
}
}
return true ;
+120 -53
View File
@@ -20,6 +20,9 @@
using namespace std ;
//--------------------------- Constants --------------------------------------
const double MIN_SNAP_STEP = 0.1 ;
//----------------------------------------------------------------------------
bool
Scene::SetGridShow( bool bShowGrid, bool bShowFrame)
@@ -33,11 +36,41 @@ Scene::SetGridShow( bool bShowGrid, bool bShowFrame)
bool
Scene::SetGridGeo( double dSnapStep, int nMinLineSstep, int nMajLineSstep, int nExtSstep)
{
const double MIN_SNAP_STEP = 0.1 ;
m_dSnapStep = max( abs( dSnapStep), MIN_SNAP_STEP) ;
m_nMinLineSstep = abs( nMinLineSstep) ;
m_nMajLineSstep = max( abs( nMajLineSstep), m_nMinLineSstep) ;
if ( dSnapStep > 0)
m_dSnapStep = max( dSnapStep, MIN_SNAP_STEP) ;
if ( nMinLineSstep > 0)
m_nMinLineSstep = nMinLineSstep ;
if ( nMajLineSstep > 0)
m_nMajLineSstep = max( nMajLineSstep, m_nMinLineSstep) ;
m_nExtSstep = max( abs( nExtSstep), m_nMajLineSstep) ;
m_dGridMinX = -INFINITO ;
m_dGridMaxX = INFINITO ;
m_dGridMinY = -INFINITO ;
m_dGridMaxY = INFINITO ;
return true ;
}
//----------------------------------------------------------------------------
bool
Scene::SetGridGeoAdv( double dSnapStep, int nMinLineSstep, int nMajLineSstep,
double dXmin, double dXmax, double dYmin, double dYmax)
{
if ( dSnapStep > 0)
m_dSnapStep = max( dSnapStep, MIN_SNAP_STEP) ;
if ( nMinLineSstep > 0)
m_nMinLineSstep = nMinLineSstep ;
if ( nMajLineSstep > 0)
m_nMajLineSstep = max( nMajLineSstep, m_nMinLineSstep) ;
if ( dXmin > dXmax)
swap( dXmin, dXmax) ;
if ( dYmin > dYmax)
swap( dYmin, dYmax) ;
int nExtSstep = int( ceil( max( max( abs( dXmin), abs( dYmin)), max( abs( dXmax), abs( dYmax))) / m_dSnapStep)) ;
m_nExtSstep = max( abs( nExtSstep), m_nMajLineSstep) ;
m_dGridMinX = dXmin ;
m_dGridMaxX = dXmax ;
m_dGridMinY = dYmin ;
m_dGridMaxY = dYmax ;
return true ;
}
@@ -89,6 +122,10 @@ Scene::DrawGrid( void)
// semi-estensione della griglia
float dExt = float( m_nExtSstep * m_dSnapStep) ;
float dExtMinX = max( float( m_dGridMinX), -dExt) ;
float dExtMaxX = min( float( m_dGridMaxX), dExt) ;
float dExtMinY = max( float( m_dGridMinY), -dExt) ;
float dExtMaxY = min( float( m_dGridMaxY), dExt) ;
// abbassamento in Z per evitare sovrapposizioni con geometria
const float Z_DOWN = float( - 0.01) ;
@@ -105,18 +142,26 @@ Scene::DrawGrid( void)
// se non si sovrappongono alle maggiori
if ( ( i % m_nMajLineSstep) != 0) {
float dPos = float( i * m_dSnapStep) ;
// X +
glVertex3f( dPos, - dExt, Z_DOWN) ;
glVertex3f( dPos, dExt, Z_DOWN) ;
// X -
glVertex3f( - dPos, - dExt, Z_DOWN) ;
glVertex3f( - dPos, dExt, Z_DOWN) ;
// Y +
glVertex3f( - dExt, dPos, Z_DOWN) ;
glVertex3f( dExt, dPos, Z_DOWN) ;
// Y -
glVertex3f( - dExt, - dPos, Z_DOWN) ;
glVertex3f( dExt, - dPos, Z_DOWN) ;
// X +
if ( dPos >= dExtMinX && dPos <= dExtMaxX) {
glVertex3f( dPos, dExtMinY, Z_DOWN) ;
glVertex3f( dPos, dExtMaxY, Z_DOWN) ;
}
// X -
if ( -dPos >= dExtMinX && -dPos <= dExtMaxX) {
glVertex3f( -dPos, dExtMinY, Z_DOWN) ;
glVertex3f( -dPos, dExtMaxY, Z_DOWN) ;
}
// Y +
if ( dPos >= dExtMinY && dPos <= dExtMaxY) {
glVertex3f( dExtMinX, dPos, Z_DOWN) ;
glVertex3f( dExtMaxX, dPos, Z_DOWN) ;
}
// Y -
if ( -dPos >= dExtMinY && -dPos <= dExtMaxY) {
glVertex3f( dExtMinX, -dPos, Z_DOWN) ;
glVertex3f( dExtMaxX, -dPos, Z_DOWN) ;
}
}
}
glEnd() ;
@@ -129,50 +174,68 @@ Scene::DrawGrid( void)
glColor3f( m_colMajLine.GetRed(), m_colMajLine.GetGreen(), m_colMajLine.GetBlue()) ;
for ( int i = min( nCoeff * m_nMajLineSstep, m_nExtSstep) ; i <= m_nExtSstep ; i += nCoeff * m_nMajLineSstep) {
float dPos = float( i * m_dSnapStep) ;
// X +
glVertex3f( dPos, - dExt, Z_DOWN) ;
glVertex3f( dPos, dExt, Z_DOWN) ;
// X -
glVertex3f( - dPos, - dExt, Z_DOWN) ;
glVertex3f( - dPos, dExt, Z_DOWN) ;
// Y +
glVertex3f( - dExt, dPos, Z_DOWN) ;
glVertex3f( dExt, dPos, Z_DOWN) ;
// Y -
glVertex3f( - dExt, - dPos, Z_DOWN) ;
glVertex3f( dExt, - dPos, Z_DOWN) ;
// X +
if ( dPos >= dExtMinX && dPos <= dExtMaxX) {
glVertex3f( dPos, dExtMinY, Z_DOWN) ;
glVertex3f( dPos, dExtMaxY, Z_DOWN) ;
}
// X -
if ( -dPos >= dExtMinX && -dPos <= dExtMaxX) {
glVertex3f( -dPos, dExtMinY, Z_DOWN) ;
glVertex3f( -dPos, dExtMaxY, Z_DOWN) ;
}
// Y +
if ( dPos >= dExtMinY && dPos <= dExtMaxY) {
glVertex3f( dExtMinX, dPos, Z_DOWN) ;
glVertex3f( dExtMaxX, dPos, Z_DOWN) ;
}
// Y -
if ( -dPos >= dExtMinY && -dPos <= dExtMaxY) {
glVertex3f( dExtMinX, -dPos, Z_DOWN) ;
glVertex3f( dExtMaxX, -dPos, Z_DOWN) ;
}
}
glEnd() ;
}
// se richiesto, disegno assi del frame
if ( m_bShowFrame) {
// calcolo lunghezza asse Z
// calcolo lunghezza asse Z
GLint Viewport[4] ;
glGetIntegerv(GL_VIEWPORT, Viewport) ;
const double LEN_AX = 28 ;
double dLenZ = LEN_AX * ( 2 * m_dHalfWidth) / Viewport[2] ;
float fLenZ = float( min( m_dSnapStep, dLenZ)) ;
glBegin( GL_LINES) ;
// asse X+
glColor3f( 0.8f, 0, 0) ;
glVertex3f( 0, 0, Z_DOWN) ;
glVertex3f( dExt, 0, Z_DOWN) ;
// asse Y+
glColor3f( 0, 0.8f, 0) ;
glVertex3f( 0, 0, Z_DOWN) ;
glVertex3f( 0, dExt, Z_DOWN) ;
// asse Z+
glColor3f( 0, 0, 0.8f) ;
glVertex3f( 0, 0, Z_DOWN) ;
glVertex3f( 0, 0, fLenZ) ;
// se richiesta griglia, assi X- e Y-
// asse X+
if ( 0 >= dExtMinY && 0 <= dExtMaxY && 0 >= dExtMinY) {
glColor3f( 0.8f, 0, 0) ;
glVertex3f( max( 0.0f, dExtMinX), 0, Z_DOWN) ;
glVertex3f( dExtMaxX, 0, Z_DOWN) ;
}
// asse Y+
if ( 0 >= dExtMinX && 0 <= dExtMaxX && 0 <= dExtMaxY) {
glColor3f( 0, 0.8f, 0) ;
glVertex3f( 0, max( 0.0f, dExtMinY), Z_DOWN) ;
glVertex3f( 0, dExtMaxY, Z_DOWN) ;
}
// asse Z+
if ( 0 >= dExtMinX && 0 <= dExtMaxX && 0 >= dExtMinY && 0 <= dExtMaxY) {
glColor3f( 0, 0, 0.8f) ;
glVertex3f( 0, 0, Z_DOWN) ;
glVertex3f( 0, 0, fLenZ) ;
}
// se richiesta griglia, assi X- e Y-
if ( m_bShowGrid) {
glColor3f( m_colMajLine.GetRed(), m_colMajLine.GetGreen(), m_colMajLine.GetBlue()) ;
glVertex3f( 0, 0, Z_DOWN) ;
glVertex3f( -dExt, 0, Z_DOWN) ;
glVertex3f( 0, 0, Z_DOWN) ;
glVertex3f( 0, -dExt, Z_DOWN) ;
if ( 0 >= dExtMinY && 0 <= dExtMaxY && 0 >= dExtMinX) {
glVertex3f( min( 0.0f, dExtMaxX), 0, Z_DOWN) ;
glVertex3f( dExtMinX, 0, Z_DOWN) ;
}
if ( 0 >= dExtMinX && 0 <= dExtMaxX && 0 >= dExtMinY) {
glVertex3f( 0, min( 0.0f, dExtMaxY), Z_DOWN) ;
glVertex3f( 0, dExtMinY, Z_DOWN) ;
}
}
glEnd() ;
}
@@ -180,12 +243,16 @@ Scene::DrawGrid( void)
else if ( m_bShowGrid) {
glBegin( GL_LINES) ;
glColor3f( m_colMajLine.GetRed(), m_colMajLine.GetGreen(), m_colMajLine.GetBlue()) ;
// asse X
glVertex3f( - dExt, 0, Z_DOWN) ;
glVertex3f( dExt, 0, Z_DOWN) ;
// asse Y
glVertex3f( 0, - dExt, Z_DOWN) ;
glVertex3f( 0, dExt, Z_DOWN) ;
// asse X
if ( 0 >= dExtMinY && 0 <= dExtMaxY) {
glVertex3f( dExtMinX, 0, Z_DOWN) ;
glVertex3f( dExtMaxX, 0, Z_DOWN) ;
}
// asse Y
if ( 0 >= dExtMinX && 0 <= dExtMaxX) {
glVertex3f( 0, dExtMinY, Z_DOWN) ;
glVertex3f( 0, dExtMaxY, Z_DOWN) ;
}
glEnd() ;
}
@@ -211,4 +278,4 @@ bool
Scene::GetShowGrid()
{
return m_bShowGrid ;
}
}