40#include <wx/filedlg.h>
73 m_importer = std::make_unique<GRAPHICS_IMPORTER_LIB_SYMBOL>( symFrame->GetCurSymbol(), symFrame->GetUnit() );
75 m_importer = std::make_unique<GRAPHICS_IMPORTER_SCH>();
85 GetSizer()->Fit(
this );
86 GetSizer()->SetSizeHints(
this );
109 DIALOG_SHIM::TransferDataToWindow();
121 bool enableDXFControls =
true;
124 if( std::unique_ptr<GRAPHICS_IMPORT_PLUGIN> plugin =
m_gfxImportMgr->GetPluginByExt( ext ) )
139 if( !filename.IsEmpty() )
141 wxFileName fn( filename );
143 filename = fn.GetFullName();
147 wxString wildcardsDesc;
148 wxString allWildcards;
152 std::unique_ptr<GRAPHICS_IMPORT_PLUGIN> plugin =
m_gfxImportMgr->GetPlugin( pluginType );
153 const std::vector<std::string> extensions = plugin->GetFileExtensions();
156 allWildcards += plugin->GetWildcards() + wxT(
";" );
159 wildcardsDesc =
_(
"All supported formats" ) + wxT(
"|" ) + allWildcards + wildcardsDesc;
161 wxFileDialog dlg(
m_parent,
_(
"Import Graphics" ),
path, filename, wildcardsDesc,
162 wxFD_OPEN | wxFD_FILE_MUST_EXIST );
166 if( dlg.ShowModal() == wxID_OK && !dlg.GetPath().IsEmpty() )
173 if( !wxDialog::TransferDataFromWindow() )
178 wxMessageBox(
_(
"No file selected!" ) );
184 double xscale =
scale;
185 double yscale =
scale;
189 if( std::unique_ptr<GRAPHICS_IMPORT_PLUGIN> plugin =
m_gfxImportMgr->GetPluginByExt( ext ) )
199 dxfPlugin->SetUnit( it->first );
217 wxString warnings =
m_importer->GetMessages();
220 if( !warnings.empty() )
223 dlg.
MessageSet(
_(
"Items in the imported file could not be handled properly." ) );
224 warnings.Replace( wxT(
"\n" ), wxT(
"<br/>" ) );
233 wxMessageBox(
_(
"There is no plugin to handle this file type." ) );
constexpr EDA_IU_SCALE schIUScale
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
wxTextCtrl * m_lineWidthCtrl
STD_BITMAP_BUTTON * m_browseButton
DIALOG_IMPORT_GFX_SCH_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)
wxStaticText * m_lineWidthUnits
wxRadioButton * m_rbInteractivePlacement
wxRadioButton * m_rbAbsolutePlacement
wxChoice * m_choiceDxfUnits
wxStaticText * m_staticTextLineWidth1
wxTextCtrl * m_textCtrlFileName
wxTextCtrl * m_importScaleCtrl
wxStaticText * m_lineWidthLabel
void onBrowseFiles(wxCommandEvent &event) override
std::unique_ptr< GRAPHICS_IMPORTER > m_importer
SCH_BASE_FRAME * m_parent
bool TransferDataToWindow() override
wxString m_filenameOverride
void onFilename(wxCommandEvent &event)
DIALOG_IMPORT_GFX_SCH(SCH_BASE_FRAME *aParent)
void originOptionOnUpdateUI(wxUpdateUIEvent &event) override
void SetFilenameOverride(const wxString &aFilenameOverride)
Set the filename override to be applied in TransferDataToWindow.
bool TransferDataFromWindow() override
static double m_importScale
static bool m_placementInteractive
UNIT_BINDER m_defaultLineWidth
std::unique_ptr< GRAPHICS_IMPORT_MGR > m_gfxImportMgr
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.
A shim class between EDA_DRAW_FRAME and several derived classes: SYMBOL_EDIT_FRAME,...
Schematic editor (Eeschema) main window.
The symbol library editor main window.
const std::map< DXF_IMPORT_UNITS, wxString > dxfUnitsMap
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
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.