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{
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{
90
91 // Build default output file name
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 {
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
int ExportIDF(const TOOL_EVENT &aEvent)
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:317
const BOX2I GetBoardEdgesBoundingBox() const
Return the board bounding box calculated using exclusively the board edges (graphics on Edge....
Definition: board.h:1002
const wxString & GetFileName() const
Definition: board.h:354
constexpr Vec Centre() const
Definition: box2.h:97
Class DIALOG_EXPORT_IDF3_BASE.
wxFilePickerCtrl * m_filePickerIDF
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:50
void DoNotShowCheckbox(wxString file, int line)
Shows the 'do not show again' checkbox.
Definition: kidialog.cpp:51
int ShowModal() override
Definition: kidialog.cpp:95
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.
bool Export_IDF3(BOARD *aPcb, const wxString &aFullFileName, bool aUseThou, double aXRef, double aYRef, bool aIncludeUnspecified, bool aIncludeDNP)
Create an IDF3 compliant BOARD (*.emn) and LIBRARY (*.emp) file.
Definition: export_idf.cpp:612
BOARD * board() const
Generic, UI-independent tool event.
Definition: tool_event.h:168
void Enable(bool aEnable)
Enable/disable the label, widget and units label.
#define _(s)
This file is part of the common library.
@ LAST_PATH_IDF
Definition: project_file.h:53
std::vector< FAB_LAYER_COLOR > dummy
const double MM_PER_IU
Definition: base_units.h:80