From 0c459ced972db24ff70b4efbbc672bbe1ab1f92d Mon Sep 17 00:00:00 2001 From: Dick Hollenbeck Date: Mon, 23 Jan 2017 14:30:11 -0600 Subject: [PATCH] EDA_TEXT object refactor. Make all EDA_TEXT data private and rename accessors to avoid function name collisions in derived classes. Overload EDA_TEXT's SetTextAngle() and SetEffects() in TEXTE_PCB. Add support for preserving Reference text position, size, orientation during a netlist import into a BOARD, as well as the one off footprint update dialog. --- 3d-viewer/3d_canvas/create_layer_items.cpp | 12 +- common/common_plot_functions.cpp | 6 +- common/drawtxt.cpp | 3 +- common/eda_text.cpp | 186 +++--- common/gal/graphics_abstraction_layer.cpp | 3 +- .../page_layout/class_worksheet_dataitem.cpp | 2 +- .../page_layout/page_layout_graphic_items.cpp | 8 +- common/worksheet_viewitem.cpp | 4 +- eeschema/autoplace_fields.cpp | 4 +- .../dialog_edit_component_in_schematic.cpp | 46 +- eeschema/dialogs/dialog_edit_label.cpp | 12 +- .../dialog_edit_libentry_fields_in_lib.cpp | 20 +- eeschema/dialogs/dialog_edit_one_field.cpp | 8 +- eeschema/dialogs/dialog_lib_edit_text.cpp | 45 +- eeschema/edit_component_in_schematic.cpp | 6 +- eeschema/edit_label.cpp | 14 +- eeschema/lib_field.cpp | 211 +++--- eeschema/lib_field.h | 29 +- eeschema/lib_pin.cpp | 52 +- eeschema/lib_text.cpp | 169 ++--- eeschema/lib_text.h | 6 +- eeschema/libeditframe.cpp | 2 +- eeschema/libeditframe.h | 4 +- eeschema/sch_component.cpp | 36 +- eeschema/sch_field.cpp | 128 ++-- eeschema/sch_field.h | 14 +- eeschema/sch_legacy_plugin.cpp | 52 +- eeschema/sch_screen.cpp | 10 +- eeschema/sch_sheet.cpp | 8 +- eeschema/sch_sheet.h | 2 +- eeschema/sch_sheet_pin.cpp | 76 +-- eeschema/sch_text.cpp | 609 ++++++++++-------- eeschema/sch_text.h | 41 +- eeschema/sheetlab.cpp | 17 +- eeschema/symbdraw.cpp | 17 +- gerbview/class_gbr_layout.cpp | 4 +- include/common.h | 9 +- include/eda_text.h | 213 +++--- include/macros.h | 7 +- include/trigo.h | 43 +- include/worksheet_shape_builder.h | 5 + pcbnew/autorouter/routing_matrix.cpp | 4 +- pcbnew/block_module_editor.cpp | 6 +- ...board_items_to_polygon_shape_transform.cpp | 18 +- pcbnew/class_board.cpp | 10 + pcbnew/class_dimension.cpp | 27 +- pcbnew/class_dimension.h | 6 +- pcbnew/class_drawsegment.cpp | 4 +- pcbnew/class_module.cpp | 7 +- pcbnew/class_pad.cpp | 4 +- pcbnew/class_pcb_text.cpp | 41 +- pcbnew/class_pcb_text.h | 8 +- pcbnew/class_text_mod.cpp | 89 +-- pcbnew/class_text_mod.h | 35 +- .../dialog_edit_module_for_BoardEditor.cpp | 4 +- .../dialog_edit_module_for_Modedit.cpp | 4 +- pcbnew/dialogs/dialog_edit_module_text.cpp | 26 +- .../dialog_global_modules_fields_edition.cpp | 12 +- ...og_graphic_item_properties_for_Modedit.cpp | 2 +- pcbnew/dialogs/dialog_pcb_text_properties.cpp | 20 +- pcbnew/dimension.cpp | 34 +- pcbnew/eagle_plugin.cpp | 37 +- pcbnew/edit_pcb_text.cpp | 18 +- pcbnew/edtxtmod.cpp | 30 +- pcbnew/exporters/export_gencad.cpp | 8 +- pcbnew/exporters/export_vrml.cpp | 12 +- pcbnew/gpcb_plugin.cpp | 12 +- pcbnew/import_dxf/dxf2brd_items.cpp | 16 +- pcbnew/kicad_plugin.cpp | 43 +- pcbnew/legacy_plugin.cpp | 12 +- pcbnew/librairi.cpp | 4 +- pcbnew/muonde.cpp | 8 +- .../pcad2kicad_common.cpp | 6 +- pcbnew/pcad2kicadpcb_plugin/pcb_module.cpp | 4 +- pcbnew/pcad2kicadpcb_plugin/pcb_text.cpp | 6 +- pcbnew/pcb_painter.cpp | 14 +- pcbnew/pcb_parser.cpp | 26 +- pcbnew/plot_brditems_plotter.cpp | 10 +- pcbnew/tools/drawing_tool.cpp | 31 +- pcbnew/xchgmod.cpp | 10 + 80 files changed, 1530 insertions(+), 1281 deletions(-) diff --git a/3d-viewer/3d_canvas/create_layer_items.cpp b/3d-viewer/3d_canvas/create_layer_items.cpp index 4c10d5e2da..f080707974 100644 --- a/3d-viewer/3d_canvas/create_layer_items.cpp +++ b/3d-viewer/3d_canvas/create_layer_items.cpp @@ -93,7 +93,7 @@ void CINFO3D_VISU::AddShapeWithClearanceToContainer( const TEXTE_PCB* aTextPCB, LAYER_ID aLayerId, int aClearanceValue ) { - wxSize size = aTextPCB->GetSize(); + wxSize size = aTextPCB->GetTextSize(); if( aTextPCB->IsMirrored() ) size.x = -size.x; @@ -121,7 +121,7 @@ void CINFO3D_VISU::AddShapeWithClearanceToContainer( const TEXTE_PCB* aTextPCB, wxString txt = strings_list.Item( ii ); DrawGraphicText( NULL, NULL, positions[ii], dummy_color, - txt, aTextPCB->GetOrientation(), size, + txt, aTextPCB->GetTextAngle(), size, aTextPCB->GetHorizJustify(), aTextPCB->GetVertJustify(), aTextPCB->GetThickness(), aTextPCB->IsItalic(), true, addTextSegmToContainer ); @@ -129,8 +129,8 @@ void CINFO3D_VISU::AddShapeWithClearanceToContainer( const TEXTE_PCB* aTextPCB, } else { - DrawGraphicText( NULL, NULL, aTextPCB->GetTextPosition(), dummy_color, - aTextPCB->GetShownText(), aTextPCB->GetOrientation(), size, + DrawGraphicText( NULL, NULL, aTextPCB->GetTextPos(), dummy_color, + aTextPCB->GetShownText(), aTextPCB->GetTextAngle(), size, aTextPCB->GetHorizJustify(), aTextPCB->GetVertJustify(), aTextPCB->GetThickness(), aTextPCB->IsItalic(), true, addTextSegmToContainer ); @@ -199,12 +199,12 @@ void CINFO3D_VISU::AddGraphicsShapesWithClearanceToContainer( const MODULE* aMod { TEXTE_MODULE *textmod = texts[ii]; s_textWidth = textmod->GetThickness() + ( 2 * aInflateValue ); - wxSize size = textmod->GetSize(); + wxSize size = textmod->GetTextSize(); if( textmod->IsMirrored() ) size.x = -size.x; - DrawGraphicText( NULL, NULL, textmod->GetTextPosition(), BLACK, + DrawGraphicText( NULL, NULL, textmod->GetTextPos(), BLACK, textmod->GetShownText(), textmod->GetDrawRotation(), size, textmod->GetHorizJustify(), textmod->GetVertJustify(), textmod->GetThickness(), textmod->IsItalic(), diff --git a/common/common_plot_functions.cpp b/common/common_plot_functions.cpp index cda3788152..815479670a 100644 --- a/common/common_plot_functions.cpp +++ b/common/common_plot_functions.cpp @@ -128,9 +128,9 @@ void PlotWorkSheet( PLOTTER* plotter, const TITLE_BLOCK& aTitleBlock, case WS_DRAW_ITEM_BASE::wsg_text: { WS_DRAW_ITEM_TEXT* text = (WS_DRAW_ITEM_TEXT*) item; - plotter->Text( text->GetTextPosition(), text->GetColor(), - text->GetShownText(), text->GetOrientation(), - text->GetSize(), + plotter->Text( text->GetTextPos(), text->GetColor(), + text->GetShownText(), text->GetTextAngle(), + text->GetTextSize(), text->GetHorizJustify(), text->GetVertJustify(), text->GetPenWidth(), text->IsItalic(), text->IsBold(), diff --git a/common/drawtxt.cpp b/common/drawtxt.cpp index 85e6449015..85ca77681b 100644 --- a/common/drawtxt.cpp +++ b/common/drawtxt.cpp @@ -160,7 +160,7 @@ void DrawGraphicText( EDA_RECT* aClipBox, if( size.x < 0 ) size.x = - size.x; - dummy.SetSize( size ); + dummy.SetTextSize( size ); basic_gal.SetTextAttributes( &dummy ); basic_gal.SetPlotter( aPlotter ); @@ -172,6 +172,7 @@ void DrawGraphicText( EDA_RECT* aClipBox, basic_gal.StrokeText( aText, VECTOR2D( aPos ), aOrient * M_PI/1800 ); } + void DrawGraphicHaloText( EDA_RECT* aClipBox, wxDC * aDC, const wxPoint &aPos, enum EDA_COLOR_T aBgColor, diff --git a/common/eda_text.cpp b/common/eda_text.cpp index 6500c6eec1..cd917498a1 100644 --- a/common/eda_text.cpp +++ b/common/eda_text.cpp @@ -50,19 +50,12 @@ #include -EDA_TEXT::EDA_TEXT( const wxString& text ) +EDA_TEXT::EDA_TEXT( const wxString& text ) : + m_Text( text ), + m_e( 1< positions; wxArrayString strings; wxStringSplit( GetShownText(), strings, '\n' ); + positions.reserve( strings.Count() ); - GetPositionsOfLinesOfMultilineText(positions, strings.Count() ); + GetPositionsOfLinesOfMultilineText( positions, strings.Count() ); for( unsigned ii = 0; ii < strings.Count(); ii++ ) { @@ -315,13 +311,13 @@ void EDA_TEXT::Draw( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset, } else drawOneLineOfText( aClipBox, aDC, aOffset, aColor, - aDrawMode, aFillMode, GetShownText(), m_Pos ); + aDrawMode, aFillMode, GetShownText(), GetTextPos() ); // Draw text anchor, if requested if( aAnchor_color != UNSPECIFIED_COLOR ) { GRDrawAnchor( aClipBox, aDC, - m_Pos.x + aOffset.x, m_Pos.y + aOffset.y, + GetTextPos().x + aOffset.x, GetTextPos().y + aOffset.y, DIM_ANCRE_TEXTE, aAnchor_color ); } } @@ -330,17 +326,17 @@ void EDA_TEXT::Draw( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset, void EDA_TEXT::GetPositionsOfLinesOfMultilineText( std::vector& aPositions, int aLineCount ) const { - wxPoint pos = m_Pos; // Position of first line of the - // multiline text according to - // the center of the multiline text block + wxPoint pos = GetTextPos(); // Position of first line of the + // multiline text according to + // the center of the multiline text block - wxPoint offset; // Offset to next line. + wxPoint offset; // Offset to next line. offset.y = GetInterline(); if( aLineCount > 1 ) { - switch( m_VJustify ) + switch( GetVertJustify() ) { case GR_TEXT_VJUSTIFY_TOP: break; @@ -357,10 +353,10 @@ void EDA_TEXT::GetPositionsOfLinesOfMultilineText( // Rotate the position of the first line // around the center of the multiline text block - RotatePoint( &pos, m_Pos, m_Orient ); + RotatePoint( &pos, GetTextPos(), GetTextAngle() ); // Rotate the offset lines to increase happened in the right direction - RotatePoint( &offset, m_Orient ); + RotatePoint( &offset, GetTextAngle() ); for( int ii = 0; ii < aLineCount; ii++ ) { @@ -374,7 +370,7 @@ void EDA_TEXT::drawOneLineOfText( EDA_RECT* aClipBox, wxDC* aDC, GR_DRAWMODE aDrawMode, EDA_DRAW_MODE_T aFillMode, const wxString& aText, const wxPoint &aPos ) { - int width = m_Thickness; + int width = GetThickness(); if( aDrawMode != UNSPECIFIED_DRAWMODE ) GRSetDrawMode( aDC, aDrawMode ); @@ -382,13 +378,14 @@ void EDA_TEXT::drawOneLineOfText( EDA_RECT* aClipBox, wxDC* aDC, if( aFillMode == SKETCH ) width = -width; - wxSize size = m_Size; + wxSize size = GetTextSize(); - if( m_Mirror ) + if( IsMirrored() ) size.x = -size.x; - DrawGraphicText( aClipBox, aDC, aOffset + aPos, aColor, aText, m_Orient, size, - m_HJustify, m_VJustify, width, m_Italic, m_Bold ); + DrawGraphicText( aClipBox, aDC, aOffset + aPos, aColor, aText, GetTextAngle(), size, + GetHorizJustify(), GetVertJustify(), + width, IsItalic(), IsBold() ); } @@ -396,10 +393,10 @@ wxString EDA_TEXT::GetTextStyleName() { int style = 0; - if( m_Italic ) + if( IsItalic() ) style = 1; - if( m_Bold ) + if( IsBold() ) style += 2; wxString stylemsg[4] = { @@ -415,16 +412,17 @@ wxString EDA_TEXT::GetTextStyleName() bool EDA_TEXT::IsDefaultFormatting() const { - return ( ( m_Size.x == Mils2iu( DEFAULT_SIZE_TEXT ) ) - && ( m_Size.y == Mils2iu( DEFAULT_SIZE_TEXT ) ) - && ( m_Attributs == 0 ) - && ( m_Mirror == false ) - && ( m_HJustify == GR_TEXT_HJUSTIFY_CENTER ) - && ( m_VJustify == GR_TEXT_VJUSTIFY_CENTER ) - && ( m_Thickness == 0 ) - && ( m_Italic == false ) - && ( m_Bold == false ) - && ( m_MultilineAllowed == false ) ); + return ( GetTextWidth() == Mils2iu( DEFAULT_SIZE_TEXT ) + && GetTextHeight() == Mils2iu( DEFAULT_SIZE_TEXT ) + && IsVisible() + && !IsMirrored() + && GetHorizJustify() == GR_TEXT_HJUSTIFY_CENTER + && GetVertJustify() == GR_TEXT_VJUSTIFY_CENTER + && GetThickness() == 0 + && !IsItalic() + && !IsBold() + && !IsMultilineAllowed() + ); } void EDA_TEXT::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const @@ -437,23 +435,27 @@ void EDA_TEXT::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControl { aFormatter->Print( aNestLevel+1, "(effects" ); - if( ( m_Size.x != Mils2iu( DEFAULT_SIZE_TEXT ) ) - || ( m_Size.y != Mils2iu( DEFAULT_SIZE_TEXT ) ) - || ( m_Thickness != 0 ) || m_Bold || m_Italic ) + if( ( GetTextWidth() != Mils2iu( DEFAULT_SIZE_TEXT ) ) + || ( GetTextHeight() != Mils2iu( DEFAULT_SIZE_TEXT ) ) + || ( GetThickness() != 0 ) || IsBold() || IsItalic() ) { aFormatter->Print( 0, " (font" ); // Add font support here at some point in the future. - if( ( m_Size.x != Mils2iu( DEFAULT_SIZE_TEXT ) ) - || ( m_Size.y != Mils2iu( DEFAULT_SIZE_TEXT ) ) ) - aFormatter->Print( 0, " (size %s %s)", FMT_IU( m_Size.GetHeight() ).c_str(), - FMT_IU( m_Size.GetWidth() ).c_str() ); + if( GetTextWidth() != Mils2iu( DEFAULT_SIZE_TEXT ) + || GetTextHeight() != Mils2iu( DEFAULT_SIZE_TEXT ) ) + { + aFormatter->Print( 0, " (size %s %s)", + FMT_IU( GetTextHeight() ).c_str(), + FMT_IU( GetTextWidth() ).c_str() + ); + } - if( m_Thickness != 0 ) + if( GetThickness() ) aFormatter->Print( 0, " (thickness %s)", FMT_IU( GetThickness() ).c_str() ); - if( m_Bold ) + if( IsBold() ) aFormatter->Print( 0, " bold" ); if( IsItalic() ) @@ -462,25 +464,25 @@ void EDA_TEXT::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControl aFormatter->Print( 0, ")"); } - if( m_Mirror || ( m_HJustify != GR_TEXT_HJUSTIFY_CENTER ) - || ( m_VJustify != GR_TEXT_VJUSTIFY_CENTER ) ) + if( IsMirrored() || ( GetHorizJustify() != GR_TEXT_HJUSTIFY_CENTER ) + || ( GetVertJustify() != GR_TEXT_VJUSTIFY_CENTER ) ) { aFormatter->Print( 0, " (justify"); - if( m_HJustify != GR_TEXT_HJUSTIFY_CENTER ) - aFormatter->Print( 0, (m_HJustify == GR_TEXT_HJUSTIFY_LEFT) ? " left" : " right" ); + if( GetHorizJustify() != GR_TEXT_HJUSTIFY_CENTER ) + aFormatter->Print( 0, (GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT) ? " left" : " right" ); - if( m_VJustify != GR_TEXT_VJUSTIFY_CENTER ) - aFormatter->Print( 0, (m_VJustify == GR_TEXT_VJUSTIFY_TOP) ? " top" : " bottom" ); + if( GetVertJustify() != GR_TEXT_VJUSTIFY_CENTER ) + aFormatter->Print( 0, (GetVertJustify() == GR_TEXT_VJUSTIFY_TOP) ? " top" : " bottom" ); - if( m_Mirror ) + if( IsMirrored() ) aFormatter->Print( 0, " mirror" ); aFormatter->Print( 0, ")" ); } // As of now the only place this is used is in Eeschema to hide or show the text. - if( m_Attributs ) + if( !IsVisible() ) aFormatter->Print( 0, " hide" ); aFormatter->Print( 0, ")\n" ); @@ -503,7 +505,7 @@ static void addTextSegmToBuffer( int x0, int y0, int xf, int yf ) void EDA_TEXT::TransformTextShapeToSegmentList( std::vector& aCornerBuffer ) const { - wxSize size = GetSize(); + wxSize size = GetTextSize(); if( IsMirrored() ) size.x = -size.x; @@ -523,7 +525,7 @@ void EDA_TEXT::TransformTextShapeToSegmentList( std::vector& aCornerBuf { wxString txt = strings_list.Item( ii ); DrawGraphicText( NULL, NULL, positions[ii], color, - txt, GetOrientation(), size, + txt, GetTextAngle(), size, GetHorizJustify(), GetVertJustify(), GetThickness(), IsItalic(), true, addTextSegmToBuffer ); @@ -531,8 +533,8 @@ void EDA_TEXT::TransformTextShapeToSegmentList( std::vector& aCornerBuf } else { - DrawGraphicText( NULL, NULL, GetTextPosition(), color, - GetText(), GetOrientation(), size, + DrawGraphicText( NULL, NULL, GetTextPos(), color, + GetText(), GetTextAngle(), size, GetHorizJustify(), GetVertJustify(), GetThickness(), IsItalic(), true, addTextSegmToBuffer ); diff --git a/common/gal/graphics_abstraction_layer.cpp b/common/gal/graphics_abstraction_layer.cpp index 113690fda6..8ba184ea2f 100644 --- a/common/gal/graphics_abstraction_layer.cpp +++ b/common/gal/graphics_abstraction_layer.cpp @@ -78,7 +78,7 @@ GAL::~GAL() void GAL::SetTextAttributes( const EDA_TEXT* aText ) { - SetGlyphSize( VECTOR2D( aText->GetSize() ) ); + SetGlyphSize( VECTOR2D( aText->GetTextSize() ) ); SetHorizontalJustify( aText->GetHorizJustify() ); SetVerticalJustify( aText->GetVertJustify() ); SetFontBold( aText->IsBold() ); @@ -86,6 +86,7 @@ void GAL::SetTextAttributes( const EDA_TEXT* aText ) SetTextMirrored( aText->IsMirrored() ); } + VECTOR2D GAL::GetTextLineSize( const UTF8& aText ) const { // Compute the X and Y size of a given text. diff --git a/common/page_layout/class_worksheet_dataitem.cpp b/common/page_layout/class_worksheet_dataitem.cpp index 40d707d262..3faf86bf2c 100644 --- a/common/page_layout/class_worksheet_dataitem.cpp +++ b/common/page_layout/class_worksheet_dataitem.cpp @@ -467,7 +467,7 @@ void WORKSHEET_DATAITEM_TEXT::TransfertSetupToGraphicText( WS_DRAW_ITEM_TEXT* aG { aGText->SetHorizJustify( m_Hjustify ) ; aGText->SetVertJustify( m_Vjustify ); - aGText->SetOrientation( m_Orient * 10 ); // graphic text orient unit = 0.1 degree + aGText->SetTextAngle( m_Orient * 10 ); // graphic text orient unit = 0.1 degree } diff --git a/common/page_layout/page_layout_graphic_items.cpp b/common/page_layout/page_layout_graphic_items.cpp index dc424b5d43..21dd1dd28d 100644 --- a/common/page_layout/page_layout_graphic_items.cpp +++ b/common/page_layout/page_layout_graphic_items.cpp @@ -140,7 +140,7 @@ void WS_DRAW_ITEM_LIST::Draw( EDA_RECT* aClipBox, wxDC* aDC ) WS_DRAW_ITEM_TEXT* text = (WS_DRAW_ITEM_TEXT*) item; if( markerSize ) - drawMarker( aClipBox, aDC, text->GetTextPosition(), + drawMarker( aClipBox, aDC, text->GetTextPos(), markerSize ); } break; @@ -179,8 +179,8 @@ WS_DRAW_ITEM_TEXT::WS_DRAW_ITEM_TEXT( WORKSHEET_DATAITEM* aParent, bool aItalic, bool aBold ) : WS_DRAW_ITEM_BASE( aParent, wsg_text, aColor ), EDA_TEXT( aText ) { - SetTextPosition( aPos ); - SetSize( aSize ); + SetTextPos( aPos ); + SetTextSize( aSize ); SetThickness( aPenWidth ); SetItalic( aItalic ); SetBold( aBold ); @@ -211,7 +211,7 @@ bool WS_DRAW_ITEM_TEXT::HitTest( const EDA_RECT& aRect ) const bool WS_DRAW_ITEM_TEXT::HitTestStartPoint( const wxPoint& aPosition) { - wxPoint pos = GetTextPosition(); + wxPoint pos = GetTextPos(); if( std::abs( pos.x - aPosition.x) <= WORKSHEET_DATAITEM::GetMarkerSizeUi()/2 && std::abs( pos.y - aPosition.y) <= WORKSHEET_DATAITEM::GetMarkerSizeUi()/2 ) diff --git a/common/worksheet_viewitem.cpp b/common/worksheet_viewitem.cpp index 2a2af1bf6b..c546379a45 100644 --- a/common/worksheet_viewitem.cpp +++ b/common/worksheet_viewitem.cpp @@ -184,11 +184,11 @@ void WORKSHEET_VIEWITEM::draw( const WS_DRAW_ITEM_POLYGON* aItem, GAL* aGal ) co void WORKSHEET_VIEWITEM::draw( const WS_DRAW_ITEM_TEXT* aItem, GAL* aGal ) const { - VECTOR2D position( aItem->GetTextPosition().x, aItem->GetTextPosition().y ); + VECTOR2D position( aItem->GetTextPos().x, aItem->GetTextPos().y ); aGal->Save(); aGal->Translate( position ); - aGal->Rotate( -aItem->GetOrientation() * M_PI / 1800.0 ); + aGal->Rotate( -aItem->GetTextAngle() * M_PI / 1800.0 ); aGal->SetStrokeColor( COLOR4D( aItem->GetColor() ) ); aGal->SetLineWidth( aItem->GetThickness() ); aGal->SetTextAttributes( aItem ); diff --git a/eeschema/autoplace_fields.cpp b/eeschema/autoplace_fields.cpp index cccf155c7f..e15dadf52a 100644 --- a/eeschema/autoplace_fields.cpp +++ b/eeschema/autoplace_fields.cpp @@ -195,11 +195,11 @@ protected: if( m_component->GetTransform().y1 ) { - field->SetOrientation( TEXT_ORIENT_VERT ); + field->SetTextAngle( TEXT_ANGLE_VERT ); } else { - field->SetOrientation( TEXT_ORIENT_HORIZ ); + field->SetTextAngle( TEXT_ANGLE_HORIZ ); } field_width = field->GetBoundingBox().GetWidth(); diff --git a/eeschema/dialogs/dialog_edit_component_in_schematic.cpp b/eeschema/dialogs/dialog_edit_component_in_schematic.cpp index 66d17b3fca..5b18548a55 100644 --- a/eeschema/dialogs/dialog_edit_component_in_schematic.cpp +++ b/eeschema/dialogs/dialog_edit_component_in_schematic.cpp @@ -480,7 +480,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnOKButtonClick( wxCommandEvent& event // change all field positions from relative to absolute for( unsigned i = 0; im_Pos ); + m_FieldsBuf[i].Offset( m_cmp->m_Pos ); } LIB_PART* entry = Prj().SchLibs()->FindLibPart( m_cmp->m_part_name ); @@ -514,7 +514,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::addFieldButtonHandler( wxCommandEvent& SCH_FIELD blank( wxPoint(), fieldNdx, m_cmp ); - blank.SetOrientation( m_FieldsBuf[REFERENCE].GetOrientation() ); + blank.SetTextAngle( m_FieldsBuf[REFERENCE].GetTextAngle() ); m_FieldsBuf.push_back( blank ); m_FieldsBuf[fieldNdx].SetName( TEMPLATE_FIELDNAME::GetDefaultFieldName( fieldNdx ) ); @@ -680,8 +680,9 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::InitBuffers( SCH_COMPONENT* aComponent #if 0 && defined(DEBUG) for( int i = 0; iGetFieldCount(); ++i ) { - printf( "Orig[%d] (x=%d, y=%d)\n", i, aComponent->m_Fields[i].GetTextPosition().x, - aComponent->m_Fields[i].GetTextPosition().y ); + printf( "Orig[%d] (x=%d, y=%d)\n", i, + aComponent->m_Fields[i].GetTextPos().x, + aComponent->m_Fields[i].GetTextPos().y ); } #endif @@ -698,7 +699,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::InitBuffers( SCH_COMPONENT* aComponent m_FieldsBuf.push_back( aComponent->m_Fields[i] ); // make the editable field position relative to the component - m_FieldsBuf[i].SetTextPosition( m_FieldsBuf[i].GetTextPosition() - m_cmp->m_Pos ); + m_FieldsBuf[i].Offset( -m_cmp->m_Pos ); } // Add template fieldnames: @@ -731,7 +732,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::InitBuffers( SCH_COMPONENT* aComponent fld = *schField; // make the editable field position relative to the component - fld.SetTextPosition( fld.GetTextPosition() - m_cmp->m_Pos ); + fld.Offset( -m_cmp->m_Pos ); } m_FieldsBuf.push_back( fld ); @@ -750,8 +751,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::InitBuffers( SCH_COMPONENT* aComponent m_FieldsBuf.push_back( *cmp ); // make the editable field position relative to the component - m_FieldsBuf[newNdx].SetTextPosition( m_FieldsBuf[newNdx].GetTextPosition() - - m_cmp->m_Pos ); + m_FieldsBuf[newNdx].Offset( -m_cmp->m_Pos ); } } @@ -837,7 +837,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copySelectedFieldToPanel() showCheckBox->SetValue( field.IsVisible() ); - rotateCheckBox->SetValue( field.GetOrientation() == TEXT_ORIENT_VERT ); + rotateCheckBox->SetValue( field.GetTextAngle() == TEXT_ANGLE_VERT ); int style = 0; @@ -910,9 +910,9 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copySelectedFieldToPanel() else fieldValueTextCtrl->Enable( true ); - textSizeTextCtrl->SetValue( EDA_GRAPHIC_TEXT_CTRL::FormatSize( g_UserUnit, field.GetSize().x ) ); + textSizeTextCtrl->SetValue( EDA_GRAPHIC_TEXT_CTRL::FormatSize( g_UserUnit, field.GetTextWidth() ) ); - wxPoint coord = field.GetTextPosition(); + wxPoint coord = field.GetTextPos(); wxPoint zero = -m_cmp->m_Pos; // relative zero // If the field value is empty and the position is at relative zero, we @@ -921,12 +921,12 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copySelectedFieldToPanel() // close to the desired position. if( coord == zero && field.GetText().IsEmpty() ) { - rotateCheckBox->SetValue( m_FieldsBuf[REFERENCE].GetOrientation() == TEXT_ORIENT_VERT ); + rotateCheckBox->SetValue( m_FieldsBuf[REFERENCE].GetTextAngle() == TEXT_ANGLE_VERT ); - coord.x = m_FieldsBuf[REFERENCE].GetTextPosition().x + coord.x = m_FieldsBuf[REFERENCE].GetTextPos().x + ( fieldNdx - MANDATORY_FIELDS + 1 ) * 100; - coord.y = m_FieldsBuf[REFERENCE].GetTextPosition().y + coord.y = m_FieldsBuf[REFERENCE].GetTextPos().y + ( fieldNdx - MANDATORY_FIELDS + 1 ) * 100; // coord can compute negative if field is < MANDATORY_FIELDS, e.g. FOOTPRINT. @@ -959,11 +959,11 @@ bool DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToSelectedField() field.SetVisible( showCheckBox->GetValue() ); if( rotateCheckBox->GetValue() ) - field.SetOrientation( TEXT_ORIENT_VERT ); + field.SetTextAngle( TEXT_ANGLE_VERT ); else - field.SetOrientation( TEXT_ORIENT_HORIZ ); + field.SetTextAngle( TEXT_ANGLE_HORIZ ); - rotateCheckBox->SetValue( field.GetOrientation() == TEXT_ORIENT_VERT ); + rotateCheckBox->SetValue( field.GetTextAngle() == TEXT_ANGLE_VERT ); // Copy the text justification static const EDA_TEXT_HJUSTIFY_T hjustify[] = { @@ -994,7 +994,7 @@ bool DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToSelectedField() setRowItem( fieldNdx, field ); // update fieldListCtrl int tmp = EDA_GRAPHIC_TEXT_CTRL::ParseSize( textSizeTextCtrl->GetValue(), g_UserUnit ); - field.SetSize( wxSize( tmp, tmp ) ); + field.SetTextSize( wxSize( tmp, tmp ) ); int style = m_StyleRadioBox->GetSelection(); field.SetItalic( (style & 1 ) != 0 ); @@ -1003,7 +1003,7 @@ bool DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToSelectedField() wxPoint pos; pos.x = ValueFromString( g_UserUnit, posXTextCtrl->GetValue() ); pos.y = ValueFromString( g_UserUnit, posYTextCtrl->GetValue() ); - field.SetTextPosition( pos ); + field.SetTextPos( pos ); return true; } @@ -1110,19 +1110,19 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::SetInitCmp( wxCommandEvent& event ) // Only VALUE, REFERENCE , FOOTPRINT and DATASHEET are re-initialized LIB_FIELD& refField = part->GetReferenceField(); - m_cmp->GetField( REFERENCE )->SetTextPosition( refField.GetTextPosition() + m_cmp->m_Pos ); + m_cmp->GetField( REFERENCE )->SetTextPos( refField.GetTextPos() + m_cmp->m_Pos ); m_cmp->GetField( REFERENCE )->ImportValues( refField ); LIB_FIELD& valField = part->GetValueField(); - m_cmp->GetField( VALUE )->SetTextPosition( valField.GetTextPosition() + m_cmp->m_Pos ); + m_cmp->GetField( VALUE )->SetTextPos( valField.GetTextPos() + m_cmp->m_Pos ); m_cmp->GetField( VALUE )->ImportValues( valField ); LIB_FIELD* field = part->GetField(FOOTPRINT); if( field && m_cmp->GetField( FOOTPRINT ) ) { - m_cmp->GetField( FOOTPRINT )->SetTextPosition( field->GetTextPosition() + m_cmp->m_Pos ); + m_cmp->GetField( FOOTPRINT )->SetTextPos( field->GetTextPos() + m_cmp->m_Pos ); m_cmp->GetField( FOOTPRINT )->ImportValues( *field ); } @@ -1130,7 +1130,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::SetInitCmp( wxCommandEvent& event ) if( field && m_cmp->GetField( DATASHEET ) ) { - m_cmp->GetField( DATASHEET )->SetTextPosition( field->GetTextPosition() + m_cmp->m_Pos ); + m_cmp->GetField( DATASHEET )->SetTextPos( field->GetTextPos() + m_cmp->m_Pos ); m_cmp->GetField( DATASHEET )->ImportValues( *field ); } diff --git a/eeschema/dialogs/dialog_edit_label.cpp b/eeschema/dialogs/dialog_edit_label.cpp index 64d77714d5..72698766b7 100644 --- a/eeschema/dialogs/dialog_edit_label.cpp +++ b/eeschema/dialogs/dialog_edit_label.cpp @@ -206,7 +206,7 @@ void DIALOG_LABEL_EDITOR::InitDialog() EnsureTextCtrlWidth( m_textLabel, &textWidth ); // Set validators - m_TextOrient->SetSelection( m_CurrentText->GetOrientation() ); + m_TextOrient->SetSelection( m_CurrentText->GetTextAngle() ); m_TextShape->SetSelection( m_CurrentText->GetShape() ); int style = 0; @@ -223,7 +223,7 @@ void DIALOG_LABEL_EDITOR::InitDialog() msg.Printf( _( "H%s x W%s" ), GetChars( units ), GetChars( units ) ); m_staticSizeUnits->SetLabel( msg ); - msg = StringFromValue( g_UserUnit, m_CurrentText->GetSize().x ); + msg = StringFromValue( g_UserUnit, m_CurrentText->GetTextWidth() ); m_TextSize->SetValue( msg ); if( m_CurrentText->Type() != SCH_GLOBAL_LABEL_T @@ -290,10 +290,10 @@ void DIALOG_LABEL_EDITOR::TextPropertiesAccept( wxCommandEvent& aEvent ) return; } - m_CurrentText->SetOrientation( m_TextOrient->GetSelection() ); + m_CurrentText->SetLabelSpinStyle( m_TextOrient->GetSelection() ); text = m_TextSize->GetValue(); value = ValueFromString( g_UserUnit, text ); - m_CurrentText->SetSize( wxSize( value, value ) ); + m_CurrentText->SetTextSize( wxSize( value, value ) ); if( m_TextShape ) /// @todo move cast to widget @@ -306,7 +306,7 @@ void DIALOG_LABEL_EDITOR::TextPropertiesAccept( wxCommandEvent& aEvent ) if( ( style & 2 ) ) { m_CurrentText->SetBold( true ); - m_CurrentText->SetThickness( GetPenSizeForBold( m_CurrentText->GetSize().x ) ); + m_CurrentText->SetThickness( GetPenSizeForBold( m_CurrentText->GetTextWidth() ) ); } else { @@ -318,7 +318,7 @@ void DIALOG_LABEL_EDITOR::TextPropertiesAccept( wxCommandEvent& aEvent ) // Make the text size the new default size ( if it is a new text ): if( m_CurrentText->IsNew() ) - SetDefaultTextSize( m_CurrentText->GetSize().x ); + SetDefaultTextSize( m_CurrentText->GetTextWidth() ); m_Parent->GetCanvas()->RefreshDrawingRect( m_CurrentText->GetBoundingBox() ); m_Parent->GetCanvas()->MoveCursorToCrossHair(); diff --git a/eeschema/dialogs/dialog_edit_libentry_fields_in_lib.cpp b/eeschema/dialogs/dialog_edit_libentry_fields_in_lib.cpp index ab69b3d93f..9f15d12e47 100644 --- a/eeschema/dialogs/dialog_edit_libentry_fields_in_lib.cpp +++ b/eeschema/dialogs/dialog_edit_libentry_fields_in_lib.cpp @@ -671,7 +671,7 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copySelectedFieldToPanel() showCheckBox->SetValue( field.IsVisible() ); - rotateCheckBox->SetValue( field.GetOrientation() == TEXT_ORIENT_VERT ); + rotateCheckBox->SetValue( field.GetTextAngle() == TEXT_ANGLE_VERT ); int style = 0; @@ -730,7 +730,7 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copySelectedFieldToPanel() fieldValueTextCtrl->SetValidator( SCH_FIELD_VALIDATOR( true, field.GetId() ) ); fieldValueTextCtrl->SetValue( field.GetText() ); - textSizeTextCtrl->SetValue( EDA_GRAPHIC_TEXT_CTRL::FormatSize( g_UserUnit, field.GetSize().x ) ); + textSizeTextCtrl->SetValue( EDA_GRAPHIC_TEXT_CTRL::FormatSize( g_UserUnit, field.GetTextSize().x ) ); m_show_datasheet_button->Enable( fieldNdx == DATASHEET || fieldNdx == FOOTPRINT ); @@ -754,7 +754,7 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copySelectedFieldToPanel() _("Used only for fields Footprint and Datasheet.") ); } - wxPoint coord = field.GetTextPosition(); + wxPoint coord = field.GetTextPos(); wxPoint zero; // If the field value is empty and the position is at relative zero, we set the @@ -763,11 +763,11 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copySelectedFieldToPanel() // close to the desired position. if( coord == zero && field.GetText().IsEmpty() ) { - rotateCheckBox->SetValue( m_FieldsBuf[REFERENCE].GetOrientation() == TEXT_ORIENT_VERT ); + rotateCheckBox->SetValue( m_FieldsBuf[REFERENCE].GetTextAngle() == TEXT_ANGLE_VERT ); - coord.x = m_FieldsBuf[REFERENCE].GetTextPosition().x + + coord.x = m_FieldsBuf[REFERENCE].GetTextPos().x + (fieldNdx - MANDATORY_FIELDS + 1) * 100; - coord.y = m_FieldsBuf[REFERENCE].GetTextPosition().y + + coord.y = m_FieldsBuf[REFERENCE].GetTextPos().y + (fieldNdx - MANDATORY_FIELDS + 1) * 100; // coord can compute negative if field is < MANDATORY_FIELDS, e.g. FOOTPRINT. @@ -806,9 +806,9 @@ bool DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copyPanelToSelectedField() field.SetVisible( false ); if( rotateCheckBox->GetValue() ) - field.SetOrientation( TEXT_ORIENT_VERT ); + field.SetTextAngle( TEXT_ANGLE_VERT ); else - field.SetOrientation( TEXT_ORIENT_HORIZ ); + field.SetTextAngle( TEXT_ANGLE_HORIZ ); // Copy the text justification static const EDA_TEXT_HJUSTIFY_T hjustify[3] = { @@ -842,7 +842,7 @@ bool DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copyPanelToSelectedField() int tmp = EDA_GRAPHIC_TEXT_CTRL::ParseSize( textSizeTextCtrl->GetValue(), g_UserUnit ); - field.SetSize( wxSize( tmp, tmp ) ); + field.SetTextSize( wxSize( tmp, tmp ) ); int style = m_StyleRadioBox->GetSelection(); @@ -856,7 +856,7 @@ bool DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copyPanelToSelectedField() // and the screen axis is top to bottom: we must change the y coord sign for editing pos.y = -pos.y; - field.SetTextPosition( pos ); + field.SetTextPos( pos ); return true; } diff --git a/eeschema/dialogs/dialog_edit_one_field.cpp b/eeschema/dialogs/dialog_edit_one_field.cpp index 3ee5f1e88f..9dbd9b7c1b 100644 --- a/eeschema/dialogs/dialog_edit_one_field.cpp +++ b/eeschema/dialogs/dialog_edit_one_field.cpp @@ -89,8 +89,8 @@ DIALOG_EDIT_ONE_FIELD::DIALOG_EDIT_ONE_FIELD( SCH_BASE_FRAME* aParent, const wxS m_text = aTextItem->GetText(); m_style = aTextItem->IsItalic() ? 1 : 0; m_style += aTextItem->IsBold() ? 2 : 0; - m_size = aTextItem->GetSize().x; - m_orientation = ( aTextItem->GetOrientation() == TEXT_ORIENT_VERT ); + m_size = aTextItem->GetTextWidth(); + m_orientation = ( aTextItem->GetTextAngle() == TEXT_ANGLE_VERT ); m_verticalJustification = aTextItem->GetVertJustify() + 1; m_horizontalJustification = aTextItem->GetHorizJustify() + 1; m_isVisible = aTextItem->IsVisible(); @@ -211,9 +211,9 @@ bool DIALOG_EDIT_ONE_FIELD::TransferDataFromWindow() void DIALOG_EDIT_ONE_FIELD::updateText( EDA_TEXT* aText ) { - aText->SetSize( wxSize( m_size, m_size ) ); + aText->SetTextSize( wxSize( m_size, m_size ) ); aText->SetVisible( m_isVisible ); - aText->SetOrientation( m_orientation ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ ); + aText->SetTextAngle( m_orientation ? TEXT_ANGLE_VERT : TEXT_ANGLE_HORIZ ); aText->SetItalic( (m_style & 1) != 0 ); aText->SetBold( (m_style & 2) != 0 ); aText->SetHorizJustify( IntToEdaTextHorizJustify( m_horizontalJustification - 1 ) ); diff --git a/eeschema/dialogs/dialog_lib_edit_text.cpp b/eeschema/dialogs/dialog_lib_edit_text.cpp index a1c7ceeadb..7e9ee28463 100644 --- a/eeschema/dialogs/dialog_lib_edit_text.cpp +++ b/eeschema/dialogs/dialog_lib_edit_text.cpp @@ -64,41 +64,40 @@ void DIALOG_LIB_EDIT_TEXT::initDlg( ) // Disable options for fieldedition, not existing in graphic text m_Invisible->Show(false); - if ( m_graphicText ) + if( m_graphicText ) { - msg = StringFromValue( g_UserUnit, m_graphicText->GetSize().x ); + msg = StringFromValue( g_UserUnit, m_graphicText->GetTextWidth() ); m_TextSize->SetValue( msg ); m_TextValue->SetValue( m_graphicText->GetText() ); - if ( m_graphicText->GetUnit() == 0 ) + if( m_graphicText->GetUnit() == 0 ) m_CommonUnit->SetValue( true ); - if ( m_graphicText->GetConvert() == 0 ) + if( m_graphicText->GetConvert() == 0 ) m_CommonConvert->SetValue( true ); - if ( m_graphicText->GetOrientation() == TEXT_ORIENT_VERT ) + if( m_graphicText->GetTextAngle() == TEXT_ANGLE_VERT ) m_Orient->SetValue( true ); int shape = 0; - if ( m_graphicText->IsItalic() ) + if( m_graphicText->IsItalic() ) shape = 1; - if ( m_graphicText->IsBold() ) + if( m_graphicText->IsBold() ) shape |= 2; m_TextShapeOpt->SetSelection( shape ); switch ( m_graphicText->GetHorizJustify() ) { - case GR_TEXT_HJUSTIFY_LEFT: - m_TextHJustificationOpt->SetSelection( 0 ); - break; + case GR_TEXT_HJUSTIFY_LEFT: + m_TextHJustificationOpt->SetSelection( 0 ); + break; - case GR_TEXT_HJUSTIFY_CENTER: - m_TextHJustificationOpt->SetSelection( 1 ); - break; - - case GR_TEXT_HJUSTIFY_RIGHT: - m_TextHJustificationOpt->SetSelection( 2 ); - break; + case GR_TEXT_HJUSTIFY_CENTER: + m_TextHJustificationOpt->SetSelection( 1 ); + break; + case GR_TEXT_HJUSTIFY_RIGHT: + m_TextHJustificationOpt->SetSelection( 2 ); + break; } switch ( m_graphicText->GetVertJustify() ) @@ -121,11 +120,11 @@ void DIALOG_LIB_EDIT_TEXT::initDlg( ) msg = StringFromValue( g_UserUnit, m_parent->m_textSize ); m_TextSize->SetValue( msg ); - if ( ! m_parent->m_drawSpecificUnit ) + if( ! m_parent->m_drawSpecificUnit ) m_CommonUnit->SetValue( true ); - if ( ! m_parent->m_drawSpecificConvert ) + if( ! m_parent->m_drawSpecificConvert ) m_CommonConvert->SetValue( true ); - if ( m_parent->m_textOrientation == TEXT_ORIENT_VERT ) + if( m_parent->m_current_text_angle == TEXT_ANGLE_VERT ) m_Orient->SetValue( true ); } @@ -155,7 +154,7 @@ void DIALOG_LIB_EDIT_TEXT::OnOkClick( wxCommandEvent& event ) wxString Line; Line = m_TextValue->GetValue(); - m_parent->m_textOrientation = m_Orient->GetValue() ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ; + m_parent->m_current_text_angle = m_Orient->GetValue() ? TEXT_ANGLE_VERT : TEXT_ANGLE_HORIZ; wxString msg = m_TextSize->GetValue(); m_parent->m_textSize = ValueFromString( g_UserUnit, msg ); m_parent->m_drawSpecificConvert = m_CommonConvert->GetValue() ? false : true; @@ -168,8 +167,8 @@ void DIALOG_LIB_EDIT_TEXT::OnOkClick( wxCommandEvent& event ) else m_graphicText->SetText( wxT( "[null]" ) ); - m_graphicText->SetSize( wxSize( m_parent->m_textSize, m_parent->m_textSize ) ); - m_graphicText->SetOrientation( m_parent->m_textOrientation ); + m_graphicText->SetTextSize( wxSize( m_parent->m_textSize, m_parent->m_textSize ) ); + m_graphicText->SetTextAngle( m_parent->m_current_text_angle ); if( m_parent->m_drawSpecificUnit ) m_graphicText->SetUnit( m_parent->GetUnit() ); diff --git a/eeschema/edit_component_in_schematic.cpp b/eeschema/edit_component_in_schematic.cpp index 6bc057c840..4efe1f1fde 100644 --- a/eeschema/edit_component_in_schematic.cpp +++ b/eeschema/edit_component_in_schematic.cpp @@ -107,10 +107,10 @@ void SCH_EDIT_FRAME::RotateField( SCH_FIELD* aField ) if( aField->GetFlags() == 0 ) SaveCopyInUndoList( component, UR_CHANGED ); - if( aField->GetOrientation() == TEXT_ORIENT_HORIZ ) - aField->SetOrientation( TEXT_ORIENT_VERT ); + if( aField->GetTextAngle() == TEXT_ANGLE_HORIZ ) + aField->SetTextAngle( TEXT_ANGLE_VERT ); else - aField->SetOrientation( TEXT_ORIENT_HORIZ ); + aField->SetTextAngle( TEXT_ANGLE_HORIZ ); OnModify(); } diff --git a/eeschema/edit_label.cpp b/eeschema/edit_label.cpp index 15e4b10c24..adbd39481b 100644 --- a/eeschema/edit_label.cpp +++ b/eeschema/edit_label.cpp @@ -52,13 +52,13 @@ void SCH_EDIT_FRAME::ChangeTextOrient( SCH_TEXT* aTextItem ) wxCHECK_RET( (aTextItem != NULL) && aTextItem->CanIncrementLabel(), wxT( "Invalid schematic text item." ) ); - int orient = ( aTextItem->GetOrientation() + 1 ) & 3; + int orient = ( aTextItem->GetLabelSpinStyle() + 1 ) & 3; // Save current text orientation in undo list if is not already in edit. if( aTextItem->GetFlags() == 0 ) SaveCopyInUndoList( aTextItem, UR_CHANGED ); - aTextItem->SetOrientation( orient ); + aTextItem->SetLabelSpinStyle( orient ); OnModify(); } @@ -96,8 +96,8 @@ SCH_TEXT* SCH_EDIT_FRAME::CreateNewText( wxDC* aDC, int aType ) textItem->SetBold( lastTextBold ); textItem->SetItalic( lastTextItalic ); - textItem->SetOrientation( lastTextOrientation ); - textItem->SetSize( wxSize( GetDefaultTextSize(), GetDefaultTextSize() ) ); + textItem->SetLabelSpinStyle( lastTextOrientation ); + textItem->SetTextSize( wxSize( GetDefaultTextSize(), GetDefaultTextSize() ) ); textItem->SetFlags( IS_NEW | IS_MOVED ); EditSchematicText( textItem ); @@ -110,7 +110,7 @@ SCH_TEXT* SCH_EDIT_FRAME::CreateNewText( wxDC* aDC, int aType ) lastTextBold = textItem->IsBold(); lastTextItalic = textItem->IsItalic(); - lastTextOrientation = textItem->GetOrientation(); + lastTextOrientation = textItem->GetLabelSpinStyle(); if( ( textItem->Type() == SCH_GLOBAL_LABEL_T ) || ( textItem->Type() == SCH_HIERARCHICAL_LABEL_T ) ) @@ -205,8 +205,8 @@ void SCH_EDIT_FRAME::OnConvertTextType( wxCommandEvent& aEvent ) */ newtext->SetFlags( text->GetFlags() ); newtext->SetShape( text->GetShape() ); - newtext->SetOrientation( text->GetOrientation() ); - newtext->SetSize( text->GetSize() ); + newtext->SetLabelSpinStyle( text->GetLabelSpinStyle() ); + newtext->SetTextSize( text->GetTextSize() ); newtext->SetThickness( text->GetThickness() ); newtext->SetItalic( text->IsItalic() ); newtext->SetBold( text->IsBold() ); diff --git a/eeschema/lib_field.cpp b/eeschema/lib_field.cpp index 5b6b01e607..b6e8cd0009 100644 --- a/eeschema/lib_field.cpp +++ b/eeschema/lib_field.cpp @@ -53,7 +53,8 @@ LIB_FIELD::LIB_FIELD(LIB_PART * aParent, int idfield ) : } -LIB_FIELD::LIB_FIELD( int idfield ) : LIB_ITEM( LIB_FIELD_T, NULL ) +LIB_FIELD::LIB_FIELD( int idfield ) : + LIB_ITEM( LIB_FIELD_T, NULL ) { Init( idfield ); } @@ -64,13 +65,28 @@ LIB_FIELD::~LIB_FIELD() } +void LIB_FIELD::operator=( const LIB_FIELD& field ) +{ + m_id = field.m_id; + m_Text = field.m_Text; + m_name = field.m_name; + m_Parent = field.m_Parent; + + SetEffects( field ); +} + + void LIB_FIELD::Init( int id ) { m_id = id; - m_Size.x = GetDefaultTextSize(); - m_Size.y = GetDefaultTextSize(); + + SetTextWidth( GetDefaultTextSize() ); + SetTextHeight( GetDefaultTextSize() ); + m_typeName = _( "Field" ); - m_Orient = TEXT_ORIENT_HORIZ; + + SetTextAngle( TEXT_ANGLE_HORIZ ); // constructor already did this. + m_rotate = false; m_updateText = false; @@ -99,27 +115,27 @@ bool LIB_FIELD::Save( OUTPUTFORMATTER& aFormatter ) hjustify = 'C'; - if( m_HJustify == GR_TEXT_HJUSTIFY_LEFT ) + if( GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT ) hjustify = 'L'; - else if( m_HJustify == GR_TEXT_HJUSTIFY_RIGHT ) + else if( GetHorizJustify() == GR_TEXT_HJUSTIFY_RIGHT ) hjustify = 'R'; vjustify = 'C'; - if( m_VJustify == GR_TEXT_VJUSTIFY_BOTTOM ) + if( GetVertJustify() == GR_TEXT_VJUSTIFY_BOTTOM ) vjustify = 'B'; - else if( m_VJustify == GR_TEXT_VJUSTIFY_TOP ) + else if( GetVertJustify() == GR_TEXT_VJUSTIFY_TOP ) vjustify = 'T'; aFormatter.Print( 0, "F%d %s %d %d %d %c %c %c %c%c%c", m_id, EscapedUTF8( text ).c_str(), // wraps in quotes - m_Pos.x, m_Pos.y, m_Size.x, - m_Orient == 0 ? 'H' : 'V', - (m_Attributs & TEXT_NO_VISIBLE ) ? 'I' : 'V', + GetTextPos().x, GetTextPos().y, GetTextWidth(), + GetTextAngle() == 0 ? 'H' : 'V', + IsVisible() ? 'V' : 'I', hjustify, vjustify, - m_Italic ? 'I' : 'N', - m_Bold ? 'B' : 'N' ); + IsItalic() ? 'I' : 'N', + IsBold() ? 'B' : 'N' ); /* Save field name, if necessary * Field name is saved only if it is not the default name. @@ -140,6 +156,7 @@ bool LIB_FIELD::Save( OUTPUTFORMATTER& aFormatter ) bool LIB_FIELD::Load( LINE_READER& aLineReader, wxString& errorMsg ) { int cnt; + int x, y, size; char textOrient; char textVisible; char textHJustify; @@ -171,7 +188,7 @@ bool LIB_FIELD::Load( LINE_READER& aLineReader, wxString& errorMsg ) memset( textVJustify, 0, sizeof( textVJustify ) ); - cnt = sscanf( line, " %d %d %d %c %c %c %255s", &m_Pos.x, &m_Pos.y, &m_Size.y, + cnt = sscanf( line, " %d %d %d %c %c %c %255s", &x, &y, &size, &textOrient, &textVisible, &textHJustify, textVJustify ); if( cnt < 5 ) @@ -181,12 +198,13 @@ bool LIB_FIELD::Load( LINE_READER& aLineReader, wxString& errorMsg ) return false; } - m_Size.x = m_Size.y; + SetTextPos( wxPoint( x, y ) ); + SetTextSize( wxSize( size, size ) ); if( textOrient == 'H' ) - m_Orient = TEXT_ORIENT_HORIZ; + SetTextAngle( TEXT_ANGLE_HORIZ ); else if( textOrient == 'V' ) - m_Orient = TEXT_ORIENT_VERT; + SetTextAngle( TEXT_ANGLE_VERT ); else { errorMsg.Printf( wxT( "field %d text orientation parameter <%c> is not valid" ), @@ -195,9 +213,9 @@ bool LIB_FIELD::Load( LINE_READER& aLineReader, wxString& errorMsg ) } if( textVisible == 'V' ) - m_Attributs &= ~TEXT_NO_VISIBLE; - else if ( textVisible == 'I' ) - m_Attributs |= TEXT_NO_VISIBLE; + SetVisible( true ); + else if( textVisible == 'I' ) + SetVisible( false ); else { errorMsg.Printf( wxT( "field %d text visible parameter <%c> is not valid" ), @@ -205,17 +223,17 @@ bool LIB_FIELD::Load( LINE_READER& aLineReader, wxString& errorMsg ) return false; } - m_HJustify = GR_TEXT_HJUSTIFY_CENTER; - m_VJustify = GR_TEXT_VJUSTIFY_CENTER; + SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER ); + SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); if( cnt >= 6 ) { if( textHJustify == 'C' ) - m_HJustify = GR_TEXT_HJUSTIFY_CENTER; + SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER ); else if( textHJustify == 'L' ) - m_HJustify = GR_TEXT_HJUSTIFY_LEFT; + SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); else if( textHJustify == 'R' ) - m_HJustify = GR_TEXT_HJUSTIFY_RIGHT; + SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); else { errorMsg.Printf( @@ -225,11 +243,11 @@ bool LIB_FIELD::Load( LINE_READER& aLineReader, wxString& errorMsg ) } if( textVJustify[0] == 'C' ) - m_VJustify = GR_TEXT_VJUSTIFY_CENTER; + SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); else if( textVJustify[0] == 'B' ) - m_VJustify = GR_TEXT_VJUSTIFY_BOTTOM; + SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); else if( textVJustify[0] == 'T' ) - m_VJustify = GR_TEXT_VJUSTIFY_TOP; + SetVertJustify( GR_TEXT_VJUSTIFY_TOP ); else { errorMsg.Printf( @@ -238,10 +256,10 @@ bool LIB_FIELD::Load( LINE_READER& aLineReader, wxString& errorMsg ) return false; } - if ( textVJustify[1] == 'I' ) // Italic - m_Italic = true; - if ( textVJustify[2] == 'B' ) // Bold - m_Bold = true; + if( textVJustify[1] == 'I' ) // Italic + SetItalic( true ); + if( textVJustify[2] == 'B' ) // Bold + SetBold( true ); } // fields in RAM must always have names. @@ -263,7 +281,7 @@ bool LIB_FIELD::Load( LINE_READER& aLineReader, wxString& errorMsg ) int LIB_FIELD::GetPenSize() const { - return ( m_Thickness == 0 ) ? GetDefaultLineThickness() : m_Thickness; + return GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness(); } @@ -275,16 +293,16 @@ void LIB_FIELD::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& a int color; int linewidth = GetPenSize(); - if( m_Bold ) - linewidth = GetPenSizeForBold( m_Size.x ); + if( IsBold() ) + linewidth = GetPenSizeForBold( GetTextWidth() ); else - linewidth = Clamp_Text_PenSize( linewidth, m_Size, m_Bold ); + linewidth = Clamp_Text_PenSize( linewidth, GetTextSize(), IsBold() ); - if( ( m_Attributs & TEXT_NO_VISIBLE ) && ( aColor < 0 ) ) + if( !IsVisible() && aColor < 0 ) { color = GetInvisibleItemColor(); } - else if( IsSelected() && ( aColor < 0 ) ) + else if( IsSelected() && aColor < 0 ) { color = GetItemSelectedColor(); } @@ -296,7 +314,7 @@ void LIB_FIELD::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& a if( color < 0 ) color = GetDefaultColor(); - text_pos = aTransform.TransformCoordinate( m_Pos ) + aOffset; + text_pos = aTransform.TransformCoordinate( GetTextPos() ) + aOffset; wxString text; @@ -307,8 +325,10 @@ void LIB_FIELD::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& a GRSetDrawMode( aDC, aDrawMode ); EDA_RECT* clipbox = aPanel? aPanel->GetClipBox() : NULL; - DrawGraphicText( clipbox, aDC, text_pos, (EDA_COLOR_T) color, text, m_Orient, m_Size, - m_HJustify, m_VJustify, linewidth, m_Italic, m_Bold ); + DrawGraphicText( clipbox, aDC, text_pos, (EDA_COLOR_T) color, text, + GetTextAngle(), GetTextSize(), + GetHorizJustify(), GetVertJustify(), + linewidth, IsItalic(), IsBold() ); /* Set to one (1) to draw bounding box around field text to validate * bounding box calculation. */ @@ -347,21 +367,21 @@ bool LIB_FIELD::HitTest( const wxPoint &aPosition, int aThreshold, const TRANSFO { wxString extended_text = tmp_text.GetText(); extended_text.Append('?'); - const LIB_PART* parent = static_cast( m_Parent ); + const LIB_PART* parent = static_cast( m_Parent ); if ( parent && ( parent->GetUnitCount() > 1 ) ) extended_text.Append('A'); tmp_text.SetText( extended_text ); } - tmp_text.SetTextPosition( aTransform.TransformCoordinate( m_Pos ) ); + tmp_text.SetTextPos( aTransform.TransformCoordinate( GetTextPos() ) ); /* 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) */ - int t1 = ( aTransform.x1 != 0 ) ^ ( m_Orient != 0 ); - tmp_text.SetOrientation( t1 ? TEXT_ORIENT_HORIZ : TEXT_ORIENT_VERT ); + bool t1 = ( aTransform.x1 != 0 ) ^ ( GetTextAngle() != 0 ); + tmp_text.SetTextAngle( t1 ? TEXT_ANGLE_HORIZ : TEXT_ANGLE_VERT ); return tmp_text.TextHitTest( aPosition ); } @@ -379,18 +399,11 @@ EDA_ITEM* LIB_FIELD::Clone() const void LIB_FIELD::Copy( LIB_FIELD* aTarget ) const { + aTarget->m_Text = m_Text; + aTarget->m_name = m_name; + + aTarget->SetEffects( *this ); aTarget->SetParent( m_Parent ); - aTarget->m_Pos = m_Pos; - aTarget->m_Size = m_Size; - aTarget->m_Thickness = m_Thickness; - aTarget->m_Orient = m_Orient; - aTarget->m_Attributs = m_Attributs; - aTarget->m_Text = m_Text; - aTarget->m_name = m_name; - aTarget->m_HJustify = m_HJustify; - aTarget->m_VJustify = m_VJustify; - aTarget->m_Italic = m_Italic; - aTarget->m_Bold = m_Bold; } @@ -408,17 +421,17 @@ int LIB_FIELD::compare( const LIB_ITEM& other ) const if( result != 0 ) return result; - if( m_Pos.x != tmp->m_Pos.x ) - return m_Pos.x - tmp->m_Pos.x; + if( GetTextPos().x != tmp->GetTextPos().x ) + return GetTextPos().x - tmp->GetTextPos().x; - if( m_Pos.y != tmp->m_Pos.y ) - return m_Pos.y - tmp->m_Pos.y; + if( GetTextPos().y != tmp->GetTextPos().y ) + return GetTextPos().y - tmp->GetTextPos().y; - if( m_Size.x != tmp->m_Size.x ) - return m_Size.x - tmp->m_Size.x; + if( GetTextWidth() != tmp->GetTextWidth() ) + return GetTextWidth() - tmp->GetTextWidth(); - if( m_Size.y != tmp->m_Size.y ) - return m_Size.y - tmp->m_Size.y; + if( GetTextHeight() != tmp->GetTextHeight() ) + return GetTextHeight() - tmp->GetTextHeight(); return 0; } @@ -426,7 +439,7 @@ int LIB_FIELD::compare( const LIB_ITEM& other ) const void LIB_FIELD::SetOffset( const wxPoint& aOffset ) { - m_Pos += aOffset; + EDA_TEXT::Offset( aOffset ); } @@ -436,35 +449,49 @@ bool LIB_FIELD::Inside( EDA_RECT& rect ) const * FIXME: This fails to take into account the size and/or orientation of * the text. */ - return rect.Contains( m_Pos.x, -m_Pos.y ); + return rect.Contains( GetTextPos().x, -GetTextPos().y ); } void LIB_FIELD::Move( const wxPoint& newPosition ) { - m_Pos = newPosition; + EDA_TEXT::SetTextPos( newPosition ); } void LIB_FIELD::MirrorHorizontal( const wxPoint& center ) { - m_Pos.x -= center.x; - m_Pos.x *= -1; - m_Pos.x += center.x; + int x = GetTextPos().x; + + x -= center.x; + x *= -1; + x += center.x; + + SetTextX( x ); } + void LIB_FIELD::MirrorVertical( const wxPoint& center ) { - m_Pos.y -= center.y; - m_Pos.y *= -1; - m_Pos.y += center.y; + int y = GetTextPos().y; + + y -= center.y; + y *= -1; + y += center.y; + + SetTextY( y ); } + void LIB_FIELD::Rotate( const wxPoint& center, bool aRotateCCW ) { int rot_angle = aRotateCCW ? -900 : 900; - RotatePoint( &m_Pos, center, rot_angle ); - m_Orient = m_Orient ? 0 : 900; + + wxPoint pt = GetTextPos(); + RotatePoint( &pt, center, rot_angle ); + SetTextPos( pt ); + + SetTextAngle( GetTextAngle() != 0.0 ? 0 : 900 ); } @@ -476,14 +503,14 @@ void LIB_FIELD::Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, /* Calculate the text orientation, according to the component * orientation/mirror */ - int orient = m_Orient; + int orient = GetTextAngle(); if( aTransform.y1 ) // Rotate component 90 deg. { - if( orient == TEXT_ORIENT_HORIZ ) - orient = TEXT_ORIENT_VERT; + if( orient == TEXT_ANGLE_HORIZ ) + orient = TEXT_ANGLE_VERT; else - orient = TEXT_ORIENT_HORIZ; + orient = TEXT_ANGLE_HORIZ; } EDA_RECT BoundaryBox = GetBoundingBox(); @@ -494,9 +521,10 @@ void LIB_FIELD::Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, wxPoint textpos = aTransform.TransformCoordinate( BoundaryBox.Centre() ) + aOffset; - aPlotter->Text( textpos, GetDefaultColor(), GetShownText(), orient, m_Size, + aPlotter->Text( textpos, GetDefaultColor(), GetShownText(), + orient, GetTextSize(), hjustify, vjustify, - GetPenSize(), m_Italic, m_Bold ); + GetPenSize(), IsItalic(), IsBold() ); } @@ -526,8 +554,10 @@ const EDA_RECT LIB_FIELD::GetBoundingBox() const // We are using now a bottom to top Y axis. wxPoint orig = rect.GetOrigin(); wxPoint end = rect.GetEnd(); - RotatePoint( &orig, m_Pos, -m_Orient ); - RotatePoint( &end, m_Pos, -m_Orient ); + + RotatePoint( &orig, GetTextPos(), -GetTextAngle() ); + RotatePoint( &end, GetTextPos(), -GetTextAngle() ); + rect.SetOrigin( orig ); rect.SetEnd( end ); @@ -569,7 +599,7 @@ void LIB_FIELD::Rotate() } else { - m_Orient = ( m_Orient == TEXT_ORIENT_VERT ) ? TEXT_ORIENT_HORIZ : TEXT_ORIENT_VERT; + SetTextAngle( GetTextAngle() == TEXT_ANGLE_VERT ? TEXT_ANGLE_HORIZ : TEXT_ANGLE_VERT ); } } @@ -688,13 +718,13 @@ void LIB_FIELD::BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aPosition ) if( aEditMode == IS_MOVED ) { - m_initialPos = m_Pos; + m_initialPos = GetTextPos(); m_initialCursorPos = aPosition; SetEraseLastDrawItem(); } else { - m_Pos = aPosition; + SetTextPos( aPosition ); } m_Flags = aEditMode; @@ -726,7 +756,7 @@ void LIB_FIELD::calcEdit( const wxPoint& aPosition ) { if( m_rotate ) { - m_Orient = ( m_Orient == TEXT_ORIENT_VERT ) ? TEXT_ORIENT_HORIZ : TEXT_ORIENT_VERT; + SetTextAngle( GetTextAngle() == TEXT_ANGLE_VERT ? TEXT_ANGLE_HORIZ : TEXT_ANGLE_VERT ); m_rotate = false; } @@ -738,7 +768,7 @@ void LIB_FIELD::calcEdit( const wxPoint& aPosition ) if( m_Flags == IS_NEW ) { - m_Pos = aPosition; + SetTextPos( aPosition ); } else if( m_Flags == IS_MOVED ) { @@ -746,6 +776,7 @@ void LIB_FIELD::calcEdit( const wxPoint& aPosition ) } } + void LIB_FIELD::GetMsgPanelInfo( MSG_PANEL_ITEMS& aList ) { wxString msg; @@ -756,10 +787,10 @@ void LIB_FIELD::GetMsgPanelInfo( MSG_PANEL_ITEMS& aList ) msg = GetTextStyleName(); aList.push_back( MSG_PANEL_ITEM( _( "Style" ), msg, MAGENTA ) ); - msg = StringFromValue( g_UserUnit, m_Size.x, true ); + msg = StringFromValue( g_UserUnit, GetTextWidth(), true ); aList.push_back( MSG_PANEL_ITEM( _( "Width" ), msg, BLUE ) ); - msg = StringFromValue( g_UserUnit, m_Size.y, true ); + msg = StringFromValue( g_UserUnit, GetTextHeight(), true ); aList.push_back( MSG_PANEL_ITEM( _( "Height" ), msg, BLUE ) ); // Display field name (ref, value ...) diff --git a/eeschema/lib_field.h b/eeschema/lib_field.h index c1f89b14b7..9e48a45e9f 100644 --- a/eeschema/lib_field.h +++ b/eeschema/lib_field.h @@ -165,10 +165,7 @@ public: * Function IsVisible * @return true is this field is visible, false if flagged invisible */ - bool IsVisible() - { - return (m_Attributs & TEXT_NO_VISIBLE) == 0 ? true : false; - } + bool IsVisible() const { return EDA_TEXT::IsVisible(); } // why needed? const EDA_RECT GetBoundingBox() const override; @@ -178,23 +175,7 @@ public: bool HitTest( const wxPoint &aPosition, int aThreshold, const TRANSFORM& aTransform ) const override; - void operator=( const LIB_FIELD& field ) - { - m_id = field.m_id; - m_Text = field.m_Text; - m_name = field.m_name; - m_Pos = field.m_Pos; - m_Size = field.m_Size; - m_Thickness = field.m_Thickness; - m_Orient = field.m_Orient; - m_Mirror = field.m_Mirror; - m_Attributs = field.m_Attributs; - m_Italic = field.m_Italic; - m_Bold = field.m_Bold; - m_HJustify = field.m_HJustify; - m_VJustify = field.m_VJustify; - m_Parent = field.m_Parent; - } + void operator=( const LIB_FIELD& field ); /** * Return the text of a field. @@ -239,7 +220,7 @@ public: void Move( const wxPoint& aPosition ) override; - wxPoint GetPosition() const override { return m_Pos; } + wxPoint GetPosition() const override { return EDA_TEXT::GetTextPos(); } void MirrorHorizontal( const wxPoint& aCenter ) override; @@ -250,9 +231,9 @@ public: void Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, const TRANSFORM& aTransform ) override; - int GetWidth() const override { return m_Thickness; } + int GetWidth() const override { return GetThickness(); } - void SetWidth( int aWidth ) override { m_Thickness = aWidth; } + void SetWidth( int aWidth ) override { SetThickness( aWidth ); } wxString GetSelectMenuText() const override; diff --git a/eeschema/lib_pin.cpp b/eeschema/lib_pin.cpp index 266ab03d64..ff13462b21 100644 --- a/eeschema/lib_pin.cpp +++ b/eeschema/lib_pin.cpp @@ -700,7 +700,7 @@ bool LIB_PIN::Load( LINE_READER& aLineReader, wxString& aErrorMsg ) // the full line starts by "X ". The pin data starts at line + 2. wxString utf8line = FROM_UTF8( aLineReader.Line() + 2 ); - wxStringTokenizer tokenizer( utf8line, wxT(" \n\r" ) ); + wxStringTokenizer tokenizer( utf8line, wxT(" \n\r" ) ); int prms_count = tokenizer.CountTokens(); if( prms_count < 11 ) @@ -1258,7 +1258,7 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel, x = x1 + TextInside; DrawGraphicText( clipbox, DC, wxPoint( x, y1 ), NameColor, m_name, - TEXT_ORIENT_HORIZ, + TEXT_ANGLE_HORIZ, PinNameSize, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, nameLineWidth, @@ -1269,7 +1269,7 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel, x = x1 - TextInside; DrawGraphicText( clipbox, DC, wxPoint( x, y1 ), NameColor, m_name, - TEXT_ORIENT_HORIZ, + TEXT_ANGLE_HORIZ, PinNameSize, GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_CENTER, nameLineWidth, @@ -1283,7 +1283,7 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel, wxPoint( (x1 + pin_pos.x) / 2, y1 - num_offset ), NumColor, StringPinNum, - TEXT_ORIENT_HORIZ, PinNumSize, + TEXT_ANGLE_HORIZ, PinNumSize, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM, numLineWidth, false, false ); @@ -1299,7 +1299,7 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel, if( DrawPinName ) DrawGraphicText( clipbox, DC, wxPoint( x1, y ), NameColor, m_name, - TEXT_ORIENT_VERT, PinNameSize, + TEXT_ANGLE_VERT, PinNameSize, GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_CENTER, nameLineWidth, false, false ); @@ -1309,7 +1309,7 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel, wxPoint( x1 - num_offset, (y1 + pin_pos.y) / 2 ), NumColor, StringPinNum, - TEXT_ORIENT_VERT, PinNumSize, + TEXT_ANGLE_VERT, PinNumSize, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM, numLineWidth, false, false ); @@ -1321,7 +1321,7 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel, if( DrawPinName ) DrawGraphicText( clipbox, DC, wxPoint( x1, y ), NameColor, m_name, - TEXT_ORIENT_VERT, PinNameSize, + TEXT_ANGLE_VERT, PinNameSize, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, nameLineWidth, false, false ); @@ -1331,7 +1331,7 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel, wxPoint( x1 - num_offset, (y1 + pin_pos.y) / 2 ), NumColor, StringPinNum, - TEXT_ORIENT_VERT, PinNumSize, + TEXT_ANGLE_VERT, PinNumSize, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM, numLineWidth, false, false ); @@ -1348,7 +1348,7 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel, x = (x1 + pin_pos.x) / 2; DrawGraphicText( clipbox, DC, wxPoint( x, y1 - name_offset ), NameColor, m_name, - TEXT_ORIENT_HORIZ, PinNameSize, + TEXT_ANGLE_HORIZ, PinNameSize, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM, nameLineWidth, false, false ); @@ -1358,7 +1358,7 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel, x = (x1 + pin_pos.x) / 2; DrawGraphicText( clipbox, DC, wxPoint( x, y1 + num_offset ), NumColor, StringPinNum, - TEXT_ORIENT_HORIZ, PinNumSize, + TEXT_ANGLE_HORIZ, PinNumSize, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP, numLineWidth, false, false ); @@ -1371,7 +1371,7 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel, y = (y1 + pin_pos.y) / 2; DrawGraphicText( clipbox, DC, wxPoint( x1 - name_offset, y ), NameColor, m_name, - TEXT_ORIENT_VERT, PinNameSize, + TEXT_ANGLE_VERT, PinNameSize, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM, nameLineWidth, false, false ); @@ -1383,7 +1383,7 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel, wxPoint( x1 + num_offset, (y1 + pin_pos.y) / 2 ), NumColor, StringPinNum, - TEXT_ORIENT_VERT, PinNumSize, + TEXT_ANGLE_VERT, PinNumSize, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP, numLineWidth, false, false ); @@ -1421,19 +1421,19 @@ void LIB_PIN::DrawPinElectricalTypeName( EDA_DRAW_PANEL* aPanel, wxDC* aDC, wxPoint txtpos = aPosition; int offset = Millimeter2iu( 0.4 ); EDA_TEXT_HJUSTIFY_T hjustify = GR_TEXT_HJUSTIFY_LEFT; - int orient = TEXT_ORIENT_HORIZ; + int orient = TEXT_ANGLE_HORIZ; switch( aOrientation ) { case PIN_UP: txtpos.y += offset; - orient = TEXT_ORIENT_VERT; + orient = TEXT_ANGLE_VERT; hjustify = GR_TEXT_HJUSTIFY_RIGHT; break; case PIN_DOWN: txtpos.y -= offset; - orient = TEXT_ORIENT_VERT; + orient = TEXT_ANGLE_VERT; break; case PIN_LEFT: @@ -1676,7 +1676,7 @@ void LIB_PIN::PlotPinTexts( PLOTTER* plotter, wxPoint& pin_pos, int orient, x = x1 + TextInside; plotter->Text( wxPoint( x, y1 ), NameColor, m_name, - TEXT_ORIENT_HORIZ, + TEXT_ANGLE_HORIZ, PinNameSize, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, @@ -1688,7 +1688,7 @@ void LIB_PIN::PlotPinTexts( PLOTTER* plotter, wxPoint& pin_pos, int orient, if( DrawPinName ) plotter->Text( wxPoint( x, y1 ), - NameColor, m_name, TEXT_ORIENT_HORIZ, + NameColor, m_name, TEXT_ANGLE_HORIZ, PinNameSize, GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_CENTER, @@ -1700,7 +1700,7 @@ void LIB_PIN::PlotPinTexts( PLOTTER* plotter, wxPoint& pin_pos, int orient, plotter->Text( wxPoint( (x1 + pin_pos.x) / 2, y1 - num_offset ), NumColor, StringPinNum, - TEXT_ORIENT_HORIZ, PinNumSize, + TEXT_ANGLE_HORIZ, PinNumSize, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM, aWidth, false, false ); @@ -1715,7 +1715,7 @@ void LIB_PIN::PlotPinTexts( PLOTTER* plotter, wxPoint& pin_pos, int orient, if( DrawPinName ) plotter->Text( wxPoint( x1, y ), NameColor, m_name, - TEXT_ORIENT_VERT, PinNameSize, + TEXT_ANGLE_VERT, PinNameSize, GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_CENTER, aWidth, false, false ); @@ -1725,7 +1725,7 @@ void LIB_PIN::PlotPinTexts( PLOTTER* plotter, wxPoint& pin_pos, int orient, plotter->Text( wxPoint( x1 - num_offset, (y1 + pin_pos.y) / 2 ), NumColor, StringPinNum, - TEXT_ORIENT_VERT, PinNumSize, + TEXT_ANGLE_VERT, PinNumSize, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM, aWidth, false, false ); @@ -1738,7 +1738,7 @@ void LIB_PIN::PlotPinTexts( PLOTTER* plotter, wxPoint& pin_pos, int orient, if( DrawPinName ) plotter->Text( wxPoint( x1, y ), NameColor, m_name, - TEXT_ORIENT_VERT, PinNameSize, + TEXT_ANGLE_VERT, PinNameSize, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, aWidth, false, false ); @@ -1748,7 +1748,7 @@ void LIB_PIN::PlotPinTexts( PLOTTER* plotter, wxPoint& pin_pos, int orient, plotter->Text( wxPoint( x1 - num_offset, (y1 + pin_pos.y) / 2 ), NumColor, StringPinNum, - TEXT_ORIENT_VERT, PinNumSize, + TEXT_ANGLE_VERT, PinNumSize, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM, aWidth, false, false ); @@ -1766,7 +1766,7 @@ void LIB_PIN::PlotPinTexts( PLOTTER* plotter, wxPoint& pin_pos, int orient, x = (x1 + pin_pos.x) / 2; plotter->Text( wxPoint( x, y1 - name_offset ), NameColor, m_name, - TEXT_ORIENT_HORIZ, PinNameSize, + TEXT_ANGLE_HORIZ, PinNameSize, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM, aWidth, false, false ); @@ -1777,7 +1777,7 @@ void LIB_PIN::PlotPinTexts( PLOTTER* plotter, wxPoint& pin_pos, int orient, x = ( x1 + pin_pos.x ) / 2; plotter->Text( wxPoint( x, y1 + num_offset ), NumColor, StringPinNum, - TEXT_ORIENT_HORIZ, PinNumSize, + TEXT_ANGLE_HORIZ, PinNumSize, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP, aWidth, false, false ); @@ -1790,7 +1790,7 @@ void LIB_PIN::PlotPinTexts( PLOTTER* plotter, wxPoint& pin_pos, int orient, y = ( y1 + pin_pos.y ) / 2; plotter->Text( wxPoint( x1 - name_offset, y ), NameColor, m_name, - TEXT_ORIENT_VERT, PinNameSize, + TEXT_ANGLE_VERT, PinNameSize, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM, aWidth, false, false ); @@ -1801,7 +1801,7 @@ void LIB_PIN::PlotPinTexts( PLOTTER* plotter, wxPoint& pin_pos, int orient, plotter->Text( wxPoint( x1 + num_offset, ( y1 + pin_pos.y ) / 2 ), NumColor, StringPinNum, - TEXT_ORIENT_VERT, PinNumSize, + TEXT_ANGLE_VERT, PinNumSize, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP, aWidth, false, false ); diff --git a/eeschema/lib_text.cpp b/eeschema/lib_text.cpp index 28f3f442c0..a60c2bbce8 100644 --- a/eeschema/lib_text.cpp +++ b/eeschema/lib_text.cpp @@ -47,7 +47,7 @@ LIB_TEXT::LIB_TEXT( LIB_PART * aParent ) : LIB_ITEM( LIB_TEXT_T, aParent ), EDA_TEXT() { - m_Size = wxSize( 50, 50 ); + SetTextSize( wxSize( 50, 50 ) ); m_typeName = _( "Text" ); m_rotate = false; m_updateText = false; @@ -71,23 +71,24 @@ bool LIB_TEXT::Save( OUTPUTFORMATTER& aFormatter ) text.Replace( wxT( " " ), wxT( "~" ) ); } - aFormatter.Print( 0, "T %g %d %d %d %d %d %d %s", GetOrientation(), m_Pos.x, m_Pos.y, - m_Size.x, m_Attributs, m_Unit, m_Convert, TO_UTF8( text ) ); + aFormatter.Print( 0, "T %g %d %d %d %d %d %d %s", GetTextAngle(), + GetTextPos().x, GetTextPos().y, + GetTextWidth(), !IsVisible(), m_Unit, m_Convert, TO_UTF8( text ) ); - aFormatter.Print( 0, " %s %d", m_Italic ? "Italic" : "Normal", ( m_Bold > 0 ) ? 1 : 0 ); + aFormatter.Print( 0, " %s %d", IsItalic() ? "Italic" : "Normal", IsBold() ); char hjustify = 'C'; - if( m_HJustify == GR_TEXT_HJUSTIFY_LEFT ) + if( GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT ) hjustify = 'L'; - else if( m_HJustify == GR_TEXT_HJUSTIFY_RIGHT ) + else if( GetHorizJustify() == GR_TEXT_HJUSTIFY_RIGHT ) hjustify = 'R'; char vjustify = 'C'; - if( m_VJustify == GR_TEXT_VJUSTIFY_BOTTOM ) + if( GetVertJustify() == GR_TEXT_VJUSTIFY_BOTTOM ) vjustify = 'B'; - else if( m_VJustify == GR_TEXT_VJUSTIFY_TOP ) + else if( GetVertJustify() == GR_TEXT_VJUSTIFY_TOP ) vjustify = 'T'; aFormatter.Print( 0, " %c %c\n", hjustify, vjustify ); @@ -104,15 +105,19 @@ bool LIB_TEXT::Load( LINE_READER& aLineReader, wxString& errorMsg ) char tmp[256]; char* line = (char*) aLineReader; double angle; + int not_visible; + int x, y, size; buf[0] = 0; tmp[0] = 0; // For italic option, Not in old versions cnt = sscanf( line + 2, "%lf %d %d %d %d %d %d \"%[^\"]\" %255s %d %c %c", - &angle, &m_Pos.x, &m_Pos.y, &m_Size.x, &m_Attributs, + &angle, &x, &y, &size, ¬_visible, &m_Unit, &m_Convert, buf, tmp, &thickness, &hjustify, &vjustify ); + SetVisible( !not_visible ); + if( cnt >= 8 ) // if quoted loading failed, load as not quoted { m_Text = FROM_UTF8( buf ); @@ -123,7 +128,7 @@ bool LIB_TEXT::Load( LINE_READER& aLineReader, wxString& errorMsg ) else { cnt = sscanf( line + 2, "%lf %d %d %d %d %d %d %255s %255s %d %c %c", - &angle, &m_Pos.x, &m_Pos.y, &m_Size.x, &m_Attributs, + &angle, &x, &y, &size, ¬_visible, &m_Unit, &m_Convert, buf, tmp, &thickness, &hjustify, &vjustify ); @@ -133,54 +138,56 @@ bool LIB_TEXT::Load( LINE_READER& aLineReader, wxString& errorMsg ) return false; } + SetVisible( !not_visible ); + /* Convert '~' to spaces (only if text is not quoted). */ m_Text = FROM_UTF8( buf ); m_Text.Replace( wxT( "~" ), wxT( " " ) ); } - SetOrientation( angle ); + SetTextAngle( angle ); - m_Size.y = m_Size.x; + SetTextSize( wxSize( size, size ) ); + SetTextPos( wxPoint( x, y ) ); if( strncasecmp( tmp, "Italic", 6 ) == 0 ) - m_Italic = true; + SetItalic( true ); if( thickness > 0 ) { - m_Bold = true; + SetBold( true ); } switch( hjustify ) { case 'L': - m_HJustify = GR_TEXT_HJUSTIFY_LEFT; + SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); break; case 'C': - m_HJustify = GR_TEXT_HJUSTIFY_CENTER; + SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER ); break; case 'R': - m_HJustify = GR_TEXT_HJUSTIFY_RIGHT; + SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); break; } switch( vjustify ) { case 'T': - m_VJustify = GR_TEXT_VJUSTIFY_TOP; + SetVertJustify( GR_TEXT_VJUSTIFY_TOP ); break; case 'C': - m_VJustify = GR_TEXT_VJUSTIFY_CENTER; + SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); break; case 'B': - m_VJustify = GR_TEXT_VJUSTIFY_BOTTOM; + SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); break; } - return true; } @@ -197,14 +204,15 @@ bool LIB_TEXT::HitTest( const wxPoint &aPosition, int aThreshold, const TRANSFOR aThreshold = 0; EDA_TEXT tmp_text( *this ); - tmp_text.SetTextPosition( aTransform.TransformCoordinate( m_Pos ) ); + tmp_text.SetTextPos( aTransform.TransformCoordinate( GetTextPos() ) ); /* The text orientation may need to be flipped if the - * transformation matrix causes xy axes to be flipped. + * transformation matrix causes xy axes to be flipped. * this simple algo works only for schematic matrix (rot 90 or/and mirror) */ - int t1 = ( aTransform.x1 != 0 ) ^ ( m_Orient != 0 ); - tmp_text.SetOrientation( t1 ? TEXT_ORIENT_HORIZ : TEXT_ORIENT_VERT ); + bool t1 = ( aTransform.x1 != 0 ) ^ ( GetTextAngle() != 0 ); + + tmp_text.SetTextAngle( t1 ? TEXT_ANGLE_HORIZ : TEXT_ANGLE_VERT ); return tmp_text.TextHitTest( aPosition ); } @@ -213,19 +221,13 @@ EDA_ITEM* LIB_TEXT::Clone() const { LIB_TEXT* newitem = new LIB_TEXT(NULL); - newitem->m_Pos = m_Pos; - newitem->m_Orient = m_Orient; - newitem->m_Size = m_Size; - newitem->m_Attributs = m_Attributs; newitem->m_Unit = m_Unit; newitem->m_Convert = m_Convert; newitem->m_Flags = m_Flags; newitem->m_Text = m_Text; - newitem->m_Thickness = m_Thickness; - newitem->m_Italic = m_Italic; - newitem->m_Bold = m_Bold; - newitem->m_HJustify = m_HJustify; - newitem->m_VJustify = m_VJustify; + + newitem->SetEffects( *this ); + return newitem; } @@ -241,17 +243,17 @@ int LIB_TEXT::compare( const LIB_ITEM& other ) const if( result != 0 ) return result; - if( m_Pos.x != tmp->m_Pos.x ) - return m_Pos.x - tmp->m_Pos.x; + if( GetTextPos().x != tmp->GetTextPos().x ) + return GetTextPos().x - tmp->GetTextPos().x; - if( m_Pos.y != tmp->m_Pos.y ) - return m_Pos.y - tmp->m_Pos.y; + if( GetTextPos().y != tmp->GetTextPos().y ) + return GetTextPos().y - tmp->GetTextPos().y; - if( m_Size.x != tmp->m_Size.x ) - return m_Size.x - tmp->m_Size.x; + if( GetTextWidth() != tmp->GetTextWidth() ) + return GetTextWidth() - tmp->GetTextWidth(); - if( m_Size.y != tmp->m_Size.y ) - return m_Size.y - tmp->m_Size.y; + if( GetTextHeight() != tmp->GetTextHeight() ) + return GetTextHeight() - tmp->GetTextHeight(); return 0; } @@ -259,7 +261,7 @@ int LIB_TEXT::compare( const LIB_ITEM& other ) const void LIB_TEXT::SetOffset( const wxPoint& aOffset ) { - m_Pos += aOffset; + EDA_TEXT::Offset( aOffset ); } @@ -269,36 +271,49 @@ bool LIB_TEXT::Inside( EDA_RECT& rect ) const * FIXME: This should calculate the text size and justification and * use rectangle intersect. */ - return rect.Contains( m_Pos.x, -m_Pos.y ); + return rect.Contains( GetTextPos().x, -GetTextPos().y ); } void LIB_TEXT::Move( const wxPoint& newPosition ) { - m_Pos = newPosition; + SetTextPos( newPosition ); } void LIB_TEXT::MirrorHorizontal( const wxPoint& center ) { - m_Pos.x -= center.x; - m_Pos.x *= -1; - m_Pos.x += center.x; + int x = GetTextPos().x; + + x -= center.x; + x *= -1; + x += center.x; + + SetTextX( x ); } + void LIB_TEXT::MirrorVertical( const wxPoint& center ) { - m_Pos.y -= center.y; - m_Pos.y *= -1; - m_Pos.y += center.y; + int y = GetTextPos().y; + + y -= center.y; + y *= -1; + y += center.y; + + SetTextY( y ); } + void LIB_TEXT::Rotate( const wxPoint& center, bool aRotateCCW ) { int rot_angle = aRotateCCW ? -900 : 900; - RotatePoint( &m_Pos, center, rot_angle ); - m_Orient = m_Orient ? 0 : 900; + wxPoint pt = GetTextPos(); + RotatePoint( &pt, center, rot_angle ); + SetTextPos( pt ); + + SetTextAngle( GetTextAngle() != 0.0 ? 0 : 900 ); } @@ -314,7 +329,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 ) ^ ( m_Orient != 0 ); + int t1 = ( aTransform.x1 != 0 ) ^ ( GetTextAngle() != 0 ); wxPoint pos = aTransform.TransformCoordinate( txtpos ) + offset; // Get color @@ -326,26 +341,26 @@ void LIB_TEXT::Plot( PLOTTER* plotter, const wxPoint& offset, bool fill, color = BLACK; plotter->Text( pos, color, GetShownText(), - t1 ? TEXT_ORIENT_HORIZ : TEXT_ORIENT_VERT, - m_Size, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, - GetPenSize(), m_Italic, m_Bold ); + t1 ? TEXT_ANGLE_HORIZ : TEXT_ANGLE_VERT, + GetTextSize(), GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, + GetPenSize(), IsItalic(), IsBold() ); } int LIB_TEXT::GetPenSize() const { - int pensize = m_Thickness; + int pensize = GetThickness(); if( pensize == 0 ) // Use default values for pen size { - if( m_Bold ) - pensize = GetPenSizeForBold( m_Size.x ); + if( IsBold() ) + pensize = GetPenSizeForBold( GetTextWidth() ); else pensize = GetDefaultLineThickness(); } // Clip pen size for small texts: - pensize = Clamp_Text_PenSize( pensize, m_Size, m_Bold ); + pensize = Clamp_Text_PenSize( pensize, GetTextSize(), IsBold() ); return pensize; } @@ -371,14 +386,14 @@ void LIB_TEXT::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aO /* Calculate the text orientation, according to the component * orientation/mirror (needed when draw text in schematic) */ - int orient = m_Orient; + int orient = GetTextAngle(); if( aTransform.y1 ) // Rotate component 90 degrees. { - if( orient == TEXT_ORIENT_HORIZ ) - orient = TEXT_ORIENT_VERT; + if( orient == TEXT_ANGLE_HORIZ ) + orient = TEXT_ANGLE_VERT; else - orient = TEXT_ORIENT_HORIZ; + orient = TEXT_ANGLE_HORIZ; } /* Calculate the text justification, according to the component @@ -393,6 +408,7 @@ void LIB_TEXT::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aO * and use GetBoundaryBox to know the text coordinate considered as centered */ EDA_RECT bBox = GetBoundingBox(); + // convert coordinates from draw Y axis to libedit Y axis: bBox.RevertYAxis(); wxPoint txtpos = bBox.Centre(); @@ -401,9 +417,9 @@ void LIB_TEXT::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aO txtpos = aTransform.TransformCoordinate( txtpos ) + aOffset; EDA_RECT* clipbox = aPanel? aPanel->GetClipBox() : NULL; - DrawGraphicText( clipbox, aDC, txtpos, color, GetShownText(), orient, m_Size, + DrawGraphicText( clipbox, aDC, txtpos, color, GetShownText(), orient, GetTextSize(), GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, GetPenSize(), - m_Italic, m_Bold ); + IsItalic(), IsBold() ); /* Enable this to draw the bounding box around the text field to validate @@ -424,7 +440,7 @@ void LIB_TEXT::GetMsgPanelInfo( MSG_PANEL_ITEMS& aList ) LIB_ITEM::GetMsgPanelInfo( aList ); - msg = StringFromValue( g_UserUnit, m_Thickness, true ); + msg = StringFromValue( g_UserUnit, GetThickness(), true ); aList.push_back( MSG_PANEL_ITEM( _( "Line Width" ), msg, BLUE ) ); } @@ -440,9 +456,10 @@ const EDA_RECT LIB_TEXT::GetBoundingBox() const // We are using now a bottom to top Y axis. wxPoint orig = rect.GetOrigin(); - wxPoint end = rect.GetEnd(); - RotatePoint( &orig, m_Pos, -m_Orient ); - RotatePoint( &end, m_Pos, -m_Orient ); + wxPoint end = rect.GetEnd(); + + RotatePoint( &orig, GetTextPos(), -GetTextAngle() ); + RotatePoint( &end, GetTextPos(), -GetTextAngle() ); rect.SetOrigin( orig ); rect.SetEnd( end ); @@ -462,7 +479,7 @@ void LIB_TEXT::Rotate() } else { - m_Orient = ( m_Orient == TEXT_ORIENT_VERT ) ? TEXT_ORIENT_HORIZ : TEXT_ORIENT_VERT; + SetTextAngle( GetTextAngle() == TEXT_ANGLE_VERT ? TEXT_ANGLE_HORIZ : TEXT_ANGLE_VERT ); } } @@ -499,13 +516,13 @@ void LIB_TEXT::BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aPosition ) if( aEditMode == IS_MOVED ) { - m_initialPos = m_Pos; + m_initialPos = GetTextPos(); m_initialCursorPos = aPosition; SetEraseLastDrawItem(); } else { - m_Pos = aPosition; + SetTextPos( aPosition ); } m_Flags = aEditMode; @@ -537,7 +554,7 @@ void LIB_TEXT::calcEdit( const wxPoint& aPosition ) { if( m_rotate ) { - m_Orient = ( m_Orient == TEXT_ORIENT_VERT ) ? TEXT_ORIENT_HORIZ : TEXT_ORIENT_VERT; + SetTextAngle( GetTextAngle() == TEXT_ANGLE_VERT ? TEXT_ANGLE_HORIZ : TEXT_ANGLE_VERT ); m_rotate = false; } @@ -550,7 +567,7 @@ void LIB_TEXT::calcEdit( const wxPoint& aPosition ) if( m_Flags == IS_NEW ) { SetEraseLastDrawItem(); - m_Pos = aPosition; + SetTextPos( aPosition ); } else if( m_Flags == IS_MOVED ) { diff --git a/eeschema/lib_text.h b/eeschema/lib_text.h index c85c746dea..dd389ea16f 100644 --- a/eeschema/lib_text.h +++ b/eeschema/lib_text.h @@ -112,7 +112,7 @@ public: void Move( const wxPoint& aPosition ) override; - wxPoint GetPosition() const override { return m_Pos; } + wxPoint GetPosition() const override { return EDA_TEXT::GetTextPos(); } void MirrorHorizontal( const wxPoint& aCenter ) override; @@ -123,9 +123,9 @@ public: void Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, const TRANSFORM& aTransform ) override; - int GetWidth() const override { return m_Thickness; } + int GetWidth() const override { return GetThickness(); } - void SetWidth( int aWidth ) override { m_Thickness = aWidth; } + void SetWidth( int aWidth ) override { SetThickness( aWidth ); } wxString GetSelectMenuText() const override; diff --git a/eeschema/libeditframe.cpp b/eeschema/libeditframe.cpp index ee06997a3c..7f0fcc83ea 100644 --- a/eeschema/libeditframe.cpp +++ b/eeschema/libeditframe.cpp @@ -71,7 +71,7 @@ LIB_ITEM* LIB_EDIT_FRAME::m_drawItem = NULL; bool LIB_EDIT_FRAME:: m_showDeMorgan = false; wxSize LIB_EDIT_FRAME:: m_clientSize = wxSize( -1, -1 ); int LIB_EDIT_FRAME:: m_textSize = -1; -int LIB_EDIT_FRAME:: m_textOrientation = TEXT_ORIENT_HORIZ; +double LIB_EDIT_FRAME:: m_current_text_angle = TEXT_ANGLE_HORIZ; int LIB_EDIT_FRAME:: m_drawLineWidth = 0; // these values are overridden when reading the config diff --git a/eeschema/libeditframe.h b/eeschema/libeditframe.h index 5f8bcf13bb..878cfd33a6 100644 --- a/eeschema/libeditframe.h +++ b/eeschema/libeditframe.h @@ -108,8 +108,8 @@ class LIB_EDIT_FRAME : public SCH_BASE_FRAME /// The current text size setting. static int m_textSize; - /// Current text orientation setting. - static int m_textOrientation; + /// Current text angle setting. + static double m_current_text_angle; /// The default pin num text size setting. static int m_textPinNumDefaultSize; diff --git a/eeschema/sch_component.cpp b/eeschema/sch_component.cpp index f1f3840419..f7b6738d13 100644 --- a/eeschema/sch_component.cpp +++ b/eeschema/sch_component.cpp @@ -102,7 +102,7 @@ static LIB_PART* dummy() LIB_TEXT* text = new LIB_TEXT( part ); - text->SetSize( wxSize( 150, 150 ) ); + text->SetTextSize( wxSize( 150, 150 ) ); text->SetText( wxString( wxT( "??" ) ) ); part->AddDrawItem( square ); @@ -171,7 +171,7 @@ SCH_COMPONENT::SCH_COMPONENT( LIB_PART& aPart, SCH_SHEET_PATH* sheet, int unit, schField = AddField( fld ); } - schField->SetTextPosition( m_Pos + it->GetTextPosition() ); + schField->SetTextPos( m_Pos + it->GetTextPos() ); schField->ImportValues( *it ); schField->SetText( it->GetText() ); } @@ -541,11 +541,11 @@ void SCH_COMPONENT::SetRef( const SCH_SHEET_PATH* sheet, const wxString& ref ) SCH_FIELD* rf = GetField( REFERENCE ); if( rf->GetText().IsEmpty() - || ( abs( rf->GetTextPosition().x - m_Pos.x ) + - abs( rf->GetTextPosition().y - m_Pos.y ) > 10000 ) ) + || ( abs( rf->GetTextPos().x - m_Pos.x ) + + abs( rf->GetTextPos().y - m_Pos.y ) > 10000 ) ) { // move it to a reasonable position - rf->SetTextPosition( m_Pos + wxPoint( 50, 50 ) ); + rf->SetTextPos( m_Pos + wxPoint( 50, 50 ) ); } rf->SetText( ref ); // for drawing. @@ -1209,7 +1209,7 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg ) { m_part_name.Empty(); GetField( VALUE )->Empty(); - GetField( VALUE )->SetOrientation( TEXT_ORIENT_HORIZ ); + GetField( VALUE )->SetTextAngle( TEXT_ANGLE_HORIZ ); GetField( VALUE )->SetVisible( false ); } @@ -1276,7 +1276,7 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg ) for( int i = 0; iGetText().IsEmpty() ) - GetField( i )->SetTextPosition( m_Pos ); + GetField( i )->SetTextPos( m_Pos ); } } else if( line[0] == 'A' && line[1] == 'R' ) @@ -1386,17 +1386,17 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg ) continue; } - GetField( fieldNdx )->SetTextPosition( wxPoint( x, y ) ); - GetField( fieldNdx )->SetAttributes( attr ); + GetField( fieldNdx )->SetTextPos( wxPoint( x, y ) ); + GetField( fieldNdx )->SetVisible( !attr ); if( (w == 0 ) || (ii == 4) ) w = GetDefaultTextSize(); - GetField( fieldNdx )->SetSize( wxSize( w, w ) ); - GetField( fieldNdx )->SetOrientation( TEXT_ORIENT_HORIZ ); + GetField( fieldNdx )->SetTextSize( wxSize( w, w ) ); + GetField( fieldNdx )->SetTextAngle( TEXT_ANGLE_HORIZ ); if( char1[0] == 'V' ) - GetField( fieldNdx )->SetOrientation( TEXT_ORIENT_VERT ); + GetField( fieldNdx )->SetTextAngle( TEXT_ANGLE_VERT ); if( ii >= 7 ) { @@ -1577,9 +1577,9 @@ void SCH_COMPONENT::MirrorY( int aYaxis_position ) for( int ii = 0; ii < GetFieldCount(); ii++ ) { // Move the fields to the new position because the component itself has moved. - wxPoint pos = GetField( ii )->GetTextPosition(); + wxPoint pos = GetField( ii )->GetTextPos(); pos.x -= dx; - GetField( ii )->SetTextPosition( pos ); + GetField( ii )->SetTextPos( pos ); } } @@ -1595,9 +1595,9 @@ void SCH_COMPONENT::MirrorX( int aXaxis_position ) for( int ii = 0; ii < GetFieldCount(); ii++ ) { // Move the fields to the new position because the component itself has moved. - wxPoint pos = GetField( ii )->GetTextPosition(); + wxPoint pos = GetField( ii )->GetTextPos(); pos.y -= dy; - GetField( ii )->SetTextPosition( pos ); + GetField( ii )->SetTextPos( pos ); } } @@ -1613,10 +1613,10 @@ void SCH_COMPONENT::Rotate( wxPoint aPosition ) for( int ii = 0; ii < GetFieldCount(); ii++ ) { // Move the fields to the new position because the component itself has moved. - wxPoint pos = GetField( ii )->GetTextPosition(); + wxPoint pos = GetField( ii )->GetTextPos(); pos.x -= prev.x - m_Pos.x; pos.y -= prev.y - m_Pos.y; - GetField( ii )->SetTextPosition( pos ); + GetField( ii )->SetTextPos( pos ); } } diff --git a/eeschema/sch_field.cpp b/eeschema/sch_field.cpp index 00c2398d3d..32d2fc4cea 100644 --- a/eeschema/sch_field.cpp +++ b/eeschema/sch_field.cpp @@ -55,11 +55,11 @@ SCH_FIELD::SCH_FIELD( const wxPoint& aPos, int aFieldId, SCH_COMPONENT* aParent, SCH_ITEM( aParent, SCH_FIELD_T ), EDA_TEXT() { - m_Pos = aPos; + SetTextPos( aPos ); m_id = aFieldId; - m_Attributs = TEXT_NO_VISIBLE; m_name = aName; + SetVisible( false ); SetLayer( LAYER_FIELDS ); } @@ -98,18 +98,18 @@ const wxString SCH_FIELD::GetFullyQualifiedText() const int SCH_FIELD::GetPenSize() const { - int pensize = m_Thickness; + int pensize = GetThickness(); if( pensize == 0 ) // Use default values for pen size { - if( m_Bold ) - pensize = GetPenSizeForBold( m_Size.x ); + if( IsBold() ) + pensize = GetPenSizeForBold( GetTextWidth() ); else pensize = GetDefaultLineThickness(); } // Clip pen size for small texts: - pensize = Clamp_Text_PenSize( pensize, m_Size, m_Bold ); + pensize = Clamp_Text_PenSize( pensize, GetTextSize(), IsBold() ); return pensize; } @@ -121,33 +121,33 @@ void SCH_FIELD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, EDA_COLOR_T color; wxPoint textpos; SCH_COMPONENT* parentComponent = (SCH_COMPONENT*) m_Parent; - int LineWidth = m_Thickness; + int lineWidth = GetThickness(); - if( LineWidth == 0 ) // Use default values for pen size + if( lineWidth == 0 ) // Use default values for pen size { - if( m_Bold ) - LineWidth = GetPenSizeForBold( m_Size.x ); + if( IsBold() ) + lineWidth = GetPenSizeForBold( GetTextWidth() ); else - LineWidth = GetDefaultLineThickness(); + lineWidth = GetDefaultLineThickness(); } // Clip pen size for small texts: - LineWidth = Clamp_Text_PenSize( LineWidth, m_Size, m_Bold ); + lineWidth = Clamp_Text_PenSize( lineWidth, GetTextSize(), IsBold() ); - if( ((m_Attributs & TEXT_NO_VISIBLE) && !m_forceVisible) || IsVoid() ) + if( ( !IsVisible() && !m_forceVisible) || IsVoid() ) return; GRSetDrawMode( aDC, aDrawMode ); // Calculate the text orientation according to the component orientation. - orient = m_Orient; + orient = GetTextAngle(); if( parentComponent->GetTransform().y1 ) // Rotate component 90 degrees. { - if( orient == TEXT_ORIENT_HORIZ ) - orient = TEXT_ORIENT_VERT; + if( orient == TEXT_ANGLE_HORIZ ) + orient = TEXT_ANGLE_VERT; else - orient = TEXT_ORIENT_HORIZ; + orient = TEXT_ANGLE_HORIZ; } /* Calculate the text justification, according to the component @@ -179,15 +179,15 @@ void SCH_FIELD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, } EDA_RECT* clipbox = aPanel ? aPanel->GetClipBox() : NULL; - DrawGraphicText( clipbox, aDC, textpos, color, GetFullyQualifiedText(), orient, m_Size, + DrawGraphicText( clipbox, aDC, textpos, color, GetFullyQualifiedText(), orient, GetTextSize(), GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, - LineWidth, m_Italic, m_Bold ); + lineWidth, IsItalic(), IsBold() ); // While moving: don't loose visual contact to which component this label belongs. if ( IsWireImage() ) { const wxPoint origin = parentComponent->GetPosition(); - textpos = m_Pos - origin; + textpos = GetTextPos() - origin; textpos = parentComponent->GetScreenCoord( textpos ); textpos += parentComponent->GetPosition(); GRLine( clipbox, aDC, origin, textpos, 2, DARKGRAY ); @@ -219,31 +219,17 @@ void SCH_FIELD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, void SCH_FIELD::ImportValues( const LIB_FIELD& aSource ) { - m_Orient = aSource.GetOrientation(); - m_Size = aSource.GetSize(); - m_HJustify = aSource.GetHorizJustify(); - m_VJustify = aSource.GetVertJustify(); - m_Italic = aSource.IsItalic(); - m_Bold = aSource.IsBold(); - m_Thickness = aSource.GetThickness(); - m_Attributs = aSource.GetAttributes(); - m_Mirror = aSource.IsMirrored(); + SetEffects( aSource ); } + void SCH_FIELD::ExportValues( LIB_FIELD& aDest ) const { aDest.SetId( GetId() ); aDest.SetText( m_Text ); // Set field value aDest.SetName( GetName() ); - aDest.SetOrientation( GetOrientation() ); - aDest.SetSize( GetSize() ); - aDest.SetTextPosition( GetTextPosition() ); - aDest.SetHorizJustify( GetHorizJustify() ); - aDest.SetVertJustify( GetVertJustify() ); - aDest.SetItalic( IsItalic() ); - aDest.SetBold( IsBold() ); - aDest.SetThickness( GetThickness() ); - aDest.SetAttributes( GetAttributes() ); + + aDest.SetEffects( *this ); } @@ -256,27 +242,19 @@ void SCH_FIELD::SwapData( SCH_ITEM* aItem ) std::swap( m_Text, item->m_Text ); std::swap( m_Layer, item->m_Layer ); - std::swap( m_Pos, item->m_Pos ); - std::swap( m_Size, item->m_Size ); - std::swap( m_Thickness, item->m_Thickness ); - std::swap( m_Orient, item->m_Orient ); - std::swap( m_Mirror, item->m_Mirror ); - std::swap( m_Attributs, item->m_Attributs ); - std::swap( m_Italic, item->m_Italic ); - std::swap( m_Bold, item->m_Bold ); - std::swap( m_HJustify, item->m_HJustify ); - std::swap( m_VJustify, item->m_VJustify ); + + SwapEffects( *item ); } const EDA_RECT SCH_FIELD::GetBoundingBox() const { SCH_COMPONENT* parentComponent = (SCH_COMPONENT*) m_Parent; - int linewidth = ( m_Thickness == 0 ) ? GetDefaultLineThickness() : m_Thickness; + int linewidth = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness(); // We must pass the effective text thickness to GetTextBox // when calculating the bounding box - linewidth = Clamp_Text_PenSize( linewidth, m_Size, m_Bold ); + linewidth = Clamp_Text_PenSize( linewidth, GetTextSize(), IsBold() ); // Calculate the text bounding box: EDA_RECT rect; @@ -293,11 +271,11 @@ const EDA_RECT SCH_FIELD::GetBoundingBox() const // Calculate the bounding box position relative to the component: wxPoint origin = parentComponent->GetPosition(); - wxPoint pos = m_Pos - origin; + wxPoint pos = GetTextPos() - origin; wxPoint begin = rect.GetOrigin() - origin; wxPoint end = rect.GetEnd() - origin; - RotatePoint( &begin, pos, m_Orient ); - RotatePoint( &end, pos, m_Orient ); + RotatePoint( &begin, pos, GetTextAngle() ); + RotatePoint( &end, pos, GetTextAngle() ); // Due to the Y axis direction, we must mirror the bounding box, // relative to the text position: @@ -336,28 +314,28 @@ bool SCH_FIELD::Save( FILE* aFile ) const { char hjustify = 'C'; - if( m_HJustify == GR_TEXT_HJUSTIFY_LEFT ) + if( GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT ) hjustify = 'L'; - else if( m_HJustify == GR_TEXT_HJUSTIFY_RIGHT ) + else if( GetHorizJustify() == GR_TEXT_HJUSTIFY_RIGHT ) hjustify = 'R'; char vjustify = 'C'; - if( m_VJustify == GR_TEXT_VJUSTIFY_BOTTOM ) + if( GetVertJustify() == GR_TEXT_VJUSTIFY_BOTTOM ) vjustify = 'B'; - else if( m_VJustify == GR_TEXT_VJUSTIFY_TOP ) + else if( GetVertJustify() == GR_TEXT_VJUSTIFY_TOP ) vjustify = 'T'; if( fprintf( aFile, "F %d %s %c %-3d %-3d %-3d %4.4X %c %c%c%c", m_id, EscapedUTF8( m_Text ).c_str(), // wraps in quotes too - m_Orient == TEXT_ORIENT_HORIZ ? 'H' : 'V', - m_Pos.x, m_Pos.y, - m_Size.x, - m_Attributs, + GetTextAngle() == TEXT_ANGLE_HORIZ ? 'H' : 'V', + GetTextPos().x, GetTextPos().y, + GetTextWidth(), + !IsVisible(), hjustify, vjustify, - m_Italic ? 'I' : 'N', - m_Bold ? 'B' : 'N' ) == EOF ) + IsItalic() ? 'I' : 'N', + IsBold() ? 'B' : 'N' ) == EOF ) { return false; } @@ -476,7 +454,9 @@ bool SCH_FIELD::Replace( wxFindReplaceData& aSearchData, void* aAuxData ) void SCH_FIELD::Rotate( wxPoint aPosition ) { - RotatePoint( &m_Pos, aPosition, 900 ); + wxPoint pt = GetTextPos(); + RotatePoint( &pt, aPosition, 900 ); + SetTextPos( pt ); } @@ -555,7 +535,7 @@ void SCH_FIELD::Plot( PLOTTER* aPlotter ) EDA_COLOR_T color = GetLayerColor( GetLayer() ); - if( m_Attributs & TEXT_NO_VISIBLE ) + if( !IsVisible() ) return; if( IsVoid() ) @@ -563,14 +543,14 @@ void SCH_FIELD::Plot( PLOTTER* aPlotter ) /* Calculate the text orientation, according to the component * orientation/mirror */ - int orient = m_Orient; + int orient = GetTextAngle(); if( parent->GetTransform().y1 ) // Rotate component 90 deg. { - if( orient == TEXT_ORIENT_HORIZ ) - orient = TEXT_ORIENT_VERT; + if( orient == TEXT_ANGLE_HORIZ ) + orient = TEXT_ANGLE_VERT; else - orient = TEXT_ORIENT_HORIZ; + orient = TEXT_ANGLE_HORIZ; } /* Calculate the text justification, according to the component @@ -591,8 +571,9 @@ void SCH_FIELD::Plot( PLOTTER* aPlotter ) int thickness = GetPenSize(); - aPlotter->Text( textpos, color, GetFullyQualifiedText(), orient, m_Size, hjustify, vjustify, - thickness, m_Italic, m_Bold ); + aPlotter->Text( textpos, color, GetFullyQualifiedText(), orient, GetTextSize(), + hjustify, vjustify, + thickness, IsItalic(), IsBold() ); } @@ -607,16 +588,15 @@ void SCH_FIELD::SetPosition( const wxPoint& aPosition ) // the position relative to the parent component. wxPoint pt = aPosition - pos; - m_Pos = pos + component->GetTransform().InverseTransform().TransformCoordinate( pt ); + SetTextPos( pos + component->GetTransform().InverseTransform().TransformCoordinate( pt ) ); } wxPoint SCH_FIELD::GetPosition() const { - SCH_COMPONENT* component = (SCH_COMPONENT*) GetParent(); - wxPoint pos = m_Pos - component->GetPosition(); + wxPoint pos = GetTextPos() - component->GetPosition(); return component->GetTransform().TransformCoordinate( pos ) + component->GetPosition(); } diff --git a/eeschema/sch_field.h b/eeschema/sch_field.h index 8acf7053ba..d467390a2c 100644 --- a/eeschema/sch_field.h +++ b/eeschema/sch_field.h @@ -140,15 +140,6 @@ public: int GetPenSize() const override; - /** - * Function IsVisible - * @return true is this field is visible, false if flagged invisible - */ - bool IsVisible() const - { - return !( m_Attributs & TEXT_NO_VISIBLE ); - } - void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor = UNSPECIFIED_COLOR ) override; @@ -158,10 +149,9 @@ public: void Move( const wxPoint& aMoveVector ) override { - m_Pos += aMoveVector; + Offset( aMoveVector ); } - void Rotate( wxPoint aPosition ) override; /** @@ -196,7 +186,7 @@ public: bool IsReplaceable() const override { return true; } - wxPoint GetLibPosition() const { return m_Pos; } + wxPoint GetLibPosition() const { return EDA_TEXT::GetTextPos(); } wxPoint GetPosition() const override; diff --git a/eeschema/sch_legacy_plugin.cpp b/eeschema/sch_legacy_plugin.cpp index ceca30815d..631d8fcde4 100644 --- a/eeschema/sch_legacy_plugin.cpp +++ b/eeschema/sch_legacy_plugin.cpp @@ -881,7 +881,7 @@ SCH_SHEET* SCH_LEGACY_PLUGIN::loadSheet( FILE_LINE_READER& aReader ) size = parseInt( aReader, line, &line ); - sheetPin->SetSize( wxSize( size, size ) ); + sheetPin->SetTextSize( wxSize( size, size ) ); sheet->AddPin( sheetPin.release() ); } @@ -1131,11 +1131,11 @@ SCH_TEXT* SCH_LEGACY_PLUGIN::loadText( FILE_LINE_READER& aReader ) position.x = parseInt( aReader, line, &line ); position.y = parseInt( aReader, line, &line ); text->SetPosition( position ); - text->SetOrientation( parseInt( aReader, line, &line ) ); + text->SetLabelSpinStyle( parseInt( aReader, line, &line ) ); int size = parseInt( aReader, line, &line ); - text->SetSize( wxSize( size, size ) ); + text->SetTextSize( wxSize( size, size ) ); // Parse the global and hierarchical label type. if( text->Type() == SCH_HIERARCHICAL_LABEL_T || text->Type() == SCH_GLOBAL_LABEL_T ) @@ -1379,14 +1379,14 @@ SCH_COMPONENT* SCH_LEGACY_PLUGIN::loadComponent( FILE_LINE_READER& aReader ) } component->GetField( index )->SetText( text ); - component->GetField( index )->SetTextPosition( pos ); - component->GetField( index )->SetAttributes( attributes ); - component->GetField( index )->SetSize( wxSize( size, size ) ); + component->GetField( index )->SetTextPos( pos ); + component->GetField( index )->SetVisible( !attributes ); + component->GetField( index )->SetTextSize( wxSize( size, size ) ); if( orientation == 'H' ) - component->GetField( index )->SetOrientation( TEXT_ORIENT_HORIZ ); + component->GetField( index )->SetTextAngle( TEXT_ANGLE_HORIZ ); else if( orientation == 'V' ) - component->GetField( index )->SetOrientation( TEXT_ORIENT_VERT ); + component->GetField( index )->SetTextAngle( TEXT_ANGLE_VERT ); else SCH_PARSE_ERROR( _( "component field orientation must be H or V" ), aReader, line ); @@ -1671,10 +1671,10 @@ void SCH_LEGACY_PLUGIN::saveField( SCH_FIELD* aField ) 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->GetOrientation() == TEXT_ORIENT_HORIZ ? 'H' : 'V', + aField->GetTextAngle() == TEXT_ANGLE_HORIZ ? 'H' : 'V', aField->GetLibPosition().x, aField->GetLibPosition().y, - aField->GetSize().x, - aField->GetAttributes(), + aField->GetTextWidth(), + !aField->IsVisible(), hjustify, vjustify, aField->IsItalic() ? 'I' : 'N', aField->IsBold() ? 'B' : 'N' ); @@ -1732,7 +1732,8 @@ void SCH_LEGACY_PLUGIN::saveSheet( SCH_SHEET* aSheet ) wxCHECK_RET( aSheet != NULL, "SCH_SHEET* is NULL" ); m_out->Print( 0, "$Sheet\n" ); - m_out->Print( 0, "S %-4d %-4d %-4d %-4d\n", aSheet->GetPosition().x, aSheet->GetPosition().y, + m_out->Print( 0, "S %-4d %-4d %-4d %-4d\n", + aSheet->GetPosition().x, aSheet->GetPosition().y, aSheet->GetSize().x, aSheet->GetSize().y ); m_out->Print( 0, "U %8.8lX\n", (unsigned long) aSheet->GetTimeStamp() ); @@ -1794,7 +1795,7 @@ void SCH_LEGACY_PLUGIN::saveSheet( SCH_SHEET* aSheet ) m_out->Print( 0, "F%d %s %c %c %-3d %-3d %-3d\n", pin.GetNumber(), EscapedUTF8( pin.GetText() ).c_str(), // supplies wrapping quotes type, side, pin.GetPosition().x, pin.GetPosition().y, - pin.GetSize().x ); + pin.GetTextWidth() ); } m_out->Print( 0, "$EndSheet\n" ); @@ -1894,16 +1895,21 @@ void SCH_LEGACY_PLUGIN::saveText( SCH_TEXT* aText ) } m_out->Print( 0, "Text %s %-4d %-4d %-4d %-4d %s %d\n%s\n", textType, - aText->GetPosition().x, aText->GetPosition().y, aText->GetOrientation(), - aText->GetSize().x, italics, aText->GetThickness(), TO_UTF8( text ) ); + aText->GetPosition().x, aText->GetPosition().y, + aText->GetLabelSpinStyle(), + aText->GetTextWidth(), + italics, aText->GetThickness(), TO_UTF8( text ) ); } else if( layer == LAYER_GLOBLABEL || layer == LAYER_HIERLABEL ) { textType = ( layer == LAYER_GLOBLABEL ) ? "GLabel" : "HLabel"; m_out->Print( 0, "Text %s %-4d %-4d %-4d %-4d %s %s %d\n%s\n", textType, - aText->GetPosition().x, aText->GetPosition().y, aText->GetOrientation(), - aText->GetSize().x, SheetLabelType[aText->GetShape()], italics, + aText->GetPosition().x, aText->GetPosition().y, + aText->GetLabelSpinStyle(), + aText->GetTextWidth(), + SheetLabelType[aText->GetShape()], + italics, aText->GetThickness(), TO_UTF8( text ) ); } } @@ -2524,14 +2530,14 @@ void SCH_LEGACY_PLUGIN_CACHE::loadField( std::unique_ptr< LIB_PART >& aPart, wxSize textSize; textSize.x = textSize.y = parseInt( aReader, line, &line ); - field->SetSize( textSize ); + field->SetTextSize( textSize ); char textOrient = parseChar( aReader, line, &line ); if( textOrient == 'H' ) - field->SetOrientation( TEXT_ORIENT_HORIZ ); + field->SetTextAngle( TEXT_ANGLE_HORIZ ); else if( textOrient == 'V' ) - field->SetOrientation( TEXT_ORIENT_VERT ); + field->SetTextAngle( TEXT_ANGLE_VERT ); else SCH_PARSE_ERROR( _( "invalid field text orientation parameter" ), aReader, line ); @@ -2818,7 +2824,7 @@ LIB_TEXT* SCH_LEGACY_PLUGIN_CACHE::loadText( std::unique_ptr< LIB_PART >& aPart, std::unique_ptr< LIB_TEXT > text( new LIB_TEXT( aPart.get() ) ); - text->SetOrientation( (double) parseInt( aReader, line, &line ) ); + text->SetTextAngle( (double) parseInt( aReader, line, &line ) ); wxPoint center; @@ -2829,8 +2835,8 @@ LIB_TEXT* SCH_LEGACY_PLUGIN_CACHE::loadText( std::unique_ptr< LIB_PART >& aPart, wxSize size; size.x = size.y = parseInt( aReader, line, &line ); - text->SetSize( size ); - text->SetAttributes( parseInt( aReader, line, &line ) ); + text->SetTextSize( size ); + text->SetVisible( !parseInt( aReader, line, &line ) ); text->SetUnit( parseInt( aReader, line, &line ) ); text->SetConvert( parseInt( aReader, line, &line ) ); diff --git a/eeschema/sch_screen.cpp b/eeschema/sch_screen.cpp index 407ef636b3..dcc8a7f487 100644 --- a/eeschema/sch_screen.cpp +++ b/eeschema/sch_screen.cpp @@ -1104,13 +1104,13 @@ bool SCH_SCREEN::SetComponentFootprint( SCH_SHEET_PATH* aSheetPath, const wxStri */ SCH_FIELD * fpfield = component->GetField( FOOTPRINT ); if( fpfield->GetText().IsEmpty() - && ( fpfield->GetTextPosition() == component->GetPosition() ) ) + && ( fpfield->GetTextPos() == component->GetPosition() ) ) { - fpfield->SetOrientation( component->GetField( VALUE )->GetOrientation() ); - fpfield->SetTextPosition( component->GetField( VALUE )->GetTextPosition() ); - fpfield->SetSize( component->GetField( VALUE )->GetSize() ); + fpfield->SetTextAngle( component->GetField( VALUE )->GetTextAngle() ); + fpfield->SetTextPos( component->GetField( VALUE )->GetTextPos() ); + fpfield->SetTextSize( component->GetField( VALUE )->GetTextSize() ); - if( fpfield->GetOrientation() == 0 ) + if( fpfield->GetTextAngle() == 0.0 ) fpfield->Offset( wxPoint( 0, 100 ) ); else fpfield->Offset( wxPoint( 100, 0 ) ); diff --git a/eeschema/sch_sheet.cpp b/eeschema/sch_sheet.cpp index 5b74045917..dc3ece8c9e 100644 --- a/eeschema/sch_sheet.cpp +++ b/eeschema/sch_sheet.cpp @@ -606,9 +606,9 @@ void SCH_SHEET::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, pos_filename = GetFileNamePosition() + aOffset; if( IsVerticalOrientation() ) - name_orientation = TEXT_ORIENT_VERT; + name_orientation = TEXT_ANGLE_VERT; else - name_orientation = TEXT_ORIENT_HORIZ; + name_orientation = TEXT_ANGLE_HORIZ; /* Draw text : SheetName */ if( aColor > 0 ) @@ -1162,13 +1162,13 @@ void SCH_SHEET::Plot( PLOTTER* aPlotter ) { pos_sheetname = wxPoint( m_pos.x - 8, m_pos.y + m_size.y ); pos_filename = wxPoint( m_pos.x + m_size.x + 4, m_pos.y + m_size.y ); - name_orientation = TEXT_ORIENT_VERT; + name_orientation = TEXT_ANGLE_VERT; } else { pos_sheetname = wxPoint( m_pos.x, m_pos.y - 4 ); pos_filename = wxPoint( m_pos.x, m_pos.y + m_size.y + 4 ); - name_orientation = TEXT_ORIENT_HORIZ; + name_orientation = TEXT_ANGLE_HORIZ; } /* Draw texts: SheetName */ diff --git a/eeschema/sch_sheet.h b/eeschema/sch_sheet.h index 26fc914764..ab7159cfd9 100644 --- a/eeschema/sch_sheet.h +++ b/eeschema/sch_sheet.h @@ -172,7 +172,7 @@ public: void Move( const wxPoint& aMoveVector ) override { - m_Pos += aMoveVector; + Offset( aMoveVector ); } void MirrorY( int aYaxis_position ) override; diff --git a/eeschema/sch_sheet_pin.cpp b/eeschema/sch_sheet_pin.cpp index 43b549d0d8..f29c390371 100644 --- a/eeschema/sch_sheet_pin.cpp +++ b/eeschema/sch_sheet_pin.cpp @@ -47,7 +47,8 @@ SCH_SHEET_PIN::SCH_SHEET_PIN( SCH_SHEET* parent, const wxPoint& pos, const wxStr SetParent( parent ); wxASSERT( parent ); m_Layer = LAYER_SHEETLABEL; - m_Pos = pos; + + SetTextPos( pos ); if( parent->IsVerticalOrientation() ) SetEdge( SHEET_TOP_SIDE ); @@ -125,26 +126,26 @@ void SCH_SHEET_PIN::SetEdge( SCH_SHEET_PIN::SHEET_SIDE aEdge ) { case SHEET_LEFT_SIDE: m_edge = aEdge; - m_Pos.x = Sheet->m_pos.x; - SetOrientation( 2 ); /* Orientation horiz inverse */ + SetTextX( Sheet->m_pos.x ); + SetLabelSpinStyle( 2 ); // Orientation horiz inverse break; case SHEET_RIGHT_SIDE: m_edge = aEdge; - m_Pos.x = Sheet->m_pos.x + Sheet->m_size.x; - SetOrientation( 0 ); /* Orientation horiz normal */ + SetTextX( Sheet->m_pos.x + Sheet->m_size.x ); + SetLabelSpinStyle( 0 ); // Orientation horiz normal break; case SHEET_TOP_SIDE: m_edge = aEdge; - m_Pos.y = Sheet->m_pos.y; - SetOrientation( 3 ); /* Orientation vert BOTTOM */ + SetTextY( Sheet->m_pos.y ); + SetLabelSpinStyle( 3 ); // Orientation vert BOTTOM break; case SHEET_BOTTOM_SIDE: m_edge = aEdge; - m_Pos.y = Sheet->m_pos.y + Sheet->m_size.y; - SetOrientation( 1 ); /* Orientation vert UP */ + SetTextY( Sheet->m_pos.y + Sheet->m_size.y ); + SetLabelSpinStyle( 1 ); // Orientation vert UP break; default: @@ -179,15 +180,15 @@ void SCH_SHEET_PIN::ConstrainOnEdge( wxPoint Pos ) SetEdge( SHEET_LEFT_SIDE ); } - m_Pos.y = Pos.y; + SetTextY( Pos.y ); - if( m_Pos.y < sheet->m_pos.y ) - m_Pos.y = sheet->m_pos.y; + if( GetTextPos().y < sheet->m_pos.y ) + SetTextY( sheet->m_pos.y ); - if( m_Pos.y > (sheet->m_pos.y + sheet->m_size.y) ) - m_Pos.y = sheet->m_pos.y + sheet->m_size.y; + if( GetTextPos().y > (sheet->m_pos.y + sheet->m_size.y) ) + SetTextY( sheet->m_pos.y + sheet->m_size.y ); } - else /* vertical sheetpin*/ + else // vertical sheetpin { if( Pos.y > center.y ) { @@ -198,17 +199,17 @@ void SCH_SHEET_PIN::ConstrainOnEdge( wxPoint Pos ) SetEdge( SHEET_TOP_SIDE ); //top } - m_Pos.x = Pos.x; + SetTextX( Pos.x ); - if( m_Pos.x < sheet->m_pos.x ) - m_Pos.x = sheet->m_pos.x; + if( GetTextPos().x < sheet->m_pos.x ) + SetTextX( sheet->m_pos.x ); - if( m_Pos.x > (sheet->m_pos.x + sheet->m_size.x) ) - m_Pos.x = sheet->m_pos.x + sheet->m_size.x; + if( GetTextPos().x > (sheet->m_pos.x + sheet->m_size.x) ) + SetTextX( sheet->m_pos.x + sheet->m_size.x ); } printf( "centre %d %d, pos %d %d, pinpos %d %d, edge %d\n", - center.x, center.y, Pos.x, Pos.y, m_Pos.x, m_Pos.y, m_edge); + center.x, center.y, Pos.x, Pos.y, GetTextPos().x, GetTextPos().y, m_edge); } @@ -259,8 +260,8 @@ bool SCH_SHEET_PIN::Save( FILE* aFile ) const if( fprintf( aFile, "F%d %s %c %c %-3d %-3d %-3d\n", m_number, EscapedUTF8( m_Text ).c_str(), // supplies wrapping quotes - type, side, m_Pos.x, m_Pos.y, - m_Size.x ) == EOF ) + type, side, GetTextPos().x, GetTextPos().y, + GetTextWidth() ) == EOF ) { return false; } @@ -271,7 +272,7 @@ bool SCH_SHEET_PIN::Save( FILE* aFile ) const bool SCH_SHEET_PIN::Load( LINE_READER& aLine, wxString& aErrorMsg ) { - int size; + int x, y, size; char number[256]; char name[256]; char connectType[256]; @@ -303,7 +304,7 @@ bool SCH_SHEET_PIN::Load( LINE_READER& aLine, wxString& aErrorMsg ) cp += strlen( sheetSide ) + 1; - int r = sscanf( cp, "%d %d %d", &m_Pos.x, &m_Pos.y, &size ); + int r = sscanf( cp, "%d %d %d", &x, &y, &size ); if( r != 3 ) { aErrorMsg.Printf( wxT( "Eeschema file sheet hierarchical label error at line %d.\n" ), @@ -318,7 +319,8 @@ bool SCH_SHEET_PIN::Load( LINE_READER& aLine, wxString& aErrorMsg ) if( size == 0 ) size = GetDefaultTextSize(); - m_Size.x = m_Size.y = size; + SetTextSize( wxSize( size, size ) ); + SetTextPos( wxPoint( x, y ) ); switch( connectType[0] ) { @@ -345,19 +347,19 @@ bool SCH_SHEET_PIN::Load( LINE_READER& aLine, wxString& aErrorMsg ) switch( sheetSide[0] ) { - case 'R' : /* pin on right side */ + case 'R' : // pin on right side SetEdge( SHEET_RIGHT_SIDE ); break; - case 'T' : /* pin on top side */ + case 'T' : // pin on top side SetEdge( SHEET_TOP_SIDE ); break; - case 'B' : /* pin on bottom side */ + case 'B' : // pin on bottom side SetEdge( SHEET_BOTTOM_SIDE ); break; - case 'L' : /* pin on left side */ + case 'L' : // pin on left side default : SetEdge( SHEET_LEFT_SIDE ); break; @@ -389,9 +391,9 @@ bool SCH_SHEET_PIN::Matches( wxFindReplaceData& aSearchData, void SCH_SHEET_PIN::MirrorX( int aXaxis_position ) { - int p = m_Pos.y - aXaxis_position; + int p = GetTextPos().y - aXaxis_position; - m_Pos.y = aXaxis_position - p; + SetTextY( aXaxis_position - p ); switch( m_edge ) { @@ -411,9 +413,9 @@ void SCH_SHEET_PIN::MirrorX( int aXaxis_position ) void SCH_SHEET_PIN::MirrorY( int aYaxis_position ) { - int p = m_Pos.x - aYaxis_position; + int p = GetTextPos().x - aYaxis_position; - m_Pos.x = aYaxis_position - p; + SetTextX( aYaxis_position - p ); switch( m_edge ) { @@ -433,7 +435,9 @@ void SCH_SHEET_PIN::MirrorY( int aYaxis_position ) void SCH_SHEET_PIN::Rotate( wxPoint aPosition ) { - RotatePoint( &m_Pos, aPosition, 900 ); + wxPoint pt = GetTextPos(); + RotatePoint( &pt, aPosition, 900 ); + SetTextPos( pt ); switch( m_edge ) { @@ -489,7 +493,7 @@ void SCH_SHEET_PIN::CreateGraphicShape( std::vector & aPoints, const wx void SCH_SHEET_PIN::GetEndPoints( std::vector & aItemList ) { - DANGLING_END_ITEM item( SHEET_LABEL_END, this, m_Pos ); + DANGLING_END_ITEM item( SHEET_LABEL_END, this, GetTextPos() ); aItemList.push_back( item ); } diff --git a/eeschema/sch_text.cpp b/eeschema/sch_text.cpp index 497e199eee..a8ad81d11b 100644 --- a/eeschema/sch_text.cpp +++ b/eeschema/sch_text.cpp @@ -52,7 +52,7 @@ extern void IncrementLabelMember( wxString& name, int aIncrement ); // Margin in internal units (mils) between labels and wires #define TXT_MARGIN 4 -/* Names of sheet label types. */ +// Names of sheet label types. const char* SheetLabelType[] = { "Input", @@ -109,10 +109,11 @@ SCH_TEXT::SCH_TEXT( const wxPoint& pos, const wxString& text, KICAD_T aType ) : m_shape( NET_INPUT ) { m_Layer = LAYER_NOTES; - m_Pos = pos; + SetTextPos( pos ); m_isDangling = false; - m_MultilineAllowed = true; - m_schematicOrientation = 0; + m_spin_style = 0; + + SetMultilineAllowed( true ); } @@ -120,11 +121,10 @@ SCH_TEXT::SCH_TEXT( const SCH_TEXT& aText ) : SCH_ITEM( aText ), EDA_TEXT( aText ) { - m_Pos = aText.m_Pos; m_shape = aText.m_shape; - m_MultilineAllowed = aText.m_MultilineAllowed; - m_schematicOrientation = aText.m_schematicOrientation; m_isDangling = false; + + SetLabelSpinStyle( aText.GetLabelSpinStyle() ); } @@ -149,22 +149,22 @@ wxPoint SCH_TEXT::GetSchematicTextOffset() const int thick_offset = TXT_MARGIN + ( GetPenSize() + GetDefaultLineThickness() ) / 2; - switch( m_schematicOrientation ) + switch( GetLabelSpinStyle() ) { default: - case 0: /* Horiz Normal Orientation (left justified) */ + case 0: // Horiz Normal Orientation (left justified) text_offset.y = -thick_offset; break; - case 1: /* Vert Orientation UP */ + case 1: // Vert Orientation UP text_offset.x = -thick_offset; break; - case 2: /* Horiz Orientation - Right justified */ + case 2: // Horiz Orientation - Right justified text_offset.y = -thick_offset; break; - case 3: /* Vert Orientation BOTTOM */ + case 3: // Vert Orientation BOTTOM text_offset.x = -thick_offset; break; } @@ -194,14 +194,14 @@ bool SCH_TEXT::Matches( wxFindReplaceData& aSearchData, void* aAuxData, wxPoint void SCH_TEXT::MirrorY( int aYaxis_position ) { // Text is NOT really mirrored; it is moved to a suitable horizontal position - switch( GetOrientation() ) + switch( GetLabelSpinStyle() ) { case 0: // horizontal text - SetOrientation( 2 ); + SetLabelSpinStyle( 2 ); break; case 2: // invert horizontal text - SetOrientation( 0 ); + SetLabelSpinStyle( 0 ); break; case 1: // Vert Orientation UP @@ -210,21 +210,21 @@ void SCH_TEXT::MirrorY( int aYaxis_position ) break; } - MIRROR( m_Pos.x, aYaxis_position ); + SetTextX( Mirror( GetTextPos().x, aYaxis_position ) ); } void SCH_TEXT::MirrorX( int aXaxis_position ) { // Text is NOT really mirrored; it is moved to a suitable vertical position - switch( GetOrientation() ) + switch( GetLabelSpinStyle() ) { case 1: // Vert Orientation UP - SetOrientation( 3 ); + SetLabelSpinStyle( 3 ); break; case 3: // Vert Orientation BOTTOM - SetOrientation( 1 ); + SetLabelSpinStyle( 1 ); break; case 0: // horizontal text @@ -233,7 +233,7 @@ void SCH_TEXT::MirrorX( int aXaxis_position ) break; } - MIRROR( m_Pos.y, aXaxis_position ); + SetTextY( Mirror( GetTextPos().y, aXaxis_position ) ); } @@ -241,13 +241,16 @@ void SCH_TEXT::Rotate( wxPoint aPosition ) { int dy; - RotatePoint( &m_Pos, aPosition, 900 ); - SetOrientation( (GetOrientation() + 1) % 4 ); + wxPoint pt = GetTextPos(); + RotatePoint( &pt, aPosition, 900 ); + SetTextPos( pt ); - switch( GetOrientation() ) + SetLabelSpinStyle( (GetLabelSpinStyle() + 1) % 4 ); + + switch( GetLabelSpinStyle() ) { case 0: // horizontal text - dy = m_Size.y; + dy = GetTextHeight(); break; case 1: // Vert Orientation UP @@ -255,7 +258,7 @@ void SCH_TEXT::Rotate( wxPoint aPosition ) break; case 2: // invert horizontal text - dy = m_Size.y; + dy = GetTextHeight(); break; case 3: // Vert Orientation BOTTOM @@ -267,39 +270,39 @@ void SCH_TEXT::Rotate( wxPoint aPosition ) break; } - m_Pos.y += dy; + SetTextY( GetTextPos().y + dy ); } -void SCH_TEXT::SetOrientation( int aOrientation ) +void SCH_TEXT::SetLabelSpinStyle( int aSpinStyle ) { - m_schematicOrientation = aOrientation; + m_spin_style = aSpinStyle; - switch( m_schematicOrientation ) + switch( aSpinStyle ) { default: - case 0: /* Horiz Normal Orientation (left justified) */ - m_Orient = TEXT_ORIENT_HORIZ; - m_HJustify = GR_TEXT_HJUSTIFY_LEFT; - m_VJustify = GR_TEXT_VJUSTIFY_BOTTOM; + case 0: // Horiz Normal Orientation (left justified) + SetTextAngle( TEXT_ANGLE_HORIZ ); + SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); + SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); break; - case 1: /* Vert Orientation UP */ - m_Orient = TEXT_ORIENT_VERT; - m_HJustify = GR_TEXT_HJUSTIFY_LEFT; - m_VJustify = GR_TEXT_VJUSTIFY_BOTTOM; + case 1: // Vert Orientation UP + SetTextAngle( TEXT_ANGLE_VERT ); + SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); + SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); break; - case 2: /* Horiz Orientation - Right justified */ - m_Orient = TEXT_ORIENT_HORIZ; - m_HJustify = GR_TEXT_HJUSTIFY_RIGHT; - m_VJustify = GR_TEXT_VJUSTIFY_BOTTOM; + case 2: // Horiz Orientation - Right justified + SetTextAngle( TEXT_ANGLE_HORIZ ); + SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); + SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); break; - case 3: /* Vert Orientation BOTTOM */ - m_Orient = TEXT_ORIENT_VERT; - m_HJustify = GR_TEXT_HJUSTIFY_RIGHT; - m_VJustify = GR_TEXT_VJUSTIFY_BOTTOM; + case 3: // Vert Orientation BOTTOM + SetTextAngle( TEXT_ANGLE_VERT ); + SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); + SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); break; } } @@ -310,34 +313,28 @@ void SCH_TEXT::SwapData( SCH_ITEM* aItem ) SCH_TEXT* item = (SCH_TEXT*) aItem; std::swap( m_Text, item->m_Text ); - std::swap( m_Pos, item->m_Pos ); - std::swap( m_Size, item->m_Size ); - std::swap( m_Thickness, item->m_Thickness ); - std::swap( m_shape, item->m_shape ); - std::swap( m_Orient, item->m_Orient ); - std::swap( m_Layer, item->m_Layer ); - std::swap( m_HJustify, item->m_HJustify ); - std::swap( m_VJustify, item->m_VJustify ); std::swap( m_isDangling, item->m_isDangling ); - std::swap( m_schematicOrientation, item->m_schematicOrientation ); + std::swap( m_spin_style, item->m_spin_style ); + + SwapEffects( *item ); } int SCH_TEXT::GetPenSize() const { - int pensize = m_Thickness; + int pensize = GetThickness(); if( pensize == 0 ) // Use default values for pen size { - if( m_Bold ) - pensize = GetPenSizeForBold( m_Size.x ); + if( IsBold() ) + pensize = GetPenSizeForBold( GetTextWidth() ); else pensize = GetDefaultLineThickness(); } // Clip pen size for small texts: - pensize = Clamp_Text_PenSize( pensize, m_Size, m_Bold ); + pensize = Clamp_Text_PenSize( pensize, GetTextSize(), IsBold() ); return pensize; } @@ -346,10 +343,10 @@ void SCH_TEXT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& aOffset, GR_DRAWMODE DrawMode, EDA_COLOR_T Color ) { EDA_COLOR_T color; - int linewidth = ( m_Thickness == 0 ) ? GetDefaultLineThickness() : m_Thickness; - EDA_RECT* clipbox = panel? panel->GetClipBox() : NULL; + int linewidth = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness(); + EDA_RECT* clipbox = panel? panel->GetClipBox() : NULL; - linewidth = Clamp_Text_PenSize( linewidth, m_Size, m_Bold ); + linewidth = Clamp_Text_PenSize( linewidth, GetTextSize(), IsBold() ); if( Color >= 0 ) color = Color; @@ -359,12 +356,16 @@ void SCH_TEXT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& aOffset, GRSetDrawMode( DC, DrawMode ); wxPoint text_offset = aOffset + GetSchematicTextOffset(); - std::swap( linewidth, m_Thickness ); // Set the minimum width + + int savedWidth = GetThickness(); + SetThickness( linewidth ); // Set the minimum width + EDA_TEXT::Draw( clipbox, DC, text_offset, color, DrawMode, FILLED, UNSPECIFIED_COLOR ); - std::swap( linewidth, m_Thickness ); // set initial value + + SetThickness( savedWidth ); if( m_isDangling && panel) - DrawDanglingSymbol( panel, DC, m_Pos + aOffset, color ); + DrawDanglingSymbol( panel, DC, GetTextPos() + aOffset, color ); // Enable these line to draw the bounding box (debug tests purposes only) #if DRAW_BBOX @@ -381,7 +382,7 @@ bool SCH_TEXT::Save( FILE* aFile ) const bool success = true; const char* shape = "~"; - if( m_Italic ) + if( IsItalic() ) shape = "Italic"; // For compatibility reason, the text must be saved in only one text line @@ -404,10 +405,9 @@ bool SCH_TEXT::Save( FILE* aFile ) const ii++; } - if( fprintf( aFile, "Text Notes %-4d %-4d %-4d %-4d %s %d\n%s\n", - m_Pos.x, m_Pos.y, m_schematicOrientation, m_Size.x, - shape, m_Thickness, TO_UTF8( text ) ) == EOF ) + GetTextPos().x, GetTextPos().y, GetLabelSpinStyle(), GetTextWidth(), + shape, GetThickness(), TO_UTF8( text ) ) == EOF ) { success = false; } @@ -418,10 +418,11 @@ bool SCH_TEXT::Save( FILE* aFile ) const bool SCH_TEXT::Load( LINE_READER& aLine, wxString& aErrorMsg ) { - char Name1[256]; - char Name2[256]; - char Name3[256]; - int thickness = 0, size = 0, orient = 0; + char Name1[256]; + char Name2[256]; + char Name3[256]; + int thickness = 0, orient = 0; + int x, y, size = 0; Name1[0] = 0; Name2[0] = 0; Name3[0] = 0; @@ -431,7 +432,7 @@ bool SCH_TEXT::Load( LINE_READER& aLine, wxString& aErrorMsg ) sline++; // sline points the start of parameters - int ii = sscanf( sline, "%255s %d %d %d %d %255s %255s %d", Name1, &m_Pos.x, &m_Pos.y, + int ii = sscanf( sline, "%255s %d %d %d %d %255s %255s %d", Name1, &x, &y, &orient, &size, Name2, Name3, &thickness ); if( ii < 4 ) @@ -474,18 +475,21 @@ bool SCH_TEXT::Load( LINE_READER& aLine, wxString& aErrorMsg ) } m_Text = val; - m_Size.x = m_Size.y = size; - SetOrientation( orient ); + + SetTextSize( wxSize( size, size ) ); + SetTextPos( wxPoint( x, y ) ); + + SetLabelSpinStyle( orient ); if( isdigit( Name3[0] ) ) { thickness = atol( Name3 ); - m_Bold = ( thickness != 0 ); - m_Thickness = m_Bold ? GetPenSizeForBold( size ) : 0; + SetBold( thickness != 0 ); + SetThickness( IsBold() ? GetPenSizeForBold( size ) : 0 ); } if( strncasecmp( Name2, "Italic", 6 ) == 0 ) - m_Italic = 1; + SetItalic( true ); return true; } @@ -497,7 +501,7 @@ void SCH_TEXT::GetEndPoints( std::vector & aItemList ) if( Type() == SCH_TEXT_T ) return; - DANGLING_END_ITEM item( LABEL_END, this, m_Pos ); + DANGLING_END_ITEM item( LABEL_END, this, GetTextPos() ); aItemList.push_back( item ); } @@ -523,7 +527,7 @@ bool SCH_TEXT::IsDanglingStateChanged( std::vector< DANGLING_END_ITEM >& aItemLi case PIN_END: case LABEL_END: case SHEET_LABEL_END: - if( m_Pos == item.GetPosition() ) + if( GetTextPos() == item.GetPosition() ) m_isDangling = false; break; @@ -539,7 +543,7 @@ bool SCH_TEXT::IsDanglingStateChanged( std::vector< DANGLING_END_ITEM >& aItemLi wxT( "Dangling end type list overflow. Bad programmer!" ) ); DANGLING_END_ITEM & nextItem = aItemList[ii]; - m_isDangling = !IsPointOnSegment( item.GetPosition(), nextItem.GetPosition(), m_Pos ); + m_isDangling = !IsPointOnSegment( item.GetPosition(), nextItem.GetPosition(), GetTextPos() ); } break; @@ -559,7 +563,7 @@ bool SCH_TEXT::IsSelectStateChanged( const wxRect& aRect ) { bool previousState = IsSelected(); - if( aRect.Contains( m_Pos ) ) + if( aRect.Contains( GetTextPos() ) ) SetFlags( SELECTED ); else ClearFlags( SELECTED ); @@ -574,7 +578,7 @@ void SCH_TEXT::GetConnectionPoints( std::vector< wxPoint >& aPoints ) const if( Type() == SCH_TEXT_T ) return; - aPoints.push_back( m_Pos ); + aPoints.push_back( GetTextPos() ); } @@ -582,18 +586,20 @@ const EDA_RECT SCH_TEXT::GetBoundingBox() const { // We must pass the effective text thickness to GetTextBox // when calculating the bounding box - int linewidth = ( m_Thickness == 0 ) ? GetDefaultLineThickness() : m_Thickness; + int linewidth = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness(); - linewidth = Clamp_Text_PenSize( linewidth, m_Size, m_Bold ); + linewidth = Clamp_Text_PenSize( linewidth, GetTextSize(), IsBold() ); EDA_RECT rect = GetTextBox( -1, linewidth ); - if( m_Orient ) // Rotate rect + if( GetTextAngle() ) // Rotate rect { wxPoint pos = rect.GetOrigin(); wxPoint end = rect.GetEnd(); - RotatePoint( &pos, m_Pos, m_Orient ); - RotatePoint( &end, m_Pos, m_Orient ); + + RotatePoint( &pos, GetTextPos(), GetTextAngle() ); + RotatePoint( &end, GetTextPos(), GetTextAngle() ); + rect.SetOrigin( pos ); rect.SetEnd( end ); } @@ -629,11 +635,11 @@ void SCH_TEXT::GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems, item->m_Type = NET_HIERLABEL; item->m_Label = m_Text; - item->m_Start = item->m_End = m_Pos; + item->m_Start = item->m_End = GetTextPos(); aNetListItems.push_back( item ); - /* If a bus connects to label */ + // If a bus connects to label if( IsBusLabel( m_Text ) ) item->ConvertBusToNetListItems( aNetListItems ); } @@ -667,7 +673,7 @@ void SCH_TEXT::Plot( PLOTTER* aPlotter ) aPlotter->SetCurrentLineWidth( thickness ); - if( m_MultilineAllowed ) + if( IsMultilineAllowed() ) { std::vector positions; wxArrayString strings_list; @@ -680,19 +686,22 @@ void SCH_TEXT::Plot( PLOTTER* aPlotter ) { wxPoint textpos = positions[ii] + GetSchematicTextOffset(); wxString& txt = strings_list.Item( ii ); - aPlotter->Text( textpos, color, txt, m_Orient, m_Size, m_HJustify, - m_VJustify, thickness, m_Italic, m_Bold ); + aPlotter->Text( textpos, color, txt, GetTextAngle(), GetTextSize(), + GetHorizJustify(), GetVertJustify(), + thickness, IsItalic(), IsBold() ); } } else { - wxPoint textpos = m_Pos + GetSchematicTextOffset(); - aPlotter->Text( textpos, color, GetShownText(), m_Orient, m_Size, m_HJustify, - m_VJustify, thickness, m_Italic, m_Bold ); + wxPoint textpos = GetTextPos() + GetSchematicTextOffset(); + + aPlotter->Text( textpos, color, GetShownText(), GetTextAngle(), GetTextSize(), + GetHorizJustify(), GetVertJustify(), + thickness, IsItalic(), IsBold() ); } - /* Draw graphic symbol for global or hierarchical labels */ - CreateGraphicShape( Poly, m_Pos ); + // Draw graphic symbol for global or hierarchical labels + CreateGraphicShape( Poly, GetTextPos() ); aPlotter->SetCurrentLineWidth( GetPenSize() ); @@ -736,7 +745,7 @@ void SCH_TEXT::GetMsgPanelInfo( MSG_PANEL_ITEMS& aList ) aList.push_back( MSG_PANEL_ITEM( msg, GetShownText(), DARKCYAN ) ); - switch( GetOrientation() ) + switch( GetLabelSpinStyle() ) { case 0: // horizontal text msg = _( "Horizontal" ); @@ -764,10 +773,10 @@ void SCH_TEXT::GetMsgPanelInfo( MSG_PANEL_ITEMS& aList ) wxString textStyle[] = { _( "Normal" ), _( "Italic" ), _( "Bold" ), _( "Bold Italic" ) }; int style = 0; - if( m_Italic ) + if( IsItalic() ) style = 1; - if( m_Bold ) + if( IsBold() ) style += 2; aList.push_back( MSG_PANEL_ITEM( _( "Style" ), textStyle[style], BROWN ) ); @@ -792,7 +801,7 @@ void SCH_TEXT::GetMsgPanelInfo( MSG_PANEL_ITEMS& aList ) } // Display text size (X or Y value, with are the same value in Eeschema) - msg = StringFromValue( g_UserUnit, m_Size.x, true ); + msg = StringFromValue( g_UserUnit, GetTextWidth(), true ); aList.push_back( MSG_PANEL_ITEM( _( "Size" ), msg, RED ) ); } @@ -821,7 +830,7 @@ SCH_LABEL::SCH_LABEL( const wxPoint& pos, const wxString& text ) : m_Layer = LAYER_LOCLABEL; m_shape = NET_INPUT; m_isDangling = true; - m_MultilineAllowed = false; + SetMultilineAllowed( false ); } @@ -837,23 +846,23 @@ wxPoint SCH_LABEL::GetSchematicTextOffset() const } -void SCH_LABEL::SetOrientation( int aOrientation ) +void SCH_LABEL::SetLabelSpinStyle( int aOrientation ) { - SCH_TEXT::SetOrientation( aOrientation ); + SCH_TEXT::SetLabelSpinStyle( aOrientation ); } void SCH_LABEL::MirrorX( int aXaxis_position ) { // Text is NOT really mirrored; it is moved to a suitable position - switch( GetOrientation() ) + switch( GetLabelSpinStyle() ) { case 1: // Vert Orientation UP - SetOrientation( 3 ); + SetLabelSpinStyle( 3 ); break; case 3: // Vert Orientation BOTTOM - SetOrientation( 1 ); + SetLabelSpinStyle( 1 ); break; case 0: // horizontal text @@ -862,14 +871,17 @@ void SCH_LABEL::MirrorX( int aXaxis_position ) break; } - MIRROR( m_Pos.y, aXaxis_position ); + SetTextY( ::Mirror( GetTextPos().y, aXaxis_position ) ); } void SCH_LABEL::Rotate( wxPoint aPosition ) { - RotatePoint( &m_Pos, aPosition, 900 ); - SetOrientation( (GetOrientation() + 1) % 4 ); + wxPoint pt = GetTextPos(); + RotatePoint( &pt, aPosition, 900 ); + SetTextPos( pt ); + + SetLabelSpinStyle( (GetLabelSpinStyle() + 1) % 4 ); } @@ -878,12 +890,12 @@ bool SCH_LABEL::Save( FILE* aFile ) const bool success = true; const char* shape = "~"; - if( m_Italic ) + if( IsItalic() ) shape = "Italic"; if( fprintf( aFile, "Text Label %-4d %-4d %-4d %-4d %s %d\n%s\n", - m_Pos.x, m_Pos.y, m_schematicOrientation, m_Size.x, shape, - m_Thickness, TO_UTF8( m_Text ) ) == EOF ) + GetTextPos().x, GetTextPos().y, GetLabelSpinStyle(), GetTextWidth(), shape, + GetThickness(), TO_UTF8( m_Text ) ) == EOF ) { success = false; } @@ -894,10 +906,11 @@ bool SCH_LABEL::Save( FILE* aFile ) const bool SCH_LABEL::Load( LINE_READER& aLine, wxString& aErrorMsg ) { - char Name1[256]; - char Name2[256]; - char Name3[256]; - int thickness = 0, size = 0, orient = 0; + char Name1[256]; + char Name2[256]; + char Name3[256]; + int thickness = 0, size = 0, orient = 0; + int x, y; Name1[0] = 0; Name2[0] = 0; Name3[0] = 0; @@ -907,7 +920,7 @@ bool SCH_LABEL::Load( LINE_READER& aLine, wxString& aErrorMsg ) sline++; // sline points the start of parameters - int ii = sscanf( sline, "%255s %d %d %d %d %255s %255s %d", Name1, &m_Pos.x, &m_Pos.y, + int ii = sscanf( sline, "%255s %d %d %d %d %255s %255s %d", Name1, &x, &y, &orient, &size, Name2, Name3, &thickness ); if( ii < 4 ) @@ -937,18 +950,21 @@ bool SCH_LABEL::Load( LINE_READER& aLine, wxString& aErrorMsg ) } m_Text = FROM_UTF8( text ); - m_Size.x = m_Size.y = size; - SetOrientation( orient ); + + SetTextSize( wxSize( size, size ) ); + SetTextPos( wxPoint( x, y ) ); + + SetLabelSpinStyle( orient ); if( isdigit( Name3[0] ) ) { thickness = atol( Name3 ); - m_Bold = ( thickness != 0 ); - m_Thickness = m_Bold ? GetPenSizeForBold( size ) : 0; + SetBold( thickness != 0 ); + SetThickness( IsBold() ? GetPenSizeForBold( size ) : 0 ); } if( strcasecmp( Name2, "Italic" ) == 0 ) - m_Italic = 1; + SetItalic( true ); return true; } @@ -963,15 +979,18 @@ void SCH_LABEL::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset, const EDA_RECT SCH_LABEL::GetBoundingBox() const { - int linewidth = (m_Thickness == 0) ? GetDefaultLineThickness() : m_Thickness; - EDA_RECT rect = GetTextBox( -1, linewidth ); + int linewidth = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness(); + EDA_RECT rect = GetTextBox( -1, linewidth ); - if( m_Orient ) - { // Rotate rect + if( GetTextAngle() != 0.0 ) + { + // Rotate rect wxPoint pos = rect.GetOrigin(); wxPoint end = rect.GetEnd(); - RotatePoint( &pos, m_Pos, m_Orient ); - RotatePoint( &end, m_Pos, m_Orient ); + + RotatePoint( &pos, GetTextPos(), GetTextAngle() ); + RotatePoint( &end, GetTextPos(), GetTextAngle() ); + rect.SetOrigin( pos ); rect.SetEnd( end ); @@ -990,14 +1009,13 @@ wxString SCH_LABEL::GetSelectMenuText() const } - SCH_GLOBALLABEL::SCH_GLOBALLABEL( const wxPoint& pos, const wxString& text ) : SCH_TEXT( pos, text, SCH_GLOBAL_LABEL_T ) { m_Layer = LAYER_GLOBLABEL; m_shape = NET_BIDI; m_isDangling = true; - m_MultilineAllowed = false; + SetMultilineAllowed( false ); } @@ -1012,12 +1030,12 @@ bool SCH_GLOBALLABEL::Save( FILE* aFile ) const bool success = true; const char* shape = "~"; - if( m_Italic ) + if( IsItalic() ) shape = "Italic"; if( fprintf( aFile, "Text GLabel %-4d %-4d %-4d %-4d %s %s %d\n%s\n", - m_Pos.x, m_Pos.y, m_schematicOrientation, m_Size.x, - SheetLabelType[m_shape], shape, m_Thickness, TO_UTF8( m_Text ) ) == EOF ) + GetTextPos().x, GetTextPos().y, GetLabelSpinStyle(), GetTextWidth(), + SheetLabelType[m_shape], shape, GetThickness(), TO_UTF8( m_Text ) ) == EOF ) { success = false; } @@ -1028,10 +1046,11 @@ bool SCH_GLOBALLABEL::Save( FILE* aFile ) const bool SCH_GLOBALLABEL::Load( LINE_READER& aLine, wxString& aErrorMsg ) { - char Name1[256]; - char Name2[256]; - char Name3[256]; - int thickness = 0, size = 0, orient = 0; + char Name1[256]; + char Name2[256]; + char Name3[256]; + int thickness = 0, size = 0, orient = 0; + int x, y; Name1[0] = 0; Name2[0] = 0; Name3[0] = 0; @@ -1041,7 +1060,7 @@ bool SCH_GLOBALLABEL::Load( LINE_READER& aLine, wxString& aErrorMsg ) sline++; // sline points the start of parameters - int ii = sscanf( sline, "%255s %d %d %d %d %255s %255s %d", Name1, &m_Pos.x, &m_Pos.y, + int ii = sscanf( sline, "%255s %d %d %d %d %255s %255s %d", Name1, &x, &y, &orient, &size, Name2, Name3, &thickness ); if( ii < 4 ) @@ -1071,11 +1090,15 @@ bool SCH_GLOBALLABEL::Load( LINE_READER& aLine, wxString& aErrorMsg ) } m_Text = FROM_UTF8( text ); - m_Size.x = m_Size.y = size; - SetOrientation( orient ); + + SetTextSize( wxSize( size, size ) ); + SetTextPos( wxPoint( x, y ) ); + + SetLabelSpinStyle( orient ); + m_shape = NET_INPUT; - m_Bold = ( thickness != 0 ); - m_Thickness = m_Bold ? GetPenSizeForBold( size ) : 0; + SetBold( thickness != 0 ); + SetThickness( IsBold() ? GetPenSizeForBold( size ) : 0 ); if( strcasecmp( Name2, SheetLabelType[NET_OUTPUT] ) == 0 ) m_shape = NET_OUTPUT; @@ -1090,7 +1113,7 @@ bool SCH_GLOBALLABEL::Load( LINE_READER& aLine, wxString& aErrorMsg ) m_shape = NET_UNSPECIFIED; if( strcasecmp( Name3, "Italic" ) == 0 ) - m_Italic = 1; + SetItalic( true ); return true; } @@ -1103,52 +1126,55 @@ void SCH_GLOBALLABEL::MirrorY( int aYaxis_position ) * for a vertical label, the schematic orientation is not changed. * and the label is moved to a suitable position */ - switch( GetOrientation() ) + switch( GetLabelSpinStyle() ) { - case 0: /* horizontal text */ - SetOrientation( 2 ); + case 0: // horizontal text + SetLabelSpinStyle( 2 ); break; - case 2: /* invert horizontal text*/ - SetOrientation( 0 ); + case 2: // invert horizontal text + SetLabelSpinStyle( 0 ); break; } - MIRROR( m_Pos.x, aYaxis_position ); + SetTextX( ::Mirror( GetTextPos().x, aYaxis_position ) ); } void SCH_GLOBALLABEL::MirrorX( int aXaxis_position ) { - switch( GetOrientation() ) + switch( GetLabelSpinStyle() ) { - case 1: /* vertical text */ - SetOrientation( 3 ); + case 1: // vertical text + SetLabelSpinStyle( 3 ); break; - case 3: /* invert vertical text*/ - SetOrientation( 1 ); + case 3: // invert vertical text + SetLabelSpinStyle( 1 ); break; } - MIRROR( m_Pos.y, aXaxis_position ); + SetTextY( ::Mirror( GetTextPos().y, aXaxis_position ) ); } void SCH_GLOBALLABEL::Rotate( wxPoint aPosition ) { - RotatePoint( &m_Pos, aPosition, 900 ); - SetOrientation( (GetOrientation() + 3) % 4 ); + wxPoint pt = GetTextPos(); + RotatePoint( &pt, aPosition, 900 ); + SetTextPos( pt ); + + SetLabelSpinStyle( (GetLabelSpinStyle() + 3) % 4 ); } wxPoint SCH_GLOBALLABEL::GetSchematicTextOffset() const { wxPoint text_offset; - int width = (m_Thickness == 0) ? GetDefaultLineThickness() : m_Thickness; + int width = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness(); - width = Clamp_Text_PenSize( width, m_Size, m_Bold ); - int halfSize = m_Size.x / 2; + width = Clamp_Text_PenSize( width, GetTextSize(), IsBold() ); + int halfSize = GetTextWidth() / 2; int offset = width; switch( m_shape ) @@ -1168,21 +1194,21 @@ wxPoint SCH_GLOBALLABEL::GetSchematicTextOffset() const break; } - switch( m_schematicOrientation ) + switch( GetLabelSpinStyle() ) { - case 0: /* Orientation horiz normal */ + case 0: // Orientation horiz normal text_offset.x -= offset; break; - case 1: /* Orientation vert UP */ + case 1: // Orientation vert UP text_offset.y -= offset; break; - case 2: /* Orientation horiz inverse */ + case 2: // Orientation horiz inverse text_offset.x += offset; break; - case 3: /* Orientation vert BOTTOM */ + case 3: // Orientation vert BOTTOM text_offset.y += offset; break; } @@ -1191,35 +1217,35 @@ wxPoint SCH_GLOBALLABEL::GetSchematicTextOffset() const } -void SCH_GLOBALLABEL::SetOrientation( int aOrientation ) +void SCH_GLOBALLABEL::SetLabelSpinStyle( int aSpinStyle ) { - m_schematicOrientation = aOrientation; + m_spin_style = aSpinStyle; - switch( m_schematicOrientation ) + switch( aSpinStyle ) { default: - case 0: /* Horiz Normal Orientation */ - m_Orient = TEXT_ORIENT_HORIZ; - m_HJustify = GR_TEXT_HJUSTIFY_RIGHT; - m_VJustify = GR_TEXT_VJUSTIFY_CENTER; + case 0: // Horiz Normal Orientation + SetTextAngle( TEXT_ANGLE_HORIZ ); + SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); + SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); break; - case 1: /* Vert Orientation UP */ - m_Orient = TEXT_ORIENT_VERT; - m_HJustify = GR_TEXT_HJUSTIFY_LEFT; - m_VJustify = GR_TEXT_VJUSTIFY_CENTER; + case 1: // Vert Orientation UP + SetTextAngle( TEXT_ANGLE_VERT ); + SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); + SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); break; - case 2: /* Horiz Orientation */ - m_Orient = TEXT_ORIENT_HORIZ; - m_HJustify = GR_TEXT_HJUSTIFY_LEFT; - m_VJustify = GR_TEXT_VJUSTIFY_CENTER; + case 2: // Horiz Orientation + SetTextAngle( TEXT_ANGLE_HORIZ ); + SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); + SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); break; - case 3: /* Vert Orientation BOTTOM */ - m_Orient = TEXT_ORIENT_VERT; - m_HJustify = GR_TEXT_HJUSTIFY_RIGHT; - m_VJustify = GR_TEXT_VJUSTIFY_CENTER; + case 3: // Vert Orientation BOTTOM + SetTextAngle( TEXT_ANGLE_VERT ); + SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); + SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); break; } } @@ -1242,18 +1268,23 @@ void SCH_GLOBALLABEL::Draw( EDA_DRAW_PANEL* panel, GRSetDrawMode( DC, DrawMode ); - int linewidth = (m_Thickness == 0) ? GetDefaultLineThickness() : m_Thickness; - linewidth = Clamp_Text_PenSize( linewidth, m_Size, m_Bold ); - std::swap( linewidth, m_Thickness ); // Set the minimum width + int linewidth = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness(); + + linewidth = Clamp_Text_PenSize( linewidth, GetTextSize(), IsBold() ); + + int save_width = GetThickness(); + SetThickness( linewidth ); + EDA_RECT* clipbox = panel? panel->GetClipBox() : NULL; EDA_TEXT::Draw( clipbox, DC, text_offset, color, DrawMode, FILLED, UNSPECIFIED_COLOR ); - std::swap( linewidth, m_Thickness ); // set initial value - CreateGraphicShape( Poly, m_Pos + aOffset ); + SetThickness( save_width ); // restore initial value + + CreateGraphicShape( Poly, GetTextPos() + aOffset ); GRPoly( clipbox, DC, Poly.size(), &Poly[0], 0, linewidth, color, color ); if( m_isDangling && panel ) - DrawDanglingSymbol( panel, DC, m_Pos + aOffset, color ); + DrawDanglingSymbol( panel, DC, GetTextPos() + aOffset, color ); // Enable these line to draw the bounding box (debug tests purposes only) #if DRAW_BBOX @@ -1267,10 +1298,10 @@ void SCH_GLOBALLABEL::Draw( EDA_DRAW_PANEL* panel, void SCH_GLOBALLABEL::CreateGraphicShape( std::vector & aPoints, const wxPoint& Pos ) { - int halfSize = m_Size.y / 2; - int linewidth = (m_Thickness == 0) ? GetDefaultLineThickness() : m_Thickness; + int halfSize = GetTextHeight() / 2; + int linewidth = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness(); - linewidth = Clamp_Text_PenSize( linewidth, m_Size, m_Bold ); + linewidth = Clamp_Text_PenSize( linewidth, GetTextSize(), IsBold() ); aPoints.clear(); @@ -1342,20 +1373,20 @@ void SCH_GLOBALLABEL::CreateGraphicShape( std::vector & aPoints, const int angle = 0; - switch( m_schematicOrientation ) + switch( GetLabelSpinStyle() ) { - case 0: /* Orientation horiz normal */ + case 0: // Orientation horiz normal break; - case 1: /* Orientation vert UP */ + case 1: // Orientation vert UP angle = -900; break; - case 2: /* Orientation horiz inverse */ + case 2: // Orientation horiz inverse angle = 1800; break; - case 3: /* Orientation vert BOTTOM */ + case 3: // Orientation vert BOTTOM angle = 900; break; } @@ -1379,40 +1410,41 @@ const EDA_RECT SCH_GLOBALLABEL::GetBoundingBox() const { int x, y, dx, dy, length, height; - x = m_Pos.x; - y = m_Pos.y; + x = GetTextPos().x; + y = GetTextPos().y; dx = dy = 0; - int width = (m_Thickness == 0) ? GetDefaultLineThickness() : m_Thickness; - height = ( (m_Size.y * 15) / 10 ) + width + 2 * TXT_MARGIN; + int width = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness(); + + height = ( (GetTextHeight() * 15) / 10 ) + width + 2 * TXT_MARGIN; // text X size add height for triangular shapes(bidirectional) length = LenSize( GetShownText() ) + height + DANGLING_SYMBOL_SIZE; - switch( m_schematicOrientation ) // respect orientation + switch( GetLabelSpinStyle() ) // respect orientation { - case 0: /* Horiz Normal Orientation (left justified) */ + case 0: // Horiz Normal Orientation (left justified) dx = -length; dy = height; x += DANGLING_SYMBOL_SIZE; y -= height / 2; break; - case 1: /* Vert Orientation UP */ + case 1: // Vert Orientation UP dx = height; dy = -length; x -= height / 2; y += DANGLING_SYMBOL_SIZE; break; - case 2: /* Horiz Orientation - Right justified */ + case 2: // Horiz Orientation - Right justified dx = length; dy = height; x -= DANGLING_SYMBOL_SIZE; y -= height / 2; break; - case 3: /* Vert Orientation BOTTOM */ + case 3: // Vert Orientation BOTTOM dx = height; dy = length; x -= height / 2; @@ -1441,7 +1473,7 @@ SCH_HIERLABEL::SCH_HIERLABEL( const wxPoint& pos, const wxString& text, KICAD_T m_Layer = LAYER_HIERLABEL; m_shape = NET_INPUT; m_isDangling = true; - m_MultilineAllowed = false; + SetMultilineAllowed( false ); } @@ -1456,12 +1488,12 @@ bool SCH_HIERLABEL::Save( FILE* aFile ) const bool success = true; const char* shape = "~"; - if( m_Italic ) + if( IsItalic() ) shape = "Italic"; if( fprintf( aFile, "Text HLabel %-4d %-4d %-4d %-4d %s %s %d\n%s\n", - m_Pos.x, m_Pos.y, m_schematicOrientation, m_Size.x, - SheetLabelType[m_shape], shape, m_Thickness, TO_UTF8( m_Text ) ) == EOF ) + GetTextPos().x, GetTextPos().y, GetLabelSpinStyle(), GetTextWidth(), + SheetLabelType[m_shape], shape, GetThickness(), TO_UTF8( m_Text ) ) == EOF ) { success = false; } @@ -1472,10 +1504,11 @@ bool SCH_HIERLABEL::Save( FILE* aFile ) const bool SCH_HIERLABEL::Load( LINE_READER& aLine, wxString& aErrorMsg ) { - char Name1[256]; - char Name2[256]; - char Name3[256]; - int thickness = 0, size = 0, orient = 0; + char Name1[256]; + char Name2[256]; + char Name3[256]; + int thickness = 0, size = 0, orient = 0; + int x, y; Name1[0] = 0; Name2[0] = 0; Name3[0] = 0; @@ -1485,7 +1518,8 @@ bool SCH_HIERLABEL::Load( LINE_READER& aLine, wxString& aErrorMsg ) sline++; // sline points the start of parameters - int ii = sscanf( sline, "%255s %d %d %d %d %255s %255s %d", Name1, &m_Pos.x, &m_Pos.y, + int ii = sscanf( sline, "%255s %d %d %d %d %255s %255s %d", Name1, + &x, &y, &orient, &size, Name2, Name3, &thickness ); if( ii < 4 ) @@ -1515,11 +1549,15 @@ bool SCH_HIERLABEL::Load( LINE_READER& aLine, wxString& aErrorMsg ) } m_Text = FROM_UTF8( text ); - m_Size.x = m_Size.y = size; - SetOrientation( orient ); + + SetTextSize( wxSize( size, size ) ); + SetTextPos( wxPoint( x, y ) ); + + SetLabelSpinStyle( orient ); m_shape = NET_INPUT; - m_Bold = ( thickness != 0 ); - m_Thickness = m_Bold ? GetPenSizeForBold( size ) : 0; + SetBold( thickness != 0 ); + + SetThickness( IsBold() ? GetPenSizeForBold( size ) : 0 ); if( strcasecmp( Name2, SheetLabelType[NET_OUTPUT] ) == 0 ) m_shape = NET_OUTPUT; @@ -1534,41 +1572,41 @@ bool SCH_HIERLABEL::Load( LINE_READER& aLine, wxString& aErrorMsg ) m_shape = NET_UNSPECIFIED; if( strcasecmp( Name3, "Italic" ) == 0 ) - m_Italic = 1; + SetItalic( true ); return true; } -void SCH_HIERLABEL::SetOrientation( int aOrientation ) +void SCH_HIERLABEL::SetLabelSpinStyle( int aSpinStyle ) { - m_schematicOrientation = aOrientation; + m_spin_style = aSpinStyle; - switch( m_schematicOrientation ) + switch( aSpinStyle ) { default: - case 0: /* Horiz Normal Orientation */ - m_Orient = TEXT_ORIENT_HORIZ; - m_HJustify = GR_TEXT_HJUSTIFY_RIGHT; - m_VJustify = GR_TEXT_VJUSTIFY_CENTER; + case 0: // Horiz Normal Orientation + SetTextAngle( TEXT_ANGLE_HORIZ ); + SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); + SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); break; - case 1: /* Vert Orientation UP */ - m_Orient = TEXT_ORIENT_VERT; - m_HJustify = GR_TEXT_HJUSTIFY_LEFT; - m_VJustify = GR_TEXT_VJUSTIFY_CENTER; + case 1: // Vert Orientation UP + SetTextAngle( TEXT_ANGLE_VERT ); + SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); + SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); break; - case 2: /* Horiz Orientation */ - m_Orient = TEXT_ORIENT_HORIZ; - m_HJustify = GR_TEXT_HJUSTIFY_LEFT; - m_VJustify = GR_TEXT_VJUSTIFY_CENTER; + case 2: // Horiz Orientation + SetTextAngle( TEXT_ANGLE_HORIZ ); + SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); + SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); break; - case 3: /* Vert Orientation BOTTOM */ - m_Orient = TEXT_ORIENT_VERT; - m_HJustify = GR_TEXT_HJUSTIFY_RIGHT; - m_VJustify = GR_TEXT_VJUSTIFY_CENTER; + case 3: // Vert Orientation BOTTOM + SetTextAngle( TEXT_ANGLE_VERT ); + SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); + SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); break; } } @@ -1582,11 +1620,10 @@ void SCH_HIERLABEL::Draw( EDA_DRAW_PANEL* panel, { static std::vector Poly; EDA_COLOR_T color; - int linewidth = m_Thickness == 0 ? - GetDefaultLineThickness() : m_Thickness; - EDA_RECT* clipbox = panel? panel->GetClipBox() : NULL; + int linewidth = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness(); + EDA_RECT* clipbox = panel? panel->GetClipBox() : NULL; - linewidth = Clamp_Text_PenSize( linewidth, m_Size, m_Bold ); + linewidth = Clamp_Text_PenSize( linewidth, GetTextSize(), IsBold() ); if( Color >= 0 ) color = Color; @@ -1595,16 +1632,19 @@ void SCH_HIERLABEL::Draw( EDA_DRAW_PANEL* panel, GRSetDrawMode( DC, DrawMode ); - std::swap( linewidth, m_Thickness ); // Set the minimum width + int save_width = GetThickness(); + SetThickness( linewidth ); + wxPoint text_offset = offset + GetSchematicTextOffset(); EDA_TEXT::Draw( clipbox, DC, text_offset, color, DrawMode, FILLED, UNSPECIFIED_COLOR ); - std::swap( linewidth, m_Thickness ); // set initial value - CreateGraphicShape( Poly, m_Pos + offset ); + SetThickness( save_width ); // restore initial value + + CreateGraphicShape( Poly, GetTextPos() + offset ); GRPoly( clipbox, DC, Poly.size(), &Poly[0], 0, linewidth, color, color ); if( m_isDangling && panel ) - DrawDanglingSymbol( panel, DC, m_Pos + offset, color ); + DrawDanglingSymbol( panel, DC, GetTextPos() + offset, color ); // Enable these line to draw the bounding box (debug tests purposes only) #if DRAW_BBOX @@ -1618,8 +1658,8 @@ void SCH_HIERLABEL::Draw( EDA_DRAW_PANEL* panel, void SCH_HIERLABEL::CreateGraphicShape( std::vector & aPoints, const wxPoint& Pos ) { - int* Template = TemplateShape[m_shape][m_schematicOrientation]; - int halfSize = m_Size.x / 2; + int* Template = TemplateShape[m_shape][m_spin_style]; + int halfSize = GetTextWidth() / 2; int imax = *Template; Template++; @@ -1643,40 +1683,41 @@ const EDA_RECT SCH_HIERLABEL::GetBoundingBox() const { int x, y, dx, dy, length, height; - x = m_Pos.x; - y = m_Pos.y; + x = GetTextPos().x; + y = GetTextPos().y; dx = dy = 0; - int width = (m_Thickness == 0) ? GetDefaultLineThickness() : m_Thickness; - height = m_Size.y + width + 2 * TXT_MARGIN; + int width = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness(); + + height = GetTextHeight() + width + 2 * TXT_MARGIN; length = LenSize( GetShownText() ) + height // add height for triangular shapes + 2 * DANGLING_SYMBOL_SIZE; - switch( m_schematicOrientation ) // respect orientation + switch( GetLabelSpinStyle() ) { - case 0: /* Horiz Normal Orientation (left justified) */ + case 0: // Horiz Normal Orientation (left justified) dx = -length; dy = height; x += DANGLING_SYMBOL_SIZE; y -= height / 2; break; - case 1: /* Vert Orientation UP */ + case 1: // Vert Orientation UP dx = height; dy = -length; x -= height / 2; y += DANGLING_SYMBOL_SIZE; break; - case 2: /* Horiz Orientation - Right justified */ + case 2: // Horiz Orientation - Right justified dx = length; dy = height; x -= DANGLING_SYMBOL_SIZE; y -= height / 2; break; - case 3: /* Vert Orientation BOTTOM */ + case 3: // Vert Orientation BOTTOM dx = height; dy = length; x -= height / 2; @@ -1694,25 +1735,25 @@ wxPoint SCH_HIERLABEL::GetSchematicTextOffset() const { wxPoint text_offset; - int width = std::max( m_Thickness, GetDefaultLineThickness() ); + int width = std::max( GetThickness(), GetDefaultLineThickness() ); - int ii = m_Size.x + TXT_MARGIN + width; + int ii = GetTextWidth() + TXT_MARGIN + width; - switch( m_schematicOrientation ) + switch( GetLabelSpinStyle() ) { - case 0: /* Orientation horiz normale */ + case 0: // Orientation horiz normale text_offset.x = -ii; break; - case 1: /* Orientation vert UP */ + case 1: // Orientation vert UP text_offset.y = -ii; break; - case 2: /* Orientation horiz inverse */ + case 2: // Orientation horiz inverse text_offset.x = ii; break; - case 3: /* Orientation vert BOTTOM */ + case 3: // Orientation vert BOTTOM text_offset.y = ii; break; } @@ -1727,43 +1768,45 @@ void SCH_HIERLABEL::MirrorY( int aYaxis_position ) * orientation is changed. For a vertical label, the schematic orientation is not changed * and the label is moved to a suitable position. */ - - switch( GetOrientation() ) + switch( GetLabelSpinStyle() ) { - case 0: /* horizontal text */ - SetOrientation( 2 ); + case 0: // horizontal text + SetLabelSpinStyle( 2 ); break; - case 2: /* invert horizontal text*/ - SetOrientation( 0 ); + case 2: // invert horizontal text + SetLabelSpinStyle( 0 ); break; } - MIRROR( m_Pos.x, aYaxis_position ); + SetTextX( Mirror( GetTextPos().x, aYaxis_position ) ); } void SCH_HIERLABEL::MirrorX( int aXaxis_position ) { - switch( GetOrientation() ) + switch( GetLabelSpinStyle() ) { - case 1: /* vertical text */ - SetOrientation( 3 ); + case 1: // vertical text + SetLabelSpinStyle( 3 ); break; - case 3: /* invert vertical text*/ - SetOrientation( 1 ); + case 3: // invert vertical text + SetLabelSpinStyle( 1 ); break; } - MIRROR( m_Pos.y, aXaxis_position ); + SetTextY( Mirror( GetTextPos().y, aXaxis_position ) ); } void SCH_HIERLABEL::Rotate( wxPoint aPosition ) { - RotatePoint( &m_Pos, aPosition, 900 ); - SetOrientation( (GetOrientation() + 3) % 4 ); + wxPoint pt = GetTextPos(); + RotatePoint( &pt, aPosition, 900 ); + SetTextPos( pt ); + + SetLabelSpinStyle( (GetLabelSpinStyle() + 3) % 4 ); } diff --git a/eeschema/sch_text.h b/eeschema/sch_text.h index 228ddf999c..24b1aaa74a 100644 --- a/eeschema/sch_text.h +++ b/eeschema/sch_text.h @@ -54,6 +54,7 @@ enum PINSHEETLABEL_SHAPE { extern const char* SheetLabelType[]; /* names of types of labels */ + class SCH_TEXT : public SCH_ITEM, public EDA_TEXT { protected: @@ -70,9 +71,9 @@ protected: * 2 is horizontal and right justified. It is the equivalent of the mirrored 0 orentation. * 3 is veritcal and bottom justifiend. It is the equivalent of the mirrored 1 orentation. * This is a duplicattion of m_Orient, m_HJustified, and m_VJustified in #EDA_TEXT but is - * easier to handle that 3 parameters when editing and reading and saving files. + * easier to handle than 3 parameters when editing and reading and saving files. */ - int m_schematicOrientation; + int m_spin_style; public: SCH_TEXT( const wxPoint& pos = wxPoint( 0, 0 ), @@ -104,22 +105,20 @@ public: void IncrementLabel( int aIncrement ); /** - * Function SetOrientation - * Set m_schematicOrientation, and initialize - * m_orient,m_HJustified and m_VJustified, according to the value of - * m_schematicOrientation (for a text ) - * must be called after changing m_schematicOrientation - * @param aSchematicOrientation = + * Function SetLabelSpinStyle + * sets a spin or rotation angle, along with specific horizontal and vertical + * justification styles with each angle. + * + * @param aSpinStyle = * 0 = normal (horizontal, left justified). * 1 = up (vertical) * 2 = (horizontal, right justified). This can be seen as the mirrored position of 0 * 3 = bottom . This can be seen as the mirrored position of up */ - virtual void SetOrientation( int aSchematicOrientation ); + virtual void SetLabelSpinStyle( int aSpinStyle ); + int GetLabelSpinStyle() const { return m_spin_style; } - int GetOrientation() { return m_schematicOrientation; } - - PINSHEETLABEL_SHAPE GetShape() const { return m_shape; } + PINSHEETLABEL_SHAPE GetShape() const { return m_shape; } void SetShape( PINSHEETLABEL_SHAPE aShape ) { m_shape = aShape; } @@ -161,7 +160,7 @@ public: virtual void Move( const wxPoint& aMoveVector ) override { - m_Pos += aMoveVector; + EDA_TEXT::Offset( aMoveVector ); } virtual void MirrorY( int aYaxis_position ) override; @@ -198,9 +197,9 @@ public: virtual void GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems, SCH_SHEET_PATH* aSheetPath ) override; - virtual wxPoint GetPosition() const override { return m_Pos; } + virtual wxPoint GetPosition() const override { return EDA_TEXT::GetTextPos(); } - virtual void SetPosition( const wxPoint& aPosition ) override { m_Pos = aPosition; } + virtual void SetPosition( const wxPoint& aPosition ) override { EDA_TEXT::SetTextPos( aPosition ); } virtual bool HitTest( const wxPoint& aPosition, int aAccuracy ) const override; @@ -236,7 +235,7 @@ public: return wxT( "SCH_LABEL" ); } - void SetOrientation( int aSchematicOrientation ) override; + void SetLabelSpinStyle( int aSpinStyle ) override; wxPoint GetSchematicTextOffset() const override; @@ -261,7 +260,7 @@ public: EDA_ITEM* Clone() const override; private: - bool doIsConnected( const wxPoint& aPosition ) const override { return m_Pos == aPosition; } + bool doIsConnected( const wxPoint& aPosition ) const override { return EDA_TEXT::GetTextPos() == aPosition; } }; @@ -282,7 +281,7 @@ public: return wxT( "SCH_GLOBALLABEL" ); } - void SetOrientation( int aSchematicOrientation ) override; + void SetLabelSpinStyle( int aSpinStyle ) override; wxPoint GetSchematicTextOffset() const override; @@ -309,7 +308,7 @@ public: EDA_ITEM* Clone() const override; private: - bool doIsConnected( const wxPoint& aPosition ) const override { return m_Pos == aPosition; } + bool doIsConnected( const wxPoint& aPosition ) const override { return EDA_TEXT::GetTextPos() == aPosition; } }; @@ -332,7 +331,7 @@ public: return wxT( "SCH_HIERLABEL" ); } - void SetOrientation( int aSchematicOrientation ) override; + void SetLabelSpinStyle( int aSpinStyle ) override; wxPoint GetSchematicTextOffset() const override; @@ -359,7 +358,7 @@ public: EDA_ITEM* Clone() const override; private: - bool doIsConnected( const wxPoint& aPosition ) const override { return m_Pos == aPosition; } + bool doIsConnected( const wxPoint& aPosition ) const override { return EDA_TEXT::GetTextPos() == aPosition; } }; #endif /* CLASS_TEXT_LABEL_H */ diff --git a/eeschema/sheetlab.cpp b/eeschema/sheetlab.cpp index c5e58ef8bf..b7412479be 100644 --- a/eeschema/sheetlab.cpp +++ b/eeschema/sheetlab.cpp @@ -66,9 +66,9 @@ int SCH_EDIT_FRAME::EditSheetPin( SCH_SHEET_PIN* aSheetPin, bool aRedraw ) DIALOG_SCH_EDIT_SHEET_PIN dlg( this ); dlg.SetLabelName( aSheetPin->GetText() ); - dlg.SetTextHeight( StringFromValue( g_UserUnit, aSheetPin->GetSize().y ) ); + dlg.SetTextHeight( StringFromValue( g_UserUnit, aSheetPin->GetTextHeight() ) ); dlg.SetTextHeightUnits( GetUnitsLabel( g_UserUnit ) ); - dlg.SetTextWidth( StringFromValue( g_UserUnit, aSheetPin->GetSize().x ) ); + dlg.SetTextWidth( StringFromValue( g_UserUnit, aSheetPin->GetTextWidth() ) ); dlg.SetTextWidthUnits( GetUnitsLabel( g_UserUnit ) ); dlg.SetConnectionType( aSheetPin->GetShape() ); @@ -91,8 +91,11 @@ int SCH_EDIT_FRAME::EditSheetPin( SCH_SHEET_PIN* aSheetPin, bool aRedraw ) } aSheetPin->SetText( dlg.GetLabelName() ); - aSheetPin->SetSize( wxSize( ValueFromString( g_UserUnit, dlg.GetTextWidth() ), - ValueFromString( g_UserUnit, dlg.GetTextHeight() ) ) ); + + aSheetPin->SetTextSize( wxSize( + ValueFromString( g_UserUnit, dlg.GetTextWidth() ), + ValueFromString( g_UserUnit, dlg.GetTextHeight() ) ) ); + aSheetPin->SetShape( dlg.GetConnectionType() ); OnModify(); @@ -111,7 +114,7 @@ SCH_SHEET_PIN* SCH_EDIT_FRAME::CreateSheetPin( SCH_SHEET* aSheet, wxDC* aDC ) sheetPin = new SCH_SHEET_PIN( aSheet, wxPoint( 0, 0 ), line ); sheetPin->SetFlags( IS_NEW ); - sheetPin->SetSize( GetLastSheetPinTextSize() ); + sheetPin->SetTextSize( GetLastSheetPinTextSize() ); sheetPin->SetShape( m_lastSheetPinType ); int response = EditSheetPin( sheetPin, false ); @@ -123,7 +126,7 @@ SCH_SHEET_PIN* SCH_EDIT_FRAME::CreateSheetPin( SCH_SHEET* aSheet, wxDC* aDC ) } m_lastSheetPinType = sheetPin->GetShape(); - m_lastSheetPinTextSize = sheetPin->GetSize(); + m_lastSheetPinTextSize = sheetPin->GetTextSize(); sheetPin->SetPosition( GetCrossHairPosition() ); sheetPin->Draw( m_canvas, aDC, wxPoint( 0, 0 ), g_XorMode ); @@ -167,7 +170,7 @@ SCH_SHEET_PIN* SCH_EDIT_FRAME::ImportSheetPin( SCH_SHEET* aSheet, wxDC* aDC ) sheetPin = new SCH_SHEET_PIN( aSheet, wxPoint( 0, 0 ), label->GetText() ); sheetPin->SetFlags( IS_NEW ); - sheetPin->SetSize( GetLastSheetPinTextSize() ); + sheetPin->SetTextSize( GetLastSheetPinTextSize() ); m_lastSheetPinType = label->GetShape(); sheetPin->SetShape( label->GetShape() ); sheetPin->SetPosition( GetCrossHairPosition() ); diff --git a/eeschema/symbdraw.cpp b/eeschema/symbdraw.cpp index e2cdee0b26..136c914b14 100644 --- a/eeschema/symbdraw.cpp +++ b/eeschema/symbdraw.cpp @@ -147,7 +147,7 @@ static void AbortSymbolTraceOn( EDA_DRAW_PANEL* Panel, wxDC* DC ) } -LIB_ITEM* LIB_EDIT_FRAME::CreateGraphicItem( LIB_PART* LibEntry, wxDC* DC ) +LIB_ITEM* LIB_EDIT_FRAME::CreateGraphicItem( LIB_PART* LibEntry, wxDC* DC ) { m_canvas->SetMouseCapture( SymbolDisplayDraw, AbortSymbolTraceOn ); wxPoint drawPos = GetCrossHairPosition( true ); @@ -176,24 +176,25 @@ LIB_ITEM* LIB_EDIT_FRAME::CreateGraphicItem( LIB_PART* LibEntry, wxDC* DC ) case ID_LIBEDIT_BODY_TEXT_BUTT: { - LIB_TEXT* Text = new LIB_TEXT( LibEntry ); - Text->SetSize( wxSize( m_textSize, m_textSize ) ); - Text->SetOrientation( m_textOrientation ); + LIB_TEXT* text = new LIB_TEXT( LibEntry ); + text->SetTextSize( wxSize( m_textSize, m_textSize ) ); + text->SetTextAngle( m_current_text_angle ); // Enter the graphic text info m_canvas->SetIgnoreMouseEvents( true ); - EditSymbolText( NULL, Text ); + EditSymbolText( NULL, text ); + m_canvas->SetIgnoreMouseEvents( false ); m_canvas->MoveCursorToCrossHair(); - if( Text->GetText().IsEmpty() ) + if( text->GetText().IsEmpty() ) { - delete Text; + delete text; m_drawItem = NULL; } else { - m_drawItem = Text; + m_drawItem = text; } } break; diff --git a/gerbview/class_gbr_layout.cpp b/gerbview/class_gbr_layout.cpp index 826418ca25..b9588d0774 100644 --- a/gerbview/class_gbr_layout.cpp +++ b/gerbview/class_gbr_layout.cpp @@ -407,7 +407,7 @@ void GBR_LAYOUT::DrawItemsDCodeID( EDA_DRAW_PANEL* aPanel, wxDC* aDC, else width = std::min( item->m_Size.x, item->m_Size.y ); - double orient = TEXT_ORIENT_HORIZ; + double orient = TEXT_ANGLE_HORIZ; if( item->m_Flashed ) { @@ -419,7 +419,7 @@ void GBR_LAYOUT::DrawItemsDCodeID( EDA_DRAW_PANEL* aPanel, wxDC* aDC, wxPoint delta = item->m_Start - item->m_End; if( abs( delta.x ) < abs( delta.y ) ) - orient = TEXT_ORIENT_VERT; + orient = TEXT_ANGLE_VERT; // A reasonable size for text is width/2 because text needs margin below and above it. // a margin = width/4 seems good diff --git a/include/common.h b/include/common.h index 64ad39beb7..dbd4dd6834 100644 --- a/include/common.h +++ b/include/common.h @@ -107,11 +107,10 @@ enum pseudokeys { #endif -// Graphic Texts Orientation in 0.1 degree -#define TEXT_ORIENT_HORIZ 0 -#define TEXT_ORIENT_VERT 900 - - +/// 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 //----------------------------------------------------------------- diff --git a/include/eda_text.h b/include/eda_text.h index aa2b6d4c1a..53b9e059f6 100644 --- a/include/eda_text.h +++ b/include/eda_text.h @@ -65,36 +65,48 @@ enum EDA_DRAW_MODE_T { * you do not fully realize the effect it has on sexp serialization * (text size equal to this is not explicitly wrote, so it would change * subsequent reads) */ -#define DEFAULT_SIZE_TEXT 60 // default text height (in mils, i.e. 1/1000") -#define TEXT_NO_VISIBLE 1 //< EDA_TEXT::m_Attribut(e?) visibility flag. -#define DIM_ANCRE_TEXTE 2 // Anchor size for text +#define DEFAULT_SIZE_TEXT 60 // default text height (in mils, i.e. 1/1000") +#define DIM_ANCRE_TEXTE 2 // Anchor size for text + + +/** + * Struct TEXT_EFFECTS + * is a bucket 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 ) + {} + + short 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< + * Calculates the distance (pitch) between 2 text lines + * the distance includes the interline + room for chars like j { and [ + * Is used for multiline texts, but also for single line texts, to calculate + * the text bounding box + *. * @param aTextThickness Overrides the current thickness when greater than 0. * this is needed when the current m_Thickness is 0 and a default line thickness * is used @@ -279,12 +315,6 @@ public: */ wxString GetTextStyleName(); - EDA_TEXT_HJUSTIFY_T GetHorizJustify() const { return m_HJustify; }; - EDA_TEXT_VJUSTIFY_T GetVertJustify() const { return m_VJustify; }; - - void SetHorizJustify( EDA_TEXT_HJUSTIFY_T aType ) { m_HJustify = aType; }; - void SetVertJustify( EDA_TEXT_VJUSTIFY_T aType ) { m_VJustify = aType; }; - /** * Function GetPositionsOfLinesOfMultilineText * Populates aPositions with the position of each line of @@ -308,11 +338,13 @@ public: virtual void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const throw( IO_ERROR ); -private: +protected: + wxString m_Text; +private: /** * Function drawOneLineOfText - * Draw a single text line. + * draws a single text line. * Used to draw each line of this EDA_TEXT, that can be multiline * @param aClipBox = the clipping rect, or NULL if no clipping * @param aDC = the current Device Context @@ -326,7 +358,20 @@ private: void drawOneLineOfText( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset, EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode, EDA_DRAW_MODE_T aFillMode, - const wxString& aText, const wxPoint &aPos ); + const wxString& aText, const wxPoint& aPos ); + + // Private text effects data. API above provides accessor funcs. + TEXT_EFFECTS m_e; + + /// EDA_TEXT effects bools + enum TE_FLAGS { + // start at zero, sequence is irrelevant + TE_MIRROR, + TE_ITALIC, + TE_BOLD, + TE_MULTILINE, + TE_VISIBLE, + }; }; diff --git a/include/macros.h b/include/macros.h index e216dcd327..f794b26696 100644 --- a/include/macros.h +++ b/include/macros.h @@ -103,9 +103,14 @@ static inline const wxChar* GetChars( const wxString& s ) * Mirror @a aPoint in @a aMirrorRef. */ template +T Mirror( T aPoint, T aMirrorRef ) +{ + return -( aPoint - aMirrorRef ) + aMirrorRef; +} +template void MIRROR( T& aPoint, const T& aMirrorRef ) { - aPoint = -( aPoint - aMirrorRef ) + aMirrorRef; + aPoint = Mirror( aPoint, aMirrorRef ); } diff --git a/include/trigo.h b/include/trigo.h index 838ee43307..082f397a0b 100644 --- a/include/trigo.h +++ b/include/trigo.h @@ -199,32 +199,45 @@ inline double RAD2DECIDEG( double rad ) { return rad * 1800.0 / M_PI; } is still using int for angles in some place */ /// Normalize angle to be in the -360.0 .. 360.0: -template inline void NORMALIZE_ANGLE_360( T &Angle ) +template inline T NormalizeAngle360( T Angle ) { while( Angle <= -3600 ) Angle += 3600; while( Angle >= 3600 ) Angle -= 3600; + return Angle; } + /// Normalize angle to be in the 0.0 .. 360.0 range: /// angle is in 1/10 degees -template inline void NORMALIZE_ANGLE_POS( T &Angle ) +template inline T NormalizeAnglePos( T Angle ) { while( Angle < 0 ) Angle += 3600; while( Angle >= 3600 ) Angle -= 3600; + return Angle; } +template inline void NORMALIZE_ANGLE_POS( T& Angle ) +{ + Angle = NormalizeAnglePos( Angle ); +} + /// Normalize angle to be in the 0.0 .. 360.0 range: /// angle is in degrees -inline void NORMALIZE_ANGLE_DEGREES_POS( double &Angle ) +inline double NormalizeAngleDegreesPos( double Angle ) { while( Angle < 0 ) Angle += 360.0; while( Angle >= 360.0 ) Angle -= 360.0; + return Angle; +} +inline void NORMALIZE_ANGLE_DEGREES_POS( double& Angle ) +{ + Angle = NormalizeAngleDegreesPos( Angle ); } /// Add two angles (keeping the result normalized). T2 is here @@ -237,32 +250,50 @@ template inline T AddAngles( T a1, T2 a2 ) return a1; } -template inline void NEGATE_AND_NORMALIZE_ANGLE_POS( T &Angle ) +template inline T NegateAndNormalizeAnglePos( T Angle ) { Angle = -Angle; while( Angle < 0 ) Angle += 3600; while( Angle >= 3600 ) Angle -= 3600; + return Angle; +} +template inline void NEGATE_AND_NORMALIZE_ANGLE_POS( T& Angle ) +{ + Angle = NegateAndNormalizeAnglePos( Angle ); } + /// Normalize angle to be in the -90.0 .. 90.0 range -template inline void NORMALIZE_ANGLE_90( T &Angle ) +template inline T NormalizeAngle90( T Angle ) { while( Angle < -900 ) Angle += 1800; while( Angle > 900 ) Angle -= 1800; + return Angle; +} +template inline void NORMALIZE_ANGLE_90( T& Angle ) +{ + Angle = NormalizeAngle90( Angle ); } + /// Normalize angle to be in the -180.0 .. 180.0 range -template inline void NORMALIZE_ANGLE_180( T &Angle ) +template inline T NormalizeAngle180( T Angle ) { while( Angle <= -1800 ) Angle += 3600; while( Angle > 1800 ) Angle -= 3600; + return Angle; } +template inline void NORMALIZE_ANGLE_180( T& Angle ) +{ + Angle = NormalizeAngle180( Angle ); +} + /** * Circle generation utility: computes r * sin(a) diff --git a/include/worksheet_shape_builder.h b/include/worksheet_shape_builder.h index 504d7c3a2a..8cd5f22d66 100644 --- a/include/worksheet_shape_builder.h +++ b/include/worksheet_shape_builder.h @@ -297,6 +297,11 @@ public: // Accessors: int GetPenWidth() { return GetThickness(); } + void SetTextAngle( double aAngle ) + { + EDA_TEXT::SetTextAngle( NormalizeAngle360( aAngle ) ); + } + /** * Virtual function * return true if the point aPosition is on the text diff --git a/pcbnew/autorouter/routing_matrix.cpp b/pcbnew/autorouter/routing_matrix.cpp index 2c97f0d0a6..6319562823 100644 --- a/pcbnew/autorouter/routing_matrix.cpp +++ b/pcbnew/autorouter/routing_matrix.cpp @@ -302,12 +302,12 @@ void PlaceCells( BOARD* aPcb, int net_code, int flag ) layerMask = LSET( PtText->GetLayer() ); TraceFilledRectangle( ux0 - marge, uy0 - marge, ux1 + marge, - uy1 + marge, PtText->GetOrientation(), + uy1 + marge, PtText->GetTextAngle(), layerMask, HOLE, WRITE_CELL ); TraceFilledRectangle( ux0 - via_marge, uy0 - via_marge, ux1 + via_marge, uy1 + via_marge, - PtText->GetOrientation(), + PtText->GetTextAngle(), layerMask, VIA_IMPOSSIBLE, WRITE_OR_CELL ); } break; diff --git a/pcbnew/block_module_editor.cpp b/pcbnew/block_module_editor.cpp index 0c7feb733c..a34eb58429 100644 --- a/pcbnew/block_module_editor.cpp +++ b/pcbnew/block_module_editor.cpp @@ -809,7 +809,7 @@ int MarkItemsInBloc( MODULE* module, EDA_RECT& Rect ) ClearMarkItems( module ); // Just in case ... - pos = module->Reference().GetTextPosition(); + pos = module->Reference().GetTextPos(); if( Rect.Contains( pos ) ) { @@ -817,7 +817,7 @@ int MarkItemsInBloc( MODULE* module, EDA_RECT& Rect ) ItemsCount++; } - pos = module->Value().GetTextPosition(); + pos = module->Value().GetTextPos(); if( Rect.Contains( pos ) ) { @@ -857,7 +857,7 @@ int MarkItemsInBloc( MODULE* module, EDA_RECT& Rect ) break; case PCB_MODULE_TEXT_T: - pos = static_cast( item )->GetTextPosition(); + pos = static_cast( item )->GetTextPos(); if( Rect.Contains( pos ) ) { diff --git a/pcbnew/board_items_to_polygon_shape_transform.cpp b/pcbnew/board_items_to_polygon_shape_transform.cpp index c1bab07900..cdeae72bb5 100644 --- a/pcbnew/board_items_to_polygon_shape_transform.cpp +++ b/pcbnew/board_items_to_polygon_shape_transform.cpp @@ -259,12 +259,12 @@ void MODULE::TransformGraphicShapesWithClearanceToPolygonSet( { TEXTE_MODULE *textmod = texts[ii]; s_textWidth = textmod->GetThickness() + ( 2 * aInflateValue ); - wxSize size = textmod->GetSize(); + wxSize size = textmod->GetTextSize(); if( textmod->IsMirrored() ) size.x = -size.x; - DrawGraphicText( NULL, NULL, textmod->GetTextPosition(), BLACK, + DrawGraphicText( NULL, NULL, textmod->GetTextPos(), BLACK, textmod->GetShownText(), textmod->GetDrawRotation(), size, textmod->GetHorizJustify(), textmod->GetVertJustify(), textmod->GetThickness(), textmod->IsItalic(), @@ -328,12 +328,12 @@ void MODULE::TransformGraphicTextWithClearanceToPolygonSet( { TEXTE_MODULE *textmod = texts[ii]; s_textWidth = textmod->GetThickness() + ( 2 * aInflateValue ); - wxSize size = textmod->GetSize(); + wxSize size = textmod->GetTextSize(); if( textmod->IsMirrored() ) size.x = -size.x; - DrawGraphicText( NULL, NULL, textmod->GetTextPosition(), BLACK, + DrawGraphicText( NULL, NULL, textmod->GetTextPos(), BLACK, textmod->GetShownText(), textmod->GetDrawRotation(), size, textmod->GetHorizJustify(), textmod->GetVertJustify(), textmod->GetThickness(), textmod->IsItalic(), @@ -413,7 +413,7 @@ void TEXTE_PCB::TransformBoundingBoxWithClearanceToPolygon( for( int ii = 0; ii < 4; ii++ ) { // Rotate polygon - RotatePoint( &corners[ii].x, &corners[ii].y, m_Pos.x, m_Pos.y, m_Orient ); + RotatePoint( &corners[ii].x, &corners[ii].y, GetTextPos().x, GetTextPos().y, GetTextAngle() ); aCornerBuffer.Append( corners[ii].x, corners[ii].y ); } } @@ -437,7 +437,7 @@ void TEXTE_PCB::TransformShapeWithClearanceToPolygonSet( int aCircleToSegmentsCount, double aCorrectionFactor ) const { - wxSize size = GetSize(); + wxSize size = GetTextSize(); if( IsMirrored() ) size.x = -size.x; @@ -459,7 +459,7 @@ void TEXTE_PCB::TransformShapeWithClearanceToPolygonSet( { wxString txt = strings_list.Item( ii ); DrawGraphicText( NULL, NULL, positions[ii], color, - txt, GetOrientation(), size, + txt, GetTextAngle(), size, GetHorizJustify(), GetVertJustify(), GetThickness(), IsItalic(), true, addTextSegmToPoly ); @@ -467,8 +467,8 @@ void TEXTE_PCB::TransformShapeWithClearanceToPolygonSet( } else { - DrawGraphicText( NULL, NULL, GetTextPosition(), color, - GetShownText(), GetOrientation(), size, + DrawGraphicText( NULL, NULL, GetTextPos(), color, + GetShownText(), GetTextAngle(), size, GetHorizJustify(), GetVertJustify(), GetThickness(), IsItalic(), true, addTextSegmToPoly ); diff --git a/pcbnew/class_board.cpp b/pcbnew/class_board.cpp index 6608c3ce07..d715f442fa 100644 --- a/pcbnew/class_board.cpp +++ b/pcbnew/class_board.cpp @@ -2550,6 +2550,16 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, bool aDeleteSinglePadNets, // will be used footprint->CopyNetlistSettings( newFootprint, false ); + // Compare the footprint name only, in case the nickname is empty or in case + // user moved the footprint to a new library. Chances are if footprint name is + // same then the footprint is very nearly the same and the two texts should + // be kept at same size, position, and rotation. + if( newFootprint->GetFPID().GetLibItemName() == footprint->GetFPID().GetLibItemName() ) + { + newFootprint->Reference().SetEffects( footprint->Reference() ); + newFootprint->Value().SetEffects( footprint->Value() ); + } + Remove( footprint ); Add( newFootprint, ADD_APPEND ); footprint = newFootprint; diff --git a/pcbnew/class_dimension.cpp b/pcbnew/class_dimension.cpp index bcdb38abf5..0efa9faaf3 100644 --- a/pcbnew/class_dimension.cpp +++ b/pcbnew/class_dimension.cpp @@ -60,13 +60,13 @@ DIMENSION::~DIMENSION() void DIMENSION::SetPosition( const wxPoint& aPos ) { - m_Text.SetTextPosition( aPos ); + m_Text.SetTextPos( aPos ); } const wxPoint& DIMENSION::GetPosition() const { - return m_Text.GetTextPosition(); + return m_Text.GetTextPos(); } @@ -91,7 +91,8 @@ void DIMENSION::SetLayer( LAYER_ID aLayer ) void DIMENSION::Move( const wxPoint& offset ) { - m_Text.SetTextPosition( m_Text.GetTextPosition() + offset ); + m_Text.Offset( offset ); + m_crossBarO += offset; m_crossBarF += offset; m_featureLineGO += offset; @@ -107,11 +108,11 @@ void DIMENSION::Move( const wxPoint& offset ) void DIMENSION::Rotate( const wxPoint& aRotCentre, double aAngle ) { - wxPoint tmp = m_Text.GetTextPosition(); + wxPoint tmp = m_Text.GetTextPos(); RotatePoint( &tmp, aRotCentre, aAngle ); - m_Text.SetTextPosition( tmp ); + m_Text.SetTextPos( tmp ); - double newAngle = m_Text.GetOrientation() + aAngle; + double newAngle = m_Text.GetTextAngle() + aAngle; if( newAngle >= 3600 ) newAngle -= 3600; @@ -119,7 +120,7 @@ void DIMENSION::Rotate( const wxPoint& aRotCentre, double aAngle ) if( newAngle > 900 && newAngle < 2700 ) newAngle -= 1800; - m_Text.SetOrientation( newAngle ); + m_Text.SetTextAngle( newAngle ); RotatePoint( &m_crossBarO, aRotCentre, aAngle ); RotatePoint( &m_crossBarF, aRotCentre, aAngle ); @@ -146,15 +147,15 @@ void DIMENSION::Flip( const wxPoint& aCentre ) void DIMENSION::Mirror( const wxPoint& axis_pos ) { - wxPoint newPos = m_Text.GetTextPosition(); + wxPoint newPos = m_Text.GetTextPos(); #define INVERT( pos ) (pos) = axis_pos.y - ( (pos) - axis_pos.y ) INVERT( newPos.y ); - m_Text.SetTextPosition( newPos ); + m_Text.SetTextPos( newPos ); // invert angle - m_Text.SetOrientation( -m_Text.GetOrientation() ); + m_Text.SetTextAngle( -m_Text.GetTextAngle() ); INVERT( m_crossBarO.y ); INVERT( m_crossBarF.y ); @@ -220,7 +221,7 @@ void DIMENSION::AdjustDimensionDetails( bool aDoNotChangeText ) m_Text.SetLayer( GetLayer() ); // calculate the size of the dimension (text + line above the text) - ii = m_Text.GetSize().y + m_Text.GetThickness() + (m_Width * 3); + ii = m_Text.GetTextHeight() + m_Text.GetThickness() + (m_Width * 3); deltax = m_featureLineDO.x - m_featureLineGO.x; deltay = m_featureLineDO.y - m_featureLineGO.y; @@ -291,7 +292,7 @@ void DIMENSION::AdjustDimensionDetails( bool aDoNotChangeText ) wxPoint textPos; textPos.x = (m_crossBarF.x + m_featureLineGF.x) / 2; textPos.y = (m_crossBarF.y + m_featureLineGF.y) / 2; - m_Text.SetTextPosition( textPos ); + m_Text.SetTextPos( textPos ); double newAngle = -RAD2DECIDEG( angle ); @@ -300,7 +301,7 @@ void DIMENSION::AdjustDimensionDetails( bool aDoNotChangeText ) if( newAngle > 900 && newAngle < 2700 ) newAngle -= 1800; - m_Text.SetOrientation( newAngle ); + m_Text.SetTextAngle( newAngle ); if( !aDoNotChangeText ) { diff --git a/pcbnew/class_dimension.h b/pcbnew/class_dimension.h index 62bf204638..2ad91ee41f 100644 --- a/pcbnew/class_dimension.h +++ b/pcbnew/class_dimension.h @@ -93,15 +93,15 @@ public: void SetTextSize( const wxSize& aTextSize ) { - m_Text.SetSize( aTextSize ); + m_Text.SetTextSize( aTextSize ); } void SetLayer( LAYER_ID aLayer ) override; void SetShape( int aShape ) { m_Shape = aShape; } - int GetShape() const { return m_Shape; } + int GetShape() const { return m_Shape; } - int GetWidth() const { return m_Width; } + int GetWidth() const { return m_Width; } void SetWidth( int aWidth ) { m_Width = aWidth; } /** diff --git a/pcbnew/class_drawsegment.cpp b/pcbnew/class_drawsegment.cpp index 8dc8b1865c..37d776a0b7 100644 --- a/pcbnew/class_drawsegment.cpp +++ b/pcbnew/class_drawsegment.cpp @@ -184,9 +184,7 @@ double DRAWSEGMENT::GetArcAngleStart() const void DRAWSEGMENT::SetAngle( double aAngle ) { - NORMALIZE_ANGLE_360( aAngle ); - - m_Angle = aAngle; + m_Angle = NormalizeAngle360( aAngle ); } diff --git a/pcbnew/class_module.cpp b/pcbnew/class_module.cpp index ff914e8d62..40020fd8de 100644 --- a/pcbnew/class_module.cpp +++ b/pcbnew/class_module.cpp @@ -958,8 +958,9 @@ void MODULE::SetPosition( const wxPoint& newpos ) wxPoint delta = newpos - m_Pos; m_Pos += delta; - m_Reference->SetTextPosition( m_Reference->GetTextPosition() + delta ); - m_Value->SetTextPosition( m_Value->GetTextPosition() + delta ); + + m_Reference->EDA_TEXT::Offset( delta ); + m_Value->EDA_TEXT::Offset( delta ); for( D_PAD* pad = m_Pads; pad; pad = pad->Next() ) { @@ -980,7 +981,7 @@ void MODULE::SetPosition( const wxPoint& newpos ) case PCB_MODULE_TEXT_T: { TEXTE_MODULE* text = static_cast( item ); - text->SetTextPosition( text->GetTextPosition() + delta ); + text->EDA_TEXT::Offset( delta ); break; } diff --git a/pcbnew/class_pad.cpp b/pcbnew/class_pad.cpp index d4822f71f9..cab4376e27 100644 --- a/pcbnew/class_pad.cpp +++ b/pcbnew/class_pad.cpp @@ -835,8 +835,8 @@ int D_PAD::Compare( const D_PAD* padref, const D_PAD* padcmp ) void D_PAD::Rotate( const wxPoint& aRotCentre, double aAngle ) { RotatePoint( &m_Pos, aRotCentre, aAngle ); - m_Orient += aAngle; - NORMALIZE_ANGLE_360( m_Orient ); + + m_Orient = NormalizeAngle360( m_Orient + aAngle ); SetLocalCoord(); } diff --git a/pcbnew/class_pcb_text.cpp b/pcbnew/class_pcb_text.cpp index 27164e3b14..82e6ea93b6 100644 --- a/pcbnew/class_pcb_text.cpp +++ b/pcbnew/class_pcb_text.cpp @@ -51,15 +51,21 @@ TEXTE_PCB::TEXTE_PCB( BOARD_ITEM* parent ) : BOARD_ITEM( parent, PCB_TEXT_T ), EDA_TEXT() { - m_MultilineAllowed = true; + SetMultilineAllowed( true ); } -TEXTE_PCB:: ~TEXTE_PCB() +TEXTE_PCB::~TEXTE_PCB() { } +void TEXTE_PCB::SetTextAngle( double aAngle ) +{ + EDA_TEXT::SetTextAngle( NormalizeAngle360( aAngle ) ); +} + + void TEXTE_PCB::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE DrawMode, const wxPoint& offset ) { @@ -118,30 +124,31 @@ void TEXTE_PCB::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) aList.push_back( MSG_PANEL_ITEM( _( "Layer" ), GetLayerName(), BLUE ) ); - if( !m_Mirror ) + if( !IsMirrored() ) aList.push_back( MSG_PANEL_ITEM( _( "Mirror" ), _( "No" ), DARKGREEN ) ); else aList.push_back( MSG_PANEL_ITEM( _( "Mirror" ), _( "Yes" ), DARKGREEN ) ); - msg.Printf( wxT( "%.1f" ), m_Orient / 10.0 ); + msg.Printf( wxT( "%.1f" ), GetTextAngle() / 10.0 ); aList.push_back( MSG_PANEL_ITEM( _( "Angle" ), msg, DARKGREEN ) ); - msg = ::CoordinateToString( m_Thickness ); + msg = ::CoordinateToString( GetThickness() ); aList.push_back( MSG_PANEL_ITEM( _( "Thickness" ), msg, MAGENTA ) ); - msg = ::CoordinateToString( m_Size.x ); + msg = ::CoordinateToString( GetTextWidth() ); aList.push_back( MSG_PANEL_ITEM( _( "Width" ), msg, RED ) ); - msg = ::CoordinateToString( m_Size.y ); + msg = ::CoordinateToString( GetTextHeight() ); aList.push_back( MSG_PANEL_ITEM( _( "Height" ), msg, RED ) ); } + const EDA_RECT TEXTE_PCB::GetBoundingBox() const { EDA_RECT rect = GetTextBox( -1, -1 ); - if( m_Orient ) - rect = rect.GetBoundingBoxRotated( m_Pos, m_Orient ); + if( GetTextAngle() ) + rect = rect.GetBoundingBoxRotated( GetTextPos(), GetTextAngle() ); return rect; } @@ -149,18 +156,22 @@ const EDA_RECT TEXTE_PCB::GetBoundingBox() const void TEXTE_PCB::Rotate( const wxPoint& aRotCentre, double aAngle ) { - RotatePoint( &m_Pos, aRotCentre, aAngle ); - m_Orient += aAngle; - NORMALIZE_ANGLE_360( m_Orient ); + wxPoint pt = GetTextPos(); + RotatePoint( &pt, aRotCentre, aAngle ); + SetTextPos( pt ); + + SetTextAngle( GetTextAngle() + aAngle ); } -void TEXTE_PCB::Flip(const wxPoint& aCentre ) +void TEXTE_PCB::Flip( const wxPoint& aCentre ) { - m_Pos.y = aCentre.y - ( m_Pos.y - aCentre.y ); + SetTextY( aCentre.y - ( GetTextPos().y - aCentre.y ) ); + int copperLayerCount = GetBoard()->GetCopperLayerCount(); + SetLayer( FlipLayer( GetLayer(), copperLayerCount ) ); - m_Mirror = !m_Mirror; + SetMirrored( !IsMirrored() ); } diff --git a/pcbnew/class_pcb_text.h b/pcbnew/class_pcb_text.h index ff5009fe62..677e42a27c 100644 --- a/pcbnew/class_pcb_text.h +++ b/pcbnew/class_pcb_text.h @@ -57,19 +57,21 @@ public: virtual const wxPoint& GetPosition() const override { - return m_Pos; + return EDA_TEXT::GetTextPos(); } virtual void SetPosition( const wxPoint& aPos ) override { - m_Pos = aPos; + EDA_TEXT::SetTextPos( aPos ); } void Move( const wxPoint& aMoveVector ) override { - m_Pos += aMoveVector; + EDA_TEXT::Offset( aMoveVector ); } + void SetTextAngle( double aAngle ); + void Rotate( const wxPoint& aRotCentre, double aAngle ) override; void Flip( const wxPoint& aCentre ) override; diff --git a/pcbnew/class_text_mod.cpp b/pcbnew/class_text_mod.cpp index d069bedf96..3703d7cfab 100644 --- a/pcbnew/class_text_mod.cpp +++ b/pcbnew/class_text_mod.cpp @@ -57,20 +57,20 @@ TEXTE_MODULE::TEXTE_MODULE( MODULE* parent, TEXT_TYPE text_type ) : MODULE* module = static_cast( m_Parent ); m_Type = text_type; - m_NoShow = false; + // Set text thickness to a default value - m_Thickness = Millimeter2iu( 0.15 ); + SetThickness( Millimeter2iu( 0.15 ) ); SetLayer( F_SilkS ); // Set position and give a default layer if a valid parent footprint exists if( module && ( module->Type() == PCB_MODULE_T ) ) { - m_Pos = module->GetPosition(); + SetTextPos( module->GetPosition() ); if( IsBackLayer( module->GetLayer() ) ) { SetLayer( B_SilkS ); - m_Mirror = true; + SetMirrored( true ); } } @@ -83,12 +83,22 @@ TEXTE_MODULE::~TEXTE_MODULE() } +void TEXTE_MODULE::SetTextAngle( double aAngle ) +{ + EDA_TEXT::SetTextAngle( NormalizeAngle360( aAngle ) ); +} + + void TEXTE_MODULE::Rotate( const wxPoint& aRotCentre, double aAngle ) { // Used in footprint edition // Note also in module editor, m_Pos0 = m_Pos - RotatePoint( &m_Pos, aRotCentre, aAngle ); - SetOrientation( GetOrientation() + aAngle ); + + wxPoint pt = GetTextPos(); + RotatePoint( &pt, aRotCentre, aAngle ); + SetTextPos( pt ); + + SetTextAngle( GetTextAngle() + aAngle ); SetLocalCoord(); } @@ -96,10 +106,12 @@ void TEXTE_MODULE::Rotate( const wxPoint& aRotCentre, double aAngle ) void TEXTE_MODULE::Flip( const wxPoint& aCentre ) { // flipping the footprint is relative to the X axis - MIRROR( m_Pos.y, aCentre.y ); - NEGATE_AND_NORMALIZE_ANGLE_POS( m_Orient ); + SetTextY( ::Mirror( GetTextPos().y, aCentre.y ) ); + + SetTextAngle( -GetTextAngle() ); + SetLayer( FlipLayer( GetLayer() ) ); - m_Mirror = IsBackLayer( GetLayer() ); + SetMirrored( IsBackLayer( GetLayer() ) ); SetLocalCoord(); } @@ -110,18 +122,17 @@ void TEXTE_MODULE::Mirror( const wxPoint& aCentre, bool aMirrorAroundXAxis ) // the mirror is around the Y axis or X axis if aMirrorAroundXAxis = true // the position is mirrored, but the text itself is not mirrored if( aMirrorAroundXAxis ) - MIRROR( m_Pos.y, aCentre.y ); + SetTextY( ::Mirror( GetTextPos().y, aCentre.y ) ); else - MIRROR( m_Pos.x, aCentre.x ); + SetTextX( ::Mirror( GetTextPos().x, aCentre.x ) ); - NEGATE_AND_NORMALIZE_ANGLE_POS( m_Orient ); SetLocalCoord(); } void TEXTE_MODULE::Move( const wxPoint& aMoveVector ) { - m_Pos += aMoveVector; + Offset( aMoveVector ); SetLocalCoord(); } @@ -136,14 +147,17 @@ void TEXTE_MODULE::SetDrawCoord() { const MODULE* module = static_cast( m_Parent ); - m_Pos = m_Pos0; + SetTextPos( m_Pos0 ); if( module ) { double angle = module->GetOrientation(); - RotatePoint( &m_Pos.x, &m_Pos.y, angle ); - m_Pos += module->GetPosition(); + wxPoint pt = GetTextPos(); + RotatePoint( &pt, angle ); + SetTextPos( pt ); + + Offset( module->GetPosition() ); } } @@ -154,13 +168,15 @@ void TEXTE_MODULE::SetLocalCoord() if( module ) { - m_Pos0 = m_Pos - module->GetPosition(); + m_Pos0 = GetTextPos() - module->GetPosition(); + double angle = module->GetOrientation(); + RotatePoint( &m_Pos0.x, &m_Pos0.y, -angle ); } else { - m_Pos0 = m_Pos; + m_Pos0 = GetTextPos(); } } @@ -174,7 +190,7 @@ bool TEXTE_MODULE::HitTest( const wxPoint& aPosition ) const * is relative to an horizontal text) */ rel_pos = aPosition; - RotatePoint( &rel_pos, m_Pos, -GetDrawRotation() ); + RotatePoint( &rel_pos, GetTextPos(), -GetDrawRotation() ); if( area.Contains( rel_pos ) ) return true; @@ -189,7 +205,7 @@ const EDA_RECT TEXTE_MODULE::GetBoundingBox() const EDA_RECT text_area = GetTextBox( -1, -1 ); if( angle ) - text_area = text_area.GetBoundingBoxRotated( m_Pos, angle ); + text_area = text_area.GetBoundingBoxRotated( GetTextPos(), angle ); return text_area; } @@ -216,7 +232,7 @@ void TEXTE_MODULE::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMod // Invisible texts are still drawn (not plotted) in MOD_TEXT_INVISIBLE // Just because we must have to edit them (at least to make them visible) - if( m_NoShow ) + if( !IsVisible() ) { if( !brd->IsElementVisible( MOD_TEXT_INVISIBLE ) ) return; @@ -236,13 +252,13 @@ void TEXTE_MODULE::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMod } // Draw mode compensation for the width - int width = m_Thickness; + int width = GetThickness(); if( displ_opts && displ_opts->m_DisplayModTextFill == SKETCH ) width = -width; GRSetDrawMode( aDC, aDrawMode ); - wxPoint pos = m_Pos - aOffset; + wxPoint pos = GetTextPos() - aOffset; // Draw the text anchor point if( brd->IsElementVisible( ANCHOR_VISIBLE ) ) @@ -252,15 +268,16 @@ void TEXTE_MODULE::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMod } // Draw the text proper, with the right attributes - wxSize size = m_Size; + wxSize size = GetTextSize(); double orient = GetDrawRotation(); // If the text is mirrored : negate size.x (mirror / Y axis) - if( m_Mirror ) + if( IsMirrored() ) size.x = -size.x; DrawGraphicText( aPanel->GetClipBox(), aDC, pos, color, GetShownText(), orient, - size, m_HJustify, m_VJustify, width, m_Italic, m_Bold ); + size, GetHorizJustify(), GetVertJustify(), + width, IsItalic(), IsBold() ); // Enable these line to draw the bounding box (debug test purpose only) #if 0 @@ -284,7 +301,7 @@ void TEXTE_MODULE::DrawUmbilical( EDA_DRAW_PANEL* aPanel, GRSetDrawMode( aDC, GR_XOR ); GRLine( aPanel->GetClipBox(), aDC, - parent->GetPosition(), GetTextPosition() + aOffset, + parent->GetPosition(), GetTextPos() + aOffset, 0, UMBILICAL_COLOR); } @@ -292,7 +309,7 @@ void TEXTE_MODULE::DrawUmbilical( EDA_DRAW_PANEL* aPanel, double TEXTE_MODULE::GetDrawRotation() const { MODULE* module = (MODULE*) m_Parent; - double rotation = m_Orient; + double rotation = GetTextAngle(); if( module ) rotation += module->GetOrientation(); @@ -332,7 +349,7 @@ void TEXTE_MODULE::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) wxASSERT( m_Type >= TEXT_is_REFERENCE && m_Type <= TEXT_is_DIVERS ); aList.push_back( MSG_PANEL_ITEM( _( "Type" ), text_type_msg[m_Type], DARKGREEN ) ); - if( m_NoShow ) + if( !IsVisible() ) msg = _( "No" ); else msg = _( "Yes" ); @@ -342,23 +359,23 @@ void TEXTE_MODULE::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) // Display text layer aList.push_back( MSG_PANEL_ITEM( _( "Layer" ), GetLayerName(), DARKGREEN ) ); - if( m_Mirror ) + if( IsMirrored() ) msg = _( " Yes" ); else msg = _( " No" ); aList.push_back( MSG_PANEL_ITEM( _( "Mirror" ), msg, DARKGREEN ) ); - msg.Printf( wxT( "%.1f" ), GetOrientationDegrees() ); + msg.Printf( wxT( "%.1f" ), GetTextAngleDegrees() ); aList.push_back( MSG_PANEL_ITEM( _( "Angle" ), msg, DARKGREEN ) ); - msg = ::CoordinateToString( m_Thickness ); + msg = ::CoordinateToString( GetThickness() ); aList.push_back( MSG_PANEL_ITEM( _( "Thickness" ), msg, DARKGREEN ) ); - msg = ::CoordinateToString( m_Size.x ); + msg = ::CoordinateToString( GetTextWidth() ); aList.push_back( MSG_PANEL_ITEM( _( "Width" ), msg, RED ) ); - msg = ::CoordinateToString( m_Size.y ); + msg = ::CoordinateToString( GetTextHeight() ); aList.push_back( MSG_PANEL_ITEM( _( "Height" ), msg, RED ) ); } @@ -400,7 +417,7 @@ const BOX2I TEXTE_MODULE::ViewBBox() const EDA_RECT text_area = GetTextBox( -1, -1 ); if( angle ) - text_area = text_area.GetBoundingBoxRotated( m_Pos, angle ); + text_area = text_area.GetBoundingBoxRotated( GetTextPos(), angle ); return BOX2I( text_area.GetPosition(), text_area.GetSize() ); } @@ -408,7 +425,7 @@ const BOX2I TEXTE_MODULE::ViewBBox() const void TEXTE_MODULE::ViewGetLayers( int aLayers[], int& aCount ) const { - if( m_NoShow ) // Hidden text + if( !IsVisible() ) // Hidden text aLayers[0] = ITEM_GAL_LAYER( MOD_TEXT_INVISIBLE ); //else if( IsFrontLayer( m_Layer ) ) //aLayers[0] = ITEM_GAL_LAYER( MOD_TEXT_FR_VISIBLE ); diff --git a/pcbnew/class_text_mod.h b/pcbnew/class_text_mod.h index 76d56fb541..535f2730be 100644 --- a/pcbnew/class_text_mod.h +++ b/pcbnew/class_text_mod.h @@ -76,15 +76,17 @@ public: virtual const wxPoint& GetPosition() const override { - return m_Pos; + return EDA_TEXT::GetTextPos(); } virtual void SetPosition( const wxPoint& aPos ) override { - m_Pos = aPos; + EDA_TEXT::SetTextPos( aPos ); SetLocalCoord(); } + void SetTextAngle( double aAngle ); + /// Rotate text, in footprint editor /// (for instance in footprint rotation transform) void Rotate( const wxPoint& aOffset, double aAngle ) override; @@ -106,8 +108,28 @@ public: void SetType( TEXT_TYPE aType ) { m_Type = aType; } TEXT_TYPE GetType() const { return m_Type; } - void SetVisible( bool isVisible ) { m_NoShow = !isVisible; } - bool IsVisible() const { return !m_NoShow; } + /** + * Function SetEffects + * sets the text effects from another instance. + */ + void SetEffects( const TEXTE_MODULE& aSrc ) + { + EDA_TEXT::SetEffects( aSrc ); + SetLocalCoord(); + // SetType( aSrc.GetType() ); + } + + /** + * Function SwapEffects + * swaps the text effects of the two involved instances. + */ + void SwapEffects( TEXTE_MODULE& aTradingPartner ) + { + EDA_TEXT::SwapEffects( aTradingPartner ); + SetLocalCoord(); + aTradingPartner.SetLocalCoord(); + // std::swap( m_Type, aTradingPartner.m_Type ); + } // The Pos0 accessors are for module-relative coordinates void SetPos0( const wxPoint& aPos ) { m_Pos0 = aPos; SetDrawCoord(); } @@ -196,10 +218,9 @@ private: */ TEXT_TYPE m_Type; ///< 0=ref, 1=val, etc. - bool m_NoShow; ///< true = invisible - wxPoint m_Pos0; ///< text coordinates relatives to the footprint anchor, orient 0. - ///< text coordinate ref point is the text centre + wxPoint m_Pos0; ///< text coordinates relative to the footprint anchor, orient 0. + ///< text coordinate ref point is the text center }; #endif // TEXT_MODULE_H_ diff --git a/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp b/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp index 30548a21a4..03a2a3e9ed 100644 --- a/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp +++ b/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp @@ -761,7 +761,7 @@ void DIALOG_MODULE_BOARD_EDITOR::OnEditReference( wxCommandEvent& event ) { wxPoint tmp = m_Parent->GetCrossHairPosition(); - m_Parent->SetCrossHairPosition( m_ReferenceCopy->GetTextPosition() ); + m_Parent->SetCrossHairPosition( m_ReferenceCopy->GetTextPos() ); m_ReferenceCopy->SetParent( m_CurrentModule ); m_Parent->InstallTextModOptionsFrame( m_ReferenceCopy, NULL ); m_Parent->SetCrossHairPosition( tmp ); @@ -773,7 +773,7 @@ void DIALOG_MODULE_BOARD_EDITOR::OnEditValue( wxCommandEvent& event ) { wxPoint tmp = m_Parent->GetCrossHairPosition(); - m_Parent->SetCrossHairPosition( m_ValueCopy->GetTextPosition() ); + m_Parent->SetCrossHairPosition( m_ValueCopy->GetTextPos() ); m_ValueCopy->SetParent( m_CurrentModule ); m_Parent->InstallTextModOptionsFrame( m_ValueCopy, NULL ); m_Parent->SetCrossHairPosition( tmp ); diff --git a/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp b/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp index 4d2bb7c448..cd8f6605a5 100644 --- a/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp +++ b/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp @@ -534,7 +534,7 @@ void DIALOG_MODULE_MODULE_EDITOR::OnOkClick( wxCommandEvent& event ) void DIALOG_MODULE_MODULE_EDITOR::OnEditReference(wxCommandEvent& event) { wxPoint tmp = m_parent->GetCrossHairPosition(); - m_parent->SetCrossHairPosition( m_referenceCopy->GetTextPosition() ); + m_parent->SetCrossHairPosition( m_referenceCopy->GetTextPos() ); m_parent->InstallTextModOptionsFrame( m_referenceCopy, NULL ); m_parent->SetCrossHairPosition( tmp ); m_ReferenceCtrl->SetValue( m_referenceCopy->GetText() ); @@ -544,7 +544,7 @@ void DIALOG_MODULE_MODULE_EDITOR::OnEditReference(wxCommandEvent& event) void DIALOG_MODULE_MODULE_EDITOR::OnEditValue(wxCommandEvent& event) { wxPoint tmp = m_parent->GetCrossHairPosition(); - m_parent->SetCrossHairPosition( m_valueCopy->GetTextPosition() ); + m_parent->SetCrossHairPosition( m_valueCopy->GetTextPos() ); m_parent->InstallTextModOptionsFrame( m_valueCopy, NULL ); m_parent->SetCrossHairPosition( tmp ); m_ValueCtrl->SetValue( m_valueCopy->GetText() ); diff --git a/pcbnew/dialogs/dialog_edit_module_text.cpp b/pcbnew/dialogs/dialog_edit_module_text.cpp index df809cbefa..ddae8a4d82 100644 --- a/pcbnew/dialogs/dialog_edit_module_text.cpp +++ b/pcbnew/dialogs/dialog_edit_module_text.cpp @@ -136,10 +136,10 @@ bool DialogEditModuleText::TransferDataToWindow() m_Style->SetSelection( m_currentText->IsItalic() ? 1 : 0 ); AddUnitSymbol( *m_SizeXTitle ); - PutValueInLocalUnits( *m_TxtSizeCtrlX, m_currentText->GetSize().x ); + PutValueInLocalUnits( *m_TxtSizeCtrlX, m_currentText->GetTextWidth() ); AddUnitSymbol( *m_SizeYTitle ); - PutValueInLocalUnits( *m_TxtSizeCtrlY, m_currentText->GetSize().y ); + PutValueInLocalUnits( *m_TxtSizeCtrlY, m_currentText->GetTextHeight() ); AddUnitSymbol( *m_PosXTitle ); PutValueInLocalUnits( *m_TxtPosCtrlX, m_currentText->GetPos0().x ); @@ -150,10 +150,10 @@ bool DialogEditModuleText::TransferDataToWindow() AddUnitSymbol( *m_WidthTitle ); PutValueInLocalUnits( *m_TxtWidthCtlr, m_currentText->GetThickness() ); - double text_orient = m_currentText->GetOrientation(); + double text_orient = m_currentText->GetTextAngle(); NORMALIZE_ANGLE_90( text_orient ); - if( (text_orient != 0) ) + if( text_orient != 0.0 ) m_Orient->SetSelection( 1 ); if( !m_currentText->IsVisible() ) @@ -244,7 +244,7 @@ bool DialogEditModuleText::TransferDataFromWindow() if( textSize.y < TEXTS_MIN_SIZE ) textSize.y = TEXTS_MIN_SIZE; - m_currentText->SetSize( textSize ); + m_currentText->SetTextSize( textSize ); int width = ValueFromString( g_UserUnit, m_TxtWidthCtlr->GetValue() ); @@ -252,7 +252,7 @@ bool DialogEditModuleText::TransferDataFromWindow() if( width <= 1 ) width = 1; - int maxthickness = Clamp_Text_PenSize(width, m_currentText->GetSize() ); + int maxthickness = Clamp_Text_PenSize(width, m_currentText->GetTextSize() ); if( width > maxthickness ) { @@ -269,24 +269,24 @@ bool DialogEditModuleText::TransferDataFromWindow() switch( m_Orient->GetSelection() ) { case 0: - m_currentText->SetOrientation( 0 ); + m_currentText->SetTextAngle( 0 ); break; case 1: - m_currentText->SetOrientation( 900 ); + m_currentText->SetTextAngle( 900 ); break; case 2: - m_currentText->SetOrientation( -900 ); + m_currentText->SetTextAngle( -900 ); break; default: custom_orientation = true; - m_currentText->SetOrientation( KiROUND( m_OrientValue * 10.0 ) ); + m_currentText->SetTextAngle( KiROUND( m_OrientValue * 10.0 ) ); break; }; - switch( int( m_currentText->GetOrientation() ) ) + switch( int( m_currentText->GetTextAngle() ) ) { case 0: m_Orient->SetSelection( 0 ); @@ -304,11 +304,11 @@ bool DialogEditModuleText::TransferDataFromWindow() default: m_Orient->SetSelection( 3 ); - m_currentText->SetOrientation( KiROUND( m_OrientValue * 10.0 ) ); + m_currentText->SetTextAngle( KiROUND( m_OrientValue * 10.0 ) ); custom_orientation = true; break; } - m_OrientValue = 10.0 * m_currentText->GetOrientation(); + m_OrientValue = 10.0 * m_currentText->GetTextAngle(); m_OrientValueCtrl->Enable( custom_orientation ); m_OrientValidator.TransferToWindow(); diff --git a/pcbnew/dialogs/dialog_global_modules_fields_edition.cpp b/pcbnew/dialogs/dialog_global_modules_fields_edition.cpp index c72c08aa01..21cca12aa6 100644 --- a/pcbnew/dialogs/dialog_global_modules_fields_edition.cpp +++ b/pcbnew/dialogs/dialog_global_modules_fields_edition.cpp @@ -162,12 +162,12 @@ void PCB_BASE_FRAME::ResetModuleTextSizes( const wxString & aFilter, bool aRef, { TEXTE_MODULE* item = &module->Reference(); - if( item->GetSize() != GetDesignSettings().m_ModuleTextSize || + if( item->GetTextSize() != GetDesignSettings().m_ModuleTextSize || item->GetThickness() != GetDesignSettings().m_ModuleTextWidth ) { commit.Modify( item ); item->SetThickness( modTextWidth ); - item->SetSize( modTextSize ); + item->SetTextSize( modTextSize ); } } @@ -175,12 +175,12 @@ void PCB_BASE_FRAME::ResetModuleTextSizes( const wxString & aFilter, bool aRef, { TEXTE_MODULE* item = &module->Value(); - if( item->GetSize() != GetDesignSettings().m_ModuleTextSize || + if( item->GetTextSize() != GetDesignSettings().m_ModuleTextSize || item->GetThickness() != GetDesignSettings().m_ModuleTextWidth ) { commit.Modify( item ); item->SetThickness( modTextWidth ); - item->SetSize( modTextSize ); + item->SetTextSize( modTextSize ); } } @@ -193,12 +193,12 @@ void PCB_BASE_FRAME::ResetModuleTextSizes( const wxString & aFilter, bool aRef, { TEXTE_MODULE* item = static_cast( boardItem ); - if( item->GetSize() != GetDesignSettings().m_ModuleTextSize + if( item->GetTextSize() != GetDesignSettings().m_ModuleTextSize || item->GetThickness() != GetDesignSettings().m_ModuleTextWidth ) { commit.Modify( item ); item->SetThickness( modTextWidth ); - item->SetSize( modTextSize ); + item->SetTextSize( modTextSize ); } } } diff --git a/pcbnew/dialogs/dialog_graphic_item_properties_for_Modedit.cpp b/pcbnew/dialogs/dialog_graphic_item_properties_for_Modedit.cpp index da5a89d352..9de5632d90 100644 --- a/pcbnew/dialogs/dialog_graphic_item_properties_for_Modedit.cpp +++ b/pcbnew/dialogs/dialog_graphic_item_properties_for_Modedit.cpp @@ -290,7 +290,7 @@ bool DIALOG_MODEDIT_FP_BODY_ITEM_PROPERTIES::Validate() // Check angle of arc. double angle; m_AngleCtrl->GetValue().ToDouble( &angle ); - NORMALIZE_ANGLE_360( angle ); + angle = NormalizeAngle360( angle ); if( angle == 0 ) { diff --git a/pcbnew/dialogs/dialog_pcb_text_properties.cpp b/pcbnew/dialogs/dialog_pcb_text_properties.cpp index 73aaf22520..65077725da 100644 --- a/pcbnew/dialogs/dialog_pcb_text_properties.cpp +++ b/pcbnew/dialogs/dialog_pcb_text_properties.cpp @@ -136,11 +136,11 @@ bool DIALOG_PCB_TEXT_PROPERTIES::TransferDataToWindow() // Fill fields with current values *m_TextContentCtrl << m_SelectedPCBText->GetText(); - PutValueInLocalUnits( *m_SizeXCtrl, m_SelectedPCBText->GetSize().x ); - PutValueInLocalUnits( *m_SizeYCtrl, m_SelectedPCBText->GetSize().y ); + PutValueInLocalUnits( *m_SizeXCtrl, m_SelectedPCBText->GetTextWidth() ); + PutValueInLocalUnits( *m_SizeYCtrl, m_SelectedPCBText->GetTextHeight() ); PutValueInLocalUnits( *m_ThicknessCtrl, m_SelectedPCBText->GetThickness() ); - PutValueInLocalUnits( *m_PositionXCtrl, m_SelectedPCBText->GetTextPosition().x ); - PutValueInLocalUnits( *m_PositionYCtrl, m_SelectedPCBText->GetTextPosition().y ); + PutValueInLocalUnits( *m_PositionXCtrl, m_SelectedPCBText->GetTextPos().x ); + PutValueInLocalUnits( *m_PositionYCtrl, m_SelectedPCBText->GetTextPos().y ); // Configure the layers list selector m_LayerSelectionCtrl->SetLayersHotkeys( false ); @@ -151,7 +151,7 @@ bool DIALOG_PCB_TEXT_PROPERTIES::TransferDataToWindow() m_LayerSelectionCtrl->Resync(); m_LayerSelectionCtrl->SetLayerSelection( m_SelectedPCBText->GetLayer() ); - m_OrientValue = m_SelectedPCBText->GetOrientation() / 10.0; + m_OrientValue = m_SelectedPCBText->GetTextAngleDegrees(); if( m_SelectedPCBText->IsMirrored() ) m_DisplayCtrl->SetSelection( 1 ); @@ -235,7 +235,7 @@ bool DIALOG_PCB_TEXT_PROPERTIES::TransferDataFromWindow() // Set PCB Text position newPosition.x = ValueFromString( g_UserUnit, m_PositionXCtrl->GetValue() ); newPosition.y = ValueFromString( g_UserUnit, m_PositionYCtrl->GetValue() ); - m_SelectedPCBText->SetTextPosition( newPosition ); + m_SelectedPCBText->SetTextPos( newPosition ); // Check constraints and set PCB Text size newSize.x = ValueFromString( g_UserUnit, m_SizeXCtrl->GetValue() ); @@ -253,7 +253,7 @@ bool DIALOG_PCB_TEXT_PROPERTIES::TransferDataFromWindow() if( newSize.y > TEXTS_MAX_WIDTH ) newSize.y = TEXTS_MAX_WIDTH; - m_SelectedPCBText->SetSize( newSize ); + m_SelectedPCBText->SetTextSize( newSize ); // Set the new thickness m_SelectedPCBText->SetThickness( ValueFromString( g_UserUnit, @@ -261,7 +261,7 @@ bool DIALOG_PCB_TEXT_PROPERTIES::TransferDataFromWindow() // Test for acceptable values for thickness and size and clamp if fails int maxthickness = Clamp_Text_PenSize( m_SelectedPCBText->GetThickness(), - m_SelectedPCBText->GetSize() ); + m_SelectedPCBText->GetTextSize() ); if( m_SelectedPCBText->GetThickness() > maxthickness ) { @@ -276,8 +276,8 @@ bool DIALOG_PCB_TEXT_PROPERTIES::TransferDataFromWindow() // Set whether the PCB text is mirrored (faced down from layer face perspective) m_SelectedPCBText->SetMirrored( m_DisplayCtrl->GetSelection() == 1 ); - // Set the text orientation - m_SelectedPCBText->SetOrientation( m_OrientValue * 10.0 ); + // Set the text angle + m_SelectedPCBText->SetTextAngle( m_OrientValue * 10.0 ); // Set whether the PCB text is slanted (it is not italics, as italics has additional curves in style) m_SelectedPCBText->SetItalic( m_StyleCtrl->GetSelection() ); diff --git a/pcbnew/dimension.cpp b/pcbnew/dimension.cpp index 28f3c91480..87255701cd 100644 --- a/pcbnew/dimension.cpp +++ b/pcbnew/dimension.cpp @@ -118,9 +118,9 @@ DIALOG_DIMENSION_EDITOR::DIALOG_DIMENSION_EDITOR( PCB_EDIT_FRAME* aParent, m_Name->SetValue( aDimension->Text().GetText() ); // Enter size value in dialog - PutValueInLocalUnits( *m_TxtSizeXCtrl, aDimension->Text().GetSize().x ); + PutValueInLocalUnits( *m_TxtSizeXCtrl, aDimension->Text().GetTextWidth() ); AddUnitSymbol( *m_staticTextSizeX ); - PutValueInLocalUnits( *m_TxtSizeYCtrl, aDimension->Text().GetSize().y ); + PutValueInLocalUnits( *m_TxtSizeYCtrl, aDimension->Text().GetTextHeight() ); AddUnitSymbol( *m_staticTextSizeY ); // Enter lines thickness value in dialog @@ -128,9 +128,9 @@ DIALOG_DIMENSION_EDITOR::DIALOG_DIMENSION_EDITOR( PCB_EDIT_FRAME* aParent, AddUnitSymbol( *m_staticTextWidth ); // Enter position value in dialog - PutValueInLocalUnits( *m_textCtrlPosX, aDimension->Text().GetTextPosition().x ); + PutValueInLocalUnits( *m_textCtrlPosX, aDimension->Text().GetTextPos().x ); AddUnitSymbol( *m_staticTextPosX ); - PutValueInLocalUnits( *m_textCtrlPosY, aDimension->Text().GetTextPosition().y ); + PutValueInLocalUnits( *m_textCtrlPosY, aDimension->Text().GetTextPos().y ); AddUnitSymbol( *m_staticTextPosY ); // Configure the layers list selector @@ -191,9 +191,9 @@ void DIALOG_DIMENSION_EDITOR::OnOKClick( wxCommandEvent& event ) // Get new size value: msg = m_TxtSizeXCtrl->GetValue(); - m_currentDimension->Text().SetWidth( ValueFromString( g_UserUnit, msg ) ); + m_currentDimension->Text().SetTextWidth( ValueFromString( g_UserUnit, msg ) ); msg = m_TxtSizeYCtrl->GetValue(); - m_currentDimension->Text().SetHeight( ValueFromString( g_UserUnit, msg ) ); + m_currentDimension->Text().SetTextHeight( ValueFromString( g_UserUnit, msg ) ); // Get new position value: // It will be copied later in dimension, because @@ -202,12 +202,12 @@ void DIALOG_DIMENSION_EDITOR::OnOKClick( wxCommandEvent& event ) pos.x = ValueFromString( g_UserUnit, msg ); msg = m_textCtrlPosY->GetValue(); pos.y = ValueFromString( g_UserUnit, msg ); - m_currentDimension->Text().SetTextPosition( pos ); + m_currentDimension->Text().SetTextPos( pos ); // Get new line thickness value: msg = m_TxtWidthCtrl->GetValue(); int width = ValueFromString( g_UserUnit, msg ); - int maxthickness = Clamp_Text_PenSize( width, m_currentDimension->Text().GetSize() ); + int maxthickness = Clamp_Text_PenSize( width, m_currentDimension->Text().GetTextSize() ); if( width > maxthickness ) { @@ -273,9 +273,9 @@ DIMENSION* PCB_EDIT_FRAME::EditDimension( DIMENSION* aDimension, wxDC* aDC ) aDimension->SetOrigin( pos ); aDimension->SetEnd( pos ); - aDimension->Text().SetSize( GetBoard()->GetDesignSettings().m_PcbTextSize ); + aDimension->Text().SetTextSize( GetBoard()->GetDesignSettings().m_PcbTextSize ); int width = GetBoard()->GetDesignSettings().m_PcbTextWidth; - int maxthickness = Clamp_Text_PenSize(width, aDimension->Text().GetSize() ); + int maxthickness = Clamp_Text_PenSize(width, aDimension->Text().GetTextSize() ); if( width > maxthickness ) { @@ -386,13 +386,13 @@ void PCB_EDIT_FRAME::BeginMoveDimensionText( DIMENSION* aItem, wxDC* DC ) return; // Store the initial position for undo/abort command - initialTextPosition = aItem->Text().GetTextPosition(); + initialTextPosition = aItem->Text().GetTextPos(); aItem->Draw( m_canvas, DC, GR_XOR ); aItem->SetFlags( IS_MOVED ); SetMsgPanel( aItem ); - SetCrossHairPosition( aItem->Text().GetTextPosition() ); + SetCrossHairPosition( aItem->Text().GetTextPos() ); m_canvas->MoveCursorToCrossHair(); m_canvas->SetMouseCapture( MoveDimensionText, AbortMoveDimensionText ); @@ -413,7 +413,7 @@ static void MoveDimensionText( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& if( aErase ) dimension->Draw( aPanel, aDC, GR_XOR ); - dimension->Text().SetTextPosition( aPanel->GetParent()->GetCrossHairPosition() ); + dimension->Text().SetTextPos( aPanel->GetParent()->GetCrossHairPosition() ); dimension->Draw( aPanel, aDC, GR_XOR ); } @@ -435,7 +435,7 @@ void AbortMoveDimensionText( EDA_DRAW_PANEL* aPanel, wxDC* aDC ) return; dimension->Draw( aPanel, aDC, GR_XOR ); - dimension->Text().SetTextPosition( initialTextPosition ); + dimension->Text().SetTextPos( initialTextPosition ); dimension->ClearFlags(); dimension->Draw( aPanel, aDC, GR_OR ); } @@ -455,9 +455,9 @@ void PCB_EDIT_FRAME::PlaceDimensionText( DIMENSION* aItem, wxDC* DC ) aItem->Draw( m_canvas, DC, GR_OR ); OnModify(); - wxPoint tmp = aItem->Text().GetTextPosition(); - aItem->Text().SetTextPosition( initialTextPosition ); + wxPoint tmp = aItem->Text().GetTextPos(); + aItem->Text().SetTextPos( initialTextPosition ); SaveCopyInUndoList( aItem, UR_CHANGED ); - aItem->Text().SetTextPosition( tmp ); + aItem->Text().SetTextPos( tmp ); aItem->ClearFlags(); } diff --git a/pcbnew/eagle_plugin.cpp b/pcbnew/eagle_plugin.cpp index 3c26df49f9..3913f29a25 100644 --- a/pcbnew/eagle_plugin.cpp +++ b/pcbnew/eagle_plugin.cpp @@ -1491,9 +1491,9 @@ void EAGLE_PLUGIN::loadPlain( CPTREE& aGraphics ) pcbtxt->SetLayer( layer ); pcbtxt->SetTimeStamp( timeStamp( gr->second ) ); pcbtxt->SetText( FROM_UTF8( t.text.c_str() ) ); - pcbtxt->SetTextPosition( wxPoint( kicad_x( t.x ), kicad_y( t.y ) ) ); + pcbtxt->SetTextPos( wxPoint( kicad_x( t.x ), kicad_y( t.y ) ) ); - pcbtxt->SetSize( kicad_fontz( t.size ) ); + pcbtxt->SetTextSize( kicad_fontz( t.size ) ); double ratio = t.ratio ? *t.ratio : 8; // DTD says 8 is default @@ -1509,12 +1509,12 @@ void EAGLE_PLUGIN::loadPlain( CPTREE& aGraphics ) double degrees = t.rot->degrees; if( degrees == 90 || t.rot->spin ) - pcbtxt->SetOrientation( sign * t.rot->degrees * 10 ); + pcbtxt->SetTextAngle( sign * t.rot->degrees * 10 ); else if( degrees == 180 ) align = ETEXT::TOP_RIGHT; else if( degrees == 270 ) { - pcbtxt->SetOrientation( sign * 90 * 10 ); + pcbtxt->SetTextAngle( sign * 90 * 10 ); align = ETEXT::TOP_RIGHT; } } @@ -1681,10 +1681,10 @@ void EAGLE_PLUGIN::loadPlain( CPTREE& aGraphics ) // The origin and end are assumed to always be in this order from eagle dimension->SetOrigin( wxPoint( kicad_x( d.x1 ), kicad_y( d.y1 ) ) ); dimension->SetEnd( wxPoint( kicad_x( d.x2 ), kicad_y( d.y2 ) ) ); - dimension->Text().SetSize( m_board->GetDesignSettings().m_PcbTextSize ); + dimension->Text().SetTextSize( m_board->GetDesignSettings().m_PcbTextSize ); int width = m_board->GetDesignSettings().m_PcbTextWidth; - int maxThickness = Clamp_Text_PenSize( width, dimension->Text().GetSize() ); + int maxThickness = Clamp_Text_PenSize( width, dimension->Text().GetTextSize() ); if( width > maxThickness ) width = maxThickness; @@ -2031,18 +2031,18 @@ void EAGLE_PLUGIN::orientModuleText( MODULE* m, const EELEMENT& e, if( a.x && a.y ) // boost::optional { wxPoint pos( kicad_x( *a.x ), kicad_y( *a.y ) ); - txt->SetTextPosition( pos ); + txt->SetTextPos( pos ); } // Even though size and ratio are both optional, I am not seeing // a case where ratio is present but size is not. double ratio = 8; - wxSize fontz = txt->GetSize(); + wxSize fontz = txt->GetTextSize(); if( a.size ) { fontz = kicad_fontz( *a.size ); - txt->SetSize( fontz ); + txt->SetTextSize( fontz ); if( a.ratio ) ratio = *a.ratio; @@ -2073,24 +2073,24 @@ void EAGLE_PLUGIN::orientModuleText( MODULE* m, const EELEMENT& e, if( degrees == 90 || degrees == 0 || spin ) { orient = degrees - m->GetOrientation() / 10; - txt->SetOrientation( sign * orient * 10 ); + txt->SetTextAngle( sign * orient * 10 ); } else if( degrees == 180 ) { orient = 0 - m->GetOrientation() / 10; - txt->SetOrientation( sign * orient * 10 ); + txt->SetTextAngle( sign * orient * 10 ); align = ETEXT::TOP_RIGHT; } else if( degrees == 270 ) { orient = 90 - m->GetOrientation() / 10; align = ETEXT::TOP_RIGHT; - txt->SetOrientation( sign * orient * 10 ); + txt->SetTextAngle( sign * orient * 10 ); } else { orient = 90 - degrees - m->GetOrientation() / 10; - txt->SetOrientation( sign * orient * 10 ); + txt->SetTextAngle( sign * orient * 10 ); } switch( align ) @@ -2111,7 +2111,7 @@ void EAGLE_PLUGIN::orientModuleText( MODULE* m, const EELEMENT& e, } else // Part is not smash so use Lib default for NAME/VALUE // the text is per the original package, sans { - double degrees = ( txt->GetOrientation() + m->GetOrientation() ) / 10; + double degrees = ( txt->GetTextAngle() + m->GetOrientation() ) / 10; // @todo there are a few more cases than these to contend with: if( (!txt->IsMirrored() && ( abs( degrees ) == 180 || abs( degrees ) == 270 )) @@ -2322,12 +2322,11 @@ void EAGLE_PLUGIN::packageText( MODULE* aModule, CPTREE& aTree ) const wxPoint pos( kicad_x( t.x ), kicad_y( t.y ) ); - txt->SetTextPosition( pos ); + txt->SetTextPos( pos ); txt->SetPos0( pos - aModule->GetPosition() ); txt->SetLayer( layer ); - - txt->SetSize( kicad_fontz( t.size ) ); + txt->SetTextSize( kicad_fontz( t.size ) ); double ratio = t.ratio ? *t.ratio : 8; // DTD says 8 is default @@ -2346,13 +2345,13 @@ void EAGLE_PLUGIN::packageText( MODULE* aModule, CPTREE& aTree ) const double degrees = t.rot->degrees; if( degrees == 90 || t.rot->spin ) - txt->SetOrientation( sign * degrees * 10 ); + txt->SetTextAngle( sign * degrees * 10 ); else if( degrees == 180 ) align = ETEXT::TOP_RIGHT; else if( degrees == 270 ) { align = ETEXT::TOP_RIGHT; - txt->SetOrientation( sign * 90 * 10 ); + txt->SetTextAngle( sign * 90 * 10 ); } } diff --git a/pcbnew/edit_pcb_text.cpp b/pcbnew/edit_pcb_text.cpp index c9c11e5e7e..c12e608e0d 100644 --- a/pcbnew/edit_pcb_text.cpp +++ b/pcbnew/edit_pcb_text.cpp @@ -110,7 +110,7 @@ void PCB_EDIT_FRAME::Place_Texte_Pcb( TEXTE_PCB* TextePcb, wxDC* DC ) if( TextePcb->IsMoving() ) // If moved only { SaveCopyInUndoList( TextePcb, UR_MOVED, - TextePcb->GetTextPosition() - s_TextCopy.GetTextPosition() ); + TextePcb->GetTextPos() - s_TextCopy.GetTextPos() ); } else { @@ -145,7 +145,7 @@ void PCB_EDIT_FRAME::StartMoveTextePcb( TEXTE_PCB* aTextePcb, wxDC* aDC, bool aE m_canvas->Refresh(); #endif - SetCrossHairPosition( aTextePcb->GetTextPosition() ); + SetCrossHairPosition( aTextePcb->GetTextPos() ); m_canvas->MoveCursorToCrossHair(); m_canvas->SetMouseCapture( Move_Texte_Pcb, Abort_Edit_Pcb_Text ); @@ -166,7 +166,7 @@ static void Move_Texte_Pcb( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aP if( aErase ) TextePcb->Draw( aPanel, aDC, GR_XOR ); - TextePcb->SetTextPosition( aPanel->GetParent()->GetCrossHairPosition() ); + TextePcb->SetTextPos( aPanel->GetParent()->GetCrossHairPosition() ); TextePcb->Draw( aPanel, aDC, GR_XOR ); } @@ -214,8 +214,8 @@ TEXTE_PCB* PCB_EDIT_FRAME::CreateTextePcb( wxDC* aDC, TEXTE_PCB* aText ) ) textePcb->SetMirrored( true ); - textePcb->SetSize( GetBoard()->GetDesignSettings().m_PcbTextSize ); - textePcb->SetTextPosition( GetCrossHairPosition() ); + textePcb->SetTextSize( GetBoard()->GetDesignSettings().m_PcbTextSize ); + textePcb->SetTextPos( GetCrossHairPosition() ); textePcb->SetThickness( GetBoard()->GetDesignSettings().m_PcbTextWidth ); InstallTextPCBOptionsFrame( textePcb, aDC ); @@ -243,14 +243,14 @@ void PCB_EDIT_FRAME::Rotate_Texte_Pcb( TEXTE_PCB* TextePcb, wxDC* DC ) // Erase previous text: TextePcb->Draw( m_canvas, DC, GR_XOR ); - TextePcb->SetOrientation( TextePcb->GetOrientation() + 900 ); + TextePcb->SetTextAngle( TextePcb->GetTextAngle() + 900 ); // Redraw text in new position: TextePcb->Draw( m_canvas, DC, GR_XOR ); SetMsgPanel( TextePcb ); if( TextePcb->GetFlags() == 0 ) // i.e. not edited, or moved - SaveCopyInUndoList( TextePcb, UR_ROTATED, TextePcb->GetTextPosition() ); + SaveCopyInUndoList( TextePcb, UR_ROTATED, TextePcb->GetTextPos() ); else // set flag edit, to show it was a complex command TextePcb->SetFlags( IN_EDIT ); @@ -268,13 +268,13 @@ void PCB_EDIT_FRAME::FlipTextePcb( TEXTE_PCB* aTextePcb, wxDC* aDC ) aTextePcb->Draw( m_canvas, aDC, GR_XOR ); - aTextePcb->Flip( aTextePcb->GetTextPosition() ); + aTextePcb->Flip( aTextePcb->GetTextPos() ); aTextePcb->Draw( m_canvas, aDC, GR_XOR ); SetMsgPanel( aTextePcb ); if( aTextePcb->GetFlags() == 0 ) // i.e. not edited, or moved - SaveCopyInUndoList( aTextePcb, UR_FLIPPED, aTextePcb->GetTextPosition() ); + SaveCopyInUndoList( aTextePcb, UR_FLIPPED, aTextePcb->GetTextPos() ); else // set edit flag, for the current command aTextePcb->SetFlags( IN_EDIT ); diff --git a/pcbnew/edtxtmod.cpp b/pcbnew/edtxtmod.cpp index 07372bf50e..3437c26538 100644 --- a/pcbnew/edtxtmod.cpp +++ b/pcbnew/edtxtmod.cpp @@ -71,7 +71,7 @@ TEXTE_MODULE* FOOTPRINT_EDIT_FRAME::CreateTextModule( MODULE* aModule, wxDC* aDC GetDesignSettings().m_ModuleTextWidth = Clamp_Text_PenSize( GetDesignSettings().m_ModuleTextWidth, std::min( GetDesignSettings().m_ModuleTextSize.x, GetDesignSettings().m_ModuleTextSize.y ), true ); - text->SetSize( GetDesignSettings().m_ModuleTextSize ); + text->SetTextSize( GetDesignSettings().m_ModuleTextSize ); text->SetThickness( GetDesignSettings().m_ModuleTextWidth ); text->SetPosition( GetCrossHairPosition() ); @@ -121,7 +121,7 @@ void PCB_BASE_FRAME::RotateTextModule( TEXTE_MODULE* Text, wxDC* DC ) // we expect MoveVector to be (0,0) if there is no move in progress Text->Draw( m_canvas, DC, GR_XOR, MoveVector ); - Text->SetOrientation( Text->GetOrientation() + 900 ); + Text->SetTextAngle( Text->GetTextAngle() + 900 ); Text->Draw( m_canvas, DC, GR_XOR, MoveVector ); SetMsgPanel( Text ); @@ -179,7 +179,7 @@ static void AbortMoveTextModule( EDA_DRAW_PANEL* Panel, wxDC* DC ) // If the text was moved (the move does not change internal data) // it could be rotated while moving. So set old value for orientation if( Text->IsMoving() ) - Text->SetOrientation( TextInitialOrientation ); + Text->SetTextAngle( TextInitialOrientation ); // Redraw the text Panel->RefreshDrawingRect( Text->GetBoundingBox() ); @@ -208,8 +208,8 @@ void PCB_BASE_FRAME::StartMoveTexteModule( TEXTE_MODULE* Text, wxDC* DC ) MoveVector.x = MoveVector.y = 0; - TextInitialPosition = Text->GetTextPosition(); - TextInitialOrientation = Text->GetOrientation(); + TextInitialPosition = Text->GetTextPos(); + TextInitialOrientation = Text->GetTextAngle(); // Center cursor on initial position of text SetCrossHairPosition( TextInitialPosition ); @@ -237,19 +237,19 @@ void PCB_BASE_FRAME::PlaceTexteModule( TEXTE_MODULE* Text, wxDC* DC ) if( Module ) { // Prepare undo command (a rotation can be made while moving) - double tmp = Text->GetOrientation(); - Text->SetOrientation( TextInitialOrientation ); + double tmp = Text->GetTextAngle(); + Text->SetTextAngle( TextInitialOrientation ); if( IsType( FRAME_PCB ) ) SaveCopyInUndoList( Module, UR_CHANGED ); else SaveCopyInUndoList( Module, UR_CHANGED ); - Text->SetOrientation( tmp ); + Text->SetTextAngle( tmp ); // Set the new position for text. - Text->SetTextPosition( GetCrossHairPosition() ); - wxPoint textRelPos = Text->GetTextPosition() - Module->GetPosition(); + Text->SetTextPos( GetCrossHairPosition() ); + wxPoint textRelPos = Text->GetTextPos() - Module->GetPosition(); RotatePoint( &textRelPos, -Module->GetOrientation() ); Text->SetPos0( textRelPos ); Text->ClearFlags(); @@ -262,7 +262,7 @@ void PCB_BASE_FRAME::PlaceTexteModule( TEXTE_MODULE* Text, wxDC* DC ) } else { - Text->SetTextPosition( GetCrossHairPosition() ); + Text->SetTextPos( GetCrossHairPosition() ); } } @@ -311,11 +311,11 @@ void PCB_BASE_FRAME::ResetTextSize( BOARD_ITEM* aItem, wxDC* aDC ) TEXTE_PCB* text = static_cast( aItem ); // Exit if there's nothing to do - if( text->GetSize() == newSize && text->GetThickness() == newThickness ) + if( text->GetTextSize() == newSize && text->GetThickness() == newThickness ) return; SaveCopyInUndoList( text, UR_CHANGED ); - text->SetSize( newSize ); + text->SetTextSize( newSize ); text->SetThickness( newThickness ); } @@ -326,11 +326,11 @@ void PCB_BASE_FRAME::ResetTextSize( BOARD_ITEM* aItem, wxDC* aDC ) TEXTE_MODULE* text = static_cast( aItem ); // Exit if there's nothing to do - if( text->GetSize() == newSize && text->GetThickness() == newThickness ) + if( text->GetTextSize() == newSize && text->GetThickness() == newThickness ) return; SaveCopyInUndoList( text->GetParent(), UR_CHANGED ); - text->SetSize( newSize ); + text->SetTextSize( newSize ); text->SetThickness( newThickness ); } else diff --git a/pcbnew/exporters/export_gencad.cpp b/pcbnew/exporters/export_gencad.cpp index 0ffa023877..1276864068 100644 --- a/pcbnew/exporters/export_gencad.cpp +++ b/pcbnew/exporters/export_gencad.cpp @@ -733,13 +733,13 @@ static void CreateComponentsSection( FILE* aFile, BOARD* aPcb ) for( int ii = 0; ii < 2; ii++ ) { - double txt_orient = textmod->GetOrientation(); + double txt_orient = textmod->GetTextAngle(); std::string layer = GenCADLayerName( cu_count, module->GetFlag() ? B_SilkS : F_SilkS ); fprintf( aFile, "TEXT %g %g %g %g %s %s \"%s\"", textmod->GetPos0().x / SCALE_FACTOR, -textmod->GetPos0().y / SCALE_FACTOR, - textmod->GetSize().x / SCALE_FACTOR, + textmod->GetTextWidth() / SCALE_FACTOR, txt_orient / 10.0, mirror, layer.c_str(), @@ -747,8 +747,8 @@ static void CreateComponentsSection( FILE* aFile, BOARD* aPcb ) // Please note, the width is approx fprintf( aFile, " 0 0 %g %g\n", - ( textmod->GetSize().x * textmod->GetLength() ) / SCALE_FACTOR, - textmod->GetSize().y / SCALE_FACTOR ); + ( textmod->GetTextWidth() * textmod->GetLength() ) / SCALE_FACTOR, + textmod->GetTextHeight() / SCALE_FACTOR ); textmod = &module->Value(); // Dirty trick for the second iteration } diff --git a/pcbnew/exporters/export_vrml.cpp b/pcbnew/exporters/export_vrml.cpp index 0eb692617a..5793b34e9c 100644 --- a/pcbnew/exporters/export_vrml.cpp +++ b/pcbnew/exporters/export_vrml.cpp @@ -729,7 +729,7 @@ 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->GetSize(); + wxSize size = text->GetTextSize(); if( text->IsMirrored() ) size.x = -size.x; @@ -748,7 +748,7 @@ static void export_vrml_pcbtext( MODEL_VRML& aModel, TEXTE_PCB* text ) { wxString& txt = strings_list.Item( ii ); DrawGraphicText( NULL, NULL, positions[ii], color, - txt, text->GetOrientation(), size, + txt, text->GetTextAngle(), size, text->GetHorizJustify(), text->GetVertJustify(), text->GetThickness(), text->IsItalic(), true, @@ -757,8 +757,8 @@ static void export_vrml_pcbtext( MODEL_VRML& aModel, TEXTE_PCB* text ) } else { - DrawGraphicText( NULL, NULL, text->GetTextPosition(), color, - text->GetShownText(), text->GetOrientation(), size, + DrawGraphicText( NULL, NULL, text->GetTextPos(), color, + text->GetShownText(), text->GetTextAngle(), size, text->GetHorizJustify(), text->GetVertJustify(), text->GetThickness(), text->IsItalic(), true, @@ -983,7 +983,7 @@ static void export_vrml_text_module( TEXTE_MODULE* module ) { if( module->IsVisible() ) { - wxSize size = module->GetSize(); + wxSize size = module->GetTextSize(); if( module->IsMirrored() ) size.x = -size.x; // Text is mirrored @@ -991,7 +991,7 @@ static void export_vrml_text_module( TEXTE_MODULE* module ) model_vrml->m_text_layer = module->GetLayer(); model_vrml->m_text_width = module->GetThickness(); - DrawGraphicText( NULL, NULL, module->GetTextPosition(), BLACK, + DrawGraphicText( NULL, NULL, module->GetTextPos(), BLACK, module->GetShownText(), module->GetDrawRotation(), size, module->GetHorizJustify(), module->GetVertJustify(), module->GetThickness(), module->IsItalic(), diff --git a/pcbnew/gpcb_plugin.cpp b/pcbnew/gpcb_plugin.cpp index 6e620c6061..e4c092b9f8 100644 --- a/pcbnew/gpcb_plugin.cpp +++ b/pcbnew/gpcb_plugin.cpp @@ -480,7 +480,7 @@ MODULE* GPCB_FPL_CACHE::parseMODULE( LINE_READER* aLineReader ) throw( IO_ERROR, } int orientation = parseInt( parameters[paramCnt-4], 1.0 ); - module->Reference().SetOrientation( (orientation % 2) ? 900 : 0 ); + module->Reference().SetTextAngle( (orientation % 2) ? 900 : 0 ); // Calculate size: default height is 40 mils, width 30 mil. // real size is: default * ibuf[idx+3] / 100 (size in gpcb is given in percent of default size @@ -500,19 +500,19 @@ MODULE* GPCB_FPL_CACHE::parseMODULE( LINE_READER* aLineReader ) throw( IO_ERROR, textPos.x -= thsize / 10; textPos.y += thsize / 2; - module->Reference().SetTextPosition( textPos ); + module->Reference().SetTextPos( textPos ); module->Reference().SetPos0( textPos ); - module->Reference().SetSize( wxSize( twsize, thsize ) ); + module->Reference().SetTextSize( wxSize( twsize, thsize ) ); module->Reference().SetThickness( 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().SetOrientation( module->Reference().GetOrientation() ); - module->Value().SetSize( module->Reference().GetSize() ); + module->Value().SetTextAngle( module->Reference().GetTextAngle() ); + module->Value().SetTextSize( module->Reference().GetTextSize() ); module->Value().SetThickness( module->Reference().GetThickness() ); textPos.y += thsize * 13 / 10; // 130% line height - module->Value().SetTextPosition( textPos ); + module->Value().SetTextPos( textPos ); module->Value().SetPos0( textPos ); while( aLineReader->ReadLine() ) diff --git a/pcbnew/import_dxf/dxf2brd_items.cpp b/pcbnew/import_dxf/dxf2brd_items.cpp index 97004a77f1..dfd8272c98 100644 --- a/pcbnew/import_dxf/dxf2brd_items.cpp +++ b/pcbnew/import_dxf/dxf2brd_items.cpp @@ -378,12 +378,12 @@ void DXF2BRD_CONVERTER::addText( const DRW_Text& aData ) wxString text = toNativeString( wxString::FromUTF8( aData.text.c_str() ) ); - textItem->SetTextPosition( refPoint ); - textItem->SetOrientation( aData.angle * 10 ); + textItem->SetTextPos( refPoint ); + textItem->SetTextAngle( aData.angle * 10 ); // The 0.8 factor gives a better height/width ratio with our font - textItem->SetWidth( mapDim( aData.height * 0.8 ) ); - textItem->SetHeight( mapDim( aData.height ) ); + textItem->SetTextWidth( mapDim( aData.height * 0.8 ) ); + textItem->SetTextHeight( mapDim( aData.height ) ); textItem->SetThickness( mapDim( aData.thickness == 0 ? m_defaultThickness : aData.thickness ) ); textItem->SetText( text ); @@ -440,12 +440,12 @@ void DXF2BRD_CONVERTER::addMText( const DRW_MText& aData ) brdItem->SetLayer( ToLAYER_ID( m_brdLayer ) ); wxPoint textpos( mapX( aData.basePoint.x ), mapY( aData.basePoint.y ) ); - textItem->SetTextPosition( textpos ); - textItem->SetOrientation( aData.angle * 10 ); + textItem->SetTextPos( textpos ); + textItem->SetTextAngle( aData.angle * 10 ); // The 0.8 factor gives a better height/width ratio with our font - textItem->SetWidth( mapDim( aData.height * 0.8 ) ); - textItem->SetHeight( mapDim( aData.height ) ); + textItem->SetTextWidth( mapDim( aData.height * 0.8 ) ); + textItem->SetTextHeight( mapDim( aData.height ) ); textItem->SetThickness( mapDim( aData.thickness == 0 ? m_defaultThickness : aData.thickness ) ); textItem->SetText( text ); diff --git a/pcbnew/kicad_plugin.cpp b/pcbnew/kicad_plugin.cpp index 8df1655603..ca0bde29ed 100644 --- a/pcbnew/kicad_plugin.cpp +++ b/pcbnew/kicad_plugin.cpp @@ -1355,10 +1355,10 @@ void PCB_IO::format( TEXTE_PCB* aText, int aNestLevel ) const { m_out->Print( aNestLevel, "(gr_text %s (at %s", m_out->Quotew( aText->GetText() ).c_str(), - FMT_IU( aText->GetTextPosition() ).c_str() ); + FMT_IU( aText->GetTextPos() ).c_str() ); - if( aText->GetOrientation() != 0.0 ) - m_out->Print( 0, " %s", FMT_ANGLE( aText->GetOrientation() ).c_str() ); + if( aText->GetTextAngle() != 0.0 ) + m_out->Print( 0, " %s", FMT_ANGLE( aText->GetTextAngle() ).c_str() ); m_out->Print( 0, ")" ); @@ -1378,27 +1378,44 @@ void PCB_IO::format( TEXTE_PCB* aText, int aNestLevel ) const void PCB_IO::format( TEXTE_MODULE* aText, int aNestLevel ) const throw( IO_ERROR ) { - MODULE* parent = (MODULE*) aText->GetParent(); - double orient = aText->GetOrientation(); wxString type; switch( aText->GetType() ) { - case TEXTE_MODULE::TEXT_is_REFERENCE: type = wxT( "reference" ); break; - case TEXTE_MODULE::TEXT_is_VALUE: type = wxT( "value" ); break; - case TEXTE_MODULE::TEXT_is_DIVERS: type = wxT( "user" ); + case TEXTE_MODULE::TEXT_is_REFERENCE: type = "reference"; break; + case TEXTE_MODULE::TEXT_is_VALUE: type = "value"; break; + case TEXTE_MODULE::TEXT_is_DIVERS: type = "user"; } - // Due to the Pcbnew history, m_Orient is saved in screen value - // but it is handled as relative to its parent footprint - if( parent ) - orient += parent->GetOrientation(); - m_out->Print( aNestLevel, "(fp_text %s %s (at %s", m_out->Quotew( type ).c_str(), m_out->Quotew( aText->GetText() ).c_str(), FMT_IU( aText->GetPos0() ).c_str() ); + // 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(); + MODULE* parent = (MODULE*) aText->GetParent(); + + if( parent ) + { + // GetTextAngle() is always in -360..+360 range because of + // TEXTE_MODULE::SetTextAngle(), but summing that angle with an + // additional board angle could kick sum up >= 360 or <= -360, so to have + // consistent results, normalize again for the BOARD save. A footprint + // save does not use this code path since parent is NULL. +#if 0 + // This one could be considered reasonable if you like positive angles + // in your board text. + orient = NormalizeAnglePos( orient + parent->GetOrientation() ); +#else + // Choose compatibility for now, even though this is only a 720 degree clamp + // with two possible values for every angle. + orient = NormalizeAngle360( orient + parent->GetOrientation() ); +#endif + } + if( orient != 0.0 ) m_out->Print( 0, " %s", FMT_ANGLE( orient ).c_str() ); diff --git a/pcbnew/legacy_plugin.cpp b/pcbnew/legacy_plugin.cpp index fe58d6089c..21026b155d 100644 --- a/pcbnew/legacy_plugin.cpp +++ b/pcbnew/legacy_plugin.cpp @@ -1832,11 +1832,11 @@ void LEGACY_PLUGIN::loadMODULE_TEXT( TEXTE_MODULE* aText ) aText->SetType( static_cast( type ) ); aText->SetPos0( wxPoint( pos0_x, pos0_y ) ); - aText->SetSize( wxSize( size0_x, size0_y ) ); + aText->SetTextSize( wxSize( size0_x, size0_y ) ); orient -= ( static_cast( aText->GetParent() ) )->GetOrientation(); - aText->SetOrientation( orient ); + aText->SetTextAngle( orient ); // @todo put in accessors? // Set a reasonable width: @@ -2174,7 +2174,7 @@ void LEGACY_PLUGIN::loadPCB_TEXT() sz.y = 5; */ - pcbtxt->SetSize( size ); + pcbtxt->SetTextSize( size ); /* @todo move into an accessor // Set a reasonable width: @@ -2185,9 +2185,9 @@ void LEGACY_PLUGIN::loadPCB_TEXT() */ pcbtxt->SetThickness( thickn ); - pcbtxt->SetOrientation( angle ); + pcbtxt->SetTextAngle( angle ); - pcbtxt->SetTextPosition( wxPoint( pos_x, pos_y ) ); + pcbtxt->SetTextPos( wxPoint( pos_x, pos_y ) ); } else if( TESTLINE( "De" ) ) @@ -2823,7 +2823,7 @@ void LEGACY_PLUGIN::loadDIMENSION() dim->Text().SetMirrored( mirror && *mirror == '0' ); dim->Text().SetThickness( thickn ); - dim->Text().SetOrientation( orient ); + dim->Text().SetTextAngle( orient ); } else if( TESTLINE( "Sb" ) ) diff --git a/pcbnew/librairi.cpp b/pcbnew/librairi.cpp index 869dfcdfce..9549d36826 100644 --- a/pcbnew/librairi.cpp +++ b/pcbnew/librairi.cpp @@ -791,7 +791,7 @@ MODULE* PCB_BASE_FRAME::CreateNewModule( const wxString& aModuleName ) module->SetReference( settings.m_RefDefaultText ); module->Reference().SetThickness( settings.m_ModuleTextWidth ); - module->Reference().SetSize( settings.m_ModuleTextSize ); + module->Reference().SetTextSize( settings.m_ModuleTextSize ); default_pos.y = GetDesignSettings().m_ModuleTextSize.y / 2; module->Reference().SetPosition( default_pos ); module->Reference().SetLayer( ToLAYER_ID( settings.m_RefDefaultlayer ) ); @@ -804,7 +804,7 @@ MODULE* PCB_BASE_FRAME::CreateNewModule( const wxString& aModuleName ) module->SetValue( settings.m_ValueDefaultText ); module->Value().SetThickness( GetDesignSettings().m_ModuleTextWidth ); - module->Value().SetSize( GetDesignSettings().m_ModuleTextSize ); + module->Value().SetTextSize( GetDesignSettings().m_ModuleTextSize ); default_pos.y = -default_pos.y; module->Value().SetPosition( default_pos ); module->Value().SetLayer( ToLAYER_ID( settings.m_ValueDefaultlayer ) ); diff --git a/pcbnew/muonde.cpp b/pcbnew/muonde.cpp index fa7c685171..ef86a00cac 100644 --- a/pcbnew/muonde.cpp +++ b/pcbnew/muonde.cpp @@ -338,9 +338,9 @@ MODULE* CreateMicrowaveInductor( PCB_EDIT_FRAME* aPcbFrame, wxString& aErrorMess wxPoint valPos = refPos; - refPos.y -= module->Reference().GetSize().y; + refPos.y -= module->Reference().GetTextSize().y; module->Reference().SetPosition( refPos ); - valPos.y += module->Value().GetSize().y; + valPos.y += module->Value().GetTextSize().y; module->Value().SetPosition( valPos ); module->CalculateBoundingBox(); @@ -579,9 +579,9 @@ MODULE* PCB_EDIT_FRAME::CreateMuWaveBaseFootprint( const wxString& aValue, if( aTextSize > 0 ) { - module->Reference().SetSize( wxSize( aTextSize, aTextSize ) ); + module->Reference().SetTextSize( wxSize( aTextSize, aTextSize ) ); module->Reference().SetThickness( aTextSize/5 ); - module->Value().SetSize( wxSize( aTextSize, aTextSize ) ); + module->Value().SetTextSize( wxSize( aTextSize, aTextSize ) ); module->Value().SetThickness( aTextSize/5 ); } diff --git a/pcbnew/pcad2kicadpcb_plugin/pcad2kicad_common.cpp b/pcbnew/pcad2kicadpcb_plugin/pcad2kicad_common.cpp index be0328fbc4..31ebf5de18 100644 --- a/pcbnew/pcad2kicadpcb_plugin/pcad2kicad_common.cpp +++ b/pcbnew/pcad2kicadpcb_plugin/pcad2kicad_common.cpp @@ -548,12 +548,14 @@ void CorrectTextPosition( TTEXTVALUE* aValue ) } } + void SetTextSizeFromStrokeFontHeight( EDA_TEXT* aText, int aTextHeight ) { - aText->SetSize( wxSize( KiROUND( aTextHeight * TEXT_WIDTH_TO_SIZE ), - KiROUND( aTextHeight * TEXT_HEIGHT_TO_SIZE ) ) ); + aText->SetTextSize( wxSize( KiROUND( aTextHeight * TEXT_WIDTH_TO_SIZE ), + KiROUND( aTextHeight * TEXT_HEIGHT_TO_SIZE ) ) ); } + XNODE* FindNode( XNODE* aChild, wxString aTag ) { aChild = aChild->GetChildren(); diff --git a/pcbnew/pcad2kicadpcb_plugin/pcb_module.cpp b/pcbnew/pcad2kicadpcb_plugin/pcb_module.cpp index 4a978cea77..9f4afb2aa8 100644 --- a/pcbnew/pcad2kicadpcb_plugin/pcb_module.cpp +++ b/pcbnew/pcad2kicadpcb_plugin/pcb_module.cpp @@ -536,7 +536,7 @@ void PCB_MODULE::AddToBoard() SetTextSizeFromStrokeFontHeight( ref_text, m_name.textHeight ); r = m_name.textRotation - m_rotation; - ref_text->SetOrientation( r ); + ref_text->SetTextAngle( r ); ref_text->SetThickness( m_name.textstrokeWidth ); @@ -558,7 +558,7 @@ void PCB_MODULE::AddToBoard() SetTextSizeFromStrokeFontHeight( val_text, m_value.textHeight ); r = m_value.textRotation - m_rotation; - val_text->SetOrientation( r ); + val_text->SetTextAngle( r ); val_text->SetThickness( m_value.textstrokeWidth ); diff --git a/pcbnew/pcad2kicadpcb_plugin/pcb_text.cpp b/pcbnew/pcad2kicadpcb_plugin/pcb_text.cpp index f2f096c428..b4629f1ed4 100644 --- a/pcbnew/pcad2kicadpcb_plugin/pcb_text.cpp +++ b/pcbnew/pcad2kicadpcb_plugin/pcb_text.cpp @@ -113,11 +113,11 @@ void PCB_TEXT::AddToBoard() SetTextSizeFromStrokeFontHeight( pcbtxt, m_name.textHeight ); pcbtxt->SetThickness( m_name.textstrokeWidth ); - pcbtxt->SetOrientation( m_name.textRotation ); + pcbtxt->SetTextAngle( m_name.textRotation ); SetTextJustify( pcbtxt, m_name.justify ); - pcbtxt->SetTextPosition( wxPoint( m_name.textPositionX, - m_name.textPositionY ) ); + pcbtxt->SetTextPos( wxPoint( m_name.textPositionX, + m_name.textPositionY ) ); pcbtxt->SetMirrored( m_name.mirror ); pcbtxt->SetTimeStamp( 0 ); diff --git a/pcbnew/pcb_painter.cpp b/pcbnew/pcb_painter.cpp index 7515bcd753..fd320fbfe0 100644 --- a/pcbnew/pcb_painter.cpp +++ b/pcbnew/pcb_painter.cpp @@ -804,7 +804,7 @@ void PCB_PAINTER::draw( const TEXTE_PCB* aText, int aLayer ) return; const COLOR4D& color = m_pcbSettings.GetColor( aText, aText->GetLayer() ); - VECTOR2D position( aText->GetTextPosition().x, aText->GetTextPosition().y ); + VECTOR2D position( aText->GetTextPos().x, aText->GetTextPos().y ); if( m_pcbSettings.m_sketchMode[aLayer] ) { @@ -821,7 +821,7 @@ void PCB_PAINTER::draw( const TEXTE_PCB* aText, int aLayer ) m_gal->SetIsFill( false ); m_gal->SetIsStroke( true ); m_gal->SetTextAttributes( aText ); - m_gal->StrokeText( shownText, position, aText->GetOrientationRadians() ); + m_gal->StrokeText( shownText, position, aText->GetTextAngleRadians() ); } @@ -832,7 +832,7 @@ void PCB_PAINTER::draw( const TEXTE_MODULE* aText, int aLayer ) return; const COLOR4D& color = m_pcbSettings.GetColor( aText, aLayer ); - VECTOR2D position( aText->GetTextPosition().x, aText->GetTextPosition().y ); + VECTOR2D position( aText->GetTextPos().x, aText->GetTextPos().y ); if( m_pcbSettings.m_sketchMode[aLayer] ) { @@ -933,8 +933,8 @@ void PCB_PAINTER::draw( const ZONE_CONTAINER* aZone ) for( int i = 0; i < polySet.OutlineCount(); i++ ) { const SHAPE_LINE_CHAIN& outline = polySet.COutline( i ); - // fixme: GAL drawing API that accepts SHAPEs directly (this fiddling with double<>int conversion - // is just a performance hog) + // fixme: GAL drawing API that accepts SHAPEs directly (this fiddling with double<>int conversion + // is just a performance hog) for( int j = 0; j < outline.PointCount(); j++ ) corners.push_back ( (VECTOR2D) outline.CPoint( j ) ); @@ -979,11 +979,11 @@ void PCB_PAINTER::draw( const DIMENSION* aDimension, int aLayer ) // Draw text TEXTE_PCB& text = aDimension->Text(); - VECTOR2D position( text.GetTextPosition().x, text.GetTextPosition().y ); + VECTOR2D position( text.GetTextPos().x, text.GetTextPos().y ); m_gal->SetLineWidth( text.GetThickness() ); m_gal->SetTextAttributes( &text ); - m_gal->StrokeText( text.GetShownText(), position, text.GetOrientationRadians() ); + m_gal->StrokeText( text.GetShownText(), position, text.GetTextAngleRadians() ); } diff --git a/pcbnew/pcb_parser.cpp b/pcbnew/pcb_parser.cpp index 89460ec405..981be0aa5e 100644 --- a/pcbnew/pcb_parser.cpp +++ b/pcbnew/pcb_parser.cpp @@ -264,7 +264,7 @@ void PCB_PARSER::parseEDA_TEXT( EDA_TEXT* aText ) throw( PARSE_ERROR, IO_ERROR ) wxSize sz; sz.SetHeight( parseBoardUnits( "text height" ) ); sz.SetWidth( parseBoardUnits( "text width" ) ); - aText->SetSize( sz ); + aText->SetTextSize( sz ); NeedRIGHT(); break; } @@ -1518,14 +1518,14 @@ TEXTE_PCB* PCB_PARSER::parseTEXTE_PCB() throw( IO_ERROR, PARSE_ERROR ) pt.x = parseBoardUnits( "X coordinate" ); pt.y = parseBoardUnits( "Y coordinate" ); - text->SetTextPosition( pt ); + text->SetTextPos( pt ); // If there is no orientation defined, then it is the default value of 0 degrees. token = NextTok(); if( token == T_NUMBER ) { - text->SetOrientation( parseDouble() * 10.0 ); + text->SetTextAngle( parseDouble() * 10.0 ); NeedRIGHT(); } else if( token != T_RIGHT ) @@ -1607,7 +1607,7 @@ DIMENSION* PCB_PARSER::parseDIMENSION() throw( IO_ERROR, PARSE_ERROR ) { TEXTE_PCB* text = parseTEXTE_PCB(); dimension->Text() = *text; - dimension->SetPosition( text->GetTextPosition() ); + dimension->SetPosition( text->GetTextPos() ); delete text; break; } @@ -1919,9 +1919,9 @@ MODULE* PCB_PARSER::parseMODULE_unchecked( wxArrayString* aInitialComments ) { TEXTE_MODULE* text = parseTEXTE_MODULE(); text->SetParent( module.get() ); - double orientation = text->GetOrientation(); + double orientation = text->GetTextAngle(); orientation -= module->GetOrientation(); - text->SetOrientation( orientation ); + text->SetTextAngle( orientation ); text->SetDrawCoord(); switch( text->GetType() ) @@ -2017,6 +2017,18 @@ TEXTE_MODULE* PCB_PARSER::parseTEXTE_MODULE() throw( IO_ERROR, PARSE_ERROR ) NeedSYMBOLorNUMBER(); +#if defined(DEBUG) + { + wxString ref = FromUTF8(); + + if( ref == "LED7" ) + { + int breakhere = 1; + (void) breakhere; + } + } +#endif + text->SetText( FromUTF8() ); NeedLEFT(); token = NextTok(); @@ -2034,7 +2046,7 @@ TEXTE_MODULE* PCB_PARSER::parseTEXTE_MODULE() throw( IO_ERROR, PARSE_ERROR ) // If there is no orientation defined, then it is the default value of 0 degrees. if( token == T_NUMBER ) { - text->SetOrientation( parseDouble() * 10.0 ); + text->SetTextAngle( parseDouble() * 10.0 ); NeedRIGHT(); } else if( token != T_RIGHT ) diff --git a/pcbnew/plot_brditems_plotter.cpp b/pcbnew/plot_brditems_plotter.cpp index 3998f095a1..12fce73a87 100644 --- a/pcbnew/plot_brditems_plotter.cpp +++ b/pcbnew/plot_brditems_plotter.cpp @@ -305,8 +305,8 @@ void BRDITEMS_PLOTTER::PlotTextModule( TEXTE_MODULE* pt_texte, EDA_COLOR_T aColo m_plotter->SetColor( aColor ); // calculate some text parameters : - size = pt_texte->GetSize(); - pos = pt_texte->GetTextPosition(); + size = pt_texte->GetTextSize(); + pos = pt_texte->GetTextPos(); orient = pt_texte->GetDrawRotation(); @@ -565,9 +565,9 @@ void BRDITEMS_PLOTTER::PlotTextePcb( TEXTE_PCB* pt_texte ) m_plotter->SetColor( getColor( pt_texte->GetLayer() ) ); - size = pt_texte->GetSize(); - pos = pt_texte->GetTextPosition(); - orient = pt_texte->GetOrientation(); + size = pt_texte->GetTextSize(); + pos = pt_texte->GetTextPos(); + orient = pt_texte->GetTextAngle(); thickness = pt_texte->GetThickness(); if( pt_texte->IsMirrored() ) diff --git a/pcbnew/tools/drawing_tool.cpp b/pcbnew/tools/drawing_tool.cpp index 18e7c75537..d2b8ba7ae3 100644 --- a/pcbnew/tools/drawing_tool.cpp +++ b/pcbnew/tools/drawing_tool.cpp @@ -264,9 +264,9 @@ int DRAWING_TOOL::PlaceText( const TOOL_EVENT& aEvent ) TEXTE_MODULE* textMod = new TEXTE_MODULE( (MODULE*) m_frame->GetModel() ); textMod->SetLayer( m_frame->GetActiveLayer() ); - textMod->SetSize( dsnSettings.m_ModuleTextSize ); + textMod->SetTextSize( dsnSettings.m_ModuleTextSize ); textMod->SetThickness( dsnSettings.m_ModuleTextWidth ); - textMod->SetTextPosition( wxPoint( cursorPos.x, cursorPos.y ) ); + textMod->SetTextPos( wxPoint( cursorPos.x, cursorPos.y ) ); DialogEditModuleText textDialog( m_frame, textMod, NULL ); bool placing; @@ -293,9 +293,9 @@ int DRAWING_TOOL::PlaceText( const TOOL_EVENT& aEvent ) if( IsBackLayer( layer ) ) textPcb->SetMirrored( true ); - textPcb->SetSize( dsnSettings.m_PcbTextSize ); + textPcb->SetTextSize( dsnSettings.m_PcbTextSize ); textPcb->SetThickness( dsnSettings.m_PcbTextWidth ); - textPcb->SetTextPosition( wxPoint( cursorPos.x, cursorPos.y ) ); + textPcb->SetTextPos( wxPoint( cursorPos.x, cursorPos.y ) ); RunMainStack( [&]() { getEditFrame()->InstallTextPCBOptionsFrame( textPcb, NULL ); @@ -319,7 +319,7 @@ int DRAWING_TOOL::PlaceText( const TOOL_EVENT& aEvent ) else { //assert( text->GetText().Length() > 0 ); - //assert( text->GetSize().x > 0 && text->GetSize().y > 0 ); + //assert( text->GetTextSize().x > 0 && text->GetTextSize().y > 0 ); text->ClearFlags(); preview.Remove( text ); @@ -448,10 +448,10 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent ) dimension->SetLayer( layer ); dimension->SetOrigin( wxPoint( cursorPos.x, cursorPos.y ) ); dimension->SetEnd( wxPoint( cursorPos.x, cursorPos.y ) ); - dimension->Text().SetSize( m_board->GetDesignSettings().m_PcbTextSize ); + dimension->Text().SetTextSize( m_board->GetDesignSettings().m_PcbTextSize ); int width = m_board->GetDesignSettings().m_PcbTextWidth; - maxThickness = Clamp_Text_PenSize( width, dimension->Text().GetSize() ); + maxThickness = Clamp_Text_PenSize( width, dimension->Text().GetTextSize() ); if( width > maxThickness ) width = maxThickness; @@ -663,22 +663,27 @@ int DRAWING_TOOL::PlaceDXF( const TOOL_EVENT& aEvent ) { TEXTE_PCB* text = static_cast( item ); TEXTE_MODULE* textMod = new TEXTE_MODULE( (MODULE*) parent ); + // Assignment operator also copies the item PCB_TEXT_T type, // so it cannot be added to a module which handles PCB_MODULE_TEXT_T - textMod->SetPosition( text->GetPosition() ); textMod->SetText( text->GetText() ); - textMod->SetSize( text->GetSize() ); +#if 0 + textMod->SetTextSize( text->GetTextSize() ); textMod->SetThickness( text->GetThickness() ); - textMod->SetOrientation( text->GetOrientation() ); - textMod->SetTextPosition( text->GetTextPosition() ); - textMod->SetSize( text->GetSize() ); + textMod->SetOrientation( text->GetTextAngle() ); + textMod->SetTextPos( text->GetTextPos() ); + textMod->SetTextSize( text->GetTextSize() ); + textMod->SetVisible( text->GetVisible() ); textMod->SetMirrored( text->IsMirrored() ); - textMod->SetAttributes( text->GetAttributes() ); textMod->SetItalic( text->IsItalic() ); textMod->SetBold( text->IsBold() ); textMod->SetHorizJustify( text->GetHorizJustify() ); textMod->SetVertJustify( text->GetVertJustify() ); textMod->SetMultilineAllowed( text->IsMultilineAllowed() ); +#else + textMod->EDA_TEXT::SetEffects( *text ); + textMod->SetLocalCoord(); // using changed SetTexPos() via SetEffects() +#endif converted = textMod; break; } diff --git a/pcbnew/xchgmod.cpp b/pcbnew/xchgmod.cpp index 86496ba0ef..59fe238550 100644 --- a/pcbnew/xchgmod.cpp +++ b/pcbnew/xchgmod.cpp @@ -395,6 +395,16 @@ void PCB_EDIT_FRAME::Exchange_Module( MODULE* aOldModule, aNewModule->SetReference( aOldModule->GetReference() ); aNewModule->SetValue( aOldModule->GetValue() ); + // Compare the footprint name only, in case the nickname is empty or in case + // user moved the footprint to a new library. Chances are if footprint name is + // same then the footprint is very nearly the same and the two texts should + // be kept at same size, position, and rotation. + if( aNewModule->GetFPID().GetLibItemName() == aOldModule->GetFPID().GetLibItemName() ) + { + aNewModule->Reference().SetEffects( aOldModule->Reference() ); + aNewModule->Value().SetEffects( aOldModule->Value() ); + } + // Updating other parameters aNewModule->SetTimeStamp( aOldModule->GetTimeStamp() ); aNewModule->SetPath( aOldModule->GetPath() );