2012-01-14 19:50:32 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2015-08-01 10:20:23 +00:00
|
|
|
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2012-06-08 09:56:42 +00:00
|
|
|
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
2022-01-10 01:53:01 +00:00
|
|
|
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
2012-01-14 19:50:32 +00:00
|
|
|
*
|
|
|
|
* 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>
|
2013-01-12 17:32:24 +00:00
|
|
|
#include <base_units.h>
|
2017-02-20 12:20:39 +00:00
|
|
|
#include <bitmaps.h>
|
2020-11-12 20:19:22 +00:00
|
|
|
#include <board.h>
|
2021-06-06 19:03:10 +00:00
|
|
|
#include <board_design_settings.h>
|
2020-11-18 01:21:04 +00:00
|
|
|
#include <core/mirror.h>
|
2020-11-12 20:19:22 +00:00
|
|
|
#include <footprint.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <settings/settings_manager.h>
|
2020-10-14 03:37:48 +00:00
|
|
|
#include <trigo.h>
|
2021-07-29 09:56:22 +00:00
|
|
|
#include <string_utils.h>
|
2021-06-03 21:42:07 +00:00
|
|
|
#include <painter.h>
|
2021-06-06 19:03:10 +00:00
|
|
|
#include <geometry/shape_compound.h>
|
2022-01-10 14:03:53 +00:00
|
|
|
#include <callback_gal.h>
|
2022-01-10 01:53:01 +00:00
|
|
|
#include <convert_basic_shapes_to_polygon.h>
|
2007-06-05 12:10:51 +00:00
|
|
|
|
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 ),
|
2012-01-14 19:50:32 +00:00
|
|
|
EDA_TEXT()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2020-11-14 18:11:28 +00:00
|
|
|
FOOTPRINT* parentFootprint = static_cast<FOOTPRINT*>( m_parent );
|
2007-08-04 20:05:54 +00:00
|
|
|
|
2013-04-07 11:55:18 +00:00
|
|
|
m_Type = text_type;
|
2022-01-13 20:23:38 +00:00
|
|
|
SetKeepUpright( true );
|
2017-01-23 20:30:11 +00:00
|
|
|
|
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 ) );
|
2014-06-24 16:17:18 +00:00
|
|
|
SetLayer( F_SilkS );
|
2012-01-14 19:50:32 +00:00
|
|
|
|
2015-07-31 19:04:30 +00:00
|
|
|
// 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 )
|
2007-08-04 20:05:54 +00:00
|
|
|
{
|
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() ) )
|
2013-04-07 11:55:18 +00:00
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
SetLayer( B_SilkS );
|
2017-01-23 20:30:11 +00:00
|
|
|
SetMirrored( true );
|
2013-04-07 11:55:18 +00:00
|
|
|
}
|
2007-08-04 20:05:54 +00:00
|
|
|
}
|
2015-07-31 19:04:30 +00:00
|
|
|
|
|
|
|
SetDrawCoord();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-04 20:05:54 +00:00
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
FP_TEXT::~FP_TEXT()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
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();
|
2021-12-29 21:30:11 +00:00
|
|
|
VECTOR2I location = aPoint;
|
2017-05-02 06:44:41 +00:00
|
|
|
|
|
|
|
rect.Inflate( aAccuracy );
|
|
|
|
|
2021-12-29 21:30:11 +00:00
|
|
|
RotatePoint( location, GetTextPos(), -GetDrawRotation() );
|
2017-05-02 06:44:41 +00:00
|
|
|
|
|
|
|
return rect.Contains( location );
|
|
|
|
}
|
|
|
|
|
2017-05-10 09:40:49 +00:00
|
|
|
|
2020-10-04 23:34:59 +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
|
|
|
}
|
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
|
2022-01-13 20:23:38 +00:00
|
|
|
void FP_TEXT::KeepUpright( const EDA_ANGLE& aOldOrientation, const EDA_ANGLE& aNewOrientation )
|
2019-04-07 21:09:50 +00:00
|
|
|
{
|
|
|
|
if( !IsKeepUpright() )
|
|
|
|
return;
|
|
|
|
|
2022-01-13 20:23:38 +00:00
|
|
|
EDA_ANGLE newAngle = GetTextAngle() + aNewOrientation;
|
|
|
|
newAngle.Normalize();
|
|
|
|
|
|
|
|
bool needsFlipped = newAngle >= ANGLE_180;
|
2019-04-07 21:09:50 +00:00
|
|
|
|
Rotate FP_TEST properly when flipping
The angle was `-angle` instead of `180 deg - angle` when flipping top to
bottom.
Fixing that, in turn, created some problems with justification, which
was modified both by `FP_TEXT::Flip()` and `FP_TEXT::KeepUpright()`.
What's worse, `FP_TEXT` has another mechanism for keeping the text
upright: `FP_TEXT::GetDrawRotation()` returns different angles if the
"keep upright" flag is set. But there is no analogous behavior for
justification, so the text would sometimes get shifted, and sometimes
not, depending on which mechanism was engaged. And both are used,
apparently.
Clearly, such an arrangement an open invitation to bugs and
inconsistencies. One of these mechanisms should be removed. I haven't
done this yet, and would prefer to postpone this until V6 is out.
I've fixed the justification problems, but this was by trial-and-error,
and I don't feel I really understand the behavior responsible. But I
think it's a good sign that most of my changes are line removals, not
additions. Flipping is a simple operation, it's just mirroring and layer
change. If something simple has a complicated routine, then it's
probably full of hacks.
Fixes https://gitlab.com/kicad/code/kicad/issues/7289
2021-03-19 21:45:24 +00:00
|
|
|
if( needsFlipped )
|
2019-04-07 21:09:50 +00:00
|
|
|
{
|
2021-12-28 22:13:54 +00:00
|
|
|
SetHorizJustify( static_cast<GR_TEXT_H_ALIGN_T>( -GetHorizJustify() ) );
|
2022-01-13 20:23:38 +00:00
|
|
|
SetTextAngle( GetTextAngle() + ANGLE_180 );
|
2019-04-07 21:09:50 +00:00
|
|
|
SetDrawCoord();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-01-13 19:32:00 +00:00
|
|
|
void FP_TEXT::Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle )
|
2013-09-03 12:15:37 +00:00
|
|
|
{
|
2018-06-22 13:05:11 +00:00
|
|
|
// Used in footprint editing
|
2020-11-13 02:57:11 +00:00
|
|
|
// Note also in footprint editor, m_Pos0 = m_Pos
|
2017-01-23 20:30:11 +00:00
|
|
|
|
2021-12-29 21:30:11 +00:00
|
|
|
VECTOR2I pt = GetTextPos();
|
|
|
|
RotatePoint( pt, aRotCentre, aAngle );
|
2017-01-23 20:30:11 +00:00
|
|
|
SetTextPos( pt );
|
|
|
|
|
2022-02-01 17:06:58 +00:00
|
|
|
EDA_ANGLE new_angle = GetTextAngle() + aAngle;
|
|
|
|
new_angle.Normalize180();
|
|
|
|
SetTextAngle( new_angle );
|
|
|
|
|
2015-02-28 17:39:05 +00:00
|
|
|
SetLocalCoord();
|
2013-09-03 12:15:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
void FP_TEXT::Flip( const VECTOR2I& aCentre, bool aFlipLeftRight )
|
2014-09-10 15:18:42 +00:00
|
|
|
{
|
2014-09-27 16:39:18 +00:00
|
|
|
// flipping the footprint is relative to the X axis
|
2019-07-12 21:02:10 +00:00
|
|
|
if( aFlipLeftRight )
|
Rotate FP_TEST properly when flipping
The angle was `-angle` instead of `180 deg - angle` when flipping top to
bottom.
Fixing that, in turn, created some problems with justification, which
was modified both by `FP_TEXT::Flip()` and `FP_TEXT::KeepUpright()`.
What's worse, `FP_TEXT` has another mechanism for keeping the text
upright: `FP_TEXT::GetDrawRotation()` returns different angles if the
"keep upright" flag is set. But there is no analogous behavior for
justification, so the text would sometimes get shifted, and sometimes
not, depending on which mechanism was engaged. And both are used,
apparently.
Clearly, such an arrangement an open invitation to bugs and
inconsistencies. One of these mechanisms should be removed. I haven't
done this yet, and would prefer to postpone this until V6 is out.
I've fixed the justification problems, but this was by trial-and-error,
and I don't feel I really understand the behavior responsible. But I
think it's a good sign that most of my changes are line removals, not
additions. Flipping is a simple operation, it's just mirroring and layer
change. If something simple has a complicated routine, then it's
probably full of hacks.
Fixes https://gitlab.com/kicad/code/kicad/issues/7289
2021-03-19 21:45:24 +00:00
|
|
|
{
|
|
|
|
SetTextX( MIRRORVAL( GetTextPos().x, aCentre.x ) );
|
|
|
|
SetTextAngle( -GetTextAngle() );
|
|
|
|
}
|
2019-07-12 21:02:10 +00:00
|
|
|
else
|
Rotate FP_TEST properly when flipping
The angle was `-angle` instead of `180 deg - angle` when flipping top to
bottom.
Fixing that, in turn, created some problems with justification, which
was modified both by `FP_TEXT::Flip()` and `FP_TEXT::KeepUpright()`.
What's worse, `FP_TEXT` has another mechanism for keeping the text
upright: `FP_TEXT::GetDrawRotation()` returns different angles if the
"keep upright" flag is set. But there is no analogous behavior for
justification, so the text would sometimes get shifted, and sometimes
not, depending on which mechanism was engaged. And both are used,
apparently.
Clearly, such an arrangement an open invitation to bugs and
inconsistencies. One of these mechanisms should be removed. I haven't
done this yet, and would prefer to postpone this until V6 is out.
I've fixed the justification problems, but this was by trial-and-error,
and I don't feel I really understand the behavior responsible. But I
think it's a good sign that most of my changes are line removals, not
additions. Flipping is a simple operation, it's just mirroring and layer
change. If something simple has a complicated routine, then it's
probably full of hacks.
Fixes https://gitlab.com/kicad/code/kicad/issues/7289
2021-03-19 21:45:24 +00:00
|
|
|
{
|
|
|
|
SetTextY( MIRRORVAL( GetTextPos().y, aCentre.y ) );
|
2022-01-13 19:32:00 +00:00
|
|
|
SetTextAngle( ANGLE_180 - GetTextAngle() );
|
Rotate FP_TEST properly when flipping
The angle was `-angle` instead of `180 deg - angle` when flipping top to
bottom.
Fixing that, in turn, created some problems with justification, which
was modified both by `FP_TEXT::Flip()` and `FP_TEXT::KeepUpright()`.
What's worse, `FP_TEXT` has another mechanism for keeping the text
upright: `FP_TEXT::GetDrawRotation()` returns different angles if the
"keep upright" flag is set. But there is no analogous behavior for
justification, so the text would sometimes get shifted, and sometimes
not, depending on which mechanism was engaged. And both are used,
apparently.
Clearly, such an arrangement an open invitation to bugs and
inconsistencies. One of these mechanisms should be removed. I haven't
done this yet, and would prefer to postpone this until V6 is out.
I've fixed the justification problems, but this was by trial-and-error,
and I don't feel I really understand the behavior responsible. But I
think it's a good sign that most of my changes are line removals, not
additions. Flipping is a simple operation, it's just mirroring and layer
change. If something simple has a complicated routine, then it's
probably full of hacks.
Fixes https://gitlab.com/kicad/code/kicad/issues/7289
2021-03-19 21:45:24 +00:00
|
|
|
}
|
2017-01-23 20:30:11 +00:00
|
|
|
|
2021-02-20 12:16:45 +00:00
|
|
|
SetLayer( FlipLayer( GetLayer(), GetBoard()->GetCopperLayerCount() ) );
|
2017-01-23 20:30:11 +00:00
|
|
|
SetMirrored( IsBackLayer( GetLayer() ) );
|
2015-07-31 19:04:30 +00:00
|
|
|
SetLocalCoord();
|
2014-09-10 15:18:42 +00:00
|
|
|
}
|
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
bool FP_TEXT::IsParentFlipped() const
|
2018-02-17 18:03:22 +00:00
|
|
|
{
|
|
|
|
if( GetParent() && GetParent()->GetLayer() == B_Cu )
|
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-09-10 15:18:42 +00:00
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
void FP_TEXT::Mirror( const VECTOR2I& aCentre, bool aMirrorAroundXAxis )
|
2014-09-10 15:18:42 +00:00
|
|
|
{
|
2014-09-27 16:39:18 +00:00
|
|
|
// the position is mirrored, but the text itself is not mirrored
|
2020-11-16 00:45:43 +00:00
|
|
|
|
2015-07-31 19:04:30 +00:00
|
|
|
if( aMirrorAroundXAxis )
|
2020-10-26 00:44:22 +00:00
|
|
|
SetTextY( ::MIRRORVAL( GetTextPos().y, aCentre.y ) );
|
2015-07-31 19:04:30 +00:00
|
|
|
else
|
2020-10-26 00:44:22 +00:00
|
|
|
SetTextX( ::MIRRORVAL( GetTextPos().x, aCentre.x ) );
|
2015-08-02 09:19:01 +00:00
|
|
|
|
2015-07-31 19:04:30 +00:00
|
|
|
SetLocalCoord();
|
2014-09-10 15:18:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
void FP_TEXT::Move( const VECTOR2I& aMoveVector )
|
2014-09-10 15:18:42 +00:00
|
|
|
{
|
2017-01-23 20:30:11 +00:00
|
|
|
Offset( aMoveVector );
|
2015-08-02 09:19:01 +00:00
|
|
|
SetLocalCoord();
|
2014-09-27 16:39:18 +00:00
|
|
|
}
|
2014-09-10 15:18:42 +00:00
|
|
|
|
2016-04-20 15:28:44 +00:00
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
int FP_TEXT::GetLength() const
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2019-08-02 00:10:25 +00:00
|
|
|
return GetText().Len();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2014-07-09 09:59:24 +00:00
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
void FP_TEXT::SetDrawCoord()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2020-11-14 18:11:28 +00:00
|
|
|
const FOOTPRINT* parentFootprint = static_cast<const FOOTPRINT*>( m_parent );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
SetTextPos( m_Pos0 );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2020-11-13 02:57:11 +00:00
|
|
|
if( parentFootprint )
|
2014-09-11 16:35:19 +00:00
|
|
|
{
|
2021-12-29 21:30:11 +00:00
|
|
|
VECTOR2I pt = GetTextPos();
|
2022-01-13 17:27:36 +00:00
|
|
|
RotatePoint( pt, parentFootprint->GetOrientation() );
|
2017-01-23 20:30:11 +00:00
|
|
|
SetTextPos( pt );
|
|
|
|
|
2020-11-13 02:57:11 +00:00
|
|
|
Offset( parentFootprint->GetPosition() );
|
2014-09-11 16:35:19 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-04 20:05:54 +00:00
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
void FP_TEXT::SetLocalCoord()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2020-11-14 18:11:28 +00:00
|
|
|
const FOOTPRINT* parentFootprint = static_cast<const FOOTPRINT*>( m_parent );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2020-11-13 02:57:11 +00:00
|
|
|
if( parentFootprint )
|
2014-09-11 16:35:19 +00:00
|
|
|
{
|
2022-01-01 06:04:08 +00:00
|
|
|
m_Pos0 = GetTextPos() - parentFootprint->GetPosition();
|
2022-01-13 17:27:36 +00:00
|
|
|
RotatePoint( &m_Pos0.x, &m_Pos0.y, - parentFootprint->GetOrientation() );
|
2014-09-11 16:35:19 +00:00
|
|
|
}
|
|
|
|
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
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
const EDA_RECT FP_TEXT::GetBoundingBox() const
|
2008-03-15 10:24:32 +00:00
|
|
|
{
|
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() )
|
2017-01-23 20:30:11 +00:00
|
|
|
text_area = text_area.GetBoundingBoxRotated( GetTextPos(), angle );
|
2008-04-01 05:21:50 +00:00
|
|
|
|
|
|
|
return text_area;
|
2008-03-15 10:24:32 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-08-09 08:05:42 +00:00
|
|
|
|
2021-12-28 22:13:54 +00:00
|
|
|
EDA_ANGLE FP_TEXT::GetDrawRotation() const
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
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();
|
2010-12-10 19:47:44 +00:00
|
|
|
|
2020-11-13 02:57:11 +00:00
|
|
|
if( parentFootprint )
|
|
|
|
rotation += parentFootprint->GetOrientation();
|
2007-08-04 20:05:54 +00:00
|
|
|
|
2022-01-13 20:23:38 +00:00
|
|
|
if( IsKeepUpright() )
|
2017-11-25 19:55:32 +00:00
|
|
|
{
|
2020-11-09 22:47:57 +00:00
|
|
|
// Keep angle between 0 .. 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;
|
2017-11-25 19:55:32 +00:00
|
|
|
|
2022-01-13 17:27:36 +00:00
|
|
|
while( rotation < ANGLE_0 )
|
|
|
|
rotation += ANGLE_180;
|
2017-11-25 19:55:32 +00:00
|
|
|
}
|
2018-04-28 15:22:25 +00:00
|
|
|
else
|
|
|
|
{
|
2022-01-13 17:27:36 +00:00
|
|
|
rotation.Normalize();
|
2018-04-28 15:22:25 +00:00
|
|
|
}
|
2016-03-15 00:51:28 +00:00
|
|
|
|
2022-01-13 17:27:36 +00:00
|
|
|
return rotation;
|
2007-08-04 20:05:54 +00:00
|
|
|
}
|
2007-08-06 20:26:59 +00:00
|
|
|
|
2007-08-20 19:33:15 +00:00
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
void FP_TEXT::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
|
2007-08-20 19:33:15 +00:00
|
|
|
{
|
2021-10-31 16:32:24 +00:00
|
|
|
wxString msg;
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2009-11-23 21:03:26 +00:00
|
|
|
static const wxString text_type_msg[3] =
|
|
|
|
{
|
2021-10-31 16:32:24 +00:00
|
|
|
_( "Reference" ), _( "Value" ), _( "Text" )
|
2008-08-09 08:05:42 +00:00
|
|
|
};
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2021-10-31 16:32:24 +00:00
|
|
|
if( aFrame->GetName() == PCB_EDIT_FRAME_NAME )
|
|
|
|
{
|
|
|
|
FOOTPRINT* fp = static_cast<FOOTPRINT*>( m_parent );
|
|
|
|
|
|
|
|
if( fp )
|
|
|
|
aList.emplace_back( _( "Footprint" ), fp->GetReference() );
|
|
|
|
}
|
2007-08-20 19:33:15 +00:00
|
|
|
|
2021-03-03 16:38:41 +00:00
|
|
|
// Don't use GetShownText() here; we want to show the user the variable references
|
|
|
|
aList.emplace_back( _( "Text" ), UnescapeString( GetText() ) );
|
2007-08-20 19:33:15 +00:00
|
|
|
|
2013-04-07 11:55:18 +00:00
|
|
|
wxASSERT( m_Type >= TEXT_is_REFERENCE && m_Type <= TEXT_is_DIVERS );
|
2020-11-30 14:35:48 +00:00
|
|
|
aList.emplace_back( _( "Type" ), text_type_msg[m_Type] );
|
2007-08-20 19:33:15 +00:00
|
|
|
|
2021-10-31 16:32:24 +00:00
|
|
|
if( aFrame->GetName() == PCB_EDIT_FRAME_NAME && IsLocked() )
|
2021-04-21 14:40:16 +00:00
|
|
|
aList.emplace_back( _( "Status" ), _( "Locked" ) );
|
2021-01-12 09:00:21 +00:00
|
|
|
|
2020-11-30 14:35:48 +00:00
|
|
|
aList.emplace_back( _( "Display" ), IsVisible() ? _( "Yes" ) : _( "No" ) );
|
2007-08-20 19:33:15 +00:00
|
|
|
|
2013-04-07 11:55:18 +00:00
|
|
|
// Display text layer
|
2020-11-30 14:35:48 +00:00
|
|
|
aList.emplace_back( _( "Layer" ), GetLayerName() );
|
2013-01-12 17:32:24 +00:00
|
|
|
|
2020-11-30 14:35:48 +00:00
|
|
|
aList.emplace_back( _( "Mirror" ), IsMirrored() ? _( "Yes" ) : _( "No" ) );
|
2007-08-20 19:33:15 +00:00
|
|
|
|
2021-12-28 22:13:54 +00:00
|
|
|
msg.Printf( wxT( "%g" ), GetTextAngle().AsDegrees() );
|
2020-11-30 14:35:48 +00:00
|
|
|
aList.emplace_back( _( "Angle" ), msg );
|
2007-08-20 19:33:15 +00:00
|
|
|
|
2020-10-02 20:51:24 +00:00
|
|
|
msg = MessageTextFromValue( aFrame->GetUserUnits(), GetTextThickness() );
|
2020-11-30 14:35:48 +00:00
|
|
|
aList.emplace_back( _( "Thickness" ), msg );
|
2007-08-20 19:33:15 +00:00
|
|
|
|
2020-10-02 20:51:24 +00:00
|
|
|
msg = MessageTextFromValue( aFrame->GetUserUnits(), GetTextWidth() );
|
2020-11-30 14:35:48 +00:00
|
|
|
aList.emplace_back( _( "Width" ), msg );
|
2007-08-20 19:33:15 +00:00
|
|
|
|
2020-10-02 20:51:24 +00:00
|
|
|
msg = MessageTextFromValue( aFrame->GetUserUnits(), GetTextHeight() );
|
2020-11-30 14:35:48 +00:00
|
|
|
aList.emplace_back( _( "Height" ), msg );
|
2007-08-20 19:33:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
wxString FP_TEXT::GetSelectMenuText( EDA_UNITS aUnits ) const
|
2011-07-14 15:42:44 +00:00
|
|
|
{
|
|
|
|
switch( m_Type )
|
|
|
|
{
|
|
|
|
case TEXT_is_REFERENCE:
|
2020-09-19 18:53:58 +00:00
|
|
|
return wxString::Format( _( "Reference '%s'" ),
|
2020-11-13 15:15:52 +00:00
|
|
|
static_cast<FOOTPRINT*>( GetParent() )->GetReference() );
|
2011-07-14 15:42:44 +00:00
|
|
|
|
|
|
|
case TEXT_is_VALUE:
|
2020-09-19 18:53:58 +00:00
|
|
|
return wxString::Format( _( "Value '%s' of %s" ),
|
2018-04-10 10:52:12 +00:00
|
|
|
GetShownText(),
|
2020-11-13 15:15:52 +00:00
|
|
|
static_cast<FOOTPRINT*>( GetParent() )->GetReference() );
|
2011-07-14 15:42:44 +00:00
|
|
|
|
2020-09-19 18:53:58 +00:00
|
|
|
default:
|
|
|
|
return wxString::Format( _( "Footprint Text '%s' of %s" ),
|
2018-04-10 10:52:12 +00:00
|
|
|
ShortenedShownText(),
|
2020-11-13 15:15:52 +00:00
|
|
|
static_cast<FOOTPRINT*>( GetParent() )->GetReference() );
|
2011-07-14 15:42:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-03-08 02:59:07 +00:00
|
|
|
BITMAPS FP_TEXT::GetMenuImage() const
|
2017-02-20 12:20:39 +00:00
|
|
|
{
|
2021-03-08 02:59:07 +00:00
|
|
|
return BITMAPS::text;
|
2017-02-20 12:20:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
EDA_ITEM* FP_TEXT::Clone() const
|
2012-01-14 19:50:32 +00:00
|
|
|
{
|
2020-10-04 23:34:59 +00:00
|
|
|
return new FP_TEXT( *this );
|
2012-01-14 19:50:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
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() )
|
2017-01-23 20:30:11 +00:00
|
|
|
text_area = text_area.GetBoundingBoxRotated( GetTextPos(), angle );
|
2014-01-07 13:09:27 +00:00
|
|
|
|
|
|
|
return BOX2I( text_area.GetPosition(), text_area.GetSize() );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
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
|
|
|
{
|
2018-03-14 22:55:01 +00:00
|
|
|
if( IsVisible() )
|
2018-03-15 10:59:59 +00:00
|
|
|
aLayers[0] = GetLayer();
|
2018-03-14 22:55:01 +00:00
|
|
|
else
|
2018-03-15 10:59:59 +00:00
|
|
|
aLayers[0] = LAYER_MOD_TEXT_INVISIBLE;
|
|
|
|
|
|
|
|
aCount = 1;
|
2015-06-16 15:03:36 +00:00
|
|
|
}
|
2014-01-26 21:02:48 +00:00
|
|
|
|
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
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
double FP_TEXT::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
|
2015-06-16 15:03:36 +00:00
|
|
|
{
|
2020-09-21 15:03:08 +00:00
|
|
|
constexpr double HIDE = (double)std::numeric_limits<double>::max();
|
2015-06-16 15:03:36 +00:00
|
|
|
|
2016-12-02 17:58:12 +00:00
|
|
|
if( !aView )
|
2020-09-21 15:03:08 +00:00
|
|
|
return 0.0;
|
2015-07-24 07:42:46 +00:00
|
|
|
|
2018-03-15 10:59:59 +00:00
|
|
|
// 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;
|
|
|
|
|
2021-06-06 16:57:26 +00:00
|
|
|
RENDER_SETTINGS* renderSettings = aView->GetPainter()->GetSettings();
|
|
|
|
COLOR4D backgroundColor = renderSettings->GetLayerColor( LAYER_PCB_BACKGROUND );
|
|
|
|
|
2018-02-17 18:03:22 +00:00
|
|
|
// Handle Render tab switches
|
2021-06-03 21:42:07 +00:00
|
|
|
if( m_Type == TEXT_is_VALUE || GetText() == wxT( "${VALUE}" ) )
|
|
|
|
{
|
|
|
|
if( !aView->IsLayerVisible( LAYER_MOD_VALUES )
|
|
|
|
|| renderSettings->GetLayerColor( LAYER_MOD_VALUES ) == backgroundColor )
|
|
|
|
{
|
|
|
|
return HIDE;
|
|
|
|
}
|
|
|
|
}
|
2015-06-16 15:03:36 +00:00
|
|
|
|
2021-06-03 21:42:07 +00:00
|
|
|
if( m_Type == TEXT_is_REFERENCE || GetText() == wxT( "${REFERENCE}" ) )
|
|
|
|
{
|
|
|
|
if( !aView->IsLayerVisible( LAYER_MOD_REFERENCES )
|
|
|
|
|| renderSettings->GetLayerColor( LAYER_MOD_REFERENCES ) == backgroundColor )
|
|
|
|
{
|
|
|
|
return HIDE;
|
|
|
|
}
|
|
|
|
}
|
2018-02-17 18:03:22 +00:00
|
|
|
|
|
|
|
if( !IsParentFlipped() && !aView->IsLayerVisible( LAYER_MOD_FR ) )
|
|
|
|
return HIDE;
|
|
|
|
|
|
|
|
if( IsParentFlipped() && !aView->IsLayerVisible( LAYER_MOD_BK ) )
|
|
|
|
return HIDE;
|
2015-06-16 15:03:36 +00:00
|
|
|
|
2021-10-22 20:12:57 +00:00
|
|
|
if( !aView->IsLayerVisible( LAYER_MOD_TEXT ) )
|
2018-02-17 18:03:22 +00:00
|
|
|
return HIDE;
|
2015-06-16 15:03:36 +00:00
|
|
|
|
2018-02-17 18:03:22 +00:00
|
|
|
// Other layers are shown without any conditions
|
2020-09-21 15:03:08 +00:00
|
|
|
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
|
|
|
}
|
2014-09-10 15:18:42 +00:00
|
|
|
|
2015-06-16 15:03:36 +00:00
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
wxString FP_TEXT::GetShownText( int aDepth ) const
|
2014-10-04 15:15:38 +00:00
|
|
|
{
|
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-03-26 11:02:59 +00:00
|
|
|
|
2020-11-13 02:57:11 +00:00
|
|
|
std::function<bool( wxString* )> footprintResolver =
|
2020-04-06 13:06:57 +00:00
|
|
|
[&]( wxString* token ) -> bool
|
2020-04-05 19:51:48 +00:00
|
|
|
{
|
2020-11-13 02:57:11 +00:00
|
|
|
return parentFootprint && parentFootprint->ResolveTextVar( token, aDepth );
|
2020-04-05 19:51:48 +00:00
|
|
|
};
|
|
|
|
|
2020-08-19 18:21:24 +00:00
|
|
|
std::function<bool( wxString* )> boardTextResolver =
|
|
|
|
[&]( wxString* token ) -> bool
|
|
|
|
{
|
|
|
|
return board->ResolveTextVar( token, aDepth + 1 );
|
|
|
|
};
|
|
|
|
|
2021-06-29 12:54:40 +00:00
|
|
|
wxString text = EDA_TEXT::GetShownText();
|
2020-04-24 20:33:59 +00:00
|
|
|
|
2021-06-29 12:54:40 +00:00
|
|
|
if( HasTextVars() )
|
2020-04-24 20:33:59 +00:00
|
|
|
{
|
|
|
|
PROJECT* project = nullptr;
|
2020-04-06 13:06:57 +00:00
|
|
|
|
2020-11-13 02:57:11 +00:00
|
|
|
if( parentFootprint && parentFootprint->GetParent() )
|
|
|
|
project = static_cast<BOARD*>( parentFootprint->GetParent() )->GetProject();
|
2020-04-06 13:06:57 +00:00
|
|
|
|
2020-04-24 20:33:59 +00:00
|
|
|
if( aDepth < 10 )
|
2021-01-17 15:47:04 +00:00
|
|
|
text = ExpandTextVars( text, &footprintResolver, &boardTextResolver, project );
|
2020-04-24 20:33:59 +00:00
|
|
|
}
|
2020-04-06 13:06:57 +00:00
|
|
|
|
|
|
|
return text;
|
2014-10-04 15:15:38 +00:00
|
|
|
}
|
2020-02-02 18:40:14 +00:00
|
|
|
|
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
std::shared_ptr<SHAPE> FP_TEXT::GetEffectiveShape( PCB_LAYER_ID aLayer ) const
|
2020-08-08 22:37:41 +00:00
|
|
|
{
|
2020-10-02 12:29:17 +00:00
|
|
|
return GetEffectiveTextShape();
|
2020-08-08 22:37:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-10-25 19:50:33 +00:00
|
|
|
void FP_TEXT::TransformTextShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer,
|
|
|
|
PCB_LAYER_ID aLayer, int aClearance,
|
|
|
|
int aError, ERROR_LOC aErrorLoc ) const
|
|
|
|
{
|
2022-01-10 14:03:53 +00:00
|
|
|
KIGFX::GAL_DISPLAY_OPTIONS empty_opts;
|
|
|
|
KIFONT::FONT* font = GetDrawFont();
|
|
|
|
int penWidth = GetEffectiveTextPenWidth();
|
2021-10-25 19:50:33 +00:00
|
|
|
|
2022-01-10 14:03:53 +00:00
|
|
|
CALLBACK_GAL callback_gal( empty_opts,
|
2022-01-10 01:53:01 +00:00
|
|
|
// 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 14:03:53 +00:00
|
|
|
|
2022-01-10 15:30:19 +00:00
|
|
|
TEXT_ATTRIBUTES attrs = GetAttributes();
|
|
|
|
attrs.m_Angle = GetDrawRotation();
|
|
|
|
|
|
|
|
font->Draw( &callback_gal, GetShownText(), GetTextPos(), attrs );
|
2021-10-25 19:50:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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 );
|
|
|
|
|
|
|
|
const FOOTPRINT* parentFootprint = static_cast<const FOOTPRINT*>( m_parent );
|
|
|
|
|
|
|
|
if( parentFootprint )
|
2022-01-20 20:54:22 +00:00
|
|
|
buffer.Rotate( -GetDrawRotation(), GetTextPos() );
|
2021-10-25 19:50:33 +00:00
|
|
|
|
|
|
|
aCornerBuffer.Append( buffer );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-14 23:37:26 +00:00
|
|
|
static struct FP_TEXT_DESC
|
2020-02-02 18:40:14 +00:00
|
|
|
{
|
2020-10-14 23:37:26 +00:00
|
|
|
FP_TEXT_DESC()
|
2020-02-02 18:40:14 +00:00
|
|
|
{
|
|
|
|
PROPERTY_MANAGER& propMgr = PROPERTY_MANAGER::Instance();
|
2020-10-04 23:34:59 +00:00
|
|
|
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 ) );
|
2021-02-19 21:06:28 +00:00
|
|
|
|
|
|
|
propMgr.AddProperty( new PROPERTY<FP_TEXT, wxString>( _HKI( "Parent" ),
|
|
|
|
NO_SETTER( FP_TEXT, wxString ), &FP_TEXT::GetParentAsString ) );
|
2020-02-02 18:40:14 +00:00
|
|
|
}
|
2020-10-14 23:37:26 +00:00
|
|
|
} _FP_TEXT_DESC;
|