21#include <wx/clipbrd.h>
69 auto clipboard = wxTheClipboard;
70 wxClipboardLocker clipboardLock( clipboard );
72 if( !clipboardLock || !clipboard->IsOpened() )
75 clipboard->SetData(
new wxTextDataObject( aData ) );
87 if( clipboard->IsSupported( wxDF_TEXT ) || clipboard->IsSupported( wxDF_UNICODETEXT ) )
89 wxTextDataObject data;
90 clipboard->GetData( data );
101 auto clipboard = wxTheClipboard;
102 wxClipboardLocker clipboardLock( clipboard );
105 return wxEmptyString;
107 if( clipboard->IsSupported( wxDF_TEXT ) || clipboard->IsSupported( wxDF_UNICODETEXT ) )
109 wxTextDataObject data;
110 clipboard->GetData( data );
111 return data.GetText();
114 return wxEmptyString;
120 std::vector<BOARD_ITEM*> items;
121 std::set<EDA_ITEM*> promoted;
125 if( !item->IsBOARD_ITEM() )
131 if( promoted.insert( item->GetParent() ).second )
132 items.push_back(
static_cast<BOARD_ITEM*
>( item->GetParent() ) );
137 items.push_back(
static_cast<BOARD_ITEM*
>( item ) );
149 if( aSelected.
Empty() )
155 auto deleteUnselectedCells =
158 int minCol = aTable->GetColCount();
160 int minRow = aTable->GetRowCount();
163 for(
int row = 0; row < aTable->GetRowCount(); ++row )
165 for(
int col = 0; col < aTable->GetColCount(); ++col )
171 minRow = std::min( minRow, row );
172 maxRow = std::max( maxRow, row );
173 minCol = std::min( minCol, col );
174 maxCol = std::max( maxCol, col );
183 wxCHECK_MSG( maxCol >= minCol && maxRow >= minRow, ,
184 wxT(
"No selected cells!" ) );
189 for(
int row = minRow; row <= maxRow; row++ )
190 aTable->SetRowHeight( destRow++, aTable->GetRowHeight( row ) );
194 for(
int col = minCol; col <= maxCol; col++ )
195 aTable->SetColWidth( destCol++, aTable->GetColWidth( col ) );
197 aTable->DeleteMarkedCells();
198 aTable->SetColCount( ( maxCol - minCol ) + 1 );
202 std::set<PCB_TABLE*> promotedTables;
205 std::set<const EDA_ITEM*> promotedSources;
210 if( isFootprintEditor )
219 partialFootprint.
SetFPID(
id );
223 if( !item->IsBOARD_ITEM() )
231 if( field->IsMandatory() )
245 if( !promotedSources.insert( item->GetParent() ).second )
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( !promotedSources.insert( item->GetParent() ).second )
417 if( field->IsMandatory() )
424 copy->SetLocked(
false );
426 copy->SetParentGroup(
nullptr );
431 pad->SetNetCode( 0 );
435 copy->Move( -refPoint );
468 std::unique_ptr<PCB_CONSTRAINT>
copy(
481 m_writer( wxString( prettyData.c_str(), wxConvUTF8 ) );
504 const std::map<std::string, UTF8>* aProperties )
513 m_formatter.Print(
"(kicad_pcb (version %d) (generator \"pcbnew\") (generator_version %s)",
524 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 std::vector< BOARD_ITEM * > CopiedItems(const PCB_SELECTION &aSelection)
The items a copy of aSelection carries, which is what its reference point has to be picked from.
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.
bool IsGenerated() const
True when the cells' text comes from the board, so only their formatting is the user's.
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
int RefreshGeneratedTables(BOARD &aBoard)
Bring every generated table on the board up to date and return how many were rebuilt.
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