KiCad PCB EDA Suite
invoke_pcb_dialog.h File Reference

Go to the source code of this file.

Functions

void InvokePcbLibTableEditor (KIWAY *aKiway, wxWindow *aCaller)
 Function InvokePcbLibTableEditor shows the modal DIALOG_FP_LIB_TABLE for purposes of editing the global and project library tables. More...
 
void Invoke3DShapeLibsDownloaderWizard (wxWindow *aCaller)
 Function Invoke3DShapeLibsDownloaderWizard Runs the downloader wizard for easy 3D shape libraries download from the official Kicad Github repository of *.3Dshape libraries. More...
 
void InvokePluginOptionsEditor (wxWindow *aCaller, const wxString &aNickname, const wxString &aPluginType, const wxString &aOptions, wxString *aResult)
 Function InvokePluginOptionsEditor calls DIALOG_FP_PLUGIN_OPTIONS dialog so that plugin options set can be edited. More...
 
bool InvokeDialogImportGfxBoard (PCB_BASE_FRAME *aCaller)
 Shows the modal DIALOG_IMPORT_GFX for importing a DXF file to a board. More...
 
bool InvokeDialogImportGfxModule (PCB_BASE_FRAME *aCaller, MODULE *aModule)
 shows the modal DIALOG_IMPORT_GFX for importing a DXF file as footprint outlines. More...
 
bool InvokeExportSVG (PCB_BASE_FRAME *aCaller, BOARD *aBoard)
 Function InvokeExportSVG shows the Export SVG dialog. More...
 

Function Documentation

◆ Invoke3DShapeLibsDownloaderWizard()

void Invoke3DShapeLibsDownloaderWizard ( wxWindow *  aCaller)

Function Invoke3DShapeLibsDownloaderWizard Runs the downloader wizard for easy 3D shape libraries download from the official Kicad Github repository of *.3Dshape libraries.

Parameters
aCalleris the wxWindow which is invoking the dialog.

Definition at line 58 of file wizard_3DShape_Libs_downloader.cpp.

59 {
60  WIZARD_3DSHAPE_LIBS_DOWNLOADER wizard( aCaller );
61  wizard.RunWizard( wizard.GetFirstPage() );
62 }

References WIZARD_3DSHAPE_LIBS_DOWNLOADER::GetFirstPage().

Referenced by PCB_EDIT_FRAME::Process_Config().

◆ InvokeDialogImportGfxBoard()

bool InvokeDialogImportGfxBoard ( PCB_BASE_FRAME aCaller)

Shows the modal DIALOG_IMPORT_GFX for importing a DXF file to a board.

Parameters
aCalleris the wxTopLevelWindow which is invoking the dialog.
Returns
true if the import was made.

Definition at line 383 of file dialog_import_gfx.cpp.

