~pierre-parent-k/kicad/length-tunning

« back to all changes in this revision

Viewing changes to pcbnew/print_board_functions.cpp

  • Committer: Pierre Parent
  • Date: 2014-07-06 10:32:13 UTC
  • mfrom: (4798.1.179 kicad)
  • Revision ID: pierre.parent@insa-rouen.fr-20140706103213-wjsdy0hc9q6wbz5v
Merge with lp:kicad 4977

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
 
45
45
 
46
46
static void Print_Module( EDA_DRAW_PANEL* aPanel, wxDC* aDC, MODULE* aModule,
47
 
                          GR_DRAWMODE aDraw_mode, LAYER_MSK aMasklayer,
 
47
                          GR_DRAWMODE aDraw_mode, LSET aMasklayer,
48
48
                          PRINT_PARAMETERS::DrillShapeOptT aDrillShapeOpt );
49
49
 
50
50
void FOOTPRINT_EDIT_FRAME::PrintPage( wxDC* aDC,
51
 
                                      LAYER_MSK aPrintMaskLayer,
 
51
                                      LSET aPrintMaskLayer,
52
52
                                      bool  aPrintMirrorMode,
53
53
                                      void * aData)
54
54
{
93
93
        drawmode = GR_OR;
94
94
 
95
95
    // Draw footprints, this is done at last in order to print the pad holes in
96
 
    // white (or g_DrawBgColor) after the tracks and zones
 
96
    // white after the tracks and zones
97
97
    int tmp = D_PAD::m_PadSketchModePenSize;
98
98
    D_PAD::m_PadSketchModePenSize = defaultPenSize;
99
99
 
120
120
}
121
121
 
122
122
 
123
 
/**
124
 
 * Function PrintPage
125
 
 * is used to print the board (on printer, or when creating SVF files).
126
 
 * Print the board, but only layers allowed by aPrintMaskLayer
127
 
 * @param aDC = the print device context
128
 
 * @param aPrintMaskLayer = a 32 bits mask: bit n = 1 -> layer n is printed
129
 
 * @param aPrintMirrorMode = true to plot mirrored
130
 
 * @param aData = a pointer to an optional data (NULL if not used)
131
 
 */
132
123
void PCB_EDIT_FRAME::PrintPage( wxDC* aDC,
133
 
                                LAYER_MSK aPrintMaskLayer,
 
124
                                LSET  aPrintMask,
134
125
                                bool  aPrintMirrorMode,
135
126
                                void* aData)
136
127
{
137
 
    MODULE* Module;
138
128
    GR_DRAWMODE     drawmode = GR_COPY;
139
129
    DISPLAY_OPTIONS save_opt;
140
130
    BOARD*          Pcb   = GetBoard();
141
131
    int             defaultPenSize = Millimeter2iu( 0.2 );
142
132
    bool            onePagePerLayer = false;
143
133
 
144
 
    PRINT_PARAMETERS * printParameters = (PRINT_PARAMETERS*) aData; // can be null
 
134
    PRINT_PARAMETERS* printParameters = (PRINT_PARAMETERS*) aData; // can be null
145
135
 
146
136
    if( printParameters && printParameters->m_OptionPrintPage == 0 )
147
137
        onePagePerLayer = true;
155
145
    }
156
146
 
157
147
    save_opt = DisplayOpt;
158
 
    LAYER_NUM activeLayer = GetScreen()->m_Active_Layer;
 
148
 
 
149
    LAYER_ID activeLayer = GetScreen()->m_Active_Layer;
159
150
 
160
151
    DisplayOpt.ContrastModeDisplay = false;
161
152
    DisplayOpt.DisplayPadFill = true;
162
153
    DisplayOpt.DisplayViaFill = true;
163
154
 
164
 
    if( (aPrintMaskLayer & ALL_CU_LAYERS) == 0 )
 
155
    if( !( aPrintMask & LSET::AllCuMask() ).any() )
