KiCad PCB EDA Suite
Loading...
Searching...
No Matches
dialog_export_odbpp.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2023 KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
21
22#include <board.h>
23#include <footprint.h>
24#include <kiway_holder.h>
25#include <pcb_edit_frame.h>
26#include <pcbnew_settings.h>
27#include <pgm_base.h>
28#include <project.h>
33
34#include <set>
35#include <vector>
36#include <wx/dirdlg.h>
37
38static wxString s_oemColumn = wxEmptyString;
39
41 DIALOG_EXPORT_ODBPP_BASE( aParent ), m_parent( aParent )
42{
43 m_browseButton->SetBitmap( KiBitmapBundle( BITMAPS::small_folder ) );
44
45 SetupStandardButtons( { { wxID_OK, _( "Export" ) }, { wxID_CANCEL, _( "Close" ) } } );
46
48
49 if( path.IsEmpty() )
50 {
51 wxFileName brdFile( m_parent->GetBoard()->GetFileName() );
52 path = brdFile.GetPath();
53 }
54
55 m_outputFileName->SetValue( path );
56
57 // Fill wxChoice (and others) items with data before calling finishDialogSettings()
58 // to calculate suitable widgets sizes
59 Init();
60
61 // Now all widgets have the size fixed, call FinishDialogSettings
63}
64
65
66void DIALOG_EXPORT_ODBPP::onBrowseClicked( wxCommandEvent& event )
67{
68 // Build the absolute path of current output directory to preselect it in the file browser.
69 wxString path = ExpandEnvVarSubstitutions( m_outputFileName->GetValue(), &Prj() );
70 wxFileName fn( Prj().AbsolutePath( path ) );
71
72 wxDirDialog dlg( this, _( "Export ODB++ File" ), fn.GetPath() );
73
74 if( dlg.ShowModal() == wxID_CANCEL )
75 return;
76
77 m_outputFileName->SetValue( dlg.GetPath() );
78}
79
80
81void DIALOG_EXPORT_ODBPP::onOKClick( wxCommandEvent& event )
82{
84
85 event.Skip();
86}
87
88
90{
92
93 m_choiceUnits->SetSelection( cfg->m_ExportODBPP.units );
94 m_precision->SetValue( cfg->m_ExportODBPP.precision );
95 m_cbCompress->SetValue( cfg->m_ExportODBPP.compress );
96
97 return true;
98}
99
100
102{
104
105 cfg->m_ExportODBPP.units = m_choiceUnits->GetSelection();
106 cfg->m_ExportODBPP.precision = m_precision->GetValue();
107 cfg->m_ExportODBPP.compress = m_cbCompress->GetValue();
108
109 return true;
110}
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap)
Definition: bitmap.cpp:110
const wxString & GetFileName() const
Definition: board.h:327
Class DIALOG_EXPORT_ODBPP_BASE.
STD_BITMAP_BUTTON * m_browseButton
bool TransferDataFromWindow() override
void onBrowseClicked(wxCommandEvent &event) override
DIALOG_EXPORT_ODBPP(PCB_EDIT_FRAME *aParent)
PCB_EDIT_FRAME * m_parent
void onOKClick(wxCommandEvent &event) override
void SetupStandardButtons(std::map< int, wxString > aLabels={})
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
DIALOG_EXPORT_ODBPP m_ExportODBPP
BOARD * GetBoard() const
The main frame for Pcbnew.
void SetLastPath(LAST_PATH_TYPE aType, const wxString &aLastPath)
Set the path of the last file successfully read.
wxString GetLastPath(LAST_PATH_TYPE aType)
Get the last path for a particular type.
virtual SETTINGS_MANAGER & GetSettingsManager() const
Definition: pgm_base.h:142
T * GetAppSettings()
Returns a handle to the a given settings by type If the settings have already been loaded,...
void SetBitmap(const wxBitmapBundle &aBmp)
const wxString ExpandEnvVarSubstitutions(const wxString &aString, const PROJECT *aProject)
Replace any environment variable & text variable references with their values.
Definition: common.cpp:343
static wxString s_oemColumn
#define _(s)
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: pgm_base.cpp:1060
see class PGM_BASE
@ LAST_PATH_ODBPP
Definition: project_file.h:60