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 fileName;
197  wxString path = m_mruPath;
198 
199  wxFileDialog filedlg( this, _( "Board File Name" ),
200  path, fileName, PcbFileWildcard(),
201  wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
202 
203  if( filedlg.ShowModal() == wxID_CANCEL )
204  return;
205 
206  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  m_mruPath = wxFileName( fileName ).GetPath();
219 
220  GBR_TO_PCB_EXPORTER gbr_exporter( this, fileName );
221 
222  gbr_exporter.ExportPcb( layerdlg->GetLayersLookUpTable(), layerdlg->GetCopperLayersCount() );
223 }
224 
225 
226 bool GBR_TO_PCB_EXPORTER::ExportPcb( LAYER_NUM* aLayerLookUpTable, int aCopperLayers )
227 {
228  LOCALE_IO toggle; // toggles on, then off, the C locale.
229 
230  m_fp = wxFopen( m_pcb_file_name, wxT( "wt" ) );
231 
232  if( m_fp == NULL )
233  {
234  wxString msg;
235  msg.Printf( _( "Cannot create file \"%s\"" ), GetChars( m_pcb_file_name ) );
237  return false;
238  }
239 
240  m_pcbCopperLayersCount = aCopperLayers;
241 
242  writePcbHeader( aLayerLookUpTable );
243 
244  // create an image of gerber data
245  // First: non copper layers:
246  const int pcbCopperLayerMax = 31;
248 
249  for( unsigned layer = 0; layer < images->ImagesMaxCount(); ++layer )
250  {
251  GERBER_FILE_IMAGE* gerber = images->GetGbrImage( layer );
252 
253  if( gerber == NULL ) // Graphic layer not yet used
254  continue;
255 
256  LAYER_NUM pcb_layer_number = aLayerLookUpTable[layer];
257 
258  if( !IsPcbLayer( pcb_layer_number ) )
259  continue;
260 
261  if( pcb_layer_number <= pcbCopperLayerMax ) // copper layer
262  continue;
263 
264  for( GERBER_DRAW_ITEM* gerb_item : gerber->GetItems() )
265  export_non_copper_item( gerb_item, pcb_layer_number );
266  }
267 
268  // Copper layers
269  for( unsigned layer = 0; layer < images->ImagesMaxCount(); ++layer )
270  {
271  GERBER_FILE_IMAGE* gerber = images->GetGbrImage( layer );
272 
273  if( gerber == NULL ) // Graphic layer not yet used
274  continue;
275 
276  LAYER_NUM pcb_layer_number = aLayerLookUpTable[layer];
277 
278  if( pcb_layer_number < 0 || pcb_layer_number > pcbCopperLayerMax )
279  continue;
280 
281  for( GERBER_DRAW_ITEM* gerb_item : gerber->GetItems() )
282  export_copper_item( gerb_item, pcb_layer_number );
283  }
284 
285  fprintf( m_fp, ")\n" );
286 
287  fclose( m_fp );
288  m_fp = NULL;
289  return true;
290 }
291 
292 
294 {
295  bool isArc = false;
296 
297  double angle = 0;
298  wxPoint seg_start = aGbrItem->m_Start;
299  wxPoint seg_end = aGbrItem->m_End;
300 
301  if( aGbrItem->m_Shape == GBR_POLYGON )
302  {
303  writePcbPolygonItem( aGbrItem, aLayer );
304  return;
305  }
306 
307  if( aGbrItem->m_Shape == GBR_ARC )
308  {
309  double a = atan2( (double) ( aGbrItem->m_Start.y - aGbrItem->m_ArcCentre.y),
310  (double) ( aGbrItem->m_Start.x - aGbrItem->m_ArcCentre.x ) );
311  double b = atan2( (double) ( aGbrItem->m_End.y - aGbrItem->m_ArcCentre.y ),
312  (double) ( aGbrItem->m_End.x - aGbrItem->m_ArcCentre.x ) );
313 
314  isArc = true;
315  angle = RAD2DEG(b - a);
316  seg_start = aGbrItem->m_ArcCentre;
317 
318  // Ensure arc orientation is CCW
319  if( angle < 0 )
320  angle += 360.0;
321  }
322 
323  // Reverse Y axis:
324  seg_start.y = -seg_start.y;
325  seg_end.y = -seg_end.y;
326  writePcbLineItem( isArc, seg_start, seg_end, aGbrItem->m_Size.x, aLayer, angle );
327 }
328 
329 
331 {
332  switch( aGbrItem->m_Shape )
333  {
334  case GBR_SPOT_CIRCLE:
335  case GBR_SPOT_RECT:
336  case GBR_SPOT_OVAL:
337  // replace spots with vias when possible
338  export_flashed_copper_item( aGbrItem );
339  break;
340 
341  case GBR_ARC:
342  export_segarc_copper_item( aGbrItem, aLayer );
343  break;
344 
345  case GBR_POLYGON:
346  // One can use a polygon or a zone to output a Gerber region.
347  // none are perfect.
348  // The current way is use a polygon, as the zone export
349  // is exprimental and only for tests.
350 #if 1
351  writePcbPolygonItem( aGbrItem, aLayer );
352 #else
353  // Only for tests:
354  writePcbZoneItem( aGbrItem, aLayer );
355 #endif
356  break;
357 
358  default:
359  export_segline_copper_item( aGbrItem, aLayer );
360  break;
361  }
362 }
363 
364 
366 {
367  wxPoint seg_start, seg_end;
368 
369  seg_start = aGbrItem->m_Start;
370  seg_end = aGbrItem->m_End;
371 
372  // Reverse Y axis:
373  seg_start.y = -seg_start.y;
374  seg_end.y = -seg_end.y;
375 
376  writeCopperLineItem( seg_start, seg_end, aGbrItem->m_Size.x, aLayer );
377 }
378 
379 
381  int aWidth, LAYER_NUM aLayer )
382 {
383  fprintf( m_fp, "(segment (start %s %s) (end %s %s) (width %s) (layer %s) (net 0))\n",
384  Double2Str( MapToPcbUnits(aStart.x) ).c_str(),
385  Double2Str( MapToPcbUnits(aStart.y) ).c_str(),
386  Double2Str( MapToPcbUnits(aEnd.x) ).c_str(),
387  Double2Str( MapToPcbUnits(aEnd.y) ).c_str(),
388  Double2Str( MapToPcbUnits( aWidth ) ).c_str(),
389  TO_UTF8( GetPCBDefaultLayerName( aLayer ) ) );
390 }
391 
392 
394 {
395  double a = atan2( (double) ( aGbrItem->m_Start.y - aGbrItem->m_ArcCentre.y ),
396  (double) ( aGbrItem->m_Start.x - aGbrItem->m_ArcCentre.x ) );
397  double b = atan2( (double) ( aGbrItem->m_End.y - aGbrItem->m_ArcCentre.y ),
398  (double) ( aGbrItem->m_End.x - aGbrItem->m_ArcCentre.x ) );
399 
400  wxPoint start = aGbrItem->m_Start;
401  wxPoint end = aGbrItem->m_End;
402 
403  /* Because Pcbnew does not know arcs in tracks,
404  * approximate arc by segments (SEG_COUNT__CIRCLE segment per 360 deg)
405  * The arc is drawn anticlockwise from the start point to the end point.
406  */
407  #define SEG_COUNT_CIRCLE 16
408  #define DELTA_ANGLE 2 * M_PI / SEG_COUNT_CIRCLE
409 
410  // calculate the number of segments from a to b.
411  // we want CNT_PER_360 segments fo a circle
412  if( a > b )
413  b += 2 * M_PI;
414 
415  wxPoint curr_start = start;
416  wxPoint seg_start, seg_end;
417 
418  int ii = 1;
419 
420  for( double rot = a; rot < (b - DELTA_ANGLE); rot += DELTA_ANGLE, ii++ )
421  {
422  seg_start = curr_start;
423  wxPoint curr_end = start;
424  RotatePoint( &curr_end, aGbrItem->m_ArcCentre,
425  -RAD2DECIDEG( DELTA_ANGLE * ii ) );
426  seg_end = curr_end;
427  // Reverse Y axis:
428  seg_start.y = -seg_start.y;
429  seg_end.y = -seg_end.y;
430  writeCopperLineItem( seg_start, seg_end, aGbrItem->m_Size.x, aLayer );
431  curr_start = curr_end;
432  }
433 
434  if( end != curr_start )
435  {
436  seg_start = curr_start;
437  seg_end = end;
438  // Reverse Y axis:
439  seg_start.y = -seg_start.y;
440  seg_end.y = -seg_end.y;
441  writeCopperLineItem( seg_start, seg_end, aGbrItem->m_Size.x, aLayer );
442  }
443 }
444 
445 
446 /*
447  * creates a via from a flashed gerber item.
448  * Flashed items are usually pads or vias, so we try to export all of them
449  * using vias
450  */
452 {
453  // First, explore already created vias, before creating a new via
454  for( unsigned ii = 0; ii < m_vias_coordinates.size(); ii++ )
455  {
456  if( m_vias_coordinates[ii] == aGbrItem->m_Start ) // Already created
457  return;
458  }
459 
460  m_vias_coordinates.push_back( aGbrItem->m_Start );
461 
462  wxPoint via_pos = aGbrItem->m_Start;
463  int width = (aGbrItem->m_Size.x + aGbrItem->m_Size.y) / 2;
464  // Reverse Y axis:
465  via_pos.y = -via_pos.y;
466 
467  // Layers are Front to Back
468  fprintf( m_fp, " (via (at %s %s) (size %s)",
469  Double2Str( MapToPcbUnits(via_pos.x) ).c_str(),
470  Double2Str( MapToPcbUnits(via_pos.y) ).c_str(),
471  Double2Str( MapToPcbUnits( width ) ).c_str() );
472 
473  fprintf( m_fp, " (layers %s %s))\n",
476 }
477 
479 {
480  fprintf( m_fp, "(kicad_pcb (version 4) (host Gerbview \"%s\")\n\n",
481  TO_UTF8( GetBuildVersion() ) );
482 
483  // Write layers section
484  fprintf( m_fp, " (layers \n" );
485 
486  for( int ii = 0; ii < m_pcbCopperLayersCount; ii++ )
487  {
488  int id = ii;
489 
490  if( ii == m_pcbCopperLayersCount-1)
491  id = B_Cu;
492 
493  fprintf( m_fp, " (%d %s signal)\n", id, TO_UTF8( GetPCBDefaultLayerName( id ) ) );
494  }
495 
496  for( int ii = B_Adhes; ii < PCB_LAYER_ID_COUNT; ii++ )
497  {
498  if( GetPCBDefaultLayerName( ii ).IsEmpty() ) // Layer not available for export
499  continue;
500 
501  fprintf( m_fp, " (%d %s user)\n", ii, TO_UTF8( GetPCBDefaultLayerName( ii ) ) );
502  }
503 
504  fprintf( m_fp, " )\n\n" );
505 }
506 
507 
508 void GBR_TO_PCB_EXPORTER::writePcbLineItem( bool aIsArc, wxPoint& aStart, wxPoint& aEnd,
509  int aWidth, LAYER_NUM aLayer, double aAngle )
510 {
511  if( aIsArc && ( aAngle == 360.0 || aAngle == 0 ) )
512  {
513  fprintf( m_fp, "(gr_circle (center %s %s) (end %s %s)(layer %s) (width %s))\n",
514  Double2Str( MapToPcbUnits(aStart.x) ).c_str(),
515  Double2Str( MapToPcbUnits(aStart.y) ).c_str(),
516  Double2Str( MapToPcbUnits(aEnd.x) ).c_str(),
517  Double2Str( MapToPcbUnits(aEnd.y) ).c_str(),
518  TO_UTF8( GetPCBDefaultLayerName( aLayer ) ),
519  Double2Str( MapToPcbUnits( aWidth ) ).c_str()
520  );
521  }
522  else if( aIsArc )
523  {
524  fprintf( m_fp, "(gr_arc (start %s %s) (end %s %s) (angle %s)(layer %s) (width %s))\n",
525  Double2Str( MapToPcbUnits(aStart.x) ).c_str(),
526  Double2Str( MapToPcbUnits(aStart.y) ).c_str(),
527  Double2Str( MapToPcbUnits(aEnd.x) ).c_str(),
528  Double2Str( MapToPcbUnits(aEnd.y) ).c_str(),
529  Double2Str( aAngle ).c_str(),
530  TO_UTF8( GetPCBDefaultLayerName( aLayer ) ),
531  Double2Str( MapToPcbUnits( aWidth ) ).c_str()
532  );
533  }
534  else
535  {
536  fprintf( m_fp, "(gr_line (start %s %s) (end %s %s)(layer %s) (width %s))\n",
537  Double2Str( MapToPcbUnits(aStart.x) ).c_str(),
538  Double2Str( MapToPcbUnits(aStart.y) ).c_str(),
539  Double2Str( MapToPcbUnits(aEnd.x) ).c_str(),
540  Double2Str( MapToPcbUnits(aEnd.y) ).c_str(),
541  TO_UTF8( GetPCBDefaultLayerName( aLayer ) ),
542  Double2Str( MapToPcbUnits( aWidth ) ).c_str()
543  );
544  }
545 }
546 
547 
549 {
550  SHAPE_POLY_SET polys = aGbrItem->m_Polygon;
551 
552  // Cleanup the polygon
554 
555  // Ensure the polygon is valid:
556  if( polys.OutlineCount() == 0 )
557  return;
558 
560 
561  SHAPE_LINE_CHAIN& poly = polys.Outline( 0 );
562 
563  fprintf( m_fp, "(gr_poly (pts " );
564 
565  #define MAX_COORD_CNT 4
566  int jj = MAX_COORD_CNT;
567  int cnt_max = poly.PointCount() -1;
568 
569  // Do not generate last corner, if it is the same point as the first point:
570  if( poly.CPoint( 0 ) == poly.CPoint( cnt_max ) )
571  cnt_max--;
572 
573  for( int ii = 0; ii <= cnt_max; ii++ )
574  {
575  if( --jj == 0 )
576  {
577  jj = MAX_COORD_CNT;
578  fprintf( m_fp, "\n" );
579  }
580 
581  fprintf( m_fp, " (xy %s %s)", Double2Str( MapToPcbUnits( poly.CPoint( ii ).x ) ).c_str(),
582  Double2Str( MapToPcbUnits( -poly.CPoint( ii ).y ) ).c_str() );
583  }
584 
585  fprintf( m_fp, ")" );
586 
587  if( jj != MAX_COORD_CNT )
588  fprintf( m_fp, "\n" );
589 
590  fprintf( m_fp, "(layer %s) (width 0) )\n",
591  TO_UTF8( GetPCBDefaultLayerName( aLayer ) ) );
592 }
593 
594 
596 {
597  SHAPE_POLY_SET polys = aGbrItem->m_Polygon;
599 
600  if( polys.OutlineCount() == 0 )
601  return;
602 
603  fprintf( m_fp, "(zone (net 0) (net_name \"\") (layer %s) (tstamp 0000000) (hatch edge 0.508)\n",
604  TO_UTF8( GetPCBDefaultLayerName( aLayer ) ) );
605 
606  fprintf( m_fp, " (connect_pads (clearance 0.0))\n" );
607 
608  fprintf( m_fp, " (min_thickness 0.1) (filled_areas_thickness no)\n"
609  " (fill (thermal_gap 0.3) (thermal_bridge_width 0.3))\n" );
610 
611  // Now, write the zone outlines with holes.
612  // first polygon is the main outline, next are holes
613  // One cannot know the initial zone outline.
614  // However most of (if not all) holes are just items with clearance,
615  // not really a hole in the initial zone outline.
616  // So we build a zone outline only with no hole.
617  fprintf( m_fp, " (polygon\n (pts" );
618 
619  SHAPE_LINE_CHAIN& poly = polys.Outline( 0 );
620 
621  #define MAX_COORD_CNT 4
622  int jj = MAX_COORD_CNT;
623  int cnt_max = poly.PointCount() -1;
624 
625  // Do not generate last corner, if it is the same point as the first point:
626  if( poly.CPoint( 0 ) == poly.CPoint( cnt_max ) )
627  cnt_max--;
628 
629  for( int ii = 0; ii <= cnt_max; ii++ )
630  {
631  if( --jj == 0 )
632  {
633  jj = MAX_COORD_CNT;
634  fprintf( m_fp, "\n " );
635  }
636 
637  fprintf( m_fp, " (xy %s %s)", Double2Str( MapToPcbUnits( poly.CPoint( ii ).x ) ).c_str(),
638  Double2Str( MapToPcbUnits( -poly.CPoint( ii ).y ) ).c_str() );
639  }
640 
641  fprintf( m_fp, ")\n" );
642 
643  fprintf( m_fp, " )\n)\n" );
644 }
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:236
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:90
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:211
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:215
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
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()
Function GetBuildVersion Return the build 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:31
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:264
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