2012-09-24 16:03:03 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2020-06-14 16:16:01 +00:00
|
|
|
* Copyright (C) 1992-2020 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 <stddef.h> // for NULL, size_t
|
|
|
|
#include <vector> // for vector, __vector_base<>...
|
|
|
|
|
2020-10-14 01:06:53 +00:00
|
|
|
#include <eda_item.h>
|
2020-01-07 17:12:59 +00:00
|
|
|
#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>
|
2020-10-24 02:06:42 +00:00
|
|
|
#include <kicad_string.h>
|
2020-01-07 17:12:59 +00:00
|
|
|
#include <math/util.h> // for KiROUND, Clamp
|
|
|
|
#include <math/vector2d.h> // for VECTOR2I
|
2018-01-28 18:12:26 +00:00
|
|
|
#include <plotter.h>
|
2020-12-14 02:00:53 +00:00
|
|
|
#include <plotters_specific.h>
|
2012-09-24 16:03:03 +00:00
|
|
|
#include <trigo.h>
|
2020-01-07 17:12:59 +00:00
|
|
|
|
|
|
|
#include <board_design_settings.h> // for BOARD_DESIGN_SETTINGS
|
|
|
|
#include <core/typeinfo.h> // for dyn_cast, PCB_DIMENSION_T
|
2020-10-15 23:33:18 +00:00
|
|
|
#include <outline_mode.h>
|
2020-01-07 17:12:59 +00:00
|
|
|
#include <gal/color4d.h> // for COLOR4D, operator!=
|
|
|
|
#include <gbr_metadata.h>
|
|
|
|
#include <gbr_netlist_metadata.h> // for GBR_NETLIST_METADATA
|
|
|
|
#include <layers_id_colors_and_visibility.h> // for LSET, IsCopperLayer
|
2020-09-30 15:38:35 +00:00
|
|
|
#include <pad_shapes.h> // for PAD_ATTRIB_NPTH
|
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
|
|
|
|
2020-11-12 20:19:22 +00:00
|
|
|
#include <board.h>
|
2020-11-14 18:11:28 +00:00
|
|
|
#include <board_item.h> // for BOARD_ITEM, S_CIRCLE
|
2020-11-11 23:05:59 +00:00
|
|
|
#include <dimension.h>
|
2020-10-04 23:34:59 +00:00
|
|
|
#include <pcb_shape.h>
|
|
|
|
#include <fp_shape.h>
|
2020-11-12 20:19:22 +00:00
|
|
|
#include <footprint.h>
|
2020-11-12 22:30:02 +00:00
|
|
|
#include <fp_text.h>
|
2020-11-12 20:19:22 +00:00
|
|
|
#include <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>
|
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
|
|
|
|
#include <wx/wx.h> // for wxPoint, wxSize, wxArra...
|
|
|
|
|
2012-09-24 16:03:03 +00:00
|
|
|
|
|
|
|
/* class BRDITEMS_PLOTTER is a helper class to plot board items
|
|
|
|
* and a group of board items
|
|
|
|
*/
|
|
|
|
|
2017-02-20 16:57:41 +00:00
|
|
|
COLOR4D BRDITEMS_PLOTTER::getColor( LAYER_NUM aLayer )
|
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
|
|
|
|
2020-03-25 15:16:47 +00:00
|
|
|
// A hack to avoid plotting a white item in white color, expecting the paper
|
2017-10-08 14:08:42 +00:00
|
|
|
// is also white: use a non white color:
|
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
|
|
|
|
2020-11-12 22:30:02 +00:00
|
|
|
void BRDITEMS_PLOTTER::PlotPad( PAD* aPad, COLOR4D aColor, OUTLINE_MODE aPlotMode )
|
2012-09-25 07:49:29 +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
|
|
|
wxPoint shape_pos = aPad->ShapePos();
|
2016-09-19 11:01:36 +00:00
|
|
|
GBR_METADATA gbr_metadata;
|
|
|
|
|
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
|
|
|
|
|
|
|
gbr_metadata.SetCmpReference( aPad->GetParent()->GetReference() );
|
|
|
|
|
2020-06-14 16:16:01 +00:00
|
|
|
if( plotOnCopperLayer )
|
2016-09-19 11:01:36 +00:00
|
|
|
{
|
|
|
|
gbr_metadata.SetNetAttribType( GBR_NETINFO_ALL );
|
2017-05-03 18:04:31 +00:00
|
|
|
gbr_metadata.SetCopper( true );
|
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
|
|
|
|
gbr_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;
|
|
|
|
gbr_metadata.SetPadName( aPad->GetName(), useUTF8, useQuoting );
|
2019-11-17 09:11:29 +00:00
|
|
|
|
2020-06-14 16:16:01 +00:00
|
|
|
if( !aPad->GetName().IsEmpty() )
|
|
|
|
gbr_metadata.SetPadPinFunction( aPad->GetPinFunction(), useUTF8, useQuoting );
|
2016-09-19 11:01:36 +00:00
|
|
|
|
|
|
|
gbr_metadata.SetNetName( aPad->GetNetname() );
|
|
|
|
|
|
|
|
// 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.
|
2020-09-30 15:38:35 +00:00
|
|
|
if( aPad->GetAttribute() == PAD_ATTRIB_NPTH || aPad->GetName().IsEmpty() )
|
2016-09-19 11:01:36 +00:00
|
|
|
gbr_metadata.m_NetlistMetadata.m_NotInNet = true;
|
|
|
|
|
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
|
2016-09-19 11:01:36 +00:00
|
|
|
gbr_metadata.SetNetAttribType( GBR_NETLIST_METADATA::GBR_NETINFO_NET |
|
|
|
|
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.
|
|
|
|
// Pad with type PAD_ATTRIB_CONN or PAD_ATTRIB_SMD that is not on outer layer
|
|
|
|
// has its aperture attribute set to GBR_APERTURE_ATTRIB_CONDUCTOR
|
|
|
|
switch( aPad->GetAttribute() )
|
2016-09-19 11:01:36 +00:00
|
|
|
{
|
2020-09-30 15:38:35 +00:00
|
|
|
case PAD_ATTRIB_NPTH: // Mechanical pad through hole
|
2020-06-14 16:16:01 +00:00
|
|
|
gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_WASHERPAD );
|
|
|
|
break;
|
2016-09-19 11:01:36 +00:00
|
|
|
|
2020-09-30 15:38:35 +00:00
|
|
|
case PAD_ATTRIB_PTH : // Pad through hole, a hole is also expected
|
2020-06-14 16:16:01 +00:00
|
|
|
gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_COMPONENTPAD );
|
|
|
|
break;
|
2016-09-19 11:01:36 +00:00
|
|
|
|
2020-06-14 16:16:01 +00:00
|
|
|
case PAD_ATTRIB_CONN: // Connector pads, no solder paste but with solder mask.
|
|
|
|
if( plotOnExternalCopperLayer )
|
2016-09-19 11:01:36 +00:00
|
|
|
gbr_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
|
|
|
|
2020-06-14 16:16:01 +00:00
|
|
|
case PAD_ATTRIB_SMD: // SMD pads (on external copper layer only)
|
|
|
|
// with solder paste and mask
|
|
|
|
if( plotOnExternalCopperLayer )
|
2019-12-11 10:36:45 +00:00
|
|
|
gbr_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() )
|
|
|
|
{
|
|
|
|
case PAD_PROP_BGA: // Only applicable to outer layers
|
|
|
|
if( plotOnExternalCopperLayer )
|
2019-12-11 10:36:45 +00:00
|
|
|
gbr_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
|
|
|
|
2020-06-14 16:16:01 +00:00
|
|
|
case PAD_PROP_FIDUCIAL_GLBL:
|
|
|
|
gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_FIDUCIAL_GLBL );
|
|
|
|
break;
|
2019-12-11 10:36:45 +00:00
|
|
|
|
2020-06-14 16:16:01 +00:00
|
|
|
case PAD_PROP_FIDUCIAL_LOCAL:
|
|
|
|
gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_FIDUCIAL_LOCAL );
|
|
|
|
break;
|
2019-12-11 10:36:45 +00:00
|
|
|
|
2020-06-14 16:16:01 +00:00
|
|
|
case PAD_PROP_TESTPOINT: // Only applicable to outer layers
|
|
|
|
if( plotOnExternalCopperLayer )
|
2019-12-11 10:36:45 +00:00
|
|
|
gbr_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
|
|
|
|
2020-06-14 16:16:01 +00:00
|
|
|
case PAD_PROP_HEATSINK:
|
|
|
|
gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_HEATSINKPAD );
|
|
|
|
break;
|
2019-12-11 10:36:45 +00:00
|
|
|
|
2020-06-14 16:16:01 +00:00
|
|
|
case PAD_PROP_CASTELLATED:
|
|
|
|
gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CASTELLATEDPAD );
|
|
|
|
break;
|
2019-12-11 10:36:45 +00:00
|
|
|
|
2020-06-14 16:16:01 +00:00
|
|
|
case PAD_PROP_NONE:
|
|
|
|
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
|
2020-09-30 15:38:35 +00:00
|
|
|
if( aPad->GetAttribute() == PAD_ATTRIB_NPTH )
|
2016-09-19 11:01:36 +00:00
|
|
|
gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_WASHERPAD );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gbr_metadata.SetNetAttribType( GBR_NETLIST_METADATA::GBR_NETINFO_CMP );
|
|
|
|
}
|
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 )
|
|
|
|
m_plotter->SetCurrentLineWidth( GetSketchPadLineWidth(), &gbr_metadata );
|
|
|
|
|
2012-09-25 07:49:29 +00:00
|
|
|
switch( aPad->GetShape() )
|
|
|
|
{
|
2015-08-23 19:40:33 +00:00
|
|
|
case PAD_SHAPE_CIRCLE:
|
2016-09-19 11:01:36 +00:00
|
|
|
m_plotter->FlashPadCircle( shape_pos, aPad->GetSize().x, aPlotMode, &gbr_metadata );
|
2012-09-25 07:49:29 +00:00
|
|
|
break;
|
|
|
|
|
2015-08-23 19:40:33 +00:00
|
|
|
case PAD_SHAPE_OVAL:
|
2021-01-03 13:59:23 +00:00
|
|
|
m_plotter->FlashPadOval( shape_pos, aPad->GetSize(), aPad->GetOrientation(), aPlotMode,
|
|
|
|
&gbr_metadata );
|
2012-09-25 07:49:29 +00:00
|
|
|
break;
|
|
|
|
|
2020-06-22 19:35:09 +00:00
|
|
|
case PAD_SHAPE_RECT:
|
|
|
|
m_plotter->FlashPadRect( shape_pos, aPad->GetSize(), aPad->GetOrientation(), aPlotMode,
|
|
|
|
&gbr_metadata );
|
2012-09-25 07:49:29 +00:00
|
|
|
break;
|
|
|
|
|
2016-04-06 18:15:49 +00:00
|
|
|
case PAD_SHAPE_ROUNDRECT:
|
|
|
|
m_plotter->FlashPadRoundRect( shape_pos, aPad->GetSize(), aPad->GetRoundRectCornerRadius(),
|
2016-09-19 11:01:36 +00:00
|
|
|
aPad->GetOrientation(), aPlotMode, &gbr_metadata );
|
2016-04-06 18:15:49 +00:00
|
|
|
break;
|
|
|
|
|
2020-06-22 19:35:09 +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
|
|
|
|
wxPoint coord[4];
|
|
|
|
// Order is lower left, lower right, upper right, upper left
|
|
|
|
wxSize half_size = aPad->GetSize()/2;
|
|
|
|
wxSize trap_delta = aPad->GetDelta()/2;
|
|
|
|
|
|
|
|
coord[0] = wxPoint( -half_size.x - trap_delta.y, half_size.y + trap_delta.x );
|
|
|
|
coord[1] = wxPoint( half_size.x + trap_delta.y, half_size.y - trap_delta.x );
|
|
|
|
coord[2] = wxPoint( half_size.x - trap_delta.y, -half_size.y + trap_delta.x );
|
|
|
|
coord[3] = wxPoint( -half_size.x + trap_delta.y, -half_size.y - trap_delta.x );
|
|
|
|
|
|
|
|
m_plotter->FlashPadTrapez( shape_pos, coord, aPad->GetOrientation(), aPlotMode,
|
2021-01-03 13:59:23 +00:00
|
|
|
&gbr_metadata );
|
2020-09-28 13:36:52 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2018-08-29 07:13:07 +00:00
|
|
|
case PAD_SHAPE_CHAMFERED_RECT:
|
2020-10-08 12:51:25 +00:00
|
|
|
if( m_plotter->GetPlotterType() == PLOT_FORMAT::GERBER )
|
|
|
|
{
|
|
|
|
static_cast<GERBER_PLOTTER*>( m_plotter )->FlashPadChamferRoundRect(
|
|
|
|
shape_pos, aPad->GetSize(),
|
|
|
|
aPad->GetRoundRectCornerRadius(),
|
|
|
|
aPad->GetChamferRectRatio(),
|
|
|
|
aPad->GetChamferPositions(),
|
|
|
|
aPad->GetOrientation(), aPlotMode, &gbr_metadata );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
KI_FALLTHROUGH;
|
|
|
|
|
|
|
|
default:
|
2017-01-13 17:51:22 +00:00
|
|
|
case PAD_SHAPE_CUSTOM:
|
2020-06-22 19:35:09 +00:00
|
|
|
{
|
2020-07-25 11:58:17 +00:00
|
|
|
const std::shared_ptr<SHAPE_POLY_SET>& polygons = aPad->GetEffectivePolygon();
|
2017-01-13 17:51:22 +00:00
|
|
|
|
2020-07-25 11:58:17 +00:00
|
|
|
if( polygons->OutlineCount() )
|
|
|
|
{
|
2021-01-23 17:02:58 +00:00
|
|
|
m_plotter->FlashPadCustom( shape_pos, aPad->GetSize(), aPad->GetOrientation(),
|
|
|
|
polygons.get(), aPlotMode, &gbr_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
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
void BRDITEMS_PLOTTER::PlotFootprintTextItems( FOOTPRINT* aFootprint )
|
2012-09-24 16:03:03 +00:00
|
|
|
{
|
2020-11-13 15:15:52 +00:00
|
|
|
FP_TEXT* textItem = &aFootprint->Reference();
|
2020-10-04 23:34:59 +00:00
|
|
|
LAYER_NUM textLayer = textItem->GetLayer();
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2019-08-13 07:43:36 +00:00
|
|
|
// Reference and value are specfic items, not in graphic items list
|
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
|
|
|
{
|
2020-11-24 22:16:41 +00:00
|
|
|
PlotFootprintTextItem( textItem, getColor( textLayer ) );
|
2018-05-30 19:45:02 +00:00
|
|
|
}
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2020-11-13 15:15:52 +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
|
|
|
{
|
2020-11-24 22:16:41 +00:00
|
|
|
PlotFootprintTextItem( textItem, getColor( textLayer ) );
|
2012-09-24 16:03:03 +00:00
|
|
|
}
|
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
for( BOARD_ITEM* item : aFootprint->GraphicalItems() )
|
2012-09-24 16:03:03 +00:00
|
|
|
{
|
2020-10-04 23:34:59 +00:00
|
|
|
textItem = dyn_cast<FP_TEXT*>( item );
|
2014-06-06 09:44:21 +00:00
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
if( !textItem )
|
2012-09-24 16:03:03 +00:00
|
|
|
continue;
|
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
if( !textItem->IsVisible() )
|
2012-09-24 16:03:03 +00:00
|
|
|
continue;
|
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
textLayer = textItem->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
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
if( !m_layerMask[textLayer] )
|
2012-09-24 16:03:03 +00:00
|
|
|
continue;
|
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
if( textItem->GetText() == wxT( "${REFERENCE}" ) && !GetPlotReference() )
|
2018-02-10 20:47:19 +00:00
|
|
|
continue;
|
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
if( textItem->GetText() == wxT( "${VALUE}" ) && !GetPlotValue() )
|
2018-02-10 20:47:19 +00:00
|
|
|
continue;
|
|
|
|
|
2020-11-24 22:16:41 +00:00
|
|
|
PlotFootprintTextItem( textItem, getColor( textLayer ) );
|
2012-09-24 16:03:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-13 11:17:15 +00:00
|
|
|
// plot items like text and graphics, but not tracks and footprints
|
2012-09-24 16:03:03 +00:00
|
|
|
void BRDITEMS_PLOTTER::PlotBoardGraphicItems()
|
|
|
|
{
|
2020-11-13 11:17:15 +00:00
|
|
|
for( BOARD_ITEM* item : m_board->Drawings() )
|
2012-09-24 16:03:03 +00:00
|
|
|
{
|
|
|
|
switch( item->Type() )
|
|
|
|
{
|
2020-10-13 17:46:48 +00:00
|
|
|
case PCB_SHAPE_T:
|
|
|
|
PlotPcbShape( (PCB_SHAPE*) item );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PCB_TEXT_T:
|
|
|
|
if( item->GetLayer() != Edge_Cuts )
|
|
|
|
PlotPcbText( (PCB_TEXT*) item );
|
|
|
|
|
|
|
|
break;
|
2020-09-12 20:09:40 +00:00
|
|
|
|
|
|
|
case PCB_DIM_ALIGNED_T:
|
2020-09-17 00:54:58 +00:00
|
|
|
case PCB_DIM_CENTER_T:
|
|
|
|
case PCB_DIM_ORTHOGONAL_T:
|
2020-10-13 17:46:48 +00:00
|
|
|
case PCB_DIM_LEADER_T:
|
|
|
|
if( item->GetLayer() != Edge_Cuts )
|
2020-11-11 23:05:59 +00:00
|
|
|
PlotDimension( (DIMENSION_BASE*) item );
|
2020-10-04 14:19:33 +00:00
|
|
|
|
2020-10-13 17:46:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PCB_TARGET_T:
|
|
|
|
PlotPcbTarget( (PCB_TARGET*) item );
|
|
|
|
break;
|
2020-09-12 20:09:40 +00:00
|
|
|
|
2020-10-13 17:46:48 +00:00
|
|
|
default:
|
|
|
|
break;
|
2012-09-24 16:03:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
void BRDITEMS_PLOTTER::PlotFootprintTextItem( FP_TEXT* aTextMod, COLOR4D aColor )
|
2012-09-24 16:03:03 +00:00
|
|
|
{
|
2017-02-20 17:48:27 +00:00
|
|
|
if( aColor == COLOR4D::WHITE )
|
2017-02-20 16:57:41 +00:00
|
|
|
aColor = COLOR4D( LIGHTGRAY );
|
2013-03-20 14:50:12 +00:00
|
|
|
|
2012-09-24 16:03:03 +00:00
|
|
|
m_plotter->SetColor( aColor );
|
|
|
|
|
|
|
|
// calculate some text parameters :
|
2020-05-01 16:24:01 +00:00
|
|
|
wxSize size = aTextMod->GetTextSize();
|
|
|
|
wxPoint pos = aTextMod->GetTextPos();
|
|
|
|
double orient = aTextMod->GetDrawRotation();
|
2020-05-13 16:15:35 +00:00
|
|
|
int thickness = aTextMod->GetEffectiveTextPenWidth();
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2020-05-01 16:24:01 +00:00
|
|
|
if( aTextMod->IsMirrored() )
|
2015-06-26 13:41:56 +00:00
|
|
|
size.x = -size.x; // Text is mirrored
|
2012-09-24 16:03:03 +00:00
|
|
|
|
|
|
|
// Non bold texts thickness is clamped at 1/6 char size by the low level draw function.
|
|
|
|
// but in Pcbnew we do not manage bold texts and thickness up to 1/4 char size
|
|
|
|
// (like bold text) and we manage the thickness.
|
|
|
|
// So we set bold flag to true
|
2020-05-01 16:24:01 +00:00
|
|
|
bool allow_bold = true;
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2016-09-19 11:01:36 +00:00
|
|
|
GBR_METADATA gbr_metadata;
|
|
|
|
gbr_metadata.SetNetAttribType( GBR_NETLIST_METADATA::GBR_NETINFO_CMP );
|
2020-11-13 15:15:52 +00:00
|
|
|
FOOTPRINT* parent = static_cast<FOOTPRINT*> ( aTextMod->GetParent() );
|
2016-09-19 11:01:36 +00:00
|
|
|
gbr_metadata.SetCmpReference( parent->GetReference() );
|
|
|
|
|
2020-05-13 16:15:35 +00:00
|
|
|
m_plotter->SetCurrentLineWidth( thickness );
|
|
|
|
|
2020-05-01 16:24:01 +00:00
|
|
|
m_plotter->Text( pos, aColor, aTextMod->GetShownText(), orient, size,
|
2020-05-13 16:15:35 +00:00
|
|
|
aTextMod->GetHorizJustify(), aTextMod->GetVertJustify(), thickness,
|
|
|
|
aTextMod->IsItalic(), allow_bold, false, &gbr_metadata );
|
2012-09-24 16:03:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-11 23:05:59 +00:00
|
|
|
void BRDITEMS_PLOTTER::PlotDimension( 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-10-04 23:34:59 +00:00
|
|
|
PCB_SHAPE draw;
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2020-09-09 03:17:08 +00:00
|
|
|
draw.SetWidth( aDim->GetLineThickness() );
|
2012-09-24 16:03:03 +00:00
|
|
|
draw.SetLayer( aDim->GetLayer() );
|
|
|
|
|
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
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
PlotPcbText( &aDim->Text() );
|
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();
|
|
|
|
|
|
|
|
draw.SetShape( S_SEGMENT );
|
|
|
|
draw.SetStart( wxPoint( seg.A ) );
|
|
|
|
draw.SetEnd( wxPoint( seg.B ) );
|
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
PlotPcbShape( &draw );
|
2020-09-12 20:09:40 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case SH_CIRCLE:
|
|
|
|
{
|
|
|
|
wxPoint start( shape->Centre() );
|
|
|
|
int radius = static_cast<const SHAPE_CIRCLE*>( shape.get() )->GetRadius();
|
|
|
|
|
|
|
|
draw.SetShape( S_CIRCLE );
|
2020-11-14 01:16:02 +00:00
|
|
|
draw.SetFilled( false );
|
2020-09-12 20:09:40 +00:00
|
|
|
draw.SetStart( start );
|
|
|
|
draw.SetEnd( wxPoint( start.x + radius, start.y ) );
|
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
PlotPcbShape( &draw );
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BRDITEMS_PLOTTER::PlotPcbTarget( PCB_TARGET* aMire )
|
|
|
|
{
|
|
|
|
int dx1, dx2, dy1, dy2, radius;
|
|
|
|
|
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() ) );
|
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
PCB_SHAPE draw;
|
2012-09-24 16:03:03 +00:00
|
|
|
|
|
|
|
draw.SetShape( S_CIRCLE );
|
2020-11-14 01:16:02 +00:00
|
|
|
draw.SetFilled( false );
|
2015-02-02 08:06:39 +00:00
|
|
|
draw.SetWidth( aMire->GetWidth() );
|
2012-09-24 16:03:03 +00:00
|
|
|
draw.SetLayer( aMire->GetLayer() );
|
|
|
|
draw.SetStart( aMire->GetPosition() );
|
|
|
|
radius = aMire->GetSize() / 3;
|
2013-03-20 14:50:12 +00:00
|
|
|
|
2012-09-24 16:03:03 +00:00
|
|
|
if( aMire->GetShape() ) // shape X
|
|
|
|
radius = aMire->GetSize() / 2;
|
|
|
|
|
|
|
|
// Draw the circle
|
2020-11-24 22:16:41 +00:00
|
|
|
draw.SetEnd( wxPoint( draw.GetStart().x + radius, draw.GetStart().y ) );
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
PlotPcbShape( &draw );
|
2012-09-24 16:03:03 +00:00
|
|
|
|
|
|
|
draw.SetShape( S_SEGMENT );
|
|
|
|
|
|
|
|
radius = aMire->GetSize() / 2;
|
|
|
|
dx1 = radius;
|
|
|
|
dy1 = 0;
|
|
|
|
dx2 = 0;
|
|
|
|
dy2 = radius;
|
|
|
|
|
|
|
|
if( aMire->GetShape() ) // Shape X
|
|
|
|
{
|
|
|
|
dx1 = dy1 = radius;
|
|
|
|
dx2 = dx1;
|
|
|
|
dy2 = -dy1;
|
|
|
|
}
|
|
|
|
|
|
|
|
wxPoint mirePos( aMire->GetPosition() );
|
|
|
|
|
|
|
|
// Draw the X or + shape:
|
2020-11-24 22:16:41 +00:00
|
|
|
draw.SetStart( wxPoint( mirePos.x - dx1, mirePos.y - dy1 ) );
|
|
|
|
draw.SetEnd( wxPoint( mirePos.x + dx1, mirePos.y + dy1 ) );
|
2020-10-04 23:34:59 +00:00
|
|
|
PlotPcbShape( &draw );
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2020-11-24 22:16:41 +00:00
|
|
|
draw.SetStart( wxPoint( mirePos.x - dx2, mirePos.y - dy2 ) );
|
|
|
|
draw.SetEnd( wxPoint( mirePos.x + dx2, mirePos.y + dy2 ) );
|
2020-10-04 23:34:59 +00:00
|
|
|
PlotPcbShape( &draw );
|
2012-09-24 16:03:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Plot footprints graphic items (outlines)
|
2020-11-13 15:15:52 +00:00
|
|
|
void BRDITEMS_PLOTTER::PlotFootprintGraphicItems( FOOTPRINT* aFootprint )
|
2012-09-24 16:03:03 +00:00
|
|
|
{
|
2020-11-13 15:15:52 +00:00
|
|
|
for( BOARD_ITEM* item : aFootprint->GraphicalItems() )
|
2012-09-24 16:03:03 +00:00
|
|
|
{
|
2021-01-03 13:59:23 +00:00
|
|
|
FP_SHAPE* shape = dynamic_cast<FP_SHAPE*>( item );
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2021-01-03 13:59:23 +00:00
|
|
|
if( shape && m_layerMask[ shape->GetLayer() ] )
|
|
|
|
PlotFootprintGraphicItem( shape );
|
2012-09-24 16:03:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//* Plot a graphic item (outline) relative to a footprint
|
2020-10-04 23:34:59 +00:00
|
|
|
void BRDITEMS_PLOTTER::PlotFootprintGraphicItem( FP_SHAPE* aShape )
|
2012-09-24 16:03:03 +00:00
|
|
|
{
|
2020-10-04 23:34:59 +00:00
|
|
|
if( aShape->Type() != PCB_FP_SHAPE_T )
|
2012-09-24 16:03:03 +00:00
|
|
|
return;
|
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
m_plotter->SetColor( getColor( aShape->GetLayer() ) );
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2020-11-14 01:16:02 +00:00
|
|
|
bool sketch = GetPlotMode() == SKETCH;
|
2020-10-04 23:34:59 +00:00
|
|
|
int thickness = aShape->GetWidth();
|
|
|
|
wxPoint pos( aShape->GetStart() );
|
|
|
|
wxPoint end( aShape->GetEnd() );
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2016-09-19 11:01:36 +00:00
|
|
|
GBR_METADATA gbr_metadata;
|
|
|
|
gbr_metadata.SetNetAttribType( GBR_NETLIST_METADATA::GBR_NETINFO_CMP );
|
2020-11-13 15:15:52 +00:00
|
|
|
FOOTPRINT* parent = static_cast<FOOTPRINT*> ( aShape->GetParent() );
|
2016-09-19 11:01:36 +00:00
|
|
|
gbr_metadata.SetCmpReference( parent->GetReference() );
|
|
|
|
|
|
|
|
bool isOnCopperLayer = ( m_layerMask & LSET::AllCuMask() ).any();
|
|
|
|
|
|
|
|
if( isOnCopperLayer )
|
|
|
|
{
|
|
|
|
gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_ETCHEDCMP );
|
2017-05-03 18:04:31 +00:00
|
|
|
gbr_metadata.SetCopper( true );
|
2016-09-19 11:01:36 +00:00
|
|
|
}
|
2020-10-04 23:34:59 +00:00
|
|
|
else if( aShape->GetLayer() == Edge_Cuts ) // happens also when plotting copper layers
|
2016-09-19 11:01:36 +00:00
|
|
|
{
|
2019-10-09 13:46:35 +00:00
|
|
|
gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_EDGECUT );
|
2016-09-19 11:01:36 +00:00
|
|
|
}
|
|
|
|
|
2019-11-05 10:07:07 +00:00
|
|
|
int radius; // Circle/arc radius.
|
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
switch( aShape->GetShape() )
|
2012-09-24 16:03:03 +00:00
|
|
|
{
|
|
|
|
case S_SEGMENT:
|
2016-09-19 11:01:36 +00:00
|
|
|
m_plotter->ThickSegment( pos, end, thickness, GetPlotMode(), &gbr_metadata );
|
2012-09-24 16:03:03 +00:00
|
|
|
break;
|
|
|
|
|
2020-06-15 19:50:20 +00:00
|
|
|
case S_RECT:
|
|
|
|
{
|
2020-10-04 23:34:59 +00:00
|
|
|
std::vector<wxPoint> pts = aShape->GetRectCorners();
|
2020-06-15 19:50:20 +00:00
|
|
|
|
2020-11-14 01:16:02 +00:00
|
|
|
if( sketch || thickness > 0 )
|
2020-06-19 20:46:43 +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 );
|
|
|
|
}
|
2020-11-14 01:16:02 +00:00
|
|
|
|
|
|
|
if( !sketch && aShape->IsFilled() )
|
2020-06-19 20:46:43 +00:00
|
|
|
{
|
|
|
|
SHAPE_LINE_CHAIN poly;
|
|
|
|
|
|
|
|
for( const wxPoint& pt : pts )
|
|
|
|
poly.Append( pt );
|
|
|
|
|
2020-10-15 01:45:20 +00:00
|
|
|
m_plotter->PlotPoly( poly, FILL_TYPE::FILLED_SHAPE, -1, &gbr_metadata );
|
2020-06-19 20:46:43 +00:00
|
|
|
}
|
2020-06-15 19:50:20 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2012-09-24 16:03:03 +00:00
|
|
|
case S_CIRCLE:
|
2013-05-01 17:32:36 +00:00
|
|
|
radius = KiROUND( GetLineLength( end, pos ) );
|
2020-06-19 20:46:43 +00:00
|
|
|
|
2020-11-14 01:16:02 +00:00
|
|
|
if( aShape->IsFilled() )
|
|
|
|
m_plotter->FilledCircle( pos, radius * 2 + thickness, GetPlotMode(), &gbr_metadata );
|
2020-06-19 20:46:43 +00:00
|
|
|
else
|
2020-11-14 01:16:02 +00:00
|
|
|
m_plotter->ThickCircle( pos, radius * 2, thickness, GetPlotMode(), &gbr_metadata );
|
2020-06-19 20:46:43 +00:00
|
|
|
|
2012-09-24 16:03:03 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case S_ARC:
|
2013-03-20 14:50:12 +00:00
|
|
|
{
|
2013-05-01 17:32:36 +00:00
|
|
|
radius = KiROUND( GetLineLength( end, pos ) );
|
2013-03-20 14:50:12 +00:00
|
|
|
double startAngle = ArcTangente( end.y - pos.y, end.x - pos.x );
|
2020-10-04 23:34:59 +00:00
|
|
|
double endAngle = startAngle + aShape->GetAngle();
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2018-02-04 16:22:14 +00:00
|
|
|
// when startAngle == endAngle ThickArc() doesn't know whether it's 0 deg and 360 deg
|
2020-10-04 23:34:59 +00:00
|
|
|
if( std::abs( aShape->GetAngle() ) == 3600.0 )
|
2020-11-07 17:35:24 +00:00
|
|
|
{
|
2018-02-04 16:22:14 +00:00
|
|
|
m_plotter->ThickCircle( pos, radius * 2, thickness, GetPlotMode(), &gbr_metadata );
|
2020-11-07 17:35:24 +00:00
|
|
|
}
|
2018-02-04 16:22:14 +00:00
|
|
|
else
|
2020-11-07 17:35:24 +00:00
|
|
|
{
|
|
|
|
m_plotter->ThickArc( pos, -endAngle, -startAngle, radius, thickness, GetPlotMode(),
|
|
|
|
&gbr_metadata );
|
|
|
|
}
|
2013-03-20 14:50:12 +00:00
|
|
|
}
|
2019-11-05 10:07:07 +00:00
|
|
|
break;
|
2012-09-24 16:03:03 +00:00
|
|
|
|
|
|
|
case S_POLYGON:
|
2020-10-04 23:34:59 +00:00
|
|
|
if( aShape->IsPolyShapeValid() )
|
2018-01-24 13:22:43 +00:00
|
|
|
{
|
2020-10-04 23:34:59 +00:00
|
|
|
const std::vector<wxPoint> &polyPoints = aShape->BuildPolyPointsList();
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2020-11-07 17:35:24 +00:00
|
|
|
// We must compute board coordinates from m_PolyList which are relative to the parent
|
|
|
|
// position at orientation 0
|
2020-11-13 15:15:52 +00:00
|
|
|
FOOTPRINT *parentFootprint = aShape->GetParentFootprint();
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2019-08-06 04:23:57 +00:00
|
|
|
std::vector<wxPoint> cornerList;
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2018-01-24 13:22:43 +00:00
|
|
|
cornerList.reserve( polyPoints.size() );
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2019-04-10 09:19:16 +00:00
|
|
|
for( wxPoint corner : polyPoints )
|
2018-01-24 13:22:43 +00:00
|
|
|
{
|
2020-11-13 02:57:11 +00:00
|
|
|
if( parentFootprint )
|
2018-01-24 13:22:43 +00:00
|
|
|
{
|
2020-11-13 02:57:11 +00:00
|
|
|
RotatePoint( &corner, parentFootprint->GetOrientation() );
|
|
|
|
corner += parentFootprint->GetPosition();
|
2018-01-24 13:22:43 +00:00
|
|
|
}
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2018-01-24 13:22:43 +00:00
|
|
|
cornerList.push_back( corner );
|
2012-09-24 16:03:03 +00:00
|
|
|
}
|
|
|
|
|
2020-11-14 01:16:02 +00:00
|
|
|
if( sketch || thickness > 0 )
|
2018-12-02 15:33:12 +00:00
|
|
|
{
|
|
|
|
for( size_t i = 1; i < cornerList.size(); i++ )
|
|
|
|
{
|
2019-08-06 04:23:57 +00:00
|
|
|
m_plotter->ThickSegment( cornerList[i - 1], cornerList[i], thickness,
|
2020-11-13 02:57:11 +00:00
|
|
|
GetPlotMode(), &gbr_metadata );
|
2018-12-02 15:33:12 +00:00
|
|
|
}
|
|
|
|
|
2019-04-10 09:19:16 +00:00
|
|
|
m_plotter->ThickSegment( cornerList.back(), cornerList.front(), thickness,
|
2020-11-13 02:57:11 +00:00
|
|
|
GetPlotMode(), &gbr_metadata );
|
2018-12-02 15:33:12 +00:00
|
|
|
|
|
|
|
}
|
2020-11-14 01:16:02 +00:00
|
|
|
|
|
|
|
if( !sketch && aShape->IsFilled() )
|
2018-12-02 15:33:12 +00:00
|
|
|
{
|
2019-08-06 04:23:57 +00:00
|
|
|
// This must be simplified and fractured to prevent overlapping polygons
|
|
|
|
// from generating invalid Gerber files
|
|
|
|
|
|
|
|
SHAPE_LINE_CHAIN line( cornerList );
|
|
|
|
SHAPE_POLY_SET tmpPoly;
|
|
|
|
|
|
|
|
line.SetClosed( true );
|
|
|
|
tmpPoly.AddOutline( line );
|
|
|
|
tmpPoly.Fracture( SHAPE_POLY_SET::PM_FAST );
|
|
|
|
|
|
|
|
for( int jj = 0; jj < tmpPoly.OutlineCount(); ++jj )
|
|
|
|
{
|
|
|
|
SHAPE_LINE_CHAIN &poly = tmpPoly.Outline( jj );
|
2020-10-15 01:45:20 +00:00
|
|
|
m_plotter->PlotPoly( poly, FILL_TYPE::FILLED_SHAPE, thickness, &gbr_metadata );
|
2019-08-06 04:23:57 +00:00
|
|
|
}
|
2018-12-02 15:33:12 +00:00
|
|
|
}
|
2012-09-24 16:03:03 +00:00
|
|
|
}
|
2019-11-05 10:07:07 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case S_CURVE:
|
2020-10-04 23:34:59 +00:00
|
|
|
m_plotter->BezierCurve( aShape->GetStart(), aShape->GetBezControl1(),
|
2020-11-14 01:16:02 +00:00
|
|
|
aShape->GetBezControl2(), aShape->GetEnd(), 0, thickness );
|
2019-11-05 10:07:07 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2020-10-04 23:34:59 +00:00
|
|
|
wxASSERT_MSG( false, "Unhandled FP_SHAPE shape" );
|
2019-11-05 10:07:07 +00:00
|
|
|
break;
|
2012-09-24 16:03:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-09-19 11:01:36 +00:00
|
|
|
// Plot a PCB Text, i.e. a text found on a copper or technical layer
|
2020-10-04 23:34:59 +00:00
|
|
|
void BRDITEMS_PLOTTER::PlotPcbText( PCB_TEXT* aText )
|
2012-09-24 16:03:03 +00:00
|
|
|
{
|
2020-10-04 23:34:59 +00:00
|
|
|
wxString shownText( aText->GetShownText() );
|
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;
|
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
if( !m_layerMask[aText->GetLayer()] )
|
2012-09-24 16:03:03 +00:00
|
|
|
return;
|
|
|
|
|
2016-09-19 11:01:36 +00:00
|
|
|
GBR_METADATA gbr_metadata;
|
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
if( IsCopperLayer( aText->GetLayer() ) )
|
2016-09-19 11:01:36 +00:00
|
|
|
gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_NONCONDUCTOR );
|
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
COLOR4D color = getColor( aText->GetLayer() );
|
2017-07-31 12:28:35 +00:00
|
|
|
m_plotter->SetColor( color );
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
wxSize size = aText->GetTextSize();
|
|
|
|
wxPoint pos = aText->GetTextPos();
|
|
|
|
double orient = aText->GetTextAngle();
|
|
|
|
int thickness = aText->GetEffectiveTextPenWidth();
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
if( aText->IsMirrored() )
|
2012-09-24 16:03:03 +00:00
|
|
|
size.x = -size.x;
|
|
|
|
|
|
|
|
// Non bold texts thickness is clamped at 1/6 char size by the low level draw function.
|
|
|
|
// but in Pcbnew we do not manage bold texts and thickness up to 1/4 char size
|
|
|
|
// (like bold text) and we manage the thickness.
|
|
|
|
// So we set bold flag to true
|
2020-05-01 16:24:01 +00:00
|
|
|
bool allow_bold = true;
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2020-04-21 20:17:01 +00:00
|
|
|
m_plotter->SetCurrentLineWidth( thickness );
|
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
if( aText->IsMultilineAllowed() )
|
2012-09-24 16:03:03 +00:00
|
|
|
{
|
2013-11-29 08:13:43 +00:00
|
|
|
std::vector<wxPoint> 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
|
|
|
|
2015-01-15 20:01:53 +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 );
|
2020-10-04 23:34:59 +00:00
|
|
|
m_plotter->Text( positions[ii], color, txt, orient, size, aText->GetHorizJustify(),
|
|
|
|
aText->GetVertJustify(), thickness, aText->IsItalic(),
|
2020-04-18 20:04:41 +00:00
|
|
|
allow_bold, false, &gbr_metadata );
|
2012-09-24 16:03:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-10-04 23:34:59 +00:00
|
|
|
m_plotter->Text( pos, color, shownText, orient, size, aText->GetHorizJustify(),
|
|
|
|
aText->GetVertJustify(), thickness, aText->IsItalic(), allow_bold,
|
2020-04-18 20:04:41 +00:00
|
|
|
false, &gbr_metadata );
|
2012-09-24 16:03:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-11 23:05:59 +00:00
|
|
|
void BRDITEMS_PLOTTER::PlotFilledAreas( ZONE* aZone, SHAPE_POLY_SET& polysList )
|
2012-09-24 16:03:03 +00:00
|
|
|
{
|
2015-07-27 19:45:57 +00:00
|
|
|
if( polysList.IsEmpty() )
|
2012-09-24 16:03:03 +00:00
|
|
|
return;
|
|
|
|
|
2016-09-19 11:01:36 +00:00
|
|
|
GBR_METADATA gbr_metadata;
|
|
|
|
|
|
|
|
bool isOnCopperLayer = aZone->IsOnCopperLayer();
|
|
|
|
|
|
|
|
if( isOnCopperLayer )
|
|
|
|
{
|
|
|
|
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
|
|
|
{
|
2016-09-19 11:01:36 +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 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-24 16:03:03 +00:00
|
|
|
// We need a buffer to store corners coordinates:
|
2019-08-27 11:32:00 +00:00
|
|
|
std::vector< wxPoint > cornerList;
|
2012-09-24 16:03:03 +00:00
|
|
|
|
|
|
|
m_plotter->SetColor( getColor( aZone->GetLayer() ) );
|
|
|
|
|
2020-06-28 08:37:36 +00:00
|
|
|
m_plotter->StartBlock( nullptr ); // Clean current object attributes
|
|
|
|
|
2012-09-24 16:03:03 +00:00
|
|
|
/* Plot all filled areas: filled areas have a filled area and a thick
|
2019-08-25 10:10:48 +00:00
|
|
|
* outline (depending on the fill area option we must plot the filled area itself
|
|
|
|
* and plot the thick outline itself, if the thickness has meaning (at least is > 1)
|
2012-09-24 16:03:03 +00:00
|
|
|
*
|
|
|
|
* in non filled mode the outline is plotted, but not the filling items
|
|
|
|
*/
|
2019-08-25 10:10:48 +00:00
|
|
|
int outline_thickness = aZone->GetFilledPolysUseThickness() ? aZone->GetMinThickness() : 0;
|
|
|
|
|
2019-08-27 11:32:00 +00:00
|
|
|
for( int idx = 0; idx < polysList.OutlineCount(); ++idx )
|
2012-09-24 16:03:03 +00:00
|
|
|
{
|
2019-08-27 11:32:00 +00:00
|
|
|
SHAPE_LINE_CHAIN& outline = polysList.Outline( idx );
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2019-08-27 11:32:00 +00:00
|
|
|
cornerList.clear();
|
|
|
|
cornerList.reserve( outline.PointCount() );
|
|
|
|
|
|
|
|
for( int ic = 0; ic < outline.PointCount(); ++ic )
|
|
|
|
{
|
2019-03-24 13:54:56 +00:00
|
|
|
cornerList.emplace_back( wxPoint( outline.CPoint( ic ) ) );
|
2019-08-27 11:32:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( cornerList.size() ) // Plot the current filled area outline
|
2012-09-24 16:03:03 +00:00
|
|
|
{
|
|
|
|
// First, close the outline
|
|
|
|
if( cornerList[0] != cornerList[cornerList.size() - 1] )
|
|
|
|
cornerList.push_back( cornerList[0] );
|
|
|
|
|
2020-06-28 08:37:36 +00:00
|
|
|
// Plot the current filled area (as region for Gerber plotter
|
|
|
|
// to manage attributes) and its outline for thick outline
|
2015-02-02 08:06:39 +00:00
|
|
|
if( GetPlotMode() == FILLED )
|
2012-09-24 16:03:03 +00:00
|
|
|
{
|
2020-06-28 08:37:36 +00:00
|
|
|
if( m_plotter->GetPlotterType() == PLOT_FORMAT::GERBER )
|
|
|
|
{
|
|
|
|
if( outline_thickness > 0 )
|
2021-01-03 13:59:23 +00:00
|
|
|
{
|
|
|
|
m_plotter->PlotPoly( cornerList, FILL_TYPE::NO_FILL, outline_thickness,
|
|
|
|
&gbr_metadata );
|
|
|
|
}
|
2020-06-28 08:37:36 +00:00
|
|
|
|
2021-01-03 13:59:23 +00:00
|
|
|
static_cast<GERBER_PLOTTER*>( m_plotter )->PlotGerberRegion( cornerList,
|
|
|
|
&gbr_metadata );
|
2020-06-28 08:37:36 +00:00
|
|
|
}
|
|
|
|
else
|
2021-01-03 13:59:23 +00:00
|
|
|
{
|
|
|
|
m_plotter->PlotPoly( cornerList, FILL_TYPE::FILLED_SHAPE, outline_thickness,
|
|
|
|
&gbr_metadata );
|
|
|
|
}
|
2012-09-24 16:03:03 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-06-04 07:23:12 +00:00
|
|
|
if( outline_thickness )
|
2012-09-24 16:03:03 +00:00
|
|
|
{
|
2019-04-10 09:19:16 +00:00
|
|
|
for( unsigned jj = 1; jj < cornerList.size(); jj++ )
|
|
|
|
{
|
2012-09-24 16:03:03 +00:00
|
|
|
m_plotter->ThickSegment( cornerList[jj -1], cornerList[jj],
|
2021-01-03 13:59:23 +00:00
|
|
|
outline_thickness, GetPlotMode(), &gbr_metadata );
|
2019-04-10 09:19:16 +00:00
|
|
|
}
|
2012-09-24 16:03:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
m_plotter->SetCurrentLineWidth( -1 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-06-28 08:37:36 +00:00
|
|
|
|
|
|
|
m_plotter->EndBlock( nullptr ); // Clear object attributes
|
2012-09-24 16:03:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
/* Plot items type PCB_SHAPE on layers allowed by aLayerMask
|
2012-09-24 16:03:03 +00:00
|
|
|
*/
|
2020-10-04 23:34:59 +00:00
|
|
|
void BRDITEMS_PLOTTER::PlotPcbShape( 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;
|
|
|
|
|
2015-02-02 08:06:39 +00:00
|
|
|
int radius = 0;
|
|
|
|
double StAngle = 0, EndAngle = 0;
|
2020-11-14 01:16:02 +00:00
|
|
|
bool sketch = GetPlotMode() == SKETCH;
|
2020-10-04 23:34:59 +00:00
|
|
|
int thickness = aShape->GetWidth();
|
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
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
wxPoint start( aShape->GetStart() );
|
|
|
|
wxPoint end( aShape->GetEnd() );
|
2016-09-19 11:01:36 +00:00
|
|
|
|
|
|
|
GBR_METADATA gbr_metadata;
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
if( aShape->GetLayer() == Edge_Cuts )
|
2019-10-09 13:46:35 +00:00
|
|
|
gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_EDGECUT );
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
if( IsCopperLayer( aShape->GetLayer() ) )
|
|
|
|
// Graphic items (PCB_SHAPE, TEXT) having no net have the NonConductor attribute
|
2020-03-19 11:53:52 +00:00
|
|
|
// 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-10-04 23:34:59 +00:00
|
|
|
switch( aShape->GetShape() )
|
2012-09-24 16:03:03 +00:00
|
|
|
{
|
2020-07-17 09:26:35 +00:00
|
|
|
case S_SEGMENT:
|
|
|
|
m_plotter->ThickSegment( start, end, thickness, GetPlotMode(), &gbr_metadata );
|
|
|
|
break;
|
|
|
|
|
2012-09-24 16:03:03 +00:00
|
|
|
case S_CIRCLE:
|
2013-05-01 17:32:36 +00:00
|
|
|
radius = KiROUND( GetLineLength( end, start ) );
|
2020-10-12 09:30:43 +00:00
|
|
|
|
2020-11-14 01:16:02 +00:00
|
|
|
if( aShape->IsFilled() )
|
|
|
|
m_plotter->FilledCircle( start, radius * 2 + thickness, GetPlotMode(), &gbr_metadata );
|
2020-10-12 09:30:43 +00:00
|
|
|
else
|
2020-11-14 01:16:02 +00:00
|
|
|
m_plotter->ThickCircle( start, radius * 2, thickness, GetPlotMode(), &gbr_metadata );
|
|
|
|
|
2012-09-24 16:03:03 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case S_ARC:
|
2013-05-01 17:32:36 +00:00
|
|
|
radius = KiROUND( GetLineLength( end, start ) );
|
2012-09-24 16:03:03 +00:00
|
|
|
StAngle = ArcTangente( end.y - start.y, end.x - start.x );
|
2020-10-04 23:34:59 +00:00
|
|
|
EndAngle = StAngle + aShape->GetAngle();
|
2018-02-04 16:22:14 +00:00
|
|
|
|
|
|
|
// when startAngle == endAngle ThickArc() doesn't know whether it's 0 deg and 360 deg
|
2020-10-04 23:34:59 +00:00
|
|
|
if( std::abs( aShape->GetAngle() ) == 3600.0 )
|
2020-11-14 01:16:02 +00:00
|
|
|
{
|
2018-02-04 16:22:14 +00:00
|
|
|
m_plotter->ThickCircle( start, radius * 2, thickness, GetPlotMode(), &gbr_metadata );
|
2020-11-14 01:16:02 +00:00
|
|
|
}
|
2018-02-04 16:22:14 +00:00
|
|
|
else
|
2020-11-14 01:16:02 +00:00
|
|
|
{
|
|
|
|
m_plotter->ThickArc( start, -EndAngle, -StAngle, radius, thickness, GetPlotMode(),
|
|
|
|
&gbr_metadata );
|
|
|
|
}
|
2012-09-24 16:03:03 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case S_CURVE:
|
2020-11-14 01:16:02 +00:00
|
|
|
m_plotter->BezierCurve( aShape->GetStart(), aShape->GetBezControl1(),
|
|
|
|
aShape->GetBezControl2(), aShape->GetEnd(), 0, thickness );
|
2012-09-24 16:03:03 +00:00
|
|
|
break;
|
|
|
|
|
2017-11-16 11:09:24 +00:00
|
|
|
case S_POLYGON:
|
2020-11-14 01:16:02 +00:00
|
|
|
if( aShape->IsPolyShapeValid() )
|
2017-11-16 11:09:24 +00:00
|
|
|
{
|
2020-11-14 01:16:02 +00:00
|
|
|
if( sketch || thickness > 0 )
|
2018-12-02 04:41:17 +00:00
|
|
|
{
|
2020-10-04 23:34:59 +00:00
|
|
|
for( auto it = aShape->GetPolyShape().CIterateSegments( 0 ); it; it++ )
|
2018-12-02 04:41:17 +00:00
|
|
|
{
|
|
|
|
auto seg = it.Get();
|
|
|
|
m_plotter->ThickSegment( wxPoint( seg.A ), wxPoint( seg.B ),
|
2020-05-01 16:24:01 +00:00
|
|
|
thickness, GetPlotMode(), &gbr_metadata );
|
2018-12-02 04:41:17 +00:00
|
|
|
}
|
|
|
|
}
|
2020-11-14 01:16:02 +00:00
|
|
|
|
|
|
|
if( !sketch && aShape->IsFilled() )
|
2017-11-16 11:09:24 +00:00
|
|
|
{
|
2018-12-02 04:41:17 +00:00
|
|
|
m_plotter->SetCurrentLineWidth( thickness, &gbr_metadata );
|
|
|
|
// 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 )
|
2018-12-21 01:03:55 +00:00
|
|
|
// This must be simplified and fractured to prevent overlapping polygons
|
|
|
|
// from generating invalid Gerber files
|
2020-10-04 23:34:59 +00:00
|
|
|
auto tmpPoly = SHAPE_POLY_SET( aShape->GetPolyShape() );
|
2018-12-21 01:03:55 +00:00
|
|
|
tmpPoly.Fracture( SHAPE_POLY_SET::PM_FAST );
|
|
|
|
|
|
|
|
for( int jj = 0; jj < tmpPoly.OutlineCount(); ++jj )
|
2018-12-02 04:41:17 +00:00
|
|
|
{
|
2018-12-21 01:03:55 +00:00
|
|
|
SHAPE_LINE_CHAIN& poly = tmpPoly.Outline( jj );
|
2020-10-15 01:45:20 +00:00
|
|
|
m_plotter->PlotPoly( poly, FILL_TYPE::FILLED_SHAPE, thickness, &gbr_metadata );
|
2018-12-02 04:41:17 +00:00
|
|
|
}
|
2017-11-16 11:09:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2020-07-17 09:26:35 +00:00
|
|
|
case S_RECT:
|
|
|
|
{
|
2020-10-04 23:34:59 +00:00
|
|
|
std::vector<wxPoint> pts = aShape->GetRectCorners();
|
2020-07-17 09:26:35 +00:00
|
|
|
|
2020-11-14 01:16:02 +00:00
|
|
|
if( sketch || thickness > 0 )
|
2020-07-17 09:26:35 +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 );
|
|
|
|
}
|
2020-11-14 01:16:02 +00:00
|
|
|
|
|
|
|
if( !sketch && aShape->IsFilled() )
|
2020-07-17 09:26:35 +00:00
|
|
|
{
|
|
|
|
SHAPE_LINE_CHAIN poly;
|
|
|
|
|
|
|
|
for( const wxPoint& pt : pts )
|
|
|
|
poly.Append( pt );
|
|
|
|
|
2020-10-15 01:45:20 +00:00
|
|
|
m_plotter->PlotPoly( poly, FILL_TYPE::FILLED_SHAPE, -1, &gbr_metadata );
|
2020-07-17 09:26:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2012-09-24 16:03:03 +00:00
|
|
|
default:
|
2020-10-04 23:34:59 +00:00
|
|
|
wxASSERT_MSG( false, "Unhandled PCB_SHAPE shape" );
|
2016-09-19 11:01:36 +00:00
|
|
|
m_plotter->ThickSegment( start, end, thickness, GetPlotMode(), &gbr_metadata );
|
2012-09-24 16:03:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-20 14:50:12 +00:00
|
|
|
|
2012-09-24 16:03:03 +00:00
|
|
|
/** Helper function to plot a single drill mark. It compensate and clamp
|
|
|
|
* the drill mark size depending on the current plot options
|
|
|
|
*/
|
2019-04-10 09:19:16 +00:00
|
|
|
void BRDITEMS_PLOTTER::plotOneDrillMark( PAD_DRILL_SHAPE_T aDrillShape, const wxPoint &aDrillPos,
|
|
|
|
wxSize aDrillSize, const wxSize &aPadSize,
|
|
|
|
double aOrientation, int aSmallDrill )
|
2012-09-24 16:03:03 +00:00
|
|
|
{
|
|
|
|
// Small drill marks have no significance when applied to slots
|
2015-08-23 19:40:33 +00:00
|
|
|
if( aSmallDrill && aDrillShape == PAD_DRILL_SHAPE_CIRCLE )
|
2012-09-24 16:03:03 +00:00
|
|
|
aDrillSize.x = std::min( aSmallDrill, aDrillSize.x );
|
|
|
|
|
|
|
|
// Round holes only have x diameter, slots have both
|
|
|
|
aDrillSize.x -= getFineWidthAdj();
|
|
|
|
aDrillSize.x = Clamp( 1, aDrillSize.x, aPadSize.x - 1 );
|
2013-03-20 14:50:12 +00:00
|
|
|
|
2015-08-23 19:40:33 +00:00
|
|
|
if( aDrillShape == PAD_DRILL_SHAPE_OBLONG )
|
2012-09-24 16:03:03 +00:00
|
|
|
{
|
|
|
|
aDrillSize.y -= getFineWidthAdj();
|
|
|
|
aDrillSize.y = Clamp( 1, aDrillSize.y, aPadSize.y - 1 );
|
2016-09-19 11:01:36 +00:00
|
|
|
m_plotter->FlashPadOval( aDrillPos, aDrillSize, aOrientation, GetPlotMode(), NULL );
|
2012-09-24 16:03:03 +00:00
|
|
|
}
|
|
|
|
else
|
2021-01-03 13:59:23 +00:00
|
|
|
{
|
2016-09-19 11:01:36 +00:00
|
|
|
m_plotter->FlashPadCircle( aDrillPos, aDrillSize.x, GetPlotMode(), NULL );
|
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()
|
|
|
|
{
|
|
|
|
/* If small drills marks were requested prepare a clamp value to pass
|
|
|
|
to the helper function */
|
2021-01-23 17:02:58 +00:00
|
|
|
int smallDrill = GetDrillMarksType() == PCB_PLOT_PARAMS::SMALL_DRILL_SHAPE
|
2021-01-04 22:26:23 +00:00
|
|
|
? Millimeter2iu( ADVANCED_CFG::GetCfg().m_SmallDrillMarkSize ) : 0;
|
2012-09-24 16:03:03 +00:00
|
|
|
|
|
|
|
/* In the filled trace mode drill marks are drawn white-on-black to scrape
|
|
|
|
the underlying pad. This works only for drivers supporting color change,
|
|
|
|
obviously... it means that:
|
|
|
|
- PS, SVG and PDF output is correct (i.e. you have a 'donut' pad)
|
|
|
|
- In HPGL you can't see them
|
|
|
|
- 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 scrape the film.
|
|
|
|
- In DXF they go into the 'WHITE' layer. This could be useful.
|
|
|
|
*/
|
2015-02-02 08:06:39 +00:00
|
|
|
if( GetPlotMode() == FILLED )
|
2012-09-24 16:03:03 +00:00
|
|
|
m_plotter->SetColor( WHITE );
|
|
|
|
|
2021-01-03 13:59:23 +00:00
|
|
|
for( TRACK* tracks : m_board->Tracks() )
|
2012-09-24 16:03:03 +00:00
|
|
|
{
|
2021-01-03 13:59:23 +00:00
|
|
|
const VIA* via = dyn_cast<const VIA*>( tracks );
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2014-04-25 06:00:04 +00:00
|
|
|
if( via )
|
2019-04-10 09:19:16 +00:00
|
|
|
{
|
2015-08-23 19:40:33 +00:00
|
|
|
plotOneDrillMark( PAD_DRILL_SHAPE_CIRCLE, via->GetStart(),
|
2021-01-03 13:59:23 +00:00
|
|
|
wxSize( via->GetDrillValue(), 0 ),
|
|
|
|
wxSize( via->GetWidth(), 0 ), 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(),
|
|
|
|
pad->GetSize(), pad->GetOrientation(), smallDrill );
|
2012-09-24 16:03:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-02 08:06:39 +00:00
|
|
|
if( GetPlotMode() == FILLED )
|
2021-01-03 13:59:23 +00:00
|
|
|
m_plotter->SetColor( BLACK );
|
2012-09-24 16:03:03 +00:00
|
|
|
}
|