You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1367 lines
53 KiB

14 years ago
17 years ago
17 years ago
4 years ago
4 years ago
4 years ago
4 years ago
17 years ago
14 years ago
4 years ago
4 years ago
4 years ago
4 years ago
14 years ago
14 years ago
17 years ago
Clean up arc/circle polygonization. 1) For a while now we've been using a calculated seg count from a given maxError, and a correction factor to push the radius out so that all the error is outside the arc/circle. However, the second calculation (which pre-dates the first) is pretty much just the inverse of the first (and yields nothing more than maxError back). This is particularly sub-optimal given the cost of trig functions. 2) There are a lot of old optimizations to reduce segcounts in certain situations, someting that our error-based calculation compensates for anyway. (Smaller radii need fewer segments to meet the maxError condition.) But perhaps more importantly we now surface maxError in the UI and we don't really want to call it "Max deviation except when it's not". 3) We were also clamping the segCount twice: once in the calculation routine and once in most of it's callers. Furthermore, the caller clamping was inconsistent (both in being done and in the clamping value). We now clamp only in the calculation routine. 4) There's no reason to use the correction factors in the 3Dviewer; it's just a visualization and whether the polygonization error is inside or outside the shape isn't really material. 5) The arc-correction-disabling stuff (used for solder mask layer) was somewhat fragile in that it depended on the caller to turn it back on afterwards. It's now only exposed as a RAII object which automatically cleans up when it goes out of scope. 6) There were also bugs in a couple of the polygonization routines where we'd accumulate round-off error in adding up the segments and end up with an overly long last segment (which of course would voilate the error max). This was the cause of the linked bug and also some issues with vias that we had fudged in the past with extra clearance. Fixes https://gitlab.com/kicad/code/kicad/issues/5567
5 years ago
Clean up arc/circle polygonization. 1) For a while now we've been using a calculated seg count from a given maxError, and a correction factor to push the radius out so that all the error is outside the arc/circle. However, the second calculation (which pre-dates the first) is pretty much just the inverse of the first (and yields nothing more than maxError back). This is particularly sub-optimal given the cost of trig functions. 2) There are a lot of old optimizations to reduce segcounts in certain situations, someting that our error-based calculation compensates for anyway. (Smaller radii need fewer segments to meet the maxError condition.) But perhaps more importantly we now surface maxError in the UI and we don't really want to call it "Max deviation except when it's not". 3) We were also clamping the segCount twice: once in the calculation routine and once in most of it's callers. Furthermore, the caller clamping was inconsistent (both in being done and in the clamping value). We now clamp only in the calculation routine. 4) There's no reason to use the correction factors in the 3Dviewer; it's just a visualization and whether the polygonization error is inside or outside the shape isn't really material. 5) The arc-correction-disabling stuff (used for solder mask layer) was somewhat fragile in that it depended on the caller to turn it back on afterwards. It's now only exposed as a RAII object which automatically cleans up when it goes out of scope. 6) There were also bugs in a couple of the polygonization routines where we'd accumulate round-off error in adding up the segments and end up with an overly long last segment (which of course would voilate the error max). This was the cause of the linked bug and also some issues with vias that we had fudged in the past with extra clearance. Fixes https://gitlab.com/kicad/code/kicad/issues/5567
5 years ago
Clean up arc/circle polygonization. 1) For a while now we've been using a calculated seg count from a given maxError, and a correction factor to push the radius out so that all the error is outside the arc/circle. However, the second calculation (which pre-dates the first) is pretty much just the inverse of the first (and yields nothing more than maxError back). This is particularly sub-optimal given the cost of trig functions. 2) There are a lot of old optimizations to reduce segcounts in certain situations, someting that our error-based calculation compensates for anyway. (Smaller radii need fewer segments to meet the maxError condition.) But perhaps more importantly we now surface maxError in the UI and we don't really want to call it "Max deviation except when it's not". 3) We were also clamping the segCount twice: once in the calculation routine and once in most of it's callers. Furthermore, the caller clamping was inconsistent (both in being done and in the clamping value). We now clamp only in the calculation routine. 4) There's no reason to use the correction factors in the 3Dviewer; it's just a visualization and whether the polygonization error is inside or outside the shape isn't really material. 5) The arc-correction-disabling stuff (used for solder mask layer) was somewhat fragile in that it depended on the caller to turn it back on afterwards. It's now only exposed as a RAII object which automatically cleans up when it goes out of scope. 6) There were also bugs in a couple of the polygonization routines where we'd accumulate round-off error in adding up the segments and end up with an overly long last segment (which of course would voilate the error max). This was the cause of the linked bug and also some issues with vias that we had fudged in the past with extra clearance. Fixes https://gitlab.com/kicad/code/kicad/issues/5567
5 years ago
Clean up arc/circle polygonization. 1) For a while now we've been using a calculated seg count from a given maxError, and a correction factor to push the radius out so that all the error is outside the arc/circle. However, the second calculation (which pre-dates the first) is pretty much just the inverse of the first (and yields nothing more than maxError back). This is particularly sub-optimal given the cost of trig functions. 2) There are a lot of old optimizations to reduce segcounts in certain situations, someting that our error-based calculation compensates for anyway. (Smaller radii need fewer segments to meet the maxError condition.) But perhaps more importantly we now surface maxError in the UI and we don't really want to call it "Max deviation except when it's not". 3) We were also clamping the segCount twice: once in the calculation routine and once in most of it's callers. Furthermore, the caller clamping was inconsistent (both in being done and in the clamping value). We now clamp only in the calculation routine. 4) There's no reason to use the correction factors in the 3Dviewer; it's just a visualization and whether the polygonization error is inside or outside the shape isn't really material. 5) The arc-correction-disabling stuff (used for solder mask layer) was somewhat fragile in that it depended on the caller to turn it back on afterwards. It's now only exposed as a RAII object which automatically cleans up when it goes out of scope. 6) There were also bugs in a couple of the polygonization routines where we'd accumulate round-off error in adding up the segments and end up with an overly long last segment (which of course would voilate the error max). This was the cause of the linked bug and also some issues with vias that we had fudged in the past with extra clearance. Fixes https://gitlab.com/kicad/code/kicad/issues/5567
5 years ago
Clean up arc/circle polygonization. 1) For a while now we've been using a calculated seg count from a given maxError, and a correction factor to push the radius out so that all the error is outside the arc/circle. However, the second calculation (which pre-dates the first) is pretty much just the inverse of the first (and yields nothing more than maxError back). This is particularly sub-optimal given the cost of trig functions. 2) There are a lot of old optimizations to reduce segcounts in certain situations, someting that our error-based calculation compensates for anyway. (Smaller radii need fewer segments to meet the maxError condition.) But perhaps more importantly we now surface maxError in the UI and we don't really want to call it "Max deviation except when it's not". 3) We were also clamping the segCount twice: once in the calculation routine and once in most of it's callers. Furthermore, the caller clamping was inconsistent (both in being done and in the clamping value). We now clamp only in the calculation routine. 4) There's no reason to use the correction factors in the 3Dviewer; it's just a visualization and whether the polygonization error is inside or outside the shape isn't really material. 5) The arc-correction-disabling stuff (used for solder mask layer) was somewhat fragile in that it depended on the caller to turn it back on afterwards. It's now only exposed as a RAII object which automatically cleans up when it goes out of scope. 6) There were also bugs in a couple of the polygonization routines where we'd accumulate round-off error in adding up the segments and end up with an overly long last segment (which of course would voilate the error max). This was the cause of the linked bug and also some issues with vias that we had fudged in the past with extra clearance. Fixes https://gitlab.com/kicad/code/kicad/issues/5567
5 years ago
Clean up arc/circle polygonization. 1) For a while now we've been using a calculated seg count from a given maxError, and a correction factor to push the radius out so that all the error is outside the arc/circle. However, the second calculation (which pre-dates the first) is pretty much just the inverse of the first (and yields nothing more than maxError back). This is particularly sub-optimal given the cost of trig functions. 2) There are a lot of old optimizations to reduce segcounts in certain situations, someting that our error-based calculation compensates for anyway. (Smaller radii need fewer segments to meet the maxError condition.) But perhaps more importantly we now surface maxError in the UI and we don't really want to call it "Max deviation except when it's not". 3) We were also clamping the segCount twice: once in the calculation routine and once in most of it's callers. Furthermore, the caller clamping was inconsistent (both in being done and in the clamping value). We now clamp only in the calculation routine. 4) There's no reason to use the correction factors in the 3Dviewer; it's just a visualization and whether the polygonization error is inside or outside the shape isn't really material. 5) The arc-correction-disabling stuff (used for solder mask layer) was somewhat fragile in that it depended on the caller to turn it back on afterwards. It's now only exposed as a RAII object which automatically cleans up when it goes out of scope. 6) There were also bugs in a couple of the polygonization routines where we'd accumulate round-off error in adding up the segments and end up with an overly long last segment (which of course would voilate the error max). This was the cause of the linked bug and also some issues with vias that we had fudged in the past with extra clearance. Fixes https://gitlab.com/kicad/code/kicad/issues/5567
5 years ago
Clean up arc/circle polygonization. 1) For a while now we've been using a calculated seg count from a given maxError, and a correction factor to push the radius out so that all the error is outside the arc/circle. However, the second calculation (which pre-dates the first) is pretty much just the inverse of the first (and yields nothing more than maxError back). This is particularly sub-optimal given the cost of trig functions. 2) There are a lot of old optimizations to reduce segcounts in certain situations, someting that our error-based calculation compensates for anyway. (Smaller radii need fewer segments to meet the maxError condition.) But perhaps more importantly we now surface maxError in the UI and we don't really want to call it "Max deviation except when it's not". 3) We were also clamping the segCount twice: once in the calculation routine and once in most of it's callers. Furthermore, the caller clamping was inconsistent (both in being done and in the clamping value). We now clamp only in the calculation routine. 4) There's no reason to use the correction factors in the 3Dviewer; it's just a visualization and whether the polygonization error is inside or outside the shape isn't really material. 5) The arc-correction-disabling stuff (used for solder mask layer) was somewhat fragile in that it depended on the caller to turn it back on afterwards. It's now only exposed as a RAII object which automatically cleans up when it goes out of scope. 6) There were also bugs in a couple of the polygonization routines where we'd accumulate round-off error in adding up the segments and end up with an overly long last segment (which of course would voilate the error max). This was the cause of the linked bug and also some issues with vias that we had fudged in the past with extra clearance. Fixes https://gitlab.com/kicad/code/kicad/issues/5567
5 years ago
Clean up arc/circle polygonization. 1) For a while now we've been using a calculated seg count from a given maxError, and a correction factor to push the radius out so that all the error is outside the arc/circle. However, the second calculation (which pre-dates the first) is pretty much just the inverse of the first (and yields nothing more than maxError back). This is particularly sub-optimal given the cost of trig functions. 2) There are a lot of old optimizations to reduce segcounts in certain situations, someting that our error-based calculation compensates for anyway. (Smaller radii need fewer segments to meet the maxError condition.) But perhaps more importantly we now surface maxError in the UI and we don't really want to call it "Max deviation except when it's not". 3) We were also clamping the segCount twice: once in the calculation routine and once in most of it's callers. Furthermore, the caller clamping was inconsistent (both in being done and in the clamping value). We now clamp only in the calculation routine. 4) There's no reason to use the correction factors in the 3Dviewer; it's just a visualization and whether the polygonization error is inside or outside the shape isn't really material. 5) The arc-correction-disabling stuff (used for solder mask layer) was somewhat fragile in that it depended on the caller to turn it back on afterwards. It's now only exposed as a RAII object which automatically cleans up when it goes out of scope. 6) There were also bugs in a couple of the polygonization routines where we'd accumulate round-off error in adding up the segments and end up with an overly long last segment (which of course would voilate the error max). This was the cause of the linked bug and also some issues with vias that we had fudged in the past with extra clearance. Fixes https://gitlab.com/kicad/code/kicad/issues/5567
5 years ago
Clean up arc/circle polygonization. 1) For a while now we've been using a calculated seg count from a given maxError, and a correction factor to push the radius out so that all the error is outside the arc/circle. However, the second calculation (which pre-dates the first) is pretty much just the inverse of the first (and yields nothing more than maxError back). This is particularly sub-optimal given the cost of trig functions. 2) There are a lot of old optimizations to reduce segcounts in certain situations, someting that our error-based calculation compensates for anyway. (Smaller radii need fewer segments to meet the maxError condition.) But perhaps more importantly we now surface maxError in the UI and we don't really want to call it "Max deviation except when it's not". 3) We were also clamping the segCount twice: once in the calculation routine and once in most of it's callers. Furthermore, the caller clamping was inconsistent (both in being done and in the clamping value). We now clamp only in the calculation routine. 4) There's no reason to use the correction factors in the 3Dviewer; it's just a visualization and whether the polygonization error is inside or outside the shape isn't really material. 5) The arc-correction-disabling stuff (used for solder mask layer) was somewhat fragile in that it depended on the caller to turn it back on afterwards. It's now only exposed as a RAII object which automatically cleans up when it goes out of scope. 6) There were also bugs in a couple of the polygonization routines where we'd accumulate round-off error in adding up the segments and end up with an overly long last segment (which of course would voilate the error max). This was the cause of the linked bug and also some issues with vias that we had fudged in the past with extra clearance. Fixes https://gitlab.com/kicad/code/kicad/issues/5567
5 years ago
Clean up arc/circle polygonization. 1) For a while now we've been using a calculated seg count from a given maxError, and a correction factor to push the radius out so that all the error is outside the arc/circle. However, the second calculation (which pre-dates the first) is pretty much just the inverse of the first (and yields nothing more than maxError back). This is particularly sub-optimal given the cost of trig functions. 2) There are a lot of old optimizations to reduce segcounts in certain situations, someting that our error-based calculation compensates for anyway. (Smaller radii need fewer segments to meet the maxError condition.) But perhaps more importantly we now surface maxError in the UI and we don't really want to call it "Max deviation except when it's not". 3) We were also clamping the segCount twice: once in the calculation routine and once in most of it's callers. Furthermore, the caller clamping was inconsistent (both in being done and in the clamping value). We now clamp only in the calculation routine. 4) There's no reason to use the correction factors in the 3Dviewer; it's just a visualization and whether the polygonization error is inside or outside the shape isn't really material. 5) The arc-correction-disabling stuff (used for solder mask layer) was somewhat fragile in that it depended on the caller to turn it back on afterwards. It's now only exposed as a RAII object which automatically cleans up when it goes out of scope. 6) There were also bugs in a couple of the polygonization routines where we'd accumulate round-off error in adding up the segments and end up with an overly long last segment (which of course would voilate the error max). This was the cause of the linked bug and also some issues with vias that we had fudged in the past with extra clearance. Fixes https://gitlab.com/kicad/code/kicad/issues/5567
5 years ago
Clean up arc/circle polygonization. 1) For a while now we've been using a calculated seg count from a given maxError, and a correction factor to push the radius out so that all the error is outside the arc/circle. However, the second calculation (which pre-dates the first) is pretty much just the inverse of the first (and yields nothing more than maxError back). This is particularly sub-optimal given the cost of trig functions. 2) There are a lot of old optimizations to reduce segcounts in certain situations, someting that our error-based calculation compensates for anyway. (Smaller radii need fewer segments to meet the maxError condition.) But perhaps more importantly we now surface maxError in the UI and we don't really want to call it "Max deviation except when it's not". 3) We were also clamping the segCount twice: once in the calculation routine and once in most of it's callers. Furthermore, the caller clamping was inconsistent (both in being done and in the clamping value). We now clamp only in the calculation routine. 4) There's no reason to use the correction factors in the 3Dviewer; it's just a visualization and whether the polygonization error is inside or outside the shape isn't really material. 5) The arc-correction-disabling stuff (used for solder mask layer) was somewhat fragile in that it depended on the caller to turn it back on afterwards. It's now only exposed as a RAII object which automatically cleans up when it goes out of scope. 6) There were also bugs in a couple of the polygonization routines where we'd accumulate round-off error in adding up the segments and end up with an overly long last segment (which of course would voilate the error max). This was the cause of the linked bug and also some issues with vias that we had fudged in the past with extra clearance. Fixes https://gitlab.com/kicad/code/kicad/issues/5567
5 years ago
Clean up arc/circle polygonization. 1) For a while now we've been using a calculated seg count from a given maxError, and a correction factor to push the radius out so that all the error is outside the arc/circle. However, the second calculation (which pre-dates the first) is pretty much just the inverse of the first (and yields nothing more than maxError back). This is particularly sub-optimal given the cost of trig functions. 2) There are a lot of old optimizations to reduce segcounts in certain situations, someting that our error-based calculation compensates for anyway. (Smaller radii need fewer segments to meet the maxError condition.) But perhaps more importantly we now surface maxError in the UI and we don't really want to call it "Max deviation except when it's not". 3) We were also clamping the segCount twice: once in the calculation routine and once in most of it's callers. Furthermore, the caller clamping was inconsistent (both in being done and in the clamping value). We now clamp only in the calculation routine. 4) There's no reason to use the correction factors in the 3Dviewer; it's just a visualization and whether the polygonization error is inside or outside the shape isn't really material. 5) The arc-correction-disabling stuff (used for solder mask layer) was somewhat fragile in that it depended on the caller to turn it back on afterwards. It's now only exposed as a RAII object which automatically cleans up when it goes out of scope. 6) There were also bugs in a couple of the polygonization routines where we'd accumulate round-off error in adding up the segments and end up with an overly long last segment (which of course would voilate the error max). This was the cause of the linked bug and also some issues with vias that we had fudged in the past with extra clearance. Fixes https://gitlab.com/kicad/code/kicad/issues/5567
5 years ago
4 years ago
4 years ago
  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version 2
  9. * of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, you may find one here:
  18. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  19. * or you may search the http://www.gnu.org website for the version 2 license,
  20. * or you may write to the Free Software Foundation, Inc.,
  21. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  22. */
  23. #include <wx/log.h>
  24. #include <eda_item.h>
  25. #include <layer_ids.h>
  26. #include <lset.h>
  27. #include <geometry/geometry_utils.h>
  28. #include <geometry/shape_segment.h>
  29. #include <pcb_base_frame.h>
  30. #include <math/util.h> // for KiROUND
  31. #include <board.h>
  32. #include <footprint.h>
  33. #include <pcb_track.h>
  34. #include <pad.h>
  35. #include <zone.h>
  36. #include <pcb_shape.h>
  37. #include <pcb_target.h>
  38. #include <pcb_dimension.h>
  39. #include <pcbplot.h>
  40. #include <plotters/plotter_dxf.h>
  41. #include <plotters/plotter_hpgl.h>
  42. #include <plotters/plotter_gerber.h>
  43. #include <plotters/plotters_pslike.h>
  44. #include <pcb_painter.h>
  45. #include <gbr_metadata.h>
  46. #include <advanced_config.h>
  47. /*
  48. * Plot a solder mask layer. Solder mask layers have a minimum thickness value and cannot be
  49. * drawn like standard layers, unless the minimum thickness is 0.
  50. */
  51. static void PlotSolderMaskLayer( BOARD *aBoard, PLOTTER* aPlotter, LSET aLayerMask,
  52. const PCB_PLOT_PARAMS& aPlotOpt, int aMinThickness );
  53. void PlotBoardLayers( BOARD* aBoard, PLOTTER* aPlotter, const LSEQ& aLayers,
  54. const PCB_PLOT_PARAMS& aPlotOptions )
  55. {
  56. if( !aBoard || !aPlotter || aLayers.empty() )
  57. return;
  58. // if a drill mark must be plotted, the copper layer needs to be plotted
  59. // after other layers because the drill mark must be plotted as a filled
  60. // white shape *after* all other shapes are plotted
  61. bool plot_mark = aPlotOptions.GetDrillMarksType() != DRILL_MARKS::NO_DRILL_SHAPE;
  62. for( PCB_LAYER_ID layer : aLayers )
  63. {
  64. // copper layers with drill marks will be plotted after all other layers
  65. if( IsCopperLayer( layer ) && plot_mark )
  66. continue;
  67. PlotOneBoardLayer( aBoard, aPlotter, layer, aPlotOptions );
  68. }
  69. if( !plot_mark )
  70. return;
  71. for( PCB_LAYER_ID layer : aLayers )
  72. {
  73. if( !IsCopperLayer( layer ) )
  74. continue;
  75. PlotOneBoardLayer( aBoard, aPlotter, layer, aPlotOptions );
  76. }
  77. }
  78. void PlotInteractiveLayer( BOARD* aBoard, PLOTTER* aPlotter, const PCB_PLOT_PARAMS& aPlotOpt )
  79. {
  80. for( const FOOTPRINT* fp : aBoard->Footprints() )
  81. {
  82. if( fp->GetLayer() == F_Cu && !aPlotOpt.m_PDFFrontFPPropertyPopups )
  83. continue;
  84. if( fp->GetLayer() == B_Cu && !aPlotOpt.m_PDFBackFPPropertyPopups )
  85. continue;
  86. std::vector<wxString> properties;
  87. properties.emplace_back( wxString::Format( wxT( "!%s = %s" ),
  88. _( "Reference designator" ),
  89. fp->Reference().GetShownText( false ) ) );
  90. properties.emplace_back( wxString::Format( wxT( "!%s = %s" ),
  91. _( "Value" ),
  92. fp->Value().GetShownText( false ) ) );
  93. properties.emplace_back( wxString::Format( wxT( "!%s = %s" ),
  94. _( "Footprint" ),
  95. fp->GetFPID().GetUniStringLibItemName() ) );
  96. for( const PCB_FIELD* field : fp->GetFields() )
  97. {
  98. if( field->IsReference() || field->IsValue() )
  99. continue;
  100. if( field->GetText().IsEmpty() )
  101. continue;
  102. properties.emplace_back( wxString::Format( wxT( "!%s = %s" ),
  103. field->GetName(),
  104. field->GetText() ) );
  105. }
  106. // These 2 properties are not very useful in a plot file (like a PDF)
  107. #if 0
  108. properties.emplace_back( wxString::Format( wxT( "!%s = %s" ), _( "Library Description" ),
  109. fp->GetLibDescription() ) );
  110. properties.emplace_back( wxString::Format( wxT( "!%s = %s" ),
  111. _( "Keywords" ),
  112. fp->GetKeywords() ) );
  113. #endif
  114. // Draw items are plotted with a position offset. So we need to move
  115. // our boxes (which are not plotted) by the same offset.
  116. VECTOR2I offset = -aPlotter->GetPlotOffsetUserUnits();
  117. // Use a footprint bbox without texts to create the hyperlink area
  118. BOX2I bbox = fp->GetBoundingBox( false );
  119. bbox.Move( offset );
  120. aPlotter->HyperlinkMenu( bbox, properties );
  121. // Use a footprint bbox with visible texts only to create the bookmark area
  122. // which is the area to zoom on ft selection
  123. // However the bbox need to be inflated for a better look.
  124. bbox = fp->GetBoundingBox( true );
  125. bbox.Move( offset );
  126. bbox.Inflate( bbox.GetWidth() /2, bbox.GetHeight() /2 );
  127. aPlotter->Bookmark( bbox, fp->GetReference(), _( "Footprints" ) );
  128. }
  129. }
  130. void PlotOneBoardLayer( BOARD *aBoard, PLOTTER* aPlotter, PCB_LAYER_ID aLayer,
  131. const PCB_PLOT_PARAMS& aPlotOpt )
  132. {
  133. auto plotLayer =
  134. [&]( LSET layerMask, PCB_PLOT_PARAMS& plotOpts )
  135. {
  136. // PlotLayerOutlines() is designed only for DXF plotters.
  137. if( plotOpts.GetFormat() == PLOT_FORMAT::DXF && plotOpts.GetDXFPlotPolygonMode() )
  138. PlotLayerOutlines( aBoard, aPlotter, layerMask, plotOpts );
  139. else
  140. PlotStandardLayer( aBoard, aPlotter, layerMask, plotOpts );
  141. };
  142. PCB_PLOT_PARAMS plotOpt = aPlotOpt;
  143. int soldermask_min_thickness = aBoard->GetDesignSettings().m_SolderMaskMinWidth;
  144. // Set a default color and the text mode for this layer
  145. aPlotter->SetColor( BLACK );
  146. aPlotter->SetTextMode( aPlotOpt.GetTextMode() );
  147. // Specify that the contents of the "Edges Pcb" layer are to be plotted in addition to the
  148. // contents of the currently specified layer.
  149. LSET layer_mask( { aLayer } );
  150. if( IsCopperLayer( aLayer ) )
  151. {
  152. // Skip NPTH pads on copper layers ( only if hole size == pad size ):
  153. // Drill mark will be plotted if drill mark is SMALL_DRILL_SHAPE or FULL_DRILL_SHAPE
  154. if( plotOpt.GetFormat() == PLOT_FORMAT::DXF )
  155. plotOpt.SetDXFPlotPolygonMode( true );
  156. else
  157. plotOpt.SetSkipPlotNPTH_Pads( true );
  158. plotLayer( layer_mask, plotOpt );
  159. }
  160. else
  161. {
  162. switch( aLayer )
  163. {
  164. case B_Mask:
  165. case F_Mask:
  166. // Disable plot pad holes
  167. plotOpt.SetDrillMarksType( DRILL_MARKS::NO_DRILL_SHAPE );
  168. // Use outline mode for DXF
  169. plotOpt.SetDXFPlotPolygonMode( true );
  170. // Plot solder mask:
  171. if( soldermask_min_thickness == 0 )
  172. {
  173. plotLayer( layer_mask, plotOpt );
  174. }
  175. else
  176. {
  177. PlotSolderMaskLayer( aBoard, aPlotter, layer_mask, plotOpt,
  178. soldermask_min_thickness );
  179. }
  180. break;
  181. case B_Adhes:
  182. case F_Adhes:
  183. case B_Paste:
  184. case F_Paste:
  185. // Disable plot pad holes
  186. plotOpt.SetDrillMarksType( DRILL_MARKS::NO_DRILL_SHAPE );
  187. // Use outline mode for DXF
  188. plotOpt.SetDXFPlotPolygonMode( true );
  189. plotLayer( layer_mask, plotOpt );
  190. break;
  191. case F_SilkS:
  192. case B_SilkS:
  193. plotLayer( layer_mask, plotOpt );
  194. // Gerber: Subtract soldermask from silkscreen if enabled
  195. if( aPlotter->GetPlotterType() == PLOT_FORMAT::GERBER
  196. && plotOpt.GetSubtractMaskFromSilk() )
  197. {
  198. if( aLayer == F_SilkS )
  199. layer_mask = LSET( { F_Mask } );
  200. else
  201. layer_mask = LSET( { B_Mask } );
  202. // Create the mask to subtract by creating a negative layer polarity
  203. aPlotter->SetLayerPolarity( false );
  204. // Disable plot pad holes
  205. plotOpt.SetDrillMarksType( DRILL_MARKS::NO_DRILL_SHAPE );
  206. // Plot the mask
  207. PlotStandardLayer( aBoard, aPlotter, layer_mask, plotOpt );
  208. // Disable the negative polarity
  209. aPlotter->SetLayerPolarity( true );
  210. }
  211. break;
  212. case Dwgs_User:
  213. case Cmts_User:
  214. case Eco1_User:
  215. case Eco2_User:
  216. case Edge_Cuts:
  217. case Margin:
  218. case F_CrtYd:
  219. case B_CrtYd:
  220. case F_Fab:
  221. case B_Fab:
  222. default:
  223. plotLayer( layer_mask, plotOpt );
  224. break;
  225. }
  226. }
  227. }
  228. /**
  229. * Plot any layer EXCEPT a solder-mask with an enforced minimum width.
  230. */
  231. void PlotStandardLayer( BOARD* aBoard, PLOTTER* aPlotter, LSET aLayerMask,
  232. const PCB_PLOT_PARAMS& aPlotOpt )
  233. {
  234. BRDITEMS_PLOTTER itemplotter( aPlotter, aBoard, aPlotOpt );
  235. int maxError = aBoard->GetDesignSettings().m_MaxError;
  236. itemplotter.SetLayerSet( aLayerMask );
  237. OUTLINE_MODE plotMode = aPlotOpt.GetPlotMode();
  238. bool onCopperLayer = ( LSET::AllCuMask() & aLayerMask ).any();
  239. bool onSolderMaskLayer = ( LSET( { F_Mask, B_Mask } ) & aLayerMask ).any();
  240. bool onSolderPasteLayer = ( LSET( { F_Paste, B_Paste } ) & aLayerMask ).any();
  241. bool onFrontFab = ( LSET( { F_Fab } ) & aLayerMask ).any();
  242. bool onBackFab = ( LSET( { B_Fab } ) & aLayerMask ).any();
  243. bool sketchPads = ( onFrontFab || onBackFab ) && aPlotOpt.GetSketchPadsOnFabLayers();
  244. // Plot edge layer and graphic items
  245. for( const BOARD_ITEM* item : aBoard->Drawings() )
  246. itemplotter.PlotBoardGraphicItem( item );
  247. // Draw footprint texts:
  248. for( const FOOTPRINT* footprint : aBoard->Footprints() )
  249. itemplotter.PlotFootprintTextItems( footprint );
  250. // Draw footprint other graphic items:
  251. for( const FOOTPRINT* footprint : aBoard->Footprints() )
  252. itemplotter.PlotFootprintGraphicItems( footprint );
  253. // Plot footprint pads
  254. for( FOOTPRINT* footprint : aBoard->Footprints() )
  255. {
  256. aPlotter->StartBlock( nullptr );
  257. for( PAD* pad : footprint->Pads() )
  258. {
  259. OUTLINE_MODE padPlotMode = plotMode;
  260. if( !( pad->GetLayerSet() & aLayerMask ).any() )
  261. {
  262. if( sketchPads &&
  263. ( ( onFrontFab && pad->GetLayerSet().Contains( F_Cu ) ) ||
  264. ( onBackFab && pad->GetLayerSet().Contains( B_Cu ) ) ) )
  265. {
  266. padPlotMode = SKETCH;
  267. }
  268. else
  269. {
  270. continue;
  271. }
  272. }
  273. if( onCopperLayer && !pad->IsOnCopperLayer() )
  274. continue;
  275. /// pads not connected to copper are optionally not drawn
  276. if( onCopperLayer && !pad->FlashLayer( aLayerMask ) )
  277. continue;
  278. // TODO(JE) padstacks - different behavior for single layer or multilayer
  279. COLOR4D color = COLOR4D::BLACK;
  280. // If we're plotting a single layer, the color for that layer can be used directly.
  281. if( aLayerMask.count() == 1 )
  282. {
  283. color = aPlotOpt.ColorSettings()->GetColor( aLayerMask.Seq()[0] );
  284. }
  285. else
  286. {
  287. if( ( pad->GetLayerSet() & aLayerMask )[B_Cu] )
  288. color = aPlotOpt.ColorSettings()->GetColor( B_Cu );
  289. if( ( pad->GetLayerSet() & aLayerMask )[F_Cu] )
  290. color = color.LegacyMix( aPlotOpt.ColorSettings()->GetColor( F_Cu ) );
  291. if( sketchPads && aLayerMask[F_Fab] )
  292. color = aPlotOpt.ColorSettings()->GetColor( F_Fab );
  293. else if( sketchPads && aLayerMask[B_Fab] )
  294. color = aPlotOpt.ColorSettings()->GetColor( B_Fab );
  295. }
  296. if( sketchPads &&
  297. ( ( onFrontFab && pad->GetLayerSet().Contains( F_Cu ) ) ||
  298. ( onBackFab && pad->GetLayerSet().Contains( B_Cu ) ) ) )
  299. {
  300. if( aPlotOpt.GetPlotPadNumbers() )
  301. itemplotter.PlotPadNumber( pad, color );
  302. }
  303. auto plotPadLayer =
  304. [&]( PCB_LAYER_ID aLayer )
  305. {
  306. VECTOR2I margin;
  307. int width_adj = 0;
  308. if( onCopperLayer )
  309. width_adj = itemplotter.getFineWidthAdj();
  310. if( onSolderMaskLayer )
  311. margin.x = margin.y = pad->GetSolderMaskExpansion( aLayer );
  312. if( onSolderPasteLayer )
  313. margin = pad->GetSolderPasteMargin( aLayer );
  314. // not all shapes can have a different margin for x and y axis
  315. // in fact only oval and rect shapes can have different values.
  316. // Round shape have always the same x,y margin
  317. // so define a unique value for other shapes that do not support different values
  318. int mask_clearance = margin.x;
  319. // Now offset the pad size by margin + width_adj
  320. VECTOR2I padPlotsSize =
  321. pad->GetSize( aLayer ) + margin * 2 + VECTOR2I( width_adj, width_adj );
  322. // Store these parameters that can be modified to plot inflated/deflated pads shape
  323. PAD_SHAPE padShape = pad->GetShape( aLayer );
  324. VECTOR2I padSize = pad->GetSize( aLayer );
  325. VECTOR2I padDelta = pad->GetDelta( aLayer ); // has meaning only for trapezoidal pads
  326. // CornerRadius and CornerRadiusRatio can be modified
  327. // the radius is built from the ratio, so saving/restoring the ratio is enough
  328. double padCornerRadiusRatio = pad->GetRoundRectRadiusRatio( aLayer );
  329. // Don't draw a 0 sized pad.
  330. // Note: a custom pad can have its pad anchor with size = 0
  331. if( padShape != PAD_SHAPE::CUSTOM
  332. && ( padPlotsSize.x <= 0 || padPlotsSize.y <= 0 ) )
  333. {
  334. return;
  335. }
  336. switch( padShape )
  337. {
  338. case PAD_SHAPE::CIRCLE:
  339. case PAD_SHAPE::OVAL:
  340. pad->SetSize( aLayer, padPlotsSize );
  341. if( aPlotOpt.GetSkipPlotNPTH_Pads() &&
  342. ( aPlotOpt.GetDrillMarksType() == DRILL_MARKS::NO_DRILL_SHAPE ) &&
  343. ( pad->GetSize(aLayer ) == pad->GetDrillSize() ) &&
  344. ( pad->GetAttribute() == PAD_ATTRIB::NPTH ) )
  345. {
  346. break;
  347. }
  348. itemplotter.PlotPad( pad, aLayer, color, padPlotMode );
  349. break;
  350. case PAD_SHAPE::RECTANGLE:
  351. pad->SetSize( aLayer, padPlotsSize );
  352. if( mask_clearance > 0 )
  353. {
  354. pad->SetShape( aLayer, PAD_SHAPE::ROUNDRECT );
  355. pad->SetRoundRectCornerRadius( aLayer, mask_clearance );
  356. }
  357. itemplotter.PlotPad( pad, aLayer, color, padPlotMode );
  358. break;
  359. case PAD_SHAPE::TRAPEZOID:
  360. // inflate/deflate a trapezoid is a bit complex.
  361. // so if the margin is not null, build a similar polygonal pad shape,
  362. // and inflate/deflate the polygonal shape
  363. // because inflating/deflating using different values for y and y
  364. // we are using only margin.x as inflate/deflate value
  365. if( mask_clearance == 0 )
  366. {
  367. itemplotter.PlotPad( pad, aLayer, color, padPlotMode );
  368. }
  369. else
  370. {
  371. PAD dummy( *pad );
  372. dummy.SetAnchorPadShape( aLayer, PAD_SHAPE::CIRCLE );
  373. dummy.SetShape( aLayer, PAD_SHAPE::CUSTOM );
  374. SHAPE_POLY_SET outline;
  375. outline.NewOutline();
  376. int dx = padSize.x / 2;
  377. int dy = padSize.y / 2;
  378. int ddx = padDelta.x / 2;
  379. int ddy = padDelta.y / 2;
  380. outline.Append( -dx - ddy, dy + ddx );
  381. outline.Append( dx + ddy, dy - ddx );
  382. outline.Append( dx - ddy, -dy + ddx );
  383. outline.Append( -dx + ddy, -dy - ddx );
  384. // Shape polygon can have holes so use InflateWithLinkedHoles(), not Inflate()
  385. // which can create bad shapes if margin.x is < 0
  386. outline.InflateWithLinkedHoles( mask_clearance,
  387. CORNER_STRATEGY::ROUND_ALL_CORNERS, maxError );
  388. dummy.DeletePrimitivesList();
  389. dummy.AddPrimitivePoly( aLayer, outline, 0, true );
  390. // Be sure the anchor pad is not bigger than the deflated shape because this
  391. // anchor will be added to the pad shape when plotting the pad. So now the
  392. // polygonal shape is built, we can clamp the anchor size
  393. dummy.SetSize( aLayer, VECTOR2I( 0, 0 ) );
  394. itemplotter.PlotPad( &dummy, aLayer, color, padPlotMode );
  395. }
  396. break;
  397. case PAD_SHAPE::ROUNDRECT:
  398. {
  399. // rounding is stored as a percent, but we have to update this ratio
  400. // to force recalculation of other values after size changing (we do not
  401. // really change the rounding percent value)
  402. double radius_ratio = pad->GetRoundRectRadiusRatio( aLayer );
  403. pad->SetSize( aLayer, padPlotsSize );
  404. pad->SetRoundRectRadiusRatio( aLayer, radius_ratio );
  405. itemplotter.PlotPad( pad, aLayer, color, padPlotMode );
  406. break;
  407. }
  408. case PAD_SHAPE::CHAMFERED_RECT:
  409. if( mask_clearance == 0 )
  410. {
  411. // the size can be slightly inflated by width_adj (PS/PDF only)
  412. pad->SetSize( aLayer, padPlotsSize );
  413. itemplotter.PlotPad( pad, aLayer, color, padPlotMode );
  414. }
  415. else
  416. {
  417. // Due to the polygonal shape of a CHAMFERED_RECT pad, the best way is to
  418. // convert the pad shape to a full polygon, inflate/deflate the polygon
  419. // and use a dummy CUSTOM pad to plot the final shape.
  420. PAD dummy( *pad );
  421. // Build the dummy pad outline with coordinates relative to the pad position
  422. // pad offset and orientation 0. The actual pos, offset and rotation will be
  423. // taken in account later by the plot function
  424. dummy.SetPosition( VECTOR2I( 0, 0 ) );
  425. dummy.SetOffset( aLayer, VECTOR2I( 0, 0 ) );
  426. dummy.SetOrientation( ANGLE_0 );
  427. SHAPE_POLY_SET outline;
  428. dummy.TransformShapeToPolygon( outline, UNDEFINED_LAYER, 0, maxError,
  429. ERROR_INSIDE );
  430. outline.InflateWithLinkedHoles( mask_clearance,
  431. CORNER_STRATEGY::ROUND_ALL_CORNERS, maxError );
  432. // Initialize the dummy pad shape:
  433. dummy.SetAnchorPadShape( aLayer, PAD_SHAPE::CIRCLE );
  434. dummy.SetShape( aLayer, PAD_SHAPE::CUSTOM );
  435. dummy.DeletePrimitivesList();
  436. dummy.AddPrimitivePoly( aLayer, outline, 0, true );
  437. // Be sure the anchor pad is not bigger than the deflated shape because this
  438. // anchor will be added to the pad shape when plotting the pad.
  439. // So we set the anchor size to 0
  440. dummy.SetSize( aLayer, VECTOR2I( 0, 0 ) );
  441. // Restore pad position and offset
  442. dummy.SetPosition( pad->GetPosition() );
  443. dummy.SetOffset( aLayer, pad->GetOffset( aLayer ) );
  444. dummy.SetOrientation( pad->GetOrientation() );
  445. itemplotter.PlotPad( &dummy, aLayer, color, padPlotMode );
  446. }
  447. break;
  448. case PAD_SHAPE::CUSTOM:
  449. {
  450. // inflate/deflate a custom shape is a bit complex.
  451. // so build a similar pad shape, and inflate/deflate the polygonal shape
  452. PAD dummy( *pad );
  453. dummy.SetParentGroup( nullptr );
  454. SHAPE_POLY_SET shape;
  455. pad->MergePrimitivesAsPolygon( aLayer, &shape );
  456. // Shape polygon can have holes so use InflateWithLinkedHoles(), not Inflate()
  457. // which can create bad shapes if margin.x is < 0
  458. shape.InflateWithLinkedHoles( mask_clearance,
  459. CORNER_STRATEGY::ROUND_ALL_CORNERS, maxError );
  460. dummy.DeletePrimitivesList();
  461. dummy.AddPrimitivePoly( aLayer, shape, 0, true );
  462. // Be sure the anchor pad is not bigger than the deflated shape because this
  463. // anchor will be added to the pad shape when plotting the pad. So now the
  464. // polygonal shape is built, we can clamp the anchor size
  465. if( mask_clearance < 0 ) // we expect margin.x = margin.y for custom pads
  466. dummy.SetSize( aLayer, VECTOR2I( std::max( 0, padPlotsSize.x ),
  467. std::max( 0, padPlotsSize.y ) ) );
  468. itemplotter.PlotPad( &dummy, aLayer, color, padPlotMode );
  469. break;
  470. }
  471. }
  472. // Restore the pad parameters modified by the plot code
  473. pad->SetSize( aLayer, padSize );
  474. pad->SetDelta( aLayer, padDelta );
  475. pad->SetShape( aLayer, padShape );
  476. pad->SetRoundRectRadiusRatio( aLayer, padCornerRadiusRatio );
  477. };
  478. for( PCB_LAYER_ID layer : aLayerMask.SeqStackupForPlotting() )
  479. plotPadLayer( layer );
  480. }
  481. if( footprint->IsDNP()
  482. && !itemplotter.GetHideDNPFPsOnFabLayers()
  483. && itemplotter.GetCrossoutDNPFPsOnFabLayers()
  484. && ( onFrontFab || onBackFab ) )
  485. {
  486. BOX2I rect = footprint->GetBoundingHull().BBox();
  487. int width = aBoard->GetDesignSettings().m_LineThickness[ LAYER_CLASS_FAB ];
  488. aPlotter->ThickSegment( rect.GetOrigin(), rect.GetEnd(), width, FILLED, nullptr );
  489. aPlotter->ThickSegment( VECTOR2I( rect.GetLeft(), rect.GetBottom() ),
  490. VECTOR2I( rect.GetRight(), rect.GetTop() ),
  491. width, FILLED, nullptr );
  492. }
  493. aPlotter->EndBlock( nullptr );
  494. }
  495. // Plot vias on copper layers, and if aPlotOpt.GetPlotViaOnMaskLayer() is true,
  496. GBR_METADATA gbr_metadata;
  497. if( onCopperLayer )
  498. {
  499. gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_VIAPAD );
  500. gbr_metadata.SetNetAttribType( GBR_NETLIST_METADATA::GBR_NETINFO_NET );
  501. }
  502. aPlotter->StartBlock( nullptr );
  503. for( const PCB_TRACK* track : aBoard->Tracks() )
  504. {
  505. if( track->Type() != PCB_VIA_T )
  506. continue;
  507. const PCB_VIA* via = static_cast<const PCB_VIA*>( track );
  508. // vias are not plotted if not on selected layer
  509. LSET via_mask_layer = via->GetLayerSet();
  510. if( !( via_mask_layer & aLayerMask ).any() )
  511. continue;
  512. int via_margin = 0;
  513. double width_adj = 0;
  514. // TODO(JE) padstacks - separate top/bottom margin
  515. if( onSolderMaskLayer )
  516. via_margin = via->GetSolderMaskExpansion();
  517. if( ( aLayerMask & LSET::AllCuMask() ).any() )
  518. width_adj = itemplotter.getFineWidthAdj();
  519. /// Vias not connected to copper are optionally not drawn
  520. if( onCopperLayer && !via->FlashLayer( aLayerMask ) )
  521. continue;
  522. int diameter = 0;
  523. for( PCB_LAYER_ID layer : aLayerMask.Seq() )
  524. diameter = std::max( diameter, via->GetWidth( layer ) );
  525. diameter += 2 * via_margin + width_adj;
  526. // Don't draw a null size item :
  527. if( diameter <= 0 )
  528. continue;
  529. // Some vias can be not connected (no net).
  530. // Set the m_NotInNet for these vias to force a empty net name in gerber file
  531. gbr_metadata.m_NetlistMetadata.m_NotInNet = via->GetNetname().IsEmpty();
  532. gbr_metadata.SetNetName( via->GetNetname() );
  533. COLOR4D color;
  534. // If we're plotting a single layer, the color for that layer can be used directly.
  535. if( aLayerMask.count() == 1 )
  536. {
  537. color = aPlotOpt.ColorSettings()->GetColor( aLayerMask.Seq()[0] );
  538. }
  539. else
  540. {
  541. color = aPlotOpt.ColorSettings()->GetColor(
  542. LAYER_VIAS + static_cast<int>( via->GetViaType() ) );
  543. }
  544. // Change UNSPECIFIED or WHITE to LIGHTGRAY because the white items are not seen on a
  545. // white paper or screen
  546. if( color == COLOR4D::UNSPECIFIED || color == WHITE )
  547. color = LIGHTGRAY;
  548. aPlotter->SetColor( color );
  549. aPlotter->FlashPadCircle( via->GetStart(), diameter, plotMode, &gbr_metadata );
  550. }
  551. aPlotter->EndBlock( nullptr );
  552. aPlotter->StartBlock( nullptr );
  553. if( onCopperLayer )
  554. {
  555. gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CONDUCTOR );
  556. gbr_metadata.SetNetAttribType( GBR_NETLIST_METADATA::GBR_NETINFO_NET );
  557. }
  558. else
  559. {
  560. // Reset attributes if non-copper (soldermask) layer
  561. gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_NONE );
  562. gbr_metadata.SetNetAttribType( GBR_NETLIST_METADATA::GBR_NETINFO_UNSPECIFIED );
  563. }
  564. // Plot tracks (not vias) :
  565. for( const PCB_TRACK* track : aBoard->Tracks() )
  566. {
  567. if( track->Type() == PCB_VIA_T )
  568. continue;
  569. if( !( aLayerMask & track->GetLayerSet() ).any() )
  570. continue;
  571. // Some track segments can be not connected (no net).
  572. // Set the m_NotInNet for these segments to force a empty net name in gerber file
  573. gbr_metadata.m_NetlistMetadata.m_NotInNet = track->GetNetname().IsEmpty();
  574. gbr_metadata.SetNetName( track->GetNetname() );
  575. int margin = 0;
  576. if( onSolderMaskLayer )
  577. margin = track->GetSolderMaskExpansion();
  578. int width = track->GetWidth() + 2 * margin + itemplotter.getFineWidthAdj();
  579. aPlotter->SetColor( itemplotter.getColor( track->GetLayer() ) );
  580. if( track->Type() == PCB_ARC_T )
  581. {
  582. const PCB_ARC* arc = static_cast<const PCB_ARC*>( track );
  583. // Too small arcs cannot be really handled: arc center (and arc radius)
  584. // cannot be safely computed
  585. if( !arc->IsDegenerated( 10 /* in IU */ ) )
  586. {
  587. aPlotter->ThickArc( arc->GetCenter(), arc->GetArcAngleStart(), arc->GetAngle(),
  588. arc->GetRadius(), width, plotMode, &gbr_metadata );
  589. }
  590. else
  591. {
  592. // Approximate this very small arc by a segment.
  593. aPlotter->ThickSegment( track->GetStart(), track->GetEnd(), width, plotMode,
  594. &gbr_metadata );
  595. }
  596. }
  597. else
  598. {
  599. aPlotter->ThickSegment( track->GetStart(), track->GetEnd(), width, plotMode,
  600. &gbr_metadata );
  601. }
  602. }
  603. aPlotter->EndBlock( nullptr );
  604. // Plot filled ares
  605. aPlotter->StartBlock( nullptr );
  606. NETINFO_ITEM nonet( aBoard );
  607. for( const ZONE* zone : aBoard->Zones() )
  608. {
  609. if( zone->GetIsRuleArea() )
  610. continue;
  611. for( PCB_LAYER_ID layer : zone->GetLayerSet().Seq() )
  612. {
  613. if( !aLayerMask[layer] )
  614. continue;
  615. SHAPE_POLY_SET mainArea = zone->GetFilledPolysList( layer )->CloneDropTriangulation();
  616. SHAPE_POLY_SET islands;
  617. for( int i = mainArea.OutlineCount() - 1; i >= 0; i-- )
  618. {
  619. if( zone->IsIsland( layer, i ) )
  620. {
  621. islands.AddOutline( mainArea.CPolygon( i )[0] );
  622. mainArea.DeletePolygon( i );
  623. }
  624. }
  625. itemplotter.PlotZone( zone, layer, mainArea );
  626. if( !islands.IsEmpty() )
  627. {
  628. ZONE dummy( *zone );
  629. dummy.SetNet( &nonet );
  630. itemplotter.PlotZone( &dummy, layer, islands );
  631. }
  632. }
  633. }
  634. aPlotter->EndBlock( nullptr );
  635. // Adding drill marks, if required and if the plotter is able to plot them:
  636. if( aPlotOpt.GetDrillMarksType() != DRILL_MARKS::NO_DRILL_SHAPE )
  637. itemplotter.PlotDrillMarks();
  638. }
  639. /**
  640. * Plot outlines.
  641. */
  642. void PlotLayerOutlines( BOARD* aBoard, PLOTTER* aPlotter, LSET aLayerMask,
  643. const PCB_PLOT_PARAMS& aPlotOpt )
  644. {
  645. BRDITEMS_PLOTTER itemplotter( aPlotter, aBoard, aPlotOpt );
  646. itemplotter.SetLayerSet( aLayerMask );
  647. SHAPE_POLY_SET outlines;
  648. for( PCB_LAYER_ID layer : aLayerMask.Seq( aLayerMask.SeqStackupForPlotting() ) )
  649. {
  650. outlines.RemoveAllContours();
  651. aBoard->ConvertBrdLayerToPolygonalContours( layer, outlines );
  652. outlines.Simplify();
  653. // Plot outlines
  654. std::vector<VECTOR2I> cornerList;
  655. // Now we have one or more basic polygons: plot each polygon
  656. for( int ii = 0; ii < outlines.OutlineCount(); ii++ )
  657. {
  658. for( int kk = 0; kk <= outlines.HoleCount(ii); kk++ )
  659. {
  660. cornerList.clear();
  661. const SHAPE_LINE_CHAIN& path = ( kk == 0 ) ? outlines.COutline( ii )
  662. : outlines.CHole( ii, kk - 1 );
  663. aPlotter->PlotPoly( path, FILL_T::NO_FILL );
  664. }
  665. }
  666. // Plot pad holes
  667. if( aPlotOpt.GetDrillMarksType() != DRILL_MARKS::NO_DRILL_SHAPE )
  668. {
  669. int smallDrill = ( aPlotOpt.GetDrillMarksType() == DRILL_MARKS::SMALL_DRILL_SHAPE )
  670. ? pcbIUScale.mmToIU( ADVANCED_CFG::GetCfg().m_SmallDrillMarkSize )
  671. : INT_MAX;
  672. for( FOOTPRINT* footprint : aBoard->Footprints() )
  673. {
  674. for( PAD* pad : footprint->Pads() )
  675. {
  676. if( pad->HasHole() )
  677. {
  678. std::shared_ptr<SHAPE_SEGMENT> slot = pad->GetEffectiveHoleShape();
  679. if( slot->GetSeg().A == slot->GetSeg().B ) // circular hole
  680. {
  681. int drill = std::min( smallDrill, slot->GetWidth() );
  682. aPlotter->Circle( pad->GetPosition(), drill, FILL_T::NO_FILL );
  683. }
  684. else
  685. {
  686. // Note: small drill marks have no significance when applied to slots
  687. aPlotter->ThickSegment( slot->GetSeg().A, slot->GetSeg().B,
  688. slot->GetWidth(), SKETCH, nullptr );
  689. }
  690. }
  691. }
  692. }
  693. }
  694. // Plot vias holes
  695. for( PCB_TRACK* track : aBoard->Tracks() )
  696. {
  697. if( track->Type() != PCB_VIA_T )
  698. continue;
  699. const PCB_VIA* via = static_cast<const PCB_VIA*>( track );
  700. if( via->GetLayerSet().Contains( layer ) ) // via holes can be not through holes
  701. aPlotter->Circle( via->GetPosition(), via->GetDrillValue(), FILL_T::NO_FILL );
  702. }
  703. }
  704. }
  705. /**
  706. * Plot a solder mask layer.
  707. *
  708. * Solder mask layers have a minimum thickness value and cannot be drawn like standard layers,
  709. * unless the minimum thickness is 0.
  710. *
  711. * The algorithm is somewhat complicated to allow for min web thickness while also preserving
  712. * pad attributes in Gerber.
  713. *
  714. * 1 - create initial polygons for every shape
  715. * 2 - inflate and deflate polygons with Min Thickness/2, and merges the result
  716. * 3 - substract all initial polygons from (2), leaving the areas where the thickness was less
  717. * than min thickness
  718. * 4 - plot all initial shapes by flashing (or using regions), including Gerber attribute data
  719. * 5 - plot remaining polygons from (2) (witout any Gerber attributes)
  720. */
  721. void PlotSolderMaskLayer( BOARD *aBoard, PLOTTER* aPlotter, LSET aLayerMask,
  722. const PCB_PLOT_PARAMS& aPlotOpt, int aMinThickness )
  723. {
  724. int maxError = aBoard->GetDesignSettings().m_MaxError;
  725. PCB_LAYER_ID layer = aLayerMask[B_Mask] ? B_Mask : F_Mask;
  726. SHAPE_POLY_SET buffer;
  727. SHAPE_POLY_SET* boardOutline = nullptr;
  728. if( aBoard->GetBoardPolygonOutlines( buffer ) )
  729. boardOutline = &buffer;
  730. // We remove 1nm as we expand both sides of the shapes, so allowing for a strictly greater
  731. // than or equal comparison in the shape separation (boolean add)
  732. int inflate = aMinThickness / 2 - 1;
  733. BRDITEMS_PLOTTER itemplotter( aPlotter, aBoard, aPlotOpt );
  734. itemplotter.SetLayerSet( aLayerMask );
  735. // Build polygons for each pad shape. The size of the shape on solder mask should be size
  736. // of pad + clearance around the pad, where clearance = solder mask clearance + extra margin.
  737. // Extra margin is half the min width for solder mask, which is used to merge too-close shapes
  738. // (distance < aMinThickness), and will be removed when creating the actual shapes.
  739. // Will contain shapes inflated by inflate value that will be merged and deflated by inflate
  740. // value to build final polygons
  741. SHAPE_POLY_SET areas;
  742. // Will contain exact shapes of all items on solder mask
  743. SHAPE_POLY_SET initialPolys;
  744. auto plotFPTextItem =
  745. [&]( const PCB_TEXT& aText )
  746. {
  747. if( !itemplotter.GetPlotFPText() )
  748. return;
  749. if( !aText.IsVisible() && !itemplotter.GetPlotInvisibleText() )
  750. return;
  751. if( aText.GetText() == wxT( "${REFERENCE}" ) && !itemplotter.GetPlotReference() )
  752. return;
  753. if( aText.GetText() == wxT( "${VALUE}" ) && !itemplotter.GetPlotValue() )
  754. return;
  755. // add shapes with their exact mask layer size in initialPolys
  756. aText.TransformTextToPolySet( initialPolys, 0, maxError, ERROR_OUTSIDE );
  757. // add shapes inflated by aMinThickness/2 in areas
  758. aText.TransformTextToPolySet( areas, inflate, maxError, ERROR_OUTSIDE );
  759. };
  760. // Generate polygons with arcs inside the shape or exact shape to minimize shape changes
  761. // created by arc to segment size correction.
  762. DISABLE_ARC_RADIUS_CORRECTION disabler;
  763. {
  764. // Plot footprint pads and graphics
  765. for( const FOOTPRINT* footprint : aBoard->Footprints() )
  766. {
  767. // add shapes with their exact mask layer size in initialPolys
  768. footprint->TransformPadsToPolySet( initialPolys, layer, 0, maxError, ERROR_OUTSIDE );
  769. // add shapes inflated by aMinThickness/2 in areas
  770. footprint->TransformPadsToPolySet( areas, layer, inflate, maxError, ERROR_OUTSIDE );
  771. for( const PCB_FIELD* field : footprint->GetFields() )
  772. {
  773. if( field->IsReference() && !itemplotter.GetPlotReference() )
  774. continue;
  775. if( field->IsValue() && !itemplotter.GetPlotValue() )
  776. continue;
  777. if( field->IsOnLayer( layer ) )
  778. plotFPTextItem( static_cast<const PCB_TEXT&>( *field ) );
  779. }
  780. for( const BOARD_ITEM* item : footprint->GraphicalItems() )
  781. {
  782. if( item->IsOnLayer( layer ) )
  783. {
  784. if( item->Type() == PCB_TEXT_T )
  785. {
  786. plotFPTextItem( static_cast<const PCB_TEXT&>( *item ) );
  787. }
  788. else
  789. {
  790. // add shapes with their exact mask layer size in initialPolys
  791. item->TransformShapeToPolygon( initialPolys, layer, 0, maxError,
  792. ERROR_OUTSIDE );
  793. // add shapes inflated by aMinThickness/2 in areas
  794. item->TransformShapeToPolygon( areas, layer, inflate, maxError,
  795. ERROR_OUTSIDE );
  796. }
  797. }
  798. }
  799. }
  800. // Plot (untented) vias
  801. for( const PCB_TRACK* track : aBoard->Tracks() )
  802. {
  803. if( track->Type() != PCB_VIA_T )
  804. continue;
  805. const PCB_VIA* via = static_cast<const PCB_VIA*>( track );
  806. // Note: IsOnLayer() checks relevant mask layers of untented vias
  807. if( !via->IsOnLayer( layer ) )
  808. continue;
  809. int clearance = via->GetSolderMaskExpansion();
  810. // add shapes with their exact mask layer size in initialPolys
  811. via->TransformShapeToPolygon( initialPolys, layer, clearance, maxError, ERROR_OUTSIDE );
  812. // add shapes inflated by aMinThickness/2 in areas
  813. clearance += inflate;
  814. via->TransformShapeToPolygon( areas, layer, clearance, maxError, ERROR_OUTSIDE );
  815. }
  816. // Add filled zone areas.
  817. #if 0 // Set to 1 if a solder mask expansion must be applied to zones on solder mask
  818. int zone_margin = aBoard->GetDesignSettings().m_SolderMaskExpansion;
  819. #else
  820. int zone_margin = 0;
  821. #endif
  822. for( const BOARD_ITEM* item : aBoard->Drawings() )
  823. {
  824. if( item->IsOnLayer( layer ) )
  825. {
  826. if( item->Type() == PCB_TEXT_T )
  827. {
  828. const PCB_TEXT* text = static_cast<const PCB_TEXT*>( item );
  829. // add shapes with their exact mask layer size in initialPolys
  830. text->TransformTextToPolySet( initialPolys, 0, maxError, ERROR_OUTSIDE );
  831. // add shapes inflated by aMinThickness/2 in areas
  832. text->TransformTextToPolySet( areas, inflate, maxError, ERROR_OUTSIDE );
  833. }
  834. else
  835. {
  836. // add shapes with their exact mask layer size in initialPolys
  837. item->TransformShapeToPolygon( initialPolys, layer, 0, maxError,
  838. ERROR_OUTSIDE );
  839. // add shapes inflated by aMinThickness/2 in areas
  840. item->TransformShapeToPolygon( areas, layer, inflate, maxError, ERROR_OUTSIDE );
  841. }
  842. }
  843. }
  844. for( ZONE* zone : aBoard->Zones() )
  845. {
  846. if( zone->GetIsRuleArea() )
  847. continue;
  848. if( !zone->IsOnLayer( layer ) )
  849. continue;
  850. // add shapes inflated by aMinThickness/2 in areas
  851. zone->TransformSmoothedOutlineToPolygon( areas, inflate + zone_margin, maxError,
  852. ERROR_OUTSIDE, boardOutline );
  853. // add shapes with their exact mask layer size in initialPolys
  854. zone->TransformSmoothedOutlineToPolygon( initialPolys, zone_margin, maxError,
  855. ERROR_OUTSIDE, boardOutline );
  856. }
  857. }
  858. // Merge all polygons: After deflating, not merged (not overlapping) polygons will have the
  859. // initial shape (with perhaps small changes due to deflating transform)
  860. areas.Simplify();
  861. areas.Deflate( inflate, CORNER_STRATEGY::CHAMFER_ALL_CORNERS, maxError );
  862. // To avoid a lot of code, use a ZONE to handle and plot polygons, because our polygons look
  863. // exactly like filled areas in zones.
  864. // Note, also this code is not optimized: it creates a lot of copy/duplicate data.
  865. // However it is not complex, and fast enough for plot purposes (copy/convert data is only a
  866. // very small calculation time for these calculations).
  867. ZONE zone( aBoard );
  868. zone.SetMinThickness( 0 ); // trace polygons only
  869. zone.SetLayer( layer );
  870. // Combine the current areas to initial areas. This is mandatory because inflate/deflate
  871. // transform is not perfect, and we want the initial areas perfectly kept
  872. areas.BooleanAdd( initialPolys );
  873. areas.Fracture();
  874. itemplotter.PlotZone( &zone, layer, areas );
  875. }
  876. /**
  877. * Set up most plot options for plotting a board (especially the viewport)
  878. * Important thing:
  879. * page size is the 'drawing' page size,
  880. * paper size is the physical page size
  881. */
  882. static void initializePlotter( PLOTTER* aPlotter, const BOARD* aBoard,
  883. const PCB_PLOT_PARAMS* aPlotOpts )
  884. {
  885. PAGE_INFO pageA4( wxT( "A4" ) );
  886. const PAGE_INFO& pageInfo = aBoard->GetPageSettings();
  887. const PAGE_INFO* sheet_info;
  888. double paperscale; // Page-to-paper ratio
  889. VECTOR2I paperSizeIU;
  890. VECTOR2I pageSizeIU( pageInfo.GetSizeIU( pcbIUScale.IU_PER_MILS ) );
  891. bool autocenter = false;
  892. // Special options: to fit the sheet to an A4 sheet replace the paper size. However there
  893. // is a difference between the autoscale and the a4paper option:
  894. // - Autoscale fits the board to the paper size
  895. // - A4paper fits the original paper size to an A4 sheet
  896. // - Both of them fit the board to an A4 sheet
  897. if( aPlotOpts->GetA4Output() )
  898. {
  899. sheet_info = &pageA4;
  900. paperSizeIU = pageA4.GetSizeIU( pcbIUScale.IU_PER_MILS );
  901. paperscale = (double) paperSizeIU.x / pageSizeIU.x;
  902. autocenter = true;
  903. }
  904. else
  905. {
  906. sheet_info = &pageInfo;
  907. paperSizeIU = pageSizeIU;
  908. paperscale = 1;
  909. // Need autocentering only if scale is not 1:1
  910. autocenter = (aPlotOpts->GetScale() != 1.0);
  911. }
  912. BOX2I bbox = aBoard->ComputeBoundingBox( false );
  913. VECTOR2I boardCenter = bbox.Centre();
  914. VECTOR2I boardSize = bbox.GetSize();
  915. double compound_scale;
  916. // Fit to 80% of the page if asked; it could be that the board is empty, in this case
  917. // regress to 1:1 scale
  918. if( aPlotOpts->GetAutoScale() && boardSize.x > 0 && boardSize.y > 0 )
  919. {
  920. double xscale = (paperSizeIU.x * 0.8) / boardSize.x;
  921. double yscale = (paperSizeIU.y * 0.8) / boardSize.y;
  922. compound_scale = std::min( xscale, yscale ) * paperscale;
  923. }
  924. else
  925. {
  926. compound_scale = aPlotOpts->GetScale() * paperscale;
  927. }
  928. // For the plot offset we have to keep in mind the auxiliary origin too: if autoscaling is
  929. // off we check that plot option (i.e. autoscaling overrides auxiliary origin)
  930. VECTOR2I offset( 0, 0);
  931. if( autocenter )
  932. {
  933. offset.x = KiROUND( boardCenter.x - ( paperSizeIU.x / 2.0 ) / compound_scale );
  934. offset.y = KiROUND( boardCenter.y - ( paperSizeIU.y / 2.0 ) / compound_scale );
  935. }
  936. else
  937. {
  938. if( aPlotOpts->GetUseAuxOrigin() )
  939. offset = aBoard->GetDesignSettings().GetAuxOrigin();
  940. }
  941. aPlotter->SetPageSettings( *sheet_info );
  942. aPlotter->SetViewport( offset, pcbIUScale.IU_PER_MILS/10, compound_scale, aPlotOpts->GetMirror() );
  943. // Has meaning only for gerber plotter. Must be called only after SetViewport
  944. aPlotter->SetGerberCoordinatesFormat( aPlotOpts->GetGerberPrecision() );
  945. // Has meaning only for SVG plotter. Must be called only after SetViewport
  946. aPlotter->SetSvgCoordinatesFormat( aPlotOpts->GetSvgPrecision() );
  947. aPlotter->SetCreator( wxT( "PCBNEW" ) );
  948. aPlotter->SetColorMode( !aPlotOpts->GetBlackAndWhite() ); // default is plot in Black and White.
  949. aPlotter->SetTextMode( aPlotOpts->GetTextMode() );
  950. }
  951. /**
  952. * Prefill in black an area a little bigger than the board to prepare for the negative plot
  953. */
  954. static void FillNegativeKnockout( PLOTTER *aPlotter, const BOX2I &aBbbox )
  955. {
  956. const int margin = 5 * pcbIUScale.IU_PER_MM; // Add a 5 mm margin around the board
  957. aPlotter->SetNegative( true );
  958. aPlotter->SetColor( WHITE ); // Which will be plotted as black
  959. BOX2I area = aBbbox;
  960. area.Inflate( margin );
  961. aPlotter->Rect( area.GetOrigin(), area.GetEnd(), FILL_T::FILLED_SHAPE );
  962. aPlotter->SetColor( BLACK );
  963. }
  964. /**
  965. * Calculate the effective size of HPGL pens and set them in the plotter object
  966. */
  967. static void ConfigureHPGLPenSizes( HPGL_PLOTTER *aPlotter, const PCB_PLOT_PARAMS *aPlotOpts )
  968. {
  969. // Compute penDiam (the value is given in mils) in pcb units, with plot scale (if Scale is 2,
  970. // penDiam value is always m_HPGLPenDiam so apparent penDiam is actually penDiam / Scale
  971. int penDiam = KiROUND( aPlotOpts->GetHPGLPenDiameter() * pcbIUScale.IU_PER_MILS / aPlotOpts->GetScale() );
  972. // Set HPGL-specific options and start
  973. aPlotter->SetPenSpeed( aPlotOpts->GetHPGLPenSpeed() );
  974. aPlotter->SetPenNumber( aPlotOpts->GetHPGLPenNum() );
  975. aPlotter->SetPenDiameter( penDiam );
  976. }
  977. /**
  978. * Open a new plotfile using the options (and especially the format) specified in the options
  979. * and prepare the page for plotting.
  980. *
  981. * @return the plotter object if OK, NULL if the file is not created (or has a problem).
  982. */
  983. PLOTTER* StartPlotBoard( BOARD *aBoard, const PCB_PLOT_PARAMS *aPlotOpts, int aLayer,
  984. const wxString& aLayerName, const wxString& aFullFileName,
  985. const wxString& aSheetName, const wxString& aSheetPath,
  986. const wxString& aPageName, const wxString& aPageNumber,
  987. const int aPageCount )
  988. {
  989. wxCHECK( aBoard && aPlotOpts, nullptr );
  990. // Create the plotter driver and set the few plotter specific options
  991. PLOTTER* plotter = nullptr;
  992. switch( aPlotOpts->GetFormat() )
  993. {
  994. case PLOT_FORMAT::DXF:
  995. DXF_PLOTTER* DXF_plotter;
  996. DXF_plotter = new DXF_PLOTTER();
  997. DXF_plotter->SetUnits( aPlotOpts->GetDXFPlotUnits() );
  998. plotter = DXF_plotter;
  999. break;
  1000. case PLOT_FORMAT::POST:
  1001. PS_PLOTTER* PS_plotter;
  1002. PS_plotter = new PS_PLOTTER();
  1003. PS_plotter->SetScaleAdjust( aPlotOpts->GetFineScaleAdjustX(),
  1004. aPlotOpts->GetFineScaleAdjustY() );
  1005. plotter = PS_plotter;
  1006. break;
  1007. case PLOT_FORMAT::PDF:
  1008. plotter = new PDF_PLOTTER( aBoard->GetProject() );
  1009. break;
  1010. case PLOT_FORMAT::HPGL:
  1011. HPGL_PLOTTER* HPGL_plotter;
  1012. HPGL_plotter = new HPGL_PLOTTER();
  1013. // HPGL options are a little more convoluted to compute, so they get their own function
  1014. ConfigureHPGLPenSizes( HPGL_plotter, aPlotOpts );
  1015. plotter = HPGL_plotter;
  1016. break;
  1017. case PLOT_FORMAT::GERBER:
  1018. // For Gerber plotter, a valid board layer must be set, in order to create a valid
  1019. // Gerber header, especially the TF.FileFunction and .FilePolarity data
  1020. if( aLayer < PCBNEW_LAYER_ID_START || aLayer >= PCB_LAYER_ID_COUNT )
  1021. {
  1022. wxLogError( wxString::Format(
  1023. "Invalid board layer %d, cannot build a valid Gerber file header",
  1024. aLayer ) );
  1025. }
  1026. plotter = new GERBER_PLOTTER();
  1027. break;
  1028. case PLOT_FORMAT::SVG:
  1029. plotter = new SVG_PLOTTER();
  1030. break;
  1031. default:
  1032. wxASSERT( false );
  1033. return nullptr;
  1034. }
  1035. KIGFX::PCB_RENDER_SETTINGS* renderSettings = new KIGFX::PCB_RENDER_SETTINGS();
  1036. renderSettings->LoadColors( aPlotOpts->ColorSettings() );
  1037. renderSettings->SetDefaultPenWidth( pcbIUScale.mmToIU( 0.0212 ) ); // Hairline at 1200dpi
  1038. renderSettings->SetLayerName( aLayerName );
  1039. plotter->SetRenderSettings( renderSettings );
  1040. // Compute the viewport and set the other options
  1041. // page layout is not mirrored, so temporarily change mirror option for the page layout
  1042. PCB_PLOT_PARAMS plotOpts = *aPlotOpts;
  1043. if( plotOpts.GetPlotFrameRef() && plotOpts.GetMirror() )
  1044. plotOpts.SetMirror( false );
  1045. initializePlotter( plotter, aBoard, &plotOpts );
  1046. if( plotter->OpenFile( aFullFileName ) )
  1047. {
  1048. plotter->ClearHeaderLinesList();
  1049. // For the Gerber "file function" attribute, set the layer number
  1050. if( plotter->GetPlotterType() == PLOT_FORMAT::GERBER )
  1051. {
  1052. bool useX2mode = plotOpts.GetUseGerberX2format();
  1053. GERBER_PLOTTER* gbrplotter = static_cast <GERBER_PLOTTER*> ( plotter );
  1054. gbrplotter->DisableApertMacros( plotOpts.GetDisableGerberMacros() );
  1055. gbrplotter->UseX2format( useX2mode );
  1056. gbrplotter->UseX2NetAttributes( plotOpts.GetIncludeGerberNetlistInfo() );
  1057. // Attributes can be added using X2 format or as comment (X1 format)
  1058. AddGerberX2Attribute( plotter, aBoard, aLayer, not useX2mode );
  1059. }
  1060. bool startPlotSuccess = false;
  1061. if (plotter->GetPlotterType() == PLOT_FORMAT::PDF)
  1062. {
  1063. startPlotSuccess =
  1064. static_cast<PDF_PLOTTER*>( plotter )->StartPlot( aPageNumber, aPageName );
  1065. }
  1066. else
  1067. {
  1068. startPlotSuccess = plotter->StartPlot( aPageName );
  1069. }
  1070. if( startPlotSuccess )
  1071. {
  1072. // Plot the frame reference if requested
  1073. if( aPlotOpts->GetPlotFrameRef() )
  1074. {
  1075. PlotDrawingSheet( plotter, aBoard->GetProject(), aBoard->GetTitleBlock(),
  1076. aBoard->GetPageSettings(), &aBoard->GetProperties(), aPageNumber,
  1077. aPageCount, aSheetName, aSheetPath, aBoard->GetFileName(),
  1078. renderSettings->GetLayerColor( LAYER_DRAWINGSHEET ) );
  1079. if( aPlotOpts->GetMirror() )
  1080. initializePlotter( plotter, aBoard, aPlotOpts );
  1081. }
  1082. // When plotting a negative board: draw a black rectangle (background for plot board
  1083. // in white) and switch the current color to WHITE; note the color inversion is actually
  1084. // done in the driver (if supported)
  1085. if( aPlotOpts->GetNegative() )
  1086. {
  1087. BOX2I bbox = aBoard->ComputeBoundingBox( false );
  1088. FillNegativeKnockout( plotter, bbox );
  1089. }
  1090. return plotter;
  1091. }
  1092. }
  1093. delete plotter->RenderSettings();
  1094. delete plotter;
  1095. return nullptr;
  1096. }
  1097. void setupPlotterNewPDFPage( PLOTTER* aPlotter,
  1098. BOARD* aBoard,
  1099. const PCB_PLOT_PARAMS* aPlotOpts,
  1100. const wxString& aSheetName, const wxString& aSheetPath,
  1101. const wxString& aPageNumber, int aPageCount )
  1102. {
  1103. // Plot the frame reference if requested
  1104. if( aPlotOpts->GetPlotFrameRef() )
  1105. {
  1106. PlotDrawingSheet( aPlotter, aBoard->GetProject(), aBoard->GetTitleBlock(),
  1107. aBoard->GetPageSettings(), &aBoard->GetProperties(), aPageNumber,
  1108. aPageCount,
  1109. aSheetName, aSheetPath, aBoard->GetFileName(),
  1110. aPlotter->RenderSettings()->GetLayerColor( LAYER_DRAWINGSHEET ) );
  1111. if( aPlotOpts->GetMirror() )
  1112. initializePlotter( aPlotter, aBoard, aPlotOpts );
  1113. }
  1114. }