KiCad PCB EDA Suite
Loading...
Searching...
No Matches
gerber_jobfile_writer.h
Go to the documentation of this file.
1
6/*
7 * This program source code file is part of KiCad, a free EDA CAD application.
8 *
9 * Copyright (C) 1992-2018 Jean_Pierre Charras <jp.charras at wanadoo.fr>
10 * Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, you may find one here:
24 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
25 * or you may search the http://www.gnu.org website for the version 2 license,
26 * or you may write to the Free Software Foundation, Inc.,
27 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
28 */
29
30#ifndef GERBER_JOBFILE_WRITER_H
31#define GERBER_JOBFILE_WRITER_H
32
33#include <nlohmann/json.hpp>
34
35
36// A helper enum to handle sides of some layers (silk, mask)
38{
39 SIDE_NONE = 0, // layers not present
40 SIDE_TOP = 1, // top layer only
41 SIDE_BOTTOM = 2, // bottom layer only
42 SIDE_BOTH = SIDE_TOP|SIDE_BOTTOM // both layers
43};
44
45class BOARD;
46
52{
53public:
54 wxArrayString m_GerberFileList; // the list of gerber filenames (without path)
55 std::vector<PCB_LAYER_ID> m_LayerId; // the list of corresponding layer id
56};
57
58
72{
73public:
74 GERBER_JOBFILE_WRITER( BOARD* aPcb, REPORTER* aReporter = nullptr );
75
77 {
78 }
79
85 void AddGbrFile( PCB_LAYER_ID aLayer, wxString& aFilename )
86 {
87 m_params.m_GerberFileList.Add( aFilename );
88 m_params.m_LayerId.push_back( aLayer );
89 }
90
96 bool CreateJobFile( const wxString& aFullFilename );
97
104 bool WriteJSONJobFile( const wxString& aFullFilename );
105
106private:
112 enum ONSIDE hasSilkLayers();
113
119 enum ONSIDE hasSolderMasks();
120
124 const char* sideKeyValue( enum ONSIDE aValue );
125
129 void addJSONHeader();
130
134 void addJSONGeneralSpecs();
135
140
147
151 void addJSONDesignRules();
152
156 std::string formatStringFromUTF32( const wxString& aText );
157
162 double mapValue( double aUiValue );
163
164private:
165 BOARD* m_pcb; // The board
166 REPORTER* m_reporter; // a reporter for messages (can be null)
167 JOBFILE_PARAMS m_params; // the list of various prms and data to write in a job file
168 double m_conversionUnits; // scaling factor to convert brd units to gerber units (mm)
169 nlohmann::ordered_json m_json; // json document built by this class
170};
171
172#endif // #ifndef GERBER_JOBFILE_WRITER_H
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:281
GERBER_JOBFILE_WRITER is a class used to create Gerber job file a Gerber job file stores info to make...
void addJSONHeader()
Add the job file header in JSON format to m_JSONbuffer.
void addJSONMaterialStackup()
Add the Material Stackup section in JSON format to m_JSONbuffer This is the ordered list of stackup l...
void addJSONFilesAttributes()
Add the Files Attributes section in JSON format to m_JSONbuffer.
nlohmann::ordered_json m_json
bool CreateJobFile(const wxString &aFullFilename)
Creates a Gerber job file.
void addJSONGeneralSpecs()
Add the General Specs in JSON format to m_JSONbuffer.
bool WriteJSONJobFile(const wxString &aFullFilename)
Creates an Gerber job file in JSON format.
double mapValue(double aUiValue)
A helper function to convert a double in Pcbnew internal units to a JSON double value (in mm),...
const char * sideKeyValue(enum ONSIDE aValue)
void addJSONDesignRules()
Add the Design Rules section in JSON format to m_JSONbuffer.
std::string formatStringFromUTF32(const wxString &aText)
A helper function to convert a wxString ( therefore a Unicode text ) to a JSON compatible string (a e...
void AddGbrFile(PCB_LAYER_ID aLayer, wxString &aFilename)
add a gerber file name and type in job file list
JOBFILE_PARAMS store the list of parameters written in Gerber job file especially list of ....
wxArrayString m_GerberFileList
std::vector< PCB_LAYER_ID > m_LayerId
A pure virtual class used to derive REPORTER objects from.
Definition: reporter.h:71
@ SIDE_BOTTOM
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:60