44#include <wx/filedlg.h>
69 m_xOrigin( aParent, m_xLabel, m_xCtrl, m_xUnits ),
70 m_yOrigin( aParent, m_yLabel, m_yCtrl, m_yUnits ),
71 m_defaultLineWidth( aParent, m_lineWidthLabel, m_lineWidthCtrl, m_lineWidthUnits )
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 );
162 bool enableDXFControls =
true;
165 if( std::unique_ptr<GRAPHICS_IMPORT_PLUGIN> plugin =
m_gfxImportMgr->GetPluginByExt( ext ) )
180 if( !filename.IsEmpty() )
182 wxFileName fn( filename );
184 filename = fn.GetFullName();
188 wxString wildcardsDesc;
189 wxString allWildcards;
193 std::unique_ptr<GRAPHICS_IMPORT_PLUGIN> plugin =
m_gfxImportMgr->GetPlugin( pluginType );
194 const std::vector<std::string> extensions = plugin->GetFileExtensions();
197 allWildcards += plugin->GetWildcards() + wxT(
";" );
200 wildcardsDesc =
_(
"All supported formats" ) + wxT(
"|" ) + allWildcards + wildcardsDesc;
202 wxFileDialog dlg(
m_parent,
_(
"Import Graphics" ),
path, filename, wildcardsDesc,
203 wxFD_OPEN | wxFD_FILE_MUST_EXIST );
205 if( dlg.ShowModal() == wxID_OK && !dlg.GetPath().IsEmpty() )
212 if( !wxDialog::TransferDataFromWindow() )
217 wxMessageBox(
_(
"No file selected!" ) );
223 double xscale =
scale;
224 double yscale =
scale;
231 if( std::unique_ptr<GRAPHICS_IMPORT_PLUGIN> plugin =
m_gfxImportMgr->GetPluginByExt( ext ) )
239 dxfPlugin->SetUnit( DXF_IMPORT_UNITS::DEFAULT );
241 dxfPlugin->SetUnit( it->first );
259 wxString warnings =
m_importer->GetMessages();
262 if( !warnings.empty() )
265 dlg.
MessageSet(
_(
"Items in the imported file could not be handled properly." ) );
266 warnings.Replace( wxT(
"\n" ), wxT(
"<br/>" ) );
275 wxMessageBox(
_(
"There is no plugin to handle this file type." ) );
constexpr EDA_IU_SCALE schIUScale
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap)
Class DIALOG_IMPORT_GFX_SCH_BASE.
STD_BITMAP_BUTTON * m_browseButton
wxRadioButton * m_rbInteractivePlacement
wxRadioButton * m_rbAbsolutePlacement
wxChoice * m_choiceDxfUnits
wxStaticText * m_staticTextLineWidth1
wxTextCtrl * m_textCtrlFileName
wxTextCtrl * m_importScaleCtrl
void onBrowseFiles(wxCommandEvent &event) override
std::unique_ptr< GRAPHICS_IMPORTER > m_importer
SCH_BASE_FRAME * m_parent
void onFilename(wxCommandEvent &event)
DIALOG_IMPORT_GFX_SCH(SCH_BASE_FRAME *aParent)
void originOptionOnUpdateUI(wxUpdateUIEvent &event) override
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.
virtual long long int GetValue()
Return the current value in Internal Units.
void Enable(bool aEnable)
Enable/disable the label, widget and units label.
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
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
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.