2012-01-14 19:50:32 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2015-07-31 19:04:30 +00:00
|
|
|
* Copyright (C) 2015 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
|
2012-06-08 09:56:42 +00:00
|
|
|
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
|
|
|
* Copyright (C) 2012 Wayne Stambaugh <stambaughw@verizon.net>
|
2015-07-31 19:04:30 +00:00
|
|
|
* Copyright (C) 1992-2015 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
|
|
|
|
*/
|
|
|
|
|
2021-03-20 15:35:37 +00:00
|
|
|
#include <core/wx_stl_compat.h>
|
2017-02-20 12:20:39 +00:00
|
|
|
#include <bitmaps.h>
|
2020-11-18 01:21:04 +00:00
|
|
|
#include <core/mirror.h>
|
2021-03-20 15:35:37 +00:00
|
|
|
#include <macros.h>
|
2020-01-07 17:12:59 +00:00
|
|
|
#include <math/util.h> // for KiROUND
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <settings/color_settings.h>
|
|
|
|
#include <settings/settings_manager.h>
|
2018-01-29 20:58:58 +00:00
|
|
|
#include <pcb_edit_frame.h>
|
2020-11-12 20:19:22 +00:00
|
|
|
#include <footprint.h>
|
2020-10-04 23:34:59 +00:00
|
|
|
#include <fp_shape.h>
|
2018-02-17 18:03:22 +00:00
|
|
|
#include <view/view.h>
|
|
|
|
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2021-07-21 18:31:25 +00:00
|
|
|
FP_SHAPE::FP_SHAPE( FOOTPRINT* parent, SHAPE_T aShape ) :
|
2021-07-14 20:03:32 +00:00
|
|
|
PCB_SHAPE( parent, PCB_FP_SHAPE_T, aShape )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2020-11-14 14:29:11 +00:00
|
|
|
m_layer = F_SilkS;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-06 20:26:59 +00:00
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
FP_SHAPE::~FP_SHAPE()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-08-06 20:26:59 +00:00
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
void FP_SHAPE::SetLocalCoord()
|
2014-07-09 09:59:24 +00:00
|
|
|
{
|
2020-11-14 18:11:28 +00:00
|
|
|
FOOTPRINT* fp = static_cast<FOOTPRINT*>( m_parent );
|
2014-07-09 09:59:24 +00:00
|
|
|
|
2020-10-14 23:37:26 +00:00
|
|
|
if( fp == NULL )
|
2014-07-09 09:59:24 +00:00
|
|
|
{
|
2021-10-14 23:39:31 +00:00
|
|
|
m_start0 = m_start;
|
|
|
|
m_end0 = m_end;
|
2021-07-17 19:56:18 +00:00
|
|
|
m_arcCenter0 = m_arcCenter;
|
2021-07-18 12:31:56 +00:00
|
|
|
m_bezierC1_0 = m_bezierC1;
|
|
|
|
m_bezierC2_0 = m_bezierC2;
|
2014-07-09 09:59:24 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-10-14 23:39:31 +00:00
|
|
|
m_start0 = m_start - fp->GetPosition();
|
|
|
|
m_end0 = m_end - fp->GetPosition();
|
2021-07-17 19:56:18 +00:00
|
|
|
m_arcCenter0 = m_arcCenter - fp->GetPosition();
|
2021-10-14 23:39:31 +00:00
|
|
|
m_bezierC1_0 = m_bezierC1 - fp->GetPosition();
|
|
|
|
m_bezierC2_0 = m_bezierC2 - fp->GetPosition();
|
|
|
|
|
2020-10-14 23:37:26 +00:00
|
|
|
double angle = fp->GetOrientation();
|
2021-10-14 23:39:31 +00:00
|
|
|
RotatePoint( &m_start0.x, &m_start0.y, -angle );
|
|
|
|
RotatePoint( &m_end0.x, &m_end0.y, -angle );
|
2021-07-17 19:56:18 +00:00
|
|
|
RotatePoint( &m_arcCenter0.x, &m_arcCenter0.y, -angle );
|
2021-07-18 12:31:56 +00:00
|
|
|
RotatePoint( &m_bezierC1_0.x, &m_bezierC1_0.y, -angle );
|
|
|
|
RotatePoint( &m_bezierC2_0.x, &m_bezierC2_0.y, -angle );
|
2014-07-09 09:59:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
void FP_SHAPE::SetDrawCoord()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2020-11-14 18:11:28 +00:00
|
|
|
FOOTPRINT* fp = static_cast<FOOTPRINT*>( m_parent );
|
2007-08-06 20:26:59 +00:00
|
|
|
|
2021-10-14 23:39:31 +00:00
|
|
|
m_start = m_start0;
|
|
|
|
m_end = m_end0;
|
2021-07-17 19:56:18 +00:00
|
|
|
m_arcCenter = m_arcCenter0;
|
2021-10-14 23:39:31 +00:00
|
|
|
m_bezierC1 = m_bezierC1_0;
|
|
|
|
m_bezierC2 = m_bezierC2_0;
|
2007-08-06 20:26:59 +00:00
|
|
|
|
2020-10-14 23:37:26 +00:00
|
|
|
if( fp )
|
2007-08-06 20:26:59 +00:00
|
|
|
{
|
2020-11-13 21:00:28 +00:00
|
|
|
RotatePoint( &m_start.x, &m_start.y, fp->GetOrientation() );
|
|
|
|
RotatePoint( &m_end.x, &m_end.y, fp->GetOrientation() );
|
2021-07-17 19:56:18 +00:00
|
|
|
RotatePoint( &m_arcCenter.x, &m_arcCenter.y, fp->GetOrientation() );
|
2020-11-13 21:00:28 +00:00
|
|
|
RotatePoint( &m_bezierC1.x, &m_bezierC1.y, fp->GetOrientation() );
|
|
|
|
RotatePoint( &m_bezierC2.x, &m_bezierC2.y, fp->GetOrientation() );
|
|
|
|
|
2021-10-14 23:39:31 +00:00
|
|
|
m_start += fp->GetPosition();
|
|
|
|
m_end += fp->GetPosition();
|
2021-07-17 19:56:18 +00:00
|
|
|
m_arcCenter += fp->GetPosition();
|
2021-10-14 23:39:31 +00:00
|
|
|
m_bezierC1 += fp->GetPosition();
|
|
|
|
m_bezierC2 += fp->GetPosition();
|
2007-08-06 20:26:59 +00:00
|
|
|
}
|
2018-07-07 11:04:01 +00:00
|
|
|
|
2020-11-13 21:00:28 +00:00
|
|
|
RebuildBezierToSegmentsPointsList( m_width );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
void FP_SHAPE::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
|
|
|
if( aFrame->GetName() == PCB_EDIT_FRAME_NAME )
|
|
|
|
{
|
|
|
|
FOOTPRINT* fp = static_cast<FOOTPRINT*>( m_parent );
|
2009-11-20 19:51:39 +00:00
|
|
|
|
2021-10-31 16:32:24 +00:00
|
|
|
if( fp )
|
|
|
|
aList.emplace_back( _( "Footprint" ), fp->GetReference() );
|
|
|
|
}
|
2014-11-15 13:09:59 +00:00
|
|
|
|
|
|
|
// append the features shared with the base class
|
2020-10-04 23:34:59 +00:00
|
|
|
PCB_SHAPE::GetMsgPanelInfo( aFrame, aList );
|
2007-08-20 19:33:15 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
wxString FP_SHAPE::GetSelectMenuText( EDA_UNITS aUnits ) const
|
2011-07-14 15:42:44 +00:00
|
|
|
{
|
2020-09-19 16:12:00 +00:00
|
|
|
return wxString::Format( _( "%s on %s" ),
|
2021-07-14 20:03:32 +00:00
|
|
|
ShowShape(),
|
2018-04-10 10:52:12 +00:00
|
|
|
GetLayerName() );
|
2011-07-14 15:42:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-03-08 02:59:07 +00:00
|
|
|
BITMAPS FP_SHAPE::GetMenuImage() const
|
2017-02-20 12:20:39 +00:00
|
|
|
{
|
2021-03-08 02:59:07 +00:00
|
|
|
return BITMAPS::show_mod_edge;
|
2017-02-20 12:20:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
EDA_ITEM* FP_SHAPE::Clone() const
|
2012-01-14 19:50:32 +00:00
|
|
|
{
|
2020-10-04 23:34:59 +00:00
|
|
|
return new FP_SHAPE( *this );
|
2012-01-14 19:50:32 +00:00
|
|
|
}
|
|
|
|
|
2014-09-24 16:42:56 +00:00
|
|
|
|
2021-07-17 19:56:18 +00:00
|
|
|
wxPoint FP_SHAPE::GetCenter0() const
|
2020-08-15 15:42:18 +00:00
|
|
|
{
|
2021-07-17 19:56:18 +00:00
|
|
|
switch( m_shape )
|
|
|
|
{
|
|
|
|
case SHAPE_T::ARC:
|
|
|
|
return m_arcCenter0;
|
|
|
|
|
|
|
|
case SHAPE_T::CIRCLE:
|
|
|
|
return m_start0;
|
|
|
|
|
|
|
|
default:
|
|
|
|
UNIMPLEMENTED_FOR( SHAPE_T_asString() );
|
|
|
|
return wxPoint();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-08 09:59:17 +00:00
|
|
|
|
2021-07-17 19:56:18 +00:00
|
|
|
void FP_SHAPE::SetCenter0( const wxPoint& aCenter )
|
|
|
|
{
|
|
|
|
switch( m_shape )
|
2020-10-08 09:59:17 +00:00
|
|
|
{
|
2021-07-17 19:56:18 +00:00
|
|
|
case SHAPE_T::ARC:
|
|
|
|
m_arcCenter0 = aCenter;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SHAPE_T::CIRCLE:
|
|
|
|
m_start0 = aCenter;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
UNIMPLEMENTED_FOR( SHAPE_T_asString() );
|
2020-10-08 09:59:17 +00:00
|
|
|
}
|
2020-08-15 15:42:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-10-14 23:39:31 +00:00
|
|
|
wxPoint FP_SHAPE::GetArcMid0() const
|
|
|
|
{
|
|
|
|
wxPoint mid0 = m_start0;
|
|
|
|
RotatePoint( &mid0, m_arcCenter0, -GetArcAngle() / 2.0 );
|
|
|
|
return mid0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FP_SHAPE::SetArcAngleAndEnd0( double aAngle, bool aCheckNegativeAngle )
|
2021-07-17 19:56:18 +00:00
|
|
|
{
|
2021-10-14 23:39:31 +00:00
|
|
|
m_end0 = m_start0;
|
|
|
|
RotatePoint( &m_end0, m_arcCenter0, -NormalizeAngle360Max( aAngle ) );
|
2021-07-17 19:56:18 +00:00
|
|
|
|
2021-10-14 23:39:31 +00:00
|
|
|
if( aCheckNegativeAngle && aAngle < 0 )
|
|
|
|
std::swap( m_start0, m_end0 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FP_SHAPE::SetArcGeometry0( const wxPoint& aStart0, const wxPoint& aMid0, const wxPoint& aEnd0 )
|
|
|
|
{
|
|
|
|
m_start0 = aStart0;
|
|
|
|
m_end0 = aEnd0;
|
|
|
|
m_arcCenter0 = CalcArcCenter( aStart0, aMid0, aEnd0 );
|
2021-07-17 19:56:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
void FP_SHAPE::Flip( const wxPoint& aCentre, bool aFlipLeftRight )
|
2014-09-24 16:42:56 +00:00
|
|
|
{
|
2019-10-01 10:01:40 +00:00
|
|
|
wxPoint pt( 0, 0 );
|
2014-09-24 16:42:56 +00:00
|
|
|
|
|
|
|
switch( GetShape() )
|
|
|
|
{
|
2021-07-21 18:31:25 +00:00
|
|
|
case SHAPE_T::ARC:
|
|
|
|
case SHAPE_T::SEGMENT:
|
2021-07-18 23:08:54 +00:00
|
|
|
case SHAPE_T::RECT:
|
|
|
|
case SHAPE_T::CIRCLE:
|
2021-07-21 18:31:25 +00:00
|
|
|
case SHAPE_T::BEZIER:
|
2020-11-16 00:45:43 +00:00
|
|
|
// If Start0 and Start are equal (ie: Footprint Editor), then flip both sets around the
|
2019-10-01 10:01:40 +00:00
|
|
|
// centre point.
|
2021-07-18 12:31:56 +00:00
|
|
|
if( m_start == m_start0 )
|
2019-10-01 10:01:40 +00:00
|
|
|
pt = aCentre;
|
|
|
|
|
2019-07-12 21:02:10 +00:00
|
|
|
if( aFlipLeftRight )
|
|
|
|
{
|
2020-11-13 21:00:28 +00:00
|
|
|
MIRROR( m_start.x, aCentre.x );
|
|
|
|
MIRROR( m_end.x, aCentre.x );
|
2021-07-17 19:56:18 +00:00
|
|
|
MIRROR( m_arcCenter.x, aCentre.x );
|
2020-11-13 21:00:28 +00:00
|
|
|
MIRROR( m_bezierC1.x, aCentre.x );
|
|
|
|
MIRROR( m_bezierC2.x, aCentre.x );
|
2021-07-18 12:31:56 +00:00
|
|
|
MIRROR( m_start0.x, pt.x );
|
|
|
|
MIRROR( m_end0.x, pt.x );
|
2021-07-17 19:56:18 +00:00
|
|
|
MIRROR( m_arcCenter0.x, pt.x );
|
2021-07-18 12:31:56 +00:00
|
|
|
MIRROR( m_bezierC1_0.x, pt.x );
|
|
|
|
MIRROR( m_bezierC2_0.x, pt.x );
|
2019-07-12 21:02:10 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-11-13 21:00:28 +00:00
|
|
|
MIRROR( m_start.y, aCentre.y );
|
|
|
|
MIRROR( m_end.y, aCentre.y );
|
2021-07-17 19:56:18 +00:00
|
|
|
MIRROR( m_arcCenter.y, aCentre.y );
|
2020-11-13 21:00:28 +00:00
|
|
|
MIRROR( m_bezierC1.y, aCentre.y );
|
|
|
|
MIRROR( m_bezierC2.y, aCentre.y );
|
2021-07-18 12:31:56 +00:00
|
|
|
MIRROR( m_start0.y, pt.y );
|
|
|
|
MIRROR( m_end0.y, pt.y );
|
2021-07-17 19:56:18 +00:00
|
|
|
MIRROR( m_arcCenter0.y, pt.y );
|
2021-07-18 12:31:56 +00:00
|
|
|
MIRROR( m_bezierC1_0.y, pt.y );
|
|
|
|
MIRROR( m_bezierC2_0.y, pt.y );
|
2019-07-12 21:02:10 +00:00
|
|
|
}
|
2018-07-07 11:04:01 +00:00
|
|
|
|
2021-07-18 23:08:54 +00:00
|
|
|
if( GetShape() == SHAPE_T::BEZIER )
|
|
|
|
RebuildBezierToSegmentsPointsList( m_width );
|
|
|
|
|
2021-10-18 15:10:39 +00:00
|
|
|
if( GetShape() == SHAPE_T::ARC )
|
|
|
|
{
|
|
|
|
std::swap( m_start, m_end );
|
|
|
|
std::swap( m_start0, m_end0 );
|
|
|
|
}
|
|
|
|
|
2014-09-24 16:42:56 +00:00
|
|
|
break;
|
|
|
|
|
2021-07-21 18:31:25 +00:00
|
|
|
case SHAPE_T::POLY:
|
2020-06-27 18:01:00 +00:00
|
|
|
// polygon corners coordinates are relative to the footprint position, orientation 0
|
2020-11-13 21:00:28 +00:00
|
|
|
m_poly.Mirror( aFlipLeftRight, !aFlipLeftRight );
|
2019-03-23 18:26:44 +00:00
|
|
|
break;
|
2021-07-18 23:08:54 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
UNIMPLEMENTED_FOR( SHAPE_T_asString() );
|
2014-09-24 16:42:56 +00:00
|
|
|
}
|
|
|
|
|
2021-02-20 12:16:45 +00:00
|
|
|
SetLayer( FlipLayer( GetLayer(), GetBoard()->GetCopperLayerCount() ) );
|
2014-09-24 16:42:56 +00:00
|
|
|
}
|
2015-02-28 17:39:05 +00:00
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
bool FP_SHAPE::IsParentFlipped() const
|
2018-02-17 18:03:22 +00:00
|
|
|
{
|
|
|
|
if( GetParent() && GetParent()->GetLayer() == B_Cu )
|
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
2015-07-31 19:04:30 +00:00
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
void FP_SHAPE::Mirror( const wxPoint& aCentre, bool aMirrorAroundXAxis )
|
2015-07-31 19:04:30 +00:00
|
|
|
{
|
|
|
|
// Mirror an edge of the footprint. the layer is not modified
|
|
|
|
// This is a footprint shape modification.
|
2021-02-08 09:11:04 +00:00
|
|
|
|
2015-07-31 19:04:30 +00:00
|
|
|
switch( GetShape() )
|
|
|
|
{
|
2021-07-21 18:31:25 +00:00
|
|
|
case SHAPE_T::ARC:
|
|
|
|
case SHAPE_T::SEGMENT:
|
2021-07-18 23:08:54 +00:00
|
|
|
case SHAPE_T::RECT:
|
|
|
|
case SHAPE_T::CIRCLE:
|
|
|
|
case SHAPE_T::BEZIER:
|
2015-07-31 19:04:30 +00:00
|
|
|
if( aMirrorAroundXAxis )
|
|
|
|
{
|
2021-07-18 12:31:56 +00:00
|
|
|
MIRROR( m_start0.y, aCentre.y );
|
|
|
|
MIRROR( m_end0.y, aCentre.y );
|
2021-07-17 19:56:18 +00:00
|
|
|
MIRROR( m_arcCenter0.y, aCentre.y );
|
2021-07-18 12:31:56 +00:00
|
|
|
MIRROR( m_bezierC1_0.y, aCentre.y );
|
|
|
|
MIRROR( m_bezierC2_0.y, aCentre.y );
|
2015-07-31 19:04:30 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-07-18 12:31:56 +00:00
|
|
|
MIRROR( m_start0.x, aCentre.x );
|
|
|
|
MIRROR( m_end0.x, aCentre.x );
|
2021-07-17 19:56:18 +00:00
|
|
|
MIRROR( m_arcCenter0.x, aCentre.x );
|
2021-07-18 12:31:56 +00:00
|
|
|
MIRROR( m_bezierC1_0.x, aCentre.x );
|
|
|
|
MIRROR( m_bezierC2_0.x, aCentre.x );
|
2015-07-31 19:04:30 +00:00
|
|
|
}
|
2018-07-07 11:04:01 +00:00
|
|
|
|
2022-01-21 15:00:49 +00:00
|
|
|
if( GetShape() == SHAPE_T::ARC )
|
|
|
|
{
|
|
|
|
std::swap( m_start, m_end );
|
|
|
|
std::swap( m_start0, m_end0 );
|
|
|
|
}
|
|
|
|
|
2021-07-18 23:08:54 +00:00
|
|
|
if( GetShape() == SHAPE_T::BEZIER )
|
|
|
|
RebuildBezierToSegmentsPointsList( m_width );
|
2018-07-07 11:04:01 +00:00
|
|
|
|
|
|
|
break;
|
2015-07-31 19:04:30 +00:00
|
|
|
|
2021-07-21 18:31:25 +00:00
|
|
|
case SHAPE_T::POLY:
|
2015-07-31 19:04:30 +00:00
|
|
|
// polygon corners coordinates are always relative to the
|
|
|
|
// footprint position, orientation 0
|
2020-11-13 21:00:28 +00:00
|
|
|
m_poly.Mirror( !aMirrorAroundXAxis, aMirrorAroundXAxis );
|
2019-03-23 18:26:44 +00:00
|
|
|
break;
|
2021-07-18 23:08:54 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
UNIMPLEMENTED_FOR( SHAPE_T_asString() );
|
2015-07-31 19:04:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SetDrawCoord();
|
|
|
|
}
|
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
void FP_SHAPE::Rotate( const wxPoint& aRotCentre, double aAngle )
|
2015-02-28 17:39:05 +00:00
|
|
|
{
|
2020-06-27 18:01:00 +00:00
|
|
|
// We should rotate the relative coordinates, but to avoid duplicate code do the base class
|
2020-10-14 23:37:26 +00:00
|
|
|
// rotation of draw coordinates, which is acceptable because in the footprint editor
|
|
|
|
// m_Pos0 = m_Pos
|
2020-10-04 23:34:59 +00:00
|
|
|
PCB_SHAPE::Rotate( aRotCentre, aAngle );
|
2015-02-28 17:39:05 +00:00
|
|
|
|
2020-06-27 18:01:00 +00:00
|
|
|
// and now update the relative coordinates, which are the reference in most transforms.
|
2015-02-28 17:39:05 +00:00
|
|
|
SetLocalCoord();
|
|
|
|
}
|
2015-07-31 19:04:30 +00:00
|
|
|
|
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
void FP_SHAPE::Move( const wxPoint& aMoveVector )
|
2015-07-31 19:04:30 +00:00
|
|
|
{
|
|
|
|
// Move an edge of the footprint.
|
|
|
|
// This is a footprint shape modification.
|
|
|
|
|
|
|
|
switch( GetShape() )
|
|
|
|
{
|
2021-07-18 23:08:54 +00:00
|
|
|
case SHAPE_T::ARC:
|
|
|
|
case SHAPE_T::SEGMENT:
|
|
|
|
case SHAPE_T::RECT:
|
|
|
|
case SHAPE_T::CIRCLE:
|
|
|
|
case SHAPE_T::BEZIER:
|
|
|
|
m_start0 += aMoveVector;
|
|
|
|
m_end0 += aMoveVector;
|
|
|
|
m_arcCenter0 += aMoveVector;
|
|
|
|
m_bezierC1_0 += aMoveVector;
|
|
|
|
m_bezierC2_0 += aMoveVector;
|
2015-07-31 19:04:30 +00:00
|
|
|
break;
|
|
|
|
|
2021-07-21 18:31:25 +00:00
|
|
|
case SHAPE_T::POLY:
|
2015-07-31 19:04:30 +00:00
|
|
|
// polygon corners coordinates are always relative to the
|
|
|
|
// footprint position, orientation 0
|
2020-11-13 21:00:28 +00:00
|
|
|
m_poly.Move( VECTOR2I( aMoveVector ) );
|
2018-07-22 12:50:35 +00:00
|
|
|
|
|
|
|
break;
|
2021-07-18 23:08:54 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
UNIMPLEMENTED_FOR( SHAPE_T_asString() );
|
2015-07-31 19:04:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SetDrawCoord();
|
|
|
|
}
|
2018-02-17 18:03:22 +00:00
|
|
|
|
2020-02-02 18:40:14 +00:00
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
double FP_SHAPE::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
|
2018-02-17 18:03:22 +00:00
|
|
|
{
|
2020-09-21 15:03:08 +00:00
|
|
|
constexpr double HIDE = std::numeric_limits<double>::max();
|
2018-02-17 18:03:22 +00:00
|
|
|
|
|
|
|
if( !aView )
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
// Handle Render tab switches
|
|
|
|
if( !IsParentFlipped() && !aView->IsLayerVisible( LAYER_MOD_FR ) )
|
|
|
|
return HIDE;
|
|
|
|
|
|
|
|
if( IsParentFlipped() && !aView->IsLayerVisible( LAYER_MOD_BK ) )
|
|
|
|
return HIDE;
|
|
|
|
|
|
|
|
// Other layers are shown without any conditions
|
2020-09-21 15:03:08 +00:00
|
|
|
return 0.0;
|
2018-02-17 18:03:22 +00:00
|
|
|
}
|
2020-02-02 18:40:14 +00:00
|
|
|
|
|
|
|
|
2020-10-14 23:37:26 +00:00
|
|
|
static struct FP_SHAPE_DESC
|
2020-02-02 18:40:14 +00:00
|
|
|
{
|
2020-10-14 23:37:26 +00:00
|
|
|
FP_SHAPE_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_SHAPE );
|
2021-10-14 23:39:31 +00:00
|
|
|
propMgr.AddTypeCast( new TYPE_CAST<FP_SHAPE, BOARD_ITEM> );
|
|
|
|
propMgr.AddTypeCast( new TYPE_CAST<FP_SHAPE, EDA_SHAPE> );
|
|
|
|
propMgr.AddTypeCast( new TYPE_CAST<FP_SHAPE, PCB_SHAPE> );
|
|
|
|
propMgr.InheritsAfter( TYPE_HASH( FP_SHAPE ), TYPE_HASH( BOARD_ITEM ) );
|
|
|
|
propMgr.InheritsAfter( TYPE_HASH( FP_SHAPE ), TYPE_HASH( EDA_SHAPE ) );
|
2020-10-04 23:34:59 +00:00
|
|
|
propMgr.InheritsAfter( TYPE_HASH( FP_SHAPE ), TYPE_HASH( PCB_SHAPE ) );
|
2021-02-19 21:06:28 +00:00
|
|
|
|
|
|
|
propMgr.AddProperty( new PROPERTY<FP_SHAPE, wxString>( _HKI( "Parent" ),
|
|
|
|
NO_SETTER( FP_SHAPE, wxString ), &FP_SHAPE::GetParentAsString ) );
|
2020-02-02 18:40:14 +00:00
|
|
|
}
|
2020-10-14 23:37:26 +00:00
|
|
|
} _FP_SHAPE_DESC;
|