21#include <wx/clipbrd.h>
66 auto clipboard = wxTheClipboard;
67 wxClipboardLocker clipboardLock( clipboard );
69 if( !clipboardLock || !clipboard->IsOpened() )
72 clipboard->SetData(
new wxTextDataObject( aData ) );
84 if( clipboard->IsSupported( wxDF_TEXT ) || clipboard->IsSupported( wxDF_UNICODETEXT ) )
86 wxTextDataObject data;
87 clipboard->GetData( data );
98 auto clipboard = wxTheClipboard;
99 wxClipboardLocker clipboardLock( clipboard );
102 return wxEmptyString;
104 if( clipboard->IsSupported( wxDF_TEXT ) || clipboard->IsSupported( wxDF_UNICODETEXT ) )
106 wxTextDataObject data;
107 clipboard->GetData( data );
108 return data.GetText();
111 return wxEmptyString;
120 if( aSelected.
Empty() )
126 auto deleteUnselectedCells =
129 int minCol = aTable->GetColCount();
131 int minRow = aTable->GetRowCount();
134 for(
int row = 0; row < aTable->GetRowCount(); ++row )
136 for(
int col = 0; col < aTable->GetColCount(); ++col )
142 minRow = std::min( minRow, row );
143 maxRow = std::max( maxRow, row );
144 minCol = std::min( minCol, col );
145 maxCol = std::max( maxCol, col );
154 wxCHECK_MSG( maxCol >= minCol && maxRow >= minRow, ,
155 wxT(
"No selected cells!" ) );
160 for(
int row = minRow; row <= maxRow; row++ )
161 aTable->SetRowHeight( destRow++, aTable->GetRowHeight( row ) );
165 for(
int col = minCol; col <= maxCol; col++ )
166 aTable->SetColWidth( destCol++, aTable->GetColWidth( col ) );
168 aTable->DeleteMarkedCells();
169 aTable->SetColCount( ( maxCol - minCol ) + 1 );
173 std::set<PCB_TABLE*> promotedTables;
175 auto parentIsPromoted =
180 if(
table->m_Uuid == cell->GetParent()->m_Uuid )
195 pad->SetNetCode( 0 );
208 else if( isFootprintEditor )
217 partialFootprint.
SetFPID(
id );
221 if( !item->IsBOARD_ITEM() )
229 if( field->IsMandatory() )
243 if( parentIsPromoted(
static_cast<PCB_TABLECELL*
>( item ) ) )
256 pad->SetNetCode( 0 );
260 copy->SetParentGroup(
nullptr );
268 std::vector<BOARD_ITEM*> skipped_items;
273 group->RunOnChildren(
282 if( field->IsMandatory() )
287 partialFootprint.
Add( descendant );
289 skipped_items.push_back( descendant );
295 copy->Move( -refPoint );
298 for(
BOARD_ITEM* skipped_item : skipped_items )
313 deleteUnselectedCells(
table );
315 Format( &partialFootprint );
325 m_formatter.Print(
"(kicad_pcb (version %d) (generator \"pcbnew\") (generator_version %s)",
333 if( !item->IsBOARD_ITEM() )
339 wxCHECK2( boardItem,
continue );
354 if ( textItem->
GetText() == wxT(
"${VALUE}" ) )
356 else if ( textItem->
GetText() == wxT(
"${REFERENCE}" ) )
366 if( textItem->
GetText() == wxT(
"${VALUE}" ) )
368 else if( textItem->
GetText() == wxT(
"${REFERENCE}" ) )
381 if( parentIsPromoted(
static_cast<PCB_TABLECELL*
>( item ) ) )
406 if( field->IsMandatory() )
413 copy->SetLocked(
false );
415 copy->SetParentGroup(
nullptr );
418 copy->Move( -refPoint );
424 if( promotedTables.count(
table ) )
425 deleteUnselectedCells(
table );
452 m_writer( wxString( prettyData.c_str(), wxConvUTF8 ) );
475 const std::map<std::string, UTF8>* aProperties )
481 m_formatter.Print(
"(kicad_pcb (version %d) (generator \"pcbnew\") (generator_version %s)",
492 m_writer( wxString( prettyData.c_str(), wxConvUTF8 ) );
497 const std::map<std::string, UTF8>* aProperties,
PROJECT* aProject )
501 std::function<bool( wxString,
int, wxString, wxString )> queryUser =
502 [&]( wxString aTitle,
int aIcon, wxString aMessage, wxString aAction ) ->
bool
504 KIDIALOG dlg(
nullptr, aMessage, aTitle, wxOK | wxCANCEL | aIcon );
506 if( !aAction.IsEmpty() )
507 dlg.SetOKLabel( aAction );
524 item = parser.
Parse();
542 THROW_PARSE_ERROR(
_(
"Clipboard content is not KiCad compatible" ), parser.CurSource(),
543 parser.CurLine(), parser.CurLineNumber(), parser.CurOffset() );
547 board =
dynamic_cast<BOARD*
>( item );
551 if( board && !aAppendToMe )
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...
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
void SetLocked(bool aLocked) override
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
FOOTPRINT * GetParentFootprint() const
Information pertinent to a Pcbnew printed circuit board.
void SetFileName(const wxString &aFileName)
void SaveSelection(const PCB_SELECTION &selected, bool isFootprintEditor)
STRING_FORMATTER m_formatter
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...
static void clipboardWriter(const wxString &aData)
static wxString clipboardReader()
void SetBoard(BOARD *aBoard)
std::function< wxString()> m_reader
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 ...
std::function< void(const wxString &)> m_writer
A base class for most all the KiCad significant classes used in schematics and boards.
void SetFlags(EDA_ITEM_FLAGS aMask)
KICAD_T Type() const
Returns the type of object.
virtual void SetParentGroup(EDA_GROUP *aGroup)
virtual EDA_ITEM * Clone() const
Create a duplicate of this item with linked list members set to NULL.
virtual void SetParent(EDA_ITEM *aParent)
virtual const wxString & GetText() const
Return the string associated with the text object.
void SetAttributes(const EDA_TEXT &aSrc, bool aSetPosition=true)
Set the text attributes from another instance.
wxString GetHyperlink() const
const TEXT_ATTRIBUTES & GetAttributes() const
void SetHyperlink(wxString aLink)
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)
Shows the 'do not show again' checkbox.
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.
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.
void formatBoardLayers(const BOARD *aBoard) const
formats the board layer information
BOARD_ITEM * Parse(const wxString &aClipboardSourceInput)
void init(const std::map< std::string, UTF8 > *aProperties)
void Format(const BOARD_ITEM *aItem) const
Output aItem to aFormatter in s-expression format.
PCB_IO_KICAD_SEXPR(int aControlFlags=CTL_FOR_BOARD)
OUTPUTFORMATTER * m_out
output any Format()s to this, no ownership
BOARD * m_board
The board BOARD being worked on, no ownership here.
virtual VECTOR2I GetPosition() const override
virtual void SetPosition(const VECTOR2I &aPos) override
EDA_ANGLE GetDrawRotation() const override
void SetTextAngle(const EDA_ANGLE &aAngle) override
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.
#define STRUCT_DELETED
flag indication structures to be erased
void ignore_unused(const T &)
#define THROW_PARSE_ERROR(aProblem, aSource, aInputLine, aLineNumber, aByteIndex)
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
A filename or source description, a problem input line, a line number, a byte offset,...
std::vector< std::vector< std::string > > table
wxString result
Test unit parsing edge cases and error handling.
@ PCB_GENERATOR_T
class PCB_GENERATOR, generator on a layer
@ PCB_GROUP_T
class PCB_GROUP, a set of BOARD_ITEMs
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
@ PCB_FIELD_T
class PCB_FIELD, text associated with a footprint property
@ PCB_TABLECELL_T
class PCB_TABLECELL, PCB_TEXTBOX for use in tables
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
@ PCB_PAD_T
class PAD, a pad in a footprint
@ PCB_TABLE_T
class PCB_TABLE, table of PCB_TABLECELLs
VECTOR2< int32_t > VECTOR2I