2011-10-13 19:56:32 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2012-06-08 09:56:42 +00:00
|
|
|
* Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
|
|
|
|
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
|
|
|
* Copyright (C) 2012 Wayne Stambaugh <stambaughw@verizon.net>
|
2019-03-27 12:38:29 +00:00
|
|
|
* Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors.
|
2011-10-13 19:56: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 15:39:40 +00:00
|
|
|
#include <pcb_base_frame.h>
|
2020-07-27 19:41:50 +00:00
|
|
|
#include <connectivity/connectivity_data.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <class_board.h>
|
|
|
|
#include <class_track.h>
|
2012-04-27 14:15:11 +00:00
|
|
|
#include <base_units.h>
|
2017-02-20 12:20:39 +00:00
|
|
|
#include <bitmaps.h>
|
2020-10-15 22:39:33 +00:00
|
|
|
#include <kicad_string.h>
|
2018-02-19 14:48:22 +00:00
|
|
|
#include <view/view.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <settings/color_settings.h>
|
|
|
|
#include <settings/settings_manager.h>
|
2020-10-16 15:51:24 +00:00
|
|
|
#include <i18n_utility.h>
|
2020-08-08 22:37:41 +00:00
|
|
|
#include <geometry/shape_segment.h>
|
|
|
|
#include <geometry/shape_circle.h>
|
|
|
|
#include <geometry/shape_arc.h>
|
2020-09-15 19:13:45 +00:00
|
|
|
#include <drc/drc_engine.h>
|
2008-03-11 01:19:08 +00:00
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
TRACK::TRACK( BOARD_ITEM* aParent, KICAD_T idtype ) :
|
|
|
|
BOARD_CONNECTED_ITEM( aParent, idtype )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2020-04-21 10:47:48 +00:00
|
|
|
m_Width = Millimeter2iu( 0.2 ); // Gives a reasonable default width
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-08 20:51:08 +00:00
|
|
|
|
2012-03-17 14:39:27 +00:00
|
|
|
EDA_ITEM* TRACK::Clone() const
|
2012-01-14 19:50:32 +00:00
|
|
|
{
|
|
|
|
return new TRACK( *this );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-03-27 12:38:29 +00:00
|
|
|
EDA_ITEM* ARC::Clone() const
|
|
|
|
{
|
|
|
|
return new ARC( *this );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
VIA::VIA( BOARD_ITEM* aParent ) :
|
|
|
|
TRACK( aParent, PCB_VIA_T )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2019-12-28 00:55:11 +00:00
|
|
|
SetViaType( VIATYPE::THROUGH );
|
2014-06-24 16:17:18 +00:00
|
|
|
m_BottomLayer = B_Cu;
|
2014-04-25 06:00:04 +00:00
|
|
|
SetDrillDefault();
|
2020-07-27 19:41:50 +00:00
|
|
|
m_RemoveUnconnectedLayer = false;
|
|
|
|
m_KeepTopBottomLayer = true;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-08 20:51:08 +00:00
|
|
|
|
2014-04-25 06:00:04 +00:00
|
|
|
EDA_ITEM* VIA::Clone() const
|
2012-01-14 19:50:32 +00:00
|
|
|
{
|
2014-04-25 06:00:04 +00:00
|
|
|
return new VIA( *this );
|
2012-01-14 19:50:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-12-20 14:11:39 +00:00
|
|
|
wxString VIA::GetSelectMenuText( EDA_UNITS aUnits ) const
|
2011-07-14 15:42:44 +00:00
|
|
|
{
|
2020-09-19 18:53:58 +00:00
|
|
|
wxString formatStr;
|
2011-07-14 15:42:44 +00:00
|
|
|
|
2014-04-25 06:00:04 +00:00
|
|
|
switch( GetViaType() )
|
|
|
|
{
|
2020-09-19 18:53:58 +00:00
|
|
|
case VIATYPE::BLIND_BURIED: formatStr = _( "Blind/Buried Via %s on %s" ); break;
|
|
|
|
case VIATYPE::MICROVIA: formatStr = _( "Micro Via %s on %s" ); break;
|
|
|
|
default: formatStr = _( "Via %s on %s" ); break;
|
2014-04-25 06:00:04 +00:00
|
|
|
}
|
|
|
|
|
2020-09-19 18:53:58 +00:00
|
|
|
return wxString::Format( formatStr,
|
2020-09-16 09:41:40 +00:00
|
|
|
GetNetnameMsg(),
|
2020-09-19 18:53:58 +00:00
|
|
|
LayerMaskDescribe() );
|
2011-07-14 15:42:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-02-20 12:20:39 +00:00
|
|
|
BITMAP_DEF VIA::GetMenuImage() const
|
|
|
|
{
|
2017-12-13 18:42:33 +00:00
|
|
|
return via_xpm;
|
2017-02-20 12:20:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-05-29 12:36:45 +00:00
|
|
|
int TRACK::GetLocalClearance( wxString* aSource ) const
|
2010-04-08 11:33:43 +00:00
|
|
|
{
|
2020-05-29 12:36:45 +00:00
|
|
|
// Not currently implemented
|
|
|
|
return 0;
|
2010-04-08 11:33:43 +00:00
|
|
|
}
|
2007-09-01 12:00:30 +00:00
|
|
|
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2020-05-23 21:48:24 +00:00
|
|
|
void TRACK::GetWidthConstraints( int* aMin, int* aMax, wxString* aSource ) const
|
2020-05-21 17:42:42 +00:00
|
|
|
{
|
2020-09-16 09:41:40 +00:00
|
|
|
*aMin = 0;
|
|
|
|
*aMax = INT_MAX;
|
2020-09-15 19:13:45 +00:00
|
|
|
|
2020-09-16 09:41:40 +00:00
|
|
|
DRC_CONSTRAINT constraint;
|
2020-05-29 12:36:45 +00:00
|
|
|
|
2020-09-16 09:41:40 +00:00
|
|
|
if( GetBoard() && GetBoard()->GetDesignSettings().m_DRCEngine )
|
|
|
|
{
|
|
|
|
BOARD_DESIGN_SETTINGS& bds = GetBoard()->GetDesignSettings();
|
|
|
|
|
|
|
|
constraint = bds.m_DRCEngine->EvalRulesForItems( DRC_CONSTRAINT_TYPE_TRACK_WIDTH, this,
|
|
|
|
nullptr, GetLayer() );
|
|
|
|
}
|
2020-05-21 17:42:42 +00:00
|
|
|
|
2020-09-15 19:13:45 +00:00
|
|
|
if( constraint.Value().HasMin() || constraint.Value().HasMax() )
|
2020-05-21 17:42:42 +00:00
|
|
|
{
|
2020-09-15 19:13:45 +00:00
|
|
|
if( constraint.Value().HasMin() )
|
|
|
|
*aMin = constraint.Value().Min();
|
2020-05-21 17:42:42 +00:00
|
|
|
|
2020-09-15 19:13:45 +00:00
|
|
|
if( constraint.Value().HasMax() )
|
|
|
|
*aMax = constraint.Value().Max();
|
2020-05-21 17:42:42 +00:00
|
|
|
|
2020-09-15 19:13:45 +00:00
|
|
|
if( aSource )
|
|
|
|
*aSource = constraint.GetName();
|
2020-05-23 21:48:24 +00:00
|
|
|
}
|
2020-05-21 17:42:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-08-07 20:18:33 +00:00
|
|
|
int VIA::GetMinAnnulus( PCB_LAYER_ID aLayer, wxString* aSource ) const
|
2020-05-21 17:42:42 +00:00
|
|
|
{
|
2020-09-29 20:40:17 +00:00
|
|
|
if( !FlashLayer( aLayer ) )
|
2020-07-27 19:41:50 +00:00
|
|
|
{
|
|
|
|
if( aSource )
|
2020-09-23 10:46:41 +00:00
|
|
|
*aSource = _( "removed annular ring" );
|
2020-07-27 19:41:50 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-09-16 09:41:40 +00:00
|
|
|
DRC_CONSTRAINT constraint;
|
|
|
|
|
|
|
|
if( GetBoard() && GetBoard()->GetDesignSettings().m_DRCEngine )
|
|
|
|
{
|
|
|
|
BOARD_DESIGN_SETTINGS& bds = GetBoard()->GetDesignSettings();
|
2020-05-21 17:42:42 +00:00
|
|
|
|
2020-09-23 10:46:41 +00:00
|
|
|
constraint = bds.m_DRCEngine->EvalRulesForItems( DRC_CONSTRAINT_TYPE_ANNULAR_WIDTH, this,
|
2020-09-16 09:41:40 +00:00
|
|
|
nullptr, aLayer );
|
|
|
|
}
|
2020-05-21 17:42:42 +00:00
|
|
|
|
2020-09-15 19:13:45 +00:00
|
|
|
if( constraint.Value().HasMin() )
|
2020-05-23 21:48:24 +00:00
|
|
|
{
|
|
|
|
if( aSource )
|
2020-09-15 19:13:45 +00:00
|
|
|
*aSource = constraint.GetName();
|
2020-05-21 17:42:42 +00:00
|
|
|
|
2020-09-15 19:13:45 +00:00
|
|
|
return constraint.Value().Min();
|
2020-05-23 21:48:24 +00:00
|
|
|
}
|
2020-09-15 19:13:45 +00:00
|
|
|
|
|
|
|
return 0;
|
2020-05-21 17:42:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-04-25 06:00:04 +00:00
|
|
|
int VIA::GetDrillValue() const
|
2008-01-12 20:31:56 +00:00
|
|
|
{
|
2019-12-28 00:55:11 +00:00
|
|
|
if( m_Drill > 0 ) // Use the specific value.
|
2008-02-09 08:34:45 +00:00
|
|
|
return m_Drill;
|
2008-01-12 20:31:56 +00:00
|
|
|
|
2009-10-21 19:16:25 +00:00
|
|
|
// Use the default value from the Netclass
|
2020-05-18 00:20:16 +00:00
|
|
|
NETCLASS* netclass = GetNetClass();
|
2009-10-21 19:16:25 +00:00
|
|
|
|
2019-12-28 00:55:11 +00:00
|
|
|
if( GetViaType() == VIATYPE::MICROVIA )
|
2009-10-21 19:16:25 +00:00
|
|
|
return netclass->GetuViaDrill();
|
2008-01-12 20:31:56 +00:00
|
|
|
|
2009-10-21 19:16:25 +00:00
|
|
|
return netclass->GetViaDrill();
|
2008-01-12 20:31:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-31 02:30:28 +00:00
|
|
|
STATUS_FLAGS TRACK::IsPointOnEnds( const wxPoint& point, int min_dist ) const
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2013-03-28 19:12:46 +00:00
|
|
|
STATUS_FLAGS result = 0;
|
2007-08-08 20:51:08 +00:00
|
|
|
|
2011-09-14 15:08:44 +00:00
|
|
|
if( min_dist < 0 )
|
|
|
|
min_dist = m_Width / 2;
|
2007-08-08 20:51:08 +00:00
|
|
|
|
2011-09-14 15:08:44 +00:00
|
|
|
if( min_dist == 0 )
|
2007-08-08 20:51:08 +00:00
|
|
|
{
|
2013-05-04 11:57:09 +00:00
|
|
|
if( m_Start == point )
|
2007-08-08 20:51:08 +00:00
|
|
|
result |= STARTPOINT;
|
2013-05-04 11:57:09 +00:00
|
|
|
|
|
|
|
if( m_End == point )
|
|
|
|
result |= ENDPOINT;
|
2007-08-08 20:51:08 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-05-04 11:57:09 +00:00
|
|
|
double dist = GetLineLength( m_Start, point );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2013-05-01 17:32:36 +00:00
|
|
|
if( min_dist >= KiROUND( dist ) )
|
2007-08-08 20:51:08 +00:00
|
|
|
result |= STARTPOINT;
|
|
|
|
|
2013-05-04 11:57:09 +00:00
|
|
|
dist = GetLineLength( m_End, point );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2013-05-01 17:32:36 +00:00
|
|
|
if( min_dist >= KiROUND( dist ) )
|
2007-08-08 20:51:08 +00:00
|
|
|
result |= ENDPOINT;
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-08 20:51:08 +00:00
|
|
|
|
2013-11-24 17:48:14 +00:00
|
|
|
const EDA_RECT TRACK::GetBoundingBox() const
|
2008-03-05 22:39:33 +00:00
|
|
|
{
|
2008-03-10 13:33:12 +00:00
|
|
|
// end of track is round, this is its radius, rounded up
|
2018-06-12 08:36:41 +00:00
|
|
|
int radius = ( m_Width + 1 ) / 2;
|
|
|
|
int ymax, xmax, ymin, xmin;
|
2008-03-10 15:00:22 +00:00
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
if( Type() == PCB_VIA_T )
|
2008-03-10 15:00:22 +00:00
|
|
|
{
|
|
|
|
ymax = m_Start.y;
|
|
|
|
xmax = m_Start.x;
|
|
|
|
|
|
|
|
ymin = m_Start.y;
|
|
|
|
xmin = m_Start.x;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-09-22 11:19:37 +00:00
|
|
|
ymax = std::max( m_Start.y, m_End.y );
|
|
|
|
xmax = std::max( m_Start.x, m_End.x );
|
2008-03-10 15:00:22 +00:00
|
|
|
|
2012-09-22 11:19:37 +00:00
|
|
|
ymin = std::min( m_Start.y, m_End.y );
|
|
|
|
xmin = std::min( m_Start.x, m_End.x );
|
2008-03-10 15:00:22 +00:00
|
|
|
}
|
2008-03-05 22:39:33 +00:00
|
|
|
|
|
|
|
ymax += radius;
|
|
|
|
xmax += radius;
|
|
|
|
|
|
|
|
ymin -= radius;
|
|
|
|
xmin -= radius;
|
|
|
|
|
2008-03-10 13:33:12 +00:00
|
|
|
// return a rectangle which is [pos,dim) in nature. therefore the +1
|
2011-03-29 19:33:07 +00:00
|
|
|
EDA_RECT ret( wxPoint( xmin, ymin ), wxSize( xmax - xmin + 1, ymax - ymin + 1 ) );
|
2008-03-11 01:19:08 +00:00
|
|
|
|
|
|
|
return ret;
|
2008-03-05 22:39:33 +00:00
|
|
|
}
|
|
|
|
|
2009-10-10 17:27:53 +00:00
|
|
|
|
2011-12-14 04:29:25 +00:00
|
|
|
void TRACK::Rotate( const wxPoint& aRotCentre, double aAngle )
|
2009-08-01 19:26:05 +00:00
|
|
|
{
|
|
|
|
RotatePoint( &m_Start, aRotCentre, aAngle );
|
|
|
|
RotatePoint( &m_End, aRotCentre, aAngle );
|
|
|
|
}
|
|
|
|
|
2009-10-10 17:27:53 +00:00
|
|
|
|
2019-03-27 12:38:29 +00:00
|
|
|
void ARC::Rotate( const wxPoint& aRotCentre, double aAngle )
|
|
|
|
{
|
|
|
|
RotatePoint( &m_Start, aRotCentre, aAngle );
|
|
|
|
RotatePoint( &m_End, aRotCentre, aAngle );
|
|
|
|
RotatePoint( &m_Mid, aRotCentre, aAngle );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-07-12 21:02:10 +00:00
|
|
|
void TRACK::Flip( const wxPoint& aCentre, bool aFlipLeftRight )
|
2009-08-01 19:26:05 +00:00
|
|
|
{
|
2019-07-12 21:02:10 +00:00
|
|
|
if( aFlipLeftRight )
|
|
|
|
{
|
|
|
|
m_Start.x = aCentre.x - ( m_Start.x - aCentre.x );
|
|
|
|
m_End.x = aCentre.x - ( m_End.x - aCentre.x );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_Start.y = aCentre.y - ( m_Start.y - aCentre.y );
|
|
|
|
m_End.y = aCentre.y - ( m_End.y - aCentre.y );
|
|
|
|
}
|
|
|
|
|
2015-12-27 15:51:13 +00:00
|
|
|
int copperLayerCount = GetBoard()->GetCopperLayerCount();
|
|
|
|
SetLayer( FlipLayer( GetLayer(), copperLayerCount ) );
|
2014-04-30 19:16:22 +00:00
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
|
|
|
|
2019-03-27 12:38:29 +00:00
|
|
|
void ARC::Flip( const wxPoint& aCentre, bool aFlipLeftRight )
|
|
|
|
{
|
|
|
|
if( aFlipLeftRight )
|
|
|
|
{
|
|
|
|
m_Start.x = aCentre.x - ( m_Start.x - aCentre.x );
|
|
|
|
m_End.x = aCentre.x - ( m_End.x - aCentre.x );
|
|
|
|
m_Mid.x = aCentre.x - ( m_Mid.x - aCentre.x );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_Start.y = aCentre.y - ( m_Start.y - aCentre.y );
|
|
|
|
m_End.y = aCentre.y - ( m_End.y - aCentre.y );
|
|
|
|
m_Mid.y = aCentre.y - ( m_Mid.y - aCentre.y );
|
|
|
|
}
|
|
|
|
|
|
|
|
int copperLayerCount = GetBoard()->GetCopperLayerCount();
|
|
|
|
SetLayer( FlipLayer( GetLayer(), copperLayerCount ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-07-12 21:02:10 +00:00
|
|
|
void VIA::Flip( const wxPoint& aCentre, bool aFlipLeftRight )
|
2014-04-30 19:16:22 +00:00
|
|
|
{
|
2019-07-12 21:02:10 +00:00
|
|
|
if( aFlipLeftRight )
|
|
|
|
{
|
|
|
|
m_Start.x = aCentre.x - ( m_Start.x - aCentre.x );
|
|
|
|
m_End.x = aCentre.x - ( m_End.x - aCentre.x );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_Start.y = aCentre.y - ( m_Start.y - aCentre.y );
|
|
|
|
m_End.y = aCentre.y - ( m_End.y - aCentre.y );
|
|
|
|
}
|
2015-12-27 15:51:13 +00:00
|
|
|
|
2019-12-28 00:55:11 +00:00
|
|
|
if( GetViaType() != VIATYPE::THROUGH )
|
2015-12-27 15:51:13 +00:00
|
|
|
{
|
2019-12-28 00:55:11 +00:00
|
|
|
int copperLayerCount = GetBoard()->GetCopperLayerCount();
|
2017-03-13 03:19:33 +00:00
|
|
|
PCB_LAYER_ID top_layer;
|
|
|
|
PCB_LAYER_ID bottom_layer;
|
2015-12-27 15:51:13 +00:00
|
|
|
LayerPair( &top_layer, &bottom_layer );
|
2019-12-28 00:55:11 +00:00
|
|
|
top_layer = FlipLayer( top_layer, copperLayerCount );
|
2015-12-27 15:51:13 +00:00
|
|
|
bottom_layer = FlipLayer( bottom_layer, copperLayerCount );
|
|
|
|
SetLayerPair( top_layer, bottom_layer );
|
|
|
|
}
|
2009-08-01 19:26:05 +00:00
|
|
|
}
|
|
|
|
|
2008-03-05 22:39:33 +00:00
|
|
|
|
2011-09-14 15:08:44 +00:00
|
|
|
// see class_track.h
|
2016-07-12 19:05:54 +00:00
|
|
|
SEARCH_RESULT TRACK::Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] )
|
2007-08-30 22:20:52 +00:00
|
|
|
{
|
2007-10-19 06:31:17 +00:00
|
|
|
KICAD_T stype = *scanTypes;
|
2007-08-08 20:51:08 +00:00
|
|
|
|
2007-08-30 22:20:52 +00:00
|
|
|
// If caller wants to inspect my type
|
2007-09-01 12:00:30 +00:00
|
|
|
if( stype == Type() )
|
2007-08-30 22:20:52 +00:00
|
|
|
{
|
2019-12-28 00:55:11 +00:00
|
|
|
if( SEARCH_RESULT::QUIT == inspector( this, testData ) )
|
|
|
|
return SEARCH_RESULT::QUIT;
|
2007-08-30 22:20:52 +00:00
|
|
|
}
|
|
|
|
|
2019-12-28 00:55:11 +00:00
|
|
|
return SEARCH_RESULT::CONTINUE;
|
2007-08-30 22:20:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-03-13 03:19:33 +00:00
|
|
|
bool VIA::IsOnLayer( PCB_LAYER_ID layer_number ) const
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2017-03-13 03:19:33 +00:00
|
|
|
PCB_LAYER_ID bottom_layer, top_layer;
|
2007-10-15 07:50:59 +00:00
|
|
|
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
LayerPair( &top_layer, &bottom_layer );
|
2007-10-15 07:50:59 +00:00
|
|
|
|
2014-06-30 04:40:16 +00:00
|
|
|
wxASSERT( top_layer <= bottom_layer );
|
|
|
|
|
|
|
|
if( top_layer <= layer_number && layer_number <= bottom_layer )
|
2007-08-30 22:20:52 +00:00
|
|
|
return true;
|
2007-08-08 20:51:08 +00:00
|
|
|
else
|
2007-08-30 22:20:52 +00:00
|
|
|
return false;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
|
|
|
|
LSET VIA::GetLayerSet() const
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2019-12-28 00:55:11 +00:00
|
|
|
if( GetViaType() == VIATYPE::THROUGH )
|
2014-06-24 16:17:18 +00:00
|
|
|
return LSET::AllCuMask();
|
2007-10-15 07:50:59 +00:00
|
|
|
|
2014-04-25 06:00:04 +00:00
|
|
|
// VIA_BLIND_BURIED or VIA_MICRVIA:
|
2007-08-08 20:51:08 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
LSET layermask;
|
2007-08-08 20:51:08 +00:00
|
|
|
|
2014-07-23 16:27:52 +00:00
|
|
|
wxASSERT( m_Layer <= m_BottomLayer );
|
2007-08-08 20:51:08 +00:00
|
|
|
|
2017-03-13 03:19:33 +00:00
|
|
|
// PCB_LAYER_IDs are numbered from front to back, this is top to bottom.
|
2019-12-28 00:55:11 +00:00
|
|
|
for( LAYER_NUM id = m_Layer; id <= m_BottomLayer; ++id )
|
2011-09-07 19:41:04 +00:00
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
layermask.set( id );
|
2011-09-07 19:41:04 +00:00
|
|
|
}
|
2014-04-25 06:00:04 +00:00
|
|
|
|
|
|
|
return layermask;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2020-08-09 11:22:09 +00:00
|
|
|
void VIA::SetLayerSet( LSET aLayerSet )
|
|
|
|
{
|
|
|
|
bool first = true;
|
|
|
|
|
|
|
|
for( PCB_LAYER_ID layer : aLayerSet.Seq() )
|
|
|
|
{
|
|
|
|
if( first )
|
|
|
|
{
|
|
|
|
m_Layer = layer;
|
|
|
|
first = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_BottomLayer = layer;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-03-13 03:19:33 +00:00
|
|
|
void VIA::SetLayerPair( PCB_LAYER_ID aTopLayer, PCB_LAYER_ID aBottomLayer )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-10-16 20:52:49 +00:00
|
|
|
|
2014-04-25 08:03:50 +00:00
|
|
|
m_Layer = aTopLayer;
|
|
|
|
m_BottomLayer = aBottomLayer;
|
2018-01-06 22:32:22 +00:00
|
|
|
SanitizeLayers();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void VIA::SetTopLayer( PCB_LAYER_ID aLayer )
|
|
|
|
{
|
|
|
|
m_Layer = aLayer;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void VIA::SetBottomLayer( PCB_LAYER_ID aLayer )
|
|
|
|
{
|
|
|
|
m_BottomLayer = aLayer;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-08 20:51:08 +00:00
|
|
|
|
2017-03-13 03:19:33 +00:00
|
|
|
void VIA::LayerPair( PCB_LAYER_ID* top_layer, PCB_LAYER_ID* bottom_layer ) const
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2017-03-13 03:19:33 +00:00
|
|
|
PCB_LAYER_ID t_layer = F_Cu;
|
|
|
|
PCB_LAYER_ID b_layer = B_Cu;
|
2007-08-08 20:51:08 +00:00
|
|
|
|
2019-12-28 00:55:11 +00:00
|
|
|
if( GetViaType() != VIATYPE::THROUGH )
|
2009-05-21 12:45:21 +00:00
|
|
|
{
|
2014-04-25 08:03:50 +00:00
|
|
|
b_layer = m_BottomLayer;
|
|
|
|
t_layer = m_Layer;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2014-06-25 17:01:50 +00:00
|
|
|
if( b_layer < t_layer )
|
2015-06-26 13:41:56 +00:00
|
|
|
std::swap( b_layer, t_layer );
|
2009-05-21 12:45:21 +00:00
|
|
|
}
|
2007-10-19 06:31:17 +00:00
|
|
|
|
2007-08-08 20:51:08 +00:00
|
|
|
if( top_layer )
|
|
|
|
*top_layer = t_layer;
|
2007-10-19 06:31:17 +00:00
|
|
|
|
2007-08-08 20:51:08 +00:00
|
|
|
if( bottom_layer )
|
|
|
|
*bottom_layer = b_layer;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-01-06 22:32:22 +00:00
|
|
|
PCB_LAYER_ID VIA::TopLayer() const
|
|
|
|
{
|
|
|
|
return m_Layer;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PCB_LAYER_ID VIA::BottomLayer() const
|
|
|
|
{
|
|
|
|
return m_BottomLayer;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void VIA::SanitizeLayers()
|
|
|
|
{
|
2019-12-28 00:55:11 +00:00
|
|
|
if( GetViaType() == VIATYPE::THROUGH )
|
2018-01-06 22:32:22 +00:00
|
|
|
{
|
2019-12-28 00:55:11 +00:00
|
|
|
m_Layer = F_Cu;
|
2018-01-06 22:32:22 +00:00
|
|
|
m_BottomLayer = B_Cu;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( m_BottomLayer < m_Layer )
|
|
|
|
std::swap( m_BottomLayer, m_Layer );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-09-29 20:40:17 +00:00
|
|
|
bool VIA::FlashLayer( LSET aLayers ) const
|
2020-07-27 19:41:50 +00:00
|
|
|
{
|
|
|
|
for( auto layer : aLayers.Seq() )
|
|
|
|
{
|
2020-09-29 20:40:17 +00:00
|
|
|
if( FlashLayer( layer ) )
|
2020-07-27 19:41:50 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-09-29 20:40:17 +00:00
|
|
|
bool VIA::FlashLayer( int aLayer ) const
|
2020-07-27 19:41:50 +00:00
|
|
|
{
|
|
|
|
BOARD* board = GetBoard();
|
|
|
|
|
|
|
|
if( !board )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if( !IsOnLayer( static_cast<PCB_LAYER_ID>( aLayer ) ) )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if( !m_RemoveUnconnectedLayer )
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if( m_KeepTopBottomLayer && ( aLayer == m_Layer || aLayer == m_BottomLayer ) )
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return board->GetConnectivity()->IsConnectedOnLayer( this, static_cast<int>( aLayer ),
|
|
|
|
{ PCB_TRACE_T, PCB_ARC_T, PCB_PAD_T } );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-07-08 07:57:23 +00:00
|
|
|
void TRACK::ViewGetLayers( int aLayers[], int& aCount ) const
|
|
|
|
{
|
|
|
|
// Show the track and its netname on different layers
|
|
|
|
aLayers[0] = GetLayer();
|
2013-07-08 14:46:04 +00:00
|
|
|
aLayers[1] = GetNetnameLayer( aLayers[0] );
|
2013-07-08 07:57:23 +00:00
|
|
|
aCount = 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-09-21 15:03:08 +00:00
|
|
|
double TRACK::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
|
2013-07-08 07:57:23 +00:00
|
|
|
{
|
2020-09-21 15:03:08 +00:00
|
|
|
constexpr double HIDE = std::numeric_limits<double>::max();
|
2018-02-19 14:48:22 +00:00
|
|
|
|
|
|
|
if( !aView->IsLayerVisible( LAYER_TRACKS ) )
|
|
|
|
return HIDE;
|
|
|
|
|
2013-07-08 07:57:23 +00:00
|
|
|
// Netnames will be shown only if zoom is appropriate
|
2014-02-03 13:14:53 +00:00
|
|
|
if( IsNetnameLayer( aLayer ) )
|
2013-07-08 07:57:23 +00:00
|
|
|
{
|
2020-09-21 15:03:08 +00:00
|
|
|
return ( double ) Millimeter2iu( 4 ) / ( m_Width + 1 );
|
2013-07-08 07:57:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Other layers are shown without any conditions
|
2020-09-21 15:03:08 +00:00
|
|
|
return 0.0;
|
2013-07-08 07:57:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-06-12 08:36:41 +00:00
|
|
|
const BOX2I TRACK::ViewBBox() const
|
|
|
|
{
|
2018-01-30 06:45:53 +00:00
|
|
|
BOX2I bbox = GetBoundingBox();
|
2020-10-12 17:40:03 +00:00
|
|
|
bbox.Inflate( 2 * GetOwnClearance( GetLayer() ) );
|
2018-06-12 08:36:41 +00:00
|
|
|
return bbox;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-04-25 06:00:04 +00:00
|
|
|
void VIA::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
|
|
|
{
|
2017-03-13 03:19:33 +00:00
|
|
|
aLayers[0] = LAYER_VIAS_HOLES;
|
2017-04-25 09:47:21 +00:00
|
|
|
aLayers[1] = LAYER_VIAS_NETNAMES;
|
2017-04-22 15:46:31 +00:00
|
|
|
aCount = 3;
|
2014-08-06 11:53:02 +00:00
|
|
|
|
|
|
|
// Just show it on common via & via holes layers
|
|
|
|
switch( GetViaType() )
|
|
|
|
{
|
2019-12-28 00:55:11 +00:00
|
|
|
case VIATYPE::THROUGH:
|
2017-04-22 15:46:31 +00:00
|
|
|
aLayers[2] = LAYER_VIA_THROUGH;
|
2014-08-06 11:53:02 +00:00
|
|
|
break;
|
|
|
|
|
2019-12-28 00:55:11 +00:00
|
|
|
case VIATYPE::BLIND_BURIED:
|
2017-04-22 15:46:31 +00:00
|
|
|
aLayers[2] = LAYER_VIA_BBLIND;
|
|
|
|
aLayers[3] = m_Layer;
|
|
|
|
aLayers[4] = m_BottomLayer;
|
2014-08-06 11:53:02 +00:00
|
|
|
aCount += 2;
|
|
|
|
break;
|
|
|
|
|
2019-12-28 00:55:11 +00:00
|
|
|
case VIATYPE::MICROVIA:
|
2017-04-22 15:46:31 +00:00
|
|
|
aLayers[2] = LAYER_VIA_MICROVIA;
|
2020-05-11 14:21:39 +00:00
|
|
|
aLayers[3] = m_Layer;
|
|
|
|
aLayers[4] = m_BottomLayer;
|
|
|
|
aCount += 2;
|
2014-08-06 11:53:02 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2017-04-25 09:47:21 +00:00
|
|
|
aLayers[2] = LAYER_GP_OVERLAY;
|
|
|
|
wxASSERT( false );
|
2014-08-06 11:53:02 +00:00
|
|
|
break;
|
|
|
|
}
|
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-09-21 15:03:08 +00:00
|
|
|
double VIA::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
|
2017-04-20 16:19:41 +00:00
|
|
|
{
|
2020-09-21 15:03:08 +00:00
|
|
|
constexpr double HIDE = (double)std::numeric_limits<double>::max();
|
2018-11-02 23:47:57 +00:00
|
|
|
|
|
|
|
// Netnames will be shown only if zoom is appropriate
|
|
|
|
if( IsNetnameLayer( aLayer ) )
|
2020-09-21 15:03:08 +00:00
|
|
|
return m_Width == 0 ? HIDE : ( (double)Millimeter2iu( 10 ) / m_Width );
|
2018-11-02 23:47:57 +00:00
|
|
|
|
2020-08-10 21:52:22 +00:00
|
|
|
bool onVisibleLayer = false;
|
2018-11-02 23:47:57 +00:00
|
|
|
|
2020-08-10 21:52:22 +00:00
|
|
|
PCB_LAYER_ID top;
|
|
|
|
PCB_LAYER_ID bottom;
|
|
|
|
LayerPair( &top, &bottom );
|
|
|
|
|
|
|
|
for( int layer = top; layer <= bottom; ++layer )
|
2020-04-20 16:00:00 +00:00
|
|
|
{
|
2020-08-10 21:52:22 +00:00
|
|
|
if( aView->IsLayerVisible( layer ) )
|
|
|
|
{
|
|
|
|
onVisibleLayer = true;
|
|
|
|
break;
|
|
|
|
}
|
2020-04-20 16:00:00 +00:00
|
|
|
}
|
2017-04-20 16:19:41 +00:00
|
|
|
|
2020-07-11 17:42:00 +00:00
|
|
|
// Draw through vias unconditionally if the vias control is turned on.
|
|
|
|
// Draw blind/buried/microvias only if at least one of the layers crossed is enabeld.
|
|
|
|
if( aView->IsLayerVisible( LAYER_VIAS ) )
|
2019-11-05 14:20:50 +00:00
|
|
|
{
|
2020-07-11 17:42:00 +00:00
|
|
|
if( !onVisibleLayer && m_ViaType != VIATYPE::THROUGH )
|
|
|
|
return HIDE;
|
|
|
|
|
2020-09-21 15:03:08 +00:00
|
|
|
return aView->IsLayerVisible( LAYER_VIAS ) ? 0.0 : HIDE;
|
2019-11-05 14:20:50 +00:00
|
|
|
}
|
2017-04-20 16:19:41 +00:00
|
|
|
|
2018-11-02 23:47:57 +00:00
|
|
|
return HIDE;
|
2017-04-20 16:19:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-14 15:08:44 +00:00
|
|
|
// see class_track.h
|
2020-04-24 13:36:10 +00:00
|
|
|
void TRACK::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
|
2009-10-14 18:14:58 +00:00
|
|
|
{
|
2020-05-21 17:42:42 +00:00
|
|
|
EDA_UNITS units = aFrame->GetUserUnits();
|
|
|
|
wxString msg;
|
|
|
|
wxString msg2;
|
|
|
|
wxString source;
|
|
|
|
BOARD* board = GetBoard();
|
2009-10-16 17:18:23 +00:00
|
|
|
|
2009-10-14 18:14:58 +00:00
|
|
|
// Display basic infos
|
2020-05-21 17:42:42 +00:00
|
|
|
aList.emplace_back( _( "Type" ), _( "Track" ), DARKCYAN );
|
|
|
|
|
|
|
|
GetMsgPanelInfoBase_Common( aFrame, aList );
|
|
|
|
|
|
|
|
// Display layer
|
2020-09-19 18:53:58 +00:00
|
|
|
aList.emplace_back( _( "Layer" ), LayerMaskDescribe(), DARKGREEN );
|
2020-05-21 17:42:42 +00:00
|
|
|
|
|
|
|
// Display width
|
2020-10-02 20:51:24 +00:00
|
|
|
msg = MessageTextFromValue( aFrame->GetUserUnits(), m_Width );
|
2020-05-21 17:42:42 +00:00
|
|
|
|
|
|
|
aList.emplace_back( _( "Width" ), msg, DARKCYAN );
|
2009-10-14 18:14:58 +00:00
|
|
|
|
2011-09-30 18:15:37 +00:00
|
|
|
// Display full track length (in Pcbnew)
|
2013-01-12 17:32:24 +00:00
|
|
|
if( board )
|
2009-10-14 18:14:58 +00:00
|
|
|
{
|
2019-05-31 02:30:28 +00:00
|
|
|
int count;
|
|
|
|
double trackLen;
|
|
|
|
double lenPadToDie;
|
2018-06-12 14:50:18 +00:00
|
|
|
|
2019-05-31 02:30:28 +00:00
|
|
|
std::tie( count, trackLen, lenPadToDie ) = board->GetTrackLength( *this );
|
2018-06-12 14:50:18 +00:00
|
|
|
|
2020-04-24 13:36:10 +00:00
|
|
|
msg = MessageTextFromValue( aFrame->GetUserUnits(), trackLen );
|
2019-12-05 15:41:21 +00:00
|
|
|
aList.emplace_back( _( "Length" ), msg, DARKCYAN );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2012-12-12 11:57:17 +00:00
|
|
|
if( lenPadToDie != 0 )
|
2011-08-20 14:46:48 +00:00
|
|
|
{
|
2020-10-02 20:51:24 +00:00
|
|
|
msg = MessageTextFromValue( aFrame->GetUserUnits(), lenPadToDie );
|
2019-12-05 15:41:21 +00:00
|
|
|
aList.emplace_back( _( "Pad To Die Length" ), msg, DARKCYAN );
|
2020-05-21 17:42:42 +00:00
|
|
|
|
|
|
|
msg = MessageTextFromValue( aFrame->GetUserUnits(), trackLen + lenPadToDie );
|
|
|
|
aList.emplace_back( _( "Full Length" ), msg, DARKCYAN );
|
2011-08-20 14:46:48 +00:00
|
|
|
}
|
2009-10-14 18:14:58 +00:00
|
|
|
}
|
2011-03-11 15:53:28 +00:00
|
|
|
|
2020-10-12 17:40:03 +00:00
|
|
|
int clearance = GetOwnClearance( GetLayer(), &source );
|
2018-04-10 10:52:12 +00:00
|
|
|
|
2020-10-02 20:51:24 +00:00
|
|
|
msg.Printf( _( "Min Clearance: %s" ), MessageTextFromValue( units, clearance ) );
|
2020-05-22 10:31:14 +00:00
|
|
|
msg2.Printf( _( "(from %s)" ), source );
|
2020-05-21 17:42:42 +00:00
|
|
|
aList.emplace_back( msg, msg2, BLACK );
|
2018-04-10 10:52:12 +00:00
|
|
|
|
2020-05-23 21:48:24 +00:00
|
|
|
int minWidth, maxWidth;
|
|
|
|
GetWidthConstraints( &minWidth, &maxWidth, &source );
|
2018-04-10 10:52:12 +00:00
|
|
|
|
2020-10-02 20:51:24 +00:00
|
|
|
msg.Printf( _( "Min Width: %s" ), MessageTextFromValue( units, minWidth ) );
|
2020-05-22 10:31:14 +00:00
|
|
|
msg2.Printf( _( "(from %s)" ), source );
|
2020-05-21 17:42:42 +00:00
|
|
|
aList.emplace_back( msg, msg2, BLACK );
|
2009-10-14 18:14:58 +00:00
|
|
|
}
|
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
|
2020-05-21 17:42:42 +00:00
|
|
|
void VIA::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
|
2014-04-25 06:00:04 +00:00
|
|
|
{
|
2020-05-21 17:42:42 +00:00
|
|
|
EDA_UNITS units = aFrame->GetUserUnits();
|
|
|
|
wxString msg;
|
|
|
|
wxString msg2;
|
|
|
|
wxString source;
|
2014-04-25 06:00:04 +00:00
|
|
|
|
2020-05-21 17:42:42 +00:00
|
|
|
// Display basic infos
|
2014-04-25 06:00:04 +00:00
|
|
|
switch( GetViaType() )
|
2009-10-10 17:27:53 +00:00
|
|
|
{
|
2020-09-19 16:12:00 +00:00
|
|
|
case VIATYPE::MICROVIA: msg = _( "Micro Via" ); break;
|
|
|
|
case VIATYPE::BLIND_BURIED: msg = _( "Blind/Buried Via" ); break;
|
|
|
|
case VIATYPE::THROUGH: msg = _( "Through Via" ); break;
|
|
|
|
default: msg = _( "Via" ); break;
|
2009-10-10 17:27:53 +00:00
|
|
|
}
|
2014-04-25 06:00:04 +00:00
|
|
|
|
2019-12-05 15:41:21 +00:00
|
|
|
aList.emplace_back( _( "Type" ), msg, DARKCYAN );
|
2014-04-25 06:00:04 +00:00
|
|
|
|
2020-04-24 13:36:10 +00:00
|
|
|
GetMsgPanelInfoBase_Common( aFrame, aList );
|
2014-04-25 06:00:04 +00:00
|
|
|
|
|
|
|
// Display layer pair
|
2020-09-19 18:53:58 +00:00
|
|
|
aList.emplace_back( _( "Layer" ), LayerMaskDescribe(), DARKGREEN );
|
2014-04-25 06:00:04 +00:00
|
|
|
|
|
|
|
// Display width
|
2020-10-02 20:51:24 +00:00
|
|
|
msg = MessageTextFromValue( aFrame->GetUserUnits(), m_Width );
|
2014-04-25 06:00:04 +00:00
|
|
|
|
|
|
|
// Display diameter value:
|
2019-12-05 15:41:21 +00:00
|
|
|
aList.emplace_back( _( "Diameter" ), msg, DARKCYAN );
|
2014-04-25 06:00:04 +00:00
|
|
|
|
|
|
|
// Display drill value
|
2020-04-24 13:36:10 +00:00
|
|
|
msg = MessageTextFromValue( aFrame->GetUserUnits(), GetDrillValue() );
|
2014-04-25 06:00:04 +00:00
|
|
|
|
2020-05-21 17:42:42 +00:00
|
|
|
aList.emplace_back( _( "Drill" ), msg, RED );
|
|
|
|
|
2020-10-12 17:40:03 +00:00
|
|
|
int clearance = GetOwnClearance( GetLayer(), &source );
|
2020-05-21 17:42:42 +00:00
|
|
|
|
2020-10-02 20:51:24 +00:00
|
|
|
msg.Printf( _( "Min Clearance: %s" ), MessageTextFromValue( units, clearance ) );
|
2020-05-22 10:31:14 +00:00
|
|
|
msg2.Printf( _( "(from %s)" ), source );
|
2020-05-21 17:42:42 +00:00
|
|
|
aList.emplace_back( msg, msg2, BLACK );
|
|
|
|
|
2020-08-07 20:18:33 +00:00
|
|
|
int minAnnulus = GetMinAnnulus( GetLayer(), &source );
|
2014-04-25 06:00:04 +00:00
|
|
|
|
2020-10-02 20:51:24 +00:00
|
|
|
msg.Printf( _( "Min Annular Width: %s" ), MessageTextFromValue( units, minAnnulus ) );
|
2020-05-22 10:31:14 +00:00
|
|
|
msg2.Printf( _( "(from %s)" ), source );
|
2020-05-21 17:42:42 +00:00
|
|
|
aList.emplace_back( msg, msg2, BLACK );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-27 11:03:35 +00:00
|
|
|
void TRACK::GetMsgPanelInfoBase_Common( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) const
|
2020-05-21 17:42:42 +00:00
|
|
|
{
|
|
|
|
wxString msg;
|
2015-06-18 13:19:30 +00:00
|
|
|
|
2020-05-21 17:42:42 +00:00
|
|
|
// Display Net Name
|
2015-06-18 13:19:30 +00:00
|
|
|
if( GetBoard() )
|
|
|
|
{
|
|
|
|
NETINFO_ITEM* net = GetNet();
|
2020-05-21 17:42:42 +00:00
|
|
|
NETCLASS* netclass = nullptr;
|
2015-06-18 13:19:30 +00:00
|
|
|
|
|
|
|
if( net )
|
|
|
|
{
|
2020-05-21 17:42:42 +00:00
|
|
|
if( net->GetNet() )
|
|
|
|
netclass = GetNetClass();
|
2015-06-18 13:19:30 +00:00
|
|
|
else
|
2020-05-21 17:42:42 +00:00
|
|
|
netclass = GetBoard()->GetDesignSettings().GetDefault();
|
|
|
|
|
|
|
|
msg = UnescapeString( net->GetNetname() );
|
2015-06-18 13:19:30 +00:00
|
|
|
}
|
2020-05-21 17:42:42 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
msg = wxT( "<no name>" );
|
|
|
|
}
|
|
|
|
|
|
|
|
aList.emplace_back( _( "Net" ), msg, RED );
|
2015-06-18 13:19:30 +00:00
|
|
|
|
2020-05-21 17:42:42 +00:00
|
|
|
if( netclass )
|
|
|
|
aList.emplace_back( _( "NetClass" ), netclass->GetName(), DARKMAGENTA );
|
2015-06-18 13:19:30 +00:00
|
|
|
}
|
|
|
|
|
2020-05-21 17:42:42 +00:00
|
|
|
#if 0 // Enable for debugging
|
|
|
|
if( GetBoard() )
|
|
|
|
{
|
|
|
|
// Display net code:
|
|
|
|
msg.Printf( wxT( "%d" ), GetNetCode() );
|
|
|
|
aList.emplace_back( _( "NetCode" ), msg, RED );
|
|
|
|
}
|
2015-06-18 13:19:30 +00:00
|
|
|
|
2020-05-21 17:42:42 +00:00
|
|
|
// Display the flags:
|
|
|
|
msg.Printf( wxT( "0x%08X" ), m_Flags );
|
|
|
|
aList.emplace_back( wxT( "Flags" ), msg, BLUE );
|
|
|
|
|
|
|
|
// Display start and end positions:
|
|
|
|
msg.Printf( wxT( "%d %d" ), m_Start.x, m_Start.y );
|
|
|
|
aList.push_back( MSG_PANEL_ITEM( wxT( "Start pos" ), msg, BLUE ) );
|
|
|
|
msg.Printf( wxT( "%d %d" ), m_End.x, m_End.y );
|
|
|
|
aList.push_back( MSG_PANEL_ITEM( wxT( "End pos" ), msg, BLUE ) );
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Display the State member
|
|
|
|
msg = wxT( ". . " );
|
2014-04-25 06:00:04 +00:00
|
|
|
|
2020-05-21 17:42:42 +00:00
|
|
|
if( GetState( TRACK_LOCKED ) )
|
|
|
|
msg[0] = 'L';
|
|
|
|
|
|
|
|
if( GetState( TRACK_AR ) )
|
|
|
|
msg[2] = 'A';
|
|
|
|
|
|
|
|
aList.emplace_back( _( "Status" ), msg, MAGENTA );
|
2007-08-20 19:33:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-09-19 18:53:58 +00:00
|
|
|
wxString VIA::LayerMaskDescribe() const
|
2020-09-19 16:12:00 +00:00
|
|
|
{
|
|
|
|
BOARD* board = GetBoard();
|
|
|
|
PCB_LAYER_ID top_layer;
|
|
|
|
PCB_LAYER_ID bottom_layer;
|
|
|
|
|
|
|
|
LayerPair( &top_layer, &bottom_layer );
|
|
|
|
|
|
|
|
return board->GetLayerName( top_layer ) + wxT( " - " ) + board->GetLayerName( bottom_layer );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-05 10:33:34 +00:00
|
|
|
bool TRACK::HitTest( const wxPoint& aPosition, int aAccuracy ) const
|
2007-08-08 20:51:08 +00:00
|
|
|
{
|
2019-05-05 10:33:34 +00:00
|
|
|
return TestSegmentHit( aPosition, m_Start, m_End, aAccuracy + ( m_Width / 2 ) );
|
2014-05-01 06:50:11 +00:00
|
|
|
}
|
2008-03-05 22:39:33 +00:00
|
|
|
|
2019-12-20 14:11:39 +00:00
|
|
|
|
2019-03-27 12:38:29 +00:00
|
|
|
bool ARC::HitTest( const wxPoint& aPosition, int aAccuracy ) const
|
|
|
|
{
|
|
|
|
int max_dist = aAccuracy + ( m_Width / 2 );
|
2019-05-17 00:13:21 +00:00
|
|
|
wxPoint center = GetPosition();
|
|
|
|
wxPoint relpos = aPosition - center;
|
|
|
|
double dist = EuclideanNorm( relpos );
|
|
|
|
double radius = GetRadius();
|
2019-03-27 12:38:29 +00:00
|
|
|
|
2019-05-17 00:13:21 +00:00
|
|
|
if( std::abs( dist - radius ) > max_dist )
|
|
|
|
return false;
|
2019-03-27 12:38:29 +00:00
|
|
|
|
2019-05-17 00:13:21 +00:00
|
|
|
double arc_angle_start = GetArcAngleStart(); // Always 0.0 ... 360 deg, in 0.1 deg
|
|
|
|
double arc_hittest = ArcTangente( relpos.y, relpos.x );
|
|
|
|
|
|
|
|
// Calculate relative angle between the starting point of the arc, and the test point
|
|
|
|
arc_hittest -= arc_angle_start;
|
2019-03-27 12:38:29 +00:00
|
|
|
|
2019-05-17 00:13:21 +00:00
|
|
|
// Normalise arc_hittest between 0 ... 360 deg
|
|
|
|
NORMALIZE_ANGLE_POS( arc_hittest );
|
|
|
|
double arc_angle = GetAngle();
|
|
|
|
|
|
|
|
if( arc_angle < 0 )
|
|
|
|
return arc_hittest >= 3600 + arc_angle;
|
|
|
|
|
|
|
|
return arc_hittest <= GetAngle();
|
2019-03-27 12:38:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-05 10:33:34 +00:00
|
|
|
bool VIA::HitTest( const wxPoint& aPosition, int aAccuracy ) const
|
2014-05-01 06:50:11 +00:00
|
|
|
{
|
2019-05-05 10:33:34 +00:00
|
|
|
int max_dist = aAccuracy + ( m_Width / 2 );
|
2008-03-05 22:39:33 +00:00
|
|
|
|
2014-05-01 06:50:11 +00:00
|
|
|
// rel_pos is aPosition relative to m_Start (or the center of the via)
|
|
|
|
wxPoint rel_pos = aPosition - m_Start;
|
|
|
|
double dist = (double) rel_pos.x * rel_pos.x + (double) rel_pos.y * rel_pos.y;
|
|
|
|
return dist <= (double) max_dist * max_dist;
|
2007-10-19 06:31:17 +00:00
|
|
|
}
|
2007-08-09 01:41:30 +00:00
|
|
|
|
2008-12-14 19:45:05 +00:00
|
|
|
|
2013-09-21 18:09:41 +00:00
|
|
|
bool TRACK::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
|
2008-01-06 12:43:57 +00:00
|
|
|
{
|
2013-09-21 18:09:41 +00:00
|
|
|
EDA_RECT arect = aRect;
|
|
|
|
arect.Inflate( aAccuracy );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2014-05-01 06:50:11 +00:00
|
|
|
if( aContained )
|
2020-08-25 19:10:25 +00:00
|
|
|
return arect.Contains( GetStart() ) && arect.Contains( GetEnd() );
|
2013-09-21 18:09:41 +00:00
|
|
|
else
|
2014-05-01 06:50:11 +00:00
|
|
|
return arect.Intersects( GetStart(), GetEnd() );
|
2008-01-06 12:43:57 +00:00
|
|
|
}
|
|
|
|
|
2019-12-20 14:11:39 +00:00
|
|
|
|
2019-03-27 12:38:29 +00:00
|
|
|
bool ARC::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
|
|
|
|
{
|
|
|
|
EDA_RECT box;
|
|
|
|
EDA_RECT arect = aRect;
|
|
|
|
arect.Inflate( aAccuracy );
|
|
|
|
|
|
|
|
box.SetOrigin( GetStart() );
|
|
|
|
box.Merge( GetMid() );
|
|
|
|
box.Merge( GetEnd() );
|
|
|
|
|
|
|
|
box.Inflate( GetWidth() / 2 );
|
|
|
|
|
|
|
|
if( aContained )
|
|
|
|
return arect.Contains( box );
|
|
|
|
else
|
|
|
|
return arect.Intersects( box );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-05-01 06:50:11 +00:00
|
|
|
bool VIA::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
|
2011-09-14 20:04:58 +00:00
|
|
|
{
|
2013-09-21 18:09:41 +00:00
|
|
|
EDA_RECT box;
|
|
|
|
EDA_RECT arect = aRect;
|
|
|
|
arect.Inflate( aAccuracy );
|
2011-09-14 20:04:58 +00:00
|
|
|
|
2014-05-01 06:50:11 +00:00
|
|
|
box.SetOrigin( GetStart() );
|
|
|
|
box.Inflate( GetWidth() / 2 );
|
2011-09-14 20:04:58 +00:00
|
|
|
|
2014-05-01 06:50:11 +00:00
|
|
|
if( aContained )
|
|
|
|
return arect.Contains( box );
|
2013-09-21 18:09:41 +00:00
|
|
|
else
|
2017-07-03 10:36:22 +00:00
|
|
|
return arect.IntersectsCircle( GetStart(), GetWidth() / 2 );
|
2008-01-06 12:43:57 +00:00
|
|
|
}
|
2011-09-14 20:04:58 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2019-12-20 14:11:39 +00:00
|
|
|
wxString TRACK::GetSelectMenuText( EDA_UNITS aUnits ) const
|
2011-07-14 15:42:44 +00:00
|
|
|
{
|
2020-09-19 16:12:00 +00:00
|
|
|
return wxString::Format( _("Track %s on %s, length %s" ),
|
2018-04-10 10:52:12 +00:00
|
|
|
GetNetnameMsg(),
|
|
|
|
GetLayerName(),
|
|
|
|
MessageTextFromValue( aUnits, GetLength() ) );
|
2011-07-14 15:42:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-10-31 13:59:03 +00:00
|
|
|
BITMAP_DEF TRACK::GetMenuImage() const
|
2017-02-20 12:20:39 +00:00
|
|
|
{
|
2017-12-13 18:42:33 +00:00
|
|
|
return add_tracks_xpm;
|
2017-02-20 12:20:39 +00:00
|
|
|
}
|
|
|
|
|
2017-10-31 13:59:03 +00:00
|
|
|
void TRACK::SwapData( BOARD_ITEM* aImage )
|
|
|
|
{
|
|
|
|
assert( aImage->Type() == PCB_TRACE_T );
|
|
|
|
|
|
|
|
std::swap( *((TRACK*) this), *((TRACK*) aImage) );
|
|
|
|
}
|
|
|
|
|
2019-03-27 12:38:29 +00:00
|
|
|
void ARC::SwapData( BOARD_ITEM* aImage )
|
|
|
|
{
|
|
|
|
assert( aImage->Type() == PCB_ARC_T );
|
|
|
|
|
|
|
|
std::swap( *this, *static_cast<ARC*>( aImage ) );
|
|
|
|
}
|
|
|
|
|
2017-10-31 13:59:03 +00:00
|
|
|
void VIA::SwapData( BOARD_ITEM* aImage )
|
|
|
|
{
|
|
|
|
assert( aImage->Type() == PCB_VIA_T );
|
|
|
|
|
|
|
|
std::swap( *((VIA*) this), *((VIA*) aImage) );
|
|
|
|
}
|
2017-02-20 12:20:39 +00:00
|
|
|
|
2019-05-17 00:13:21 +00:00
|
|
|
|
2020-05-27 14:01:07 +00:00
|
|
|
wxPoint ARC::GetPosition() const
|
2019-05-17 00:13:21 +00:00
|
|
|
{
|
|
|
|
auto center = GetArcCenter( VECTOR2I( m_Start ), VECTOR2I( m_Mid ), VECTOR2I( m_End ) );
|
|
|
|
return wxPoint( center.x, center.y );
|
|
|
|
}
|
|
|
|
|
|
|
|
double ARC::GetRadius() const
|
|
|
|
{
|
|
|
|
auto center = GetArcCenter( VECTOR2I( m_Start ), VECTOR2I( m_Mid ), VECTOR2I( m_End ) );
|
|
|
|
return GetLineLength( wxPoint( center ), m_Start );
|
|
|
|
}
|
|
|
|
|
|
|
|
double ARC::GetAngle() const
|
|
|
|
{
|
|
|
|
wxPoint center = GetPosition();
|
|
|
|
wxPoint p0 = m_Start - center;
|
|
|
|
wxPoint p1 = m_Mid - center;
|
|
|
|
wxPoint p2 = m_End - center;
|
|
|
|
double angle1 = ArcTangente( p1.y, p1.x ) - ArcTangente( p0.y, p0.x );
|
|
|
|
double angle2 = ArcTangente( p2.y, p2.x ) - ArcTangente( p1.y, p1.x );
|
|
|
|
|
|
|
|
return NormalizeAngle180( angle1 ) + NormalizeAngle180( angle2 );
|
|
|
|
}
|
|
|
|
|
|
|
|
double ARC::GetArcAngleStart() const
|
|
|
|
{
|
|
|
|
wxPoint center = GetPosition();
|
|
|
|
|
|
|
|
double angleStart = ArcTangente( m_Start.y - center.y,
|
|
|
|
m_Start.x - center.x );
|
|
|
|
return NormalizeAnglePos( angleStart );
|
|
|
|
}
|
|
|
|
|
|
|
|
double ARC::GetArcAngleEnd() const
|
|
|
|
{
|
|
|
|
wxPoint center = GetPosition();
|
|
|
|
|
|
|
|
double angleEnd = ArcTangente( m_End.y - center.y,
|
|
|
|
m_End.x - center.x );
|
|
|
|
return NormalizeAnglePos( angleEnd );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-07-24 22:08:36 +00:00
|
|
|
bool TRACK::cmp_tracks::operator() ( const TRACK* a, const TRACK* b ) const
|
|
|
|
{
|
|
|
|
if( a->GetNetCode() != b->GetNetCode() )
|
|
|
|
return a->GetNetCode() < b->GetNetCode();
|
|
|
|
|
|
|
|
if( a->GetLayer() != b->GetLayer() )
|
|
|
|
return a->GetLayer() < b->GetLayer();
|
|
|
|
|
|
|
|
if( a->Type() != b->Type() )
|
|
|
|
return a->Type() < b->Type();
|
|
|
|
|
2020-10-11 17:02:38 +00:00
|
|
|
if( a->m_Uuid != b->m_Uuid )
|
|
|
|
return a->m_Uuid < b->m_Uuid;
|
|
|
|
|
|
|
|
return a < b;
|
2020-07-24 22:08:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-08-08 22:37:41 +00:00
|
|
|
std::shared_ptr<SHAPE> TRACK::GetEffectiveShape( PCB_LAYER_ID aLayer ) const
|
|
|
|
{
|
2020-10-20 10:33:20 +00:00
|
|
|
return std::make_shared<SHAPE_SEGMENT>( m_Start, m_End, m_Width );
|
2020-08-08 22:37:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
std::shared_ptr<SHAPE> VIA::GetEffectiveShape( PCB_LAYER_ID aLayer ) const
|
|
|
|
{
|
|
|
|
// fixme: pad stack support (depending on aLayer )
|
2020-10-20 10:33:20 +00:00
|
|
|
return std::make_shared<SHAPE_CIRCLE>( m_Start, m_Width / 2 );
|
2020-08-08 22:37:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
std::shared_ptr<SHAPE> ARC::GetEffectiveShape( PCB_LAYER_ID aLayer ) const
|
|
|
|
{
|
2020-10-20 10:33:20 +00:00
|
|
|
return std::make_shared<SHAPE_ARC>( GetStart(), GetMid(), GetEnd(), GetWidth() );
|
2020-08-08 22:37:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-05-21 12:45:21 +00:00
|
|
|
#if defined(DEBUG)
|
2007-10-01 04:14:29 +00:00
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
wxString TRACK::ShowState( int stateBits )
|
|
|
|
{
|
|
|
|
wxString ret;
|
|
|
|
|
2011-02-13 17:53:48 +00:00
|
|
|
if( stateBits & IS_LINKED )
|
|
|
|
ret << wxT( " | IS_LINKED" );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2011-02-13 17:53:48 +00:00
|
|
|
if( stateBits & TRACK_AR )
|
|
|
|
ret << wxT( " | TRACK_AR" );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2011-02-13 17:53:48 +00:00
|
|
|
if( stateBits & TRACK_LOCKED )
|
|
|
|
ret << wxT( " | TRACK_LOCKED" );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2011-02-13 17:53:48 +00:00
|
|
|
if( stateBits & IN_EDIT )
|
|
|
|
ret << wxT( " | IN_EDIT" );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2011-02-13 17:53:48 +00:00
|
|
|
if( stateBits & IS_DRAGGED )
|
|
|
|
ret << wxT( " | IS_DRAGGED" );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2011-02-13 17:53:48 +00:00
|
|
|
if( stateBits & DO_NOT_DRAW )
|
|
|
|
ret << wxT( " | DO_NOT_DRAW" );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2011-02-13 17:53:48 +00:00
|
|
|
if( stateBits & IS_DELETED )
|
|
|
|
ret << wxT( " | IS_DELETED" );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2008-12-14 19:45:05 +00:00
|
|
|
if( stateBits & END_ONPAD )
|
|
|
|
ret << wxT( " | END_ONPAD" );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2008-12-14 19:45:05 +00:00
|
|
|
if( stateBits & BEGIN_ONPAD )
|
|
|
|
ret << wxT( " | BEGIN_ONPAD" );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2007-08-09 01:41:30 +00:00
|
|
|
#endif
|
2020-02-02 18:40:14 +00:00
|
|
|
|
|
|
|
|
|
|
|
static struct TRACK_VIA_DESC
|
|
|
|
{
|
|
|
|
TRACK_VIA_DESC()
|
|
|
|
{
|
|
|
|
ENUM_MAP<VIATYPE>::Instance()
|
2020-07-23 10:35:05 +00:00
|
|
|
.Undefined( VIATYPE::NOT_DEFINED )
|
2020-10-16 15:51:24 +00:00
|
|
|
.Map( VIATYPE::THROUGH, _HKI( "Through" ) )
|
|
|
|
.Map( VIATYPE::BLIND_BURIED, _HKI( "Blind/buried" ) )
|
|
|
|
.Map( VIATYPE::MICROVIA, _HKI( "Micro" ) );
|
2020-02-02 18:40:14 +00:00
|
|
|
|
2020-08-18 21:42:56 +00:00
|
|
|
ENUM_MAP<PCB_LAYER_ID>& layerEnum = ENUM_MAP<PCB_LAYER_ID>::Instance();
|
|
|
|
|
|
|
|
if( layerEnum.Choices().GetCount() == 0 )
|
|
|
|
{
|
|
|
|
layerEnum.Undefined( UNDEFINED_LAYER );
|
|
|
|
|
|
|
|
for( LSEQ seq = LSET::AllLayersMask().Seq(); seq; ++seq )
|
|
|
|
layerEnum.Map( *seq, LSET::Name( *seq ) );
|
|
|
|
}
|
|
|
|
|
2020-02-02 18:40:14 +00:00
|
|
|
PROPERTY_MANAGER& propMgr = PROPERTY_MANAGER::Instance();
|
|
|
|
|
|
|
|
// Track
|
|
|
|
REGISTER_TYPE( TRACK );
|
|
|
|
propMgr.InheritsAfter( TYPE_HASH( TRACK ), TYPE_HASH( BOARD_CONNECTED_ITEM ) );
|
|
|
|
|
2020-10-16 15:51:24 +00:00
|
|
|
propMgr.AddProperty( new PROPERTY<TRACK, int>( _HKI( "Width" ),
|
2020-02-05 15:04:12 +00:00
|
|
|
&TRACK::SetWidth, &TRACK::GetWidth, PROPERTY_DISPLAY::DISTANCE ) );
|
2020-10-16 15:51:24 +00:00
|
|
|
propMgr.ReplaceProperty( TYPE_HASH( BOARD_ITEM ), _HKI( "Position X" ),
|
|
|
|
new PROPERTY<TRACK, int, BOARD_ITEM>( _HKI( "Origin X" ),
|
2020-02-05 15:04:12 +00:00
|
|
|
&TRACK::SetX, &TRACK::GetX, PROPERTY_DISPLAY::DISTANCE ) );
|
2020-10-16 15:51:24 +00:00
|
|
|
propMgr.ReplaceProperty( TYPE_HASH( BOARD_ITEM ), _HKI( "Position Y" ),
|
|
|
|
new PROPERTY<TRACK, int, BOARD_ITEM>( _HKI( "Origin Y" ),
|
2020-02-05 15:04:12 +00:00
|
|
|
&TRACK::SetY, &TRACK::GetY, PROPERTY_DISPLAY::DISTANCE ) );
|
2020-10-16 15:51:24 +00:00
|
|
|
propMgr.AddProperty( new PROPERTY<TRACK, int>( _HKI( "End X" ),
|
2020-02-05 15:04:12 +00:00
|
|
|
&TRACK::SetEndX, &TRACK::GetEndX, PROPERTY_DISPLAY::DISTANCE ) );
|
2020-10-16 15:51:24 +00:00
|
|
|
propMgr.AddProperty( new PROPERTY<TRACK, int>( _HKI( "End Y" ),
|
2020-02-05 15:04:12 +00:00
|
|
|
&TRACK::SetEndY, &TRACK::GetEndY, PROPERTY_DISPLAY::DISTANCE ) );
|
2020-02-02 18:40:14 +00:00
|
|
|
|
2020-10-23 12:42:48 +00:00
|
|
|
// Arc
|
|
|
|
REGISTER_TYPE( ARC );
|
|
|
|
propMgr.InheritsAfter( TYPE_HASH( ARC ), TYPE_HASH( BOARD_CONNECTED_ITEM ) );
|
|
|
|
|
|
|
|
propMgr.AddProperty( new PROPERTY<TRACK, int>( _HKI( "Width" ),
|
|
|
|
&ARC::SetWidth, &ARC::GetWidth, PROPERTY_DISPLAY::DISTANCE ) );
|
|
|
|
propMgr.ReplaceProperty( TYPE_HASH( BOARD_ITEM ), _HKI( "Position X" ),
|
|
|
|
new PROPERTY<ARC, int, BOARD_ITEM>( _HKI( "Origin X" ),
|
|
|
|
&TRACK::SetX, &ARC::GetX, PROPERTY_DISPLAY::DISTANCE ) );
|
|
|
|
propMgr.ReplaceProperty( TYPE_HASH( BOARD_ITEM ), _HKI( "Position Y" ),
|
|
|
|
new PROPERTY<ARC, int, BOARD_ITEM>( _HKI( "Origin Y" ),
|
|
|
|
&TRACK::SetY, &ARC::GetY, PROPERTY_DISPLAY::DISTANCE ) );
|
|
|
|
propMgr.AddProperty( new PROPERTY<TRACK, int>( _HKI( "End X" ),
|
|
|
|
&TRACK::SetEndX, &ARC::GetEndX, PROPERTY_DISPLAY::DISTANCE ) );
|
|
|
|
propMgr.AddProperty( new PROPERTY<TRACK, int>( _HKI( "End Y" ),
|
|
|
|
&TRACK::SetEndY, &ARC::GetEndY, PROPERTY_DISPLAY::DISTANCE ) );
|
|
|
|
|
2020-02-02 18:40:14 +00:00
|
|
|
// Via
|
|
|
|
REGISTER_TYPE( VIA );
|
|
|
|
propMgr.InheritsAfter( TYPE_HASH( VIA ), TYPE_HASH( BOARD_CONNECTED_ITEM ) );
|
|
|
|
|
|
|
|
// TODO layerset for vias?
|
|
|
|
// TODO test drill, use getdrillvalue?
|
2020-10-16 15:51:24 +00:00
|
|
|
propMgr.ReplaceProperty( TYPE_HASH( TRACK ), _HKI( "Width" ),
|
|
|
|
new PROPERTY<VIA, int, TRACK>( _HKI( "Diameter" ),
|
2020-09-24 13:39:59 +00:00
|
|
|
&VIA::SetWidth, &VIA::GetWidth, PROPERTY_DISPLAY::DISTANCE ) );
|
2020-10-16 15:51:24 +00:00
|
|
|
propMgr.AddProperty( new PROPERTY<VIA, int>( _HKI( "Drill" ),
|
2020-02-05 15:04:12 +00:00
|
|
|
&VIA::SetDrill, &VIA::GetDrillValue, PROPERTY_DISPLAY::DISTANCE ) );
|
2020-10-16 15:51:24 +00:00
|
|
|
propMgr.ReplaceProperty( TYPE_HASH( BOARD_ITEM ), _HKI( "Layer" ),
|
|
|
|
new PROPERTY_ENUM<VIA, PCB_LAYER_ID, BOARD_ITEM>( _HKI( "Layer Top" ),
|
2020-09-24 13:39:59 +00:00
|
|
|
&VIA::SetLayer, &VIA::GetLayer ) );
|
2020-10-16 15:51:24 +00:00
|
|
|
propMgr.AddProperty( new PROPERTY_ENUM<VIA, PCB_LAYER_ID>( _HKI( "Layer Bottom" ),
|
2020-02-05 15:04:12 +00:00
|
|
|
&VIA::SetBottomLayer, &VIA::BottomLayer ) );
|
2020-10-16 15:51:24 +00:00
|
|
|
propMgr.AddProperty( new PROPERTY_ENUM<VIA, VIATYPE>( _HKI( "Via Type" ),
|
2020-02-05 15:04:12 +00:00
|
|
|
&VIA::SetViaType, &VIA::GetViaType ) );
|
2020-02-02 18:40:14 +00:00
|
|
|
}
|
|
|
|
} _TRACK_VIA_DESC;
|
|
|
|
|
|
|
|
ENUM_TO_WXANY( VIATYPE );
|