34#include <wx/checkbox.h> 
   35#include <wx/filedlg.h> 
   36#include <wx/filedlgcustomize.h> 
   66    if( !aLayerMask.any() )
 
   70    if( aLayerMask[
F_Cu] && aLayerMask[
B_Cu] )
 
   74    if( aLayerMask[
F_Cu] )
 
   78    if( aLayerMask[
B_Cu] )
 
   86        if( aLayerMask[layer] )
 
 
   97    int val = 
KiROUND( 
static_cast<double>( iu ) / ( 
pcbIUScale.IU_PER_MILS / 10.0 ) );
 
   98    if( val > clamp ) 
return clamp;
 
   99    if( val < -clamp ) 
return -clamp;
 
 
  110        for( 
PAD* 
pad : footprint->Pads() )
 
  123            rk.
pin = 
pad->GetNumber();
 
  124            rk.
refdes = footprint->GetReference();
 
  127            rk.
drill = std::min( drill.
x, drill.
y );
 
  136            rk.
x_size = 
pad->GetSize( accessLayer ).x;
 
  142                rk.
y_size = 
pad->GetSize( accessLayer ).y;
 
  158            aRecords.push_back( std::move( rk ) );
 
 
  170    if( (top_layer == 
F_Cu) && (bottom_layer == 
B_Cu) )
 
  174    if( top_layer == 
F_Cu )
 
  178    if( bottom_layer == 
B_Cu )
 
  183    return ( top_layer / 2 ) + 1;
 
 
  192    for( 
auto track : aPcb->
Tracks() )
 
  214            via->LayerPair( &top_layer, &bottom_layer );
 
  234            aRecords.push_back( rk );
 
 
  241        std::map<wxString, wxString> &aMap, std::set<wxString> &aSet )
 
  245    for( 
size_t ii = 0; ii < aNetname.Len(); ++ii )
 
  248        wxUniChar ch = aNetname[ii];
 
  250        if( ch > 126 || !std::isgraph( 
static_cast<unsigned char>( ch ) ) )
 
  261    if( canon.size() > 14 )
 
  263        canon = canon.Right( 14 );
 
  267    if( aSet.count( canon ) )
 
  270        wxString base( canon );
 
  271        if( base.size() > 10 )
 
  273            base = base.Right( 10 );
 
  282        } 
