21#include <wx/clipbrd.h>
68 auto clipboard = wxTheClipboard;
69 wxClipboardLocker clipboardLock( clipboard );
71 if( !clipboardLock || !clipboard->IsOpened() )
74 clipboard->SetData(
new wxTextDataObject( aData ) );
86 if( clipboard->IsSupported( wxDF_TEXT ) || clipboard->IsSupported( wxDF_UNICODETEXT ) )
88 wxTextDataObject data;
89 clipboard->GetData( data );
100 auto clipboard = wxTheClipboard;
101 wxClipboardLocker clipboardLock( clipboard );
104 return wxEmptyString;
106 if( clipboard->IsSupported( wxDF_TEXT ) || clipboard->IsSupported( wxDF_UNICODETEXT ) )
108 wxTextDataObject data;
109 clipboard->GetData( data );
110 return data.GetText();
113 return wxEmptyString;
122 if( aSelected.
Empty() )
128 auto deleteUnselectedCells =
131 int minCol = aTable->GetColCount();
133 int minRow = aTable->GetRowCount();
136 for(
int row = 0; row < aTable->GetRowCount(); ++row )
138 for(
int col = 0; col < aTable->GetColCount(); ++col )
144 minRow = std::min( minRow, row );
145 maxRow = std::max( maxRow, row );
146 minCol = std::min( minCol, col );
147 maxCol = std::max( maxCol, col );
156 wxCHECK_MSG( maxCol >= minCol && maxRow >= minRow, ,
157 wxT(
"No selected cells!" ) );
162 for(
int row = minRow; row <= maxRow; row++ )
163 aTable->SetRowHeight( destRow++, aTable->GetRowHeight( row ) );
167 for(
int col = minCol; col <= maxCol; col++ )
168 aTable->SetColWidth( destCol++, aTable->GetColWidth( col ) );
170 aTable->DeleteMarkedCells();
171 aTable->SetColCount( ( maxCol - minCol ) + 1 );
175 std::set<PCB_TABLE*> promotedTables;
177 auto parentIsPromoted =
182 if(
table->m_Uuid == cell->GetParent()->m_Uuid )
197 pad->SetNetCode( 0 );
210 else if( isFootprintEditor )
219 partialFootprint.
SetFPID(
id );
223 if( !item->IsBOARD_ITEM() )
231 if( field->IsMandatory() )
245 if( parentIsPromoted(
static_cast<PCB_TABLECELL*
>( item ) ) )
258 pad->SetNetCode( 0 );
262 copy->SetParentGroup(
nullptr );
270 std::vector<BOARD_ITEM*> skipped_items;
275 group->RunOnChildren(
284 if( field->IsMandatory() )
289 partialFootprint.
Add( descendant );
291 skipped_items.push_back( descendant );
297 copy->Move( -refPoint );
300 for(
BOARD_ITEM* skipped_item : skipped_items )
325 deleteUnselectedCells(
table );
327 Format( &partialFootprint );
337 m_formatter.Print(
"(kicad_pcb (version %d) (generator \"pcbnew\") (generator_version %s)",
345 if( !item->IsBOARD_ITEM() )
351 wxCHECK2( boardItem,
continue );
366 if ( textItem->
GetText() == wxT(
"${VALUE}" ) )
368 else if ( textItem->
GetText() == wxT(
"${REFERENCE}" ) )
378 if( textItem->
GetText() == wxT(
"${VALUE}" ) )
380 else if( textItem->
GetText() == wxT(
"${REFERENCE}" ) )
393 if( parentIsPromoted(
static_cast<PCB_TABLECELL*
>( item ) ) )
418 if( field->IsMandatory() )
425 copy->SetLocked(
false );
427 copy->SetParentGroup(
nullptr );
430 copy->Move( -refPoint );
436 if( promotedTables.count(
table ) )
437 deleteUnselectedCells(
table );
466 std::unique_ptr<PCB_CONSTRAINT>
copy(
479 m_writer( wxString( prettyData.c_str(), wxConvUTF8 ) );
502 const std::map<std::string, UTF8>* aProperties )
508 m_formatter.Print(
"(kicad_pcb (version %d) (generator \"pcbnew\") (generator_version %s)",
519 m_writer( wxString( prettyData.c_str(), wxConvUTF8 ) );
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...
void SetLocked(bool aLocked) override
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
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 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 SaveSelection(const PCB_SELECTION &selected, bool isFootprintEditor)
STRING_FORMATTER m_formatter
static void clipboardWriter(const wxString &aData)
static wxString clipboardReader()
void SetBoard(BOARD *aBoard)
std::function< wxString()> m_reader
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)
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 geometric constraint between board items (issue #2329).
A set of BOARD_ITEMs (i.e., without duplicates).
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.
VECTOR2I GetPosition() const override
void SetPosition(const VECTOR2I &aPos) override
EDA_ANGLE GetDrawRotation() const override
void SetTextAngle(const EDA_ANGLE &aAngle) override
VECTOR2I GetReferencePoint() const
int Size() const
Returns the number of selected parts.
bool Empty() const
Checks if there is anything selected.
bool HasReferencePoint() const
std::set< KIID > CollectConstraintScopeIds(const PCB_SELECTION &aSelection)
Shared logic deciding which constraints follow items through copy paste or duplicate.
bool ConstraintFullySelected(const PCB_CONSTRAINT *aConstraint, const std::set< KIID > &aScopeIds)
True when aConstraint has members and every one of them is present in aScopeIds, so the whole relatio...
#define STRUCT_DELETED
flag indication structures to be erased
void ignore_unused(const T &)
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
@ USER
The field ID hasn't been set yet; field is invalid.
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