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 <wildcards_and_files_ext.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_IMPORT_UNITS_KEY   "DxfImportOffsetUnits"
 
#define DXF_IMPORT_IMPORT_OFFSET_X_KEY   "DxfImportOffsetX"
 
#define DXF_IMPORT_IMPORT_OFFSET_Y_KEY   "DxfImportOffsetY"
 
#define DXF_IMPORT_LINEWIDTH_UNITS_KEY   "DxfImportLineWidthUnits"
 
#define DXF_IMPORT_LINEWIDTH_KEY   "DxfImportLineWidth"
 

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_IMPORT_OFFSET_X_KEY   "DxfImportOffsetX"
#define DXF_IMPORT_IMPORT_OFFSET_Y_KEY   "DxfImportOffsetY"
#define DXF_IMPORT_IMPORT_UNITS_KEY   "DxfImportOffsetUnits"
#define DXF_IMPORT_LAST_FILE_KEY   "DxfImportLastFile"
#define DXF_IMPORT_LAYER_OPTION_KEY   "DxfImportBrdLayer"
#define DXF_IMPORT_LINEWIDTH_KEY   "DxfImportLineWidth"
#define DXF_IMPORT_LINEWIDTH_UNITS_KEY   "DxfImportLineWidthUnits"

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 305 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().

306 {
307  DIALOG_DXF_IMPORT dlg( aCaller );
308  bool success = ( dlg.ShowModal() == wxID_OK );
309 
310  if( success )
311  {
312  const std::list<BOARD_ITEM*>& list = dlg.GetImportedItems();
313  PICKED_ITEMS_LIST picklist;
314  BOARD* board = aCaller->GetBoard();
315 
316  std::list<BOARD_ITEM*>::const_iterator it, itEnd;
317  for( it = list.begin(), itEnd = list.end(); it != itEnd; ++it )
318  {
319  BOARD_ITEM* item = *it;
320  board->Add( item );
321 
322  ITEM_PICKER itemWrapper( item, UR_NEW );
323  picklist.PushItem( itemWrapper );
324  }
325 
326  aCaller->SaveCopyInUndoList( picklist, UR_NEW, wxPoint( 0, 0 ) );
327  aCaller->OnModify();
328  }
329 
330  return success;
331 }
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
Adds an item to the container.
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:169
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 334 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().

335 {
336  wxASSERT( aModule );
337 
338  DIALOG_DXF_IMPORT dlg( aCaller, true );
339  bool success = ( dlg.ShowModal() == wxID_OK );
340 
341  if( success )
342  {
343  const std::list<BOARD_ITEM*>& list = dlg.GetImportedItems();
344 
345  aCaller->SaveCopyInUndoList( aModule, UR_CHANGED );
346  aCaller->OnModify();
347 
348  std::list<BOARD_ITEM*>::const_iterator it, itEnd;
349 
350  for( it = list.begin(), itEnd = list.end(); it != itEnd; ++it )
351  {
352  aModule->Add( *it );
353  }
354  }
355 
356  return success;
357 }
void Add(BOARD_ITEM *aItem, 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.