kicad/gerbview/tracepcb.cpp

163 lines
5.0 KiB
C++
Raw Normal View History

2007-08-15 02:43:57 +00:00
/*****************************************/
/* Routines generales d'affichage du PCB */
/*****************************************/
/* fichier TRACEPCB.CPP */
/*
2007-08-15 02:43:57 +00:00
* Routines d'affichage grille, Boite de coordonnees, Curseurs, marqueurs ...
*/
#include "fctsys.h"
#include "common.h"
#include "gerbview.h"
#include "pcbplot.h"
#include "protos.h"
/* Externes */
/* Variables Locales */
/**********************************************************************************/
2007-08-15 02:43:57 +00:00
void WinEDA_DrawPanel::PrintPage( wxDC* DC, bool Print_Sheet_Ref, int printmasklayer )
/**********************************************************************************/
/* routine de trace du pcb, avec selection des couches */
{
2007-08-15 02:43:57 +00:00
DISPLAY_OPTIONS save_opt;
int DisplayPolygonsModeImg;
2007-08-15 02:43:57 +00:00
save_opt = DisplayOpt;
if( printmasklayer & ALL_CU_LAYERS )
DisplayOpt.DisplayPadFill = FILLED;
else
DisplayOpt.DisplayPadFill = SKETCH;
DisplayOpt.DisplayPadNum = 0;
DisplayOpt.DisplayPadNoConn = 0;
DisplayOpt.DisplayPadIsol = 0;
DisplayOpt.DisplayModEdge = FILLED;
DisplayOpt.DisplayModText = FILLED;
DisplayOpt.DisplayPcbTrackFill = FILLED;
DisplayOpt.DisplayTrackIsol = 0;
DisplayOpt.DisplayDrawItems = FILLED;
DisplayOpt.DisplayZones = 1;
DisplayPolygonsModeImg = g_DisplayPolygonsModeSketch;
g_DisplayPolygonsModeSketch = 0;
2007-08-15 02:43:57 +00:00
( (WinEDA_GerberFrame*) m_Parent )->Trace_Gerber( DC, GR_COPY, printmasklayer );
2007-08-15 02:43:57 +00:00
if( Print_Sheet_Ref )
m_Parent->TraceWorkSheet( DC, GetScreen(), 0 );
DisplayOpt = save_opt;
g_DisplayPolygonsModeSketch = DisplayPolygonsModeImg;
}
2007-08-15 02:43:57 +00:00
/*******************************************************************/
2007-08-15 02:43:57 +00:00
void WinEDA_GerberFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
/*******************************************************************/
2007-08-15 02:43:57 +00:00
/* Trace le PCB, et les elements complementaires ( axes, grille .. )
2007-08-15 02:43:57 +00:00
*/
{
PCB_SCREEN* screen = (PCB_SCREEN*)GetScreen();
2007-08-15 02:43:57 +00:00
if( !m_Pcb )
return;
ActiveScreen = screen;
GRSetDrawMode( DC, GR_COPY );
2007-08-15 02:43:57 +00:00
if( EraseBg )
DrawPanel->EraseScreen( DC );
2007-08-15 02:43:57 +00:00
DrawPanel->DrawBackGround( DC );
Trace_Gerber( DC, GR_OR, -1 );
2007-08-15 02:43:57 +00:00
TraceWorkSheet( DC, screen, 0 );
Affiche_Status_Box();
2007-08-15 02:43:57 +00:00
if( DrawPanel->ManageCurseur )
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
DrawPanel->Trace_Curseur( DC );
}
2007-08-15 02:43:57 +00:00
/***********************************************************************************/
void WinEDA_GerberFrame::Trace_Gerber( wxDC* DC, int draw_mode, int printmasklayer )
/***********************************************************************************/
/*
* Trace l'ensemble des elements du PCB sur l'ecran actif
* @param DC = device context to draw
* @param draw_mode = draw mode for the device context (GR_COPY, GR_OR, GR_XOR ..)
* @param printmasklayer = mask for allowed layer (=-1 to draw all layers)
*/
{
2007-08-15 02:43:57 +00:00
if( !m_Pcb )
return;
// Draw tracks and flashes
Draw_Track_Buffer( DrawPanel, DC, m_Pcb, draw_mode, printmasklayer );
2007-08-15 02:43:57 +00:00
// Draw filled polygons
#define NBMAX 2000
TRACK* track;
int nbpoints = 0;
int nbpointsmax = NBMAX;
int* coord = (int*) malloc( nbpointsmax * sizeof(int) * 2 );
int* ptcoord = coord;
track = m_Pcb->m_Zone;
for( ; track != NULL; track = track->Next() )
{
if ( printmasklayer != -1 )
if ( (track->ReturnMaskLayer() & printmasklayer) == 0 ) continue;
if( track->GetNet() == 0 ) // StartPoint
2007-08-15 02:43:57 +00:00
{
if( nbpoints ) // we have found a new polygon: Draw the old polygon
2007-08-15 02:43:57 +00:00
{
2007-08-23 04:28:46 +00:00
int Color = g_DesignSettings.m_LayerColor[track->GetLayer()];
int filled = (g_DisplayPolygonsModeSketch == 0) ? 1 : 0;
2007-08-15 02:43:57 +00:00
GRClosedPoly( &DrawPanel->m_ClipBox, DC, nbpoints, coord,
filled, Color, Color );
2007-08-15 02:43:57 +00:00
}
nbpoints = 2;
ptcoord = coord;
*ptcoord = track->m_Start.x; ptcoord++;
*ptcoord = track->m_Start.y; ptcoord++;
*ptcoord = track->m_End.x; ptcoord++;
*ptcoord = track->m_End.y; ptcoord++;
}
else
{
if( nbpoints >= nbpointsmax )
{
nbpointsmax *= 2;
coord = (int*) realloc( coord, nbpointsmax * sizeof(int) * 2 );
ptcoord = coord + nbpointsmax;
}
nbpoints++;
*ptcoord = track->m_End.x; ptcoord++;
*ptcoord = track->m_End.y; ptcoord++;
}
if( track->Next() == NULL ) // Last point
{
2007-08-23 04:28:46 +00:00
int Color = g_DesignSettings.m_LayerColor[track->GetLayer()];
int filled = (g_DisplayPolygonsModeSketch == 0) ? 1 : 0;
2007-08-15 02:43:57 +00:00
GRClosedPoly( &DrawPanel->m_ClipBox, DC, nbpoints, coord,
filled, Color, Color );
2007-08-15 02:43:57 +00:00
}
}
free( coord );
if( DisplayOpt.DisplayPadNum )
Affiche_DCodes_Pistes( DrawPanel, DC, m_Pcb, GR_COPY );
GetScreen()->ClrRefreshReq();
}