44#include <wx/filedlg.h>
75 auto initWidgetsFromSettings = [&](
const auto& aCfg )
89 for(
const std::pair<const DXF_IMPORT_UNITS, wxString>& unitEntry :
dxfUnitsMap )
97 m_importer = std::make_unique<GRAPHICS_IMPORTER_LIB_SYMBOL>( symFrame->GetCurSymbol(),
98 symFrame->GetUnit() );
101 initWidgetsFromSettings( cfg );
105 m_importer = std::make_unique<GRAPHICS_IMPORTER_SCH>();
108 initWidgetsFromSettings( cfg );
113 wxCommandEvent
dummy;
119 GetSizer()->Fit(
this );
120 GetSizer()->SetSizeHints(
this );
131 auto saveToSettings = [&](
const auto& aCfg )
146 saveToSettings( cfg );
151 saveToSettings( cfg );
168 DIALOG_SHIM::TransferDataToWindow();
180 bool enableDXFControls =
true;
183 if( std::unique_ptr<GRAPHICS_IMPORT_PLUGIN> plugin =
m_gfxImportMgr->GetPluginByExt( ext ) )
198 if( !filename.IsEmpty() )
200 wxFileName fn( filename );
202 filename = fn.GetFullName();
206 wxString wildcardsDesc;
207 wxString allWildcards;
211 std::unique_ptr<GRAPHICS_IMPORT_PLUGIN> plugin =
m_gfxImportMgr->GetPlugin( pluginType );
212 const std::vector<std::string> extensions = plugin->GetFileExtensions();
215 allWildcards += plugin->GetWildcards() + wxT(
";" );
218 wildcardsDesc =
_(
"All supported formats" ) + wxT(
"|" ) + allWildcards + wildcardsDesc;
220 wxFileDialog dlg(
m_parent,
_(
"Import Graphics" ),
path, filename, wildcardsDesc,
221 wxFD_OPEN | wxFD_FILE_MUST_EXIST );
223 if( dlg.ShowModal() == wxID_OK && !dlg.GetPath().IsEmpty() )
230 if( !wxDialog::TransferDataFromWindow() )
235 wxMessageBox(
_(
"No file selected!" ) );
241 double xscale =
scale;
242 double yscale =
scale;
246 if( std::unique_ptr<GRAPHICS_IMPORT_PLUGIN> plugin =
m_gfxImportMgr->GetPluginByExt( ext ) )
256 dxfPlugin->SetUnit( it->first );
274 wxString warnings =
m_importer->GetMessages();
277 if( !warnings.empty() )
280 dlg.
MessageSet(
_(
"Items in the imported file could not be handled properly." ) );
281 warnings.Replace( wxT(
"\n" ), wxT(
"<br/>" ) );
290 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,...
SYMBOL_EDITOR_SETTINGS * libeditconfig() const
EESCHEMA_SETTINGS * eeconfig() const
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.