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, see <https://www.gnu.org/licenses/>.
19 */
20
21#include <pcb_edit_frame.h>
22#include <board.h>
24#include <dialog_export_idf.h>
25#include <pcbnew_settings.h>
27#include <project/project_file.h> // LAST_PATH_TYPE
28#include <kidialog.h>
29
30
32 DIALOG_EXPORT_IDF3_BASE( aEditFrame ),
33 m_xPos( aEditFrame, m_xLabel, m_IDF_Xref, m_xUnits ),
34 m_yPos( aEditFrame, m_yLabel, m_IDF_Yref, m_yUnits )
35{
36 SetFocus();
37
39
41
42 // Now all widgets have the size fixed, call FinishDialogSettings
44}
45
46
48{
49 m_xPos.Enable( m_cbSetBoardReferencePoint->GetValue() );
50 m_yPos.Enable( m_cbSetBoardReferencePoint->GetValue() );
51
52 event.Skip();
53}
54
55
57{
58 wxCommandEvent dummy;
60
61 return true;
62}
63
64
66{
67 wxFileName fn = m_filePickerIDF->GetPath();
68
69 if( fn.FileExists() )
70 {
71 KIDIALOG dlg( this, wxString::Format( _( "File %s already exists." ), fn.GetPath() ),
72 _( "Confirmation" ), wxOK | wxCANCEL | wxICON_WARNING );
73 dlg.SetOKLabel( _( "Overwrite" ) );
74 dlg.DoNotShowCheckbox( __FILE__, __LINE__ );
75
76 return ( dlg.ShowModal() == wxID_OK );
77 }
78
79 return true;
80}
81
82
84{
85 BOARD* board = m_frame->GetBoard();
86
87 // Build default output file name
88 wxString path = m_frame->GetLastPath( LAST_PATH_IDF );
89
90 if( path.IsEmpty() )
91 {
92 wxFileName brdFile = board->GetFileName();
93 brdFile.SetExt( wxT( "emn" ) );
94 path = brdFile.GetFullPath();
95 }
96
98 dlg.FilePicker()->SetPath( path );
99
100 if ( dlg.ShowModal() != wxID_OK )
101 return 0;
102
103 double aXRef;
104 double aYRef;
105
106 if( dlg.GetSetBoardReferencePoint() )
107 {
108 aXRef = dlg.GetXRefMM();
109 aYRef = dlg.GetYRefMM();
110 }
111 else
112 {
113 BOX2I bbox = board->GetBoardEdgesBoundingBox();
114 aXRef = bbox.Centre().x * pcbIUScale.MM_PER_IU;
115 aYRef = bbox.Centre().y * pcbIUScale.MM_PER_IU;
116 }
117
118 wxString fullFilename = dlg.FilePicker()->GetPath();
119 m_frame->SetLastPath( LAST_PATH_IDF, fullFilename );
120
121 wxBusyCursor dummy;
122
123 if( !m_frame->Export_IDF3( board, fullFilename, dlg.GetThouOption(), aXRef, aYRef,
124 !dlg.GetNoUnspecifiedOption(), !dlg.GetNoDNPOption() ) )
125 {
126 wxMessageBox( wxString::Format( _( "Failed to create file '%s'." ), fullFilename ) );
127 }
128
129 return 0;
130}
131
constexpr EDA_IU_SCALE pcbIUScale
Definition base_units.h:121
BOX2< VECTOR2I > BOX2I
Definition box2.h:918
int ExportIDF(const TOOL_EVENT &aEvent)
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:372
constexpr Vec Centre() const
Definition box2.h:93
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:38
void DoNotShowCheckbox(wxString file, int line)
Shows the 'do not show again' checkbox.
Definition kidialog.cpp:51
int ShowModal() override
Definition kidialog.cpp:89
The main frame for Pcbnew.
BOARD * board() const
Generic, UI-independent tool event.
Definition tool_event.h:167
#define _(s)
@ LAST_PATH_IDF
std::vector< FAB_LAYER_COLOR > dummy
std::string path