2014-02-05 09:27:21 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2014 Cirilo Bernardo
|
2018-07-08 18:12:06 +00:00
|
|
|
* Copyright (C) 2018 KiCad Developers, see AUTHORS.txt for contributors.
|
2014-02-05 09:27:21 +00: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 DXF2IDF_H
|
|
|
|
#define DXF2IDF_H
|
|
|
|
|
|
|
|
#include <string>
|
2018-07-08 18:12:06 +00:00
|
|
|
#include "dl_dxf.h"
|
|
|
|
#include "dl_creationadapter.h"
|
2014-02-05 09:27:21 +00:00
|
|
|
#include <idf_common.h>
|
|
|
|
|
2018-07-08 18:12:06 +00:00
|
|
|
class DXF2IDF : public DL_CreationAdapter
|
2014-02-05 09:27:21 +00:00
|
|
|
{
|
|
|
|
private:
|
|
|
|
std::list< IDF_SEGMENT* > lines; // Unsorted list of graphical segments
|
2016-03-22 02:53:32 +00:00
|
|
|
double m_scale; // scaling factor to mm
|
2018-07-08 18:12:06 +00:00
|
|
|
int m_entityType; // the DXF type of entity
|
|
|
|
int m_entityParseStatus; // Inside a entity: status od parsing:
|
|
|
|
// 0 = no entity
|
|
|
|
// 1 = first item of entity
|
|
|
|
// 2 = entity in progress
|
|
|
|
int m_entity_flags; // state of flags read from last entity
|
|
|
|
IDF_POINT m_lastCoordinate; // the last vertex coordinate read (unit = mm)
|
|
|
|
IDF_POINT m_polylineStart; // The first point of the polyline entity, when reading a polyline (unit = mm)
|
|
|
|
double m_bulgeVertex; // the last vertex bulge value read
|
2016-03-22 02:53:32 +00:00
|
|
|
|
|
|
|
void insertLine( const IDF_POINT& aSegStart, const IDF_POINT& aSegEnd );
|
|
|
|
void insertArc( const IDF_POINT& aSegStart, const IDF_POINT& aSegEnd, double aBulge );
|
2014-02-05 09:27:21 +00:00
|
|
|
|
|
|
|
public:
|
2018-07-08 18:12:06 +00:00
|
|
|
DXF2IDF() : m_scale( 1.0 ), m_entityType( 0 ), m_entityParseStatus( 0 ),
|
|
|
|
m_entity_flags( 0 ), m_bulgeVertex( 0.0 ) {};
|
2014-02-05 09:27:21 +00:00
|
|
|
~DXF2IDF();
|
|
|
|
|
2017-09-23 09:20:10 +00:00
|
|
|
bool ReadDxf( const std::string& aFile );
|
2014-02-05 09:27:21 +00:00
|
|
|
bool WriteOutline( FILE* aFile, bool isInch );
|
|
|
|
|
|
|
|
private:
|
|
|
|
// DRW_Interface implemented callback functions
|
2018-07-08 18:12:06 +00:00
|
|
|
virtual void addLine( const DL_LineData& aData ) override;
|
|
|
|
virtual void addArc( const DL_ArcData& aData ) override;
|
|
|
|
virtual void addCircle( const DL_CircleData& aData ) override;
|
|
|
|
virtual void addPolyline( const DL_PolylineData& aData ) override;
|
|
|
|
/** Called for every polyline vertex */
|
|
|
|
virtual void addVertex( const DL_VertexData& aData ) override;
|
2014-02-05 09:27:21 +00:00
|
|
|
|
2018-07-08 18:12:06 +00:00
|
|
|
/**
|
|
|
|
* Called for every string variable in the DXF file (e.g. "$ACADVER").
|
|
|
|
*/
|
|
|
|
virtual void setVariableString( const std::string& key, const std::string& value,
|
|
|
|
int code ) override {};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called for every int variable in the DXF file (e.g. "$ACADMAINTVER").
|
|
|
|
*/
|
|
|
|
virtual void setVariableInt( const std::string& key, int value, int code ) override;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called for every double variable in the DXF file (e.g. "$DIMEXO").
|
|
|
|
*/
|
|
|
|
virtual void setVariableDouble( const std::string& key, double value, int code ) override {}
|
|
|
|
|
|
|
|
virtual void endEntity() override;
|
2014-02-05 09:27:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // DXF2IDF_H
|