Cleanup. No (intentional) functional changes.

This commit is contained in:
Jeff Young 2023-06-06 12:30:35 +01:00
parent 1ed4cd3644
commit 9fe00bb808
9 changed files with 180 additions and 248 deletions

View File

@ -279,18 +279,18 @@ std::string GBR_APERTURE_METADATA::FormatAttribute( GBR_APERTURE_ATTRIB aAttribu
attribute_string = "TA.AperFunction,ComponentMain"; attribute_string = "TA.AperFunction,ComponentMain";
break; break;
case GBR_APERTURE_ATTRIB_PAD1_POSITION: // print info associated to a component case GBR_APERTURE_ATTRIB_PAD1_POS: // print info associated to a component
// flashed shape at pad 1 position // flashed shape at pad 1 position
// (pad 1 is also pad A1 or pad AA1) // (pad 1 is also pad A1 or pad AA1)
// in placement files // in placement files
attribute_string = "TA.AperFunction,ComponentPin"; attribute_string = "TA.AperFunction,ComponentPin";
break; break;
case GBR_APERTURE_ATTRIB_PADOTHER_POSITION: // print info associated to a component case GBR_APERTURE_ATTRIB_PADOTHER_POS: // print info associated to a component
// flashed shape at pads position (all but pad 1) // flashed shape at pads position (all but pad 1)
// in placement files // in placement files
// Currently: (could be changed later) same as // Currently: (could be changed later) same as
// GBR_APERTURE_ATTRIB_PADOTHER_POSITION // GBR_APERTURE_ATTRIB_PADOTHER_POS
attribute_string = "TA.AperFunction,ComponentPin"; attribute_string = "TA.AperFunction,ComponentPin";
break; break;

View File

@ -146,10 +146,10 @@ public:
GBR_APERTURE_ATTRIB_CMP_POSITION, GBR_APERTURE_ATTRIB_CMP_POSITION,
///< aperture used for flashed pin 1 (or A1 or AA1) position in placement files. ///< aperture used for flashed pin 1 (or A1 or AA1) position in placement files.
GBR_APERTURE_ATTRIB_PAD1_POSITION, GBR_APERTURE_ATTRIB_PAD1_POS,
///< aperture used for flashed pads position in placement files. ///< aperture used for flashed pads position in placement files.
GBR_APERTURE_ATTRIB_PADOTHER_POSITION, GBR_APERTURE_ATTRIB_PADOTHER_POS,
///< aperture used to draw component physical body outline without pins in placement files. ///< aperture used to draw component physical body outline without pins in placement files.
GBR_APERTURE_ATTRIB_CMP_BODY, GBR_APERTURE_ATTRIB_CMP_BODY,

View File

@ -225,7 +225,7 @@ bool GENDRILL_WRITER_BASE::genDrillMapFile( const wxString& aFullFileName, PLOT_
{ {
PCB_SHAPE dummy_shape( *static_cast<PCB_SHAPE*>( item ) ); PCB_SHAPE dummy_shape( *static_cast<PCB_SHAPE*>( item ) );
dummy_shape.SetLayer( Dwgs_User ); dummy_shape.SetLayer( Dwgs_User );
itemplotter.PlotPcbShape( &dummy_shape ); itemplotter.PlotShape( &dummy_shape );
} }
break; break;

View File

@ -31,11 +31,7 @@
#include <string_utils.h> #include <string_utils.h>
#include <locale_io.h> #include <locale_io.h>
#include <macros.h> #include <macros.h>
#include <board.h>
#include <board_design_settings.h>
#include <pcb_shape.h> #include <pcb_shape.h>
#include <pcbplot.h> #include <pcbplot.h>
#include <wildcards_and_files_ext.h> #include <wildcards_and_files_ext.h>
#include <gbr_metadata.h> #include <gbr_metadata.h>
@ -115,7 +111,7 @@ int PLACEFILE_GERBER_WRITER::CreatePlaceFile( wxString& aFullFilename, PCB_LAYER
// and component outline thickness (polyline) // and component outline thickness (polyline)
int flash_position_shape_diam = pcbIUScale.mmToIU( 0.3 ); // defined size for position shape (circle) int flash_position_shape_diam = pcbIUScale.mmToIU( 0.3 ); // defined size for position shape (circle)
int pad1_mark_size = pcbIUScale.mmToIU( 0.36 ); // defined size for pad 1 position (diamond) int pad1_mark_size = pcbIUScale.mmToIU( 0.36 ); // defined size for pad 1 position (diamond)
int other_pads_mark_size = 0; // defined size for position shape (circle) int other_pads_mark_size = 0; // defined size for position shape (circle)
int line_thickness = pcbIUScale.mmToIU( 0.1 ); // defined size for component outlines int line_thickness = pcbIUScale.mmToIU( 0.1 ); // defined size for component outlines
brd_plotter.SetLayerSet( LSET( aLayer ) ); brd_plotter.SetLayerSet( LSET( aLayer ) );
@ -126,16 +122,16 @@ int PLACEFILE_GERBER_WRITER::CreatePlaceFile( wxString& aFullFilename, PCB_LAYER
for( FOOTPRINT* footprint : fp_list ) for( FOOTPRINT* footprint : fp_list )
{ {
// Manage the aperture attribute component position: // Manage the aperture attribute component position:
GBR_METADATA gbr_metadata; GBR_METADATA metadata;
gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CMP_POSITION ); metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CMP_POSITION );
// Add object attribute: component reference to flash (mainly useful for users) // Add object attribute: component reference to flash (mainly useful for users)
// using quoted UTF8 string // using quoted UTF8 string
wxString ref = ConvertNotAllowedCharsInGerber( footprint->Reference().GetShownText( false ), wxString ref = ConvertNotAllowedCharsInGerber( footprint->Reference().GetShownText( false ),
allowUtf8, true ); allowUtf8, true );
gbr_metadata.SetCmpReference( ref ); metadata.SetCmpReference( ref );
gbr_metadata.SetNetAttribType( GBR_NETLIST_METADATA::GBR_NETINFO_CMP ); metadata.SetNetAttribType( GBR_NETLIST_METADATA::GBR_NETINFO_CMP );
// Add P&P specific attributes // Add P&P specific attributes
GBR_CMP_PNP_METADATA pnpAttrib; GBR_CMP_PNP_METADATA pnpAttrib;
@ -163,15 +159,15 @@ int PLACEFILE_GERBER_WRITER::CreatePlaceFile( wxString& aFullFilename, PCB_LAYER
fp_info = FROM_UTF8( footprint->GetFPID().GetLibNickname().c_str() ); fp_info = FROM_UTF8( footprint->GetFPID().GetLibNickname().c_str() );
pnpAttrib.m_LibraryName = ConvertNotAllowedCharsInGerber( fp_info, allowUtf8, true ); pnpAttrib.m_LibraryName = ConvertNotAllowedCharsInGerber( fp_info, allowUtf8, true );
gbr_metadata.m_NetlistMetadata.SetExtraData( pnpAttrib.FormatCmpPnPMetadata() ); metadata.m_NetlistMetadata.SetExtraData( pnpAttrib.FormatCmpPnPMetadata() );
VECTOR2I flash_pos = footprint->GetPosition(); VECTOR2I flash_pos = footprint->GetPosition();
plotter.FlashPadCircle( flash_pos, flash_position_shape_diam, FILLED, &gbr_metadata ); plotter.FlashPadCircle( flash_pos, flash_position_shape_diam, FILLED, &metadata );
gbr_metadata.m_NetlistMetadata.ClearExtraData(); metadata.m_NetlistMetadata.ClearExtraData();
// Now some extra metadata is output, avoid blindly clearing the full metadata list // Now some extra metadata is output, avoid blindly clearing the full metadata list
gbr_metadata.m_NetlistMetadata.m_TryKeepPreviousAttributes = true; metadata.m_NetlistMetadata.m_TryKeepPreviousAttributes = true;
// We plot the footprint courtyard when possible. // We plot the footprint courtyard when possible.
// If not, the pads bounding box will be used. // If not, the pads bounding box will be used.
@ -184,8 +180,7 @@ int PLACEFILE_GERBER_WRITER::CreatePlaceFile( wxString& aFullFilename, PCB_LAYER
if( ( footprint->GetFlags() & checkFlag ) == 0 ) if( ( footprint->GetFlags() & checkFlag ) == 0 )
{ {
gbr_metadata.SetApertureAttrib( metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CMP_COURTYARD );
GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CMP_COURTYARD );
const SHAPE_POLY_SET& courtyard = footprint->GetCourtyard( aLayer ); const SHAPE_POLY_SET& courtyard = footprint->GetCourtyard( aLayer );
@ -197,14 +192,13 @@ int PLACEFILE_GERBER_WRITER::CreatePlaceFile( wxString& aFullFilename, PCB_LAYER
continue; continue;
useFpPadsBbox = false; useFpPadsBbox = false;
plotter.PLOTTER::PlotPoly( poly, FILL_T::NO_FILL, line_thickness, &gbr_metadata ); plotter.PLOTTER::PlotPoly( poly, FILL_T::NO_FILL, line_thickness, &metadata );
} }
} }
if( useFpPadsBbox ) if( useFpPadsBbox )
{ {
gbr_metadata.SetApertureAttrib( metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CMP_FOOTPRINT );
GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CMP_FOOTPRINT );
// bbox of fp pads, pos 0, rot 0, non flipped // bbox of fp pads, pos 0, rot 0, non flipped
BOX2I bbox = footprint->GetFpPadsLocalBbox(); BOX2I bbox = footprint->GetFpPadsLocalBbox();
@ -222,7 +216,7 @@ int PLACEFILE_GERBER_WRITER::CreatePlaceFile( wxString& aFullFilename, PCB_LAYER
poly.Rotate( footprint->GetOrientation() ); poly.Rotate( footprint->GetOrientation() );
poly.Move( footprint->GetPosition() ); poly.Move( footprint->GetPosition() );
plotter.PLOTTER::PlotPoly( poly, FILL_T::NO_FILL, line_thickness, &gbr_metadata ); plotter.PLOTTER::PlotPoly( poly, FILL_T::NO_FILL, line_thickness, &metadata );
} }
std::vector<PAD*>pad_key_list; std::vector<PAD*>pad_key_list;
@ -233,26 +227,21 @@ int PLACEFILE_GERBER_WRITER::CreatePlaceFile( wxString& aFullFilename, PCB_LAYER
for( PAD* pad1 : pad_key_list ) for( PAD* pad1 : pad_key_list )
{ {
gbr_metadata.SetApertureAttrib( metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_PAD1_POS );
GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_PAD1_POSITION ); metadata.SetPadName( pad1->GetNumber(), allowUtf8, true );
metadata.SetPadPinFunction( pad1->GetPinFunction(), allowUtf8, true );
gbr_metadata.SetPadName( pad1->GetNumber(), allowUtf8, true ); metadata.SetNetAttribType( GBR_NETLIST_METADATA::GBR_NETINFO_PAD );
gbr_metadata.SetPadPinFunction( pad1->GetPinFunction(), allowUtf8, true );
gbr_metadata.SetNetAttribType( GBR_NETLIST_METADATA::GBR_NETINFO_PAD );
// Flashes a diamond at pad position: // Flashes a diamond at pad position:
plotter.FlashRegularPolygon( pad1->GetPosition(), pad1_mark_size, 4, ANGLE_0, plotter.FlashRegularPolygon( pad1->GetPosition(), pad1_mark_size, 4, ANGLE_0,
FILLED, &gbr_metadata ); FILLED, &metadata );
} }
} }
if( m_plotOtherPadsMarker ) if( m_plotOtherPadsMarker )
{ {
gbr_metadata.SetApertureAttrib( metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_PADOTHER_POS );
GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_PADOTHER_POSITION ); metadata.SetNetAttribType( GBR_NETLIST_METADATA::GBR_NETINFO_PAD );
gbr_metadata.SetNetAttribType( GBR_NETLIST_METADATA::GBR_NETINFO_PAD );
for( PAD* pad: footprint->Pads() ) for( PAD* pad: footprint->Pads() )
{ {
@ -275,13 +264,11 @@ int PLACEFILE_GERBER_WRITER::CreatePlaceFile( wxString& aFullFilename, PCB_LAYER
if( !pad->IsOnLayer( aLayer ) ) if( !pad->IsOnLayer( aLayer ) )
continue; continue;
gbr_metadata.SetPadName( pad->GetNumber(), allowUtf8, true ); metadata.SetPadName( pad->GetNumber(), allowUtf8, true );
metadata.SetPadPinFunction( pad->GetPinFunction(), allowUtf8, true );
gbr_metadata.SetPadPinFunction( pad->GetPinFunction(), allowUtf8, true );
// Flashes a round, 0 sized round shape at pad position // Flashes a round, 0 sized round shape at pad position
plotter.FlashPadCircle( pad->GetPosition(), other_pads_mark_size, FILLED, plotter.FlashPadCircle( pad->GetPosition(), other_pads_mark_size, FILLED, &metadata );
&gbr_metadata );
} }
} }
@ -296,7 +283,8 @@ int PLACEFILE_GERBER_WRITER::CreatePlaceFile( wxString& aFullFilename, PCB_LAYER
brd_plotter.SetLayerSet( LSET( Edge_Cuts ) ); brd_plotter.SetLayerSet( LSET( Edge_Cuts ) );
// Plot edge layer and graphic items // Plot edge layer and graphic items
brd_plotter.PlotBoardGraphicItems(); for( const BOARD_ITEM* item : m_pcb->Drawings() )
brd_plotter.PlotBoardGraphicItem( item );
// Draw footprint other graphic items: // Draw footprint other graphic items:
for( FOOTPRINT* footprint : fp_list ) for( FOOTPRINT* footprint : fp_list )
@ -304,7 +292,7 @@ int PLACEFILE_GERBER_WRITER::CreatePlaceFile( wxString& aFullFilename, PCB_LAYER
for( BOARD_ITEM* item : footprint->GraphicalItems() ) for( BOARD_ITEM* item : footprint->GraphicalItems() )
{ {
if( item->Type() == PCB_SHAPE_T && item->GetLayer() == Edge_Cuts ) if( item->Type() == PCB_SHAPE_T && item->GetLayer() == Edge_Cuts )
brd_plotter.PlotPcbShape( static_cast<PCB_SHAPE*>( item ) ); brd_plotter.PlotShape( static_cast<PCB_SHAPE*>( item ) );
} }
} }
} }

