~bidulock/kicad/kicad-brian

« back to all changes in this revision

Viewing changes to pcbnew/class_zone.h

  • Committer: Brian F. G. Bidulock
  • Date: 2010-10-11 15:40:59 UTC
  • mfrom: (2360.34.14 kicad-brian)
  • Revision ID: brian@habeascorpus-20101011154059-uj1c42yjgwh2qv83
- committed current working tree

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
#include <vector>
9
9
#include "gr_basic.h"
10
10
#include "PolyLine.h"
 
11
#include "common.h"
11
12
 
12
13
/* a small class used when filling areas with segments */
13
14
class SEGMENT
24
25
    }
25
26
 };
26
27
 
27
 
/************************/
28
 
/* class ZONE_CONTAINER */
29
 
/************************/
30
 
 
31
 
/* handle a list of polygons delimiting a copper zone
32
 
 * a zone is described by a main polygon, a time stamp, a layer and a net name.
33
 
 * others polygons inside this main polygon are holes.
34
 
 */
35
 
 
 
28
class NC_NTD;
 
29
class NC_IPCD356;
 
30
 
 
31
/**
 
32
  * @class ZONE_CONTAINER
 
33
  * Handle a list of polygons delimiting a copper zone a zone is described by a
 
34
  * main polygon, a time stamp, a layer and a net name.  Others polygons inside
 
35
  * this main polygon are holes.
 
36
  *
 
37
  * Zones can occur on any layer.  On some layers, zones have special meanings
 
38
  * as follows:
 
39
  *
 
40
  * - Copper:
 
41
  *   Provides copper zones for ground and power planes.
 
42
  *
 
43
  * - Dielectric:
 
44
  *   Provides outline of embedded passives.
 
45
  *
 
46
  * - Plating:
 
47
  *   Provides a general purpose imaging area.
 
48
  *
 
49
  * - HoleFill:
 
50
  *   Provides a general purpose imaging area.
 
51
  *
 
52
  * - KeepOut:
 
53
  *   Provide outline of board keep-out areas.
 
54
  *
 
55
  * - ViaPlug:
 
56
  *   Provides a general purpose imaging area.
 
57
  *
 
58
  * - SolderMask:
 
59
  *   Provides a general purpose imaging area.  This can be used for removal of
 
60
  *   primary mask from board edge connectors and removal of primary mask from
 
61
  *   around microstrip traces.  Because zones on soldermask layers overlap the
 
62
  *   zone outline by 1/2 of the line thickness, minimum thickness can be
 
63
  *   adjusted to match the primary mask registration tolerance.  (This data is
 
64
  *   available in the process specification.)
 
65
  *
 
66
  * - Contacts:
 
67
  *   Provides a general purpose imaging area.  This can be used for outline of
 
68
  *   contact finish areas where multiple immersion finishes are required.
 
69
  *
 
70
  * - PeelMask:
 
71
  *   Provides a general purpose imaging area.  This can be used for outlining
 
72
  *   areas of removable or peelable masks.  Because zones on removable mask
 
73
  *   layers overlap the zone outlin by 1/2 the line thickness, minimum
 
74
  *   thickness can be adjusted to match the removable maks registration
 
75
  *   tolerance.  (This data is available in the process specification.)
 
76
  *
 
77
  * - Finish:
 
78
  *   Provides a general purpose imaging area.  This can be used for outlining
 
79
  *   areas of separate finishes for boards with multiple finishes.  This data
 
80
  *   is used to provide plots for imaging of resists for applying finishes.
 
81
  *
 
82
  * - SilkScreen:
 
83
  *   Provides a general purpose imaging area.
 
84
  *
 
85
  * - SolderPaste:
 
86
  *   Provides a general purpose imaging area.  This can be used to apply or
 
87
  *   remove solder paste to or from specific areas.  It has marginal utility at
 
88
  *   the board level.  Polylines on modules can be used for the same purpose.
 
89
  *
 
90
  * - Adhesive:
 
91
  *   Provides a general purpose imaging area.  This can be used to apply or
 
92
  *   remove adhesive from specific areas.  It has marginal utility at the board
 
93
  *   level.  Polylines on modules can be used for the same purpose.
 
94
  *
 
95
  * - Courtyard:
 
96
  *   Provides outline of general component keep-outs, for example, for
 
97
  *   outlining rework areas.
 
98
  *
 
99
  * - Component:
 
100
  *   Provides a general purpose drawing capability on component outline
 
101
  *   assembly drawings.  Zones defined in this layer appear on component
 
102
  *   outline assembly drawings.
 
103
  *
 
104
  * - Coating:
 
105
  *   Provides a general purpose imaging area.  This can be used to apply or
 
106
  *   remove coatings.  Zones defined in this layer appear on coating layer
 
107
  *   plots.
 
108
  *
 
109
  * - Edges:
 
110
  *   Provides the ability to describe cutouts and wells not related to a
 
111
  *   particular module.  Zones defined in this area generate route tool paths
 
112
  *   for NC routing files.  They can also be used to remove primary mask and
 
113
  *   legend.  They can also be used to define trace and component keep-out
 
114
  *   areas.  They can also be used to remove from near board edges.  They can
 
115
  *   also be used to define hole filling for cutouts and wells.
 
116
  *
 
117
  * - Eco:
 
118
  *   Provides a general purpose imaging area.
 
119
  *
 
120
  * - Probe:
 
121
  *   Provides the ability to describe probe keep-out areas.  Zones defined in
 
122
  *   this area affect accessiblity of probe points in netlist files (IPC-D-356)
 
123
  *   and can affect pad-master plots for probe testing (removal of pads in the
 
124
  *   inaccessible areas).
 
125
  *
 
126
  * - Fixture:
 
127
  *   Provides the ability to describe test fixture keep-out areas.
 
128
  *
 
129
  * - Comment:
 
130
  *   Provides a general purpose drawing area.
 
131
  *
 
132
  * - Drawing:
 
133
  *   Provides a general purpose drawing area.
 
134
  *
 
135
  * @todo
 
136
  * Zones need to be equipped to understand polarity and information layers.
 
137
  * Zones merging need to not merge zones that have a different polarity or
 
138
  * information layer.  Also, zones need to display reversed when poliarity is
 
139
  * clear.  2.5D and 3D board imaging needs to be taught polarity and
 
140
  * information layer.  To simplify the task (and to simplify plot creation),
 
141
  * only one dark and one clear information layer need be handled initially.
 
142
  */
