KiCad PCB EDA Suite
Loading...
Searching...
No Matches
kicad_clipboard.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2017 KiCad Developers, see AUTHORS.TXT for contributors.
5 * Copyright (C) 2017-2023 KiCad Developers, see AUTHORS.txt for contributors.
6 * @author Kristoffer Ödmark
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, you may find one here:
20 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21 * or you may search the http://www.gnu.org website for the version 2 license,
22 * or you may write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24 */
25
26#include <wx/clipbrd.h>
27#include <wx/log.h>
28
29#include <board.h>
30#include <build_version.h>
31#include <core/ignore.h>
32#include <font/fontconfig.h>
33#include <pad.h>
34#include <pcb_group.h>
35#include <pcb_generator.h>
36#include <pcb_text.h>
37#include <pcb_table.h>
38#include <zone.h>
39#include <locale_io.h>
42#include <kicad_clipboard.h>
43#include <kidialog.h>
44
47 m_formatter()
48{
50}
51
52
54{
55}
56
57
59{
60 m_board = aBoard;
61}
62
63
64void CLIPBOARD_IO::SaveSelection( const PCB_SELECTION& aSelected, bool isFootprintEditor )
65{
66 VECTOR2I refPoint( 0, 0 );
67
68 // dont even start if the selection is empty
69 if( aSelected.Empty() )
70 return;
71
72 if( aSelected.HasReferencePoint() )
73 refPoint = aSelected.GetReferencePoint();
74
75 // Prepare net mapping that assures that net codes saved in a file are consecutive integers
77
78 auto deleteUnselectedCells =
79 []( PCB_TABLE* aTable )
80 {
81 int minCol = aTable->GetColCount();
82 int maxCol = -1;
83 int minRow = aTable->GetRowCount();
84 int maxRow = -1;
85
86 for( int row = 0; row < aTable->GetRowCount(); ++row )
87 {
88 for( int col = 0; col < aTable->GetColCount(); ++col )
89 {
90 PCB_TABLECELL* cell = aTable->GetCell( row, col );
91
92 if( cell->IsSelected() )
93 {
94 minRow = std::min( minRow, row );
95 maxRow = std::max( maxRow, row );
96 minCol = std::min( minCol, col );
97 maxCol = std::max( maxCol, col );
98 }
99 else
100 {
101 cell->SetFlags( STRUCT_DELETED );
102 }
103 }
104 }
105
106 wxCHECK_MSG( maxCol >= minCol && maxRow >= minRow, /*void*/,
107 wxT( "No selected cells!" ) );
108
109 // aTable is always a clone in the clipboard case
110 int destRow = 0;
111
112 for( int row = minRow; row <= maxRow; row++ )
113 aTable->SetRowHeight( destRow++, aTable->GetRowHeight( row ) );
114
115 int destCol = 0;
116
117 for( int col = minCol; col <= maxCol; col++ )
118 aTable->SetColWidth( destCol++, aTable->GetColWidth( col ) );
119
120 aTable->DeleteMarkedCells();
121 aTable->SetColCount( ( maxCol - minCol ) + 1 );
122 aTable->Normalize();
123 };
124
125 std::set<PCB_TABLE*> promotedTables;
126
127 auto parentIsPromoted =
128 [&]( PCB_TABLECELL* cell ) -> bool
129 {
130 for( PCB_TABLE* table : promotedTables )
131 {
132 if( table->m_Uuid == cell->GetParent()->m_Uuid )
133 return true;
134 }
135
136 return false;
137 };
138
139 if( aSelected.Size() == 1 && aSelected.Front()->Type() == PCB_FOOTPRINT_T )
140 {
141 // make the footprint safe to transfer to other pcbs
142 const FOOTPRINT* footprint = static_cast<FOOTPRINT*>( aSelected.Front() );
143 // Do not modify existing board
144 FOOTPRINT newFootprint( *footprint );
145
146 for( PAD* pad : newFootprint.Pads() )
147 pad->SetNetCode( 0 );
148
149 // locked means "locked in place"; copied items therefore can't be locked
150 newFootprint.SetLocked( false );
151
152 // locate the reference point at (0, 0) in the copied items
153 newFootprint.Move( VECTOR2I( -refPoint.x, -refPoint.y ) );
154
155 Format( static_cast<BOARD_ITEM*>( &newFootprint ) );
156
157 newFootprint.SetParent( nullptr );
158 newFootprint.SetParentGroup( nullptr );
159 }
160 else if( isFootprintEditor )
161 {
162 FOOTPRINT partialFootprint( m_board );
163
164 // Useful to copy the selection to the board editor (if any), and provides
165 // a dummy lib id.
166 // Perhaps not a good Id, but better than a empty id
167 KIID dummy;
168 LIB_ID id( "clipboard", dummy.AsString() );
169 partialFootprint.SetFPID( id );
170
171 for( EDA_ITEM* item : aSelected )
172 {
173 if( !item->IsBOARD_ITEM() )
174 continue;
175
176 BOARD_ITEM* boardItem = static_cast<BOARD_ITEM*>( item );
177 BOARD_ITEM* copy = nullptr;
178
179 if( PCB_FIELD* field = dynamic_cast<PCB_FIELD*>( item ) )
180 {
181 if( field->IsMandatoryField() )
182 continue;
183 }
184
185 if( boardItem->Type() == PCB_GROUP_T )
186 {
187 copy = static_cast<PCB_GROUP*>( boardItem )->DeepClone();
188 }
189 else if( boardItem->Type() == PCB_GENERATOR_T )
190 {
191 copy = static_cast<PCB_GENERATOR*>( boardItem )->DeepClone();
192 }
193 else if( item->Type() == PCB_TABLECELL_T )
194 {
195 if( parentIsPromoted( static_cast<PCB_TABLECELL*>( item ) ) )
196 continue;
197
198 copy = static_cast<BOARD_ITEM*>( item->GetParent()->Clone() );
199 promotedTables.insert( static_cast<PCB_TABLE*>( copy ) );
200 }
201 else
202 {
203 copy = static_cast<BOARD_ITEM*>( boardItem->Clone() );
204 }
205
206 // If it is only a footprint, clear the nets from the pads
207 if( PAD* pad = dynamic_cast<PAD*>( copy ) )
208 pad->SetNetCode( 0 );
209
210 // Don't copy group membership information for the 1st level objects being copied
211 // since the group they belong to isn't being copied.
212 copy->SetParentGroup( nullptr );
213
214 // Add the pad to the new footprint before moving to ensure the local coords are
215 // correct
216 partialFootprint.Add( copy );
217
218 // A list of not added items, when adding items to the footprint
219 // some PCB_TEXT (reference and value) cannot be added to the footprint
220 std::vector<BOARD_ITEM*> skipped_items;
221
222 if( copy->Type() == PCB_GROUP_T || copy->Type() == PCB_GENERATOR_T )
223 {
224 copy->RunOnDescendants(
225 [&]( BOARD_ITEM* descendant )
226 {
227 // One cannot add an additional mandatory field to a given footprint:
228 // only one is allowed. So add only non-mandatory fields.
229 bool can_add = true;
230
231 if( const PCB_FIELD* field = dynamic_cast<const PCB_FIELD*>( item ) )
232 {
233 if( field->IsMandatoryField() )
234 can_add = false;
235 }
236
237 if( can_add )
238 partialFootprint.Add( descendant );
239 else
240 skipped_items.push_back( descendant );
241 } );
242 }
243
244 // locate the reference point at (0, 0) in the copied items
245 copy->Move( -refPoint );
246
247 // Now delete items, duplicated but not added:
248 for( BOARD_ITEM* skipped_item : skipped_items )
249 {
250 static_cast<PCB_GROUP*>( copy )->RemoveItem( skipped_item );
251 skipped_item->SetParentGroup( nullptr );
252 delete skipped_item;
253 }
254 }
255
256 // Set the new relative internal local coordinates of copied items
257 FOOTPRINT* editedFootprint = m_board->Footprints().front();
258 VECTOR2I moveVector = partialFootprint.GetPosition() + editedFootprint->GetPosition();
259
260 partialFootprint.MoveAnchorPosition( moveVector );
261
262 for( PCB_TABLE* table : promotedTables )
263 deleteUnselectedCells( table );
264
265 Format( &partialFootprint, 0 );
266
267 partialFootprint.SetParent( nullptr );
268 }
269 else
270 {
271 // we will fake being a .kicad_pcb to get the full parser kicking
272 // This means we also need layers and nets
273 LOCALE_IO io;
274
275 m_formatter.Print( 0, "(kicad_pcb (version %d) (generator \"pcbnew\") (generator_version \"%s\")\n",
277
278 m_formatter.Print( 0, "\n" );
279
282
283 m_formatter.Print( 0, "\n" );
284
285 for( EDA_ITEM* item : aSelected )
286 {
287 if( !item->IsBOARD_ITEM() )
288 continue;
289
290 BOARD_ITEM* boardItem = static_cast<BOARD_ITEM*>( item );
291 BOARD_ITEM* copy = nullptr;
292
293 wxCHECK2( boardItem, continue );
294
295 if( boardItem->Type() == PCB_FIELD_T )
296 {
297 PCB_FIELD* field = static_cast<PCB_FIELD*>( boardItem );
298 copy = new PCB_TEXT( m_board );
299
300 PCB_TEXT* textItem = static_cast<PCB_TEXT*>( copy );
301 textItem->SetPosition( field->GetPosition() );
302 textItem->SetLayer( field->GetLayer() );
303 textItem->SetHyperlink( field->GetHyperlink() );
304 textItem->SetText( field->GetText() );
305 textItem->SetAttributes( field->GetAttributes() );
306 textItem->SetTextAngle( field->GetDrawRotation() );
307
308 if ( textItem->GetText() == wxT( "${VALUE}" ) )
309 textItem->SetText( boardItem->GetParentFootprint()->GetValue() );
310 else if ( textItem->GetText() == wxT( "${REFERENCE}" ) )
311 textItem->SetText( boardItem->GetParentFootprint()->GetReference() );
312
313 }
314 else if( boardItem->Type() == PCB_TEXT_T )
315 {
316 copy = static_cast<BOARD_ITEM*>( boardItem->Clone() );
317
318 PCB_TEXT* textItem = static_cast<PCB_TEXT*>( copy );
319
320 if( textItem->GetText() == wxT( "${VALUE}" ) )
321 textItem->SetText( boardItem->GetParentFootprint()->GetValue() );
322 else if( textItem->GetText() == wxT( "${REFERENCE}" ) )
323 textItem->SetText( boardItem->GetParentFootprint()->GetReference() );
324 }
325 else if( boardItem->Type() == PCB_GROUP_T )
326 {
327 copy = static_cast<PCB_GROUP*>( boardItem )->DeepClone();
328 }
329 else if( boardItem->Type() == PCB_GENERATOR_T )
330 {
331 copy = static_cast<PCB_GENERATOR*>( boardItem )->DeepClone();
332 }
333 else if( item->Type() == PCB_TABLECELL_T )
334 {
335 if( parentIsPromoted( static_cast<PCB_TABLECELL*>( item ) ) )
336 continue;
337
338 copy = static_cast<BOARD_ITEM*>( item->GetParent()->Clone() );
339 promotedTables.insert( static_cast<PCB_TABLE*>( copy ) );
340 }
341 else
342 {
343 copy = static_cast<BOARD_ITEM*>( boardItem->Clone() );
344 }
345
346 if( copy )
347 {
348 if( copy->Type() == PCB_FIELD_T || copy->Type() == PCB_PAD_T )
349 {
350 // Create a parent footprint to own the copied item
351 FOOTPRINT* footprint = new FOOTPRINT( m_board );
352
353 footprint->SetPosition( copy->GetPosition() );
354 footprint->Add( copy );
355
356 // Convert any mandatory fields to user fields. The destination footprint
357 // will already have its own mandatory fields.
358 if( PCB_FIELD* field = dynamic_cast<PCB_FIELD*>( copy ) )
359 {
360 if( field->IsMandatoryField() )
361 field->SetId( footprint->GetFieldCount() );
362 }
363
364 copy = footprint;
365 }
366
367 copy->SetLocked( false );
368
369 // locate the reference point at (0, 0) in the copied items
370 copy->Move( -refPoint );
371
372 if( copy->Type() == PCB_TABLE_T )
373 {
374 PCB_TABLE* table = static_cast<PCB_TABLE*>( copy );
375
376 if( promotedTables.count( table ) )
377 deleteUnselectedCells( table );
378 }
379
380 Format( copy, 1 );
381
382 if( copy->Type() == PCB_GROUP_T || copy->Type() == PCB_GENERATOR_T )
383 {
384 copy->RunOnDescendants(
385 [&]( BOARD_ITEM* descendant )
386 {
387 descendant->SetLocked( false );
388 Format( descendant, 1 );
389 } );
390 }
391
392 copy->SetParentGroup( nullptr );
393 delete copy;
394 }
395 }
396
397 m_formatter.Print( 0, "\n)" );
398 }
399
400 // These are placed at the end to minimize the open time of the clipboard
401 wxLogNull doNotLog; // disable logging of failed clipboard actions
402 auto clipboard = wxTheClipboard;
403 wxClipboardLocker clipboardLock( clipboard );
404
405 if( !clipboardLock || !clipboard->IsOpened() )
406 return;
407
408 clipboard->SetData( new wxTextDataObject( wxString( m_formatter.GetString().c_str(),
409 wxConvUTF8 ) ) );
410
411 clipboard->Flush();
412
413 #ifndef __WXOSX__
414 // This section exists to return the clipboard data, ensuring it has fully
415 // been processed by the system clipboard. This appears to be needed for
416 // extremely large clipboard copies on asynchronous linux clipboard managers
417 // such as KDE's Klipper. However, a read back of the data on OSX before the
418 // clipboard is closed seems to cause an ASAN error (heap-buffer-overflow)
419 // since it uses the cached version of the clipboard data and not the system
420 // clipboard data.
421 if( clipboard->IsSupported( wxDF_TEXT ) || clipboard->IsSupported( wxDF_UNICODETEXT ) )
422 {
423 wxTextDataObject data;
424 clipboard->GetData( data );
425 ignore_unused( data.GetText() );
426 }
427 #endif
428}
429
430
432{
433 BOARD_ITEM* item;
434 wxString result;
435
436 wxLogNull doNotLog; // disable logging of failed clipboard actions
437
438 auto clipboard = wxTheClipboard;
439 wxClipboardLocker clipboardLock( clipboard );
440
441 if( !clipboardLock )
442 return nullptr;
443
444 if( clipboard->IsSupported( wxDF_TEXT ) || clipboard->IsSupported( wxDF_UNICODETEXT ) )
445 {
446 wxTextDataObject data;
447 clipboard->GetData( data );
448 result = data.GetText();
449 }
450
451 try
452 {
453 item = PCB_IO_KICAD_SEXPR::Parse( result );
454 }
455 catch (...)
456 {
457 item = nullptr;
458 }
459
460 return item;
461}
462
463
464void CLIPBOARD_IO::SaveBoard( const wxString& aFileName, BOARD* aBoard,
465 const std::map<std::string, UTF8>* aProperties )
466{
467 init( aProperties );
468
469 m_board = aBoard; // after init()
470
471 // Prepare net mapping that assures that net codes saved in a file are consecutive integers
472 m_mapping->SetBoard( aBoard );
473
474 STRING_FORMATTER formatter;
475
476 m_out = &formatter;
477
478 m_out->Print( 0, "(kicad_pcb (version %d) (generator \"pcbnew\") (generator_version \"%s\")\n", SEXPR_BOARD_FILE_VERSION, GetMajorMinorVersion().c_str().AsChar() );
479
480 Format( aBoard, 1 );
481
482 m_out->Print( 0, ")\n" );
483
484 wxLogNull doNotLog; // disable logging of failed clipboard actions
485
486 auto clipboard = wxTheClipboard;
487 wxClipboardLocker clipboardLock( clipboard );
488
489 if( !clipboardLock )
490 return;
491
492 clipboard->SetData( new wxTextDataObject(
493 wxString( m_formatter.GetString().c_str(), wxConvUTF8 ) ) );
494 clipboard->Flush();
495
496 // This section exists to return the clipboard data, ensuring it has fully
497 // been processed by the system clipboard. This appears to be needed for
498 // extremely large clipboard copies on asynchronous linux clipboard managers
499 // such as KDE's Klipper
500 if( clipboard->IsSupported( wxDF_TEXT ) || clipboard->IsSupported( wxDF_UNICODETEXT ) )
501 {
502 wxTextDataObject data;
503 clipboard->GetData( data );
504 ignore_unused( data.GetText() );
505 }
506}
507
508
509BOARD* CLIPBOARD_IO::LoadBoard( const wxString& aFileName, BOARD* aAppendToMe,
510 const std::map<std::string, UTF8>* aProperties, PROJECT* aProject )
511{
512 std::string result;
513
514 wxLogNull doNotLog; // disable logging of failed clipboard actions
515
517
518 auto clipboard = wxTheClipboard;
519 wxClipboardLocker clipboardLock( clipboard );
520
521 if( !clipboardLock )
522 return nullptr;
523
524 if( clipboard->IsSupported( wxDF_TEXT ) || clipboard->IsSupported( wxDF_UNICODETEXT ) )
525 {
526 wxTextDataObject data;
527 clipboard->GetData( data );
528
529 result = data.GetText().mb_str();
530 }
531
532 std::function<bool( wxString, int, wxString, wxString )> queryUser =
533 [&]( wxString aTitle, int aIcon, wxString aMessage, wxString aAction ) -> bool
534 {
535 KIDIALOG dlg( nullptr, aMessage, aTitle, wxOK | wxCANCEL | aIcon );
536
537 if( !aAction.IsEmpty() )
538 dlg.SetOKLabel( aAction );
539
540 dlg.DoNotShowCheckbox( aMessage, 0 );
541
542 return dlg.ShowModal() == wxID_OK;
543 };
544
545 STRING_LINE_READER reader( result, wxT( "clipboard" ) );
546 PCB_IO_KICAD_SEXPR_PARSER parser( &reader, aAppendToMe, queryUser );
547
548 init( aProperties );
549
550 BOARD_ITEM* item;
551 BOARD* board;
552
553 try
554 {
555 item = parser.Parse();
556 }
557 catch( const FUTURE_FORMAT_ERROR& )
558 {
559 // Don't wrap a FUTURE_FORMAT_ERROR in another
560 throw;
561 }
562 catch( const PARSE_ERROR& parse_error )
563 {
564 if( parser.IsTooRecent() )
565 throw FUTURE_FORMAT_ERROR( parse_error, parser.GetRequiredVersion() );
566 else
567 throw;
568 }
569
570 if( item->Type() != PCB_T )
571 {
572 // The parser loaded something that was valid, but wasn't a board.
573 THROW_PARSE_ERROR( _( "Clipboard content is not KiCad compatible" ), parser.CurSource(),
574 parser.CurLine(), parser.CurLineNumber(), parser.CurOffset() );
575 }
576 else
577 {
578 board = dynamic_cast<BOARD*>( item );
579 }
580
581 // Give the filename to the board if it's new
582 if( board && !aAppendToMe )
583 board->SetFileName( aFileName );
584
585 return board;
586}
wxString GetMajorMinorVersion()
Get only the major and minor version in a string major.minor.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:79
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:237
void SetParentGroup(PCB_GROUP *aGroup)
Definition: board_item.h:89
virtual void SetLocked(bool aLocked)
Definition: board_item.h:328
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition: board_item.h:288
FOOTPRINT * GetParentFootprint() const
Definition: board_item.cpp:299
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:290
void SetFileName(const wxString &aFileName)
Definition: board.h:325
const FOOTPRINTS & Footprints() const
Definition: board.h:331
void SaveSelection(const PCB_SELECTION &selected, bool isFootprintEditor)
STRING_FORMATTER m_formatter
BOARD_ITEM * Parse()
void SaveBoard(const wxString &aFileName, BOARD *aBoard, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Write aBoard to a storage file in a format that this PCB_IO implementation knows about or it can be u...
void SetBoard(BOARD *aBoard)
BOARD * LoadBoard(const wxString &aFileName, BOARD *aAppendToMe, const std::map< std::string, UTF8 > *aProperties=nullptr, PROJECT *aProject=nullptr) override
Load information from some input file format that this PCB_IO implementation knows about into either ...
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:89
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:127
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:101
bool IsSelected() const
Definition: eda_item.h:110
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:104
virtual EDA_ITEM * Clone() const
Create a duplicate of this item with linked list members set to NULL.
Definition: eda_item.cpp:85
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:94
void SetAttributes(const EDA_TEXT &aSrc, bool aSetPosition=true)
Set the text attributes from another instance.
Definition: eda_text.cpp:322
wxString GetHyperlink() const
Definition: eda_text.h:381
const TEXT_ATTRIBUTES & GetAttributes() const
Definition: eda_text.h:214
void SetHyperlink(wxString aLink)
Definition: eda_text.h:382
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:182
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
Definition: eda_text.cpp:204
void SetPosition(const VECTOR2I &aPos) override
Definition: footprint.cpp:2341
void SetFPID(const LIB_ID &aFPID)
Definition: footprint.h:249
int GetFieldCount() const
Return the number of fields in this symbol.
Definition: footprint.h:720
void SetLocked(bool isLocked) override
Set the #MODULE_is_LOCKED bit in the m_ModuleStatus.
Definition: footprint.h:421
void MoveAnchorPosition(const VECTOR2I &aMoveVector)
Move the reference point of the footprint.
Definition: footprint.cpp:2367
std::deque< PAD * > & Pads()
Definition: footprint.h:206
void Move(const VECTOR2I &aMoveVector) override
Move this object.
Definition: footprint.cpp:2237
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
Definition: footprint.cpp:982
const wxString & GetValue() const
Definition: footprint.h:624
const wxString & GetReference() const
Definition: footprint.h:602
VECTOR2I GetPosition() const override
Definition: footprint.h:224
Helper class to create more flexible dialogs, including 'do not show again' checkbox handling.
Definition: kidialog.h:43
void DoNotShowCheckbox(wxString file, int line)
Checks the 'do not show again' setting for the dialog.
Definition: kidialog.cpp:51
int ShowModal() override
Definition: kidialog.cpp:95
Definition: kiid.h:49
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:49
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: locale_io.h:49
void SetBoard(const BOARD *aBoard)
Set a BOARD object that is used to prepare the net code map.
Definition: netinfo.h:223
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Format and write text to the output stream.
Definition: richio.cpp:458
Definition: pad.h:54
A set of BOARD_ITEMs (i.e., without duplicates).
Definition: pcb_group.h:52
Read a Pcbnew s-expression formatted LINE_READER object and returns the appropriate BOARD_ITEM object...
bool IsTooRecent()
Return whether a version number, if any was parsed, was too recent.
wxString GetRequiredVersion()
Return a string representing the version of KiCad required to open this file.
A #PLUGIN derivation for saving and loading Pcbnew s-expression formatted files.
NETINFO_MAPPING * m_mapping
mapping for net codes, so only not empty net codes are stored with consecutive integers as net codes
void formatNetInformation(const BOARD *aBoard, int aNestLevel=0) const
formats the Nets and Netclasses
void Format(const BOARD_ITEM *aItem, int aNestLevel=0) const
Output aItem to aFormatter in s-expression format.
BOARD_ITEM * Parse(const wxString &aClipboardSourceInput)
void init(const std::map< std::string, UTF8 > *aProperties)
void formatBoardLayers(const BOARD *aBoard, int aNestLevel=0) const
formats the board layer information
OUTPUTFORMATTER * m_out
output any Format()s to this, no ownership
BOARD * m_board
The board BOARD being worked on, no ownership here.
Definition: pcb_io.h:342
virtual VECTOR2I GetPosition() const override
Definition: pcb_text.h:82
virtual void SetPosition(const VECTOR2I &aPos) override
Definition: pcb_text.h:87
EDA_ANGLE GetDrawRotation() const override
Definition: pcb_text.cpp:227
Container for project specific data.
Definition: project.h:64
VECTOR2I GetReferencePoint() const
Definition: selection.cpp:171
EDA_ITEM * Front() const
Definition: selection.h:172
int Size() const
Returns the number of selected parts.
Definition: selection.h:116
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:110
bool HasReferencePoint() const
Definition: selection.h:211
Implement an OUTPUTFORMATTER to a memory buffer.
Definition: richio.h:436
const std::string & GetString()
Definition: richio.h:459
Is a LINE_READER that reads from a multiline 8 bit wide std::string.
Definition: richio.h:253
static void SetReporter(REPORTER *aReporter)
Set the reporter to use for reporting font substitution warnings.
Definition: fontconfig.cpp:64
#define _(s)
#define STRUCT_DELETED
flag indication structures to be erased
void ignore_unused(const T &)
Definition: ignore.h:24
#define THROW_PARSE_ERROR(aProblem, aSource, aInputLine, aLineNumber, aByteIndex)
Definition: ki_exception.h:165
This file is part of the common library.
Class to handle a set of BOARD_ITEMs.
#define CTL_FOR_CLIPBOARD
Format output for the clipboard instead of footprint library or BOARD.
#define SEXPR_BOARD_FILE_VERSION
Current s-expression file format version. 2 was the last legacy format version.
Pcbnew s-expression file format parser definition.
std::vector< FAB_LAYER_COLOR > dummy
Variant of PARSE_ERROR indicating that a syntax or related error was likely caused by a file generate...
Definition: ki_exception.h:176
A filename or source description, a problem input line, a line number, a byte offset,...
Definition: ki_exception.h:120
@ PCB_T
Definition: typeinfo.h:82
@ PCB_GENERATOR_T
class PCB_GENERATOR, generator on a layer
Definition: typeinfo.h:91
@ PCB_GROUP_T
class PCB_GROUP, a set of BOARD_ITEMs
Definition: typeinfo.h:110
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
Definition: typeinfo.h:92
@ PCB_FIELD_T
class PCB_FIELD, text associated with a footprint property
Definition: typeinfo.h:90
@ PCB_TABLECELL_T
class PCB_TABLECELL, PCB_TEXTBOX for use in tables
Definition: typeinfo.h:95
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
Definition: typeinfo.h:86
@ PCB_PAD_T
class PAD, a pad in a footprint
Definition: typeinfo.h:87
@ PCB_TABLE_T
class PCB_TABLE, table of PCB_TABLECELLs
Definition: typeinfo.h:94
VECTOR2< int32_t > VECTOR2I
Definition: vector2d.h:691