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() );
224 snprintf( line,
sizeof(line),
"### Printed by KiCad version %s\n",
TO_UTF8( Title ) );
228 buffer +=
"## Side : ";
241 snprintf( line,
sizeof(line),
"%-*s %-*s %-*s %9.9s %9.9s %8.8s %s\n",
242 int(lenRefText),
"# Ref",
243 int(lenValText),
"Val",
244 int(lenPkgText),
"Package",
245 "PosX",
"PosY",
"Rot",
"Side" );
251 footprint_pos = list[ii].m_Footprint->GetPosition();
254 int layer = list[ii].m_Footprint->GetLayer();
255 wxASSERT( layer ==
F_Cu || layer ==
B_Cu );
258 footprint_pos.
x = - footprint_pos.
x;
260 wxString ref = list[ii].m_Reference;
261 wxString val = list[ii].m_Value;
262 wxString pkg = list[ii].m_Footprint->GetFPID().GetLibItemName();
263 ref.Replace( wxT(
" " ), wxT(
"_" ) );
264 val.Replace( wxT(
" " ), wxT(
"_" ) );
265 pkg.Replace( wxT(
" " ), wxT(
"_" ) );
266 snprintf( line,
sizeof(line),
"%-*s %-*s %-*s %9.4f %9.4f %8.4f %s\n",
270 footprint_pos.
x * conv_unit,
273 -footprint_pos.
y * conv_unit,
274 list[ii].m_Footprint->GetOrientation().AsDegrees(),
280 buffer +=
"## End\n";
305 snprintf( line,
sizeof(line),
"## Created by KiCad version %s\n",
TO_UTF8( Title ) );
310 buffer +=
"\n$BeginDESCRIPTION\n";
314 buffer +=
"\n$BOARD\n";
316 snprintf( line,
sizeof(line),
"upper_left_corner %9.6f %9.6f\n",
317 bbbox.
GetX() * conv_unit, bbbox.
GetY() * conv_unit );
320 snprintf( line,
sizeof(line),
"lower_right_corner %9.6f %9.6f\n",
324 buffer +=
"$EndBOARD\n\n";
326 std::vector<FOOTPRINT*> sortedFootprints;
329 sortedFootprints.push_back( footprint );
331 std::sort( sortedFootprints.begin(), sortedFootprints.end(),
334 return StrNumCmp( a->GetReference(), b->GetReference(), true ) < 0;
337 for(
FOOTPRINT* footprint : sortedFootprints )
339 wxString ref = footprint->Reference().GetShownText(
false );
340 wxString value = footprint->Value().GetShownText(
false );
342 snprintf( line,
sizeof(line),
"$MODULE %s\n",
TO_UTF8( ref ) );
345 snprintf( line,
sizeof(line),
"reference %s\n",
TO_UTF8( ref ) );
346 snprintf( line,
sizeof(line),
"value %s\n",
TO_UTF8( value ) );
347 snprintf( line,
sizeof(line),
"footprint %s\n", footprint->GetFPID().Format().c_str() );
350 buffer +=
"attribut";
353 buffer +=
" virtual";
355 if( footprint->GetAttributes() &
FP_SMD )
363 VECTOR2I footprint_pos = footprint->GetPosition();
366 snprintf( line,
sizeof(line),
"position %9.6f %9.6f orientation %.2f\n",
367 footprint_pos.
x * conv_unit,
368 footprint_pos.
y * conv_unit,
369 footprint->GetOrientation().AsDegrees() );
372 if( footprint->GetLayer() ==
F_Cu )
373 buffer +=
"layer front\n";
374 else if( footprint->GetLayer() ==
B_Cu )
375 buffer +=
"layer back\n";
377 buffer +=
"layer other\n";
379 std::vector<PAD*> sortedPads;
381 for(
PAD*
pad : footprint->Pads() )
382 sortedPads.push_back(
pad );
384 std::sort( sortedPads.begin(), sortedPads.end(),
385 [](
PAD* a,
PAD* b ) ->
bool
387 return StrNumCmp( a->GetNumber(), b->GetNumber(), true ) < 0;
390 for(
PAD*
pad : sortedPads )
392 snprintf( line,
sizeof(line),
"$PAD \"%s\"\n",
TO_UTF8(
pad->GetNumber() ) );
404 static const char* layer_name[4] = {
"nocopper",
"back",
"front",
"both" };
405 snprintf( line,
sizeof(line),
"Shape %s Layer %s\n",
412 snprintf( line,
sizeof(line),
"position %9.6f %9.6f size %9.6f %9.6f orientation %.2f\n",
413 padPos.
x * conv_unit,
414 padPos.
y * conv_unit,
417 (
pad->GetOrientation() - footprint->GetOrientation() ).AsDegrees() );
420 snprintf( line,
sizeof(line),
"drill %9.6f\n",
pad->GetDrillSize().x * conv_unit );
423 snprintf( line,
sizeof(line),
"shape_offset %9.6f %9.6f\n",
428 buffer +=
"$EndPAD\n";
431 snprintf( line,
sizeof(line),
"$EndMODULE %s\n\n",
TO_UTF8( ref ) );
436 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).
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()
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