2009-01-11 19:12:18 +00:00
|
|
|
/************************************************************/
|
|
|
|
/* print_board_functions.cpp: some functions to plot boards */
|
|
|
|
/************************************************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "gr_basic.h"
|
|
|
|
#include "common.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "class_drawpanel.h"
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "pcbnew.h"
|
|
|
|
#include "pcbplot.h"
|
|
|
|
#include "protos.h"
|
|
|
|
|
2008-12-17 06:51:39 +00:00
|
|
|
/* Local functions */
|
|
|
|
static void Print_Module( WinEDA_DrawPanel* panel, wxDC* DC, MODULE* Module,
|
2007-08-23 04:28:46 +00:00
|
|
|
int draw_mode, int masklayer );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
2008-11-02 19:52:57 +00:00
|
|
|
/************************************************************************************************************/
|
2009-01-13 19:18:54 +00:00
|
|
|
void WinEDA_DrawPanel::PrintPage( wxDC* aDC, bool aPrint_Sheet_Ref, int aPrintMaskLayer, bool aPrintMirrorMode )
|
2008-11-02 19:52:57 +00:00
|
|
|
/************************************************************************************************************/
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2009-01-13 19:18:54 +00:00
|
|
|
/** Function PrintPage
|
|
|
|
* Used to print the board (on printer, or when creating SVF files).
|
|
|
|
* Print the board, but only layers allowed by aPrintMaskLayer
|
2007-08-23 04:28:46 +00:00
|
|
|
* ( printmasklayer is a 32 bits mask: bit n = 1 -> layer n is printed)
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
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;
|
2009-01-05 05:21:35 +00:00
|
|
|
BOARD* Pcb = frame->GetBoard();
|
2007-08-23 04:28:46 +00:00
|
|
|
|
|
|
|
save_opt = DisplayOpt;
|
2009-01-13 19:18:54 +00:00
|
|
|
if( aPrintMaskLayer & ALL_CU_LAYERS )
|
2009-09-29 04:44:35 +00:00
|
|
|
{
|
2009-05-21 17:42:42 +00:00
|
|
|
DisplayOpt.DisplayPadFill = true;
|
2009-09-29 04:44:35 +00:00
|
|
|
DisplayOpt.DisplayViaFill = true;
|
|
|
|
}
|
2007-08-23 04:28:46 +00:00
|
|
|
else
|
2009-09-29 04:44:35 +00:00
|
|
|
{
|
2009-05-21 17:42:42 +00:00
|
|
|
DisplayOpt.DisplayPadFill = false;
|
2009-09-29 04:44:35 +00:00
|
|
|
DisplayOpt.DisplayViaFill = false;
|
|
|
|
}
|
|
|
|
|
2007-08-23 04:28:46 +00:00
|
|
|
frame->m_DisplayPadFill = DisplayOpt.DisplayPadFill;
|
2009-09-29 04:44:35 +00:00
|
|
|
frame->m_DisplayViaFill = DisplayOpt.DisplayViaFill;
|
2008-12-17 06:51:39 +00:00
|
|
|
frame->m_DisplayPadNum = DisplayOpt.DisplayPadNum = false;
|
|
|
|
DisplayOpt.DisplayPadNoConn = false;
|
|
|
|
DisplayOpt.DisplayPadIsol = false;
|
2007-08-23 04:28:46 +00:00
|
|
|
DisplayOpt.DisplayModEdge = FILLED;
|
|
|
|
DisplayOpt.DisplayModText = FILLED;
|
|
|
|
frame->m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill = FILLED;
|
2009-06-18 20:51:01 +00:00
|
|
|
DisplayOpt.ShowTrackClearanceMode = DO_NOT_SHOW_CLEARANCE;
|
2007-08-23 04:28:46 +00:00
|
|
|
DisplayOpt.DisplayDrawItems = FILLED;
|
2008-12-12 21:30:07 +00:00
|
|
|
DisplayOpt.DisplayZonesMode = 0;
|
2009-06-18 20:51:01 +00:00
|
|
|
DisplayOpt.DisplayNetNamesMode = 0;
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2008-11-02 19:52:57 +00:00
|
|
|
m_PrintIsMirrored = aPrintMirrorMode;
|
2009-06-18 20:51:01 +00:00
|
|
|
|
2009-03-18 16:46:07 +00:00
|
|
|
// The OR mode is used in color mode, but be aware the backgroud *must be BLACK.
|
|
|
|
// In print page dialog, we first plrint in BLACK, and after reprint in color,
|
|
|
|
// on the black "local" backgroud, in OR mode
|
|
|
|
// the black print is not made before, only a white page is printed
|
|
|
|
if( GetGRForceBlackPenState( ) == false )
|
2009-01-15 14:32:29 +00:00
|
|
|
drawmode = GR_OR;
|
|
|
|
|
2008-11-02 19:52:57 +00:00
|
|
|
|
2008-12-17 06:51:39 +00:00
|
|
|
/* Print the pcb graphic items (texts, ...) */
|
2009-01-15 14:32:29 +00:00
|
|
|
GRSetDrawMode( aDC, drawmode );
|
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
|
|
|
{
|
2008-12-04 04:28:11 +00:00
|
|
|
case TYPE_DRAWSEGMENT:
|
|
|
|
case TYPE_COTATION:
|
|
|
|
case TYPE_TEXTE:
|
|
|
|
case TYPE_MIRE:
|
2009-01-13 19:18:54 +00:00
|
|
|
if( ((1<<item->GetLayer()) & aPrintMaskLayer) == 0 )
|
2007-08-23 04:28:46 +00:00
|
|
|
break;
|
|
|
|
|
2009-01-13 19:18:54 +00:00
|
|
|
item->Draw( this, aDC, drawmode );
|
2007-08-23 04:28:46 +00:00
|
|
|
break;
|
|
|
|
|
2009-08-01 19:26:05 +00:00
|
|
|
case TYPE_MARKER_PCB: /* Trace des marqueurs */
|
2007-08-23 04:28:46 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-17 06:51:39 +00:00
|
|
|
/* Print tracks */
|
2007-08-23 04:28:46 +00:00
|
|
|
pt_piste = Pcb->m_Track;
|
2008-11-24 06:53:43 +00:00
|
|
|
for( ; pt_piste != NULL; pt_piste = pt_piste->Next() )
|
2007-08-23 04:28:46 +00:00
|
|
|
{
|
2009-01-13 19:18:54 +00:00
|
|
|
if( ( aPrintMaskLayer & pt_piste->ReturnMaskLayer() ) == 0 )
|
2007-08-23 04:28:46 +00:00
|
|
|
continue;
|
2008-12-04 04:28:11 +00:00
|
|
|
if( pt_piste->Type() == TYPE_VIA ) /* 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];
|
2009-01-13 19:18:54 +00:00
|
|
|
GRSetDrawMode( aDC, drawmode );
|
|
|
|
GRFilledCircle( &m_ClipBox, aDC, pt_piste->m_Start.x, pt_piste->m_Start.y,
|
2007-08-23 04:28:46 +00:00
|
|
|
rayon, 0, color, color );
|
|
|
|
}
|
|
|
|
else
|
2009-01-13 19:18:54 +00:00
|
|
|
pt_piste->Draw( this, aDC, drawmode );
|
2007-08-23 04:28:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pt_piste = Pcb->m_Zone;
|
2008-11-24 06:53:43 +00:00
|
|
|
for( ; pt_piste != NULL; pt_piste = pt_piste->Next() )
|
2007-08-23 04:28:46 +00:00
|
|
|
{
|
2009-01-13 19:18:54 +00:00
|
|
|
if( ( aPrintMaskLayer & pt_piste->ReturnMaskLayer() ) == 0 )
|
2007-08-23 04:28:46 +00:00
|
|
|
continue;
|
2009-01-13 19:18:54 +00:00
|
|
|
pt_piste->Draw( this, aDC, drawmode );
|
2007-08-23 04:28:46 +00:00
|
|
|
}
|
|
|
|
|
2009-01-15 14:32:29 +00:00
|
|
|
|
|
|
|
/* Draw filled areas (i.e. zones) */
|
|
|
|
for( int ii = 0; ii < Pcb->GetAreaCount(); ii++ )
|
|
|
|
{
|
|
|
|
ZONE_CONTAINER* zone = Pcb->GetArea(ii);
|
|
|
|
if( ( aPrintMaskLayer & (1 << zone->GetLayer()) ) == 0 )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
zone->DrawFilledArea( this, aDC, drawmode );
|
|
|
|
}
|
|
|
|
|
2009-08-13 06:18:06 +00:00
|
|
|
// Draw footprints, this is done at last in order to print the pad holes in white (or g_DrawBgColor)
|
|
|
|
// after the tracks and zones
|
|
|
|
Module = (MODULE*) Pcb->m_Modules;
|
|
|
|
for( ; Module != NULL; Module = Module->Next() )
|
|
|
|
{
|
|
|
|
Print_Module( this, aDC, Module, drawmode, aPrintMaskLayer );
|
|
|
|
}
|
|
|
|
|
2009-01-15 14:32:29 +00:00
|
|
|
/* Print via holes in bg color: Not sure it is good for buried or blind vias */
|
2007-08-23 04:28:46 +00:00
|
|
|
pt_piste = Pcb->m_Track;
|
2009-01-15 14:32:29 +00:00
|
|
|
int color = g_DrawBgColor;
|
2008-08-09 08:05:42 +00:00
|
|
|
bool blackpenstate = GetGRForceBlackPenState( );
|
2008-12-17 06:51:39 +00:00
|
|
|
GRForceBlackPen( false );
|
2009-01-15 14:32:29 +00:00
|
|
|
GRSetDrawMode( aDC, GR_COPY );
|
2008-11-24 06:53:43 +00:00
|
|
|
for( ; pt_piste != NULL; pt_piste = pt_piste->Next() )
|
2007-08-23 04:28:46 +00:00
|
|
|
{
|
2009-01-13 19:18:54 +00:00
|
|
|
if( ( aPrintMaskLayer & pt_piste->ReturnMaskLayer() ) == 0 )
|
2007-08-23 04:28:46 +00:00
|
|
|
continue;
|
2008-12-04 04:28:11 +00:00
|
|
|
if( pt_piste->Type() == TYPE_VIA ) /* VIA rencontree */
|
2007-08-23 04:28:46 +00:00
|
|
|
{
|
2009-01-15 14:32:29 +00:00
|
|
|
int rayon = g_DesignSettings.m_ViaDrill / 2;
|
2009-01-13 19:18:54 +00:00
|
|
|
GRFilledCircle( &m_ClipBox, aDC, pt_piste->m_Start.x, pt_piste->m_Start.y,
|
2007-08-23 04:28:46 +00:00
|
|
|
rayon, 0, color, color );
|
|
|
|
}
|
|
|
|
}
|
2008-08-09 08:05:42 +00:00
|
|
|
GRForceBlackPen( blackpenstate );
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2009-01-13 19:18:54 +00:00
|
|
|
if( aPrint_Sheet_Ref )
|
2009-06-28 16:50:42 +00:00
|
|
|
m_Parent->TraceWorkSheet( aDC, GetScreen(), 10 );
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2008-11-02 19:52:57 +00:00
|
|
|
m_PrintIsMirrored = false;
|
|
|
|
|
2007-08-23 04:28:46 +00:00
|
|
|
DisplayOpt = save_opt;
|
|
|
|
frame->m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill;
|
|
|
|
frame->m_DisplayPadFill = DisplayOpt.DisplayPadFill;
|
2009-09-29 04:44:35 +00:00
|
|
|
frame->m_DisplayViaFill = DisplayOpt.DisplayViaFill;
|
2007-08-23 04:28:46 +00:00
|
|
|
frame->m_DisplayPadNum = DisplayOpt.DisplayPadNum;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************/
|
2008-12-17 06:51:39 +00:00
|
|
|
static void Print_Module( WinEDA_DrawPanel* panel, wxDC* DC,
|
2007-08-23 04:28:46 +00:00
|
|
|
MODULE* Module, int draw_mode, int masklayer )
|
2007-06-05 12:10:51 +00:00
|
|
|
/***********************************************************/
|
|
|
|
{
|
2007-08-23 04:28:46 +00:00
|
|
|
D_PAD* pt_pad;
|
|
|
|
EDA_BaseStruct* PtStruct;
|
|
|
|
TEXTE_MODULE* TextMod;
|
|
|
|
int mlayer;
|
|
|
|
|
2008-12-17 06:51:39 +00:00
|
|
|
/* Print pads */
|
2007-08-23 04:28:46 +00:00
|
|
|
pt_pad = Module->m_Pads;
|
2008-11-24 06:53:43 +00:00
|
|
|
for( ; pt_pad != NULL; pt_pad = pt_pad->Next() )
|
2007-08-23 04:28:46 +00:00
|
|
|
{
|
|
|
|
if( (pt_pad->m_Masque_Layer & masklayer ) == 0 )
|
|
|
|
continue;
|
2008-11-24 06:53:43 +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
|
|
|
|
pt_pad->Draw( panel, DC, draw_mode );
|
2007-08-23 04:28:46 +00:00
|
|
|
}
|
|
|
|
|
2008-12-17 06:51:39 +00:00
|
|
|
/* Print footprint graphic shapes */
|
2007-08-23 04:28:46 +00:00
|
|
|
PtStruct = Module->m_Drawings;
|
|
|
|
mlayer = g_TabOneLayerMask[Module->GetLayer()];
|
2007-10-07 18:24:15 +00:00
|
|
|
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 )
|
|
|
|
{
|
2008-12-17 06:51:39 +00:00
|
|
|
if( ! Module->m_Reference->m_NoShow )
|
2008-04-01 05:21:50 +00:00
|
|
|
Module->m_Reference->Draw( panel, DC, draw_mode );
|
2008-12-17 06:51:39 +00:00
|
|
|
if( ! Module->m_Value->m_NoShow )
|
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
|
|
|
{
|
2008-12-04 04:28:11 +00:00
|
|
|
case TYPE_TEXTE_MODULE:
|
2007-08-23 04:28:46 +00:00
|
|
|
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;
|
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
case TYPE_EDGE_MODULE:
|
2007-08-23 04:28:46 +00:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|