384 {
385  DIALOG_IMPORT_GFX dlg( aCaller );
386 
387  if( dlg.ShowModal() != wxID_OK )
388  return false;
389 
390  auto& list = dlg.GetImportedItems();
391 
392  // Ensure the list is not empty:
393  if( list.empty() )
394  {
395  wxMessageBox( _( "No graphic items found in file to import." ) );
396  return false;
397  }
398 
399  PICKED_ITEMS_LIST picklist; // the pick list for undo command
400  ITEM_PICKER item_picker( nullptr, UR_NEW );
401  BOARD* board = aCaller->GetBoard();
402 
403  // Now prepare a block move command to place the new items, if interactive placement,
404  // and prepare the undo command.
405  EDA_RECT bbox; // the new items bounding box, for block move if interactive placement.
406  bool bboxInit = true; // true until the bounding box is initialized
407  BLOCK_SELECTOR& blockmove = aCaller->GetScreen()->m_BlockLocate;
408 
409  if( dlg.IsPlacementInteractive() )
410  aCaller->HandleBlockBegin( NULL, BLOCK_PRESELECT_MOVE, wxPoint( 0, 0 ) );
411 
412  PICKED_ITEMS_LIST& blockitemsList = blockmove.GetItems();
413 
414  for( auto it = list.begin(); it != list.end(); ++it )
415  {
416  BOARD_ITEM* item = static_cast<BOARD_ITEM*>( it->release() );
417 
418  if( dlg.IsPlacementInteractive() )
419  item->SetFlags( IS_MOVED );
420 
421  board->Add( item );
422 
423  item_picker.SetItem( item );
424  picklist.PushItem( item_picker );
425 
426  if( dlg.IsPlacementInteractive() )
427  {
428  blockitemsList.PushItem( item_picker );
429 
430  if( bboxInit )
431  bbox = item->GetBoundingBox();
432  else
433  bbox.Merge( item->GetBoundingBox() );
434 
435  bboxInit = false;
436  }
437  }
438 
439  aCaller->SaveCopyInUndoList( picklist, UR_NEW, wxPoint( 0, 0 ) );
440  aCaller->OnModify();
441 
442  if( dlg.IsPlacementInteractive() )
443  {
444  // Finish block move command:
445  wxPoint cpos = aCaller->GetNearestGridPosition( bbox.Centre() );
446  blockmove.SetOrigin( bbox.GetOrigin() );
447  blockmove.SetSize( bbox.GetSize() );
448  blockmove.SetLastCursorPosition( cpos );
449  aCaller->HandleBlockEnd( NULL );
450  }
451 
452  return true;
453 }
BLOCK_SELECTOR m_BlockLocate
Block description for block commands.
Definition: base_screen.h:214
void Merge(const EDA_RECT &aRect)
Function Merge modifies the position and size of the rectangle in order to contain aRect.
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
void SetOrigin(const wxPoint &pos)
Definition: eda_rect.h:124
void PushItem(const ITEM_PICKER &aItem)
Function PushItem pushes aItem to the top of the list.
virtual bool HandleBlockBegin(wxDC *aDC, EDA_KEY aKey, const wxPoint &aPosition, int aExplicitCommand=0)
Initialize a block command.
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:259
const wxPoint GetOrigin() const
Definition: eda_rect.h:112
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_INSERT) override
Adds an item to the container.
Class PICKED_ITEMS_LIST is a holder to handle information on schematic or board items.
virtual bool HandleBlockEnd(wxDC *DC)
Handle the "end" of a block command, i.e.
wxPoint GetNearestGridPosition(const wxPoint &aPosition, wxRealPoint *aGridSize=NULL) const
Return the nearest aGridSize location to aPosition.
virtual void OnModify()
Function OnModify Virtual Must be called after a change in order to set the "modify" flag of the curr...
void SetSize(const wxSize &size)
Definition: eda_rect.h:126
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:170
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
virtual void SaveCopyInUndoList(BOARD_ITEM *aItemToCopy, UNDO_REDO_T aTypeCommand, const wxPoint &aTransformPoint=wxPoint(0, 0))=0
Function SaveCopyInUndoList (virtual pure) Creates a new entry in undo list of commands.
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
wxPoint Centre() const
Definition: eda_rect.h:60
PICKED_ITEMS_LIST & GetItems()
BOARD * GetBoard() const
virtual const EDA_RECT GetBoundingBox() const
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
void SetLastCursorPosition(const wxPoint &aPosition)
Function SetLastCursorPosition sets the last cursor position to aPosition.
const wxSize GetSize() const
Definition: eda_rect.h:101
#define IS_MOVED
Item being moved.
Definition: base_struct.h:113

References BOARD::Add(), BLOCK_PRESELECT_MOVE, EDA_RECT::Centre(), PCB_BASE_FRAME::GetBoard(), EDA_ITEM::GetBoundingBox(), DIALOG_IMPORT_GFX::GetImportedItems(), BLOCK_SELECTOR::GetItems(), EDA_DRAW_FRAME::GetNearestGridPosition(), EDA_RECT::GetOrigin(), PCB_BASE_FRAME::GetScreen(), EDA_RECT::GetSize(), EDA_DRAW_FRAME::HandleBlockBegin(), EDA_DRAW_FRAME::HandleBlockEnd(), IS_MOVED, DIALOG_IMPORT_GFX::IsPlacementInteractive(), BASE_SCREEN::m_BlockLocate, EDA_RECT::Merge(), PCB_BASE_FRAME::OnModify(), PICKED_ITEMS_LIST::PushItem(), PCB_BASE_FRAME::SaveCopyInUndoList(), EDA_ITEM::SetFlags(), ITEM_PICKER::SetItem(), BLOCK_SELECTOR::SetLastCursorPosition(), EDA_RECT::SetOrigin(), EDA_RECT::SetSize(), and UR_NEW.

