From 6e800bddae16c74b4a3182b37f05509b14875a78 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Mon, 13 Apr 2020 20:55:27 +0100 Subject: [PATCH] Rationalize penWidth processing as first step in removing some globals. --- .../3d_canvas/create_3Dgraphic_brd_items.cpp | 22 ++-- common/eda_text.cpp | 47 +++++-- common/gr_text.cpp | 23 +--- common/page_layout/ws_data_item.cpp | 2 +- common/page_layout/ws_draw_item.cpp | 2 +- common/page_layout/ws_painter.cpp | 2 +- common/painter.cpp | 3 +- common/plotters/common_plot_functions.cpp | 4 +- eeschema/dialogs/dialog_edit_label.cpp | 4 +- eeschema/edit_label.cpp | 2 +- eeschema/lib_field.cpp | 12 +- eeschema/lib_field.h | 4 +- eeschema/lib_text.cpp | 20 +-- eeschema/lib_text.h | 4 +- eeschema/sch_eagle_plugin.cpp | 2 +- eeschema/sch_field.cpp | 15 +-- eeschema/sch_legacy_plugin.cpp | 14 +-- eeschema/sch_painter.cpp | 5 +- eeschema/sch_sexpr_parser.cpp | 2 +- eeschema/sch_text.cpp | 61 ++------- include/eda_text.h | 41 +++--- include/painter.h | 86 +++++-------- include/preview_items/draw_context.h | 1 + include/ws_draw_item.h | 6 +- include/ws_painter.h | 1 + pcbnew/altium2kicadpcb_plugin/altium_pcb.cpp | 6 +- ...board_items_to_polygon_shape_transform.cpp | 118 +++++------------- pcbnew/class_dimension.cpp | 4 +- pcbnew/class_module.h | 14 +-- pcbnew/class_pcb_text.cpp | 8 +- pcbnew/class_text_mod.cpp | 14 +-- .../dialog_edit_footprint_for_BoardEditor.cpp | 2 +- .../dialog_edit_footprint_for_fp_editor.cpp | 2 +- .../dialog_global_edit_text_and_graphics.cpp | 4 +- pcbnew/dialogs/dialog_text_properties.cpp | 10 +- pcbnew/drc/drc.cpp | 8 +- pcbnew/eagle_plugin.cpp | 9 +- pcbnew/exporters/export_vrml.cpp | 28 +++-- pcbnew/footprint_libraries_utils.cpp | 4 +- pcbnew/gpcb_plugin.cpp | 4 +- .../import_gfx/graphics_importer_pcbnew.cpp | 2 +- pcbnew/legacy_plugin.cpp | 15 +-- pcbnew/microwave/microwave_footprint.cpp | 4 +- pcbnew/pcad2kicadpcb_plugin/pcb_module.cpp | 10 +- pcbnew/pcad2kicadpcb_plugin/pcb_text.cpp | 2 +- pcbnew/pcb_painter.cpp | 11 +- pcbnew/pcb_parser.cpp | 2 +- pcbnew/plot_brditems_plotter.cpp | 4 +- pcbnew/router/pns_kicad_iface.cpp | 2 +- pcbnew/text_mod_grid_table.cpp | 4 +- pcbnew/tools/drawing_tool.cpp | 6 +- pcbnew/tools/pcb_actions.h | 3 +- pcbnew/tools/pcbnew_control.cpp | 1 - 53 files changed, 261 insertions(+), 425 deletions(-) diff --git a/3d-viewer/3d_canvas/create_3Dgraphic_brd_items.cpp b/3d-viewer/3d_canvas/create_3Dgraphic_brd_items.cpp index f9121d5efe..a6a7299745 100644 --- a/3d-viewer/3d_canvas/create_3Dgraphic_brd_items.cpp +++ b/3d-viewer/3d_canvas/create_3Dgraphic_brd_items.cpp @@ -93,11 +93,13 @@ void BOARD_ADAPTER::AddShapeWithClearanceToContainer( const TEXTE_PCB* aText, s_boardItem = (const BOARD_ITEM *) &aText; s_dstcontainer = aDstContainer; - s_textWidth = aText->GetThickness() + ( 2 * aClearanceValue ); + s_textWidth = aText->GetEffectiveTextPenWidth( nullptr ) + ( 2 * aClearanceValue ); s_biuTo3Dunits = m_biuTo3Dunits; // not actually used, but needed by GRText const COLOR4D dummy_color = COLOR4D::BLACK; + bool forceBold = true; + int penWidth = 0; // force max width for bold if( aText->IsMultilineAllowed() ) { @@ -111,16 +113,16 @@ void BOARD_ADAPTER::AddShapeWithClearanceToContainer( const TEXTE_PCB* aText, { wxString txt = strings_list.Item( ii ); - GRText( NULL, positions[ii], dummy_color, txt, aText->GetTextAngle(), size, - aText->GetHorizJustify(), aText->GetVertJustify(), aText->GetThickness(), - aText->IsItalic(), true, addTextSegmToContainer ); + GRText( nullptr, positions[ii], dummy_color, txt, aText->GetTextAngle(), size, + aText->GetHorizJustify(), aText->GetVertJustify(), penWidth, aText->IsItalic(), + penWidth, addTextSegmToContainer ); } } else { - GRText( NULL, aText->GetTextPos(), dummy_color, aText->GetShownText(), + GRText( nullptr, aText->GetTextPos(), dummy_color, aText->GetShownText(), aText->GetTextAngle(), size, aText->GetHorizJustify(), aText->GetVertJustify(), - aText->GetThickness(), aText->IsItalic(), true, addTextSegmToContainer ); + penWidth, aText->IsItalic(), penWidth, addTextSegmToContainer ); } } @@ -215,15 +217,17 @@ void BOARD_ADAPTER::AddGraphicsShapesWithClearanceToContainer( const MODULE* aMo for( TEXTE_MODULE* text : texts ) { - s_textWidth = text->GetThickness() + ( 2 * aInflateValue ); + s_textWidth = text->GetEffectiveTextPenWidth( nullptr ) + ( 2 * aInflateValue ); wxSize size = text->GetTextSize(); + bool forceBold = true; + int penWidth = 0; // force max width for bold if( text->IsMirrored() ) size.x = -size.x; GRText( NULL, text->GetTextPos(), BLACK, text->GetShownText(), text->GetDrawRotation(), - size, text->GetHorizJustify(), text->GetVertJustify(), text->GetThickness(), - text->IsItalic(), true, addTextSegmToContainer ); + size, text->GetHorizJustify(), text->GetVertJustify(), penWidth, text->IsItalic(), + forceBold, addTextSegmToContainer ); } } diff --git a/common/eda_text.cpp b/common/eda_text.cpp index 7fc6ac5045..fe42b39862 100644 --- a/common/eda_text.cpp +++ b/common/eda_text.cpp @@ -141,6 +141,23 @@ void EDA_TEXT::SwapEffects( EDA_TEXT& aTradingPartner ) } +int EDA_TEXT::GetEffectiveTextPenWidth( RENDER_SETTINGS* aSettings ) const +{ + int width = GetTextPenWidth(); + + if( width == 0 && IsBold() ) + width = GetPenSizeForBold( GetTextWidth() ); + + if( width <= 0 && aSettings ) + width = aSettings->GetDefaultPenWidth(); + + // Clip pen size for small texts: + width = Clamp_Text_PenSize( width, GetTextSize(), IsBold() ); + + return width; +} + + bool EDA_TEXT::Replace( wxFindReplaceData& aSearchData ) { return EDA_ITEM::Replace( aSearchData, m_text ); @@ -181,14 +198,15 @@ int EDA_TEXT::GetInterline() const } -EDA_RECT EDA_TEXT::GetTextBox( int aLine, int aThickness, bool aInvertY, int aMarkupFlags ) const +EDA_RECT EDA_TEXT::GetTextBox( RENDER_SETTINGS* aSettings, int aLine, bool aInvertY ) const { EDA_RECT rect; wxArrayString strings; wxString text = GetShownText(); - int thickness = ( aThickness < 0 ) ? GetThickness() : aThickness; + int thickness = GetEffectiveTextPenWidth( aSettings ); int linecount = 1; bool hasOverBar = false; // true if the first line of text as an overbar + int markupFlags = aSettings ? aSettings->GetTextMarkupFlags() : 0; if( IsMultilineAllowed() ) { @@ -220,7 +238,7 @@ EDA_RECT EDA_TEXT::GetTextBox( int aLine, int aThickness, bool aInvertY, int aMa const auto& font = basic_gal.GetStrokeFont(); VECTOR2D size( GetTextSize() ); double penWidth( thickness ); - int dx = KiROUND( font.ComputeStringBoundaryLimits( text, size, penWidth, aMarkupFlags ).x ); + int dx = KiROUND( font.ComputeStringBoundaryLimits( text, size, penWidth, markupFlags ).x ); int dy = GetInterline(); // Creates bounding box (rectangle) for an horizontal @@ -258,7 +276,7 @@ EDA_RECT EDA_TEXT::GetTextBox( int aLine, int aThickness, bool aInvertY, int aMa for( unsigned ii = 1; ii < strings.GetCount(); ii++ ) { text = strings.Item( ii ); - dx = KiROUND( font.ComputeStringBoundaryLimits( text, size, penWidth, aMarkupFlags ).x ); + dx = KiROUND( font.ComputeStringBoundaryLimits( text, size, penWidth, markupFlags ).x ); textsize.x = std::max( textsize.x, dx ); textsize.y += dy; } @@ -335,7 +353,7 @@ EDA_RECT EDA_TEXT::GetTextBox( int aLine, int aThickness, bool aInvertY, int aMa bool EDA_TEXT::TextHitTest( const wxPoint& aPoint, int aAccuracy ) const { - EDA_RECT rect = GetTextBox( -1 ); // Get the full text area. + EDA_RECT rect = GetTextBox( nullptr ); // JEY TODO: requires RENDER_SETTINGS wxPoint location = aPoint; rect.Inflate( aAccuracy ); @@ -352,9 +370,9 @@ bool EDA_TEXT::TextHitTest( const EDA_RECT& aRect, bool aContains, int aAccuracy rect.Inflate( aAccuracy ); if( aContains ) - return rect.Contains( GetTextBox( -1 ) ); + return rect.Contains( GetTextBox( nullptr ) ); // JEY TODO: requires RENDER_SETTINGS - return rect.Intersects( GetTextBox( -1 ), GetTextAngle() ); + return rect.Intersects( GetTextBox( nullptr ), GetTextAngle() ); // JEY TODO: requires RENDER_SETTINGS } @@ -427,7 +445,7 @@ void EDA_TEXT::printOneLineOfText( wxDC* aDC, const wxPoint& aOffset, COLOR4D aC EDA_DRAW_MODE_T aFillMode, const wxString& aText, const wxPoint &aPos ) { - int width = GetThickness(); + int width = GetEffectiveTextPenWidth( nullptr ); if( aFillMode == SKETCH ) width = -width; @@ -469,7 +487,7 @@ bool EDA_TEXT::IsDefaultFormatting() const && !IsMirrored() && GetHorizJustify() == GR_TEXT_HJUSTIFY_CENTER && GetVertJustify() == GR_TEXT_VJUSTIFY_CENTER - && GetThickness() == 0 + && GetTextPenWidth() == 0 && !IsItalic() && !IsBold() && !IsMultilineAllowed() @@ -492,8 +510,8 @@ void EDA_TEXT::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControl FormatInternalUnits( GetTextHeight() ).c_str(), FormatInternalUnits( GetTextWidth() ).c_str() ); - if( GetThickness() ) - aFormatter->Print( 0, " (thickness %s)", FormatInternalUnits( GetThickness() ).c_str() ); + if( GetTextPenWidth() ) + aFormatter->Print( 0, " (thickness %s)", FormatInternalUnits( GetTextPenWidth() ).c_str() ); if( IsBold() ) aFormatter->Print( 0, " bold" ); @@ -548,6 +566,9 @@ void EDA_TEXT::TransformTextShapeToSegmentList( std::vector& aCornerBuf if( IsMirrored() ) size.x = -size.x; + bool forceBold = true; + int penWidth = 0; // use max-width for bold text + COLOR4D color = COLOR4D::BLACK; // not actually used, but needed by GRText if( IsMultilineAllowed() ) @@ -562,14 +583,14 @@ void EDA_TEXT::TransformTextShapeToSegmentList( std::vector& aCornerBuf { wxString txt = strings_list.Item( ii ); GRText( NULL, positions[ii], color, txt, GetTextAngle(), size, GetHorizJustify(), - GetVertJustify(), GetThickness(), IsItalic(), true, addTextSegmToBuffer, + GetVertJustify(), penWidth, IsItalic(), forceBold, addTextSegmToBuffer, &aCornerBuffer ); } } else { GRText( NULL, GetTextPos(), color, GetText(), GetTextAngle(), size, GetHorizJustify(), - GetVertJustify(), GetThickness(), IsItalic(), true, addTextSegmToBuffer, + GetVertJustify(), penWidth, IsItalic(), forceBold, addTextSegmToBuffer, &aCornerBuffer ); } } diff --git a/common/gr_text.cpp b/common/gr_text.cpp index 9fd571fd51..e9f04d53cf 100644 --- a/common/gr_text.cpp +++ b/common/gr_text.cpp @@ -220,9 +220,7 @@ void GRHaloText( wxDC * aDC, const wxPoint &aPos, const COLOR4D aBgColor, COLOR4 * @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) - * @param aWidth = line width (pen width) (default = 0) - * if width < 0 : draw segments in sketch mode, width = abs(width) - * Use a value min(aSize.x, aSize.y) / 5 for a bold text + * @param aPenWidth = line width (if = 0, use plot default line width) * @param aItalic = true to simulate an italic font * @param aBold = true to use a bold font Useful only with default width value (aWidth = 0) * @param aMultilineAllowed = true to plot text as multiline, otherwise single line @@ -236,29 +234,14 @@ void PLOTTER::Text( const wxPoint& aPos, const wxSize& aSize, enum EDA_TEXT_HJUSTIFY_T aH_justify, enum EDA_TEXT_VJUSTIFY_T aV_justify, - int aWidth, + int aPenWidth, bool aItalic, bool aBold, bool aMultilineAllowed, void* aData ) { - int textPensize = aWidth; - - if( textPensize == 0 && aBold ) // Use default values if aWidth == 0 - textPensize = GetPenSizeForBold( std::min( aSize.x, aSize.y ) ); - - if( textPensize >= 0 ) - textPensize = Clamp_Text_PenSize( aWidth, aSize, aBold ); - else - textPensize = -Clamp_Text_PenSize( -aWidth, aSize, aBold ); - - SetCurrentLineWidth( textPensize, aData ); - SetColor( aColor ); - GRText( NULL, aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify, textPensize, + GRText( NULL, aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify, aPenWidth, aItalic, aBold, nullptr, nullptr, this ); - - if( aWidth != textPensize ) - SetCurrentLineWidth( aWidth, aData ); } diff --git a/common/page_layout/ws_data_item.cpp b/common/page_layout/ws_data_item.cpp index 4c2359bc38..63704135cf 100644 --- a/common/page_layout/ws_data_item.cpp +++ b/common/page_layout/ws_data_item.cpp @@ -714,7 +714,7 @@ void WS_DATA_ITEM_TEXT::SetConstrainedTextSize() dummy.SetVertJustify( m_Vjustify ); dummy.SetTextAngle( m_Orient * 10 ); - EDA_RECT rect = dummy.GetTextBox(); + EDA_RECT rect = dummy.GetTextBox( nullptr ); // JEY TODO: requires RENDER_SETTINGS DSIZE size; size.x = rect.GetWidth() / FSCALE; size.y = rect.GetHeight() / FSCALE; diff --git a/common/page_layout/ws_draw_item.cpp b/common/page_layout/ws_draw_item.cpp index 88698ed8a8..41d5186526 100644 --- a/common/page_layout/ws_draw_item.cpp +++ b/common/page_layout/ws_draw_item.cpp @@ -163,7 +163,7 @@ void WS_DRAW_ITEM_TEXT::PrintWsItem( wxDC* aDC, const wxPoint& aOffset, COLOR4D const EDA_RECT WS_DRAW_ITEM_TEXT::GetBoundingBox() const { - return EDA_TEXT::GetTextBox( -1 ); + return EDA_TEXT::GetTextBox( nullptr ); // JEY TODO: requires RENDER_SETTINGS } diff --git a/common/page_layout/ws_painter.cpp b/common/page_layout/ws_painter.cpp index c74332bfc5..bdddedad56 100644 --- a/common/page_layout/ws_painter.cpp +++ b/common/page_layout/ws_painter.cpp @@ -289,7 +289,7 @@ void KIGFX::WS_PAINTER::draw( const WS_DRAW_ITEM_TEXT* aItem, int aLayer ) const m_gal->Translate( position ); m_gal->Rotate( -aItem->GetTextAngle() * M_PI / 1800.0 ); m_gal->SetStrokeColor( m_renderSettings.GetColor( aItem, aLayer ) ); - m_gal->SetLineWidth( aItem->GetThickness() ); + m_gal->SetLineWidth( aItem->GetEffectiveTextPenWidth( nullptr ) ); // JEY TODO: requires RENDER_SETTINGS m_gal->SetTextAttributes( aItem ); m_gal->SetIsFill( false ); m_gal->SetIsStroke( true ); diff --git a/common/painter.cpp b/common/painter.cpp index f853827f22..bb994e38d1 100644 --- a/common/painter.cpp +++ b/common/painter.cpp @@ -34,7 +34,6 @@ RENDER_SETTINGS::RENDER_SETTINGS() // Set the default initial values m_highlightFactor = 0.5f; m_selectFactor = 0.5f; - m_layerOpacity = 0.8f; m_highlightItems = false; m_highlightEnabled = false; m_hiContrastEnabled = false; @@ -42,6 +41,8 @@ RENDER_SETTINGS::RENDER_SETTINGS() m_highlightNetcode = -1; m_outlineWidth = 1; m_worksheetLineWidth = 100000; + m_defaultPenWidth = 0; + m_textMarkupFlags = 0; m_showPageLimits = false; } diff --git a/common/plotters/common_plot_functions.cpp b/common/plotters/common_plot_functions.cpp index 2cbd196c17..aac97abf4f 100644 --- a/common/plotters/common_plot_functions.cpp +++ b/common/plotters/common_plot_functions.cpp @@ -116,8 +116,8 @@ void PlotWorkSheet( PLOTTER* plotter, const PROJECT* aProject, const TITLE_BLOCK plotter->Text( text->GetTextPos(), plotColor, text->GetShownText(), text->GetTextAngle(), text->GetTextSize(), text->GetHorizJustify(), text->GetVertJustify(), - text->GetPenWidth(), text->IsItalic(), text->IsBold(), - text->IsMultilineAllowed() ); + text->GetEffectiveTextPenWidth( nullptr ), + text->IsItalic(), text->IsBold(), text->IsMultilineAllowed() ); } break; diff --git a/eeschema/dialogs/dialog_edit_label.cpp b/eeschema/dialogs/dialog_edit_label.cpp index e843522a36..6812fc8ce6 100644 --- a/eeschema/dialogs/dialog_edit_label.cpp +++ b/eeschema/dialogs/dialog_edit_label.cpp @@ -460,12 +460,12 @@ bool DIALOG_LABEL_EDITOR::TransferDataFromWindow() if( ( style & 2 ) ) { m_CurrentText->SetBold( true ); - m_CurrentText->SetThickness( GetPenSizeForBold( m_CurrentText->GetTextWidth() ) ); + m_CurrentText->SetTextPenWidth( GetPenSizeForBold( m_CurrentText->GetTextWidth() ) ); } else { m_CurrentText->SetBold( false ); - m_CurrentText->SetThickness( 0 ); + m_CurrentText->SetTextPenWidth( 0 ); // Use default pen width } m_Parent->RefreshItem( m_CurrentText ); diff --git a/eeschema/edit_label.cpp b/eeschema/edit_label.cpp index 54a4b41784..61bb7e0628 100644 --- a/eeschema/edit_label.cpp +++ b/eeschema/edit_label.cpp @@ -234,7 +234,7 @@ void SCH_EDIT_FRAME::ConvertTextType( SCH_TEXT* aText, KICAD_T aNewType ) newtext->SetShape( aText->GetShape() ); newtext->SetLabelSpinStyle( orientation ); newtext->SetTextSize( aText->GetTextSize() ); - newtext->SetThickness( aText->GetThickness() ); + newtext->SetTextPenWidth( aText->GetTextPenWidth() ); newtext->SetItalic( aText->IsItalic() ); newtext->SetBold( aText->IsBold() ); newtext->SetIsDangling( aText->IsDangling() ); diff --git a/eeschema/lib_field.cpp b/eeschema/lib_field.cpp index 5d4290366b..d20689e55c 100644 --- a/eeschema/lib_field.cpp +++ b/eeschema/lib_field.cpp @@ -101,15 +101,7 @@ void LIB_FIELD::Init( int id ) int LIB_FIELD::GetPenSize() const { - int pensize = GetThickness(); - - if( pensize == 0 && IsBold() ) - pensize = GetPenSizeForBold( GetTextWidth() ); - - // Clip pen size for small texts: - pensize = Clamp_Text_PenSize( pensize, GetTextSize(), IsBold() ); - - return pensize; + return GetEffectiveTextPenWidth( nullptr ); // JEY TODO: requires RENDER_SETTINGS } @@ -325,7 +317,7 @@ const EDA_RECT LIB_FIELD::GetBoundingBox() const /* Y coordinates for LIB_ITEMS are bottom to top, so we must invert the Y position when * calling GetTextBox() that works using top to bottom Y axis orientation. */ - EDA_RECT rect = GetTextBox( -1, -1, true, GetTextMarkupFlags() ); + EDA_RECT rect = GetTextBox( nullptr, -1, true ); // JEY TODO: requires RENDER_SETTINGS rect.RevertYAxis(); // We are using now a bottom to top Y axis. diff --git a/eeschema/lib_field.h b/eeschema/lib_field.h index d2be03f97a..ab7c1ade44 100644 --- a/eeschema/lib_field.h +++ b/eeschema/lib_field.h @@ -190,8 +190,8 @@ public: void Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, const TRANSFORM& aTransform ) override; - int GetWidth() const override { return GetThickness(); } - void SetWidth( int aWidth ) override { SetThickness( aWidth ); } + int GetWidth() const override { return GetTextPenWidth(); } + void SetWidth( int aWidth ) override { SetTextPenWidth( aWidth ); } wxString GetSelectMenuText( EDA_UNITS aUnits ) const override; diff --git a/eeschema/lib_text.cpp b/eeschema/lib_text.cpp index cab253da23..cf0ee0bc5e 100644 --- a/eeschema/lib_text.cpp +++ b/eeschema/lib_text.cpp @@ -143,7 +143,7 @@ void LIB_TEXT::MoveTo( const wxPoint& newPosition ) void LIB_TEXT::NormalizeJustification( bool inverse ) { wxPoint delta( 0, 0 ); - EDA_RECT bbox = GetTextBox( -1 ); + EDA_RECT bbox = GetTextBox( nullptr ); // JEY TODO: requires RENDER_SETTINGS if( GetTextAngle() == 0.0 ) { @@ -300,15 +300,7 @@ void LIB_TEXT::Plot( PLOTTER* plotter, const wxPoint& offset, bool fill, int LIB_TEXT::GetPenSize() const { - int pensize = GetThickness(); - - if( pensize == 0 && IsBold() ) - pensize = GetPenSizeForBold( GetTextWidth() ); - - // Clip pen size for small texts: - pensize = Clamp_Text_PenSize( pensize, GetTextSize(), IsBold() ); - - return pensize; + return GetEffectiveTextPenWidth( nullptr ); // JEY TODO: requires RENDER_SETTINGS } @@ -319,7 +311,7 @@ void LIB_TEXT::print( wxDC* aDC, const wxPoint& aOffset, void* aData, const TRAN /* Calculate the text orientation, according to the component * orientation/mirror (needed when draw text in schematic) */ - int orient = GetTextAngle(); + int orient = (int) GetTextAngle(); if( aTransform.y1 ) // Rotate component 90 degrees. { @@ -350,7 +342,7 @@ void LIB_TEXT::print( wxDC* aDC, const wxPoint& aOffset, void* aData, const TRAN txtpos = aTransform.TransformCoordinate( txtpos ) + aOffset; GRText( aDC, txtpos, color, GetShownText(), orient, GetTextSize(), GR_TEXT_HJUSTIFY_CENTER, - GR_TEXT_VJUSTIFY_CENTER, GetPenSize(), IsItalic(), IsBold() ); + GR_TEXT_VJUSTIFY_CENTER, GetEffectiveTextPenWidth( nullptr ), IsItalic(), IsBold() ); } @@ -358,7 +350,7 @@ void LIB_TEXT::GetMsgPanelInfo( EDA_UNITS aUnits, MSG_PANEL_ITEMS& aList ) { LIB_ITEM::GetMsgPanelInfo( aUnits, aList ); - wxString msg = MessageTextFromValue( aUnits, GetThickness(), true ); + wxString msg = MessageTextFromValue( aUnits, GetTextPenWidth(), true ); aList.push_back( MSG_PANEL_ITEM( _( "Line Width" ), msg, BLUE ) ); } @@ -368,7 +360,7 @@ const EDA_RECT LIB_TEXT::GetBoundingBox() const /* Y coordinates for LIB_ITEMS are bottom to top, so we must invert the Y position when * calling GetTextBox() that works using top to bottom Y axis orientation. */ - EDA_RECT rect = GetTextBox( -1, -1, true, GetTextMarkupFlags() ); + EDA_RECT rect = GetTextBox( nullptr, -1, true ); // JEY TODO: requires RENDER_SETTINGS rect.RevertYAxis(); // We are using now a bottom to top Y axis. diff --git a/eeschema/lib_text.h b/eeschema/lib_text.h index 828d1b3824..00ebb54078 100644 --- a/eeschema/lib_text.h +++ b/eeschema/lib_text.h @@ -94,8 +94,8 @@ public: void Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, const TRANSFORM& aTransform ) override; - int GetWidth() const override { return GetThickness(); } - void SetWidth( int aWidth ) override { SetThickness( aWidth ); } + int GetWidth() const override { return GetTextPenWidth(); } + void SetWidth( int aWidth ) override { SetTextPenWidth( aWidth ); } wxString GetSelectMenuText( EDA_UNITS aUnits ) const override; diff --git a/eeschema/sch_eagle_plugin.cpp b/eeschema/sch_eagle_plugin.cpp index 4d7199c00f..577a444ba1 100644 --- a/eeschema/sch_eagle_plugin.cpp +++ b/eeschema/sch_eagle_plugin.cpp @@ -1839,7 +1839,7 @@ void SCH_EAGLE_PLUGIN::loadTextAttributes( EDA_TEXT* aText, const ETEXT& aAttrib if( aAttribs.ratio.CGet() > 12 ) { aText->SetBold( true ); - aText->SetThickness( GetPenSizeForBold( aText->GetTextWidth() ) ); + aText->SetTextPenWidth( GetPenSizeForBold( aText->GetTextWidth() ) ); } } diff --git a/eeschema/sch_field.cpp b/eeschema/sch_field.cpp index e5ef8898c9..9a0bb31f71 100644 --- a/eeschema/sch_field.cpp +++ b/eeschema/sch_field.cpp @@ -131,15 +131,7 @@ wxString SCH_FIELD::GetShownText( int aDepth ) const int SCH_FIELD::GetPenSize() const { - int pensize = GetThickness(); - - if( pensize == 0 && IsBold() ) - pensize = GetPenSizeForBold( GetTextWidth() ); - - // Clip pen size for small texts: - pensize = Clamp_Text_PenSize( pensize, GetTextSize(), IsBold() ); - - return pensize; + return GetEffectiveTextPenWidth( nullptr ); // JEY TODO: requires RENDER_SETTINGS } @@ -214,15 +206,12 @@ void SCH_FIELD::SwapData( SCH_ITEM* aItem ) const EDA_RECT SCH_FIELD::GetBoundingBox() const { - // Use the maximum clamped pen width to give us a bit of wiggle room - int linewidth = Clamp_Text_PenSize( GetTextSize().x, GetTextSize(), IsBold() ); - // Calculate the text bounding box: EDA_RECT rect; SCH_FIELD text( *this ); // Make a local copy to change text // because GetBoundingBox() is const text.SetText( GetShownText() ); - rect = text.GetTextBox( -1, linewidth, false, GetTextMarkupFlags() ); + rect = text.GetTextBox( nullptr ); // JEY TODO: requires RENDER_SETTINGS // Calculate the bounding box position relative to the parent: wxPoint origin = GetParentPosition(); diff --git a/eeschema/sch_legacy_plugin.cpp b/eeschema/sch_legacy_plugin.cpp index 6b10761d1c..fc277d0379 100644 --- a/eeschema/sch_legacy_plugin.cpp +++ b/eeschema/sch_legacy_plugin.cpp @@ -1427,7 +1427,7 @@ SCH_TEXT* SCH_LEGACY_PLUGIN::loadText( LINE_READER& aReader ) SCH_PARSE_ERROR( "invalid label type", aReader, line ); } - int thickness = 0; + int penWidth = 0; // The following tokens do not exist in version 1 schematic files, // and not always in version 2 for HLabels and GLabels @@ -1441,14 +1441,14 @@ SCH_TEXT* SCH_LEGACY_PLUGIN::loadText( LINE_READER& aReader ) SCH_PARSE_ERROR( _( "expected 'Italics' or '~'" ), aReader, line ); } - // The thickness token does not exist in older versions of the schematic file format + // The penWidth token does not exist in older versions of the schematic file format // so calling parseInt will be made only if the EOL is not reached. if( *line >= ' ' ) - thickness = parseInt( aReader, line, &line ); + penWidth = parseInt( aReader, line, &line ); } - text->SetBold( thickness != 0 ); - text->SetThickness( thickness != 0 ? GetPenSizeForBold( size ) : 0 ); + text->SetBold( penWidth != 0 ); + text->SetTextPenWidth( penWidth != 0 ? GetPenSizeForBold( size ) : 0 ); // Read the text string for the text. char* tmp = aReader.ReadLine(); @@ -2357,7 +2357,7 @@ void SCH_LEGACY_PLUGIN::saveText( SCH_TEXT* aText ) Iu2Mils( aText->GetPosition().x ), Iu2Mils( aText->GetPosition().y ), spinStyle, Iu2Mils( aText->GetTextWidth() ), - italics, Iu2Mils( aText->GetThickness() ), TO_UTF8( text ) ); + italics, Iu2Mils( aText->GetTextPenWidth() ), TO_UTF8( text ) ); } else if( layer == LAYER_GLOBLABEL || layer == LAYER_HIERLABEL ) { @@ -2372,7 +2372,7 @@ void SCH_LEGACY_PLUGIN::saveText( SCH_TEXT* aText ) Iu2Mils( aText->GetTextWidth() ), shapeLabelIt->second, italics, - Iu2Mils( aText->GetThickness() ), TO_UTF8( text ) ); + Iu2Mils( aText->GetTextPenWidth() ), TO_UTF8( text ) ); } } diff --git a/eeschema/sch_painter.cpp b/eeschema/sch_painter.cpp index d95b11793d..68c76c9bb5 100644 --- a/eeschema/sch_painter.cpp +++ b/eeschema/sch_painter.cpp @@ -331,10 +331,7 @@ float SCH_PAINTER::getLineWidth( const SCH_ITEM* aItem, bool aDrawingShadows ) float SCH_PAINTER::getTextThickness( const SCH_TEXT* aItem, bool aDrawingShadows ) { - float width = (float) aItem->GetThickness(); - - if( width == 0 ) - width = (float) m_schSettings.m_DefaultLineWidth; + float width = (float) aItem->GetEffectiveTextPenWidth( &m_schSettings ); if( aItem->IsSelected() && aDrawingShadows ) width += getShadowWidth(); diff --git a/eeschema/sch_sexpr_parser.cpp b/eeschema/sch_sexpr_parser.cpp index 7024eeb4a9..26b18ef838 100644 --- a/eeschema/sch_sexpr_parser.cpp +++ b/eeschema/sch_sexpr_parser.cpp @@ -535,7 +535,7 @@ void SCH_SEXPR_PARSER::parseEDA_TEXT( EDA_TEXT* aText ) } case T_thickness: - aText->SetThickness( parseInternalUnits( "text thickness" ) ); + aText->SetTextPenWidth( parseInternalUnits( "text thickness" ) ); NeedRIGHT(); break; diff --git a/eeschema/sch_text.cpp b/eeschema/sch_text.cpp index 87bc7b6d05..7b19598d80 100644 --- a/eeschema/sch_text.cpp +++ b/eeschema/sch_text.cpp @@ -282,30 +282,16 @@ bool SCH_TEXT::operator<( const SCH_ITEM& aItem ) const int SCH_TEXT::GetPenSize() const { - int pensize = GetThickness(); - - if( pensize == 0 && IsBold() ) - pensize = GetPenSizeForBold( GetTextWidth() ); - - // Clip pen size for small texts: - pensize = Clamp_Text_PenSize( pensize, GetTextSize(), IsBold() ); - - return pensize; + return GetEffectiveTextPenWidth( nullptr ); // JEY TODO: requires RENDER_SETTINGS } void SCH_TEXT::Print( wxDC* DC, const wxPoint& aOffset ) { COLOR4D color = GetLayerColor( m_Layer ); - int linewidth = GetPenSize(); wxPoint text_offset = aOffset + GetSchematicTextOffset(); - int savedWidth = GetThickness(); - - SetThickness( linewidth ); // Set the minimum width EDA_TEXT::Print( DC, text_offset, color ); - - SetThickness( savedWidth ); } @@ -415,10 +401,7 @@ void SCH_TEXT::GetConnectionPoints( std::vector< wxPoint >& aPoints ) const const EDA_RECT SCH_TEXT::GetBoundingBox() const { - // Use the maximum clamped pen width to give us a bit of wiggle room - int linewidth = Clamp_Text_PenSize( GetTextSize().x, GetTextSize(), IsBold() ); - - EDA_RECT rect = GetTextBox( -1, linewidth, false, GetTextMarkupFlags() ); + EDA_RECT rect = GetTextBox( nullptr ); // JEY TODO: requires RENDER_SETTINGS if( GetTextAngle() != 0 ) // Rotate rect { @@ -586,15 +569,10 @@ bool SCH_TEXT::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) void SCH_TEXT::Plot( PLOTTER* aPlotter ) { static std::vector Poly; - COLOR4D color = aPlotter->ColorSettings()->GetColor( GetLayer() ); - int tmp = GetThickness(); - int thickness = GetPenSize(); + COLOR4D color = aPlotter->ColorSettings()->GetColor( GetLayer() ); + int penWidth = GetEffectiveTextPenWidth( nullptr ); - // Two thicknesses are set here: - // The first is for EDA_TEXT, which controls the interline spacing based on text thickness - // The second is for the output that sets the actual stroke size - SetThickness( thickness ); - aPlotter->SetCurrentLineWidth( thickness ); + aPlotter->SetCurrentLineWidth( penWidth ); if( IsMultilineAllowed() ) { @@ -610,7 +588,7 @@ void SCH_TEXT::Plot( PLOTTER* aPlotter ) wxPoint textpos = positions[ii] + GetSchematicTextOffset(); wxString& txt = strings_list.Item( ii ); aPlotter->Text( textpos, color, txt, GetTextAngle(), GetTextSize(), GetHorizJustify(), - GetVertJustify(), thickness, IsItalic(), IsBold() ); + GetVertJustify(), penWidth, IsItalic(), IsBold() ); } } else @@ -618,7 +596,7 @@ void SCH_TEXT::Plot( PLOTTER* aPlotter ) wxPoint textpos = GetTextPos() + GetSchematicTextOffset(); aPlotter->Text( textpos, color, GetShownText(), GetTextAngle(), GetTextSize(), - GetHorizJustify(), GetVertJustify(), thickness, IsItalic(), IsBold() ); + GetHorizJustify(), GetVertJustify(), penWidth, IsItalic(), IsBold() ); } // Draw graphic symbol for global or hierarchical labels @@ -628,8 +606,6 @@ void SCH_TEXT::Plot( PLOTTER* aPlotter ) if( Poly.size() ) aPlotter->PlotPoly( Poly, NO_FILL ); - - SetThickness( tmp ); } @@ -765,10 +741,7 @@ bool SCH_LABEL::IsType( const KICAD_T aScanTypes[] ) const const EDA_RECT SCH_LABEL::GetBoundingBox() const { - // Use the maximum clamped pen width to give us a bit of wiggle room - int linewidth = Clamp_Text_PenSize( GetTextSize().x, GetTextSize(), IsBold() ); - - EDA_RECT rect = GetTextBox( -1, linewidth, false, GetTextMarkupFlags() ); + EDA_RECT rect = GetTextBox( nullptr ); // JEY TODO: requires RENDER_SETTINGS if( GetTextAngle() != 0.0 ) { @@ -908,17 +881,11 @@ void SCH_GLOBALLABEL::Print( wxDC* DC, const wxPoint& aOffset ) COLOR4D color = GetLayerColor( m_Layer ); wxPoint text_offset = aOffset + GetSchematicTextOffset(); - int linewidth = GetPenSize(); - int save_width = GetThickness(); - - SetThickness( linewidth ); EDA_TEXT::Print( DC, text_offset, color ); - SetThickness( save_width ); // restore initial value - CreateGraphicShape( Poly, GetTextPos() + aOffset ); - GRPoly( nullptr, DC, Poly.size(), &Poly[0], 0, linewidth, color, color ); + GRPoly( nullptr, DC, Poly.size(), &Poly[0], false, GetTextPenWidth(), color, color ); } @@ -1152,18 +1119,12 @@ void SCH_HIERLABEL::Print( wxDC* DC, const wxPoint& offset ) auto conn = Connection( *g_CurrentSheet ); COLOR4D color = GetLayerColor( ( conn && conn->IsBus() ) ? LAYER_BUS : m_Layer ); - int linewidth = GetPenSize(); - int save_width = GetThickness(); - - SetThickness( linewidth ); - wxPoint text_offset = offset + GetSchematicTextOffset(); + EDA_TEXT::Print( DC, text_offset, color ); - SetThickness( save_width ); // restore initial value - CreateGraphicShape( Poly, GetTextPos() + offset ); - GRPoly( nullptr, DC, Poly.size(), &Poly[0], 0, linewidth, color, color ); + GRPoly( nullptr, DC, Poly.size(), &Poly[0], false, GetTextPenWidth(), color, color ); } diff --git a/include/eda_text.h b/include/eda_text.h index 9a60cbd12f..e3446990e7 100644 --- a/include/eda_text.h +++ b/include/eda_text.h @@ -30,9 +30,12 @@ #include // EDA_DRAW_MODE_T #include // EDA_RECT #include "kicad_string.h" +#include "painter.h" class SHAPE_POLY_SET; +using KIGFX::RENDER_SETTINGS; + // 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 @@ -137,15 +140,14 @@ public: virtual void SetText( const wxString& aText ); /** - * Set the pen width. - * - * @param aNewThickness is the new pen width + * The TextPenWidth is that set by the user. The EffectiveTextPenWidth also factors + * in bold text, default text thickness, and thickness clamping. */ - void SetThickness( int aNewThickness ) { m_e.penwidth = aNewThickness; }; + void SetTextPenWidth( int aWidth ) { m_e.penwidth = aWidth; }; + int GetTextPenWidth() const { return m_e.penwidth; }; + int GetEffectiveTextPenWidth( RENDER_SETTINGS* aSettings ) const; - /** - * Return the pen width. - */ + // JEY TODO: delete int GetThickness() const { return m_e.penwidth; }; void SetTextAngle( double aAngle ) @@ -308,25 +310,16 @@ public: int LenSize( const wxString& aLine, int aThickness, int aMarkupFlags ) const; /** - * Useful in multiline texts to calculate the full text or a line area (for - * zones filling, locate functions....) - * - * @return the rect containing the line of text (i.e. the position and the - * size of one line) - * this rectangle is calculated for 0 orient text. - * If orientation is not 0 the rect must be rotated to match the - * physical area - * @param aLine The line of text to consider. - * for single line text, aLine is unused - * If aLine == -1, the full area (considering all lines) is returned - * @param aThickness Overrides the current penwidth when greater than 0. - * This is needed when the current penwidth is 0 and a default penwidth is used. + * Useful in multiline texts to calculate the full text or a line area (for zones filling, + * locate functions....) + * @param aSettings An options rendering context to provide defaults, processing flags, etc. + * @param aLine The line of text to consider. Pass -1 for all lines. * @param aInvertY Invert the Y axis when calculating bounding box. - * @param aMarkupFlags a flagset of MARKUP_FLAG enums indicating which markup tokens should - * be processed + * @return the rect containing the line of text (i.e. the position and the size of one line) + * this rectangle is calculated for 0 orient text. + * If orientation is not 0 the rect must be rotated to match the physical area */ - EDA_RECT GetTextBox( int aLine = -1, int aThickness = -1, bool aInvertY = false, - int aMarkupFlags = 0 ) const; + EDA_RECT GetTextBox( RENDER_SETTINGS* aSettings, int aLine = -1, bool aInvertY = false ) const; /** * Return the distance between two lines of text. diff --git a/include/painter.h b/include/painter.h index acb1687962..4248e617b8 100644 --- a/include/painter.h +++ b/include/painter.h @@ -31,7 +31,6 @@ #include #include -#include #include #include @@ -45,11 +44,12 @@ class VIEW_ITEM; /** * RENDER_SETTINGS - * Contains all the knowledge about how graphical objects are drawn on - * any output surface/device. This includes: + * Contains all the knowledge about how graphical objects are drawn on any output + * surface/device. This includes: * - color/transparency settings * - highlighting and high contrast mode control * - drawing quality control (sketch/outline mode) + * - text processing flags * The class acts as an interface between the PAINTER object and the GUI (i.e. Layers/Items * widget or display options dialog). */ @@ -143,22 +143,9 @@ public: /** * Function SetHighContrast * Turns on/off high contrast display mode. - * @param aEnabled determines if high contrast display mode should be enabled or not. */ - inline void SetHighContrast( bool aEnabled ) - { - m_hiContrastEnabled = aEnabled; - } - - /** - * Function GetHighContrast - * Returns information about high contrast display mode. - * @return True if the high contrast mode is on, false otherwise. - */ - inline bool GetHighContrast() const - { - return m_hiContrastEnabled; - } + void SetHighContrast( bool aEnabled ) { m_hiContrastEnabled = aEnabled; } + bool GetHighContrast() const { return m_hiContrastEnabled; } /** * Function GetColor @@ -170,20 +157,13 @@ public: */ virtual const COLOR4D& GetColor( const VIEW_ITEM* aItem, int aLayer ) const = 0; - float GetWorksheetLineWidth() const - { - return m_worksheetLineWidth; - } + float GetWorksheetLineWidth() const { return m_worksheetLineWidth; } - inline bool GetShowPageLimits() const - { - return m_showPageLimits; - } + int GetDefaultPenWidth() const { return m_defaultPenWidth; } + int GetTextMarkupFlags() const { return m_textMarkupFlags; } - inline void SetShowPageLimits( bool aDraw ) - { - m_showPageLimits = aDraw; - } + bool GetShowPageLimits() const { return m_showPageLimits; } + void SetShowPageLimits( bool aDraw ) { m_showPageLimits = aDraw; } /** * Function GetBackgroundColor @@ -256,40 +236,34 @@ protected: std::set m_activeLayers; ///< Stores active layers number - ///> Colors for all layers (normal) - COLOR4D m_layerColors[LAYER_ID_COUNT]; + COLOR4D m_layerColors[LAYER_ID_COUNT]; // Layer colors + COLOR4D m_layerColorsHi[LAYER_ID_COUNT]; // Layer colors for highlighted objects + COLOR4D m_layerColorsSel[LAYER_ID_COUNT]; // Layer colors for selected objects - ///> Colors for all layers (highlighted) - COLOR4D m_layerColorsHi[LAYER_ID_COUNT]; + COLOR4D m_hiContrastColor[LAYER_ID_COUNT]; // High-contrast mode layer colors + COLOR4D m_layerColorsDark[LAYER_ID_COUNT]; // Darkened layer colors (for high-contrast mode) - ///> Colors for all layers (selected) - COLOR4D m_layerColorsSel[LAYER_ID_COUNT]; - - ///> Colors for all layers (darkened) - COLOR4D m_layerColorsDark[LAYER_ID_COUNT]; - - ///< Colora used for high contrast display mode - COLOR4D m_hiContrastColor[LAYER_ID_COUNT]; + COLOR4D m_backgroundColor; // The background color /// Parameters for display modes - bool m_hiContrastEnabled; ///< High contrast display mode on/off - float m_hiContrastFactor; ///< Factor used for computing high contrast color + bool m_hiContrastEnabled; // High contrast display mode on/off + float m_hiContrastFactor; // Factor used for computing high contrast color - bool m_highlightEnabled; ///< Highlight display mode on/off - int m_highlightNetcode; ///< Net number that is displayed in highlight - ///< -1 means that there is no specific net, and whole active - ///< layer is highlighted - bool m_highlightItems; ///< Highlight items with their HIGHLIGHT flags set - float m_highlightFactor; ///< Factor used for computing highlight color + bool m_highlightEnabled; // Highlight display mode on/off + int m_highlightNetcode; // Net number that is displayed in highlight + // -1 means that there is no specific net, and whole active + // layer is highlighted + bool m_highlightItems; // Highlight items with their HIGHLIGHT flags set + float m_highlightFactor; // Factor used for computing highlight color - float m_selectFactor; ///< Specifies how color of selected items is changed - float m_layerOpacity; ///< Determines opacity of all layers - float m_outlineWidth; ///< Line width used when drawing outlines - float m_worksheetLineWidth; ///< Line width used when drawing worksheet + float m_selectFactor; // Specifies how color of selected items is changed + float m_outlineWidth; // Line width used when drawing outlines + float m_worksheetLineWidth; // Line width used when drawing worksheet + int m_defaultPenWidth; + int m_textMarkupFlags; // Indicates whether or not certain markups (such as super- + // and subscript) should be processed. bool m_showPageLimits; - - COLOR4D m_backgroundColor; ///< The background color }; diff --git a/include/preview_items/draw_context.h b/include/preview_items/draw_context.h index 9b2ef11491..28d0c15090 100644 --- a/include/preview_items/draw_context.h +++ b/include/preview_items/draw_context.h @@ -25,6 +25,7 @@ #define PREVIEW_PREVIEW_DRAW_CONTEXT__H_ #include +#include namespace KIGFX { diff --git a/include/ws_draw_item.h b/include/ws_draw_item.h index d1f876171d..235a673732 100644 --- a/include/ws_draw_item.h +++ b/include/ws_draw_item.h @@ -27,7 +27,6 @@ #include #include -#include #include #include "msgpanel.h" #include @@ -280,7 +279,7 @@ public: { SetTextPos( aPos ); SetTextSize( aSize ); - SetThickness( aPenWidth ); + SetTextPenWidth( aPenWidth ); SetItalic( aItalic ); SetBold( aBold ); } @@ -289,9 +288,6 @@ public: void PrintWsItem( wxDC* aDC, const wxPoint& aOffset, COLOR4D aColor ) override; - // Accessors: - int GetPenWidth() { return GetThickness(); } - void SetTextAngle( double aAngle ) { EDA_TEXT::SetTextAngle( NormalizeAngle360Min( aAngle ) ); diff --git a/include/ws_painter.h b/include/ws_painter.h index 2656abf17a..98a3fa114d 100644 --- a/include/ws_painter.h +++ b/include/ws_painter.h @@ -29,6 +29,7 @@ #include #include #include +#include // Forward declarations: class EDA_RECT; diff --git a/pcbnew/altium2kicadpcb_plugin/altium_pcb.cpp b/pcbnew/altium2kicadpcb_plugin/altium_pcb.cpp index 1c6852cf5a..c14a333404 100644 --- a/pcbnew/altium2kicadpcb_plugin/altium_pcb.cpp +++ b/pcbnew/altium2kicadpcb_plugin/altium_pcb.cpp @@ -758,7 +758,7 @@ void ALTIUM_PCB::HelperParseDimensions6Linear( const ADIMENSION6& aElem ) dimension->SetWidth( aElem.linewidth ); - dimension->Text().SetThickness( aElem.textlinewidth ); + dimension->Text().SetTextPenWidth( aElem.textlinewidth ); dimension->Text().SetTextSize( wxSize( aElem.textheight, aElem.textheight ) ); dimension->Text().SetBold( aElem.textbold ); dimension->Text().SetItalic( aElem.textitalic ); @@ -855,7 +855,7 @@ void ALTIUM_PCB::HelperParseDimensions6Leader( const ADIMENSION6& aElem ) text->SetPosition( aElem.textPoint.at( 0 ) ); text->SetLayer( klayer ); text->SetTextSize( wxSize( aElem.textheight, aElem.textheight ) ); // TODO: parse text width - text->SetThickness( aElem.textlinewidth ); + text->SetTextPenWidth( aElem.textlinewidth ); text->SetHorizJustify( EDA_TEXT_HJUSTIFY_T::GR_TEXT_HJUSTIFY_LEFT ); text->SetVertJustify( EDA_TEXT_VJUSTIFY_T::GR_TEXT_VJUSTIFY_BOTTOM ); } @@ -1865,7 +1865,7 @@ void ALTIUM_PCB::ParseTexts6Data( itm->SetLayer( klayer ); tx->SetTextSize( wxSize( elem.height, elem.height ) ); // TODO: parse text width - tx->SetThickness( elem.strokewidth ); + tx->SetTextPenWidth( elem.strokewidth ); tx->SetMirrored( elem.mirrored ); if( elem.isDesignator || elem.isComment ) // That's just a bold assumption { diff --git a/pcbnew/board_items_to_polygon_shape_transform.cpp b/pcbnew/board_items_to_polygon_shape_transform.cpp index 8d410da019..b6198350ff 100644 --- a/pcbnew/board_items_to_polygon_shape_transform.cpp +++ b/pcbnew/board_items_to_polygon_shape_transform.cpp @@ -184,54 +184,48 @@ void MODULE::TransformPadsShapesWithClearanceToPolygon( PCB_LAYER_ID aLayer, void MODULE::TransformGraphicShapesWithClearanceToPolygonSet( PCB_LAYER_ID aLayer, SHAPE_POLY_SET& aCornerBuffer, int aInflateValue, - int aError, bool aIncludeText ) const + int aError, + bool aIncludeText, + bool aIncludeEdges ) const { std::vector texts; // List of TEXTE_MODULE to convert for( auto item : GraphicalItems() ) { - switch( item->Type() ) - { - case PCB_MODULE_TEXT_T: + if( item->Type() == PCB_MODULE_TEXT_T && aIncludeText ) { TEXTE_MODULE* text = static_cast( item ); - if( ( aLayer != UNDEFINED_LAYER && text->GetLayer() == aLayer ) && text->IsVisible() ) + if( aLayer != UNDEFINED_LAYER && text->GetLayer() == aLayer && text->IsVisible() ) texts.push_back( text ); } - break; - case PCB_MODULE_EDGE_T: + if( item->Type() == PCB_MODULE_EDGE_T && aIncludeEdges ) { EDGE_MODULE* outline = (EDGE_MODULE*) item; - if( aLayer != UNDEFINED_LAYER && outline->GetLayer() != aLayer ) - break; - - outline->TransformShapeWithClearanceToPolygon( aCornerBuffer, 0, aError ); - } - break; - - default: - break; + if( aLayer != UNDEFINED_LAYER && outline->GetLayer() == aLayer ) + outline->TransformShapeWithClearanceToPolygon( aCornerBuffer, 0, aError ); } } - if( !aIncludeText ) - return; + if( aIncludeText ) + { + if( Reference().GetLayer() == aLayer && Reference().IsVisible() ) + texts.push_back( &Reference() ); - // Convert texts sur modules - if( Reference().GetLayer() == aLayer && Reference().IsVisible() ) - texts.push_back( &Reference() ); - - if( Value().GetLayer() == aLayer && Value().IsVisible() ) - texts.push_back( &Value() ); + if( Value().GetLayer() == aLayer && Value().IsVisible() ) + texts.push_back( &Value() ); + } prms.m_cornerBuffer = &aCornerBuffer; for( TEXTE_MODULE* textmod : texts ) { - prms.m_textWidth = textmod->GetThickness() + ( 2 * aInflateValue ); + bool forceBold = true; + int penWidth = 0; // force max width for bold text + + prms.m_textWidth = textmod->GetEffectiveTextPenWidth( nullptr ) + ( 2 * aInflateValue ); prms.m_error = aError; wxSize size = textmod->GetTextSize(); @@ -240,66 +234,9 @@ void MODULE::TransformGraphicShapesWithClearanceToPolygonSet( PCB_LAYER_ID aLaye GRText( NULL, textmod->GetTextPos(), BLACK, textmod->GetShownText(), textmod->GetDrawRotation(), size, textmod->GetHorizJustify(), - textmod->GetVertJustify(), textmod->GetThickness(), textmod->IsItalic(), - true, addTextSegmToPoly, &prms ); + textmod->GetVertJustify(), penWidth, textmod->IsItalic(), + forceBold, addTextSegmToPoly, &prms ); } - -} - - -// Same as function TransformGraphicShapesWithClearanceToPolygonSet but this only for text -void MODULE::TransformGraphicTextWithClearanceToPolygonSet( PCB_LAYER_ID aLayer, - SHAPE_POLY_SET& aCornerBuffer, - int aInflateValue, int aError ) const -{ - std::vector texts; // List of TEXTE_MODULE to convert - - for( auto item : GraphicalItems() ) - { - switch( item->Type() ) - { - case PCB_MODULE_TEXT_T: - { - TEXTE_MODULE* text = static_cast( item ); - - if( text->GetLayer() == aLayer && text->IsVisible() ) - texts.push_back( text ); - } - break; - - case PCB_MODULE_EDGE_T: - // This function does not render this - break; - - default: - break; - } - } - - // Convert texts sur modules - if( Reference().GetLayer() == aLayer && Reference().IsVisible() ) - texts.push_back( &Reference() ); - - if( Value().GetLayer() == aLayer && Value().IsVisible() ) - texts.push_back( &Value() ); - - prms.m_cornerBuffer = &aCornerBuffer; - - for( TEXTE_MODULE* textmod : texts ) - { - prms.m_textWidth = textmod->GetThickness() + ( 2 * aInflateValue ); - prms.m_error = aError; - wxSize size = textmod->GetTextSize(); - - if( textmod->IsMirrored() ) - size.x = -size.x; - - GRText( NULL, textmod->GetTextPos(), BLACK, textmod->GetShownText(), - textmod->GetDrawRotation(), size, textmod->GetHorizJustify(), - textmod->GetVertJustify(), textmod->GetThickness(), textmod->IsItalic(), - true, addTextSegmToPoly, &prms ); - } - } @@ -342,8 +279,8 @@ void EDA_TEXT::TransformBoundingBoxWithClearanceToPolygon( SHAPE_POLY_SET* aCorn wxPoint corners[4]; // Buffer of polygon corners - EDA_RECT rect = GetTextBox( -1 ); - rect.Inflate( aClearanceValue ); + EDA_RECT rect = GetTextBox( nullptr ); + rect.Inflate( aClearanceValue + Millimeter2iu( DEFAULT_TEXT_WIDTH ) ); corners[0].x = rect.GetOrigin().x; corners[0].y = rect.GetOrigin().y; corners[1].y = corners[0].y; @@ -379,8 +316,11 @@ void TEXTE_PCB::TransformShapeWithClearanceToPolygonSet( SHAPE_POLY_SET& aCorner if( IsMirrored() ) size.x = -size.x; + bool forceBold = true; + int penWidth = 0; // force max width for bold text + prms.m_cornerBuffer = &aCornerBuffer; - prms.m_textWidth = GetThickness() + ( 2 * aClearanceValue ); + prms.m_textWidth = GetEffectiveTextPenWidth( nullptr ) + ( 2 * aClearanceValue ); prms.m_error = aError; COLOR4D color = COLOR4D::BLACK; // not actually used, but needed by GRText @@ -396,13 +336,13 @@ void TEXTE_PCB::TransformShapeWithClearanceToPolygonSet( SHAPE_POLY_SET& aCorner { wxString txt = strings_list.Item( ii ); GRText( NULL, positions[ii], color, txt, GetTextAngle(), size, GetHorizJustify(), - GetVertJustify(), GetThickness(), IsItalic(), true, addTextSegmToPoly, &prms ); + GetVertJustify(), penWidth, IsItalic(), forceBold, addTextSegmToPoly, &prms ); } } else { GRText( NULL, GetTextPos(), color, GetShownText(), GetTextAngle(), size, GetHorizJustify(), - GetVertJustify(), GetThickness(), IsItalic(), true, addTextSegmToPoly, &prms ); + GetVertJustify(), penWidth, IsItalic(), forceBold, addTextSegmToPoly, &prms ); } } diff --git a/pcbnew/class_dimension.cpp b/pcbnew/class_dimension.cpp index 3e5f82ca5d..06c037edfa 100644 --- a/pcbnew/class_dimension.cpp +++ b/pcbnew/class_dimension.cpp @@ -245,7 +245,7 @@ void DIMENSION::AdjustDimensionDetails( int aPrecision ) m_Text.SetLayer( GetLayer() ); // calculate the size of the dimension (text + line above the text) - ii = m_Text.GetTextHeight() + m_Text.GetThickness() + ( m_Width ); + ii = m_Text.GetTextHeight() + m_Text.GetEffectiveTextPenWidth( nullptr ) + m_Width; // JEY TODO: requires RENDER_SETTINGS deltax = m_featureLineDO.x - m_featureLineGO.x; deltay = m_featureLineDO.y - m_featureLineGO.y; @@ -456,7 +456,7 @@ const EDA_RECT DIMENSION::GetBoundingBox() const EDA_RECT bBox; int xmin, xmax, ymin, ymax; - bBox = m_Text.GetTextBox( -1 ); + bBox = m_Text.GetTextBox( nullptr ); // JEY TODO: requires RENDER_SETTINGS xmin = bBox.GetX(); xmax = bBox.GetRight(); ymin = bBox.GetY(); diff --git a/pcbnew/class_module.h b/pcbnew/class_module.h index b7edf66f68..bb117237b5 100644 --- a/pcbnew/class_module.h +++ b/pcbnew/class_module.h @@ -393,23 +393,23 @@ public: * aInflateValue = 0 to have the exact shape size * @param aError = Maximum error between true arc and polygon approx * @param aIncludeText = True to transform text shapes + * @param aIncludeEdges = True to transform module shapes */ void TransformGraphicShapesWithClearanceToPolygonSet( PCB_LAYER_ID aLayer, SHAPE_POLY_SET& aCornerBuffer, int aInflateValue, int aError = ARC_HIGH_DEF, - bool aIncludeText = true ) const; + bool aIncludeText = true, bool aIncludeEdges = true ) const; /** * @brief TransformGraphicTextWithClearanceToPolygonSet * This function is the same as TransformGraphicShapesWithClearanceToPolygonSet * but only generate text - * @param aLayer = the layer to consider, or UNDEFINED_LAYER to consider all - * @param aCornerBuffer = the buffer to store polygons - * @param aInflateValue = a value to inflate shapes - * aInflateValue = 0 to have the exact shape size - * @param aError = Maximum error between true arc and polygon approx */ void TransformGraphicTextWithClearanceToPolygonSet( PCB_LAYER_ID aLayer, - SHAPE_POLY_SET& aCornerBuffer, int aInflateValue, int aError = ARC_HIGH_DEF ) const; + SHAPE_POLY_SET& aCornerBuffer, int aInflateValue, int aError = ARC_HIGH_DEF ) const + { + TransformGraphicShapesWithClearanceToPolygonSet( aLayer, aCornerBuffer, aInflateValue, + aError, true, false ); + } /** * Resolve any references to system tokens supported by the component. diff --git a/pcbnew/class_pcb_text.cpp b/pcbnew/class_pcb_text.cpp index 560132a096..598160de45 100644 --- a/pcbnew/class_pcb_text.cpp +++ b/pcbnew/class_pcb_text.cpp @@ -149,7 +149,7 @@ void TEXTE_PCB::GetMsgPanelInfo( EDA_UNITS aUnits, std::vector& msg.Printf( wxT( "%.1f" ), GetTextAngle() / 10.0 ); aList.emplace_back( _( "Angle" ), msg, DARKGREEN ); - msg = MessageTextFromValue( aUnits, GetThickness() ); + msg = MessageTextFromValue( aUnits, GetTextPenWidth() ); aList.emplace_back( _( "Thickness" ), msg, MAGENTA ); msg = MessageTextFromValue( aUnits, GetTextWidth() ); @@ -162,7 +162,7 @@ void TEXTE_PCB::GetMsgPanelInfo( EDA_UNITS aUnits, std::vector& const EDA_RECT TEXTE_PCB::GetBoundingBox() const { - EDA_RECT rect = GetTextBox( -1, -1 ); + EDA_RECT rect = GetTextBox( nullptr ); // JEY TODO: requires RENDER_SETTINGS if( GetTextAngle() ) rect = rect.GetBoundingBoxRotated( GetTextPos(), GetTextAngle() ); @@ -197,9 +197,9 @@ void TEXTE_PCB::Flip( const wxPoint& aCentre, bool aFlipLeftRight ) if( GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT || GetHorizJustify() == GR_TEXT_HJUSTIFY_RIGHT ) { if( ( GetHorizJustify() == GR_TEXT_HJUSTIFY_RIGHT ) == IsMirrored() ) - SetTextX( GetTextPos().x - GetTextBox().GetWidth() ); + SetTextX( GetTextPos().x - GetTextBox( nullptr ).GetWidth() ); // JEY TODO: requires RENDER_SETTINGS else - SetTextX( GetTextPos().x + GetTextBox().GetWidth() ); + SetTextX( GetTextPos().x + GetTextBox( nullptr ).GetWidth() ); // JEY TODO: requires RENDER_SETTINGS } } diff --git a/pcbnew/class_text_mod.cpp b/pcbnew/class_text_mod.cpp index 7f68ab84e9..0737f74443 100644 --- a/pcbnew/class_text_mod.cpp +++ b/pcbnew/class_text_mod.cpp @@ -54,7 +54,7 @@ TEXTE_MODULE::TEXTE_MODULE( MODULE* parent, TEXT_TYPE text_type ) : m_keepUpright = true; // Set text thickness to a default value - SetThickness( Millimeter2iu( DEFAULT_TEXT_WIDTH ) ); + SetTextPenWidth( Millimeter2iu( DEFAULT_TEXT_WIDTH ) ); SetLayer( F_SilkS ); // Set position and give a default layer if a valid parent footprint exists @@ -86,7 +86,7 @@ void TEXTE_MODULE::SetTextAngle( double aAngle ) bool TEXTE_MODULE::TextHitTest( const wxPoint& aPoint, int aAccuracy ) const { - EDA_RECT rect = GetTextBox( -1 ); + EDA_RECT rect = GetTextBox( nullptr ); // JEY TODO: requires RENDER_SETTINGS wxPoint location = aPoint; rect.Inflate( aAccuracy ); @@ -106,7 +106,7 @@ bool TEXTE_MODULE::TextHitTest( const EDA_RECT& aRect, bool aContains, int aAccu if( aContains ) return rect.Contains( GetBoundingBox() ); else - return rect.Intersects( GetTextBox( -1 ), GetDrawRotation() ); + return rect.Intersects( GetTextBox( nullptr ), GetDrawRotation() ); // JEY TODO: requires RENDER_SETTINGS } @@ -252,7 +252,7 @@ void TEXTE_MODULE::SetLocalCoord() const EDA_RECT TEXTE_MODULE::GetBoundingBox() const { double angle = GetDrawRotation(); - EDA_RECT text_area = GetTextBox( -1, -1 ); + EDA_RECT text_area = GetTextBox( nullptr ); // JEY TODO: requires RENDER_SETTINGS if( angle ) text_area = text_area.GetBoundingBoxRotated( GetTextPos(), angle ); @@ -292,7 +292,7 @@ void TEXTE_MODULE::Print( PCB_BASE_FRAME* aFrame, wxDC* aDC, const wxPoint& aOff } // Draw mode compensation for the width - int width = GetThickness(); + int width = GetEffectiveTextPenWidth( nullptr ); if( aFrame->GetDisplayOptions().m_DisplayModTextFill == SKETCH ) width = -width; @@ -382,7 +382,7 @@ void TEXTE_MODULE::GetMsgPanelInfo( EDA_UNITS aUnits, std::vectorat( m_texts->size() - 1 ).GetLayer() ); textMod.SetTextSize( dsnSettings.GetTextSize( textMod.GetLayer() ) ); - textMod.SetThickness( dsnSettings.GetTextThickness( textMod.GetLayer() ) ); + textMod.SetTextPenWidth( dsnSettings.GetTextThickness( textMod.GetLayer() ) ); textMod.SetItalic( dsnSettings.GetTextItalic( textMod.GetLayer() ) ); textMod.SetKeepUpright( dsnSettings.GetTextUpright( textMod.GetLayer() ) ); textMod.SetMirrored( IsBackLayer( textMod.GetLayer() ) ); diff --git a/pcbnew/dialogs/dialog_edit_footprint_for_fp_editor.cpp b/pcbnew/dialogs/dialog_edit_footprint_for_fp_editor.cpp index 046349fe1f..7632a52722 100644 --- a/pcbnew/dialogs/dialog_edit_footprint_for_fp_editor.cpp +++ b/pcbnew/dialogs/dialog_edit_footprint_for_fp_editor.cpp @@ -720,7 +720,7 @@ void DIALOG_FOOTPRINT_FP_EDITOR::OnAddField( wxCommandEvent& event ) textMod.SetLayer( m_texts->at( m_texts->size() - 1 ).GetLayer() ); textMod.SetTextSize( dsnSettings.GetTextSize( textMod.GetLayer() ) ); - textMod.SetThickness( dsnSettings.GetTextThickness( textMod.GetLayer() ) ); + textMod.SetTextPenWidth( dsnSettings.GetTextThickness( textMod.GetLayer() ) ); textMod.SetItalic( dsnSettings.GetTextItalic( textMod.GetLayer() ) ); m_texts->push_back( textMod ); diff --git a/pcbnew/dialogs/dialog_global_edit_text_and_graphics.cpp b/pcbnew/dialogs/dialog_global_edit_text_and_graphics.cpp index 39c45b82f7..a6ad1e2f3f 100644 --- a/pcbnew/dialogs/dialog_global_edit_text_and_graphics.cpp +++ b/pcbnew/dialogs/dialog_global_edit_text_and_graphics.cpp @@ -277,7 +277,7 @@ void DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::processItem( BOARD_COMMIT& aCommit, B textItem->SetTextSize( wxSize( textItem->GetTextSize().x, m_textHeight.GetValue() ) ); if( !m_thickness.IsIndeterminate() && textItem ) - textItem->SetThickness( m_thickness.GetValue() ); + textItem->SetTextPenWidth( m_thickness.GetValue() ); if( m_Italic->Get3StateValue() != wxCHK_UNDETERMINED && textItem ) textItem->SetItalic( m_Italic->GetValue() ); @@ -298,7 +298,7 @@ void DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::processItem( BOARD_COMMIT& aCommit, B if( textItem ) { textItem->SetTextSize( m_brdSettings->GetTextSize( layer ) ); - textItem->SetThickness( m_brdSettings->GetTextThickness( layer ) ); + textItem->SetTextPenWidth( m_brdSettings->GetTextThickness( layer ) ); textItem->SetItalic( m_brdSettings->GetTextItalic( layer ) ); } diff --git a/pcbnew/dialogs/dialog_text_properties.cpp b/pcbnew/dialogs/dialog_text_properties.cpp index 5dc815014c..80a3f0faab 100644 --- a/pcbnew/dialogs/dialog_text_properties.cpp +++ b/pcbnew/dialogs/dialog_text_properties.cpp @@ -451,7 +451,7 @@ bool DIALOG_TEXT_PROPERTIES::TransferDataToWindow() m_textWidth.SetValue( m_edaText->GetTextSize().x ); m_textHeight.SetValue( m_edaText->GetTextSize().y ); - m_thickness.SetValue( m_edaText->GetThickness() ); + m_thickness.SetValue( m_edaText->GetTextPenWidth() ); m_posX.SetValue( m_edaText->GetTextPos().x ); m_posY.SetValue( m_edaText->GetTextPos().y ); @@ -542,20 +542,20 @@ bool DIALOG_TEXT_PROPERTIES::TransferDataFromWindow() m_item->SetLayer( ToLAYER_ID( m_LayerSelectionCtrl->GetLayerSelection() ) ); m_edaText->SetTextSize( wxSize( m_textWidth.GetValue(), m_textHeight.GetValue() ) ); - m_edaText->SetThickness( m_thickness.GetValue() ); + m_edaText->SetTextPenWidth( m_thickness.GetValue() ); m_edaText->SetTextPos( wxPoint( m_posX.GetValue(), m_posY.GetValue() ) ); if( m_modText ) m_modText->SetLocalCoord(); // Test for acceptable values for thickness and size and clamp if fails - int maxthickness = Clamp_Text_PenSize( m_edaText->GetThickness(), m_edaText->GetTextSize() ); + int maxPenWidth = Clamp_Text_PenSize( m_edaText->GetTextPenWidth(), m_edaText->GetTextSize() ); - if( m_edaText->GetThickness() > maxthickness ) + if( m_edaText->GetTextPenWidth() > maxPenWidth ) { DisplayError( this, _( "The text thickness is too large for the text size.\n" "It will be clamped." ) ); - m_edaText->SetThickness( maxthickness ); + m_edaText->SetTextPenWidth( maxPenWidth ); } m_edaText->SetVisible( m_Visible->GetValue() ); diff --git a/pcbnew/drc/drc.cpp b/pcbnew/drc/drc.cpp index 03bc0c322d..9c1d4fc54a 100644 --- a/pcbnew/drc/drc.cpp +++ b/pcbnew/drc/drc.cpp @@ -1059,7 +1059,7 @@ void DRC::testCopperTextItem( BOARD_ITEM* aTextItem ) return; std::vector textShape; // a buffer to store the text shape (set of segments) - int textWidth = text->GetThickness(); + int penWidth = text->GetEffectiveTextPenWidth( nullptr ); // JEY TODO: requires RENDER_SETTINGS // So far the bounding box makes up the text-area text->TransformTextShapeToSegmentList( textShape ); @@ -1067,7 +1067,7 @@ void DRC::testCopperTextItem( BOARD_ITEM* aTextItem ) if( textShape.size() == 0 ) // Should not happen (empty text?) return; - EDA_RECT bbox = text->GetTextBox(); + EDA_RECT bbox = text->GetTextBox( nullptr ); // JEY TODO: requires RENDER_SETTINGS SHAPE_RECT rect_area( bbox.GetX(), bbox.GetY(), bbox.GetWidth(), bbox.GetHeight() ); // Test tracks and vias @@ -1076,7 +1076,7 @@ void DRC::testCopperTextItem( BOARD_ITEM* aTextItem ) if( !track->IsOnLayer( aTextItem->GetLayer() ) ) continue; - int minDist = ( track->GetWidth() + textWidth ) / 2 + track->GetClearance( NULL ); + int minDist = ( track->GetWidth() + penWidth ) / 2 + track->GetClearance( NULL ); SEG trackAsSeg( track->GetStart(), track->GetEnd() ); // Fast test to detect a trach segment candidate inside the text bounding box @@ -1122,7 +1122,7 @@ void DRC::testCopperTextItem( BOARD_ITEM* aTextItem ) SHAPE_POLY_SET padOutline; - int minDist = textWidth/2 + pad->GetClearance( NULL ); + int minDist = penWidth / 2 + pad->GetClearance( NULL ); pad->TransformShapeWithClearanceToPolygon( padOutline, 0 ); for( unsigned jj = 0; jj < textShape.size(); jj += 2 ) diff --git a/pcbnew/eagle_plugin.cpp b/pcbnew/eagle_plugin.cpp index cc3a7a5fb2..fdd7bd231d 100644 --- a/pcbnew/eagle_plugin.cpp +++ b/pcbnew/eagle_plugin.cpp @@ -547,7 +547,7 @@ void EAGLE_PLUGIN::loadPlain( wxXmlNode* aGraphics ) double ratio = t.ratio ? *t.ratio : 8; // DTD says 8 is default - pcbtxt->SetThickness( KiROUND( t.size.ToPcbUnits() * ratio / 100 ) ); + pcbtxt->SetTextPenWidth( KiROUND( t.size.ToPcbUnits() * ratio / 100 ) ); int align = t.align ? *t.align : ETEXT::BOTTOM_LEFT; @@ -762,7 +762,7 @@ void EAGLE_PLUGIN::loadPlain( wxXmlNode* aGraphics ) dimension->SetEnd( wxPoint( kicad_x( d.x2 ), kicad_y( d.y2 ) ), DIMENSION_PRECISION ); dimension->Text().SetTextSize( designSettings.GetTextSize( layer ) ); - dimension->Text().SetThickness( designSettings.GetTextThickness( layer ) ); + dimension->Text().SetTextPenWidth( designSettings.GetTextThickness( layer ) ); dimension->SetWidth( designSettings.GetLineThickness( layer ) ); dimension->SetUnits( EDA_UNITS::MILLIMETRES, false ); @@ -1307,8 +1307,7 @@ void EAGLE_PLUGIN::orientModuleText( MODULE* m, const EELEMENT& e, ratio = *a.ratio; } - int lw = int( fontz.y * ratio / 100 ); - txt->SetThickness( lw ); + txt->SetTextPenWidth( KiROUND( fontz.y * ratio / 100 ) ); int align = ETEXT::BOTTOM_LEFT; // bottom-left is eagle default @@ -1656,7 +1655,7 @@ void EAGLE_PLUGIN::packageText( MODULE* aModule, wxXmlNode* aTree ) const double ratio = t.ratio ? *t.ratio : 8; // DTD says 8 is default - txt->SetThickness( KiROUND( t.size.ToPcbUnits() * ratio / 100 ) ); + txt->SetTextPenWidth( KiROUND( t.size.ToPcbUnits() * ratio / 100 ) ); int align = t.align ? *t.align : ETEXT::BOTTOM_LEFT; // bottom-left is eagle default diff --git a/pcbnew/exporters/export_vrml.cpp b/pcbnew/exporters/export_vrml.cpp index ecef9749b4..c8e5b5fc1d 100644 --- a/pcbnew/exporters/export_vrml.cpp +++ b/pcbnew/exporters/export_vrml.cpp @@ -773,16 +773,17 @@ static void vrml_text_callback( int x0, int y0, int xf, int yf, void* aData ) static void export_vrml_pcbtext( MODEL_VRML& aModel, TEXTE_PCB* text ) { - model_vrml->m_text_layer = text->GetLayer(); - model_vrml->m_text_width = text->GetThickness(); - wxSize size = text->GetTextSize(); if( text->IsMirrored() ) size.x = -size.x; + int penWidth = text->GetEffectiveTextPenWidth( nullptr ); COLOR4D color = COLOR4D::BLACK; // not actually used, but needed by GRText + model_vrml->m_text_layer = text->GetLayer(); + model_vrml->m_text_width = penWidth; + if( text->IsMultilineAllowed() ) { wxArrayString strings_list; @@ -793,17 +794,16 @@ static void export_vrml_pcbtext( MODEL_VRML& aModel, TEXTE_PCB* text ) for( unsigned ii = 0; ii < strings_list.Count(); ii++ ) { - wxString& txt = strings_list.Item( ii ); - GRText( NULL, positions[ii], color, txt, text->GetTextAngle(), size, - text->GetHorizJustify(), text->GetVertJustify(), text->GetThickness(), - text->IsItalic(), true, vrml_text_callback ); + GRText( nullptr, positions[ii], color, strings_list[ii], text->GetTextAngle(), size, + text->GetHorizJustify(), text->GetVertJustify(), penWidth, text->IsItalic(), + true, vrml_text_callback ); } } else { - GRText( NULL, text->GetTextPos(), color, text->GetShownText(), text->GetTextAngle(), - size, text->GetHorizJustify(), text->GetVertJustify(), text->GetThickness(), - text->IsItalic(), true, vrml_text_callback ); + GRText( nullptr, text->GetTextPos(), color, text->GetShownText(), text->GetTextAngle(), + size, text->GetHorizJustify(), text->GetVertJustify(), penWidth, text->IsItalic(), + true, vrml_text_callback ); } } @@ -1057,12 +1057,14 @@ static void export_vrml_text_module( TEXTE_MODULE* item ) if( item->IsMirrored() ) size.x = -size.x; // Text is mirrored + int penWidth = item->GetEffectiveTextPenWidth( nullptr ); + model_vrml->m_text_layer = item->GetLayer(); - model_vrml->m_text_width = item->GetThickness(); + model_vrml->m_text_width = penWidth; GRText( NULL, item->GetTextPos(), BLACK, item->GetShownText(), item->GetDrawRotation(), - size, item->GetHorizJustify(), item->GetVertJustify(), item->GetThickness(), - item->IsItalic(), true, vrml_text_callback ); + size, item->GetHorizJustify(), item->GetVertJustify(), penWidth, item->IsItalic(), + true, vrml_text_callback ); } } diff --git a/pcbnew/footprint_libraries_utils.cpp b/pcbnew/footprint_libraries_utils.cpp index 2356df51ab..ace6f4b341 100644 --- a/pcbnew/footprint_libraries_utils.cpp +++ b/pcbnew/footprint_libraries_utils.cpp @@ -1058,7 +1058,7 @@ MODULE* PCB_BASE_FRAME::CreateNewModule( const wxString& aModuleName ) module->SetReference( settings.m_RefDefaultText ); PCB_LAYER_ID layer = ToLAYER_ID( settings.m_RefDefaultlayer ); - module->Reference().SetThickness( settings.GetTextThickness( layer ) ); + module->Reference().SetTextPenWidth( settings.GetTextThickness( layer ) ); module->Reference().SetTextSize( settings.GetTextSize( layer ) ); module->Reference().SetItalic( settings.GetTextItalic( layer ) ); module->Reference().SetKeepUpright( settings.GetTextUpright( layer ) ); @@ -1074,7 +1074,7 @@ MODULE* PCB_BASE_FRAME::CreateNewModule( const wxString& aModuleName ) module->SetValue( settings.m_ValueDefaultText ); layer = ToLAYER_ID( settings.m_ValueDefaultlayer ); - module->Value().SetThickness( settings.GetTextThickness( layer ) ); + module->Value().SetTextPenWidth( settings.GetTextThickness( layer ) ); module->Value().SetTextSize( settings.GetTextSize( layer ) ); module->Value().SetItalic( settings.GetTextItalic( layer ) ); module->Value().SetKeepUpright( settings.GetTextUpright( layer ) ); diff --git a/pcbnew/gpcb_plugin.cpp b/pcbnew/gpcb_plugin.cpp index ddc9f3e4e8..608f50cbe6 100644 --- a/pcbnew/gpcb_plugin.cpp +++ b/pcbnew/gpcb_plugin.cpp @@ -419,14 +419,14 @@ MODULE* GPCB_FPL_CACHE::parseMODULE( LINE_READER* aLineReader ) module->Reference().SetTextPos( textPos ); module->Reference().SetPos0( textPos ); module->Reference().SetTextSize( wxSize( twsize, thsize ) ); - module->Reference().SetThickness( thickness ); + module->Reference().SetTextPenWidth( thickness ); // gEDA/pcb shows only one of value/reference/description at a time. Which // one is selectable by a global menu setting. pcbnew needs reference as // well as value visible, so place the value right below the reference. module->Value().SetTextAngle( module->Reference().GetTextAngle() ); module->Value().SetTextSize( module->Reference().GetTextSize() ); - module->Value().SetThickness( module->Reference().GetThickness() ); + module->Value().SetTextPenWidth( module->Reference().GetTextPenWidth() ); textPos.y += thsize * 13 / 10; // 130% line height module->Value().SetTextPos( textPos ); module->Value().SetPos0( textPos ); diff --git a/pcbnew/import_gfx/graphics_importer_pcbnew.cpp b/pcbnew/import_gfx/graphics_importer_pcbnew.cpp index 199b333b14..806059adba 100644 --- a/pcbnew/import_gfx/graphics_importer_pcbnew.cpp +++ b/pcbnew/import_gfx/graphics_importer_pcbnew.cpp @@ -138,7 +138,7 @@ void GRAPHICS_IMPORTER_PCBNEW::AddText( const VECTOR2D& aOrigin, const wxString& EDA_TEXT* textItem; tie( boardItem, textItem ) = createText(); boardItem->SetLayer( GetLayer() ); - textItem->SetThickness( MapLineWidth( aThickness ) ); + textItem->SetTextPenWidth( MapLineWidth( aThickness ) ); textItem->SetTextPos( MapCoordinate( aOrigin ) ); textItem->SetTextAngle( aOrientation * 10.0 ); // Pcbnew uses the decidegree textItem->SetTextWidth( aWidth * ImportScalingFactor() ); diff --git a/pcbnew/legacy_plugin.cpp b/pcbnew/legacy_plugin.cpp index dd535022c7..866a15a944 100644 --- a/pcbnew/legacy_plugin.cpp +++ b/pcbnew/legacy_plugin.cpp @@ -1813,15 +1813,7 @@ void LEGACY_PLUGIN::loadMODULE_TEXT( TEXTE_MODULE* aText ) aText->SetTextAngle( orient ); - // Set a reasonable width: - if( thickn < 1 ) - thickn = 1; - - /* this is better left to the dialogs UIs - aText->SetThickness( Clamp_Text_PenSize( thickn, aText->GetSize() ) ); - */ - - aText->SetThickness( thickn ); + aText->SetTextPenWidth( thickn < 1 ? 0 : thickn ); aText->SetMirrored( mirror && *mirror == 'M' ); @@ -2137,8 +2129,7 @@ void LEGACY_PLUGIN::loadPCB_TEXT() double angle = degParse( data ); pcbtxt->SetTextSize( size ); - - pcbtxt->SetThickness( thickn ); + pcbtxt->SetTextPenWidth( thickn ); pcbtxt->SetTextAngle( angle ); pcbtxt->SetTextPos( wxPoint( pos_x, pos_y ) ); @@ -2776,7 +2767,7 @@ void LEGACY_PLUGIN::loadDIMENSION() dim->SetTextSize( wxSize( width, height ) ); dim->Text().SetMirrored( mirror && *mirror == '0' ); - dim->Text().SetThickness( thickn ); + dim->Text().SetTextPenWidth( thickn ); dim->Text().SetTextAngle( orient ); } diff --git a/pcbnew/microwave/microwave_footprint.cpp b/pcbnew/microwave/microwave_footprint.cpp index 7cbf4c609b..08e75ed257 100644 --- a/pcbnew/microwave/microwave_footprint.cpp +++ b/pcbnew/microwave/microwave_footprint.cpp @@ -190,9 +190,9 @@ MODULE* MICROWAVE_TOOL::createBaseFootprint( const wxString& aValue, if( aTextSize > 0 ) { module->Reference().SetTextSize( wxSize( aTextSize, aTextSize ) ); - module->Reference().SetThickness( aTextSize/5 ); + module->Reference().SetTextPenWidth( aTextSize/5 ); module->Value().SetTextSize( wxSize( aTextSize, aTextSize ) ); - module->Value().SetThickness( aTextSize/5 ); + module->Value().SetTextPenWidth( aTextSize/5 ); } // Create 2 pads used in gaps and stubs. The gap is between these 2 pads diff --git a/pcbnew/pcad2kicadpcb_plugin/pcb_module.cpp b/pcbnew/pcad2kicadpcb_plugin/pcb_module.cpp index fed9f108cf..b000a13a2a 100644 --- a/pcbnew/pcad2kicadpcb_plugin/pcb_module.cpp +++ b/pcbnew/pcad2kicadpcb_plugin/pcb_module.cpp @@ -503,12 +503,10 @@ void PCB_MODULE::AddToBoard() // transform text positions CorrectTextPosition( &m_name ); - RotatePoint( &m_name.correctedPositionX, &m_name.correctedPositionY, - (double) -m_rotation ); + RotatePoint( &m_name.correctedPositionX, &m_name.correctedPositionY, (double) -m_rotation ); CorrectTextPosition( &m_value ); - RotatePoint( &m_value.correctedPositionX, &m_value.correctedPositionY, - (double) -m_rotation ); + RotatePoint( &m_value.correctedPositionX, &m_value.correctedPositionY, (double) -m_rotation ); MODULE* module = new MODULE( m_board ); m_board->Add( module, ADD_MODE::APPEND ); @@ -541,7 +539,7 @@ void PCB_MODULE::AddToBoard() ref_text->SetKeepUpright( false ); ref_text->SetItalic( m_name.isItalic ); - ref_text->SetThickness( m_name.textstrokeWidth ); + ref_text->SetTextPenWidth( m_name.textstrokeWidth ); ref_text->SetMirrored( m_name.mirror ); ref_text->SetVisible( m_name.textIsVisible ); @@ -568,7 +566,7 @@ void PCB_MODULE::AddToBoard() val_text->SetKeepUpright( false ); val_text->SetItalic( m_value.isItalic ); - val_text->SetThickness( m_value.textstrokeWidth ); + val_text->SetTextPenWidth( m_value.textstrokeWidth ); val_text->SetMirrored( m_value.mirror ); val_text->SetVisible( m_value.textIsVisible ); diff --git a/pcbnew/pcad2kicadpcb_plugin/pcb_text.cpp b/pcbnew/pcad2kicadpcb_plugin/pcb_text.cpp index 89b939df0b..0b583d5997 100644 --- a/pcbnew/pcad2kicadpcb_plugin/pcb_text.cpp +++ b/pcbnew/pcad2kicadpcb_plugin/pcb_text.cpp @@ -115,7 +115,7 @@ void PCB_TEXT::AddToBoard() SetTextSizeFromStrokeFontHeight( pcbtxt, m_name.textHeight ); pcbtxt->SetItalic( m_name.isItalic ); - pcbtxt->SetThickness( m_name.textstrokeWidth ); + pcbtxt->SetTextPenWidth( m_name.textstrokeWidth ); SetTextJustify( pcbtxt, m_name.justify ); pcbtxt->SetTextPos( wxPoint( m_name.textPositionX, diff --git a/pcbnew/pcb_painter.cpp b/pcbnew/pcb_painter.cpp index 4e5c31e689..85845e03d2 100644 --- a/pcbnew/pcb_painter.cpp +++ b/pcbnew/pcb_painter.cpp @@ -1016,7 +1016,7 @@ void PCB_PAINTER::draw( const TEXTE_PCB* aText, int aLayer ) else { // Filled mode - m_gal->SetLineWidth( getLineThickness( aText->GetThickness() ) ); + m_gal->SetLineWidth( getLineThickness( aText->GetEffectiveTextPenWidth( nullptr ) ) ); // JEY TODO: requires RENDER_SETTINGS } m_gal->SetStrokeColor( color ); @@ -1048,14 +1048,15 @@ void PCB_PAINTER::draw( const TEXTE_MODULE* aText, int aLayer ) else { // Filled mode - m_gal->SetLineWidth( getLineThickness( aText->GetThickness() ) ); + m_gal->SetLineWidth( getLineThickness( aText->GetEffectiveTextPenWidth( nullptr ) ) ); // JEY TODO: requires RENDER_SETTINGS } m_gal->SetStrokeColor( color ); m_gal->SetIsFill( false ); m_gal->SetIsStroke( true ); m_gal->SetTextAttributes( aText ); - m_gal->StrokeText( shownText, position, aText->GetDrawRotationRadians(), GetTextMarkupFlags() ); + m_gal->StrokeText( shownText, position, aText->GetDrawRotationRadians(), + GetTextMarkupFlags() ); // JEY TODO: requires RENDER_SETTINGS // Draw the umbilical line if( aText->IsSelected() ) @@ -1183,10 +1184,10 @@ void PCB_PAINTER::draw( const DIMENSION* aDimension, int aLayer ) TEXTE_PCB& text = aDimension->Text(); VECTOR2D position( text.GetTextPos().x, text.GetTextPos().y ); - m_gal->SetLineWidth( text.GetThickness() ); + m_gal->SetLineWidth( getLineThickness( text.GetEffectiveTextPenWidth( nullptr ) ) ); // JEY TODO: requires RENDER_SETTINGS m_gal->SetTextAttributes( &text ); m_gal->StrokeText( text.GetShownText(), position, text.GetTextAngleRadians(), - GetTextMarkupFlags() ); + GetTextMarkupFlags() ); // JEY TODO: requires RENDER_SETTINGS } diff --git a/pcbnew/pcb_parser.cpp b/pcbnew/pcb_parser.cpp index 982a9879ed..677def3cf5 100644 --- a/pcbnew/pcb_parser.cpp +++ b/pcbnew/pcb_parser.cpp @@ -300,7 +300,7 @@ void PCB_PARSER::parseEDA_TEXT( EDA_TEXT* aText ) break; case T_thickness: - aText->SetThickness( parseBoardUnits( "text thickness" ) ); + aText->SetTextPenWidth( parseBoardUnits( "text thickness" ) ); NeedRIGHT(); break; diff --git a/pcbnew/plot_brditems_plotter.cpp b/pcbnew/plot_brditems_plotter.cpp index 22e3bd28be..c9d7f9cdf4 100644 --- a/pcbnew/plot_brditems_plotter.cpp +++ b/pcbnew/plot_brditems_plotter.cpp @@ -361,7 +361,7 @@ void BRDITEMS_PLOTTER::PlotTextModule( TEXTE_MODULE* pt_texte, COLOR4D aColor ) orient = pt_texte->GetDrawRotation(); - thickness = pt_texte->GetThickness(); + thickness = pt_texte->GetEffectiveTextPenWidth( nullptr ); if( pt_texte->IsMirrored() ) size.x = -size.x; // Text is mirrored @@ -653,7 +653,7 @@ void BRDITEMS_PLOTTER::PlotTextePcb( TEXTE_PCB* pt_texte ) size = pt_texte->GetTextSize(); pos = pt_texte->GetTextPos(); orient = pt_texte->GetTextAngle(); - thickness = pt_texte->GetThickness(); + thickness = pt_texte->GetEffectiveTextPenWidth( nullptr ); if( pt_texte->IsMirrored() ) size.x = -size.x; diff --git a/pcbnew/router/pns_kicad_iface.cpp b/pcbnew/router/pns_kicad_iface.cpp index ea39fdb2f2..3203e2a549 100644 --- a/pcbnew/router/pns_kicad_iface.cpp +++ b/pcbnew/router/pns_kicad_iface.cpp @@ -942,7 +942,7 @@ bool PNS_KICAD_IFACE_BASE::syncTextItem( PNS::NODE* aWorld, EDA_TEXT* aText, PCB if( !IsCopperLayer( aLayer ) ) return false; - int textWidth = aText->GetThickness(); + int textWidth = aText->GetEffectiveTextPenWidth( nullptr ); // JEY TODO: requires RENDER_SETTINGS std::vector textShape; aText->TransformTextShapeToSegmentList( textShape ); diff --git a/pcbnew/text_mod_grid_table.cpp b/pcbnew/text_mod_grid_table.cpp index 35d243523e..2bec139d10 100644 --- a/pcbnew/text_mod_grid_table.cpp +++ b/pcbnew/text_mod_grid_table.cpp @@ -195,7 +195,7 @@ wxString TEXT_MOD_GRID_TABLE::GetValue( int aRow, int aCol ) return StringFromValue( m_userUnits, text.GetTextHeight(), true, true ); case TMC_THICKNESS: - return StringFromValue( m_userUnits, text.GetThickness(), true, true ); + return StringFromValue( m_userUnits, text.GetTextPenWidth(), true, true ); case TMC_LAYER: return text.GetLayerName(); @@ -268,7 +268,7 @@ void TEXT_MOD_GRID_TABLE::SetValue( int aRow, int aCol, const wxString &aValue ) break; case TMC_THICKNESS: - text.SetThickness( ValueFromString( m_userUnits, aValue, true ) ); + text.SetTextPenWidth( ValueFromString( m_userUnits, aValue, true ) ); break; case TMC_ORIENTATION: diff --git a/pcbnew/tools/drawing_tool.cpp b/pcbnew/tools/drawing_tool.cpp index 26bad4e519..4f41dfe1de 100644 --- a/pcbnew/tools/drawing_tool.cpp +++ b/pcbnew/tools/drawing_tool.cpp @@ -347,7 +347,7 @@ int DRAWING_TOOL::PlaceText( const TOOL_EVENT& aEvent ) textMod->SetLayer( layer ); textMod->SetTextSize( dsnSettings.GetTextSize( layer ) ); - textMod->SetThickness( dsnSettings.GetTextThickness( layer ) ); + textMod->SetTextPenWidth( dsnSettings.GetTextThickness( layer ) ); textMod->SetItalic( dsnSettings.GetTextItalic( layer ) ); textMod->SetKeepUpright( dsnSettings.GetTextUpright( layer ) ); textMod->SetTextPos( (wxPoint) cursorPos ); @@ -386,7 +386,7 @@ int DRAWING_TOOL::PlaceText( const TOOL_EVENT& aEvent ) textPcb->SetMirrored( true ); textPcb->SetTextSize( dsnSettings.GetTextSize( layer ) ); - textPcb->SetThickness( dsnSettings.GetTextThickness( layer ) ); + textPcb->SetTextPenWidth( dsnSettings.GetTextThickness( layer ) ); textPcb->SetItalic( dsnSettings.GetTextItalic( layer ) ); textPcb->SetTextPos( (wxPoint) cursorPos ); @@ -596,7 +596,7 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent ) dimension->SetOrigin( (wxPoint) cursorPos, boardSettings.m_DimensionPrecision ); dimension->SetEnd( (wxPoint) cursorPos, boardSettings.m_DimensionPrecision ); dimension->Text().SetTextSize( boardSettings.GetTextSize( layer ) ); - dimension->Text().SetThickness( boardSettings.GetTextThickness( layer ) ); + dimension->Text().SetTextPenWidth( boardSettings.GetTextThickness( layer ) ); dimension->Text().SetItalic( boardSettings.GetTextItalic( layer ) ); dimension->SetWidth( boardSettings.GetLineThickness( layer ) ); dimension->SetUnits( boardSettings.m_DimensionUnits == 2 ? EDA_UNITS::MILLIMETRES : diff --git a/pcbnew/tools/pcb_actions.h b/pcbnew/tools/pcb_actions.h index 16a9044996..6bd09a4a67 100644 --- a/pcbnew/tools/pcb_actions.h +++ b/pcbnew/tools/pcb_actions.h @@ -359,7 +359,8 @@ public: /// Display module edges as outlines static TOOL_ACTION moduleEdgeOutlines; - /// Display module texts as lines + /// Display module texts as lines // JEY TODO: if we're going to keep this, it needs + // to be all text, not just module text.... static TOOL_ACTION moduleTextOutlines; // Pad tools diff --git a/pcbnew/tools/pcbnew_control.cpp b/pcbnew/tools/pcbnew_control.cpp index 1691cb5ea5..af69e0242c 100644 --- a/pcbnew/tools/pcbnew_control.cpp +++ b/pcbnew/tools/pcbnew_control.cpp @@ -1158,7 +1158,6 @@ void PCBNEW_CONTROL::setTransitions() Go( &PCBNEW_CONTROL::ViaDisplayMode, PCB_ACTIONS::viaDisplayMode.MakeEvent() ); Go( &PCBNEW_CONTROL::GraphicDisplayMode, PCB_ACTIONS::graphicDisplayMode.MakeEvent() ); Go( &PCBNEW_CONTROL::ModuleEdgeOutlines, PCB_ACTIONS::moduleEdgeOutlines.MakeEvent() ); - Go( &PCBNEW_CONTROL::ModuleTextOutlines, PCB_ACTIONS::moduleTextOutlines.MakeEvent() ); Go( &PCBNEW_CONTROL::ZoneDisplayMode, PCB_ACTIONS::zoneDisplayEnable.MakeEvent() ); Go( &PCBNEW_CONTROL::ZoneDisplayMode, PCB_ACTIONS::zoneDisplayDisable.MakeEvent() ); Go( &PCBNEW_CONTROL::ZoneDisplayMode, PCB_ACTIONS::zoneDisplayOutlines.MakeEvent() );