KiCad PCB EDA Suite
Loading...
Searching...
No Matches
GENCAD_EXPORTER Class Reference

Export board to GenCAD file format. More...

#include <export_gencad_writer.h>

Public Member Functions

 GENCAD_EXPORTER (BOARD *aBoard)
 
bool WriteFile (const wxString &aFullFileName)
 Export a GenCAD file.
 
void SetPlotOffet (VECTOR2I aOffset)
 Set the coordinates offset when exporting items.
 
void FlipBottomPads (bool aFlip)
 Flip pad shapes on the bottom side.
 
void UsePinNamesUnique (bool aUnique)
 Make pin names unique.
 
void UseIndividualShapes (bool aUnique)
 Make pad shapes unique.
 
void StoreOriginCoordsInFile (bool aStore)
 Store origin coordinate in GenCAD file.
 

Private Member Functions

bool createHeaderInfoData ()
 Creates the header section.
 
void createArtworksSection ()
 
void createTracksInfoData ()
 Create the "$TRACKS" section.
 
void createBoardSection ()
 
void createComponentsSection ()
 Create the $COMPONENTS GenCAD section.
 
void createDevicesSection ()
 Create the $DEVICES section.
 
void createRoutesSection ()
 Create the $ROUTES section.
 
void createSignalsSection ()
 
void createShapesSection ()
 Create the footprint shape list.
 
void createPadsShapesSection ()
 
void footprintWriteShape (FOOTPRINT *aFootprint, const wxString &aShapeName)
 Create the shape of a footprint (SHAPE section)
 
const wxString getShapeName (FOOTPRINT *aFootprint)
 
double mapXTo (int aX)
 Helper functions to calculate coordinates of footprints in GenCAD values.
 
double mapYTo (int aY)
 

Private Attributes

BOARDm_board
 
wxString m_fullFileName
 
FILE * m_file
 
bool m_flipBottomPads
 
bool m_useUniquePins
 
bool m_useIndividualShapes
 
bool m_storeOriginCoords
 
VECTOR2I m_gencadOffset
 

Detailed Description

Export board to GenCAD file format.

Note
This exporter only supports GenCAD version 1.4.

Definition at line 29 of file export_gencad_writer.h.

Constructor & Destructor Documentation

◆ GENCAD_EXPORTER()

GENCAD_EXPORTER::GENCAD_EXPORTER ( BOARD aBoard)
inline

Definition at line 32 of file export_gencad_writer.h.

Member Function Documentation

◆ createArtworksSection()

void GENCAD_EXPORTER::createArtworksSection ( )
private

Definition at line 249 of file export_gencad_writer.cpp.

References m_file.

Referenced by WriteFile().

◆ createBoardSection()

void GENCAD_EXPORTER::createBoardSection ( )
private

◆ createComponentsSection()

void GENCAD_EXPORTER::createComponentsSection ( )
private

Create the $COMPONENTS GenCAD section.

GenCAD $COMPONENTS are the footprint placements. Bottom side components are difficult to handle because shapes must be mirrored or flipped. Silk screen layers need to be handled correctly and so on. Also it seems that no one follows the specs...

Definition at line 754 of file export_gencad_writer.cpp.

References EDA_ANGLE::AsDegrees(), B_SilkS, escapeString(), F_SilkS, BOARD::Footprints(), genCADLayerName(), BOARD::GetCopperLayerCount(), BOX2< Vec >::GetHeight(), getShapeName(), BOX2< Vec >::GetWidth(), EDA_ANGLE::Invert(), m_board, m_file, mapXTo(), mapYTo(), EDA_ANGLE::Normalize(), SCALE_FACTOR, and TO_UTF8.

Referenced by WriteFile().

◆ createDevicesSection()

void GENCAD_EXPORTER::createDevicesSection ( )
private

Create the $DEVICES section.

This is a list of footprints properties. Footprint shapes are in $SHAPES section.

Definition at line 1038 of file export_gencad_writer.cpp.

References componentShapes, escapeString(), LIB_ID::Format(), FOOTPRINT::GetFPID(), FOOTPRINT::GetValue(), m_file, shapeNames, and TO_UTF8.

Referenced by WriteFile().

◆ createHeaderInfoData()

bool GENCAD_EXPORTER::createHeaderInfoData ( )
private

◆ createPadsShapesSection()

◆ createRoutesSection()

void GENCAD_EXPORTER::createRoutesSection ( )
private

Create the $ROUTES section.

This section handles tracks and vias

Todo:
Add zones to GenCAD output.

Definition at line 910 of file export_gencad_writer.cpp.

References BOARD::GetCopperLayerCount(), BOARD::GetDesignSettings(), BOARD_DESIGN_SETTINGS::GetEnabledLayers(), BOARD_CONNECTED_ITEM::GetNetCode(), m_board, TRACKS, and BOARD::Tracks().

Referenced by WriteFile().

◆ createShapesSection()

void GENCAD_EXPORTER::createShapesSection ( )
private

Create the footprint shape list.

Since footprint shape is customizable after the placement we cannot share them. Instead we opt for the one footprint one shape one component one device approach.

Definition at line 638 of file export_gencad_writer.cpp.

References EDA_ANGLE::AsDegrees(), componentShapes, escapeString(), BOARD::Footprints(), footprintWriteShape(), hashFootprint(), m_board, m_file, m_flipBottomPads, m_useIndividualShapes, m_useUniquePins, EDA_ANGLE::Normalize(), pad, SCALE_FACTOR, shapeNames, TO_UTF8, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by WriteFile().

◆ createSignalsSection()

void GENCAD_EXPORTER::createSignalsSection ( )
private

