77 bool aExcludeAllTH,
bool aTopSide,
bool aBottomSide,
78 bool aFormatCSV,
bool aUseAuxOrigin,
bool aNegateBottomX )
87 if( aTopSide && aBottomSide )
91 else if( aBottomSide )
124 std::vector<LIST_MOD> list;
149 item.
m_Reference = footprint->Reference().GetShownText(
false );
150 item.
m_Value = footprint->Value().GetShownText(
false );
151 item.
m_Layer = footprint->GetLayer();
152 list.push_back( item );
154 lenRefText = std::max( lenRefText, (
int) item.
m_Reference.length() );
155 lenValText = std::max( lenValText, (
int) item.
m_Value.length() );
159 if( list.size() > 1 )
167 wxChar csv_sep =
',';
170 snprintf( line,
sizeof(line),
"Ref%cVal%cPackage%cPosX%cPosY%cRot%cSide\n",
171 csv_sep, csv_sep, csv_sep, csv_sep, csv_sep, csv_sep );
178 footprint_pos = list[ii].m_Footprint->GetPosition();
181 int layer = list[ii].m_Footprint->GetLayer();
182 wxASSERT( layer ==
F_Cu || layer ==
B_Cu );
185 footprint_pos.
x = - footprint_pos.
x;
187 wxString tmp = wxT(
"\"" ) + list[ii].m_Reference;
188 tmp << wxT(
"\"" ) << csv_sep;
189 tmp << wxT(
"\"" ) << list[ii].m_Value;
190 tmp << wxT(
"\"" ) << csv_sep;
191 tmp << wxT(
"\"" ) << list[ii].m_Footprint->GetFPID().GetLibItemName().wx_str();
192 tmp << wxT(
"\"" ) << csv_sep;
194 tmp << wxString::Format( wxT(
"%f%c%f%c%f" ),
195 footprint_pos.
x * conv_unit,
199 -footprint_pos.
y * conv_unit,
201 list[ii].m_Footprint->GetOrientation().AsDegrees() );
214 snprintf( line,
sizeof(line),
"### Footprint positions - created on %s ###\n",
TO_UTF8(
DateAndTime() ) );
219 snprintf( line,
sizeof(line),
"### Printed by KiCad version %s\n",
TO_UTF8( Title ) );
223 buffer +=
"## Side : ";
236 snprintf( line,
sizeof(line),
"%-*s %-*s %-*s %9.9s %9.9s %8.8s %s\n",
237 int(lenRefText),
"# Ref",
238 int(lenValText),
"Val",
239 int(lenPkgText),
"Package",
240 "PosX",
"PosY",
"Rot",
"Side" );
246 footprint_pos = list[ii].m_Footprint->GetPosition();
249 int layer = list[ii].m_Footprint->GetLayer();
250 wxASSERT( layer ==
F_Cu || layer ==
B_Cu );
253 footprint_pos.
x = - footprint_pos.
x;
255 wxString ref = list[ii].m_Reference;
256 wxString val = list[ii].m_Value;
257 wxString pkg = list[ii].m_Footprint->GetFPID().GetLibItemName();
258 ref.Replace( wxT(
" " ), wxT(
"_" ) );
259 val.Replace( wxT(
" " ), wxT(
"_" ) );
260 pkg.Replace( wxT(
" " ), wxT(
"_" ) );
261 snprintf( line,
sizeof(line),
"%-*s %-*s %-*s %9.4f %9.4f %8.4f %s\n",
265 footprint_pos.
x * conv_unit,
268 -footprint_pos.
y * conv_unit,
269 list[ii].m_Footprint->GetOrientation().AsDegrees(),
275 buffer +=
"## End\n";
296 snprintf( line,
sizeof(line),
"## Footprint report - date %s\n",
TO_UTF8(
DateAndTime() ) );
300 snprintf( line,
sizeof(line),
"## Created by KiCad version %s\n",
TO_UTF8( Title ) );
305 buffer +=
"\n$BeginDESCRIPTION\n";
309 buffer +=
"\n$BOARD\n";
311 snprintf( line,
sizeof(line),
"upper_left_corner %9.6f %9.6f\n",
312 bbbox.
GetX() * conv_unit, bbbox.
GetY() * conv_unit );
315 snprintf( line,
sizeof(line),
"lower_right_corner %9.6f %9.6f\n",
319 buffer +=
"$EndBOARD\n\n";
321 std::vector<FOOTPRINT*> sortedFootprints;
324 sortedFootprints.push_back( footprint );
326 std::sort( sortedFootprints.begin(), sortedFootprints.end(),
329 return StrNumCmp( a->GetReference(), b->GetReference(), true ) < 0;
332 for(
FOOTPRINT* footprint : sortedFootprints )
334 wxString ref = footprint->Reference().GetShownText(
false );
335 wxString value = footprint->Value().GetShownText(
false );
337 snprintf( line,
sizeof(line),
"$MODULE %s\n",
TO_UTF8( ref ) );
340 snprintf( line,
sizeof(line),
"reference %s\n",
TO_UTF8( ref ) );
341 snprintf( line,
sizeof(line),
"value %s\n",
TO_UTF8( value ) );
342 snprintf( line,
sizeof(line),
"footprint %s\n", footprint->GetFPID().Format().c_str() );
345 buffer +=
"attribut";
348 buffer +=
" virtual";
350 if( footprint->GetAttributes() &
FP_SMD )
358 VECTOR2I footprint_pos = footprint->GetPosition();
361 snprintf( line,
sizeof(line),
"position %9.6f %9.6f orientation %.2f\n",
362 footprint_pos.
x * conv_unit,
363 footprint_pos.
y * conv_unit,
364 footprint->GetOrientation().AsDegrees() );
367 if( footprint->GetLayer() ==
F_Cu )
368 buffer +=
"layer front\n";
369 else if( footprint->GetLayer() ==
B_Cu )
370 buffer +=
"layer back\n";
372 buffer +=
"layer other\n";
374 std::vector<PAD*> sortedPads;
376 for(
PAD*
pad : footprint->Pads() )
377 sortedPads.push_back(
pad );
379 std::sort( sortedPads.begin(), sortedPads.end(),
380 [](
PAD* a,
PAD* b ) ->
bool
382 return StrNumCmp( a->GetNumber(), b->GetNumber(), true ) < 0;
385 for(
PAD*
pad : sortedPads )
387 snprintf( line,
sizeof(line),
"$PAD \"%s\"\n",
TO_UTF8(
pad->GetNumber() ) );
398 static const char* layer_name[4] = {
"nocopper",
"back",
"front",
"both" };
399 snprintf( line,
sizeof(line),
"Shape %s Layer %s\n",
406 snprintf( line,
sizeof(line),
"position %9.6f %9.6f size %9.6f %9.6f orientation %.2f\n",
407 padPos.
x * conv_unit,
408 padPos.
y * conv_unit,
409 pad->GetSize().x * conv_unit,
410 pad->GetSize().y * conv_unit,
411 (
pad->GetOrientation() - footprint->GetOrientation() ).AsDegrees() );
414 snprintf( line,
sizeof(line),
"drill %9.6f\n",
pad->GetDrillSize().x * conv_unit );
417 snprintf( line,
sizeof(line),
"shape_offset %9.6f %9.6f\n",
418 pad->GetOffset().x * conv_unit,
419 pad->GetOffset().y * conv_unit );
422 buffer +=
"$EndPAD\n";
425 snprintf( line,
sizeof(line),
"$EndMODULE %s\n\n",
TO_UTF8( ref ) );
430 buffer +=
"$EndDESCRIPTION\n";
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).
FOOTPRINTS & Footprints()
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
coord_type GetRight() const
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 std::string GetFrontSideName()
std::string GenPositionData()
build a string filled with the position data
static std::string GetBackSideName()
PLACE_FILE_EXPORTER(BOARD *aBoard, bool aUnitsMM, bool aOnlySMD, bool aExcludeAllTH, bool aTopSide, bool aBottomSide, bool aFormatCSV, bool aUseAuxOrigin, bool aNegateBottomX)
Create a PLACE_FILE_EXPORTER.
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.
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
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.