Support text expansion in dimensions

This commit is contained in:
Jon Evans 2020-09-12 10:23:07 -04:00
parent de12d40ee6
commit 0347515cec
5 changed files with 14 additions and 5 deletions

View File

@ -50,13 +50,20 @@ DIMENSION::DIMENSION( BOARD_ITEM* aParent ) :
m_extensionOffset( 0 ),
m_textPosition( DIM_TEXT_POSITION::OUTSIDE ),
m_keepTextAligned( true ),
m_text( this ),
m_text( aParent ),
m_measuredValue( 0 )
{
m_Layer = Dwgs_User;
}
void DIMENSION::SetParent( EDA_ITEM* aParent )
{
BOARD_ITEM::SetParent( aParent );
m_text.SetParent( aParent );
}
void DIMENSION::SetPosition( const wxPoint& aPos )
{
m_text.SetTextPos( aPos );

View File

@ -92,6 +92,8 @@ class DIMENSION : public BOARD_ITEM
public:
DIMENSION( BOARD_ITEM* aParent );
void SetParent( EDA_ITEM* aParent ) override;
/**
* The dimension's origin is the first feature point for the dimension. Every dimension has
* one or more feature points, so every dimension has at least an origin.

View File

@ -50,8 +50,7 @@ TEXTE_PCB::~TEXTE_PCB()
wxString TEXTE_PCB::GetShownText( int aDepth ) const
{
BOARD* board = static_cast<BOARD*>( GetParent() );
wxASSERT( board );
BOARD* board = dynamic_cast<BOARD*>( GetParent() );
std::function<bool( wxString* )> pcbTextResolver =
[&]( wxString* token ) -> bool
@ -91,7 +90,7 @@ wxString TEXTE_PCB::GetShownText( int aDepth ) const
bool processTextVars = false;
wxString text = EDA_TEXT::GetShownText( &processTextVars );
if( processTextVars && aDepth < 10 )
if( board && processTextVars && aDepth < 10 )
text = ExpandTextVars( text, &pcbTextResolver, board->GetProject(), &boardTextResolver );
return text;

View File

@ -46,6 +46,7 @@ DIALOG_DIMENSION_PROPERTIES::DIALOG_DIMENSION_PROPERTIES( PCB_BASE_EDIT_FRAME* a
wxASSERT( aItem->Type() == PCB_DIMENSION_T );
m_dimension = static_cast<DIMENSION*>( aItem );
m_previewDimension = static_cast<DIMENSION*>( m_dimension->Clone() );
m_previewDimension->SetParent( m_frame->GetBoard() );
// Configure display origin transforms
m_textPosX.SetCoordType( ORIGIN_TRANSFORMS::ABS_X_COORD );

View File

@ -1296,7 +1296,7 @@ void PCB_PAINTER::draw( const DIMENSION* aDimension, int aLayer )
}
m_gal->SetTextAttributes( &text );
m_gal->StrokeText( aDimension->GetText(), position, text.GetTextAngleRadians() );
m_gal->StrokeText( text.GetShownText(), position, text.GetTextAngleRadians() );
}