26#include <wx/clipbrd.h>
69 if( aSelected.
Empty() )
98 else if( isFootprintEditor )
107 partialFootprint.
SetFPID(
id );
109 for(
const EDA_ITEM* item : aSelected )
114 if(
const PCB_TEXT*
text = dyn_cast<const PCB_TEXT*>( item ) )
123 clone =
static_cast<BOARD_ITEM*
>( item->Clone() );
126 if(
PAD*
pad = dyn_cast<PAD*>( clone ) )
127 pad->SetNetCode( 0 );
131 partialFootprint.
Add( clone );
135 std::vector<BOARD_ITEM*> skipped_items;
139 static_cast<PCB_GROUP*
>( clone )->RunOnDescendants(
146 if(
const PCB_TEXT*
text = dyn_cast<const PCB_TEXT*>( descendant ) )
153 partialFootprint.
Add( descendant );
155 skipped_items.push_back( descendant );
160 clone->
Move( -refPoint );
173 Format( &partialFootprint, 0 );
204 if( textItem->
GetText() == wxT(
"${VALUE}" ) )
206 else if( textItem->
GetText() == wxT(
"${REFERENCE}" ) )
238 copy->Move( -refPoint );
244 static_cast<PCB_GROUP*
>(
copy )->RunOnDescendants( prepItem );
259 auto clipboard = wxTheClipboard;
260 wxClipboardLocker clipboardLock( clipboard );
262 if( !clipboardLock || !clipboard->IsOpened() )
278 if( clipboard->IsSupported( wxDF_TEXT ) || clipboard->IsSupported( wxDF_UNICODETEXT ) )
280 wxTextDataObject data;
281 clipboard->GetData( data );
295 auto clipboard = wxTheClipboard;
296 wxClipboardLocker clipboardLock( clipboard );
301 if( clipboard->IsSupported( wxDF_TEXT ) || clipboard->IsSupported( wxDF_UNICODETEXT ) )
303 wxTextDataObject data;
304 clipboard->GetData( data );
305 result = data.GetText();
343 auto clipboard = wxTheClipboard;
344 wxClipboardLocker clipboardLock( clipboard );
349 clipboard->SetData(
new wxTextDataObject(
357 if( clipboard->IsSupported( wxDF_TEXT ) || clipboard->IsSupported( wxDF_UNICODETEXT ) )
359 wxTextDataObject data;
360 clipboard->GetData( data );
374 auto clipboard = wxTheClipboard;
375 wxClipboardLocker clipboardLock( clipboard );
380 if( clipboard->IsSupported( wxDF_TEXT ) || clipboard->IsSupported( wxDF_UNICODETEXT ) )
382 wxTextDataObject data;
383 clipboard->GetData( data );
385 result = data.GetText().mb_str();
388 std::function<bool( wxString,
int, wxString, wxString )> queryUser =
389 [&]( wxString aTitle,
int aIcon, wxString aMessage, wxString aAction ) ->
bool
391 KIDIALOG dlg(
nullptr, aMessage, aTitle, wxOK | wxCANCEL | aIcon );
393 if( !aAction.IsEmpty() )
394 dlg.SetOKLabel( aAction );
402 PCB_PARSER parser( &reader, aAppendToMe, queryUser );
411 item = parser.
Parse();
429 THROW_PARSE_ERROR(
_(
"Clipboard content is not KiCad compatible" ), parser.CurSource(),
430 parser.CurLine(), parser.CurLineNumber(), parser.CurOffset() );
434 board =
dynamic_cast<BOARD*
>( item );
438 if( board && !aAppendToMe )
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
virtual void SetLocked(bool aLocked)
virtual void Move(const VECTOR2I &aMoveVector)
Move this object.
FOOTPRINT * GetParentFootprint() const
Information pertinent to a Pcbnew printed circuit board.
void SetFileName(const wxString &aFileName)
FOOTPRINTS & Footprints()
void SaveSelection(const PCB_SELECTION &selected, bool isFootprintEditor)
STRING_FORMATTER m_formatter
BOARD * Load(const wxString &aFileName, BOARD *aAppendToMe, const STRING_UTF8_MAP *aProperties=nullptr, PROJECT *aProject=nullptr, PROGRESS_REPORTER *aProgressReporter=nullptr) override
Load information from some input file format that this PLUGIN implementation knows about into either ...
void SetBoard(BOARD *aBoard)
void Save(const wxString &aFileName, BOARD *aBoard, const STRING_UTF8_MAP *aProperties=nullptr) override
Write aBoard to a storage file in a format that this PLUGIN implementation knows about or it can be u...
A base class for most all the KiCad significant classes used in schematics and boards.
KICAD_T Type() const
Returns the type of object.
virtual void SetParent(EDA_ITEM *aParent)
virtual EDA_ITEM * Clone() const
Create a duplicate of this item with linked list members set to NULL.
virtual const wxString & GetText() const
Return the string associated with the text object.
virtual void SetText(const wxString &aText)
Helper class to create more flexible dialogs, including 'do not show again' checkbox handling.
void DoNotShowCheckbox(wxString file, int line)
Checks the 'do not show again' setting for the dialog.
A logical library item identifier and consists of various portions much like a URI.
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
void SetBoard(const BOARD *aBoard)
Set a BOARD object that is used to prepare the net code map.
A set of BOARD_ITEMs (i.e., without duplicates).
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.
BOARD * m_board
which BOARD, no ownership here
void init(const STRING_UTF8_MAP *aProperties)
BOARD_ITEM * Parse(const wxString &aClipboardSourceInput)
OUTPUTFORMATTER * m_out
output any Format()s to this, no ownership
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 formatBoardLayers(const BOARD *aBoard, int aNestLevel=0) const
formats the board layer information
void Format(const BOARD_ITEM *aItem, int aNestLevel=0) const
Output aItem to aFormatter in s-expression format.
A progress reporter interface for use in multi-threaded environments.
Container for project specific data.
VECTOR2I GetReferencePoint() const
int Size() const
Returns the number of selected parts.
bool Empty() const
Checks if there is anything selected.
bool HasReferencePoint() const
Is a LINE_READER that reads from a multiline 8 bit wide std::string.
A name/value tuple with unique names and optional values.
This file is part of the common library.
void ignore_unused(const T &)
#define THROW_PARSE_ERROR(aProblem, aSource, aInputLine, aLineNumber, aByteIndex)
Class to handle a set of BOARD_ITEMs.
Pcbnew s-expression file format parser definition.
#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.
std::vector< FAB_LAYER_COLOR > dummy
A filename or source description, a problem input line, a line number, a byte offset,...
@ PCB_GROUP_T
class PCB_GROUP, a set of BOARD_ITEMs
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
@ PCB_PAD_T
class PAD, a pad in a footprint