KiCad PCB EDA Suite
specctra_export.cpp File Reference
#include <pcb_edit_frame.h>
#include <confirm.h>
#include <gestfich.h>
#include <trigo.h>
#include <locale_io.h>
#include <macros.h>
#include <math/util.h>
#include <set>
#include <map>
#include <board.h>
#include <board_design_settings.h>
#include <footprint.h>
#include <fp_shape.h>
#include <pcb_track.h>
#include <pad.h>
#include <zone.h>
#include <base_units.h>
#include <collectors.h>
#include <geometry/shape_poly_set.h>
#include <geometry/convex_hull.h>
#include <convert_basic_shapes_to_polygon.h>
#include <geometry/geometry_utils.h>
#include <pcbnew_settings.h>
#include <wx/log.h>
#include "specctra.h"

Go to the source code of this file.

Namespaces

 DSN
 This source file implements export and import capabilities to the specctra dsn file format.
 

Macros

#define EXPORT_CUSTOM_PADS_CONVEX_HULL
 

Typedefs

typedef std::map< wxString, int > DSN::PINMAP
 data type used to ensure unique-ness of pin names, holding (wxString and int) More...
 
typedef std::set< std::string > DSN::STRINGSET
 
typedef std::pair< STRINGSET::iterator, bool > DSN::STRINGSET_PAIR
 

Functions

void ExportBoardToSpecctraFile (BOARD *aBoard, const wxString &aFullFilename)
 Helper method to export board to DSN file. More...
 
static double DSN::scale (int kicadDist)
 Convert a distance from Pcbnew internal units to the reported Specctra DSN units in floating point format. More...
 
static double DSN::IU2um (int kicadDist)
 
static double DSN::mapX (int x)
 
static double DSN::mapY (int y)
 
static POINT DSN::mapPt (const wxPoint &pt)
 Convert a KiCad point into a DSN file point. More...
 
static bool DSN::isRoundKeepout (PAD *aPad)
 Decide if the pad is a copper-less through hole which needs to be made into a round keepout. More...
 
static PATHDSN::makePath (const POINT &aStart, const POINT &aEnd, const std::string &aLayerName)
 Create a PATH element with a single straight line, a pair of vertices. More...
 

Variables

static const double safetyMargin = 0.1
 

Macro Definition Documentation

◆ EXPORT_CUSTOM_PADS_CONVEX_HULL

#define EXPORT_CUSTOM_PADS_CONVEX_HULL

Definition at line 73 of file specctra_export.cpp.

Function Documentation

◆ ExportBoardToSpecctraFile()

void ExportBoardToSpecctraFile ( BOARD aBoard,
const wxString &  aFullFilename 
)

Helper method to export board to DSN file.

Parameters
aBoardboard object
aFullFilenamespecctra file name

Definition at line 124 of file specctra_export.cpp.

125 {
126  SPECCTRA_DB db;
127 
128  db.SetPCB( SPECCTRA_DB::MakePCB() );
129 
130  LOCALE_IO toggle; // Switch the locale to standard C
131 
132  // Build the board outlines *before* flipping footprints
133  if( !db.BuiltBoardOutlines( aBoard ) )
134  wxLogWarning( _( "Board outline is malformed. Run DRC for a full analysis." ) );
135 
136  // DSN Images (=KiCad FOOTPRINTs and PADs) must be presented from the top view. So we
137  // temporarily flip any footprints which are on the back side of the board to the front,
138  // and record this in the FOOTPRINT's flag field.
139  db.FlipFOOTPRINTs( aBoard );
140 
141  try
142  {
144  db.FromBOARD( aBoard );
145  db.ExportPCB( aFullFilename, true );
146  db.RevertFOOTPRINTs( aBoard );
147 
148  // if an exception is thrown by FromBOARD or ExportPCB(), then
149  // ~SPECCTRA_DB() will close the file.
150  }
151  catch( ... )
152  {
153  db.RevertFOOTPRINTs( aBoard );
154  throw;
155  }
156 }
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: locale_io.h:40
void SetPCB(PCB *aPcb)
Delete any existing PCB and replaces it with the given one.
Definition: specctra.h:3688
void SynchronizeNetsAndNetClasses()
Copy NETCLASS info to each NET, based on NET membership in a NETCLASS.
Definition: board.cpp:1391
void RevertFOOTPRINTs(BOARD *aBoard)
Flip the footprints which were on the back side of the board back to the back.
#define _(s)
A DSN data tree, usually coming from a DSN file.
Definition: specctra.h:3647
bool BuiltBoardOutlines(BOARD *aBoard)
Build the board outlines and store it in m_brd_outlines.
void FromBOARD(BOARD *aBoard)
Add the entire BOARD to the PCB but does not write it out.
void ExportPCB(const wxString &aFilename, bool aNameChange=false)
Write the internal PCB instance out as a SPECTRA DSN format file.
Definition: specctra.cpp:3697
void FlipFOOTPRINTs(BOARD *aBoard)
Flip the footprints which are on the back side of the board to the front.

References _, DSN::SPECCTRA_DB::BuiltBoardOutlines(), DSN::SPECCTRA_DB::ExportPCB(), DSN::SPECCTRA_DB::FlipFOOTPRINTs(), DSN::SPECCTRA_DB::FromBOARD(), DSN::SPECCTRA_DB::MakePCB(), DSN::SPECCTRA_DB::RevertFOOTPRINTs(), DSN::SPECCTRA_DB::SetPCB(), and BOARD::SynchronizeNetsAndNetClasses().

Referenced by ExportSpecctraDSN(), and PCB_EDIT_FRAME::ExportSpecctraFile().

Variable Documentation

◆ safetyMargin

const double safetyMargin = 0.1
static