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

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

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