EgtGeomKernel 1.5c5 :
- IGdbIterator può utilizzare un altro IGdbIterator per andare sul gruppo - aggiunta gestione nomi di colori standard - Aggiunte ToString e FromString per Color - TSC ora accetta colori standard da nome.
This commit is contained in:
+58
-49
@@ -14,7 +14,8 @@
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "Attribs.h"
|
||||
#include "/EgtDev/Include/EgnStringUtils.h"
|
||||
#include "/EgtDev/Include/EGnStringUtils.h"
|
||||
#include "/EgtDev/Include/EGkStringUtils3d.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
@@ -60,10 +61,15 @@ Attribs::Dump( string& sOut, const char* szNewLine) const
|
||||
// eventuale colore
|
||||
if ( m_Material != MAT_PARENT && m_Material != MAT_NULL) {
|
||||
sOut += " Col=" ;
|
||||
sOut += ToString( m_Color.GetIntRed()) + "," ;
|
||||
sOut += ToString( m_Color.GetIntGreen()) + "," ;
|
||||
sOut += ToString( m_Color.GetIntBlue()) + "," ;
|
||||
sOut += ToString( m_Color.GetIntAlpha()) ;
|
||||
string sColName ;
|
||||
if ( GetNameOfStdColor( m_Color, sColName))
|
||||
sOut += sColName ;
|
||||
sOut += "(" + ToString( m_Color.GetIntRed()) ;
|
||||
sOut += "," + ToString( m_Color.GetIntGreen()) ;
|
||||
sOut += "," + ToString( m_Color.GetIntBlue()) ;
|
||||
if ( m_Color.GetIntAlpha() != 100)
|
||||
sOut += "," + ToString( m_Color.GetIntAlpha()) ;
|
||||
sOut += ")" ;
|
||||
}
|
||||
sOut += szNewLine ;
|
||||
// eventuali nome e stringhe informative
|
||||
@@ -82,22 +88,19 @@ Attribs::Save( ostream& osOut) const
|
||||
osOut << "A" << endl ;
|
||||
|
||||
// livello
|
||||
osOut << ToString( m_Data[LEVEL]) ;
|
||||
osOut << ToString( m_Data[LEVEL]) << "," ;
|
||||
// modo
|
||||
osOut << "," << ToString( m_Data[MODE]) ;
|
||||
osOut << ToString( m_Data[MODE]) << "," ;
|
||||
// stato
|
||||
osOut << "," << ToString( m_Data[STATUS]) ;
|
||||
osOut << ToString( m_Data[STATUS]) << "," ;
|
||||
// altro
|
||||
osOut << "," << ToString( m_Data[OTHER]) ;
|
||||
osOut << ToString( m_Data[OTHER]) << ";" ;
|
||||
// materiale
|
||||
osOut << ";" << ToString( m_Material) ;
|
||||
osOut << ToString( m_Material) << ";" ;
|
||||
// colore
|
||||
osOut << ";" << ToString( m_Color.GetIntRed()) ;
|
||||
osOut << "," << ToString( m_Color.GetIntGreen()) ;
|
||||
osOut << "," << ToString( m_Color.GetIntBlue()) ;
|
||||
osOut << "," << ToString( m_Color.GetIntAlpha()) ;
|
||||
osOut << ToString( m_Color) << ";" ;
|
||||
// numero di stringhe di info (nelle linee successive)
|
||||
osOut << ";" << ToString( int( m_slInfo.size())) << ";" << endl ;
|
||||
osOut << ToString( int( m_slInfo.size())) << ";" << endl ;
|
||||
// stringhe di info
|
||||
STRLIST::const_iterator iIter ;
|
||||
for ( iIter = m_slInfo.begin() ; iIter != m_slInfo.end() ; ++ iIter)
|
||||
@@ -116,9 +119,46 @@ Attribs::Load( Scanner& TheScanner)
|
||||
return false ;
|
||||
// la divido in parametri
|
||||
STRVECTOR vsParams ;
|
||||
Tokenize( sLine, ",;", vsParams) ;
|
||||
// 10 parametri
|
||||
if ( vsParams.size() != 10)
|
||||
Tokenize( sLine, ";", vsParams) ;
|
||||
// 4 parametri
|
||||
if ( vsParams.size() != 4)
|
||||
return false ;
|
||||
// Data (Level,Mode,Status,Other)
|
||||
if ( ! DataFromString( vsParams[0]))
|
||||
return false ;
|
||||
// materiale
|
||||
int nMat ;
|
||||
if ( ! FromString( vsParams[1], nMat))
|
||||
return false ;
|
||||
m_Material = __max( nMat, MAT_PARENT) ;
|
||||
// colore
|
||||
if ( ! FromString( vsParams[2], m_Color))
|
||||
return false ;
|
||||
// numero di stringhe (nelle linee successive)
|
||||
int nNext ;
|
||||
if ( ! FromString( vsParams[3], nNext))
|
||||
return false ;
|
||||
// leggo le eventuali stringhe
|
||||
for ( int i = 0 ; i < nNext ; ++i) {
|
||||
// leggo la linea
|
||||
if ( ! TheScanner.GetLine( sLine))
|
||||
return false ;
|
||||
// la carico in lista
|
||||
m_slInfo.push_back( sLine) ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Attribs::DataFromString( const string& sParam)
|
||||
{
|
||||
// il primo parametro è diviso in 4 parti
|
||||
STRVECTOR vsParams ;
|
||||
Tokenize( sParam, ",", vsParams) ;
|
||||
// 4 parti
|
||||
if ( vsParams.size() != 4)
|
||||
return false ;
|
||||
// livello
|
||||
int nLev ;
|
||||
@@ -140,37 +180,6 @@ Attribs::Load( Scanner& TheScanner)
|
||||
if ( ! FromString( vsParams[3], nOther))
|
||||
return false ;
|
||||
m_Data[OTHER] = CLIP( nOther, 0, 255) ;
|
||||
// materiale
|
||||
int nMat ;
|
||||
if ( ! FromString( vsParams[4], nMat))
|
||||
return false ;
|
||||
m_Material = __max( nMat, MAT_PARENT) ;
|
||||
// colore
|
||||
int nRed ;
|
||||
if ( ! FromString( vsParams[5], nRed))
|
||||
return false ;
|
||||
int nGreen ;
|
||||
if ( ! FromString( vsParams[6], nGreen))
|
||||
return false ;
|
||||
int nBlue ;
|
||||
if ( ! FromString( vsParams[7], nBlue))
|
||||
return false ;
|
||||
int nAlpha ;
|
||||
if ( ! FromString( vsParams[8], nAlpha))
|
||||
return false ;
|
||||
m_Color.Set( nRed, nGreen, nBlue, nAlpha) ;
|
||||
// numero di stringhe (nelle linee successive)
|
||||
int nNext ;
|
||||
if ( ! FromString( vsParams[9], nNext))
|
||||
return false ;
|
||||
// leggo le eventuali stringhe
|
||||
for ( int i = 0 ; i < nNext ; ++i) {
|
||||
// leggo la linea
|
||||
if ( ! TheScanner.GetLine( sLine))
|
||||
return false ;
|
||||
// la carico in lista
|
||||
m_slInfo.push_back( sLine) ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
@@ -77,6 +77,7 @@ class Attribs
|
||||
enum { LEVEL = 0, MODE = 1, STATUS = 2, OTHER = 3, DIM = 4} ;
|
||||
|
||||
private :
|
||||
bool DataFromString( const std::string& sParam) ;
|
||||
bool FindKey( const std::string& sString, const std::string& sKey) const ;
|
||||
bool ValidString( const std::string& sString) const ;
|
||||
|
||||
|
||||
@@ -0,0 +1,133 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2014-2014
|
||||
//----------------------------------------------------------------------------
|
||||
// File : Color.cpp Data : 12.03.14 Versione : 1.5a5
|
||||
// Contenuto : Implementazione funzioni per gestione colori.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 12.03.14 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "/EgtDev/Include/EGkColor.h"
|
||||
#include "/EgtDev/Include/EGnStringUtils.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//------------------------- Constants ----------------------------------------
|
||||
static const char* SZ_BLACK = "BLACK" ;
|
||||
static const char* SZ_GRAY = "GRAY" ;
|
||||
static const char* SZ_LGRAY = "LGRAY" ;
|
||||
static const char* SZ_WHITE = "WHITE" ;
|
||||
static const char* SZ_RED = "RED" ;
|
||||
static const char* SZ_GREEN = "GREEN" ;
|
||||
static const char* SZ_BLUE = "BLUE" ;
|
||||
static const char* SZ_CYAN = "CYAN" ;
|
||||
static const char* SZ_MAGENTA = "MAGENTA" ;
|
||||
static const char* SZ_YELLOW = "YELLOW" ;
|
||||
static const char* SZ_BROWN = "BROWN" ;
|
||||
static const char* SZ_PURPLE = "PURPLE" ;
|
||||
static const char* SZ_ORANGE = "ORANGE" ;
|
||||
static const char* SZ_LRED = "LRED" ;
|
||||
static const char* SZ_LGREEN = "LGREEN" ;
|
||||
static const char* SZ_LBLUE = "LBLUE" ;
|
||||
static const char* SZ_LCYAN = "LCYAN" ;
|
||||
static const char* SZ_LMAGENTA = "LMAGENTA" ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GetStdColor( const string& sName, Color& cCol)
|
||||
{
|
||||
string sCol = sName ;
|
||||
ToUpper( sCol) ;
|
||||
if ( sCol == SZ_BLACK)
|
||||
cCol = BLACK ;
|
||||
else if ( sCol == SZ_GRAY)
|
||||
cCol = GRAY ;
|
||||
else if ( sCol == SZ_LGRAY)
|
||||
cCol = LGRAY ;
|
||||
else if ( sCol == SZ_WHITE)
|
||||
cCol = WHITE ;
|
||||
else if ( sCol == SZ_RED)
|
||||
cCol = RED ;
|
||||
else if ( sCol == SZ_GREEN)
|
||||
cCol = GREEN ;
|
||||
else if ( sCol == SZ_BLUE)
|
||||
cCol = BLUE ;
|
||||
else if ( sCol == SZ_CYAN)
|
||||
cCol = CYAN ;
|
||||
else if ( sCol == SZ_MAGENTA)
|
||||
cCol = MAGENTA ;
|
||||
else if ( sCol == SZ_YELLOW)
|
||||
cCol = YELLOW ;
|
||||
else if ( sCol == SZ_BROWN)
|
||||
cCol = BROWN ;
|
||||
else if ( sCol == SZ_PURPLE)
|
||||
cCol = PURPLE ;
|
||||
else if ( sCol == SZ_ORANGE)
|
||||
cCol = ORANGE ;
|
||||
else if ( sCol == SZ_LRED)
|
||||
cCol = LRED ;
|
||||
else if ( sCol == SZ_LGREEN)
|
||||
cCol = LGREEN ;
|
||||
else if ( sCol == SZ_LBLUE)
|
||||
cCol = LBLUE ;
|
||||
else if ( sCol == SZ_LCYAN)
|
||||
cCol = LCYAN ;
|
||||
else if ( sCol == SZ_LMAGENTA)
|
||||
cCol = LMAGENTA ;
|
||||
else
|
||||
return false ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GetNameOfStdColor( const Color& cCol, string& sName)
|
||||
{
|
||||
if ( cCol == BLACK)
|
||||
sName = SZ_BLACK ;
|
||||
else if ( cCol == GRAY)
|
||||
sName = SZ_GRAY ;
|
||||
else if ( cCol == LGRAY)
|
||||
sName = SZ_LGRAY ;
|
||||
else if ( cCol == WHITE)
|
||||
sName = SZ_WHITE ;
|
||||
else if ( cCol == RED)
|
||||
sName = SZ_RED ;
|
||||
else if ( cCol == GREEN)
|
||||
sName = SZ_GREEN ;
|
||||
else if ( cCol == BLUE)
|
||||
sName = SZ_BLUE ;
|
||||
else if ( cCol == CYAN)
|
||||
sName = SZ_CYAN ;
|
||||
else if ( cCol == MAGENTA)
|
||||
sName = SZ_MAGENTA ;
|
||||
else if ( cCol == YELLOW)
|
||||
sName = SZ_YELLOW ;
|
||||
else if ( cCol == BROWN)
|
||||
sName = SZ_BROWN ;
|
||||
else if ( cCol == PURPLE)
|
||||
sName = SZ_PURPLE ;
|
||||
else if ( cCol == ORANGE)
|
||||
sName = SZ_ORANGE ;
|
||||
else if ( cCol == LRED)
|
||||
sName = SZ_LRED ;
|
||||
else if ( cCol == LGREEN)
|
||||
sName = SZ_LGREEN ;
|
||||
else if ( cCol == LBLUE)
|
||||
sName = SZ_LBLUE ;
|
||||
else if ( cCol == LCYAN)
|
||||
sName = SZ_LCYAN ;
|
||||
else if ( cCol == LMAGENTA)
|
||||
sName = SZ_LMAGENTA ;
|
||||
else
|
||||
return false ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
Binary file not shown.
@@ -227,6 +227,7 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Attribs.cpp" />
|
||||
<ClCompile Include="BBox3d.cpp" />
|
||||
<ClCompile Include="Color.cpp" />
|
||||
<ClCompile Include="DistPointArc.cpp" />
|
||||
<ClCompile Include="DistPointCrvAux.cpp" />
|
||||
<ClCompile Include="DistPointCrvBezier.cpp" />
|
||||
@@ -265,6 +266,7 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\Include\EGkBBox3d.h" />
|
||||
<ClInclude Include="..\Include\EGkColor.h" />
|
||||
<ClInclude Include="..\Include\EgkCurve.h" />
|
||||
<ClInclude Include="..\Include\EgkCurveArc.h" />
|
||||
<ClInclude Include="..\Include\EgkCurveBezier.h" />
|
||||
|
||||
@@ -129,6 +129,9 @@
|
||||
<ClCompile Include="Attribs.cpp">
|
||||
<Filter>File di origine\Gdb</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Color.cpp">
|
||||
<Filter>File di origine\Base</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="stdafx.h">
|
||||
@@ -323,6 +326,9 @@
|
||||
<ClInclude Include="GdbObj.h">
|
||||
<Filter>File di intestazione</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Include\EGkColor.h">
|
||||
<Filter>File di intestazione</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="EgtGeomKernel.rc">
|
||||
|
||||
+50
-32
@@ -759,10 +759,10 @@ GdbExecutor::GetVectorParam( const std::string& sParam, Vector3d& vtV)
|
||||
{
|
||||
// se insieme di tre componenti
|
||||
if ( sParam[0] == '(') {
|
||||
STRVECTOR vsParams ;
|
||||
STRVECTOR::iterator Iter ;
|
||||
// divido in parti
|
||||
STRVECTOR vsParams ;
|
||||
Tokenize( sParam, ",", vsParams) ;
|
||||
STRVECTOR::iterator Iter ;
|
||||
for ( Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
|
||||
Trim( (*Iter), " \t\r\n()") ;
|
||||
// verifico siano 3 parti e le converto
|
||||
@@ -788,10 +788,10 @@ GdbExecutor::GetPointParam( const std::string& sParam, Point3d& ptP)
|
||||
{
|
||||
// se insieme di tre coordinate
|
||||
if ( sParam[0] == '(') {
|
||||
STRVECTOR vsParams ;
|
||||
STRVECTOR::iterator Iter ;
|
||||
// divido in parti
|
||||
STRVECTOR vsParams ;
|
||||
Tokenize( sParam, ",", vsParams) ;
|
||||
STRVECTOR::iterator Iter ;
|
||||
for ( Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
|
||||
Trim( (*Iter), " \t\r\n()") ;
|
||||
// verifico siano 3 parti e le converto
|
||||
@@ -815,16 +815,14 @@ GdbExecutor::GetPointParam( const std::string& sParam, Point3d& ptP)
|
||||
bool
|
||||
GdbExecutor::GetPointWParam( const std::string& sParam, Point3d& ptP, double& dW)
|
||||
{
|
||||
STRVECTOR vsParams ;
|
||||
STRVECTOR::iterator Iter ;
|
||||
|
||||
|
||||
// deve essere insieme di dati
|
||||
if ( sParam[0] != '(')
|
||||
return false ;
|
||||
|
||||
// divido in parti
|
||||
STRVECTOR vsParams ;
|
||||
Tokenize( sParam, ",", vsParams) ;
|
||||
STRVECTOR::iterator Iter ;
|
||||
for ( Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
|
||||
Trim( (*Iter), " \t\r\n()") ;
|
||||
|
||||
@@ -888,32 +886,56 @@ GdbExecutor::GetFrameParam( const std::string& sParam, Frame3d& frF)
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbExecutor::GetColorParam( const std::string& sParam, Color& cCol)
|
||||
{
|
||||
// se insieme di tre o quattro valori
|
||||
if ( sParam[0] == '(') {
|
||||
// divido in parti
|
||||
STRVECTOR vsParams ;
|
||||
Tokenize( sParam, ",", vsParams) ;
|
||||
STRVECTOR::iterator Iter ;
|
||||
for ( Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
|
||||
Trim( (*Iter), " \t\r\n()") ;
|
||||
// devono essere 3 o 4 parametri ( Red, Green, Blue [, Alpha])
|
||||
if ( vsParams.size() != 3 && vsParams.size() != 4)
|
||||
return false ;
|
||||
int nRed, nGreen, nBlue ;
|
||||
if ( ! FromString( vsParams[0], nRed) ||
|
||||
! FromString( vsParams[1], nGreen) ||
|
||||
! FromString( vsParams[2], nBlue))
|
||||
return false ;
|
||||
int nAlpha = 100 ;
|
||||
if ( vsParams.size() == 4 &&
|
||||
! FromString( vsParams[3], nAlpha))
|
||||
return false ;
|
||||
cCol.Set( nRed, nGreen, nBlue, nAlpha) ;
|
||||
return true ;
|
||||
}
|
||||
// altrimenti colore predefinito
|
||||
else {
|
||||
return GetStdColor( sParam, cCol) ;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbExecutor::ExecuteColor( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
{
|
||||
// assegnazione colore di oggetto
|
||||
if ( sCmd2.empty()) {
|
||||
// 4 o 5 parametri ( Id, Red, Green, Blue, Alpha)
|
||||
if ( vsParams.size() != 4 && vsParams.size() != 5)
|
||||
// devono essere 2 parametri ( Id, Colore)
|
||||
if ( vsParams.size() != 2)
|
||||
return false ;
|
||||
// recupero lista Id
|
||||
STRVECTOR vsNames ;
|
||||
if ( ! GetNamesParam( vsParams[0], vsNames))
|
||||
return false ;
|
||||
// recupero i colori
|
||||
int nRed ;
|
||||
int nGreen ;
|
||||
int nBlue ;
|
||||
if ( ! FromString( vsParams[1], nRed) ||
|
||||
! FromString( vsParams[2], nGreen) ||
|
||||
! FromString( vsParams[3], nBlue))
|
||||
// recupero il colore
|
||||
Color cCol ;
|
||||
if ( ! GetColorParam( vsParams[1], cCol))
|
||||
return false ;
|
||||
int nAlpha = 100 ;
|
||||
if ( vsParams.size() == 5 &&
|
||||
! FromString( vsParams[4], nAlpha))
|
||||
return false ;
|
||||
Color cCol( nRed, nGreen, nBlue, nAlpha) ;
|
||||
// esecuzione impostazione colore
|
||||
STRVECTOR::iterator Iter ;
|
||||
for ( Iter = vsNames.begin() ; Iter != vsNames.end() ; ++Iter) {
|
||||
@@ -924,18 +946,14 @@ GdbExecutor::ExecuteColor( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
}
|
||||
// impostazione colore di default
|
||||
else if ( sCmd2 == "DEF" || sCmd2 == "DEFAULT") {
|
||||
// 3 parametri ( Red, Green, Blue)
|
||||
if ( vsParams.size() != 3)
|
||||
// 1 parametro ( Colore)
|
||||
if ( vsParams.size() != 1)
|
||||
return false ;
|
||||
// recupero i colori
|
||||
int nRed ;
|
||||
int nGreen ;
|
||||
int nBlue ;
|
||||
if ( ! FromString( vsParams[0], nRed) ||
|
||||
! FromString( vsParams[1], nGreen) ||
|
||||
! FromString( vsParams[2], nBlue))
|
||||
// recupero il colore
|
||||
Color cCol ;
|
||||
if ( ! GetColorParam( vsParams[0], cCol))
|
||||
return false ;
|
||||
Color cCol( nRed, nGreen, nBlue) ;
|
||||
// imposto il colore di default
|
||||
return m_pGDB->SetDefaultColor( cCol) ;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,9 @@
|
||||
#include "/EgtDev/Include/EgkGdbExecutor.h"
|
||||
#include "/EgtDev/Include/EgtPerfCounter.h"
|
||||
|
||||
class Vector3d ;
|
||||
class Color ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
class GdbExecutor : public IGdbExecutor
|
||||
{
|
||||
@@ -38,6 +41,7 @@ class GdbExecutor : public IGdbExecutor
|
||||
bool GetPointParam( const std::string& sParam, Point3d& ptP) ;
|
||||
bool GetPointWParam( const std::string& sParam, Point3d& ptP, double& dW) ;
|
||||
bool GetFrameParam( const std::string& sParam, Frame3d& frF) ;
|
||||
bool GetColorParam( const std::string& sParam, Color& cCol) ;
|
||||
bool ExecuteGroup( const std::string& sCmd2, const STRVECTOR& vsParams) ;
|
||||
bool ExecutePoint( const std::string& sCmd2, const STRVECTOR& vsParams) ;
|
||||
bool ExecuteVector( const std::string& sCmd2, const STRVECTOR& vsParams) ;
|
||||
|
||||
@@ -46,3 +46,9 @@ class GdbGeo : public GdbObj
|
||||
public :
|
||||
IGeoObj* m_pGeoObj ;
|
||||
} ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
inline const GdbGeo* GetGdbGeo( const GdbObj* pGObj)
|
||||
{ return dynamic_cast<const GdbGeo*>(pGObj) ; }
|
||||
inline GdbGeo* GetGdbGeo( GdbObj* pGObj)
|
||||
{ return dynamic_cast<GdbGeo*>(pGObj) ; }
|
||||
|
||||
@@ -75,3 +75,9 @@ class GdbGroup : public GdbObj
|
||||
GdbObj* m_pFirstObj ;
|
||||
GdbObj* m_pLastObj ;
|
||||
} ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
inline const GdbGroup* GetGdbGroup( const GdbObj* pGObj)
|
||||
{ return dynamic_cast<const GdbGroup*>(pGObj) ; }
|
||||
inline GdbGroup* GetGdbGroup( GdbObj* pGObj)
|
||||
{ return dynamic_cast<GdbGroup*>(pGObj) ; }
|
||||
|
||||
+67
-9
@@ -54,8 +54,10 @@ GdbIterator::SetGDB( IGeomDB* pGDB)
|
||||
bool
|
||||
GdbIterator::GoTo( int nId)
|
||||
{
|
||||
if ( m_pGDB == nullptr)
|
||||
if ( m_pGDB == nullptr) {
|
||||
m_pCurrObj = nullptr ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
m_pCurrObj = m_pGDB->GetGdbObj( nId) ;
|
||||
|
||||
@@ -66,14 +68,41 @@ GdbIterator::GoTo( int nId)
|
||||
bool
|
||||
GdbIterator::GoToFirstInGroup( int nIdGroup)
|
||||
{
|
||||
GdbGroup* pGdbGroup ;
|
||||
|
||||
|
||||
if ( m_pGDB == nullptr)
|
||||
if ( m_pGDB == nullptr) {
|
||||
m_pCurrObj = nullptr ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
// recupero il gruppo
|
||||
pGdbGroup = m_pGDB->GetGdbGroup( nIdGroup) ;
|
||||
GdbGroup* pGdbGroup = m_pGDB->GetGdbGroup( nIdGroup) ;
|
||||
if ( pGdbGroup == nullptr) {
|
||||
m_pCurrObj = nullptr ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
// recupero l'oggetto
|
||||
m_pCurrObj = pGdbGroup->GetFirstObj() ;
|
||||
|
||||
return ( m_pCurrObj != nullptr) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbIterator::GoToFirstInGroup( const IGdbIterator& iIter)
|
||||
{
|
||||
if ( m_pGDB == nullptr) {
|
||||
m_pCurrObj = nullptr ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
const GdbIterator* pIter = dynamic_cast<const GdbIterator*> (&iIter) ;
|
||||
if ( pIter == nullptr || pIter->m_pGDB != m_pGDB) {
|
||||
m_pCurrObj = nullptr ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
// recupero il gruppo
|
||||
GdbGroup* pGdbGroup = GetGdbGroup( pIter->m_pCurrObj) ;
|
||||
if ( pGdbGroup == nullptr) {
|
||||
m_pCurrObj = nullptr ;
|
||||
return false ;
|
||||
@@ -101,12 +130,41 @@ GdbIterator::GoToNext( void)
|
||||
bool
|
||||
GdbIterator::GoToLastInGroup( int nIdGroup)
|
||||
{
|
||||
if ( m_pGDB == nullptr)
|
||||
if ( m_pGDB == nullptr) {
|
||||
m_pCurrObj = nullptr ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
// recupero il gruppo
|
||||
GdbGroup* pGdbGroup ;
|
||||
pGdbGroup = m_pGDB->GetGdbGroup( nIdGroup) ;
|
||||
GdbGroup* pGdbGroup = m_pGDB->GetGdbGroup( nIdGroup) ;
|
||||
if ( pGdbGroup == nullptr) {
|
||||
m_pCurrObj = nullptr ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
// recupero l'oggetto
|
||||
m_pCurrObj = pGdbGroup->GetLastObj() ;
|
||||
|
||||
return ( m_pCurrObj != nullptr) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbIterator::GoToLastInGroup( const IGdbIterator& iIter)
|
||||
{
|
||||
if ( m_pGDB == nullptr) {
|
||||
m_pCurrObj = nullptr ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
const GdbIterator* pIter = dynamic_cast<const GdbIterator*> (&iIter) ;
|
||||
if ( pIter == nullptr || pIter->m_pGDB != m_pGDB) {
|
||||
m_pCurrObj = nullptr ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
// recupero il gruppo
|
||||
GdbGroup* pGdbGroup = GetGdbGroup( pIter->m_pCurrObj) ;
|
||||
if ( pGdbGroup == nullptr) {
|
||||
m_pCurrObj = nullptr ;
|
||||
return false ;
|
||||
|
||||
+7
-1
@@ -20,13 +20,16 @@
|
||||
class GdbIterator : public IGdbIterator
|
||||
{
|
||||
public :
|
||||
GdbIterator( void) ;
|
||||
virtual ~GdbIterator( void) ;
|
||||
virtual bool SetGDB( IGeomDB* pGDB) ;
|
||||
virtual GeomDB* GetGDB( void)
|
||||
{ return m_pGDB ; }
|
||||
virtual bool GoTo( int nId) ;
|
||||
virtual bool GoToFirstInGroup( int nIdGroup) ;
|
||||
virtual bool GoToFirstInGroup( const IGdbIterator& iIter) ;
|
||||
virtual bool GoToNext( void) ;
|
||||
virtual bool GoToLastInGroup( int nIdGroup) ;
|
||||
virtual bool GoToLastInGroup( const IGdbIterator& iIter) ;
|
||||
virtual bool GoToPrev( void) ;
|
||||
|
||||
virtual GdbType GetGdbType( void) const ;
|
||||
@@ -47,6 +50,9 @@ class GdbIterator : public IGdbIterator
|
||||
virtual bool GetInfo( const std::string& sKey, std::string& sInfo) const ;
|
||||
virtual bool RemoveInfo( const std::string& sKey) ;
|
||||
|
||||
public :
|
||||
GdbIterator( void) ;
|
||||
|
||||
private :
|
||||
GeomDB* m_pGDB ;
|
||||
GdbObj* m_pCurrObj ;
|
||||
|
||||
+7
-4
@@ -131,8 +131,8 @@ GeoFrame3d::Load( Scanner& TheScanner)
|
||||
bool
|
||||
GeoFrame3d::GetLocalBBox( BBox3d& b3Loc) const
|
||||
{
|
||||
// reset del box (un riferimento non occupa posizioni nello spazio)
|
||||
b3Loc.Reset() ;
|
||||
// assegno il box in locale (considero l'origine)
|
||||
b3Loc.Set( m_frF.Orig()) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
@@ -143,8 +143,11 @@ GeoFrame3d::GetBBox( const Frame3d& frRef, BBox3d& b3Ref) const
|
||||
// verifico validità del frame
|
||||
if ( frRef.GetType() == Frame3d::ERR)
|
||||
return false ;
|
||||
// reset del box (un riferimento non occupa posizioni nello spazio)
|
||||
b3Ref.Reset() ;
|
||||
// porto l'origine nel riferimento passato
|
||||
Point3d ptP = m_frF.Orig() ;
|
||||
ptP.ToGlob( frRef) ;
|
||||
// assegno il box nel riferimento
|
||||
b3Ref.Set( ptP) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -240,7 +240,7 @@ GeomDB::SaveHeader( ostream& osOut) const
|
||||
{
|
||||
// intestazione
|
||||
osOut << "START" << endl ;
|
||||
osOut << "GeomDB,1.5c2" << endl ;
|
||||
osOut << "GeomDB,1.5.3.5;" << endl ;
|
||||
|
||||
// colore di default
|
||||
osOut << "COL_DEF" << endl ;
|
||||
|
||||
@@ -96,13 +96,3 @@ class GeomDB : public IGeomDB
|
||||
GdbGroup m_GrpRadix ; // gruppo radice di tutto il DB
|
||||
IdManager m_IdManager ; // gestore del nuovo Id
|
||||
} ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
inline const GdbGeo* GetGdbGeo( const GdbObj* pGObj)
|
||||
{ return dynamic_cast<const GdbGeo*>(pGObj) ; }
|
||||
inline GdbGeo* GetGdbGeo( GdbObj* pGObj)
|
||||
{ return dynamic_cast<GdbGeo*>(pGObj) ; }
|
||||
inline const GdbGroup* GetGdbGroup( const GdbObj* pGObj)
|
||||
{ return dynamic_cast<const GdbGroup*>(pGObj) ; }
|
||||
inline GdbGroup* GetGdbGroup( GdbObj* pGObj)
|
||||
{ return dynamic_cast<GdbGroup*>(pGObj) ; }
|
||||
|
||||
+9
-4
@@ -14,6 +14,11 @@
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "OutScl.h"
|
||||
#include "/EgtDev/Include/EgkPoint3d.h"
|
||||
#include "/EgtDev/Include/EgkCurveLine.h"
|
||||
#include "/EgtDev/Include/EgkCurveArc.h"
|
||||
#include "/EgtDev/Include/EgkCurveBezier.h"
|
||||
#include "/EgtDev/Include/EgkCurveComposite.h"
|
||||
#include "/EgtDev/Include/EGkStringUtils3d.h"
|
||||
#include "/EgtDev/Include/EGnStringConverter.h"
|
||||
|
||||
@@ -101,7 +106,7 @@ OutScl::New( void)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
OutScl::Remark( string sRemark)
|
||||
OutScl::Remark( const string& sRemark)
|
||||
{
|
||||
// verifico sia aperto
|
||||
if ( ! m_ofFile.is_open())
|
||||
@@ -134,7 +139,7 @@ OutScl::SetMaterial( double dRed, double dGreen, double dBlue)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
OutScl::SetMaterial( string sMaterial, double dRed, double dGreen, double dBlue)
|
||||
OutScl::SetMaterial( const string& sMaterial, double dRed, double dGreen, double dBlue)
|
||||
{
|
||||
// verifico sia aperto
|
||||
if ( ! m_ofFile.is_open())
|
||||
@@ -152,7 +157,7 @@ OutScl::SetMaterial( string sMaterial, double dRed, double dGreen, double dBlue)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
OutScl::SetPartLay( string sPart, string sLay)
|
||||
OutScl::SetPartLay( const string& sPart, const string& sLay)
|
||||
{
|
||||
// verifico sia aperto
|
||||
if ( ! m_ofFile.is_open())
|
||||
@@ -170,7 +175,7 @@ OutScl::SetPartLay( string sPart, string sLay)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
OutScl::SetPartLayRef( string sPart, string sLay, const Frame3d& frFrame)
|
||||
OutScl::SetPartLayRef( const string& sPart, const string& sLay, const Frame3d& frFrame)
|
||||
{
|
||||
double dAngC ;
|
||||
double dAngA ;
|
||||
|
||||
@@ -15,11 +15,14 @@
|
||||
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include "/EgtDev/Include/EgkPoint3d.h"
|
||||
#include "/EgtDev/Include/EgkCurveLine.h"
|
||||
#include "/EgtDev/Include/EgkCurveArc.h"
|
||||
#include "/EgtDev/Include/EgkCurveBezier.h"
|
||||
#include "/EgtDev/Include/EgkCurveComposite.h"
|
||||
|
||||
class Point3d ;
|
||||
class BBox3d ;
|
||||
class Frame3d ;
|
||||
class IGeoObj ;
|
||||
class ICurve ;
|
||||
class ICurveBezier ;
|
||||
class CrvPointDiffGeom ;
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -30,10 +33,10 @@ class OutScl
|
||||
~OutScl( void) ;
|
||||
bool Open( const std::string& sOutScl) ;
|
||||
bool Close( void) ;
|
||||
bool Remark( std::string sRemark) ;
|
||||
bool Remark( const std::string& sRemark) ;
|
||||
bool SetMaterial( double dRed, double dGreen, double dBlue) ;
|
||||
bool SetPartLay( std::string sPart, std::string sLay) ;
|
||||
bool SetPartLayRef( std::string sPart, std::string sLay, const Frame3d& frFrame) ;
|
||||
bool SetPartLay( const std::string& sPart, const std::string& sLay) ;
|
||||
bool SetPartLayRef( const std::string& sPart, const std::string& sLay, const Frame3d& frFrame) ;
|
||||
bool PutCurrRef( void) ;
|
||||
bool PutGeoObj( const IGeoObj* pGeoObj, int nFlag) ;
|
||||
bool PutBBox( const BBox3d& b3B) ;
|
||||
@@ -42,7 +45,7 @@ class OutScl
|
||||
bool Start( void) ;
|
||||
bool End( void) ;
|
||||
bool New( void) ;
|
||||
bool SetMaterial( std::string sMaterial, double dRed, double dGreen, double dBlue) ;
|
||||
bool SetMaterial( const std::string& sMaterial, double dRed, double dGreen, double dBlue) ;
|
||||
bool Line2P( const Point3d& ptP1, const Point3d& ptP2) ;
|
||||
bool Arc3P( const Point3d& ptP1, const Point3d& ptP2, const Point3d& ptP3) ;
|
||||
bool ArcCPA( const Point3d& ptCen, const Point3d& ptMed, double dAngCenDeg) ;
|
||||
|
||||
@@ -103,3 +103,25 @@ FromString( const string& sVal, Frame3d& frFrame)
|
||||
// imposto il riferimento
|
||||
return frFrame.Set( ptOrig, vtDirX, vtDirY, vtDirZ) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
FromString( const string& sVal, Color& cCol)
|
||||
{
|
||||
// divido la stringa in parametri
|
||||
STRVECTOR vsParams ;
|
||||
Tokenize( sVal, ",", vsParams) ;
|
||||
// devono essere 4 parametri : Red, Green, Blue, Alpha
|
||||
if ( vsParams.size() != 4)
|
||||
return false ;
|
||||
// recupero i parametri
|
||||
int nRed, nGreen, nBlue, nAlpha ;
|
||||
if ( ! FromString( vsParams[0], nRed) ||
|
||||
! FromString( vsParams[1], nGreen) ||
|
||||
! FromString( vsParams[2], nBlue) ||
|
||||
! FromString( vsParams[3], nAlpha))
|
||||
return false ;
|
||||
// assegno il colore
|
||||
cCol.Set( nRed, nGreen, nBlue, nAlpha) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user