38#include <wx/filedlg.h>
64 m_xOrigin( aParent, nullptr, m_xCtrl, nullptr ),
65 m_yOrigin( aParent, m_yLabel, m_yCtrl, m_yUnits ),
66 m_defaultLineWidth( aParent, m_lineWidthLabel, m_lineWidthCtrl, m_lineWidthUnits ),
67 m_tolerance( aParent, m_toleranceLabel, m_toleranceCtrl, m_toleranceUnits )
108 for(
const std::pair<const DXF_IMPORT_UNITS, wxString>& unitEntry :
dxfUnitsMap )
115 wxCommandEvent
dummy;
121 GetSizer()->Fit(
this );
122 GetSizer()->SetSizeHints(
this );
145 catch(
const std::runtime_error& e )
147 wxFAIL_MSG( e.what() );
175 bool enableDXFControls =
true;
178 if( std::unique_ptr<GRAPHICS_IMPORT_PLUGIN> plugin =
m_gfxImportMgr->GetPluginByExt( ext ) )
193 if( !filename.IsEmpty() )
195 wxFileName fn( filename );
197 filename = fn.GetFullName();
201 wxString wildcardsDesc;
202 wxString allWildcards;
206 std::unique_ptr<GRAPHICS_IMPORT_PLUGIN> plugin =
m_gfxImportMgr->GetPlugin( pluginType );
207 const std::vector<std::string> extensions = plugin->GetFileExtensions();
210 allWildcards += plugin->GetWildcards() + wxT(
";" );
213 wildcardsDesc =
_(
"All supported formats" ) + wxT(
"|" ) + allWildcards + wildcardsDesc;
215 wxFileDialog dlg(
m_parent,
_(
"Import Graphics" ),
path, filename, wildcardsDesc,
216 wxFD_OPEN | wxFD_FILE_MUST_EXIST );
218 if( dlg.ShowModal() == wxID_OK && !dlg.GetPath().IsEmpty() )
225 if( !wxDialog::TransferDataFromWindow() )
230 wxMessageBox(
_(
"Please select a file to import." ) );
236 wxMessageBox(
_(
"Please select a valid layer." ) );
243 double xscale =
scale;
244 double yscale =
scale;
254 if( std::unique_ptr<GRAPHICS_IMPORT_PLUGIN> plugin =
m_gfxImportMgr->GetPluginByExt( ext ) )
262 dxfPlugin->SetUnit( DXF_IMPORT_UNITS::DEFAULT );
264 dxfPlugin->SetUnit( it->first );
288 wxString warnings =
m_importer->GetMessages();
291 if( !warnings.empty() )
294 dlg.
MessageSet(
_(
"Items in the imported file could not be handled properly." ) );
295 warnings.Replace( wxT(
"\n" ), wxT(
"<br/>" ) );
304 wxMessageBox(
_(
"There is no plugin to handle this file type." ) );
constexpr EDA_IU_SCALE pcbIUScale
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap)
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
wxCheckBox * m_cbGroupItems
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
static bool s_useDlgLayerSelection
static bool s_fixDiscontinuities
bool TransferDataFromWindow() override
static bool s_placementInteractive
UNIT_BINDER m_defaultLineWidth
void onBrowseFiles(wxCommandEvent &event) override
static double s_importScale
static int s_toleranceValue
void onUpdateUI(wxUpdateUIEvent &event) override
static bool s_shouldGroupItems
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
int SetLayerSelection(int layer)
bool SetLayersHotkeys(bool value)
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
DISPLAY_OPTIONS m_Display
DIALOG_IMPORT_GRAPHICS m_ImportGraphics
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.
virtual void SetValue(long long int aValue)
Set new value (in Internal Units) for the text field, taking care of units conversion.
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)
Function DoubleValueFromString converts aTextValue to a double.
std::vector< FAB_LAYER_COLOR > dummy
constexpr double IUTomm(int iu) const
constexpr int mmToIU(double mm) const
bool use_dlg_layer_selection
bool interactive_placement
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.