38#include <wx/filedlg.h>
74 for(
const std::pair<const DXF_IMPORT_UNITS, wxString>& unitEntry :
dxfUnitsMap )
85 GetSizer()->Fit(
this );
86 GetSizer()->SetSizeHints(
this );
111 DIALOG_SHIM::TransferDataToWindow();
123 bool enableDXFControls =
true;
126 if( std::unique_ptr<GRAPHICS_IMPORT_PLUGIN> plugin =
m_gfxImportMgr->GetPluginByExt( ext ) )
141 if( !filename.IsEmpty() )
143 wxFileName fn( filename );
145 filename = fn.GetFullName();
149 wxString wildcardsDesc;
150 wxString allWildcards;
154 std::unique_ptr<GRAPHICS_IMPORT_PLUGIN> plugin =
m_gfxImportMgr->GetPlugin( pluginType );
155 const std::vector<std::string> extensions = plugin->GetFileExtensions();
158 allWildcards += plugin->GetWildcards() + wxT(
";" );
161 wildcardsDesc =
_(
"All supported formats" ) + wxT(
"|" ) + allWildcards + wildcardsDesc;
163 wxFileDialog dlg(
m_parent,
_(
"Import Graphics" ),
path, filename, wildcardsDesc,
164 wxFD_OPEN | wxFD_FILE_MUST_EXIST );
166 if( dlg.ShowModal() == wxID_OK && !dlg.GetPath().IsEmpty() )
173 if( !wxDialog::TransferDataFromWindow() )
178 wxMessageBox(
_(
"Please select a file to import." ) );
184 wxMessageBox(
_(
"Please select a valid layer." ) );
191 double xscale =
scale;
192 double yscale =
scale;
202 if( std::unique_ptr<GRAPHICS_IMPORT_PLUGIN> plugin =
m_gfxImportMgr->GetPluginByExt( ext ) )
212 dxfPlugin->SetUnit( it->first );
236 wxString warnings =
m_importer->GetMessages();
239 if( !warnings.empty() )
242 dlg.
MessageSet(
_(
"Items in the imported file could not be handled properly." ) );
243 warnings.Replace( wxT(
"\n" ), wxT(
"<br/>" ) );
252 wxMessageBox(
_(
"There is no plugin to handle this file type." ) );
constexpr EDA_IU_SCALE pcbIUScale
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
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
wxCheckBox * m_setLayerCheckbox
wxStaticText * m_lineWidthUnits
PCB_LAYER_BOX_SELECTOR * m_SelLayerBox
wxStaticText * m_toleranceLabel
wxTextCtrl * m_toleranceCtrl
wxTextCtrl * m_importScaleCtrl
wxTextCtrl * m_textCtrlFileName
STD_BITMAP_BUTTON * m_browseButton
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)
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={})
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.
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
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.