kicad/pcbnew/fp_text.cpp

505 lines
14 KiB
C++
Raw Normal View History

/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
2018-01-29 20:58:58 +00:00
#include <pcb_edit_frame.h>
#include <base_units.h>
#include <bitmaps.h>
#include <board.h>
#include <board_design_settings.h>
#include <core/mirror.h>
#include <footprint.h>
#include <settings/settings_manager.h>
2020-10-14 03:37:48 +00:00
#include <trigo.h>
#include <string_utils.h>
#include <painter.h>
#include <geometry/shape_compound.h>
#include <callback_gal.h>
#include <convert_basic_shapes_to_polygon.h>
2020-11-13 15:15:52 +00:00
FP_TEXT::FP_TEXT( FOOTPRINT* aParentFootprint, TEXT_TYPE text_type ) :
2020-11-13 02:57:11 +00:00
BOARD_ITEM( aParentFootprint, PCB_FP_TEXT_T ),
EDA_TEXT()
{
2020-11-14 18:11:28 +00:00
FOOTPRINT* parentFootprint = static_cast<FOOTPRINT*>( m_parent );
m_Type = text_type;
SetKeepUpright( true );
2016-02-11 15:02:37 +00:00
// Set text thickness to a default value
2020-04-14 12:25:00 +00:00
SetTextThickness( Millimeter2iu( DEFAULT_TEXT_WIDTH ) );
SetLayer( F_SilkS );
// Set position and give a default layer if a valid parent footprint exists
2020-11-13 12:21:02 +00:00
if( parentFootprint && parentFootprint->Type() == PCB_FOOTPRINT_T )
{
2020-11-13 02:57:11 +00:00
SetTextPos( parentFootprint->GetPosition() );
2007-08-23 04:28:46 +00:00
2020-11-13 02:57:11 +00:00
if( IsBackLayer( parentFootprint->GetLayer() ) )
{
SetLayer( B_SilkS );
SetMirrored( true );
}
}
SetDrawCoord();
}
FP_TEXT::~FP_TEXT()
{
}
bool FP_TEXT::TextHitTest( const VECTOR2I& aPoint, int aAccuracy ) const
2017-05-02 06:44:41 +00:00
{
2020-04-14 12:25:00 +00:00
EDA_RECT rect = GetTextBox();
VECTOR2I location = aPoint;
2017-05-02 06:44:41 +00:00
rect.Inflate( aAccuracy );
RotatePoint( location, GetTextPos(), -GetDrawRotation() );
2017-05-02 06:44:41 +00:00
return rect.Contains( location );
}
2017-05-10 09:40:49 +00:00
bool FP_TEXT::TextHitTest( const EDA_RECT& aRect, bool aContains, int aAccuracy ) const
2017-05-02 06:44:41 +00:00
{
EDA_RECT rect = aRect;
rect.Inflate( aAccuracy );
if( aContains )
return rect.Contains( GetBoundingBox() );
else
2022-01-16 21:15:20 +00:00
return rect.Intersects( GetTextBox(), GetDrawRotation() );
2017-05-02 06:44:41 +00:00
}
void FP_TEXT::KeepUpright( const EDA_ANGLE& aOldOrientation, const EDA_ANGLE& aNewOrientation )
{
if( !IsKeepUpright() )
return;
EDA_ANGLE newAngle = GetTextAngle() + aNewOrientation;
newAngle.Normalize();
bool needsFlipped = newAngle >= ANGLE_180;
if( needsFlipped )
{
SetHorizJustify( static_cast<GR_TEXT_H_ALIGN_T>( -GetHorizJustify() ) );
SetTextAngle( GetTextAngle() + ANGLE_180 );
SetDrawCoord();
}
}
void FP_TEXT::Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle )
{
// Used in footprint editing
2020-11-13 02:57:11 +00:00
// Note also in footprint editor, m_Pos0 = m_Pos
VECTOR2I pt = GetTextPos();
RotatePoint( pt, aRotCentre, aAngle );
SetTextPos( pt );
EDA_ANGLE new_angle = GetTextAngle() + aAngle;
new_angle.Normalize180();
SetTextAngle( new_angle );
SetLocalCoord();
}
void FP_TEXT::Flip( const VECTOR2I& aCentre, bool aFlipLeftRight )
{
// flipping the footprint is relative to the X axis
if( aFlipLeftRight )
{
SetTextX( MIRRORVAL( GetTextPos().x, aCentre.x ) );
SetTextAngle( -GetTextAngle() );
}
else
{
SetTextY( MIRRORVAL( GetTextPos().y, aCentre.y ) );
SetTextAngle( ANGLE_180 - GetTextAngle() );
}
SetLayer( FlipLayer( GetLayer(), GetBoard()->GetCopperLayerCount() ) );
SetMirrored( IsBackLayer( GetLayer() ) );
SetLocalCoord();
}
bool FP_TEXT::IsParentFlipped() const
{
if( GetParent() && GetParent()->GetLayer() == B_Cu )
return true;
return false;
}
void FP_TEXT::Mirror( const VECTOR2I& aCentre, bool aMirrorAroundXAxis )
{
// the position is mirrored, but the text itself is not mirrored
2020-11-16 00:45:43 +00:00
if( aMirrorAroundXAxis )
SetTextY( ::MIRRORVAL( GetTextPos().y, aCentre.y ) );
else
SetTextX( ::MIRRORVAL( GetTextPos().x, aCentre.x ) );
SetLocalCoord();
}
void FP_TEXT::Move( const VECTOR2I& aMoveVector )
{
Offset( aMoveVector );
SetLocalCoord();
}
int FP_TEXT::GetLength() const
{
return GetText().Len();
}
void FP_TEXT::SetDrawCoord()
{
2020-11-14 18:11:28 +00:00
const FOOTPRINT* parentFootprint = static_cast<const FOOTPRINT*>( m_parent );
SetTextPos( m_Pos0 );
2020-11-13 02:57:11 +00:00
if( parentFootprint )
{
VECTOR2I pt = GetTextPos();
2022-01-13 17:27:36 +00:00
RotatePoint( pt, parentFootprint->GetOrientation() );
SetTextPos( pt );
2020-11-13 02:57:11 +00:00
Offset( parentFootprint->GetPosition() );
}
}
void FP_TEXT::SetLocalCoord()
{
2020-11-14 18:11:28 +00:00
const FOOTPRINT* parentFootprint = static_cast<const FOOTPRINT*>( m_parent );
2020-11-13 02:57:11 +00:00
if( parentFootprint )
{
m_Pos0 = GetTextPos() - parentFootprint->GetPosition();
2022-01-13 17:27:36 +00:00
RotatePoint( &m_Pos0.x, &m_Pos0.y, - parentFootprint->GetOrientation() );
}
else
2009-08-11 10:27:21 +00:00
{
2022-01-02 02:06:40 +00:00
m_Pos0 = GetTextPos();
2009-08-11 10:27:21 +00:00
}
}
const EDA_RECT FP_TEXT::GetBoundingBox() const
{
2022-01-16 21:15:20 +00:00
EDA_ANGLE angle = GetDrawRotation();
EDA_RECT text_area = GetTextBox();
2008-04-01 05:21:50 +00:00
2022-01-16 21:15:20 +00:00
if( !angle.IsZero() )
text_area = text_area.GetBoundingBoxRotated( GetTextPos(), angle );
2008-04-01 05:21:50 +00:00
return text_area;
}
EDA_ANGLE FP_TEXT::GetDrawRotation() const
{
2020-11-14 18:11:28 +00:00
FOOTPRINT* parentFootprint = static_cast<FOOTPRINT*>( m_parent );
2022-01-13 17:27:36 +00:00
EDA_ANGLE rotation = GetTextAngle();
2020-11-13 02:57:11 +00:00
if( parentFootprint )
rotation += parentFootprint->GetOrientation();
if( IsKeepUpright() )
{
// Keep angle between ]-90 .. 90 deg]. Otherwise the text is not easy to read
2022-01-13 17:27:36 +00:00
while( rotation > ANGLE_90 )
rotation -= ANGLE_180;
while( rotation <= -ANGLE_90 )
2022-01-13 17:27:36 +00:00
rotation += ANGLE_180;
}
else
{
2022-01-13 17:27:36 +00:00
rotation.Normalize();
}
2022-01-13 17:27:36 +00:00
return rotation;
}
void FP_TEXT::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
{
wxString msg;
2008-03-04 04:22:27 +00:00
static const wxString text_type_msg[3] =
{
_( "Reference" ), _( "Value" ), _( "Text" )
};
2008-03-04 04:22:27 +00:00
if( aFrame->GetName() == PCB_EDIT_FRAME_NAME )
{
FOOTPRINT* fp = static_cast<FOOTPRINT*>( m_parent );
if( fp )
aList.emplace_back( _( "Footprint" ), fp->GetReference() );
}
// Don't use GetShownText() here; we want to show the user the variable references
aList.emplace_back( _( "Text" ), UnescapeString( GetText() ) );
wxASSERT( m_Type >= TEXT_is_REFERENCE && m_Type <= TEXT_is_DIVERS );
aList.emplace_back( _( "Type" ), text_type_msg[m_Type] );
if( aFrame->GetName() == PCB_EDIT_FRAME_NAME && IsLocked() )
aList.emplace_back( _( "Status" ), _( "Locked" ) );
aList.emplace_back( _( "Display" ), IsVisible() ? _( "Yes" ) : _( "No" ) );
// Display text layer
aList.emplace_back( _( "Layer" ), GetLayerName() );
aList.emplace_back( _( "Mirror" ), IsMirrored() ? _( "Yes" ) : _( "No" ) );
msg.Printf( wxT( "%g" ), GetTextAngle().AsDegrees() );
aList.emplace_back( _( "Angle" ), msg );
msg = MessageTextFromValue( aFrame->GetUserUnits(), GetTextThickness() );
aList.emplace_back( _( "Thickness" ), msg );
msg = MessageTextFromValue( aFrame->GetUserUnits(), GetTextWidth() );
aList.emplace_back( _( "Width" ), msg );
msg = MessageTextFromValue( aFrame->GetUserUnits(), GetTextHeight() );
aList.emplace_back( _( "Height" ), msg );
}
wxString FP_TEXT::GetSelectMenuText( EDA_UNITS aUnits ) const
{
switch( m_Type )
{
case TEXT_is_REFERENCE:
return wxString::Format( _( "Reference '%s'" ),
2020-11-13 15:15:52 +00:00
static_cast<FOOTPRINT*>( GetParent() )->GetReference() );
case TEXT_is_VALUE:
return wxString::Format( _( "Value '%s' of %s" ),
GetShownText(),
2020-11-13 15:15:52 +00:00
static_cast<FOOTPRINT*>( GetParent() )->GetReference() );
default:
return wxString::Format( _( "Footprint Text '%s' of %s" ),
ShortenedShownText(),
2020-11-13 15:15:52 +00:00
static_cast<FOOTPRINT*>( GetParent() )->GetReference() );
}
}
BITMAPS FP_TEXT::GetMenuImage() const
{
return BITMAPS::text;
}
EDA_ITEM* FP_TEXT::Clone() const
{
return new FP_TEXT( *this );
}
const BOX2I FP_TEXT::ViewBBox() const
2014-01-07 13:09:27 +00:00
{
2022-01-16 21:15:20 +00:00
EDA_ANGLE angle = GetDrawRotation();
EDA_RECT text_area = GetTextBox();
2014-01-07 13:09:27 +00:00
2022-01-16 21:15:20 +00:00
if( !angle.IsZero() )
text_area = text_area.GetBoundingBoxRotated( GetTextPos(), angle );
2014-01-07 13:09:27 +00:00
return BOX2I( text_area.GetPosition(), text_area.GetSize() );
}
void FP_TEXT::ViewGetLayers( int aLayers[], int& aCount ) const
Introduction of Graphics Abstraction Layer based rendering for pcbnew. New classes: - VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.) - VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes). - EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL). - GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries. - WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc. - PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods. - STROKE_FONT - Implements stroke font drawing using GAL methods. Most important changes to Kicad original code: * EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects. * EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime. * There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew) * Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom. * Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime. * Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods. * Removed tools/class_painter.h, as now it is extended and included in source code. Build changes: * GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL. * When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required. * GAL-related code is compiled into a static library (common/libgal). * Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS). More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
{
if( IsVisible() )
aLayers[0] = GetLayer();
else
aLayers[0] = LAYER_MOD_TEXT_INVISIBLE;
aCount = 1;
}
Introduction of Graphics Abstraction Layer based rendering for pcbnew. New classes: - VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.) - VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes). - EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL). - GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries. - WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc. - PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods. - STROKE_FONT - Implements stroke font drawing using GAL methods. Most important changes to Kicad original code: * EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects. * EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime. * There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew) * Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom. * Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime. * Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods. * Removed tools/class_painter.h, as now it is extended and included in source code. Build changes: * GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL. * When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required. * GAL-related code is compiled into a static library (common/libgal). * Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS). More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
double FP_TEXT::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
{
constexpr double HIDE = (double)std::numeric_limits<double>::max();
if( !aView )
return 0.0;
// Hidden text gets put on the LAYER_MOD_TEXT_INVISIBLE for rendering, but
// should only render if its native layer is visible.
if( !aView->IsLayerVisible( GetLayer() ) )
return HIDE;
// Handle Render tab switches
if( m_Type == TEXT_is_VALUE || GetText() == wxT( "${VALUE}" ) )
{
if( !aView->IsLayerVisible( LAYER_MOD_VALUES ) )
{
return HIDE;
}
}
if( m_Type == TEXT_is_REFERENCE || GetText() == wxT( "${REFERENCE}" ) )
{
if( !aView->IsLayerVisible( LAYER_MOD_REFERENCES ) )
{
return HIDE;
}
}
if( !IsParentFlipped() && !aView->IsLayerVisible( LAYER_MOD_FR ) )
return HIDE;
if( IsParentFlipped() && !aView->IsLayerVisible( LAYER_MOD_BK ) )
return HIDE;
if( !aView->IsLayerVisible( LAYER_MOD_TEXT ) )
return HIDE;
// Other layers are shown without any conditions
return 0.0;
Introduction of Graphics Abstraction Layer based rendering for pcbnew. New classes: - VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.) - VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes). - EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL). - GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries. - WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc. - PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods. - STROKE_FONT - Implements stroke font drawing using GAL methods. Most important changes to Kicad original code: * EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects. * EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime. * There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew) * Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom. * Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime. * Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods. * Removed tools/class_painter.h, as now it is extended and included in source code. Build changes: * GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL. * When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required. * GAL-related code is compiled into a static library (common/libgal). * Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS). More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
}
wxString FP_TEXT::GetShownText( int aDepth ) const
{
2020-11-13 15:15:52 +00:00
const FOOTPRINT* parentFootprint = static_cast<FOOTPRINT*>( GetParent() );
2020-11-13 02:57:11 +00:00
wxASSERT( parentFootprint );
const BOARD* board = parentFootprint->GetBoard();
2020-11-13 02:57:11 +00:00
std::function<bool( wxString* )> footprintResolver =
[&]( wxString* token ) -> bool
{
2020-11-13 02:57:11 +00:00
return parentFootprint && parentFootprint->ResolveTextVar( token, aDepth );
};
std::function<bool( wxString* )> boardTextResolver =
[&]( wxString* token ) -> bool
{
return board->ResolveTextVar( token, aDepth + 1 );
};
wxString text = EDA_TEXT::GetShownText();
2020-04-24 20:33:59 +00:00
if( HasTextVars() )
2020-04-24 20:33:59 +00:00
{
PROJECT* project = nullptr;
2020-11-13 02:57:11 +00:00
if( parentFootprint && parentFootprint->GetParent() )
project = static_cast<BOARD*>( parentFootprint->GetParent() )->GetProject();
2020-04-24 20:33:59 +00:00
if( aDepth < 10 )
text = ExpandTextVars( text, &footprintResolver, &boardTextResolver, project );
2020-04-24 20:33:59 +00:00
}
return text;
}
std::shared_ptr<SHAPE> FP_TEXT::GetEffectiveShape( PCB_LAYER_ID aLayer, FLASHING aFlash ) const
{
return GetEffectiveTextShape();
}
void FP_TEXT::TransformTextShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer,
PCB_LAYER_ID aLayer, int aClearance,
int aError, ERROR_LOC aErrorLoc ) const
{
KIGFX::GAL_DISPLAY_OPTIONS empty_opts;
KIFONT::FONT* font = GetDrawFont();
int penWidth = GetEffectiveTextPenWidth();
CALLBACK_GAL callback_gal( empty_opts,
// Stroke callback
[&]( const VECTOR2I& aPt1, const VECTOR2I& aPt2 )
{
TransformOvalToPolygon( aCornerBuffer, aPt1, aPt2, penWidth+ ( 2 * aClearance ),
aError, ERROR_INSIDE );
},
// Triangulation callback
[&]( const VECTOR2I& aPt1, const VECTOR2I& aPt2, const VECTOR2I& aPt3 )
{
aCornerBuffer.NewOutline();
for( const VECTOR2I& point : { aPt1, aPt2, aPt3 } )
aCornerBuffer.Append( point.x, point.y );
} );
2022-01-10 15:30:19 +00:00
TEXT_ATTRIBUTES attrs = GetAttributes();
attrs.m_Angle = GetDrawRotation();
font->Draw( &callback_gal, GetShownText(), GetTextPos(), attrs );
}
void FP_TEXT::TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer,
PCB_LAYER_ID aLayer, int aClearance,
int aError, ERROR_LOC aErrorLoc,
bool aIgnoreLineWidth ) const
{
SHAPE_POLY_SET buffer;
EDA_TEXT::TransformBoundingBoxWithClearanceToPolygon( &buffer, aClearance );
aCornerBuffer.Append( buffer );
}
2020-10-14 23:37:26 +00:00
static struct FP_TEXT_DESC
{
2020-10-14 23:37:26 +00:00
FP_TEXT_DESC()
{
PROPERTY_MANAGER& propMgr = PROPERTY_MANAGER::Instance();
REGISTER_TYPE( FP_TEXT );
propMgr.AddTypeCast( new TYPE_CAST<FP_TEXT, BOARD_ITEM> );
propMgr.AddTypeCast( new TYPE_CAST<FP_TEXT, EDA_TEXT> );
propMgr.InheritsAfter( TYPE_HASH( FP_TEXT ), TYPE_HASH( BOARD_ITEM ) );
propMgr.InheritsAfter( TYPE_HASH( FP_TEXT ), TYPE_HASH( EDA_TEXT ) );
propMgr.AddProperty( new PROPERTY<FP_TEXT, wxString>( _HKI( "Parent" ),
NO_SETTER( FP_TEXT, wxString ), &FP_TEXT::GetParentAsString ) );
}
2020-10-14 23:37:26 +00:00
} _FP_TEXT_DESC;