From 82b2fcf8ae2875992e2ff0699be1c1aceb26e7f0 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Sun, 23 Mar 2014 12:39:06 +0000 Subject: [PATCH] Include : - modifiche interfacce - aggiunto manager esecutori. --- EGkColor.h | 41 ++++++++++++++++++----------------- EGkGdbConst.h | 22 +++++++++++-------- EGkGdbFunct.h | 14 ++++++++++++ EGkGdbIterator.h | 4 ++++ EGkGeomDB.h | 15 +++++++++++++ EGkStringUtils3d.h | 2 +- EGnStringUtils.h | 3 --- EGrScene.h | 3 ++- EgnCmdExecutor.h | 7 +++--- EgnCmdParser.h | 8 ++++--- EgtExecMgr.h | 53 ++++++++++++++++++++++++++++++++++++++++++++++ 11 files changed, 131 insertions(+), 41 deletions(-) create mode 100644 EgtExecMgr.h diff --git a/EGkColor.h b/EGkColor.h index a9da744..613da03 100644 --- a/EGkColor.h +++ b/EGkColor.h @@ -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) ; \ No newline at end of file diff --git a/EGkGdbConst.h b/EGkGdbConst.h index 55864b7..a2fafc7 100644 --- a/EGkGdbConst.h +++ b/EGkGdbConst.h @@ -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, diff --git a/EGkGdbFunct.h b/EGkGdbFunct.h index a832a56..4d42448 100644 --- a/EGkGdbFunct.h +++ b/EGkGdbFunct.h @@ -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 \ No newline at end of file diff --git a/EGkGdbIterator.h b/EGkGdbIterator.h index 39c2afb..14ecb08 100644 --- a/EGkGdbIterator.h +++ b/EGkGdbIterator.h @@ -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 ; diff --git a/EGkGeomDB.h b/EGkGeomDB.h index 4aaabb6..d9c09d4 100644 --- a/EGkGeomDB.h +++ b/EGkGeomDB.h @@ -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 ; diff --git a/EGkStringUtils3d.h b/EGkStringUtils3d.h index b6ac0fd..6eea11a 100644 --- a/EGkStringUtils3d.h +++ b/EGkStringUtils3d.h @@ -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()) ; diff --git a/EGnStringUtils.h b/EGnStringUtils.h index f5652de..90373ec 100644 --- a/EGnStringUtils.h +++ b/EGnStringUtils.h @@ -24,9 +24,6 @@ #define EGN_EXPORT __declspec( dllimport) #endif -//---------------------------------------------------------------------------- -typedef std::vector STRVECTOR ; - //---------------------------------------------------------------------------- inline std::string& TrimLeft( std::string& sString, const char* szTarget = " \t\r\n") diff --git a/EGrScene.h b/EGrScene.h index d91f6cc..13902b1 100644 --- a/EGrScene.h +++ b/EGrScene.h @@ -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 ; diff --git a/EgnCmdExecutor.h b/EgnCmdExecutor.h index 1595665..0f7181f 100644 --- a/EgnCmdExecutor.h +++ b/EgnCmdExecutor.h @@ -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 ; } ; diff --git a/EgnCmdParser.h b/EgnCmdParser.h index d3f6f2b..34d2e53 100644 --- a/EgnCmdParser.h +++ b/EgnCmdParser.h @@ -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 ; } ; //----------------------------------------------------------------------------- diff --git a/EgtExecMgr.h b/EgtExecMgr.h new file mode 100644 index 0000000..92ad538 --- /dev/null +++ b/EgtExecMgr.h @@ -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 +#include + + +//---------------------------------------------------------------------------- +enum { ER_ERR = 0, ER_OK = 1, ER_MISSING = 2 } ; + +//---------------------------------------------------------------------------- +template +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 ; +} ;