From 86cb57f4a7075ad252ad16deaa70f4405454076b Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Tue, 28 Dec 2021 22:13:54 +0000 Subject: [PATCH] Cherry-pick TEXT_ATTRIBUTES and EDA_ANGLE from rockola/kicad-strokefont --- common/CMakeLists.txt | 5 + common/drawing_sheet/drawing_sheet_parser.cpp | 12 +- common/drawing_sheet/ds_data_item.cpp | 4 +- common/drawing_sheet/ds_data_model_io.cpp | 10 +- common/drawing_sheet/ds_painter.cpp | 2 +- common/eda_angle.cpp | 114 ++++++ common/eda_text.cpp | 148 +++---- common/gal/graphics_abstraction_layer.cpp | 4 +- common/gal/opengl/opengl_gal.cpp | 12 +- common/gal/stroke_font.cpp | 18 +- common/gr_text.cpp | 74 +--- common/hash_eda.cpp | 2 +- common/plotters/DXF_plotter.cpp | 97 ++--- common/plotters/GERBER_plotter.cpp | 17 +- common/plotters/PDF_plotter.cpp | 11 +- common/plotters/PS_plotter.cpp | 65 ++-- common/plotters/SVG_plotter.cpp | 51 +-- common/plotters/plotter.cpp | 38 ++ .../cadstar/cadstar_archive_parser.cpp | 2 +- common/preview_items/preview_utils.cpp | 8 +- common/preview_items/ruler_item.cpp | 4 +- eeschema/autoplace_fields.cpp | 21 +- eeschema/dialogs/dialog_change_symbols.cpp | 7 +- eeschema/dialogs/dialog_field_properties.cpp | 34 +- .../dialogs/dialog_lib_text_properties.cpp | 32 +- .../dialogs/dialog_update_symbol_fields.cpp | 6 +- .../dialogs/panel_eeschema_color_settings.cpp | 4 +- eeschema/fields_grid_table.cpp | 39 +- eeschema/lib_field.cpp | 41 +- eeschema/lib_pin.cpp | 110 +++--- eeschema/lib_text.cpp | 116 +++--- eeschema/lib_text.h | 2 +- eeschema/sch_field.cpp | 105 +++-- eeschema/sch_field.h | 10 +- eeschema/sch_painter.cpp | 107 ++--- .../sch_plugins/altium/sch_altium_plugin.cpp | 44 +-- .../cadstar/cadstar_sch_archive_loader.cpp | 368 +++++++++--------- .../sch_plugins/eagle/sch_eagle_plugin.cpp | 40 +- .../sch_plugins/kicad/sch_sexpr_parser.cpp | 154 ++++---- .../sch_plugins/kicad/sch_sexpr_plugin.cpp | 8 +- .../sch_plugins/legacy/sch_legacy_plugin.cpp | 81 ++-- eeschema/sch_sheet.cpp | 24 +- eeschema/sch_text.cpp | 116 +++--- eeschema/symbol_editor/symbol_edit_frame.cpp | 8 +- eeschema/tools/sch_edit_tool.cpp | 18 +- .../tools/symbol_editor_drawing_tools.cpp | 3 +- eeschema/tools/symbol_editor_drawing_tools.h | 6 +- gerbview/gerber_draw_item.cpp | 2 +- gerbview/gerbview_painter.cpp | 4 +- include/drawing_sheet/ds_data_item.h | 4 +- include/eda_angle.h | 264 +++++++++++++ include/eda_text.h | 164 +++----- include/font/text_attributes.h | 86 ++++ include/gal/graphics_abstraction_layer.h | 22 +- include/gr_text.h | 40 +- include/plotters/plotter.h | 53 ++- include/plotters/plotter_dxf.h | 8 +- include/plotters/plotter_gerber.h | 8 +- include/plotters/plotters_pslike.h | 32 +- .../dialogs/properties_frame.cpp | 24 +- .../dialogs/dialog_dimension_properties.cpp | 7 +- pcbnew/dialogs/dialog_exchange_footprints.cpp | 4 +- pcbnew/dialogs/dialog_text_properties.cpp | 14 +- pcbnew/exporters/export_gencad.cpp | 3 +- pcbnew/exporters/gen_drill_report_files.cpp | 8 +- pcbnew/fp_text.cpp | 36 +- pcbnew/fp_text.h | 25 +- pcbnew/fp_text_grid_table.cpp | 3 +- pcbnew/import_gfx/dxf_import_plugin.cpp | 32 +- pcbnew/import_gfx/graphics_importer.h | 6 +- .../import_gfx/graphics_importer_buffer.cpp | 15 +- pcbnew/import_gfx/graphics_importer_buffer.h | 14 +- .../import_gfx/graphics_importer_pcbnew.cpp | 4 +- pcbnew/import_gfx/graphics_importer_pcbnew.h | 6 +- pcbnew/kicad_clipboard.cpp | 2 +- pcbnew/pcb_dimension.cpp | 10 +- pcbnew/pcb_painter.cpp | 18 +- pcbnew/pcb_text.cpp | 16 +- pcbnew/pcb_text.h | 1 + pcbnew/plot_brditems_plotter.cpp | 16 +- pcbnew/plugins/altium/altium_pcb.cpp | 28 +- .../cadstar/cadstar_pcb_archive_loader.cpp | 76 ++-- pcbnew/plugins/eagle/eagle_plugin.cpp | 114 +++--- pcbnew/plugins/fabmaster/import_fabmaster.cpp | 6 +- pcbnew/plugins/fabmaster/import_fabmaster.h | 2 +- pcbnew/plugins/kicad/pcb_parser.cpp | 10 +- pcbnew/plugins/kicad/pcb_plugin.cpp | 8 +- pcbnew/plugins/legacy/legacy_plugin.cpp | 18 +- pcbnew/plugins/pcad/pcad2kicad_common.cpp | 36 +- pcbnew/tools/drawing_stackup_table_tool.cpp | 16 +- pcbnew/tools/pcb_control.cpp | 5 +- 91 files changed, 1896 insertions(+), 1576 deletions(-) create mode 100644 common/eda_angle.cpp create mode 100644 include/eda_angle.h create mode 100644 include/font/text_attributes.h diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index e650b5649db..5235caccc4d 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -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 diff --git a/common/drawing_sheet/drawing_sheet_parser.cpp b/common/drawing_sheet/drawing_sheet_parser.cpp index d848b5d5ab4..059b8fe41d8 100644 --- a/common/drawing_sheet/drawing_sheet_parser.cpp +++ b/common/drawing_sheet/drawing_sheet_parser.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: diff --git a/common/drawing_sheet/ds_data_item.cpp b/common/drawing_sheet/ds_data_item.cpp index 226508bfb5b..ca356a4c022 100644 --- a/common/drawing_sheet/ds_data_item.cpp +++ b/common/drawing_sheet/ds_data_item.cpp @@ -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; diff --git a/common/drawing_sheet/ds_data_model_io.cpp b/common/drawing_sheet/ds_data_model_io.cpp index 6879176abc1..3532741674b 100644 --- a/common/drawing_sheet/ds_data_model_io.cpp +++ b/common/drawing_sheet/ds_data_model_io.cpp @@ -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, ")" ); diff --git a/common/drawing_sheet/ds_painter.cpp b/common/drawing_sheet/ds_painter.cpp index ad4ad58f4db..b15c471e779 100644 --- a/common/drawing_sheet/ds_painter.cpp +++ b/common/drawing_sheet/ds_painter.cpp @@ -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 ); diff --git a/common/eda_angle.cpp b/common/eda_angle.cpp new file mode 100644 index 00000000000..44c8b4df58a --- /dev/null +++ b/common/eda_angle.cpp @@ -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 . + */ + +#include + +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; +} diff --git a/common/eda_text.cpp b/common/eda_text.cpp index 51aa0dbbd02..3544d5a44b6 100644 --- a/common/eda_text.cpp +++ b/common/eda_text.cpp @@ -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( aHorizJustify ); + return static_cast( 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( aVertJustify ); + return static_cast( 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& 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& 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::Instance() - .Map( GR_TEXT_HJUSTIFY_LEFT, _HKI( "Left" ) ) - .Map( GR_TEXT_HJUSTIFY_CENTER, _HKI( "Center" ) ) - .Map( GR_TEXT_HJUSTIFY_RIGHT, _HKI( "Right" ) ); - ENUM_MAP::Instance() - .Map( GR_TEXT_VJUSTIFY_TOP, _HKI( "Top" ) ) - .Map( GR_TEXT_VJUSTIFY_CENTER, _HKI( "Center" ) ) - .Map( GR_TEXT_VJUSTIFY_BOTTOM, _HKI( "Bottom" ) ); + ENUM_MAP::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::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( _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( _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 ) diff --git a/common/gal/graphics_abstraction_layer.cpp b/common/gal/graphics_abstraction_layer.cpp index 38497bb1a78..18a6b457fd4 100644 --- a/common/gal/graphics_abstraction_layer.cpp +++ b/common/gal/graphics_abstraction_layer.cpp @@ -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 ); diff --git a/common/gal/opengl/opengl_gal.cpp b/common/gal/opengl/opengl_gal.cpp index 55208d6bab3..44c0c8e280d 100644 --- a/common/gal/opengl/opengl_gal.cpp +++ b/common/gal/opengl/opengl_gal.cpp @@ -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; } diff --git a/common/gal/stroke_font.cpp b/common/gal/stroke_font.cpp index d268b15742f..1ae7e668109 100644 --- a/common/gal/stroke_font.cpp +++ b/common/gal/stroke_font.cpp @@ -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; diff --git a/common/gr_text.cpp b/common/gr_text.cpp index 0f36751423b..c5ec2926937 100644 --- a/common/gr_text.cpp +++ b/common/gr_text.cpp @@ -31,7 +31,6 @@ #include #include -#include // EDA_TEXT_HJUSTIFY_T and EDA_TEXT_VJUSTIFY_T #include #include #include // 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 ); -} diff --git a/common/hash_eda.cpp b/common/hash_eda.cpp index cb561d7a52b..77c62b57b3d 100644 --- a/common/hash_eda.cpp +++ b/common/hash_eda.cpp @@ -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; diff --git a/common/plotters/DXF_plotter.cpp b/common/plotters/DXF_plotter.cpp index 880efc82b0b..2ed12407cf4 100644 --- a/common/plotters/DXF_plotter.cpp +++ b/common/plotters/DXF_plotter.cpp @@ -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 diff --git a/common/plotters/GERBER_plotter.cpp b/common/plotters/GERBER_plotter.cpp index 895c8cf4fd8..9bfa69e5544 100644 --- a/common/plotters/GERBER_plotter.cpp +++ b/common/plotters/GERBER_plotter.cpp @@ -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( aData ); diff --git a/common/plotters/PDF_plotter.cpp b/common/plotters/PDF_plotter.cpp index f5e467e2a59..65e48303140 100644 --- a/common/plotters/PDF_plotter.cpp +++ b/common/plotters/PDF_plotter.cpp @@ -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 ); diff --git a/common/plotters/PS_plotter.cpp b/common/plotters/PS_plotter.cpp index b3e4ae3c09a..d453343a766 100644 --- a/common/plotters/PS_plotter.cpp +++ b/common/plotters/PS_plotter.cpp @@ -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 ); diff --git a/common/plotters/SVG_plotter.cpp b/common/plotters/SVG_plotter.cpp index 9b18054d999..ab4182bb2a1 100644 --- a/common/plotters/SVG_plotter.cpp +++ b/common/plotters/SVG_plotter.cpp @@ -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, "\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, - "\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( "\n", m_outputFile ); - fprintf( m_outputFile, - "%s\n", + fprintf( m_outputFile, "%s\n", TO_UTF8( XmlEsc( aText ) ) ); + PLOTTER::Text( aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify, aWidth, aItalic, aBold, aMultilineAllowed ); + fputs( "", m_outputFile ); } diff --git a/common/plotters/plotter.cpp b/common/plotters/plotter.cpp index 617c062373f..c3e4e0a75f2 100644 --- a/common/plotters/plotter.cpp +++ b/common/plotters/plotter.cpp @@ -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 ); +} diff --git a/common/plugins/cadstar/cadstar_archive_parser.cpp b/common/plugins/cadstar/cadstar_archive_parser.cpp index 7eeba56011f..eabf94f5823 100644 --- a/common/plugins/cadstar/cadstar_archive_parser.cpp +++ b/common/plugins/cadstar/cadstar_archive_parser.cpp @@ -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 ); diff --git a/common/preview_items/preview_utils.cpp b/common/preview_items/preview_utils.cpp index 995781adc7a..04164e2de0f 100644 --- a/common/preview_items/preview_utils.cpp +++ b/common/preview_items/preview_utils.cpp @@ -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(); diff --git a/common/preview_items/ruler_item.cpp b/common/preview_items/ruler_item.cpp index 81daac0dce3..fd0a64a7e27 100644 --- a/common/preview_items/ruler_item.cpp +++ b/common/preview_items/ruler_item.cpp @@ -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; } diff --git a/eeschema/autoplace_fields.cpp b/eeschema/autoplace_fields.cpp index 7be39e4330b..758c9dffd11 100644 --- a/eeschema/autoplace_fields.cpp +++ b/eeschema/autoplace_fields.cpp @@ -82,15 +82,6 @@ template 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( x ); -} - - class AUTOPLACER { public: @@ -204,9 +195,9 @@ class AUTOPLACER 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 @@ class AUTOPLACER 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 @@ class AUTOPLACER 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: diff --git a/eeschema/dialogs/dialog_change_symbols.cpp b/eeschema/dialogs/dialog_change_symbols.cpp index 7d41fd05753..9246e1bebdb 100644 --- a/eeschema/dialogs/dialog_change_symbols.cpp +++ b/eeschema/dialogs/dialog_change_symbols.cpp @@ -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() ); } diff --git a/eeschema/dialogs/dialog_field_properties.cpp b/eeschema/dialogs/dialog_field_properties.cpp index b9d65738585..4fe0ae438f4 100644 --- a/eeschema/dialogs/dialog_field_properties.cpp +++ b/eeschema/dialogs/dialog_field_properties.cpp @@ -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 ) diff --git a/eeschema/dialogs/dialog_lib_text_properties.cpp b/eeschema/dialogs/dialog_lib_text_properties.cpp index f74608ee5fb..453b7784f2f 100644 --- a/eeschema/dialogs/dialog_lib_text_properties.cpp +++ b/eeschema/dialogs/dialog_lib_text_properties.cpp @@ -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(); diff --git a/eeschema/dialogs/dialog_update_symbol_fields.cpp b/eeschema/dialogs/dialog_update_symbol_fields.cpp index 9296d69cb9b..f08bb2cbfb6 100644 --- a/eeschema/dialogs/dialog_update_symbol_fields.cpp +++ b/eeschema/dialogs/dialog_update_symbol_fields.cpp @@ -167,11 +167,11 @@ void DIALOG_UPDATE_SYMBOL_FIELDS::onOkButtonClicked( wxCommandEvent& aEvent ) 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( *parentField ); + field.SetAttributes( *parentField ); field.SetVisible( visible ); field.SetPosition( pos ); @@ -207,7 +207,7 @@ void DIALOG_UPDATE_SYMBOL_FIELDS::onOkButtonClicked( wxCommandEvent& aEvent ) newField->SetName( parentField->GetCanonicalName() ); newField->SetText( parentField->GetText() ); - newField->SetEffects( *parentField ); // Includes visible bit and position + newField->SetAttributes( *parentField ); // Includes visible bit and position } } diff --git a/eeschema/dialogs/panel_eeschema_color_settings.cpp b/eeschema/dialogs/panel_eeschema_color_settings.cpp index 88cc37756ec..05ee0656899 100644 --- a/eeschema/dialogs/panel_eeschema_color_settings.cpp +++ b/eeschema/dialogs/panel_eeschema_color_settings.cpp @@ -359,13 +359,13 @@ void PANEL_EESCHEMA_COLOR_SETTINGS::createPreviewItems() ref.SetText( wxT( "U1" ) ); ref.SetPosition( MILS_POINT( p.x + 30, p.y + 260 ) ); - ref.SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); + ref.SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); LIB_FIELD& value = symbol->GetValueField(); value.SetText( wxT( "OPA604" ) ); value.SetPosition( MILS_POINT( p.x + 30, p.y + 180 ) ); - value.SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); + value.SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); symbol->SetShowPinNames( true ); symbol->SetShowPinNumbers( true ); diff --git a/eeschema/fields_grid_table.cpp b/eeschema/fields_grid_table.cpp index 8147f373133..ff0d18f18e9 100644 --- a/eeschema/fields_grid_table.cpp +++ b/eeschema/fields_grid_table.cpp @@ -466,9 +466,9 @@ wxString FIELDS_GRID_TABLE::GetValue( int aRow, int aCol ) case FDC_H_ALIGN: switch ( field.GetHorizJustify() ) { - case GR_TEXT_HJUSTIFY_LEFT: return _( "Left" ); - case GR_TEXT_HJUSTIFY_CENTER: return _( "Center" ); - case GR_TEXT_HJUSTIFY_RIGHT: return _( "Right" ); + case GR_TEXT_H_ALIGN_LEFT: return _( "Left" ); + case GR_TEXT_H_ALIGN_CENTER: return _( "Center" ); + case GR_TEXT_H_ALIGN_RIGHT: return _( "Right" ); } break; @@ -476,9 +476,9 @@ wxString FIELDS_GRID_TABLE::GetValue( int aRow, int aCol ) case FDC_V_ALIGN: switch ( field.GetVertJustify() ) { - case GR_TEXT_VJUSTIFY_TOP: return _( "Top" ); - case GR_TEXT_VJUSTIFY_CENTER: return _( "Center" ); - case GR_TEXT_VJUSTIFY_BOTTOM: return _( "Bottom" ); + case GR_TEXT_V_ALIGN_TOP: return _( "Top" ); + case GR_TEXT_V_ALIGN_CENTER: return _( "Center" ); + case GR_TEXT_V_ALIGN_BOTTOM: return _( "Bottom" ); } break; @@ -493,13 +493,10 @@ wxString FIELDS_GRID_TABLE::GetValue( int aRow, int aCol ) return StringFromValue( m_frame->GetUserUnits(), field.GetTextSize().GetHeight(), true ); case FDC_ORIENTATION: - switch ( (int) field.GetTextAngle() ) - { - case TEXT_ANGLE_HORIZ: return _( "Horizontal" ); - case TEXT_ANGLE_VERT: return _( "Vertical" ); - } - - break; + if( field.GetTextAngle().IsHorizontal() ) + return _( "Horizontal" ); + else + return _( "Vertical" ); case FDC_POSX: return StringFromValue( m_frame->GetUserUnits(), field.GetTextPos().x, true ); @@ -579,22 +576,22 @@ void FIELDS_GRID_TABLE::SetValue( int aRow, int aCol, const wxString &aValue case FDC_H_ALIGN: if( aValue == _( "Left" ) ) - field.SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); + field.SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); else if( aValue == _( "Center" ) ) - field.SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER ); + field.SetHorizJustify( GR_TEXT_H_ALIGN_CENTER ); else if( aValue == _( "Right" ) ) - field.SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); + field.SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); else wxFAIL_MSG( wxT( "unknown horizontal alignment: " ) + aValue ); break; case FDC_V_ALIGN: if( aValue == _( "Top" ) ) - field.SetVertJustify( GR_TEXT_VJUSTIFY_TOP ); + field.SetVertJustify( GR_TEXT_V_ALIGN_TOP ); else if( aValue == _( "Center" ) ) - field.SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); + field.SetVertJustify( GR_TEXT_V_ALIGN_CENTER ); else if( aValue == _( "Bottom" ) ) - field.SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); + field.SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM ); else wxFAIL_MSG( wxT( "unknown vertical alignment: " ) + aValue); break; @@ -614,9 +611,9 @@ void FIELDS_GRID_TABLE::SetValue( int aRow, int aCol, const wxString &aValue case FDC_ORIENTATION: if( aValue == _( "Horizontal" ) ) - field.SetTextAngle( TEXT_ANGLE_HORIZ ); + field.SetTextAngle( EDA_ANGLE::HORIZONTAL ); else if( aValue == _( "Vertical" ) ) - field.SetTextAngle( TEXT_ANGLE_VERT ); + field.SetTextAngle( EDA_ANGLE::VERTICAL ); else wxFAIL_MSG( wxT( "unknown orientation: " ) + aValue ); break; diff --git a/eeschema/lib_field.cpp b/eeschema/lib_field.cpp index 65b88a16ffd..1ea1a38b900 100644 --- a/eeschema/lib_field.cpp +++ b/eeschema/lib_field.cpp @@ -73,7 +73,7 @@ LIB_FIELD& LIB_FIELD::operator=( const LIB_FIELD& field ) m_parent = field.m_parent; SetText( field.GetText() ); - SetEffects( field ); + SetAttributes( field ); return *this; } @@ -85,7 +85,7 @@ void LIB_FIELD::Init( int aId ) m_id = aId; - SetTextAngle( TEXT_ANGLE_HORIZ ); // constructor already did this. + SetTextAngle( EDA_ANGLE::HORIZONTAL ); // constructor already did this. // Fields in RAM must always have names, because we are trying to get less dependent on // field ids and more dependent on names. Plus assumptions are made in the field editors. @@ -152,8 +152,8 @@ bool LIB_FIELD::HitTest( const wxPoint& aPosition, int aAccuracy ) const // The text orientation may need to be flipped if the transformation matrix causes xy axes // to be flipped. This simple algo works only for schematic matrix (rot 90 or/and mirror) - bool t1 = ( DefaultTransform.x1 != 0 ) ^ ( GetTextAngle() != 0 ); - tmp_text.SetTextAngle( t1 ? TEXT_ANGLE_HORIZ : TEXT_ANGLE_VERT ); + bool t1 = ( DefaultTransform.x1 != 0 ) ^ ( GetTextAngle() != EDA_ANGLE::HORIZONTAL ); + tmp_text.SetTextAngle( t1 ? EDA_ANGLE::HORIZONTAL : EDA_ANGLE::VERTICAL ); return tmp_text.TextHitTest( aPosition, aAccuracy ); } @@ -174,7 +174,7 @@ void LIB_FIELD::Copy( LIB_FIELD* aTarget ) const aTarget->m_name = m_name; aTarget->CopyText( *this ); - aTarget->SetEffects( *this ); + aTarget->SetAttributes( *this ); aTarget->SetParent( m_parent ); } @@ -280,7 +280,8 @@ void LIB_FIELD::Rotate( const wxPoint& center, bool aRotateCCW ) RotatePoint( &pt, center, rot_angle ); SetTextPos( pt ); - SetTextAngle( GetTextAngle() != 0.0 ? 0 : 900 ); + SetTextAngle( GetTextAngle() != EDA_ANGLE::HORIZONTAL ? EDA_ANGLE::HORIZONTAL + : EDA_ANGLE::VERTICAL ); } @@ -291,21 +292,21 @@ void LIB_FIELD::Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, return; // Calculate the text orientation, according to the symbol orientation/mirror. - int orient = (int) GetTextAngle(); + EDA_ANGLE orient = GetTextAngle(); if( aTransform.y1 ) // Rotate symbol 90 deg. { - if( orient == TEXT_ANGLE_HORIZ ) - orient = TEXT_ANGLE_VERT; + if( orient.IsHorizontal() ) + orient = EDA_ANGLE::VERTICAL; else - orient = TEXT_ANGLE_HORIZ; + orient = EDA_ANGLE::HORIZONTAL; } EDA_RECT bbox = GetBoundingBox(); bbox.RevertYAxis(); - EDA_TEXT_HJUSTIFY_T hjustify = GR_TEXT_HJUSTIFY_CENTER; - EDA_TEXT_VJUSTIFY_T vjustify = GR_TEXT_VJUSTIFY_CENTER; + GR_TEXT_H_ALIGN_T hjustify = GR_TEXT_H_ALIGN_CENTER; + GR_TEXT_V_ALIGN_T vjustify = GR_TEXT_V_ALIGN_CENTER; wxPoint textpos = aTransform.TransformCoordinate( bbox.Centre() ) + aOffset; COLOR4D color; @@ -351,8 +352,8 @@ const EDA_RECT LIB_FIELD::GetBoundingBox() const wxPoint orig = rect.GetOrigin(); wxPoint end = rect.GetEnd(); - RotatePoint( &orig, GetTextPos(), -GetTextAngle() ); - RotatePoint( &end, GetTextPos(), -GetTextAngle() ); + RotatePoint( &orig, GetTextPos(), -GetTextAngle().AsTenthsOfADegree() ); + RotatePoint( &end, GetTextPos(), -GetTextAngle().AsTenthsOfADegree() ); rect.SetOrigin( orig ); rect.SetEnd( end ); @@ -468,18 +469,18 @@ void LIB_FIELD::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vectorText( wxPoint( x, y1 ), nameColor, name, TEXT_ANGLE_HORIZ, pinNameSize, - hjustify, GR_TEXT_VJUSTIFY_CENTER, namePenWidth, + aPlotter->Text( wxPoint( x, y1 ), nameColor, name, EDA_ANGLE::HORIZONTAL, + pinNameSize, hjustify, GR_TEXT_V_ALIGN_CENTER, namePenWidth, false, false ); } if( aDrawPinNum ) { aPlotter->Text( wxPoint( ( x1 + aPinPos.x) / 2, y1 - num_offset ), numColor, - number, TEXT_ANGLE_HORIZ, pinNumSize, GR_TEXT_HJUSTIFY_CENTER, - GR_TEXT_VJUSTIFY_BOTTOM, numPenWidth, false, false ); + number, EDA_ANGLE::HORIZONTAL, pinNumSize, GR_TEXT_H_ALIGN_CENTER, + GR_TEXT_V_ALIGN_BOTTOM, numPenWidth, false, false ); } } else /* Its a vertical line. */ @@ -758,15 +758,15 @@ void LIB_PIN::PlotPinTexts( PLOTTER* aPlotter, const wxPoint& aPinPos, int aPinO y = y1 + aTextInside; if( aDrawPinName ) - aPlotter->Text( wxPoint( x1, y ), nameColor, name, TEXT_ANGLE_VERT, - pinNameSize, GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_CENTER, + aPlotter->Text( wxPoint( x1, y ), nameColor, name, EDA_ANGLE::VERTICAL, + pinNameSize, GR_TEXT_H_ALIGN_RIGHT, GR_TEXT_V_ALIGN_CENTER, namePenWidth, false, false ); if( aDrawPinNum ) { aPlotter->Text( wxPoint( x1 - num_offset, ( y1 + aPinPos.y) / 2 ), numColor, - number, TEXT_ANGLE_VERT, pinNumSize, GR_TEXT_HJUSTIFY_CENTER, - GR_TEXT_VJUSTIFY_BOTTOM, numPenWidth, false, false ); + number, EDA_ANGLE::VERTICAL, pinNumSize, GR_TEXT_H_ALIGN_CENTER, + GR_TEXT_V_ALIGN_BOTTOM, numPenWidth, false, false ); } } else /* PIN_UP */ @@ -775,16 +775,16 @@ void LIB_PIN::PlotPinTexts( PLOTTER* aPlotter, const wxPoint& aPinPos, int aPinO if( aDrawPinName ) { - aPlotter->Text( wxPoint( x1, y ), nameColor, name, TEXT_ANGLE_VERT, - pinNameSize, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, + aPlotter->Text( wxPoint( x1, y ), nameColor, name, EDA_ANGLE::VERTICAL, + pinNameSize, GR_TEXT_H_ALIGN_LEFT, GR_TEXT_V_ALIGN_CENTER, namePenWidth, false, false ); } if( aDrawPinNum ) { aPlotter->Text( wxPoint( x1 - num_offset, ( y1 + aPinPos.y) / 2 ), numColor, - number, TEXT_ANGLE_VERT, pinNumSize, GR_TEXT_HJUSTIFY_CENTER, - GR_TEXT_VJUSTIFY_BOTTOM, numPenWidth, false, false ); + number, EDA_ANGLE::VERTICAL, pinNumSize, GR_TEXT_H_ALIGN_CENTER, + GR_TEXT_V_ALIGN_BOTTOM, numPenWidth, false, false ); } } } @@ -798,16 +798,16 @@ void LIB_PIN::PlotPinTexts( PLOTTER* aPlotter, const wxPoint& aPinPos, int aPinO { x = ( x1 + aPinPos.x) / 2; aPlotter->Text( wxPoint( x, y1 - name_offset ), nameColor, name, - TEXT_ANGLE_HORIZ, pinNameSize, GR_TEXT_HJUSTIFY_CENTER, - GR_TEXT_VJUSTIFY_BOTTOM, namePenWidth, false, false ); + EDA_ANGLE::HORIZONTAL, pinNameSize, GR_TEXT_H_ALIGN_CENTER, + GR_TEXT_V_ALIGN_BOTTOM, namePenWidth, false, false ); } if( aDrawPinNum ) { x = ( x1 + aPinPos.x ) / 2; aPlotter->Text( wxPoint( x, y1 + num_offset ), numColor, number, - TEXT_ANGLE_HORIZ, pinNumSize, GR_TEXT_HJUSTIFY_CENTER, - GR_TEXT_VJUSTIFY_TOP, numPenWidth, false, false ); + EDA_ANGLE::HORIZONTAL, pinNumSize, GR_TEXT_H_ALIGN_CENTER, + GR_TEXT_V_ALIGN_TOP, numPenWidth, false, false ); } } else /* Its a vertical line. */ @@ -816,15 +816,15 @@ void LIB_PIN::PlotPinTexts( PLOTTER* aPlotter, const wxPoint& aPinPos, int aPinO { y = ( y1 + aPinPos.y ) / 2; aPlotter->Text( wxPoint( x1 - name_offset, y ), nameColor, name, - TEXT_ANGLE_VERT, pinNameSize, GR_TEXT_HJUSTIFY_CENTER, - GR_TEXT_VJUSTIFY_BOTTOM, namePenWidth, false, false ); + EDA_ANGLE::VERTICAL, pinNameSize, GR_TEXT_H_ALIGN_CENTER, + GR_TEXT_V_ALIGN_BOTTOM, namePenWidth, false, false ); } if( aDrawPinNum ) { aPlotter->Text( wxPoint( x1 + num_offset, ( y1 + aPinPos.y ) / 2 ), numColor, - number, TEXT_ANGLE_VERT, pinNumSize, GR_TEXT_HJUSTIFY_CENTER, - GR_TEXT_VJUSTIFY_TOP, numPenWidth, false, false ); + number, EDA_ANGLE::VERTICAL, pinNumSize, GR_TEXT_H_ALIGN_CENTER, + GR_TEXT_V_ALIGN_TOP, numPenWidth, false, false ); } } } diff --git a/eeschema/lib_text.cpp b/eeschema/lib_text.cpp index cfc51b5247d..285a5f834ea 100644 --- a/eeschema/lib_text.cpp +++ b/eeschema/lib_text.cpp @@ -62,9 +62,9 @@ bool LIB_TEXT::HitTest( const wxPoint& aPosition, int aAccuracy ) const * transformation matrix causes xy axes to be flipped. * this simple algo works only for schematic matrix (rot 90 or/and mirror) */ - bool t1 = ( DefaultTransform.x1 != 0 ) ^ ( GetTextAngle() != 0 ); + bool t1 = ( DefaultTransform.x1 != 0 ) ^ ( GetTextAngle() != EDA_ANGLE::HORIZONTAL ); - tmp_text.SetTextAngle( t1 ? TEXT_ANGLE_HORIZ : TEXT_ANGLE_VERT ); + tmp_text.SetTextAngle( t1 ? EDA_ANGLE::HORIZONTAL : EDA_ANGLE::VERTICAL ); return tmp_text.TextHitTest( aPosition, aAccuracy ); } @@ -78,7 +78,7 @@ EDA_ITEM* LIB_TEXT::Clone() const newitem->m_flags = m_flags; newitem->SetText( GetText() ); - newitem->SetEffects( *this ); + newitem->SetAttributes( *this ); return newitem; } @@ -133,28 +133,28 @@ void LIB_TEXT::NormalizeJustification( bool inverse ) wxPoint delta( 0, 0 ); EDA_RECT bbox = GetTextBox(); - if( GetTextAngle() == 0.0 ) + if( GetTextAngle().IsHorizontal() ) { - if( GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT ) + if( GetHorizJustify() == GR_TEXT_H_ALIGN_LEFT ) delta.x = bbox.GetWidth() / 2; - else if( GetHorizJustify() == GR_TEXT_HJUSTIFY_RIGHT ) + else if( GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT ) delta.x = - bbox.GetWidth() / 2; - if( GetVertJustify() == GR_TEXT_VJUSTIFY_TOP ) + if( GetVertJustify() == GR_TEXT_V_ALIGN_TOP ) delta.y = - bbox.GetHeight() / 2; - else if( GetVertJustify() == GR_TEXT_VJUSTIFY_BOTTOM ) + else if( GetVertJustify() == GR_TEXT_V_ALIGN_BOTTOM ) delta.y = bbox.GetHeight() / 2; } else { - if( GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT ) + if( GetHorizJustify() == GR_TEXT_H_ALIGN_LEFT ) delta.y = bbox.GetWidth() / 2; - else if( GetHorizJustify() == GR_TEXT_HJUSTIFY_RIGHT ) + else if( GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT ) delta.y = - bbox.GetWidth() / 2; - if( GetVertJustify() == GR_TEXT_VJUSTIFY_TOP ) + if( GetVertJustify() == GR_TEXT_V_ALIGN_TOP ) delta.x = + bbox.GetHeight() / 2; - else if( GetVertJustify() == GR_TEXT_VJUSTIFY_BOTTOM ) + else if( GetVertJustify() == GR_TEXT_V_ALIGN_BOTTOM ) delta.x = - bbox.GetHeight() / 2; } @@ -174,19 +174,19 @@ void LIB_TEXT::MirrorHorizontal( const wxPoint& center ) x *= -1; x += center.x; - if( GetTextAngle() == 0.0 ) + if( GetTextAngle().IsHorizontal() ) { - if( GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT ) - SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); - else if( GetHorizJustify() == GR_TEXT_HJUSTIFY_RIGHT ) - SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); + if( GetHorizJustify() == GR_TEXT_H_ALIGN_LEFT ) + SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); + else if( GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT ) + SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); } else { - if( GetVertJustify() == GR_TEXT_VJUSTIFY_TOP ) - SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); - else if( GetVertJustify() == GR_TEXT_VJUSTIFY_BOTTOM ) - SetVertJustify( GR_TEXT_VJUSTIFY_TOP ); + if( GetVertJustify() == GR_TEXT_V_ALIGN_TOP ) + SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM ); + else if( GetVertJustify() == GR_TEXT_V_ALIGN_BOTTOM ) + SetVertJustify( GR_TEXT_V_ALIGN_TOP ); } SetTextX( x ); @@ -203,19 +203,19 @@ void LIB_TEXT::MirrorVertical( const wxPoint& center ) y *= -1; y += center.y; - if( GetTextAngle() == 0.0 ) + if( GetTextAngle().IsHorizontal() ) { - if( GetVertJustify() == GR_TEXT_VJUSTIFY_TOP ) - SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); - else if( GetVertJustify() == GR_TEXT_VJUSTIFY_BOTTOM ) - SetVertJustify( GR_TEXT_VJUSTIFY_TOP ); + if( GetVertJustify() == GR_TEXT_V_ALIGN_TOP ) + SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM ); + else if( GetVertJustify() == GR_TEXT_V_ALIGN_BOTTOM ) + SetVertJustify( GR_TEXT_V_ALIGN_TOP ); } else { - if( GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT ) - SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); - else if( GetHorizJustify() == GR_TEXT_HJUSTIFY_RIGHT ) - SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); + if( GetHorizJustify() == GR_TEXT_H_ALIGN_LEFT ) + SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); + else if( GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT ) + SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); } SetTextY( y ); @@ -232,23 +232,23 @@ void LIB_TEXT::Rotate( const wxPoint& center, bool aRotateCCW ) RotatePoint( &pt, center, rot_angle ); SetTextPos( pt ); - if( GetTextAngle() == 0.0 ) + if( GetTextAngle().IsHorizontal() ) { - SetTextAngle( 900 ); + SetTextAngle( EDA_ANGLE::VERTICAL ); } else { // 180º of rotation is a mirror - if( GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT ) - SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); - else if( GetHorizJustify() == GR_TEXT_HJUSTIFY_RIGHT ) - SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); + if( GetHorizJustify() == GR_TEXT_H_ALIGN_LEFT ) + SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); + else if( GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT ) + SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); - if( GetVertJustify() == GR_TEXT_VJUSTIFY_TOP ) - SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); - else if( GetVertJustify() == GR_TEXT_VJUSTIFY_BOTTOM ) - SetVertJustify( GR_TEXT_VJUSTIFY_TOP ); + if( GetVertJustify() == GR_TEXT_V_ALIGN_TOP ) + SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM ); + else if( GetVertJustify() == GR_TEXT_V_ALIGN_BOTTOM ) + SetVertJustify( GR_TEXT_V_ALIGN_TOP ); SetTextAngle( 0 ); } @@ -269,7 +269,7 @@ void LIB_TEXT::Plot( PLOTTER* plotter, const wxPoint& offset, bool fill, // The text orientation may need to be flipped if the transformation matrix causes xy // axes to be flipped. - int t1 = ( aTransform.x1 != 0 ) ^ ( GetTextAngle() != 0 ); + int t1 = ( aTransform.x1 != 0 ) ^ ( GetTextAngle() != EDA_ANGLE::HORIZONTAL ); wxPoint pos = aTransform.TransformCoordinate( txtpos ) + offset; // Get color @@ -284,9 +284,9 @@ void LIB_TEXT::Plot( PLOTTER* plotter, const wxPoint& offset, bool fill, int penWidth = std::max( GetEffectiveTextPenWidth(), settings->GetMinPenWidth() ); - plotter->Text( pos, color, GetText(), t1 ? TEXT_ANGLE_HORIZ : TEXT_ANGLE_VERT, GetTextSize(), - GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, penWidth, IsItalic(), - IsBold() ); + plotter->Text( pos, color, GetText(), t1 ? EDA_ANGLE::HORIZONTAL : EDA_ANGLE::VERTICAL, + GetTextSize(), GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_CENTER, penWidth, + IsItalic(), IsBold() ); } @@ -305,14 +305,14 @@ void LIB_TEXT::print( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset, // Calculate the text orientation, according to the symbol orientation/mirror (needed when // draw text in schematic) - int orient = (int) GetTextAngle(); + EDA_ANGLE orient = GetTextAngle(); if( aTransform.y1 ) // Rotate symbol 90 degrees. { - if( orient == TEXT_ANGLE_HORIZ ) - orient = TEXT_ANGLE_VERT; + if( orient == EDA_ANGLE::HORIZONTAL ) + orient = EDA_ANGLE::VERTICAL; else - orient = TEXT_ANGLE_HORIZ; + orient = EDA_ANGLE::HORIZONTAL; } /* @@ -334,8 +334,8 @@ void LIB_TEXT::print( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset, // Calculate pos according to mirror/rotation. txtpos = aTransform.TransformCoordinate( txtpos ) + aOffset; - GRText( DC, txtpos, color, GetShownText(), orient, GetTextSize(), GR_TEXT_HJUSTIFY_CENTER, - GR_TEXT_VJUSTIFY_CENTER, penWidth, IsItalic(), IsBold() ); + GRText( DC, txtpos, color, GetShownText(), orient, GetTextSize(), GR_TEXT_H_ALIGN_CENTER, + GR_TEXT_V_ALIGN_CENTER, penWidth, IsItalic(), IsBold() ); } @@ -355,18 +355,18 @@ void LIB_TEXT::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vectorGetPrintDC(); COLOR4D color = aSettings->GetLayerColor( IsForceVisible() ? LAYER_HIDDEN : m_layer ); - int orient; wxPoint textpos; int penWidth = GetEffectiveTextPenWidth( aSettings->GetDefaultPenWidth() ); @@ -225,7 +224,7 @@ void SCH_FIELD::Print( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset return; // Calculate the text orientation according to the symbol orientation. - orient = GetTextAngle(); + EDA_ANGLE orient = GetTextAngle(); if( m_parent && m_parent->Type() == SCH_SYMBOL_T ) { @@ -233,10 +232,10 @@ void SCH_FIELD::Print( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset if( parentSymbol && parentSymbol->GetTransform().y1 ) // Rotate symbol 90 degrees. { - if( orient == TEXT_ANGLE_HORIZ ) - orient = TEXT_ANGLE_VERT; + if( orient == EDA_ANGLE::HORIZONTAL ) + orient = EDA_ANGLE::VERTICAL; else - orient = TEXT_ANGLE_HORIZ; + orient = EDA_ANGLE::HORIZONTAL; } } @@ -252,14 +251,14 @@ void SCH_FIELD::Print( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset */ textpos = GetBoundingBox().Centre() + aOffset; - GRText( DC, textpos, color, GetShownText(), orient, GetTextSize(), GR_TEXT_HJUSTIFY_CENTER, - GR_TEXT_VJUSTIFY_CENTER, penWidth, IsItalic(), IsBold() ); + GRText( DC, textpos, color, GetShownText(), orient, GetTextSize(), GR_TEXT_H_ALIGN_CENTER, + GR_TEXT_V_ALIGN_CENTER, penWidth, IsItalic(), IsBold() ); } void SCH_FIELD::ImportValues( const LIB_FIELD& aSource ) { - SetEffects( aSource ); + SetAttributes( aSource ); } @@ -272,14 +271,14 @@ void SCH_FIELD::SwapData( SCH_ITEM* aItem ) std::swap( m_layer, item->m_layer ); SwapText( *item ); - SwapEffects( *item ); + SwapAttributes( *item ); } -double SCH_FIELD::GetDrawRotation() const +EDA_ANGLE SCH_FIELD::GetDrawRotation() const { // Calculate the text orientation according to the symbol orientation. - int orient = GetTextAngle(); + EDA_ANGLE orient = GetTextAngle(); if( m_parent && m_parent->Type() == SCH_SYMBOL_T ) { @@ -287,10 +286,10 @@ double SCH_FIELD::GetDrawRotation() const if( parentSymbol && parentSymbol->GetTransform().y1 ) // Rotate symbol 90 degrees. { - if( orient == TEXT_ANGLE_HORIZ ) - orient = TEXT_ANGLE_VERT; + if( orient.IsHorizontal() ) + orient = EDA_ANGLE::VERTICAL; else - orient = TEXT_ANGLE_HORIZ; + orient = EDA_ANGLE::HORIZONTAL; } } @@ -304,15 +303,15 @@ wxPoint SCH_FIELD::GetDrawPos() const } -EDA_TEXT_HJUSTIFY_T SCH_FIELD::GetDrawHorizJustify() const +GR_TEXT_H_ALIGN_T SCH_FIELD::GetDrawHorizJustify() const { - return GR_TEXT_HJUSTIFY_CENTER; + return GR_TEXT_H_ALIGN_CENTER; } -EDA_TEXT_VJUSTIFY_T SCH_FIELD::GetDrawVertJustify() const +GR_TEXT_V_ALIGN_T SCH_FIELD::GetDrawVertJustify() const { - return GR_TEXT_VJUSTIFY_CENTER; + return GR_TEXT_V_ALIGN_CENTER; } @@ -326,8 +325,8 @@ const EDA_RECT SCH_FIELD::GetBoundingBox() const wxPoint pos = GetTextPos() - origin; wxPoint begin = rect.GetOrigin() - origin; wxPoint end = rect.GetEnd() - origin; - RotatePoint( &begin, pos, GetTextAngle() ); - RotatePoint( &end, pos, GetTextAngle() ); + RotatePoint( &begin, pos, GetTextAngle().AsTenthsOfADegree() ); + RotatePoint( &end, pos, GetTextAngle().AsTenthsOfADegree() ); // Now, apply the symbol transform (mirror/rot) TRANSFORM transform; @@ -365,13 +364,13 @@ bool SCH_FIELD::IsHorizJustifyFlipped() const switch( GetHorizJustify() ) { - case GR_TEXT_HJUSTIFY_LEFT: - if( GetDrawRotation() == TEXT_ANGLE_VERT ) + case GR_TEXT_H_ALIGN_LEFT: + if( GetDrawRotation().IsVertical() ) return render_center.y > pos.y; else return render_center.x < pos.x; - case GR_TEXT_HJUSTIFY_RIGHT: - if( GetDrawRotation() == TEXT_ANGLE_VERT ) + case GR_TEXT_H_ALIGN_RIGHT: + if( GetDrawRotation().IsVertical() ) return render_center.y < pos.y; else return render_center.x > pos.x; @@ -381,16 +380,16 @@ bool SCH_FIELD::IsHorizJustifyFlipped() const } -EDA_TEXT_HJUSTIFY_T SCH_FIELD::GetEffectiveHorizJustify() const +GR_TEXT_H_ALIGN_T SCH_FIELD::GetEffectiveHorizJustify() const { switch( GetHorizJustify() ) { - case GR_TEXT_HJUSTIFY_LEFT: - return IsHorizJustifyFlipped() ? GR_TEXT_HJUSTIFY_RIGHT : GR_TEXT_HJUSTIFY_LEFT; - case GR_TEXT_HJUSTIFY_RIGHT: - return IsHorizJustifyFlipped() ? GR_TEXT_HJUSTIFY_LEFT : GR_TEXT_HJUSTIFY_RIGHT; + case GR_TEXT_H_ALIGN_LEFT: + return IsHorizJustifyFlipped() ? GR_TEXT_H_ALIGN_RIGHT : GR_TEXT_H_ALIGN_LEFT; + case GR_TEXT_H_ALIGN_RIGHT: + return IsHorizJustifyFlipped() ? GR_TEXT_H_ALIGN_LEFT : GR_TEXT_H_ALIGN_RIGHT; default: - return GR_TEXT_HJUSTIFY_CENTER; + return GR_TEXT_H_ALIGN_CENTER; } } @@ -402,13 +401,13 @@ bool SCH_FIELD::IsVertJustifyFlipped() const switch( GetVertJustify() ) { - case GR_TEXT_VJUSTIFY_TOP: - if( GetDrawRotation() == TEXT_ANGLE_VERT ) + case GR_TEXT_V_ALIGN_TOP: + if( GetDrawRotation().IsVertical() ) return render_center.x < pos.x; else return render_center.y < pos.y; - case GR_TEXT_VJUSTIFY_BOTTOM: - if( GetDrawRotation() == TEXT_ANGLE_VERT ) + case GR_TEXT_V_ALIGN_BOTTOM: + if( GetDrawRotation().IsVertical() ) return render_center.x > pos.x; else return render_center.y > pos.y; @@ -418,16 +417,16 @@ bool SCH_FIELD::IsVertJustifyFlipped() const } -EDA_TEXT_VJUSTIFY_T SCH_FIELD::GetEffectiveVertJustify() const +GR_TEXT_V_ALIGN_T SCH_FIELD::GetEffectiveVertJustify() const { switch( GetVertJustify() ) { - case GR_TEXT_VJUSTIFY_TOP: - return IsVertJustifyFlipped() ? GR_TEXT_VJUSTIFY_BOTTOM : GR_TEXT_VJUSTIFY_TOP; - case GR_TEXT_VJUSTIFY_BOTTOM: - return IsVertJustifyFlipped() ? GR_TEXT_VJUSTIFY_TOP : GR_TEXT_VJUSTIFY_BOTTOM; + case GR_TEXT_V_ALIGN_TOP: + return IsVertJustifyFlipped() ? GR_TEXT_V_ALIGN_BOTTOM : GR_TEXT_V_ALIGN_TOP; + case GR_TEXT_V_ALIGN_BOTTOM: + return IsVertJustifyFlipped() ? GR_TEXT_V_ALIGN_TOP : GR_TEXT_V_ALIGN_BOTTOM; default: - return GR_TEXT_VJUSTIFY_CENTER; + return GR_TEXT_V_ALIGN_CENTER; } } @@ -610,18 +609,18 @@ void SCH_FIELD::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vectorType() == SCH_SYMBOL_T ) { @@ -841,10 +840,10 @@ void SCH_FIELD::Plot( PLOTTER* aPlotter ) const if( parentSymbol->GetTransform().y1 ) // Rotate symbol 90 deg. { - if( orient == TEXT_ANGLE_HORIZ ) - orient = TEXT_ANGLE_VERT; + if( orient.IsHorizontal() ) + orient = EDA_ANGLE::VERTICAL; else - orient = TEXT_ANGLE_HORIZ; + orient = EDA_ANGLE::HORIZONTAL; } } @@ -858,9 +857,9 @@ void SCH_FIELD::Plot( PLOTTER* aPlotter ) const * to calculate so the easier way is to use no justifications (centered text) and use * GetBoundingBox to know the text coordinate considered as centered */ - EDA_TEXT_HJUSTIFY_T hjustify = GR_TEXT_HJUSTIFY_CENTER; - EDA_TEXT_VJUSTIFY_T vjustify = GR_TEXT_VJUSTIFY_CENTER; - wxPoint textpos = GetBoundingBox().Centre(); + GR_TEXT_H_ALIGN_T hjustify = GR_TEXT_H_ALIGN_CENTER; + GR_TEXT_V_ALIGN_T vjustify = GR_TEXT_V_ALIGN_CENTER; + wxPoint textpos = GetBoundingBox().Centre(); aPlotter->Text( textpos, color, GetShownText(), orient, GetTextSize(), hjustify, vjustify, penWidth, IsItalic(), IsBold() ); diff --git a/eeschema/sch_field.h b/eeschema/sch_field.h index 0f6d7b964ac..ff89831ac23 100644 --- a/eeschema/sch_field.h +++ b/eeschema/sch_field.h @@ -119,10 +119,10 @@ class SCH_FIELD : public SCH_ITEM, public EDA_TEXT /** * Adjusters to allow EDA_TEXT to draw/print/etc. text in absolute coords. */ - double GetDrawRotation() const override; + EDA_ANGLE GetDrawRotation() const override; wxPoint GetDrawPos() const override; - EDA_TEXT_HJUSTIFY_T GetDrawHorizJustify() const override; - EDA_TEXT_VJUSTIFY_T GetDrawVertJustify() const override; + GR_TEXT_H_ALIGN_T GetDrawHorizJustify() const override; + GR_TEXT_V_ALIGN_T GetDrawVertJustify() const override; const EDA_RECT GetBoundingBox() const override; @@ -133,8 +133,8 @@ class SCH_FIELD : public SCH_ITEM, public EDA_TEXT bool IsHorizJustifyFlipped() const; bool IsVertJustifyFlipped() const; - EDA_TEXT_HJUSTIFY_T GetEffectiveHorizJustify() const; - EDA_TEXT_VJUSTIFY_T GetEffectiveVertJustify() const; + GR_TEXT_H_ALIGN_T GetEffectiveHorizJustify() const; + GR_TEXT_V_ALIGN_T GetEffectiveVertJustify() const; /** * @return true if the field is either empty or holds "~". diff --git a/eeschema/sch_painter.cpp b/eeschema/sch_painter.cpp index 1774f8c0e59..4a2b63ce611 100644 --- a/eeschema/sch_painter.cpp +++ b/eeschema/sch_painter.cpp @@ -187,8 +187,8 @@ bool SCH_PAINTER::Draw( const VIEW_ITEM *aItem, int aLayer ) auto pos = item->GetBoundingBox().Centre(); auto label = conn->Name( true ); - m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_CENTER ); - m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_CENTER ); + m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_CENTER ); + m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_CENTER ); m_gal->SetStrokeColor( COLOR4D( LIGHTRED ) ); m_gal->SetLineWidth( Mils2ui( 2 ) ); m_gal->SetGlyphSize( VECTOR2D( Mils2ui( 20 ), Mils2ui( 20 ) ) ); @@ -448,14 +448,14 @@ void SCH_PAINTER::boxText( const wxString& aText, const VECTOR2D& aPosition, dou m_gal->GetLineWidth() ); EDA_RECT box( (wxPoint) aPosition, wxSize( extents.x, extents.y ) ); - if( m_gal->GetHorizontalJustify() == GR_TEXT_HJUSTIFY_CENTER ) + if( m_gal->GetHorizontalJustify() == GR_TEXT_H_ALIGN_CENTER ) box.SetX( box.GetX() - ( box.GetWidth() / 2) ); - else if( m_gal->GetHorizontalJustify() == GR_TEXT_HJUSTIFY_RIGHT ) + else if( m_gal->GetHorizontalJustify() == GR_TEXT_H_ALIGN_RIGHT ) box.SetX( box.GetX() - box.GetWidth() ); - if( m_gal->GetVerticalJustify() == GR_TEXT_VJUSTIFY_CENTER ) + if( m_gal->GetVerticalJustify() == GR_TEXT_V_ALIGN_CENTER ) box.SetY( box.GetY() - ( box.GetHeight() / 2) ); - else if( m_gal->GetVerticalJustify() == GR_TEXT_VJUSTIFY_BOTTOM ) + else if( m_gal->GetVerticalJustify() == GR_TEXT_V_ALIGN_BOTTOM ) box.SetY( box.GetY() - box.GetHeight() ); box.Normalize(); // Make h and v sizes always >= 0 @@ -695,12 +695,13 @@ void SCH_PAINTER::draw( const LIB_FIELD *aField, int aLayer ) } else { - m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_CENTER ); - m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_CENTER ); + m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_CENTER ); + m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_CENTER ); m_gal->SetGlyphSize( VECTOR2D( aField->GetTextSize() ) ); m_gal->SetFontItalic( aField->IsItalic() ); - strokeText( UnescapeString( aField->GetText() ), textpos, aField->GetTextAngleRadians() ); + strokeText( UnescapeString( aField->GetText() ), textpos, + aField->GetTextAngle().AsRadians() ); } // Draw the umbilical line when in the schematic editor @@ -736,10 +737,10 @@ void SCH_PAINTER::draw( const LIB_TEXT *aText, int aLayer ) EDA_RECT bBox = aText->GetBoundingBox(); bBox.RevertYAxis(); VECTOR2D pos = mapCoords( bBox.Centre() ); - double orient = aText->GetTextAngleRadians(); + double orient = aText->GetTextAngle().AsRadians(); - m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_CENTER ); - m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_CENTER ); + m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_CENTER ); + m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_CENTER ); m_gal->SetLineWidth( getTextThickness( aText, drawingShadows ) ); m_gal->SetIsFill( false ); m_gal->SetIsStroke( true ); @@ -1105,29 +1106,29 @@ void SCH_PAINTER::draw( LIB_PIN *aPin, int aLayer ) if( size[INSIDE] ) { setupDC( INSIDE ); - m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_RIGHT ); - m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_CENTER ); + m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_RIGHT ); + m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_CENTER ); drawText( text[INSIDE], pos + VECTOR2D( -insideOffset - len, 0 ), 0 ); } if( size[OUTSIDE] ) { setupDC( OUTSIDE ); - m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_LEFT ); - m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_CENTER ); + m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_LEFT ); + m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_CENTER ); drawText( text[OUTSIDE], pos + VECTOR2D( outsideOffset, 0 ), 0 ); } if( size[ABOVE] ) { setupDC( ABOVE ); - m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_CENTER ); - m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_BOTTOM ); + m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_CENTER ); + m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_BOTTOM ); drawText( text[ABOVE], pos + VECTOR2D( -len / 2.0, -aboveOffset ), 0 ); } if( size[BELOW] ) { setupDC( BELOW ); - m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_CENTER ); - m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_TOP ); + m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_CENTER ); + m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_TOP ); drawText( text[BELOW], pos + VECTOR2D( -len / 2.0, belowOffset ), 0 ); } break; @@ -1136,30 +1137,30 @@ void SCH_PAINTER::draw( LIB_PIN *aPin, int aLayer ) if( size[INSIDE] ) { setupDC( INSIDE ); - m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_LEFT ); - m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_CENTER ); - m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_LEFT ); + m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_LEFT ); + m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_CENTER ); + m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_LEFT ); drawText( text[INSIDE], pos + VECTOR2D( insideOffset + len, 0 ), 0 ); } if( size[OUTSIDE] ) { setupDC( OUTSIDE ); - m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_RIGHT ); - m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_CENTER ); + m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_RIGHT ); + m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_CENTER ); drawText( text[OUTSIDE], pos + VECTOR2D( -outsideOffset, 0 ), 0 ); } if( size[ABOVE] ) { setupDC( ABOVE ); - m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_CENTER ); - m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_BOTTOM ); + m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_CENTER ); + m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_BOTTOM ); drawText( text[ABOVE], pos + VECTOR2D( len / 2.0, -aboveOffset ), 0 ); } if( size[BELOW] ) { setupDC( BELOW ); - m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_CENTER ); - m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_TOP ); + m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_CENTER ); + m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_TOP ); drawText( text[BELOW], pos + VECTOR2D( len / 2.0, belowOffset ), 0 ); } break; @@ -1168,29 +1169,29 @@ void SCH_PAINTER::draw( LIB_PIN *aPin, int aLayer ) if( size[INSIDE] ) { setupDC( INSIDE ); - m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_RIGHT ); - m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_CENTER ); + m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_RIGHT ); + m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_CENTER ); drawText( text[INSIDE], pos + VECTOR2D( 0, insideOffset + len ), M_PI / 2 ); } if( size[OUTSIDE] ) { setupDC( OUTSIDE ); - m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_LEFT ); - m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_CENTER ); + m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_LEFT ); + m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_CENTER ); drawText( text[OUTSIDE], pos + VECTOR2D( 0, -outsideOffset ), M_PI / 2 ); } if( size[ABOVE] ) { setupDC( ABOVE ); - m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_CENTER ); - m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_BOTTOM ); + m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_CENTER ); + m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_BOTTOM ); drawText( text[ABOVE], pos + VECTOR2D( -aboveOffset, len / 2.0 ), M_PI / 2 ); } if( size[BELOW] ) { setupDC( BELOW ); - m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_CENTER ); - m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_TOP ); + m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_CENTER ); + m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_TOP ); drawText( text[BELOW], pos + VECTOR2D( belowOffset, len / 2.0 ), M_PI / 2 ); } break; @@ -1199,29 +1200,29 @@ void SCH_PAINTER::draw( LIB_PIN *aPin, int aLayer ) if( size[INSIDE] ) { setupDC( INSIDE ); - m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_LEFT ); - m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_CENTER ); + m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_LEFT ); + m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_CENTER ); drawText( text[INSIDE], pos + VECTOR2D( 0, -insideOffset - len ), M_PI / 2 ); } if( size[OUTSIDE] ) { setupDC( OUTSIDE ); - m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_RIGHT ); - m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_CENTER ); + m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_RIGHT ); + m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_CENTER ); drawText( text[OUTSIDE], pos + VECTOR2D( 0, outsideOffset ), M_PI / 2 ); } if( size[ABOVE] ) { setupDC( ABOVE ); - m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_CENTER ); - m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_BOTTOM ); + m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_CENTER ); + m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_BOTTOM ); drawText( text[ABOVE], pos + VECTOR2D( -aboveOffset, -len / 2.0 ), M_PI / 2 ); } if( size[BELOW] ) { setupDC( BELOW ); - m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_CENTER ); - m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_TOP ); + m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_CENTER ); + m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_TOP ); drawText( text[BELOW], pos + VECTOR2D( belowOffset, -len / 2.0 ), M_PI / 2 ); } break; @@ -1518,7 +1519,7 @@ void SCH_PAINTER::draw( const SCH_TEXT *aText, int aLayer ) m_gal->SetTextAttributes( aText ); m_gal->SetFontUnderlined( false ); - strokeText( shownText, text_offset, aText->GetTextAngleRadians() ); + strokeText( shownText, text_offset, aText->GetTextAngle().AsRadians() ); } } @@ -1672,17 +1673,17 @@ void SCH_PAINTER::draw( const SCH_FIELD *aField, int aLayer ) } // Calculate the text orientation according to the parent orientation. - int orient = (int) aField->GetTextAngle(); + EDA_ANGLE orient = aField->GetTextAngle(); if( aField->GetParent() && aField->GetParent()->Type() == SCH_SYMBOL_T ) { if( static_cast( aField->GetParent() )->GetTransform().y1 ) { // Rotate symbol 90 degrees. - if( orient == TEXT_ANGLE_HORIZ ) - orient = TEXT_ANGLE_VERT; + if( orient.IsHorizontal() ) + orient = EDA_ANGLE::VERTICAL; else - orient = TEXT_ANGLE_HORIZ; + orient = EDA_ANGLE::HORIZONTAL; } } @@ -1720,8 +1721,8 @@ void SCH_PAINTER::draw( const SCH_FIELD *aField, int aLayer ) } else { - m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_CENTER ); - m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_CENTER ); + m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_CENTER ); + m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_CENTER ); m_gal->SetIsFill( false ); m_gal->SetGlyphSize( VECTOR2D( aField->GetTextSize() ) ); m_gal->SetFontBold( aField->IsBold() ); @@ -1729,7 +1730,7 @@ void SCH_PAINTER::draw( const SCH_FIELD *aField, int aLayer ) m_gal->SetFontUnderlined( underline ); m_gal->SetTextMirrored( aField->IsMirrored() ); - strokeText( aField->GetShownText(), textpos, orient == TEXT_ANGLE_VERT ? M_PI / 2 : 0 ); + strokeText( aField->GetShownText(), textpos, orient.AsRadians() ); } // Draw the umbilical line diff --git a/eeschema/sch_plugins/altium/sch_altium_plugin.cpp b/eeschema/sch_plugins/altium/sch_altium_plugin.cpp index 461f675c8bc..e2c38cec64d 100644 --- a/eeschema/sch_plugins/altium/sch_altium_plugin.cpp +++ b/eeschema/sch_plugins/altium/sch_altium_plugin.cpp @@ -791,8 +791,8 @@ void SCH_ALTIUM_PLUGIN::ParsePin( const std::map& aPropertie void SetTextPositioning( EDA_TEXT* text, ASCH_LABEL_JUSTIFICATION justification, ASCH_RECORD_ORIENTATION orientation ) { - int vjustify, hjustify; - double angle = TEXT_ANGLE_HORIZ; + int vjustify, hjustify; + EDA_ANGLE angle = EDA_ANGLE::HORIZONTAL; switch( justification ) { @@ -801,17 +801,17 @@ void SetTextPositioning( EDA_TEXT* text, ASCH_LABEL_JUSTIFICATION justification, case ASCH_LABEL_JUSTIFICATION::BOTTOM_LEFT: case ASCH_LABEL_JUSTIFICATION::BOTTOM_CENTER: case ASCH_LABEL_JUSTIFICATION::BOTTOM_RIGHT: - vjustify = EDA_TEXT_VJUSTIFY_T::GR_TEXT_VJUSTIFY_BOTTOM; + vjustify = GR_TEXT_V_ALIGN_BOTTOM; break; case ASCH_LABEL_JUSTIFICATION::CENTER_LEFT: case ASCH_LABEL_JUSTIFICATION::CENTER_CENTER: case ASCH_LABEL_JUSTIFICATION::CENTER_RIGHT: - vjustify = EDA_TEXT_VJUSTIFY_T::GR_TEXT_VJUSTIFY_CENTER; + vjustify = GR_TEXT_V_ALIGN_CENTER; break; case ASCH_LABEL_JUSTIFICATION::TOP_LEFT: case ASCH_LABEL_JUSTIFICATION::TOP_CENTER: case ASCH_LABEL_JUSTIFICATION::TOP_RIGHT: - vjustify = EDA_TEXT_VJUSTIFY_T::GR_TEXT_VJUSTIFY_TOP; + vjustify = GR_TEXT_V_ALIGN_TOP; break; } @@ -822,42 +822,42 @@ void SetTextPositioning( EDA_TEXT* text, ASCH_LABEL_JUSTIFICATION justification, case ASCH_LABEL_JUSTIFICATION::BOTTOM_LEFT: case ASCH_LABEL_JUSTIFICATION::CENTER_LEFT: case ASCH_LABEL_JUSTIFICATION::TOP_LEFT: - hjustify = EDA_TEXT_HJUSTIFY_T::GR_TEXT_HJUSTIFY_LEFT; + hjustify = GR_TEXT_H_ALIGN_LEFT; break; case ASCH_LABEL_JUSTIFICATION::BOTTOM_CENTER: case ASCH_LABEL_JUSTIFICATION::CENTER_CENTER: case ASCH_LABEL_JUSTIFICATION::TOP_CENTER: - hjustify = EDA_TEXT_HJUSTIFY_T::GR_TEXT_HJUSTIFY_CENTER; + hjustify = GR_TEXT_H_ALIGN_CENTER; break; case ASCH_LABEL_JUSTIFICATION::BOTTOM_RIGHT: case ASCH_LABEL_JUSTIFICATION::CENTER_RIGHT: case ASCH_LABEL_JUSTIFICATION::TOP_RIGHT: - hjustify = EDA_TEXT_HJUSTIFY_T::GR_TEXT_HJUSTIFY_RIGHT; + hjustify = GR_TEXT_H_ALIGN_RIGHT; break; } switch( orientation ) { case ASCH_RECORD_ORIENTATION::RIGHTWARDS: - angle = TEXT_ANGLE_HORIZ; + angle = EDA_ANGLE::HORIZONTAL; break; case ASCH_RECORD_ORIENTATION::LEFTWARDS: vjustify *= -1; hjustify *= -1; - angle = TEXT_ANGLE_HORIZ; + angle = EDA_ANGLE::HORIZONTAL; break; case ASCH_RECORD_ORIENTATION::UPWARDS: - angle = TEXT_ANGLE_VERT; + angle = EDA_ANGLE::VERTICAL; break; case ASCH_RECORD_ORIENTATION::DOWNWARDS: vjustify *= -1; hjustify *= -1; - angle = TEXT_ANGLE_VERT; + angle = EDA_ANGLE::VERTICAL; break; } - text->SetVertJustify( static_cast( vjustify ) ); - text->SetHorizJustify( static_cast( hjustify ) ); + text->SetVertJustify( static_cast( vjustify ) ); + text->SetHorizJustify( static_cast( hjustify ) ); text->SetTextAngle( angle ); } @@ -1858,23 +1858,23 @@ void SCH_ALTIUM_PLUGIN::ParsePowerPort( const std::map& aPro { case ASCH_RECORD_ORIENTATION::RIGHTWARDS: symbol->SetOrientation( SYMBOL_ORIENTATION_T::SYM_ORIENT_90 ); - valueField->SetTextAngle( TEXT_ANGLE_VERT ); - valueField->SetHorizJustify( EDA_TEXT_HJUSTIFY_T::GR_TEXT_HJUSTIFY_RIGHT ); + valueField->SetTextAngle( EDA_ANGLE::VERTICAL ); + valueField->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); break; case ASCH_RECORD_ORIENTATION::UPWARDS: symbol->SetOrientation( SYMBOL_ORIENTATION_T::SYM_ORIENT_180 ); - valueField->SetTextAngle( TEXT_ANGLE_HORIZ ); - valueField->SetHorizJustify( EDA_TEXT_HJUSTIFY_T::GR_TEXT_HJUSTIFY_CENTER ); + valueField->SetTextAngle( EDA_ANGLE::HORIZONTAL ); + valueField->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER ); break; case ASCH_RECORD_ORIENTATION::LEFTWARDS: symbol->SetOrientation( SYMBOL_ORIENTATION_T::SYM_ORIENT_270 ); - valueField->SetTextAngle( TEXT_ANGLE_VERT ); - valueField->SetHorizJustify( EDA_TEXT_HJUSTIFY_T::GR_TEXT_HJUSTIFY_RIGHT ); + valueField->SetTextAngle( EDA_ANGLE::VERTICAL ); + valueField->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); break; case ASCH_RECORD_ORIENTATION::DOWNWARDS: symbol->SetOrientation( SYMBOL_ORIENTATION_T::SYM_ORIENT_0 ); - valueField->SetTextAngle( TEXT_ANGLE_HORIZ ); - valueField->SetHorizJustify( EDA_TEXT_HJUSTIFY_T::GR_TEXT_HJUSTIFY_CENTER ); + valueField->SetTextAngle( EDA_ANGLE::HORIZONTAL ); + valueField->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER ); break; default: m_reporter->Report( _( "Pin has unexpected orientation." ), RPT_SEVERITY_WARNING ); diff --git a/eeschema/sch_plugins/cadstar/cadstar_sch_archive_loader.cpp b/eeschema/sch_plugins/cadstar/cadstar_sch_archive_loader.cpp index 8c63003b0c9..7d3c0c33723 100644 --- a/eeschema/sch_plugins/cadstar/cadstar_sch_archive_loader.cpp +++ b/eeschema/sch_plugins/cadstar/cadstar_sch_archive_loader.cpp @@ -218,12 +218,12 @@ void CADSTAR_SCH_ARCHIVE_LOADER::Load( SCHEMATIC* aSchematic, SCH_SHEET* aRootSh // the margin to the nearest grid, ensuring all items remain on the grid. wxSize targetSheetSize = sheetBoundingBox.GetSize(); int longestSide = std::max( targetSheetSize.x, targetSheetSize.y ); - int margin = ( (double) longestSide * 0.03); + int margin = ( (double) longestSide * 0.03 ); margin = roundToNearestGrid( margin ); targetSheetSize.IncBy( margin * 2, margin * 2 ); // Update page size always - PAGE_INFO pageInfo = sheet->GetScreen()->GetPageSettings(); + PAGE_INFO pageInfo = sheet->GetScreen()->GetPageSettings(); pageInfo.SetWidthMils( Iu2Mils( targetSheetSize.x ) ); pageInfo.SetHeightMils( Iu2Mils( targetSheetSize.y ) ); @@ -243,7 +243,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::Load( SCHEMATIC* aSchematic, SCH_SHEET* aRootSh std::vector allItems; std::copy( sheet->GetScreen()->Items().begin(), sheet->GetScreen()->Items().end(), - std::back_inserter( allItems ) ); + std::back_inserter( allItems ) ); for( SCH_ITEM* item : allItems ) { @@ -295,9 +295,9 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSheets() wxFileName loadedFilePath = wxFileName( Filename ); - std::string filename = wxString::Format( - "%s_%02d", loadedFilePath.GetName(), getSheetNumber( rootSheetID ) ) - .ToStdString(); + std::string filename = wxString::Format( "%s_%02d", + loadedFilePath.GetName(), + getSheetNumber( rootSheetID ) ).ToStdString(); ReplaceIllegalFileNameChars( &filename ); filename += wxT( "." ) + KiCadSchematicFileExtension; @@ -366,7 +366,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadPartsLibrary() { for( std::pair partPair : Parts.PartDefinitions ) { - PART_ID partID = partPair.first; + PART_ID partID = partPair.first; PART part = partPair.second; if( part.Definition.GateSymbols.size() == 0 ) @@ -442,7 +442,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbolInstances() "symbol was not loaded" ), sym.ComponentRef.Designator, sym.PartRef.RefID ), - RPT_SEVERITY_ERROR); + RPT_SEVERITY_ERROR ); continue; } @@ -484,8 +484,8 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbolInstances() sym.ComponentRef.Designator.Replace( wxT( " " ), wxT( "_" ) ); refField->SetText( sym.ComponentRef.Designator ); - loadSymbolFieldAttribute( sym.ComponentRef.AttrLoc, symOrientDeciDeg, - sym.Mirror, refField ); + loadSymbolFieldAttribute( sym.ComponentRef.AttrLoc, symOrientDeciDeg, sym.Mirror, + refField ); if( sym.HasPartRef ) { @@ -506,8 +506,8 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbolInstances() partname.Replace( wxT( "\t" ), wxT( "\\t" ) ); partField->SetText( partname ); - loadSymbolFieldAttribute( sym.PartRef.AttrLoc, symOrientDeciDeg, - sym.Mirror, partField ); + loadSymbolFieldAttribute( sym.PartRef.AttrLoc, symOrientDeciDeg, sym.Mirror, + partField ); partField->SetVisible( SymbolPartNameColor.IsVisible ); } @@ -796,7 +796,6 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadBusses() // (the position of the wire will determine how best to place the bus label) } } - } } @@ -874,23 +873,20 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadNets() } auto getHierarchicalLabel = - [&]( NETELEMENT_ID aNode ) -> SCH_HIERLABEL* - { - if( aNode.Contains( "BLKT" ) ) + [&]( NETELEMENT_ID aNode ) -> SCH_HIERLABEL* { - NET_SCH::BLOCK_TERM blockTerm = net.BlockTerminals.at( aNode ); - BLOCK_PIN_ID blockPinID = std::make_pair( blockTerm.BlockID, - blockTerm.TerminalID ); - - if( m_sheetPinMap.find( blockPinID ) - != m_sheetPinMap.end() ) + if( aNode.Contains( "BLKT" ) ) { - return m_sheetPinMap.at( blockPinID ); + NET_SCH::BLOCK_TERM blockTerm = net.BlockTerminals.at( aNode ); + BLOCK_PIN_ID blockPinID = std::make_pair( blockTerm.BlockID, + blockTerm.TerminalID ); + + if( m_sheetPinMap.find( blockPinID ) != m_sheetPinMap.end() ) + return m_sheetPinMap.at( blockPinID ); } - } - return nullptr; - }; + return nullptr; + }; //Add net name to all hierarchical pins (block terminals in CADSTAR) for( std::pair blockPair : net.BlockTerminals ) @@ -1067,18 +1063,18 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadNets() } auto fixNetLabelsAndSheetPins = - [&]( double aWireAngleDeciDeg, NETELEMENT_ID& aNetEleID ) - { - LABEL_SPIN_STYLE spin = getSpinStyleDeciDeg( aWireAngleDeciDeg ); + [&]( double aWireAngleDeciDeg, NETELEMENT_ID& aNetEleID ) + { + LABEL_SPIN_STYLE spin = getSpinStyleDeciDeg( aWireAngleDeciDeg ); - if( netlabels.find( aNetEleID ) != netlabels.end() ) - netlabels.at( aNetEleID )->SetLabelSpinStyle( spin.MirrorY() ); + if( netlabels.find( aNetEleID ) != netlabels.end() ) + netlabels.at( aNetEleID )->SetLabelSpinStyle( spin.MirrorY() ); - SCH_HIERLABEL* sheetPin = getHierarchicalLabel( aNetEleID ); + SCH_HIERLABEL* sheetPin = getHierarchicalLabel( aNetEleID ); - if( sheetPin ) - sheetPin->SetLabelSpinStyle( spin.MirrorX() ); - }; + if( sheetPin ) + sheetPin->SetLabelSpinStyle( spin.MirrorX() ); + }; // Now we can load the wires and fix the label orientations for( const VECTOR2I& pt : wireChain.CPoints() ) @@ -1181,7 +1177,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadTexts() void CADSTAR_SCH_ARCHIVE_LOADER::loadDocumentationSymbols() { for( std::pair docSymPair : - Schematic.DocumentationSymbols ) + Schematic.DocumentationSymbols ) { DOCUMENTATION_SYMBOL docSym = docSymPair.second; @@ -1241,23 +1237,25 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadDocumentationSymbols() void CADSTAR_SCH_ARCHIVE_LOADER::loadTextVariables() { - auto findAndReplaceTextField = [&]( TEXT_FIELD_NAME aField, wxString aValue ) { - if( m_context.TextFieldToValuesMap.find( aField ) != m_context.TextFieldToValuesMap.end() ) - { - if( m_context.TextFieldToValuesMap.at( aField ) != aValue ) + auto findAndReplaceTextField = + [&]( TEXT_FIELD_NAME aField, wxString aValue ) { - m_context.TextFieldToValuesMap.at( aField ) = aValue; - m_context.InconsistentTextFields.insert( aField ); - return false; - } - } - else - { - m_context.TextFieldToValuesMap.insert( { aField, aValue } ); - } + if( m_context.TextFieldToValuesMap.find( aField ) != m_context.TextFieldToValuesMap.end() ) + { + if( m_context.TextFieldToValuesMap.at( aField ) != aValue ) + { + m_context.TextFieldToValuesMap.at( aField ) = aValue; + m_context.InconsistentTextFields.insert( aField ); + return false; + } + } + else + { + m_context.TextFieldToValuesMap.insert( { aField, aValue } ); + } - return true; - }; + return true; + }; PROJECT* pj = &m_schematic->Prj(); @@ -1314,7 +1312,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSymDefIntoLibrary( const SYMDEF_ID& aSymdef int lineThickness = getLineThickness( fig.LineCodeID ); loadLibrarySymbolShapeVertices( fig.Shape.Vertices, symbol.Origin, aSymbol, gateNumber, - lineThickness ); + lineThickness ); for( CUTOUT c : fig.Shape.Cutouts ) { @@ -1428,12 +1426,12 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSymDefIntoLibrary( const SYMDEF_ID& aSymdef EDA_RECT bbox = libtext->GetTextBox( ii, true ); wxPoint linePos = { bbox.GetLeft(), -bbox.GetBottom() }; - RotatePoint( &linePos, libtext->GetTextPos(), -libtext->GetTextAngle() ); + RotatePoint( &linePos, libtext->GetTextPos(), -libtext->GetTextAngle().AsTenthsOfADegree() ); LIB_TEXT* line = static_cast( libtext->Clone() ); line->SetText( strings[ii] ); - line->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); - line->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); + line->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); + line->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM ); line->SetTextPos( linePos ); // Multiline text not allowed in LIB_TEXT @@ -1498,87 +1496,87 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSymDefIntoLibrary( const SYMDEF_ID& aSymdef wxString footprintAlternateName = wxEmptyString; auto loadLibraryField = - [&]( ATTRIBUTE_VALUE& aAttributeVal ) - { - wxString attrName = getAttributeName( aAttributeVal.AttributeID ); + [&]( ATTRIBUTE_VALUE& aAttributeVal ) + { + wxString attrName = getAttributeName( aAttributeVal.AttributeID ); - // Remove invalid field characters - aAttributeVal.Value.Replace( wxT( "\n" ), wxT( "\\n" ) ); - aAttributeVal.Value.Replace( wxT( "\r" ), wxT( "\\r" ) ); - aAttributeVal.Value.Replace( wxT( "\t" ), wxT( "\\t" ) ); + // Remove invalid field characters + aAttributeVal.Value.Replace( wxT( "\n" ), wxT( "\\n" ) ); + aAttributeVal.Value.Replace( wxT( "\r" ), wxT( "\\r" ) ); + aAttributeVal.Value.Replace( wxT( "\t" ), wxT( "\\t" ) ); - //TODO: Handle "links": In cadstar a field can be a "link" if its name starts - // with the characters "Link ". Need to figure out how to convert them to - // equivalent in KiCad. + //TODO: Handle "links": In cadstar a field can be a "link" if its name starts + // with the characters "Link ". Need to figure out how to convert them to + // equivalent in KiCad. - if( attrName == wxT( "(PartDefinitionNameStem)" ) ) - { - //Space not allowed in Reference field - aAttributeVal.Value.Replace( wxT( " " ), "_" ); - aSymbol->GetReferenceField().SetText( aAttributeVal.Value ); - return; - } - else if( attrName == wxT( "(PartDescription)" ) ) - { - aSymbol->SetDescription( aAttributeVal.Value ); - return; - } - else if( attrName == wxT( "(PartDefinitionReferenceName)" ) ) - { - footprintRefName = aAttributeVal.Value; - return; - } - else if( attrName == wxT( "(PartDefinitionAlternateName)" ) ) - { - footprintAlternateName = aAttributeVal.Value; - return; - } + if( attrName == wxT( "(PartDefinitionNameStem)" ) ) + { + //Space not allowed in Reference field + aAttributeVal.Value.Replace( wxT( " " ), "_" ); + aSymbol->GetReferenceField().SetText( aAttributeVal.Value ); + return; + } + else if( attrName == wxT( "(PartDescription)" ) ) + { + aSymbol->SetDescription( aAttributeVal.Value ); + return; + } + else if( attrName == wxT( "(PartDefinitionReferenceName)" ) ) + { + footprintRefName = aAttributeVal.Value; + return; + } + else if( attrName == wxT( "(PartDefinitionAlternateName)" ) ) + { + footprintAlternateName = aAttributeVal.Value; + return; + } - LIB_FIELD* attrField = aSymbol->FindField( attrName ); + LIB_FIELD* attrField = aSymbol->FindField( attrName ); - if( !attrField ) - { - int fieldID = aSymbol->GetFieldCount(); - attrField = new LIB_FIELD( aSymbol, fieldID ); - attrField->SetName( attrName ); - aSymbol->AddField( attrField ); - } + if( !attrField ) + { + int fieldID = aSymbol->GetFieldCount(); + attrField = new LIB_FIELD( aSymbol, fieldID ); + attrField->SetName( attrName ); + aSymbol->AddField( attrField ); + } - wxASSERT( attrField->GetName() == attrName ); - attrField->SetText( aAttributeVal.Value ); - attrField->SetUnit( gateNumber ); + wxASSERT( attrField->GetName() == attrName ); + attrField->SetText( aAttributeVal.Value ); + attrField->SetUnit( gateNumber ); - ATTRIBUTE_ID& attrid = aAttributeVal.AttributeID; - attrField->SetVisible( isAttributeVisible( attrid ) ); + ATTRIBUTE_ID& attrid = aAttributeVal.AttributeID; + attrField->SetVisible( isAttributeVisible( attrid ) ); - if( aAttributeVal.HasLocation ) - { - // #1 Check if the part itself defined a location for the field - applyToLibraryFieldAttribute( aAttributeVal.AttributeLocation, symbol.Origin, - attrField ); - } - else if( symbol.TextLocations.find( aAttributeVal.AttributeID ) - != symbol.TextLocations.end() ) - { - // #2 Look in the symbol definition: Text locations - TEXT_LOCATION symTxtLoc = symbol.TextLocations.at( aAttributeVal.AttributeID ); - applyToLibraryFieldAttribute( symTxtLoc, symbol.Origin, attrField ); - } - else if( symbol.AttributeValues.find( attrid ) != symbol.AttributeValues.end() - && symbol.AttributeValues.at( attrid ).HasLocation ) - { - // #3 Look in the symbol definition: Attribute values - ATTRIBUTE_VALUE symAttrVal = symbol.AttributeValues.at( attrid ); - applyToLibraryFieldAttribute( symAttrVal.AttributeLocation, symbol.Origin, - attrField ); - } - else - { - attrField->SetVisible( false ); - applyTextSettings( attrField, wxT( "TC1" ), ALIGNMENT::NO_ALIGNMENT, - JUSTIFICATION::LEFT ); - } - }; + if( aAttributeVal.HasLocation ) + { + // #1 Check if the part itself defined a location for the field + applyToLibraryFieldAttribute( aAttributeVal.AttributeLocation, symbol.Origin, + attrField ); + } + else if( symbol.TextLocations.find( aAttributeVal.AttributeID ) + != symbol.TextLocations.end() ) + { + // #2 Look in the symbol definition: Text locations + TEXT_LOCATION symTxtLoc = symbol.TextLocations.at( aAttributeVal.AttributeID ); + applyToLibraryFieldAttribute( symTxtLoc, symbol.Origin, attrField ); + } + else if( symbol.AttributeValues.find( attrid ) != symbol.AttributeValues.end() + && symbol.AttributeValues.at( attrid ).HasLocation ) + { + // #3 Look in the symbol definition: Attribute values + ATTRIBUTE_VALUE symAttrVal = symbol.AttributeValues.at( attrid ); + applyToLibraryFieldAttribute( symAttrVal.AttributeLocation, symbol.Origin, + attrField ); + } + else + { + attrField->SetVisible( false ); + applyTextSettings( attrField, wxT( "TC1" ), ALIGNMENT::NO_ALIGNMENT, + JUSTIFICATION::LEFT ); + } + }; // Load all attributes in the Part Definition for( std::pairSetPosition( getKiCadPoint( aCadstarSymbol.Origin ) ); double compAngleDeciDeg = getAngleTenthDegree( aCadstarSymbol.OrientAngle ); - int compOrientation = 0; + int compOrientation = 0; if( aCadstarSymbol.Mirror ) { @@ -1744,7 +1742,7 @@ SCH_SYMBOL* CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbol( const SYMBOL& aCads "manual fixing." ), aCadstarSymbol.ComponentRef.Designator, compAngleDeciDeg / 10.0 ), - RPT_SEVERITY_ERROR); + RPT_SEVERITY_ERROR ); } symbol->SetOrientation( compOrientation ); @@ -1779,14 +1777,15 @@ SCH_SYMBOL* CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbol( const SYMBOL& aCads symbol->GetLibSymbolRef()->GetPin( term.second ) } ); } - auto replacePinNumber = [&]( wxString aOldPinNum, wxString aNewPinNum ) - { - if( aOldPinNum == aNewPinNum ) - return; + auto replacePinNumber = + [&]( wxString aOldPinNum, wxString aNewPinNum ) + { + if( aOldPinNum == aNewPinNum ) + return; - LIB_PIN* libpin = pinNumToLibPinMap.at( aOldPinNum ); - libpin->SetNumber( HandleTextOverbar( aNewPinNum ) ); - }; + LIB_PIN* libpin = pinNumToLibPinMap.at( aOldPinNum ); + libpin->SetNumber( HandleTextOverbar( aNewPinNum ) ); + }; //Older versions of Cadstar used pin numbers for( auto& pinPair : aCadstarSymbol.PinNumbers ) @@ -1847,8 +1846,8 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSymbolFieldAttribute( } -int CADSTAR_SCH_ARCHIVE_LOADER::getComponentOrientation( - double aOrientAngleDeciDeg, double& aReturnedOrientationDeciDeg ) +int CADSTAR_SCH_ARCHIVE_LOADER::getComponentOrientation( double aOrientAngleDeciDeg, + double& aReturnedOrientationDeciDeg ) { int compOrientation = SYMBOL_ORIENTATION_T::SYM_ORIENT_0; @@ -1879,8 +1878,9 @@ int CADSTAR_SCH_ARCHIVE_LOADER::getComponentOrientation( } -CADSTAR_SCH_ARCHIVE_LOADER::POINT CADSTAR_SCH_ARCHIVE_LOADER::getLocationOfNetElement( - const NET_SCH& aNet, const NETELEMENT_ID& aNetElementID ) +CADSTAR_SCH_ARCHIVE_LOADER::POINT +CADSTAR_SCH_ARCHIVE_LOADER::getLocationOfNetElement( const NET_SCH& aNet, + const NETELEMENT_ID& aNetElementID ) { // clang-format off auto logUnknownNetElementError = @@ -2028,8 +2028,8 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadShapeVertices( const std::vector& a const VERTEX* prev = &aCadstarVertices.at( 0 ); const VERTEX* cur; - wxASSERT_MSG( - prev->Type == VERTEX_TYPE::POINT, "First vertex should always be a point vertex" ); + wxASSERT_MSG( prev->Type == VERTEX_TYPE::POINT, + "First vertex should always be a point vertex" ); for( size_t ii = 1; ii < aCadstarVertices.size(); ii++ ) { @@ -2124,8 +2124,8 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSheetAndChildSheets( wxCHECK_MSG( m_sheetMap.find( aCadstarSheetID ) == m_sheetMap.end(), , "Sheet already loaded!" ); - SCH_SHEET* sheet = new SCH_SHEET( aParentSheet.Last(), aPosition ); - SCH_SCREEN* screen = new SCH_SCREEN( m_schematic ); + SCH_SHEET* sheet = new SCH_SHEET( aParentSheet.Last(), aPosition ); + SCH_SCREEN* screen = new SCH_SCREEN( m_schematic ); SCH_SHEET_PATH instance( aParentSheet ); sheet->SetSize( aSheetSize ); @@ -2138,8 +2138,8 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSheetAndChildSheets( sheetNameField.SetText( name ); - int sheetNum = getSheetNumber( aCadstarSheetID ); - wxString loadedFilename = wxFileName( Filename ).GetName(); + int sheetNum = getSheetNumber( aCadstarSheetID ); + wxString loadedFilename = wxFileName( Filename ).GetName(); std::string filename = wxString::Format( "%s_%02d", loadedFilename, sheetNum ).ToStdString(); ReplaceIllegalFileNameChars( &filename ); @@ -2168,7 +2168,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadChildSheets( LAYER_ID aCadstarSheetID, const SCH_SHEET_PATH& aSheet ) { wxCHECK_MSG( m_sheetMap.find( aCadstarSheetID ) != m_sheetMap.end(), , - "FIXME! Parent sheet should be loaded before attempting to load subsheets" ); + "FIXME! Parent sheet should be loaded before attempting to load subsheets" ); for( std::pair blockPair : Schematic.Blocks ) { @@ -2327,8 +2327,8 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadItemOntoKiCadSheet( LAYER_ID aCadstarSheetI } else if( aCadstarSheetID == "NO_SHEET" ) { - wxASSERT_MSG( - false, "Trying to add an item to NO_SHEET? This might be a documentation symbol." ); + wxASSERT_MSG( false, + "Trying to add an item to NO_SHEET? This might be a documentation symbol." ); } else { @@ -2345,8 +2345,9 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadItemOntoKiCadSheet( LAYER_ID aCadstarSheetI } -CADSTAR_SCH_ARCHIVE_LOADER::SYMDEF_ID CADSTAR_SCH_ARCHIVE_LOADER::getSymDefFromName( - const wxString& aSymdefName, const wxString& aSymDefAlternate ) +CADSTAR_SCH_ARCHIVE_LOADER::SYMDEF_ID +CADSTAR_SCH_ARCHIVE_LOADER::getSymDefFromName( const wxString& aSymdefName, + const wxString& aSymDefAlternate ) { // Do a case-insensitive comparison for( std::pair symPair : Library.SymbolDefinitions ) @@ -2409,8 +2410,8 @@ PLOT_DASH_TYPE CADSTAR_SCH_ARCHIVE_LOADER::getLineStyle( const LINECODE_ID& aCad } -CADSTAR_SCH_ARCHIVE_LOADER::TEXTCODE CADSTAR_SCH_ARCHIVE_LOADER::getTextCode( - const TEXTCODE_ID& aCadstarTextCodeID ) +CADSTAR_SCH_ARCHIVE_LOADER::TEXTCODE +CADSTAR_SCH_ARCHIVE_LOADER::getTextCode( const TEXTCODE_ID& aCadstarTextCodeID ) { wxCHECK( Assignments.Codedefs.TextCodes.find( aCadstarTextCodeID ) != Assignments.Codedefs.TextCodes.end(), @@ -2438,8 +2439,8 @@ wxString CADSTAR_SCH_ARCHIVE_LOADER::getAttributeName( const ATTRIBUTE_ID& aCads } -CADSTAR_SCH_ARCHIVE_LOADER::PART CADSTAR_SCH_ARCHIVE_LOADER::getPart( - const PART_ID& aCadstarPartID ) +CADSTAR_SCH_ARCHIVE_LOADER::PART +CADSTAR_SCH_ARCHIVE_LOADER::getPart( const PART_ID& aCadstarPartID ) { wxCHECK( Parts.PartDefinitions.find( aCadstarPartID ) != Parts.PartDefinitions.end(), PART() ); @@ -2447,8 +2448,8 @@ CADSTAR_SCH_ARCHIVE_LOADER::PART CADSTAR_SCH_ARCHIVE_LOADER::getPart( } -CADSTAR_SCH_ARCHIVE_LOADER::ROUTECODE CADSTAR_SCH_ARCHIVE_LOADER::getRouteCode( - const ROUTECODE_ID& aCadstarRouteCodeID ) +CADSTAR_SCH_ARCHIVE_LOADER::ROUTECODE +CADSTAR_SCH_ARCHIVE_LOADER::getRouteCode( const ROUTECODE_ID& aCadstarRouteCodeID ) { wxCHECK( Assignments.Codedefs.RouteCodes.find( aCadstarRouteCodeID ) != Assignments.Codedefs.RouteCodes.end(), @@ -2458,11 +2459,12 @@ CADSTAR_SCH_ARCHIVE_LOADER::ROUTECODE CADSTAR_SCH_ARCHIVE_LOADER::getRouteCode( } -CADSTAR_SCH_ARCHIVE_LOADER::PART::DEFINITION::PIN CADSTAR_SCH_ARCHIVE_LOADER::getPartDefinitionPin( - const PART& aCadstarPart, const GATE_ID& aGateID, const TERMINAL_ID& aTerminalID ) +CADSTAR_SCH_ARCHIVE_LOADER::PART::DEFINITION::PIN +CADSTAR_SCH_ARCHIVE_LOADER::getPartDefinitionPin( const PART& aCadstarPart, const GATE_ID& aGateID, + const TERMINAL_ID& aTerminalID ) { for( std::pair pinPair : - aCadstarPart.Definition.Pins ) + aCadstarPart.Definition.Pins ) { PART::DEFINITION::PIN partPin = pinPair.second; @@ -2635,48 +2637,48 @@ void CADSTAR_SCH_ARCHIVE_LOADER::applyTextSettings( EDA_TEXT* aKiCadT FixTextPositionNoAlignment( aText ); KI_FALLTHROUGH; case ALIGNMENT::BOTTOMLEFT: - aText->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); - aText->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); + aText->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM ); + aText->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); break; case ALIGNMENT::BOTTOMCENTER: - aText->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); - aText->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER ); + aText->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM ); + aText->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER ); break; case ALIGNMENT::BOTTOMRIGHT: - aText->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); - aText->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); + aText->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM ); + aText->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); break; case ALIGNMENT::CENTERLEFT: - aText->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); - aText->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); + aText->SetVertJustify( GR_TEXT_V_ALIGN_CENTER ); + aText->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); break; case ALIGNMENT::CENTERCENTER: - aText->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); - aText->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER ); + aText->SetVertJustify( GR_TEXT_V_ALIGN_CENTER ); + aText->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER ); break; case ALIGNMENT::CENTERRIGHT: - aText->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); - aText->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); + aText->SetVertJustify( GR_TEXT_V_ALIGN_CENTER ); + aText->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); break; case ALIGNMENT::TOPLEFT: - aText->SetVertJustify( GR_TEXT_VJUSTIFY_TOP ); - aText->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); + aText->SetVertJustify( GR_TEXT_V_ALIGN_TOP ); + aText->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); break; case ALIGNMENT::TOPCENTER: - aText->SetVertJustify( GR_TEXT_VJUSTIFY_TOP ); - aText->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER ); + aText->SetVertJustify( GR_TEXT_V_ALIGN_TOP ); + aText->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER ); break; case ALIGNMENT::TOPRIGHT: - aText->SetVertJustify( GR_TEXT_VJUSTIFY_TOP ); - aText->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); + aText->SetVertJustify( GR_TEXT_V_ALIGN_TOP ); + aText->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); break; } }; @@ -2695,7 +2697,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::applyTextSettings( EDA_TEXT* aKiCadT { // Spin style not used. All text justifications are permitted. However, only orientations // of 0 deg or 90 deg are supported - double angleDeciDeg = NormalizeAnglePos( aKiCadTextItem->GetTextAngle() ); + double angleDeciDeg = NormalizeAnglePos( aKiCadTextItem->GetTextAngle().AsTenthsOfADegree() ); int quadrant = KiROUND( angleDeciDeg / 900.0 ); quadrant %= 4; @@ -2725,7 +2727,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::applyTextSettings( EDA_TEXT* aKiCadT case SCH_TEXT_T: { - // Note spin style in a SCH_TEXT results in a vertical alignment GR_TEXT_VJUSTIFY_BOTTOM + // Note spin style in a SCH_TEXT results in a vertical alignment GR_TEXT_V_ALIGN_BOTTOM // so need to adjust the location of the text element based on Cadstar's original text // alignment (anchor position). setAlignment( aKiCadTextItem, textAlignment ); @@ -3055,6 +3057,6 @@ double CADSTAR_SCH_ARCHIVE_LOADER::getPolarAngle( const wxPoint& aPoint ) double CADSTAR_SCH_ARCHIVE_LOADER::getPolarRadius( const wxPoint& aPoint ) { - return sqrt( - ( (double) aPoint.x * (double) aPoint.x ) + ( (double) aPoint.y * (double) aPoint.y ) ); + return sqrt( ( (double) aPoint.x * (double) aPoint.x ) + + ( (double) aPoint.y * (double) aPoint.y ) ); } diff --git a/eeschema/sch_plugins/eagle/sch_eagle_plugin.cpp b/eeschema/sch_plugins/eagle/sch_eagle_plugin.cpp index 0399b42e8e9..6a5993c99ad 100644 --- a/eeschema/sch_plugins/eagle/sch_eagle_plugin.cpp +++ b/eeschema/sch_plugins/eagle/sch_eagle_plugin.cpp @@ -298,53 +298,53 @@ static void eagleToKicadAlignment( EDA_TEXT* aText, int aEagleAlignment, int aRe switch( align ) { case ETEXT::CENTER: - aText->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER ); - aText->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); + aText->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER ); + aText->SetVertJustify( GR_TEXT_V_ALIGN_CENTER ); break; case ETEXT::CENTER_LEFT: - aText->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); - aText->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); + aText->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); + aText->SetVertJustify( GR_TEXT_V_ALIGN_CENTER ); break; case ETEXT::CENTER_RIGHT: - aText->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); - aText->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); + aText->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); + aText->SetVertJustify( GR_TEXT_V_ALIGN_CENTER ); break; case ETEXT::TOP_CENTER: - aText->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER ); - aText->SetVertJustify( GR_TEXT_VJUSTIFY_TOP ); + aText->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER ); + aText->SetVertJustify( GR_TEXT_V_ALIGN_TOP ); break; case ETEXT::TOP_LEFT: - aText->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); - aText->SetVertJustify( GR_TEXT_VJUSTIFY_TOP ); + aText->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); + aText->SetVertJustify( GR_TEXT_V_ALIGN_TOP ); break; case ETEXT::TOP_RIGHT: - aText->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); - aText->SetVertJustify( GR_TEXT_VJUSTIFY_TOP ); + aText->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); + aText->SetVertJustify( GR_TEXT_V_ALIGN_TOP ); break; case ETEXT::BOTTOM_CENTER: - aText->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER ); - aText->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); + aText->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER ); + aText->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM ); break; case ETEXT::BOTTOM_LEFT: - aText->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); - aText->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); + aText->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); + aText->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM ); break; case ETEXT::BOTTOM_RIGHT: - aText->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); - aText->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); + aText->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); + aText->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM ); break; default: - aText->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); - aText->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); + aText->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); + aText->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM ); break; } } diff --git a/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp b/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp index 5f8ff97452a..66cf680bd98 100644 --- a/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp +++ b/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp @@ -130,7 +130,7 @@ void SCH_SEXPR_PARSER::ParseLib( LIB_SYMBOL_MAP& aSymbolLibMap ) NextTok(); parseHeader( T_kicad_symbol_lib, SEXPR_SYMBOL_LIB_FILE_VERSION ); - for( token = NextTok(); token != T_RIGHT; token = NextTok() ) + for( token = NextTok(); token != T_RIGHT; token = NextTok() ) { if( token != T_LEFT ) Expecting( T_LEFT ); @@ -193,7 +193,7 @@ LIB_SYMBOL* SCH_SEXPR_PARSER::ParseSymbol( LIB_SYMBOL_MAP& aSymbolLibMap, int aF symbol->SetName( m_symbolName ); symbol->SetLibId( id ); - for( token = NextTok(); token != T_RIGHT; token = NextTok() ) + for( token = NextTok(); token != T_RIGHT; token = NextTok() ) { if( token != T_LEFT ) Expecting( T_LEFT ); @@ -331,7 +331,7 @@ LIB_SYMBOL* SCH_SEXPR_PARSER::ParseSymbol( LIB_SYMBOL_MAP& aSymbolLibMap, int aF if( m_unit > symbol->GetUnitCount() ) symbol->SetUnitCount( m_unit, false ); - for( token = NextTok(); token != T_RIGHT; token = NextTok() ) + for( token = NextTok(); token != T_RIGHT; token = NextTok() ) { if( token != T_LEFT ) Expecting( T_LEFT ); @@ -506,7 +506,7 @@ void SCH_SEXPR_PARSER::parseFill( FILL_PARAMS& aFill ) T token; - for( token = NextTok(); token != T_RIGHT; token = NextTok() ) + for( token = NextTok(); token != T_RIGHT; token = NextTok() ) { if( token != T_LEFT ) Expecting( T_LEFT ); @@ -564,7 +564,7 @@ void SCH_SEXPR_PARSER::parseEDA_TEXT( EDA_TEXT* aText, bool aConvertOverbarSynta T token; - for( token = NextTok(); token != T_RIGHT; token = NextTok() ) + for( token = NextTok(); token != T_RIGHT; token = NextTok() ) { if( token == T_LEFT ) token = NextTok(); @@ -572,7 +572,7 @@ void SCH_SEXPR_PARSER::parseEDA_TEXT( EDA_TEXT* aText, bool aConvertOverbarSynta switch( token ) { case T_font: - for( token = NextTok(); token != T_RIGHT; token = NextTok() ) + for( token = NextTok(); token != T_RIGHT; token = NextTok() ) { if( token == T_LEFT ) token = NextTok(); @@ -614,11 +614,11 @@ void SCH_SEXPR_PARSER::parseEDA_TEXT( EDA_TEXT* aText, bool aConvertOverbarSynta { switch( token ) { - case T_left: aText->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); break; - case T_right: aText->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); break; - case T_top: aText->SetVertJustify( GR_TEXT_VJUSTIFY_TOP ); break; - case T_bottom: aText->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); break; - case T_mirror: aText->SetMirrored( true ); break; + case T_left: aText->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); break; + case T_right: aText->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); break; + case T_top: aText->SetVertJustify( GR_TEXT_V_ALIGN_TOP ); break; + case T_bottom: aText->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM ); break; + case T_mirror: aText->SetMirrored( true ); break; default: Expecting( "left, right, top, bottom, or mirror" ); } } @@ -752,7 +752,7 @@ LIB_FIELD* SCH_SEXPR_PARSER::parseProperty( std::unique_ptr& aSymbol field->SetText( value ); - for( token = NextTok(); token != T_RIGHT; token = NextTok() ) + for( token = NextTok(); token != T_RIGHT; token = NextTok() ) { if( token != T_LEFT ) Expecting( T_LEFT ); @@ -838,7 +838,7 @@ LIB_FIELD* SCH_SEXPR_PARSER::parseProperty( std::unique_ptr& aSymbol wxString base_name = field->GetCanonicalName(); // Arbitrary limit 10 attempts to find a new name - for( int ii = 1; ii < 10 && existingField ; ii++ ) + for( int ii = 1; ii < 10 && existingField; ii++ ) { wxString newname = base_name; newname << '_' << ii; @@ -914,7 +914,7 @@ LIB_SHAPE* SCH_SEXPR_PARSER::parseArc() break; case T_radius: - for( token = NextTok(); token != T_RIGHT; token = NextTok() ) + for( token = NextTok(); token != T_RIGHT; token = NextTok() ) { if( token != T_LEFT ) Expecting( T_LEFT ); @@ -1014,7 +1014,7 @@ LIB_SHAPE* SCH_SEXPR_PARSER::parseBezier() bezier->SetUnit( m_unit ); bezier->SetConvert( m_convert ); - for( token = NextTok(); token != T_RIGHT; token = NextTok() ) + for( token = NextTok(); token != T_RIGHT; token = NextTok() ) { if( token != T_LEFT ) Expecting( T_LEFT ); @@ -1089,7 +1089,7 @@ LIB_SHAPE* SCH_SEXPR_PARSER::parseCircle() circle->SetUnit( m_unit ); circle->SetConvert( m_convert ); - for( token = NextTok(); token != T_RIGHT; token = NextTok() ) + for( token = NextTok(); token != T_RIGHT; token = NextTok() ) { if( token != T_LEFT ) Expecting( T_LEFT ); @@ -1183,9 +1183,9 @@ LIB_PIN* SCH_SEXPR_PARSER::parsePin() wxCHECK_MSG( CurTok() == T_pin, nullptr, wxT( "Cannot parse " ) + GetTokenString( CurTok() ) + wxT( " as a pin token." ) ); - T token; - wxString tmp; - wxString error; + T token; + wxString tmp; + wxString error; std::unique_ptr pin = std::make_unique( nullptr ); pin->SetUnit( m_unit ); @@ -1199,7 +1199,7 @@ LIB_PIN* SCH_SEXPR_PARSER::parsePin() token = NextTok(); pin->SetShape( parseShape( token ) ); - for( token = NextTok(); token != T_RIGHT; token = NextTok() ) + for( token = NextTok(); token != T_RIGHT; token = NextTok() ) { if( token == T_hide ) { @@ -1329,8 +1329,8 @@ LIB_PIN* SCH_SEXPR_PARSER::parsePin() pin->GetAlternates()[ alt.m_Name ] = alt; NeedRIGHT(); - } break; + } default: Expecting( "at, name, number, length, or alternate" ); @@ -1364,7 +1364,7 @@ LIB_SHAPE* SCH_SEXPR_PARSER::parsePolyLine() switch( token ) { case T_pts: - for( token = NextTok(); token != T_RIGHT; token = NextTok() ) + for( token = NextTok(); token != T_RIGHT; token = NextTok() ) { if( token != T_LEFT ) Expecting( T_LEFT ); @@ -1414,7 +1414,7 @@ LIB_SHAPE* SCH_SEXPR_PARSER::parseRectangle() rectangle->SetUnit( m_unit ); rectangle->SetConvert( m_convert ); - for( token = NextTok(); token != T_RIGHT; token = NextTok() ) + for( token = NextTok(); token != T_RIGHT; token = NextTok() ) { if( token != T_LEFT ) Expecting( T_LEFT ); @@ -1474,7 +1474,7 @@ LIB_TEXT* SCH_SEXPR_PARSER::parseText() text->SetText( FromUTF8() ); - for( token = NextTok(); token != T_RIGHT; token = NextTok() ) + for( token = NextTok(); token != T_RIGHT; token = NextTok() ) { if( token != T_LEFT ) Expecting( T_LEFT ); @@ -1561,7 +1561,7 @@ void SCH_SEXPR_PARSER::parseTITLE_BLOCK( TITLE_BLOCK& aTitleBlock ) T token; - for( token = NextTok(); token != T_RIGHT; token = NextTok() ) + for( token = NextTok(); token != T_RIGHT; token = NextTok() ) { if( token != T_LEFT ) Expecting( T_LEFT ); @@ -1696,7 +1696,7 @@ SCH_FIELD* SCH_SEXPR_PARSER::parseSchField( SCH_ITEM* aParent ) field->SetText( value ); field->SetVisible( true ); - for( token = NextTok(); token != T_RIGHT; token = NextTok() ) + for( token = NextTok(); token != T_RIGHT; token = NextTok() ) { if( token != T_LEFT ) Expecting( T_LEFT ); @@ -1766,7 +1766,7 @@ SCH_SHEET_PIN* SCH_SEXPR_PARSER::parseSchSheetPin( SCH_SHEET* aSheet ) Expecting( "input, output, bidirectional, tri_state, or passive" ); } - for( token = NextTok(); token != T_RIGHT; token = NextTok() ) + for( token = NextTok(); token != T_RIGHT; token = NextTok() ) { if( token != T_LEFT ) Expecting( T_LEFT ); @@ -1823,7 +1823,7 @@ void SCH_SEXPR_PARSER::parseSchSheetInstances( SCH_SHEET* aRootSheet, SCH_SCREEN T token; - for( token = NextTok(); token != T_RIGHT; token = NextTok() ) + for( token = NextTok(); token != T_RIGHT; token = NextTok() ) { if( token != T_LEFT ) Expecting( T_LEFT ); @@ -1840,7 +1840,7 @@ void SCH_SEXPR_PARSER::parseSchSheetInstances( SCH_SHEET* aRootSheet, SCH_SCREEN instance.m_Path = KIID_PATH( FromUTF8() ); - for( token = NextTok(); token != T_RIGHT; token = NextTok() ) + for( token = NextTok(); token != T_RIGHT; token = NextTok() ) { if( token != T_LEFT ) Expecting( T_LEFT ); @@ -1902,7 +1902,7 @@ void SCH_SEXPR_PARSER::parseSchSymbolInstances( SCH_SCREEN* aScreen ) T token; - for( token = NextTok(); token != T_RIGHT; token = NextTok() ) + for( token = NextTok(); token != T_RIGHT; token = NextTok() ) { if( token != T_LEFT ) Expecting( T_LEFT ); @@ -1919,7 +1919,7 @@ void SCH_SEXPR_PARSER::parseSchSymbolInstances( SCH_SCREEN* aScreen ) instance.m_Path = KIID_PATH( FromUTF8() ); - for( token = NextTok(); token != T_RIGHT; token = NextTok() ) + for( token = NextTok(); token != T_RIGHT; token = NextTok() ) { if( token != T_LEFT ) Expecting( T_LEFT ); @@ -1993,7 +1993,7 @@ void SCH_SEXPR_PARSER::ParseSchematic( SCH_SHEET* aSheet, bool aIsCopyableOnly, screen->SetFileFormatVersionAtLoad( m_requiredVersion ); - for( token = NextTok(); token != T_RIGHT; token = NextTok() ) + for( token = NextTok(); token != T_RIGHT; token = NextTok() ) { if( aIsCopyableOnly && token == T_EOF ) break; @@ -2057,7 +2057,7 @@ void SCH_SEXPR_PARSER::ParseSchematic( SCH_SHEET* aSheet, bool aIsCopyableOnly, LIB_SYMBOL_MAP symbolLibMap; LIB_SYMBOL* symbol; - for( token = NextTok(); token != T_RIGHT; token = NextTok() ) + for( token = NextTok(); token != T_RIGHT; token = NextTok() ) { if( token != T_LEFT ) Expecting( T_LEFT ); @@ -2188,7 +2188,7 @@ SCH_SYMBOL* SCH_SEXPR_PARSER::parseSchematicSymbol() m_fieldId = MANDATORY_FIELDS; - for( token = NextTok(); token != T_RIGHT; token = NextTok() ) + for( token = NextTok(); token != T_RIGHT; token = NextTok() ) { if( token != T_LEFT ) Expecting( T_LEFT ); @@ -2322,7 +2322,7 @@ SCH_SYMBOL* SCH_SEXPR_PARSER::parseSchematicSymbol() while( prefix.Length() ) { - if( ( prefix.Last() < '0' || prefix.Last() > '9') && prefix.Last() != '?' ) + if( ( prefix.Last() < '0' || prefix.Last() > '9' ) && prefix.Last() != '?' ) break; prefix.RemoveLast(); @@ -2356,7 +2356,7 @@ SCH_SYMBOL* SCH_SEXPR_PARSER::parseSchematicSymbol() NeedSYMBOL(); number = FromUTF8(); - for( token = NextTok(); token != T_RIGHT; token = NextTok() ) + for( token = NextTok(); token != T_RIGHT; token = NextTok() ) { if( token != T_LEFT ) Expecting( T_LEFT ); @@ -2414,10 +2414,10 @@ SCH_BITMAP* SCH_SEXPR_PARSER::parseImage() wxCHECK_MSG( CurTok() == T_image, nullptr, wxT( "Cannot parse " ) + GetTokenString( CurTok() ) + wxT( " as an image." ) ); - T token; + T token; std::unique_ptr bitmap = std::make_unique(); - for( token = NextTok(); token != T_RIGHT; token = NextTok() ) + for( token = NextTok(); token != T_RIGHT; token = NextTok() ) { if( token != T_LEFT ) Expecting( T_LEFT ); @@ -2465,10 +2465,10 @@ SCH_BITMAP* SCH_SEXPR_PARSER::parseImage() token = NextTok(); } - wxMemoryBuffer buffer = wxBase64Decode( data ); + wxMemoryBuffer buffer = wxBase64Decode( data ); wxMemoryOutputStream stream( buffer.GetData(), buffer.GetBufSize() ); - wxImage* image = new wxImage(); - wxMemoryInputStream istream( stream ); + wxImage* image = new wxImage(); + wxMemoryInputStream istream( stream ); image->LoadFile( istream, wxBITMAP_TYPE_PNG ); bitmap->GetImage()->SetImage( image ); bitmap->GetImage()->SetBitmap( new wxBitmap( *image ) ); @@ -2500,7 +2500,7 @@ SCH_SHEET* SCH_SEXPR_PARSER::parseSheet() // We'll reset this if we find a fields_autoplaced token sheet->ClearFieldsAutoplaced(); - for( token = NextTok(); token != T_RIGHT; token = NextTok() ) + for( token = NextTok(); token != T_RIGHT; token = NextTok() ) { if( token != T_LEFT ) Expecting( T_LEFT ); @@ -2596,10 +2596,10 @@ SCH_JUNCTION* SCH_SEXPR_PARSER::parseJunction() wxCHECK_MSG( CurTok() == T_junction, nullptr, wxT( "Cannot parse " ) + GetTokenString( CurTok() ) + wxT( " as a junction." ) ); - T token; + T token; std::unique_ptr junction = std::make_unique(); - for( token = NextTok(); token != T_RIGHT; token = NextTok() ) + for( token = NextTok(); token != T_RIGHT; token = NextTok() ) { if( token != T_LEFT ) Expecting( T_LEFT ); @@ -2652,10 +2652,10 @@ SCH_NO_CONNECT* SCH_SEXPR_PARSER::parseNoConnect() wxCHECK_MSG( CurTok() == T_no_connect, nullptr, wxT( "Cannot parse " ) + GetTokenString( CurTok() ) + wxT( " as a no connect." ) ); - T token; + T token; std::unique_ptr no_connect = std::make_unique(); - for( token = NextTok(); token != T_RIGHT; token = NextTok() ) + for( token = NextTok(); token != T_RIGHT; token = NextTok() ) { if( token != T_LEFT ) Expecting( T_LEFT ); @@ -2693,7 +2693,7 @@ SCH_BUS_WIRE_ENTRY* SCH_SEXPR_PARSER::parseBusEntry() STROKE_PARAMS stroke( Mils2iu( DEFAULT_LINE_WIDTH_MILS ), PLOT_DASH_TYPE::DEFAULT ); std::unique_ptr busEntry = std::make_unique(); - for( token = NextTok(); token != T_RIGHT; token = NextTok() ) + for( token = NextTok(); token != T_RIGHT; token = NextTok() ) { if( token != T_LEFT ) Expecting( T_LEFT ); @@ -2755,7 +2755,7 @@ SCH_LINE* SCH_SEXPR_PARSER::parseLine() std::unique_ptr line = std::make_unique( wxPoint(), layer ); - for( token = NextTok(); token != T_RIGHT; token = NextTok() ) + for( token = NextTok(); token != T_RIGHT; token = NextTok() ) { if( token != T_LEFT ) Expecting( T_LEFT ); @@ -2809,20 +2809,20 @@ SCH_SHAPE* SCH_SEXPR_PARSER::parseSchArc() wxCHECK_MSG( CurTok() == T_arc, nullptr, wxT( "Cannot parse " ) + GetTokenString( CurTok() ) + wxT( " as an arc." ) ); - T token; - wxPoint startPoint; - wxPoint midPoint; - wxPoint endPoint; - wxPoint pos; - int startAngle; - int endAngle; + T token; + wxPoint startPoint; + wxPoint midPoint; + wxPoint endPoint; + wxPoint pos; + int startAngle; + int endAngle; STROKE_PARAMS stroke( Mils2iu( DEFAULT_LINE_WIDTH_MILS ), PLOT_DASH_TYPE::DEFAULT ); - FILL_PARAMS fill; - bool hasMidPoint = false; - bool hasAngles = false; + FILL_PARAMS fill; + bool hasMidPoint = false; + bool hasAngles = false; std::unique_ptr arc = std::make_unique( SHAPE_T::ARC ); - for( token = NextTok(); token != T_RIGHT; token = NextTok() ) + for( token = NextTok(); token != T_RIGHT; token = NextTok() ) { if( token != T_LEFT ) Expecting( T_LEFT ); @@ -2848,7 +2848,7 @@ SCH_SHAPE* SCH_SEXPR_PARSER::parseSchArc() break; case T_radius: - for( token = NextTok(); token != T_RIGHT; token = NextTok() ) + for( token = NextTok(); token != T_RIGHT; token = NextTok() ) { if( token != T_LEFT ) Expecting( T_LEFT ); @@ -2945,14 +2945,14 @@ SCH_SHAPE* SCH_SEXPR_PARSER::parseSchCircle() wxCHECK_MSG( CurTok() == T_circle, nullptr, wxT( "Cannot parse " ) + GetTokenString( CurTok() ) + wxT( " as a circle." ) ); - T token; - wxPoint center; - int radius; + T token; + wxPoint center; + int radius; STROKE_PARAMS stroke( Mils2iu( DEFAULT_LINE_WIDTH_MILS ), PLOT_DASH_TYPE::DEFAULT ); - FILL_PARAMS fill; + FILL_PARAMS fill; std::unique_ptr circle = std::make_unique( SHAPE_T::CIRCLE ); - for( token = NextTok(); token != T_RIGHT; token = NextTok() ) + for( token = NextTok(); token != T_RIGHT; token = NextTok() ) { if( token != T_LEFT ) Expecting( T_LEFT ); @@ -3005,12 +3005,12 @@ SCH_SHAPE* SCH_SEXPR_PARSER::parseSchRectangle() wxCHECK_MSG( CurTok() == T_rectangle, nullptr, wxT( "Cannot parse " ) + GetTokenString( CurTok() ) + wxT( " as a rectangle." ) ); - T token; + T token; STROKE_PARAMS stroke( Mils2iu( DEFAULT_LINE_WIDTH_MILS ), PLOT_DASH_TYPE::DEFAULT ); - FILL_PARAMS fill; + FILL_PARAMS fill; std::unique_ptr rectangle = std::make_unique( SHAPE_T::RECT ); - for( token = NextTok(); token != T_RIGHT; token = NextTok() ) + for( token = NextTok(); token != T_RIGHT; token = NextTok() ) { if( token != T_LEFT ) Expecting( T_LEFT ); @@ -3060,12 +3060,12 @@ SCH_SHAPE* SCH_SEXPR_PARSER::parseSchBezier() wxCHECK_MSG( CurTok() == T_bezier, nullptr, wxT( "Cannot parse " ) + GetTokenString( CurTok() ) + wxT( " as a bezier." ) ); - T token; + T token; STROKE_PARAMS stroke( Mils2iu( DEFAULT_LINE_WIDTH_MILS ), PLOT_DASH_TYPE::DEFAULT ); - FILL_PARAMS fill; + FILL_PARAMS fill; std::unique_ptr bezier = std::make_unique( SHAPE_T::BEZIER ); - for( token = NextTok(); token != T_RIGHT; token = NextTok() ) + for( token = NextTok(); token != T_RIGHT; token = NextTok() ) { if( token != T_LEFT ) Expecting( T_LEFT ); @@ -3120,7 +3120,7 @@ SCH_SHAPE* SCH_SEXPR_PARSER::parseSchBezier() SCH_TEXT* SCH_SEXPR_PARSER::parseSchText() { - T token; + T token; std::unique_ptr text; switch( CurTok() ) @@ -3145,7 +3145,7 @@ SCH_TEXT* SCH_SEXPR_PARSER::parseSchText() text->SetText( FromUTF8() ); - for( token = NextTok(); token != T_RIGHT; token = NextTok() ) + for( token = NextTok(); token != T_RIGHT; token = NextTok() ) { if( token != T_LEFT ) Expecting( T_LEFT ); @@ -3220,15 +3220,15 @@ SCH_TEXT* SCH_SEXPR_PARSER::parseSchText() // Spin style is defined differently for graphical text (#SCH_TEXT) objects. if( text->Type() == SCH_TEXT_T ) { - if( text->GetHorizJustify() == GR_TEXT_HJUSTIFY_RIGHT - && text->GetTextAngle() == TEXT_ANGLE_VERT ) + if( text->GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT + && text->GetTextAngle().IsVertical() ) { // The vertically aligned text angle is always 90 (labels use 270 for the // down direction) combined with the text justification flags. text->SetLabelSpinStyle( LABEL_SPIN_STYLE::BOTTOM ); } - else if( text->GetHorizJustify() == GR_TEXT_HJUSTIFY_RIGHT - && text->GetTextAngle() == TEXT_ANGLE_HORIZ ) + else if( text->GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT + && text->GetTextAngle().IsHorizontal() ) { // The horizontally aligned text angle is always 0 (labels use 180 for the // left direction) combined with the text justification flags. diff --git a/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp b/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp index 78d2cd8522c..c860d0f4e05 100644 --- a/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp +++ b/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp @@ -1148,7 +1148,7 @@ void SCH_SEXPR_PLUGIN::saveField( SCH_FIELD* aField, int aNestLevel ) aField->GetId(), FormatInternalUnits( aField->GetPosition().x ).c_str(), FormatInternalUnits( aField->GetPosition().y ).c_str(), - FormatAngle( aField->GetTextAngleDegrees() * 10.0 ).c_str() ); + FormatAngle( aField->GetTextAngle().AsTenthsOfADegree() ).c_str() ); if( !aField->IsDefaultFormatting() || ( aField->GetTextHeight() != Mils2iu( DEFAULT_SIZE_TEXT ) ) ) @@ -1455,7 +1455,7 @@ void SCH_SEXPR_PLUGIN::saveText( SCH_TEXT* aText, int aNestLevel ) m_out->Print( aNestLevel + 1, "(at %s %s %s)", FormatInternalUnits( aText->GetPosition().x ).c_str(), FormatInternalUnits( aText->GetPosition().y ).c_str(), - FormatAngle( aText->GetTextAngle() ).c_str() ); + FormatAngle( aText->GetTextAngle().AsTenthsOfADegree() ).c_str() ); } if( aText->GetFieldsAutoplaced() != FIELDS_AUTOPLACED_NO ) @@ -2042,7 +2042,7 @@ void SCH_SEXPR_PLUGIN_CACHE::saveField( LIB_FIELD* aField, OUTPUTFORMATTER& aFor aField->GetId(), FormatInternalUnits( aField->GetPosition().x ).c_str(), FormatInternalUnits( aField->GetPosition().y ).c_str(), - static_cast( aField->GetTextAngle() ) / 10.0 ); + aField->GetTextAngle().AsDegrees() ); aField->Format( &aFormatter, aNestLevel, 0 ); aFormatter.Print( aNestLevel, ")\n" ); @@ -2101,7 +2101,7 @@ void SCH_SEXPR_PLUGIN_CACHE::saveText( LIB_TEXT* aText, OUTPUTFORMATTER& aFormat aFormatter.Quotew( aText->GetText() ).c_str(), FormatInternalUnits( aText->GetPosition().x ).c_str(), FormatInternalUnits( aText->GetPosition().y ).c_str(), - aText->GetTextAngle() ); + (double) aText->GetTextAngle().AsTenthsOfADegree() ); aText->Format( &aFormatter, aNestLevel, 0 ); aFormatter.Print( aNestLevel, ")\n" ); } diff --git a/eeschema/sch_plugins/legacy/sch_legacy_plugin.cpp b/eeschema/sch_plugins/legacy/sch_legacy_plugin.cpp index ff1513a7f35..4f39d2818b9 100644 --- a/eeschema/sch_plugins/legacy/sch_legacy_plugin.cpp +++ b/eeschema/sch_plugins/legacy/sch_legacy_plugin.cpp @@ -1740,9 +1740,9 @@ SCH_SYMBOL* SCH_LEGACY_PLUGIN::loadSymbol( LINE_READER& aReader ) parseQuotedString( name, aReader, line, &line, true ); if( hjustify == 'L' ) - field.SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); + field.SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); else if( hjustify == 'R' ) - field.SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); + field.SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); else if( hjustify != 'C' ) SCH_PARSE_ERROR( "symbol field text horizontal justification must be " "L, R, or C", aReader, line ); @@ -1750,9 +1750,9 @@ SCH_SYMBOL* SCH_LEGACY_PLUGIN::loadSymbol( LINE_READER& aReader ) // We are guaranteed to have a least one character here for older file formats // otherwise an exception would have been raised.. if( textAttrs[0] == 'T' ) - field.SetVertJustify( GR_TEXT_VJUSTIFY_TOP ); + field.SetVertJustify( GR_TEXT_V_ALIGN_TOP ); else if( textAttrs[0] == 'B' ) - field.SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); + field.SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM ); else if( textAttrs[0] != 'C' ) SCH_PARSE_ERROR( "symbol field text vertical justification must be " "B, T, or C", aReader, line ); @@ -1784,9 +1784,9 @@ SCH_SYMBOL* SCH_LEGACY_PLUGIN::loadSymbol( LINE_READER& aReader ) field.SetTextSize( wxSize( size, size ) ); if( orientation == 'H' ) - field.SetTextAngle( TEXT_ANGLE_HORIZ ); + field.SetTextAngle( EDA_ANGLE::HORIZONTAL ); else if( orientation == 'V' ) - field.SetTextAngle( TEXT_ANGLE_VERT ); + field.SetTextAngle( EDA_ANGLE::VERTICAL ); else SCH_PARSE_ERROR( "symbol field orientation must be H or V", aReader, line ); @@ -2155,22 +2155,22 @@ void SCH_LEGACY_PLUGIN::saveField( SCH_FIELD* aField ) { char hjustify = 'C'; - if( aField->GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT ) + if( aField->GetHorizJustify() == GR_TEXT_H_ALIGN_LEFT ) hjustify = 'L'; - else if( aField->GetHorizJustify() == GR_TEXT_HJUSTIFY_RIGHT ) + else if( aField->GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT ) hjustify = 'R'; char vjustify = 'C'; - if( aField->GetVertJustify() == GR_TEXT_VJUSTIFY_BOTTOM ) + if( aField->GetVertJustify() == GR_TEXT_V_ALIGN_BOTTOM ) vjustify = 'B'; - else if( aField->GetVertJustify() == GR_TEXT_VJUSTIFY_TOP ) + else if( aField->GetVertJustify() == GR_TEXT_V_ALIGN_TOP ) vjustify = 'T'; m_out->Print( 0, "F %d %s %c %-3d %-3d %-3d %4.4X %c %c%c%c", aField->GetId(), EscapedUTF8( aField->GetText() ).c_str(), // wraps in quotes too - aField->GetTextAngle() == TEXT_ANGLE_HORIZ ? 'H' : 'V', + aField->GetTextAngle().IsHorizontal() ? 'H' : 'V', Iu2Mils( aField->GetLibPosition().x ), Iu2Mils( aField->GetLibPosition().y ), Iu2Mils( aField->GetTextWidth() ), @@ -3093,9 +3093,9 @@ void SCH_LEGACY_PLUGIN_CACHE::loadField( std::unique_ptr& aSymbol, char textOrient = parseChar( aReader, line, &line ); if( textOrient == 'H' ) - field->SetTextAngle( TEXT_ANGLE_HORIZ ); + field->SetTextAngle( EDA_ANGLE::HORIZONTAL ); else if( textOrient == 'V' ) - field->SetTextAngle( TEXT_ANGLE_VERT ); + field->SetTextAngle( EDA_ANGLE::VERTICAL ); else SCH_PARSE_ERROR( "invalid field text orientation parameter", aReader, line ); @@ -3117,11 +3117,11 @@ void SCH_LEGACY_PLUGIN_CACHE::loadField( std::unique_ptr& aSymbol, char textHJustify = parseChar( aReader, line, &line ); if( textHJustify == 'C' ) - field->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER ); + field->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER ); else if( textHJustify == 'L' ) - field->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); + field->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); else if( textHJustify == 'R' ) - field->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); + field->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); else SCH_PARSE_ERROR( "invalid field text horizontal justification", aReader, line ); @@ -3136,9 +3136,9 @@ void SCH_LEGACY_PLUGIN_CACHE::loadField( std::unique_ptr& aSymbol, switch( (wxChar) attributes[0] ) { - case 'C': field->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); break; - case 'B': field->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); break; - case 'T': field->SetVertJustify( GR_TEXT_VJUSTIFY_TOP ); break; + case 'C': field->SetVertJustify( GR_TEXT_V_ALIGN_CENTER ); break; + case 'B': field->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM ); break; + case 'T': field->SetVertJustify( GR_TEXT_V_ALIGN_TOP ); break; default: SCH_PARSE_ERROR( "invalid field text vertical justification", aReader, line ); } @@ -3446,18 +3446,18 @@ LIB_TEXT* SCH_LEGACY_PLUGIN_CACHE::loadText( std::unique_ptr& aSymbo { switch( parseChar( aReader, line, &line ) ) { - case 'L': text->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); break; - case 'C': text->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER ); break; - case 'R': text->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); break; + case 'L': text->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); break; + case 'C': text->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER ); break; + case 'R': text->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); break; default: SCH_PARSE_ERROR( "invalid horizontal text justication; expected L, C, or R", aReader, line ); } switch( parseChar( aReader, line, &line ) ) { - case 'T': text->SetVertJustify( GR_TEXT_VJUSTIFY_TOP ); break; - case 'C': text->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); break; - case 'B': text->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); break; + case 'T': text->SetVertJustify( GR_TEXT_V_ALIGN_TOP ); break; + case 'C': text->SetVertJustify( GR_TEXT_V_ALIGN_CENTER ); break; + case 'B': text->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM ); break; default: SCH_PARSE_ERROR( "invalid vertical text justication; expected T, C, or B", aReader, line ); } @@ -4058,16 +4058,16 @@ void SCH_LEGACY_PLUGIN_CACHE::saveField( const LIB_FIELD* aField, OUTPUTFORMATTE hjustify = 'C'; - if( aField->GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT ) + if( aField->GetHorizJustify() == GR_TEXT_H_ALIGN_LEFT ) hjustify = 'L'; - else if( aField->GetHorizJustify() == GR_TEXT_HJUSTIFY_RIGHT ) + else if( aField->GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT ) hjustify = 'R'; vjustify = 'C'; - if( aField->GetVertJustify() == GR_TEXT_VJUSTIFY_BOTTOM ) + if( aField->GetVertJustify() == GR_TEXT_V_ALIGN_BOTTOM ) vjustify = 'B'; - else if( aField->GetVertJustify() == GR_TEXT_VJUSTIFY_TOP ) + else if( aField->GetVertJustify() == GR_TEXT_V_ALIGN_TOP ) vjustify = 'T'; aFormatter.Print( 0, "F%d %s %d %d %d %c %c %c %c%c%c", @@ -4076,7 +4076,7 @@ void SCH_LEGACY_PLUGIN_CACHE::saveField( const LIB_FIELD* aField, OUTPUTFORMATTE Iu2Mils( aField->GetTextPos().x ), Iu2Mils( aField->GetTextPos().y ), Iu2Mils( aField->GetTextWidth() ), - aField->GetTextAngle() == 0 ? 'H' : 'V', + aField->GetTextAngle().IsHorizontal() ? 'H' : 'V', aField->IsVisible() ? 'V' : 'I', hjustify, vjustify, aField->IsItalic() ? 'I' : 'N', @@ -4207,25 +4207,30 @@ void SCH_LEGACY_PLUGIN_CACHE::saveText( const LIB_TEXT* aText, OUTPUTFORMATTER& text = wxT( "\"" ) + text + wxT( "\"" ); } - aFormatter.Print( 0, "T %g %d %d %d %d %d %d %s", aText->GetTextAngle(), - Iu2Mils( aText->GetTextPos().x ), Iu2Mils( aText->GetTextPos().y ), - Iu2Mils( aText->GetTextWidth() ), !aText->IsVisible(), - aText->GetUnit(), aText->GetConvert(), TO_UTF8( text ) ); + aFormatter.Print( 0, "T %g %d %d %d %d %d %d %s", + (double) aText->GetTextAngle().AsTenthsOfADegree(), + Iu2Mils( aText->GetTextPos().x ), + Iu2Mils( aText->GetTextPos().y ), + Iu2Mils( aText->GetTextWidth() ), + !aText->IsVisible(), + aText->GetUnit(), + aText->GetConvert(), + TO_UTF8( text ) ); aFormatter.Print( 0, " %s %d", aText->IsItalic() ? "Italic" : "Normal", aText->IsBold() ); char hjustify = 'C'; - if( aText->GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT ) + if( aText->GetHorizJustify() == GR_TEXT_H_ALIGN_LEFT ) hjustify = 'L'; - else if( aText->GetHorizJustify() == GR_TEXT_HJUSTIFY_RIGHT ) + else if( aText->GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT ) hjustify = 'R'; char vjustify = 'C'; - if( aText->GetVertJustify() == GR_TEXT_VJUSTIFY_BOTTOM ) + if( aText->GetVertJustify() == GR_TEXT_V_ALIGN_BOTTOM ) vjustify = 'B'; - else if( aText->GetVertJustify() == GR_TEXT_VJUSTIFY_TOP ) + else if( aText->GetVertJustify() == GR_TEXT_V_ALIGN_TOP ) vjustify = 'T'; aFormatter.Print( 0, " %c %c\n", hjustify, vjustify ); diff --git a/eeschema/sch_sheet.cpp b/eeschema/sch_sheet.cpp index 56979636905..ecd9ade1be1 100644 --- a/eeschema/sch_sheet.cpp +++ b/eeschema/sch_sheet.cpp @@ -558,16 +558,16 @@ void SCH_SHEET::AutoplaceFields( SCH_SCREEN* aScreen, bool aManual ) if( IsVerticalOrientation() ) { m_fields[ SHEETNAME ].SetTextPos( m_pos + wxPoint( -margin, m_size.y ) ); - m_fields[ SHEETNAME ].SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); - m_fields[ SHEETNAME ].SetVertJustify(GR_TEXT_VJUSTIFY_BOTTOM ); - m_fields[ SHEETNAME ].SetTextAngle( TEXT_ANGLE_VERT ); + m_fields[ SHEETNAME ].SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); + m_fields[ SHEETNAME ].SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM ); + m_fields[ SHEETNAME ].SetTextAngle( EDA_ANGLE::VERTICAL ); } else { m_fields[ SHEETNAME ].SetTextPos( m_pos + wxPoint( 0, -margin ) ); - m_fields[ SHEETNAME ].SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); - m_fields[ SHEETNAME ].SetVertJustify(GR_TEXT_VJUSTIFY_BOTTOM ); - m_fields[ SHEETNAME ].SetTextAngle( TEXT_ANGLE_HORIZ ); + m_fields[ SHEETNAME ].SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); + m_fields[ SHEETNAME ].SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM ); + m_fields[ SHEETNAME ].SetTextAngle( EDA_ANGLE::HORIZONTAL ); } textSize = m_fields[ SHEETFILENAME ].GetTextSize(); @@ -576,16 +576,16 @@ void SCH_SHEET::AutoplaceFields( SCH_SCREEN* aScreen, bool aManual ) if( IsVerticalOrientation() ) { m_fields[ SHEETFILENAME ].SetTextPos( m_pos + wxPoint( m_size.x + margin, m_size.y ) ); - m_fields[ SHEETFILENAME ].SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); - m_fields[ SHEETFILENAME ].SetVertJustify(GR_TEXT_VJUSTIFY_TOP ); - m_fields[ SHEETFILENAME ].SetTextAngle( TEXT_ANGLE_VERT ); + m_fields[ SHEETFILENAME ].SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); + m_fields[ SHEETFILENAME ].SetVertJustify( GR_TEXT_V_ALIGN_TOP ); + m_fields[ SHEETFILENAME ].SetTextAngle( EDA_ANGLE::VERTICAL ); } else { m_fields[ SHEETFILENAME ].SetTextPos( m_pos + wxPoint( 0, m_size.y + margin ) ); - m_fields[ SHEETFILENAME ].SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); - m_fields[ SHEETFILENAME ].SetVertJustify(GR_TEXT_VJUSTIFY_TOP ); - m_fields[ SHEETFILENAME ].SetTextAngle( TEXT_ANGLE_HORIZ ); + m_fields[ SHEETFILENAME ].SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); + m_fields[ SHEETFILENAME ].SetVertJustify( GR_TEXT_V_ALIGN_TOP ); + m_fields[ SHEETFILENAME ].SetTextAngle( EDA_ANGLE::HORIZONTAL ); } m_fieldsAutoplaced = FIELDS_AUTOPLACED_AUTO; diff --git a/eeschema/sch_text.cpp b/eeschema/sch_text.cpp index 70e8cbe094b..f72c4de729f 100644 --- a/eeschema/sch_text.cpp +++ b/eeschema/sch_text.cpp @@ -325,27 +325,27 @@ void SCH_TEXT::SetLabelSpinStyle( LABEL_SPIN_STYLE aSpinStyle ) KI_FALLTHROUGH; case LABEL_SPIN_STYLE::RIGHT: // Horiz Normal Orientation - SetTextAngle( TEXT_ANGLE_HORIZ ); - SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); + SetTextAngle( EDA_ANGLE::HORIZONTAL ); + SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); break; case LABEL_SPIN_STYLE::UP: // Vert Orientation UP - SetTextAngle( TEXT_ANGLE_VERT ); - SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); + SetTextAngle( EDA_ANGLE::VERTICAL ); + SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); break; case LABEL_SPIN_STYLE::LEFT: // Horiz Orientation - Right justified - SetTextAngle( TEXT_ANGLE_HORIZ ); - SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); + SetTextAngle( EDA_ANGLE::HORIZONTAL ); + SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); break; case LABEL_SPIN_STYLE::BOTTOM: // Vert Orientation BOTTOM - SetTextAngle( TEXT_ANGLE_VERT ); - SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); + SetTextAngle( EDA_ANGLE::VERTICAL ); + SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); break; } - SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); + SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM ); } @@ -357,7 +357,7 @@ void SCH_TEXT::SwapData( SCH_ITEM* aItem ) std::swap( m_spin_style, item->m_spin_style ); SwapText( *item ); - SwapEffects( *item ); + SwapAttributes( *item ); } @@ -417,13 +417,13 @@ const EDA_RECT SCH_TEXT::GetBoundingBox() const { EDA_RECT rect = GetTextBox(); - if( GetTextAngle() != 0 ) // Rotate rect. + if( GetTextAngle() != EDA_ANGLE::ANGLE_0 ) // Rotate rect. { wxPoint pos = rect.GetOrigin(); wxPoint end = rect.GetEnd(); - RotatePoint( &pos, GetTextPos(), GetTextAngle() ); - RotatePoint( &end, GetTextPos(), GetTextAngle() ); + RotatePoint( &pos, GetTextPos(), GetTextAngle().AsTenthsOfADegree() ); + RotatePoint( &end, GetTextPos(), GetTextAngle().AsTenthsOfADegree() ); rect.SetOrigin( pos ); rect.SetEnd( end ); @@ -750,37 +750,37 @@ void SCH_LABEL_BASE::Rotate90( bool aClockwise ) { for( SCH_FIELD& field : m_fields ) { - if( field.GetTextAngle() == TEXT_ANGLE_VERT - && field.GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT ) + if( field.GetTextAngle().IsVertical() + && field.GetHorizJustify() == GR_TEXT_H_ALIGN_LEFT ) { if( !aClockwise ) - field.SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); + field.SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); - field.SetTextAngle( TEXT_ANGLE_HORIZ ); + field.SetTextAngle( EDA_ANGLE::HORIZONTAL ); } - else if( field.GetTextAngle() == TEXT_ANGLE_VERT - && field.GetHorizJustify() == GR_TEXT_HJUSTIFY_RIGHT ) + else if( field.GetTextAngle().IsVertical() + && field.GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT ) { if( !aClockwise ) - field.SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); + field.SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); - field.SetTextAngle( TEXT_ANGLE_HORIZ ); + field.SetTextAngle( EDA_ANGLE::HORIZONTAL ); } - else if( field.GetTextAngle() == TEXT_ANGLE_HORIZ - && field.GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT ) + else if( field.GetTextAngle().IsHorizontal() + && field.GetHorizJustify() == GR_TEXT_H_ALIGN_LEFT ) { if( aClockwise ) - field.SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); + field.SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); - field.SetTextAngle( TEXT_ANGLE_VERT ); + field.SetTextAngle( EDA_ANGLE::VERTICAL ); } - else if( field.GetTextAngle() == TEXT_ANGLE_HORIZ - && field.GetHorizJustify() == GR_TEXT_HJUSTIFY_RIGHT ) + else if( field.GetTextAngle().IsHorizontal() + && field.GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT ) { if( aClockwise ) - field.SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); + field.SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); - field.SetTextAngle( TEXT_ANGLE_VERT ); + field.SetTextAngle( EDA_ANGLE::VERTICAL ); } wxPoint pos = field.GetTextPos(); @@ -808,8 +808,8 @@ void SCH_LABEL_BASE::AutoplaceFields( SCH_SCREEN* aScreen, bool aManual ) { default: case LABEL_SPIN_STYLE::LEFT: - field.SetTextAngle( TEXT_ANGLE_HORIZ ); - field.SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); + field.SetTextAngle( EDA_ANGLE::HORIZONTAL ); + field.SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); if( Type() == SCH_GLOBAL_LABEL_T && field.GetId() == 0 ) offset.x = - ( labelLen + margin ); @@ -819,8 +819,8 @@ void SCH_LABEL_BASE::AutoplaceFields( SCH_SCREEN* aScreen, bool aManual ) break; case LABEL_SPIN_STYLE::UP: - field.SetTextAngle( TEXT_ANGLE_VERT ); - field.SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); + field.SetTextAngle( EDA_ANGLE::VERTICAL ); + field.SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); if( Type() == SCH_GLOBAL_LABEL_T && field.GetId() == 0 ) offset.y = - ( labelLen + margin ); @@ -830,8 +830,8 @@ void SCH_LABEL_BASE::AutoplaceFields( SCH_SCREEN* aScreen, bool aManual ) break; case LABEL_SPIN_STYLE::RIGHT: - field.SetTextAngle( TEXT_ANGLE_HORIZ ); - field.SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); + field.SetTextAngle( EDA_ANGLE::HORIZONTAL ); + field.SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); if( Type() == SCH_GLOBAL_LABEL_T && field.GetId() == 0 ) offset.x = labelLen + margin; @@ -841,8 +841,8 @@ void SCH_LABEL_BASE::AutoplaceFields( SCH_SCREEN* aScreen, bool aManual ) break; case LABEL_SPIN_STYLE::BOTTOM: - field.SetTextAngle( TEXT_ANGLE_VERT ); - field.SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); + field.SetTextAngle( EDA_ANGLE::VERTICAL ); + field.SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); if( Type() == SCH_GLOBAL_LABEL_T && field.GetId() == 0 ) offset.y = labelLen + margin; @@ -1288,14 +1288,14 @@ const EDA_RECT SCH_LABEL::GetBodyBoundingBox() const rect.Offset( 0, -GetTextOffset() ); - if( GetTextAngle() != 0.0 ) + if( GetTextAngle() != EDA_ANGLE::ANGLE_0 ) { // Rotate rect wxPoint pos = rect.GetOrigin(); wxPoint end = rect.GetEnd(); - RotatePoint( &pos, GetTextPos(), GetTextAngle() ); - RotatePoint( &end, GetTextPos(), GetTextAngle() ); + RotatePoint( &pos, GetTextPos(), GetTextAngle().AsTenthsOfADegree() ); + RotatePoint( &end, GetTextPos(), GetTextAngle().AsTenthsOfADegree() ); rect.SetOrigin( pos ); rect.SetEnd( end ); @@ -1335,7 +1335,7 @@ SCH_NETCLASS_FLAG::SCH_NETCLASS_FLAG( const wxPoint& pos ) : m_fields[0].SetLayer( LAYER_NETCLASS_REFS ); m_fields[0].SetVisible( true ); m_fields[0].SetItalic( true ); - m_fields[0].SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); + m_fields[0].SetVertJustify( GR_TEXT_V_ALIGN_CENTER ); } @@ -1436,27 +1436,27 @@ void SCH_NETCLASS_FLAG::AutoplaceFields( SCH_SCREEN* aScreen, bool aManual ) { default: case LABEL_SPIN_STYLE::LEFT: - field.SetTextAngle( TEXT_ANGLE_HORIZ ); + field.SetTextAngle( EDA_ANGLE::HORIZONTAL ); offset = { symbolWidth + margin, origin }; break; case LABEL_SPIN_STYLE::UP: - field.SetTextAngle( TEXT_ANGLE_VERT ); + field.SetTextAngle( EDA_ANGLE::VERTICAL ); offset = { -origin, -( symbolWidth + margin ) }; break; case LABEL_SPIN_STYLE::RIGHT: - field.SetTextAngle( TEXT_ANGLE_HORIZ ); + field.SetTextAngle( EDA_ANGLE::HORIZONTAL ); offset = { symbolWidth + margin, -origin }; break; case LABEL_SPIN_STYLE::BOTTOM: - field.SetTextAngle( TEXT_ANGLE_VERT ); + field.SetTextAngle( EDA_ANGLE::VERTICAL ); offset = { origin, -( symbolWidth + margin ) }; break; } - field.SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); + field.SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); field.SetTextPos( GetPosition() + offset ); origin -= field.GetTextHeight() + margin; @@ -1479,13 +1479,13 @@ SCH_GLOBALLABEL::SCH_GLOBALLABEL( const wxPoint& pos, const wxString& text ) : m_shape = LABEL_FLAG_SHAPE::L_BIDI; m_isDangling = true; - SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); + SetVertJustify( GR_TEXT_V_ALIGN_CENTER ); m_fields.emplace_back( SCH_FIELD( { 0, 0 }, 0, this, _( "Sheet References" ) ) ); m_fields[0].SetText( wxT( "${INTERSHEET_REFS}" ) ); m_fields[0].SetVisible( true ); m_fields[0].SetLayer( LAYER_INTERSHEET_REFS ); - m_fields[0].SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); + m_fields[0].SetVertJustify( GR_TEXT_V_ALIGN_CENTER ); } @@ -1530,7 +1530,7 @@ wxPoint SCH_GLOBALLABEL::GetSchematicTextOffset( const RENDER_SETTINGS* aSetting void SCH_GLOBALLABEL::SetLabelSpinStyle( LABEL_SPIN_STYLE aSpinStyle ) { SCH_TEXT::SetLabelSpinStyle( aSpinStyle ); - SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); + SetVertJustify( GR_TEXT_V_ALIGN_CENTER ); } @@ -1540,13 +1540,13 @@ void SCH_GLOBALLABEL::MirrorSpinStyle( bool aLeftRight ) for( SCH_FIELD& field : m_fields ) { - if( ( aLeftRight && field.GetTextAngle() == TEXT_ANGLE_HORIZ ) - || ( !aLeftRight && field.GetTextAngle() == TEXT_ANGLE_VERT ) ) + if( ( aLeftRight && field.GetTextAngle().IsHorizontal() ) + || ( !aLeftRight && field.GetTextAngle().IsVertical() ) ) { - if( field.GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT ) - field.SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); + if( field.GetHorizJustify() == GR_TEXT_H_ALIGN_LEFT ) + field.SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); else - field.SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); + field.SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); } wxPoint pos = field.GetTextPos(); @@ -1569,10 +1569,10 @@ void SCH_GLOBALLABEL::MirrorHorizontally( int aCenter ) for( SCH_FIELD& field : m_fields ) { - if( field.GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT ) - field.SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); + if( field.GetHorizJustify() == GR_TEXT_H_ALIGN_LEFT ) + field.SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); else - field.SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); + field.SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); wxPoint pos = field.GetTextPos(); wxPoint delta = old_pos - pos; @@ -1755,7 +1755,7 @@ SCH_HIERLABEL::SCH_HIERLABEL( const wxPoint& pos, const wxString& text, KICAD_T void SCH_HIERLABEL::SetLabelSpinStyle( LABEL_SPIN_STYLE aSpinStyle ) { SCH_TEXT::SetLabelSpinStyle( aSpinStyle ); - SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); + SetVertJustify( GR_TEXT_V_ALIGN_CENTER ); } diff --git a/eeschema/symbol_editor/symbol_edit_frame.cpp b/eeschema/symbol_editor/symbol_edit_frame.cpp index 6b8f758815e..f4cc93a7fad 100644 --- a/eeschema/symbol_editor/symbol_edit_frame.cpp +++ b/eeschema/symbol_editor/symbol_edit_frame.cpp @@ -485,9 +485,9 @@ void SYMBOL_EDIT_FRAME::setupUIConditions() mgr->SetConditions( ACTIONS::deleteTool, EDIT_TOOL( ACTIONS::deleteTool ) ); mgr->SetConditions( EE_ACTIONS::placeSymbolPin, EDIT_TOOL( EE_ACTIONS::placeSymbolPin ) ); mgr->SetConditions( EE_ACTIONS::placeSymbolText, EDIT_TOOL( EE_ACTIONS::placeSymbolText ) ); - mgr->SetConditions( EE_ACTIONS::drawRectangle, EDIT_TOOL( EE_ACTIONS::drawRectangle ) ); - mgr->SetConditions( EE_ACTIONS::drawCircle, EDIT_TOOL( EE_ACTIONS::drawCircle ) ); - mgr->SetConditions( EE_ACTIONS::drawArc, EDIT_TOOL( EE_ACTIONS::drawArc ) ); + mgr->SetConditions( EE_ACTIONS::drawRectangle, EDIT_TOOL( EE_ACTIONS::drawRectangle ) ); + mgr->SetConditions( EE_ACTIONS::drawCircle, EDIT_TOOL( EE_ACTIONS::drawCircle ) ); + mgr->SetConditions( EE_ACTIONS::drawArc, EDIT_TOOL( EE_ACTIONS::drawArc ) ); mgr->SetConditions( EE_ACTIONS::drawSymbolLines, EDIT_TOOL( EE_ACTIONS::drawSymbolLines ) ); mgr->SetConditions( EE_ACTIONS::placeSymbolAnchor, EDIT_TOOL( EE_ACTIONS::placeSymbolAnchor ) ); @@ -1320,7 +1320,7 @@ void SYMBOL_EDIT_FRAME::LoadSymbolFromSchematic( SCH_SYMBOL* aSymbol ) libField.SetName( field.GetName( false ) ); libField.SetText( field.GetText() ); - libField.SetEffects( field ); + libField.SetAttributes( field ); libField.SetPosition( wxPoint( pos.x, -pos.y ) ); fullSetOfFields.emplace_back( std::move( libField ) ); diff --git a/eeschema/tools/sch_edit_tool.cpp b/eeschema/tools/sch_edit_tool.cpp index 93b6d568bdb..e58a8a8e8ca 100644 --- a/eeschema/tools/sch_edit_tool.cpp +++ b/eeschema/tools/sch_edit_tool.cpp @@ -537,10 +537,10 @@ int SCH_EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent ) { SCH_FIELD* field = static_cast( head ); - if( field->GetTextAngle() == TEXT_ANGLE_HORIZ ) - field->SetTextAngle( TEXT_ANGLE_VERT ); + if( field->GetTextAngle().IsHorizontal() ) + field->SetTextAngle( EDA_ANGLE::VERTICAL ); else - field->SetTextAngle( TEXT_ANGLE_HORIZ ); + field->SetTextAngle( EDA_ANGLE::HORIZONTAL ); // Now that we're moving a field, they're no longer autoplaced. static_cast( head->GetParent() )->ClearFieldsAutoplaced(); @@ -643,10 +643,10 @@ int SCH_EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent ) field->Rotate( rotPoint ); - if( field->GetTextAngle() == TEXT_ANGLE_HORIZ ) - field->SetTextAngle( TEXT_ANGLE_VERT ); + if( field->GetTextAngle().IsHorizontal() ) + field->SetTextAngle( EDA_ANGLE::VERTICAL ); else - field->SetTextAngle( TEXT_ANGLE_HORIZ ); + field->SetTextAngle( EDA_ANGLE::HORIZONTAL ); // Now that we're moving a field, they're no longer autoplaced. static_cast( field->GetParent() )->ClearFieldsAutoplaced(); @@ -757,12 +757,12 @@ int SCH_EDIT_TOOL::Mirror( const TOOL_EVENT& aEvent ) SCH_FIELD* field = static_cast( item ); if( vertical ) - field->SetVertJustify( (EDA_TEXT_VJUSTIFY_T)-field->GetVertJustify() ); + field->SetVertJustify( TO_VJUSTIFY( -field->GetVertJustify() ) ); else - field->SetHorizJustify( (EDA_TEXT_HJUSTIFY_T)-field->GetHorizJustify() ); + field->SetHorizJustify( TO_HJUSTIFY( -field->GetHorizJustify() ) ); // Now that we're re-justifying a field, they're no longer autoplaced. - static_cast( item->GetParent() )->ClearFieldsAutoplaced(); + static_cast( field->GetParent() )->ClearFieldsAutoplaced(); break; } diff --git a/eeschema/tools/symbol_editor_drawing_tools.cpp b/eeschema/tools/symbol_editor_drawing_tools.cpp index 04cc88e3a21..a1d136e05a6 100644 --- a/eeschema/tools/symbol_editor_drawing_tools.cpp +++ b/eeschema/tools/symbol_editor_drawing_tools.cpp @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include @@ -40,7 +39,7 @@ static void* g_lastPinWeakPtr; SYMBOL_EDITOR_DRAWING_TOOLS::SYMBOL_EDITOR_DRAWING_TOOLS() : EE_TOOL_BASE( "eeschema.SymbolDrawing" ), - m_lastTextAngle( 0.0 ), + m_lastTextAngle( EDA_ANGLE::HORIZONTAL ), m_lastFillStyle( FILL_T::NO_FILL ), m_drawSpecificConvert( true ), m_drawSpecificUnit( false ) diff --git a/eeschema/tools/symbol_editor_drawing_tools.h b/eeschema/tools/symbol_editor_drawing_tools.h index e7aacfe9eb9..f3b95588fac 100644 --- a/eeschema/tools/symbol_editor_drawing_tools.h +++ b/eeschema/tools/symbol_editor_drawing_tools.h @@ -52,8 +52,8 @@ class SYMBOL_EDITOR_DRAWING_TOOLS : public EE_TOOL_BASE int RepeatDrawItem( const TOOL_EVENT& aEvent ); - void SetLastTextAngle( double aAngle ) { m_lastTextAngle = aAngle; } - double GetLastTextAngle() const { return m_lastTextAngle; } + void SetLastTextAngle( const EDA_ANGLE& aAngle ) { m_lastTextAngle = aAngle; } + EDA_ANGLE GetLastTextAngle() const { return m_lastTextAngle; } void SetDrawSpecificConvert( bool aSpecific ) { m_drawSpecificConvert = aSpecific; } bool GetDrawSpecificConvert() const { return m_drawSpecificConvert; } @@ -65,7 +65,7 @@ class SYMBOL_EDITOR_DRAWING_TOOLS : public EE_TOOL_BASE void setTransitions() override; private: - double m_lastTextAngle; + EDA_ANGLE m_lastTextAngle; FILL_T m_lastFillStyle; bool m_drawSpecificConvert; bool m_drawSpecificUnit; diff --git a/gerbview/gerber_draw_item.cpp b/gerbview/gerber_draw_item.cpp index 9c4973675b8..cbd72572786 100644 --- a/gerbview/gerber_draw_item.cpp +++ b/gerbview/gerber_draw_item.cpp @@ -105,7 +105,7 @@ bool GERBER_DRAW_ITEM::GetTextD_CodePrms( int& aSize, wxPoint& aPos, double& aOr else size = std::min( m_Size.x, m_Size.y ); - aOrientation = TEXT_ANGLE_HORIZ; + aOrientation = 0; if( m_Flashed ) { diff --git a/gerbview/gerbview_painter.cpp b/gerbview/gerbview_painter.cpp index b8ba3ae0e81..c007185f649 100644 --- a/gerbview/gerbview_painter.cpp +++ b/gerbview/gerbview_painter.cpp @@ -225,8 +225,8 @@ void GERBVIEW_PAINTER::draw( /*const*/ GERBER_DRAW_ITEM* aItem, int aLayer ) m_gal->SetFontUnderlined( false ); m_gal->SetTextMirrored( false ); m_gal->SetGlyphSize( VECTOR2D( textSize, textSize) ); - m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_CENTER ); - m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_CENTER ); + m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_CENTER ); + m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_CENTER ); m_gal->BitmapText( codeText, textPosition, orient ); return; diff --git a/include/drawing_sheet/ds_data_item.h b/include/drawing_sheet/ds_data_item.h index c2ab14ec6be..ba4c57569d9 100644 --- a/include/drawing_sheet/ds_data_item.h +++ b/include/drawing_sheet/ds_data_item.h @@ -335,8 +335,8 @@ class DS_DATA_ITEM_TEXT : public DS_DATA_ITEM wxString m_TextBase; // The basic text, with format symbols wxString m_FullText; // The expanded text, shown on screen double m_Orient; // Orientation in degrees - EDA_TEXT_HJUSTIFY_T m_Hjustify; - EDA_TEXT_VJUSTIFY_T m_Vjustify; + GR_TEXT_H_ALIGN_T m_Hjustify; + GR_TEXT_V_ALIGN_T m_Vjustify; bool m_Italic; bool m_Bold; DSIZE m_TextSize; diff --git a/include/eda_angle.h b/include/eda_angle.h new file mode 100644 index 00000000000..af22b55b061 --- /dev/null +++ b/include/eda_angle.h @@ -0,0 +1,264 @@ +/* + * 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 . + */ + +#ifndef EDA_ANGLE_H +#define EDA_ANGLE_H + +#include +#include + +class EDA_ANGLE +{ +public: + enum ANGLE_TYPE + { + TENTHS_OF_A_DEGREE = 1, + DEGREES = 10, + RADIANS ///< enum value does not matter + }; + + // Angles can be created in degrees, 1/10ths of a degree, and radians, + // and read as any of the angle types + // + // Angle type must be explicitly specified at creation, because + // there is no other way of knowing what an int or a double represents + EDA_ANGLE( int aValue, ANGLE_TYPE aAngleType ) : + m_initial_type( aAngleType ) + { + switch( aAngleType ) + { + case RADIANS: + m_radians = aValue; + m_value = int( aValue / TENTHS_OF_A_DEGREE_TO_RADIANS ); + break; + + default: + m_value = aValue * aAngleType; + } + } + + EDA_ANGLE( double aValue, ANGLE_TYPE aAngleType ) : + m_initial_type( aAngleType ) + { + switch( aAngleType ) + { + case RADIANS: + m_radians = aValue; + m_value = int( aValue / TENTHS_OF_A_DEGREE_TO_RADIANS ); + break; + + default: + m_value = int( aValue * aAngleType ); + } + } + + EDA_ANGLE() : + m_value( 0 ), + m_radians( 0.0 ), + m_initial_type( EDA_ANGLE::RADIANS ) + {} + + inline double AsDegrees() const { return m_value / (double) EDA_ANGLE::DEGREES; } + + inline int AsTenthsOfADegree() const { return m_value; } + + inline double AsRadians() const + { + if( m_initial_type == EDA_ANGLE::RADIANS ) + { + // if this was initialized with radians, return exact initial value + return m_radians; + } + else + { + // otherwise compute from value stored as 1/10ths of a degree + return m_value * TENTHS_OF_A_DEGREE_TO_RADIANS; + } + } + + inline double AsAngleType( ANGLE_TYPE aAngleType ) const + { + switch( aAngleType ) + { + case TENTHS_OF_A_DEGREE: return AsTenthsOfADegree(); + case DEGREES: return AsDegrees(); + case RADIANS: return AsRadians(); + default: assert( 1 == 0 ); + } + } + + static constexpr double TENTHS_OF_A_DEGREE_TO_RADIANS = M_PI / 1800; + + /** + * @return true if angle is one of the four cardinal directions (0/90/180/270 degrees), + * otherwise false + */ + bool IsCardinal() const + { + return AsTenthsOfADegree() % 900 == 0; + } + + bool IsZero() const + { + return AsTenthsOfADegree() == 0; + } + + bool IsHorizontal() const + { + return AsTenthsOfADegree() == 0 || AsTenthsOfADegree() == 1800; + } + + bool IsVertical() const + { + return AsTenthsOfADegree() == 900 || AsTenthsOfADegree() == 2700; + } + + EDA_ANGLE Add( const EDA_ANGLE& aAngle ) const + { + ANGLE_TYPE initialType = GetInitialAngleType(); + + // if both were given in radians, addition is exact + if( initialType == EDA_ANGLE::RADIANS + && aAngle.GetInitialAngleType() == EDA_ANGLE::RADIANS ) + { + //double newAngle = normalize( AsRadians() + aAngle.AsRadians(), EDA_ANGLE::RADIANS ); + double newAngle = AsRadians() + aAngle.AsRadians(); + return EDA_ANGLE( newAngle, EDA_ANGLE::RADIANS ); + } + + // if both were not given in radians, addition is done using + // 1/10ths of a degree, then converted to original angle type + // of this angle + //int newAngle = normalize( AsTenthsOfADegree() + aAngle.AsTenthsOfADegree(), + //EDA_ANGLE::TENTHS_OF_A_DEGREE ); + int newAngle = AsTenthsOfADegree() + aAngle.AsTenthsOfADegree(); + + switch( initialType ) + { + case DEGREES: + return EDA_ANGLE( newAngle / EDA_ANGLE::DEGREES, EDA_ANGLE::DEGREES ); + + case RADIANS: + return EDA_ANGLE( newAngle / TENTHS_OF_A_DEGREE_TO_RADIANS, EDA_ANGLE::RADIANS ); + + default: + case TENTHS_OF_A_DEGREE: + return EDA_ANGLE( newAngle, EDA_ANGLE::TENTHS_OF_A_DEGREE ); + } + } + + EDA_ANGLE Invert() const + { + switch( GetInitialAngleType() ) + { + case RADIANS: + return EDA_ANGLE( -m_radians, EDA_ANGLE::RADIANS ); + default: + return EDA_ANGLE( -m_value / GetInitialAngleType(), GetInitialAngleType() ); + } + } + + EDA_ANGLE Subtract( const EDA_ANGLE& aAngle ) const { return Add( aAngle.Invert() ); } + + inline ANGLE_TYPE GetInitialAngleType() const { return m_initial_type; } + + double Sin() const { return sin( AsRadians() ); } + + double Cos() const { return cos( AsRadians() ); } + + double Tan() const { return tan( AsRadians() ); } + + static EDA_ANGLE Arccos( double x ) { return EDA_ANGLE( acos( x ), EDA_ANGLE::RADIANS ); } + + static EDA_ANGLE Arcsin( double x ) { return EDA_ANGLE( asin( x ), EDA_ANGLE::RADIANS ); } + + static EDA_ANGLE Arctan( double x ) { return EDA_ANGLE( atan( x ), EDA_ANGLE::RADIANS ); } + + static EDA_ANGLE Arctan2( double y, double x ) + { + return EDA_ANGLE( atan2( y, x ), EDA_ANGLE::RADIANS ); + } + + inline EDA_ANGLE Normalize() + { + normalize( false ); + return *this; + } + + inline EDA_ANGLE Normalize720() + { + normalize( true ); + return *this; + } + + EDA_ANGLE KeepUpright() const; + +private: + // value is always stored in 1/10ths of a degree + int m_value; + + double m_radians; //< only used with as-radians constructor + + ANGLE_TYPE m_initial_type; + + void normalize( bool n720 = false ); + int normalize( int aValue, ANGLE_TYPE aAngleType, bool n720 = false ) const; + double normalize( double aValue, ANGLE_TYPE aAngleType, bool n720 = false ) const; + + static constexpr int TENTHS_OF_A_DEGREE_FULL_CIRCLE = 3600; + static constexpr int DEGREES_FULL_CIRCLE = 360; + static constexpr double RADIANS_FULL_CIRCLE = 2 * M_PI; + + static EDA_ANGLE m_angle0; + static EDA_ANGLE m_angle90; + static EDA_ANGLE m_angle180; + static EDA_ANGLE m_angle270; + static EDA_ANGLE m_angle360; + +public: + static constexpr EDA_ANGLE& HORIZONTAL = m_angle0; + static constexpr EDA_ANGLE& VERTICAL = m_angle90; + static constexpr EDA_ANGLE& FULL_CIRCLE = m_angle360; + static constexpr EDA_ANGLE& ANGLE_0 = m_angle0; + static constexpr EDA_ANGLE& ANGLE_90 = m_angle90; + static constexpr EDA_ANGLE& ANGLE_180 = m_angle180; + static constexpr EDA_ANGLE& ANGLE_270 = m_angle270; +}; + + +inline EDA_ANGLE operator-( const EDA_ANGLE& aAngle ) +{ + return aAngle.Invert(); +} + + +inline bool operator==( const EDA_ANGLE& aAngleA, const EDA_ANGLE& aAngleB ) +{ + return aAngleA.AsTenthsOfADegree() == aAngleB.AsTenthsOfADegree(); +} + + +inline bool operator!=( const EDA_ANGLE& aAngleA, const EDA_ANGLE& aAngleB ) +{ + return aAngleA.AsTenthsOfADegree() != aAngleB.AsTenthsOfADegree(); +} + + +#endif // EDA_ANGLE_H diff --git a/include/eda_text.h b/include/eda_text.h index 4dfd3dfac3e..0cb4adccfd6 100644 --- a/include/eda_text.h +++ b/include/eda_text.h @@ -30,6 +30,7 @@ #include #include +#include class OUTPUTFORMATTER; class SHAPE_COMPOUND; @@ -66,33 +67,12 @@ namespace KIGFX using KIGFX::RENDER_SETTINGS; using KIGFX::COLOR4D; -/// Frequent text rotations, used with {Set,Get}TextAngle(), -/// in 0.1 degrees for now, hoping to migrate to degrees eventually. -#define TEXT_ANGLE_HORIZ 0 -#define TEXT_ANGLE_VERT 900 - // part of the kicad_plugin.h family of defines. // See kicad_plugin.h for the choice of the value // When set when calling EDA_TEXT::Format, disable writing the "hide" keyword in save file #define CTL_OMIT_HIDE (1 << 6) -// Graphic Text justify: -// Values -1,0,1 are used in computations, do not change them -enum EDA_TEXT_HJUSTIFY_T { - GR_TEXT_HJUSTIFY_LEFT = -1, - GR_TEXT_HJUSTIFY_CENTER = 0, - GR_TEXT_HJUSTIFY_RIGHT = 1 -}; - - -enum EDA_TEXT_VJUSTIFY_T { - GR_TEXT_VJUSTIFY_TOP = -1, - GR_TEXT_VJUSTIFY_CENTER = 0, - GR_TEXT_VJUSTIFY_BOTTOM = 1 -}; - - /** * This is the "default-of-the-default" hardcoded text size; individual * application define their own default policy starting with this @@ -102,35 +82,6 @@ enum EDA_TEXT_VJUSTIFY_T { #define DIM_ANCRE_TEXTE 2 // Anchor size for text -/** - * A container for text effects. - * - * These fields are bundled so they can be easily copied together as a lot. The privacy - * policy is established by client (incorporating) code. - */ -struct TEXT_EFFECTS -{ - TEXT_EFFECTS( int aSetOfBits = 0 ) : - bits( aSetOfBits ), - hjustify( GR_TEXT_HJUSTIFY_CENTER ), - vjustify( GR_TEXT_VJUSTIFY_CENTER ), - penwidth( 0 ), - angle( 0.0 ) - {} - - int bits; ///< any set of booleans a client uses. - signed char hjustify; ///< horizontal justification - signed char vjustify; ///< vertical justification - wxSize size; - int penwidth; - double angle; ///< now: 0.1 degrees; future: degrees - wxPoint pos; - - void Bit( int aBit, bool aValue ) { aValue ? bits |= (1< 1 or aDefaultWidth. */ int GetEffectiveTextPenWidth( int aDefaultWidth = 0 ) const; - virtual void SetTextAngle( double aAngle ) + virtual void SetTextAngle( double aAngleInTenthsOfADegree ) { // Higher level classes may be more restrictive than this by overloading // SetTextAngle() or merely calling EDA_TEXT::SetTextAngle() after clamping // aAngle before calling this lowest inline accessor. - m_e.angle = aAngle; + m_attributes.m_Angle = EDA_ANGLE( aAngleInTenthsOfADegree, EDA_ANGLE::TENTHS_OF_A_DEGREE ); + } + + void SetTextAngle( const EDA_ANGLE& aAngle ) + { + m_attributes.m_Angle = aAngle; } - double GetTextAngle() const { return m_e.angle; } - double GetTextAngleDegrees() const { return GetTextAngle() / 10.0; } - double GetTextAngleRadians() const { return GetTextAngle() * M_PI/1800; } + const EDA_ANGLE& GetTextAngle() const { return m_attributes.m_Angle; } - void SetItalic( bool isItalic ) { m_e.Bit( TE_ITALIC, isItalic ); } - bool IsItalic() const { return m_e.Bit( TE_ITALIC ); } + void SetItalic( bool aItalic ) { m_attributes.m_Italic = aItalic; } + bool IsItalic() const { return m_attributes.m_Italic; } - void SetBold( bool aBold ) { m_e.Bit( TE_BOLD, aBold); } - bool IsBold() const { return m_e.Bit( TE_BOLD ); } + void SetBold( bool aBold ) { m_attributes.m_Bold = aBold; } + bool IsBold() const { return m_attributes.m_Bold; } - virtual void SetVisible( bool aVisible ) { m_e.Bit( TE_VISIBLE, aVisible ); } - virtual bool IsVisible() const { return m_e.Bit( TE_VISIBLE ); } + virtual void SetVisible( bool aVisible ) { m_attributes.m_Visible = aVisible; } + virtual bool IsVisible() const { return m_attributes.m_Visible; } - void SetMirrored( bool isMirrored ) { m_e.Bit( TE_MIRROR, isMirrored ); } - bool IsMirrored() const { return m_e.Bit( TE_MIRROR ); } + void SetMirrored( bool isMirrored ) { m_attributes.m_Mirrored = isMirrored; } + bool IsMirrored() const { return m_attributes.m_Mirrored; } /** * @param aAllow true if ok to use multiline option, false if ok to use only single line * text. (Single line is faster in calculations than multiline.) */ - void SetMultilineAllowed( bool aAllow ) { m_e.Bit( TE_MULTILINE, aAllow ); } - bool IsMultilineAllowed() const { return m_e.Bit( TE_MULTILINE ); } + void SetMultilineAllowed( bool aAllow ) { m_attributes.m_Multiline = aAllow; } + bool IsMultilineAllowed() const { return m_attributes.m_Multiline; } - EDA_TEXT_HJUSTIFY_T GetHorizJustify() const { return EDA_TEXT_HJUSTIFY_T( m_e.hjustify ); }; - EDA_TEXT_VJUSTIFY_T GetVertJustify() const { return EDA_TEXT_VJUSTIFY_T( m_e.vjustify ); }; + GR_TEXT_H_ALIGN_T GetHorizJustify() const { return m_attributes.m_Halign; }; + GR_TEXT_V_ALIGN_T GetVertJustify() const { return m_attributes.m_Valign; }; - void SetHorizJustify( EDA_TEXT_HJUSTIFY_T aType ) { m_e.hjustify = aType; }; - void SetVertJustify( EDA_TEXT_VJUSTIFY_T aType ) { m_e.vjustify = aType; }; + void SetHorizJustify( GR_TEXT_H_ALIGN_T aType ) { m_attributes.m_Halign = aType; }; + void SetVertJustify( GR_TEXT_V_ALIGN_T aType ) { m_attributes.m_Valign = aType; }; /** - * Set the text effects from another instance. - * - * #TEXT_EFFECTS is not exposed in the public API, but includes everything except the actual - * text string itself. + * Set the text attributes from another instance. */ - void SetEffects( const EDA_TEXT& aSrc ); + void SetAttributes( const EDA_TEXT& aSrc ); /** - * Swap the text effects of the two involved instances. - * - * #TEXT_EFFECTS is not exposed in the public API, but includes everything except the actual - * text string itself. + * Swap the text attributes of the two involved instances. */ - void SwapEffects( EDA_TEXT& aTradingPartner ); + void SwapAttributes( EDA_TEXT& aTradingPartner ); void SwapText( EDA_TEXT& aTradingPartner ); @@ -255,28 +203,29 @@ class EDA_TEXT bool IsDefaultFormatting() const; - void SetTextSize( const wxSize& aNewSize ) { m_e.size = aNewSize; } - const wxSize& GetTextSize() const { return m_e.size; } + void SetTextSize( const wxSize& aNewSize ) { m_attributes.m_Size = aNewSize; } + wxSize GetTextSize() const { return wxSize( m_attributes.m_Size.x, + m_attributes.m_Size.y ); } - void SetTextWidth( int aWidth ) { m_e.size.x = aWidth; } - int GetTextWidth() const { return m_e.size.x; } + void SetTextWidth( int aWidth ) { m_attributes.m_Size.x = aWidth; } + int GetTextWidth() const { return m_attributes.m_Size.x; } - void SetTextHeight( int aHeight ) { m_e.size.y = aHeight; } - int GetTextHeight() const { return m_e.size.y; } + void SetTextHeight( int aHeight ) { m_attributes.m_Size.y = aHeight; } + int GetTextHeight() const { return m_attributes.m_Size.y; } - void SetTextPos( const wxPoint& aPoint ) { m_e.pos = aPoint; } - const wxPoint& GetTextPos() const { return m_e.pos; } + void SetTextPos( const wxPoint& aPoint ) { m_pos = aPoint; } + const wxPoint& GetTextPos() const { return m_pos; } - void SetTextX( int aX ) { m_e.pos.x = aX; } - void SetTextY( int aY ) { m_e.pos.y = aY; } + void SetTextX( int aX ) { m_pos.x = aX; } + void SetTextY( int aY ) { m_pos.y = aY; } - void Offset( const wxPoint& aOffset ) { m_e.pos += aOffset; } + void Offset( const wxPoint& aOffset ) { m_pos += aOffset; } void Empty() { m_text.Empty(); } - static EDA_TEXT_HJUSTIFY_T MapHorizJustify( int aHorizJustify ); + static GR_TEXT_H_ALIGN_T MapHorizJustify( int aHorizJustify ); - static EDA_TEXT_VJUSTIFY_T MapVertJustify( int aVertJustify ); + static GR_TEXT_V_ALIGN_T MapVertJustify( int aVertJustify ); /** * Print this text object to the device context \a aDC. @@ -385,10 +334,10 @@ class EDA_TEXT */ virtual void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const; - virtual double GetDrawRotation() const { return GetTextAngle(); } + virtual EDA_ANGLE GetDrawRotation() const { return GetTextAngle(); } virtual wxPoint GetDrawPos() const { return GetTextPos(); } - virtual EDA_TEXT_HJUSTIFY_T GetDrawHorizJustify() const { return GetHorizJustify(); }; - virtual EDA_TEXT_VJUSTIFY_T GetDrawVertJustify() const { return GetVertJustify(); }; + virtual GR_TEXT_H_ALIGN_T GetDrawHorizJustify() const { return GetHorizJustify(); }; + virtual GR_TEXT_V_ALIGN_T GetDrawVertJustify() const { return GetVertJustify(); }; int Compare( const EDA_TEXT* aOther ) const; @@ -396,7 +345,7 @@ class EDA_TEXT void cacheShownText(); /** - * Print each line of this EDA_TEXT.. + * Print each line of this EDA_TEXT. * * @param aOffset draw offset (usually (0,0)). * @param aColor text color. @@ -408,19 +357,12 @@ class EDA_TEXT const COLOR4D& aColor, OUTLINE_MODE aFillMode, const wxString& aText, const wxPoint& aPos ); - wxString m_text; - wxString m_shown_text; // Cache of unescaped text for efficient access - bool m_shown_text_has_text_var_refs; - - TEXT_EFFECTS m_e; // Private bitflags for text styling. API above - // provides accessor funcs. - enum TE_FLAGS { - TE_MIRROR, - TE_ITALIC, - TE_BOLD, - TE_MULTILINE, - TE_VISIBLE, - }; + wxString m_text; + wxString m_shown_text; // Cache of unescaped text for efficient access + bool m_shown_text_has_text_var_refs; + + TEXT_ATTRIBUTES m_attributes; + wxPoint m_pos; }; diff --git a/include/font/text_attributes.h b/include/font/text_attributes.h new file mode 100644 index 00000000000..bee0a57f555 --- /dev/null +++ b/include/font/text_attributes.h @@ -0,0 +1,86 @@ +/* + * 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 . + */ + +#ifndef TEXT_ATTRIBUTES_H +#define TEXT_ATTRIBUTES_H + +#include +#include +#include +#include +#include + +class EDA_TEXT; + +namespace KIFONT +{ +class FONT; +}; + + +// Graphic Text alignments: +// +// NB: values -1,0,1 are used in computations, do not change them +// + +enum GR_TEXT_H_ALIGN_T +{ + GR_TEXT_H_ALIGN_LEFT = -1, + GR_TEXT_H_ALIGN_CENTER = 0, + GR_TEXT_H_ALIGN_RIGHT = 1 +}; + +enum GR_TEXT_V_ALIGN_T +{ + GR_TEXT_V_ALIGN_TOP = -1, + GR_TEXT_V_ALIGN_CENTER = 0, + GR_TEXT_V_ALIGN_BOTTOM = 1 +}; + + +#define TO_HJUSTIFY( x ) static_cast( x ) +#define TO_VJUSTIFY( x ) static_cast( x ) + + +class TEXT_ATTRIBUTES +{ +public: + KIFONT::FONT* m_Font = nullptr; + GR_TEXT_H_ALIGN_T m_Halign = GR_TEXT_H_ALIGN_CENTER; + GR_TEXT_V_ALIGN_T m_Valign = GR_TEXT_V_ALIGN_CENTER; + EDA_ANGLE m_Angle; + double m_LineSpacing = 1.0; + int m_StrokeWidth = 0; + bool m_Italic = false; + bool m_Bold = false; + bool m_Underlined = false; + bool m_Visible = true; + bool m_Mirrored = false; + bool m_Multiline = true; + VECTOR2D m_Size; + + /** + * If true, keep rotation angle between -90...90 degrees for readability + */ + bool m_KeepUpright = false; +}; + + +#endif //TEXT_ATTRIBUTES_H diff --git a/include/gal/graphics_abstraction_layer.h b/include/gal/graphics_abstraction_layer.h index 172df84cb11..20c6964950f 100644 --- a/include/gal/graphics_abstraction_layer.h +++ b/include/gal/graphics_abstraction_layer.h @@ -447,7 +447,7 @@ class GAL : GAL_DISPLAY_OPTIONS_OBSERVER * * @param aHorizontalJustify is the horizontal justify value. */ - inline void SetHorizontalJustify( const EDA_TEXT_HJUSTIFY_T aHorizontalJustify ) + inline void SetHorizontalJustify( const GR_TEXT_H_ALIGN_T aHorizontalJustify ) { textProperties.m_horizontalJustify = aHorizontalJustify; } @@ -455,7 +455,7 @@ class GAL : GAL_DISPLAY_OPTIONS_OBSERVER /** * Return current text horizontal justification setting. */ - inline EDA_TEXT_HJUSTIFY_T GetHorizontalJustify() const + inline GR_TEXT_H_ALIGN_T GetHorizontalJustify() const { return textProperties.m_horizontalJustify; } @@ -465,7 +465,7 @@ class GAL : GAL_DISPLAY_OPTIONS_OBSERVER * * @param aVerticalJustify is the vertical justify value. */ - inline void SetVerticalJustify( const EDA_TEXT_VJUSTIFY_T aVerticalJustify ) + inline void SetVerticalJustify( const GR_TEXT_V_ALIGN_T aVerticalJustify ) { textProperties.m_verticalJustify = aVerticalJustify; } @@ -473,7 +473,7 @@ class GAL : GAL_DISPLAY_OPTIONS_OBSERVER /** * Returns current text vertical justification setting. */ - inline EDA_TEXT_VJUSTIFY_T GetVerticalJustify() const + inline GR_TEXT_V_ALIGN_T GetVerticalJustify() const { return textProperties.m_verticalJustify; } @@ -1218,13 +1218,13 @@ class GAL : GAL_DISPLAY_OPTIONS_OBSERVER private: struct TEXT_PROPERTIES { - VECTOR2D m_glyphSize; ///< Size of the glyphs - EDA_TEXT_HJUSTIFY_T m_horizontalJustify; ///< Horizontal justification - EDA_TEXT_VJUSTIFY_T m_verticalJustify; ///< Vertical justification - bool m_bold; - bool m_italic; - bool m_underlined; - bool m_mirrored; + VECTOR2D m_glyphSize; ///< Size of the glyphs + GR_TEXT_H_ALIGN_T m_horizontalJustify; ///< Horizontal justification + GR_TEXT_V_ALIGN_T m_verticalJustify; ///< Vertical justification + bool m_bold; + bool m_italic; + bool m_underlined; + bool m_mirrored; } textProperties; }; diff --git a/include/gr_text.h b/include/gr_text.h index b72ca667b3c..76f88264e84 100644 --- a/include/gr_text.h +++ b/include/gr_text.h @@ -22,17 +22,16 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -/** - * This file is part of the common library - * @file drawtxt.h - * @see common.h - */ - -#ifndef __INCLUDE__DRAWTXT_H__ -#define __INCLUDE__DRAWTXT_H__ 1 +#ifndef GR_TEXT_H +#define GR_TEXT_H #include -#include // EDA_TEXT_HJUSTIFY_T and EDA_TEXT_VJUSTIFY_T +#include + +namespace KIGFX +{ + class COLOR4D; +} /** * Minimum dimension in pixel for drawing/no drawing a text used in Pcbnew to decide to @@ -93,7 +92,7 @@ int GraphicTextWidth( const wxString& aText, const wxSize& aSize, bool italic, b * @param aPos text position (according to h_justify, v_justify). * @param aColor (COLOR4D) = text color. * @param aText text to draw. - * @param aOrient angle in 0.1 degree. + * @param aOrient angle. * @param aSize text size (size.x or size.y can be < 0 for mirrored texts). * @param aH_justify horizontal justification (Left, center, right). * @param aV_justify vertical justification (bottom, center, top). @@ -110,24 +109,11 @@ int GraphicTextWidth( const wxString& aText, const wxSize& aSize, bool italic, b * @param aPlotter = a pointer to a PLOTTER instance, when this function is used to plot * 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, +void GRText( wxDC* aDC, const wxPoint& aPos, const KIGFX::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, void (*aCallback)( int x0, int y0, int xf, int yf, void* aData ) = nullptr, void* aCallbackData = nullptr, PLOTTER* aPlotter = nullptr ); -/** - * Draw graphic text with a border so that it can be read on different backgrounds. - * - * See GRText for most of the parameters. If \a aBgColor is a dark color text is drawn - * in \a aColor2 with \a aColor1 border. Otherwise colors are swapped. - */ -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 ) = nullptr, - void* aCallbackData = nullptr, PLOTTER* aPlotter = nullptr ); - -#endif /* __INCLUDE__DRAWTXT_H__ */ +#endif /* GR_TEXT_H */ diff --git a/include/plotters/plotter.h b/include/plotters/plotter.h index 920353010ee..862159fd61b 100644 --- a/include/plotters/plotter.h +++ b/include/plotters/plotter.h @@ -126,10 +126,7 @@ class PLOTTER virtual bool StartPlot() = 0; virtual bool EndPlot() = 0; - virtual void SetNegative( bool aNegative ) - { - m_negativeMode = aNegative; - } + virtual void SetNegative( bool aNegative ) { m_negativeMode = aNegative; } /** * Plot in B/W or color. @@ -306,14 +303,14 @@ class PLOTTER // Higher level primitives -- can be drawn as line, sketch or 'filled' virtual void ThickSegment( const wxPoint& start, const wxPoint& end, int width, OUTLINE_MODE tracemode, void* aData ); - virtual void ThickArc( const wxPoint& centre, double StAngle, double EndAngle, - int rayon, int width, OUTLINE_MODE tracemode, void* aData ); - virtual void ThickRect( const wxPoint& p1, const wxPoint& p2, int width, - OUTLINE_MODE tracemode, void* aData ); - virtual void ThickCircle( const wxPoint& pos, int diametre, int width, - OUTLINE_MODE tracemode, void* aData ); - virtual void FilledCircle( const wxPoint& pos, int diametre, - OUTLINE_MODE tracemode, void* aData ); + virtual void ThickArc( const wxPoint& centre, double StAngle, double EndAngle, int rayon, + int width, OUTLINE_MODE tracemode, void* aData ); + virtual void ThickRect( const wxPoint& p1, const wxPoint& p2, int width, OUTLINE_MODE tracemode, + void* aData ); + virtual void ThickCircle( const wxPoint& pos, int diametre, int width, OUTLINE_MODE tracemode, + void* aData ); + virtual void FilledCircle( const wxPoint& pos, int diametre, OUTLINE_MODE tracemode, + void* aData ); // Flash primitives @@ -324,8 +321,8 @@ class PLOTTER * @param aTraceMode is the drawing mode, FILLED or SKETCH. * @param aData is an auxiliary info (mainly for gerber format attributes). */ - virtual void FlashPadCircle( const wxPoint& aPadPos, int aDiameter, - OUTLINE_MODE aTraceMode, void* aData ) = 0; + virtual void FlashPadCircle( const wxPoint& aPadPos, int aDiameter, OUTLINE_MODE aTraceMode, + void* aData ) = 0; /** * @param aPadPos Position of the shape (center of the rectangle. @@ -344,8 +341,8 @@ class PLOTTER * @param aTraceMode is the drawing mode, FILLED or SKETCH. * @param aData an auxiliary info (mainly for gerber format attributes). */ - virtual void FlashPadRect( const wxPoint& aPadPos, const wxSize& aSize, - double aPadOrient, OUTLINE_MODE aTraceMode, void* aData ) = 0; + virtual void FlashPadRect( const wxPoint& aPadPos, const wxSize& aSize, double aPadOrient, + OUTLINE_MODE aTraceMode, void* aData ) = 0; /** * @param aPadPos Position of the shape (center of the rectangle. @@ -355,9 +352,8 @@ class PLOTTER * @param aTraceMode is the drawing mode, FILLED or SKETCH. * @param aData an auxiliary info (mainly for gerber format attributes). */ - virtual void FlashPadRoundRect( const wxPoint& aPadPos, const wxSize& aSize, - int aCornerRadius, double aOrient, - OUTLINE_MODE aTraceMode, void* aData ) = 0; + virtual void FlashPadRoundRect( const wxPoint& aPadPos, const wxSize& aSize, int aCornerRadius, + double aOrient, OUTLINE_MODE aTraceMode, void* aData ) = 0; /** * @param aPadPos Position of the shape. @@ -367,9 +363,9 @@ class PLOTTER * @param aTraceMode is the drawing mode, FILLED or SKETCH. * @param aData an auxiliary info (mainly for gerber format attributes). */ - virtual void FlashPadCustom( const wxPoint& aPadPos, const wxSize& aSize, - double aPadOrient, SHAPE_POLY_SET* aPolygons, - OUTLINE_MODE aTraceMode, void* aData ) = 0; + virtual void FlashPadCustom( const wxPoint& aPadPos, const wxSize& aSize, double aPadOrient, + SHAPE_POLY_SET* aPolygons, OUTLINE_MODE aTraceMode, + void* aData ) = 0; /** * Flash a trapezoidal pad. @@ -381,9 +377,8 @@ class PLOTTER * @param aTraceMode is the drawing mode, FILLED or SKETCH. * @param aData an auxiliary info (mainly for gerber format attributes). */ - virtual void FlashPadTrapez( const wxPoint& aPadPos, const wxPoint *aCorners, - double aPadOrient, OUTLINE_MODE aTraceMode, - void* aData ) = 0; + virtual void FlashPadTrapez( const wxPoint& aPadPos, const wxPoint* aCorners, double aPadOrient, + OUTLINE_MODE aTraceMode, void* aData ) = 0; /** * Flash a regular polygon. Useful only in Gerber files to flash a regular polygon. @@ -396,7 +391,7 @@ class PLOTTER * specific to the plotter. */ virtual void FlashRegularPolygon( const wxPoint& aShapePos, int aDiameter, int aCornerCount, - double aOrient, OUTLINE_MODE aTraceMode, void* aData ) = 0 ; + double aOrient, OUTLINE_MODE aTraceMode, void* aData ) = 0; /** * Draw text with the plotter. @@ -407,10 +402,10 @@ class PLOTTER virtual void 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, diff --git a/include/plotters/plotter_dxf.h b/include/plotters/plotter_dxf.h index 29bacb5a7d2..489999255a2 100644 --- a/include/plotters/plotter_dxf.h +++ b/include/plotters/plotter_dxf.h @@ -152,15 +152,15 @@ class DXF_PLOTTER : public PLOTTER virtual void 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, bool aMultilineAllowed = false, - void* aData = nullptr ) override; + void* aData = nullptr ) override; /** diff --git a/include/plotters/plotter_gerber.h b/include/plotters/plotter_gerber.h index a2cbe8c82cf..1369181265b 100644 --- a/include/plotters/plotter_gerber.h +++ b/include/plotters/plotter_gerber.h @@ -102,15 +102,15 @@ class GERBER_PLOTTER : public PLOTTER virtual void 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, bool aMultilineAllowed = false, - void* aData = nullptr ) override; + void* aData = nullptr ) override; /** * Filled circular flashes are stored as apertures diff --git a/include/plotters/plotters_pslike.h b/include/plotters/plotters_pslike.h index 3214781e8a9..880d4f3d9dd 100644 --- a/include/plotters/plotters_pslike.h +++ b/include/plotters/plotters_pslike.h @@ -97,11 +97,11 @@ class PSLIKE_PLOTTER : public PLOTTER */ void 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, @@ -217,15 +217,16 @@ class PS_PLOTTER : public PSLIKE_PLOTTER virtual void 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, bool aMultilineAllowed = false, - void* aData = nullptr ) override; + void* aData = nullptr ) override; + protected: virtual void emitSetRGBColor( double r, double g, double b ) override; }; @@ -333,15 +334,16 @@ class PDF_PLOTTER : public PSLIKE_PLOTTER virtual void 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, bool aMultilineAllowed = false, - void* aData = nullptr ) override; + void* aData = nullptr ) override; + /** * PDF images are handles as inline, not XObject streams... */ @@ -495,15 +497,15 @@ class SVG_PLOTTER : public PSLIKE_PLOTTER virtual void 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, bool aMultilineAllowed = false, - void* aData = nullptr ) override; + void* aData = nullptr ) override; protected: /** diff --git a/pagelayout_editor/dialogs/properties_frame.cpp b/pagelayout_editor/dialogs/properties_frame.cpp index 20fb43929f8..9dc1104f66a 100644 --- a/pagelayout_editor/dialogs/properties_frame.cpp +++ b/pagelayout_editor/dialogs/properties_frame.cpp @@ -263,16 +263,16 @@ void PROPERTIES_FRAME::CopyPrmsFromItemToPanel( DS_DATA_ITEM* aItem ) switch( item->m_Hjustify ) { - case GR_TEXT_HJUSTIFY_LEFT: m_choiceHjustify->SetSelection( 0 ); break; - case GR_TEXT_HJUSTIFY_CENTER: m_choiceHjustify->SetSelection( 1 ); break; - case GR_TEXT_HJUSTIFY_RIGHT: m_choiceHjustify->SetSelection( 2 ); break; + case GR_TEXT_H_ALIGN_LEFT: m_choiceHjustify->SetSelection( 0 ); break; + case GR_TEXT_H_ALIGN_CENTER: m_choiceHjustify->SetSelection( 1 ); break; + case GR_TEXT_H_ALIGN_RIGHT: m_choiceHjustify->SetSelection( 2 ); break; } switch( item->m_Vjustify ) { - case GR_TEXT_VJUSTIFY_TOP: m_choiceVjustify->SetSelection( 0 ); break; - case GR_TEXT_VJUSTIFY_CENTER: m_choiceVjustify->SetSelection( 1 ); break; - case GR_TEXT_VJUSTIFY_BOTTOM: m_choiceVjustify->SetSelection( 2 ); break; + case GR_TEXT_V_ALIGN_TOP: m_choiceVjustify->SetSelection( 0 ); break; + case GR_TEXT_V_ALIGN_CENTER: m_choiceVjustify->SetSelection( 1 ); break; + case GR_TEXT_V_ALIGN_BOTTOM: m_choiceVjustify->SetSelection( 2 ); break; } // Text size @@ -474,16 +474,16 @@ bool PROPERTIES_FRAME::CopyPrmsFromPanelToItem( DS_DATA_ITEM* aItem ) switch( m_choiceHjustify->GetSelection() ) { - case 0: item->m_Hjustify = GR_TEXT_HJUSTIFY_LEFT; break; - case 1: item->m_Hjustify = GR_TEXT_HJUSTIFY_CENTER; break; - case 2: item->m_Hjustify = GR_TEXT_HJUSTIFY_RIGHT; break; + case 0: item->m_Hjustify = GR_TEXT_H_ALIGN_LEFT; break; + case 1: item->m_Hjustify = GR_TEXT_H_ALIGN_CENTER; break; + case 2: item->m_Hjustify = GR_TEXT_H_ALIGN_RIGHT; break; } switch( m_choiceVjustify->GetSelection() ) { - case 0: item->m_Vjustify = GR_TEXT_VJUSTIFY_TOP; break; - case 1: item->m_Vjustify = GR_TEXT_VJUSTIFY_CENTER; break; - case 2: item->m_Vjustify = GR_TEXT_VJUSTIFY_BOTTOM; break; + case 0: item->m_Vjustify = GR_TEXT_V_ALIGN_TOP; break; + case 1: item->m_Vjustify = GR_TEXT_V_ALIGN_CENTER; break; + case 2: item->m_Vjustify = GR_TEXT_V_ALIGN_BOTTOM; break; } msg = m_textCtrlRotation->GetValue(); diff --git a/pcbnew/dialogs/dialog_dimension_properties.cpp b/pcbnew/dialogs/dialog_dimension_properties.cpp index e26a8fd3dbb..ddd7b37550e 100644 --- a/pcbnew/dialogs/dialog_dimension_properties.cpp +++ b/pcbnew/dialogs/dialog_dimension_properties.cpp @@ -221,7 +221,7 @@ bool DIALOG_DIMENSION_PROPERTIES::TransferDataToWindow() m_txtTextPosY->Disable(); } - m_orientValue = text.GetTextAngleDegrees(); + m_orientValue = text.GetTextAngle().AsDegrees(); m_cbKeepAligned->SetValue( m_dimension->GetKeepTextAligned() ); m_cbTextOrientation->Enable( !m_dimension->GetKeepTextAligned() ); @@ -229,7 +229,7 @@ bool DIALOG_DIMENSION_PROPERTIES::TransferDataToWindow() m_cbItalic->SetValue( text.IsItalic() ); m_cbMirrored->SetValue( text.IsMirrored() ); - EDA_TEXT_HJUSTIFY_T hJustify = text.GetHorizJustify(); + GR_TEXT_H_ALIGN_T hJustify = text.GetHorizJustify(); m_cbJustification->SetSelection( (int) hJustify + 1 ); m_lineThickness.SetValue( m_dimension->GetLineThickness() ); @@ -346,8 +346,7 @@ void DIALOG_DIMENSION_PROPERTIES::updateDimensionFromDialog( PCB_DIMENSION_BASE* text.SetTextThickness( m_textThickness.GetValue() ); text.SetItalic( m_cbItalic->GetValue() ); text.SetMirrored( m_cbMirrored->GetValue() ); - int justification = m_cbJustification->GetSelection() - 1; - text.SetHorizJustify( static_cast( justification ) ); + text.SetHorizJustify( TO_HJUSTIFY( m_cbJustification->GetSelection() - 1 ) ); aTarget->SetLineThickness( m_lineThickness.GetValue() ); aTarget->SetArrowLength( m_arrowLength.GetValue() ); diff --git a/pcbnew/dialogs/dialog_exchange_footprints.cpp b/pcbnew/dialogs/dialog_exchange_footprints.cpp index 60d6cfe4c79..fc85b793716 100644 --- a/pcbnew/dialogs/dialog_exchange_footprints.cpp +++ b/pcbnew/dialogs/dialog_exchange_footprints.cpp @@ -436,9 +436,9 @@ void processTextItem( const FP_TEXT& aSrc, FP_TEXT& aDest, } else { - // Careful: the visible bit is also in Effects + // Careful: the visible bit and position are also set by SetAttributes() bool visible = aDest.IsVisible(); - aDest.SetEffects( aSrc ); + aDest.SetAttributes( aSrc ); aDest.SetVisible( visible ); } diff --git a/pcbnew/dialogs/dialog_text_properties.cpp b/pcbnew/dialogs/dialog_text_properties.cpp index 57acc5136ca..d2f807ccdc8 100644 --- a/pcbnew/dialogs/dialog_text_properties.cpp +++ b/pcbnew/dialogs/dialog_text_properties.cpp @@ -273,14 +273,14 @@ bool DIALOG_TEXT_PROPERTIES::TransferDataToWindow() switch ( m_edaText->GetHorizJustify() ) { - case GR_TEXT_HJUSTIFY_LEFT: m_alignLeft->Check( true ); break; - case GR_TEXT_HJUSTIFY_CENTER: m_alignCenter->Check( true ); break; - case GR_TEXT_HJUSTIFY_RIGHT: m_alignRight->Check( true ); break; + case GR_TEXT_H_ALIGN_LEFT: m_alignLeft->Check( true ); break; + case GR_TEXT_H_ALIGN_CENTER: m_alignCenter->Check( true ); break; + case GR_TEXT_H_ALIGN_RIGHT: m_alignRight->Check( true ); break; } m_mirrored->Check( m_edaText->IsMirrored() ); - m_OrientValue = m_edaText->GetTextAngle(); + m_OrientValue = m_edaText->GetTextAngle().AsTenthsOfADegree(); m_orientation.SetDoubleValue( m_OrientValue ); return DIALOG_TEXT_PROPERTIES_BASE::TransferDataToWindow(); @@ -377,11 +377,11 @@ bool DIALOG_TEXT_PROPERTIES::TransferDataFromWindow() m_edaText->SetItalic( m_italic->IsChecked() ); if( m_alignLeft->IsChecked() ) - m_edaText->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); + m_edaText->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); else if( m_alignCenter->IsChecked() ) - m_edaText->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER ); + m_edaText->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER ); else - m_edaText->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); + m_edaText->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); m_edaText->SetMirrored( m_mirrored->IsChecked() ); diff --git a/pcbnew/exporters/export_gencad.cpp b/pcbnew/exporters/export_gencad.cpp index e1668433a3f..e4e7705e97a 100644 --- a/pcbnew/exporters/export_gencad.cpp +++ b/pcbnew/exporters/export_gencad.cpp @@ -893,7 +893,6 @@ static void CreateComponentsSection( FILE* aFile, BOARD* aPcb ) // Text on silk layer: RefDes and value (are they actually useful?) for( FP_TEXT* textItem : { &footprint->Reference(), &footprint->Value() } ) { - double txt_orient = textItem->GetTextAngle(); std::string layer = GenCADLayerName( cu_count, footprint->GetFlag() ? B_SilkS : F_SilkS ); @@ -901,7 +900,7 @@ static void CreateComponentsSection( FILE* aFile, BOARD* aPcb ) textItem->GetPos0().x / SCALE_FACTOR, -textItem->GetPos0().y / SCALE_FACTOR, textItem->GetTextWidth() / SCALE_FACTOR, - txt_orient / 10.0, + textItem->GetTextAngle().AsDegrees(), mirror, layer.c_str(), TO_UTF8( escapeString( textItem->GetText() ) ) ); diff --git a/pcbnew/exporters/gen_drill_report_files.cpp b/pcbnew/exporters/gen_drill_report_files.cpp index 3d8d2238490..39f3da0bc4a 100644 --- a/pcbnew/exporters/gen_drill_report_files.cpp +++ b/pcbnew/exporters/gen_drill_report_files.cpp @@ -252,9 +252,9 @@ bool GENDRILL_WRITER_BASE::genDrillMapFile( const wxString& aFullFileName, PLOT_ // Plot title "Info" wxString Text = wxT( "Drill Map:" ); - plotter->Text( wxPoint( plotX, plotY ), COLOR4D::UNSPECIFIED, Text, 0, + plotter->Text( wxPoint( plotX, plotY ), COLOR4D::UNSPECIFIED, Text, EDA_ANGLE::HORIZONTAL, wxSize( KiROUND( charSize * charScale ), KiROUND( charSize * charScale ) ), - GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, TextWidth, false, false ); + GR_TEXT_H_ALIGN_LEFT, GR_TEXT_V_ALIGN_CENTER, TextWidth, false, false ); // For some formats (PS, PDF SVG) we plot the drill size list on more than one column // because the list must be contained inside the printed page @@ -313,9 +313,9 @@ bool GENDRILL_WRITER_BASE::genDrillMapFile( const wxString& aFullFileName, PLOT_ if( tool.m_Hole_NotPlated ) msg += wxT( " (not plated)" ); - plotter->Text( wxPoint( plotX, y ), COLOR4D::UNSPECIFIED, msg, 0, + plotter->Text( wxPoint( plotX, y ), COLOR4D::UNSPECIFIED, msg, EDA_ANGLE::HORIZONTAL, wxSize( KiROUND( charSize * charScale ), KiROUND( charSize * charScale ) ), - GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, TextWidth, false, false ); + GR_TEXT_H_ALIGN_LEFT, GR_TEXT_V_ALIGN_CENTER, TextWidth, false, false ); intervalle = KiROUND( ( ( charSize * charScale ) + TextWidth ) * 1.2 ); diff --git a/pcbnew/fp_text.cpp b/pcbnew/fp_text.cpp index 1bb8b1f232c..3fc2906fa48 100644 --- a/pcbnew/fp_text.cpp +++ b/pcbnew/fp_text.cpp @@ -76,6 +76,12 @@ void FP_TEXT::SetTextAngle( double aAngle ) } +void FP_TEXT::SetTextAngle( const EDA_ANGLE& aAngle ) +{ + EDA_TEXT::SetTextAngle( aAngle ); +} + + bool FP_TEXT::TextHitTest( const wxPoint& aPoint, int aAccuracy ) const { EDA_RECT rect = GetTextBox(); @@ -83,7 +89,7 @@ bool FP_TEXT::TextHitTest( const wxPoint& aPoint, int aAccuracy ) const rect.Inflate( aAccuracy ); - RotatePoint( &location, GetTextPos(), -GetDrawRotation() ); + RotatePoint( &location, GetTextPos(), -GetDrawRotation().AsTenthsOfADegree() ); return rect.Contains( location ); } @@ -98,7 +104,7 @@ bool FP_TEXT::TextHitTest( const EDA_RECT& aRect, bool aContains, int aAccuracy if( aContains ) return rect.Contains( GetBoundingBox() ); else - return rect.Intersects( GetTextBox(), GetDrawRotation() ); + return rect.Intersects( GetTextBox(), GetDrawRotation().AsTenthsOfADegree() ); } @@ -107,14 +113,14 @@ void FP_TEXT::KeepUpright( double aOldOrientation, double aNewOrientation ) if( !IsKeepUpright() ) return; - double newAngle = GetTextAngle() + aNewOrientation; + double newAngle = GetTextAngle().AsTenthsOfADegree() + aNewOrientation; NORMALIZE_ANGLE_POS( newAngle ); bool needsFlipped = newAngle >= 1800.0; if( needsFlipped ) { - SetHorizJustify( static_cast( -GetHorizJustify() ) ); - SetTextAngle( GetTextAngle() + 1800.0 ); + SetHorizJustify( static_cast( -GetHorizJustify() ) ); + SetTextAngle( GetTextAngle().AsTenthsOfADegree() + 1800.0 ); SetDrawCoord(); } } @@ -129,7 +135,7 @@ void FP_TEXT::Rotate( const wxPoint& aRotCentre, double aAngle ) RotatePoint( &pt, aRotCentre, aAngle ); SetTextPos( pt ); - SetTextAngle( GetTextAngle() + aAngle ); + SetTextAngle( GetTextAngle().AsTenthsOfADegree() + aAngle ); SetLocalCoord(); } @@ -145,7 +151,7 @@ void FP_TEXT::Flip( const wxPoint& aCentre, bool aFlipLeftRight ) else { SetTextY( MIRRORVAL( GetTextPos().y, aCentre.y ) ); - SetTextAngle( 1800 - GetTextAngle() ); + SetTextAngle( 1800 - GetTextAngle().AsTenthsOfADegree() ); } SetLayer( FlipLayer( GetLayer(), GetBoard()->GetCopperLayerCount() ) ); @@ -226,7 +232,7 @@ void FP_TEXT::SetLocalCoord() const EDA_RECT FP_TEXT::GetBoundingBox() const { - double angle = GetDrawRotation(); + double angle = GetDrawRotation().AsTenthsOfADegree(); EDA_RECT text_area = GetTextBox(); if( angle ) @@ -236,10 +242,10 @@ const EDA_RECT FP_TEXT::GetBoundingBox() const } -double FP_TEXT::GetDrawRotation() const +EDA_ANGLE FP_TEXT::GetDrawRotation() const { FOOTPRINT* parentFootprint = static_cast( m_parent ); - double rotation = GetTextAngle(); + double rotation = GetTextAngle().AsTenthsOfADegree(); if( parentFootprint ) rotation += parentFootprint->GetOrientation(); @@ -258,7 +264,7 @@ double FP_TEXT::GetDrawRotation() const NORMALIZE_ANGLE_POS( rotation ); } - return rotation; + return EDA_ANGLE( rotation, EDA_ANGLE::TENTHS_OF_A_DEGREE ); } @@ -295,7 +301,7 @@ void FP_TEXT::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vectorGetUserUnits(), GetTextThickness() ); @@ -344,10 +350,10 @@ EDA_ITEM* FP_TEXT::Clone() const const BOX2I FP_TEXT::ViewBBox() const { - double angle = GetDrawRotation(); + double angle = GetDrawRotation().AsTenthsOfADegree(); EDA_RECT text_area = GetTextBox(); - if( angle != 0.0 ) + if( angle ) text_area = text_area.GetBoundingBoxRotated( GetTextPos(), angle ); return BOX2I( text_area.GetPosition(), text_area.GetSize() ); @@ -486,7 +492,7 @@ void FP_TEXT::TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffe const FOOTPRINT* parentFootprint = static_cast( m_parent ); if( parentFootprint ) - buffer.Rotate( DECIDEG2RAD( GetDrawRotation() ), GetTextPos() ); + buffer.Rotate( GetDrawRotation().AsRadians(), GetTextPos() ); aCornerBuffer.Append( buffer ); } diff --git a/pcbnew/fp_text.h b/pcbnew/fp_text.h index 2155c33c75b..29a6c7b075c 100644 --- a/pcbnew/fp_text.h +++ b/pcbnew/fp_text.h @@ -97,6 +97,7 @@ class FP_TEXT : public BOARD_ITEM, public EDA_TEXT } void SetTextAngle( double aAngle ) override; + void SetTextAngle( const EDA_ANGLE& aAngle ); /** * Called when rotating the parent footprint. @@ -133,27 +134,6 @@ class FP_TEXT : public BOARD_ITEM, public EDA_TEXT void SetType( TEXT_TYPE aType ) { m_Type = aType; } TEXT_TYPE GetType() const { return m_Type; } - /** - * Set the text effects from another instance. - */ - void SetEffects( const FP_TEXT& aSrc ) - { - EDA_TEXT::SetEffects( aSrc ); - SetLocalCoord(); - // SetType( aSrc.GetType() ); - } - - /** - * Swap the text effects of the two involved instances. - */ - void SwapEffects( FP_TEXT& aTradingPartner ) - { - EDA_TEXT::SwapEffects( aTradingPartner ); - SetLocalCoord(); - aTradingPartner.SetLocalCoord(); - // std::swap( m_Type, aTradingPartner.m_Type ); - } - // The Pos0 accessors are for footprint-relative coordinates. void SetPos0( const wxPoint& aPos ) { m_Pos0 = aPos; SetDrawCoord(); } const wxPoint& GetPos0() const { return m_Pos0; } @@ -164,8 +144,7 @@ class FP_TEXT : public BOARD_ITEM, public EDA_TEXT * @return the text rotation for drawings and plotting the footprint rotation is taken * in account. */ - virtual double GetDrawRotation() const override; - double GetDrawRotationRadians() const { return GetDrawRotation() * M_PI/1800; } + virtual EDA_ANGLE GetDrawRotation() const override; // Virtual function const EDA_RECT GetBoundingBox() const override; diff --git a/pcbnew/fp_text_grid_table.cpp b/pcbnew/fp_text_grid_table.cpp index 44888c23b27..16782ec61c8 100644 --- a/pcbnew/fp_text_grid_table.cpp +++ b/pcbnew/fp_text_grid_table.cpp @@ -211,7 +211,8 @@ wxString FP_TEXT_GRID_TABLE::GetValue( int aRow, int aCol ) return text.GetLayerName(); case FPT_ORIENTATION: - return StringFromValue( EDA_UNITS::DEGREES, (int) NormalizeAnglePos( text.GetTextAngle() ), + return StringFromValue( EDA_UNITS::DEGREES, + NormalizeAnglePos( text.GetTextAngle().AsTenthsOfADegree() ), true ); case FPT_XOFFSET: diff --git a/pcbnew/import_gfx/dxf_import_plugin.cpp b/pcbnew/import_gfx/dxf_import_plugin.cpp index f2c1dc2e2f1..bbe096607ed 100644 --- a/pcbnew/import_gfx/dxf_import_plugin.cpp +++ b/pcbnew/import_gfx/dxf_import_plugin.cpp @@ -588,21 +588,21 @@ void DXF_IMPORT_PLUGIN::addText( const DL_TextData& aData ) VECTOR2D topLeft(0.0, 0.0); VECTOR2D topRight(0.0, 0.0); - EDA_TEXT_HJUSTIFY_T hJustify = GR_TEXT_HJUSTIFY_LEFT; - EDA_TEXT_VJUSTIFY_T vJustify = GR_TEXT_VJUSTIFY_BOTTOM; + GR_TEXT_H_ALIGN_T hJustify = GR_TEXT_H_ALIGN_LEFT; + GR_TEXT_V_ALIGN_T vJustify = GR_TEXT_V_ALIGN_BOTTOM; switch( aData.vJustification ) { case 0: //DRW_Text::VBaseLine: case 1: //DRW_Text::VBottom: - vJustify = GR_TEXT_VJUSTIFY_BOTTOM; + vJustify = GR_TEXT_V_ALIGN_BOTTOM; topLeft.y = textHeight; topRight.y = textHeight; break; case 2: //DRW_Text::VMiddle: - vJustify = GR_TEXT_VJUSTIFY_CENTER; + vJustify = GR_TEXT_V_ALIGN_CENTER; bottomRight.y = -textHeight / 2.0; bottomLeft.y = -textHeight / 2.0; @@ -611,7 +611,7 @@ void DXF_IMPORT_PLUGIN::addText( const DL_TextData& aData ) break; case 3: //DRW_Text::VTop: - vJustify = GR_TEXT_VJUSTIFY_TOP; + vJustify = GR_TEXT_V_ALIGN_TOP; bottomLeft.y = -textHeight; bottomRight.y = -textHeight; @@ -623,7 +623,7 @@ void DXF_IMPORT_PLUGIN::addText( const DL_TextData& aData ) case 0: //DRW_Text::HLeft: case 3: //DRW_Text::HAligned: // no equivalent options in text pcb. case 5: //DRW_Text::HFit: // no equivalent options in text pcb. - hJustify = GR_TEXT_HJUSTIFY_LEFT; + hJustify = GR_TEXT_H_ALIGN_LEFT; bottomRight.x = textWidth; topRight.x = textWidth; @@ -631,7 +631,7 @@ void DXF_IMPORT_PLUGIN::addText( const DL_TextData& aData ) case 1: //DRW_Text::HCenter: case 4: //DRW_Text::HMiddle: // no equivalent options in text pcb. - hJustify = GR_TEXT_HJUSTIFY_CENTER; + hJustify = GR_TEXT_H_ALIGN_CENTER; bottomLeft.x = -textWidth / 2.0; topLeft.x = -textWidth / 2.0; @@ -640,7 +640,7 @@ void DXF_IMPORT_PLUGIN::addText( const DL_TextData& aData ) break; case 2: //DRW_Text::HRight: - hJustify = GR_TEXT_HJUSTIFY_RIGHT; + hJustify = GR_TEXT_H_ALIGN_RIGHT; bottomLeft.x = -textWidth; topLeft.x = -textWidth; @@ -755,19 +755,19 @@ void DXF_IMPORT_PLUGIN::addMText( const DL_MTextData& aData ) VECTOR2D textpos( mapX( textposCoords.x ), mapY( textposCoords.y ) ); // Initialize text justifications: - EDA_TEXT_HJUSTIFY_T hJustify = GR_TEXT_HJUSTIFY_LEFT; - EDA_TEXT_VJUSTIFY_T vJustify = GR_TEXT_VJUSTIFY_BOTTOM; + GR_TEXT_H_ALIGN_T hJustify = GR_TEXT_H_ALIGN_LEFT; + GR_TEXT_V_ALIGN_T vJustify = GR_TEXT_V_ALIGN_BOTTOM; if( aData.attachmentPoint <= 3 ) { - vJustify = GR_TEXT_VJUSTIFY_TOP; + vJustify = GR_TEXT_V_ALIGN_TOP; bottomLeft.y = -textHeight; bottomRight.y = -textHeight; } else if( aData.attachmentPoint <= 6 ) { - vJustify = GR_TEXT_VJUSTIFY_CENTER; + vJustify = GR_TEXT_V_ALIGN_CENTER; bottomRight.y = -textHeight / 2.0; bottomLeft.y = -textHeight / 2.0; @@ -776,7 +776,7 @@ void DXF_IMPORT_PLUGIN::addMText( const DL_MTextData& aData ) } else { - vJustify = GR_TEXT_VJUSTIFY_BOTTOM; + vJustify = GR_TEXT_V_ALIGN_BOTTOM; topLeft.y = textHeight; topRight.y = textHeight; @@ -784,14 +784,14 @@ void DXF_IMPORT_PLUGIN::addMText( const DL_MTextData& aData ) if( aData.attachmentPoint % 3 == 1 ) { - hJustify = GR_TEXT_HJUSTIFY_LEFT; + hJustify = GR_TEXT_H_ALIGN_LEFT; bottomRight.x = textWidth; topRight.x = textWidth; } else if( aData.attachmentPoint % 3 == 2 ) { - hJustify = GR_TEXT_HJUSTIFY_CENTER; + hJustify = GR_TEXT_H_ALIGN_CENTER; bottomLeft.x = -textWidth / 2.0; topLeft.x = -textWidth / 2.0; @@ -800,7 +800,7 @@ void DXF_IMPORT_PLUGIN::addMText( const DL_MTextData& aData ) } else { - hJustify = GR_TEXT_HJUSTIFY_RIGHT; + hJustify = GR_TEXT_H_ALIGN_RIGHT; bottomLeft.x = -textWidth; topLeft.x = -textWidth; diff --git a/pcbnew/import_gfx/graphics_importer.h b/pcbnew/import_gfx/graphics_importer.h index b14c2dd19ee..2c332d04319 100644 --- a/pcbnew/import_gfx/graphics_importer.h +++ b/pcbnew/import_gfx/graphics_importer.h @@ -231,9 +231,9 @@ class GRAPHICS_IMPORTER * @param aVJustify is the text vertical justification. * @param aWidth is the segment thickness in mm. Use -1 for default line thickness */ - virtual void AddText( const VECTOR2D& aOrigin, const wxString& aText, - double aHeight, double aWidth, double aThickness, double aOrientation, - EDA_TEXT_HJUSTIFY_T aHJustify, EDA_TEXT_VJUSTIFY_T aVJustify ) = 0; + virtual void AddText( const VECTOR2D& aOrigin, const wxString& aText, double aHeight, + double aWidth, double aThickness, double aOrientation, + GR_TEXT_H_ALIGN_T aHJustify, GR_TEXT_V_ALIGN_T aVJustify ) = 0; /** * Create an object representing an arc. diff --git a/pcbnew/import_gfx/graphics_importer_buffer.cpp b/pcbnew/import_gfx/graphics_importer_buffer.cpp index 6be5c61b2fd..df8d034ceb9 100644 --- a/pcbnew/import_gfx/graphics_importer_buffer.cpp +++ b/pcbnew/import_gfx/graphics_importer_buffer.cpp @@ -48,29 +48,30 @@ void GRAPHICS_IMPORTER_BUFFER::AddCircle( const VECTOR2D& aCenter, double aRadiu void GRAPHICS_IMPORTER_BUFFER::AddArc( const VECTOR2D& aCenter, const VECTOR2D& aStart, double aAngle, double aWidth ) { - m_shapes.push_back( make_shape< IMPORTED_ARC >( aCenter, aStart, aAngle, aWidth ) ); + m_shapes.push_back( make_shape( aCenter, aStart, aAngle, aWidth ) ); } void GRAPHICS_IMPORTER_BUFFER::AddPolygon( const std::vector< VECTOR2D >& aVertices, double aWidth ) { - m_shapes.push_back( make_shape< IMPORTED_POLYGON >( aVertices, aWidth ) ); + m_shapes.push_back( make_shape( aVertices, aWidth ) ); } void GRAPHICS_IMPORTER_BUFFER::AddText( const VECTOR2D& aOrigin, const wxString& aText, - double aHeight, double aWidth, double aThickness, double aOrientation, - EDA_TEXT_HJUSTIFY_T aHJustify, EDA_TEXT_VJUSTIFY_T aVJustify ) + double aHeight, double aWidth, double aThickness, + double aOrientation, GR_TEXT_H_ALIGN_T aHJustify, + GR_TEXT_V_ALIGN_T aVJustify ) { m_shapes.push_back( make_shape< IMPORTED_TEXT >( aOrigin, aText, aHeight, aWidth, - aThickness, aOrientation, aHJustify, aVJustify ) ); + aThickness, aOrientation, aHJustify, aVJustify ) ); } void GRAPHICS_IMPORTER_BUFFER::AddSpline( const VECTOR2D& aStart, const VECTOR2D& aBezierControl1, const VECTOR2D& aBezierControl2, const VECTOR2D& aEnd , double aWidth ) { - m_shapes.push_back( make_shape< IMPORTED_SPLINE >( aStart, aBezierControl1, aBezierControl2, aEnd, aWidth ) ); + m_shapes.push_back( make_shape( aStart, aBezierControl1, aBezierControl2, aEnd, aWidth ) ); } @@ -82,6 +83,6 @@ void GRAPHICS_IMPORTER_BUFFER::AddShape( std::unique_ptr& aShape void GRAPHICS_IMPORTER_BUFFER::ImportTo( GRAPHICS_IMPORTER& aImporter ) { - for( auto& shape : m_shapes ) + for( std::unique_ptr& shape : m_shapes ) shape->ImportTo( aImporter ); } diff --git a/pcbnew/import_gfx/graphics_importer_buffer.h b/pcbnew/import_gfx/graphics_importer_buffer.h index c5390379762..f9153b95511 100644 --- a/pcbnew/import_gfx/graphics_importer_buffer.h +++ b/pcbnew/import_gfx/graphics_importer_buffer.h @@ -218,8 +218,8 @@ class IMPORTED_TEXT : public IMPORTED_SHAPE { public: IMPORTED_TEXT( const VECTOR2D& aOrigin, const wxString& aText, double aHeight, double aWidth, - double aThickness, double aOrientation, EDA_TEXT_HJUSTIFY_T aHJustify, - EDA_TEXT_VJUSTIFY_T aVJustify ) : + double aThickness, double aOrientation, GR_TEXT_H_ALIGN_T aHJustify, + GR_TEXT_V_ALIGN_T aVJustify ) : m_origin( aOrigin ), m_text( aText ), m_height( aHeight ), @@ -260,8 +260,8 @@ class IMPORTED_TEXT : public IMPORTED_SHAPE double m_width; double m_thickness; double m_orientation; - EDA_TEXT_HJUSTIFY_T m_hJustify; - EDA_TEXT_VJUSTIFY_T m_vJustify; + GR_TEXT_H_ALIGN_T m_hJustify; + GR_TEXT_V_ALIGN_T m_vJustify; }; @@ -329,9 +329,9 @@ class GRAPHICS_IMPORTER_BUFFER : public GRAPHICS_IMPORTER void AddPolygon( const std::vector< VECTOR2D >& aVertices, double aWidth ) override; - void AddText( const VECTOR2D& aOrigin, const wxString& aText, - double aHeight, double aWidth, double aThickness, double aOrientation, - EDA_TEXT_HJUSTIFY_T aHJustify, EDA_TEXT_VJUSTIFY_T aVJustify ) override; + void AddText( const VECTOR2D& aOrigin, const wxString& aText, double aHeight, double aWidth, + double aThickness, double aOrientation, GR_TEXT_H_ALIGN_T aHJustify, + GR_TEXT_V_ALIGN_T aVJustify ) override; void AddSpline( const VECTOR2D& aStart, const VECTOR2D& BezierControl1, const VECTOR2D& BezierControl2, const VECTOR2D& aEnd , double aWidth ) override; diff --git a/pcbnew/import_gfx/graphics_importer_pcbnew.cpp b/pcbnew/import_gfx/graphics_importer_pcbnew.cpp index 6dd7d4e3a0b..8de68643b2a 100644 --- a/pcbnew/import_gfx/graphics_importer_pcbnew.cpp +++ b/pcbnew/import_gfx/graphics_importer_pcbnew.cpp @@ -146,8 +146,8 @@ void GRAPHICS_IMPORTER_PCBNEW::AddPolygon( const std::vector< VECTOR2D >& aVerti void GRAPHICS_IMPORTER_PCBNEW::AddText( const VECTOR2D& aOrigin, const wxString& aText, double aHeight, double aWidth, double aThickness, - double aOrientation, EDA_TEXT_HJUSTIFY_T aHJustify, - EDA_TEXT_VJUSTIFY_T aVJustify ) + double aOrientation, GR_TEXT_H_ALIGN_T aHJustify, + GR_TEXT_V_ALIGN_T aVJustify ) { std::unique_ptr boardItem; EDA_TEXT* textItem; diff --git a/pcbnew/import_gfx/graphics_importer_pcbnew.h b/pcbnew/import_gfx/graphics_importer_pcbnew.h index 3a4fb4bdb53..a89fbf276f8 100644 --- a/pcbnew/import_gfx/graphics_importer_pcbnew.h +++ b/pcbnew/import_gfx/graphics_importer_pcbnew.h @@ -69,9 +69,9 @@ class GRAPHICS_IMPORTER_PCBNEW : public GRAPHICS_IMPORTER void AddPolygon( const std::vector< VECTOR2D >& aVertices, double aWidth ) override; - void AddText( const VECTOR2D& aOrigin, const wxString& aText, - double aHeight, double aWidth, double aThickness, double aOrientation, - EDA_TEXT_HJUSTIFY_T aHJustify, EDA_TEXT_VJUSTIFY_T aVJustify ) override; + void AddText( const VECTOR2D& aOrigin, const wxString& aText, double aHeight, double aWidth, + double aThickness, double aOrientation, GR_TEXT_H_ALIGN_T aHJustify, + GR_TEXT_V_ALIGN_T aVJustify ) override; void AddSpline( const VECTOR2D& aStart, const VECTOR2D& aBezierControl1, const VECTOR2D& aBezierControl2, const VECTOR2D& aEnd, diff --git a/pcbnew/kicad_clipboard.cpp b/pcbnew/kicad_clipboard.cpp index 98efba298b7..2fac08ae158 100644 --- a/pcbnew/kicad_clipboard.cpp +++ b/pcbnew/kicad_clipboard.cpp @@ -210,7 +210,7 @@ void CLIPBOARD_IO::SaveSelection( const PCB_SELECTION& aSelected, bool isFootpri else pcb_text->CopyText( *fp_text ); - pcb_text->SetEffects( *fp_text ); + pcb_text->SetAttributes( *fp_text ); pcb_text->SetLayer( fp_text->GetLayer() ); copy = pcb_text; } diff --git a/pcbnew/pcb_dimension.cpp b/pcbnew/pcb_dimension.cpp index 3614314f6db..bdddd1c1616 100644 --- a/pcbnew/pcb_dimension.cpp +++ b/pcbnew/pcb_dimension.cpp @@ -213,7 +213,7 @@ void PCB_DIMENSION_BASE::Move( const wxPoint& offset ) void PCB_DIMENSION_BASE::Rotate( const wxPoint& aRotCentre, double aAngle ) { - double newAngle = m_text.GetTextAngle() + aAngle; + double newAngle = m_text.GetTextAngle().AsTenthsOfADegree() + aAngle; if( newAngle >= 3600 ) newAngle -= 3600; @@ -613,7 +613,7 @@ void PCB_DIM_ALIGNED::updateGeometry() polyBox.Append( textBox.GetOrigin().x, textBox.GetEnd().y ); polyBox.Append( textBox.GetEnd() ); polyBox.Append( textBox.GetEnd().x, textBox.GetOrigin().y ); - polyBox.Rotate( -m_text.GetTextAngleRadians(), textBox.GetCenter() ); + polyBox.Rotate( -m_text.GetTextAngle().AsRadians(), textBox.GetCenter() ); // The ideal crossbar, if the text doesn't collide SEG crossbar( m_crossBarStart, m_crossBarEnd ); @@ -796,7 +796,7 @@ void PCB_DIM_ORTHOGONAL::updateGeometry() polyBox.Append( textBox.GetOrigin().x, textBox.GetEnd().y ); polyBox.Append( textBox.GetEnd() ); polyBox.Append( textBox.GetEnd().x, textBox.GetOrigin().y ); - polyBox.Rotate( -m_text.GetTextAngleRadians(), textBox.GetCenter() ); + polyBox.Rotate( -m_text.GetTextAngle().AsRadians(), textBox.GetCenter() ); // The ideal crossbar, if the text doesn't collide SEG crossbar( m_crossBarStart, m_crossBarEnd ); @@ -986,7 +986,7 @@ void PCB_DIM_LEADER::updateGeometry() polyBox.Append( textBox.GetOrigin().x, textBox.GetEnd().y ); polyBox.Append( textBox.GetEnd() ); polyBox.Append( textBox.GetEnd().x, textBox.GetOrigin().y ); - polyBox.Rotate( -m_text.GetTextAngleRadians(), textBox.GetCenter() ); + polyBox.Rotate( -m_text.GetTextAngle().AsRadians(), textBox.GetCenter() ); VECTOR2I firstLine( m_end - m_start ); VECTOR2I start( m_start ); @@ -1178,7 +1178,7 @@ void PCB_DIM_RADIAL::updateGeometry() polyBox.Append( textBox.GetOrigin().x, textBox.GetEnd().y ); polyBox.Append( textBox.GetEnd() ); polyBox.Append( textBox.GetEnd().x, textBox.GetOrigin().y ); - polyBox.Rotate( -m_text.GetTextAngleRadians(), textBox.GetCenter() ); + polyBox.Rotate( -m_text.GetTextAngle().AsRadians(), textBox.GetCenter() ); VECTOR2I radial( m_end - m_start ); radial = radial.Resize( m_leaderLength ); diff --git a/pcbnew/pcb_painter.cpp b/pcbnew/pcb_painter.cpp index e01c6570c9a..680803b6bf9 100644 --- a/pcbnew/pcb_painter.cpp +++ b/pcbnew/pcb_painter.cpp @@ -611,8 +611,8 @@ void PCB_PAINTER::draw( const PCB_TRACK* aTrack, int aLayer ) m_gal->SetFontUnderlined( false ); m_gal->SetTextMirrored( false ); m_gal->SetGlyphSize( VECTOR2D( textSize * 0.55, textSize * 0.55 ) ); - m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_CENTER ); - m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_CENTER ); + m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_CENTER ); + m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_CENTER ); m_gal->BitmapText( netName, textPosition, textOrientation ); return; @@ -912,8 +912,8 @@ void PCB_PAINTER::draw( const PAD* aPad, int aLayer ) size = maxSize; // Default font settings - m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_CENTER ); - m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_CENTER ); + m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_CENTER ); + m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_CENTER ); m_gal->SetFontBold( false ); m_gal->SetFontItalic( false ); m_gal->SetFontUnderlined( false ); @@ -1568,7 +1568,7 @@ void PCB_PAINTER::draw( const PCB_TEXT* aText, int aLayer ) m_gal->SetIsFill( false ); m_gal->SetIsStroke( true ); m_gal->SetTextAttributes( aText ); - m_gal->StrokeText( shownText, position, aText->GetTextAngleRadians() ); + m_gal->StrokeText( shownText, position, aText->GetTextAngle().AsRadians() ); } @@ -1592,7 +1592,7 @@ void PCB_PAINTER::draw( const FP_TEXT* aText, int aLayer ) m_gal->SetIsFill( false ); m_gal->SetIsStroke( true ); m_gal->SetTextAttributes( aText ); - m_gal->StrokeText( shownText, position, aText->GetDrawRotationRadians() ); + m_gal->StrokeText( shownText, position, aText->GetDrawRotation().AsRadians() ); // Draw the umbilical line if( aText->IsSelected() ) @@ -1686,8 +1686,8 @@ void PCB_PAINTER::draw( const PCB_GROUP* aGroup, int aLayer ) m_gal->SetFontItalic( true ); m_gal->SetFontUnderlined( false ); m_gal->SetTextMirrored( m_gal->IsFlippedX() ); - m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_CENTER ); - m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_BOTTOM ); + m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_CENTER ); + m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_BOTTOM ); m_gal->SetIsFill( false ); m_gal->SetGlyphSize( VECTOR2D( textSize, textSize ) ); m_gal->SetLineWidth( penWidth ); @@ -1833,7 +1833,7 @@ void PCB_PAINTER::draw( const PCB_DIMENSION_BASE* aDimension, int aLayer ) m_gal->SetLineWidth( getLineThickness( text.GetEffectiveTextPenWidth() ) ); m_gal->SetTextAttributes( &text ); - m_gal->StrokeText( text.GetShownText(), position, text.GetTextAngleRadians() ); + m_gal->StrokeText( text.GetShownText(), position, text.GetTextAngle().AsRadians() ); } diff --git a/pcbnew/pcb_text.cpp b/pcbnew/pcb_text.cpp index d53cab2e282..64044c02eec 100644 --- a/pcbnew/pcb_text.cpp +++ b/pcbnew/pcb_text.cpp @@ -107,6 +107,12 @@ void PCB_TEXT::SetTextAngle( double aAngle ) } +void PCB_TEXT::SetTextAngle( const EDA_ANGLE& aAngle ) +{ + EDA_TEXT::SetTextAngle( aAngle ); +} + + void PCB_TEXT::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector& aList ) { EDA_UNITS units = aFrame->GetUserUnits(); @@ -121,7 +127,7 @@ void PCB_TEXT::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vectorGetCopperLayerCount() ) ); diff --git a/pcbnew/pcb_text.h b/pcbnew/pcb_text.h index 288a54b58c2..c2f8f6fd6c9 100644 --- a/pcbnew/pcb_text.h +++ b/pcbnew/pcb_text.h @@ -89,6 +89,7 @@ class PCB_TEXT : public BOARD_ITEM, public EDA_TEXT } void SetTextAngle( double aAngle ) override; + void SetTextAngle( const EDA_ANGLE& aAngle ); void Rotate( const wxPoint& aRotCentre, double aAngle ) override; diff --git a/pcbnew/plot_brditems_plotter.cpp b/pcbnew/plot_brditems_plotter.cpp index 1b395e06cb3..2055dac31c2 100644 --- a/pcbnew/plot_brditems_plotter.cpp +++ b/pcbnew/plot_brditems_plotter.cpp @@ -389,7 +389,6 @@ void BRDITEMS_PLOTTER::PlotFootprintTextItem( const FP_TEXT* aTextMod, const COL // calculate some text parameters : wxSize size = aTextMod->GetTextSize(); wxPoint pos = aTextMod->GetTextPos(); - double orient = aTextMod->GetDrawRotation(); int thickness = aTextMod->GetEffectiveTextPenWidth(); if( aTextMod->IsMirrored() ) @@ -412,7 +411,7 @@ void BRDITEMS_PLOTTER::PlotFootprintTextItem( const FP_TEXT* aTextMod, const COL m_plotter->SetCurrentLineWidth( thickness ); - m_plotter->Text( pos, aColor, aTextMod->GetShownText(), orient, size, + m_plotter->Text( pos, aColor, aTextMod->GetShownText(), aTextMod->GetDrawRotation(), size, aTextMod->GetHorizJustify(), aTextMod->GetVertJustify(), thickness, aTextMod->IsItalic(), allow_bold, false, &gbr_metadata ); } @@ -757,7 +756,6 @@ void BRDITEMS_PLOTTER::PlotPcbText( const PCB_TEXT* aText ) wxSize size = aText->GetTextSize(); wxPoint pos = aText->GetTextPos(); - double orient = aText->GetTextAngle(); int thickness = aText->GetEffectiveTextPenWidth(); if( aText->IsMirrored() ) @@ -783,16 +781,16 @@ void BRDITEMS_PLOTTER::PlotPcbText( const PCB_TEXT* aText ) for( unsigned ii = 0; ii < strings_list.Count(); ii++ ) { wxString& txt = strings_list.Item( ii ); - m_plotter->Text( positions[ii], color, txt, orient, size, aText->GetHorizJustify(), - aText->GetVertJustify(), thickness, aText->IsItalic(), - allow_bold, false, &gbr_metadata ); + m_plotter->Text( positions[ii], color, txt, aText->GetTextAngle(), size, + aText->GetHorizJustify(), aText->GetVertJustify(), thickness, + aText->IsItalic(), allow_bold, false, &gbr_metadata ); } } else { - m_plotter->Text( pos, color, shownText, orient, size, aText->GetHorizJustify(), - aText->GetVertJustify(), thickness, aText->IsItalic(), allow_bold, - false, &gbr_metadata ); + m_plotter->Text( pos, color, shownText, aText->GetTextAngle(), size, + aText->GetHorizJustify(), aText->GetVertJustify(), thickness, + aText->IsItalic(), allow_bold, false, &gbr_metadata ); } } diff --git a/pcbnew/plugins/altium/altium_pcb.cpp b/pcbnew/plugins/altium/altium_pcb.cpp index 7c1516ed97d..a5fb22f60de 100644 --- a/pcbnew/plugins/altium/altium_pcb.cpp +++ b/pcbnew/plugins/altium/altium_pcb.cpp @@ -1228,12 +1228,12 @@ void ALTIUM_PCB::HelperParseDimensions6Radial(const ADIMENSION6 &aElem) // It's unclear exactly how Altium figures it's text positioning, but this gets us reasonably // close. - dimension->Text().SetVertJustify( EDA_TEXT_VJUSTIFY_T::GR_TEXT_VJUSTIFY_BOTTOM ); - dimension->Text().SetHorizJustify( EDA_TEXT_HJUSTIFY_T::GR_TEXT_HJUSTIFY_LEFT ); + dimension->Text().SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM ); + dimension->Text().SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); int yAdjust = dimension->Text().GetCenter().y - dimension->Text().GetPosition().y; dimension->Text().Move( wxPoint( 0, yAdjust + aElem.textgap ) ); - dimension->Text().SetVertJustify( EDA_TEXT_VJUSTIFY_T::GR_TEXT_VJUSTIFY_CENTER ); + dimension->Text().SetVertJustify( GR_TEXT_V_ALIGN_CENTER ); } @@ -1309,8 +1309,8 @@ void ALTIUM_PCB::HelperParseDimensions6Leader( const ADIMENSION6& aElem ) text->SetLayer( klayer ); text->SetTextSize( wxSize( aElem.textheight, aElem.textheight ) ); // TODO: parse text width text->SetTextThickness( aElem.textlinewidth ); - text->SetHorizJustify( EDA_TEXT_HJUSTIFY_T::GR_TEXT_HJUSTIFY_LEFT ); - text->SetVertJustify( EDA_TEXT_VJUSTIFY_T::GR_TEXT_VJUSTIFY_BOTTOM ); + text->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); + text->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM ); } @@ -2751,7 +2751,7 @@ void ALTIUM_PCB::ParseTexts6Data( const CFB::CompoundFileReader& aReader, FOOTPRINT* parentFootprint = static_cast( fpText->GetParent() ); double orientation = parentFootprint->GetOrientation(); - fpText->SetTextAngle( fpText->GetTextAngle() - orientation ); + fpText->SetTextAngle( fpText->GetTextAngle().AsTenthsOfADegree() - orientation ); fpText->SetLocalCoord(); } } @@ -2785,8 +2785,8 @@ void ALTIUM_PCB::ParseTexts6Data( const CFB::CompoundFileReader& aReader, if( elem.isDesignator || elem.isComment ) // That's just a bold assumption { - tx->SetHorizJustify( EDA_TEXT_HJUSTIFY_T::GR_TEXT_HJUSTIFY_LEFT ); - tx->SetVertJustify( EDA_TEXT_VJUSTIFY_T::GR_TEXT_VJUSTIFY_BOTTOM ); + tx->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); + tx->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM ); } else { @@ -2795,17 +2795,17 @@ void ALTIUM_PCB::ParseTexts6Data( const CFB::CompoundFileReader& aReader, case ALTIUM_TEXT_POSITION::LEFT_TOP: case ALTIUM_TEXT_POSITION::LEFT_CENTER: case ALTIUM_TEXT_POSITION::LEFT_BOTTOM: - tx->SetHorizJustify( EDA_TEXT_HJUSTIFY_T::GR_TEXT_HJUSTIFY_LEFT ); + tx->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); break; case ALTIUM_TEXT_POSITION::CENTER_TOP: case ALTIUM_TEXT_POSITION::CENTER_CENTER: case ALTIUM_TEXT_POSITION::CENTER_BOTTOM: - tx->SetHorizJustify( EDA_TEXT_HJUSTIFY_T::GR_TEXT_HJUSTIFY_CENTER ); + tx->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER ); break; case ALTIUM_TEXT_POSITION::RIGHT_TOP: case ALTIUM_TEXT_POSITION::RIGHT_CENTER: case ALTIUM_TEXT_POSITION::RIGHT_BOTTOM: - tx->SetHorizJustify( EDA_TEXT_HJUSTIFY_T::GR_TEXT_HJUSTIFY_RIGHT ); + tx->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); break; default: wxLogError( "Unexpected horizontal Text Position. This should never happen." ); @@ -2817,17 +2817,17 @@ void ALTIUM_PCB::ParseTexts6Data( const CFB::CompoundFileReader& aReader, case ALTIUM_TEXT_POSITION::LEFT_TOP: case ALTIUM_TEXT_POSITION::CENTER_TOP: case ALTIUM_TEXT_POSITION::RIGHT_TOP: - tx->SetVertJustify( EDA_TEXT_VJUSTIFY_T::GR_TEXT_VJUSTIFY_TOP ); + tx->SetVertJustify( GR_TEXT_V_ALIGN_TOP ); break; case ALTIUM_TEXT_POSITION::LEFT_CENTER: case ALTIUM_TEXT_POSITION::CENTER_CENTER: case ALTIUM_TEXT_POSITION::RIGHT_CENTER: - tx->SetVertJustify( EDA_TEXT_VJUSTIFY_T::GR_TEXT_VJUSTIFY_CENTER ); + tx->SetVertJustify( GR_TEXT_V_ALIGN_CENTER ); break; case ALTIUM_TEXT_POSITION::LEFT_BOTTOM: case ALTIUM_TEXT_POSITION::CENTER_BOTTOM: case ALTIUM_TEXT_POSITION::RIGHT_BOTTOM: - tx->SetVertJustify( EDA_TEXT_VJUSTIFY_T::GR_TEXT_VJUSTIFY_BOTTOM ); + tx->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM ); break; default: wxLogError( "Unexpected vertical text position. This should never happen." ); diff --git a/pcbnew/plugins/cadstar/cadstar_pcb_archive_loader.cpp b/pcbnew/plugins/cadstar/cadstar_pcb_archive_loader.cpp index f3c9b86864c..f138aa057df 100644 --- a/pcbnew/plugins/cadstar/cadstar_pcb_archive_loader.cpp +++ b/pcbnew/plugins/cadstar/cadstar_pcb_archive_loader.cpp @@ -1552,9 +1552,9 @@ void CADSTAR_PCB_ARCHIVE_LOADER::loadDimensions() leaderDim->SetUnitsFormat( DIM_UNITS_FORMAT::NO_SUFFIX ); if( orientX == 1 ) - leaderDim->Text().SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); + leaderDim->Text().SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); else - leaderDim->Text().SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); + leaderDim->Text().SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); leaderDim->SetExtensionOffset( 0 ); } @@ -2547,48 +2547,48 @@ void CADSTAR_PCB_ARCHIVE_LOADER::drawCadstarText( const TEXT& aCadstarText, { case ALIGNMENT::NO_ALIGNMENT: // Default for Single line text is Bottom Left case ALIGNMENT::BOTTOMLEFT: - txt->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); - txt->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); + txt->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM ); + txt->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); break; case ALIGNMENT::BOTTOMCENTER: - txt->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); - txt->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER ); + txt->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM ); + txt->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER ); break; case ALIGNMENT::BOTTOMRIGHT: - txt->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); - txt->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); + txt->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM ); + txt->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); break; case ALIGNMENT::CENTERLEFT: - txt->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); - txt->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); + txt->SetVertJustify( GR_TEXT_V_ALIGN_CENTER ); + txt->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); break; case ALIGNMENT::CENTERCENTER: - txt->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); - txt->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER ); + txt->SetVertJustify( GR_TEXT_V_ALIGN_CENTER ); + txt->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER ); break; case ALIGNMENT::CENTERRIGHT: - txt->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); - txt->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); + txt->SetVertJustify( GR_TEXT_V_ALIGN_CENTER ); + txt->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); break; case ALIGNMENT::TOPLEFT: - txt->SetVertJustify( GR_TEXT_VJUSTIFY_TOP ); - txt->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); + txt->SetVertJustify( GR_TEXT_V_ALIGN_TOP ); + txt->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); break; case ALIGNMENT::TOPCENTER: - txt->SetVertJustify( GR_TEXT_VJUSTIFY_TOP ); - txt->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER ); + txt->SetVertJustify( GR_TEXT_V_ALIGN_TOP ); + txt->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER ); break; case ALIGNMENT::TOPRIGHT: - txt->SetVertJustify( GR_TEXT_VJUSTIFY_TOP ); - txt->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); + txt->SetVertJustify( GR_TEXT_V_ALIGN_TOP ); + txt->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); break; default: @@ -3270,48 +3270,48 @@ void CADSTAR_PCB_ARCHIVE_LOADER::addAttribute( const ATTRIBUTE_LOCATION& aCadsta FixTextPositionNoAlignment( txt ); KI_FALLTHROUGH; case ALIGNMENT::BOTTOMLEFT: - txt->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); - txt->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); + txt->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM ); + txt->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); break; case ALIGNMENT::BOTTOMCENTER: - txt->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); - txt->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER ); + txt->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM ); + txt->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER ); break; case ALIGNMENT::BOTTOMRIGHT: - txt->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); - txt->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); + txt->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM ); + txt->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); break; case ALIGNMENT::CENTERLEFT: - txt->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); - txt->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); + txt->SetVertJustify( GR_TEXT_V_ALIGN_CENTER ); + txt->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); break; case ALIGNMENT::CENTERCENTER: - txt->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); - txt->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER ); + txt->SetVertJustify( GR_TEXT_V_ALIGN_CENTER ); + txt->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER ); break; case ALIGNMENT::CENTERRIGHT: - txt->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); - txt->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); + txt->SetVertJustify( GR_TEXT_V_ALIGN_CENTER ); + txt->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); break; case ALIGNMENT::TOPLEFT: - txt->SetVertJustify( GR_TEXT_VJUSTIFY_TOP ); - txt->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); + txt->SetVertJustify( GR_TEXT_V_ALIGN_TOP ); + txt->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); break; case ALIGNMENT::TOPCENTER: - txt->SetVertJustify( GR_TEXT_VJUSTIFY_TOP ); - txt->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER ); + txt->SetVertJustify( GR_TEXT_V_ALIGN_TOP ); + txt->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER ); break; case ALIGNMENT::TOPRIGHT: - txt->SetVertJustify( GR_TEXT_VJUSTIFY_TOP ); - txt->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); + txt->SetVertJustify( GR_TEXT_V_ALIGN_TOP ); + txt->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); break; default: diff --git a/pcbnew/plugins/eagle/eagle_plugin.cpp b/pcbnew/plugins/eagle/eagle_plugin.cpp index cf81b802b2a..aeefc9c623f 100644 --- a/pcbnew/plugins/eagle/eagle_plugin.cpp +++ b/pcbnew/plugins/eagle/eagle_plugin.cpp @@ -808,48 +808,48 @@ void EAGLE_PLUGIN::loadPlain( wxXmlNode* aGraphics ) switch( align ) { case ETEXT::CENTER: - pcbtxt->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER ); - pcbtxt->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); + pcbtxt->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER ); + pcbtxt->SetVertJustify( GR_TEXT_V_ALIGN_CENTER ); break; case ETEXT::CENTER_LEFT: - pcbtxt->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); - pcbtxt->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); + pcbtxt->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); + pcbtxt->SetVertJustify( GR_TEXT_V_ALIGN_CENTER ); break; case ETEXT::CENTER_RIGHT: - pcbtxt->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); - pcbtxt->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); + pcbtxt->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); + pcbtxt->SetVertJustify( GR_TEXT_V_ALIGN_CENTER ); break; case ETEXT::TOP_CENTER: - pcbtxt->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER ); - pcbtxt->SetVertJustify( GR_TEXT_VJUSTIFY_TOP ); + pcbtxt->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER ); + pcbtxt->SetVertJustify( GR_TEXT_V_ALIGN_TOP ); break; case ETEXT::TOP_LEFT: - pcbtxt->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); - pcbtxt->SetVertJustify( GR_TEXT_VJUSTIFY_TOP ); + pcbtxt->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); + pcbtxt->SetVertJustify( GR_TEXT_V_ALIGN_TOP ); break; case ETEXT::TOP_RIGHT: - pcbtxt->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); - pcbtxt->SetVertJustify( GR_TEXT_VJUSTIFY_TOP ); + pcbtxt->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); + pcbtxt->SetVertJustify( GR_TEXT_V_ALIGN_TOP ); break; case ETEXT::BOTTOM_CENTER: - pcbtxt->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER ); - pcbtxt->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); + pcbtxt->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER ); + pcbtxt->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM ); break; case ETEXT::BOTTOM_LEFT: - pcbtxt->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); - pcbtxt->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); + pcbtxt->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); + pcbtxt->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM ); break; case ETEXT::BOTTOM_RIGHT: - pcbtxt->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); - pcbtxt->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); + pcbtxt->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); + pcbtxt->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM ); break; } } @@ -1631,48 +1631,48 @@ void EAGLE_PLUGIN::orientFPText( FOOTPRINT* aFootprint, const EELEMENT& e, FP_TE switch( align ) { case ETEXT::TOP_RIGHT: - aFPText->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); - aFPText->SetVertJustify( GR_TEXT_VJUSTIFY_TOP ); + aFPText->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); + aFPText->SetVertJustify( GR_TEXT_V_ALIGN_TOP ); break; case ETEXT::BOTTOM_LEFT: - aFPText->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); - aFPText->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); + aFPText->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); + aFPText->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM ); break; case ETEXT::TOP_LEFT: - aFPText->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); - aFPText->SetVertJustify( GR_TEXT_VJUSTIFY_TOP ); + aFPText->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); + aFPText->SetVertJustify( GR_TEXT_V_ALIGN_TOP ); break; case ETEXT::BOTTOM_RIGHT: - aFPText->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); - aFPText->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); + aFPText->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); + aFPText->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM ); break; case ETEXT::TOP_CENTER: - aFPText->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER ); - aFPText->SetVertJustify( GR_TEXT_VJUSTIFY_TOP ); + aFPText->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER ); + aFPText->SetVertJustify( GR_TEXT_V_ALIGN_TOP ); break; case ETEXT::BOTTOM_CENTER: - aFPText->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER ); - aFPText->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); + aFPText->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER ); + aFPText->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM ); break; case ETEXT::CENTER: - aFPText->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER ); - aFPText->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); + aFPText->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER ); + aFPText->SetVertJustify( GR_TEXT_V_ALIGN_CENTER ); break; case ETEXT::CENTER_LEFT: - aFPText->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); - aFPText->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); + aFPText->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); + aFPText->SetVertJustify( GR_TEXT_V_ALIGN_CENTER ); break; case ETEXT::CENTER_RIGHT: - aFPText->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); - aFPText->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); + aFPText->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); + aFPText->SetVertJustify( GR_TEXT_V_ALIGN_CENTER ); break; default: @@ -1683,15 +1683,15 @@ void EAGLE_PLUGIN::orientFPText( FOOTPRINT* aFootprint, const EELEMENT& e, FP_TE { // Part is not smash so use Lib default for NAME/VALUE // the text is per the original // package, sans . - double degrees = ( aFPText->GetTextAngle() + aFootprint->GetOrientation() ) / 10; + double degrees = aFPText->GetTextAngle().AsDegrees() + aFootprint->GetOrientation() / 10.0; // @todo there are a few more cases than these to contend with: if( ( !aFPText->IsMirrored() && ( abs( degrees ) == 180 || abs( degrees ) == 270 ) ) || ( aFPText->IsMirrored() && ( degrees == 360 ) ) ) { // ETEXT::TOP_RIGHT: - aFPText->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); - aFPText->SetVertJustify( GR_TEXT_VJUSTIFY_TOP ); + aFPText->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); + aFPText->SetVertJustify( GR_TEXT_V_ALIGN_TOP ); } } } @@ -1984,48 +1984,48 @@ void EAGLE_PLUGIN::packageText( FOOTPRINT* aFootprint, wxXmlNode* aTree ) const switch( align ) { case ETEXT::CENTER: - txt->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER ); - txt->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); + txt->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER ); + txt->SetVertJustify( GR_TEXT_V_ALIGN_CENTER ); break; case ETEXT::CENTER_LEFT: - txt->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); - txt->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); + txt->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); + txt->SetVertJustify( GR_TEXT_V_ALIGN_CENTER ); break; case ETEXT::CENTER_RIGHT: - txt->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); - txt->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); + txt->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); + txt->SetVertJustify( GR_TEXT_V_ALIGN_CENTER ); break; case ETEXT::TOP_CENTER: - txt->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER ); - txt->SetVertJustify( GR_TEXT_VJUSTIFY_TOP ); + txt->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER ); + txt->SetVertJustify( GR_TEXT_V_ALIGN_TOP ); break; case ETEXT::TOP_LEFT: - txt->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); - txt->SetVertJustify( GR_TEXT_VJUSTIFY_TOP ); + txt->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); + txt->SetVertJustify( GR_TEXT_V_ALIGN_TOP ); break; case ETEXT::TOP_RIGHT: - txt->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); - txt->SetVertJustify( GR_TEXT_VJUSTIFY_TOP ); + txt->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); + txt->SetVertJustify( GR_TEXT_V_ALIGN_TOP ); break; case ETEXT::BOTTOM_CENTER: - txt->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER ); - txt->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); + txt->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER ); + txt->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM ); break; case ETEXT::BOTTOM_LEFT: - txt->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); - txt->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); + txt->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); + txt->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM ); break; case ETEXT::BOTTOM_RIGHT: - txt->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); - txt->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); + txt->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); + txt->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM ); break; } } diff --git a/pcbnew/plugins/fabmaster/import_fabmaster.cpp b/pcbnew/plugins/fabmaster/import_fabmaster.cpp index b109d420589..55180d6b4d9 100644 --- a/pcbnew/plugins/fabmaster/import_fabmaster.cpp +++ b/pcbnew/plugins/fabmaster/import_fabmaster.cpp @@ -1110,11 +1110,11 @@ FABMASTER::GRAPHIC_TEXT* FABMASTER::processText( const FABMASTER::GRAPHIC_DATA& new_text->mirror = ( aData.graphic_data4 == "YES" ); if( aData.graphic_data5 == "RIGHT" ) - new_text->orient = GR_TEXT_HJUSTIFY_RIGHT; + new_text->orient = GR_TEXT_H_ALIGN_RIGHT; else if( aData.graphic_data5 == "CENTER" ) - new_text->orient = GR_TEXT_HJUSTIFY_CENTER; + new_text->orient = GR_TEXT_H_ALIGN_CENTER; else - new_text->orient = GR_TEXT_HJUSTIFY_LEFT; + new_text->orient = GR_TEXT_H_ALIGN_LEFT; std::vector toks = split( aData.graphic_data6, " \t" ); diff --git a/pcbnew/plugins/fabmaster/import_fabmaster.h b/pcbnew/plugins/fabmaster/import_fabmaster.h index 371c4c4f764..0e1a791b427 100644 --- a/pcbnew/plugins/fabmaster/import_fabmaster.h +++ b/pcbnew/plugins/fabmaster/import_fabmaster.h @@ -266,7 +266,7 @@ class FABMASTER { double rotation; ///SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); + aText->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); break; case T_right: - aText->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); + aText->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); break; case T_top: - aText->SetVertJustify( GR_TEXT_VJUSTIFY_TOP ); + aText->SetVertJustify( GR_TEXT_V_ALIGN_TOP ); break; case T_bottom: - aText->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); + aText->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM ); break; case T_mirror: @@ -3492,7 +3492,7 @@ FOOTPRINT* PCB_PARSER::parseFOOTPRINT_unchecked( wxArrayString* aInitialComments { FP_TEXT* text = parseFP_TEXT(); text->SetParent( footprint.get() ); - double orientation = text->GetTextAngle(); + double orientation = text->GetTextAngle().AsTenthsOfADegree(); orientation -= footprint->GetOrientation(); text->SetTextAngle( orientation ); text->SetDrawCoord(); diff --git a/pcbnew/plugins/kicad/pcb_plugin.cpp b/pcbnew/plugins/kicad/pcb_plugin.cpp index c9a1edfa080..9e56414755c 100644 --- a/pcbnew/plugins/kicad/pcb_plugin.cpp +++ b/pcbnew/plugins/kicad/pcb_plugin.cpp @@ -1770,8 +1770,8 @@ void PCB_PLUGIN::format( const PCB_TEXT* aText, int aNestLevel ) const m_out->Quotew( aText->GetText() ).c_str(), FormatInternalUnits( aText->GetTextPos() ).c_str() ); - if( aText->GetTextAngle() != 0.0 ) - m_out->Print( 0, " %s", FormatAngle( aText->GetTextAngle() ).c_str() ); + if( aText->GetTextAngle() != EDA_ANGLE::ANGLE_0 ) + m_out->Print( 0, " %s", FormatAngle( aText->GetTextAngle().AsTenthsOfADegree() ).c_str() ); m_out->Print( 0, ")" ); @@ -1838,8 +1838,8 @@ void PCB_PLUGIN::format( const FP_TEXT* aText, int aNestLevel ) const // Due to Pcbnew history, fp_text angle is saved as an absolute on screen angle, // but internally the angle is held relative to its parent footprint. parent // may be NULL when saving a footprint outside a BOARD. - double orient = aText->GetTextAngle(); - FOOTPRINT* parent = (FOOTPRINT*) aText->GetParent(); + double orient = aText->GetTextAngle().AsTenthsOfADegree(); + FOOTPRINT* parent = static_cast( aText->GetParent() ); if( parent ) { diff --git a/pcbnew/plugins/legacy/legacy_plugin.cpp b/pcbnew/plugins/legacy/legacy_plugin.cpp index 82525925c6d..d188fece540 100644 --- a/pcbnew/plugins/legacy/legacy_plugin.cpp +++ b/pcbnew/plugins/legacy/legacy_plugin.cpp @@ -254,26 +254,26 @@ static inline char* ReadLine( LINE_READER* rdr, const char* caller ) #endif -static EDA_TEXT_HJUSTIFY_T horizJustify( const char* horizontal ) +static GR_TEXT_H_ALIGN_T horizJustify( const char* horizontal ) { if( !strcmp( "L", horizontal ) ) - return GR_TEXT_HJUSTIFY_LEFT; + return GR_TEXT_H_ALIGN_LEFT; if( !strcmp( "R", horizontal ) ) - return GR_TEXT_HJUSTIFY_RIGHT; + return GR_TEXT_H_ALIGN_RIGHT; - return GR_TEXT_HJUSTIFY_CENTER; + return GR_TEXT_H_ALIGN_CENTER; } -static EDA_TEXT_VJUSTIFY_T vertJustify( const char* vertical ) +static GR_TEXT_V_ALIGN_T vertJustify( const char* vertical ) { if( !strcmp( "T", vertical ) ) - return GR_TEXT_VJUSTIFY_TOP; + return GR_TEXT_V_ALIGN_TOP; if( !strcmp( "B", vertical ) ) - return GR_TEXT_VJUSTIFY_BOTTOM; + return GR_TEXT_V_ALIGN_BOTTOM; - return GR_TEXT_VJUSTIFY_CENTER; + return GR_TEXT_V_ALIGN_CENTER; } @@ -2047,7 +2047,7 @@ void LEGACY_PLUGIN::loadPCB_TEXT() else { // boom, somebody changed a constructor, I was relying on this: - wxASSERT( pcbtxt->GetHorizJustify() == GR_TEXT_HJUSTIFY_CENTER ); + wxASSERT( pcbtxt->GetHorizJustify() == GR_TEXT_H_ALIGN_CENTER ); } if( vJustify ) diff --git a/pcbnew/plugins/pcad/pcad2kicad_common.cpp b/pcbnew/plugins/pcad/pcad2kicad_common.cpp index 564371bd629..1ce935759c1 100644 --- a/pcbnew/plugins/pcad/pcad2kicad_common.cpp +++ b/pcbnew/plugins/pcad/pcad2kicad_common.cpp @@ -468,40 +468,40 @@ void SetTextJustify( EDA_TEXT* aText, TTEXT_JUSTIFY aJustify ) switch( aJustify ) { case LowerLeft: - aText->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); - aText->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); + aText->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM ); + aText->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); break; case LowerCenter: - aText->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); - aText->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER ); + aText->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM ); + aText->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER ); break; case LowerRight: - aText->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); - aText->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); + aText->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM ); + aText->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); break; case UpperLeft: - aText->SetVertJustify( GR_TEXT_VJUSTIFY_TOP ); - aText->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); + aText->SetVertJustify( GR_TEXT_V_ALIGN_TOP ); + aText->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); break; case UpperCenter: - aText->SetVertJustify( GR_TEXT_VJUSTIFY_TOP ); - aText->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER ); + aText->SetVertJustify( GR_TEXT_V_ALIGN_TOP ); + aText->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER ); break; case UpperRight: - aText->SetVertJustify( GR_TEXT_VJUSTIFY_TOP ); - aText->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); + aText->SetVertJustify( GR_TEXT_V_ALIGN_TOP ); + aText->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); break; case Left: - aText->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); - aText->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); + aText->SetVertJustify( GR_TEXT_V_ALIGN_CENTER ); + aText->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); break; case Center: - aText->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); - aText->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER ); + aText->SetVertJustify( GR_TEXT_V_ALIGN_CENTER ); + aText->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER ); break; case Right: - aText->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); - aText->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); + aText->SetVertJustify( GR_TEXT_V_ALIGN_CENTER ); + aText->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); break; } } diff --git a/pcbnew/tools/drawing_stackup_table_tool.cpp b/pcbnew/tools/drawing_stackup_table_tool.cpp index 28a82e5e715..b3c255107f8 100644 --- a/pcbnew/tools/drawing_stackup_table_tool.cpp +++ b/pcbnew/tools/drawing_stackup_table_tool.cpp @@ -224,8 +224,8 @@ std::vector DRAWING_TOOL::DrawSpecificationStackup( const wxPoint& headStyle->SetItalic( false ); headStyle->SetTextPos( wxPoint( 0, 0 ) ); headStyle->SetText( "Layer" ); - headStyle->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); - headStyle->SetVertJustify( GR_TEXT_VJUSTIFY_TOP ); + headStyle->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); + headStyle->SetVertJustify( GR_TEXT_V_ALIGN_TOP ); // Style : data PCB_TEXT* dataStyle = new PCB_TEXT( static_cast( m_frame->GetModel() ) ); @@ -235,8 +235,8 @@ std::vector DRAWING_TOOL::DrawSpecificationStackup( const wxPoint& dataStyle->SetItalic( false ); dataStyle->SetTextPos( wxPoint( 0, 0 ) ); dataStyle->SetText( "Layer" ); - dataStyle->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); - dataStyle->SetVertJustify( GR_TEXT_VJUSTIFY_TOP ); + dataStyle->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); + dataStyle->SetVertJustify( GR_TEXT_V_ALIGN_TOP ); //Get Layer names BOARD_DESIGN_SETTINGS& dsnSettings = m_frame->GetDesignSettings(); @@ -388,8 +388,8 @@ std::vector DRAWING_TOOL::DrawBoardCharacteristics( const wxPoint& headStyle->SetTextThickness( Millimeter2iu( 0.4 ) ); headStyle->SetItalic( false ); headStyle->SetTextPos( wxPoint( 0, 0 ) ); - headStyle->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); - headStyle->SetVertJustify( GR_TEXT_VJUSTIFY_TOP ); + headStyle->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); + headStyle->SetVertJustify( GR_TEXT_V_ALIGN_TOP ); // Style : Data PCB_TEXT* dataStyle = new PCB_TEXT( static_cast( m_frame->GetModel() ) ); @@ -398,8 +398,8 @@ std::vector DRAWING_TOOL::DrawBoardCharacteristics( const wxPoint& dataStyle->SetTextThickness( Millimeter2iu( 0.2 ) ); dataStyle->SetItalic( false ); dataStyle->SetTextPos( wxPoint( 0, 0 ) ); - dataStyle->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); - dataStyle->SetVertJustify( GR_TEXT_VJUSTIFY_TOP ); + dataStyle->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); + dataStyle->SetVertJustify( GR_TEXT_V_ALIGN_TOP ); PCB_TEXT* t; diff --git a/pcbnew/tools/pcb_control.cpp b/pcbnew/tools/pcb_control.cpp index 4c3a9d21d82..15f3c632a8e 100644 --- a/pcbnew/tools/pcb_control.cpp +++ b/pcbnew/tools/pcb_control.cpp @@ -675,7 +675,8 @@ static void pasteFootprintItemsToFootprintEditor( FOOTPRINT* aClipFootprint, BOA if( text->GetType() != FP_TEXT::TEXT_is_DIVERS ) continue; - text->SetTextAngle( text->GetTextAngle() + aClipFootprint->GetOrientation() ); + text->SetTextAngle( text->GetTextAngle().AsTenthsOfADegree() + + aClipFootprint->GetOrientation() ); text->SetParent( nullptr ); text->SetLocalCoord(); @@ -785,7 +786,7 @@ int PCB_CONTROL::Paste( const TOOL_EVENT& aEvent ) // Convert to PCB_FP_TEXT_T FP_TEXT* pastedTextItem = new FP_TEXT( editorFootprint ); static_cast( pastedTextItem )->SwapText( *clipTextItem ); - static_cast( pastedTextItem )->SwapEffects( *clipTextItem ); + static_cast( pastedTextItem )->SwapAttributes( *clipTextItem ); pastedTextItem->SetParent( editorFootprint ); pastedItems.push_back( pastedTextItem );