EgtGeomKernel :
- migliorie e correzioni alle quotature.
This commit is contained in:
+81
-12
@@ -22,24 +22,32 @@
|
||||
#include "/EgtDev/Include/EGkStringUtils3d.h"
|
||||
#include "/EgtDev/Include/EGkExtText.h"
|
||||
#include "/EgtDev/Include/EGkUiUnits.h"
|
||||
#include "/EgtDev/Include/EgtNumUtils.h"
|
||||
#include <new>
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static const string IS_MEASURE = "<>" ;
|
||||
static const double STD_EXTLINELEN = 5.0 ;
|
||||
static const double MIN_EXTLINELEN = 0.1 ;
|
||||
static const double STD_ARROWLEN = 5.0 ;
|
||||
static const double MIN_ARROWLEN = 0.1 ;
|
||||
static const double STD_TEXTDIST = 2.0 ;
|
||||
static const double MIN_TEXTDIST = 0.1 ;
|
||||
static const int STD_DECDIGIT = -2 ;
|
||||
static const int MAX_DECDIGIT = 6 ;
|
||||
static const string STD_FONT = "ModernPropS.Nfe" ;
|
||||
static const int FONT_WEIGHT = 400 ;
|
||||
static const bool FONT_ITALIC = false ;
|
||||
static const double FONT_RATIO = 0.75 ;
|
||||
static const double FONT_ADDADVANCE = 0 ;
|
||||
static const double STD_TEXTHEIGHT = 10.0 ;
|
||||
static const double MIN_TEXTHEIGHT = 1.0 ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
GEOOBJ_REGISTER( EXT_DIMENSION, NGE_E_DIM, ExtDimension) ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
ExtDimension::ExtDimension( void)
|
||||
: m_dExtLineLen( 5), m_dArrowLen( 5), m_dTextDist( 2), m_bLenIsMM( true), m_nLenDec( -2), m_sFont( STD_FONT), m_dTextHeight( 10)
|
||||
: m_dExtLineLen( STD_EXTLINELEN), m_dArrowLen( STD_ARROWLEN), m_dTextDist( STD_TEXTDIST),
|
||||
m_bLenIsMM( true), m_nDecDigit( STD_DECDIGIT), m_sFont( STD_FONT), m_dTextHeight( STD_TEXTHEIGHT)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -48,6 +56,21 @@ ExtDimension::~ExtDimension( void)
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExtDimension::SetStyle( double dExtLineLen, double dArrowLen, double dTextDist, bool bLenIsMM,
|
||||
int nDecDigit, const string& sFont, double dTextHeight)
|
||||
{
|
||||
m_dExtLineLen = max( dExtLineLen, MIN_EXTLINELEN) ;
|
||||
m_dArrowLen = max( dArrowLen, MIN_ARROWLEN) ;
|
||||
m_dTextDist = max( dTextDist, MIN_TEXTDIST) ;
|
||||
m_bLenIsMM = bLenIsMM ;
|
||||
m_nDecDigit = Clamp( nDecDigit, -MAX_DECDIGIT, MAX_DECDIGIT) ;
|
||||
m_sFont = sFont ;
|
||||
m_dTextHeight = max( dTextHeight, MIN_TEXTHEIGHT) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExtDimension::SetLinear( const Point3d& ptP1, const Point3d& ptP2, const Point3d& ptPos,
|
||||
@@ -160,7 +183,7 @@ ExtDimension::CopyFrom( const ExtDimension& clSrc)
|
||||
m_dArrowLen = clSrc.m_dArrowLen ;
|
||||
m_dTextDist = clSrc.m_dTextDist ;
|
||||
m_bLenIsMM = clSrc.m_bLenIsMM ;
|
||||
m_nLenDec = clSrc.m_nLenDec ;
|
||||
m_nDecDigit = clSrc.m_nDecDigit ;
|
||||
m_sFont = clSrc.m_sFont ;
|
||||
m_dTextHeight = clSrc.m_dTextHeight ;
|
||||
m_nTempProp = clSrc.m_nTempProp ;
|
||||
@@ -213,7 +236,7 @@ ExtDimension::Dump( string& sOut, bool bMM, const char* szNewLine) const
|
||||
" Al=" + ToString( GetInUiUnits( m_dArrowLen, bMM), 3) +
|
||||
" Td=" + ToString( GetInUiUnits( m_dTextDist, bMM), 3) + szNewLine ;
|
||||
sOut += "Mm=" + string( m_bLenIsMM ? "1" : "0") +
|
||||
" Dec=" + ToString( m_nLenDec) + szNewLine ;
|
||||
" Dec=" + ToString( m_nDecDigit) + szNewLine ;
|
||||
sOut += "Fnt=" + m_sFont +
|
||||
" H=" + ToString( GetInUiUnits( m_dTextHeight, bMM), 3) + szNewLine ;
|
||||
|
||||
@@ -266,7 +289,7 @@ ExtDimension::Save( NgeWriter& ngeOut) const
|
||||
return false ;
|
||||
if ( ! ngeOut.WriteBool( m_bLenIsMM, ","))
|
||||
return false ;
|
||||
if ( ! ngeOut.WriteInt( m_nLenDec, ","))
|
||||
if ( ! ngeOut.WriteInt( m_nDecDigit, ","))
|
||||
return false ;
|
||||
if ( ! ngeOut.WriteString( m_sFont, ","))
|
||||
return false ;
|
||||
@@ -318,7 +341,7 @@ ExtDimension::Load( NgeReader& ngeIn)
|
||||
return false ;
|
||||
if ( ! ngeIn.ReadBool( m_bLenIsMM, ","))
|
||||
return false ;
|
||||
if ( ! ngeIn.ReadInt( m_nLenDec, ","))
|
||||
if ( ! ngeIn.ReadInt( m_nDecDigit, ","))
|
||||
return false ;
|
||||
if ( ! ngeIn.ReadString( m_sFont, ","))
|
||||
return false ;
|
||||
@@ -648,7 +671,7 @@ ExtDimension::Update( void) const
|
||||
m_sCalcText = m_sText ;
|
||||
if ( m_sCalcText.find( IS_MEASURE) != string::npos) {
|
||||
double dVal = ( m_ptP2 - m_ptP1) * m_vtDir * ( m_bLenIsMM ? 1 : 1. / ONEINCH) ;
|
||||
string sVal = ToString( dVal, m_nLenDec) ;
|
||||
string sVal = ToString( dVal, m_nDecDigit) ;
|
||||
ReplaceString( m_sCalcText, IS_MEASURE, sVal) ;
|
||||
}
|
||||
// punto di inserimento del testo
|
||||
@@ -685,6 +708,36 @@ ExtDimension::Update( void) const
|
||||
return false ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExtDimension::GetMidPoint( Point3d& ptMid) const
|
||||
{
|
||||
// eventuale ricalcolo
|
||||
Update() ;
|
||||
// se quota lineare
|
||||
if ( m_nType == DT_LINEAR) {
|
||||
ptMid = ( m_ptP1 + m_ptP2) / 2 ;
|
||||
return true ;
|
||||
}
|
||||
else
|
||||
return false ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExtDimension::GetCenterPoint( Point3d& ptCen) const
|
||||
{
|
||||
// eventuale ricalcolo
|
||||
Update() ;
|
||||
// se quota lineare
|
||||
if ( m_nType == DT_LINEAR) {
|
||||
ptCen = ( m_ptP5 + m_ptP6) / 2 ;
|
||||
return true ;
|
||||
}
|
||||
else
|
||||
return false ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExtDimension::ApproxWithLines( double dLinTol, double dAngTolDeg, POLYLINELIST& lstPL) const
|
||||
@@ -768,6 +821,18 @@ ExtDimension::GetArrowHead( const Point3d& ptTip, const Vector3d& vtDir, PolyLin
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExtDimension::SetCurrFont( FontManager& fntMgr) const
|
||||
{
|
||||
static const int FONT_WEIGHT = 400 ;
|
||||
static const bool FONT_ITALIC = false ;
|
||||
static const double FONT_RATIO = 0.75 ;
|
||||
static const double FONT_ADDADVANCE = 0 ;
|
||||
|
||||
return fntMgr.SetCurrFont( m_sFont, FONT_WEIGHT, FONT_ITALIC, m_dTextHeight, FONT_RATIO, FONT_ADDADVANCE) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExtDimension::ApproxTextWithLines( double dLinTol, double dAngTolDeg, POLYLINELIST& lstPL) const
|
||||
@@ -775,9 +840,13 @@ ExtDimension::ApproxTextWithLines( double dLinTol, double dAngTolDeg, POLYLINELI
|
||||
// eventuale ricalcolo
|
||||
Update() ;
|
||||
|
||||
// se testo vuoto, risultato vuoto
|
||||
if ( IsEmptyOrSpaces( m_sCalcText))
|
||||
return true ;
|
||||
|
||||
// imposto il font corrente e i suoi dati
|
||||
FontManager& fntMgr = FontManager::GetFontManager() ;
|
||||
if ( ! fntMgr.SetCurrFont( m_sFont, FONT_WEIGHT, FONT_ITALIC, m_dTextHeight, FONT_RATIO, FONT_ADDADVANCE))
|
||||
if ( ! SetCurrFont( fntMgr))
|
||||
return false ;
|
||||
|
||||
// richiedo l'outline
|
||||
@@ -809,7 +878,7 @@ ExtDimension::GetTextMyBBox( const Point3d& ptPos, BBox3d& b3Loc) const
|
||||
|
||||
// imposto il font corrente e i suoi dati
|
||||
FontManager& fntMgr = FontManager::GetFontManager() ;
|
||||
if ( ! fntMgr.SetCurrFont( m_sFont, FONT_WEIGHT, FONT_ITALIC, m_dTextHeight, FONT_RATIO, FONT_ADDADVANCE))
|
||||
if ( ! SetCurrFont( fntMgr))
|
||||
return false ;
|
||||
|
||||
// richiedo il box
|
||||
|
||||
Reference in New Issue
Block a user