36
143
class ZONE_CONTAINER : public BOARD_CONNECTED_ITEM
37
144
{
 
145
    wxPoint     m_CornerPosition;           // reference corner position
38
146
public:
39
 
    wxString              m_Netname;                        // Net Name
40
 
    CPolyLine*            m_Poly;                           // outlines
41
 
    int                   m_CornerSelection;                // For corner moving, corner index to drag, or -1 if no selection
42
 
    int                   m_ZoneClearance;                  // clearance value
43
 
    int                   m_ZoneMinThickness;               // Min thickness value in filled areas
44
 
    int                   m_FillMode;                       // How to fillingareas: 0 = use polygonal areas , != 0 fill with segments
45
 
    int                   m_ArcToSegmentsCount;             // number of segments to convert a circle to a polygon
46
 
                                                            // (uses ARC_APPROX_SEGMENTS_COUNT_LOW_DEF or ARC_APPROX_SEGMENTS_COUNT_HIGHT_DEF)
47
 
    int                   m_PadOption;                      //
48
 
    int                   m_ThermalReliefGapValue;          // tickness of the gap in thermal reliefs
49
 
    int                   m_ThermalReliefCopperBridgeValue; // tickness of the copper bridge in thermal reliefs
50
 
    int                   utility, utility2;                // flags used in polygon calculations
51
 
    bool                  m_IsFilled;                       // true when a zone was filled, false after deleting the filled areas
52
 
    std::vector <CPolyPt> m_FilledPolysList;  /* set of filled polygons used to draw a zone as a filled area.
53
 
                                               * from outlines (m_Poly) but unlike m_Poly these filled polygons have no hole (they are all in one piece)
54
 
                                               * In very simple cases m_FilledPolysList is same as m_Poly
55
 
                                               * In less simple cases (when m_Poly has holes) m_FilledPolysList is a polygon equivalent to m_Poly, without holes
56
 
                                               * but with extra outline segment connecting "holes" with external main outline
57
 
                                               * In complex cases an ouline decribed by m_Poly can have many filled areas
58
 
                                               */
59
 
    std::vector <SEGMENT> m_FillSegmList;      /* set of segments used to fill area, when fill zone by segment is used.
60
 
                                                *  ( m_FillMode == 1 )
61
 
                                                *  in this case segments have m_ZoneMinThickness width
62
 
                                                */
63
 
 
 
147
    wxString    m_Netname;                  // Net Name
 
148
    CPolyLine*  m_Poly;                     // outlines
 
149
    int         m_CornerSelection;          // For corner moving, corner index to drag, or -1 if no selection
 
150
    int         m_ZoneClearance;            // clearance value
 
151
    int         m_ZoneMinThickness;         // Min thickness value in filled areas
 
152
    int         m_FillMode;                 // How to fillingareas: 0 = use polygonal areas , != 0 fill with segments
 
153
    int         m_ArcToSegmentsCount;       // number of segments to convert a circle to a polygon
 
154
                                            // (uses ARC_APPROX_SEGMENTS_COUNT_LOW_DEF or ARC_APPROX_SEGMENTS_COUNT_HIGHT_DEF)
 
155
    int         m_PadOption;                //
 
156
    int         m_ThermalReliefGapValue;    // tickness of the gap in thermal reliefs
 
157
    int         m_ThermalReliefCopperBridgeValue; // tickness of the copper bridge in thermal reliefs
 
158
    int         utility, utility2;          // flags used in polygon calculations
 
159
    bool        m_IsFilled;                 // true when a zone was filled, false after deleting the filled areas
 
160
 
 
161
    /** Set of filled polygons used to draw a zone as a filled area.  From
 
162
      * outlines (m_Poly) but unlike m_Poly these filled polygons have no hole
 
163
      * (they are all in one piece) In very simple cases m_FilledPolysList is
 
164
      * same as m_Poly.  In less simple cases (when m_Poly has holes),
 
165
      * m_FilledPolysList is a polygon equivalent to m_Poly, without holes but
 
166
      * with extra outline segment connecting "holes" with external main outline
 
167
      * In complex cases an ouline decribed by m_Poly can have many filled
 
168
      * areas.
 
169
      */
 
170
    std::vector <CPolyPt> m_FilledPolysList;
 
171
 
 
172
    /** set of segments used to fill area, when fill zone by segment is used.
 
173
      * ( m_FillMode == 1 ) in this case segments have m_ZoneMinThickness width
 
174
      */
 
175
    std::vector <SEGMENT> m_FillSegmList;
64
176
public:
65
177
    ZONE_CONTAINER( BOARD* parent );
66
178
    ~ZONE_CONTAINER();
67
179
 
68
 
    bool     Save( FILE* aFile ) const;
69
 
    int      ReadDescr( FILE* aFile, int* aLineNum = NULL );
 
180
    /// For processing deferred updates.
 
181
    virtual int Cleanup( int what = -1 );
 
182
 
 
183
    virtual void ProxMapRefresh( void );
70
184
 
71
185
    /** virtual function GetPosition
72
186
     * @return a wxPoint, position of the first point of the outline
73
187
     */
74
 
    wxPoint& GetPosition();
 
188
    virtual wxPoint GetPosition() const;
 
189
    virtual wxPoint GetEndpoint() const;
 
190
    virtual void SetPosition( const wxPoint& aPos );
 
191
    virtual void SetEndpoint( const wxPoint& aPos );
75
192
 
76
193
 
77
194
    /**
78
195
     * Function copy
79
 
     * copy usefull data from the source.
80
 
     * flags and linked list pointers are NOT copied
 
196
     * copies usefull data from the source.
 
197
     * Flags and linked list pointers are NOT copied.
81
198
     */
82
199
    void     Copy( ZONE_CONTAINER* src );
83
200
 
84
 
    void     DisplayInfo( WinEDA_DrawFrame* frame );
 
201
    virtual double GetItemLength( ) const { return 0.0; }
 
202
 
 
203
    /** Board item identification and information display methods.
 
204
      * @{ */
 
205
    virtual wxString     MenuText( ) const;
 
206
    virtual const char** MenuIcon( ) const;
 
207
    virtual void         DisplayInfo( WinEDA_DrawFrame* frame ) const;
 
208
    /** @} */
 
209
 
 
210
    /** Read and write PCB files: implemented in pcbnew/ioascii.cpp.
 
211
      * @{ */
 
212
 
 
213
    /// Save this zone container to a PCB file.
 
214
    virtual bool SaveDescr( PCB_File_Context& aFC );
 
215
 
 
216
    /// Create and read a zone container from a PCB file.
 
217
    static ZONE_CONTAINER* ReadDescr( PCB_File_Context& aFC, BOARD* aParent );
 
218
 
 
219
    /** @} */
85
220
 
86
221
    /**
87
222
     * Function Draw
120
255
     */
121
256
    void     DrawWhileCreateOutline( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode = GR_OR );
122
257
 
 
258
    /**
 
259
     * Function Plot
 
260
     * Plots the for the layer on the plotter.  Implemented in
 
261
     * pcbnew/plot_rtn.cpp.
 
262
     */
 
263
    virtual void Plot( PLOTTER* aPlotter, const LAYER_ID& aLayer, const PCB_Plot_Options& aPlotOptions ) const;
 
264
 
 
265
    virtual void Draw3D( Pcb3D_GLCanvas& aCanvas ) const;
 
266
 
 
267
    /**
 
268
     * Function ExportVrml
 
269
     * Export the board item to VRML.  Implemented in pcbnew/export_vrml.cpp.
 
270
     */
 
271
    virtual void ExportVrml( ) const;
 
272
 
 
273
    /**
 
274
     * Function ExportIpcD356()
 
275
     * Export the board item to the IPC-D-356 file.  Implemented in
 
276
     * pcbnew/ipcd356.cpp.
 
277
     */
 
278
    virtual void ExportIpcD356( NC_IPCD356& aNc ) const;
 
279
 
 
280
    /**
 
281
     * Function ExportNtd()
 
282
     * Export the board item to the NTD file.  Implemented in
 
283
     * pcbnew/ipcd356.cpp.
 
284
     */
 
285
    virtual void ExportNtd( NC_NTD& aNc ) const;
123
286
 
124
287
    /* Function GetBoundingBox
125
288
     * @return an EDA_Rect that is the bounding box of the zone outline
126
289
     */
127
 
    EDA_Rect GetBoundingBox();
 
290
    EDA_Rect GetBoundingBox() const;
128
291
 
129
292
    /**
130
293
     * Function Test_For_Copper_Island_And_Remove__Insulated_Islands
133
296
     */
134
297
    void     Test_For_Copper_Island_And_Remove_Insulated_Islands( BOARD* aPcb );
135
298
 
136
 
    /** function CalculateSubAreaBoundaryBox
137
 
     * Calculates the bounding box of a a filled area ( list of CPolyPt )
138
 
     * use m_FilledPolysList as list of CPolyPt (that are the corners of one or more polygons or filled areas )
139
 
     * @return an EDA_Rect as bounding box
140
 
     * @param aIndexStart = index of the first corner of a polygon (filled area) in m_FilledPolysList
141
 
     * @param aIndexEnd = index of the last corner of a polygon in m_FilledPolysList
142
 
     */
 
299
    /**
 
300
      * Function CalculateSubAreaBoundaryBox
 
301
      * Calculates the bounding box of a a filled area ( list of CPolyPt ) use
 
302
      * m_FilledPolysList as list of CPolyPt (that are the corners of one or
 
303
      * more polygons or filled areas )
 
304
      *
 
305
      * @return an EDA_Rect as bounding box
 
306
      * @param aIndexStart = index of the first corner of a polygon (filled
 
307
      *     area) in m_FilledPolysList
 
308
      * @param aIndexEnd = index of the last corner of a polygon in
 
309
      *     m_FilledPolysList
 
310
      */
143
311
    EDA_Rect CalculateSubAreaBoundaryBox( int aIndexStart, int aIndexEnd );
144
312
 
145
313
    /**
146
314
     * Function IsOnCopperLayer
147
 
     * @return true if this zone is on a copper layer, false if on a technical layer
 
315
     * @return bool - true if this zone is on a copper layer,
 
316
     *     false if on a technical layer
148
317
     */
149
 
    bool IsOnCopperLayer( void )
 
318
    bool IsOnCopperLayer( ) const
150
319
    {
151
 
        return ( GetLayer() < FIRST_NO_COPPER_LAYER ) ? true : false;
 
320
        return ( GetLayer().GetClass() == LayerClass::Copper );
152
321
    }
153
322
 
154
323
    virtual void SetNet( int anet_code );
158
327
     * Fin the nat name corresponding to the net code.
159
328
     * @return bool - true if net found, else false
160
329
     */
161
 
    bool SetNetNameFromNetCode( void );
 
330
    bool SetNetNameFromNetCode( );
162
331
 
163
332
    /**
164
333
     * Function HitTest
167
336
     * @param refPos A wxPoint to test
168
337
     * @return bool - true if a hit, else false
169
338
     */
170
 
    bool HitTest( const wxPoint& refPos );
 
339
    virtual bool HitTest( const wxPoint& refPos ) const;
 
340
 
 
341
    virtual bool HitTest( const EDA_Rect& refArea ) const { return false; }
171
342
 
172
343
    /**
173
344
     * Function HitTestFilledArea
222
393
     * @return -1 if none, corner index in .corner <vector>
223
394
     * @param refPos : A wxPoint to test
224
395
     */
225
 
    int  HitTestForCorner( const wxPoint& refPos );
 
396
    int  HitTestForCorner( const wxPoint& refPos ) const;
226
397
 
227
398
    /**
228
399
     * Function HitTestForEdge
230
401
     * @return -1 if none,  or index of the starting corner in .corner <vector>
231
402
     * @param refPos : A wxPoint to test
232
403
     */
233
 
    int  HitTestForEdge( const wxPoint& refPos );
 
404
    int  HitTestForEdge( const wxPoint& refPos ) const;
234
405
 
235
406
    /**
236
407
     * Function HitTest (overlayed)
263
434
     */
264
435
    int  Fill_Zone_Areas_With_Segments( );
265
436
 
 
437
    virtual void AddToBoard( BOARD* aBoard )
 
438
    {
 
439
        SetParent( aBoard );
 
440
        SetState( DELETED, OFF );
 
441
        SetDirty( Presence );
 
442
        aBoard->AddItem( this );
 
443
    }
 
444
 
 
445
    virtual void Delete( void )
 
446
    {
 
447
        SetState( DELETED, ON );
 
448
        SetDirty( Presence );
 
449
        GetBoard()->DeleteItem( this );
 
450
        // will be removed and freed later by collector function
 
451
    }
 
452
 
 
453
    virtual void Remove( void )
 
454
    {
 
455
        SetDirtyParent( NULL );
 
456
        GetBoard()->RemoveItem( this );
 
457
        // must be unlinked immediately
 
458
    }
266
459
 
267
460
    /* Geometric transformations: */
268
461
 
309
502
     * returns the class name.
310
503
     * @return wxString
311
504
     */
312
 
    wxString GetClass() const
313
 
    {
314
 
        return wxT( "ZONE_CONTAINER" );
315
 
    }
 
505
    wxString GetClass() const { return wxT( "ZONE_CONTAINER" ); }
316
506
 
 
507
    /// Calculates clearance from zones to various board items.
 
508
    virtual bool GetClearance( int& aClearance, const BOARD_ITEM& aItem,
 
509
                               const LAYER_ID& aLayer ) const;
317
510
 
318
511
    /** Acces to m_Poly parameters
319
512
     */
320
513
 
321
 
    int GetNumCorners( void )
 
514
    int GetNumCorners( void ) const
322
515
    {
323
516
        return m_Poly->GetNumCorners();
324
517
    }
330
523
    }
331
524
 
332
525
 
333
 
    wxPoint GetCornerPosition( int aCornerIndex )
 
526
    wxPoint GetCornerPosition( int aCornerIndex ) const
334
527
    {
335
528
        return wxPoint( m_Poly->GetX( aCornerIndex ), m_Poly->GetY( aCornerIndex ) );
336
529
    }
340
533
    {
341
534
        m_Poly->SetX( aCornerIndex, new_pos.x );
342
535
        m_Poly->SetY( aCornerIndex, new_pos.y );
 
536
        SetDirty( Position | Geometry );
343
537
    }
344
538
 
345
539
 
346
540
    void AppendCorner( wxPoint position )
347
541
    {
348
542
        m_Poly->AppendCorner( position.x, position.y );
 
543
        SetDirty( Position | Geometry );
349
544
    }
350
545
 
351
546
 
362
557
    bool IsSame( const ZONE_CONTAINER &aZoneToCompare);
363
558
};
364
559
 
365
 
 
366
560
#endif  // #ifndef CLASS_ZONE_H