diff --git a/EgtGeomKernel.rc b/EgtGeomKernel.rc index 209c59a..28dca1f 100644 Binary files a/EgtGeomKernel.rc and b/EgtGeomKernel.rc differ diff --git a/EgtGeomKernel.vcxproj b/EgtGeomKernel.vcxproj index f41a48c..b868241 100644 --- a/EgtGeomKernel.vcxproj +++ b/EgtGeomKernel.vcxproj @@ -235,6 +235,7 @@ copy $(TargetPath) \EgtProg\Dll64 + @@ -256,9 +257,9 @@ copy $(TargetPath) \EgtProg\Dll64 - + - + @@ -328,6 +329,7 @@ copy $(TargetPath) \EgtProg\Dll64 + @@ -351,12 +353,12 @@ copy $(TargetPath) \EgtProg\Dll64 - + - + diff --git a/EgtGeomKernel.vcxproj.filters b/EgtGeomKernel.vcxproj.filters index 4556cb2..7c7f057 100644 --- a/EgtGeomKernel.vcxproj.filters +++ b/EgtGeomKernel.vcxproj.filters @@ -168,10 +168,13 @@ File di origine\Gdb - + File di origine\Gdb - + + File di origine\Gdb + + File di origine\Gdb @@ -431,10 +434,13 @@ File di intestazione - + File di intestazione - + + File di intestazione + + File di intestazione diff --git a/ExtText.cpp b/ExtText.cpp index 53d2b07..c7d0af6 100644 --- a/ExtText.cpp +++ b/ExtText.cpp @@ -44,6 +44,9 @@ ExtText::~ExtText( void) bool ExtText::Set( const string& sText, const Point3d& ptP, double dAngDeg, double dH) { + // controllo testo + if ( sText.empty()) + return false ; // assegno i dati m_ptP = ptP ; m_vtN = Z_AX ; @@ -55,6 +58,7 @@ ExtText::Set( const string& sText, const Point3d& ptP, double dAngDeg, double dH m_dHeight = dH ; m_dRatio = 1 ; m_dAddAdvance = 0 ; + m_nInsPos = ETXT_IPBL ; // imposto ricalcolo della grafica m_OGrMgr.Reset() ; @@ -65,8 +69,12 @@ ExtText::Set( const string& sText, const Point3d& ptP, double dAngDeg, double dH //---------------------------------------------------------------------------- bool ExtText::Set( const string& sText, const Point3d& ptP, double dAngDeg, - const string& sFont, int nW, bool bItl, double dH, double dRat, double dAddAdv) + const string& sFont, int nW, bool bItl, double dH, double dRat, double dAddAdv, + int nInsPos) { + // controllo testo + if ( sText.empty()) + return false ; // assegno i dati m_ptP = ptP ; m_vtN = Z_AX ; @@ -78,6 +86,39 @@ ExtText::Set( const string& sText, const Point3d& ptP, double dAngDeg, m_dHeight = dH ; m_dRatio = dRat ; m_dAddAdvance = dAddAdv ; + m_nInsPos = (( nInsPos >= ETXT_IPTL && nInsPos <= ETXT_IPBR) ? nInsPos : ETXT_IPBL) ; + + // imposto ricalcolo della grafica + m_OGrMgr.Reset() ; + + return true ; +} + +//---------------------------------------------------------------------------- +bool +ExtText::Set( const string& sText, const Point3d& ptP, const Vector3d& vtN, const Vector3d& vtD, + const string& sFont, int nW, bool bItl, double dH, double dRat, double dAddAdv, + int nInsPos) +{ + // controllo testo + if ( sText.empty()) + return false ; + // assegno i dati + m_ptP = ptP ; + m_vtN = vtN ; + if ( ! m_vtN.Normalize()) + return false ; + m_vtD = vtD - m_vtN * ( vtD * m_vtN) ; + if ( ! m_vtD.Normalize()) + return false ; + m_sText = sText ; + m_sFont = sFont ; + m_nWeight = nW ; + m_bItalic = bItl ; + m_dHeight = dH ; + m_dRatio = dRat ; + m_dAddAdvance = dAddAdv ; + m_nInsPos = (( nInsPos >= ETXT_IPTL && nInsPos <= ETXT_IPBR) ? nInsPos : ETXT_IPBL) ; // imposto ricalcolo della grafica m_OGrMgr.Reset() ; @@ -128,6 +169,7 @@ ExtText::Copy( const ExtText& clSrc) m_dHeight = clSrc.m_dHeight ; m_dRatio = clSrc.m_dRatio ; m_dAddAdvance = clSrc.m_dAddAdvance ; + m_nInsPos = clSrc.m_nInsPos ; return true ; } @@ -150,8 +192,9 @@ ExtText::GetTitle( void) const bool ExtText::Dump( string& sOut, const char* szNewLine) const { - // parametri : PtIns, Normale, DirStart, Rad, AngCenDeg, DeltaN - sOut += "P(" + ToString( m_ptP, 3) + ") " + szNewLine ; + // parametri + sOut += "P(" + ToString( m_ptP, 3) + ") " ; + sOut += " IP=" + ToString( m_nInsPos) + szNewLine ; sOut += "VN(" + ToString( m_vtN, 6) + ") " + szNewLine ; sOut += "VS(" + ToString( m_vtD, 6) + ") " + szNewLine ; sOut += "Txt=" + m_sText + szNewLine ; @@ -178,6 +221,8 @@ ExtText::Save( NgeWriter& ngeOut) const { // punto di inserimento ngeOut.WritePoint( m_ptP, ";") ; + // flag posizione inserimento + ngeOut.WriteInt( m_nInsPos, ";") ; // versore normale ngeOut.WriteVector( m_vtN, ";") ; // versore di direzione @@ -206,9 +251,11 @@ ExtText::Load( NgeReader& ngeIn) { // imposto ricalcolo della grafica m_OGrMgr.Reset() ; - // leggo la prossima linea : punto, normale, direzione + // leggo la prossima linea : punto, posiz. inserimento, normale, direzione if ( ! ngeIn.ReadPoint( m_ptP, ";")) return false ; + if ( ! ngeIn.ReadInt( m_nInsPos, ";")) + return false ; if ( ! ngeIn.ReadVector( m_vtN, ";")) return false ; if ( ! ngeIn.ReadVector( m_vtD, ";", true)) @@ -245,7 +292,7 @@ ExtText::GetLocalBBox( BBox3d& b3Loc) const return false ; // richiedo il box - if ( ! fntMgr.GetBBox( m_sText, b3Loc)) + if ( ! fntMgr.GetBBox( m_sText, m_nInsPos, b3Loc)) return false ; // calcolo ed eseguo la trasformazione @@ -273,7 +320,7 @@ ExtText::GetBBox( const Frame3d& frRef, BBox3d& b3Ref) const return false ; // richiedo il box - if ( ! fntMgr.GetBBox( m_sText, b3Ref)) + if ( ! fntMgr.GetBBox( m_sText, m_nInsPos, b3Ref)) return false ; // calcolo ed eseguo la prima trasformazione (per tener conto dell'orientamento del testo) @@ -454,12 +501,62 @@ ExtText::LocToLoc( const Frame3d& frOri, const Frame3d& frDest) m_vtD.ToGlob( frOri) && m_vtD.ToLoc( frDest)) ; } +//---------------------------------------------------------------------------- +bool +ExtText::GetHeightVersor( Vector3d& vtH) const +{ + vtH = m_vtN ^ m_vtD ; + return ( vtH.Normalize()) ; +} + //---------------------------------------------------------------------------- bool ExtText::GetStartPoint( Point3d& ptStart) const { - // assegno il punto - ptStart = m_ptP ; + // imposto il font corrente e i suoi dati + FontManager& fntMgr = FontManager::GetFontManager() ; + if ( ! fntMgr.SetCurrFont( m_sFont, m_nWeight, m_bItalic, m_dHeight, m_dRatio, m_dAddAdvance)) + return false ; + + // richiedo il box delle maiuscole + BBox3d b3Loc ; + if ( ! fntMgr.GetCapBox( m_sText, m_nInsPos, b3Loc)) + return false ; + + // ricavo il punto di inizio + ptStart = b3Loc.GetMin() ; + + // calcolo ed eseguo la trasformazione (da riferimento canonico font alla entità) + Frame3d frRef ; + if ( ! frRef.Set( m_ptP, m_vtN, m_vtD)) + return false ; + ptStart.ToGlob( frRef) ; + + return true ; +} + +//---------------------------------------------------------------------------- +bool +ExtText::GetOverStartPoint( Point3d& ptStart) const +{ + // imposto il font corrente e i suoi dati + FontManager& fntMgr = FontManager::GetFontManager() ; + if ( ! fntMgr.SetCurrFont( m_sFont, m_nWeight, m_bItalic, m_dHeight, m_dRatio, m_dAddAdvance)) + return false ; + + // richiedo il box delle maiuscole + BBox3d b3Loc ; + if ( ! fntMgr.GetCapBox( m_sText, m_nInsPos, b3Loc)) + return false ; + + // ricavo il punto sopra l'inizio + ptStart.Set( b3Loc.GetMin().x, b3Loc.GetMax().y, 0) ; + + // calcolo ed eseguo la trasformazione (da riferimento canonico font alla entità) + Frame3d frRef ; + if ( ! frRef.Set( m_ptP, m_vtN, m_vtD)) + return false ; + ptStart.ToGlob( frRef) ; return true ; } @@ -473,13 +570,45 @@ ExtText::GetEndPoint( Point3d& ptEnd) const if ( ! fntMgr.SetCurrFont( m_sFont, m_nWeight, m_bItalic, m_dHeight, m_dRatio, m_dAddAdvance)) return false ; - // richiedo la lunghezza - double dLen ; - if ( ! fntMgr.GetLength( m_sText, dLen)) + // richiedo il box delle maiuscole + BBox3d b3Loc ; + if ( ! fntMgr.GetCapBox( m_sText, m_nInsPos, b3Loc)) return false ; - // calcolo il punto - ptEnd = m_ptP + m_vtD * dLen ; + // ricavo il punto di fine + ptEnd.Set( b3Loc.GetMax().x, b3Loc.GetMin().y, 0) ; + + // calcolo ed eseguo la trasformazione (da riferimento canonico font alla entità) + Frame3d frRef ; + if ( ! frRef.Set( m_ptP, m_vtN, m_vtD)) + return false ; + ptEnd.ToGlob( frRef) ; + + return true ; +} + +//---------------------------------------------------------------------------- +bool +ExtText::GetOverEndPoint( Point3d& ptEnd) const +{ + // imposto il font corrente e i suoi dati + FontManager& fntMgr = FontManager::GetFontManager() ; + if ( ! fntMgr.SetCurrFont( m_sFont, m_nWeight, m_bItalic, m_dHeight, m_dRatio, m_dAddAdvance)) + return false ; + + // richiedo il box delle maiuscole + BBox3d b3Loc ; + if ( ! fntMgr.GetCapBox( m_sText, m_nInsPos, b3Loc)) + return false ; + + // ricavo il punto sopra la fine + ptEnd = b3Loc.GetMax() ; + + // calcolo ed eseguo la trasformazione (da riferimento canonico font alla entità) + Frame3d frRef ; + if ( ! frRef.Set( m_ptP, m_vtN, m_vtD)) + return false ; + ptEnd.ToGlob( frRef) ; return true ; } @@ -493,13 +622,19 @@ ExtText::GetMidPoint( Point3d& ptMid) const if ( ! fntMgr.SetCurrFont( m_sFont, m_nWeight, m_bItalic, m_dHeight, m_dRatio, m_dAddAdvance)) return false ; - // richiedo la lunghezza - double dLen ; - if ( ! fntMgr.GetLength( m_sText, dLen)) + // richiedo il box delle maiuscole + BBox3d b3Loc ; + if ( ! fntMgr.GetCapBox( m_sText, m_nInsPos, b3Loc)) return false ; - // calcolo il punto - ptMid = m_ptP + m_vtD * ( 0.5 * dLen) ; + // assegno il medio + ptMid.Set( 0.5 * ( b3Loc.GetMin().x + b3Loc.GetMax().x), b3Loc.GetMin().y, 0) ; + + // calcolo ed eseguo la trasformazione (da riferimento canonico font alla entità) + Frame3d frRef ; + if ( ! frRef.Set( m_ptP, m_vtN, m_vtD)) + return false ; + ptMid.ToGlob( frRef) ; return true ; } @@ -513,21 +648,19 @@ ExtText::GetCenterPoint( Point3d& ptCen) const if ( ! fntMgr.SetCurrFont( m_sFont, m_nWeight, m_bItalic, m_dHeight, m_dRatio, m_dAddAdvance)) return false ; - // richiedo lunghezza e altezza delle maiuscole - double dLen ; - if ( ! fntMgr.GetLength( m_sText, dLen)) - return false ; - double dCapH ; - if ( ! fntMgr.GetCapHeight( dCapH)) + // richiedo il box delle maiuscole + BBox3d b3Loc ; + if ( ! fntMgr.GetCapBox( m_sText, m_nInsPos, b3Loc)) return false ; - // vettore diretto come l'altezza - Vector3d vtH = m_vtN ^ m_vtD ; - if ( ! vtH.Normalize()) - return false ; + // ricavo il centro + ptCen = Media( b3Loc.GetMin(), b3Loc.GetMax(), 0.5) ; - // calcolo il punto - ptCen = m_ptP + m_vtD * ( 0.5 * dLen) + vtH * ( 0.5 * dCapH) ; + // calcolo ed eseguo la trasformazione (da riferimento canonico font alla entità) + Frame3d frRef ; + if ( ! frRef.Set( m_ptP, m_vtN, m_vtD)) + return false ; + ptCen.ToGlob( frRef) ; return true ; } @@ -542,7 +675,7 @@ ExtText::GetOutline( ICURVEPLIST& lstPC) const return false ; // richiedo l'outline - if ( ! fntMgr.GetOutline( m_sText, lstPC)) + if ( ! fntMgr.GetOutline( m_sText, m_nInsPos, lstPC)) return false ; // calcolo la trasformazione @@ -568,7 +701,7 @@ ExtText::ApproxWithLines( double dLinTol, double dAngTolDeg, POLYLINELIST& lstPL return false ; // richiedo l'outline - if ( ! fntMgr.ApproxWithLines( m_sText, dLinTol, dAngTolDeg, lstPL)) + if ( ! fntMgr.ApproxWithLines( m_sText, m_nInsPos, dLinTol, dAngTolDeg, lstPL)) return false ; // calcolo la trasformazione @@ -610,28 +743,30 @@ ExtText::Mir( bool bOnLen) // se auto-mirror sulla lunghezza del testo if ( bOnLen) { - // richiedo lunghezza - double dLen ; - if ( ! fntMgr.GetLength( m_sText, dLen)) - return false ; - // calcolo il punto - m_ptP += m_vtD * dLen ; + // faccio mirror sulla lunghezza della posizione di inserimento + switch ( m_nInsPos) { + case ETXT_IPTL : m_nInsPos = ETXT_IPTR ; break ; + case ETXT_IPTR : m_nInsPos = ETXT_IPTL ; break ; + case ETXT_IPML : m_nInsPos = ETXT_IPMR ; break ; + case ETXT_IPMR : m_nInsPos = ETXT_IPML ; break ; + case ETXT_IPBL : m_nInsPos = ETXT_IPBR ; break ; + case ETXT_IPBR : m_nInsPos = ETXT_IPBL ; break ; + } // inverto i versori m_vtN *= - 1 ; m_vtD *= - 1 ; } // altrimenti auto-mirror su altezza del testo else { - // richiedo altezza delle maiuscole - double dCapH ; - if ( ! fntMgr.GetCapHeight( dCapH)) - return false ; - // vettore diretto come l'altezza - Vector3d vtH = m_vtN ^ m_vtD ; - if ( ! vtH.Normalize()) - return false ; - // calcolo il punto - m_ptP += vtH * dCapH ; + // faccio mirror sulla altezza della posizione di inserimento + switch ( m_nInsPos) { + case ETXT_IPTL : m_nInsPos = ETXT_IPBL ; break ; + case ETXT_IPTC : m_nInsPos = ETXT_IPBC ; break ; + case ETXT_IPTR : m_nInsPos = ETXT_IPBR ; break ; + case ETXT_IPBL : m_nInsPos = ETXT_IPTL ; break ; + case ETXT_IPBC : m_nInsPos = ETXT_IPTC ; break ; + case ETXT_IPBR : m_nInsPos = ETXT_IPTR ; break ; + } // inverto il versore normale m_vtN *= - 1 ; } diff --git a/ExtText.h b/ExtText.h index 9e9f591..6ca13d6 100644 --- a/ExtText.h +++ b/ExtText.h @@ -54,7 +54,11 @@ class ExtText : public IExtText, public IGeoObjRW virtual bool Copy( const IGeoObj* pGObjSrc) ; virtual bool Set( const std::string& sText, const Point3d& ptP, double dAngDeg, double dH) ; virtual bool Set( const std::string& sText, const Point3d& ptP, double dAngDeg, - const std::string& sFont, int nW, bool bItl, double dH, double dRat, double dAddAdv) ; + const std::string& sFont, int nW, bool bItl, double dH, double dRat, double dAddAdv, + int nInsPos = 7) ; + virtual bool Set( const std::string& sText, const Point3d& ptP, const Vector3d& vtN, const Vector3d& vtD, + const std::string& sFont, int nW, bool bItl, double dH, double dRat, double dAddAdv, + int nInsPos = 7) ; virtual const Point3d& GetPoint( void) const { return m_ptP ; } virtual const Vector3d& GetNormVersor( void) const @@ -75,8 +79,13 @@ class ExtText : public IExtText, public IGeoObjRW { return m_dRatio ; } virtual double GetAddAdvance( void) const { return m_dAddAdvance ; } + virtual int GetInsPosition( void) const + { return m_nInsPos ; } + virtual bool GetHeightVersor( Vector3d& vtH) const ; virtual bool GetStartPoint( Point3d& ptStart) const ; + virtual bool GetOverStartPoint( Point3d& ptStart) const ; virtual bool GetEndPoint( Point3d& ptEnd) const ; + virtual bool GetOverEndPoint( Point3d& ptEnd) const ; virtual bool GetMidPoint( Point3d& ptMid) const ; virtual bool GetCenterPoint( Point3d& ptCen) const ; virtual bool GetOutline( ICURVEPLIST& lstPC) const ; @@ -111,4 +120,5 @@ class ExtText : public IExtText, public IGeoObjRW double m_dHeight ; // altezza del carattere double m_dRatio ; // rapporto tra larghezza e altezza double m_dAddAdvance ; // avanzamento addizionale tra caratteri + int m_nInsPos ; // posizione del punto di inserimento rispetto al testo } ; diff --git a/FontAux.cpp b/FontAux.cpp new file mode 100644 index 0000000..07b4969 --- /dev/null +++ b/FontAux.cpp @@ -0,0 +1,59 @@ +//---------------------------------------------------------------------------- +// EgalTech 2014-2014 +//---------------------------------------------------------------------------- +// File : FontAux.cpp Data : 05.06.14 Versione : 1.5f2 +// Contenuto : Implementazione delle funzioni ausiliarie per i font. +// +// +// +// Modifiche : 05.06.14 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +//--------------------------- Include ---------------------------------------- +#include "stdafx.h" +#include "FontAux.h" +#include "/EgtDev/Include/EGkExtText.h" + +//---------------------------------------------------------------------------- +bool +IsLineBreak( const UINTVECTOR& vCode, int nInd, int& nLen) +{ + // riconoscimento del comando di interruzione di linea "
" + if ( vCode[nInd] == '<' && ( nInd + 4) < int( vCode.size()) && + vCode[nInd+1] == 'b' && vCode[nInd+2] == 'r' && + vCode[nInd+3] == '/' && vCode[nInd+4] == '>') { + nLen = 4 ; + return true ; + } + + return false ; +} + +//---------------------------------------------------------------------------- +Vector3d +GetTextInsertPointMove( double dMaxW, double dAscent, double dMinH, int nInsPos) +{ + switch ( nInsPos) { + case ETXT_IPTL : + return Vector3d( 0, - dAscent, 0) ; + case ETXT_IPTC : + return Vector3d( - 0.5 * dMaxW, - dAscent, 0) ; + case ETXT_IPTR : + return Vector3d( - dMaxW, - dAscent, 0) ; + case ETXT_IPML : + return Vector3d( 0, 0.5 * ( dMinH - dAscent), 0) ; + case ETXT_IPMC : + return Vector3d( - 0.5 * dMaxW, 0.5 * ( dMinH - dAscent), 0) ; + case ETXT_IPMR : + return Vector3d( - dMaxW, 0.5 * ( dMinH - dAscent), 0) ; + default : + case ETXT_IPBL : + return Vector3d( 0, - dMinH, 0) ; + case ETXT_IPBC : + return Vector3d( - 0.5 * dMaxW, - dMinH, 0) ; + case ETXT_IPBR : + return Vector3d( - dMaxW, - dMinH, 0) ; + } +} diff --git a/FontAux.h b/FontAux.h new file mode 100644 index 0000000..2b926d0 --- /dev/null +++ b/FontAux.h @@ -0,0 +1,21 @@ +//---------------------------------------------------------------------------- +// EgalTech 2014-2014 +//---------------------------------------------------------------------------- +// File : FontAux.h Data : 05.06.14 Versione : 1.5f2 +// Contenuto : Dichiarazione delle funzioni ausiliarie per i font. +// +// +// +// Modifiche : 05.06.14 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +#pragma once + +#include "/EgtDev/Include/EGkVector3d.h" +#include "/EgtDev/Include/EGtNumCollection.h" + +//---------------------------------------------------------------------------- +bool IsLineBreak( const UINTVECTOR& vCode, int nInd, int& nLen) ; +Vector3d GetTextInsertPointMove( double dMaxW, double dAscent, double dMinH, int nInsPos) ; diff --git a/FontManager.cpp b/FontManager.cpp index fd80960..0a3da92 100644 --- a/FontManager.cpp +++ b/FontManager.cpp @@ -25,7 +25,7 @@ using namespace std ; //---------------------------------------------------------------------------- bool -FontManager::Init( const std::string& sNfeFontDir, const std::string& sDefaultFont) +FontManager::Init( const string& sNfeFontDir, const string& sDefaultFont) { // assegno direttorio file per font Nfe m_sNfeFontDir = sNfeFontDir ; @@ -37,22 +37,30 @@ FontManager::Init( const std::string& sNfeFontDir, const std::string& sDefaultFo //---------------------------------------------------------------------------- bool -FontManager::SetCurrFont( const std::string& sFont, int nWeight, bool bItalic, +FontManager::SetCurrFont( const string& sFont, int nWeight, bool bItalic, double dHeight, double dRatio, double dAddAdvance) { // gestione font di default - string sTFont = (( sFont.empty()) ? m_sDefaultFont : sFont) ; + string sFontName = (( sFont.empty()) ? m_sDefaultFont : sFont) ; + // lo cerco tra i font Nfe - if ( FileExtensionMatches( sTFont, "NFE")) { + if ( FileExtensionMatches( sFontName, "NFE")) { + // verifico che il font richiesto esista, altrimenti prendo il primo dello stesso tipo + string sPath = m_sNfeFontDir + "\\" + sFontName ; + if ( ! ExistsFile( sPath)) { + if ( FindFirstFileEgt( m_sNfeFontDir + "\\*.Nfe", sFontName)) + sPath = m_sNfeFontDir + "\\" + sFontName ; + } + // imposto il font corrente m_bCurrNfeFont = true ; - if ( ! m_NfeFont.SetCurrFont( m_sNfeFontDir + "\\" + sTFont, nWeight, bItalic, - dHeight, dRatio, dAddAdvance)) + if ( ! m_NfeFont.SetCurrFont( sPath, nWeight, bItalic, dHeight, dRatio, dAddAdvance)) return false ; } + // altrimenti lo cerco tra i font di sistema else { m_bCurrNfeFont = false ; - if ( ! m_OsFont.SetCurrFont( sTFont, nWeight, bItalic, dHeight, dRatio, dAddAdvance)) + if ( ! m_OsFont.SetCurrFont( sFontName, nWeight, bItalic, dHeight, dRatio, dAddAdvance)) return false ; } @@ -91,40 +99,40 @@ FontManager::GetDescent( double& dDesc) //---------------------------------------------------------------------------- bool -FontManager::GetLength( const string& sText, double& dLen) +FontManager::GetCapBox( const string& sText, int nInsPos, BBox3d& b3Box) { if ( m_bCurrNfeFont) - return m_NfeFont.GetLength( sText, dLen) ; + return m_NfeFont.GetXBox( sText, nInsPos, true, b3Box) ; else - return m_OsFont.GetLength( sText, dLen) ; + return m_OsFont.GetXBox( sText, nInsPos, true, b3Box) ; } //---------------------------------------------------------------------------- bool -FontManager::GetBBox( const string& sText, BBox3d& b3Box) +FontManager::GetBBox( const string& sText, int nInsPos, BBox3d& b3Box) { if ( m_bCurrNfeFont) - return m_NfeFont.GetBBox( sText, b3Box) ; + return m_NfeFont.GetXBox( sText, nInsPos, false, b3Box) ; else - return m_OsFont.GetBBox( sText, b3Box) ; + return m_OsFont.GetXBox( sText, nInsPos, false, b3Box) ; } //---------------------------------------------------------------------------- bool -FontManager::GetOutline( const string& sText, ICURVEPLIST& lstPC) +FontManager::GetOutline( const string& sText, int nInsPos, ICURVEPLIST& lstPC) { if ( m_bCurrNfeFont) - return m_NfeFont.GetOutline( sText, lstPC) ; + return m_NfeFont.GetOutline( sText, nInsPos, lstPC) ; else - return m_OsFont.GetOutline( sText, lstPC) ; + return m_OsFont.GetOutline( sText, nInsPos, lstPC) ; } //---------------------------------------------------------------------------- bool -FontManager::ApproxWithLines( const string& sText, double dLinTol, double dAngTolDeg, POLYLINELIST& lstPL) +FontManager::ApproxWithLines( const string& sText, int nInsPos, double dLinTol, double dAngTolDeg, POLYLINELIST& lstPL) { if ( m_bCurrNfeFont) - return m_NfeFont.ApproxWithLines( sText, dLinTol, dAngTolDeg, lstPL) ; + return m_NfeFont.ApproxWithLines( sText, nInsPos, dLinTol, dAngTolDeg, lstPL) ; else - return m_OsFont.ApproxWithLines( sText, dLinTol, dAngTolDeg, lstPL) ; + return m_OsFont.ApproxWithLines( sText, nInsPos, dLinTol, dAngTolDeg, lstPL) ; } diff --git a/FontManager.h b/FontManager.h index 947d971..628a909 100644 --- a/FontManager.h +++ b/FontManager.h @@ -13,8 +13,8 @@ #pragma once -#include "NfeFont.h" -#include "OsFont.h" +#include "FontNfe.h" +#include "FontOs.h" #include "/EgtDev/Include/EGkBBox3d.h" #include "/EgtDev/Include/EGkPolyLine.h" #include @@ -29,10 +29,10 @@ class FontManager bool GetCapHeight( double& dCapH) ; bool GetAscent( double& dAsc) ; bool GetDescent( double& dDesc) ; - bool GetLength( const std::string& sText, double& dLen) ; - bool GetBBox( const std::string& sText, BBox3d& b3Box) ; - bool GetOutline( const std::string& sText, ICURVEPLIST& lstPC) ; - bool ApproxWithLines( const std::string& sText, double dLinTol, double dAngTolDeg, POLYLINELIST& lstPL) ; + bool GetCapBox( const std::string& sText, int nInsPos, BBox3d& b3Box) ; + bool GetBBox( const std::string& sText, int nInsPos, BBox3d& b3Box) ; + bool GetOutline( const std::string& sText, int nInsPos, ICURVEPLIST& lstPC) ; + bool ApproxWithLines( const std::string& sText, int nInsPos, double dLinTol, double dAngTolDeg, POLYLINELIST& lstPL) ; private : std::string m_sNfeFontDir ; diff --git a/NfeFont.cpp b/FontNfe.cpp similarity index 71% rename from NfeFont.cpp rename to FontNfe.cpp index 0a90310..038b3a3 100644 --- a/NfeFont.cpp +++ b/FontNfe.cpp @@ -1,7 +1,7 @@ //---------------------------------------------------------------------------- // EgalTech 2014-2014 //---------------------------------------------------------------------------- -// File : NfeFont.cpp Data : 29.05.14 Versione : 1.5f1 +// File : FontNfe.cpp Data : 05.06.14 Versione : 1.5f2 // Contenuto : Implementazione della classe NfeFont (formato font proprietario). // // @@ -13,11 +13,13 @@ //--------------------------- Include ---------------------------------------- #include "stdafx.h" -#include "NfeFont.h" +#include "FontNfe.h" +#include "FontAux.h" #include "/EgtDev/Include/EGkGeomDB.h" #include "/EgtDev/Include/EGkGdbIterator.h" #include "/EgtDev/Include/EGkCurve.h" #include "/EgtDev/Include/EGkCurveAux.h" +#include "/EgtDev/Include/EGkExtText.h" #include "/EgtDev/Include/EgtPointerOwner.h" #include "/EgtDev/Include/EgnStringUtils.h" #include "/EgtDev/Include/EGnStringDecoder.h" @@ -150,7 +152,7 @@ NfeFont::GetDescent( double& dDesc) //---------------------------------------------------------------------------- bool -NfeFont::GetLength( const string& sText, double& dLen) +NfeFont::GetXBox( const string& sText, int nInsPos, bool bCapOrBound, BBox3d& b3Box) { // verifico esistenza font corrente if ( m_pGDB == nullptr || m_sFont.empty()) @@ -161,53 +163,63 @@ NfeFont::GetLength( const string& sText, double& dLen) if ( ! IsValid( pIter)) return false ; - // calcolo il fattore di scala - double dScaX = m_dHeight / m_dHCap * m_dRatio ; + // calcolo i fattori di scala + double dScaY = m_dHeight / m_dHCap ; + double dScaX = dScaY * m_dRatio ; + + // recupero altezza maiuscole, ascent, descent e interlinea + double dHCap = m_dHeight ; + double dAscent = m_dAsc * m_dHeight / m_dHCap ; + double dDescent = m_dDesc * m_dHeight / m_dHCap ; + double dH = m_dH * m_dHeight / m_dHCap ; // converto i byte della stringa in codici carattere UINTVECTOR vCode ; GetCodePoints( sText, vCode) ; // scandisco i codici - dLen = 0 ; + double dCurrW = 0 ; + double dMaxW = 0 ; + double dMinH = 0 ; for ( unsigned int i = 0 ; i < vCode.size() ; ++ i) { + // verifico se comando di a capo + int nLbLen ; + if ( IsLineBreak( vCode, i, nLbLen)) { + dCurrW = 0 ; + dMinH -= dH ; + i += nLbLen ; + continue ; + } // gruppo del carattere int nGroup = sText[i] ; - if ( nGroup < NFE_MIN_CHAR || m_pGDB->GetGdbType( nGroup) == GDB_TY_NONE) + if ( nGroup < NFE_MIN_CHAR || m_pGDB->GetGdbType( nGroup) != GDB_TY_GROUP) nGroup = NFE_ERR_CHAR ; // recupero lo spostamento per il prossimo carattere double dAdvance ; if ( ! m_pGDB->GetInfo( nGroup, NFE_LEN_CHAR, dAdvance)) dAdvance = m_dAdv ; - dLen += dAdvance * dScaX + m_dAddAdvance ; + dCurrW += dAdvance * dScaX + m_dAddAdvance ; + if ( dCurrW > dMaxW) + dMaxW = dCurrW ; } - return true ; -} - -//---------------------------------------------------------------------------- -bool -NfeFont::GetBBox( const string& sText, BBox3d& b3Box) -{ - // recupero le dimensioni - double dAsc ; - if ( ! GetAscent( dAsc)) - return false ; - double dDesc ; - if ( ! GetDescent( dDesc)) - return false ; - double dLen ; - if ( ! GetLength( sText, dLen)) - return false ; + // punti estremi + Point3d ptMin( 0, dMinH - ( bCapOrBound ? 0 : dDescent), 0) ; + Point3d ptMax( dMaxW, ( bCapOrBound ? dHCap : dAscent), 0) ; + // sistemazioni per la posizione del punto di inserimento + Vector3d vtIpMove = GetTextInsertPointMove( dMaxW, dHCap, dMinH, nInsPos) ; + ptMin.Translate( vtIpMove) ; + ptMax.Translate( vtIpMove) ; // assegno l'ingombro - b3Box.Set( 0, - dDesc, 0, dLen, dAsc, 0) ; + b3Box.Set( ptMin, ptMax) ; + return true ; } //---------------------------------------------------------------------------- bool -NfeFont::GetOutline( const string& sText, ICURVEPLIST& lstPC) +NfeFont::GetOutline( const string& sText, int nInsPos, ICURVEPLIST& lstPC) { // verifico esistenza font corrente if ( m_pGDB == nullptr || m_sFont.empty()) @@ -223,21 +235,36 @@ NfeFont::GetOutline( const string& sText, ICURVEPLIST& lstPC) double dScaX = dScaY * m_dRatio ; double dScaZ = 1 ; + // recupero altezza maiuscole e interlinea + double dHCap = m_dHeight ; + double dH = m_dH * m_dHeight / m_dHCap ; + // converto i byte della stringa in codici carattere UINTVECTOR vCode ; GetCodePoints( sText, vCode) ; // scandisco i codici + double dMaxW = 0 ; + double dMinH = 0 ; Vector3d vtMove ; for ( unsigned int i = 0 ; i < vCode.size() ; ++ i) { + // verifico se comando di a capo + int nLbLen ; + if ( IsLineBreak( vCode, i, nLbLen)) { + vtMove.Set( 0, vtMove.y - dH, 0) ; + if ( vtMove.y < dMinH) + dMinH = vtMove.y ; + i += nLbLen ; + continue ; + } // verifico esistenza del gruppo del carattere int nGroup = vCode[i] ; - if ( nGroup < NFE_MIN_CHAR || m_pGDB->GetGdbType( nGroup) == GDB_TY_NONE) + if ( nGroup < NFE_MIN_CHAR || m_pGDB->GetGdbType( nGroup) != GDB_TY_GROUP) nGroup = NFE_ERR_CHAR ; // ciclo sulle entità geometriche del carattere bool bIter = pIter->GoToFirstInGroup( nGroup) ; while ( bIter) { - ICurve* pCrv = GetCurve( pIter->GetGeoObj()) ; + const ICurve* pCrv = GetCurve( pIter->GetGeoObj()) ; if ( pCrv != nullptr) { ICurve* pCopyCrv = GetCurve( pCrv->Clone()) ; if ( pCopyCrv == nullptr) @@ -265,14 +292,23 @@ NfeFont::GetOutline( const string& sText, ICURVEPLIST& lstPC) if ( ! m_pGDB->GetInfo( nGroup, NFE_LEN_CHAR, dAdvance)) dAdvance = m_dAdv ; vtMove += Vector3d( ( dAdvance * dScaX + m_dAddAdvance), 0, 0) ; + if ( vtMove.x > dMaxW) + dMaxW = vtMove.x ; } + // sistemazioni per la posizione del punto di inserimento + Vector3d vtIpMove = GetTextInsertPointMove( dMaxW, dHCap, dMinH, nInsPos) ; + ICURVEPLIST::iterator iIter ; + for ( iIter = lstPC.begin() ; iIter != lstPC.end() ; ++ iIter) + (*iIter)->Translate( vtIpMove) ; + return true ; } //---------------------------------------------------------------------------- bool -NfeFont::ApproxWithLines( const string& sText, double dLinTol, double dAngTolDeg, POLYLINELIST& lstPL) +NfeFont::ApproxWithLines( const string& sText, int nInsPos, double dLinTol, double dAngTolDeg, + POLYLINELIST& lstPL) { // verifico esistenza font corrente if ( m_pGDB == nullptr || m_sFont.empty()) @@ -289,21 +325,36 @@ NfeFont::ApproxWithLines( const string& sText, double dLinTol, double dAngTolDeg double dScaZ = 1 ; double dInvScaMed = 1 / max( ( dScaX + dScaY) / 2, EPS_SMALL) ; + // recupero altezza maiuscole e interlinea + double dHCap = m_dHeight ; + double dH = m_dH * m_dHeight / m_dHCap ; + // converto i byte della stringa in codici carattere UINTVECTOR vCode ; GetCodePoints( sText, vCode) ; // scandisco i codici + double dMaxW = 0 ; + double dMinH = 0 ; Vector3d vtMove ; for ( unsigned int i = 0 ; i < vCode.size() ; ++ i) { + // verifico se comando di a capo + int nLbLen ; + if ( IsLineBreak( vCode, i, nLbLen)) { + vtMove.Set( 0, vtMove.y - dH, 0) ; + if ( vtMove.y < dMinH) + dMinH = vtMove.y ; + i += nLbLen ; + continue ; + } // verifico esistenza del gruppo del carattere int nGroup = vCode[i] ; - if ( nGroup < NFE_MIN_CHAR || m_pGDB->GetGdbType( nGroup) == GDB_TY_NONE) + if ( nGroup < NFE_MIN_CHAR || m_pGDB->GetGdbType( nGroup) != GDB_TY_GROUP) nGroup = NFE_ERR_CHAR ; // ciclo sulle entità geometriche del carattere bool bIter = pIter->GoToFirstInGroup( nGroup) ; while ( bIter) { - ICurve* pCrv = GetCurve( pIter->GetGeoObj()) ; + const ICurve* pCrv = GetCurve( pIter->GetGeoObj()) ; if ( pCrv != nullptr) { lstPL.push_back( PolyLine()) ; pCrv->ApproxWithLines( dLinTol * dInvScaMed, dAngTolDeg, lstPL.back()) ; @@ -319,7 +370,15 @@ NfeFont::ApproxWithLines( const string& sText, double dLinTol, double dAngTolDeg if ( ! m_pGDB->GetInfo( nGroup, NFE_LEN_CHAR, dAdvance)) dAdvance = m_dAdv ; vtMove += Vector3d( ( dAdvance * dScaX + m_dAddAdvance), 0, 0) ; + if ( vtMove.x > dMaxW) + dMaxW = vtMove.x ; } + // sistemazioni per la posizione del punto di inserimento + Vector3d vtIpMove = GetTextInsertPointMove( dMaxW, dHCap, dMinH, nInsPos) ; + POLYLINELIST::iterator iIter ; + for ( iIter = lstPL.begin() ; iIter != lstPL.end() ; ++ iIter) + (*iIter).Translate( vtIpMove) ; + return true ; } diff --git a/NfeFont.h b/FontNfe.h similarity index 74% rename from NfeFont.h rename to FontNfe.h index f5882d2..75be455 100644 --- a/NfeFont.h +++ b/FontNfe.h @@ -1,7 +1,7 @@ //---------------------------------------------------------------------------- // EgalTech 2014-2014 //---------------------------------------------------------------------------- -// File : NfeFont.h Data : 29.05.14 Versione : 1.5f1 +// File : FontNfe.h Data : 05.06.14 Versione : 1.5f2 // Contenuto : Dichiarazione della classe NfeFont (formato font proprietario). // // @@ -29,10 +29,10 @@ class NfeFont bool GetCapHeight( double& dCapH) ; bool GetAscent( double& dAsc) ; bool GetDescent( double& dDesc) ; - bool GetLength( const std::string& sText, double& dLen) ; - bool GetBBox( const std::string& sText, BBox3d& b3Box) ; - bool GetOutline( const std::string& sText, ICURVEPLIST& lstPC) ; - bool ApproxWithLines( const std::string& sText, double dLinTol, double dAngTolDeg, POLYLINELIST& lstPL) ; + bool GetXBox( const std::string& sText, int nInsPos, bool bCapOrBound, BBox3d& b3Box) ; + bool GetOutline( const std::string& sText, int nInsPos, ICURVEPLIST& lstPC) ; + bool ApproxWithLines( const std::string& sText, int nInsPos, double dLinTol, double dAngTolDeg, + POLYLINELIST& lstPL) ; private : IGeomDB* m_pGDB ; diff --git a/OsFont.cpp b/FontOs.cpp similarity index 81% rename from OsFont.cpp rename to FontOs.cpp index 65c4280..e2780d3 100644 --- a/OsFont.cpp +++ b/FontOs.cpp @@ -1,8 +1,8 @@ //---------------------------------------------------------------------------- // EgalTech 2014-2014 //---------------------------------------------------------------------------- -// File : OsFont.cpp Data : 01.06.14 Versione : 1.5f1 -// Contenuto : Implementazione della classe NfeFont (formato font proprietario). +// File : FontOs.cpp Data : 05.06.14 Versione : 1.5f2 +// Contenuto : Implementazione della classe OsFont (font di sistema). // // // @@ -13,7 +13,8 @@ //--------------------------- Include ---------------------------------------- #include "stdafx.h" -#include "OsFont.h" +#include "FontOs.h" +#include "FontAux.h" #include "/EgtDev/Include/EGkGeomDB.h" #include "/EgtDev/Include/EGkGdbIterator.h" #include "/EgtDev/Include/EGkCurve.h" @@ -179,7 +180,7 @@ OsFont::GetDescent( double& dDesc) //---------------------------------------------------------------------------- bool -OsFont::GetLength( const string& sText, double& dLen) +OsFont::GetXBox( const string& sText, int nInsPos, bool bCapOrBound, BBox3d& b3Box) { // verifico esistenza font corrente if ( m_hDC == nullptr || m_hFont == nullptr || m_sFont.empty()) @@ -194,13 +195,29 @@ OsFont::GetLength( const string& sText, double& dLen) double dScaY = m_dHeight / m_dHCap ; double dScaX = dScaY * m_dRatio ; + // recupero altezza maiuscole, ascent, descent e interlinea + double dHCap = m_dHeight ; + double dAscent = m_dAsc * m_dHeight / m_dHCap ; + double dDescent = m_dDesc * m_dHeight / m_dHCap ; + double dH = m_dH * m_dHeight / m_dHCap ; + // converto i byte della stringa in codici carattere UINTVECTOR vCode ; GetCodePoints( sText, vCode) ; - // ciclo sui caratteri - dLen = 0 ; + // scandisco i codici + double dCurrW = 0 ; + double dMaxW = 0 ; + double dMinH = 0 ; for ( unsigned int i = 0 ; i < vCode.size() ; ++ i) { + // verifico se comando di a capo + int nLbLen ; + if ( IsLineBreak( vCode, i, nLbLen)) { + dCurrW = 0 ; + dMinH -= dH ; + i += nLbLen ; + continue ; + } // recupero l'avanzamento di ogni carattere ABC abc ; double dAdvance ; @@ -208,9 +225,22 @@ OsFont::GetLength( const string& sText, double& dLen) dAdvance = ( abc.abcA + abc.abcB + abc.abcC) ; else dAdvance = m_dAdv ; - dLen += dAdvance * dScaX + m_dAddAdvance ; + dCurrW += dAdvance * dScaX + m_dAddAdvance ; + if ( dCurrW > dMaxW) + dMaxW = dCurrW ; } + // punti estremi + Point3d ptMin( 0, dMinH - ( bCapOrBound ? 0 : dDescent), 0) ; + Point3d ptMax( dMaxW, ( bCapOrBound ? dHCap : dAscent), 0) ; + // sistemazioni per la posizione del punto di inserimento + Vector3d vtIpMove = GetTextInsertPointMove( dMaxW, dHCap, dMinH, nInsPos) ; + ptMin.Translate( vtIpMove) ; + ptMax.Translate( vtIpMove) ; + + // assegno l'ingombro + b3Box.Set( ptMin, ptMax) ; + // ripristino il font originale SelectObject( m_hDC, hPrevFont) ; @@ -219,27 +249,7 @@ OsFont::GetLength( const string& sText, double& dLen) //---------------------------------------------------------------------------- bool -OsFont::GetBBox( const string& sText, BBox3d& b3Box) -{ - // recupero le dimensioni - double dAsc ; - if ( ! GetAscent( dAsc)) - return false ; - double dDesc ; - if ( ! GetDescent( dDesc)) - return false ; - double dLen ; - if ( ! GetLength( sText, dLen)) - return false ; - - // assegno l'ingombro - b3Box.Set( 0, - dDesc, 0, dLen, dAsc, 0) ; - return true ; -} - -//---------------------------------------------------------------------------- -bool -OsFont::GetOutline( const string& sText, ICURVEPLIST& lstPC) +OsFont::GetOutline( const string& sText, int nInsPos, ICURVEPLIST& lstPC) { // verifico esistenza font corrente if ( m_hDC == nullptr || m_hFont == nullptr || m_sFont.empty()) @@ -255,14 +265,29 @@ OsFont::GetOutline( const string& sText, ICURVEPLIST& lstPC) double dScaX = dScaY * m_dRatio ; double dScaZ = 1 ; + // recupero altezza maiuscole e interlinea + double dHCap = m_dHeight ; + double dH = m_dH * m_dHeight / m_dHCap ; + // converto i byte della stringa in codici carattere UINTVECTOR vCode ; GetCodePoints( sText, vCode) ; - // ciclo sui caratteri + // ciclo sui codici + double dMaxW = 0 ; + double dMinH = 0 ; Vector3d vtMove ; ICURVEPLIST lstTmpPC ; for ( unsigned int i = 0 ; i < vCode.size() ; ++ i) { + // verifico se comando di a capo + int nLbLen ; + if ( IsLineBreak( vCode, i, nLbLen)) { + vtMove.Set( 0, vtMove.y - dH, 0) ; + if ( vtMove.y < dMinH) + dMinH = vtMove.y ; + i += nLbLen ; + continue ; + } // recupero l'outline double dAdvance ; if ( ! GetCharOutline( vCode[i], dAdvance, lstTmpPC)) @@ -277,10 +302,18 @@ OsFont::GetOutline( const string& sText, ICURVEPLIST& lstPC) lstPC.push_back( (*iIter)) ; } vtMove += Vector3d( dAdvance * dScaX + m_dAddAdvance, 0, 0) ; + if ( vtMove.x > dMaxW) + dMaxW = vtMove.x ; // ciclo di pulizia ( non devo cancellare le curve, perchè spostate nella lista principale) lstTmpPC.clear() ; } + // sistemazioni per la posizione del punto di inserimento + Vector3d vtIpMove = GetTextInsertPointMove( dMaxW, dHCap, dMinH, nInsPos) ; + ICURVEPLIST::iterator iIter ; + for ( iIter = lstPC.begin() ; iIter != lstPC.end() ; ++ iIter) + (*iIter)->Translate( vtIpMove) ; + // ripristino il font originale SelectObject( m_hDC, hPrevFont) ; @@ -289,7 +322,8 @@ OsFont::GetOutline( const string& sText, ICURVEPLIST& lstPC) //---------------------------------------------------------------------------- bool -OsFont::ApproxWithLines( const string& sText, double dLinTol, double dAngTolDeg, POLYLINELIST& lstPL) +OsFont::ApproxWithLines( const string& sText, int nInsPos, double dLinTol, double dAngTolDeg, + POLYLINELIST& lstPL) { // verifico esistenza font corrente if ( m_hDC == nullptr || m_hFont == nullptr || m_sFont.empty()) @@ -305,14 +339,29 @@ OsFont::ApproxWithLines( const string& sText, double dLinTol, double dAngTolDeg, double dScaX = dScaY * m_dRatio ; double dScaZ = 1 ; + // recupero altezza maiuscole e interlinea + double dHCap = m_dHeight ; + double dH = m_dH * m_dHeight / m_dHCap ; + // converto i byte della stringa in codici carattere UINTVECTOR vCode ; GetCodePoints( sText, vCode) ; // ciclo sui caratteri + double dMaxW = 0 ; + double dMinH = 0 ; Vector3d vtMove ; ICURVEPLIST lstPC ; for ( unsigned int i = 0 ; i < vCode.size() ; ++ i) { + // verifico se comando di a capo + int nLbLen ; + if ( IsLineBreak( vCode, i, nLbLen)) { + vtMove.Set( 0, vtMove.y - dH, 0) ; + if ( vtMove.y < dMinH) + dMinH = vtMove.y ; + i += nLbLen ; + continue ; + } // recupero l'outline double dAdvance ; if ( ! GetCharOutline( vCode[i], dAdvance, lstPC)) @@ -327,12 +376,20 @@ OsFont::ApproxWithLines( const string& sText, double dLinTol, double dAngTolDeg, } } vtMove += Vector3d( dAdvance * dScaX + m_dAddAdvance, 0, 0) ; + if ( vtMove.x > dMaxW) + dMaxW = vtMove.x ; // ciclo di pulizia for ( iIter = lstPC.begin() ; iIter != lstPC.end() ; ++ iIter) delete (*iIter) ; lstPC.clear() ; } + // sistemazioni per la posizione del punto di inserimento + Vector3d vtIpMove = GetTextInsertPointMove( dMaxW, dHCap, dMinH, nInsPos) ; + POLYLINELIST::iterator iIter ; + for ( iIter = lstPL.begin() ; iIter != lstPL.end() ; ++ iIter) + (*iIter).Translate( vtIpMove) ; + // ripristino il font originale SelectObject( m_hDC, hPrevFont) ; diff --git a/OsFont.h b/FontOs.h similarity index 79% rename from OsFont.h rename to FontOs.h index 3b081ce..f7ee10e 100644 --- a/OsFont.h +++ b/FontOs.h @@ -1,7 +1,7 @@ //---------------------------------------------------------------------------- // EgalTech 2014-2014 //---------------------------------------------------------------------------- -// File : OsFont.h Data : 01.06.14 Versione : 1.5f1 +// File : FontOs.h Data : 05.06.14 Versione : 1.5f2 // Contenuto : Dichiarazione della classe OsFont (font di sistema). // // @@ -31,10 +31,10 @@ class OsFont bool GetCapHeight( double& dCapH) ; bool GetAscent( double& dAsc) ; bool GetDescent( double& dDesc) ; - bool GetLength( const std::string& sText, double& dLen) ; - bool GetBBox( const std::string& sText, BBox3d& b3Box) ; - bool GetOutline( const std::string& sText, ICURVEPLIST& lstPC) ; - bool ApproxWithLines( const std::string& sText, double dLinTol, double dAngTolDeg, POLYLINELIST& lstPL) ; + bool GetXBox( const std::string& sText, int nInsPos, bool bCapOrBound, BBox3d& b3Box) ; + bool GetOutline( const std::string& sText, int nInsPos, ICURVEPLIST& lstPC) ; + bool ApproxWithLines( const std::string& sText, int nInsPos, double dLinTol, double dAngTolDeg, + POLYLINELIST& lstPL) ; private : bool CalcFontData( void) ; diff --git a/GdbExecutor.cpp b/GdbExecutor.cpp index 3e6c9cf..7635c7c 100644 --- a/GdbExecutor.cpp +++ b/GdbExecutor.cpp @@ -264,8 +264,8 @@ GdbExecutor::ExecuteVector( const string& sCmd2, const STRVECTOR& vsParams) // definizione diretta if ( sCmd2 == "" || sCmd2 == "MAKE") { Vector3d Vect ; - // 3 parametri : Id, IdParent e vettore - if ( vsParams.size() != 3) + // 3 o 4 parametri : Id, IdParent, Vettore [, ScaleFactor] + if ( vsParams.size() != 3 && vsParams.size() != 4) return false ; // recupero il riferimento in cui è immerso Frame3d frVect ; @@ -274,11 +274,15 @@ GdbExecutor::ExecuteVector( const string& sCmd2, const STRVECTOR& vsParams) // recupero i tre componenti if ( ! GetVectorParam( vsParams[2], frVect, Vect)) return false ; + // recupero l'eventuale fattore di scala + double dScale = 1 ; + if ( vsParams.size() == 4 && ! FromString( vsParams[3], dScale)) + return false ; // creo il vettore IGeoVector3d* pGVect = CreateGeoVector3d() ; if ( pGVect == nullptr) return false ; - pGVect->Set( Vect) ; + pGVect->Set( Vect * dScale) ; return AddGeoObj( vsParams[0], vsParams[1], pGVect) ; } // definizione come differenza di due punti @@ -1971,8 +1975,8 @@ GdbExecutor::TextSimple( const STRVECTOR& vsParams) bool GdbExecutor::TextComplete( const STRVECTOR& vsParams) { - // parametri : Id, ParentId, Text, Point, AngDeg, Font, W, Italic, H, Rat, AddAdv - if ( vsParams.size() != 11) + // parametri : Id, ParentId, Text, Point, AngDeg, Font, W, Italic, H, Rat, AddAdv, PosIns + if ( vsParams.size() != 12) return false ; // recupero il riferimento in cui è immerso Frame3d frRef ; @@ -2005,12 +2009,34 @@ GdbExecutor::TextComplete( const STRVECTOR& vsParams) double dAddAdv ; if ( ! FromString( vsParams[10], dAddAdv)) return false ; + // falg per posizione di inserimento + int nInsPos = ETXT_IPBL ; + string sInsPos = vsParams[11] ; + ToUpper( sInsPos) ; + if ( sInsPos == "TL") + nInsPos = ETXT_IPTL ; + else if ( sInsPos == "TC") + nInsPos = ETXT_IPTC ; + else if ( sInsPos == "TR") + nInsPos = ETXT_IPTR ; + else if ( sInsPos == "ML") + nInsPos = ETXT_IPML ; + else if ( sInsPos == "MC") + nInsPos = ETXT_IPMC ; + else if ( sInsPos == "MR") + nInsPos = ETXT_IPMR ; + else if ( sInsPos == "BL") + nInsPos = ETXT_IPBL ; + else if ( sInsPos == "BC") + nInsPos = ETXT_IPBC ; + else if ( sInsPos == "BR") + nInsPos = ETXT_IPBR ; // creo il testo PtrOwner pTXT( CreateExtText()) ; if ( ! IsValid( pTXT)) return false ; // lo riempio - if ( ! pTXT->Set( vsParams[2], ptP, dAngRotDeg, vsParams[5], nW, bItl, dH, dRat, dAddAdv)) + if ( ! pTXT->Set( vsParams[2], ptP, dAngRotDeg, vsParams[5], nW, bItl, dH, dRat, dAddAdv, nInsPos)) return false ; // inserisco il testo nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pTXT)) ; @@ -2301,6 +2327,24 @@ GdbExecutor::GetVectorParam( const string& sParam, const Frame3d& frVect, Vector return false ; } } + // se testo + else if ( pGObj->GetType() == EXT_TEXT) { + // recupero il testo + const IExtText* pTxt = GetExtText( pGObj) ; + switch ( cType) { + case 'D' : // versore direzione longitudinale del testo + vtV = pTxt->GetDirVersor() ; + return vtV.LocToLoc( frEnt, frVect) ; + case 'H' : // versore direzione trasversale del testo + return ( pTxt->GetHeightVersor( vtV) && + vtV.LocToLoc( frEnt, frVect)) ; + case 'O' : // versore ortogonale al piano del testo + vtV = pTxt->GetNormVersor() ; + return vtV.LocToLoc( frEnt, frVect) ; + default : + return false ; + } + } } return false ; } @@ -2451,10 +2495,18 @@ GdbExecutor::GetPointParam( const string& sParam, const Frame3d& frPnt, Point3d& if ( ! pTxt->GetStartPoint( ptP)) return false ; return ptP.LocToLoc( frEnt, frPnt) ; + case 'T' : // punto sopra l'iniziale + if ( ! pTxt->GetOverStartPoint( ptP)) + return false ; + return ptP.LocToLoc( frEnt, frPnt) ; case 'E' : // punto finale if ( ! pTxt->GetEndPoint( ptP)) return false ; return ptP.LocToLoc( frEnt, frPnt) ; + case 'F' : // punto sopra il finale + if ( ! pTxt->GetOverEndPoint( ptP)) + return false ; + return ptP.LocToLoc( frEnt, frPnt) ; case 'M' : // punto medio if ( ! pTxt->GetMidPoint( ptP)) return false ;