165
156
    {
166
157
        if( onePagePerLayer )
167
 
        {   // We can print mask layers (solder mask and solder paste) with the actual
 
158
        {
 
159
            // We can print mask layers (solder mask and solder paste) with the actual
168
160
            // pad sizes.  To do that, we must set ContrastModeDisplay to true and set
169
 
            //the GetScreen()->m_Active_Layer to the current printed layer
 
161
            // the GetScreen()->m_Active_Layer to the current printed layer
170
162
            DisplayOpt.ContrastModeDisplay = true;
171
163
            DisplayOpt.DisplayPadFill = true;
172
164
 
173
165
            // Calculate the active layer number to print from its mask layer:
174
 
            GetScreen()->m_Active_Layer = FIRST_LAYER;
 
166
            GetScreen()->m_Active_Layer = B_Cu;
175
167
 
176
 
            for( LAYER_NUM kk = FIRST_LAYER; kk < NB_LAYERS; ++kk )
 
168
            for( LAYER_NUM id = LAYER_ID_COUNT-1; id >= 0; --id )
177
169
            {
178
 
                if( GetLayerMask( kk ) & aPrintMaskLayer )
 
170
                if( aPrintMask[id] )
179
171
                {
180
 
                    GetScreen()->m_Active_Layer = kk;
 
172
                    GetScreen()->m_Active_Layer = LAYER_ID( id );
181
173
                    break;
182
174
                }
183
175
            }
184
176
 
185
177
            // pads on Silkscreen layer are usually plot in sketch mode:
186
 
            if( (GetScreen()->m_Active_Layer == SILKSCREEN_N_BACK)
187
 
                || (GetScreen()->m_Active_Layer == SILKSCREEN_N_FRONT) )
 
178
            if( GetScreen()->m_Active_Layer == B_SilkS ||
 
179
                GetScreen()->m_Active_Layer == F_SilkS )
 
180
            {
188
181
                DisplayOpt.DisplayPadFill = false;
189
 
 
 
182
            }
190
183
        }
191
184
        else
192
185
        {
194
187
        }
195
188
    }
196
189
 
197
 
 
198
190
    m_DisplayPadFill = DisplayOpt.DisplayPadFill;
199
191
    m_DisplayViaFill = DisplayOpt.DisplayViaFill;
200
192
    m_DisplayPadNum = DisplayOpt.DisplayPadNum = false;
 
193
 
201
194
    bool nctmp = GetBoard()->IsElementVisible( NO_CONNECTS_VISIBLE );
 
195
 
202
196
    GetBoard()->SetElementVisibility( NO_CONNECTS_VISIBLE, false );
 
197
 
203
198
    bool anchorsTmp = GetBoard()->IsElementVisible( ANCHOR_VISIBLE );
 
199
 
204
200
    GetBoard()->SetElementVisibility( ANCHOR_VISIBLE, false );
 
201
 
205
202
    DisplayOpt.DisplayPadIsol = false;
206
203
    m_DisplayModEdge = DisplayOpt.DisplayModEdge    = FILLED;
207
204
    m_DisplayModText = DisplayOpt.DisplayModText    = FILLED;
231
228
        case PCB_DIMENSION_T:
232
229
        case PCB_TEXT_T:
233
230
        case PCB_TARGET_T:
234
 
            if( GetLayerMask( item->GetLayer() ) & aPrintMaskLayer )
 
231
            if( aPrintMask[item->GetLayer()] )
235
232
                item->Draw( m_canvas, aDC, drawmode );
236
233
            break;
237
234
 
242
239
    }
243
240
 
244
241
    // Print tracks
245
 
    for( TRACK * track = Pcb->m_Track; track; track = track->Next() )
 
242
    for( TRACK* track = Pcb->m_Track; track; track = track->Next() )
