1 /* DINImport.h
2  * DIN import object (drill data)
3  *
4  * Copyright (C) 1996-2012 by vhf interservice GmbH
5  * Author:   Ilonka Fleischmann
6  *
7  * created:  1996-05-03
8  * modified: 2003-06-26
9  *
10  * This file is part of the vhf Import Library.
11  *
12  * This library is free software; you can redistribute it and/or
13  * modify it under the terms of the vhf Public License as
14  * published by the vhf interservice GmbH. Among other things,
15  * the License requires that the copyright notices and this notice
16  * be preserved on all copies.
17  *
18  * This library is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
21  * See the vhf Public License for more details.
22  *
23  * You should have received a copy of the vhf Public License along
24  * with this library; see the file LICENSE. If not, write to vhf.
25  *
26  * If you want to link this library to your proprietary software,
27  * or for other uses which are not covered by the definitions
28  * laid down in the vhf Public License, vhf also offers a proprietary
29  * license scheme. See the vhf internet pages or ask for details.
30  *
31  * vhf interservice GmbH, Im Marxle 3, 72119 Altingen, Germany
32  * eMail: info@vhf.de
33  * http://www.vhf.de
34  */
35 
36 #include <AppKit/AppKit.h>
37 
38 #define	DIN_LINE        1
39 #define	DIN_ARC         2
40 #define	DIN_PATH        3
41 
42 #define	DIN_SM1000		1
43 #define	DIN_SM3000		2
44 #define	DIN_EXCELLON	3
45 
46 typedef struct _DINState
47 {
48     NSColor     *color;		/* color of object */
49     float       width;		/* width of object */
50 
51     int         tool;
52     int         pa;			/* 1 = absolut, otherwise relative point */
53     NSPoint     point;		/* current point */
54     int         g;			/* current graphic (Gerber_LINE, Gerber_ARC) */
55     float       x, y, a, c; /* new data */
56     int         inch;		/* inch or mm */
57     NSPoint     formatX;
58     NSPoint     formatY;	/* format in which values are .. */
59     int         zeros;		/* if LTD zeros are omitted see FS */
60     int         draw;		/* if we have to draw now */
61     int         ccw;		/* counterclockwise (1) arc interpolation or clockwise (0)*/
62     int         path;		/* if we are in path mode */
63     int         offset;		/* if offset is set */
64 }DINState;
65 
66 typedef struct _DINOps
67 {
68     NSString    *init,
69                 *reset,
70                 *selectTool,
71                 *plotAbs,
72                 *plotRel,
73                 *coordX,
74                 *coordY,
75                 *coordR,
76                 *coordC,
77                 *termi,
78                 *polyBegin,
79                 *polyBegin2,
80                 *polyEnd,
81                 *comment,
82                 *line,
83                 *circleCW,
84                 *circleCCW,
85                 *start,
86                 *drill,
87                 *mm,
88                 *prgend,
89                 *offset;
90 }DINOps;
91 
92 @interface DINImport:NSObject
93 {
94     NSCharacterSet  *digitsSet, *invDigitsSet, *termiSet;
95     id              list;           /* the base list for all contents */
96     NSMutableArray  *tools;         /* tools */
97     DINState		state;          /* the current state */
98     DINOps          ops;
99     NSPoint         ll, ur;         /* bounds */
100     float           res;            /* device resolution in dots per inch */
101     float           resMM;
102     BOOL            tz;             // trailing zeros
103     BOOL            fileFormat;     /* flag which file format we got */
104     BOOL            parameterLoaded; /* flag if we allways load the parameter (for default) */
105 }
106 
107 - (void)setDefaultParameter;
108 
109 /* load parameter file */
110 - (BOOL)loadParameter:(NSString*)fileName;
111 
112 /* start import */
113 - importDIN:(NSData*)DINStream;
114 
115 /* free import object
116  * no graphic objects (line, curve) will be freed
117  * the list returned by importGerber will not be freed either
118  */
119 - (void)dealloc;
120 
121 /* methods needed to be sub classed
122  *
123  * allocate an array holding the graphic objects:
124  *  - allocateList;
125  * make a mark-object and add it to aList
126  *  - addMark:(NXPoint)pt withDiameter:(float)dia toList:aList;
127  */
128 - (id)allocateList;
129 - (void)addMark:(NSPoint)pt withDiameter:(float)dia toList:aList;
130 - (void)addLine:(NSPoint)beg :(NSPoint)end toList:aList;
131 - (void)addCircle:(NSPoint)center :(float)radius filled:(BOOL)fill toList:aList;
132 - (void)addArc:(NSPoint)center :(NSPoint)start :(float)angle toList:aList;
133 - (void)addFillList:aList toList:bList;
134 - (void)setBounds:(NSRect)bounds;
135 
136 @end
137