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 <pad.h>
33#include <pcb_group.h>
34#include <pcb_generator.h>
35#include <pcb_text.h>
36#include <pcb_table.h>
37#include <zone.h>
38#include <locale_io.h>
41#include <kicad_clipboard.h>
42#include <kidialog.h>
43
46 m_formatter()
47{
49}
50
51
53{
54}
55
56
58{
59 m_board = aBoard;
60}
61
62
63void CLIPBOARD_IO::SaveSelection( const PCB_SELECTION& aSelected, bool isFootprintEditor )
64{
65 VECTOR2I refPoint( 0, 0 );
66
67 // dont even start if the selection is empty
68 if( aSelected.Empty() )
69 return;
70
71 if( aSelected.HasReferencePoint() )
72 refPoint = aSelected.GetReferencePoint();
73
74 // Prepare net mapping that assures that net codes saved in a file are consecutive integers
76
77 auto deleteUnselectedCells =
78 []( PCB_TABLE* aTable )
79 {
80 int minCol = aTable->GetColCount();
81 int maxCol = -1;
82 int minRow = aTable->GetRowCount();
83 int maxRow = -1;
84
85 for( int row = 0; row < aTable->GetRowCount(); ++row )
86 {
87 for( int col = 0; col < aTable->GetColCount(); ++col )
88 {
89 PCB_TABLECELL* cell = aTable->GetCell( row, col );
90
91 if( cell->IsSelected() )
92 {
93 minRow = std::min( minRow, row );
94 maxRow = std::max( maxRow, row );
95 minCol = std::min( minCol, col );
96 maxCol = std::max( maxCol, col );
97 }
98 else
99 {
100 cell->SetFlags( STRUCT_DELETED );
101 }
102 }
103 }
104
105 wxCHECK_MSG( maxCol >= minCol && maxRow >= minRow, /*void*/,
106 wxT( "No selected cells!" ) );
107
108 // aTable is always a clone in the clipboard case
109 int destRow = 0;
110
111 for( int row = minRow; row <= maxRow; row++ )
112 aTable->SetRowHeight( destRow++, aTable->GetRowHeight( row ) );
113
114 int destCol = 0;
115
116 for( int col = minCol; col <= maxCol; col++ )
117 aTable->SetColWidth( destCol++, aTable->GetColWidth( col ) );
118
119 aTable->DeleteMarkedCells();
120 aTable->SetColCount( ( maxCol - minCol ) + 1 );
121 aTable->Normalize();
122 };
123
124 std::set<PCB_TABLE*> promotedTables;
125
126 auto parentIsPromoted =
127 [&]( PCB_TABLECELL* cell ) -> bool
128 {
129 for( PCB_TABLE* table : promotedTables )
130 {
131 if( table->m_Uuid == cell->GetParent()->m_Uuid )
132 return true;
133 }
134
135 return false;
136 };
137
138 if( aSelected.Size() == 1 && aSelected.Front()->Type() == PCB_FOOTPRINT_T )
139 {
140 // make the footprint safe to transfer to other pcbs
141 const FOOTPRINT* footprint = static_cast<FOOTPRINT*>( aSelected.Front() );
142 // Do not modify existing board
143 FOOTPRINT newFootprint( *footprint );
144
145 for( PAD* pad : newFootprint.Pads() )
146 pad->SetNetCode( 0 );
147
148 // locked means "locked in place"; copied items therefore can't be locked
149 newFootprint.SetLocked( false );
150
151 // locate the reference point at (0, 0) in the copied items
152 newFootprint.Move( VECTOR2I( -refPoint.x, -refPoint.y ) );
153
154 Format( static_cast<BOARD_ITEM*>( &newFootprint ) );
155
156 newFootprint.SetParent( nullptr );
157 newFootprint.SetParentGroup( nullptr );
158 }
159 else if( isFootprintEditor )
160 {
161 FOOTPRINT partialFootprint( m_board );
162
163 // Useful to copy the selection to the board editor (if any), and provides
164 // a dummy lib id.
165 // Perhaps not a good Id, but better than a empty id
166 KIID dummy;
167 LIB_ID id( "clipboard", dummy.AsString() );
168 partialFootprint.SetFPID( id );
169
170 for( EDA_ITEM* item : aSelected )
171 {
172 BOARD_ITEM* boardItem = dynamic_cast<BOARD_ITEM*>( item );
173 BOARD_ITEM* copy = nullptr;
174
175 wxCHECK2( boardItem, continue );
176
177 if( PCB_FIELD* field = dynamic_cast<PCB_FIELD*>( item ) )
178 {
179 if( field->IsMandatoryField() )
180 continue;
181 }
182
183 if( boardItem->Type() == PCB_GROUP_T )
184 {
185 copy = static_cast<PCB_GROUP*>( boardItem )->DeepClone();
186 }
187 else if( boardItem->Type() == PCB_GENERATOR_T )
188 {
189 copy = static_cast<PCB_GENERATOR*>( boardItem )->DeepClone();
190 }
191 else if( item->Type() == PCB_TABLECELL_T )
192 {
193 if( parentIsPromoted( static_cast<PCB_TABLECELL*>( item ) ) )
194 continue;
195
196 copy = static_cast<BOARD_ITEM*>( item->GetParent()->Clone() );
197 promotedTables.insert( static_cast<PCB_TABLE*>( copy ) );
198 }
199 else
200 {
201 copy = static_cast<BOARD_ITEM*>( boardItem->Clone() );
202 }
203
204 // If it is only a footprint, clear the nets from the pads
205 if( PAD* pad = dynamic_cast<PAD*>( copy ) )
206 pad->SetNetCode( 0 );
207
208 // Don't copy group membership information for the 1st level objects being copied
209 // since the group they belong to isn't being copied.
210 copy->SetParentGroup( nullptr );
211
212 // Add the pad to the new footprint before moving to ensure the local coords are
213 // correct
214 partialFootprint.Add( copy );
215
216 // A list of not added items, when adding items to the footprint
217 // some PCB_TEXT (reference and value) cannot be added to the footprint
218 std::vector<BOARD_ITEM*> skipped_items;
219
220 if( copy->Type() == PCB_GROUP_T || copy->Type() == PCB_GENERATOR_T )
221 {
222 copy->RunOnDescendants(
223 [&]( BOARD_ITEM* descendant )
224 {
225 // One cannot add an additional mandatory field to a given footprint:
226 // only one is allowed. So add only non-mandatory fields.
227 bool can_add = true;
228
229 if( const PCB_FIELD* field = dynamic_cast<const PCB_FIELD*>( item ) )
230 {
231 if( field->IsMandatoryField() )
232 can_add = false;
233 }
234
235 if( can_add )
236 partialFootprint.Add( descendant );
237 else
238 skipped_items.push_back( descendant );
239 } );
240 }
241
242 // locate the reference point at (0, 0) in the copied items
243 copy->Move( -refPoint );
244
245 // Now delete items, duplicated but not added:
246 for( BOARD_ITEM* skipped_item : skipped_items )
247 {
248 static_cast<PCB_GROUP*>( copy )->RemoveItem( skipped_item );
249 skipped_item->SetParentGroup( nullptr );
250 delete skipped_item;
251 }
252 }
253
254 // Set the new relative internal local coordinates of copied items
255 FOOTPRINT* editedFootprint = m_board->Footprints().front();
256 VECTOR2I moveVector = partialFootprint.GetPosition() + editedFootprint->GetPosition();
257
258 partialFootprint.MoveAnchorPosition( moveVector );
259
260 for( PCB_TABLE* table : promotedTables )
261 deleteUnselectedCells( table );
262
263 Format( &partialFootprint, 0 );
264
265 partialFootprint.SetParent( nullptr );
266 }
267 else
268 {
269 // we will fake being a .kicad_pcb to get the full parser kicking
270 // This means we also need layers and nets
271 LOCALE_IO io;
272
273 m_formatter.Print( 0, "(kicad_pcb (version %d) (generator \"pcbnew\") (generator_version \"%s\")\n",
275
276 m_formatter.Print( 0, "\n" );
277
280
281 m_formatter.Print( 0, "\n" );
282
283 for( EDA_ITEM* item : aSelected )
284 {
285 BOARD_ITEM* boardItem = dynamic_cast<BOARD_ITEM*>( item );
286 BOARD_ITEM* copy = nullptr;
287
288 wxCHECK2( boardItem, continue );
289
290 if( boardItem->Type() == PCB_FIELD_T )
291 {
292 PCB_FIELD* field = static_cast<PCB_FIELD*>( boardItem );
293 copy = new PCB_TEXT( m_board );
294
295 PCB_TEXT* textItem = static_cast<PCB_TEXT*>( copy );
296 textItem->SetPosition( field->GetPosition() );
297 textItem->SetLayer( field->GetLayer() );
298 textItem->SetHyperlink( field->GetHyperlink() );
299 textItem->SetText( field->GetText() );
300 textItem->SetAttributes( field->GetAttributes() );
301 textItem->SetTextAngle( field->GetDrawRotation() );
302
303 if ( textItem->GetText() == wxT( "${VALUE}" ) )
304 textItem->SetText( boardItem->GetParentFootprint()->GetValue() );
305 else if ( textItem->GetText() == wxT( "${REFERENCE}" ) )
306 textItem->SetText( boardItem->GetParentFootprint()->GetReference() );
307
308 }
309 else if( boardItem->Type() == PCB_TEXT_T )
310 {
311 copy = static_cast<BOARD_ITEM*>( boardItem->Clone() );
312
313 PCB_TEXT* textItem = static_cast<PCB_TEXT*>( copy );
314
315 if( textItem->GetText() == wxT( "${VALUE}" ) )
316 textItem->SetText( boardItem->GetParentFootprint()->GetValue() );
317 else if( textItem->GetText() == wxT( "${REFERENCE}" ) )
318 textItem->SetText( boardItem->GetParentFootprint()->GetReference() );
319 }
320 else if( boardItem->Type() == PCB_GROUP_T )
321 {
322 copy = static_cast<PCB_GROUP*>( boardItem )->DeepClone();
323 }
324 else if( boardItem->Type() == PCB_GENERATOR_T )
325 {
326 copy = static_cast<PCB_GENERATOR*>( boardItem )->DeepClone();
327 }
328 else if( item->Type() == PCB_TABLECELL_T )
329 {
330 if( parentIsPromoted( static_cast<PCB_TABLECELL*>( item ) ) )
331 continue;
332
333 copy = static_cast<BOARD_ITEM*>( item->GetParent()->Clone() );
334 promotedTables.insert( static_cast<PCB_TABLE*>( copy ) );
335 }
336 else
337 {
338 copy = static_cast<BOARD_ITEM*>( boardItem->Clone() );
339 }
340
341 if( copy )
342 {
343 if( copy->Type() == PCB_FIELD_T || copy->Type() == PCB_PAD_T )
344 {
345 // Create a parent footprint to own the copied item
346 FOOTPRINT* footprint = new FOOTPRINT( m_board );
347
348 footprint->SetPosition( copy->GetPosition() );
349 footprint->Add( copy );
350
351 // Convert any mandatory fields to user fields. The destination footprint
352 // will already have its own mandatory fields.
353 if( PCB_FIELD* field = dynamic_cast<PCB_FIELD*>( copy ) )
354 {
355 if( field->IsMandatoryField() )
356 field->SetId( footprint->GetFieldCount() );
357 }
358
359 copy = footprint;
360 }
361
362 copy->SetLocked( false );
363
364 // locate the reference point at (0, 0) in the copied items
365 copy->Move( -refPoint );
366
367 if( copy->Type() == PCB_TABLE_T )
368 {
369 PCB_TABLE* table = static_cast<PCB_TABLE*>( copy );
370
371 if( promotedTables.count( table ) )
372 deleteUnselectedCells( table );
373 }
374
375 Format( copy, 1 );
376
377 if( copy->Type() == PCB_GROUP_T || copy->Type() == PCB_GENERATOR_T )
378 {
379 copy->RunOnDescendants(
380 [&]( BOARD_ITEM* descendant )
381 {
382 descendant->SetLocked( false );
383 Format( descendant, 1 );
384 } );
385 }
386
387 copy->SetParentGroup( nullptr );
388 delete copy;
389 }
390 }
391
392 m_formatter.Print( 0, "\n)" );
393 }
394
395 // These are placed at the end to minimize the open time of the clipboard
396 wxLogNull doNotLog; // disable logging of failed clipboard actions
397 auto clipboard = wxTheClipboard;
398 wxClipboardLocker clipboardLock( clipboard );
399
400 if( !clipboardLock || !clipboard->IsOpened() )
401 return;
402
403 clipboard->SetData( new wxTextDataObject( wxString( m_formatter.GetString().c_str(),
404 wxConvUTF8 ) ) );
405
406 clipboard->Flush();
407
408 #ifndef __WXOSX__
409 // This section exists to return the clipboard data, ensuring it has fully
410 // been processed by the system clipboard. This appears to be needed for
411 // extremely large clipboard copies on asynchronous linux clipboard managers
412 // such as KDE's Klipper. However, a read back of the data on OSX before the
413 // clipboard is closed seems to cause an ASAN error (heap-buffer-overflow)
414 // since it uses the cached version of the clipboard data and not the system
415 // clipboard data.
416 if( clipboard->IsSupported( wxDF_TEXT ) || clipboard->IsSupported( wxDF_UNICODETEXT ) )
417 {
418 wxTextDataObject data;
419 clipboard->GetData( data );
420 ignore_unused( data.GetText() );
421 }
422 #endif
423}
424
425
427{
428 BOARD_ITEM* item;
429 wxString result;
430
431 wxLogNull doNotLog; // disable logging of failed clipboard actions
432
433 auto clipboard = wxTheClipboard;
434 wxClipboardLocker clipboardLock( clipboard );
435
436 if( !clipboardLock )
437 return nullptr;
438
439 if( clipboard->IsSupported( wxDF_TEXT ) || clipboard->IsSupported( wxDF_UNICODETEXT ) )
440 {
441 wxTextDataObject data;
442 clipboard->GetData( data );
443 result = data.GetText();
444 }
445
446 try
447 {
448 item = PCB_IO_KICAD_SEXPR::Parse( result );
449 }
450 catch (...)
451 {
452 item = nullptr;
453 }
454
455 return item;
456}
457
458
459void CLIPBOARD_IO::SaveBoard( const wxString& aFileName, BOARD* aBoard,
460 const STRING_UTF8_MAP* aProperties )
461{
462 init( aProperties );
463
464 m_board = aBoard; // after init()
465
466 // Prepare net mapping that assures that net codes saved in a file are consecutive integers
467 m_mapping->SetBoard( aBoard );
468
469 STRING_FORMATTER formatter;
470
471 m_out = &formatter;
472
473 m_out->Print( 0, "(kicad_pcb (version %d) (generator \"pcbnew\") (generator_version \"%s\")\n", SEXPR_BOARD_FILE_VERSION, GetMajorMinorVersion().c_str().AsChar() );
474
475 Format( aBoard, 1 );
476
477 m_out->Print( 0, ")\n" );
478
479 wxLogNull doNotLog; // disable logging of failed clipboard actions
480
481 auto clipboard = wxTheClipboard;
482 wxClipboardLocker clipboardLock( clipboard );
483
484 if( !clipboardLock )
485 return;
486
487 clipboard->SetData( new wxTextDataObject(
488 wxString( m_formatter.GetString().c_str(), wxConvUTF8 ) ) );
489 clipboard->Flush();
490
491 // This section exists to return the clipboard data, ensuring it has fully
492 // been processed by the system clipboard. This appears to be needed for
493 // extremely large clipboard copies on asynchronous linux clipboard managers
494 // such as KDE's Klipper
495 if( clipboard->IsSupported( wxDF_TEXT ) || clipboard->IsSupported( wxDF_UNICODETEXT ) )
496 {
497 wxTextDataObject data;
498 clipboard->GetData( data );
499 ignore_unused( data.GetText() );
500 }
501}
502
503
504BOARD* CLIPBOARD_IO::LoadBoard( const wxString& aFileName, BOARD* aAppendToMe,
505 const STRING_UTF8_MAP* aProperties, PROJECT* aProject )
506{
507 std::string result;
508
509 wxLogNull doNotLog; // disable logging of failed clipboard actions
510
511 auto clipboard = wxTheClipboard;
512 wxClipboardLocker clipboardLock( clipboard );
513
514 if( !clipboardLock )
515 return nullptr;
516
517 if( clipboard->IsSupported( wxDF_TEXT ) || clipboard->IsSupported( wxDF_UNICODETEXT ) )
518 {
519 wxTextDataObject data;
520 clipboard->GetData( data );
521
522 result = data.GetText().mb_str();
523 }
524
525 std::function<bool( wxString, int, wxString, wxString )> queryUser =
526 [&]( wxString aTitle, int aIcon, wxString aMessage, wxString aAction ) -> bool
527 {
528 KIDIALOG dlg( nullptr, aMessage, aTitle, wxOK | wxCANCEL | aIcon );
529
530 if( !aAction.IsEmpty() )
531 dlg.SetOKLabel( aAction );
532
533 dlg.DoNotShowCheckbox( aMessage, 0 );
534
535 return dlg.ShowModal() == wxID_OK;
536 };
537
538 STRING_LINE_READER reader( result, wxT( "clipboard" ) );
539 PCB_IO_KICAD_SEXPR_PARSER parser( &reader, aAppendToMe, queryUser );
540
541 init( aProperties );
542
543 BOARD_ITEM* item;
544 BOARD* board;
545
546 try
547 {
548 item = parser.Parse();
549 }
550 catch( const FUTURE_FORMAT_ERROR& )
551 {
552 // Don't wrap a FUTURE_FORMAT_ERROR in another
553 throw;
554 }
555 catch( const PARSE_ERROR& parse_error )
556 {
557 if( parser.IsTooRecent() )
558 throw FUTURE_FORMAT_ERROR( parse_error, parser.GetRequiredVersion() );
559 else
560 throw;
561 }
562
563 if( item->Type() != PCB_T )
564 {
565 // The parser loaded something that was valid, but wasn't a board.
566 THROW_PARSE_ERROR( _( "Clipboard content is not KiCad compatible" ), parser.CurSource(),
567 parser.CurLine(), parser.CurLineNumber(), parser.CurOffset() );
568 }
569 else
570 {
571 board = dynamic_cast<BOARD*>( item );
572 }
573
574 // Give the filename to the board if it's new
575 if( board && !aAppendToMe )
576 board->SetFileName( aFileName );
577
578 return board;
579}
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:77
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:226
void SetParentGroup(PCB_GROUP *aGroup)
Definition: board_item.h:90
virtual void SetLocked(bool aLocked)
Definition: board_item.h:300
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition: board_item.h:260
FOOTPRINT * GetParentFootprint() const
Definition: board_item.cpp:248
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:282
void SetFileName(const wxString &aFileName)
Definition: board.h:317
const FOOTPRINTS & Footprints() const
Definition: board.h:323
void SaveSelection(const PCB_SELECTION &selected, bool isFootprintEditor)
STRING_FORMATTER m_formatter
BOARD * LoadBoard(const wxString &aFileName, BOARD *aAppendToMe, const STRING_UTF8_MAP *aProperties=nullptr, PROJECT *aProject=nullptr) override
Load information from some input file format that this PCB_IO implementation knows about into either ...
BOARD_ITEM * Parse()
void SaveBoard(const wxString &aFileName, BOARD *aBoard, const STRING_UTF8_MAP *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)
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:88
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:126
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:100
bool IsSelected() const
Definition: eda_item.h:109
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:103
virtual EDA_ITEM * Clone() const
Create a duplicate of this item with linked list members set to NULL.
Definition: eda_item.cpp:82
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:98
void SetAttributes(const EDA_TEXT &aSrc, bool aSetPosition=true)
Set the text attributes from another instance.
Definition: eda_text.cpp:290
wxString GetHyperlink() const
Definition: eda_text.h:361
const TEXT_ATTRIBUTES & GetAttributes() const
Definition: eda_text.h:195
void SetHyperlink(wxString aLink)
Definition: eda_text.h:362
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:181
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
Definition: eda_text.cpp:203
void SetPosition(const VECTOR2I &aPos) override
Definition: footprint.cpp:2315
void SetFPID(const LIB_ID &aFPID)
Definition: footprint.h:234
int GetFieldCount() const
Return the number of fields in this symbol.
Definition: footprint.h:706
void SetLocked(bool isLocked) override
Set the #MODULE_is_LOCKED bit in the m_ModuleStatus.
Definition: footprint.h:407
void MoveAnchorPosition(const VECTOR2I &aMoveVector)
Move the reference point of the footprint.
Definition: footprint.cpp:2342
PADS & Pads()
Definition: footprint.h:191
void Move(const VECTOR2I &aMoveVector) override
Move this object.
Definition: footprint.cpp:2209
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
Definition: footprint.cpp:968
const wxString & GetValue() const
Definition: footprint.h:610
const wxString & GetReference() const
Definition: footprint.h:588
VECTOR2I GetPosition() const override
Definition: footprint.h:209
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:219
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Format and write text to the output stream.
Definition: richio.cpp:458
Definition: pad.h:53
A set of BOARD_ITEMs (i.e., without duplicates).
Definition: pcb_group.h:51
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 init(const STRING_UTF8_MAP *aProperties)
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 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:343
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:62
VECTOR2I GetReferencePoint() const
Definition: selection.cpp:170
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:433
const std::string & GetString()
Definition: richio.h:456
Is a LINE_READER that reads from a multiline 8 bit wide std::string.
Definition: richio.h:253
A name/value tuple with unique names and optional values.
#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< int > VECTOR2I
Definition: vector2d.h:602