38#include <wx/filedlg.h>
56 m_xOrigin( aParent, nullptr, m_xCtrl, nullptr ),
57 m_yOrigin( aParent, m_yLabel, m_yCtrl, m_yUnits ),
58 m_defaultLineWidth( aParent, m_lineWidthLabel, m_lineWidthCtrl, m_lineWidthUnits ),
59 m_tolerance( aParent, m_toleranceLabel, m_toleranceCtrl, m_toleranceUnits )
74 for(
const std::pair<const DXF_IMPORT_UNITS, wxString>& unitEntry :
dxfUnitsMap )
85 GetSizer()->Fit(
this );
86 GetSizer()->SetSizeHints(
this );
105 bool enableDXFControls =
true;
108 if( std::unique_ptr<GRAPHICS_IMPORT_PLUGIN> plugin =
m_gfxImportMgr->GetPluginByExt( ext ) )
123 if( !filename.IsEmpty() )
125 wxFileName fn( filename );
127 filename = fn.GetFullName();
131 wxString wildcardsDesc;
132 wxString allWildcards;
136 std::unique_ptr<GRAPHICS_IMPORT_PLUGIN> plugin =
m_gfxImportMgr->GetPlugin( pluginType );
137 const std::vector<std::string> extensions = plugin->GetFileExtensions();
140 allWildcards += plugin->GetWildcards() + wxT(
";" );
143 wildcardsDesc =
_(
"All supported formats" ) + wxT(
"|" ) + allWildcards + wildcardsDesc;
145 wxFileDialog dlg(
m_parent,
_(
"Import Graphics" ),
path, filename, wildcardsDesc,
146 wxFD_OPEN | wxFD_FILE_MUST_EXIST );
148 if( dlg.ShowModal() == wxID_OK && !dlg.GetPath().IsEmpty() )
155 if( !wxDialog::TransferDataFromWindow() )
160 wxMessageBox(
_(
"Please select a file to import." ) );
166 wxMessageBox(
_(
"Please select a valid layer." ) );
173 double xscale =
scale;
174 double yscale =
scale;
184 if( std::unique_ptr<GRAPHICS_IMPORT_PLUGIN> plugin =
m_gfxImportMgr->GetPluginByExt( ext ) )
192 dxfPlugin->SetUnit( DXF_IMPORT_UNITS::DEFAULT );
194 dxfPlugin->SetUnit( it->first );
218 wxString warnings =
m_importer->GetMessages();
221 if( !warnings.empty() )
224 dlg.
MessageSet(
_(
"Items in the imported file could not be handled properly." ) );
225 warnings.Replace( wxT(
"\n" ), wxT(
"<br/>" ) );
234 wxMessageBox(
_(
"There is no plugin to handle this file type." ) );
constexpr EDA_IU_SCALE pcbIUScale
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
Class DIALOG_IMPORT_GRAPHICS_BASE.
wxStaticText * m_dxfUnitsLabel
wxChoice * m_dxfUnitsChoice
wxCheckBox * m_placeAtCheckbox
wxCheckBox * m_rbFixDiscontinuities
wxCheckBox * m_setLayerCheckbox
PCB_LAYER_BOX_SELECTOR * m_SelLayerBox
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
UNIT_BINDER m_defaultLineWidth
void onBrowseFiles(wxCommandEvent &event) override
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.
int GetLayerSelection() const
bool SetLayersHotkeys(bool value)
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.
PCBNEW_SETTINGS * GetPcbNewSettings() const
virtual PCB_LAYER_ID GetActiveLayer() const
virtual BOARD_ITEM_CONTAINER * GetModel() const =0
void SetBoardFrame(PCB_BASE_FRAME *aFrame)
void Enable(bool aEnable)
Enable/disable the label, widget and units label.
virtual double GetDoubleValue()
Return the current value in Internal Units.
const std::map< DXF_IMPORT_UNITS, wxString > dxfUnitsMap
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
constexpr double IUTomm(int iu) const
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.