View File

@ -32,12 +32,12 @@
#include <convert_basic_shapes_to_polygon.h> #include <convert_basic_shapes_to_polygon.h>
#include <pcb_track.h> #include <pcb_track.h>
#include <base_units.h> #include <base_units.h>
#include <bitmaps.h> //#include <bitmaps.h>
#include <string_utils.h> #include <string_utils.h>
#include <view/view.h> #include <view/view.h>
#include <settings/color_settings.h> #include <settings/color_settings.h>
#include <settings/settings_manager.h> #include <settings/settings_manager.h>
#include <i18n_utility.h> //#include <i18n_utility.h>
#include <geometry/seg.h> #include <geometry/seg.h>
#include <geometry/shape_segment.h> #include <geometry/shape_segment.h>
#include <geometry/shape_circle.h> #include <geometry/shape_circle.h>
@ -460,9 +460,7 @@ std::shared_ptr<SHAPE_SEGMENT> PCB_VIA::GetEffectiveHoleShape() const
bool PCB_VIA::IsTented() const bool PCB_VIA::IsTented() const
{ {
const BOARD* board = GetBoard(); if( const BOARD* board = GetBoard() )
if( board )
return board->GetTentVias(); return board->GetTentVias();
else else
return true; return true;
@ -471,9 +469,7 @@ bool PCB_VIA::IsTented() const
int PCB_VIA::GetSolderMaskExpansion() const int PCB_VIA::GetSolderMaskExpansion() const
{ {
const BOARD* board = GetBoard(); if( const BOARD* board = GetBoard() )
if( board )
return board->GetDesignSettings().m_SolderMaskExpansion; return board->GetDesignSettings().m_SolderMaskExpansion;
else else
return 0; return 0;
@ -615,7 +611,7 @@ void PCB_VIA::SanitizeLayers()
bool PCB_VIA::FlashLayer( LSET aLayers ) const bool PCB_VIA::FlashLayer( LSET aLayers ) const
{ {
for( auto layer : aLayers.Seq() ) for( PCB_LAYER_ID layer : aLayers.Seq() )
{ {
if( FlashLayer( layer ) ) if( FlashLayer( layer ) )
return true; return true;
@ -737,10 +733,9 @@ double PCB_TRACK::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
const BOX2I PCB_TRACK::ViewBBox() const const BOX2I PCB_TRACK::ViewBBox() const
{ {
BOX2I bbox = GetBoundingBox(); BOX2I bbox = GetBoundingBox();
const BOARD* board = GetBoard();
if( board ) if( const BOARD* board = GetBoard() )
bbox.Inflate( 2 * board->GetDesignSettings().GetBiggestClearanceValue() ); bbox.Inflate( 2 * board->GetDesignSettings().GetBiggestClearanceValue() );
else else
bbox.Inflate( GetWidth() ); // Add a bit extra for safety bbox.Inflate( GetWidth() ); // Add a bit extra for safety
@ -777,7 +772,6 @@ double PCB_VIA::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
PCB_PAINTER* painter = static_cast<PCB_PAINTER*>( aView->GetPainter() ); PCB_PAINTER* painter = static_cast<PCB_PAINTER*>( aView->GetPainter() );
PCB_RENDER_SETTINGS* renderSettings = painter->GetSettings(); PCB_RENDER_SETTINGS* renderSettings = painter->GetSettings();
const BOARD* board = GetBoard();
LSET visible = LSET::AllLayersMask(); LSET visible = LSET::AllLayersMask();
// Meta control for hiding all vias // Meta control for hiding all vias
@ -785,7 +779,7 @@ double PCB_VIA::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
return HIDE; return HIDE;
// Handle board visibility // Handle board visibility
if( board ) if( const BOARD* board = GetBoard() )
visible = board->GetVisibleLayers() & board->GetEnabledLayers(); visible = board->GetVisibleLayers() & board->GetEnabledLayers();
// In high contrast mode don't show vias that don't cross the high-contrast layer // In high contrast mode don't show vias that don't cross the high-contrast layer
@ -1160,13 +1154,6 @@ EDA_ANGLE PCB_ARC::GetArcAngleStart() const
} }
EDA_ANGLE PCB_ARC::GetArcAngleEnd() const
{
EDA_ANGLE angleEnd( m_End - GetPosition() );
return angleEnd.Normalize();
}
bool PCB_TRACK::cmp_tracks::operator() ( const PCB_TRACK* a, const PCB_TRACK* b ) const bool PCB_TRACK::cmp_tracks::operator() ( const PCB_TRACK* a, const PCB_TRACK* b ) const
{ {
if( a->GetNetCode() != b->GetNetCode() ) if( a->GetNetCode() != b->GetNetCode() )

View File

@ -27,9 +27,9 @@
* for curved tracks (PCB_ARC) and vias (PCB_VIA). All told there are three KICAD_Ts: * for curved tracks (PCB_ARC) and vias (PCB_VIA). All told there are three KICAD_Ts:
* PCB_TRACK_T, PCB_ARC_T, and PCB_VIA_T. * PCB_TRACK_T, PCB_ARC_T, and PCB_VIA_T.
* *
* For vias there is a further VIATYPE which indicates THROUGH, BLIND_BURIED, or * For vias there is a further VIATYPE which indicates THROUGH, BLIND_BURIED, or MICROVIA,
* MICROVIA, which are supported by the synthetic KICAD_Ts PCB_LOCATE_STDVIA_T, * which are supported by the synthetic KICAD_Ts PCB_LOCATE_STDVIA_T, PCB_LOCATE_BBVIA_T, and
* PCB_LOCATE_BBVIA_T, and PCB_LOCATE_UVIA_T. * PCB_LOCATE_UVIA_T.
*/ */
#ifndef CLASS_TRACK_H #ifndef CLASS_TRACK_H
@ -99,24 +99,24 @@ public:
void Flip( const VECTOR2I& aCentre, bool aFlipLeftRight ) override; void Flip( const VECTOR2I& aCentre, bool aFlipLeftRight ) override;
void SetPosition( const VECTOR2I& aPos ) override { m_Start = aPos; } void SetPosition( const VECTOR2I& aPos ) override { m_Start = aPos; }
VECTOR2I GetPosition() const override { return m_Start; } VECTOR2I GetPosition() const override { return m_Start; }
const VECTOR2I GetFocusPosition() const override { return ( m_Start + m_End ) / 2; } const VECTOR2I GetFocusPosition() const override { return ( m_Start + m_End ) / 2; }
void SetWidth( int aWidth ) { m_Width = aWidth; } void SetWidth( int aWidth ) { m_Width = aWidth; }
int GetWidth() const { return m_Width; } int GetWidth() const { return m_Width; }
void SetEnd( const VECTOR2I& aEnd ) { m_End = aEnd; } void SetEnd( const VECTOR2I& aEnd ) { m_End = aEnd; }
const VECTOR2I& GetEnd() const { return m_End; } const VECTOR2I& GetEnd() const { return m_End; }
void SetStart( const VECTOR2I& aStart ) { m_Start = aStart; } void SetStart( const VECTOR2I& aStart ) { m_Start = aStart; }
const VECTOR2I& GetStart() const { return m_Start; } const VECTOR2I& GetStart() const { return m_Start; }
void SetEndX( int aX ) { m_End.x = aX; } void SetEndX( int aX ) { m_End.x = aX; }
void SetEndY( int aY ) { m_End.y = aY; } void SetEndY( int aY ) { m_End.y = aY; }
int GetEndX() const { return m_End.x; } int GetEndX() const { return m_End.x; }
int GetEndY() const { return m_End.y; } int GetEndY() const { return m_End.y; }
/// Return the selected endpoint (start or end) /// Return the selected endpoint (start or end)
const VECTOR2I& GetEndPoint( ENDPOINT_T aEndPoint ) const const VECTOR2I& GetEndPoint( ENDPOINT_T aEndPoint ) const
@ -275,12 +275,11 @@ protected:
std::vector<MSG_PANEL_ITEM>& aList ) const; std::vector<MSG_PANEL_ITEM>& aList ) const;
protected: protected:
int m_Width; ///< Thickness of track, or via diameter int m_Width; ///< Thickness of track, or via diameter
VECTOR2I m_Start; ///< Line start point VECTOR2I m_Start; ///< Line start point
VECTOR2I m_End; ///< Line end point VECTOR2I m_End; ///< Line end point
double m_CachedLOD; ///< Last LOD used to draw this track's net
double m_CachedLOD; ///< Last LOD used to draw this track's net
double m_CachedScale; ///< Last zoom scale used to draw this track's net. double m_CachedScale; ///< Last zoom scale used to draw this track's net.
}; };
@ -290,8 +289,7 @@ class PCB_ARC : public PCB_TRACK
public: public:
PCB_ARC( BOARD_ITEM* aParent ) : PCB_ARC( BOARD_ITEM* aParent ) :
PCB_TRACK( aParent, PCB_ARC_T ) PCB_TRACK( aParent, PCB_ARC_T )
{ { }
};
PCB_ARC( BOARD_ITEM* aParent, const SHAPE_ARC* aArc ); PCB_ARC( BOARD_ITEM* aParent, const SHAPE_ARC* aArc );
@ -313,13 +311,10 @@ public:
void Flip( const VECTOR2I& aCentre, bool aFlipLeftRight ) override; void Flip( const VECTOR2I& aCentre, bool aFlipLeftRight ) override;
void SetMid( const VECTOR2I& aMid ) { m_Mid = aMid; } void SetMid( const VECTOR2I& aMid ) { m_Mid = aMid; }
const VECTOR2I& GetMid() const { return m_Mid; } const VECTOR2I& GetMid() const { return m_Mid; }
void SetPosition( const VECTOR2I& aPos ) override void SetPosition( const VECTOR2I& aPos ) override { m_Start = aPos; }
{
m_Start = aPos;
}
virtual VECTOR2I GetPosition() const override; virtual VECTOR2I GetPosition() const override;
@ -328,7 +323,6 @@ public:
double GetRadius() const; double GetRadius() const;
EDA_ANGLE GetAngle() const; EDA_ANGLE GetAngle() const;
EDA_ANGLE GetArcAngleStart() const; EDA_ANGLE GetArcAngleStart() const;
EDA_ANGLE GetArcAngleEnd() const;
virtual bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override; virtual bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
virtual bool HitTest( const BOX2I& aRect, bool aContained = true, virtual bool HitTest( const BOX2I& aRect, bool aContained = true,
@ -443,8 +437,8 @@ public:
*/ */
void SanitizeLayers(); void SanitizeLayers();
VECTOR2I GetPosition() const override { return m_Start; } VECTOR2I GetPosition() const override { return m_Start; }
void SetPosition( const VECTOR2I& aPoint ) override { m_Start = aPoint; m_End = aPoint; } void SetPosition( const VECTOR2I& aPoint ) override { m_Start = aPoint; m_End = aPoint; }
void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override; void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
@ -548,14 +542,9 @@ public:
* *
* @return true if the via is a free via * @return true if the via is a free via
*/ */
bool GetIsFree() const { return m_isFree; } bool GetIsFree() const { return m_isFree; }
void SetIsFree( bool aFree = true ) { m_isFree = aFree; } void SetIsFree( bool aFree = true ) { m_isFree = aFree; }
/**
* @return true if the drill value is default value (-1)
*/
bool IsDrillDefault() const { return m_drill <= 0; }
// @copydoc BOARD_ITEM::GetEffectiveShape // @copydoc BOARD_ITEM::GetEffectiveShape
std::shared_ptr<SHAPE> GetEffectiveShape( PCB_LAYER_ID aLayer = UNDEFINED_LAYER, std::shared_ptr<SHAPE> GetEffectiveShape( PCB_LAYER_ID aLayer = UNDEFINED_LAYER,
FLASHING aFlash = FLASHING::DEFAULT ) const override; FLASHING aFlash = FLASHING::DEFAULT ) const override;

View File

@ -55,13 +55,11 @@ class wxFileName;
class BRDITEMS_PLOTTER : public PCB_PLOT_PARAMS class BRDITEMS_PLOTTER : public PCB_PLOT_PARAMS
{ {
public: public:
BRDITEMS_PLOTTER( PLOTTER* aPlotter, BOARD* aBoard, const PCB_PLOT_PARAMS& aPlotOpts ) BRDITEMS_PLOTTER( PLOTTER* aPlotter, BOARD* aBoard, const PCB_PLOT_PARAMS& aPlotOpts ) :
: PCB_PLOT_PARAMS( aPlotOpts ) PCB_PLOT_PARAMS( aPlotOpts ),
{ m_plotter( aPlotter ),
m_plotter = aPlotter; m_board( aBoard )
m_board = aBoard; { }
m_maxError = aBoard->GetDesignSettings().m_MaxError;
}
/** /**
* @return a 'width adjustment' for the postscript engine * @return a 'width adjustment' for the postscript engine
@ -79,20 +77,13 @@ public:
// Basic functions to plot a board item // Basic functions to plot a board item
void SetLayerSet( LSET aLayerMask ) { m_layerMask = aLayerMask; } void SetLayerSet( LSET aLayerMask ) { m_layerMask = aLayerMask; }
void PlotFootprintGraphicItems( const FOOTPRINT* aFootprint ); void PlotFootprintGraphicItems( const FOOTPRINT* aFootprint );
void PlotFootprintTextItem( const PCB_TEXT* aText, const COLOR4D& aColor );
/*
* Reference, Value, and other fields are plotted only if the corresponding option is enabled.
* Invisible text fields are plotted only if PlotInvisibleText option is set.
*/
void PlotFootprintTextItems( const FOOTPRINT* aFootprint ); void PlotFootprintTextItems( const FOOTPRINT* aFootprint );
void PlotDimension( const PCB_DIMENSION_BASE* aDim ); void PlotDimension( const PCB_DIMENSION_BASE* aDim );
void PlotPcbTarget( const PCB_TARGET* aMire ); void PlotPcbTarget( const PCB_TARGET* aMire );
void PlotFilledAreas( const ZONE* aZone, PCB_LAYER_ID aLayer, void PlotZones( const ZONE* aZone, PCB_LAYER_ID aLayer, const SHAPE_POLY_SET& aPolysList );
const SHAPE_POLY_SET& aPolysList ); void PlotText( const EDA_TEXT* aText, PCB_LAYER_ID aLayer, bool aIsKnockout );
void PlotPcbText( const EDA_TEXT* aText, PCB_LAYER_ID aLayer, bool aIsKnockout ); void PlotShape( const PCB_SHAPE* aShape );
void PlotPcbShape( const PCB_SHAPE* aShape );
/** /**
* Plot a pad. * Plot a pad.
@ -105,8 +96,7 @@ public:
/** /**
* Plot items like text and graphics but not tracks and footprints. * Plot items like text and graphics but not tracks and footprints.
*/ */
void PlotBoardGraphicItems(); void PlotBoardGraphicItem( const BOARD_ITEM* item );
void PlotPcbGraphicItem( const BOARD_ITEM* item );
/** /**
* Draw a drill mark for pads and vias. * Draw a drill mark for pads and vias.
@ -136,10 +126,9 @@ private:
const VECTOR2I& aDrillSize, const VECTOR2I& aPadSize, const VECTOR2I& aDrillSize, const VECTOR2I& aPadSize,
const EDA_ANGLE& aOrientation, int aSmallDrill ); const EDA_ANGLE& aOrientation, int aSmallDrill );
PLOTTER* m_plotter; PLOTTER* m_plotter;
BOARD* m_board; BOARD* m_board;
int m_maxError; // For use when approximating shapes as polygons LSET m_layerMask;
LSET m_layerMask;
}; };

View File

@ -284,7 +284,8 @@ void PlotStandardLayer( BOARD* aBoard, PLOTTER* aPlotter, LSET aLayerMask,
bool sketchPads = ( onFrontFab || onBackFab ) && aPlotOpt.GetSketchPadsOnFabLayers(); bool sketchPads = ( onFrontFab || onBackFab ) && aPlotOpt.GetSketchPadsOnFabLayers();
// Plot edge layer and graphic items // Plot edge layer and graphic items
itemplotter.PlotBoardGraphicItems(); for( const BOARD_ITEM* item : aBoard->Drawings() )
itemplotter.PlotBoardGraphicItem( item );
// Draw footprint texts: // Draw footprint texts:
for( const FOOTPRINT* footprint : aBoard->Footprints() ) for( const FOOTPRINT* footprint : aBoard->Footprints() )
@ -376,7 +377,9 @@ void PlotStandardLayer( BOARD* aBoard, PLOTTER* aPlotter, LSET aLayerMask,
// Note: a custom pad can have its pad anchor with size = 0 // Note: a custom pad can have its pad anchor with size = 0
if( pad->GetShape() != PAD_SHAPE::CUSTOM if( pad->GetShape() != PAD_SHAPE::CUSTOM
&& ( padPlotsSize.x <= 0 || padPlotsSize.y <= 0 ) ) && ( padPlotsSize.x <= 0 || padPlotsSize.y <= 0 ) )
{
continue; continue;
}
switch( pad->GetShape() ) switch( pad->GetShape() )
{ {
@ -689,13 +692,13 @@ void PlotStandardLayer( BOARD* aBoard, PLOTTER* aPlotter, LSET aLayerMask,
} }
} }
itemplotter.PlotFilledAreas( zone, layer, mainArea ); itemplotter.PlotZones( zone, layer, mainArea );
if( !islands.IsEmpty() ) if( !islands.IsEmpty() )
{ {
ZONE dummy( *zone ); ZONE dummy( *zone );
dummy.SetNet( &nonet ); dummy.SetNet( &nonet );
itemplotter.PlotFilledAreas( &dummy, layer, islands ); itemplotter.PlotZones( &dummy, layer, islands );
} }
} }
} }
@ -893,7 +896,7 @@ void PlotSolderMaskLayer( BOARD *aBoard, PLOTTER* aPlotter, LSET aLayerMask,
else if( item->IsOnLayer( Edge_Cuts ) ) else if( item->IsOnLayer( Edge_Cuts ) )
{ {
if( item->Type() == PCB_SHAPE_T ) if( item->Type() == PCB_SHAPE_T )
itemplotter.PlotPcbShape( static_cast<const PCB_SHAPE*>( item ) ); itemplotter.PlotShape( static_cast<const PCB_SHAPE*>( item ) );
} }
} }
} }
@ -951,7 +954,7 @@ void PlotSolderMaskLayer( BOARD *aBoard, PLOTTER* aPlotter, LSET aLayerMask,
} }
else if( item->IsOnLayer( Edge_Cuts ) ) else if( item->IsOnLayer( Edge_Cuts ) )
{ {
itemplotter.PlotPcbGraphicItem( item ); itemplotter.PlotBoardGraphicItem( item );
} }
} }
@ -989,7 +992,7 @@ void PlotSolderMaskLayer( BOARD *aBoard, PLOTTER* aPlotter, LSET aLayerMask,
areas.BooleanAdd( initialPolys, SHAPE_POLY_SET::PM_FAST ); areas.BooleanAdd( initialPolys, SHAPE_POLY_SET::PM_FAST );
areas.Fracture( SHAPE_POLY_SET::PM_STRICTLY_SIMPLE ); areas.Fracture( SHAPE_POLY_SET::PM_STRICTLY_SIMPLE );
itemplotter.PlotFilledAreas( &zone, layer, areas ); itemplotter.PlotZones( &zone, layer, areas );
} }

View File

@ -24,7 +24,6 @@
#include <algorithm> // for min #include <algorithm> // for min
#include <bitset> // for bitset, operator&, __bi... #include <bitset> // for bitset, operator&, __bi...
#include <math.h> // for abs #include <math.h> // for abs
#include <stddef.h> // for NULL, size_t
#include <geometry/seg.h> // for SEG #include <geometry/seg.h> // for SEG
#include <geometry/shape_circle.h> #include <geometry/shape_circle.h>
@ -37,20 +36,15 @@
#include <math/vector2d.h> // for VECTOR2I #include <math/vector2d.h> // for VECTOR2I
#include <plotters/plotter_gerber.h> #include <plotters/plotter_gerber.h>
#include <trigo.h> #include <trigo.h>
#include <callback_gal.h>
#include <board_design_settings.h> // for BOARD_DESIGN_SETTINGS
#include <core/typeinfo.h> // for dyn_cast, PCB_DIMENSION_T #include <core/typeinfo.h> // for dyn_cast, PCB_DIMENSION_T
#include <gbr_metadata.h> #include <gbr_metadata.h>
#include <gbr_netlist_metadata.h> // for GBR_NETLIST_METADATA #include <gbr_netlist_metadata.h> // for GBR_NETLIST_METADATA
#include <layer_ids.h> // for LSET, IsCopperLayer #include <layer_ids.h> // for LSET, IsCopperLayer
#include <pad_shapes.h> // for PAD_ATTRIB::NPTH
#include <pcbplot.h> #include <pcbplot.h>
#include <pcb_plot_params.h> // for PCB_PLOT_PARAMS, PCB_PL... #include <pcb_plot_params.h> // for PCB_PLOT_PARAMS, PCB_PL...
#include <advanced_config.h> #include <advanced_config.h>
#include <board.h>
#include <board_item.h> // for BOARD_ITEM, S_CIRCLE
#include <pcb_dimension.h> #include <pcb_dimension.h>
#include <pcb_shape.h> #include <pcb_shape.h>
#include <footprint.h> #include <footprint.h>
@ -68,8 +62,7 @@ COLOR4D BRDITEMS_PLOTTER::getColor( int aLayer ) const
{ {
COLOR4D color = ColorSettings()->GetColor( aLayer ); COLOR4D color = ColorSettings()->GetColor( aLayer );
// A hack to avoid plotting a white item in white color, expecting the paper // A hack to avoid plotting a white item in white color on white paper
// is also white: use a non white color:
if( color == COLOR4D::WHITE ) if( color == COLOR4D::WHITE )
color = COLOR4D( LIGHTGRAY ); color = COLOR4D( LIGHTGRAY );
@ -80,7 +73,7 @@ COLOR4D BRDITEMS_PLOTTER::getColor( int aLayer ) const
void BRDITEMS_PLOTTER::PlotPad( const PAD* aPad, const COLOR4D& aColor, OUTLINE_MODE aPlotMode ) void BRDITEMS_PLOTTER::PlotPad( const PAD* aPad, const COLOR4D& aColor, OUTLINE_MODE aPlotMode )
{ {
VECTOR2I shape_pos = aPad->ShapePos(); VECTOR2I shape_pos = aPad->ShapePos();
GBR_METADATA gbr_metadata; GBR_METADATA metadata;
bool plotOnCopperLayer = ( m_layerMask & LSET::AllCuMask() ).any(); bool plotOnCopperLayer = ( m_layerMask & LSET::AllCuMask() ).any();
bool plotOnExternalCopperLayer = ( m_layerMask & LSET::ExternalCuMask() ).any(); bool plotOnExternalCopperLayer = ( m_layerMask & LSET::ExternalCuMask() ).any();
@ -90,33 +83,33 @@ void BRDITEMS_PLOTTER::PlotPad( const PAD* aPad, const COLOR4D& aColor, OUTLINE_
// Not yet in use. // Not yet in use.
// bool isPadOnBoardTechLayers = ( aPad->GetLayerSet() & LSET::AllBoardTechMask() ).any(); // bool isPadOnBoardTechLayers = ( aPad->GetLayerSet() & LSET::AllBoardTechMask() ).any();
gbr_metadata.SetCmpReference( aPad->GetParent()->GetReference() ); metadata.SetCmpReference( aPad->GetParent()->GetReference() );
if( plotOnCopperLayer ) if( plotOnCopperLayer )
{ {
gbr_metadata.SetNetAttribType( GBR_NETINFO_ALL ); metadata.SetNetAttribType( GBR_NETINFO_ALL );
gbr_metadata.SetCopper( true ); metadata.SetCopper( true );
// Gives a default attribute, for instance for pads used as tracks in net ties: // Gives a default attribute, for instance for pads used as tracks in net ties:
// Connector pads and SMD pads are on external layers // Connector pads and SMD pads are on external layers
// if on internal layers, they are certainly used as net tie // if on internal layers, they are certainly used as net tie
// and are similar to tracks: just conductor items // and are similar to tracks: just conductor items
gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CONDUCTOR ); metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CONDUCTOR );
const bool useUTF8 = false; const bool useUTF8 = false;
const bool useQuoting = false; const bool useQuoting = false;
gbr_metadata.SetPadName( aPad->GetNumber(), useUTF8, useQuoting ); metadata.SetPadName( aPad->GetNumber(), useUTF8, useQuoting );
if( !aPad->GetNumber().IsEmpty() ) if( !aPad->GetNumber().IsEmpty() )
gbr_metadata.SetPadPinFunction( aPad->GetPinFunction(), useUTF8, useQuoting ); metadata.SetPadPinFunction( aPad->GetPinFunction(), useUTF8, useQuoting );
gbr_metadata.SetNetName( aPad->GetNetname() ); metadata.SetNetName( aPad->GetNetname() );
// Some pads are mechanical pads ( through hole or smd ) // Some pads are mechanical pads ( through hole or smd )
// when this is the case, they have no pad name and/or are not plated. // when this is the case, they have no pad name and/or are not plated.
// In this case gerber files have slightly different attributes. // In this case gerber files have slightly different attributes.
if( aPad->GetAttribute() == PAD_ATTRIB::NPTH || aPad->GetNumber().IsEmpty() ) if( aPad->GetAttribute() == PAD_ATTRIB::NPTH || aPad->GetNumber().IsEmpty() )
gbr_metadata.m_NetlistMetadata.m_NotInNet = true; metadata.m_NetlistMetadata.m_NotInNet = true;
if( !plotOnExternalCopperLayer ) if( !plotOnExternalCopperLayer )
{ {
@ -126,7 +119,7 @@ void BRDITEMS_PLOTTER::PlotPad( const PAD* aPad, const COLOR4D& aColor, OUTLINE_
// Currently, Pcbnew does not handle embedded component, so we disable the .P // Currently, Pcbnew does not handle embedded component, so we disable the .P
// attribute on internal layers // attribute on internal layers
// Note the Gerber doc is not really clear about through holes pads about the .P // Note the Gerber doc is not really clear about through holes pads about the .P
gbr_metadata.SetNetAttribType( GBR_NETLIST_METADATA::GBR_NETINFO_NET | metadata.SetNetAttribType( GBR_NETLIST_METADATA::GBR_NETINFO_NET |
GBR_NETLIST_METADATA::GBR_NETINFO_CMP ); GBR_NETLIST_METADATA::GBR_NETINFO_CMP );
} }
@ -139,25 +132,22 @@ void BRDITEMS_PLOTTER::PlotPad( const PAD* aPad, const COLOR4D& aColor, OUTLINE_
switch( aPad->GetAttribute() ) switch( aPad->GetAttribute() )
{ {
case PAD_ATTRIB::NPTH: // Mechanical pad through hole case PAD_ATTRIB::NPTH: // Mechanical pad through hole
gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_WASHERPAD ); metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_WASHERPAD );
break; break;
case PAD_ATTRIB::PTH : // Pad through hole, a hole is also expected case PAD_ATTRIB::PTH : // Pad through hole, a hole is also expected
gbr_metadata.SetApertureAttrib( metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_COMPONENTPAD );
GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_COMPONENTPAD );
break; break;
case PAD_ATTRIB::CONN: // Connector pads, no solder paste but with solder mask. case PAD_ATTRIB::CONN: // Connector pads, no solder paste but with solder mask.
if( plotOnExternalCopperLayer ) if( plotOnExternalCopperLayer )
gbr_metadata.SetApertureAttrib( metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CONNECTORPAD );
GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CONNECTORPAD );
break; break;
case PAD_ATTRIB::SMD: // SMD pads (on external copper layer only) case PAD_ATTRIB::SMD: // SMD pads (on external copper layer only)
// with solder paste and mask // with solder paste and mask
if( plotOnExternalCopperLayer ) if( plotOnExternalCopperLayer )
gbr_metadata.SetApertureAttrib( metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_SMDPAD_CUDEF );
GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_SMDPAD_CUDEF );
break; break;
} }
@ -167,34 +157,28 @@ void BRDITEMS_PLOTTER::PlotPad( const PAD* aPad, const COLOR4D& aColor, OUTLINE_
{ {
case PAD_PROP::BGA: // Only applicable to outer layers case PAD_PROP::BGA: // Only applicable to outer layers
if( plotOnExternalCopperLayer ) if( plotOnExternalCopperLayer )
gbr_metadata.SetApertureAttrib( metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_BGAPAD_CUDEF );
GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_BGAPAD_CUDEF );
break; break;
case PAD_PROP::FIDUCIAL_GLBL: case PAD_PROP::FIDUCIAL_GLBL:
gbr_metadata.SetApertureAttrib( metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_FIDUCIAL_GLBL );
GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_FIDUCIAL_GLBL );
break; break;
case PAD_PROP::FIDUCIAL_LOCAL: case PAD_PROP::FIDUCIAL_LOCAL:
gbr_metadata.SetApertureAttrib( metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_FIDUCIAL_LOCAL );
GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_FIDUCIAL_LOCAL );
break; break;
case PAD_PROP::TESTPOINT: // Only applicable to outer layers case PAD_PROP::TESTPOINT: // Only applicable to outer layers
if( plotOnExternalCopperLayer ) if( plotOnExternalCopperLayer )
gbr_metadata.SetApertureAttrib( metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_TESTPOINT );
GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_TESTPOINT );
break; break;
case PAD_PROP::HEATSINK: case PAD_PROP::HEATSINK:
gbr_metadata.SetApertureAttrib( metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_HEATSINKPAD );
GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_HEATSINKPAD );
break; break;
case PAD_PROP::CASTELLATED: case PAD_PROP::CASTELLATED:
gbr_metadata.SetApertureAttrib( metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CASTELLATEDPAD );
GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CASTELLATEDPAD );
break; break;
case PAD_PROP::NONE: case PAD_PROP::NONE:
@ -203,11 +187,11 @@ void BRDITEMS_PLOTTER::PlotPad( const PAD* aPad, const COLOR4D& aColor, OUTLINE_
// Ensure NPTH pads have *always* the GBR_APERTURE_ATTRIB_WASHERPAD attribute // Ensure NPTH pads have *always* the GBR_APERTURE_ATTRIB_WASHERPAD attribute
if( aPad->GetAttribute() == PAD_ATTRIB::NPTH ) if( aPad->GetAttribute() == PAD_ATTRIB::NPTH )
gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_WASHERPAD ); metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_WASHERPAD );
} }
else else
{ {
gbr_metadata.SetNetAttribType( GBR_NETLIST_METADATA::GBR_NETINFO_CMP ); metadata.SetNetAttribType( GBR_NETLIST_METADATA::GBR_NETINFO_CMP );
} }
// Set plot color (change WHITE to LIGHTGRAY because // Set plot color (change WHITE to LIGHTGRAY because
@ -215,27 +199,27 @@ void BRDITEMS_PLOTTER::PlotPad( const PAD* aPad, const COLOR4D& aColor, OUTLINE_
m_plotter->SetColor( aColor != WHITE ? aColor : LIGHTGRAY); m_plotter->SetColor( aColor != WHITE ? aColor : LIGHTGRAY);
if( aPlotMode == SKETCH ) if( aPlotMode == SKETCH )
m_plotter->SetCurrentLineWidth( GetSketchPadLineWidth(), &gbr_metadata ); m_plotter->SetCurrentLineWidth( GetSketchPadLineWidth(), &metadata );
switch( aPad->GetShape() ) switch( aPad->GetShape() )
{ {
case PAD_SHAPE::CIRCLE: case PAD_SHAPE::CIRCLE:
m_plotter->FlashPadCircle( shape_pos, aPad->GetSize().x, aPlotMode, &gbr_metadata ); m_plotter->FlashPadCircle( shape_pos, aPad->GetSize().x, aPlotMode, &metadata );
break; break;
case PAD_SHAPE::OVAL: case PAD_SHAPE::OVAL:
m_plotter->FlashPadOval( shape_pos, aPad->GetSize(), aPad->GetOrientation(), aPlotMode, m_plotter->FlashPadOval( shape_pos, aPad->GetSize(), aPad->GetOrientation(), aPlotMode,
&gbr_metadata ); &metadata );
break; break;
case PAD_SHAPE::RECTANGLE: case PAD_SHAPE::RECTANGLE:
m_plotter->FlashPadRect( shape_pos, aPad->GetSize(), aPad->GetOrientation(), aPlotMode, m_plotter->FlashPadRect( shape_pos, aPad->GetSize(), aPad->GetOrientation(), aPlotMode,
&gbr_metadata ); &metadata );
break; break;
case PAD_SHAPE::ROUNDRECT: case PAD_SHAPE::ROUNDRECT:
m_plotter->FlashPadRoundRect( shape_pos, aPad->GetSize(), aPad->GetRoundRectCornerRadius(), m_plotter->FlashPadRoundRect( shape_pos, aPad->GetSize(), aPad->GetRoundRectCornerRadius(),
aPad->GetOrientation(), aPlotMode, &gbr_metadata ); aPad->GetOrientation(), aPlotMode, &metadata );
break; break;
case PAD_SHAPE::TRAPEZOID: case PAD_SHAPE::TRAPEZOID:
@ -254,8 +238,7 @@ void BRDITEMS_PLOTTER::PlotPad( const PAD* aPad, const COLOR4D& aColor, OUTLINE_
coord[2] = 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 ); coord[3] = VECTOR2I( -half_size.x + trap_delta.y, -half_size.y - trap_delta.x );
m_plotter->FlashPadTrapez( shape_pos, coord, aPad->GetOrientation(), aPlotMode, m_plotter->FlashPadTrapez( shape_pos, coord, aPad->GetOrientation(), aPlotMode, &metadata );
&gbr_metadata );
} }
break; break;
@ -268,8 +251,7 @@ void BRDITEMS_PLOTTER::PlotPad( const PAD* aPad, const COLOR4D& aColor, OUTLINE_
aPad->GetRoundRectCornerRadius(), aPad->GetRoundRectCornerRadius(),
aPad->GetChamferRectRatio(), aPad->GetChamferRectRatio(),
aPad->GetChamferPositions(), aPad->GetChamferPositions(),
aPad->GetOrientation(), aPlotMode, aPad->GetOrientation(), aPlotMode, &metadata );
&gbr_metadata );
break; break;
} }
@ -283,7 +265,7 @@ void BRDITEMS_PLOTTER::PlotPad( const PAD* aPad, const COLOR4D& aColor, OUTLINE_
if( polygons->OutlineCount() ) if( polygons->OutlineCount() )
{ {
m_plotter->FlashPadCustom( shape_pos, aPad->GetSize(), aPad->GetOrientation(), m_plotter->FlashPadCustom( shape_pos, aPad->GetSize(), aPad->GetOrientation(),
polygons.get(), aPlotMode, &gbr_metadata ); polygons.get(), aPlotMode, &metadata );
} }
} }
break; break;
@ -300,7 +282,7 @@ void BRDITEMS_PLOTTER::PlotFootprintTextItems( const FOOTPRINT* aFootprint )
if( GetPlotReference() && m_layerMask[textLayer] if( GetPlotReference() && m_layerMask[textLayer]
&& ( textItem->IsVisible() || GetPlotInvisibleText() ) ) && ( textItem->IsVisible() || GetPlotInvisibleText() ) )
{ {
PlotPcbText( textItem, textLayer, textItem->IsKnockout() ); PlotText( textItem, textLayer, textItem->IsKnockout() );
} }
textItem = &aFootprint->Value(); textItem = &aFootprint->Value();
@ -309,7 +291,7 @@ void BRDITEMS_PLOTTER::PlotFootprintTextItems( const FOOTPRINT* aFootprint )
if( GetPlotValue() && m_layerMask[textLayer] if( GetPlotValue() && m_layerMask[textLayer]
&& ( textItem->IsVisible() || GetPlotInvisibleText() ) ) && ( textItem->IsVisible() || GetPlotInvisibleText() ) )
{ {
PlotPcbText( textItem, textLayer, textItem->IsKnockout() ); PlotText( textItem, textLayer, textItem->IsKnockout() );
} }
for( const BOARD_ITEM* item : aFootprint->GraphicalItems() ) for( const BOARD_ITEM* item : aFootprint->GraphicalItems() )
@ -336,31 +318,31 @@ void BRDITEMS_PLOTTER::PlotFootprintTextItems( const FOOTPRINT* aFootprint )
if( textItem->GetText() == wxT( "${VALUE}" ) && !GetPlotValue() ) if( textItem->GetText() == wxT( "${VALUE}" ) && !GetPlotValue() )
continue; continue;
PlotPcbText( textItem, textLayer, textItem->IsKnockout() ); PlotText( textItem, textLayer, textItem->IsKnockout() );
} }
} }
void BRDITEMS_PLOTTER::PlotPcbGraphicItem( const BOARD_ITEM* item ) void BRDITEMS_PLOTTER::PlotBoardGraphicItem( const BOARD_ITEM* item )
{ {
switch( item->Type() ) switch( item->Type() )
{ {
case PCB_SHAPE_T: case PCB_SHAPE_T:
PlotPcbShape( static_cast<const PCB_SHAPE*>( item ) ); PlotShape( static_cast<const PCB_SHAPE*>( item ) );
break; break;
case PCB_TEXT_T: case PCB_TEXT_T:
{ {
const PCB_TEXT* text = static_cast<const PCB_TEXT*>( item ); const PCB_TEXT* text = static_cast<const PCB_TEXT*>( item );
PlotPcbText( text, text->GetLayer(), text->IsKnockout() ); PlotText( text, text->GetLayer(), text->IsKnockout() );
break; break;
} }
case PCB_TEXTBOX_T: case PCB_TEXTBOX_T:
{ {
const PCB_TEXTBOX* textbox = static_cast<const PCB_TEXTBOX*>( item ); const PCB_TEXTBOX* textbox = static_cast<const PCB_TEXTBOX*>( item );
PlotPcbText( textbox, textbox->GetLayer(), textbox->IsKnockout() ); PlotText( textbox, textbox->GetLayer(), textbox->IsKnockout() );
PlotPcbShape( textbox ); PlotShape( textbox );
break; break;
} }
@ -382,30 +364,23 @@ void BRDITEMS_PLOTTER::PlotPcbGraphicItem( const BOARD_ITEM* item )
} }
void BRDITEMS_PLOTTER::PlotBoardGraphicItems()
{
for( const BOARD_ITEM* item : m_board->Drawings() )
PlotPcbGraphicItem( item );
}
void BRDITEMS_PLOTTER::PlotDimension( const PCB_DIMENSION_BASE* aDim ) void BRDITEMS_PLOTTER::PlotDimension( const PCB_DIMENSION_BASE* aDim )
{ {
if( !m_layerMask[aDim->GetLayer()] ) if( !m_layerMask[aDim->GetLayer()] )
return; return;
PCB_SHAPE draw;
draw.SetStroke( STROKE_PARAMS( aDim->GetLineThickness(), PLOT_DASH_TYPE::SOLID ) );
draw.SetLayer( aDim->GetLayer() );
COLOR4D color = ColorSettings()->GetColor( aDim->GetLayer() ); COLOR4D color = ColorSettings()->GetColor( aDim->GetLayer() );
// Set plot color (change WHITE to LIGHTGRAY because // Set plot color (change WHITE to LIGHTGRAY because
// the white items are not seen on a white paper or screen // the white items are not seen on a white paper or screen
m_plotter->SetColor( color != WHITE ? color : LIGHTGRAY); m_plotter->SetColor( color != WHITE ? color : LIGHTGRAY);
PlotPcbText( aDim, aDim->GetLayer(), false ); PlotText( aDim, aDim->GetLayer(), false );
PCB_SHAPE temp_item;
temp_item.SetStroke( STROKE_PARAMS( aDim->GetLineThickness(), PLOT_DASH_TYPE::SOLID ) );
temp_item.SetLayer( aDim->GetLayer() );
for( const std::shared_ptr<SHAPE>& shape : aDim->GetShapes() ) for( const std::shared_ptr<SHAPE>& shape : aDim->GetShapes() )
{ {
@ -415,11 +390,11 @@ void BRDITEMS_PLOTTER::PlotDimension( const PCB_DIMENSION_BASE* aDim )
{ {
const SEG& seg = static_cast<const SHAPE_SEGMENT*>( shape.get() )->GetSeg(); const SEG& seg = static_cast<const SHAPE_SEGMENT*>( shape.get() )->GetSeg();
draw.SetShape( SHAPE_T::SEGMENT ); temp_item.SetShape( SHAPE_T::SEGMENT );
draw.SetStart( seg.A ); temp_item.SetStart( seg.A );
draw.SetEnd( seg.B ); temp_item.SetEnd( seg.B );
PlotPcbShape( &draw ); PlotShape( &temp_item );
break; break;
} }
@ -428,12 +403,12 @@ void BRDITEMS_PLOTTER::PlotDimension( const PCB_DIMENSION_BASE* aDim )
VECTOR2I start( shape->Centre() ); VECTOR2I start( shape->Centre() );
int radius = static_cast<const SHAPE_CIRCLE*>( shape.get() )->GetRadius(); int radius = static_cast<const SHAPE_CIRCLE*>( shape.get() )->GetRadius();
draw.SetShape( SHAPE_T::CIRCLE ); temp_item.SetShape( SHAPE_T::CIRCLE );
draw.SetFilled( false ); temp_item.SetFilled( false );
draw.SetStart( start ); temp_item.SetStart( start );
draw.SetEnd( VECTOR2I( start.x + radius, start.y ) ); temp_item.SetEnd( VECTOR2I( start.x + radius, start.y ) );
PlotPcbShape( &draw ); PlotShape( &temp_item );
break; break;
} }
@ -453,24 +428,24 @@ void BRDITEMS_PLOTTER::PlotPcbTarget( const PCB_TARGET* aMire )
m_plotter->SetColor( getColor( aMire->GetLayer() ) ); m_plotter->SetColor( getColor( aMire->GetLayer() ) );
PCB_SHAPE draw; PCB_SHAPE temp_item;
draw.SetShape( SHAPE_T::CIRCLE ); temp_item.SetShape( SHAPE_T::CIRCLE );
draw.SetFilled( false ); temp_item.SetFilled( false );
draw.SetStroke( STROKE_PARAMS( aMire->GetWidth(), PLOT_DASH_TYPE::SOLID ) ); temp_item.SetStroke( STROKE_PARAMS( aMire->GetWidth(), PLOT_DASH_TYPE::SOLID ) );
draw.SetLayer( aMire->GetLayer() ); temp_item.SetLayer( aMire->GetLayer() );
draw.SetStart( aMire->GetPosition() ); temp_item.SetStart( aMire->GetPosition() );
radius = aMire->GetSize() / 3; radius = aMire->GetSize() / 3;
if( aMire->GetShape() ) // shape X if( aMire->GetShape() ) // temp_item X
radius = aMire->GetSize() / 2; radius = aMire->GetSize() / 2;
// Draw the circle // Draw the circle
draw.SetEnd( VECTOR2I( draw.GetStart().x + radius, draw.GetStart().y ) ); temp_item.SetEnd( VECTOR2I( temp_item.GetStart().x + radius, temp_item.GetStart().y ) );
PlotPcbShape( &draw ); PlotShape( &temp_item );
draw.SetShape( SHAPE_T::SEGMENT ); temp_item.SetShape( SHAPE_T::SEGMENT );
radius = aMire->GetSize() / 2; radius = aMire->GetSize() / 2;
dx1 = radius; dx1 = radius;
@ -487,14 +462,14 @@ void BRDITEMS_PLOTTER::PlotPcbTarget( const PCB_TARGET* aMire )
VECTOR2I mirePos( aMire->GetPosition() ); VECTOR2I mirePos( aMire->GetPosition() );
// Draw the X or + shape: // Draw the X or + temp_item:
draw.SetStart( VECTOR2I( mirePos.x - dx1, mirePos.y - dy1 ) ); temp_item.SetStart( VECTOR2I( mirePos.x - dx1, mirePos.y - dy1 ) );
draw.SetEnd( VECTOR2I( mirePos.x + dx1, mirePos.y + dy1 ) ); temp_item.SetEnd( VECTOR2I( mirePos.x + dx1, mirePos.y + dy1 ) );
PlotPcbShape( &draw ); PlotShape( &temp_item );
draw.SetStart( VECTOR2I( mirePos.x - dx2, mirePos.y - dy2 ) ); temp_item.SetStart( VECTOR2I( mirePos.x - dx2, mirePos.y - dy2 ) );
draw.SetEnd( VECTOR2I( mirePos.x + dx2, mirePos.y + dy2 ) ); temp_item.SetEnd( VECTOR2I( mirePos.x + dx2, mirePos.y + dy2 ) );
PlotPcbShape( &draw ); PlotShape( &temp_item );
} }
@ -512,7 +487,7 @@ void BRDITEMS_PLOTTER::PlotFootprintGraphicItems( const FOOTPRINT* aFootprint )
const PCB_SHAPE* shape = static_cast<const PCB_SHAPE*>( item ); const PCB_SHAPE* shape = static_cast<const PCB_SHAPE*>( item );
if( m_layerMask[ shape->GetLayer() ] ) if( m_layerMask[ shape->GetLayer() ] )
PlotPcbShape( shape ); PlotShape( shape );
break; break;
} }
@ -523,8 +498,8 @@ void BRDITEMS_PLOTTER::PlotFootprintGraphicItems( const FOOTPRINT* aFootprint )
if( m_layerMask[ textbox->GetLayer() ] ) if( m_layerMask[ textbox->GetLayer() ] )
{ {
PlotPcbText( textbox, textbox->GetLayer(), textbox->IsKnockout() ); PlotText( textbox, textbox->GetLayer(), textbox->IsKnockout() );
PlotPcbShape( textbox ); PlotShape( textbox );
} }
break; break;
@ -556,16 +531,18 @@ void BRDITEMS_PLOTTER::PlotFootprintGraphicItems( const FOOTPRINT* aFootprint )
#include <font/stroke_font.h> #include <font/stroke_font.h>
void BRDITEMS_PLOTTER::PlotPcbText( const EDA_TEXT* aText, PCB_LAYER_ID aLayer, bool aIsKnockout ) void BRDITEMS_PLOTTER::PlotText( const EDA_TEXT* aText, PCB_LAYER_ID aLayer, bool aIsKnockout )
{ {
KIFONT::FONT* font = aText->GetFont(); KIFONT::FONT* font = aText->GetFont();
if( !font ) if( !font )
{ {
font = KIFONT::FONT::GetFont( m_plotter->RenderSettings() wxString defaultFontName; // empty string is the KiCad stroke font
? m_plotter->RenderSettings()->GetDefaultFont()
: wxString( wxEmptyString ), if( m_plotter->RenderSettings() )
aText->IsBold(), aText->IsItalic() ); defaultFontName = m_plotter->RenderSettings()->GetDefaultFont();
font = KIFONT::FONT::GetFont( defaultFontName, aText->IsBold(), aText->IsItalic() );
} }
wxString shownText( aText->GetShownText( true ) ); wxString shownText( aText->GetShownText( true ) );
@ -596,9 +573,10 @@ void BRDITEMS_PLOTTER::PlotPcbText( const EDA_TEXT* aText, PCB_LAYER_ID aLayer,
if( aIsKnockout ) if( aIsKnockout )
{ {
const PCB_TEXT* text = static_cast<const PCB_TEXT*>( aText ); const PCB_TEXT* text = static_cast<const PCB_TEXT*>( aText );
SHAPE_POLY_SET finalPoly; SHAPE_POLY_SET finalPoly;
text->TransformTextToPolySet( finalPoly, 0, m_maxError, ERROR_INSIDE ); text->TransformTextToPolySet( finalPoly, 0, m_board->GetDesignSettings().m_MaxError,
ERROR_INSIDE );
finalPoly.Fracture( SHAPE_POLY_SET::PM_FAST ); finalPoly.Fracture( SHAPE_POLY_SET::PM_FAST );
for( int ii = 0; ii < finalPoly.OutlineCount(); ++ii ) for( int ii = 0; ii < finalPoly.OutlineCount(); ++ii )
@ -626,10 +604,10 @@ void BRDITEMS_PLOTTER::PlotPcbText( const EDA_TEXT* aText, PCB_LAYER_ID aLayer,
} }
void BRDITEMS_PLOTTER::PlotFilledAreas( const ZONE* aZone, PCB_LAYER_ID aLayer, void BRDITEMS_PLOTTER::PlotZones( const ZONE* aZone, PCB_LAYER_ID aLayer,
const SHAPE_POLY_SET& polysList ) const SHAPE_POLY_SET& aPolysList )
{ {
if( polysList.IsEmpty() ) if( aPolysList.IsEmpty() )
return; return;
GBR_METADATA gbr_metadata; GBR_METADATA gbr_metadata;
@ -644,8 +622,7 @@ void BRDITEMS_PLOTTER::PlotFilledAreas( const ZONE* aZone, PCB_LAYER_ID aLayer,
// be set as conductor // be set as conductor
if( aZone->GetNetname().IsEmpty() ) if( aZone->GetNetname().IsEmpty() )
{ {
gbr_metadata.SetApertureAttrib( gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_NONCONDUCTOR );
GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_NONCONDUCTOR );
} }
else else
{ {
@ -662,9 +639,9 @@ void BRDITEMS_PLOTTER::PlotFilledAreas( const ZONE* aZone, PCB_LAYER_ID aLayer,
* In non filled mode the outline is plotted, but not the filling items * In non filled mode the outline is plotted, but not the filling items
*/ */
for( int idx = 0; idx < polysList.OutlineCount(); ++idx ) for( int idx = 0; idx < aPolysList.OutlineCount(); ++idx )
{ {
const SHAPE_LINE_CHAIN& outline = polysList.Outline( idx ); const SHAPE_LINE_CHAIN& outline = aPolysList.Outline( idx );
// Plot the current filled area (as region for Gerber plotter to manage attributes) // Plot the current filled area (as region for Gerber plotter to manage attributes)
if( GetPlotMode() == FILLED ) if( GetPlotMode() == FILLED )
@ -689,7 +666,7 @@ void BRDITEMS_PLOTTER::PlotFilledAreas( const ZONE* aZone, PCB_LAYER_ID aLayer,
} }
void BRDITEMS_PLOTTER::PlotPcbShape( const PCB_SHAPE* aShape ) void BRDITEMS_PLOTTER::PlotShape( const PCB_SHAPE* aShape )
{ {
if( !m_layerMask[aShape->GetLayer()] ) if( !m_layerMask[aShape->GetLayer()] )
return; return;
@ -844,8 +821,7 @@ void BRDITEMS_PLOTTER::PlotPcbShape( const PCB_SHAPE* aShape )
poly.Append( pts[0] ); // Close polygon. poly.Append( pts[0] ); // Close polygon.
FILL_T fill_mode = aShape->IsFilled() ? FILL_T::FILLED_SHAPE FILL_T fill_mode = aShape->IsFilled() ? FILL_T::FILLED_SHAPE : FILL_T::NO_FILL;
: FILL_T::NO_FILL;
if( m_plotter->GetPlotterType() == PLOT_FORMAT::GERBER ) if( m_plotter->GetPlotterType() == PLOT_FORMAT::GERBER )
{ {