KiCad PCB EDA Suite
Loading...
Searching...
No Matches
bitmap2component.h
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) 1992-2023 Kicad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
24#ifndef BITMAP2COMPONENT_H
25#define BITMAP2COMPONENT_H
26
28#include <potracelib.h>
29
30// for consistency this enum should conform to the
31// indices in m_radioBoxFormat from bitmap2cmp_gui.cpp
33{
39};
40
41// for consistency this enum should conform to the
42// indices in m_cbPcbLayer from bitmap2cmp_gui.cpp
44{
53};
54
55
56/* Helper class to handle useful info to convert a bitmap image to
57 * a polygonal object description
58 */
60{
61private:
62 enum OUTPUT_FMT_ID m_Format; // File format
64 int m_PixmapHeight; // the bitmap size in pixels
65 double m_ScaleX;
66 double m_ScaleY; // the conversion scale
67 potrace_path_t* m_Paths; // the list of paths, from potrace (list of lines and bezier curves)
68 std::string m_CmpName; // The string used as cmp/footprint name
69 std::string& m_Data; // the buffer containing the conversion
70 std::string m_errors; // a buffer to return error messages
71
72public:
73 BITMAPCONV_INFO( std::string& aData );
74
78 int ConvertBitmap( potrace_bitmap_t* aPotrace_bitmap,
79 OUTPUT_FMT_ID aFormat, int aDpi_X, int aDpi_Y,
80 BMP2CMP_MOD_LAYER aModLayer );
81
82 std::string& GetErrorMessages() {return m_errors; }
83
84private:
89
94 void outputDataHeader( const char * aBrdLayerName );
95
100 void outputDataEnd();
101
102
107 const char * getBoardLayerName( BMP2CMP_MOD_LAYER aChoice );
108
114 void outputOnePolygon( SHAPE_LINE_CHAIN & aPolygon, const char* aBrdLayerName );
115
116};
117
118#endif // BITMAP2COMPONENT_H
BMP2CMP_MOD_LAYER
@ MOD_LYR_ECO1
@ MOD_LYR_FSILKS
@ MOD_LYR_FINAL
@ MOD_LYR_ECO2
@ MOD_LYR_DRAWINGS
@ MOD_LYR_FSOLDERMASK
@ MOD_LYR_COMMENTS
@ MOD_LYR_FAB
OUTPUT_FMT_ID
@ FINAL_FMT
@ KICAD_WKS_LOGO
@ PCBNEW_KICAD_MOD
@ POSTSCRIPT_FMT
@ EESCHEMA_FMT
void outputDataEnd()
Function outputDataEnd write to file the last strings depending on file format.
std::string & m_Data
potrace_path_t * m_Paths
std::string & GetErrorMessages()
std::string m_CmpName
void outputDataHeader(const char *aBrdLayerName)
Function outputDataHeader write to file the header depending on file format.
void outputOnePolygon(SHAPE_LINE_CHAIN &aPolygon, const char *aBrdLayerName)
Function outputOnePolygon write one polygon to output file.
enum OUTPUT_FMT_ID m_Format
void createOutputData(BMP2CMP_MOD_LAYER aModLayer=(BMP2CMP_MOD_LAYER) 0)
Creates the data specified by m_Format.
int ConvertBitmap(potrace_bitmap_t *aPotrace_bitmap, OUTPUT_FMT_ID aFormat, int aDpi_X, int aDpi_Y, BMP2CMP_MOD_LAYER aModLayer)
Run the conversion of the bitmap.
std::string m_errors
const char * getBoardLayerName(BMP2CMP_MOD_LAYER aChoice)
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...