1 /* LayerObject.h
2  * Object managing a single layer and its attributes
3  *
4  * Copyright (C) 1996-2012 by vhf interservice GmbH
5  * Author:   Georg Fleischmann
6  *
7  * Created:  1996-03-07
8  * Modified: 2012-01-25 (-setInvisible:, -invisible, invisible)
9  *
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the vhf Public License as
12  * published by vhf interservice GmbH. Among other things, the
13  * License requires that the copyright notices and this notice
14  * be preserved on all copies.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19  * See the vhf Public License for more details.
20  *
21  * You should have received a copy of the vhf Public License along
22  * with this program; see the file LICENSE. If not, write to vhf.
23  *
24  * vhf interservice GmbH, Im Marxle 3, 72119 Altingen, Germany
25  * eMail: info@vhf.de
26  * http://www.vhf.de
27  */
28 
29 #ifndef VHF_H_LAYEROBJECT
30 #define VHF_H_LAYEROBJECT
31 
32 #include "GraphicObjects.subproj/PerformanceMap.h"
33 
34 /* FIXME: CAM (should go to a sub class header) */
35 #define OUTPUT_STEPMAX 100
36 typedef struct
37 {
38     float	step[OUTPUT_STEPMAX];
39     int		count;
40 } OutputSteps;
41 
42 typedef enum
43 {
44     CUT_INSIDE    = 0,  // correct to inside
45     CUT_OUTSIDE   = 1,  // correct to outside
46     CUT_NOSIDE    = 2,  // no correction
47     CUT_PICKOUT   = 3,  // engraving with pick-out
48     CUT_ISOLATION = 4,	// calculate isolation of PCB
49     CUT_BLOWUP    = 5,	// calculate blow up   of PCB
50     CUT_RUBOUT    = 6	// calculate rubout    of PCB
51 } CAMCutType;
52 
53 /* the layer ids shouldn't be changed, they are saved to the document !
54  * FIXME: we should save the name of the layer types (not integer code)
55  */
56 typedef enum
57 {
58     /* General layer types */
59     LAYER_STANDARD   = 0,	// standard layer
60     LAYER_PASSIVE    = 1,	// passive layer, not editable, calculated automatically (CAM)
61     LAYER_CLIPPING   = 2,	// layer with regions used for clipping (CAM)
62     LAYER_LEVELING   = 3,	// layer with elements defining an area for leveling (CAM)
63     LAYER_FITTING    = 4,	// a layer with two marks for flipping the working piece (CAM)
64     LAYER_PAGE       = 5,	// page in multi page document
65 
66     /* Templates */
67     LAYER_TEMPLATE   = 10,	// general template for all layers and pages
68     LAYER_TEMPLATE_1 = 11,	// template for odd pages
69     LAYER_TEMPLATE_2 = 12,	// template for even pages
70 
71     /* CAM (FIXME: needs to go to CAM module) */
72     LAYER_CAMERA     = 50	// layer with markers defining target net for camera gauging (CAM)
73 } LayerType;
74 
75 @interface LayerObject: NSObject
76 {
77     NSString        *string;            // the name of the layer
78     PerformanceMap  *performanceMap;    // grid for faster access of objects on layer
79     NSMutableArray  *list;              // the graphic list
80     int             tag;                // tag for layers with special purpose
81     NSColor         *color;             // the color of this layer
82     int             state;              // if we have to display this layer
83     BOOL            editable;           // whether we are editable
84     int             type;               // type of layer: LAYER_STANDARD, LAYER_PASSIVE, ...
85     int             uniqueId;           // a unique id of the layer used with multi layer groups
86     BOOL            likeOtherLayers;    // YES = share parameters with other layers of state YES
87     BOOL            useForTile;         // whether layer is used for duplicates
88     BOOL            dirty;              // YES when changed
89     BOOL            invisible;          // whether this is a drawable layer
90 
91     NSMutableDictionary *layerDict;     // dictionary to store additional stuff for the layer
92 
93     /* TODO: CAM (move to a sub class) */
94     int             toolIndex;          // the index of the tool
95     NSString        *toolString;        // the name of the tool
96     BOOL            filled;             // whether we are filled
97     BOOL            mirrored;           // whether we are mirrored
98     int             side;               // whether to cut inside, outside or on the line
99     float           flatness;
100     float           fillOverlap;        // (0.0 - 1.0) 0 = no overlap
101     float           fillDirection;      // (0.0 - 360.0)
102     BOOL            removeLoops;        // whether we have to remove garbage (loops) from contour
103     BOOL            revertDirection;    // whether we revert the direction (ccw/cw)
104     float           dippingDepth;       // the dippingDepth [mm]
105     float           approachAngle;      // the approach angle for dipping, 0 - 89 [deg]
106     BOOL            stepwise;           // weather stepwise cutting is active
107     int             numSteps;           // number of middle steps
108     float           step[3];            // first, step width, final step [mm]
109     OutputSteps     calcSteps;          // calculated steps [mm]
110     float           settle;             // [mm]
111     BOOL            settleBefore;       // settlement before last step z
112     int             levelingX, levelingY;   // number of test points for leveling */
113     BOOL            inlay;
114 
115     /* CAM output */
116     NSArray         *webList;           // used to reach web list when creating output
117     int             tileCount;          // used to reach tile count when creating output
118     id              clipObject;         // used to reach clip object when creating output
119 }
120 
121 + layerObject;
122 + layerObjectWithFrame:(NSRect)bRect;
123 - init;
124 - initWithFrame:(NSRect)bRect;
125 
126 - (void)createPerformanceMapWithFrame:(NSRect)rect;
127 - (PerformanceMap*)performanceMap;
128 - (void)setList:(NSMutableArray*)aList;
129 - (NSMutableArray*)list;
130 - (void)insertObject:(id)obj atIndex:(unsigned)ix;
131 - (void)addObject:(id)obj;
132 - (void)addObjectWithoutCheck:(id)obj;
133 - (void)addObjectsFromArray:(NSArray*)array;
134 - (void)updateObject:(VGraphic*)g;
135 - (void)removeAllObjects;
136 - (void)removeObject:(id)obj;
137 - (void)draw:(NSRect)rect inView:(id)view;
138 
139 - (BOOL)isFillable;
140 - (BOOL)hasDip;             // TODO: move to CAM module
141 - (BOOL)isPassive;          // LAYER_PASSIVE
142 - (BOOL)fastSideSelection;
143 
144 - (void)setString:(NSString *)aString;
145 - (NSString*)string;
146 
147 - (void)setTag:(int)newTag;
148 - (int)tag;
149 
150 - (void)setColor:(NSColor *)aColor;
151 - (NSColor *)color;
152 
153 - (void)setState:(int)flag;
154 - (int)state;
155 
156 - (void)setInvisible:(int)flag;
157 - (int)invisible;
158 
159 - (void)setEditable:(BOOL)flag;
160 - (BOOL)editable;
161 
162 - (void)setDirty:(BOOL)flag calculate:(BOOL)cflag;
163 - (void)setDirty:(BOOL)flag;
164 - (BOOL)dirty;
165 
166 - (int)type;
167 - (void)setType:(int)newType;
168 
169 - (int)uniqueId;
170 - (void)setUniqueId:(int)newId;
171 
172 - (BOOL)useForTile;
173 - (void)setUseForTile:(BOOL)flag;
174 - (void)setTileCount:(int)c;
175 - (int)tileCount;
176 
177 - (BOOL)likeOtherLayers;
178 - (void)setLikeOtherLayers:(BOOL)flag;
179 
180 
181 /* CAM (should go to a sub class or category) */
182 - (void)setToolIndex:(int)aTool;
183 - (int)toolIndex;
184 - (void)setToolString:(NSString*)theToolString;
185 - (NSString*)toolString;
186 
187 - (void)setFilled:(BOOL)flag;
188 - (BOOL)filled;
189 
190 - (void)setMirrored:(BOOL)flag;
191 - (BOOL)mirrored;
192 
193 - (void)setInlay:(BOOL)flag;
194 - (BOOL)inlay;
195 
196 - (void)setSide:(int)s;
197 - (int)side;
198 
199 - (float)flatness;
200 - (void)setFlatness:(float)v;
201 
202 - (float)fillOverlap;
203 - (void)setFillOverlap:(float)v;
204 - (float)fillDirection;
205 - (void)setFillDirection:(float)v;
206 
207 - (void)setDippingDepth:(float)d;
208 - (float)dippingDepth;
209 
210 - (void)setApproachAngle:(float)angle;
211 - (float)approachAngle;
212 
213 - (void)setStepwise:(BOOL)flag;
214 - (BOOL)stepwise;
215 - (void)setFirstStep:(float)step;
216 - (void)setStepHeight:(float)height;
217 - (float)stepHeight;
218 - (void)setNumSteps:(int)n;
219 - (int)numSteps;
220 - (void)setFinalStep:(float)step;
221 - (float)stepWithNum:(int)n;
222 - (OutputSteps)steps;
223 - (OutputSteps)stepsForDip:(float)dip;
224 
225 - (void)setSettle:(float)value;
226 - (float)settle;
227 - (void)setSettleBefore:(BOOL)flag;
228 - (BOOL)settleBefore;
229 
230 - (BOOL)removeLoops;
231 - (void)setRemoveLoops:(BOOL)flag;
232 
233 - (BOOL)revertDirection;
234 - (void)setRevertDirection:(BOOL)flag;
235 
236 - (void)setLevelingPointsX:(int)x y:(int)y;
237 - (int)levelingPointsX;
238 - (int)levelingPointsY;
239 
240 /* CAM output, used to reach web list when creating output */
241 - (void)setWebList:(NSArray*)array;
242 - (NSArray*)webList;
243 - (void)setClipObject:obj;
244 - clipObject;
245 
246 
247 /* archiving */
248 - (void)dealloc;
249 
250 - (id)initWithCoder:(NSCoder *)aDecoder;
251 - (void)encodeWithCoder:(NSCoder *)aCoder;
252 
253 @end
254 
255 #endif // VHF_H_LAYEROBJECT
256