KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pcb_design_block_utils.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 The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
24#include <pgm_base.h>
25#include <kiway.h>
26#include <board_commit.h>
27#include <design_block.h>
29#include <footprint.h>
30#include <pad.h>
31#include <pcb_group.h>
33#include <pcb_edit_frame.h>
34#include <pcb_io/pcb_io.h>
35#include <pcb_io/pcb_io_mgr.h>
36#include <wx/choicdlg.h>
37#include <wx/msgdlg.h>
38#include <wx/textdlg.h>
40#include <paths.h>
41#include <env_paths.h>
42#include <common.h>
43#include <confirm.h>
44#include <kidialog.h>
45#include <locale_io.h>
46#include <netinfo.h>
47#include <tool/actions.h>
48#include <tool/tool_manager.h>
51#include <json_common.h>
52
53bool checkOverwriteDb( wxWindow* aFrame, wxString& libname, wxString& newName )
54{
55 wxString msg = wxString::Format( _( "Design block '%s' already exists in library '%s'." ), newName.GetData(),
56 libname.GetData() );
57
58 if( OKOrCancelDialog( aFrame, _( "Confirmation" ), msg, _( "Overwrite existing design block?" ), _( "Overwrite" ) )
59 != wxID_OK )
60 {
61 return false;
62 }
63
64 return true;
65}
66
67
68bool checkOverwriteDbLayout( wxWindow* aFrame, const LIB_ID& aLibId )
69{
70 wxString msg = wxString::Format( _( "Design block '%s' already has a layout." ), aLibId.GetUniStringLibItemName() );
71
72 if( OKOrCancelDialog( aFrame, _( "Confirmation" ), msg, _( "Overwrite existing layout?" ), _( "Overwrite" ) )
73 != wxID_OK )
74 {
75 return false;
76 }
77
78 return true;
79}
80
81
82bool PCB_EDIT_FRAME::saveBoardAsFile( BOARD* aBoard, const wxString& aFileName, bool aHeadless )
83{
84 // Ensure the "C" locale is temporary set, before saving any file
85 // It also avoid wxWidget alerts about locale issues, later, when using Python 3
87
88 wxFileName pcbFileName( aFileName );
89
90 if( !IsWritable( pcbFileName ) )
91 {
92 if( !aHeadless )
93 {
94 DisplayError( this, wxString::Format( _( "Insufficient permissions to write file '%s'." ),
95 pcbFileName.GetFullPath() ) );
96 }
97 return false;
98 }
99
100 try
101 {
103
104 wxASSERT( pcbFileName.IsAbsolute() );
105
106 pi->SaveBoard( pcbFileName.GetFullPath(), aBoard, nullptr );
107 }
108 catch( const IO_ERROR& ioe )
109 {
110 if( !aHeadless )
111 {
112 DisplayError( this, wxString::Format( _( "Error saving board file '%s'.\n%s" ), pcbFileName.GetFullPath(),
113 ioe.What() ) );
114 }
115
116 return false;
117 }
118
119 return true;
120}
121
122
123bool PCB_EDIT_FRAME::SaveBoardAsDesignBlock( const wxString& aLibraryName )
124{
125 // Make sure the user has selected a library to save into
126 if( m_designBlocksPane->GetSelectedLibId().GetLibNickname().empty() )
127 {
128 DisplayErrorMessage( this, _( "Please select a library to save the design block to." ) );
129 return false;
130 }
131
132 DESIGN_BLOCK blk;
133 wxFileName fn = wxFileNameFromPath( GetBoard()->GetFileName() );
134
135 blk.SetLibId( LIB_ID( aLibraryName, fn.GetName() ) );
136
137 DIALOG_DESIGN_BLOCK_PROPERTIES dlg( this, &blk );
138
139 if( dlg.ShowModal() != wxID_OK )
140 return false;
141
142 wxString libName = blk.GetLibId().GetLibNickname();
143 wxString newName = blk.GetLibId().GetLibItemName();
144
145 if( Prj().DesignBlockLibs()->DesignBlockExists( libName, newName ) && !checkOverwriteDb( this, libName, newName ) )
146 {
147 return false;
148 }
149
150 // Save a temporary copy of the schematic file, as the plugin is just going to move it
151 wxString tempFile = wxFileName::CreateTempFileName( "design_block" );
152
153 if( !SavePcbCopy( tempFile, false, false ) )
154 {
155 DisplayErrorMessage( this, _( "Error saving temporary board file to create design block." ) );
156 wxRemoveFile( tempFile );
157 return false;
158 }
159
160 blk.SetBoardFile( tempFile );
161
162 bool success = false;
163
164 try
165 {
166 success = Prj().DesignBlockLibs()->SaveDesignBlock( aLibraryName, &blk )
168 }
169 catch( const IO_ERROR& ioe )
170 {
171 DisplayError( this, ioe.What() );
172 }
173
174 // Clean up the temporary file
175 wxRemoveFile( tempFile );
176
177 m_designBlocksPane->RefreshLibs();
178 m_designBlocksPane->SelectLibId( blk.GetLibId() );
179
180 return success;
181}
182
183
185{
186 // Make sure the user has selected a library to save into
187 if( m_designBlocksPane->GetSelectedLibId().GetLibNickname().empty() )
188 {
189 DisplayErrorMessage( this, _( "Please select a library to save the design block to." ) );
190 return false;
191 }
192
193 std::unique_ptr<DESIGN_BLOCK> blk;
194
195 try
196 {
197 blk.reset( Prj().DesignBlockLibs()->LoadDesignBlock( aLibId.GetLibNickname(), aLibId.GetLibItemName() ) );
198 }
199 catch( const IO_ERROR& ioe )
200 {
201 DisplayError( this, ioe.What() );
202 return false;
203 }
204
205 if( !blk )
206 {
208 this, wxString::Format( _( "Design block '%s' does not exist." ), aLibId.GetUniStringLibItemName() ) );
209 return false;
210 }
211
212 if( !blk->GetBoardFile().IsEmpty() && !checkOverwriteDbLayout( this, aLibId ) )
213 return false;
214
215 // Save a temporary copy of the schematic file, as the plugin is just going to move it
216 wxString tempFile = wxFileName::CreateTempFileName( "design_block" );
217
218 if( !SavePcbCopy( tempFile, false, false ) )
219 {
220 DisplayErrorMessage( this, _( "Error saving temporary board file to create design block." ) );
221 wxRemoveFile( tempFile );
222 return false;
223 }
224
225 blk->SetBoardFile( tempFile );
226
227 bool success = false;
228
229 try
230 {
231 success = Prj().DesignBlockLibs()->SaveDesignBlock( aLibId.GetLibNickname(), blk.get() )
233 }
234 catch( const IO_ERROR& ioe )
235 {
236 DisplayError( this, ioe.What() );
237 }
238
239 // Clean up the temporary file
240 wxRemoveFile( tempFile );
241
242 m_designBlocksPane->RefreshLibs();
243 m_designBlocksPane->SelectLibId( blk->GetLibId() );
244
245 return success;
246}
247
248
249bool PCB_EDIT_FRAME::saveSelectionToDesignBlock( const wxString& aNickname, PCB_SELECTION& aSelection,
250 DESIGN_BLOCK& aBlock )
251{
252 // Create a temporary board
253 BOARD* tempBoard = new BOARD();
255 tempBoard->SetProject( &Prj(), true );
256 tempBoard->SynchronizeProperties();
257
258 // For copying net info of selected items into the new board
259 auto addNetIfNeeded =
260 [&]( EDA_ITEM* aItem )
261 {
262 BOARD_CONNECTED_ITEM* cItem = dynamic_cast<BOARD_CONNECTED_ITEM*>( aItem );
263
264 if( cItem )
265 {
266 NETINFO_ITEM* netinfo = cItem->GetNet();
267
268 if( netinfo )
269 {
270 NETINFO_ITEM* existingInfo = tempBoard->FindNet( netinfo->GetNetname() );
271
272 // If the net has already been added to the new board, update our info to match
273 if( existingInfo )
274 cItem->SetNet( existingInfo );
275 else
276 {
277 NETINFO_ITEM* newNet = new NETINFO_ITEM( tempBoard, netinfo->GetNetname() );
278 tempBoard->Add( newNet );
279 cItem->SetNet( newNet );
280 }
281 }
282 }
283 };
284
285 auto cloneAndAdd =
286 [&] ( EDA_ITEM* aItem )
287 {
288 if( !aItem->IsBOARD_ITEM() )
289 return static_cast<BOARD_ITEM*>( nullptr );
290
291 BOARD_ITEM* copy = static_cast<BOARD_ITEM*>( aItem->Clone() );
292 tempBoard->Add( copy, ADD_MODE::APPEND, false );
293 return copy;
294 };
295
296 // Copy the selected items to the temporary board
297 for( EDA_ITEM* item : aSelection )
298 {
299 BOARD_ITEM* copy = cloneAndAdd( item );
300
301 if( !copy )
302 continue;
303
304 copy->SetParentGroup( nullptr );
305
306 if( copy->Type() == PCB_FOOTPRINT_T )
307 {
308 static_cast<FOOTPRINT*>( copy )->RunOnChildren( addNetIfNeeded, RECURSE_MODE::NO_RECURSE );
309 }
310 else if( copy->Type() == PCB_GROUP_T || copy->Type() == PCB_GENERATOR_T )
311 {
312 PCB_GROUP* group = static_cast<PCB_GROUP*>( item );
313
314 // Groups also need their children copied
315 group->RunOnChildren( cloneAndAdd, RECURSE_MODE::RECURSE );
316 group->RunOnChildren( addNetIfNeeded, RECURSE_MODE::RECURSE );
317 }
318 else
319 addNetIfNeeded( copy );
320 }
321
322 wxString tempFile = wxFileName::CreateTempFileName( "design_block" );
323
324 if( !saveBoardAsFile( tempBoard, tempFile, false ) )
325 {
326 DisplayErrorMessage( this, _( "Error saving temporary board file to create design block." ) );
327 wxRemoveFile( tempFile );
328 return false;
329 }
330
331 aBlock.SetBoardFile( tempFile );
332
333 bool success = false;
334
335 try
336 {
337 success = Prj().DesignBlockLibs()->SaveDesignBlock( aNickname, &aBlock )
339 }
340 catch( const IO_ERROR& ioe )
341 {
342 DisplayError( this, ioe.What() );
343 }
344
345 // Clean up the temporary file
346 wxRemoveFile( tempFile );
347
348 m_designBlocksPane->RefreshLibs();
349 m_designBlocksPane->SelectLibId( aBlock.GetLibId() );
350
351 return success;
352}
353
354
355bool PCB_EDIT_FRAME::SaveSelectionAsDesignBlock( const wxString& aLibraryName )
356{
357 // Make sure the user has selected a library to save into
358 if( m_designBlocksPane->GetSelectedLibId().GetLibNickname().empty() )
359 {
360 DisplayErrorMessage( this, _( "Please select a library to save the design block to." ) );
361 return false;
362 }
363
364 // Get all selected items
365 PCB_SELECTION selection = m_toolManager->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
366
367 if( selection.Empty() )
368 {
369 DisplayErrorMessage( this, _( "Please select some items to save as a design block." ) );
370 return false;
371 }
372
373 DESIGN_BLOCK blk;
374 PCB_GROUP* group = nullptr;
375
376 if( selection.Size() == 1 && selection.HasType( PCB_GROUP_T ) )
377 group = static_cast<PCB_GROUP*>( selection.Front() );
378
379 if( group && !group->GetName().IsEmpty() )
380 // If the user has selected a single group, they probably want the design block named after the group
381 blk.SetLibId( LIB_ID( aLibraryName, group->GetName() ) );
382 else
383 {
384 // Otherwise, use the current screen name
385 wxFileName fn = wxFileNameFromPath( GetBoard()->GetFileName() );
386 blk.SetLibId( LIB_ID( aLibraryName, fn.GetName() ) );
387 }
388
389 DIALOG_DESIGN_BLOCK_PROPERTIES dlg( this, &blk );
390
391 if( dlg.ShowModal() != wxID_OK )
392 return false;
393
394 wxString libName = blk.GetLibId().GetLibNickname();
395 wxString newName = blk.GetLibId().GetLibItemName();
396
397 if( Prj().DesignBlockLibs()->DesignBlockExists( libName, newName ) && !checkOverwriteDb( this, libName, newName ) )
398 {
399 return false;
400 }
401
402 // If we have a single group, we want to strip the group and select the children
403 if( group )
404 {
405 selection.Remove( group );
406
407 // Don't recurse; if we have a group of groups the user probably intends the inner groups to be saved
408 group->RunOnChildren(
409 [&]( EDA_ITEM* aItem )
410 {
411 selection.Add( aItem );
412 },
414 }
415
416 bool success = saveSelectionToDesignBlock( libName, selection, blk );
417
418 if( success && !group )
419 {
420 BOARD_COMMIT commit( m_toolManager );
421
422 PCB_GROUP* newGroup = new PCB_GROUP( GetBoard() );
423 newGroup->SetName( blk.GetLibId().GetUniStringLibItemName() );
424 newGroup->SetDesignBlockLibId( blk.GetLibId() );
425
426 bool added = false;
427
428 for( EDA_ITEM* edaItem : selection )
429 {
430 if( !edaItem->IsBOARD_ITEM() )
431 continue;
432
433 BOARD_ITEM* item = static_cast<BOARD_ITEM*>( edaItem );
434
435 if( item->GetParentFootprint() )
436 continue;
437
438 if( !item->IsGroupableType() )
439 continue;
440
441 if( EDA_GROUP* existingGroup = item->GetParentGroup() )
442 commit.Modify( existingGroup->AsEdaItem(), nullptr, RECURSE_MODE::NO_RECURSE );
443
444 commit.Modify( item, nullptr, RECURSE_MODE::NO_RECURSE );
445 newGroup->AddItem( item );
446 added = true;
447 }
448
449 if( added )
450 {
451 commit.Add( newGroup );
452 commit.Push( _( "Group Items" ) );
453
455 m_toolManager->RunAction( ACTIONS::selectItem, newGroup->AsEdaItem() );
456 }
457 else
458 {
459 delete newGroup;
460 }
461 }
462
463 if( success && group && !group->HasDesignBlockLink() )
464 {
465 BOARD_COMMIT commit( m_toolManager );
466
467 commit.Modify( group, nullptr, RECURSE_MODE::NO_RECURSE );
468 group->SetDesignBlockLibId( blk.GetLibId() );
469
470 commit.Push( _( "Set Group Design Block Link" ) );
471 }
472
473 return success;
474}
475
476
478{
479 // Make sure the user has selected a library to save into
480 if( !aLibId.IsValid() )
481 {
482 DisplayErrorMessage( this, _( "Please select a library to save the design block to." ) );
483 return false;
484 }
485
486 // Get all selected items
487 PCB_SELECTION selection = m_toolManager->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
488
489 if( selection.Empty() )
490 {
491 DisplayErrorMessage( this, _( "Please select some items to save as a design block." ) );
492 return false;
493 }
494
495 // If we have a single group, we want to strip the group and select the children
496 PCB_GROUP* group = nullptr;
497
498 if( selection.Size() == 1 )
499 {
500 EDA_ITEM* item = selection.Front();
501
502 if( item->Type() == PCB_GROUP_T || item->Type() == PCB_GENERATOR_T )
503 {
504 group = static_cast<PCB_GROUP*>( item );
505
506 selection.Remove( item );
507
508 // Don't recurse; if we have a group of groups the user probably intends the inner groups to be saved
509 group->RunOnChildren( [&]( EDA_ITEM* aItem ) { selection.Add( aItem ); }, RECURSE_MODE::NO_RECURSE );
510 }
511 }
512
513 std::unique_ptr<DESIGN_BLOCK> blk;
514
515 try
516 {
517 blk.reset( Prj().DesignBlockLibs()->LoadDesignBlock( aLibId.GetLibNickname(), aLibId.GetLibItemName() ) );
518 }
519 catch( const IO_ERROR& ioe )
520 {
521 DisplayError( this, ioe.What() );
522 return false;
523 }
524
525 if( !blk )
526 {
528 this, wxString::Format( _( "Design block '%s' does not exist." ), aLibId.GetUniStringLibItemName() ) );
529 return false;
530 }
531
532 if( !blk->GetBoardFile().IsEmpty() && !checkOverwriteDbLayout( this, aLibId ) )
533 return false;
534
535 if( !saveSelectionToDesignBlock( aLibId.GetLibNickname(), selection, *blk ) )
536 return false;
537
538 // If we had a group, we need to reselect it
539 if( group )
540 {
541 selection.Clear();
542 selection.Add( group );
543
544 // If we didn't have a design block link before, add one for convenience
545 if( !group->HasDesignBlockLink() )
546 {
547 BOARD_COMMIT commit( m_toolManager );
548
549 commit.Modify( group, nullptr, RECURSE_MODE::NO_RECURSE );
550 group->SetDesignBlockLibId( aLibId );
551
552 commit.Push( _( "Set Group Design Block Link" ) );
553 }
554 }
555 else
556 {
557 BOARD_COMMIT commit( m_toolManager );
558
559 PCB_GROUP* newGroup = new PCB_GROUP( GetBoard() );
560 newGroup->SetName( aLibId.GetUniStringLibItemName() );
561 newGroup->SetDesignBlockLibId( aLibId );
562
563 bool added = false;
564
565 for( EDA_ITEM* edaItem : selection )
566 {
567 if( !edaItem->IsBOARD_ITEM() )
568 continue;
569
570 BOARD_ITEM* item = static_cast<BOARD_ITEM*>( edaItem );
571
572 if( item->GetParentFootprint() )
573 continue;
574
575 if( !item->IsGroupableType() )
576 continue;
577
578 if( EDA_GROUP* existingGroup = item->GetParentGroup() )
579 commit.Modify( existingGroup->AsEdaItem(), nullptr, RECURSE_MODE::NO_RECURSE );
580
581 commit.Modify( item, nullptr, RECURSE_MODE::NO_RECURSE );
582 newGroup->AddItem( item );
583 added = true;
584 }
585
586 if( added )
587 {
588 commit.Add( newGroup );
589 commit.Push( _( "Group Items" ) );
590
592 m_toolManager->RunAction( ACTIONS::selectItem, newGroup->AsEdaItem() );
593 }
594 else
595 {
596 delete newGroup;
597 }
598 }
599
600 return true;
601}
static TOOL_ACTION selectItem
Select an item (specified as the event parameter).
Definition actions.h:227
static TOOL_ACTION selectionClear
Clear the current selection.
Definition actions.h:224
virtual void Push(const wxString &aMessage=wxEmptyString, int aCommitFlags=0) override
Execute the changes.
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
NETINFO_ITEM * GetNet() const
Return #NET_INFO object for a given item.
void SetNet(NETINFO_ITEM *aNetInfo)
Set a NET_INFO object for the item.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition board_item.h:83
bool IsGroupableType() const
FOOTPRINT * GetParentFootprint() const
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:322
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
Definition board.cpp:1224
NETINFO_ITEM * FindNet(int aNetcode) const
Search for a net with the given netcode.
Definition board.cpp:2362
void SetDesignSettings(const BOARD_DESIGN_SETTINGS &aSettings)
Definition board.cpp:1090
void SetProject(PROJECT *aProject, bool aReferenceOnly=false)
Link a board to a given project.
Definition board.cpp:202
void SynchronizeProperties()
Copy the current project's text variables into the boards property cache.
Definition board.cpp:2482
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr, RECURSE_MODE aRecurse=RECURSE_MODE::NO_RECURSE)
Modify a given item in the model.
Definition commit.h:106
COMMIT & Add(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Add a new item to the model.
Definition commit.h:78
SAVE_T SaveDesignBlock(const wxString &aNickname, const DESIGN_BLOCK *aDesignBlock, bool aOverwrite=true)
Write aDesignBlock to an existing library given by aNickname.
void SetBoardFile(const wxString &aFile)
void SetLibId(const LIB_ID &aName)
const LIB_ID & GetLibId() const
int ShowModal() override
bool IsWritable(const wxFileName &aFileName, bool aVerbose=true)
Check if aFileName can be written.
A set of EDA_ITEMs (i.e., without duplicates).
Definition eda_group.h:46
void SetDesignBlockLibId(const LIB_ID &aLibId)
Definition eda_group.h:72
void AddItem(EDA_ITEM *aItem)
Add item to group.
Definition eda_group.cpp:27
void SetName(const wxString &aName)
Definition eda_group.h:52
A base class for most all the KiCad significant classes used in schematics and boards.
Definition eda_item.h:98
virtual EDA_GROUP * GetParentGroup() const
Definition eda_item.h:116
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:110
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
virtual const wxString What() const
A composite of Problem() and Where()
A logical library item identifier and consists of various portions much like a URI.
Definition lib_id.h:49
bool IsValid() const
Check if this LID_ID is valid.
Definition lib_id.h:172
const wxString GetUniStringLibItemName() const
Get strings for display messages in dialogs.
Definition lib_id.h:112
const UTF8 & GetLibItemName() const
Definition lib_id.h:102
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition lib_id.h:87
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition locale_io.h:41
Handle the data for a net.
Definition netinfo.h:54
const wxString & GetNetname() const
Definition netinfo.h:112
BOARD * GetBoard() const
virtual BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Return the BOARD_DESIGN_SETTINGS for the open project.
bool saveBoardAsFile(BOARD *aBoard, const wxString &aFileName, bool aHeadless=false)
Save a board object to a file.
bool saveSelectionToDesignBlock(const wxString &aNickname, PCB_SELECTION &aSelection, DESIGN_BLOCK &aBlock)
bool UpdateDesignBlockFromBoard(const LIB_ID &aLibId)
bool UpdateDesignBlockFromSelection(const LIB_ID &aLibId)
bool SavePcbCopy(const wxString &aFileName, bool aCreateProject=false, bool aHeadless=false)
Write the board data structures to aFileName.
bool SaveSelectionAsDesignBlock(const wxString &aLibraryName)
bool SaveBoardAsDesignBlock(const wxString &aLibraryName)
PCB_DESIGN_BLOCK_PANE * m_designBlocksPane
A set of BOARD_ITEMs (i.e., without duplicates).
Definition pcb_group.h:53
EDA_ITEM * AsEdaItem() override
Definition pcb_group.h:60
@ KICAD_SEXP
S-expression Pcbnew file format.
Definition pcb_io_mgr.h:58
static PCB_IO * FindPlugin(PCB_FILE_T aFileType)
Return a #PLUGIN which the caller can use to import, export, save, or load design documents.
The selection tool: currently supports:
virtual DESIGN_BLOCK_LIBRARY_ADAPTER * DesignBlockLibs()
Return the table of design block libraries.
Definition project.cpp:418
virtual void Add(EDA_ITEM *aItem)
Definition selection.cpp:42
virtual void Remove(EDA_ITEM *aItem)
Definition selection.cpp:60
EDA_ITEM * Front() const
Definition selection.h:177
virtual void Clear() override
Remove all the stored items from the group.
Definition selection.h:98
bool HasType(KICAD_T aType) const
Checks if there is at least one item of requested kind.
int Size() const
Returns the number of selected parts.
Definition selection.h:121
bool Empty() const
Checks if there is anything selected.
Definition selection.h:115
TOOL_MANAGER * m_toolManager
The common library.
int OKOrCancelDialog(wxWindow *aParent, const wxString &aWarning, const wxString &aMessage, const wxString &aDetailedMessage, const wxString &aOKLabel, const wxString &aCancelLabel, bool *aApplyToAll)
Display a warning dialog with aMessage and returns the user response.
Definition confirm.cpp:150
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition confirm.cpp:202
void DisplayError(wxWindow *aParent, const wxString &aText)
Display an error or warning message box with aMessage.
Definition confirm.cpp:177
This file is part of the common library.
#define _(s)
@ RECURSE
Definition eda_item.h:51
@ NO_RECURSE
Definition eda_item.h:52
Helper functions to substitute paths with environmental variables.
std::unique_ptr< T > IO_RELEASER
Helper to hold and release an IO_BASE object when exceptions are thrown.
Definition io_mgr.h:33
PROJECT & Prj()
Definition kicad.cpp:637
bool checkOverwriteDb(wxWindow *aFrame, wxString &libname, wxString &newName)
bool checkOverwriteDbLayout(wxWindow *aFrame, const LIB_ID &aLibId)
Class to handle a set of BOARD_ITEMs.
see class PGM_BASE
bool checkOverwriteDb(wxWindow *aFrame, wxString &libname, wxString &newName)
std::vector< FAB_LAYER_COLOR > dummy
@ 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:111
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
Definition typeinfo.h:86
Definition of file extensions used in Kicad.