KiCad PCB EDA Suite
Loading...
Searching...
No Matches
export_gencad.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) 2016 Jean-Pierre Charras, [email protected]
5 * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <[email protected]>
6 * Copyright (C) 2012 Wayne Stambaugh <[email protected]>
7 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, you may find one here:
21 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
22 * or you may search the http://www.gnu.org website for the version 2 license,
23 * or you may write to the Free Software Foundation, Inc.,
24 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
25 */
26
31#include <board.h>
33#include <confirm.h>
35#include <pcb_edit_frame.h>
37#include <project/project_file.h> // LAST_PATH_TYPE
38
40
41
42/* Driver function: processing starts here */
44{
45 DIALOG_GENCAD_EXPORT_OPTIONS optionsDialog( m_frame, _( "Export to GenCAD" ), nullptr );
46
47 if( optionsDialog.ShowModal() == wxID_CANCEL )
48 return 0;
49
50 wxString path = optionsDialog.GetFileName();
51
52 // Get options
53 bool flipBottomPads = optionsDialog.GetOption( FLIP_BOTTOM_PADS );
54 bool uniquePinName = optionsDialog.GetOption( UNIQUE_PIN_NAMES );
55 bool individualShapes = optionsDialog.GetOption( INDIVIDUAL_SHAPES );
56 bool storeOriginCoords = optionsDialog.GetOption( STORE_ORIGIN_COORDS );
57
58 // No idea on *why* this should be needed... maybe to fix net names?
60
61 GENCAD_EXPORTER exporter( m_frame->GetBoard() );
62
63 // This is the export origin (the auxiliary axis)
64 VECTOR2I GencadOffset;
66 GencadOffset.x = optionsDialog.GetOption( USE_AUX_ORIGIN ) ? auxOrigin.x : 0;
67 GencadOffset.y = optionsDialog.GetOption( USE_AUX_ORIGIN ) ? auxOrigin.y : 0;
68
69 exporter.SetPlotOffet( GencadOffset );
70 exporter.FlipBottomPads( flipBottomPads );
71 exporter.UsePinNamesUnique( uniquePinName );
72 exporter.UseIndividualShapes( individualShapes );
73 exporter.StoreOriginCoordsInFile( storeOriginCoords );
74
75 bool success = exporter.WriteFile( path );
76
77 if( !success )
78 DisplayError( m_frame, wxString::Format( _( "Failed to create file '%s'." ), path ) );
79
80 return 0;
81}
82
const VECTOR2I & GetAuxOrigin() const
int ExportGenCAD(const TOOL_EVENT &aEvent)
Export GenCAD 1.4 format.
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:1024
bool GetOption(GENCAD_EXPORT_OPT aOption) const
Return the selected file path.
int ShowModal() override
Export board to GenCAD file format.
void UseIndividualShapes(bool aUnique)
Make pad shapes unique.
void UsePinNamesUnique(bool aUnique)
Make pin names unique.
void StoreOriginCoordsInFile(bool aStore)
Store origin coordinate in GenCAD file.
void FlipBottomPads(bool aFlip)
Flip pad shapes on the bottom side.
void SetPlotOffet(VECTOR2I aOffset)
Set the coordinates offset when exporting items.
bool WriteFile(const wxString &aFullFileName)
Export a GenCAD file.
BOARD * GetBoard() const
void Compile_Ratsnest(bool aDisplayStatus)
Create the entire board ratsnest.
Definition: ratsnest.cpp:35
Generic, UI-independent tool event.
Definition: tool_event.h:168
void DisplayError(wxWindow *aParent, const wxString &aText)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:169
This file is part of the common library.
#define _(s)