KiCad PCB EDA Suite
Loading...
Searching...
No Matches
dialog_export_idf.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) 2013-2015 Cirilo Bernardo
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25#include <pcb_edit_frame.h>
26#include <board.h>
28#include <dialog_export_idf.h>
29#include <pcbnew_settings.h>
31#include <project/project_file.h> // LAST_PATH_TYPE
32#include <kidialog.h>
33
34
36 DIALOG_EXPORT_IDF3_BASE( aEditFrame ),
37 m_xPos( aEditFrame, m_xLabel, m_IDF_Xref, m_xUnits ),
38 m_yPos( aEditFrame, m_yLabel, m_IDF_Yref, m_yUnits )
39{
40 SetFocus();
41
43
45
46 // Now all widgets have the size fixed, call FinishDialogSettings
48}
49
50
52{
53 m_xPos.Enable( m_cbSetBoardReferencePoint->GetValue() );
54 m_yPos.Enable( m_cbSetBoardReferencePoint->GetValue() );
55
56 event.Skip();
57}
58
59
61{
62 wxCommandEvent dummy;
64
65 return true;
66}
67
68
70{
71 wxFileName fn = m_filePickerIDF->GetPath();
72
73 if( fn.FileExists() )
74 {
75 KIDIALOG dlg( this, wxString::Format( _( "File %s already exists." ), fn.GetPath() ),
76 _( "Confirmation" ), wxOK | wxCANCEL | wxICON_WARNING );
77 dlg.SetOKLabel( _( "Overwrite" ) );
78 dlg.DoNotShowCheckbox( __FILE__, __LINE__ );
79
80 return ( dlg.ShowModal() == wxID_OK );
81 }
82
83 return true;
84}
85
86
88{
89 BOARD* board = m_frame->GetBoard();
90
91 // Build default output file name
92 wxString path = m_frame->GetLastPath( LAST_PATH_IDF );
93
94 if( path.IsEmpty() )
95 {
96 wxFileName brdFile = board->GetFileName();
97 brdFile.SetExt( wxT( "emn" ) );
98 path = brdFile.GetFullPath();
99 }
100
102 dlg.FilePicker()->SetPath( path );
103
104 if ( dlg.ShowModal() != wxID_OK )
105 return 0;
106
107 double aXRef;
108 double aYRef;
109
110 if( dlg.GetSetBoardReferencePoint() )
111 {
112 aXRef = dlg.GetXRefMM();
113 aYRef = dlg.GetYRefMM();
114 }
115 else
116 {
117 BOX2I bbox = board->GetBoardEdgesBoundingBox();
118 aXRef = bbox.Centre().x * pcbIUScale.MM_PER_IU;
119 aYRef = bbox.Centre().y * pcbIUScale.MM_PER_IU;
120 }
121
122 wxString fullFilename = dlg.FilePicker()->GetPath();
123 m_frame->SetLastPath( LAST_PATH_IDF, fullFilename );
124
125 wxBusyCursor dummy;
126
127 if( !m_frame->Export_IDF3( board, fullFilename, dlg.GetThouOption(), aXRef, aYRef,
128 !dlg.GetNoUnspecifiedOption(), !dlg.GetNoDNPOption() ) )
129 {
130 wxMessageBox( wxString::Format( _( "Failed to create file '%s'." ), fullFilename ) );
131 }
132
133 return 0;
134}
135
constexpr EDA_IU_SCALE pcbIUScale
Definition base_units.h:112
BOX2< VECTOR2I > BOX2I
Definition box2.h:922
int ExportIDF(const TOOL_EVENT &aEvent)
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:317
constexpr Vec Centre() const
Definition box2.h:97
wxFilePickerCtrl * m_filePickerIDF
DIALOG_EXPORT_IDF3_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("Export IDFv3"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
bool TransferDataToWindow() override
wxFilePickerCtrl * FilePicker()
bool TransferDataFromWindow() override
DIALOG_EXPORT_IDF3(PCB_EDIT_FRAME *aEditFrame)
void OnBoardReferencePointChecked(wxCommandEvent &event)
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...
int ShowModal() override
Helper class to create more flexible dialogs, including 'do not show again' checkbox handling.
Definition kidialog.h:42
void DoNotShowCheckbox(wxString file, int line)
Shows the 'do not show again' checkbox.
Definition kidialog.cpp:55
int ShowModal() override
Definition kidialog.cpp:93
The main frame for Pcbnew.
BOARD * board() const
Generic, UI-independent tool event.
Definition tool_event.h:171
#define _(s)
@ LAST_PATH_IDF
std::vector< FAB_LAYER_COLOR > dummy