KiCad PCB EDA Suite
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-2014 Kicad Developers, see change_log.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 
42 {
48 };
49 
50 
51 /* Helper class to handle useful info to convert a bitmap image to
52  * a polygonal object description
53  */
55 {
56 private:
57  enum OUTPUT_FMT_ID m_Format; // File format
59  int m_PixmapHeight; // the bitmap size in pixels
60  double m_ScaleX;
61  double m_ScaleY; // the conversion scale
62  potrace_path_t* m_Paths; // the list of paths, from potrace (list of lines and bezier curves)
63  std::string m_CmpName; // The string used as cmp/footprint name
64  std::string& m_Data; // the buffer containing the conversion
65  std::string m_errors; // a buffer to return error messages
66 
67 public:
68  BITMAPCONV_INFO( std::string& aData );
69 
73  int ConvertBitmap( potrace_bitmap_t* aPotrace_bitmap,
74  OUTPUT_FMT_ID aFormat, int aDpi_X, int aDpi_Y,
75  BMP2CMP_MOD_LAYER aModLayer );
76 
77  std::string& GetErrorMessages() {return m_errors; }
78 
79 private:
84 
89  void outputDataHeader( const char * aBrdLayerName );
90 
95  void outputDataEnd();
96 
97 
102  const char * getBoardLayerName( BMP2CMP_MOD_LAYER aChoice );
103 
109  void outputOnePolygon( SHAPE_LINE_CHAIN & aPolygon, const char* aBrdLayerName );
110 
111 };
112 
113 #endif // BITMAP2COMPONENT_H
std::string & GetErrorMessages()
std::string m_CmpName
potrace_path_t * m_Paths
BITMAPCONV_INFO(std::string &aData)
void createOutputData(BMP2CMP_MOD_LAYER aModLayer=(BMP2CMP_MOD_LAYER) 0)
Creates the data specified by m_Format.
enum OUTPUT_FMT_ID m_Format
void outputDataHeader(const char *aBrdLayerName)
Function outputDataHeader write to file the header depending on file format.
BMP2CMP_MOD_LAYER
const char * getBoardLayerName(BMP2CMP_MOD_LAYER aChoice)
std::string m_errors
std::string & m_Data
void outputDataEnd()
Function outputDataEnd write to file the last strings depending on file format.
void outputOnePolygon(SHAPE_LINE_CHAIN &aPolygon, const char *aBrdLayerName)
Function outputOnePolygon write one polygon to output file.
SHAPE_LINE_CHAIN.
OUTPUT_FMT_ID
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.