while ( aSet.count( canon ) );
 
  286    aMap[aNetname] = canon;
 
  287    aSet.insert( canon );
 
 
  295    std::map<wxString, wxString> d356_net_map;
 
  296    std::set<wxString> d356_net_set;
 
  298    for( 
unsigned i = 0; i < aRecords.size(); i++ )
 
  305        wxString d356_net( wxT( 
"N/C" ) );
 
  309            d356_net = d356_net_map[rk.
netname];
 
  311            if( d356_net.empty() )
 
  331        fprintf( aFile, 
"%03d%-14.14s   %-6.6s%c%-4.4s%c",
 
  334                 rk.
pin.empty()?
' ':
'-',
 
  341            fprintf( aFile, 
"D%04d%c",
 
  346            fprintf( aFile, 
"      " );
 
  349        fprintf( aFile, 
"A%02dX%+07dY%+07dX%04dY%04dR%03d",
 
 
  365    FILE*     file = 
nullptr;
 
  368    if( ( file = wxFopen( aFilename, wxT( 
"wt" ) ) ) == 
nullptr )
 
  374    std::vector<D356_RECORD> d356_records;
 
  382    fprintf( file, 
"P  CODE 00\n" );
 
  383    fprintf( file, 
"P  UNITS CUST 0\n" );
 
  384    fprintf( file, 
"P  arrayDim   N\n" );
 
  386    fprintf( file, 
"999\n" );
 
 
  410        customizer.AddStaticText( wxT( 
"\n\n" ) );  
 
  413        m_cb = customizer.AddCheckBox( 
_( 
"Do not export unconnected pads" ) );
 
 
 
  434    wxFileName  fn = 
m_frame->GetBoard()->GetFileName();
 
  435    wxString    ext, wildcard;
 
  441    wxString pro_dir = wxPathOnly( 
m_frame->Prj().GetProjectFullName() );
 
  443    wxFileDialog dlg( 
m_frame, 
_( 
"Generate IPC-D-356 netlist file" ), pro_dir, fn.GetFullName(),
 
  444                      wildcard, wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
 
  446    dlg.SetCustomizeHook( customizeHook );
 
  448    if( dlg.ShowModal() == wxID_CANCEL )
 
  454    m_frame->GetPcbNewSettings()->m_ExportD356.doNotExportUnconnectedPads = doNotExportUnconnectedPads;
 
  456    if( writer.
Write( dlg.GetPath() ) )
 
 
constexpr EDA_IU_SCALE pcbIUScale
 
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
 
const VECTOR2I & GetAuxOrigin() const
 
int GenD356File(const TOOL_EVENT &aEvent)
 
Information pertinent to a Pcbnew printed circuit board.
 
int GetCopperLayerCount() const
 
const FOOTPRINTS & Footprints() const
 
const TRACKS & Tracks() const
 
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
 
virtual void TransferDataFromCustomControls() override
 
D365_CUSTOMIZE_HOOK(bool aDoNotExportUnconnectedPads=false)
 
wxDECLARE_NO_COPY_CLASS(D365_CUSTOMIZE_HOOK)
 
wxFileDialogCheckBox * m_cb
 
bool GetDoNotExportUnconnectedPads() const
 
bool m_doNotExportUnconnectedPads
 
virtual void AddCustomControls(wxFileDialogCustomize &customizer) override
 
Wrapper to expose an API for writing IPC-D356 files.
 
bool m_doNotExportUnconnectedPads
 
void write_D356_records(std::vector< D356_RECORD > &aRecords, FILE *aFile)
Writes a list of records to the given output stream.
 
void build_pad_testpoints(BOARD *aPcb, std::vector< D356_RECORD > &aRecords)
 
void SetDoNotExportUnconnectedPads(bool aDoNotExportUnconnectedPads)
Sets whether unconnected pads should be exported.
 
bool Write(const wxString &aFilename)
Generates and writes the netlist to a given path.
 
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
 
LSET is a set of PCB_LAYER_IDs.
 
static LSET AllCuMask()
return AllCuMask( MAX_CU_LAYERS );
 
Handle the data for a net.
 
const wxString & GetNetname() const
 
static const int UNCONNECTED
Constant that holds the "unconnected net" number (typically 0) all items "connected" to this net are ...
 
@ NORMAL
Shape is the same on all layers.
 
static constexpr PCB_LAYER_ID ALL_LAYERS
! Temporary layer identifier to identify code that is not padstack-aware
 
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
 
void DisplayError(wxWindow *aParent, const wxString &aText)
Display an error or warning message box with aMessage.
 
This file is part of the common library.
 
static void build_via_testpoints(BOARD *aPcb, std::vector< D356_RECORD > &aRecords)
 
static int iu_to_d356(int iu, int clamp)
 
static const wxString intern_new_d356_netname(const wxString &aNetname, std::map< wxString, wxString > &aMap, std::set< wxString > &aSet)
 
static int via_access_code(BOARD *aPcb, int top_layer, int bottom_layer)
 
static int compute_pad_access_code(BOARD *aPcb, LSET aLayerMask)
 
static const std::string IpcD356FileExtension
 
static wxString IpcD356FileWildcard()
 
PCB_LAYER_ID
A quick note on layer IDs:
 
This file contains miscellaneous commonly used macros and functions.
 
@ NPTH
like PAD_PTH, but not plated mechanical use only, no connection allowed
 
@ SMD
Smd pad, appears on the solder paste layer (default)
 
@ CONN
Like smd, does not appear on the solder paste layer (default) Note: also has a special attribute in G...
 
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
 
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
 
VECTOR2< int32_t > VECTOR2I
 
Definition of file extensions used in Kicad.