246
243
    {
247
 
        if( !( aPrintMaskLayer & track->GetLayerMask() ) )
 
244
        if( !( aPrintMask & track->GetLayerSet() ).any() )
248
245
            continue;
249
246
 
250
247
        if( track->Type() == PCB_VIA_T ) // VIA encountered.
251
248
        {
252
 
            int radius = track->GetWidth() >> 1;
253
 
            EDA_COLOR_T color = g_ColorsSettings.GetItemColor( VIAS_VISIBLE + track->GetShape() );
 
249
            int         radius = track->GetWidth() / 2;
 
250
            const VIA*  via = static_cast<const VIA*>( track );
 
251
 
 
252
            EDA_COLOR_T color = g_ColorsSettings.GetItemColor( VIAS_VISIBLE + via->GetViaType() );
 
253
 
254
254
            GRSetDrawMode( aDC, drawmode );
255
255
            GRFilledCircle( m_canvas->GetClipBox(), aDC,
256
 
                            track->GetStart().x,
257
 
                            track->GetStart().y,
 
256
                            via->GetStart().x,
 
257
                            via->GetStart().y,
258
258
                            radius,
259
259
                            0, color, color );
260
260
        }
265
265
    }
266
266
 
267
267
    // Outdated: only for compatibility to old boards
268
 
    for( TRACK * track = Pcb->m_Zone; track != NULL; track = track->Next() )
 
268
    for( TRACK* track = Pcb->m_Zone; track; track = track->Next() )
