kicad/pcbnew/lay2plot.cpp

231 lines
7.4 KiB
C++
Raw Normal View History

2007-08-23 04:28:46 +00:00
/**********************************************/
/* Routine de selection de couches pour trace */
/**********************************************/
#include "fctsys.h"
#include "gr_basic.h"
#include "common.h"
#include "pcbnew.h"
#include "pcbplot.h"
#include "protos.h"
/* Variables locales : */
/* Routines Locales */
2007-08-23 04:28:46 +00:00
static void Plot_Module( WinEDA_DrawPanel* panel, wxDC* DC, MODULE* Module,
int draw_mode, int masklayer );
/************************************************************************************************************/
void WinEDA_DrawPanel::PrintPage( wxDC* DC, bool Print_Sheet_Ref, int printmasklayer, bool aPrintMirrorMode )
/************************************************************************************************************/
2007-08-23 04:28:46 +00:00
/* Used to print the board.
2007-08-23 04:28:46 +00:00
* Draw the board, but only layers allowed by printmasklayer
* ( printmasklayer is a 32 bits mask: bit n = 1 -> layer n is printed)
*/
{
2007-08-23 04:28:46 +00:00
MODULE* Module;
int drawmode = GR_COPY;
DISPLAY_OPTIONS save_opt;
TRACK* pt_piste;
WinEDA_BasePcbFrame* frame = (WinEDA_BasePcbFrame*) m_Parent;
BOARD* Pcb = frame->m_Pcb;
save_opt = DisplayOpt;
if( printmasklayer & ALL_CU_LAYERS )
DisplayOpt.DisplayPadFill = FILLED;
else
DisplayOpt.DisplayPadFill = SKETCH;
frame->m_DisplayPadFill = DisplayOpt.DisplayPadFill;
frame->m_DisplayPadNum = DisplayOpt.DisplayPadNum = FALSE;
DisplayOpt.DisplayPadNoConn = FALSE;
DisplayOpt.DisplayPadIsol = FALSE;
DisplayOpt.DisplayModEdge = FILLED;
DisplayOpt.DisplayModText = FILLED;
frame->m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill = FILLED;
DisplayOpt.DisplayTrackIsol = FALSE;
DisplayOpt.DisplayDrawItems = FILLED;
DisplayOpt.DisplayZones = TRUE;
m_PrintIsMirrored = aPrintMirrorMode;
2007-08-23 04:28:46 +00:00
/* Draw the pcb graphic items (texts, ...) */
2008-04-01 06:32:48 +00:00
for( BOARD_ITEM* item = Pcb->m_Drawings; item; item = item->Next() )
2007-08-23 04:28:46 +00:00
{
2008-04-01 06:32:48 +00:00
switch( item->Type() )
2007-08-23 04:28:46 +00:00
{
case TYPEDRAWSEGMENT:
case TYPECOTATION:
case TYPETEXTE:
case TYPEMIRE:
2008-04-01 06:32:48 +00:00
if( ((1<<item->GetLayer()) & printmasklayer) == 0 )
2007-08-23 04:28:46 +00:00
break;
2008-04-01 06:32:48 +00:00
item->Draw( this, DC, drawmode );
2007-08-23 04:28:46 +00:00
break;
2008-04-01 06:32:48 +00:00
case TYPEMARKER: /* Trace des marqueurs */
2007-08-23 04:28:46 +00:00
default:
break;
}
}
/* Draw the tracks */
pt_piste = Pcb->m_Track;
for( ; pt_piste != NULL; pt_piste = (TRACK*) pt_piste->Pnext )
{
if( ( printmasklayer & pt_piste->ReturnMaskLayer() ) == 0 )
continue;
2007-09-01 12:00:30 +00:00
if( pt_piste->Type() == TYPEVIA ) /* VIA rencontree */
2007-08-23 04:28:46 +00:00
{
int rayon = pt_piste->m_Width >> 1;
int color = g_DesignSettings.m_ViaColor[pt_piste->m_Shape];
GRSetDrawMode( DC, drawmode );
GRFilledCircle( &m_ClipBox, DC, pt_piste->m_Start.x, pt_piste->m_Start.y,
rayon, 0, color, color );
}
else
pt_piste->Draw( this, DC, drawmode );
}
pt_piste = Pcb->m_Zone;
for( ; pt_piste != NULL; pt_piste = (TRACK*) pt_piste->Pnext )
{
if( ( printmasklayer & pt_piste->ReturnMaskLayer() ) == 0 )
continue;
pt_piste->Draw( this, DC, drawmode );
}
// Draw footprints, this is done at last in order to print the pad holes in while
// after the tracks
Module = (MODULE*) Pcb->m_Modules;
for( ; Module != NULL; Module = (MODULE*) Module->Pnext )
{
Plot_Module( this, DC, Module, drawmode, printmasklayer );
}
/* draw the via holes in white color*/
2007-08-23 04:28:46 +00:00
pt_piste = Pcb->m_Track;
int rayon = g_DesignSettings.m_ViaDrill / 2;
int color = WHITE;
bool blackpenstate = GetGRForceBlackPenState( );
GRForceBlackPen( FALSE );
2007-08-23 04:28:46 +00:00
for( ; pt_piste != NULL; pt_piste = (TRACK*) pt_piste->Pnext )
{
if( ( printmasklayer & pt_piste->ReturnMaskLayer() ) == 0 )
continue;
2007-09-01 12:00:30 +00:00
if( pt_piste->Type() == TYPEVIA ) /* VIA rencontree */
2007-08-23 04:28:46 +00:00
{
GRSetDrawMode( DC, drawmode );
GRFilledCircle( &m_ClipBox, DC, pt_piste->m_Start.x, pt_piste->m_Start.y,
rayon, 0, color, color );
}
}
GRForceBlackPen( blackpenstate );
2007-08-23 04:28:46 +00:00
/* Draw areas (i.e. zones) */
for( int ii = 0; ii < Pcb->GetAreaCount(); ii++ )
{
ZONE_CONTAINER* zone = Pcb->GetArea(ii);
if( ( printmasklayer & (1 << zone->GetLayer()) ) == 0 )
continue;
zone->DrawFilledArea( this, DC, drawmode );
}
2007-08-23 04:28:46 +00:00
if( Print_Sheet_Ref )
m_Parent->TraceWorkSheet( DC, ActiveScreen, 0 );
m_PrintIsMirrored = false;
2007-08-23 04:28:46 +00:00
DisplayOpt = save_opt;
frame->m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill;
frame->m_DisplayPadFill = DisplayOpt.DisplayPadFill;
frame->m_DisplayPadNum = DisplayOpt.DisplayPadNum;
}
/***********************************************************/
2007-08-23 04:28:46 +00:00
static void Plot_Module( WinEDA_DrawPanel* panel, wxDC* DC,
MODULE* Module, int draw_mode, int masklayer )
/***********************************************************/
{
2007-08-23 04:28:46 +00:00
D_PAD* pt_pad;
EDA_BaseStruct* PtStruct;
TEXTE_MODULE* TextMod;
int mlayer;
/* Draw pads */
pt_pad = Module->m_Pads;
for( ; pt_pad != NULL; pt_pad = (D_PAD*) pt_pad->Pnext )
{
if( (pt_pad->m_Masque_Layer & masklayer ) == 0 )
continue;
2008-04-03 18:03:42 +00:00
// Usually we draw pads in sketch mode on non copper layers:
if ( (masklayer & ALL_CU_LAYERS) == 0 )
{
int tmp_fill = ((WinEDA_BasePcbFrame*)panel->m_Parent)->m_DisplayPadFill;
// Switch in sketch mode
((WinEDA_BasePcbFrame*)panel->m_Parent)->m_DisplayPadFill = 0;
pt_pad->Draw( panel, DC, draw_mode );
((WinEDA_BasePcbFrame*)panel->m_Parent)->m_DisplayPadFill = tmp_fill;
}
else // on copper layer, draw pads according to current options
2008-04-03 18:03:42 +00:00
pt_pad->Draw( panel, DC, draw_mode );
2007-08-23 04:28:46 +00:00
}
/* draw footprint graphic shapes */
PtStruct = Module->m_Drawings;
mlayer = g_TabOneLayerMask[Module->GetLayer()];
if( Module->GetLayer() == COPPER_LAYER_N )
2007-08-23 04:28:46 +00:00
mlayer = SILKSCREEN_LAYER_CU;
else if( Module->GetLayer() == CMP_N )
mlayer = SILKSCREEN_LAYER_CMP;
2008-04-01 05:21:50 +00:00
2007-08-23 04:28:46 +00:00
if( mlayer & masklayer )
{
/* Analyse des autorisations de trace pour les textes VALEUR et REF */
bool trace_val, trace_ref;
trace_val = trace_ref = TRUE; // les 2 autorisations de tracer sont donnees
if( Module->m_Reference->m_NoShow )
trace_ref = FALSE;
if( Module->m_Value->m_NoShow )
trace_val = FALSE;
if( trace_ref )
2008-04-01 05:21:50 +00:00
Module->m_Reference->Draw( panel, DC, draw_mode );
2007-08-23 04:28:46 +00:00
if( trace_val )
2008-04-01 05:21:50 +00:00
Module->m_Value->Draw( panel, DC, draw_mode );
2007-08-23 04:28:46 +00:00
}
for( ; PtStruct != NULL; PtStruct = PtStruct->Next() )
{
2007-09-01 12:00:30 +00:00
switch( PtStruct->Type() )
2007-08-23 04:28:46 +00:00
{
case TYPETEXTEMODULE:
if( (mlayer & masklayer ) == 0 )
break;
TextMod = (TEXTE_MODULE*) PtStruct;
2008-04-01 05:21:50 +00:00
TextMod->Draw( panel, DC, draw_mode );
2007-08-23 04:28:46 +00:00
break;
case TYPEEDGEMODULE:
{
EDGE_MODULE* edge = (EDGE_MODULE*) PtStruct;
if( (g_TabOneLayerMask[edge->GetLayer()] & masklayer ) == 0 )
break;
2008-04-01 05:21:50 +00:00
edge->Draw( panel, DC, draw_mode );
2007-08-23 04:28:46 +00:00
break;
}
default:
break;
}
}
}