KiCad PCB EDA Suite
export_to_pcbnew.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2007-2014 Jean-Pierre Charras jp.charras at wanadoo.fr
5  * Copyright (C) 1992-2017 KiCad Developers, see change_log.txt for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
30 #include <vector>
31 
32 #include <fctsys.h>
33 #include <common.h>
34 #include <confirm.h>
35 #include <macros.h>
36 #include <trigo.h>
37 #include <gerbview.h>
38 #include <gerbview_frame.h>
39 #include <gerber_file_image.h>
40 #include <gerber_file_image_list.h>
41 #include <select_layers_to_pcb.h>
42 #include <build_version.h>
44 
45 
46 // Imported function
47 extern const wxString GetPCBDefaultLayerName( LAYER_NUM aLayerNumber );
48 
49 
50 /* A helper class to export a Gerber set of files to Pcbnew
51  */
53 {
54 private:
55  GERBVIEW_FRAME* m_gerbview_frame; // the main gerber frame
56  wxString m_pcb_file_name; // BOARD file to write to
57  FILE* m_fp; // the board file
59  std::vector<wxPoint> m_vias_coordinates; // list of already generated vias,
60  // used to export only once a via
61  // having a given coordinate
62 public:
63  GBR_TO_PCB_EXPORTER( GERBVIEW_FRAME* aFrame, const wxString& aFileName );
65 
70  bool ExportPcb( LAYER_NUM* aLayerLookUpTable, int aCopperLayers );
71 
72 private:
78  void export_non_copper_item( GERBER_DRAW_ITEM* aGbrItem, LAYER_NUM aLayer );
79 
85  void writePcbPolygonItem( GERBER_DRAW_ITEM* aGbrItem, LAYER_NUM aLayer );
86 
93  void writePcbZoneItem( GERBER_DRAW_ITEM* aGbrItem, LAYER_NUM aLayer );
94 
100  void export_copper_item( GERBER_DRAW_ITEM* aGbrItem, LAYER_NUM aLayer );
101 
108 
115  void export_segline_copper_item( GERBER_DRAW_ITEM* aGbrItem, LAYER_NUM aLayer );
116 
124  void export_segarc_copper_item( GERBER_DRAW_ITEM* aGbrItem, LAYER_NUM aLayer );
125 
131  void writePcbLineItem( bool aIsArc, wxPoint& aStart, wxPoint& aEnd,
132  int aWidth, LAYER_NUM aLayer, double aAngle = 0 );
133 
139  void writeCopperLineItem( wxPoint& aStart, wxPoint& aEnd,
140  int aWidth, LAYER_NUM aLayer );
141 
146  void writePcbHeader( LAYER_NUM* aLayerLookUpTable );
147 
152  double MapToPcbUnits( int aValue )
153  {
154  return aValue / IU_PER_MM;
155  }
156 };
157 
158 
159 GBR_TO_PCB_EXPORTER::GBR_TO_PCB_EXPORTER( GERBVIEW_FRAME* aFrame, const wxString& aFileName )
160 {
161  m_gerbview_frame = aFrame;
162  m_pcb_file_name = aFileName;
163  m_fp = NULL;
165 }
166 
167 
169 {
170 }
171 
172 
173 /* Export data in Pcbnew format
174  * remember Pcbnew uses a Y reversed axis, so we must negate all Y coordinates
175  */
176 void GERBVIEW_FRAME::ExportDataInPcbnewFormat( wxCommandEvent& event )
177 {
178  int layercount = 0;
179 
181 
182  // Count the Gerber layers which are actually currently used
183  for( LAYER_NUM ii = 0; ii < (LAYER_NUM)images->ImagesMaxCount(); ++ii )
184  {
185  if( images->GetGbrImage( ii ) )
186  layercount++;
187  }
188 
189  if( layercount == 0 )
190  {
191  DisplayInfoMessage( this,
192  _( "None of the Gerber layers contain any data" ) );
193  return;
194  }
195 
196  wxString fileDialogName( wxT( "noname." ) + KiCadPcbFileExtension );
197  wxString path = m_mruPath;
198 
199  wxFileDialog filedlg( this, _( "Board File Name" ),
200  path, fileDialogName, PcbFileWildcard(),
201  wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
202 
203  if( filedlg.ShowModal() == wxID_CANCEL )
204  return;
205 
206  wxFileName fileName = filedlg.GetPath();
207 
208  /* Install a dialog frame to choose the mapping
209  * between gerber layers and Pcbnew layers
210  */
211  LAYERS_MAP_DIALOG* layerdlg = new LAYERS_MAP_DIALOG( this );
212  int ok = layerdlg->ShowModal();
213  layerdlg->Destroy();
214 
215  if( ok != wxID_OK )
216  return;
217 
218  // If no extension was entered, then force the extension to be a KiCad PCB file
219  if( !fileName.HasExt() )
220  fileName.SetExt( KiCadPcbFileExtension );
221 
222  m_mruPath = fileName.GetPath();
223 
224  GBR_TO_PCB_EXPORTER gbr_exporter( this, fileName.GetFullPath() );
225 
226  gbr_exporter.ExportPcb( layerdlg->GetLayersLookUpTable(), layerdlg->GetCopperLayersCount() );
227 }
228 
229 
230 bool GBR_TO_PCB_EXPORTER::ExportPcb( LAYER_NUM* aLayerLookUpTable, int aCopperLayers )
231 {
232  LOCALE_IO toggle; // toggles on, then off, the C locale.
233 
234  m_fp = wxFopen( m_pcb_file_name, wxT( "wt" ) );
235 
236  if( m_fp == NULL )
237  {
238  wxString msg;
239  msg.Printf( _( "Cannot create file \"%s\"" ), GetChars( m_pcb_file_name ) );
241  return false;
242  }
243 
244  m_pcbCopperLayersCount = aCopperLayers;
245 
246  writePcbHeader( aLayerLookUpTable );
247 
248  // create an image of gerber data
249  // First: non copper layers:
250  const int pcbCopperLayerMax = 31;
252 
253  for( unsigned layer = 0; layer < images->ImagesMaxCount(); ++layer )
254  {
255  GERBER_FILE_IMAGE* gerber = images->GetGbrImage( layer );
256 
257  if( gerber == NULL ) // Graphic layer not yet used
258  continue;
259 
260  LAYER_NUM pcb_layer_number = aLayerLookUpTable[layer];
261 
262  if( !IsPcbLayer( pcb_layer_number ) )
263  continue;
264 
265  if( pcb_layer_number <= pcbCopperLayerMax ) // copper layer
266  continue;
267 
268  for( GERBER_DRAW_ITEM* gerb_item : gerber->GetItems() )
269  export_non_copper_item( gerb_item, pcb_layer_number );
270  }
271 
272  // Copper layers
273  for( unsigned layer = 0; layer < images->ImagesMaxCount(); ++layer )
274  {
275  GERBER_FILE_IMAGE* gerber = images->GetGbrImage( layer );
276 
277  if( gerber == NULL ) // Graphic layer not yet used
278  continue;
279 
280  LAYER_NUM pcb_layer_number = aLayerLookUpTable[layer];
281 
282  if( pcb_layer_number < 0 || pcb_layer_number > pcbCopperLayerMax )
283  continue;
284 
285  for( GERBER_DRAW_ITEM* gerb_item : gerber->GetItems() )
286  export_copper_item( gerb_item, pcb_layer_number );
287  }
288 
289  fprintf( m_fp, ")\n" );
290 
291  fclose( m_fp );
292  m_fp = NULL;
293  return true;
294 }
295 
296 
298 {
299  bool isArc = false;
300 
301  double angle = 0;
302  wxPoint seg_start = aGbrItem->m_Start;
303  wxPoint seg_end = aGbrItem->m_End;
304 
305  if( aGbrItem->m_Shape == GBR_POLYGON )
306  {
307  writePcbPolygonItem( aGbrItem, aLayer );
308  return;
309  }
310 
311  if( aGbrItem->m_Shape == GBR_ARC )
312  {
313  double a = atan2( (double) ( aGbrItem->m_Start.y - aGbrItem->m_ArcCentre.y),
314  (double) ( aGbrItem->m_Start.x - aGbrItem->m_ArcCentre.x ) );
315  double b = atan2( (double) ( aGbrItem->m_End.y - aGbrItem->m_ArcCentre.y ),
316  (double) ( aGbrItem->m_End.x - aGbrItem->m_ArcCentre.x ) );
317 
318  isArc = true;
319  angle = RAD2DEG(b - a);
320  seg_start = aGbrItem->m_ArcCentre;
321 
322  // Ensure arc orientation is CCW
323  if( angle < 0 )
324  angle += 360.0;
325  }
326 
327  // Reverse Y axis:
328  seg_start.y = -seg_start.y;
329  seg_end.y = -seg_end.y;
330  writePcbLineItem( isArc, seg_start, seg_end, aGbrItem->m_Size.x, aLayer, angle );
331 }
332 
333 
335 {
336  switch( aGbrItem->m_Shape )
337  {
338  case GBR_SPOT_CIRCLE:
339  case GBR_SPOT_RECT:
340  case GBR_SPOT_OVAL:
341  // replace spots with vias when possible
342  export_flashed_copper_item( aGbrItem );
343  break;
344 
345  case GBR_ARC:
346  export_segarc_copper_item( aGbrItem, aLayer );
347  break;
348 
349  case GBR_POLYGON:
350  // One can use a polygon or a zone to output a Gerber region.
351  // none are perfect.
352  // The current way is use a polygon, as the zone export
353  // is exprimental and only for tests.
354 #if 1
355  writePcbPolygonItem( aGbrItem, aLayer );
356 #else
357  // Only for tests:
358  writePcbZoneItem( aGbrItem, aLayer );
359 #endif
360  break;
361 
362  default:
363  export_segline_copper_item( aGbrItem, aLayer );
364  break;
365  }
366 }
367 
368 
370 {
371  wxPoint seg_start, seg_end;
372 
373  seg_start = aGbrItem->m_Start;
374  seg_end = aGbrItem->m_End;
375 
376  // Reverse Y axis:
377  seg_start.y = -seg_start.y;
378  seg_end.y = -seg_end.y;
379 
380  writeCopperLineItem( seg_start, seg_end, aGbrItem->m_Size.x, aLayer );
381 }
382 
383 
385  int aWidth, LAYER_NUM aLayer )
386 {
387  fprintf( m_fp, "(segment (start %s %s) (end %s %s) (width %s) (layer %s) (net 0))\n",
388  Double2Str( MapToPcbUnits(aStart.x) ).c_str(),
389  Double2Str( MapToPcbUnits(aStart.y) ).c_str(),
390  Double2Str( MapToPcbUnits(aEnd.x) ).c_str(),
391  Double2Str( MapToPcbUnits(aEnd.y) ).c_str(),
392  Double2Str( MapToPcbUnits( aWidth ) ).c_str(),
393  TO_UTF8( GetPCBDefaultLayerName( aLayer ) ) );
394 }
395 
396 
398 {
399  double a = atan2( (double) ( aGbrItem->m_Start.y - aGbrItem->m_ArcCentre.y ),
400  (double) ( aGbrItem->m_Start.x - aGbrItem->m_ArcCentre.x ) );
401  double b = atan2( (double) ( aGbrItem->m_End.y - aGbrItem->m_ArcCentre.y ),
402  (double) ( aGbrItem->m_End.x - aGbrItem->m_ArcCentre.x ) );
403 
404  wxPoint start = aGbrItem->m_Start;
405  wxPoint end = aGbrItem->m_End;
406 
407  /* Because Pcbnew does not know arcs in tracks,
408  * approximate arc by segments (SEG_COUNT__CIRCLE segment per 360 deg)
409  * The arc is drawn anticlockwise from the start point to the end point.
410  */
411  #define SEG_COUNT_CIRCLE 16
412  #define DELTA_ANGLE 2 * M_PI / SEG_COUNT_CIRCLE
413 
414  // calculate the number of segments from a to b.
415  // we want CNT_PER_360 segments fo a circle
416  if( a > b )
417  b += 2 * M_PI;
418 
419  wxPoint curr_start = start;
420  wxPoint seg_start, seg_end;
421 
422  int ii = 1;
423 
424  for( double rot = a; rot < (b - DELTA_ANGLE); rot += DELTA_ANGLE, ii++ )
425  {
426  seg_start = curr_start;
427  wxPoint curr_end = start;
428  RotatePoint( &curr_end, aGbrItem->m_ArcCentre,
429  -RAD2DECIDEG( DELTA_ANGLE * ii ) );
430  seg_end = curr_end;
431  // Reverse Y axis:
432  seg_start.y = -seg_start.y;
433  seg_end.y = -seg_end.y;
434  writeCopperLineItem( seg_start, seg_end, aGbrItem->m_Size.x, aLayer );
435  curr_start = curr_end;
436  }
437 
438  if( end != curr_start )
439  {
440  seg_start = curr_start;
441  seg_end = end;
442  // Reverse Y axis:
443  seg_start.y = -seg_start.y;
444  seg_end.y = -seg_end.y;
445  writeCopperLineItem( seg_start, seg_end, aGbrItem->m_Size.x, aLayer );
446  }
447 }
448 
449 
450 /*
451  * creates a via from a flashed gerber item.
452  * Flashed items are usually pads or vias, so we try to export all of them
453  * using vias
454  */
456 {
457  // First, explore already created vias, before creating a new via
458  for( unsigned ii = 0; ii < m_vias_coordinates.size(); ii++ )
459  {
460  if( m_vias_coordinates[ii] == aGbrItem->m_Start ) // Already created
461  return;
462  }
463 
464  m_vias_coordinates.push_back( aGbrItem->m_Start );
465 
466  wxPoint via_pos = aGbrItem->m_Start;
467  int width = (aGbrItem->m_Size.x + aGbrItem->m_Size.y) / 2;
468  // Reverse Y axis:
469  via_pos.y = -via_pos.y;
470 
471  // Layers are Front to Back
472  fprintf( m_fp, " (via (at %s %s) (size %s)",
473  Double2Str( MapToPcbUnits(via_pos.x) ).c_str(),
474  Double2Str( MapToPcbUnits(via_pos.y) ).c_str(),
475  Double2Str( MapToPcbUnits( width ) ).c_str() );
476 
477  fprintf( m_fp, " (layers %s %s))\n",
480 }
481 
483 {
484  fprintf( m_fp, "(kicad_pcb (version 4) (host Gerbview \"%s\")\n\n",
485  TO_UTF8( GetBuildVersion() ) );
486 
487  // Write layers section
488  fprintf( m_fp, " (layers \n" );
489 
490  for( int ii = 0; ii < m_pcbCopperLayersCount; ii++ )
491  {
492  int id = ii;
493 
494  if( ii == m_pcbCopperLayersCount-1)
495  id = B_Cu;
496 
497  fprintf( m_fp, " (%d %s signal)\n", id, TO_UTF8( GetPCBDefaultLayerName( id ) ) );
498  }
499 
500  for( int ii = B_Adhes; ii < PCB_LAYER_ID_COUNT; ii++ )
501  {
502  if( GetPCBDefaultLayerName( ii ).IsEmpty() ) // Layer not available for export
503  continue;
504 
505  fprintf( m_fp, " (%d %s user)\n", ii, TO_UTF8( GetPCBDefaultLayerName( ii ) ) );
506  }
507 
508  fprintf( m_fp, " )\n\n" );
509 }
510 
511 
512 void GBR_TO_PCB_EXPORTER::writePcbLineItem( bool aIsArc, wxPoint& aStart, wxPoint& aEnd,
513  int aWidth, LAYER_NUM aLayer, double aAngle )
514 {
515  if( aIsArc && ( aAngle == 360.0 || aAngle == 0 ) )
516  {
517  fprintf( m_fp, "(gr_circle (center %s %s) (end %s %s)(layer %s) (width %s))\n",
518  Double2Str( MapToPcbUnits(aStart.x) ).c_str(),
519  Double2Str( MapToPcbUnits(aStart.y) ).c_str(),
520  Double2Str( MapToPcbUnits(aEnd.x) ).c_str(),
521  Double2Str( MapToPcbUnits(aEnd.y) ).c_str(),
522  TO_UTF8( GetPCBDefaultLayerName( aLayer ) ),
523  Double2Str( MapToPcbUnits( aWidth ) ).c_str()
524  );
525  }
526  else if( aIsArc )
527  {
528  fprintf( m_fp, "(gr_arc (start %s %s) (end %s %s) (angle %s)(layer %s) (width %s))\n",
529  Double2Str( MapToPcbUnits(aStart.x) ).c_str(),
530  Double2Str( MapToPcbUnits(aStart.y) ).c_str(),
531  Double2Str( MapToPcbUnits(aEnd.x) ).c_str(),
532  Double2Str( MapToPcbUnits(aEnd.y) ).c_str(),
533  Double2Str( aAngle ).c_str(),
534  TO_UTF8( GetPCBDefaultLayerName( aLayer ) ),
535  Double2Str( MapToPcbUnits( aWidth ) ).c_str()
536  );
537  }
538  else
539  {
540  fprintf( m_fp, "(gr_line (start %s %s) (end %s %s)(layer %s) (width %s))\n",
541  Double2Str( MapToPcbUnits(aStart.x) ).c_str(),
542  Double2Str( MapToPcbUnits(aStart.y) ).c_str(),
543  Double2Str( MapToPcbUnits(aEnd.x) ).c_str(),
544  Double2Str( MapToPcbUnits(aEnd.y) ).c_str(),
545  TO_UTF8( GetPCBDefaultLayerName( aLayer ) ),
546  Double2Str( MapToPcbUnits( aWidth ) ).c_str()
547  );
548  }
549 }
550 
551 
553 {
554  SHAPE_POLY_SET polys = aGbrItem->m_Polygon;
555 
556  // Cleanup the polygon
558 
559  // Ensure the polygon is valid:
560  if( polys.OutlineCount() == 0 )
561  return;
562 
564 
565  SHAPE_LINE_CHAIN& poly = polys.Outline( 0 );
566 
567  fprintf( m_fp, "(gr_poly (pts " );
568 
569  #define MAX_COORD_CNT 4
570  int jj = MAX_COORD_CNT;
571  int cnt_max = poly.PointCount() -1;
572 
573  // Do not generate last corner, if it is the same point as the first point:
574  if( poly.CPoint( 0 ) == poly.CPoint( cnt_max ) )
575  cnt_max--;
576 
577  for( int ii = 0; ii <= cnt_max; ii++ )
578  {
579  if( --jj == 0 )
580  {
581  jj = MAX_COORD_CNT;
582  fprintf( m_fp, "\n" );
583  }
584 
585  fprintf( m_fp, " (xy %s %s)", Double2Str( MapToPcbUnits( poly.CPoint( ii ).x ) ).c_str(),
586  Double2Str( MapToPcbUnits( -poly.CPoint( ii ).y ) ).c_str() );
587  }
588 
589  fprintf( m_fp, ")" );
590 
591  if( jj != MAX_COORD_CNT )
592  fprintf( m_fp, "\n" );
593 
594  fprintf( m_fp, "(layer %s) (width 0) )\n",
595  TO_UTF8( GetPCBDefaultLayerName( aLayer ) ) );
596 }
597 
598 
600 {
601  SHAPE_POLY_SET polys = aGbrItem->m_Polygon;
603 
604  if( polys.OutlineCount() == 0 )
605  return;
606 
607  fprintf( m_fp, "(zone (net 0) (net_name \"\") (layer %s) (tstamp 0000000) (hatch edge 0.508)\n",
608  TO_UTF8( GetPCBDefaultLayerName( aLayer ) ) );
609 
610  fprintf( m_fp, " (connect_pads (clearance 0.0))\n" );
611 
612  fprintf( m_fp, " (min_thickness 0.1) (filled_areas_thickness no)\n"
613  " (fill (thermal_gap 0.3) (thermal_bridge_width 0.3))\n" );
614 
615  // Now, write the zone outlines with holes.
616  // first polygon is the main outline, next are holes
617  // One cannot know the initial zone outline.
618  // However most of (if not all) holes are just items with clearance,
619  // not really a hole in the initial zone outline.
620  // So we build a zone outline only with no hole.
621  fprintf( m_fp, " (polygon\n (pts" );
622 
623  SHAPE_LINE_CHAIN& poly = polys.Outline( 0 );
624 
625  #define MAX_COORD_CNT 4
626  int jj = MAX_COORD_CNT;
627  int cnt_max = poly.PointCount() -1;
628 
629  // Do not generate last corner, if it is the same point as the first point:
630  if( poly.CPoint( 0 ) == poly.CPoint( cnt_max ) )
631  cnt_max--;
632 
633  for( int ii = 0; ii <= cnt_max; ii++ )
634  {
635  if( --jj == 0 )
636  {
637  jj = MAX_COORD_CNT;
638  fprintf( m_fp, "\n " );
639  }
640 
641  fprintf( m_fp, " (xy %s %s)", Double2Str( MapToPcbUnits( poly.CPoint( ii ).x ) ).c_str(),
642  Double2Str( MapToPcbUnits( -poly.CPoint( ii ).y ) ).c_str() );
643  }
644 
645  fprintf( m_fp, ")\n" );
646 
647  fprintf( m_fp, " )\n)\n" );
648 }
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:239
void writePcbLineItem(bool aIsArc, wxPoint &aStart, wxPoint &aEnd, int aWidth, LAYER_NUM aLayer, double aAngle=0)
function writePcbLineItem basic write function to write a DRAWSEGMENT item or a TRACK item to the boa...
int OutlineCount() const
Returns the number of outlines in the set
wxString m_mruPath
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: common.h:202
GERBER_DRAW_ITEMS & GetItems()
This file is part of the common library.
GBR_TO_PCB_EXPORTER(GERBVIEW_FRAME *aFrame, const wxString &aFileName)
double RAD2DEG(double rad)
Definition: trigo.h:215
GERBER_FILE_IMAGE holds the Image data and parameters for one gerber file and layer parameters (TODO:...
LAYER_NUM * GetLayersLookUpTable()
void export_segline_copper_item(GERBER_DRAW_ITEM *aGbrItem, LAYER_NUM aLayer)
Function export_segline_copper_item write a track (not via) to the board file.
double RAD2DECIDEG(double rad)
Definition: trigo.h:219
void export_non_copper_item(GERBER_DRAW_ITEM *aGbrItem, LAYER_NUM aLayer)
write a non copper line or arc to the board file.
std::string Double2Str(double aValue)
Helper function Double2Str to print a float number without using scientific notation and no trailing ...
Definition: base_units.cpp:65
#define DELTA_ANGLE
const std::string KiCadPcbFileExtension
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:208
GERBER_FILE_IMAGE_LIST is a helper class to handle a list of GERBER_FILE_IMAGE files which are loaded...
int PointCount() const
Function PointCount()
SHAPE_POLY_SET m_Polygon
static int GetCopperLayersCount()
This file contains miscellaneous commonly used macros and functions.
#define TO_UTF8(wxstring)
Macro TO_UTF8 converts a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:48
const VECTOR2I & CPoint(int aIndex) const
Function Point()
void writePcbZoneItem(GERBER_DRAW_ITEM *aGbrItem, LAYER_NUM aLayer)
write a zone item to the board file.
#define NULL
GERBER_FILE_IMAGE * GetGbrImage(int aIdx)
wxString GetBuildVersion()
Get the full KiCad version string.
bool ExportPcb(LAYER_NUM *aLayerLookUpTable, int aCopperLayers)
Function ExportPcb saves a board from a set of Gerber images.
SHAPE_POLY_SET.
SHAPE_LINE_CHAIN & Outline(int aIndex)
Returns the reference to aIndex-th outline in the set
void export_flashed_copper_item(GERBER_DRAW_ITEM *aGbrItem)
Function export_flashed_copper_item write a via to the board file (always uses a via through).
std::vector< wxPoint > m_vias_coordinates
GERBVIEW_FRAME * m_gerbview_frame
Definition of file extensions used in Kicad.
void writeCopperLineItem(wxPoint &aStart, wxPoint &aEnd, int aWidth, LAYER_NUM aLayer)
function writeCopperLineItem basic write function to write a a TRACK item to the board file,...
void Simplify(POLYGON_MODE aFastMode)
Simplifies the polyset (merges overlapping polys, eliminates degeneracy/self-intersections) For aFast...
void Fracture(POLYGON_MODE aFastMode)
Converts a set of polygons with holes to a singe outline with "slits"/"fractures" connecting the oute...
int LAYER_NUM
Type LAYER_NUM can be replaced with int and removed.
GBR_LAYOUT * GetGerberLayout() const
void export_copper_item(GERBER_DRAW_ITEM *aGbrItem, LAYER_NUM aLayer)
write a track or via) to the board file.
void ExportDataInPcbnewFormat(wxCommandEvent &event)
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:101
#define MAX_COORD_CNT
#define _(s)
Definition: 3d_actions.cpp:33
SHAPE_LINE_CHAIN.
void export_segarc_copper_item(GERBER_DRAW_ITEM *aGbrItem, LAYER_NUM aLayer)
Function export_segarc_copper_item write a set of tracks (arcs are approximated by track segments) to...
void writePcbPolygonItem(GERBER_DRAW_ITEM *aGbrItem, LAYER_NUM aLayer)
write anot filled polygon item to the board file.
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
const wxString GetPCBDefaultLayerName(LAYER_NUM aLayerNumber)
GERBER_FILE_IMAGE_LIST * GetImagesList() const
Definition: gbr_layout.cpp:44
wxString PcbFileWildcard()
The common library.
bool IsPcbLayer(LAYER_NUM aLayer)
Function IsPcbLayer tests whether a layer is a valid layer for pcbnew.
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
Definition: confirm.cpp:267
double MapToPcbUnits(int aValue)
In Pcbnew files units are mm for coordinates.
void writePcbHeader(LAYER_NUM *aLayerLookUpTable)
function writePcbHeader Write a very basic header to the board file