◆ createTracksInfoData()

void GENCAD_EXPORTER::createTracksInfoData ( )
private

Create the "$TRACKS" section.

This section gives the list of widths (tools) used in tracks and vias

Each track name is build using "TRACK" + track width. For instance for a width = 120 : name = "TRACK120".

Definition at line 1101 of file export_gencad_writer.cpp.

References m_board, m_file, PCB_VIA_T, SCALE_FACTOR, and BOARD::Tracks().

Referenced by WriteFile().

◆ FlipBottomPads()

void GENCAD_EXPORTER::FlipBottomPads ( bool  aFlip)
inline

Flip pad shapes on the bottom side.

Definition at line 54 of file export_gencad_writer.h.

References m_flipBottomPads.

Referenced by BOARD_EDITOR_CONTROL::ExportGenCAD(), and PCBNEW_JOBS_HANDLER::JobExportGencad().

◆ footprintWriteShape()

void GENCAD_EXPORTER::footprintWriteShape ( FOOTPRINT aFootprint,
const wxString &  aShapeName 
)
private

Create the shape of a footprint (SHAPE section)

The shape is always given "normal" orientation. It's almost guaranteed that the silk layer will be imported wrong but the shape also contains the pads.

Definition at line 1124 of file export_gencad_writer.cpp.

References ANGLE_0, B_SilkS, center, VECTOR2< T >::Distance(), end, escapeString(), F_SilkS, FP_THROUGH_HOLE, EDA_SHAPE::GetArcAngle(), FOOTPRINT::GetAttributes(), PCB_SHAPE::GetCenter(), EDA_SHAPE::GetEnd(), FOOTPRINT::GetOrientation(), FOOTPRINT::GetPosition(), EDA_SHAPE::GetShape(), EDA_SHAPE::GetStart(), FOOTPRINT::GraphicalItems(), KiROUND(), m_file, PCB_SHAPE_T, radius, RotatePoint(), SCALE_FACTOR, TO_UTF8, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by createShapesSection().

◆ getShapeName()

const wxString GENCAD_EXPORTER::getShapeName ( FOOTPRINT aFootprint)
private

◆ mapXTo()

double GENCAD_EXPORTER::mapXTo ( int  aX)
private

Helper functions to calculate coordinates of footprints in GenCAD values.

The GenCAD Y axis from bottom to top,

Definition at line 144 of file export_gencad_writer.cpp.

References m_gencadOffset, SCALE_FACTOR, and VECTOR2< T >::x.

Referenced by createBoardSection(), createComponentsSection(), and createHeaderInfoData().

◆ mapYTo()

double GENCAD_EXPORTER::mapYTo ( int  aY)
private

◆ SetPlotOffet()

void GENCAD_EXPORTER::SetPlotOffet ( VECTOR2I  aOffset)
inline

Set the coordinates offset when exporting items.

Definition at line 51 of file export_gencad_writer.h.

References m_gencadOffset.

Referenced by BOARD_EDITOR_CONTROL::ExportGenCAD(), and PCBNEW_JOBS_HANDLER::JobExportGencad().

◆ StoreOriginCoordsInFile()

void GENCAD_EXPORTER::StoreOriginCoordsInFile ( bool  aStore)
inline

Store origin coordinate in GenCAD file.

Definition at line 63 of file export_gencad_writer.h.

References m_storeOriginCoords.

Referenced by BOARD_EDITOR_CONTROL::ExportGenCAD(), and PCBNEW_JOBS_HANDLER::JobExportGencad().

◆ UseIndividualShapes()

void GENCAD_EXPORTER::UseIndividualShapes ( bool  aUnique)
inline

Make pad shapes unique.

Definition at line 60 of file export_gencad_writer.h.

References m_useIndividualShapes.

Referenced by BOARD_EDITOR_CONTROL::ExportGenCAD(), and PCBNEW_JOBS_HANDLER::JobExportGencad().

◆ UsePinNamesUnique()

void GENCAD_EXPORTER::UsePinNamesUnique ( bool  aUnique)
inline

Make pin names unique.

Definition at line 57 of file export_gencad_writer.h.

References m_useUniquePins.

Referenced by BOARD_EDITOR_CONTROL::ExportGenCAD(), and PCBNEW_JOBS_HANDLER::JobExportGencad().

◆ WriteFile()

Member Data Documentation

◆ m_board

◆ m_file

◆ m_flipBottomPads

bool GENCAD_EXPORTER::m_flipBottomPads
private

◆ m_fullFileName

wxString GENCAD_EXPORTER::m_fullFileName
private

Definition at line 139 of file export_gencad_writer.h.

◆ m_gencadOffset

VECTOR2I GENCAD_EXPORTER::m_gencadOffset
private

Definition at line 149 of file export_gencad_writer.h.

Referenced by mapXTo(), mapYTo(), and SetPlotOffet().

◆ m_storeOriginCoords

bool GENCAD_EXPORTER::m_storeOriginCoords
private

Definition at line 146 of file export_gencad_writer.h.

Referenced by createHeaderInfoData(), and StoreOriginCoordsInFile().

◆ m_useIndividualShapes

bool GENCAD_EXPORTER::m_useIndividualShapes
private

Definition at line 145 of file export_gencad_writer.h.

Referenced by createShapesSection(), getShapeName(), and UseIndividualShapes().

◆ m_useUniquePins

bool GENCAD_EXPORTER::m_useUniquePins
private

Definition at line 144 of file export_gencad_writer.h.

Referenced by createShapesSection(), and UsePinNamesUnique().


The documentation for this class was generated from the following files: