2012-09-24 16:03:03 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2023-01-23 10:50:27 +00:00
|
|
|
* Copyright (C) 1992-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
2012-09-24 16:03:03 +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
|
|
|
|
*/
|
|
|
|
|
2020-01-07 17:12:59 +00:00
|
|
|
#include <algorithm> // for min
|
|
|
|
#include <bitset> // for bitset, operator&, __bi...
|
|
|
|
#include <math.h> // for abs
|
|
|
|
|
|
|
|
#include <geometry/seg.h> // for SEG
|
2020-09-12 20:09:40 +00:00
|
|
|
#include <geometry/shape_circle.h>
|
2020-01-07 17:12:59 +00:00
|
|
|
#include <geometry/shape_line_chain.h> // for SHAPE_LINE_CHAIN
|
|
|
|
#include <geometry/shape_poly_set.h> // for SHAPE_POLY_SET, SHAPE_P...
|
2020-09-12 20:09:40 +00:00
|
|
|
#include <geometry/shape_segment.h>
|
2021-07-29 09:56:22 +00:00
|
|
|
#include <string_utils.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, Clamp
|
|
|
|
#include <math/vector2d.h> // for VECTOR2I
|
2021-08-18 20:38:14 +00:00
|
|
|
#include <plotters/plotter_gerber.h>
|
2012-09-24 16:03:03 +00:00
|
|
|
#include <trigo.h>
|
2020-01-07 17:12:59 +00:00
|
|
|
|
|
|
|
#include <core/typeinfo.h> // for dyn_cast, PCB_DIMENSION_T
|
|
|
|
#include <gbr_metadata.h>
|
|
|
|
#include <gbr_netlist_metadata.h> // for GBR_NETLIST_METADATA
|
2021-08-17 19:41:08 +00:00
|
|
|
#include <layer_ids.h> // for LSET, IsCopperLayer
|
2020-01-07 17:12:59 +00:00
|
|
|
#include <pcbplot.h>
|
|
|
|
#include <pcb_plot_params.h> // for PCB_PLOT_PARAMS, PCB_PL...
|
2021-01-04 22:26:23 +00:00
|
|
|
#include <advanced_config.h>
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2021-06-11 16:59:28 +00:00
|
|
|
#include <pcb_dimension.h>
|
2020-10-04 23:34:59 +00:00
|
|
|
#include <pcb_shape.h>
|
2020-11-12 20:19:22 +00:00
|
|
|
#include <footprint.h>
|
2021-06-11 21:07:02 +00:00
|
|
|
#include <pcb_track.h>
|
2020-11-12 22:30:02 +00:00
|
|
|
#include <pad.h>
|
2020-11-11 23:05:59 +00:00
|
|
|
#include <pcb_target.h>
|
2020-10-04 23:34:59 +00:00
|
|
|
#include <pcb_text.h>
|
2022-01-30 10:52:52 +00:00
|
|
|
#include <pcb_textbox.h>
|
2024-03-24 16:25:03 +00:00
|
|
|
#include <pcb_tablecell.h>
|
|
|
|
#include <pcb_table.h>
|
2020-11-11 23:05:59 +00:00
|
|
|
#include <zone.h>
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2020-01-07 17:12:59 +00:00
|
|
|
#include <wx/debug.h> // for wxASSERT_MSG
|
|
|
|
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2021-07-21 23:14:56 +00:00
|
|
|
COLOR4D BRDITEMS_PLOTTER::getColor( int aLayer ) const
|
2012-09-24 16:03:03 +00:00
|
|
|
{
|
2020-03-30 01:43:18 +00:00
|
|
|
COLOR4D color = ColorSettings()->GetColor( aLayer );
|
2017-10-08 14:08:42 +00:00
|
|
|
|
2023-06-06 11:30:35 +00:00
|
|
|
// A hack to avoid plotting a white item in white color on white paper
|
2017-02-20 17:48:27 +00:00
|
|
|
if( color == COLOR4D::WHITE )
|
2017-02-20 16:57:41 +00:00
|
|
|
color = COLOR4D( LIGHTGRAY );
|
2017-10-08 14:08:42 +00:00
|
|
|
|
2012-09-24 16:03:03 +00:00
|
|
|
return color;
|
|
|
|
}
|
|
|
|
|
2013-03-20 14:50:12 +00:00
|
|
|
|
2024-05-27 19:56:16 +00:00
|
|
|
void BRDITEMS_PLOTTER::PlotPadNumber( const PAD* aPad, const COLOR4D& aColor )
|
|
|
|
{
|
|
|
|
wxString padNumber = UnescapeString( aPad->GetNumber() );
|
|
|
|
|
|
|
|
if( padNumber.IsEmpty() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
BOX2I padBBox = aPad->GetBoundingBox();
|
|
|
|
VECTOR2I position = padBBox.Centre();
|
|
|
|
VECTOR2I padsize = padBBox.GetSize();
|
|
|
|
|
|
|
|
if( aPad->GetShape() == PAD_SHAPE::CUSTOM )
|
|
|
|
{
|
|
|
|
// See if we have a number box
|
|
|
|
for( const std::shared_ptr<PCB_SHAPE>& primitive : aPad->GetPrimitives() )
|
|
|
|
{
|
|
|
|
if( primitive->IsProxyItem() && primitive->GetShape() == SHAPE_T::RECTANGLE )
|
|
|
|
{
|
|
|
|
position = primitive->GetCenter();
|
|
|
|
RotatePoint( position, aPad->GetOrientation() );
|
|
|
|
position += aPad->ShapePos();
|
|
|
|
|
|
|
|
padsize.x = abs( primitive->GetBotRight().x - primitive->GetTopLeft().x );
|
|
|
|
padsize.y = abs( primitive->GetBotRight().y - primitive->GetTopLeft().y );
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( aPad->GetShape() != PAD_SHAPE::CUSTOM )
|
|
|
|
{
|
|
|
|
// Don't allow a 45° rotation to bloat a pad's bounding box unnecessarily
|
|
|
|
int limit = KiROUND( std::min( aPad->GetSize().x, aPad->GetSize().y ) * 1.1 );
|
|
|
|
|
|
|
|
if( padsize.x > limit && padsize.y > limit )
|
|
|
|
{
|
|
|
|
padsize.x = limit;
|
|
|
|
padsize.y = limit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TEXT_ATTRIBUTES textAttrs;
|
|
|
|
|
|
|
|
if( padsize.x < ( padsize.y * 0.95 ) )
|
|
|
|
{
|
|
|
|
textAttrs.m_Angle = ANGLE_90;
|
|
|
|
std::swap( padsize.x, padsize.y );
|
|
|
|
}
|
|
|
|
|
|
|
|
// approximate the size of the pad number text:
|
|
|
|
// We use a size for at least 3 chars, to give a good look even for short numbers
|
|
|
|
int tsize = KiROUND( padsize.x / std::max( PrintableCharCount( padNumber ), 3 ) );
|
|
|
|
tsize = std::min( tsize, padsize.y );
|
|
|
|
|
|
|
|
// enforce a max size
|
|
|
|
tsize = std::min( tsize, pcbIUScale.mmToIU( 5.0 ) );
|
|
|
|
|
|
|
|
textAttrs.m_Size = VECTOR2I( tsize, tsize );
|
|
|
|
|
|
|
|
// use a somewhat spindly font to go with the outlined pads
|
|
|
|
textAttrs.m_StrokeWidth = KiROUND( tsize / 12.0 );
|
|
|
|
|
|
|
|
m_plotter->PlotText( position, aColor, padNumber, textAttrs );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-07-26 17:28:37 +00:00
|
|
|
void BRDITEMS_PLOTTER::PlotPad( const PAD* aPad, const COLOR4D& aColor, OUTLINE_MODE aPlotMode )
|
2012-09-25 07:49:29 +00:00
|
|
|
{
|
2022-01-01 06:04:08 +00:00
|
|
|
VECTOR2I shape_pos = aPad->ShapePos();
|
2023-06-06 11:30:35 +00:00
|
|
|
GBR_METADATA metadata;
|
2016-09-19 11:01:36 +00:00
|
|
|
|
2020-06-14 16:16:01 +00:00
|
|
|
bool plotOnCopperLayer = ( m_layerMask & LSET::AllCuMask() ).any();
|
|
|
|
bool plotOnExternalCopperLayer = ( m_layerMask & LSET::ExternalCuMask() ).any();
|
|
|
|
|
|
|
|
// Pad not on the solder mask layer cannot be soldered.
|
|
|
|
// therefore it can have a specific aperture attribute.
|
|
|
|
// Not yet in use.
|
|
|
|
// bool isPadOnBoardTechLayers = ( aPad->GetLayerSet() & LSET::AllBoardTechMask() ).any();
|
2016-09-19 11:01:36 +00:00
|
|
|
|
2023-06-24 18:54:50 +00:00
|
|
|
metadata.SetCmpReference( aPad->GetParentFootprint()->GetReference() );
|
2016-09-19 11:01:36 +00:00
|
|
|
|
2020-06-14 16:16:01 +00:00
|
|
|
if( plotOnCopperLayer )
|
2016-09-19 11:01:36 +00:00
|
|
|
{
|
2023-06-06 11:30:35 +00:00
|
|
|
metadata.SetNetAttribType( GBR_NETINFO_ALL );
|
|
|
|
metadata.SetCopper( true );
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2020-06-14 16:16:01 +00:00
|
|
|
// Gives a default attribute, for instance for pads used as tracks in net ties:
|
|
|
|
// Connector pads and SMD pads are on external layers
|
|
|
|
// if on internal layers, they are certainly used as net tie
|
|
|
|
// and are similar to tracks: just conductor items
|
2023-06-06 11:30:35 +00:00
|
|
|
metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CONDUCTOR );
|
2016-09-19 11:01:36 +00:00
|
|
|
|
2020-06-14 16:16:01 +00:00
|
|
|
const bool useUTF8 = false;
|
|
|
|
const bool useQuoting = false;
|
2023-06-06 11:30:35 +00:00
|
|
|
metadata.SetPadName( aPad->GetNumber(), useUTF8, useQuoting );
|
2019-11-17 09:11:29 +00:00
|
|
|
|
2021-08-23 23:10:21 +00:00
|
|
|
if( !aPad->GetNumber().IsEmpty() )
|
2023-06-06 11:30:35 +00:00
|
|
|
metadata.SetPadPinFunction( aPad->GetPinFunction(), useUTF8, useQuoting );
|
2016-09-19 11:01:36 +00:00
|
|
|
|
2023-06-06 11:30:35 +00:00
|
|
|
metadata.SetNetName( aPad->GetNetname() );
|
2016-09-19 11:01:36 +00:00
|
|
|
|
|
|
|
// Some pads are mechanical pads ( through hole or smd )
|
|
|
|
// when this is the case, they have no pad name and/or are not plated.
|
|
|
|
// In this case gerber files have slightly different attributes.
|
2021-08-23 23:10:21 +00:00
|
|
|
if( aPad->GetAttribute() == PAD_ATTRIB::NPTH || aPad->GetNumber().IsEmpty() )
|
2023-06-06 11:30:35 +00:00
|
|
|
metadata.m_NetlistMetadata.m_NotInNet = true;
|
2016-09-19 11:01:36 +00:00
|
|
|
|
2020-06-14 16:16:01 +00:00
|
|
|
if( !plotOnExternalCopperLayer )
|
2016-09-19 11:01:36 +00:00
|
|
|
{
|
2020-06-14 16:16:01 +00:00
|
|
|
// the .P object attribute (GBR_NETLIST_METADATA::GBR_NETINFO_PAD)
|
|
|
|
// is used on outer layers, unless the component is embedded
|
|
|
|
// or a "etched" component (fp only drawn, not a physical component)
|
|
|
|
// Currently, Pcbnew does not handle embedded component, so we disable the .P
|
|
|
|
// attribute on internal layers
|
|
|
|
// Note the Gerber doc is not really clear about through holes pads about the .P
|
2023-06-06 11:30:35 +00:00
|
|
|
metadata.SetNetAttribType( GBR_NETLIST_METADATA::GBR_NETINFO_NET |
|
2016-09-19 11:01:36 +00:00
|
|
|
GBR_NETLIST_METADATA::GBR_NETINFO_CMP );
|
|
|
|
|
|
|
|
}
|
2020-06-14 16:16:01 +00:00
|
|
|
|
|
|
|
// Some attributes are reserved to the external copper layers:
|
|
|
|
// GBR_APERTURE_ATTRIB_CONNECTORPAD and GBR_APERTURE_ATTRIB_SMDPAD_CUDEF
|
|
|
|
// for instance.
|
2021-05-01 14:46:50 +00:00
|
|
|
// Pad with type PAD_ATTRIB::CONN or PAD_ATTRIB::SMD that is not on outer layer
|
2020-06-14 16:16:01 +00:00
|
|
|
// has its aperture attribute set to GBR_APERTURE_ATTRIB_CONDUCTOR
|
|
|
|
switch( aPad->GetAttribute() )
|
2016-09-19 11:01:36 +00:00
|
|
|
{
|
2021-05-01 14:46:50 +00:00
|
|
|
case PAD_ATTRIB::NPTH: // Mechanical pad through hole
|
2023-06-06 11:30:35 +00:00
|
|
|
metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_WASHERPAD );
|
2020-06-14 16:16:01 +00:00
|
|
|
break;
|
2016-09-19 11:01:36 +00:00
|
|
|
|
2021-05-01 14:46:50 +00:00
|
|
|
case PAD_ATTRIB::PTH : // Pad through hole, a hole is also expected
|
2023-06-06 11:30:35 +00:00
|
|
|
metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_COMPONENTPAD );
|
2020-06-14 16:16:01 +00:00
|
|
|
break;
|
2016-09-19 11:01:36 +00:00
|
|
|
|
2021-05-01 14:46:50 +00:00
|
|
|
case PAD_ATTRIB::CONN: // Connector pads, no solder paste but with solder mask.
|
2020-06-14 16:16:01 +00:00
|
|
|
if( plotOnExternalCopperLayer )
|
2023-06-06 11:30:35 +00:00
|
|
|
metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CONNECTORPAD );
|
2020-06-14 16:16:01 +00:00
|
|
|
break;
|
2016-09-19 11:01:36 +00:00
|
|
|
|
2021-05-01 14:46:50 +00:00
|
|
|
case PAD_ATTRIB::SMD: // SMD pads (on external copper layer only)
|
2021-07-19 23:56:05 +00:00
|
|
|
// with solder paste and mask
|
2020-06-14 16:16:01 +00:00
|
|
|
if( plotOnExternalCopperLayer )
|
2023-06-06 11:30:35 +00:00
|
|
|
metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_SMDPAD_CUDEF );
|
2020-06-14 16:16:01 +00:00
|
|
|
break;
|
|
|
|
}
|
2019-12-11 10:36:45 +00:00
|
|
|
|
2020-06-14 16:16:01 +00:00
|
|
|
// Fabrication properties can have specific GBR_APERTURE_METADATA options
|
|
|
|
// that replace previous aperture attribute:
|
|
|
|
switch( aPad->GetProperty() )
|
|
|
|
{
|
2021-05-01 14:58:30 +00:00
|
|
|
case PAD_PROP::BGA: // Only applicable to outer layers
|
2020-06-14 16:16:01 +00:00
|
|
|
if( plotOnExternalCopperLayer )
|
2023-06-06 11:30:35 +00:00
|
|
|
metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_BGAPAD_CUDEF );
|
2020-06-14 16:16:01 +00:00
|
|
|
break;
|
2019-12-11 10:36:45 +00:00
|
|
|
|
2021-05-01 14:58:30 +00:00
|
|
|
case PAD_PROP::FIDUCIAL_GLBL:
|
2023-06-06 11:30:35 +00:00
|
|
|
metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_FIDUCIAL_GLBL );
|
2020-06-14 16:16:01 +00:00
|
|
|
break;
|
2019-12-11 10:36:45 +00:00
|
|
|
|
2021-05-01 14:58:30 +00:00
|
|
|
case PAD_PROP::FIDUCIAL_LOCAL:
|
2023-06-06 11:30:35 +00:00
|
|
|
metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_FIDUCIAL_LOCAL );
|
2020-06-14 16:16:01 +00:00
|
|
|
break;
|
2019-12-11 10:36:45 +00:00
|
|
|
|
2021-05-01 14:58:30 +00:00
|
|
|
case PAD_PROP::TESTPOINT: // Only applicable to outer layers
|
2020-06-14 16:16:01 +00:00
|
|
|
if( plotOnExternalCopperLayer )
|
2023-06-06 11:30:35 +00:00
|
|
|
metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_TESTPOINT );
|
2020-06-14 16:16:01 +00:00
|
|
|
break;
|
2019-12-11 10:36:45 +00:00
|
|
|
|
2021-05-01 14:58:30 +00:00
|
|
|
case PAD_PROP::HEATSINK:
|
2023-06-06 11:30:35 +00:00
|
|
|
metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_HEATSINKPAD );
|
2020-06-14 16:16:01 +00:00
|
|
|
break;
|
2019-12-11 10:36:45 +00:00
|
|
|
|
2021-05-01 14:58:30 +00:00
|
|
|
case PAD_PROP::CASTELLATED:
|
2023-06-06 11:30:35 +00:00
|
|
|
metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CASTELLATEDPAD );
|
2020-06-14 16:16:01 +00:00
|
|
|
break;
|
2019-12-11 10:36:45 +00:00
|
|
|
|
2021-05-01 14:58:30 +00:00
|
|
|
case PAD_PROP::NONE:
|
2024-03-04 21:42:57 +00:00
|
|
|
case PAD_PROP::MECHANICAL:
|
2020-06-14 16:16:01 +00:00
|
|
|
break;
|
2016-09-19 11:01:36 +00:00
|
|
|
}
|
|
|
|
|
2020-06-14 16:16:01 +00:00
|
|
|
// Ensure NPTH pads have *always* the GBR_APERTURE_ATTRIB_WASHERPAD attribute
|
2021-05-01 14:46:50 +00:00
|
|
|
if( aPad->GetAttribute() == PAD_ATTRIB::NPTH )
|
2023-06-06 11:30:35 +00:00
|
|
|
metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_WASHERPAD );
|
2016-09-19 11:01:36 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-06-06 11:30:35 +00:00
|
|
|
metadata.SetNetAttribType( GBR_NETLIST_METADATA::GBR_NETINFO_CMP );
|
2016-09-19 11:01:36 +00:00
|
|
|
}
|
2012-09-25 07:49:29 +00:00
|
|
|
|
|
|
|
// Set plot color (change WHITE to LIGHTGRAY because
|
|
|
|
// the white items are not seen on a white paper or screen
|
|
|
|
m_plotter->SetColor( aColor != WHITE ? aColor : LIGHTGRAY);
|
|
|
|
|
2020-05-01 16:24:01 +00:00
|
|
|
if( aPlotMode == SKETCH )
|
2023-06-06 11:30:35 +00:00
|
|
|
m_plotter->SetCurrentLineWidth( GetSketchPadLineWidth(), &metadata );
|
2020-05-01 16:24:01 +00:00
|
|
|
|
2012-09-25 07:49:29 +00:00
|
|
|
switch( aPad->GetShape() )
|
|
|
|
{
|
2021-05-01 12:22:35 +00:00
|
|
|
case PAD_SHAPE::CIRCLE:
|
2023-06-06 11:30:35 +00:00
|
|
|
m_plotter->FlashPadCircle( shape_pos, aPad->GetSize().x, aPlotMode, &metadata );
|
2012-09-25 07:49:29 +00:00
|
|
|
break;
|
|
|
|
|
2021-05-01 12:22:35 +00:00
|
|
|
case PAD_SHAPE::OVAL:
|
2022-01-16 01:06:25 +00:00
|
|
|
m_plotter->FlashPadOval( shape_pos, aPad->GetSize(), aPad->GetOrientation(), aPlotMode,
|
2023-06-06 11:30:35 +00:00
|
|
|
&metadata );
|
2012-09-25 07:49:29 +00:00
|
|
|
break;
|
|
|
|
|
2023-06-02 09:10:48 +00:00
|
|
|
case PAD_SHAPE::RECTANGLE:
|
2022-01-16 01:06:25 +00:00
|
|
|
m_plotter->FlashPadRect( shape_pos, aPad->GetSize(), aPad->GetOrientation(), aPlotMode,
|
2023-06-06 11:30:35 +00:00
|
|
|
&metadata );
|
2012-09-25 07:49:29 +00:00
|
|
|
break;
|
|
|
|
|
2021-05-01 12:22:35 +00:00
|
|
|
case PAD_SHAPE::ROUNDRECT:
|
2016-04-06 18:15:49 +00:00
|
|
|
m_plotter->FlashPadRoundRect( shape_pos, aPad->GetSize(), aPad->GetRoundRectCornerRadius(),
|
2023-06-06 11:30:35 +00:00
|
|
|
aPad->GetOrientation(), aPlotMode, &metadata );
|
2016-04-06 18:15:49 +00:00
|
|
|
break;
|
|
|
|
|
2021-05-01 12:22:35 +00:00
|
|
|
case PAD_SHAPE::TRAPEZOID:
|
2020-09-28 13:36:52 +00:00
|
|
|
{
|
|
|
|
// Build the pad polygon in coordinates relative to the pad
|
|
|
|
// (i.e. for a pad at pos 0,0, rot 0.0). Needed to use aperture macros,
|
|
|
|
// to be able to create a pattern common to all trapezoid pads having the same shape
|
2021-12-29 19:02:50 +00:00
|
|
|
VECTOR2I coord[4];
|
2021-08-17 19:41:08 +00:00
|
|
|
|
|
|
|
// Order is lower left, lower right, upper right, upper left.
|
2021-12-29 19:02:50 +00:00
|
|
|
VECTOR2I half_size = aPad->GetSize() / 2;
|
|
|
|
VECTOR2I trap_delta = aPad->GetDelta() / 2;
|
2020-09-28 13:36:52 +00:00
|
|
|
|
2021-12-29 19:02:50 +00:00
|
|
|
coord[0] = VECTOR2I( -half_size.x - trap_delta.y, half_size.y + trap_delta.x );
|
|
|
|
coord[1] = VECTOR2I( half_size.x + trap_delta.y, half_size.y - trap_delta.x );
|
|
|
|
coord[2] = VECTOR2I( half_size.x - trap_delta.y, -half_size.y + trap_delta.x );
|
|
|
|
coord[3] = VECTOR2I( -half_size.x + trap_delta.y, -half_size.y - trap_delta.x );
|
2020-09-28 13:36:52 +00:00
|
|
|
|
2023-06-06 11:30:35 +00:00
|
|
|
m_plotter->FlashPadTrapez( shape_pos, coord, aPad->GetOrientation(), aPlotMode, &metadata );
|
2020-09-28 13:36:52 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2021-05-01 12:22:35 +00:00
|
|
|
case PAD_SHAPE::CHAMFERED_RECT:
|
2020-10-08 12:51:25 +00:00
|
|
|
if( m_plotter->GetPlotterType() == PLOT_FORMAT::GERBER )
|
|
|
|
{
|
2022-01-16 01:06:25 +00:00
|
|
|
GERBER_PLOTTER* gerberPlotter = static_cast<GERBER_PLOTTER*>( m_plotter );
|
|
|
|
|
|
|
|
gerberPlotter->FlashPadChamferRoundRect( shape_pos, aPad->GetSize(),
|
|
|
|
aPad->GetRoundRectCornerRadius(),
|
|
|
|
aPad->GetChamferRectRatio(),
|
|
|
|
aPad->GetChamferPositions(),
|
2023-06-06 11:30:35 +00:00
|
|
|
aPad->GetOrientation(), aPlotMode, &metadata );
|
2020-10-08 12:51:25 +00:00
|
|
|
break;
|
|
|
|
}
|
2021-08-17 19:41:08 +00:00
|
|
|
|
2020-10-08 12:51:25 +00:00
|
|
|
KI_FALLTHROUGH;
|
|
|
|
|
|
|
|
default:
|
2021-05-01 12:22:35 +00:00
|
|
|
case PAD_SHAPE::CUSTOM:
|
2020-06-22 19:35:09 +00:00
|
|
|
{
|
2023-10-13 11:25:52 +00:00
|
|
|
const std::shared_ptr<SHAPE_POLY_SET>& polygons = aPad->GetEffectivePolygon( ERROR_INSIDE );
|
2017-01-13 17:51:22 +00:00
|
|
|
|
2020-07-25 11:58:17 +00:00
|
|
|
if( polygons->OutlineCount() )
|
|
|
|
{
|
2022-01-16 01:06:25 +00:00
|
|
|
m_plotter->FlashPadCustom( shape_pos, aPad->GetSize(), aPad->GetOrientation(),
|
2023-06-06 11:30:35 +00:00
|
|
|
polygons.get(), aPlotMode, &metadata );
|
2020-07-25 11:58:17 +00:00
|
|
|
}
|
2020-06-22 19:35:09 +00:00
|
|
|
}
|
2012-09-25 07:49:29 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-20 14:50:12 +00:00
|
|
|
|
2021-03-06 09:27:41 +00:00
|
|
|
void BRDITEMS_PLOTTER::PlotFootprintTextItems( const FOOTPRINT* aFootprint )
|
2012-09-24 16:03:03 +00:00
|
|
|
{
|
2023-08-15 15:56:46 +00:00
|
|
|
if( !GetPlotFPText() )
|
|
|
|
return;
|
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
const PCB_TEXT* textItem = &aFootprint->Reference();
|
2023-05-28 16:20:11 +00:00
|
|
|
PCB_LAYER_ID textLayer = textItem->GetLayer();
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2023-06-15 19:37:07 +00:00
|
|
|
// Reference and value have special controls for forcing their plotting
|
2018-05-30 19:45:02 +00:00
|
|
|
if( GetPlotReference() && m_layerMask[textLayer]
|
2020-10-04 23:34:59 +00:00
|
|
|
&& ( textItem->IsVisible() || GetPlotInvisibleText() ) )
|
2018-05-30 19:45:02 +00:00
|
|
|
{
|
2023-08-06 19:20:53 +00:00
|
|
|
PlotText( textItem, textLayer, textItem->IsKnockout(), textItem->GetFontMetrics() );
|
2018-05-30 19:45:02 +00:00
|
|
|
}
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2021-03-06 09:27:41 +00:00
|
|
|
textItem = &aFootprint->Value();
|
2020-10-04 23:34:59 +00:00
|
|
|
textLayer = textItem->GetLayer();
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2018-05-30 19:45:02 +00:00
|
|
|
if( GetPlotValue() && m_layerMask[textLayer]
|
2020-10-04 23:34:59 +00:00
|
|
|
&& ( textItem->IsVisible() || GetPlotInvisibleText() ) )
|
2012-09-24 16:03:03 +00:00
|
|
|
{
|
2023-08-06 19:20:53 +00:00
|
|
|
PlotText( textItem, textLayer, textItem->IsKnockout(), textItem->GetFontMetrics() );
|
2012-09-24 16:03:03 +00:00
|
|
|
}
|
|
|
|
|
2023-06-15 19:37:07 +00:00
|
|
|
std::vector<PCB_TEXT*> texts;
|
|
|
|
|
|
|
|
// Skip the reference and value texts that are handled specially
|
|
|
|
for( PCB_FIELD* field : aFootprint->Fields() )
|
|
|
|
{
|
|
|
|
if( field->IsReference() || field->IsValue() )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
texts.push_back( field );
|
|
|
|
}
|
|
|
|
|
|
|
|
for( BOARD_ITEM* item : aFootprint->GraphicalItems() )
|
2012-09-24 16:03:03 +00:00
|
|
|
{
|
2023-06-24 18:54:50 +00:00
|
|
|
textItem = dynamic_cast<const PCB_TEXT*>( item );
|
2014-06-06 09:44:21 +00:00
|
|
|
|
2023-06-15 19:37:07 +00:00
|
|
|
if( textItem )
|
|
|
|
texts.push_back( static_cast<PCB_TEXT*>( item ) );
|
|
|
|
}
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2023-06-15 19:37:07 +00:00
|
|
|
for( const PCB_TEXT* text : texts )
|
|
|
|
{
|
|
|
|
if( !text->IsVisible() )
|
2012-09-24 16:03:03 +00:00
|
|
|
continue;
|
|
|
|
|
2023-06-15 19:37:07 +00:00
|
|
|
textLayer = text->GetLayer();
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2020-10-13 17:46:48 +00:00
|
|
|
if( textLayer == Edge_Cuts || textLayer >= PCB_LAYER_ID_COUNT )
|
|
|
|
continue;
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2021-12-05 21:56:55 +00:00
|
|
|
if( !m_layerMask[textLayer] || aFootprint->GetPrivateLayers().test( textLayer ) )
|
2012-09-24 16:03:03 +00:00
|
|
|
continue;
|
|
|
|
|
2023-06-15 19:37:07 +00:00
|
|
|
if( text->GetText() == wxT( "${REFERENCE}" ) && !GetPlotReference() )
|
2018-02-10 20:47:19 +00:00
|
|
|
continue;
|
|
|
|
|
2023-06-15 19:37:07 +00:00
|
|
|
if( text->GetText() == wxT( "${VALUE}" ) && !GetPlotValue() )
|
2018-02-10 20:47:19 +00:00
|
|
|
continue;
|
|
|
|
|
2023-08-06 19:20:53 +00:00
|
|
|
PlotText( text, textLayer, text->IsKnockout(), text->GetFontMetrics() );
|
2012-09-24 16:03:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-06-06 11:30:35 +00:00
|
|
|
void BRDITEMS_PLOTTER::PlotBoardGraphicItem( const BOARD_ITEM* item )
|
2012-09-24 16:03:03 +00:00
|
|
|
{
|
2021-08-23 10:25:02 +00:00
|
|
|
switch( item->Type() )
|
2012-09-24 16:03:03 +00:00
|
|
|
{
|
2021-08-23 10:25:02 +00:00
|
|
|
case PCB_SHAPE_T:
|
2023-06-06 11:30:35 +00:00
|
|
|
PlotShape( static_cast<const PCB_SHAPE*>( item ) );
|
2021-08-23 10:25:02 +00:00
|
|
|
break;
|
2020-10-13 17:46:48 +00:00
|
|
|
|
2021-08-23 10:25:02 +00:00
|
|
|
case PCB_TEXT_T:
|
2022-03-08 15:52:25 +00:00
|
|
|
{
|
|
|
|
const PCB_TEXT* text = static_cast<const PCB_TEXT*>( item );
|
2023-08-06 19:20:53 +00:00
|
|
|
PlotText( text, text->GetLayer(), text->IsKnockout(), text->GetFontMetrics() );
|
2022-01-30 10:52:52 +00:00
|
|
|
break;
|
2022-03-08 15:52:25 +00:00
|
|
|
}
|
2022-01-30 10:52:52 +00:00
|
|
|
|
|
|
|
case PCB_TEXTBOX_T:
|
2022-03-08 15:52:25 +00:00
|
|
|
{
|
2023-08-25 13:03:02 +00:00
|
|
|
m_plotter->SetTextMode( PLOT_TEXT_MODE::STROKE );
|
|
|
|
|
2022-03-08 15:52:25 +00:00
|
|
|
const PCB_TEXTBOX* textbox = static_cast<const PCB_TEXTBOX*>( item );
|
2023-08-06 19:20:53 +00:00
|
|
|
PlotText( textbox, textbox->GetLayer(), textbox->IsKnockout(), textbox->GetFontMetrics() );
|
2023-08-25 13:03:02 +00:00
|
|
|
|
2023-08-25 01:00:19 +00:00
|
|
|
if( textbox->IsBorderEnabled() )
|
|
|
|
PlotShape( textbox );
|
2023-08-25 13:03:02 +00:00
|
|
|
|
|
|
|
m_plotter->SetTextMode( GetTextMode() );
|
2021-08-23 10:25:02 +00:00
|
|
|
break;
|
2022-03-08 15:52:25 +00:00
|
|
|
}
|
2020-09-12 20:09:40 +00:00
|
|
|
|
2024-03-24 16:25:03 +00:00
|
|
|
case PCB_TABLE_T:
|
|
|
|
{
|
|
|
|
const PCB_TABLE* table = static_cast<const PCB_TABLE*>( item );
|
|
|
|
|
|
|
|
m_plotter->SetTextMode( PLOT_TEXT_MODE::STROKE );
|
|
|
|
|
|
|
|
for( const PCB_TABLECELL* cell : table->GetCells() )
|
|
|
|
PlotText( cell, cell->GetLayer(), cell->IsKnockout(), cell->GetFontMetrics() );
|
|
|
|
|
|
|
|
PlotTableBorders( table );
|
|
|
|
|
|
|
|
m_plotter->SetTextMode( GetTextMode() );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2021-08-23 10:25:02 +00:00
|
|
|
case PCB_DIM_ALIGNED_T:
|
|
|
|
case PCB_DIM_CENTER_T:
|
|
|
|
case PCB_DIM_RADIAL_T:
|
|
|
|
case PCB_DIM_ORTHOGONAL_T:
|
|
|
|
case PCB_DIM_LEADER_T:
|
2023-08-25 13:03:02 +00:00
|
|
|
m_plotter->SetTextMode( PLOT_TEXT_MODE::STROKE );
|
|
|
|
|
2021-08-23 10:25:02 +00:00
|
|
|
PlotDimension( static_cast<const PCB_DIMENSION_BASE*>( item ) );
|
2023-08-25 13:03:02 +00:00
|
|
|
|
|
|
|
m_plotter->SetTextMode( GetTextMode() );
|
2021-08-23 10:25:02 +00:00
|
|
|
break;
|
2020-10-13 17:46:48 +00:00
|
|
|
|
2021-08-23 10:25:02 +00:00
|
|
|
case PCB_TARGET_T:
|
|
|
|
PlotPcbTarget( static_cast<const PCB_TARGET*>( item ) );
|
|
|
|
break;
|
2020-09-12 20:09:40 +00:00
|
|
|
|
2021-08-23 10:25:02 +00:00
|
|
|
default:
|
|
|
|
break;
|
2012-09-24 16:03:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-17 19:41:08 +00:00
|
|
|
|
2021-06-11 16:59:28 +00:00
|
|
|
void BRDITEMS_PLOTTER::PlotDimension( const PCB_DIMENSION_BASE* aDim )
|
2012-09-24 16:03:03 +00:00
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
if( !m_layerMask[aDim->GetLayer()] )
|
2012-09-24 16:03:03 +00:00
|
|
|
return;
|
|
|
|
|
2020-03-30 01:43:18 +00:00
|
|
|
COLOR4D color = ColorSettings()->GetColor( aDim->GetLayer() );
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2017-08-04 12:43:02 +00:00
|
|
|
// Set plot color (change WHITE to LIGHTGRAY because
|
|
|
|
// the white items are not seen on a white paper or screen
|
|
|
|
m_plotter->SetColor( color != WHITE ? color : LIGHTGRAY);
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2023-08-06 19:20:53 +00:00
|
|
|
PlotText( aDim, aDim->GetLayer(), false, aDim->GetFontMetrics() );
|
2023-06-06 11:30:35 +00:00
|
|
|
|
|
|
|
PCB_SHAPE temp_item;
|
|
|
|
|
2023-11-25 13:05:45 +00:00
|
|
|
temp_item.SetStroke( STROKE_PARAMS( aDim->GetLineThickness(), LINE_STYLE::SOLID ) );
|
2023-06-06 11:30:35 +00:00
|
|
|
temp_item.SetLayer( aDim->GetLayer() );
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2020-09-12 20:09:40 +00:00
|
|
|
for( const std::shared_ptr<SHAPE>& shape : aDim->GetShapes() )
|
2020-09-09 03:17:08 +00:00
|
|
|
{
|
2020-09-12 20:09:40 +00:00
|
|
|
switch( shape->Type() )
|
|
|
|
{
|
|
|
|
case SH_SEGMENT:
|
|
|
|
{
|
|
|
|
const SEG& seg = static_cast<const SHAPE_SEGMENT*>( shape.get() )->GetSeg();
|
|
|
|
|
2023-06-06 11:30:35 +00:00
|
|
|
temp_item.SetShape( SHAPE_T::SEGMENT );
|
|
|
|
temp_item.SetStart( seg.A );
|
|
|
|
temp_item.SetEnd( seg.B );
|
2020-09-12 20:09:40 +00:00
|
|
|
|
2023-06-06 11:30:35 +00:00
|
|
|
PlotShape( &temp_item );
|
2020-09-12 20:09:40 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case SH_CIRCLE:
|
|
|
|
{
|
2022-01-01 18:08:03 +00:00
|
|
|
VECTOR2I start( shape->Centre() );
|
2020-09-12 20:09:40 +00:00
|
|
|
int radius = static_cast<const SHAPE_CIRCLE*>( shape.get() )->GetRadius();
|
|
|
|
|
2023-06-06 11:30:35 +00:00
|
|
|
temp_item.SetShape( SHAPE_T::CIRCLE );
|
|
|
|
temp_item.SetFilled( false );
|
|
|
|
temp_item.SetStart( start );
|
|
|
|
temp_item.SetEnd( VECTOR2I( start.x + radius, start.y ) );
|
2020-09-12 20:09:40 +00:00
|
|
|
|
2023-06-06 11:30:35 +00:00
|
|
|
PlotShape( &temp_item );
|
2020-09-12 20:09:40 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2020-09-09 03:17:08 +00:00
|
|
|
}
|
2012-09-24 16:03:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-03-06 09:27:41 +00:00
|
|
|
void BRDITEMS_PLOTTER::PlotPcbTarget( const PCB_TARGET* aMire )
|
2012-09-24 16:03:03 +00:00
|
|
|
{
|
2021-03-06 09:27:41 +00:00
|
|
|
int dx1, dx2, dy1, dy2, radius;
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
if( !m_layerMask[aMire->GetLayer()] )
|
2012-09-24 16:03:03 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
m_plotter->SetColor( getColor( aMire->GetLayer() ) );
|
|
|
|
|
2023-06-06 11:30:35 +00:00
|
|
|
PCB_SHAPE temp_item;
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2023-06-06 11:30:35 +00:00
|
|
|
temp_item.SetShape( SHAPE_T::CIRCLE );
|
|
|
|
temp_item.SetFilled( false );
|
2023-11-25 13:05:45 +00:00
|
|
|
temp_item.SetStroke( STROKE_PARAMS( aMire->GetWidth(), LINE_STYLE::SOLID ) );
|
2023-06-06 11:30:35 +00:00
|
|
|
temp_item.SetLayer( aMire->GetLayer() );
|
|
|
|
temp_item.SetStart( aMire->GetPosition() );
|
2012-09-24 16:03:03 +00:00
|
|
|
radius = aMire->GetSize() / 3;
|
2013-03-20 14:50:12 +00:00
|
|
|
|
2023-06-06 11:30:35 +00:00
|
|
|
if( aMire->GetShape() ) // temp_item X
|
2012-09-24 16:03:03 +00:00
|
|
|
radius = aMire->GetSize() / 2;
|
|
|
|
|
|
|
|
// Draw the circle
|
2023-06-06 11:30:35 +00:00
|
|
|
temp_item.SetEnd( VECTOR2I( temp_item.GetStart().x + radius, temp_item.GetStart().y ) );
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2023-06-06 11:30:35 +00:00
|
|
|
PlotShape( &temp_item );
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2023-06-06 11:30:35 +00:00
|
|
|
temp_item.SetShape( SHAPE_T::SEGMENT );
|
2012-09-24 16:03:03 +00:00
|
|
|
|
|
|
|
radius = aMire->GetSize() / 2;
|
|
|
|
dx1 = radius;
|
|
|
|
dy1 = 0;
|
|
|
|
dx2 = 0;
|
|
|
|
dy2 = radius;
|
|
|
|
|
|
|
|
if( aMire->GetShape() ) // Shape X
|
|
|
|
{
|
|
|
|
dx1 = dy1 = radius;
|
|
|
|
dx2 = dx1;
|
|
|
|
dy2 = -dy1;
|
|
|
|
}
|
|
|
|
|
2022-01-01 18:08:03 +00:00
|
|
|
VECTOR2I mirePos( aMire->GetPosition() );
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2023-06-06 11:30:35 +00:00
|
|
|
// Draw the X or + temp_item:
|
|
|
|
temp_item.SetStart( VECTOR2I( mirePos.x - dx1, mirePos.y - dy1 ) );
|
|
|
|
temp_item.SetEnd( VECTOR2I( mirePos.x + dx1, mirePos.y + dy1 ) );
|
|
|
|
PlotShape( &temp_item );
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2023-06-06 11:30:35 +00:00
|
|
|
temp_item.SetStart( VECTOR2I( mirePos.x - dx2, mirePos.y - dy2 ) );
|
|
|
|
temp_item.SetEnd( VECTOR2I( mirePos.x + dx2, mirePos.y + dy2 ) );
|
|
|
|
PlotShape( &temp_item );
|
2012-09-24 16:03:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-03-06 09:27:41 +00:00
|
|
|
void BRDITEMS_PLOTTER::PlotFootprintGraphicItems( const FOOTPRINT* aFootprint )
|
2012-09-24 16:03:03 +00:00
|
|
|
{
|
2021-03-06 09:27:41 +00:00
|
|
|
for( const BOARD_ITEM* item : aFootprint->GraphicalItems() )
|
2012-09-24 16:03:03 +00:00
|
|
|
{
|
2021-12-05 21:56:55 +00:00
|
|
|
if( aFootprint->GetPrivateLayers().test( item->GetLayer() ) )
|
|
|
|
continue;
|
|
|
|
|
2023-08-25 13:03:02 +00:00
|
|
|
if( !m_layerMask[ item->GetLayer() ] )
|
|
|
|
continue;
|
|
|
|
|
2022-01-30 10:52:52 +00:00
|
|
|
switch( item->Type() )
|
|
|
|
{
|
2023-03-30 11:49:23 +00:00
|
|
|
case PCB_SHAPE_T:
|
2023-08-25 13:03:02 +00:00
|
|
|
PlotShape( static_cast<const PCB_SHAPE*>( item ) );
|
2022-01-30 10:52:52 +00:00
|
|
|
break;
|
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
case PCB_TEXTBOX_T:
|
2022-01-30 10:52:52 +00:00
|
|
|
{
|
2023-03-30 11:49:23 +00:00
|
|
|
const PCB_TEXTBOX* textbox = static_cast<const PCB_TEXTBOX*>( item );
|
2022-01-30 10:52:52 +00:00
|
|
|
|
2023-08-25 13:03:02 +00:00
|
|
|
m_plotter->SetTextMode( PLOT_TEXT_MODE::STROKE );
|
|
|
|
|
|
|
|
PlotText( textbox, textbox->GetLayer(), textbox->IsKnockout(),
|
|
|
|
textbox->GetFontMetrics() );
|
|
|
|
|
|
|
|
if( textbox->IsBorderEnabled() )
|
|
|
|
PlotShape( textbox );
|
2022-01-30 10:52:52 +00:00
|
|
|
|
2023-08-25 13:03:02 +00:00
|
|
|
m_plotter->SetTextMode( GetTextMode() );
|
2022-01-30 10:52:52 +00:00
|
|
|
break;
|
2021-12-04 23:52:00 +00:00
|
|
|
}
|
2022-01-30 10:52:52 +00:00
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
case PCB_DIM_ALIGNED_T:
|
|
|
|
case PCB_DIM_CENTER_T:
|
|
|
|
case PCB_DIM_RADIAL_T:
|
|
|
|
case PCB_DIM_ORTHOGONAL_T:
|
|
|
|
case PCB_DIM_LEADER_T:
|
2023-08-25 13:03:02 +00:00
|
|
|
PlotDimension( static_cast<const PCB_DIMENSION_BASE*>( item ) );
|
2022-01-30 10:52:52 +00:00
|
|
|
break;
|
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
case PCB_TEXT_T:
|
2023-05-28 16:20:11 +00:00
|
|
|
// Plotted in PlotFootprintTextItems()
|
2022-01-30 10:52:52 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
UNIMPLEMENTED_FOR( item->GetClass() );
|
2021-12-04 23:52:00 +00:00
|
|
|
}
|
2012-09-24 16:03:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-01-23 10:50:27 +00:00
|
|
|
#include <font/stroke_font.h>
|
2023-08-06 19:20:53 +00:00
|
|
|
void BRDITEMS_PLOTTER::PlotText( const EDA_TEXT* aText, PCB_LAYER_ID aLayer, bool aIsKnockout,
|
|
|
|
const KIFONT::METRICS& aFontMetrics )
|
2012-09-24 16:03:03 +00:00
|
|
|
{
|
2022-10-22 20:32:10 +00:00
|
|
|
KIFONT::FONT* font = aText->GetFont();
|
|
|
|
|
|
|
|
if( !font )
|
|
|
|
{
|
2023-06-06 11:30:35 +00:00
|
|
|
wxString defaultFontName; // empty string is the KiCad stroke font
|
|
|
|
|
|
|
|
if( m_plotter->RenderSettings() )
|
|
|
|
defaultFontName = m_plotter->RenderSettings()->GetDefaultFont();
|
|
|
|
|
|
|
|
font = KIFONT::FONT::GetFont( defaultFontName, aText->IsBold(), aText->IsItalic() );
|
2022-10-22 20:32:10 +00:00
|
|
|
}
|
|
|
|
|
2023-05-05 13:21:56 +00:00
|
|
|
wxString shownText( aText->GetShownText( true ) );
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2014-09-13 18:15:45 +00:00
|
|
|
if( shownText.IsEmpty() )
|
2012-09-24 16:03:03 +00:00
|
|
|
return;
|
|
|
|
|
2022-01-30 10:52:52 +00:00
|
|
|
if( !m_layerMask[aLayer] )
|
2012-09-24 16:03:03 +00:00
|
|
|
return;
|
|
|
|
|
2016-09-19 11:01:36 +00:00
|
|
|
GBR_METADATA gbr_metadata;
|
|
|
|
|
2022-01-30 10:52:52 +00:00
|
|
|
if( IsCopperLayer( aLayer ) )
|
2016-09-19 11:01:36 +00:00
|
|
|
gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_NONCONDUCTOR );
|
|
|
|
|
2022-01-30 10:52:52 +00:00
|
|
|
COLOR4D color = getColor( aLayer );
|
2017-07-31 12:28:35 +00:00
|
|
|
m_plotter->SetColor( color );
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2021-12-29 21:30:11 +00:00
|
|
|
VECTOR2I pos = aText->GetTextPos();
|
2022-03-08 15:52:25 +00:00
|
|
|
|
2023-02-24 08:44:25 +00:00
|
|
|
TEXT_ATTRIBUTES attrs = aText->GetAttributes();
|
2022-03-08 15:52:25 +00:00
|
|
|
attrs.m_StrokeWidth = aText->GetEffectiveTextPenWidth();
|
2023-02-24 08:44:25 +00:00
|
|
|
attrs.m_Angle = aText->GetDrawRotation();
|
|
|
|
attrs.m_Multiline = false;
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2022-03-08 15:52:25 +00:00
|
|
|
m_plotter->SetCurrentLineWidth( attrs.m_StrokeWidth );
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2022-03-08 15:52:25 +00:00
|
|
|
if( aIsKnockout )
|
|
|
|
{
|
2023-05-28 16:20:11 +00:00
|
|
|
const PCB_TEXT* text = static_cast<const PCB_TEXT*>( aText );
|
2023-06-06 11:30:35 +00:00
|
|
|
SHAPE_POLY_SET finalPoly;
|
2022-03-08 15:52:25 +00:00
|
|
|
|
2023-06-06 11:30:35 +00:00
|
|
|
text->TransformTextToPolySet( finalPoly, 0, m_board->GetDesignSettings().m_MaxError,
|
|
|
|
ERROR_INSIDE );
|
2022-03-08 15:52:25 +00:00
|
|
|
finalPoly.Fracture( SHAPE_POLY_SET::PM_FAST );
|
|
|
|
|
|
|
|
for( int ii = 0; ii < finalPoly.OutlineCount(); ++ii )
|
|
|
|
m_plotter->PlotPoly( finalPoly.Outline( ii ), FILL_T::FILLED_SHAPE, 0, &gbr_metadata );
|
|
|
|
}
|
|
|
|
else if( aText->IsMultilineAllowed() )
|
2012-09-24 16:03:03 +00:00
|
|
|
{
|
2022-01-01 06:04:08 +00:00
|
|
|
std::vector<VECTOR2I> positions;
|
2015-01-15 20:01:53 +00:00
|
|
|
wxArrayString strings_list;
|
|
|
|
wxStringSplit( shownText, strings_list, '\n' );
|
|
|
|
positions.reserve( strings_list.Count() );
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2020-11-24 22:16:41 +00:00
|
|
|
aText->GetLinePositions( positions, strings_list.Count() );
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2021-03-06 09:27:41 +00:00
|
|
|
for( unsigned ii = 0; ii < strings_list.Count(); ii++ )
|
2012-09-24 16:03:03 +00:00
|
|
|
{
|
2015-01-15 20:01:53 +00:00
|
|
|
wxString& txt = strings_list.Item( ii );
|
2023-08-06 19:20:53 +00:00
|
|
|
m_plotter->PlotText( positions[ii], color, txt, attrs, font, aFontMetrics, &gbr_metadata );
|
2012-09-24 16:03:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-08-06 19:20:53 +00:00
|
|
|
m_plotter->PlotText( pos, color, shownText, attrs, font, aFontMetrics, &gbr_metadata );
|
2012-09-24 16:03:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-08-07 12:06:46 +00:00
|
|
|
void BRDITEMS_PLOTTER::PlotZone( const ZONE* aZone, PCB_LAYER_ID aLayer,
|
|
|
|
const SHAPE_POLY_SET& aPolysList )
|
2012-09-24 16:03:03 +00:00
|
|
|
{
|
2023-06-06 11:30:35 +00:00
|
|
|
if( aPolysList.IsEmpty() )
|
2012-09-24 16:03:03 +00:00
|
|
|
return;
|
|
|
|
|
2016-09-19 11:01:36 +00:00
|
|
|
GBR_METADATA gbr_metadata;
|
|
|
|
|
2023-04-08 14:02:48 +00:00
|
|
|
if( aZone->IsOnCopperLayer() )
|
2016-09-19 11:01:36 +00:00
|
|
|
{
|
|
|
|
gbr_metadata.SetNetName( aZone->GetNetname() );
|
2017-05-03 18:04:31 +00:00
|
|
|
gbr_metadata.SetCopper( true );
|
2016-09-19 11:01:36 +00:00
|
|
|
|
|
|
|
// Zones with no net name can exist.
|
|
|
|
// they are not used to connect items, so the aperture attribute cannot
|
|
|
|
// be set as conductor
|
|
|
|
if( aZone->GetNetname().IsEmpty() )
|
2021-01-03 13:59:23 +00:00
|
|
|
{
|
2023-06-06 11:30:35 +00:00
|
|
|
gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_NONCONDUCTOR );
|
2021-01-03 13:59:23 +00:00
|
|
|
}
|
2016-09-19 11:01:36 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CONDUCTOR );
|
|
|
|
gbr_metadata.SetNetAttribType( GBR_NETLIST_METADATA::GBR_NETINFO_NET );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-08 15:52:25 +00:00
|
|
|
m_plotter->SetColor( getColor( aLayer ) );
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2020-06-28 08:37:36 +00:00
|
|
|
m_plotter->StartBlock( nullptr ); // Clean current object attributes
|
|
|
|
|
2022-02-11 12:42:09 +00:00
|
|
|
/*
|
|
|
|
* In non filled mode the outline is plotted, but not the filling items
|
2012-09-24 16:03:03 +00:00
|
|
|
*/
|
2019-08-25 10:10:48 +00:00
|
|
|
|
2023-06-06 11:30:35 +00:00
|
|
|
for( int idx = 0; idx < aPolysList.OutlineCount(); ++idx )
|
2012-09-24 16:03:03 +00:00
|
|
|
{
|
2023-06-06 11:30:35 +00:00
|
|
|
const SHAPE_LINE_CHAIN& outline = aPolysList.Outline( idx );
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2022-02-11 12:42:09 +00:00
|
|
|
// Plot the current filled area (as region for Gerber plotter to manage attributes)
|
2021-06-03 20:31:25 +00:00
|
|
|
if( GetPlotMode() == FILLED )
|
2012-09-24 16:03:03 +00:00
|
|
|
{
|
2021-06-03 20:31:25 +00:00
|
|
|
if( m_plotter->GetPlotterType() == PLOT_FORMAT::GERBER )
|
2012-09-24 16:03:03 +00:00
|
|
|
{
|
2021-07-19 23:56:05 +00:00
|
|
|
static_cast<GERBER_PLOTTER*>( m_plotter )->PlotGerberRegion( outline,
|
|
|
|
&gbr_metadata );
|
2012-09-24 16:03:03 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-02-11 12:42:09 +00:00
|
|
|
m_plotter->PlotPoly( outline, FILL_T::FILLED_SHAPE, 0, &gbr_metadata );
|
2021-06-03 20:31:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_plotter->SetCurrentLineWidth( -1 );
|
2012-09-24 16:03:03 +00:00
|
|
|
}
|
|
|
|
}
|
2020-06-28 08:37:36 +00:00
|
|
|
|
|
|
|
m_plotter->EndBlock( nullptr ); // Clear object attributes
|
2012-09-24 16:03:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-06-06 11:30:35 +00:00
|
|
|
void BRDITEMS_PLOTTER::PlotShape( const PCB_SHAPE* aShape )
|
2012-09-24 16:03:03 +00:00
|
|
|
{
|
2020-10-04 23:34:59 +00:00
|
|
|
if( !m_layerMask[aShape->GetLayer()] )
|
2012-09-24 16:03:03 +00:00
|
|
|
return;
|
|
|
|
|
2023-11-25 13:05:45 +00:00
|
|
|
bool sketch = GetPlotMode() == SKETCH;
|
|
|
|
int thickness = aShape->GetWidth();
|
|
|
|
LINE_STYLE lineStyle = aShape->GetStroke().GetLineStyle();
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
m_plotter->SetColor( getColor( aShape->GetLayer() ) );
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
const FOOTPRINT* parentFP = aShape->GetParentFootprint();
|
|
|
|
GBR_METADATA gbr_metadata;
|
|
|
|
|
|
|
|
if( parentFP )
|
2023-04-07 09:23:24 +00:00
|
|
|
{
|
2023-03-30 11:49:23 +00:00
|
|
|
gbr_metadata.SetCmpReference( parentFP->GetReference() );
|
2023-04-07 09:23:24 +00:00
|
|
|
gbr_metadata.SetNetAttribType( GBR_NETLIST_METADATA::GBR_NETINFO_CMP );
|
|
|
|
}
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
if( aShape->GetLayer() == Edge_Cuts )
|
2023-03-30 11:49:23 +00:00
|
|
|
{
|
2019-10-09 13:46:35 +00:00
|
|
|
gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_EDGECUT );
|
2023-03-30 11:49:23 +00:00
|
|
|
}
|
|
|
|
else if( IsCopperLayer( aShape->GetLayer() ) )
|
|
|
|
{
|
|
|
|
if( parentFP )
|
|
|
|
{
|
|
|
|
gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_ETCHEDCMP );
|
|
|
|
gbr_metadata.SetCopper( true );
|
|
|
|
}
|
2023-07-30 19:39:07 +00:00
|
|
|
else if( aShape->GetNetCode() > 0 )
|
|
|
|
{
|
|
|
|
gbr_metadata.SetCopper( true );
|
|
|
|
gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CONDUCTOR );
|
|
|
|
gbr_metadata.SetNetAttribType( GBR_NETLIST_METADATA::GBR_NETINFO_NET );
|
|
|
|
gbr_metadata.SetNetName( aShape->GetNetname() );
|
|
|
|
}
|
2023-03-30 11:49:23 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// Graphic items (PCB_SHAPE, TEXT) having no net have the NonConductor attribute
|
|
|
|
// Graphic items having a net have the Conductor attribute, but are not (yet?)
|
|
|
|
// supported in Pcbnew
|
|
|
|
gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_NONCONDUCTOR );
|
|
|
|
}
|
|
|
|
}
|
2020-03-19 11:53:52 +00:00
|
|
|
|
2023-11-25 13:05:45 +00:00
|
|
|
if( lineStyle <= LINE_STYLE::FIRST_TYPE )
|
2012-09-24 16:03:03 +00:00
|
|
|
{
|
2021-08-25 23:14:36 +00:00
|
|
|
switch( aShape->GetShape() )
|
2021-07-17 19:56:18 +00:00
|
|
|
{
|
2021-08-25 23:14:36 +00:00
|
|
|
case SHAPE_T::SEGMENT:
|
|
|
|
m_plotter->ThickSegment( aShape->GetStart(), aShape->GetEnd(), thickness, GetPlotMode(),
|
|
|
|
&gbr_metadata );
|
|
|
|
break;
|
2020-11-14 01:16:02 +00:00
|
|
|
|
2021-08-25 23:14:36 +00:00
|
|
|
case SHAPE_T::CIRCLE:
|
|
|
|
if( aShape->IsFilled() )
|
|
|
|
{
|
|
|
|
m_plotter->FilledCircle( aShape->GetStart(), aShape->GetRadius() * 2 + thickness,
|
|
|
|
GetPlotMode(), &gbr_metadata );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_plotter->ThickCircle( aShape->GetStart(), aShape->GetRadius() * 2, thickness,
|
|
|
|
GetPlotMode(), &gbr_metadata );
|
|
|
|
}
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2021-08-25 23:14:36 +00:00
|
|
|
break;
|
2018-02-04 16:22:14 +00:00
|
|
|
|
2021-08-25 23:14:36 +00:00
|
|
|
case SHAPE_T::ARC:
|
2020-11-14 01:16:02 +00:00
|
|
|
{
|
2021-08-25 23:14:36 +00:00
|
|
|
// when startAngle == endAngle ThickArc() doesn't know whether it's 0 deg and 360 deg
|
2022-02-20 13:59:11 +00:00
|
|
|
// but it is a circle
|
2022-01-14 15:34:41 +00:00
|
|
|
if( std::abs( aShape->GetArcAngle().AsDegrees() ) == 360.0 )
|
2021-08-25 23:14:36 +00:00
|
|
|
{
|
|
|
|
m_plotter->ThickCircle( aShape->GetCenter(), aShape->GetRadius() * 2, thickness,
|
|
|
|
GetPlotMode(), &gbr_metadata );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-02-20 13:59:11 +00:00
|
|
|
m_plotter->ThickArc( *aShape, GetPlotMode(), &gbr_metadata );
|
2021-08-25 23:14:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
2020-11-14 01:16:02 +00:00
|
|
|
}
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2021-08-25 23:14:36 +00:00
|
|
|
case SHAPE_T::BEZIER:
|
|
|
|
m_plotter->BezierCurve( aShape->GetStart(), aShape->GetBezierC1(),
|
|
|
|
aShape->GetBezierC2(), aShape->GetEnd(), 0, thickness );
|
|
|
|
break;
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2021-08-25 23:14:36 +00:00
|
|
|
case SHAPE_T::POLY:
|
|
|
|
if( aShape->IsPolyShapeValid() )
|
2018-12-02 04:41:17 +00:00
|
|
|
{
|
2022-02-28 14:32:10 +00:00
|
|
|
if( sketch )
|
2018-12-02 04:41:17 +00:00
|
|
|
{
|
2021-08-25 23:14:36 +00:00
|
|
|
for( auto it = aShape->GetPolyShape().CIterateSegments( 0 ); it; it++ )
|
|
|
|
{
|
|
|
|
auto seg = it.Get();
|
2022-01-01 18:08:03 +00:00
|
|
|
m_plotter->ThickSegment( seg.A, seg.B, thickness, GetPlotMode(),
|
|
|
|
&gbr_metadata );
|
2021-08-25 23:14:36 +00:00
|
|
|
}
|
2018-12-02 04:41:17 +00:00
|
|
|
}
|
2022-02-28 14:32:10 +00:00
|
|
|
else
|
2021-08-25 23:14:36 +00:00
|
|
|
{
|
|
|
|
m_plotter->SetCurrentLineWidth( thickness, &gbr_metadata );
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2021-08-25 23:14:36 +00:00
|
|
|
// Draw the polygon: only one polygon is expected
|
|
|
|
// However we provide a multi polygon shape drawing
|
|
|
|
// ( for the future or to show a non expected shape )
|
|
|
|
// This must be simplified and fractured to prevent overlapping polygons
|
|
|
|
// from generating invalid Gerber files
|
2022-03-14 15:52:12 +00:00
|
|
|
SHAPE_POLY_SET tmpPoly = aShape->GetPolyShape().CloneDropTriangulation();
|
2021-08-25 23:14:36 +00:00
|
|
|
tmpPoly.Fracture( SHAPE_POLY_SET::PM_FAST );
|
2022-02-28 14:32:10 +00:00
|
|
|
FILL_T fill = aShape->IsFilled() ? FILL_T::FILLED_SHAPE : FILL_T::NO_FILL;
|
2018-12-21 01:03:55 +00:00
|
|
|
|
2021-08-25 23:14:36 +00:00
|
|
|
for( int jj = 0; jj < tmpPoly.OutlineCount(); ++jj )
|
|
|
|
{
|
|
|
|
SHAPE_LINE_CHAIN& poly = tmpPoly.Outline( jj );
|
2022-02-28 14:32:10 +00:00
|
|
|
|
|
|
|
// Ensure the polygon is closed:
|
|
|
|
poly.SetClosed( true );
|
|
|
|
|
2023-02-25 14:22:49 +00:00
|
|
|
// Plot the current filled area
|
|
|
|
// (as region for Gerber plotter to manage attributes)
|
|
|
|
if( m_plotter->GetPlotterType() == PLOT_FORMAT::GERBER )
|
|
|
|
{
|
|
|
|
static_cast<GERBER_PLOTTER*>( m_plotter )->
|
|
|
|
PlotPolyAsRegion( poly, fill, thickness, &gbr_metadata );
|
|
|
|
}
|
|
|
|
else
|
2023-03-30 11:49:23 +00:00
|
|
|
{
|
2023-02-25 14:22:49 +00:00
|
|
|
m_plotter->PlotPoly( poly, fill, thickness, &gbr_metadata );
|
2023-03-30 11:49:23 +00:00
|
|
|
}
|
2021-08-25 23:14:36 +00:00
|
|
|
}
|
2018-12-02 04:41:17 +00:00
|
|
|
}
|
2017-11-16 11:09:24 +00:00
|
|
|
}
|
|
|
|
|
2021-08-25 23:14:36 +00:00
|
|
|
break;
|
2020-07-17 09:26:35 +00:00
|
|
|
|
2023-07-24 16:07:56 +00:00
|
|
|
case SHAPE_T::RECTANGLE:
|
2020-07-17 09:26:35 +00:00
|
|
|
{
|
2022-01-01 06:04:08 +00:00
|
|
|
std::vector<VECTOR2I> pts = aShape->GetRectCorners();
|
2020-11-14 01:16:02 +00:00
|
|
|
|
2023-02-25 14:22:49 +00:00
|
|
|
if( sketch )
|
2021-08-25 23:14:36 +00:00
|
|
|
{
|
|
|
|
m_plotter->ThickSegment( pts[0], pts[1], thickness, GetPlotMode(), &gbr_metadata );
|
|
|
|
m_plotter->ThickSegment( pts[1], pts[2], thickness, GetPlotMode(), &gbr_metadata );
|
|
|
|
m_plotter->ThickSegment( pts[2], pts[3], thickness, GetPlotMode(), &gbr_metadata );
|
|
|
|
m_plotter->ThickSegment( pts[3], pts[0], thickness, GetPlotMode(), &gbr_metadata );
|
|
|
|
}
|
2023-03-30 11:49:23 +00:00
|
|
|
|
|
|
|
if( !sketch )
|
2021-08-25 23:14:36 +00:00
|
|
|
{
|
|
|
|
SHAPE_LINE_CHAIN poly;
|
2020-07-17 09:26:35 +00:00
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
for( const VECTOR2I& pt : pts )
|
2021-08-25 23:14:36 +00:00
|
|
|
poly.Append( pt );
|
2020-07-17 09:26:35 +00:00
|
|
|
|
2023-02-25 14:22:49 +00:00
|
|
|
poly.Append( pts[0] ); // Close polygon.
|
|
|
|
|
2023-06-06 11:30:35 +00:00
|
|
|
FILL_T fill_mode = aShape->IsFilled() ? FILL_T::FILLED_SHAPE : FILL_T::NO_FILL;
|
2023-02-25 14:22:49 +00:00
|
|
|
|
|
|
|
if( m_plotter->GetPlotterType() == PLOT_FORMAT::GERBER )
|
|
|
|
{
|
|
|
|
static_cast<GERBER_PLOTTER*>( m_plotter )->
|
|
|
|
PlotPolyAsRegion( poly, fill_mode, thickness, &gbr_metadata );
|
|
|
|
}
|
|
|
|
else
|
2023-03-30 11:49:23 +00:00
|
|
|
{
|
2023-02-25 14:22:49 +00:00
|
|
|
m_plotter->PlotPoly( poly, fill_mode, thickness, &gbr_metadata );
|
2023-03-30 11:49:23 +00:00
|
|
|
}
|
2021-08-25 23:14:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
2020-07-17 09:26:35 +00:00
|
|
|
}
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2021-08-25 23:14:36 +00:00
|
|
|
default:
|
|
|
|
UNIMPLEMENTED_FOR( aShape->SHAPE_T_asString() );
|
|
|
|
}
|
2021-07-19 23:56:05 +00:00
|
|
|
}
|
2021-08-25 23:14:36 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
std::vector<SHAPE*> shapes = aShape->MakeEffectiveShapes( true );
|
2020-07-17 09:26:35 +00:00
|
|
|
|
2021-08-25 23:14:36 +00:00
|
|
|
for( SHAPE* shape : shapes )
|
|
|
|
{
|
|
|
|
STROKE_PARAMS::Stroke( shape, lineStyle, thickness, m_plotter->RenderSettings(),
|
2022-01-01 18:08:03 +00:00
|
|
|
[&]( const VECTOR2I& a, const VECTOR2I& b )
|
2021-08-25 23:14:36 +00:00
|
|
|
{
|
|
|
|
m_plotter->ThickSegment( a, b, thickness, GetPlotMode(),
|
|
|
|
&gbr_metadata );
|
|
|
|
} );
|
|
|
|
}
|
|
|
|
|
|
|
|
for( SHAPE* shape : shapes )
|
|
|
|
delete shape;
|
2012-09-24 16:03:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-20 14:50:12 +00:00
|
|
|
|
2024-03-24 16:25:03 +00:00
|
|
|
void BRDITEMS_PLOTTER::PlotTableBorders( const PCB_TABLE* aTable )
|
|
|
|
{
|
|
|
|
VECTOR2I pos = aTable->GetPosition();
|
|
|
|
VECTOR2I end = aTable->GetEnd();
|
|
|
|
int lineWidth;
|
|
|
|
LINE_STYLE lineStyle;
|
|
|
|
GBR_METADATA gbr_metadata;
|
|
|
|
|
|
|
|
if( const FOOTPRINT* parentFP = aTable->GetParentFootprint() )
|
|
|
|
{
|
|
|
|
gbr_metadata.SetCmpReference( parentFP->GetReference() );
|
|
|
|
gbr_metadata.SetNetAttribType( GBR_NETLIST_METADATA::GBR_NETINFO_CMP );
|
|
|
|
}
|
|
|
|
|
|
|
|
auto setupStroke =
|
|
|
|
[&]( const STROKE_PARAMS& stroke )
|
|
|
|
{
|
|
|
|
lineWidth = stroke.GetWidth();
|
|
|
|
lineStyle = stroke.GetLineStyle();
|
|
|
|
};
|
|
|
|
|
|
|
|
auto strokeShape =
|
|
|
|
[&]( const SHAPE& shape )
|
|
|
|
{
|
|
|
|
STROKE_PARAMS::Stroke( &shape, lineStyle, lineWidth, m_plotter->RenderSettings(),
|
|
|
|
[&]( const VECTOR2I& a, const VECTOR2I& b )
|
|
|
|
{
|
|
|
|
m_plotter->ThickSegment( a, b, lineWidth, GetPlotMode(),
|
|
|
|
&gbr_metadata );
|
|
|
|
} );
|
|
|
|
};
|
|
|
|
|
|
|
|
auto strokeLine =
|
|
|
|
[&]( const VECTOR2I& ptA, const VECTOR2I& ptB )
|
|
|
|
{
|
|
|
|
if( lineStyle <= LINE_STYLE::FIRST_TYPE )
|
|
|
|
{
|
|
|
|
m_plotter->ThickSegment( ptA, ptB, lineWidth, GetPlotMode(), &gbr_metadata );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SHAPE_SEGMENT seg( ptA, ptB );
|
|
|
|
strokeShape( seg );
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
auto strokeRect =
|
|
|
|
[&]( const VECTOR2I& ptA, const VECTOR2I& ptB )
|
|
|
|
{
|
|
|
|
strokeLine( VECTOR2I( ptA.x, ptA.y ), VECTOR2I( ptB.x, ptA.y ) );
|
|
|
|
strokeLine( VECTOR2I( ptB.x, ptA.y ), VECTOR2I( ptB.x, ptB.y ) );
|
|
|
|
strokeLine( VECTOR2I( ptB.x, ptB.y ), VECTOR2I( ptA.x, ptB.y ) );
|
|
|
|
strokeLine( VECTOR2I( ptA.x, ptB.y ), VECTOR2I( ptA.x, ptA.y ) );
|
|
|
|
};
|
|
|
|
|
|
|
|
if( aTable->GetSeparatorsStroke().GetWidth() >= 0 )
|
|
|
|
{
|
|
|
|
setupStroke( aTable->GetSeparatorsStroke() );
|
|
|
|
|
|
|
|
if( aTable->StrokeColumns() )
|
|
|
|
{
|
|
|
|
for( int col = 0; col < aTable->GetColCount() - 1; ++col )
|
|
|
|
{
|
|
|
|
for( int row = 0; row < aTable->GetRowCount(); ++row )
|
|
|
|
{
|
|
|
|
PCB_TABLECELL* cell = aTable->GetCell( row, col );
|
|
|
|
VECTOR2I topRight( cell->GetEndX(), cell->GetStartY() );
|
|
|
|
|
|
|
|
if( cell->GetColSpan() > 0 && cell->GetRowSpan() > 0 )
|
|
|
|
strokeLine( topRight, cell->GetEnd() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( aTable->StrokeRows() )
|
|
|
|
{
|
|
|
|
for( int row = 0; row < aTable->GetRowCount() - 1; ++row )
|
|
|
|
{
|
|
|
|
for( int col = 0; col < aTable->GetColCount(); ++col )
|
|
|
|
{
|
|
|
|
PCB_TABLECELL* cell = aTable->GetCell( row, col );
|
|
|
|
VECTOR2I botLeft( cell->GetStartX(), cell->GetEndY() );
|
|
|
|
|
|
|
|
if( cell->GetColSpan() > 0 && cell->GetRowSpan() > 0 )
|
|
|
|
strokeLine( botLeft, cell->GetEnd() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( aTable->GetBorderStroke().GetWidth() >= 0 )
|
|
|
|
{
|
|
|
|
setupStroke( aTable->GetBorderStroke() );
|
|
|
|
|
|
|
|
if( aTable->StrokeHeader() )
|
|
|
|
{
|
|
|
|
PCB_TABLECELL* cell = aTable->GetCell( 0, 0 );
|
|
|
|
strokeLine( VECTOR2I( pos.x, cell->GetEndY() ), VECTOR2I( end.x, cell->GetEndY() ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( aTable->StrokeExternal() )
|
|
|
|
strokeRect( pos, end );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-04-07 22:01:08 +00:00
|
|
|
void BRDITEMS_PLOTTER::plotOneDrillMark( PAD_DRILL_SHAPE aDrillShape, const VECTOR2I& aDrillPos,
|
2022-01-05 01:42:27 +00:00
|
|
|
const VECTOR2I& aDrillSize, const VECTOR2I& aPadSize,
|
2022-01-16 01:06:25 +00:00
|
|
|
const EDA_ANGLE& aOrientation, int aSmallDrill )
|
2012-09-24 16:03:03 +00:00
|
|
|
{
|
2022-01-05 01:42:27 +00:00
|
|
|
VECTOR2I drillSize = aDrillSize;
|
2021-07-26 23:47:26 +00:00
|
|
|
|
2012-09-24 16:03:03 +00:00
|
|
|
// Small drill marks have no significance when applied to slots
|
2024-04-07 22:01:08 +00:00
|
|
|
if( aSmallDrill && aDrillShape == PAD_DRILL_SHAPE::CIRCLE )
|
2021-07-26 23:47:26 +00:00
|
|
|
drillSize.x = std::min( aSmallDrill, drillSize.x );
|
2012-09-24 16:03:03 +00:00
|
|
|
|
|
|
|
// Round holes only have x diameter, slots have both
|
2021-07-26 23:47:26 +00:00
|
|
|
drillSize.x -= getFineWidthAdj();
|
|
|
|
drillSize.x = Clamp( 1, drillSize.x, aPadSize.x - 1 );
|
2013-03-20 14:50:12 +00:00
|
|
|
|
2024-04-07 22:01:08 +00:00
|
|
|
if( aDrillShape == PAD_DRILL_SHAPE::OBLONG )
|
2012-09-24 16:03:03 +00:00
|
|
|
{
|
2021-07-26 23:47:26 +00:00
|
|
|
drillSize.y -= getFineWidthAdj();
|
|
|
|
drillSize.y = Clamp( 1, drillSize.y, aPadSize.y - 1 );
|
2022-01-16 01:06:25 +00:00
|
|
|
|
2021-07-26 23:47:26 +00:00
|
|
|
m_plotter->FlashPadOval( aDrillPos, drillSize, aOrientation, GetPlotMode(), nullptr );
|
2012-09-24 16:03:03 +00:00
|
|
|
}
|
|
|
|
else
|
2021-01-03 13:59:23 +00:00
|
|
|
{
|
2021-07-26 23:47:26 +00:00
|
|
|
m_plotter->FlashPadCircle( aDrillPos, drillSize.x, GetPlotMode(), nullptr );
|
2021-01-03 13:59:23 +00:00
|
|
|
}
|
2012-09-24 16:03:03 +00:00
|
|
|
}
|
|
|
|
|
2013-03-20 14:50:12 +00:00
|
|
|
|
2012-09-24 16:03:03 +00:00
|
|
|
void BRDITEMS_PLOTTER::PlotDrillMarks()
|
|
|
|
{
|
2024-05-20 10:57:56 +00:00
|
|
|
bool onCopperLayer = ( LSET::AllCuMask() & m_layerMask ).any();
|
|
|
|
int smallDrill = 0;
|
|
|
|
|
|
|
|
if( GetDrillMarksType() == DRILL_MARKS::SMALL_DRILL_SHAPE )
|
|
|
|
smallDrill = pcbIUScale.mmToIU( ADVANCED_CFG::GetCfg().m_SmallDrillMarkSize );
|
|
|
|
|
|
|
|
/* In the filled trace mode drill marks are drawn white-on-black to knock-out the underlying
|
|
|
|
pad. This works only for drivers supporting color change, obviously... it means that:
|
2012-09-24 16:03:03 +00:00
|
|
|
- PS, SVG and PDF output is correct (i.e. you have a 'donut' pad)
|
|
|
|
- In HPGL you can't see them
|
2024-05-20 10:57:56 +00:00
|
|
|
- In gerbers you can't see them, too. This is arguably the right thing to do since having
|
|
|
|
drill marks and high speed drill stations is a sure recipe for broken tools and angry
|
|
|
|
manufacturers. If you *really* want them you could start a layer with negative polarity
|
|
|
|
to knock-out the film.
|
2012-09-24 16:03:03 +00:00
|
|
|
- In DXF they go into the 'WHITE' layer. This could be useful.
|
|
|
|
*/
|
2024-05-20 10:57:56 +00:00
|
|
|
if( GetPlotMode() == FILLED && onCopperLayer )
|
2012-09-24 16:03:03 +00:00
|
|
|
m_plotter->SetColor( WHITE );
|
|
|
|
|
2023-06-24 18:54:50 +00:00
|
|
|
for( PCB_TRACK* track : m_board->Tracks() )
|
2012-09-24 16:03:03 +00:00
|
|
|
{
|
2023-06-24 18:54:50 +00:00
|
|
|
if( track->Type() == PCB_VIA_T )
|
2019-04-10 09:19:16 +00:00
|
|
|
{
|
2023-06-24 18:54:50 +00:00
|
|
|
const PCB_VIA* via = static_cast<const PCB_VIA*>( track );
|
|
|
|
|
2023-08-05 08:40:35 +00:00
|
|
|
// Via are not always on all layers
|
|
|
|
if( ( via->GetLayerSet() & m_layerMask ).none() )
|
|
|
|
continue;
|
|
|
|
|
2024-04-07 22:01:08 +00:00
|
|
|
plotOneDrillMark( PAD_DRILL_SHAPE::CIRCLE, via->GetStart(),
|
2023-02-19 03:40:07 +00:00
|
|
|
VECTOR2I( via->GetDrillValue(), 0 ), VECTOR2I( via->GetWidth(), 0 ),
|
|
|
|
ANGLE_0, smallDrill );
|
2019-04-10 09:19:16 +00:00
|
|
|
}
|
2012-09-24 16:03:03 +00:00
|
|
|
}
|
|
|
|
|
2021-01-03 13:59:23 +00:00
|
|
|
for( FOOTPRINT* footprint : m_board->Footprints() )
|
2012-09-24 16:03:03 +00:00
|
|
|
{
|
2021-01-03 13:59:23 +00:00
|
|
|
for( PAD* pad : footprint->Pads() )
|
2012-09-24 16:03:03 +00:00
|
|
|
{
|
|
|
|
if( pad->GetDrillSize().x == 0 )
|
|
|
|
continue;
|
|
|
|
|
2021-01-03 13:59:23 +00:00
|
|
|
plotOneDrillMark( pad->GetDrillShape(), pad->GetPosition(), pad->GetDrillSize(),
|
2022-01-16 01:06:25 +00:00
|
|
|
pad->GetSize(), pad->GetOrientation(), smallDrill );
|
2012-09-24 16:03:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-05-20 10:57:56 +00:00
|
|
|
if( GetPlotMode() == FILLED && onCopperLayer )
|
2021-01-03 13:59:23 +00:00
|
|
|
m_plotter->SetColor( BLACK );
|
2012-09-24 16:03:03 +00:00
|
|
|
}
|