2009-11-20 14:55:20 +00:00
|
|
|
/****************/
|
|
|
|
/* tracepcb.cpp */
|
|
|
|
/****************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
/*
|
2010-01-25 14:01:46 +00:00
|
|
|
* Functions to redraw the current board ...
|
2007-08-15 02:43:03 +00:00
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-12-30 03:30:34 +00:00
|
|
|
#include <vector>
|
2007-12-29 19:15:58 +00:00
|
|
|
|
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"
|
2009-07-30 11:04:07 +00:00
|
|
|
#include "wxPcbStruct.h"
|
2010-08-10 18:34:26 +00:00
|
|
|
#include "module_editor_frame.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "pcbplot.h"
|
|
|
|
#include "protos.h"
|
2010-09-21 23:46:02 +00:00
|
|
|
#include <wx/overlay.h>
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2010-02-24 15:33:03 +00:00
|
|
|
extern int g_DrawDefaultLineThickness; // Default line thickness, used to draw Frame references
|
|
|
|
|
|
|
|
|
2010-01-28 13:10:46 +00:00
|
|
|
// Local functions:
|
|
|
|
/* Trace the pads of a module in sketch mode.
|
2010-01-31 20:01:46 +00:00
|
|
|
* Used to display pads when when the module visibility is set to not visible
|
2010-01-28 13:10:46 +00:00
|
|
|
* and we want to see pad through.
|
|
|
|
* The pads must appear on the layers selected in MasqueLayer
|
|
|
|
*/
|
|
|
|
static void Trace_Pads_Only( WinEDA_DrawPanel* panel, wxDC* DC, MODULE* Module,
|
|
|
|
int ox, int oy, int MasqueLayer, int draw_mode );
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-10-30 20:40:08 +00:00
|
|
|
/* Draw the footprint editor BOARD, and others elements : axis, grid ..
|
2007-08-15 02:43:03 +00:00
|
|
|
*/
|
2009-11-20 14:55:20 +00:00
|
|
|
void WinEDA_ModuleEditFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-04-01 05:21:50 +00:00
|
|
|
PCB_SCREEN* screen = (PCB_SCREEN*)GetScreen();
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-01-05 05:21:35 +00:00
|
|
|
if( !GetBoard() || !screen )
|
2007-08-15 02:43:03 +00:00
|
|
|
return;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-15 02:43:03 +00:00
|
|
|
ActiveScreen = screen;
|
|
|
|
GRSetDrawMode( DC, GR_COPY );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-15 02:43:03 +00:00
|
|
|
DrawPanel->DrawBackGround( DC );
|
|
|
|
TraceWorkSheet( DC, screen, 0 );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-02-25 16:35:47 +00:00
|
|
|
/* Redraw the footprints */
|
2009-01-05 05:21:35 +00:00
|
|
|
for( MODULE* module = GetBoard()->m_Modules; module; module = module->Next() )
|
2007-08-15 02:43:03 +00:00
|
|
|
{
|
2008-11-24 06:53:43 +00:00
|
|
|
module->Draw( DrawPanel, DC, GR_OR );
|
2007-08-15 02:43:03 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2010-10-09 08:08:29 +00:00
|
|
|
#ifdef USE_WX_OVERLAY
|
2010-11-03 21:19:46 +00:00
|
|
|
if(IsShown())
|
|
|
|
{
|
|
|
|
DrawPanel->m_overlay.Reset();
|
|
|
|
wxDCOverlay overlaydc( DrawPanel->m_overlay, DC );
|
|
|
|
overlaydc.Clear();
|
|
|
|
}
|
2010-09-21 23:46:02 +00:00
|
|
|
#endif
|
|
|
|
|
2010-01-22 18:13:43 +00:00
|
|
|
screen->ClrRefreshReq();
|
|
|
|
|
2007-08-15 02:43:03 +00:00
|
|
|
if( DrawPanel->ManageCurseur )
|
|
|
|
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-10-30 20:40:08 +00:00
|
|
|
/* Redraw the cursor */
|
2010-01-22 18:13:43 +00:00
|
|
|
DrawPanel->DrawCursor( DC );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-15 02:43:03 +00:00
|
|
|
|
2007-10-30 20:40:08 +00:00
|
|
|
/* Draw the BOARD, and others elements : axis, grid ..
|
2007-08-15 02:43:03 +00:00
|
|
|
*/
|
2009-11-20 14:55:20 +00:00
|
|
|
void WinEDA_PcbFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-05-01 06:21:07 +00:00
|
|
|
PCB_SCREEN* screen = GetScreen();
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-01-05 05:21:35 +00:00
|
|
|
if( !GetBoard() || !screen )
|
2007-08-15 02:43:03 +00:00
|
|
|
return;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-05-01 06:21:07 +00:00
|
|
|
ActiveScreen = screen;
|
2007-08-15 02:43:03 +00:00
|
|
|
GRSetDrawMode( DC, GR_COPY );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-15 02:43:03 +00:00
|
|
|
DrawPanel->DrawBackGround( DC );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2010-02-24 15:33:03 +00:00
|
|
|
TraceWorkSheet( DC, GetScreen(), g_DrawDefaultLineThickness );
|
2008-04-01 05:21:50 +00:00
|
|
|
|
2009-01-05 05:21:35 +00:00
|
|
|
GetBoard()->Draw( DrawPanel, DC, GR_OR );
|
2008-09-27 19:26:29 +00:00
|
|
|
|
|
|
|
DrawGeneralRatsnest( DC );
|
|
|
|
|
2010-10-09 08:08:29 +00:00
|
|
|
#ifdef USE_WX_OVERLAY
|
2010-11-03 21:19:46 +00:00
|
|
|
if(IsShown())
|
|
|
|
{
|
|
|
|
DrawPanel->m_overlay.Reset();
|
|
|
|
wxDCOverlay overlaydc( DrawPanel->m_overlay, DC );
|
|
|
|
overlaydc.Clear();
|
|
|
|
}
|
2010-09-21 23:46:02 +00:00
|
|
|
#endif
|
|
|
|
|
2008-09-27 19:26:29 +00:00
|
|
|
GetScreen()->ClrRefreshReq();
|
2008-05-01 06:21:07 +00:00
|
|
|
|
2008-04-01 05:21:50 +00:00
|
|
|
if( DrawPanel->ManageCurseur )
|
|
|
|
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
|
|
|
|
|
|
|
|
// Redraw the cursor
|
2010-01-22 18:13:43 +00:00
|
|
|
DrawPanel->DrawCursor( DC );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-15 02:43:03 +00:00
|
|
|
|
2009-11-20 14:55:20 +00:00
|
|
|
/* Redraw the BOARD items but not cursors, axis or grid */
|
2008-09-27 19:26:29 +00:00
|
|
|
void BOARD::Draw( WinEDA_DrawPanel* aPanel, wxDC* DC,
|
|
|
|
int aDrawMode, const wxPoint& offset )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-05-29 16:26:07 +00:00
|
|
|
/* The order of drawing is flexible on some systems and not on others. For
|
|
|
|
* OSes which use OR to draw, the order is not important except for the
|
2009-11-20 14:55:20 +00:00
|
|
|
* effect of the highlight and its relationship to markers. See comment
|
|
|
|
* below.
|
|
|
|
* This order independence comes from the fact that a binary OR operation is
|
2009-05-29 16:26:07 +00:00
|
|
|
* commutative in nature.
|
|
|
|
* However on the OSX, the OR operation is not used, and so this sequence
|
|
|
|
* below is chosen to give MODULEs the highest visible priority.
|
|
|
|
*/
|
2009-02-25 16:35:47 +00:00
|
|
|
|
2009-11-20 14:55:20 +00:00
|
|
|
/* Draw all tracks and zones. As long as dark colors are used for the
|
|
|
|
* tracks, Then the OR draw mode should show tracks underneath other
|
|
|
|
* tracks. But a white track will cover any other color since it has
|
|
|
|
* more bits to OR in.
|
2009-05-29 16:26:07 +00:00
|
|
|
*/
|
|
|
|
for( TRACK* track = m_Track; track; track = track->Next() )
|
|
|
|
{
|
|
|
|
track->Draw( aPanel, DC, aDrawMode );
|
|
|
|
}
|
2007-08-15 02:43:03 +00:00
|
|
|
|
2009-05-29 16:26:07 +00:00
|
|
|
for( SEGZONE* zone = m_Zone; zone; zone = zone->Next() )
|
|
|
|
{
|
|
|
|
zone->Draw( aPanel, DC, aDrawMode );
|
2007-08-15 02:43:03 +00:00
|
|
|
}
|
|
|
|
|
2008-04-01 05:21:50 +00:00
|
|
|
// Draw the graphic items
|
2008-09-27 19:26:29 +00:00
|
|
|
for( BOARD_ITEM* item = m_Drawings; item; item = item->Next() )
|
2007-08-15 02:43:03 +00:00
|
|
|
{
|
2008-04-01 05:21:50 +00:00
|
|
|
if( item->m_Flags & IS_MOVED )
|
2007-08-15 02:43:03 +00:00
|
|
|
continue;
|
|
|
|
|
2008-04-01 05:21:50 +00:00
|
|
|
switch( item->Type() )
|
2007-08-15 02:43:03 +00:00
|
|
|
{
|
2010-04-23 09:54:40 +00:00
|
|
|
case TYPE_DIMENSION:
|
2008-12-04 04:28:11 +00:00
|
|
|
case TYPE_TEXTE:
|
|
|
|
case TYPE_MIRE:
|
|
|
|
case TYPE_DRAWSEGMENT:
|
2008-09-27 19:26:29 +00:00
|
|
|
item->Draw( aPanel, DC, aDrawMode );
|
2007-08-15 02:43:03 +00:00
|
|
|
break;
|
|
|
|
|
2008-04-01 05:21:50 +00:00
|
|
|
default:
|
2007-08-15 02:43:03 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-10-08 12:36:27 +00:00
|
|
|
/* Draw areas (i.e. zones) */
|
|
|
|
for( int ii = 0; ii < GetAreaCount(); ii++ )
|
|
|
|
{
|
|
|
|
ZONE_CONTAINER* zone = GetArea(ii);
|
|
|
|
|
|
|
|
// Areas must be drawn here only if not moved or dragged,
|
|
|
|
// because these areas are drawn by ManageCursor() in a specific manner
|
|
|
|
if ( (zone->m_Flags & (IN_EDIT | IS_DRAGGED | IS_MOVED)) == 0 )
|
|
|
|
{
|
|
|
|
zone->Draw( aPanel, DC, aDrawMode );
|
|
|
|
zone->DrawFilledArea( aPanel, DC, aDrawMode );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-29 16:26:07 +00:00
|
|
|
for( MODULE* module = m_Modules; module; module = module->Next() )
|
|
|
|
{
|
|
|
|
bool display = true;
|
|
|
|
int layerMask = ALL_CU_LAYERS;
|
|
|
|
|
|
|
|
if( module->m_Flags & IS_MOVED )
|
|
|
|
continue;
|
|
|
|
|
2010-01-31 20:01:46 +00:00
|
|
|
if( !IsElementVisible( PCB_VISIBLE(MOD_FR_VISIBLE) ) )
|
2009-05-29 16:26:07 +00:00
|
|
|
{
|
2009-12-07 03:46:13 +00:00
|
|
|
if( module->GetLayer() == LAYER_N_FRONT )
|
2009-05-29 16:26:07 +00:00
|
|
|
display = FALSE;
|
2009-12-21 13:05:11 +00:00
|
|
|
layerMask &= ~LAYER_FRONT;
|
2009-05-29 16:26:07 +00:00
|
|
|
}
|
|
|
|
|
2010-01-31 20:01:46 +00:00
|
|
|
if( !IsElementVisible( PCB_VISIBLE(MOD_BK_VISIBLE) ) )
|
2009-05-29 16:26:07 +00:00
|
|
|
{
|
2009-12-07 03:46:13 +00:00
|
|
|
if( module->GetLayer() == LAYER_N_BACK )
|
2009-05-29 16:26:07 +00:00
|
|
|
display = FALSE;
|
2009-12-21 13:05:11 +00:00
|
|
|
layerMask &= ~LAYER_BACK;
|
2009-05-29 16:26:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( display )
|
|
|
|
module->Draw( aPanel, DC, aDrawMode );
|
|
|
|
else
|
|
|
|
Trace_Pads_Only( aPanel, DC, module, 0, 0, layerMask, aDrawMode );
|
|
|
|
}
|
2007-08-15 02:43:03 +00:00
|
|
|
|
2009-02-25 16:35:47 +00:00
|
|
|
// @todo: this high-light functionality could be built into me.
|
2010-01-24 13:46:01 +00:00
|
|
|
if( g_HighLight_Status )
|
|
|
|
DrawHighLight( aPanel, DC, g_HighLight_NetCode );
|
2009-02-25 16:35:47 +00:00
|
|
|
|
2009-11-20 14:55:20 +00:00
|
|
|
// draw the BOARD's markers last, otherwise the high light will erase
|
|
|
|
// any marker on a pad
|
2008-09-27 19:26:29 +00:00
|
|
|
for( unsigned i=0; i < m_markers.size(); ++i )
|
2008-04-01 05:21:50 +00:00
|
|
|
{
|
2008-09-27 19:26:29 +00:00
|
|
|
m_markers[i]->Draw( aPanel, DC, aDrawMode );
|
2008-04-01 05:21:50 +00:00
|
|
|
}
|
2009-02-25 16:35:47 +00:00
|
|
|
}
|
2008-12-14 19:45:05 +00:00
|
|
|
|
2009-02-25 16:35:47 +00:00
|
|
|
|
|
|
|
void BOARD::DrawHighLight( WinEDA_DrawPanel* aDrawPanel, wxDC* DC, int aNetCode )
|
|
|
|
{
|
|
|
|
int draw_mode;
|
|
|
|
|
2010-01-24 13:46:01 +00:00
|
|
|
if( g_HighLight_Status )
|
2009-02-25 16:35:47 +00:00
|
|
|
draw_mode = GR_SURBRILL | GR_OR;
|
|
|
|
else
|
|
|
|
draw_mode = GR_AND | GR_SURBRILL;
|
|
|
|
|
|
|
|
#if 0 // does not unhighlight properly
|
|
|
|
// redraw the zones with the aNetCode
|
|
|
|
for( SEGZONE* zone = m_Zone; zone; zone = zone->Next() )
|
2008-12-14 19:45:05 +00:00
|
|
|
{
|
2009-02-25 16:35:47 +00:00
|
|
|
if( zone->GetNet() == aNetCode )
|
|
|
|
{
|
|
|
|
zone->Draw( aDrawPanel, DC, draw_mode );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Redraw ZONE_CONTAINERS
|
|
|
|
BOARD::ZONE_CONTAINERS& zones = m_ZoneDescriptorList;
|
|
|
|
for( BOARD::ZONE_CONTAINERS::iterator zc = zones.begin(); zc!=zones.end(); ++zc )
|
|
|
|
{
|
|
|
|
if( (*zc)->GetNet() == aNetCode )
|
|
|
|
{
|
|
|
|
(*zc)->Draw( aDrawPanel, DC, draw_mode );
|
|
|
|
}
|
2008-12-14 19:45:05 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-02-25 16:35:47 +00:00
|
|
|
// Redraw any pads that have aNetCode
|
|
|
|
for( MODULE* module = m_Modules; module; module = module->Next() )
|
|
|
|
{
|
|
|
|
for( D_PAD* pad = module->m_Pads; pad; pad = pad->Next() )
|
|
|
|
{
|
|
|
|
if( pad->GetNet() == aNetCode )
|
|
|
|
{
|
|
|
|
pad->Draw( aDrawPanel, DC, draw_mode );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Redraw track and vias that have aNetCode
|
|
|
|
for( TRACK* seg = m_Track; seg; seg = seg->Next() )
|
|
|
|
{
|
|
|
|
if( seg->GetNet() == aNetCode )
|
|
|
|
{
|
|
|
|
seg->Draw( aDrawPanel, DC, draw_mode );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-01-28 13:10:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* Trace the pads of a module in sketch mode.
|
2010-01-31 20:01:46 +00:00
|
|
|
* Used to display pads when when the module visibility is set to not visible
|
2010-01-28 13:10:46 +00:00
|
|
|
* and we want to see pad through.
|
|
|
|
* The pads must appear on the layers selected in MasqueLayer
|
|
|
|
*/
|
|
|
|
void Trace_Pads_Only( WinEDA_DrawPanel* panel, wxDC* DC, MODULE* Module,
|
|
|
|
int ox, int oy, int MasqueLayer, int draw_mode )
|
|
|
|
{
|
|
|
|
int tmp;
|
|
|
|
PCB_SCREEN* screen;
|
|
|
|
WinEDA_BasePcbFrame* frame;
|
|
|
|
|
|
|
|
screen = (PCB_SCREEN*) panel->GetScreen();
|
|
|
|
frame = (WinEDA_BasePcbFrame*) panel->GetParent();
|
|
|
|
|
|
|
|
tmp = frame->m_DisplayPadFill;
|
|
|
|
frame->m_DisplayPadFill = FALSE;
|
|
|
|
|
|
|
|
/* Draw pads. */
|
|
|
|
for( D_PAD* pad = Module->m_Pads; pad; pad = pad->Next() )
|
|
|
|
{
|
|
|
|
if( (pad->m_Masque_Layer & MasqueLayer) == 0 )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
pad->Draw( panel, DC, draw_mode, wxPoint( ox, oy ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
frame->m_DisplayPadFill = tmp;
|
|
|
|
}
|
|
|
|
|