summaryrefslogtreecommitdiff
path: root/utils/idftools/dxf2idf.h
blob: 2eb8eada6427cff36967ddebf5c348e9143f1c29 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/*
 * This program source code file is part of KiCad, a free EDA CAD application.
 *
 * Copyright (C) 2014  Cirilo Bernardo
 *
 * 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>
#include <drw_interface.h>
#include <idf_common.h>

class DXF2IDF : public DRW_Interface
{
private:
    std::list< IDF_SEGMENT* > lines;    // Unsorted list of graphical segments
    double m_scale;                     // scaling factor to mm

    void insertLine( const IDF_POINT& aSegStart, const IDF_POINT& aSegEnd );
    void insertArc( const IDF_POINT& aSegStart, const IDF_POINT& aSegEnd, double aBulge );

public:
    ~DXF2IDF();

    bool ReadDxf( const std::string aFile );
    bool WriteOutline( FILE* aFile, bool isInch );

private:
    // DRW_Interface implemented callback functions
    virtual void addHeader( const DRW_Header* data );
    virtual void addLine(const DRW_Line& data);
    virtual void addArc(const DRW_Arc& data );
    virtual void addCircle(const DRW_Circle& data );
    virtual void addLWPolyline(const DRW_LWPolyline& data );
    virtual void addPolyline(const DRW_Polyline& data );

    // DRW_Interface callbacks unsupported by DXF2IDF
    virtual void addLType( const DRW_LType& data ){}
    virtual void addLayer( const DRW_Layer& data ){}
    virtual void addDimStyle( const DRW_Dimstyle& data ){}
    virtual void addVport(const DRW_Vport& data){}
    virtual void addTextStyle(const DRW_Textstyle& data){}
    virtual void addBlock(const DRW_Block& data ){}
    virtual void setBlock(const int handle){}
    virtual void endBlock(){}
    virtual void addPoint(const DRW_Point& data ){}
    virtual void addRay(const DRW_Ray& data ){}
    virtual void addXline(const DRW_Xline& data ){}
    virtual void addEllipse(const DRW_Ellipse& data ){}
    virtual void addSpline(const DRW_Spline* data ){}
    virtual void addKnot(const DRW_Entity&){}
    virtual void addInsert(const DRW_Insert& data ){}
    virtual void addTrace(const DRW_Trace& data ){}
    virtual void add3dFace(const DRW_3Dface& data ){}
    virtual void addSolid(const DRW_Solid& data ){}
    virtual void addMText(const DRW_MText& data){}
    virtual void addText(const DRW_Text& data ){}
    virtual void addDimAlign(const DRW_DimAligned *data ){}
    virtual void addDimLinear(const DRW_DimLinear *data ){}
    virtual void addDimRadial(const DRW_DimRadial *data ){}
    virtual void addDimDiametric(const DRW_DimDiametric *data ){}
    virtual void addDimAngular(const DRW_DimAngular *data ){}
    virtual void addDimAngular3P(const DRW_DimAngular3p *data ){}
    virtual void addDimOrdinate(const DRW_DimOrdinate *data ){}
    virtual void addLeader(const DRW_Leader *data ){}
    virtual void addHatch(const DRW_Hatch* data ){}
    virtual void addViewport(const DRW_Viewport& data){}
    virtual void addImage(const DRW_Image* data ){}
    virtual void linkImage(const DRW_ImageDef* data ){}
    virtual void addComment(const char*){}
    virtual void writeHeader(DRW_Header& data){}
    virtual void writeBlocks(){}
    virtual void writeBlockRecords(){}
    virtual void writeEntities(){}
    virtual void writeLTypes(){}
    virtual void writeLayers(){}
    virtual void writeTextstyles(){}
    virtual void writeVports(){}
    virtual void writeDimstyles(){}
    virtual void addAppId( const DRW_AppId& data ) {}
    virtual void writeAppId() {}
};

#endif  // DXF2IDF_H