Referenced by PCB_EDIT_FRAME::Process_Special_Functions().

◆ InvokeDialogImportGfxModule()

bool InvokeDialogImportGfxModule ( PCB_BASE_FRAME aCaller,
MODULE aModule 
)

shows the modal DIALOG_IMPORT_GFX for importing a DXF file as footprint outlines.

Parameters
aCalleris the wxTopLevelWindow which is invoking the dialog.
aModuleis the footprint currently edited.
Returns
true if the import was made.

Definition at line 457 of file dialog_import_gfx.cpp.

458 {
459  if( !aModule )
460  return false;
461 
462  DIALOG_IMPORT_GFX dlg( aCaller, true );
463 
464  if( dlg.ShowModal() != wxID_OK )
465  return false;
466 
467  auto& list = dlg.GetImportedItems();
468 
469  // Ensure the list is not empty:
470  if( list.empty() )
471  {
472  wxMessageBox( _( "No graphic items found in file to import" ) );
473  return false;
474  }
475 
476  aCaller->SaveCopyInUndoList( aModule, UR_CHANGED );
477 
478  PICKED_ITEMS_LIST picklist; // the pick list for undo command
479  ITEM_PICKER item_picker( nullptr, UR_NEW );
480 
481  // Now prepare a block move command to place the new items, if interactive placement,
482  // and prepare the undo command.
483  EDA_RECT bbox; // the new items bounding box, for block move if interactive placement.
484  bool bboxInit = true; // true until the bounding box is initialized
485  BLOCK_SELECTOR& blockmove = aCaller->GetScreen()->m_BlockLocate;
486 
487  if( dlg.IsPlacementInteractive() )
488  aCaller->HandleBlockBegin( nullptr, BLOCK_PRESELECT_MOVE, wxPoint( 0, 0 ) );
489 
490  PICKED_ITEMS_LIST& blockitemsList = blockmove.GetItems();
491 
492  for( auto it = list.begin(); it != list.end(); ++it )
493  {
494  BOARD_ITEM* item = static_cast<BOARD_ITEM*>( it->release() );
495  aModule->Add( item );
496 
497  if( dlg.IsPlacementInteractive() )
498  {
499  item->SetFlags( IS_MOVED );
500  item_picker.SetItem( item );
501  blockitemsList.PushItem( item_picker );
502 
503  if( bboxInit )
504  bbox = item->GetBoundingBox();
505  else
506  bbox.Merge( item->GetBoundingBox() );
507 
508  bboxInit = false;
509  }
510  }
511 
512  aCaller->OnModify();
513 
514  if( dlg.IsPlacementInteractive() )
515  {
516  // Finish block move command:
517  wxPoint cpos = aCaller->GetNearestGridPosition( bbox.Centre() );
518  blockmove.SetOrigin( bbox.GetOrigin() );
519  blockmove.SetSize( bbox.GetSize() );
520  blockmove.SetLastCursorPosition( cpos );
521  aCaller->HandleBlockEnd( NULL );
522  }
523 
524  return true;
525 }
BLOCK_SELECTOR m_BlockLocate
Block description for block commands.
Definition: base_screen.h:214
void Merge(const EDA_RECT &aRect)
Function Merge modifies the position and size of the rectangle in order to contain aRect.
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
void SetOrigin(const wxPoint &pos)
Definition: eda_rect.h:124
void PushItem(const ITEM_PICKER &aItem)
Function PushItem pushes aItem to the top of the list.
virtual bool HandleBlockBegin(wxDC *aDC, EDA_KEY aKey, const wxPoint &aPosition, int aExplicitCommand=0)
Initialize a block command.
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_INSERT) override
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:259
const wxPoint GetOrigin() const
Definition: eda_rect.h:112
Class PICKED_ITEMS_LIST is a holder to handle information on schematic or board items.
virtual bool HandleBlockEnd(wxDC *DC)
Handle the "end" of a block command, i.e.
wxPoint GetNearestGridPosition(const wxPoint &aPosition, wxRealPoint *aGridSize=NULL) const
Return the nearest aGridSize location to aPosition.
virtual void OnModify()
Function OnModify Virtual Must be called after a change in order to set the "modify" flag of the curr...
void SetSize(const wxSize &size)
Definition: eda_rect.h:126
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
virtual void SaveCopyInUndoList(BOARD_ITEM *aItemToCopy, UNDO_REDO_T aTypeCommand, const wxPoint &aTransformPoint=wxPoint(0, 0))=0
Function SaveCopyInUndoList (virtual pure) Creates a new entry in undo list of commands.
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
wxPoint Centre() const
Definition: eda_rect.h:60
PICKED_ITEMS_LIST & GetItems()
virtual const EDA_RECT GetBoundingBox() const
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
void SetLastCursorPosition(const wxPoint &aPosition)
Function SetLastCursorPosition sets the last cursor position to aPosition.
const wxSize GetSize() const
Definition: eda_rect.h:101
#define IS_MOVED
Item being moved.
Definition: base_struct.h:113

