40#include <wx/filedlg.h>
69 const LSET& aPermittedLayers )
71 std::vector<INPUT_LAYER_DESC> layerDescriptions;
73 for(
const wxString& sourceLayer : aSourceLayers )
76 desc.
Name = sourceLayer;
81 layerDescriptions.push_back( desc );
84 return layerDescriptions;
118 for(
const std::pair<const DXF_IMPORT_UNITS, wxString>& unitEntry :
dxfUnitsMap )
123 wxCommandEvent
dummy;
129 GetSizer()->Fit(
this );
130 GetSizer()->SetSizeHints(
this );
155 DIALOG_SHIM::TransferDataToWindow();
167 bool enableDXFControls =
true;
170 if( std::unique_ptr<GRAPHICS_IMPORT_PLUGIN> plugin =
m_gfxImportMgr->GetPluginByExt( ext ) )
190 if( !filename.IsEmpty() )
192 wxFileName fn( filename );
194 filename = fn.GetFullName();
198 wxString wildcardsDesc;
199 wxString allWildcards;
203 std::unique_ptr<GRAPHICS_IMPORT_PLUGIN> plugin =
m_gfxImportMgr->GetPlugin( pluginType );
204 const std::vector<std::string> extensions = plugin->GetFileExtensions();
207 allWildcards += plugin->GetWildcards() + wxT(
";" );
210 wildcardsDesc =
_(
"All supported formats" ) + wxT(
"|" ) + allWildcards + wildcardsDesc;
212 wxFileDialog dlg(
m_parent,
_(
"Import Graphics" ),
path, filename, wildcardsDesc,
213 wxFD_OPEN | wxFD_FILE_MUST_EXIST );
217 if( dlg.ShowModal() == wxID_OK && !dlg.GetPath().IsEmpty() )
224 if( !wxDialog::TransferDataFromWindow() )
229 wxMessageBox(
_(
"Please select a file to import." ) );
236 if( useSingleLayer &&
m_SelLayerBox->GetLayerSelection() < 0 )
238 wxMessageBox(
_(
"Please select a valid layer." ) );
245 double xscale =
scale;
246 double yscale =
scale;
256 if( std::unique_ptr<GRAPHICS_IMPORT_PLUGIN> plugin =
m_gfxImportMgr->GetPluginByExt( ext ) )
268 dxfPlugin->
SetUnit( it->first );
291 if( useDxfLayerMapping && dxfPlugin )
295 if( !sourceLayers.empty() )
307 wxString warnings =
m_importer->GetMessages();
310 if( !warnings.empty() )
313 dlg.
MessageSet(
_(
"Items in the imported file could not be handled properly." ) );
314 warnings.Replace( wxT(
"\n" ), wxT(
"<br/>" ) );
323 wxMessageBox(
_(
"There is no plugin to handle this file type." ) );
constexpr EDA_IU_SCALE pcbIUScale
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
const LSET & GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
wxTextCtrl * m_lineWidthCtrl
wxStaticText * m_dxfUnitsLabel
wxStaticText * m_lineWidthLabel
wxChoice * m_dxfUnitsChoice
wxStaticText * m_toleranceUnits
wxCheckBox * m_placeAtCheckbox
DIALOG_IMPORT_GRAPHICS_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("Import Vector Graphics File"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
wxCheckBox * m_rbFixDiscontinuities
wxStaticText * m_lineWidthUnits
PCB_LAYER_BOX_SELECTOR * m_SelLayerBox
wxStaticText * m_toleranceLabel
wxRadioButton * m_radioBtnSingleLayer
wxTextCtrl * m_toleranceCtrl
wxTextCtrl * m_importScaleCtrl
wxTextCtrl * m_textCtrlFileName
STD_BITMAP_BUTTON * m_browseButton
wxRadioButton * m_radioBtnMapLayers
std::unique_ptr< GRAPHICS_IMPORT_MGR > m_gfxImportMgr
void onFilename(wxCommandEvent &event)
~DIALOG_IMPORT_GRAPHICS()
std::unique_ptr< GRAPHICS_IMPORTER_PCBNEW > m_importer
PCB_BASE_FRAME * m_parent
bool TransferDataFromWindow() override
bool TransferDataToWindow() override
UNIT_BINDER m_defaultLineWidth
wxString m_filenameOverride
void onBrowseFiles(wxCommandEvent &event) override
void SetFilenameOverride(const wxString &aFilenameOverride)
Set the filename override to be applied in TransferDataToWindow.
void onUpdateUI(wxUpdateUIEvent &event) override
DIALOG_IMPORT_GRAPHICS(PCB_BASE_FRAME *aParent)
static std::map< wxString, PCB_LAYER_ID > RunModal(wxWindow *aParent, const std::vector< INPUT_LAYER_DESC > &aLayerDesc)
Create and show a dialog (modal) and returns the data from it after completion.
void SetInitialFocus(wxWindow *aWindow)
Sets the window (usually a wxTextCtrl) that should be focused when the dialog is shown.
void SetupStandardButtons(std::map< int, wxString > aLabels={})
std::vector< wxString > GetSourceLayers() const
void SetUnit(DXF_IMPORT_UNITS aUnit)
Set the default units when importing DXFs.
GFX_FILE_T
List of handled file types.
void MessageSet(const wxString &message)
Add a message (in bold) to message list.
void AddHTML_Text(const wxString &message)
Add HTML text (without any change) to message list.
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
LSET is a set of PCB_LAYER_IDs.
LSEQ UIOrder() const
Return the copper, technical and user layers in the order shown in layer widget.
static const LSET & AllLayersMask()
static wxString Name(PCB_LAYER_ID aLayerId)
Return the fixed name association with aLayerId.
DISPLAY_OPTIONS m_Display
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
virtual BOARD_ITEM_CONTAINER * GetModel() const =0
const std::map< DXF_IMPORT_UNITS, wxString > dxfUnitsMap
static LSET getPermittedImportLayers(PCB_BASE_FRAME *aFrame)
static PCB_LAYER_ID getAutoMappedLayer(const wxString &aSourceLayer, const LSET &aPermittedLayers)
static std::vector< INPUT_LAYER_DESC > buildDxfLayerDescriptions(const std::vector< wxString > &aSourceLayers, const LSET &aPermittedLayers)
wxString LayerName(int aLayer)
Returns the default display name for a given layer.
PCB_LAYER_ID
A quick note on layer IDs:
KICOMMON_API double DoubleValueFromString(const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnits, const wxString &aTextValue, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
Convert aTextValue to a double.
std::vector< FAB_LAYER_COLOR > dummy
bool m_DisplayInvertYAxis
bool m_DisplayInvertXAxis
VECTOR2< double > VECTOR2D
wxString AddFileExtListToFilter(const std::vector< std::string > &aExts)
Build the wildcard extension file dialog wildcard filter to add to the base message dialog.
Definition of file extensions used in Kicad.