269
269
    {
270
 
        if( !( aPrintMaskLayer & track->GetLayerMask() ) )
 
270
        if( !( aPrintMask & track->GetLayerSet() ).any() )
271
271
            continue;
272
272
 
273
273
        track->Draw( m_canvas, aDC, drawmode );
278
278
    {
279
279
        ZONE_CONTAINER* zone = Pcb->GetArea( ii );
280
280
 
281
 
        if( aPrintMaskLayer & GetLayerMask( zone->GetLayer() ) )
 
281
        if( aPrintMask[zone->GetLayer()] )
282
282
            zone->DrawFilledArea( m_canvas, aDC, drawmode );
283
283
    }
284
284
 
285
285
    // Draw footprints, this is done at last in order to print the pad holes in
286
 
    // white (or g_DrawBgColor) after the tracks and zones
287
 
    Module = (MODULE*) Pcb->m_Modules;
 
286
    // white after the tracks and zones
288
287
    int tmp = D_PAD::m_PadSketchModePenSize;
289
288
    D_PAD::m_PadSketchModePenSize = defaultPenSize;
290
289
 
291
 
    for( ; Module != NULL; Module = Module->Next() )
 
290
    for( MODULE* module = (MODULE*) Pcb->m_Modules; module;  module = module->Next() )
292
291
    {
293
 
        Print_Module( m_canvas, aDC, Module, drawmode, aPrintMaskLayer, drillShapeOpt );
 
292
        Print_Module( m_canvas, aDC, module, drawmode, aPrintMask, drillShapeOpt );
294
293
    }
295
294
 
296
295
    D_PAD::m_PadSketchModePenSize = tmp;
299
298
     * vias */
300
299
    if( drillShapeOpt != PRINT_PARAMETERS::NO_DRILL_SHAPE )
301
300
    {
302
 
        TRACK * track = Pcb->m_Track;
303
 
        EDA_COLOR_T color = g_DrawBgColor;
 
301
        TRACK*      track = Pcb->m_Track;
 
302
        EDA_COLOR_T color = WHITE;
 
303
 
304
304
        bool blackpenstate = GetGRForceBlackPenState();
 
305
 
305
306
        GRForceBlackPen( false );
306
307
        GRSetDrawMode( aDC, GR_COPY );
307
308
 
308
 
        for( ; track != NULL; track = track->Next() )
 
309
        for( ; track; track = track->Next() )
309
310
        {
310
 
            if( !( aPrintMaskLayer & track->GetLayerMask() ) )
 
311
            if( !( aPrintMask & track->GetLayerSet() ).any() )
311
312
                continue;
312
313
 
313
314
            if( track->Type() == PCB_VIA_T ) // VIA encountered.
314
315
            {
315
316
                int diameter;
 
317
                const VIA *via = static_cast<const VIA*>( track );
316
318
 
317
319
                if( drillShapeOpt == PRINT_PARAMETERS::SMALL_DRILL_SHAPE )
318
 
                    diameter = std::min( SMALL_DRILL, track->GetDrillValue() );
 
320
                    diameter = std::min( SMALL_DRILL, via->GetDrillValue() );
319
321
                else
320
 
                    diameter = track->GetDrillValue();
 
322
                    diameter = via->GetDrillValue();
321
323
 
322
324
                GRFilledCircle( m_canvas->GetClipBox(), aDC,
323
325
                                track->GetStart().x, track->GetStart().y,
339
341
    m_DisplayPadNum  = DisplayOpt.DisplayPadNum;
340
342
    m_DisplayModEdge = DisplayOpt.DisplayModEdge;
341
343
    m_DisplayModText = DisplayOpt.DisplayModText;
342
 
    GetBoard()->SetElementVisibility(NO_CONNECTS_VISIBLE, nctmp);
343
 
    GetBoard()->SetElementVisibility(ANCHOR_VISIBLE, anchorsTmp);
 
344
 
 
345
    GetBoard()->SetElementVisibility( NO_CONNECTS_VISIBLE, nctmp );
 
346
    GetBoard()->SetElementVisibility( ANCHOR_VISIBLE, anchorsTmp );
344
347
}
345
348
 
346
349
 
347
350
static void Print_Module( EDA_DRAW_PANEL* aPanel, wxDC* aDC, MODULE* aModule,
348
 
                          GR_DRAWMODE aDraw_mode, LAYER_MSK aMasklayer,
 
351
                          GR_DRAWMODE aDraw_mode, LSET aMask,
349
352
                          PRINT_PARAMETERS::DrillShapeOptT aDrillShapeOpt )
350
353
{
351
354
    // Print pads
352
355
    for( D_PAD* pad = aModule->Pads();  pad;  pad = pad->Next() )
353
356
    {
354
 
        if( !(pad->GetLayerMask() & aMasklayer ) )
 
357
        if( !( pad->GetLayerSet() & aMask ).any() )
355
358
            continue;
356
359
 
357
360
        // Manage hole according to the print drill option
382
385
    }
383
386
 
384
387
    // Print footprint graphic shapes
385
 
    LAYER_MSK mlayer = GetLayerMask( aModule->GetLayer() );
386
 
 
387
 
    if( aModule->GetLayer() == LAYER_N_BACK )
388
 
        mlayer = SILKSCREEN_LAYER_BACK;
389
 
    else if( aModule->GetLayer() == LAYER_N_FRONT )
390
 
        mlayer = SILKSCREEN_LAYER_FRONT;
391
 
 
392
 
    if( mlayer & aMasklayer )
 
388
    LSET mlayer( aModule->GetLayer() );
 
389
 
 
390
    if( aModule->GetLayer() == B_Cu )
 
391
        mlayer = LSET( B_SilkS );
 
392
    else if( aModule->GetLayer() == F_Cu )
 
393
        mlayer = LSET( F_SilkS );
 
394
 
 
395
    if( ( mlayer & aMask ).any() )
393
396
    {
394
397
        if( aModule->Reference().IsVisible() )
395
398
            aModule->Reference().Draw( aPanel, aDC, aDraw_mode );
403
406
        switch( item->Type() )
404
407
        {
405
408
        case PCB_MODULE_TEXT_T:
406
 
            if( ( mlayer & aMasklayer ) == 0 )
 
409
            if( !( mlayer & aMask ).any() )
407
410
                break;
408
411
 
409
412
            TEXTE_MODULE* textMod;
415
418
            {
416
419
                EDGE_MODULE* edge = (EDGE_MODULE*) item;
417
420
 
418
 
                if( ( GetLayerMask( edge->GetLayer() ) & aMasklayer ) == 0 )
 
421
                if( !aMask[edge->GetLayer()] )
419
422
                    break;
420
423
 
421
424
                edge->Draw( aPanel, aDC, aDraw_mode );