References MODULE::Add(), BLOCK_PRESELECT_MOVE, EDA_RECT::Centre(), EDA_ITEM::GetBoundingBox(), DIALOG_IMPORT_GFX::GetImportedItems(), BLOCK_SELECTOR::GetItems(), EDA_DRAW_FRAME::GetNearestGridPosition(), EDA_RECT::GetOrigin(), PCB_BASE_FRAME::GetScreen(), EDA_RECT::GetSize(), EDA_DRAW_FRAME::HandleBlockBegin(), EDA_DRAW_FRAME::HandleBlockEnd(), IS_MOVED, DIALOG_IMPORT_GFX::IsPlacementInteractive(), BASE_SCREEN::m_BlockLocate, EDA_RECT::Merge(), PCB_BASE_FRAME::OnModify(), PICKED_ITEMS_LIST::PushItem(), PCB_BASE_FRAME::SaveCopyInUndoList(), EDA_ITEM::SetFlags(), ITEM_PICKER::SetItem(), BLOCK_SELECTOR::SetLastCursorPosition(), EDA_RECT::SetOrigin(), EDA_RECT::SetSize(), UR_CHANGED, and UR_NEW.

Referenced by FOOTPRINT_EDIT_FRAME::Process_Special_Functions().

◆ InvokeExportSVG()

bool InvokeExportSVG ( PCB_BASE_FRAME aCaller,
BOARD aBoard 
)

Function InvokeExportSVG shows the Export SVG dialog.

Parameters
aCalleris the PCB_BASE_FRAME which is invoking the dialog.
aBoardis the currently edited board.
Returns
bool - true if user pressed OK (did not abort), else false.

Definition at line 364 of file dialog_export_svg.cpp.

365 {
366  DIALOG_EXPORT_SVG dlg( aCaller, aBoard );
367 
368  dlg.ShowModal();
369 
370  return true;
371 }

Referenced by PCB_EDIT_FRAME::ExportSVG().

◆ InvokePcbLibTableEditor()

void InvokePcbLibTableEditor ( KIWAY aKiway,
wxWindow *  aCaller 
)

Function InvokePcbLibTableEditor shows the modal DIALOG_FP_LIB_TABLE for purposes of editing the global and project library tables.

Parameters
aCalleris the wxWindow which is invoking the dialog.
Returns
true if either table changed.

Definition at line 810 of file panel_fp_lib_table.cpp.

