Include :

- modifiche interfacce
- aggiunto manager esecutori.
This commit is contained in:
Dario Sassi
2014-03-23 12:39:06 +00:00
parent 6db5b747aa
commit 82b2fcf8ae
11 changed files with 131 additions and 41 deletions
+21 -20
View File
@@ -1,7 +1,7 @@
//----------------------------------------------------------------------------
// EgalTech 2014-2014
//----------------------------------------------------------------------------
// File : EGkColor.h Data : 24.02.14 Versione : 1.5b6
// File : EGkColor.h Data : 24.02.14 Versione : 1.5c9
// Contenuto : Implementazione della classe Color.
//
//
@@ -24,10 +24,10 @@
#endif
//-----------------------------------------------------------------------------
static const int MAX_RGB = 255 ;
static const int MAX_ALPHA = 100 ;
static const float INV_MAX_RGB = 1 / float( MAX_RGB) ;
static const float INV_MAX_ALPHA = 1 / float( MAX_ALPHA) ;
const int MAX_RGB = 255 ;
const int MAX_ALPHA = 100 ;
const float INV_MAX_RGB = 1 / float( MAX_RGB) ;
const float INV_MAX_ALPHA = 1 / float( MAX_ALPHA) ;
//-----------------------------------------------------------------------------
class Color
@@ -83,25 +83,26 @@ class Color
//----------------------------------------------------------------------------
// Colori predefiniti
//----------------------------------------------------------------------------
const Color BLACK( 0, 0, 0) ;
const Color GRAY( 128, 128, 128) ;
const Color LGRAY( 192, 192, 192) ;
const Color WHITE( 255, 255, 255) ;
const Color LGRAY( 192, 192, 192) ;
const Color GRAY( 128, 128, 128) ;
const Color BLACK( 0, 0, 0) ;
const Color RED( 255, 0, 0) ;
const Color GREEN( 0, 255, 0) ;
const Color BLUE( 0, 0, 255) ;
const Color CYAN( 0, 255, 255) ;
const Color MAGENTA( 255, 0, 255) ;
const Color MAROON( 128, 0, 0) ;
const Color YELLOW( 255, 255, 0) ;
const Color BROWN( 128, 64, 0) ;
const Color OLIVE( 128, 128, 0) ;
const Color LIME( 0, 255, 0) ;
const Color GREEN( 0, 128, 0) ;
const Color AQUA( 0, 255, 255) ;
const Color TEAL( 0, 128, 128) ;
const Color BLUE( 0, 0, 255) ;
const Color NAVY( 0, 0, 128) ;
const Color FUCHSIA( 255, 0, 255) ;
const Color PURPLE( 128, 0, 128) ;
const Color ORANGE( 255, 128, 0) ;
const Color LRED( 255, 128, 128) ;
const Color LGREEN( 128, 255, 128) ;
const Color LBLUE( 128, 128, 255) ;
const Color LCYAN( 128, 255, 255) ;
const Color LMAGENTA( 255, 128, 255) ;
const Color ORANGE( 255, 165, 0) ;
const Color BROWN( 150, 75, 0) ;
//----------------------------------------------------------------------------
EGK_EXPORT bool GetStdColor( const std::string& sName, Color& cCol) ;
EGK_EXPORT bool GetNameOfStdColor( const Color& cCol, std::string& sName) ;
EGK_EXPORT bool GetNameOfStdColor( Color cCol, std::string& sName) ;
EGK_EXPORT Color GetOppositeColor( Color cCol) ;
+13 -9
View File
@@ -25,19 +25,23 @@ enum GdbType { GDB_TY_NONE = 0,
GDB_TY_GROUP = 2} ;
//----------------- Costanti livello oggetti del DB geometrico -----------------
enum GdbLevel { GDB_LV_USER = 0,
GDB_LV_SYSTEM = 1,
GDB_LV_TEMP = 2} ;
enum GdbLevel { GDB_LV_USER = 1,
GDB_LV_SYSTEM = 2,
GDB_LV_TEMP = 3} ;
//----------------- Costanti modo oggetti del DB geometrico --------------------
enum GdbMode { GDB_MD_STD = 0,
GDB_MD_LOCKED = 1,
GDB_MD_HIDDEN = 2} ;
enum GdbMode { GDB_MD_STD = 1,
GDB_MD_LOCKED = 2,
GDB_MD_HIDDEN = 3} ;
//----------------- Costanti stato oggetti del DB geometrico -------------------
enum GdbStatus { GDB_ST_ON = 0,
GDB_ST_SEL = 1,
GDB_ST_OFF = 2} ;
enum GdbStatus { GDB_ST_OFF = 0,
GDB_ST_ON = 1,
GDB_ST_SEL = 2} ;
//----------------- Costanti marcatura oggetti del DB geometrico ---------------
enum GdbMark { GDB_MK_OFF = 0,
GDB_MK_ON = 1} ;
//----------------- Costanti materiale oggetti del DB geometrico ---------------
enum GdbMaterial { GDB_MT_COLOR = -1,
+14
View File
@@ -70,3 +70,17 @@ AdjustStatusWithMode( int nObjStat, int nObjMode)
case GDB_MD_HIDDEN : return GDB_ST_OFF ;
}
}
//----------------- Funzioni per marcatura di oggetti --------------------------
// per combinare la marcatura del padre con la propria
inline int
CalcMark( int nObjMark, int nParentMark)
{
// se oggetto e padre OFF tale rimane
if ( nObjMark == GDB_MK_OFF && nParentMark == GDB_MK_OFF)
return GDB_MK_OFF ;
return GDB_MK_ON ;
}
// ovviamente la marcatura si combina con lo stato, nel senso che un oggetto
// non visibile non viene nemmeno marcato
+4
View File
@@ -61,6 +61,10 @@ class __declspec( novtable) IGdbIterator
virtual bool RevertStatus( void) = 0 ;
virtual bool GetStatus( int& nStat) const = 0 ;
virtual bool GetCalcStatus( int& nStat) const = 0 ;
virtual bool SetMark( void) = 0 ;
virtual bool ResetMark( void) = 0 ;
virtual bool GetMark( int& nMark) const = 0 ;
virtual bool GetCalcMark( int& nMark) const = 0 ;
virtual bool SetMaterial( int nMat) = 0 ;
virtual bool SetMaterial( Color cCol) = 0 ;
virtual bool GetMaterial( int& nMat) const = 0 ;
+15
View File
@@ -64,6 +64,17 @@ class __declspec( novtable) IGeomDB
virtual bool ScaleGlob( int nId, const Frame3d& frRef, double dCoeffX, double dCoeffY, double dCoeffZ) = 0 ;
virtual bool Mirror( int nId, const Point3d& ptOn, const Vector3d& vtNorm) = 0 ;
virtual bool MirrorGlob( int nId, const Point3d& ptOn, const Vector3d& vtNorm) = 0 ;
// selection
virtual bool SelectObj( int nId) = 0 ;
virtual bool DeselectObj( int nId) = 0 ;
virtual bool SelectGroupObjs( int nId) = 0 ;
virtual bool DeselectGroupObjs( int nId) = 0 ;
virtual bool IsSelectedObj( int nId) const = 0 ;
virtual int GetSelectedObjNbr( void) const = 0 ;
virtual int GetFirstSelectedObj( void) const = 0 ;
virtual int GetNextSelectedObj( void) const = 0 ;
virtual bool ClearSelection( void) = 0 ;
// attributes
virtual bool DumpAttributes( int nId, std::string& sOut, const char* szNewLine) const = 0 ;
virtual bool SetLevel( int nId, int nLevel) = 0 ;
virtual bool RevertLevel( int nId) = 0 ;
@@ -77,6 +88,10 @@ class __declspec( novtable) IGeomDB
virtual bool RevertStatus( int nId) = 0 ;
virtual bool GetStatus( int nId, int& nStat) const = 0 ;
virtual bool GetCalcStatus( int nId, int& nStat) const = 0 ;
virtual bool SetMark( int nId) = 0 ;
virtual bool ResetMark( int nId) = 0 ;
virtual bool GetMark( int nId, int& nMark) const = 0 ;
virtual bool GetCalcMark( int nId, int& nMark) const = 0 ;
virtual bool SetDefaultMaterial( Color cCol) = 0 ;
virtual bool GetDefaultMaterial( Color& cCol) const = 0 ;
virtual bool SetMaterial( int nId, int nMat) = 0 ;
+1 -1
View File
@@ -92,7 +92,7 @@ ToString( const Frame3d& frF, int nPrecP = 6, int nPrecV = 9)
sBuff += ToString( frF.VersZ().z, nPrecV) ;
return sBuff ; }
inline const std::string
ToString( const Color& cCol)
ToString( Color cCol)
{ std::string sBuff ;
sBuff.reserve( 32) ;
sBuff += ToString( cCol.GetIntRed()) ;
-3
View File
@@ -24,9 +24,6 @@
#define EGN_EXPORT __declspec( dllimport)
#endif
//----------------------------------------------------------------------------
typedef std::vector<std::string> STRVECTOR ;
//----------------------------------------------------------------------------
inline std::string&
TrimLeft( std::string& sString, const char* szTarget = " \t\r\n")
+2 -1
View File
@@ -45,7 +45,7 @@ class IEGrScene
virtual std::string GetPixelFormatInfo( void) = 0 ;
virtual bool RedrawWindow( void) = 0 ;
virtual bool Reshape( int nW, int nH) = 0 ;
virtual bool SetBackground( Color BackTop, Color BackBottom) = 0 ;
virtual bool SetBackground( Color colBackTop, Color colBackBottom) = 0 ;
virtual bool Prepare( void) = 0 ;
virtual bool Draw( void) = 0 ;
virtual bool Project( const Point3d& ptWorld, Point3d& ptView) = 0 ;
@@ -68,6 +68,7 @@ class IEGrScene
// Geometry
virtual bool SetExtension( const BBox3d& b3Ext) = 0 ;
virtual bool UpdateExtension( void) = 0 ;
virtual bool SetMark( Color colMark) = 0 ;
// Aux
virtual bool SetWinRectAttribs( bool bOutline, Color WRcol) = 0 ;
virtual bool SetWinRect( const Point3d& ptWinRectP1, const Point3d& ptWinRectP2) = 0 ;
+3 -4
View File
@@ -1,7 +1,7 @@
//----------------------------------------------------------------------------
// EgalTech 2013-2013
// EgalTech 2013-2014
//----------------------------------------------------------------------------
// File : EgnCmdExecutor.h Data : 25.11.13 Versione : 1.3a1
// File : EgnCmdExecutor.h Data : 21.03.14 Versione : 1.5c3
// Contenuto : Dichiarazione della interfaccia ICmdExecutor.
//
//
@@ -22,7 +22,6 @@ class __declspec( novtable) ICmdExecutor
{
public :
virtual bool SetCmdParser( ICmdParser* pParser) = 0 ;
virtual bool AddExecutor( ICmdExecutor* pOtherExec) = 0 ;
virtual bool AddStandardVariables( void) = 0 ;
virtual bool Execute( const std::string& sCmd1, const std::string& sCmd2, const STRVECTOR& vsParams) = 0 ;
virtual int Execute( const std::string& sCmd1, const std::string& sCmd2, const STRVECTOR& vsParams) = 0 ;
} ;
+5 -3
View File
@@ -31,13 +31,15 @@ class __declspec( novtable) ICmdParser
{
public :
virtual ~ICmdParser( void) {}
virtual bool Init( ICmdExecutor* pCmdExec) = 0 ;
virtual bool Run( const std::string& sCmdFile, bool bIsolated = true) = 0 ;
virtual bool ExecLine( const std::string& sCmdLine, bool bIsolated = false) = 0 ;
virtual bool Init( void) = 0 ;
virtual bool SetExecutor( ICmdExecutor* pCmdExec) = 0 ;
virtual bool AddExecutor( ICmdExecutor* pCmdExec) = 0 ;
virtual bool AddVariable( const std::string& sName, int nVal) = 0 ;
virtual bool SetVariable( const std::string& sName, int nVal) = 0 ;
virtual bool GetVariable( const std::string& sName, int& nVal) = 0 ;
virtual bool RemoveVariable( const std::string& sName) = 0 ;
virtual bool Run( const std::string& sCmdFile, bool bIsolated = true) = 0 ;
virtual bool ExecLine( const std::string& sCmdLine, bool bIsolated = false) = 0 ;
} ;
//-----------------------------------------------------------------------------
+53
View File
@@ -0,0 +1,53 @@
//----------------------------------------------------------------------------
// EgalTech 2014-2014
//----------------------------------------------------------------------------
// File : EgtExecMgr.h Data : 21.03.14 Versione : 1.5c3
// Contenuto : Classe ExecManager.
// Per facilitare l'implementazione di ICmdExecutor.
//
//
// Modifiche : 21.03.14 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
#pragma once
#include <string>
#include <unordered_map>
//----------------------------------------------------------------------------
enum { ER_ERR = 0, ER_OK = 1, ER_MISSING = 2 } ;
//----------------------------------------------------------------------------
template <class T>
class ExecManager
{
public :
typedef bool ( T::*Exec) ( const std::string& sCmd2, const STRVECTOR& vsParams) ;
public :
bool Init( int nBuckets)
{ m_pExecMap.clear() ;
m_pExecMap.rehash( nBuckets) ;
return true ; }
bool Insert( const std::string& sName, Exec eFunc)
{ return m_pExecMap.insert( std::pair< std::string, Exec>( sName, eFunc)).second ; }
int Execute( T& Executor, const std::string& sCmd1, const std::string& sCmd2, const STRVECTOR& vsParams)
{ KeyExecMap::iterator Iter = m_pExecMap.find( sCmd1) ;
if ( Iter != m_pExecMap.end() && (Iter->second) != nullptr) {
if ( ( Executor.*(Iter->second))( sCmd2, vsParams))
return ER_OK ;
else
return ER_ERR ;
}
else
return ER_MISSING ; }
private :
typedef std::unordered_map< std::string, Exec> KeyExecMap ;
KeyExecMap m_pExecMap ;
} ;