2014-08-21 16:57:25 +02:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KICAD, a free EDA CAD application.
|
|
|
|
*
|
2025-01-01 13:30:11 -08:00
|
|
|
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
2014-08-21 16:57:25 +02:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef BITMAP2COMPONENT_H
|
|
|
|
#define BITMAP2COMPONENT_H
|
|
|
|
|
2019-05-30 20:23:07 +02:00
|
|
|
#include <geometry/shape_poly_set.h>
|
2019-06-19 18:24:39 +02:00
|
|
|
#include <potracelib.h>
|
2019-05-30 20:23:07 +02:00
|
|
|
|
2025-01-18 12:01:28 +00:00
|
|
|
class REPORTER;
|
|
|
|
|
2014-08-21 16:57:25 +02:00
|
|
|
enum OUTPUT_FMT_ID
|
|
|
|
{
|
2025-01-18 12:01:28 +00:00
|
|
|
SYMBOL_FMT,
|
2025-01-19 17:45:40 -08:00
|
|
|
SYMBOL_PASTE_FMT, // This does not include the header information
|
2025-01-18 12:01:28 +00:00
|
|
|
FOOTPRINT_FMT,
|
2014-08-21 16:57:25 +02:00
|
|
|
POSTSCRIPT_FMT,
|
2025-01-18 12:01:28 +00:00
|
|
|
DRAWING_SHEET_FMT,
|
2014-11-12 17:59:12 +01:00
|
|
|
};
|
|
|
|
|
2019-05-30 20:23:07 +02:00
|
|
|
/* Helper class to handle useful info to convert a bitmap image to
|
|
|
|
* a polygonal object description
|
|
|
|
*/
|
|
|
|
class BITMAPCONV_INFO
|
|
|
|
{
|
|
|
|
private:
|
2025-01-18 12:01:28 +00:00
|
|
|
enum OUTPUT_FMT_ID m_Format; // File format
|
|
|
|
int m_PixmapWidth;
|
|
|
|
int m_PixmapHeight; // the bitmap size in pixels
|
2019-05-30 20:23:07 +02:00
|
|
|
double m_ScaleX;
|
2025-01-18 12:01:28 +00:00
|
|
|
double m_ScaleY; // the conversion scale
|
|
|
|
potrace_path_t* m_Paths; // the list of paths, from potrace (list of lines and bezier curves)
|
|
|
|
std::string m_CmpName; // The string used as cmp/footprint name
|
|
|
|
std::string& m_Data; // the buffer containing the conversion
|
|
|
|
REPORTER& m_reporter;
|
2019-05-30 20:23:07 +02:00
|
|
|
|
|
|
|
public:
|
2025-01-18 12:01:28 +00:00
|
|
|
BITMAPCONV_INFO( std::string& aData, REPORTER& aReporter );
|
2019-05-30 20:23:07 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Run the conversion of the bitmap
|
|
|
|
*/
|
2025-01-18 12:01:28 +00:00
|
|
|
int ConvertBitmap( potrace_bitmap_t* aPotrace_bitmap, OUTPUT_FMT_ID aFormat, int aDpi_X,
|
|
|
|
int aDpi_Y, const wxString& aLayer );
|
2019-05-30 20:23:07 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
/**
|
|
|
|
* Creates the data specified by m_Format
|
|
|
|
*/
|
2025-01-18 12:01:28 +00:00
|
|
|
void createOutputData( const wxString& aBrdLayerName = wxT( "F.SilkS" ) );
|
2019-05-30 20:23:07 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function outputDataHeader
|
|
|
|
* write to file the header depending on file format
|
|
|
|
*/
|
2025-01-18 12:01:28 +00:00
|
|
|
void outputDataHeader( const wxString& aBrdLayerName );
|
2019-05-30 20:23:07 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function outputDataEnd
|
|
|
|
* write to file the last strings depending on file format
|
|
|
|
*/
|
|
|
|
void outputDataEnd();
|
|
|
|
|
|
|
|
/**
|
2019-08-20 18:22:30 +01:00
|
|
|
* Function outputOnePolygon
|
2019-05-30 20:23:07 +02:00
|
|
|
* write one polygon to output file.
|
|
|
|
* Polygon coordinates are expected scaled by the polygon extraction function
|
|
|
|
*/
|
2025-01-18 12:01:28 +00:00
|
|
|
void outputOnePolygon( SHAPE_LINE_CHAIN & aPolygon, const wxString& aBrdLayerName );
|
2019-05-30 20:23:07 +02:00
|
|
|
};
|
|
|
|
|
2014-08-21 16:57:25 +02:00
|
|
|
#endif // BITMAP2COMPONENT_H
|