EgtGeomKernel 1.5c6 :

- aggiunta gestione attributi Level, Mode e Status
- aggiunti comandi per assegnarli.
This commit is contained in:
Dario Sassi
2014-03-14 18:38:48 +00:00
parent 01ce6ea4a4
commit e2c8e72e22
13 changed files with 770 additions and 80 deletions
+25 -22
View File
@@ -31,35 +31,34 @@ Attribs::Dump( string& sOut, const char* szNewLine) const
// livello
sOut += "Lev=" ;
switch ( m_Data[LEVEL]) {
default : /* LEV_USER */ sOut += "user" ; break ;
case LEV_SYSTEM : sOut += "system" ; break ;
case LEV_TEMP : sOut += "temp" ; break ;
default : /* GDB_LV_USER */ sOut += "user" ; break ;
case GDB_LV_SYSTEM : sOut += "system" ; break ;
case GDB_LV_TEMP : sOut += "temp" ; break ;
}
// modo
sOut += " Mod=" ;
switch ( m_Data[MODE]) {
default : /* MOD_STD */ sOut += "std" ; break ;
case MOD_LOCKED : sOut += "locked" ; break ;
case MOD_HIDDEN : sOut += "hidden" ; break ;
default : /* GDB_MD_STD */ sOut += "std" ; break ;
case GDB_MD_LOCKED : sOut += "locked" ; break ;
case GDB_MD_HIDDEN : sOut += "hidden" ; break ;
}
// stato
sOut += " Sta=" ;
switch ( m_Data[STATUS]) {
default : /* STS_ON */ sOut += "on" ; break ;
case STS_SEL : sOut += "sel" ; break ;
case STS_OFF : sOut += "off" ; break ;
default : /* GDB_ST_ON */ sOut += "on" ; break ;
case GDB_ST_SEL : sOut += "sel" ; break ;
case GDB_ST_OFF : sOut += "off" ; break ;
}
sOut += szNewLine ;
// materiale
sOut += "Mat=" ;
switch ( m_Material) {
case MAT_PARENT : sOut += "by parent" ; break ;
case MAT_COLOR : sOut += "color" ; break ;
case MAT_NULL : sOut += "null" ; break ;
case GDB_MT_COLOR : sOut += "color" ; break ;
case GDB_MT_PARENT : sOut += "by parent" ; break ;
default : sOut += ToString( m_Material) ; break ;
}
// eventuale colore
if ( m_Material != MAT_PARENT && m_Material != MAT_NULL) {
if ( m_Material == GDB_MT_COLOR) {
sOut += " Col=" ;
string sColName ;
if ( GetNameOfStdColor( m_Color, sColName))
@@ -91,8 +90,9 @@ Attribs::Save( ostream& osOut) const
osOut << ToString( m_Data[LEVEL]) << "," ;
// modo
osOut << ToString( m_Data[MODE]) << "," ;
// stato
osOut << ToString( m_Data[STATUS]) << "," ;
// stato (se SEL viene convertito in ON)
int nStat = (( m_Data[STATUS] == GDB_ST_SEL) ? GDB_ST_ON : m_Data[STATUS]) ;
osOut << ToString( nStat) << "," ;
// altro
osOut << ToString( m_Data[OTHER]) << ";" ;
// materiale
@@ -126,11 +126,14 @@ Attribs::Load( Scanner& TheScanner)
// Data (Level,Mode,Status,Other)
if ( ! DataFromString( vsParams[0]))
return false ;
// OldData è inizializzato con Data
for ( int i = 0 ; i < DIM ; ++ i)
m_OldData[i] = m_Data[i] ;
// materiale
int nMat ;
if ( ! FromString( vsParams[1], nMat))
return false ;
m_Material = __max( nMat, MAT_PARENT) ;
m_Material = __max( nMat, GDB_MT_COLOR) ;
// colore
if ( ! FromString( vsParams[2], m_Color))
return false ;
@@ -164,22 +167,22 @@ Attribs::DataFromString( const string& sParam)
int nLev ;
if ( ! FromString( vsParams[0], nLev))
return false ;
m_Data[LEVEL] = CLIP( nLev, LEV_USER, LEV_TEMP) ;
m_Data[LEVEL] = CLIP( nLev, GDB_LV_USER, GDB_LV_TEMP) ;
// modo
int nMode ;
if ( ! FromString( vsParams[1], nMode))
return false ;
m_Data[MODE] = CLIP( nMode, MOD_STD, MOD_HIDDEN) ;
m_Data[MODE] = CLIP( nMode, GDB_MD_STD, GDB_MD_HIDDEN) ;
// stato
int nStat ;
if ( ! FromString( vsParams[2], nStat))
return false ;
m_Data[STATUS] = CLIP( nStat, STS_ON, STS_OFF) ;
m_Data[STATUS] = CLIP( nStat, GDB_ST_ON, GDB_ST_OFF) ;
// altro
int nOther ;
if ( ! FromString( vsParams[3], nOther))
int nOldStatus ;
if ( ! FromString( vsParams[3], nOldStatus))
return false ;
m_Data[OTHER] = CLIP( nOther, 0, 255) ;
m_Data[OTHER] = CLIP( nOldStatus, 0, 255) ;
return true ;
}
+26 -15
View File
@@ -13,6 +13,7 @@
#pragma once
#include "/EgtDev/Include/EGkGdbConst.h"
#include "/EgtDev/Include/EGkColor.h"
#include "/EgtDev/Include/EGnScan.h"
#include "/EgtDev/Include/EGnStringBase.h"
@@ -26,9 +27,11 @@ class Attribs
{
public :
Attribs( void)
{ m_Data[LEVEL] = LEV_USER ; m_Data[MODE] = MOD_STD ;
m_Data[STATUS] = STS_ON ; m_Data[OTHER] = 0 ;
m_Material = MAT_PARENT ; m_Color.Set( 0, 0, 0) ;}
{ m_Data[LEVEL] = GDB_LV_USER ; m_OldData[LEVEL] = m_Data[LEVEL] ;
m_Data[MODE] = GDB_MD_STD ; m_OldData[MODE] = m_Data[MODE] ;
m_Data[STATUS] = GDB_ST_ON ; m_OldData[STATUS] = m_Data[STATUS] ;
m_Data[OTHER] = 0 ; m_OldData[OTHER] = m_Data[OTHER] ;
m_Material = GDB_MT_PARENT ; m_Color.Set() ;}
Attribs* Clone( void) const
{ Attribs* pAttribs ;
// alloco oggetto
@@ -40,24 +43,37 @@ class Attribs
bool Save( std::ostream& osOut) const ;
bool Load( Scanner& TheScanner) ;
void SetLevel( int nLev)
{ m_Data[LEVEL] = CLIP( nLev, LEV_USER, LEV_TEMP) ; }
{ m_OldData[LEVEL] = m_Data[LEVEL] ;
m_Data[LEVEL] = CLIP( nLev, GDB_LV_USER, GDB_LV_TEMP) ; }
void RevertLevel( void)
{ std::swap( m_Data[LEVEL], m_OldData[LEVEL]) ; }
int GetLevel( void) const
{ return m_Data[LEVEL] ; }
void SetMode( int nMode)
{ m_Data[MODE] = CLIP( nMode, MOD_STD, MOD_HIDDEN) ; }
{ m_OldData[MODE] = m_Data[MODE] ;
m_Data[MODE] = CLIP( nMode, GDB_MD_STD, GDB_MD_HIDDEN) ; }
void RevertMode( void)
{ std::swap( m_Data[MODE], m_OldData[MODE]) ; }
int GetMode( void) const
{ return m_Data[MODE] ; }
void SetStatus( int nStat)
{ m_Data[STATUS] = CLIP( nStat, STS_ON, STS_OFF) ; }
void SetStatus( int nStat) // non si conserva il selezionato
{ if ( m_Data[STATUS] != GDB_ST_SEL)
m_OldData[STATUS] = m_Data[STATUS] ;
m_Data[STATUS] = CLIP( nStat, GDB_ST_ON, GDB_ST_OFF) ; }
void RevertStatus( void)
{ if ( m_Data[STATUS] != GDB_ST_SEL)
std::swap( m_Data[STATUS], m_OldData[STATUS]) ;
else
m_Data[STATUS] = m_OldData[STATUS] ; }
int GetStatus( void) const
{ return m_Data[STATUS] ; }
void SetMaterial( int nMat)
{ if ( nMat != MAT_COLOR)
{ if ( nMat >= GDB_MT_PARENT)
m_Material = nMat ; }
int GetMaterial( void) const
{ return m_Material ; }
void SetColor( Color cCol)
{ m_Material = MAT_COLOR ; m_Color = cCol ; }
{ m_Material = GDB_MT_COLOR ; m_Color = cCol ; }
Color GetColor( void) const
{ return m_Color ; }
bool SetName( const std::string& sName) ;
@@ -67,12 +83,6 @@ class Attribs
bool GetInfo( const std::string& sKey, std::string& sVal) const ;
bool RemoveInfo( const std::string& sKey) ;
public :
enum Level { LEV_USER = 0, LEV_SYSTEM = 1, LEV_TEMP = 2} ;
enum Mode { MOD_STD = 0, MOD_LOCKED = 1, MOD_HIDDEN = 2} ;
enum Status { STS_ON = 0, STS_SEL = 1, STS_OFF = 2} ;
enum { MAT_PARENT = -2, MAT_COLOR = -1, MAT_NULL = 0} ;
private :
enum { LEVEL = 0, MODE = 1, STATUS = 2, OTHER = 3, DIM = 4} ;
@@ -83,6 +93,7 @@ class Attribs
private :
unsigned char m_Data[DIM] ;
unsigned char m_OldData[DIM] ;
int m_Material ;
Color m_Color ;
STRLIST m_slInfo ;
BIN
View File
Binary file not shown.
+1
View File
@@ -277,6 +277,7 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
<ClInclude Include="..\Include\EGkDllMain.h" />
<ClInclude Include="..\Include\EGkFrame3d.h" />
<ClInclude Include="..\Include\EGkGdbConst.h" />
<ClInclude Include="..\Include\EGkGdbFunct.h" />
<ClInclude Include="..\Include\EGkGdbIterator.h" />
<ClInclude Include="..\Include\EGkGeoConst.h" />
<ClInclude Include="..\Include\EGkGeoFrame3d.h" />
+3
View File
@@ -329,6 +329,9 @@
<ClInclude Include="..\Include\EGkColor.h">
<Filter>File di intestazione</Filter>
</ClInclude>
<ClInclude Include="..\Include\EGkGdbFunct.h">
<Filter>File di intestazione</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="EgtGeomKernel.rc">
+106 -4
View File
@@ -128,11 +128,17 @@ GdbExecutor::Execute( const string& sCmd1, const string& sCmd2, const STRVECTOR&
return ExecuteCurveBez( sCmd2, vsParams) ;
else if ( sCmd1 == "CC" || sCmd1 == "CURVECOMPO")
return ExecuteCurveCompo( sCmd2, vsParams) ;
else if ( sCmd1 == "LEV" || sCmd1 == "LEVEL")
return ExecuteLevel( sCmd2, vsParams) ;
else if ( sCmd1 == "MOD" || sCmd1 == "MODE")
return ExecuteMode( sCmd2, vsParams) ;
else if ( sCmd1 == "STA" || sCmd1 == "STATUS")
return ExecuteStatus( sCmd2, vsParams) ;
else if ( sCmd1 == "COL" || sCmd1 == "COLOR")
return ExecuteColor( sCmd2, vsParams) ;
else if ( sCmd1 == "NA" || sCmd1 == "NAME")
else if ( sCmd1 == "NAM" || sCmd1 == "NAME")
return ExecuteName( sCmd2, vsParams) ;
else if ( sCmd1 == "INFO")
else if ( sCmd1 == "INF" || sCmd1 == "INFO")
return ExecuteInfo( sCmd2, vsParams) ;
else if ( sCmd1 == "COPY")
return ExecuteCopy( sCmd2, vsParams) ;
@@ -919,6 +925,102 @@ GdbExecutor::GetColorParam( const std::string& sParam, Color& cCol)
}
}
//----------------------------------------------------------------------------
bool
GdbExecutor::ExecuteLevel( const string& sCmd2, const STRVECTOR& vsParams)
{
// devono essere 2 parametri ( Id, Livello)
if ( vsParams.size() != 2)
return false ;
// recupero lista Id
STRVECTOR vsNames ;
if ( ! GetNamesParam( vsParams[0], vsNames))
return false ;
// recupero livello
string sLevel = vsParams[1] ;
ToUpper( sLevel) ;
int nLevel ;
if ( sLevel == "USER")
nLevel = GDB_LV_USER ;
else if ( sLevel == "SYSTEM")
nLevel = GDB_LV_SYSTEM ;
else if ( sLevel == "TEMP")
nLevel = GDB_LV_TEMP ;
else
return false ;
// esecuzione impostazione livello
STRVECTOR::iterator Iter ;
for ( Iter = vsNames.begin() ; Iter != vsNames.end() ; ++Iter) {
if ( ! m_pGDB->SetLevel( GetIdParam( *Iter), nLevel))
return false ;
}
return true ;
}
//----------------------------------------------------------------------------
bool
GdbExecutor::ExecuteMode( const string& sCmd2, const STRVECTOR& vsParams)
{
// devono essere 2 parametri ( Id, Modo)
if ( vsParams.size() != 2)
return false ;
// recupero lista Id
STRVECTOR vsNames ;
if ( ! GetNamesParam( vsParams[0], vsNames))
return false ;
// recupero modo
string sMode = vsParams[1] ;
ToUpper( sMode) ;
int nMode ;
if ( sMode == "STD")
nMode = GDB_MD_STD ;
else if ( sMode == "LOCKED")
nMode = GDB_MD_LOCKED ;
else if ( sMode == "HIDDEN")
nMode = GDB_MD_HIDDEN ;
else
return false ;
// esecuzione impostazione modo
STRVECTOR::iterator Iter ;
for ( Iter = vsNames.begin() ; Iter != vsNames.end() ; ++Iter) {
if ( ! m_pGDB->SetMode( GetIdParam( *Iter), nMode))
return false ;
}
return true ;
}
//----------------------------------------------------------------------------
bool
GdbExecutor::ExecuteStatus( const string& sCmd2, const STRVECTOR& vsParams)
{
// devono essere 2 parametri ( Id, Stato)
if ( vsParams.size() != 2)
return false ;
// recupero lista Id
STRVECTOR vsNames ;
if ( ! GetNamesParam( vsParams[0], vsNames))
return false ;
// recupero stato
string sStat = vsParams[1] ;
ToUpper( sStat) ;
int nStat ;
if ( sStat == "ON")
nStat = GDB_ST_ON ;
else if ( sStat == "SEL")
nStat = GDB_ST_SEL ;
else if ( sStat == "OFF")
nStat = GDB_ST_OFF ;
else
return false ;
// esecuzione impostazione stato
STRVECTOR::iterator Iter ;
for ( Iter = vsNames.begin() ; Iter != vsNames.end() ; ++Iter) {
if ( ! m_pGDB->SetStatus( GetIdParam( *Iter), nStat))
return false ;
}
return true ;
}
//----------------------------------------------------------------------------
bool
GdbExecutor::ExecuteColor( const string& sCmd2, const STRVECTOR& vsParams)
@@ -1499,11 +1601,11 @@ GdbExecutor::OutGroupScl( int nId, int nFlag)
bNext = Iter.GoToFirstInGroup( nId) ;
while ( bNext) {
nGdbType = Iter.GetGdbType() ;
if ( nGdbType == GDB_GEO) {
if ( nGdbType == GDB_TY_GEO) {
if ( ! m_OutScl.PutGeoObj( Iter.GetGeoObj(), nFlag))
return false ;
}
else if ( nGdbType == GDB_GROUP) {
else if ( nGdbType == GDB_TY_GROUP) {
if ( ! OutGroupScl( Iter.GetId(), nFlag))
return false ;
}
+3
View File
@@ -50,6 +50,9 @@ class GdbExecutor : public IGdbExecutor
bool ExecuteCurveArc( const std::string& sCmd2, const STRVECTOR& vsParams) ;
bool ExecuteCurveBez( const std::string& sCmd2, const STRVECTOR& vsParams) ;
bool ExecuteCurveCompo( const std::string& sCmd2, const STRVECTOR& vsParams) ;
bool ExecuteLevel( const std::string& sCmd2, const STRVECTOR& vsParams) ;
bool ExecuteMode( const std::string& sCmd2, const STRVECTOR& vsParams) ;
bool ExecuteStatus( const std::string& sCmd2, const STRVECTOR& vsParams) ;
bool ExecuteColor( const std::string& sCmd2, const STRVECTOR& vsParams) ;
bool ExecuteName( const std::string& sCmd2, const STRVECTOR& vsParams) ;
bool ExecuteInfo( const std::string& sCmd2, const STRVECTOR& vsParams) ;
+148 -5
View File
@@ -189,21 +189,21 @@ GdbIterator::GoToPrev( void)
}
//----------------------------------------------------------------------------
GdbType
int
GdbIterator::GetGdbType( void) const
{
if ( m_pGDB == nullptr || m_pCurrObj == nullptr)
return GDB_NONE ;
return GDB_TY_NONE ;
// se oggetto geometrico
if ( GetGdbGeo( m_pCurrObj) != nullptr)
return GDB_GEO ;
return GDB_TY_GEO ;
// se gruppo
else if ( GetGdbGroup( m_pCurrObj) != nullptr)
return GDB_GROUP ;
return GDB_TY_GROUP ;
// altro
else
return GDB_NONE ;
return GDB_TY_NONE ;
}
//----------------------------------------------------------------------------
@@ -288,6 +288,138 @@ GdbIterator::GetParentId( void) const
//----------------------------------------------------------------------------
// Attributes
//----------------------------------------------------------------------------
bool
GdbIterator::SetLevel( int nLevel)
{
if ( m_pGDB == nullptr || m_pCurrObj == nullptr)
return false ;
// assegno il livello
return m_pCurrObj->SetLevel( nLevel) ;
}
//----------------------------------------------------------------------------
bool
GdbIterator::RevertLevel( void)
{
if ( m_pGDB == nullptr || m_pCurrObj == nullptr)
return false ;
// ripristino il livello precedente
return m_pCurrObj->RevertLevel() ;
}
//----------------------------------------------------------------------------
bool
GdbIterator::GetLevel( int& nLevel) const
{
if ( m_pGDB == nullptr || m_pCurrObj == nullptr)
return false ;
// recupero il livello
return m_pCurrObj->GetLevel( nLevel) ;
}
//----------------------------------------------------------------------------
bool
GdbIterator::GetCalcLevel( int& nLevel) const
{
if ( m_pGDB == nullptr || m_pCurrObj == nullptr)
return false ;
// recupero il livello calcolato
return m_pCurrObj->GetCalcLevel( nLevel) ;
}
//----------------------------------------------------------------------------
bool
GdbIterator::SetMode( int nMode)
{
if ( m_pGDB == nullptr || m_pCurrObj == nullptr)
return false ;
// assegno il modo
return m_pCurrObj->SetMode( nMode) ;
}
//----------------------------------------------------------------------------
bool
GdbIterator::RevertMode( void)
{
if ( m_pGDB == nullptr || m_pCurrObj == nullptr)
return false ;
// ripristino il modo precedente
return m_pCurrObj->RevertMode() ;
}
//----------------------------------------------------------------------------
bool
GdbIterator::GetMode( int& nMode) const
{
if ( m_pGDB == nullptr || m_pCurrObj == nullptr)
return false ;
// recupero il modo
return m_pCurrObj->GetMode( nMode) ;
}
//----------------------------------------------------------------------------
bool
GdbIterator::GetCalcMode( int& nMode) const
{
if ( m_pGDB == nullptr || m_pCurrObj == nullptr)
return false ;
// recupero il modo calcolato
return m_pCurrObj->GetCalcMode( nMode) ;
}
//----------------------------------------------------------------------------
bool
GdbIterator::SetStatus( int nStat)
{
if ( m_pGDB == nullptr || m_pCurrObj == nullptr)
return false ;
// assegno lo stato
return m_pCurrObj->SetStatus( nStat) ;
}
//----------------------------------------------------------------------------
bool
GdbIterator::RevertStatus( void)
{
if ( m_pGDB == nullptr || m_pCurrObj == nullptr)
return false ;
// ripristino lo stato precedente
return m_pCurrObj->RevertStatus() ;
}
//----------------------------------------------------------------------------
bool
GdbIterator::GetStatus( int& nStat) const
{
if ( m_pGDB == nullptr || m_pCurrObj == nullptr)
return false ;
// recupero lo stato
return m_pCurrObj->GetStatus( nStat) ;
}
//----------------------------------------------------------------------------
bool
GdbIterator::GetCalcStatus( int& nStat) const
{
if ( m_pGDB == nullptr || m_pCurrObj == nullptr)
return false ;
// recupero lo stato calcolato
return m_pCurrObj->GetCalcStatus( nStat) ;
}
//----------------------------------------------------------------------------
bool
GdbIterator::SetColor( Color cCol)
@@ -310,6 +442,17 @@ GdbIterator::GetColor( Color& cCol) const
return m_pCurrObj->GetColor( cCol) ;
}
//----------------------------------------------------------------------------
bool
GdbIterator::GetCalcColor( Color& cCol) const
{
if ( m_pGDB == nullptr || m_pCurrObj == nullptr)
return false ;
// recupero il colore calcolato
return m_pCurrObj->GetCalcColor( cCol) ;
}
//----------------------------------------------------------------------------
bool
GdbIterator::SetName( const string& sName)
+14 -1
View File
@@ -32,7 +32,7 @@ class GdbIterator : public IGdbIterator
virtual bool GoToLastInGroup( const IGdbIterator& iIter) ;
virtual bool GoToPrev( void) ;
virtual GdbType GetGdbType( void) const ;
virtual int GetGdbType( void) const ;
virtual IGeoObj* GetGeoObj( void) ;
virtual IGeoFrame3d* GetGeoFrame( void) ;
virtual bool GetGroupFrame( Frame3d& frGlob) const ;
@@ -41,8 +41,21 @@ class GdbIterator : public IGdbIterator
virtual int GetParentId( void) const ;
virtual bool GetGlobFrame( Frame3d& frGlob) const
{ return m_pGDB->GetGroupGlobFrame( GetParentId(), frGlob) ; }
virtual bool SetLevel( int nLevel) ;
virtual bool RevertLevel( void) ;
virtual bool GetLevel( int& nLevel) const ;
virtual bool GetCalcLevel( int& nLevel) const ;
virtual bool SetMode( int nMode) ;
virtual bool RevertMode( void) ;
virtual bool GetMode( int& nMode) const ;
virtual bool GetCalcMode( int& nMode) const ;
virtual bool SetStatus( int nStat) ;
virtual bool RevertStatus( void) ;
virtual bool GetStatus( int& nStat) const ;
virtual bool GetCalcStatus( int& nStat) const ;
virtual bool SetColor( Color cCol) ;
virtual bool GetColor( Color& cCol) const ;
virtual bool GetCalcColor( Color& cCol) const ;
virtual bool SetName( const std::string& sName) ;
virtual bool GetName( std::string& sName) const ;
virtual bool RemoveName( void) ;
+231 -22
View File
@@ -16,6 +16,7 @@
#include "GdbObj.h"
#include "GdbGroup.h"
#include "Attribs.h"
#include "/EgtDev/Include/EGkGdbFunct.h"
#include "/EgtDev/Include/EGnStringUtils.h"
#include <new>
@@ -236,17 +237,216 @@ GdbObj::GetSafeAttribs( void)
return m_pAttribs ;
}
//----------------------------------------------------------------------------
bool
GdbObj::SetLevel( int nLevel)
{
// verifico esistenza (con eventuale creazione) degli attributi
if ( GetSafeAttribs() == nullptr)
return false ;
// assegno il livello
m_pAttribs->SetLevel( nLevel) ;
return true ;
}
//----------------------------------------------------------------------------
bool
GdbObj::RevertLevel( void)
{
// se non ci sono attributi non fa alcunchè
if ( m_pAttribs == nullptr)
return true ;
// ripristina il vecchio livello
m_pAttribs->RevertLevel() ;
return true ;
}
//----------------------------------------------------------------------------
bool
GdbObj::GetLevel( int& nLevel) const
{
// se non ci sono attributi
if ( m_pAttribs == nullptr)
return false ;
// il livello è definito
nLevel = m_pAttribs->GetLevel() ;
return true ;
}
//----------------------------------------------------------------------------
bool
GdbObj::GetCalcLevel( int& nLevel) const
{
// recupero il livello dell'oggetto
int nObjLevel = GDB_LV_USER ;
if ( m_pAttribs != nullptr)
nObjLevel = m_pAttribs->GetLevel() ;
// se il livello è TEMP, non ho bisogno di sapere altro
if ( nObjLevel == GDB_LV_TEMP) {
nLevel = GDB_LV_TEMP ;
return true ;
}
// recupero il livello dell'eventuale padre
int nParentLevel = GDB_LV_USER ;
if ( GetParent() != nullptr)
GetParent()->GetCalcLevel( nParentLevel) ;
// calcolo il livello
nLevel = ::CalcLevel( nObjLevel, nParentLevel) ;
return true ;
}
//----------------------------------------------------------------------------
bool
GdbObj::SetMode( int nMode)
{
// verifico esistenza (con eventuale creazione) degli attributi
if ( GetSafeAttribs() == nullptr)
return false ;
// assegno il modo
m_pAttribs->SetMode( nMode) ;
return true ;
}
//----------------------------------------------------------------------------
bool
GdbObj::RevertMode( void)
{
// se non ci sono attributi non fa alcunchè
if ( m_pAttribs == nullptr)
return true ;
// ripristina il vecchio modo
m_pAttribs->RevertMode() ;
return true ;
}
//----------------------------------------------------------------------------
bool
GdbObj::GetMode( int& nMode) const
{
// se non ci sono attributi
if ( m_pAttribs == nullptr)
return false ;
// il modo è definito
nMode = m_pAttribs->GetMode() ;
return true ;
}
//----------------------------------------------------------------------------
bool
GdbObj::GetCalcMode( int& nMode) const
{
// recupero il modo dell'oggetto
int nObjMode = GDB_MD_STD ;
if ( m_pAttribs != nullptr)
nObjMode = m_pAttribs->GetMode() ;
// se il modo è HIDDEN, non ho bisogno di sapere altro
if ( nObjMode == GDB_MD_HIDDEN) {
nMode = GDB_MD_HIDDEN ;
return true ;
}
// recupero il modo dell'eventuale padre
int nParentMode = GDB_MD_STD ;
if ( GetParent() != nullptr)
GetParent()->GetCalcMode( nParentMode) ;
// calcolo il modo
nMode = ::CalcMode( nObjMode, nParentMode) ;
return true ;
}
//----------------------------------------------------------------------------
bool
GdbObj::SetStatus( int nStat)
{
// verifico esistenza (con eventuale creazione) degli attributi
if ( GetSafeAttribs() == nullptr)
return false ;
// assegno lo stato
m_pAttribs->SetStatus( nStat) ;
return true ;
}
//----------------------------------------------------------------------------
bool
GdbObj::RevertStatus( void)
{
// se non ci sono attributi non fa alcunchè
if ( m_pAttribs == nullptr)
return true ;
// ripristina il vecchio stato
m_pAttribs->RevertStatus() ;
return true ;
}
//----------------------------------------------------------------------------
bool
GdbObj::GetStatus( int& nStat) const
{
// se non ci sono attributi
if ( m_pAttribs == nullptr)
return false ;
// lo stato è definito
nStat = m_pAttribs->GetStatus() ;
return true ;
}
//----------------------------------------------------------------------------
bool
GdbObj::GetCalcStatus( int& nStat, int nLev) const
{
// recupero lo stato dell'oggetto
int nObjStat = GDB_ST_ON ;
if ( m_pAttribs != nullptr)
nObjStat = m_pAttribs->GetStatus() ;
// se lo stato è OFF, non ho bisogno di sapere altro
if ( nObjStat == GDB_ST_OFF) {
nStat = GDB_ST_OFF ;
return true ;
}
// recupero lo stato dell'eventuale padre
int nParentStat = GDB_ST_ON ;
if ( GetParent() != nullptr)
GetParent()->GetCalcStatus( nParentStat, ( nLev + 1)) ;
// calcolo lo stato
nStat = ::CalcStatus( nObjStat, nParentStat) ;
// se sono alla chiamata iniziale, devo aggiustare lo stato con il modo
if ( nLev == 0) {
int nMode = GDB_MD_STD ;
GetCalcMode( nMode) ;
nStat = ::AdjustStatusWithMode( nStat, nMode) ;
}
return true ;
}
//----------------------------------------------------------------------------
bool
GdbObj::SetColor( Color cCol)
{
// recupero gli attributi (se non ci sono, vengono creati)
Attribs* pAttribs = GetSafeAttribs() ;
if ( pAttribs == nullptr)
// verifico esistenza (con eventuale creazione) degli attributi
if ( GetSafeAttribs() == nullptr)
return false ;
// assegno il colore
pAttribs->SetColor( cCol) ;
m_pAttribs->SetColor( cCol) ;
return true ;
}
@@ -256,33 +456,43 @@ GdbObj::GetColor( Color& cCol) const
{
// se non ci sono attributi o ci si deve riferire al padre
if ( m_pAttribs == nullptr ||
m_pAttribs->GetMaterial() == Attribs::MAT_PARENT) {
if ( GetParent() != nullptr)
return GetParent()->GetColor( cCol) ;
else
return false ;
}
m_pAttribs->GetMaterial() == GDB_MT_PARENT)
return false ;
// se il colore è definito
if ( m_pAttribs->GetMaterial() != Attribs::MAT_NULL) {
cCol = m_pAttribs->GetColor() ;
// il colore è definito
cCol = m_pAttribs->GetColor() ;
return true ;
}
//----------------------------------------------------------------------------
bool
GdbObj::GetCalcColor( Color& cCol) const
{
// se non ci sono attributi o ci si deve riferire al padre
if ( m_pAttribs == nullptr ||
m_pAttribs->GetMaterial() == GDB_MT_PARENT) {
if ( GetParent() != nullptr)
GetParent()->GetCalcColor( cCol) ;
else
cCol.Set() ;
return true ;
}
return false ;
// il colore è definito
cCol = m_pAttribs->GetColor() ;
return true ;
}
//----------------------------------------------------------------------------
bool
GdbObj::SetName( const string& sName)
{
// recupero gli attributi (se non ci sono, vengono creati)
Attribs* pAttribs = GetSafeAttribs() ;
if ( pAttribs == nullptr)
// verifico esistenza (con eventuale creazione) degli attributi
if ( GetSafeAttribs() == nullptr)
return false ;
// assegno il nome
return pAttribs->SetName( sName) ;
return m_pAttribs->SetName( sName) ;
}
//----------------------------------------------------------------------------
@@ -313,13 +523,12 @@ GdbObj::RemoveName( void)
bool
GdbObj::SetInfo( const string& sKey, const string& sInfo)
{
// recupero gli attributi (se non ci sono, vengono creati)
Attribs* pAttribs = GetSafeAttribs() ;
if ( pAttribs == nullptr)
// verifico esistenza (con eventuale creazione) degli attributi
if ( GetSafeAttribs() == nullptr)
return false ;
// assegno il nome
return pAttribs->SetInfo( sKey, sInfo) ;
return m_pAttribs->SetInfo( sKey, sInfo) ;
}
//----------------------------------------------------------------------------
+13
View File
@@ -52,8 +52,21 @@ class GdbObj
Attribs* GetAttribs( void)
{ return m_pAttribs ; }
Attribs* GetSafeAttribs( void) ;
bool SetLevel( int nLevel) ;
bool RevertLevel( void) ;
bool GetLevel( int& nLevel) const ;
bool GetCalcLevel( int& nLevel) const ;
bool SetMode( int nMode) ;
bool RevertMode( void) ;
bool GetMode( int& nMode) const ;
bool GetCalcMode( int& nMode) const ;
bool SetStatus( int nStat) ;
bool RevertStatus( void) ;
bool GetStatus( int& nStat) const ;
bool GetCalcStatus( int& nStat, int nLev = 0) const ;
bool SetColor( Color cCol) ;
bool GetColor( Color& cCol) const ;
bool GetCalcColor( Color& cCol) const ;
bool SetName( const std::string& sName) ;
bool GetName( std::string& sName) const ;
bool RemoveName( void) ;
+186 -10
View File
@@ -37,7 +37,7 @@ CreateGeomDB( void)
GeomDB::GeomDB( void)
{
m_GrpRadix.m_nId = GDB_ID_ROOT ;
m_GrpRadix.SetColor( Color( 0, 0, 0)) ;
m_GrpRadix.SetColor( Color()) ;
}
//----------------------------------------------------------------------------
@@ -53,7 +53,7 @@ GeomDB::Init( void)
// imposto numero minimo buckets del map degli Id
m_IdManager.Init( 1024) ;
// imposto colore di default
m_GrpRadix.SetColor( Color( 0, 0, 0)) ;
m_GrpRadix.SetColor( Color()) ;
return true ;
}
@@ -221,9 +221,16 @@ GeomDB::Save( const std::string& sFileOut) const
// ciclo di scrittura degli oggetti
const GdbObj* pGdbObj = m_GrpRadix.GetFirstObj() ;
while ( pGdbObj != nullptr) {
// oggetto geometrico
if ( ! pGdbObj->Save( ofSave))
bOk = false ;
// recupero il livello dell'oggetto
int nLevel = GDB_LV_USER ;
pGdbObj->GetLevel( nLevel) ;
// se non temporaneo
if ( nLevel != GDB_LV_TEMP) {
// salvo l'oggetto
if ( ! pGdbObj->Save( ofSave))
bOk = false ;
}
// passo al successivo
pGdbObj = pGdbObj->GetNext() ;
}
ofSave << "END" << endl ;
@@ -370,7 +377,7 @@ GeomDB::AddGeoObj( int nId, int nParentId, IGeoObj* pGeoObj)
}
//----------------------------------------------------------------------------
GdbType
int
GeomDB::GetGdbType( int nId) const
{
const GdbObj* pGdbObj ;
@@ -378,17 +385,17 @@ GeomDB::GetGdbType( int nId) const
// recupero l'oggetto
if ( ( pGdbObj = (const_cast<GeomDB*> (this))->GetGdbObj( nId)) == nullptr)
return GDB_NONE ;
return GDB_TY_NONE ;
// se oggetto geometrico
if ( ::GetGdbGeo( pGdbObj) != nullptr)
return GDB_GEO ;
return GDB_TY_GEO ;
// se gruppo
else if ( ::GetGdbGroup( pGdbObj) != nullptr)
return GDB_GROUP ;
return GDB_TY_GROUP ;
// altro
else
return GDB_NONE ;
return GDB_TY_NONE ;
}
//----------------------------------------------------------------------------
@@ -781,6 +788,162 @@ GeomDB::DumpAttributes( int nId, string& sOut, const char* szNewLine) const
}
}
//----------------------------------------------------------------------------
bool
GeomDB::SetLevel( int nId, int nLevel)
{
// recupero l'oggetto
GdbObj* pGdbObj ;
if ( ( pGdbObj = GetGdbObj( nId)) == nullptr)
return false ;
// assegno il livello
return pGdbObj->SetLevel( nLevel) ;
}
//----------------------------------------------------------------------------
bool
GeomDB::RevertLevel( int nId)
{
// recupero l'oggetto
GdbObj* pGdbObj ;
if ( ( pGdbObj = GetGdbObj( nId)) == nullptr)
return false ;
// ripristino il livello precedente
return pGdbObj->RevertLevel() ;
}
//----------------------------------------------------------------------------
bool
GeomDB::GetLevel( int nId, int& nLevel) const
{
// recupero l'oggetto
const GdbObj* pGdbObj ;
if ( ( pGdbObj = (const_cast<GeomDB*>(this))->GetGdbObj( nId)) == nullptr)
return false ;
// recupero il livello
return pGdbObj->GetLevel( nLevel) ;
}
//----------------------------------------------------------------------------
bool
GeomDB::GetCalcLevel( int nId, int& nLevel) const
{
// recupero l'oggetto
const GdbObj* pGdbObj ;
if ( ( pGdbObj = (const_cast<GeomDB*>(this))->GetGdbObj( nId)) == nullptr)
return false ;
// recupero il livello calcolato
return pGdbObj->GetCalcLevel( nLevel) ;
}
//----------------------------------------------------------------------------
bool
GeomDB::SetMode( int nId, int nMode)
{
// recupero l'oggetto
GdbObj* pGdbObj ;
if ( ( pGdbObj = GetGdbObj( nId)) == nullptr)
return false ;
// assegno il modo
return pGdbObj->SetMode( nMode) ;
}
//----------------------------------------------------------------------------
bool
GeomDB::RevertMode( int nId)
{
// recupero l'oggetto
GdbObj* pGdbObj ;
if ( ( pGdbObj = GetGdbObj( nId)) == nullptr)
return false ;
// ripristino il modo precedente
return pGdbObj->RevertMode() ;
}
//----------------------------------------------------------------------------
bool
GeomDB::GetMode( int nId, int& nMode) const
{
// recupero l'oggetto
const GdbObj* pGdbObj ;
if ( ( pGdbObj = (const_cast<GeomDB*>(this))->GetGdbObj( nId)) == nullptr)
return false ;
// recupero il modo
return pGdbObj->GetMode( nMode) ;
}
//----------------------------------------------------------------------------
bool
GeomDB::GetCalcMode( int nId, int& nMode) const
{
// recupero l'oggetto
const GdbObj* pGdbObj ;
if ( ( pGdbObj = (const_cast<GeomDB*>(this))->GetGdbObj( nId)) == nullptr)
return false ;
// recupero il modo calcolato
return pGdbObj->GetCalcMode( nMode) ;
}
//----------------------------------------------------------------------------
bool
GeomDB::SetStatus( int nId, int nStat)
{
// recupero l'oggetto
GdbObj* pGdbObj ;
if ( ( pGdbObj = GetGdbObj( nId)) == nullptr)
return false ;
// assegno lo stato
return pGdbObj->SetStatus( nStat) ;
}
//----------------------------------------------------------------------------
bool
GeomDB::RevertStatus( int nId)
{
// recupero l'oggetto
GdbObj* pGdbObj ;
if ( ( pGdbObj = GetGdbObj( nId)) == nullptr)
return false ;
// ripristino lo stato precedente
return pGdbObj->RevertStatus() ;
}
//----------------------------------------------------------------------------
bool
GeomDB::GetStatus( int nId, int& nStat) const
{
// recupero l'oggetto
const GdbObj* pGdbObj ;
if ( ( pGdbObj = (const_cast<GeomDB*>(this))->GetGdbObj( nId)) == nullptr)
return false ;
// recupero lo stato
return pGdbObj->GetStatus( nStat) ;
}
//----------------------------------------------------------------------------
bool
GeomDB::GetCalcStatus( int nId, int& nStat) const
{
// recupero l'oggetto
const GdbObj* pGdbObj ;
if ( ( pGdbObj = (const_cast<GeomDB*>(this))->GetGdbObj( nId)) == nullptr)
return false ;
// recupero lo stato calcolato
return pGdbObj->GetCalcStatus( nStat) ;
}
//----------------------------------------------------------------------------
bool
GeomDB::SetDefaultColor( Color cCol)
@@ -833,6 +996,19 @@ GeomDB::GetColor( int nId, Color& cCol) const
return pGdbObj->GetColor( cCol) ;
}
//----------------------------------------------------------------------------
bool
GeomDB::GetCalcColor( int nId, Color& cCol) const
{
// recupero l'oggetto
const GdbObj* pGdbObj ;
if ( ( pGdbObj = (const_cast<GeomDB*>(this))->GetGdbObj( nId)) == nullptr)
return false ;
// recupero il colore calcolato
return pGdbObj->GetCalcColor( cCol) ;
}
//----------------------------------------------------------------------------
bool
GeomDB::SetName( int nId, const string& sName)
+14 -1
View File
@@ -37,7 +37,7 @@ class GeomDB : public IGeomDB
virtual bool ExistsObj( int nId) const ;
virtual int AddGroup( int nId, int nParentId, const Frame3d& frFrame) ;
virtual int AddGeoObj( int nId, int nParentId, IGeoObj* pGeoObj) ;
virtual GdbType GetGdbType( int nId) const ;
virtual int GetGdbType( int nId) const ;
virtual IGeoObj* GetGeoObj( int nId) ;
virtual IGeoFrame3d* GetGeoFrame( int nId) ;
virtual bool GetGroupFrame( int nId, Frame3d& frGrp) const ;
@@ -67,10 +67,23 @@ class GeomDB : public IGeomDB
virtual bool Mirror( int nId, const Point3d& ptOn, const Vector3d& vtNorm) ;
virtual bool MirrorGlob( int nId, const Point3d& ptOn, const Vector3d& vtNorm) ;
virtual bool DumpAttributes( int nId, std::string& sOut, const char* szNewLine) const ;
virtual bool SetLevel( int nId, int nLevel) ;
virtual bool RevertLevel( int nId) ;
virtual bool GetLevel( int nId, int& nLevel) const ;
virtual bool GetCalcLevel( int nId, int& nLevel) const ;
virtual bool SetMode( int nId, int nMode) ;
virtual bool RevertMode( int nId) ;
virtual bool GetMode( int nId, int& nMode) const ;
virtual bool GetCalcMode( int nId, int& nMode) const ;
virtual bool SetStatus( int nId, int nStat) ;
virtual bool RevertStatus( int nId) ;
virtual bool GetStatus( int nId, int& nStat) const ;
virtual bool GetCalcStatus( int nId, int& nStat) const ;
virtual bool SetDefaultColor( Color cCol) ;
virtual bool GetDefaultColor( Color& cCol) const ;
virtual bool SetColor( int nId, Color cCol) ;
virtual bool GetColor( int nId, Color& cCol) const ;
virtual bool GetCalcColor( int nId, Color& cCol) const ;
virtual bool SetName( int nId, const std::string& sName) ;
virtual bool GetName( int nId, std::string& sName) const ;
virtual bool RemoveName( int nId) ;