811 {
812  FP_LIB_TABLE* globalTable = &GFootprintTable;
813  wxString globalTablePath = FP_LIB_TABLE::GetGlobalTableFileName();
814  FP_LIB_TABLE* projectTable = aKiway->Prj().PcbFootprintLibs();
815  wxString projectTablePath = aKiway->Prj().FootprintLibTblName();
816  wxString msg;
817 
818  DIALOG_EDIT_LIBRARY_TABLES dlg( aCaller, _( "Footprint Libraries" ) );
819  dlg.SetKiway( &dlg, aKiway );
820 
821  dlg.InstallPanel( new PANEL_FP_LIB_TABLE( &dlg, globalTable, globalTablePath,
822  projectTable, projectTablePath,
823  aKiway->Prj().GetProjectPath() ) );
824 
825  if( dlg.ShowModal() == wxID_CANCEL )
826  return;
827 
828  if( dlg.m_GlobalTableChanged )
829  {
830  try
831  {
832  globalTable->Save( globalTablePath );
833  }
834  catch( const IO_ERROR& ioe )
835  {
836  msg.Printf( _( "Error saving global library table:\n\n%s" ), ioe.What() );
837  wxMessageBox( msg, _( "File Save Error" ), wxOK | wxICON_ERROR );
838  }
839  }
840 
841  if( dlg.m_ProjectTableChanged )
842  {
843  try
844  {
845  projectTable->Save( projectTablePath );
846  }
847  catch( const IO_ERROR& ioe )
848  {
849  msg.Printf( _( "Error saving project-specific library table:\n\n%s" ), ioe.What() );
850  wxMessageBox( msg, _( "File Save Error" ), wxOK | wxICON_ERROR );
851  }
852  }
853 
854  auto editor = (FOOTPRINT_EDIT_FRAME*) aKiway->Player( FRAME_PCB_MODULE_EDITOR, false );
855 
856  if( editor )
857  editor->SyncLibraryTree( true );
858 
859  auto viewer = (FOOTPRINT_VIEWER_FRAME*) aKiway->Player( FRAME_PCB_MODULE_VIEWER, false );
860 
861  if( viewer )
862  viewer->ReCreateLibraryList();
863 }
VTBL_ENTRY PROJECT & Prj() const
Function Prj returns the PROJECT associated with this KIWAY.
Definition: kiway.cpp:163
Component library viewer main window.
VTBL_ENTRY const wxString GetProjectPath() const
Function GetProjectPath returns the full path of the project.
Definition: project.cpp:102
FP_LIB_TABLE GFootprintTable
The global footprint library table.
Definition: pcbnew.cpp:326
VTBL_ENTRY KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=NULL)
Function Player returns the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:321
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:33
VTBL_ENTRY FP_LIB_TABLE * PcbFootprintLibs(KIWAY &aKiway)
Return the table of footprint libraries.
void Save(const wxString &aFileName) const
Write this library table to aFileName in s-expression form.
Dialog to show and edit symbol library tables.
Struct IO_ERROR is a class used to hold an error message and may be used when throwing exceptions con...
Definition: ki_exception.h:76
VTBL_ENTRY const wxString FootprintLibTblName() const
Function FootprintLibTblName returns the path and filename of this project's fp-lib-table,...
Definition: project.cpp:120
static wxString GetGlobalTableFileName()
Function GetGlobalTableFileName.

References PROJECT::FootprintLibTblName(), FRAME_PCB_MODULE_EDITOR, FRAME_PCB_MODULE_VIEWER, FP_LIB_TABLE::GetGlobalTableFileName(), PROJECT::GetProjectPath(), GFootprintTable, DIALOG_EDIT_LIBRARY_TABLES::InstallPanel(), DIALOG_EDIT_LIBRARY_TABLES::m_GlobalTableChanged, DIALOG_EDIT_LIBRARY_TABLES::m_ProjectTableChanged, PROJECT::PcbFootprintLibs(), KIWAY::Player(), KIWAY::Prj(), LIB_TABLE::Save(), KIWAY_HOLDER::SetKiway(), and IO_ERROR::What().

Referenced by PCB::IFACE::CreateWindow(), PCB_EDIT_FRAME::Process_Config(), and FOOTPRINT_EDIT_FRAME::ProcessPreferences().

◆ InvokePluginOptionsEditor()

void InvokePluginOptionsEditor ( wxWindow *  aCaller,
const wxString &  aNickname,
const wxString &  aPluginType,
const wxString &  aOptions,
wxString *  aResult 
)

Function InvokePluginOptionsEditor calls DIALOG_FP_PLUGIN_OPTIONS dialog so that plugin options set can be edited.

Parameters
aCalleris the wxTopLevelWindow which is invoking the dialog.
aNicknameis the footprint library whose options are being edited.
aPluginTypeis something that will pass through IO_MGR::EnumFromStr().
aOptionsis the options string on calling into this function.
aResultis where to put the result of the editing.

Definition at line 292 of file dialog_fp_plugin_options.cpp.

295 {
296  DIALOG_FP_PLUGIN_OPTIONS dlg( aCaller, aNickname, aPluginType, aOptions, aResult );
297 
298  dlg.ShowModal();
299 }
Class DIALOG_FP_PLUGIN_OPTIONS is an options editor in the form of a two column name/value spreadshee...

Referenced by FP_GRID_TRICKS::optionsEditor().