mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-04-20 23:41:40 +00:00
Cherry-pick TEXT_ATTRIBUTES and EDA_ANGLE from rockola/kicad-strokefont
This commit is contained in:
parent
a0c4f05c17
commit
86cb57f4a7
common
CMakeLists.txt
drawing_sheet
eda_angle.cppeda_text.cppgal
gr_text.cpphash_eda.cppplotters
plugins/cadstar
preview_items
eeschema
autoplace_fields.cppsch_sheet.cppsch_text.cpp
dialogs
dialog_change_symbols.cppdialog_field_properties.cppdialog_lib_text_properties.cppdialog_update_symbol_fields.cpppanel_eeschema_color_settings.cpp
fields_grid_table.cpplib_field.cpplib_pin.cpplib_text.cpplib_text.hsch_field.cppsch_field.hsch_painter.cppsch_plugins
altium
cadstar
eagle
kicad
legacy
symbol_editor
tools
gerbview
include
pagelayout_editor/dialogs
pcbnew
dialogs
exporters
fp_text.cppfp_text.hfp_text_grid_table.cppimport_gfx
dxf_import_plugin.cppgraphics_importer.hgraphics_importer_buffer.cppgraphics_importer_buffer.hgraphics_importer_pcbnew.cppgraphics_importer_pcbnew.h
kicad_clipboard.cpppcb_dimension.cpppcb_painter.cpppcb_text.cpppcb_text.hplot_brditems_plotter.cppplugins
altium
cadstar
eagle
fabmaster
kicad
legacy
pcad
tools
@ -296,6 +296,9 @@ set( PLUGINS_EAGLE_SRCS
|
||||
plugins/eagle/eagle_parser.cpp
|
||||
)
|
||||
|
||||
set( FONT_SRCS
|
||||
)
|
||||
|
||||
set( COMMON_SRCS
|
||||
${LIB_KICAD_SRCS}
|
||||
${COMMON_ABOUT_DLG_SRCS}
|
||||
@ -307,6 +310,7 @@ set( COMMON_SRCS
|
||||
${PLUGINS_ALTIUM_SRCS}
|
||||
${PLUGINS_CADSTAR_SRCS}
|
||||
${PLUGINS_EAGLE_SRCS}
|
||||
${FONT_SRCS}
|
||||
advanced_config.cpp
|
||||
array_axis.cpp
|
||||
array_options.cpp
|
||||
@ -325,6 +329,7 @@ set( COMMON_SRCS
|
||||
dialog_shim.cpp
|
||||
gr_text.cpp
|
||||
dsnlexer.cpp
|
||||
eda_angle.cpp
|
||||
eda_base_frame.cpp
|
||||
eda_dde.cpp
|
||||
eda_doc.cpp
|
||||
|
@ -729,24 +729,24 @@ void DRAWING_SHEET_PARSER::parseText( DS_DATA_ITEM_TEXT* aItem )
|
||||
switch( token )
|
||||
{
|
||||
case T_center:
|
||||
aItem->m_Hjustify = GR_TEXT_HJUSTIFY_CENTER;
|
||||
aItem->m_Vjustify = GR_TEXT_VJUSTIFY_CENTER;
|
||||
aItem->m_Hjustify = GR_TEXT_H_ALIGN_CENTER;
|
||||
aItem->m_Vjustify = GR_TEXT_V_ALIGN_CENTER;
|
||||
break;
|
||||
|
||||
case T_left:
|
||||
aItem->m_Hjustify = GR_TEXT_HJUSTIFY_LEFT;
|
||||
aItem->m_Hjustify = GR_TEXT_H_ALIGN_LEFT;
|
||||
break;
|
||||
|
||||
case T_right:
|
||||
aItem->m_Hjustify = GR_TEXT_HJUSTIFY_RIGHT;
|
||||
aItem->m_Hjustify = GR_TEXT_H_ALIGN_RIGHT;
|
||||
break;
|
||||
|
||||
case T_top:
|
||||
aItem->m_Vjustify = GR_TEXT_VJUSTIFY_TOP;
|
||||
aItem->m_Vjustify = GR_TEXT_V_ALIGN_TOP;
|
||||
break;
|
||||
|
||||
case T_bottom:
|
||||
aItem->m_Vjustify = GR_TEXT_VJUSTIFY_BOTTOM;
|
||||
aItem->m_Vjustify = GR_TEXT_V_ALIGN_BOTTOM;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -523,8 +523,8 @@ DS_DATA_ITEM_TEXT::DS_DATA_ITEM_TEXT( const wxString& aTextBase ) :
|
||||
{
|
||||
m_TextBase = aTextBase;
|
||||
m_IncrementLabel = 1;
|
||||
m_Hjustify = GR_TEXT_HJUSTIFY_LEFT;
|
||||
m_Vjustify = GR_TEXT_VJUSTIFY_CENTER;
|
||||
m_Hjustify = GR_TEXT_H_ALIGN_LEFT;
|
||||
m_Vjustify = GR_TEXT_V_ALIGN_CENTER;
|
||||
m_Italic = false;
|
||||
m_Bold = false;
|
||||
m_Orient = 0.0;
|
||||
|
@ -272,20 +272,20 @@ void DS_DATA_MODEL_IO::format( DS_DATA_ITEM_TEXT* aItem, int aNestLevel ) const
|
||||
}
|
||||
|
||||
// Write text justification
|
||||
if( aItem->m_Hjustify != GR_TEXT_HJUSTIFY_LEFT || aItem->m_Vjustify != GR_TEXT_VJUSTIFY_CENTER )
|
||||
if( aItem->m_Hjustify != GR_TEXT_H_ALIGN_LEFT || aItem->m_Vjustify != GR_TEXT_V_ALIGN_CENTER )
|
||||
{
|
||||
m_out->Print( 0, " (justify" );
|
||||
|
||||
// Write T_center opt first, because it is
|
||||
// also a center for both m_Hjustify and m_Vjustify
|
||||
if( aItem->m_Hjustify == GR_TEXT_HJUSTIFY_CENTER )
|
||||
if( aItem->m_Hjustify == GR_TEXT_H_ALIGN_CENTER )
|
||||
m_out->Print( 0, " center" );
|
||||
else if( aItem->m_Hjustify == GR_TEXT_HJUSTIFY_RIGHT )
|
||||
else if( aItem->m_Hjustify == GR_TEXT_H_ALIGN_RIGHT )
|
||||
m_out->Print( 0, " right" );
|
||||
|
||||
if( aItem->m_Vjustify == GR_TEXT_VJUSTIFY_TOP )
|
||||
if( aItem->m_Vjustify == GR_TEXT_V_ALIGN_TOP )
|
||||
m_out->Print( 0, " top" );
|
||||
else if( aItem->m_Vjustify == GR_TEXT_VJUSTIFY_BOTTOM )
|
||||
else if( aItem->m_Vjustify == GR_TEXT_V_ALIGN_BOTTOM )
|
||||
m_out->Print( 0, " bottom" );
|
||||
|
||||
m_out->Print( 0, ")" );
|
||||
|
@ -236,7 +236,7 @@ void KIGFX::DS_PAINTER::draw( const DS_DRAW_ITEM_TEXT* aItem, int aLayer ) const
|
||||
|
||||
m_gal->Save();
|
||||
m_gal->Translate( position );
|
||||
m_gal->Rotate( -aItem->GetTextAngle() * M_PI / 1800.0 );
|
||||
m_gal->Rotate( -aItem->GetTextAngle().AsRadians() );
|
||||
m_gal->SetStrokeColor( m_renderSettings.GetColor( aItem, aLayer ) );
|
||||
m_gal->SetLineWidth( penWidth );
|
||||
m_gal->SetTextAttributes( aItem );
|
||||
|
114
common/eda_angle.cpp
Normal file
114
common/eda_angle.cpp
Normal file
@ -0,0 +1,114 @@
|
||||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2021 Ola Rinta-Koski
|
||||
* Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <eda_angle.h>
|
||||
|
||||
EDA_ANGLE EDA_ANGLE::m_angle0 = EDA_ANGLE( 0, EDA_ANGLE::DEGREES );
|
||||
EDA_ANGLE EDA_ANGLE::m_angle90 = EDA_ANGLE( 90, EDA_ANGLE::DEGREES );
|
||||
EDA_ANGLE EDA_ANGLE::m_angle180 = EDA_ANGLE( 180, EDA_ANGLE::DEGREES );
|
||||
EDA_ANGLE EDA_ANGLE::m_angle270 = EDA_ANGLE( 270, EDA_ANGLE::DEGREES );
|
||||
EDA_ANGLE EDA_ANGLE::m_angle360 = EDA_ANGLE( 360, EDA_ANGLE::DEGREES );
|
||||
|
||||
EDA_ANGLE EDA_ANGLE::KeepUpright() const
|
||||
{
|
||||
EDA_ANGLE inAngle( *this );
|
||||
inAngle.Normalize();
|
||||
|
||||
int inDegrees = inAngle.AsDegrees();
|
||||
int outDegrees;
|
||||
|
||||
if( inDegrees <= 45 || inDegrees >= 315 || ( inDegrees > 135 && inDegrees <= 225 ) )
|
||||
outDegrees = 0;
|
||||
else
|
||||
outDegrees = 90;
|
||||
|
||||
return EDA_ANGLE( outDegrees, EDA_ANGLE::DEGREES );
|
||||
}
|
||||
|
||||
|
||||
void EDA_ANGLE::normalize( bool n720 )
|
||||
{
|
||||
if( GetInitialAngleType() == EDA_ANGLE::RADIANS )
|
||||
{
|
||||
m_radians = normalize( m_radians, EDA_ANGLE::RADIANS, n720 );
|
||||
m_value = int( m_radians / TENTHS_OF_A_DEGREE_TO_RADIANS );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_value = normalize( m_value, EDA_ANGLE::TENTHS_OF_A_DEGREE, n720 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int EDA_ANGLE::normalize( int aValue, ANGLE_TYPE aAngleType, bool n720 ) const
|
||||
{
|
||||
int full_circle_upper;
|
||||
|
||||
switch( aAngleType )
|
||||
{
|
||||
case DEGREES:
|
||||
full_circle_upper = DEGREES_FULL_CIRCLE;
|
||||
break;
|
||||
|
||||
case TENTHS_OF_A_DEGREE:
|
||||
full_circle_upper = TENTHS_OF_A_DEGREE_FULL_CIRCLE;
|
||||
break;
|
||||
|
||||
case RADIANS:
|
||||
/* ?? should not get here */
|
||||
assert( 1 == 0 );
|
||||
}
|
||||
|
||||
/* if n720 == false, clamp between 0..full_circle_upper
|
||||
* if n720 == true, clamp between +/- full_circle_upper
|
||||
*/
|
||||
int full_circle_lower = n720 ? 0 : -full_circle_upper;
|
||||
|
||||
while( aValue < full_circle_lower )
|
||||
aValue += full_circle_upper;
|
||||
|
||||
while( aValue > full_circle_upper )
|
||||
aValue -= full_circle_upper;
|
||||
|
||||
return aValue;
|
||||
}
|
||||
|
||||
|
||||
double EDA_ANGLE::normalize( double aValue, ANGLE_TYPE aAngleType, bool n720 ) const
|
||||
{
|
||||
double full_circle_upper;
|
||||
|
||||
switch( aAngleType )
|
||||
{
|
||||
case DEGREES: full_circle_upper = DEGREES_FULL_CIRCLE; break;
|
||||
case TENTHS_OF_A_DEGREE: full_circle_upper = TENTHS_OF_A_DEGREE_FULL_CIRCLE; break;
|
||||
case RADIANS: full_circle_upper = RADIANS_FULL_CIRCLE; break;
|
||||
}
|
||||
|
||||
double full_circle_lower = n720 ? 0 : -full_circle_upper;
|
||||
|
||||
while( aValue < full_circle_lower )
|
||||
aValue += full_circle_upper;
|
||||
|
||||
while( aValue > full_circle_upper )
|
||||
aValue -= full_circle_upper;
|
||||
|
||||
return aValue;
|
||||
}
|
@ -70,37 +70,36 @@ void addTextSegmToPoly( int x0, int y0, int xf, int yf, void* aData )
|
||||
}
|
||||
|
||||
|
||||
EDA_TEXT_HJUSTIFY_T EDA_TEXT::MapHorizJustify( int aHorizJustify )
|
||||
GR_TEXT_H_ALIGN_T EDA_TEXT::MapHorizJustify( int aHorizJustify )
|
||||
{
|
||||
wxASSERT( aHorizJustify >= GR_TEXT_HJUSTIFY_LEFT && aHorizJustify <= GR_TEXT_HJUSTIFY_RIGHT );
|
||||
wxASSERT( aHorizJustify >= GR_TEXT_H_ALIGN_LEFT && aHorizJustify <= GR_TEXT_H_ALIGN_RIGHT );
|
||||
|
||||
if( aHorizJustify > GR_TEXT_HJUSTIFY_RIGHT )
|
||||
return GR_TEXT_HJUSTIFY_RIGHT;
|
||||
if( aHorizJustify > GR_TEXT_H_ALIGN_RIGHT )
|
||||
return GR_TEXT_H_ALIGN_RIGHT;
|
||||
|
||||
if( aHorizJustify < GR_TEXT_HJUSTIFY_LEFT )
|
||||
return GR_TEXT_HJUSTIFY_LEFT;
|
||||
if( aHorizJustify < GR_TEXT_H_ALIGN_LEFT )
|
||||
return GR_TEXT_H_ALIGN_LEFT;
|
||||
|
||||
return static_cast<EDA_TEXT_HJUSTIFY_T>( aHorizJustify );
|
||||
return static_cast<GR_TEXT_H_ALIGN_T>( aHorizJustify );
|
||||
}
|
||||
|
||||
|
||||
EDA_TEXT_VJUSTIFY_T EDA_TEXT::MapVertJustify( int aVertJustify )
|
||||
GR_TEXT_V_ALIGN_T EDA_TEXT::MapVertJustify( int aVertJustify )
|
||||
{
|
||||
wxASSERT( aVertJustify >= GR_TEXT_VJUSTIFY_TOP && aVertJustify <= GR_TEXT_VJUSTIFY_BOTTOM );
|
||||
wxASSERT( aVertJustify >= GR_TEXT_V_ALIGN_TOP && aVertJustify <= GR_TEXT_V_ALIGN_BOTTOM );
|
||||
|
||||
if( aVertJustify > GR_TEXT_VJUSTIFY_BOTTOM )
|
||||
return GR_TEXT_VJUSTIFY_BOTTOM;
|
||||
if( aVertJustify > GR_TEXT_V_ALIGN_BOTTOM )
|
||||
return GR_TEXT_V_ALIGN_BOTTOM;
|
||||
|
||||
if( aVertJustify < GR_TEXT_VJUSTIFY_TOP )
|
||||
return GR_TEXT_VJUSTIFY_TOP;
|
||||
if( aVertJustify < GR_TEXT_V_ALIGN_TOP )
|
||||
return GR_TEXT_V_ALIGN_TOP;
|
||||
|
||||
return static_cast<EDA_TEXT_VJUSTIFY_T>( aVertJustify );
|
||||
return static_cast<GR_TEXT_V_ALIGN_T>( aVertJustify );
|
||||
}
|
||||
|
||||
|
||||
EDA_TEXT::EDA_TEXT( const wxString& text ) :
|
||||
m_text( text ),
|
||||
m_e( 1 << TE_VISIBLE )
|
||||
m_text( text )
|
||||
{
|
||||
int sz = Mils2iu( DEFAULT_SIZE_TEXT );
|
||||
SetTextSize( wxSize( sz, sz ) );
|
||||
@ -110,7 +109,7 @@ EDA_TEXT::EDA_TEXT( const wxString& text ) :
|
||||
|
||||
EDA_TEXT::EDA_TEXT( const EDA_TEXT& aText ) :
|
||||
m_text( aText.m_text ),
|
||||
m_e( aText.m_e )
|
||||
m_attributes( aText.m_attributes )
|
||||
{
|
||||
cacheShownText();
|
||||
}
|
||||
@ -136,9 +135,10 @@ void EDA_TEXT::CopyText( const EDA_TEXT& aSrc )
|
||||
}
|
||||
|
||||
|
||||
void EDA_TEXT::SetEffects( const EDA_TEXT& aSrc )
|
||||
void EDA_TEXT::SetAttributes( const EDA_TEXT& aSrc )
|
||||
{
|
||||
m_e = aSrc.m_e;
|
||||
m_attributes = aSrc.m_attributes;
|
||||
m_pos = aSrc.m_pos;
|
||||
}
|
||||
|
||||
|
||||
@ -150,9 +150,10 @@ void EDA_TEXT::SwapText( EDA_TEXT& aTradingPartner )
|
||||
}
|
||||
|
||||
|
||||
void EDA_TEXT::SwapEffects( EDA_TEXT& aTradingPartner )
|
||||
void EDA_TEXT::SwapAttributes( EDA_TEXT& aTradingPartner )
|
||||
{
|
||||
std::swap( m_e, aTradingPartner.m_e );
|
||||
std::swap( m_attributes, aTradingPartner.m_attributes );
|
||||
std::swap( m_pos, aTradingPartner.m_pos );
|
||||
}
|
||||
|
||||
|
||||
@ -328,16 +329,16 @@ EDA_RECT EDA_TEXT::GetTextBox( int aLine, bool aInvertY ) const
|
||||
*/
|
||||
switch( GetHorizJustify() )
|
||||
{
|
||||
case GR_TEXT_HJUSTIFY_LEFT:
|
||||
case GR_TEXT_H_ALIGN_LEFT:
|
||||
if( IsMirrored() )
|
||||
rect.SetX( rect.GetX() - rect.GetWidth() );
|
||||
break;
|
||||
|
||||
case GR_TEXT_HJUSTIFY_CENTER:
|
||||
case GR_TEXT_H_ALIGN_CENTER:
|
||||
rect.SetX( rect.GetX() - (rect.GetWidth() / 2) );
|
||||
break;
|
||||
|
||||
case GR_TEXT_HJUSTIFY_RIGHT:
|
||||
case GR_TEXT_H_ALIGN_RIGHT:
|
||||
if( !IsMirrored() )
|
||||
rect.SetX( rect.GetX() - rect.GetWidth() );
|
||||
break;
|
||||
@ -345,14 +346,14 @@ EDA_RECT EDA_TEXT::GetTextBox( int aLine, bool aInvertY ) const
|
||||
|
||||
switch( GetVertJustify() )
|
||||
{
|
||||
case GR_TEXT_VJUSTIFY_TOP:
|
||||
case GR_TEXT_V_ALIGN_TOP:
|
||||
break;
|
||||
|
||||
case GR_TEXT_VJUSTIFY_CENTER:
|
||||
case GR_TEXT_V_ALIGN_CENTER:
|
||||
rect.SetY( rect.GetY() - ( dy / 2) );
|
||||
break;
|
||||
|
||||
case GR_TEXT_VJUSTIFY_BOTTOM:
|
||||
case GR_TEXT_V_ALIGN_BOTTOM:
|
||||
rect.SetY( rect.GetY() - dy );
|
||||
break;
|
||||
}
|
||||
@ -364,15 +365,15 @@ EDA_RECT EDA_TEXT::GetTextBox( int aLine, bool aInvertY ) const
|
||||
|
||||
switch( GetVertJustify() )
|
||||
{
|
||||
case GR_TEXT_VJUSTIFY_TOP:
|
||||
case GR_TEXT_V_ALIGN_TOP:
|
||||
break;
|
||||
|
||||
case GR_TEXT_VJUSTIFY_CENTER:
|
||||
case GR_TEXT_V_ALIGN_CENTER:
|
||||
yoffset = linecount * GetInterline() / 2;
|
||||
rect.SetY( rect.GetY() - yoffset );
|
||||
break;
|
||||
|
||||
case GR_TEXT_VJUSTIFY_BOTTOM:
|
||||
case GR_TEXT_V_ALIGN_BOTTOM:
|
||||
yoffset = linecount * GetInterline();
|
||||
rect.SetY( rect.GetY() - yoffset );
|
||||
break;
|
||||
@ -395,7 +396,7 @@ bool EDA_TEXT::TextHitTest( const wxPoint& aPoint, int aAccuracy ) const
|
||||
wxPoint location = aPoint;
|
||||
|
||||
rect.Inflate( aAccuracy );
|
||||
RotatePoint( &location, GetTextPos(), -GetTextAngle() );
|
||||
RotatePoint( &location, GetTextPos(), -GetTextAngle().AsTenthsOfADegree() );
|
||||
|
||||
return rect.Contains( location );
|
||||
}
|
||||
@ -410,7 +411,7 @@ bool EDA_TEXT::TextHitTest( const EDA_RECT& aRect, bool aContains, int aAccuracy
|
||||
if( aContains )
|
||||
return rect.Contains( GetTextBox() );
|
||||
|
||||
return rect.Intersects( GetTextBox(), GetTextAngle() );
|
||||
return rect.Intersects( GetTextBox(), GetTextAngle().AsTenthsOfADegree() );
|
||||
}
|
||||
|
||||
|
||||
@ -451,14 +452,14 @@ void EDA_TEXT::GetLinePositions( std::vector<wxPoint>& aPositions, int aLineCoun
|
||||
{
|
||||
switch( GetVertJustify() )
|
||||
{
|
||||
case GR_TEXT_VJUSTIFY_TOP:
|
||||
case GR_TEXT_V_ALIGN_TOP:
|
||||
break;
|
||||
|
||||
case GR_TEXT_VJUSTIFY_CENTER:
|
||||
case GR_TEXT_V_ALIGN_CENTER:
|
||||
pos.y -= ( aLineCount - 1 ) * offset.y / 2;
|
||||
break;
|
||||
|
||||
case GR_TEXT_VJUSTIFY_BOTTOM:
|
||||
case GR_TEXT_V_ALIGN_BOTTOM:
|
||||
pos.y -= ( aLineCount - 1 ) * offset.y;
|
||||
break;
|
||||
}
|
||||
@ -466,10 +467,10 @@ void EDA_TEXT::GetLinePositions( std::vector<wxPoint>& aPositions, int aLineCoun
|
||||
|
||||
// Rotate the position of the first line
|
||||
// around the center of the multiline text block
|
||||
RotatePoint( &pos, GetTextPos(), GetTextAngle() );
|
||||
RotatePoint( &pos, GetTextPos(), GetTextAngle().AsTenthsOfADegree() );
|
||||
|
||||
// Rotate the offset lines to increase happened in the right direction
|
||||
RotatePoint( &offset, GetTextAngle() );
|
||||
RotatePoint( &offset, GetTextAngle().AsTenthsOfADegree() );
|
||||
|
||||
for( int ii = 0; ii < aLineCount; ii++ )
|
||||
{
|
||||
@ -523,8 +524,8 @@ bool EDA_TEXT::IsDefaultFormatting() const
|
||||
{
|
||||
return ( IsVisible()
|
||||
&& !IsMirrored()
|
||||
&& GetHorizJustify() == GR_TEXT_HJUSTIFY_CENTER
|
||||
&& GetVertJustify() == GR_TEXT_VJUSTIFY_CENTER
|
||||
&& GetHorizJustify() == GR_TEXT_H_ALIGN_CENTER
|
||||
&& GetVertJustify() == GR_TEXT_V_ALIGN_CENTER
|
||||
&& GetTextThickness() == 0
|
||||
&& !IsItalic()
|
||||
&& !IsBold()
|
||||
@ -541,9 +542,9 @@ void EDA_TEXT::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControl
|
||||
|
||||
aFormatter->Print( aNestLevel + 1, "(effects" );
|
||||
|
||||
// Text size
|
||||
aFormatter->Print( 0, " (font" );
|
||||
|
||||
// Text size
|
||||
aFormatter->Print( 0, " (size %s %s)",
|
||||
FormatInternalUnits( GetTextHeight() ).c_str(),
|
||||
FormatInternalUnits( GetTextWidth() ).c_str() );
|
||||
@ -562,16 +563,16 @@ void EDA_TEXT::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControl
|
||||
|
||||
aFormatter->Print( 0, ")"); // (font
|
||||
|
||||
if( IsMirrored() || GetHorizJustify() != GR_TEXT_HJUSTIFY_CENTER
|
||||
|| GetVertJustify() != GR_TEXT_VJUSTIFY_CENTER )
|
||||
if( IsMirrored() || GetHorizJustify() != GR_TEXT_H_ALIGN_CENTER
|
||||
|| GetVertJustify() != GR_TEXT_V_ALIGN_CENTER )
|
||||
{
|
||||
aFormatter->Print( 0, " (justify");
|
||||
|
||||
if( GetHorizJustify() != GR_TEXT_HJUSTIFY_CENTER )
|
||||
aFormatter->Print( 0, GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT ? " left" : " right" );
|
||||
if( GetHorizJustify() != GR_TEXT_H_ALIGN_CENTER )
|
||||
aFormatter->Print( 0, GetHorizJustify() == GR_TEXT_H_ALIGN_LEFT ? " left" : " right" );
|
||||
|
||||
if( GetVertJustify() != GR_TEXT_VJUSTIFY_CENTER )
|
||||
aFormatter->Print( 0, GetVertJustify() == GR_TEXT_VJUSTIFY_TOP ? " top" : " bottom" );
|
||||
if( GetVertJustify() != GR_TEXT_V_ALIGN_CENTER )
|
||||
aFormatter->Print( 0, GetVertJustify() == GR_TEXT_V_ALIGN_TOP ? " top" : " bottom" );
|
||||
|
||||
if( IsMirrored() )
|
||||
aFormatter->Print( 0, " mirror" );
|
||||
@ -661,15 +662,22 @@ int EDA_TEXT::Compare( const EDA_TEXT* aOther ) const
|
||||
#define TEST_E( a, b ) { if( abs( a - b ) > EPSILON ) return a - b; }
|
||||
#define TEST_PT( a, b ) { TEST_E( a.x, b.x ); TEST_E( a.y, b.y ); }
|
||||
|
||||
TEST_PT( m_e.pos, aOther->m_e.pos );
|
||||
TEST_PT( m_pos, aOther->m_pos );
|
||||
|
||||
TEST_PT( m_e.size, aOther->m_e.size );
|
||||
TEST_E( m_e.penwidth, aOther->m_e.penwidth );
|
||||
TEST( m_e.angle, aOther->m_e.angle );
|
||||
TEST_PT( m_attributes.m_Size, aOther->m_attributes.m_Size );
|
||||
TEST_E( m_attributes.m_StrokeWidth, aOther->m_attributes.m_StrokeWidth );
|
||||
TEST( m_attributes.m_Angle.AsTenthsOfADegree(), aOther->m_attributes.m_Angle.AsTenthsOfADegree() );
|
||||
TEST( m_attributes.m_LineSpacing, aOther->m_attributes.m_LineSpacing );
|
||||
|
||||
TEST( m_e.hjustify, aOther->m_e.hjustify );
|
||||
TEST( m_e.vjustify, aOther->m_e.vjustify );
|
||||
TEST( m_e.bits, aOther->m_e.bits );
|
||||
TEST( m_attributes.m_Halign, aOther->m_attributes.m_Halign );
|
||||
TEST( m_attributes.m_Valign, aOther->m_attributes.m_Valign );
|
||||
TEST( m_attributes.m_Italic, aOther->m_attributes.m_Italic );
|
||||
TEST( m_attributes.m_Bold, aOther->m_attributes.m_Bold );
|
||||
TEST( m_attributes.m_Underlined, aOther->m_attributes.m_Underlined );
|
||||
TEST( m_attributes.m_Visible, aOther->m_attributes.m_Visible );
|
||||
TEST( m_attributes.m_Mirrored, aOther->m_attributes.m_Mirrored );
|
||||
TEST( m_attributes.m_Multiline, aOther->m_attributes.m_Multiline );
|
||||
TEST( m_attributes.m_KeepUpright, aOther->m_attributes.m_KeepUpright );
|
||||
|
||||
return m_text.Cmp( aOther->m_text );
|
||||
}
|
||||
@ -715,7 +723,7 @@ void EDA_TEXT::TransformBoundingBoxWithClearanceToPolygon( SHAPE_POLY_SET* aCorn
|
||||
for( wxPoint& corner : corners )
|
||||
{
|
||||
// Rotate polygon
|
||||
RotatePoint( &corner.x, &corner.y, GetTextPos().x, GetTextPos().y, GetTextAngle() );
|
||||
RotatePoint( &corner, GetTextPos(), GetTextAngle().AsTenthsOfADegree() );
|
||||
aCornerBuffer->Append( corner.x, corner.y );
|
||||
}
|
||||
}
|
||||
@ -725,14 +733,14 @@ static struct EDA_TEXT_DESC
|
||||
{
|
||||
EDA_TEXT_DESC()
|
||||
{
|
||||
ENUM_MAP<EDA_TEXT_HJUSTIFY_T>::Instance()
|
||||
.Map( GR_TEXT_HJUSTIFY_LEFT, _HKI( "Left" ) )
|
||||
.Map( GR_TEXT_HJUSTIFY_CENTER, _HKI( "Center" ) )
|
||||
.Map( GR_TEXT_HJUSTIFY_RIGHT, _HKI( "Right" ) );
|
||||
ENUM_MAP<EDA_TEXT_VJUSTIFY_T>::Instance()
|
||||
.Map( GR_TEXT_VJUSTIFY_TOP, _HKI( "Top" ) )
|
||||
.Map( GR_TEXT_VJUSTIFY_CENTER, _HKI( "Center" ) )
|
||||
.Map( GR_TEXT_VJUSTIFY_BOTTOM, _HKI( "Bottom" ) );
|
||||
ENUM_MAP<GR_TEXT_H_ALIGN_T>::Instance()
|
||||
.Map( GR_TEXT_H_ALIGN_LEFT, _HKI( "Left" ) )
|
||||
.Map( GR_TEXT_H_ALIGN_CENTER, _HKI( "Center" ) )
|
||||
.Map( GR_TEXT_H_ALIGN_RIGHT, _HKI( "Right" ) );
|
||||
ENUM_MAP<GR_TEXT_V_ALIGN_T>::Instance()
|
||||
.Map( GR_TEXT_V_ALIGN_TOP, _HKI( "Top" ) )
|
||||
.Map( GR_TEXT_V_ALIGN_CENTER, _HKI( "Center" ) )
|
||||
.Map( GR_TEXT_V_ALIGN_BOTTOM, _HKI( "Bottom" ) );
|
||||
|
||||
PROPERTY_MANAGER& propMgr = PROPERTY_MANAGER::Instance();
|
||||
REGISTER_TYPE( EDA_TEXT );
|
||||
@ -762,15 +770,15 @@ static struct EDA_TEXT_DESC
|
||||
&EDA_TEXT::GetTextHeight,
|
||||
PROPERTY_DISPLAY::DISTANCE ) );
|
||||
propMgr.AddProperty( new PROPERTY_ENUM<EDA_TEXT,
|
||||
EDA_TEXT_HJUSTIFY_T>( _HKI( "Horizontal Justification" ),
|
||||
&EDA_TEXT::SetHorizJustify,
|
||||
&EDA_TEXT::GetHorizJustify ) );
|
||||
GR_TEXT_H_ALIGN_T>( _HKI( "Horizontal Justification" ),
|
||||
&EDA_TEXT::SetHorizJustify,
|
||||
&EDA_TEXT::GetHorizJustify ) );
|
||||
propMgr.AddProperty( new PROPERTY_ENUM<EDA_TEXT,
|
||||
EDA_TEXT_VJUSTIFY_T>( _HKI( "Vertical Justification" ),
|
||||
&EDA_TEXT::SetVertJustify,
|
||||
&EDA_TEXT::GetVertJustify ) );
|
||||
GR_TEXT_V_ALIGN_T>( _HKI( "Vertical Justification" ),
|
||||
&EDA_TEXT::SetVertJustify,
|
||||
&EDA_TEXT::GetVertJustify ) );
|
||||
}
|
||||
} _EDA_TEXT_DESC;
|
||||
|
||||
ENUM_TO_WXANY( EDA_TEXT_HJUSTIFY_T )
|
||||
ENUM_TO_WXANY( EDA_TEXT_VJUSTIFY_T )
|
||||
ENUM_TO_WXANY( GR_TEXT_H_ALIGN_T )
|
||||
ENUM_TO_WXANY( GR_TEXT_V_ALIGN_T )
|
||||
|
@ -170,8 +170,8 @@ void GAL::ResetTextAttributes()
|
||||
// there is no built-in default
|
||||
SetGlyphSize( { 1.0, 1.0 } );
|
||||
|
||||
SetHorizontalJustify( GR_TEXT_HJUSTIFY_CENTER );
|
||||
SetVerticalJustify( GR_TEXT_VJUSTIFY_CENTER );
|
||||
SetHorizontalJustify( GR_TEXT_H_ALIGN_CENTER );
|
||||
SetVerticalJustify( GR_TEXT_V_ALIGN_CENTER );
|
||||
|
||||
SetFontBold( false );
|
||||
SetFontItalic( false );
|
||||
|
@ -1299,16 +1299,16 @@ void OPENGL_GAL::BitmapText( const wxString& aText, const VECTOR2D& aPosition,
|
||||
|
||||
switch( GetHorizontalJustify() )
|
||||
{
|
||||
case GR_TEXT_HJUSTIFY_CENTER:
|
||||
case GR_TEXT_H_ALIGN_CENTER:
|
||||
Translate( VECTOR2D( -textSize.x / 2.0, 0 ) );
|
||||
break;
|
||||
|
||||
case GR_TEXT_HJUSTIFY_RIGHT:
|
||||
case GR_TEXT_H_ALIGN_RIGHT:
|
||||
//if( !IsTextMirrored() )
|
||||
Translate( VECTOR2D( -textSize.x, 0 ) );
|
||||
break;
|
||||
|
||||
case GR_TEXT_HJUSTIFY_LEFT:
|
||||
case GR_TEXT_H_ALIGN_LEFT:
|
||||
//if( IsTextMirrored() )
|
||||
//Translate( VECTOR2D( -textSize.x, 0 ) );
|
||||
break;
|
||||
@ -1316,17 +1316,17 @@ void OPENGL_GAL::BitmapText( const wxString& aText, const VECTOR2D& aPosition,
|
||||
|
||||
switch( GetVerticalJustify() )
|
||||
{
|
||||
case GR_TEXT_VJUSTIFY_TOP:
|
||||
case GR_TEXT_V_ALIGN_TOP:
|
||||
Translate( VECTOR2D( 0, -textSize.y ) );
|
||||
overbarHeight = -textSize.y / 2.0;
|
||||
break;
|
||||
|
||||
case GR_TEXT_VJUSTIFY_CENTER:
|
||||
case GR_TEXT_V_ALIGN_CENTER:
|
||||
Translate( VECTOR2D( 0, -textSize.y / 2.0 ) );
|
||||
overbarHeight = 0;
|
||||
break;
|
||||
|
||||
case GR_TEXT_VJUSTIFY_BOTTOM:
|
||||
case GR_TEXT_V_ALIGN_BOTTOM:
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -207,15 +207,15 @@ void STROKE_FONT::Draw( const UTF8& aText, const VECTOR2D& aPosition, double aRo
|
||||
// align the 1st line of text
|
||||
switch( m_gal->GetVerticalJustify() )
|
||||
{
|
||||
case GR_TEXT_VJUSTIFY_TOP:
|
||||
case GR_TEXT_V_ALIGN_TOP:
|
||||
m_gal->Translate( VECTOR2D( 0, glyphSize.y ) );
|
||||
break;
|
||||
|
||||
case GR_TEXT_VJUSTIFY_CENTER:
|
||||
case GR_TEXT_V_ALIGN_CENTER:
|
||||
m_gal->Translate( VECTOR2D( 0, glyphSize.y / 2.0 ) );
|
||||
break;
|
||||
|
||||
case GR_TEXT_VJUSTIFY_BOTTOM:
|
||||
case GR_TEXT_V_ALIGN_BOTTOM:
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -226,14 +226,14 @@ void STROKE_FONT::Draw( const UTF8& aText, const VECTOR2D& aPosition, double aRo
|
||||
{
|
||||
switch( m_gal->GetVerticalJustify() )
|
||||
{
|
||||
case GR_TEXT_VJUSTIFY_TOP:
|
||||
case GR_TEXT_V_ALIGN_TOP:
|
||||
break;
|
||||
|
||||
case GR_TEXT_VJUSTIFY_CENTER:
|
||||
case GR_TEXT_V_ALIGN_CENTER:
|
||||
m_gal->Translate( VECTOR2D(0, -( lineCount - 1 ) * lineHeight / 2) );
|
||||
break;
|
||||
|
||||
case GR_TEXT_VJUSTIFY_BOTTOM:
|
||||
case GR_TEXT_V_ALIGN_BOTTOM:
|
||||
m_gal->Translate( VECTOR2D(0, -( lineCount - 1 ) * lineHeight ) );
|
||||
break;
|
||||
}
|
||||
@ -295,16 +295,16 @@ void STROKE_FONT::drawSingleLineText( const UTF8& aText )
|
||||
// Adjust the text position to the given horizontal justification
|
||||
switch( m_gal->GetHorizontalJustify() )
|
||||
{
|
||||
case GR_TEXT_HJUSTIFY_CENTER:
|
||||
case GR_TEXT_H_ALIGN_CENTER:
|
||||
m_gal->Translate( VECTOR2D( -textSize.x / 2.0, 0 ) );
|
||||
break;
|
||||
|
||||
case GR_TEXT_HJUSTIFY_RIGHT:
|
||||
case GR_TEXT_H_ALIGN_RIGHT:
|
||||
if( !m_gal->IsTextMirrored() )
|
||||
m_gal->Translate( VECTOR2D( -textSize.x, 0 ) );
|
||||
break;
|
||||
|
||||
case GR_TEXT_HJUSTIFY_LEFT:
|
||||
case GR_TEXT_H_ALIGN_LEFT:
|
||||
if( m_gal->IsTextMirrored() )
|
||||
m_gal->Translate( VECTOR2D( -textSize.x, 0 ) );
|
||||
break;
|
||||
|
@ -31,7 +31,6 @@
|
||||
|
||||
#include <gr_basic.h>
|
||||
#include <plotters/plotter.h>
|
||||
#include <eda_text.h> // EDA_TEXT_HJUSTIFY_T and EDA_TEXT_VJUSTIFY_T
|
||||
#include <trigo.h>
|
||||
#include <base_screen.h>
|
||||
#include <math/util.h> // for KiROUND
|
||||
@ -109,7 +108,7 @@ int GraphicTextWidth( const wxString& aText, const wxSize& aSize, bool aItalic,
|
||||
* @param aPos is the text position (according to h_justify, v_justify).
|
||||
* @param aColor is the text color.
|
||||
* @param aText is the text to draw.
|
||||
* @param aOrient is the angle in 0.1 degree.
|
||||
* @param aOrient is the angle.
|
||||
* @param aSize is the text size (size.x or size.y can be < 0 for mirrored texts).
|
||||
* @param aH_justify is the horizontal justification (Left, center, right).
|
||||
* @param aV_justify is the vertical justification (bottom, center, top).
|
||||
@ -127,8 +126,8 @@ int GraphicTextWidth( const wxString& aText, const wxSize& aSize, bool aItalic,
|
||||
* the text. NULL to draw this text.
|
||||
*/
|
||||
void GRText( wxDC* aDC, const wxPoint& aPos, const COLOR4D& aColor, const wxString& aText,
|
||||
double aOrient, const wxSize& aSize, enum EDA_TEXT_HJUSTIFY_T aH_justify,
|
||||
enum EDA_TEXT_VJUSTIFY_T aV_justify, int aWidth, bool aItalic, bool aBold,
|
||||
const EDA_ANGLE& aOrient, const wxSize& aSize, enum GR_TEXT_H_ALIGN_T aH_justify,
|
||||
enum GR_TEXT_V_ALIGN_T aV_justify, int aWidth, bool aItalic, bool aBold,
|
||||
void (* aCallback)( int x0, int y0, int xf, int yf, void* aData ),
|
||||
void* aCallbackData, PLOTTER* aPlotter )
|
||||
{
|
||||
@ -166,72 +165,7 @@ void GRText( wxDC* aDC, const wxPoint& aPos, const COLOR4D& aColor, const wxStri
|
||||
basic_gal.m_DC = aDC;
|
||||
basic_gal.m_Color = aColor;
|
||||
basic_gal.SetClipBox( nullptr );
|
||||
basic_gal.StrokeText( aText, VECTOR2D( aPos ), aOrient * M_PI/1800 );
|
||||
basic_gal.StrokeText( aText, VECTOR2D( aPos ), aOrient.AsRadians() );
|
||||
}
|
||||
|
||||
|
||||
void GRHaloText( wxDC* aDC, const wxPoint &aPos, const COLOR4D& aBgColor, const COLOR4D& aColor1,
|
||||
const COLOR4D& aColor2, const wxString &aText, double aOrient, const wxSize &aSize,
|
||||
enum EDA_TEXT_HJUSTIFY_T aH_justify, enum EDA_TEXT_VJUSTIFY_T aV_justify,
|
||||
int aWidth, bool aItalic, bool aBold,
|
||||
void (*aCallback)( int x0, int y0, int xf, int yf, void* aData ),
|
||||
void* aCallbackData, PLOTTER * aPlotter )
|
||||
{
|
||||
COLOR4D color1 = aColor1;
|
||||
COLOR4D color2 = aColor2;
|
||||
|
||||
// Swap color if contrast would be better
|
||||
// TODO: Maybe calculate contrast some way other than brightness
|
||||
if( aBgColor.GetBrightness() > 0.5 )
|
||||
{
|
||||
COLOR4D c = color1;
|
||||
color1 = color2;
|
||||
color2 = c;
|
||||
}
|
||||
|
||||
// Draw the background
|
||||
GRText( aDC, aPos, color1, aText, aOrient, aSize, aH_justify, aV_justify, aWidth, aItalic,
|
||||
aBold, aCallback, aCallbackData, aPlotter );
|
||||
|
||||
// Draw the text
|
||||
GRText( aDC, aPos, color2, aText, aOrient, aSize, aH_justify, aV_justify, aWidth / 4, aItalic,
|
||||
aBold, aCallback, aCallbackData, aPlotter );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Same as GRText, but plot graphic text instead of draw it.
|
||||
*
|
||||
* @param aPos is the text position (according to aH_justify, aV_justify).
|
||||
* @param aColor is the text color.
|
||||
* @param aText is the text to draw.
|
||||
* @param aOrient is the angle in 0.1 degree.
|
||||
* @param aSize is the text size (size.x or size.y can be < 0 for mirrored texts).
|
||||
* @param aH_justify is the horizontal justification (Left, center, right).
|
||||
* @param aV_justify is the vertical justification (bottom, center, top).
|
||||
* @param aPenWidth is the line width (if = 0, use plot default line width).
|
||||
* @param aItalic is the true to simulate an italic font.
|
||||
* @param aBold use true to use a bold font Useful only with default width value (aWidth = 0).
|
||||
* @param aMultilineAllowed use true to plot text as multiline, otherwise single line.
|
||||
* @param aData is a parameter used by some plotters in SetCurrentLineWidth(),
|
||||
* not directly used here.
|
||||
*/
|
||||
void PLOTTER::Text( const wxPoint& aPos,
|
||||
const COLOR4D& aColor,
|
||||
const wxString& aText,
|
||||
double aOrient,
|
||||
const wxSize& aSize,
|
||||
enum EDA_TEXT_HJUSTIFY_T aH_justify,
|
||||
enum EDA_TEXT_VJUSTIFY_T aV_justify,
|
||||
int aPenWidth,
|
||||
bool aItalic,
|
||||
bool aBold,
|
||||
bool aMultilineAllowed,
|
||||
void* aData )
|
||||
{
|
||||
SetColor( aColor );
|
||||
SetCurrentLineWidth( aPenWidth, aData );
|
||||
|
||||
GRText( nullptr, aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify, aPenWidth,
|
||||
aItalic, aBold, nullptr, nullptr, this );
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ size_t hash_fp_item( const EDA_ITEM* aItem, int aFlags )
|
||||
}
|
||||
|
||||
if( aFlags & HASH_ROT )
|
||||
hash_combine( ret, text->GetTextAngle() );
|
||||
hash_combine( ret, text->GetTextAngle().AsTenthsOfADegree() );
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -831,10 +831,10 @@ bool containsNonAsciiChars( const wxString& string )
|
||||
void DXF_PLOTTER::Text( const wxPoint& aPos,
|
||||
const COLOR4D& aColor,
|
||||
const wxString& aText,
|
||||
double aOrient,
|
||||
const EDA_ANGLE& aOrient,
|
||||
const wxSize& aSize,
|
||||
enum EDA_TEXT_HJUSTIFY_T aH_justify,
|
||||
enum EDA_TEXT_VJUSTIFY_T aV_justify,
|
||||
enum GR_TEXT_H_ALIGN_T aH_justify,
|
||||
enum GR_TEXT_V_ALIGN_T aV_justify,
|
||||
int aWidth,
|
||||
bool aItalic,
|
||||
bool aBold,
|
||||
@ -852,8 +852,8 @@ void DXF_PLOTTER::Text( const wxPoint& aPos,
|
||||
// output text as graphics.
|
||||
// Perhaps multiline texts could be handled as DXF text entity
|
||||
// but I do not want spend time about this (JPC)
|
||||
PLOTTER::Text( aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify,
|
||||
aWidth, aItalic, aBold, aMultilineAllowed );
|
||||
PLOTTER::Text( aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify, aWidth,
|
||||
aItalic, aBold, aMultilineAllowed, aData );
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -867,72 +867,59 @@ void DXF_PLOTTER::Text( const wxPoint& aPos,
|
||||
|
||||
switch( aH_justify )
|
||||
{
|
||||
case GR_TEXT_HJUSTIFY_LEFT:
|
||||
h_code = 0;
|
||||
break;
|
||||
case GR_TEXT_HJUSTIFY_CENTER:
|
||||
h_code = 1;
|
||||
break;
|
||||
case GR_TEXT_HJUSTIFY_RIGHT:
|
||||
h_code = 2;
|
||||
break;
|
||||
case GR_TEXT_H_ALIGN_LEFT: h_code = 0; break;
|
||||
case GR_TEXT_H_ALIGN_CENTER: h_code = 1; break;
|
||||
case GR_TEXT_H_ALIGN_RIGHT: h_code = 2; break;
|
||||
}
|
||||
|
||||
switch( aV_justify )
|
||||
{
|
||||
case GR_TEXT_VJUSTIFY_TOP:
|
||||
v_code = 3;
|
||||
break;
|
||||
case GR_TEXT_VJUSTIFY_CENTER:
|
||||
v_code = 2;
|
||||
break;
|
||||
case GR_TEXT_VJUSTIFY_BOTTOM:
|
||||
v_code = 1;
|
||||
break;
|
||||
case GR_TEXT_V_ALIGN_TOP: v_code = 3; break;
|
||||
case GR_TEXT_V_ALIGN_CENTER: v_code = 2; break;
|
||||
case GR_TEXT_V_ALIGN_BOTTOM: v_code = 1; break;
|
||||
}
|
||||
|
||||
// Position, size, rotation and alignment
|
||||
// The two alignment point usages is somewhat idiot (see the DXF ref)
|
||||
// Anyway since we don't use the fit/aligned options, they're the same
|
||||
fprintf( m_outputFile,
|
||||
" 0\n"
|
||||
"TEXT\n"
|
||||
" 7\n"
|
||||
"%s\n" // Text style
|
||||
" 8\n"
|
||||
"%s\n" // Layer name
|
||||
" 10\n"
|
||||
"%g\n" // First point X
|
||||
" 11\n"
|
||||
"%g\n" // Second point X
|
||||
" 20\n"
|
||||
"%g\n" // First point Y
|
||||
" 21\n"
|
||||
"%g\n" // Second point Y
|
||||
" 40\n"
|
||||
"%g\n" // Text height
|
||||
" 41\n"
|
||||
"%g\n" // Width factor
|
||||
" 50\n"
|
||||
"%g\n" // Rotation
|
||||
" 51\n"
|
||||
"%g\n" // Oblique angle
|
||||
" 71\n"
|
||||
"%d\n" // Mirror flags
|
||||
" 72\n"
|
||||
"%d\n" // H alignment
|
||||
" 73\n"
|
||||
"%d\n", // V alignment
|
||||
aBold ? (aItalic ? "KICADBI" : "KICADB")
|
||||
: (aItalic ? "KICADI" : "KICAD"),
|
||||
" 0\n"
|
||||
"TEXT\n"
|
||||
" 7\n"
|
||||
"%s\n" // Text style
|
||||
" 8\n"
|
||||
"%s\n" // Layer name
|
||||
" 10\n"
|
||||
"%g\n" // First point X
|
||||
" 11\n"
|
||||
"%g\n" // Second point X
|
||||
" 20\n"
|
||||
"%g\n" // First point Y
|
||||
" 21\n"
|
||||
"%g\n" // Second point Y
|
||||
" 40\n"
|
||||
"%g\n" // Text height
|
||||
" 41\n"
|
||||
"%g\n" // Width factor
|
||||
" 50\n"
|
||||
"%g\n" // Rotation
|
||||
" 51\n"
|
||||
"%g\n" // Oblique angle
|
||||
" 71\n"
|
||||
"%d\n" // Mirror flags
|
||||
" 72\n"
|
||||
"%d\n" // H alignment
|
||||
" 73\n"
|
||||
"%d\n", // V alignment
|
||||
aBold ? (aItalic ? "KICADBI" : "KICADB") : (aItalic ? "KICADI" : "KICAD"),
|
||||
TO_UTF8( cname ),
|
||||
origin_dev.x, origin_dev.x,
|
||||
origin_dev.y, origin_dev.y,
|
||||
size_dev.y, fabs( size_dev.x / size_dev.y ),
|
||||
aOrient / 10.0,
|
||||
aOrient.AsDegrees(),
|
||||
aItalic ? DXF_OBLIQUE_ANGLE : 0,
|
||||
size_dev.x < 0 ? 2 : 0, // X mirror flag
|
||||
h_code, v_code );
|
||||
h_code, v_code );
|
||||
|
||||
/* There are two issue in emitting the text:
|
||||
- Our overline character (~) must be converted to the appropriate
|
||||
|
@ -1923,11 +1923,18 @@ void GERBER_PLOTTER::FlashRegularPolygon( const wxPoint& aShapePos, int aDiamete
|
||||
}
|
||||
|
||||
|
||||
void GERBER_PLOTTER::Text( const wxPoint& aPos, const COLOR4D& aColor,
|
||||
const wxString& aText, double aOrient, const wxSize& aSize,
|
||||
enum EDA_TEXT_HJUSTIFY_T aH_justify,
|
||||
enum EDA_TEXT_VJUSTIFY_T aV_justify, int aWidth, bool aItalic,
|
||||
bool aBold, bool aMultilineAllowed, void* aData )
|
||||
void GERBER_PLOTTER::Text( const wxPoint& aPos,
|
||||
const COLOR4D& aColor,
|
||||
const wxString& aText,
|
||||
const EDA_ANGLE& aOrient,
|
||||
const wxSize& aSize,
|
||||
enum GR_TEXT_H_ALIGN_T aH_justify,
|
||||
enum GR_TEXT_V_ALIGN_T aV_justify,
|
||||
int aWidth,
|
||||
bool aItalic,
|
||||
bool aBold,
|
||||
bool aMultilineAllowed,
|
||||
void* aData )
|
||||
{
|
||||
GBR_METADATA* gbr_metadata = static_cast<GBR_METADATA*>( aData );
|
||||
|
||||
|
@ -825,10 +825,10 @@ bool PDF_PLOTTER::EndPlot()
|
||||
void PDF_PLOTTER::Text( const wxPoint& aPos,
|
||||
const COLOR4D& aColor,
|
||||
const wxString& aText,
|
||||
double aOrient,
|
||||
const EDA_ANGLE& aOrient,
|
||||
const wxSize& aSize,
|
||||
enum EDA_TEXT_HJUSTIFY_T aH_justify,
|
||||
enum EDA_TEXT_VJUSTIFY_T aV_justify,
|
||||
enum GR_TEXT_H_ALIGN_T aH_justify,
|
||||
enum GR_TEXT_V_ALIGN_T aV_justify,
|
||||
int aWidth,
|
||||
bool aItalic,
|
||||
bool aBold,
|
||||
@ -851,9 +851,8 @@ void PDF_PLOTTER::Text( const wxPoint& aPos,
|
||||
double wideningFactor, heightFactor;
|
||||
|
||||
computeTextParameters( aPos, aText, aOrient, aSize, m_plotMirror, aH_justify,
|
||||
aV_justify, aWidth, aItalic, aBold,
|
||||
&wideningFactor, &ctm_a, &ctm_b, &ctm_c,
|
||||
&ctm_d, &ctm_e, &ctm_f, &heightFactor );
|
||||
aV_justify, aWidth, aItalic, aBold, &wideningFactor, &ctm_a,
|
||||
&ctm_b, &ctm_c, &ctm_d, &ctm_e, &ctm_f, &heightFactor );
|
||||
|
||||
SetColor( aColor );
|
||||
SetCurrentLineWidth( aWidth, aData );
|
||||
|
@ -436,11 +436,11 @@ void PS_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
|
||||
|
||||
void PSLIKE_PLOTTER::computeTextParameters( const wxPoint& aPos,
|
||||
const wxString& aText,
|
||||
int aOrient,
|
||||
const EDA_ANGLE& aOrient,
|
||||
const wxSize& aSize,
|
||||
bool aMirror,
|
||||
enum EDA_TEXT_HJUSTIFY_T aH_justify,
|
||||
enum EDA_TEXT_VJUSTIFY_T aV_justify,
|
||||
enum GR_TEXT_H_ALIGN_T aH_justify,
|
||||
enum GR_TEXT_V_ALIGN_T aV_justify,
|
||||
int aWidth,
|
||||
bool aItalic,
|
||||
bool aBold,
|
||||
@ -463,36 +463,20 @@ void PSLIKE_PLOTTER::computeTextParameters( const wxPoint& aPos,
|
||||
|
||||
switch( aH_justify )
|
||||
{
|
||||
case GR_TEXT_HJUSTIFY_CENTER:
|
||||
dx = -tw / 2;
|
||||
break;
|
||||
|
||||
case GR_TEXT_HJUSTIFY_RIGHT:
|
||||
dx = -tw;
|
||||
break;
|
||||
|
||||
case GR_TEXT_HJUSTIFY_LEFT:
|
||||
dx = 0;
|
||||
break;
|
||||
case GR_TEXT_H_ALIGN_CENTER: dx = -tw / 2; break;
|
||||
case GR_TEXT_H_ALIGN_RIGHT: dx = -tw; break;
|
||||
case GR_TEXT_H_ALIGN_LEFT: dx = 0; break;
|
||||
}
|
||||
|
||||
switch( aV_justify )
|
||||
{
|
||||
case GR_TEXT_VJUSTIFY_CENTER:
|
||||
dy = th / 2;
|
||||
break;
|
||||
|
||||
case GR_TEXT_VJUSTIFY_TOP:
|
||||
dy = th;
|
||||
break;
|
||||
|
||||
case GR_TEXT_VJUSTIFY_BOTTOM:
|
||||
dy = 0;
|
||||
break;
|
||||
case GR_TEXT_V_ALIGN_CENTER: dy = th / 2; break;
|
||||
case GR_TEXT_V_ALIGN_TOP: dy = th; break;
|
||||
case GR_TEXT_V_ALIGN_BOTTOM: dy = 0; break;
|
||||
}
|
||||
|
||||
RotatePoint( &dx, &dy, aOrient );
|
||||
RotatePoint( &tw, &th, aOrient );
|
||||
RotatePoint( &dx, &dy, aOrient.AsTenthsOfADegree() );
|
||||
RotatePoint( &tw, &th, aOrient.AsTenthsOfADegree() );
|
||||
start_pos.x += dx;
|
||||
start_pos.y += dy;
|
||||
DPOINT pos_dev = userToDeviceCoordinates( start_pos );
|
||||
@ -503,13 +487,10 @@ void PSLIKE_PLOTTER::computeTextParameters( const wxPoint& aPos,
|
||||
|
||||
// Mirrored texts must be plotted as mirrored!
|
||||
if( m_plotMirror )
|
||||
{
|
||||
*wideningFactor = -*wideningFactor;
|
||||
aOrient = -aOrient;
|
||||
}
|
||||
|
||||
// The CTM transformation matrix
|
||||
double alpha = DECIDEG2RAD( aOrient );
|
||||
double alpha = m_plotMirror ? aOrient.Invert().AsRadians() : aOrient.AsRadians();
|
||||
double sinalpha = sin( alpha );
|
||||
double cosalpha = cos( alpha );
|
||||
|
||||
@ -978,17 +959,17 @@ bool PS_PLOTTER::EndPlot()
|
||||
|
||||
|
||||
void PS_PLOTTER::Text( const wxPoint& aPos,
|
||||
const COLOR4D& aColor,
|
||||
const wxString& aText,
|
||||
double aOrient,
|
||||
const wxSize& aSize,
|
||||
enum EDA_TEXT_HJUSTIFY_T aH_justify,
|
||||
enum EDA_TEXT_VJUSTIFY_T aV_justify,
|
||||
int aWidth,
|
||||
bool aItalic,
|
||||
bool aBold,
|
||||
bool aMultilineAllowed,
|
||||
void* aData )
|
||||
const COLOR4D& aColor,
|
||||
const wxString& aText,
|
||||
const EDA_ANGLE& aOrient,
|
||||
const wxSize& aSize,
|
||||
enum GR_TEXT_H_ALIGN_T aH_justify,
|
||||
enum GR_TEXT_V_ALIGN_T aV_justify,
|
||||
int aWidth,
|
||||
bool aItalic,
|
||||
bool aBold,
|
||||
bool aMultilineAllowed,
|
||||
void* aData )
|
||||
{
|
||||
SetCurrentLineWidth( aWidth );
|
||||
SetColor( aColor );
|
||||
|
@ -758,10 +758,10 @@ bool SVG_PLOTTER::EndPlot()
|
||||
void SVG_PLOTTER::Text( const wxPoint& aPos,
|
||||
const COLOR4D& aColor,
|
||||
const wxString& aText,
|
||||
double aOrient,
|
||||
const EDA_ANGLE& aOrient,
|
||||
const wxSize& aSize,
|
||||
enum EDA_TEXT_HJUSTIFY_T aH_justify,
|
||||
enum EDA_TEXT_VJUSTIFY_T aV_justify,
|
||||
enum GR_TEXT_H_ALIGN_T aH_justify,
|
||||
enum GR_TEXT_V_ALIGN_T aV_justify,
|
||||
int aWidth,
|
||||
bool aItalic,
|
||||
bool aBold,
|
||||
@ -777,31 +777,16 @@ void SVG_PLOTTER::Text( const wxPoint& aPos,
|
||||
|
||||
switch( aH_justify )
|
||||
{
|
||||
case GR_TEXT_HJUSTIFY_CENTER:
|
||||
hjust = "middle";
|
||||
break;
|
||||
|
||||
case GR_TEXT_HJUSTIFY_RIGHT:
|
||||
hjust = "end";
|
||||
break;
|
||||
|
||||
case GR_TEXT_HJUSTIFY_LEFT:
|
||||
hjust = "start";
|
||||
break;
|
||||
case GR_TEXT_H_ALIGN_CENTER: hjust = "middle"; break;
|
||||
case GR_TEXT_H_ALIGN_RIGHT: hjust = "end"; break;
|
||||
case GR_TEXT_H_ALIGN_LEFT: hjust = "start"; break;
|
||||
}
|
||||
|
||||
switch( aV_justify )
|
||||
{
|
||||
case GR_TEXT_VJUSTIFY_CENTER:
|
||||
text_pos.y += aSize.y / 2;
|
||||
break;
|
||||
|
||||
case GR_TEXT_VJUSTIFY_TOP:
|
||||
text_pos.y += aSize.y;
|
||||
break;
|
||||
|
||||
case GR_TEXT_VJUSTIFY_BOTTOM:
|
||||
break;
|
||||
case GR_TEXT_V_ALIGN_CENTER: text_pos.y += aSize.y / 2; break;
|
||||
case GR_TEXT_V_ALIGN_TOP: text_pos.y += aSize.y; break;
|
||||
case GR_TEXT_V_ALIGN_BOTTOM: break;
|
||||
}
|
||||
|
||||
wxSize text_size;
|
||||
@ -814,14 +799,14 @@ void SVG_PLOTTER::Text( const wxPoint& aPos,
|
||||
DPOINT text_pos_dev = userToDeviceCoordinates( text_pos );
|
||||
DPOINT sz_dev = userToDeviceSize( text_size );
|
||||
|
||||
if( aOrient != 0 ) {
|
||||
if( aOrient != EDA_ANGLE::ANGLE_0 )
|
||||
{
|
||||
fprintf( m_outputFile,
|
||||
"<g transform=\"rotate(%f %f %f)\">\n",
|
||||
- aOrient * 0.1, anchor_pos_dev.x, anchor_pos_dev.y );
|
||||
- aOrient.AsDegrees(), anchor_pos_dev.x, anchor_pos_dev.y );
|
||||
}
|
||||
|
||||
fprintf( m_outputFile,
|
||||
"<text x=\"%f\" y=\"%f\"\n", text_pos_dev.x, text_pos_dev.y );
|
||||
fprintf( m_outputFile, "<text x=\"%f\" y=\"%f\"\n", text_pos_dev.x, text_pos_dev.y );
|
||||
|
||||
/// If the text is mirrored, we should also mirror the hidden text to match
|
||||
if( aSize.x < 0 )
|
||||
@ -830,16 +815,16 @@ void SVG_PLOTTER::Text( const wxPoint& aPos,
|
||||
fprintf( m_outputFile,
|
||||
"textLength=\"%f\" font-size=\"%f\" lengthAdjust=\"spacingAndGlyphs\"\n"
|
||||
"text-anchor=\"%s\" opacity=\"0\">%s</text>\n",
|
||||
sz_dev.x, sz_dev.y,
|
||||
hjust, TO_UTF8( XmlEsc( aText ) ) );
|
||||
sz_dev.x, sz_dev.y, hjust, TO_UTF8( XmlEsc( aText ) ) );
|
||||
|
||||
if( aOrient != 0 )
|
||||
if( aOrient != EDA_ANGLE::ANGLE_0 )
|
||||
fputs( "</g>\n", m_outputFile );
|
||||
|
||||
fprintf( m_outputFile,
|
||||
"<g class=\"stroked-text\"><desc>%s</desc>\n",
|
||||
fprintf( m_outputFile, "<g class=\"stroked-text\"><desc>%s</desc>\n",
|
||||
TO_UTF8( XmlEsc( aText ) ) );
|
||||
|
||||
PLOTTER::Text( aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify,
|
||||
aWidth, aItalic, aBold, aMultilineAllowed );
|
||||
|
||||
fputs( "</g>", m_outputFile );
|
||||
}
|
||||
|
@ -630,3 +630,41 @@ void PLOTTER::PlotPoly( const SHAPE_LINE_CHAIN& aCornerList, FILL_T aFill, int a
|
||||
|
||||
PlotPoly( cornerList, aFill, aWidth, aData );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Same as GRText, but plot graphic text instead of draw it.
|
||||
*
|
||||
* @param aPos is the text position (according to aH_justify, aV_justify).
|
||||
* @param aColor is the text color.
|
||||
* @param aText is the text to draw.
|
||||
* @param aOrient is the angle.
|
||||
* @param aSize is the text size (size.x or size.y can be < 0 for mirrored texts).
|
||||
* @param aH_justify is the horizontal justification (Left, center, right).
|
||||
* @param aV_justify is the vertical justification (bottom, center, top).
|
||||
* @param aPenWidth is the line width (if = 0, use plot default line width).
|
||||
* @param aItalic is the true to simulate an italic font.
|
||||
* @param aBold use true to use a bold font Useful only with default width value (aWidth = 0).
|
||||
* @param aMultilineAllowed use true to plot text as multiline, otherwise single line.
|
||||
* @param aData is a parameter used by some plotters in SetCurrentLineWidth(),
|
||||
* not directly used here.
|
||||
*/
|
||||
void PLOTTER::Text( const wxPoint& aPos,
|
||||
const COLOR4D& aColor,
|
||||
const wxString& aText,
|
||||
const EDA_ANGLE& aOrient,
|
||||
const wxSize& aSize,
|
||||
enum GR_TEXT_H_ALIGN_T aH_justify,
|
||||
enum GR_TEXT_V_ALIGN_T aV_justify,
|
||||
int aPenWidth,
|
||||
bool aItalic,
|
||||
bool aBold,
|
||||
bool aMultilineAllowed,
|
||||
void* aData )
|
||||
{
|
||||
SetColor( aColor );
|
||||
SetCurrentLineWidth( aPenWidth, aData );
|
||||
|
||||
GRText( nullptr, aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify, aPenWidth,
|
||||
aItalic, aBold, nullptr, nullptr, this );
|
||||
}
|
||||
|
@ -2618,7 +2618,7 @@ void CADSTAR_ARCHIVE_PARSER::FixTextPositionNoAlignment( EDA_TEXT* aKiCadTextIte
|
||||
{
|
||||
if( !aKiCadTextItem->GetText().IsEmpty() )
|
||||
{
|
||||
int txtAngleDecideg = aKiCadTextItem->GetTextAngleDegrees() * 10.0;
|
||||
int txtAngleDecideg = aKiCadTextItem->GetTextAngle().AsTenthsOfADegree();
|
||||
wxPoint positionOffset( 0, aKiCadTextItem->GetInterline() );
|
||||
RotatePoint( &positionOffset, txtAngleDecideg );
|
||||
|
||||
|
@ -140,9 +140,9 @@ void KIGFX::PREVIEW::DrawTextNextToCursor( KIGFX::VIEW* aView, const VECTOR2D& a
|
||||
if( aTextQuadrant.x < 0 )
|
||||
{
|
||||
if( viewFlipped )
|
||||
gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_RIGHT );
|
||||
gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_RIGHT );
|
||||
else
|
||||
gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_LEFT );
|
||||
gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_LEFT );
|
||||
|
||||
textPos.x += 15.0 / gal->GetWorldScale();
|
||||
|
||||
@ -152,9 +152,9 @@ void KIGFX::PREVIEW::DrawTextNextToCursor( KIGFX::VIEW* aView, const VECTOR2D& a
|
||||
else
|
||||
{
|
||||
if( viewFlipped )
|
||||
gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_LEFT );
|
||||
gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_LEFT );
|
||||
else
|
||||
gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_RIGHT );
|
||||
gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_RIGHT );
|
||||
|
||||
textPos.x -= 15.0 / gal->GetWorldScale();
|
||||
|
||||
|
@ -181,11 +181,11 @@ void drawTicksAlongLine( KIGFX::VIEW* aView, const VECTOR2D& aOrigin, const VECT
|
||||
|
||||
if( aLine.Angle() > 0 )
|
||||
{
|
||||
gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_LEFT );
|
||||
gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_LEFT );
|
||||
}
|
||||
else
|
||||
{
|
||||
gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_RIGHT );
|
||||
gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_RIGHT );
|
||||
labelAngle += M_PI;
|
||||
}
|
||||
|
||||
|
@ -82,15 +82,6 @@ template<typename T> T round_n( const T& value, const T& n, bool aRoundUp )
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convert an integer to a horizontal justification; neg=L zero=C pos=R
|
||||
*/
|
||||
EDA_TEXT_HJUSTIFY_T TO_HJUSTIFY( int x )
|
||||
{
|
||||
return static_cast<EDA_TEXT_HJUSTIFY_T>( x );
|
||||
}
|
||||
|
||||
|
||||
class AUTOPLACER
|
||||
{
|
||||
public:
|
||||
@ -204,9 +195,9 @@ protected:
|
||||
for( SCH_FIELD* field : m_fields )
|
||||
{
|
||||
if( m_symbol->GetTransform().y1 )
|
||||
field->SetTextAngle( TEXT_ANGLE_VERT );
|
||||
field->SetTextAngle( EDA_ANGLE::VERTICAL );
|
||||
else
|
||||
field->SetTextAngle( TEXT_ANGLE_HORIZ );
|
||||
field->SetTextAngle( EDA_ANGLE::HORIZONTAL );
|
||||
|
||||
EDA_RECT bbox = field->GetBoundingBox();
|
||||
int field_width = bbox.GetWidth();
|
||||
@ -528,7 +519,7 @@ protected:
|
||||
aField->SetHorizJustify( TO_HJUSTIFY( -aFieldSide.x ) );
|
||||
aField->SetHorizJustify( TO_HJUSTIFY( -aFieldSide.x
|
||||
* ( aField->IsHorizJustifyFlipped() ? -1 : 1 ) ) );
|
||||
aField->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER );
|
||||
aField->SetVertJustify( GR_TEXT_V_ALIGN_CENTER );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -654,13 +645,13 @@ protected:
|
||||
|
||||
switch( field_hjust )
|
||||
{
|
||||
case GR_TEXT_HJUSTIFY_LEFT:
|
||||
case GR_TEXT_H_ALIGN_LEFT:
|
||||
field_xcoord = aFieldBox.GetLeft();
|
||||
break;
|
||||
case GR_TEXT_HJUSTIFY_CENTER:
|
||||
case GR_TEXT_H_ALIGN_CENTER:
|
||||
field_xcoord = aFieldBox.Centre().x;
|
||||
break;
|
||||
case GR_TEXT_HJUSTIFY_RIGHT:
|
||||
case GR_TEXT_H_ALIGN_RIGHT:
|
||||
field_xcoord = aFieldBox.GetRight();
|
||||
break;
|
||||
default:
|
||||
|
@ -636,11 +636,11 @@ bool DIALOG_CHANGE_SYMBOLS::processSymbol( SCH_SYMBOL* aSymbol, const SCH_SHEET_
|
||||
|
||||
if( resetEffects )
|
||||
{
|
||||
// Careful: the visible bit and position are also in Effects
|
||||
// Careful: the visible bit and position are also set by SetAttributes()
|
||||
bool visible = field.IsVisible();
|
||||
wxPoint pos = field.GetPosition();
|
||||
|
||||
field.SetEffects( *libField );
|
||||
field.SetAttributes( *libField );
|
||||
|
||||
field.SetVisible( visible );
|
||||
field.SetPosition( pos );
|
||||
@ -672,7 +672,8 @@ bool DIALOG_CHANGE_SYMBOLS::processSymbol( SCH_SYMBOL* aSymbol, const SCH_SHEET_
|
||||
SCH_FIELD newField( wxPoint( 0, 0), aSymbol->GetFieldCount(), aSymbol, fieldName );
|
||||
SCH_FIELD* schField = aSymbol->AddField( newField );
|
||||
|
||||
schField->SetEffects( libField );
|
||||
// Careful: the visible bit and position are also set by SetAttributes()
|
||||
schField->SetAttributes( libField );
|
||||
schField->SetText( libField.GetText() );
|
||||
schField->SetTextPos( aSymbol->GetPosition() + libField.GetTextPos() );
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ DIALOG_FIELD_PROPERTIES::DIALOG_FIELD_PROPERTIES( SCH_BASE_FRAME* aParent, const
|
||||
m_isBold = aTextItem->IsBold();
|
||||
m_position = aTextItem->GetTextPos();
|
||||
m_size = aTextItem->GetTextWidth();
|
||||
m_isVertical = ( aTextItem->GetTextAngle() == TEXT_ANGLE_VERT );
|
||||
m_isVertical = aTextItem->GetTextAngle().IsVertical();
|
||||
m_verticalJustification = aTextItem->GetVertJustify() + 1;
|
||||
m_horizontalJustification = aTextItem->GetHorizJustify() + 1;
|
||||
m_isVisible = aTextItem->IsVisible();
|
||||
@ -305,16 +305,16 @@ bool DIALOG_FIELD_PROPERTIES::TransferDataToWindow()
|
||||
|
||||
switch ( m_horizontalJustification )
|
||||
{
|
||||
case GR_TEXT_HJUSTIFY_LEFT: m_hAlignLeft->Check( true ); break;
|
||||
case GR_TEXT_HJUSTIFY_CENTER: m_hAlignCenter->Check( true ); break;
|
||||
case GR_TEXT_HJUSTIFY_RIGHT: m_hAlignRight->Check( true ); break;
|
||||
case GR_TEXT_H_ALIGN_LEFT: m_hAlignLeft->Check( true ); break;
|
||||
case GR_TEXT_H_ALIGN_CENTER: m_hAlignCenter->Check( true ); break;
|
||||
case GR_TEXT_H_ALIGN_RIGHT: m_hAlignRight->Check( true ); break;
|
||||
}
|
||||
|
||||
switch ( m_verticalJustification )
|
||||
{
|
||||
case GR_TEXT_VJUSTIFY_TOP: m_vAlignTop->Check( true ); break;
|
||||
case GR_TEXT_VJUSTIFY_CENTER: m_vAlignCenter->Check( true ); break;
|
||||
case GR_TEXT_VJUSTIFY_BOTTOM: m_vAlignBottom->Check( true ); break;
|
||||
case GR_TEXT_V_ALIGN_TOP: m_vAlignTop->Check( true ); break;
|
||||
case GR_TEXT_V_ALIGN_CENTER: m_vAlignCenter->Check( true ); break;
|
||||
case GR_TEXT_V_ALIGN_BOTTOM: m_vAlignBottom->Check( true ); break;
|
||||
}
|
||||
|
||||
m_visible->SetValue( m_isVisible );
|
||||
@ -369,18 +369,18 @@ bool DIALOG_FIELD_PROPERTIES::TransferDataFromWindow()
|
||||
m_isItalic = m_italic->IsChecked();
|
||||
|
||||
if( m_hAlignLeft->IsChecked() )
|
||||
m_horizontalJustification = GR_TEXT_HJUSTIFY_LEFT;
|
||||
m_horizontalJustification = GR_TEXT_H_ALIGN_LEFT;
|
||||
else if( m_hAlignCenter->IsChecked() )
|
||||
m_horizontalJustification = GR_TEXT_HJUSTIFY_CENTER;
|
||||
m_horizontalJustification = GR_TEXT_H_ALIGN_CENTER;
|
||||
else
|
||||
m_horizontalJustification = GR_TEXT_HJUSTIFY_RIGHT;
|
||||
m_horizontalJustification = GR_TEXT_H_ALIGN_RIGHT;
|
||||
|
||||
if( m_vAlignTop->IsChecked() )
|
||||
m_verticalJustification = GR_TEXT_VJUSTIFY_TOP;
|
||||
m_verticalJustification = GR_TEXT_V_ALIGN_TOP;
|
||||
else if( m_vAlignCenter->IsChecked() )
|
||||
m_verticalJustification = GR_TEXT_VJUSTIFY_CENTER;
|
||||
m_verticalJustification = GR_TEXT_V_ALIGN_CENTER;
|
||||
else
|
||||
m_verticalJustification = GR_TEXT_VJUSTIFY_BOTTOM;
|
||||
m_verticalJustification = GR_TEXT_V_ALIGN_BOTTOM;
|
||||
|
||||
m_isVisible = m_visible->GetValue();
|
||||
|
||||
@ -394,7 +394,7 @@ void DIALOG_FIELD_PROPERTIES::updateText( EDA_TEXT* aText )
|
||||
aText->SetTextSize( wxSize( m_size, m_size ) );
|
||||
|
||||
aText->SetVisible( m_isVisible );
|
||||
aText->SetTextAngle( m_isVertical ? TEXT_ANGLE_VERT : TEXT_ANGLE_HORIZ );
|
||||
aText->SetTextAngle( m_isVertical ? EDA_ANGLE::VERTICAL : EDA_ANGLE::HORIZONTAL );
|
||||
aText->SetItalic( m_isItalic );
|
||||
aText->SetBold( m_isBold );
|
||||
}
|
||||
@ -596,14 +596,14 @@ void DIALOG_SCH_FIELD_PROPERTIES::UpdateField( SCH_FIELD* aField, SCH_SHEET_PATH
|
||||
symbol->SetFootprint( m_text );
|
||||
}
|
||||
|
||||
EDA_TEXT_HJUSTIFY_T hJustify = EDA_TEXT::MapHorizJustify( m_horizontalJustification - 1 );
|
||||
EDA_TEXT_VJUSTIFY_T vJustify = EDA_TEXT::MapVertJustify( m_verticalJustification - 1 );
|
||||
GR_TEXT_H_ALIGN_T hJustify = EDA_TEXT::MapHorizJustify( m_horizontalJustification - 1 );
|
||||
GR_TEXT_V_ALIGN_T vJustify = EDA_TEXT::MapVertJustify( m_verticalJustification - 1 );
|
||||
bool positioningModified = false;
|
||||
|
||||
if( aField->GetPosition() != m_position )
|
||||
positioningModified = true;
|
||||
|
||||
if( ( aField->GetTextAngle() == TEXT_ANGLE_VERT ) != m_isVertical )
|
||||
if( aField->GetTextAngle().IsVertical() != m_isVertical )
|
||||
positioningModified = true;
|
||||
|
||||
if( aField->GetEffectiveHorizJustify() != hJustify )
|
||||
|
@ -137,23 +137,23 @@ bool DIALOG_LIB_TEXT_PROPERTIES::TransferDataToWindow()
|
||||
m_CommonUnit->SetValue( m_graphicText->GetUnit() == 0 );
|
||||
m_CommonConvert->SetValue( m_graphicText->GetConvert() == 0 );
|
||||
|
||||
if( m_graphicText->GetTextAngle() == TEXT_ANGLE_HORIZ )
|
||||
if( m_graphicText->GetTextAngle().IsHorizontal() )
|
||||
m_horizontal->Check();
|
||||
else
|
||||
m_vertical->Check();
|
||||
|
||||
switch ( m_graphicText->GetHorizJustify() )
|
||||
{
|
||||
case GR_TEXT_HJUSTIFY_LEFT: m_hAlignLeft->Check( true ); break;
|
||||
case GR_TEXT_HJUSTIFY_CENTER: m_hAlignCenter->Check( true ); break;
|
||||
case GR_TEXT_HJUSTIFY_RIGHT: m_hAlignRight->Check( true ); break;
|
||||
case GR_TEXT_H_ALIGN_LEFT: m_hAlignLeft->Check( true ); break;
|
||||
case GR_TEXT_H_ALIGN_CENTER: m_hAlignCenter->Check( true ); break;
|
||||
case GR_TEXT_H_ALIGN_RIGHT: m_hAlignRight->Check( true ); break;
|
||||
}
|
||||
|
||||
switch ( m_graphicText->GetVertJustify() )
|
||||
{
|
||||
case GR_TEXT_VJUSTIFY_TOP: m_vAlignTop->Check( true ); break;
|
||||
case GR_TEXT_VJUSTIFY_CENTER: m_vAlignCenter->Check( true ); break;
|
||||
case GR_TEXT_VJUSTIFY_BOTTOM: m_vAlignBottom->Check( true ); break;
|
||||
case GR_TEXT_V_ALIGN_TOP: m_vAlignTop->Check( true ); break;
|
||||
case GR_TEXT_V_ALIGN_CENTER: m_vAlignCenter->Check( true ); break;
|
||||
case GR_TEXT_V_ALIGN_BOTTOM: m_vAlignBottom->Check( true ); break;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -166,7 +166,7 @@ bool DIALOG_LIB_TEXT_PROPERTIES::TransferDataToWindow()
|
||||
m_CommonUnit->SetValue( !tools->GetDrawSpecificUnit() );
|
||||
m_CommonConvert->SetValue( !tools->GetDrawSpecificConvert() );
|
||||
|
||||
if( tools->GetLastTextAngle() == TEXT_ANGLE_HORIZ )
|
||||
if( tools->GetLastTextAngle().IsHorizontal() )
|
||||
m_horizontal->Check();
|
||||
else
|
||||
m_vertical->Check();
|
||||
@ -221,9 +221,9 @@ bool DIALOG_LIB_TEXT_PROPERTIES::TransferDataFromWindow()
|
||||
m_graphicText->SetTextSize( wxSize( m_textSize.GetValue(), m_textSize.GetValue() ) );
|
||||
|
||||
if( m_horizontal->IsChecked() )
|
||||
m_graphicText->SetTextAngle( TEXT_ANGLE_HORIZ );
|
||||
m_graphicText->SetTextAngle( EDA_ANGLE::HORIZONTAL );
|
||||
else
|
||||
m_graphicText->SetTextAngle( TEXT_ANGLE_VERT );
|
||||
m_graphicText->SetTextAngle( EDA_ANGLE::VERTICAL );
|
||||
|
||||
if( !m_CommonUnit->GetValue() )
|
||||
m_graphicText->SetUnit( m_parent->GetUnit() );
|
||||
@ -239,18 +239,18 @@ bool DIALOG_LIB_TEXT_PROPERTIES::TransferDataFromWindow()
|
||||
m_graphicText->SetBold( m_bold->IsChecked() );
|
||||
|
||||
if( m_hAlignLeft->IsChecked() )
|
||||
m_graphicText->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
|
||||
m_graphicText->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
|
||||
else if( m_hAlignCenter->IsChecked() )
|
||||
m_graphicText->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER );
|
||||
m_graphicText->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER );
|
||||
else
|
||||
m_graphicText->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
|
||||
m_graphicText->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
|
||||
|
||||
if( m_vAlignTop->IsChecked() )
|
||||
m_graphicText->SetVertJustify( GR_TEXT_VJUSTIFY_TOP );
|
||||
m_graphicText->SetVertJustify( GR_TEXT_V_ALIGN_TOP );
|
||||
else if( m_vAlignCenter->IsChecked() )
|
||||
m_graphicText->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER );
|
||||
m_graphicText->SetVertJustify( GR_TEXT_V_ALIGN_CENTER );
|
||||
else
|
||||
m_graphicText->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
|
||||
m_graphicText->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
|
||||
|
||||
// Record settings used for next time:
|
||||
auto* tools = m_parent->GetToolManager()->GetTool<SYMBOL_EDITOR_DRAWING_TOOLS>();
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user