KiCad PCB EDA Suite
dialog_dxf_import.cpp File Reference

Dialog to import a dxf file on a given board layer. More...

#include <dialog_dxf_import.h>
#include <kiface_i.h>
#include <convert_to_biu.h>
#include <class_pcb_layer_box_selector.h>
#include <class_board.h>
#include <class_module.h>
#include <class_edge_mod.h>
#include <class_text_mod.h>
#include <class_pcb_text.h>

Go to the source code of this file.

Macros

#define DXF_IMPORT_LAYER_OPTION_KEY   "DxfImportBrdLayer"
 
#define DXF_IMPORT_COORD_ORIGIN_KEY   "DxfImportCoordOrigin"
 
#define DXF_IMPORT_LAST_FILE_KEY   "DxfImportLastFile"
 
#define DXF_IMPORT_GRID_UNITS_KEY   "DxfImportGridUnits"
 
#define DXF_IMPORT_GRID_OFFSET_X_KEY   "DxfImportGridOffsetX"
 
#define DXF_IMPORT_GRID_OFFSET_Y_KEY   "DxfImportGridOffsetY"
 

Functions

bool InvokeDXFDialogBoardImport (PCB_BASE_FRAME *aCaller)
 Function InvokeDXFDialogBoardImport shows the modal DIALOG_DXF_IMPORT for importing a DXF file to a board. More...
 
bool InvokeDXFDialogModuleImport (PCB_BASE_FRAME *aCaller, MODULE *aModule)
 Function InvokeDXFDialogModuleImport shows the modal DIALOG_DXF_IMPORT for importing a DXF file as footprint outlines. More...
 

Detailed Description

Dialog to import a dxf file on a given board layer.

Definition in file dialog_dxf_import.cpp.

Macro Definition Documentation

#define DXF_IMPORT_COORD_ORIGIN_KEY   "DxfImportCoordOrigin"
#define DXF_IMPORT_GRID_OFFSET_X_KEY   "DxfImportGridOffsetX"
#define DXF_IMPORT_GRID_OFFSET_Y_KEY   "DxfImportGridOffsetY"
#define DXF_IMPORT_GRID_UNITS_KEY   "DxfImportGridUnits"
#define DXF_IMPORT_LAST_FILE_KEY   "DxfImportLastFile"
#define DXF_IMPORT_LAYER_OPTION_KEY   "DxfImportBrdLayer"

Function Documentation

bool InvokeDXFDialogBoardImport ( PCB_BASE_FRAME aCaller)

Function InvokeDXFDialogBoardImport shows the modal DIALOG_DXF_IMPORT 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 209 of file dialog_dxf_import.cpp.

References BOARD::Add(), PCB_BASE_FRAME::GetBoard(), DIALOG_DXF_IMPORT::GetImportedItems(), PCB_BASE_FRAME::OnModify(), PICKED_ITEMS_LIST::PushItem(), PCB_BASE_FRAME::SaveCopyInUndoList(), and UR_NEW.

Referenced by PCB_EDIT_FRAME::Process_Special_Functions().

210 {
211  DIALOG_DXF_IMPORT dlg( aCaller );
212  bool success = ( dlg.ShowModal() == wxID_OK );
213 
214  if( success )
215  {
216  const std::list<BOARD_ITEM*>& list = dlg.GetImportedItems();
217  PICKED_ITEMS_LIST picklist;
218  BOARD* board = aCaller->GetBoard();
219 
220  std::list<BOARD_ITEM*>::const_iterator it, itEnd;
221  for( it = list.begin(), itEnd = list.end(); it != itEnd; ++it )
222  {
223  BOARD_ITEM* item = *it;
224  board->Add( item );
225 
226  ITEM_PICKER itemWrapper( item, UR_NEW );
227  picklist.PushItem( itemWrapper );
228  }
229 
230  aCaller->SaveCopyInUndoList( picklist, UR_NEW, wxPoint( 0, 0 ) );
231  aCaller->OnModify();
232  }
233 
234  return success;
235 }
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
BOARD * GetBoard() const
void PushItem(const ITEM_PICKER &aItem)
Function PushItem pushes aItem to the top of the list.
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_INSERT) override
>
Class PICKED_ITEMS_LIST is a holder to handle information on schematic or board items.
virtual void OnModify()
Function OnModify Virtual Must be called after a change in order to set the "modify" flag of the curr...
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:166
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.
bool InvokeDXFDialogModuleImport ( PCB_BASE_FRAME aCaller,
MODULE aModule 
)

Function InvokeDXFDialogModuleImport shows the modal DIALOG_DXF_IMPORT 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 238 of file dialog_dxf_import.cpp.

References MODULE::Add(), DIALOG_DXF_IMPORT::GetImportedItems(), PCB_BASE_FRAME::OnModify(), PCB_BASE_FRAME::SaveCopyInUndoList(), and UR_CHANGED.

Referenced by FOOTPRINT_EDIT_FRAME::Process_Special_Functions().

239 {
240  wxASSERT( aModule );
241 
242  DIALOG_DXF_IMPORT dlg( aCaller, true );
243  bool success = ( dlg.ShowModal() == wxID_OK );
244 
245  if( success )
246  {
247  const std::list<BOARD_ITEM*>& list = dlg.GetImportedItems();
248 
249  aCaller->SaveCopyInUndoList( aModule, UR_CHANGED );
250  aCaller->OnModify();
251 
252  std::list<BOARD_ITEM*>::const_iterator it, itEnd;
253 
254  for( it = list.begin(), itEnd = list.end(); it != itEnd; ++it )
255  {
256  aModule->Add( *it );
257  }
258  }
259 
260  return success;
261 }
void Add(BOARD_ITEM *aBoardItem, ADD_MODE aMode=ADD_INSERT) override
>
virtual void OnModify()
Function OnModify Virtual Must be called after a change in order to set the "modify" flag of the curr...
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.