KiCad PCB EDA Suite
Loading...
Searching...
No Matches
gerber_jobfile_writer.h
Go to the documentation of this file.
1
5
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 The 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, see <https://www.gnu.org/licenses/>.
24 */
25
26#ifndef GERBER_JOBFILE_WRITER_H
27#define GERBER_JOBFILE_WRITER_H
28
29#include <json_common.h>
30
31
32// A helper enum to handle sides of some layers (silk, mask)
34{
35 SIDE_NONE = 0, // layers not present
36 SIDE_TOP = 1, // top layer only
37 SIDE_BOTTOM = 2, // bottom layer only
39};
40
41class BOARD;
42
48{
49public:
50 wxArrayString m_GerberFileList; // the list of gerber filenames (without path)
51 std::vector<PCB_LAYER_ID> m_LayerId; // the list of corresponding layer id
52};
53
54
68{
69public:
70 GERBER_JOBFILE_WRITER( BOARD* aPcb, REPORTER* aReporter = nullptr );
71
73 {
74 }
75
81 void AddGbrFile( PCB_LAYER_ID aLayer, wxString& aFilename )
82 {
83 m_params.m_GerberFileList.Add( aFilename );
84 m_params.m_LayerId.push_back( aLayer );
85 }
86
92 bool CreateJobFile( const wxString& aFullFilename );
93
100 bool WriteJSONJobFile( const wxString& aFullFilename );
101
102private:
108 enum ONSIDE hasSilkLayers();
109
115 enum ONSIDE hasSolderMasks();
116
120 const char* sideKeyValue( enum ONSIDE aValue );
121
125 void addJSONHeader();
126
130 void addJSONGeneralSpecs();
131
136
143
147 void addJSONDesignRules();
148
152 std::string formatStringFromUTF32( const wxString& aText );
153
158 double mapValue( double aUiValue );
159
160private:
161 BOARD* m_pcb; // The board
162 REPORTER* m_reporter; // a reporter for messages (can be null)
163 JOBFILE_PARAMS m_params; // the list of various prms and data to write in a job file
164 double m_conversionUnits; // scaling factor to convert brd units to gerber units (mm)
165 nlohmann::ordered_json m_json; // json document built by this class
166};
167
168#endif // #ifndef GERBER_JOBFILE_WRITER_H
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:372
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...
GERBER_JOBFILE_WRITER(BOARD *aPcb, REPORTER *aReporter=nullptr)
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
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:56