77 bool aExcludeAllTH,
bool aExcludeDNP,
bool aTopSide,
78 bool aBottomSide,
bool aFormatCSV,
bool aUseAuxOrigin,
89 if( aTopSide && aBottomSide )
93 else if( aBottomSide )
126 std::vector<LIST_MOD> list;
154 item.
m_Reference = footprint->Reference().GetShownText(
false );
155 item.
m_Value = footprint->Value().GetShownText(
false );
156 item.
m_Layer = footprint->GetLayer();
157 list.push_back( item );
159 lenRefText = std::max( lenRefText, (
int) item.
m_Reference.length() );
160 lenValText = std::max( lenValText, (
int) item.
m_Value.length() );
164 if( list.size() > 1 )
172 wxChar csv_sep =
',';
175 snprintf( line,
sizeof(line),
"Ref%cVal%cPackage%cPosX%cPosY%cRot%cSide\n",
176 csv_sep, csv_sep, csv_sep, csv_sep, csv_sep, csv_sep );
183 footprint_pos = list[ii].m_Footprint->GetPosition();
186 int layer = list[ii].m_Footprint->GetLayer();
187 wxASSERT( layer ==
F_Cu || layer ==
B_Cu );
190 footprint_pos.
x = - footprint_pos.
x;
192 wxString tmp = wxT(
"\"" ) + list[ii].m_Reference;
193 tmp << wxT(
"\"" ) << csv_sep;
194 tmp << wxT(
"\"" ) << list[ii].m_Value;
195 tmp << wxT(
"\"" ) << csv_sep;
196 tmp << wxT(
"\"" ) << list[ii].m_Footprint->GetFPID().GetLibItemName().wx_str();
197 tmp << wxT(
"\"" ) << csv_sep;
199 tmp << wxString::Format( wxT(
"%f%c%f%c%f" ),
200 footprint_pos.
x * conv_unit,
204 -footprint_pos.
y * conv_unit,
206 list[ii].m_Footprint->GetOrientation().AsDegrees() );
219 snprintf( line,
sizeof(line),
"### Footprint positions - created on %s ###\n",
225 snprintf( line,
sizeof(line),
"### Printed by KiCad version %s\n",
TO_UTF8( Title ) );
229 buffer +=
"## Side : ";
242 snprintf( line,
sizeof(line),
"%-*s %-*s %-*s %9.9s %9.9s %8.8s %s\n",
243 int(lenRefText),
"# Ref",
244 int(lenValText),
"Val",
245 int(lenPkgText),
"Package",
246 "PosX",
"PosY",
"Rot",
"Side" );
252 footprint_pos = list[ii].m_Footprint->GetPosition();
255 int layer = list[ii].m_Footprint->GetLayer();
256 wxASSERT( layer ==
F_Cu || layer ==
B_Cu );
259 footprint_pos.
x = - footprint_pos.
x;
261 wxString ref = list[ii].m_Reference;
262 wxString val = list[ii].m_Value;
263 wxString pkg = list[ii].m_Footprint->GetFPID().GetLibItemName();
264 ref.Replace( wxT(
" " ), wxT(
"_" ) );
265 val.Replace( wxT(
" " ), wxT(
"_" ) );
266 pkg.Replace( wxT(
" " ), wxT(
"_" ) );
267 snprintf( line,
sizeof(line),
"%-*s %-*s %-*s %9.4f %9.4f %8.4f %s\n",
271 footprint_pos.
x * conv_unit,
274 -footprint_pos.
y * conv_unit,
275 list[ii].m_Footprint->GetOrientation().AsDegrees(),
281 buffer +=
"## End\n";
302 snprintf( line,
sizeof(line),
"## Footprint report - date %s\n",
307 snprintf( line,
sizeof(line),
"## Created by KiCad version %s\n",
313 buffer +=
"\n$BeginDESCRIPTION\n";
317 buffer +=
"\n$BOARD\n";
319 snprintf( line,
sizeof(line),
"upper_left_corner %9.6f %9.6f\n",
320 bbbox.
GetX() * conv_unit,
321 bbbox.
GetY() * conv_unit );
324 snprintf( line,
sizeof(line),
"lower_right_corner %9.6f %9.6f\n",
329 buffer +=
"$EndBOARD\n\n";
331 std::vector<FOOTPRINT*> sortedFootprints;
334 sortedFootprints.push_back( footprint );
336 std::sort( sortedFootprints.begin(), sortedFootprints.end(),
339 return StrNumCmp( a->GetReference(), b->GetReference(), true ) < 0;
342 for(
FOOTPRINT* footprint : sortedFootprints )
344 wxString ref = footprint->Reference().GetShownText(
false );
345 wxString value = footprint->Value().GetShownText(
false );
347 snprintf( line,
sizeof(line),
"$MODULE %s\n",
TO_UTF8( ref ) );
350 snprintf( line,
sizeof(line),
"reference %s\n",
TO_UTF8( ref ) );
351 snprintf( line,
sizeof(line),
"value %s\n",
TO_UTF8( value ) );
352 snprintf( line,
sizeof(line),
"footprint %s\n", footprint->GetFPID().Format().c_str() );
355 buffer +=
"attribut";
358 buffer +=
" virtual";
360 if( footprint->GetAttributes() &
FP_SMD )
368 VECTOR2I footprint_pos = footprint->GetPosition();
371 snprintf( line,
sizeof(line),
"position %9.6f %9.6f orientation %.2f\n",
372 footprint_pos.
x * conv_unit,
373 footprint_pos.
y * conv_unit,
374 footprint->GetOrientation().AsDegrees() );
377 if( footprint->GetLayer() ==
F_Cu )
378 buffer +=
"layer front\n";
379 else if( footprint->GetLayer() ==
B_Cu )
380 buffer +=
"layer back\n";
382 buffer +=
"layer other\n";
384 std::vector<PAD*> sortedPads;
386 for(
PAD*
pad : footprint->Pads() )
387 sortedPads.push_back(
pad );
389 std::sort( sortedPads.begin(), sortedPads.end(),
390 [](
PAD* a,
PAD* b ) ->
bool
392 return StrNumCmp( a->GetNumber(), b->GetNumber(), true ) < 0;
395 for(
PAD*
pad : sortedPads )
397 snprintf( line,
sizeof(line),
"$PAD \"%s\"\n",
TO_UTF8(
pad->GetNumber() ) );
409 static const char* layer_name[4] = {
"nocopper",
"back",
"front",
"both" };
410 snprintf( line,
sizeof(line),
"Shape %s Layer %s\n",
417 snprintf( line,
sizeof(line),
"position %9.6f %9.6f size %9.6f %9.6f orientation %.2f\n",
418 padPos.
x * conv_unit,
419 padPos.
y * conv_unit,
422 (
pad->GetOrientation() - footprint->GetOrientation() ).AsDegrees() );
425 snprintf( line,
sizeof(line),
"drill %9.6f\n",
pad->GetDrillSize().x * conv_unit );
428 snprintf( line,
sizeof(line),
"shape_offset %9.6f %9.6f\n",
433 buffer +=
"$EndPAD\n";
436 snprintf( line,
sizeof(line),
"$EndMODULE %s\n\n",
TO_UTF8( ref ) );
441 buffer +=
"$EndDESCRIPTION\n";
449 if( aFront && aBack )
450 return aBaseName + wxT(
"-" ) + wxT(
"all" );
constexpr EDA_IU_SCALE pcbIUScale
wxString GetBuildVersion()
Get the full KiCad version string.
const VECTOR2I & GetAuxOrigin()
Information pertinent to a Pcbnew printed circuit board.
BOX2I ComputeBoundingBox(bool aBoardEdgesOnly=false) const
Calculate the bounding box containing all board items (or board edge segments).
const FOOTPRINTS & Footprints() const
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
constexpr coord_type GetY() const
constexpr coord_type GetX() const
constexpr coord_type GetRight() const
constexpr coord_type GetBottom() const
const UTF8 & GetLibItemName() const
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
static constexpr PCB_LAYER_ID ALL_LAYERS
! Temporary layer identifier to identify code that is not padstack-aware
static std::string GetFrontSideName()
static wxString DecorateFilename(const wxString &aBaseName, bool aFront, bool aBack)
std::string GenPositionData()
build a string filled with the position data
PLACE_FILE_EXPORTER(BOARD *aBoard, bool aUnitsMM, bool aOnlySMD, bool aExcludeAllTH, bool aExcludeDNP, bool aTopSide, bool aBottomSide, bool aFormatCSV, bool aUseAuxOrigin, bool aNegateBottomX)
Create a PLACE_FILE_EXPORTER.
static std::string GetBackSideName()
std::string GenReportData()
build a string filled with the pad report data This report does not used options aForceSmdItems,...
std::string::size_type length() const
This file contains miscellaneous commonly used macros and functions.
static const double conv_unit_mm
static bool sortFPlist(const LIST_MOD &ref, const LIST_MOD &tst)
static const double conv_unit_inch
static const char unit_text_mm[]
static const char unit_text_inch[]
int StrNumCmp(const wxString &aString1, const wxString &aString2, bool aIgnoreCase)
Compare two strings with alphanumerical content.
wxString GetISO8601CurrentDateTime()
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
VECTOR2< int32_t > VECTOR2I