2011-10-17 20:01:27 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2012-06-08 09:56:42 +00:00
|
|
|
* Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
|
|
|
|
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
|
|
|
* Copyright (C) 2012 Wayne Stambaugh <stambaughw@verizon.net>
|
|
|
|
* Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors.
|
2011-10-17 20:01:27 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2011-09-23 13:57:12 +00:00
|
|
|
/**
|
|
|
|
* @file tracepcb.cpp
|
|
|
|
* @brief Functions to redraw the current board.
|
2007-08-15 02:43:03 +00:00
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <class_drawpanel.h>
|
|
|
|
#include <wxPcbStruct.h>
|
2012-04-16 01:25:26 +00:00
|
|
|
#include <base_units.h>
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <class_board.h>
|
|
|
|
#include <class_module.h>
|
|
|
|
#include <class_track.h>
|
|
|
|
#include <class_zone.h>
|
|
|
|
#include <class_marker_pcb.h>
|
2009-02-04 15:25:03 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <pcbnew.h>
|
|
|
|
#include <module_editor_frame.h>
|
|
|
|
#include <pcbplot.h>
|
|
|
|
#include <protos.h>
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2010-09-21 23:46:02 +00:00
|
|
|
#include <wx/overlay.h>
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2011-09-23 13:57:12 +00:00
|
|
|
|
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.
|
2011-09-07 19:41:04 +00:00
|
|
|
* The pads must appear on the layers selected in LayerMask
|
2010-01-28 13:10:46 +00:00
|
|
|
*/
|
2011-01-21 19:30:59 +00:00
|
|
|
static void Trace_Pads_Only( EDA_DRAW_PANEL* panel, wxDC* DC, MODULE* Module,
|
2013-03-30 17:24:04 +00:00
|
|
|
int ox, int oy, LAYER_MSK LayerMask, GR_DRAWMODE draw_mode );
|
2010-01-28 13:10:46 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2011-08-26 17:01:17 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2013-01-25 17:29:54 +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
|
|
|
GRSetDrawMode( DC, GR_COPY );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->DrawBackGround( DC );
|
2012-08-29 16:59:50 +00:00
|
|
|
TraceWorkSheet( DC, screen, 0, IU_PER_MILS, wxEmptyString );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
// Redraw the footprints
|
2013-01-25 17:29:54 +00:00
|
|
|
for( MODULE* module = GetBoard()->m_Modules; module; module = module->Next() )
|
2007-08-15 02:43:03 +00:00
|
|
|
{
|
2011-12-22 13:28:11 +00:00
|
|
|
module->Draw( m_canvas, 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
|
2013-01-25 17:29:54 +00:00
|
|
|
|
2011-08-26 17:01:17 +00:00
|
|
|
if( IsShown() )
|
2010-11-03 21:19:46 +00:00
|
|
|
{
|
2011-12-29 20:11:42 +00:00
|
|
|
m_overlay.Reset();
|
2013-01-25 17:29:54 +00:00
|
|
|
wxDCOverlay overlaydc( m_overlay, (wxWindowDC*) DC );
|
2010-11-03 21:19:46 +00:00
|
|
|
overlaydc.Clear();
|
|
|
|
}
|
2013-01-25 17:29:54 +00:00
|
|
|
|
2010-09-21 23:46:02 +00:00
|
|
|
#endif
|
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
if( m_canvas->IsMouseCaptured() )
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
// Redraw the cursor
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->DrawCrossHair( 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
|
|
|
*/
|
2011-03-01 19:26:17 +00:00
|
|
|
void PCB_EDIT_FRAME::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
|
|
|
|
2007-08-15 02:43:03 +00:00
|
|
|
GRSetDrawMode( DC, GR_COPY );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->DrawBackGround( DC );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-08-29 16:59:50 +00:00
|
|
|
TraceWorkSheet( DC, GetScreen(), g_DrawDefaultLineThickness,
|
2013-02-09 20:03:20 +00:00
|
|
|
IU_PER_MILS, GetBoard()->GetFileName() );
|
2008-04-01 05:21:50 +00:00
|
|
|
|
2013-01-25 17:29:54 +00:00
|
|
|
GetBoard()->Draw( m_canvas, DC, GR_OR | GR_ALLOW_HIGHCONTRAST );
|
2008-09-27 19:26:29 +00:00
|
|
|
|
|
|
|
DrawGeneralRatsnest( DC );
|
|
|
|
|
2010-10-09 08:08:29 +00:00
|
|
|
#ifdef USE_WX_OVERLAY
|
2013-01-25 17:29:54 +00:00
|
|
|
|
2011-10-17 20:01:27 +00:00
|
|
|
if( IsShown() )
|
2010-11-03 21:19:46 +00:00
|
|
|
{
|
2011-12-29 20:11:42 +00:00
|
|
|
m_overlay.Reset();
|
2013-01-25 17:29:54 +00:00
|
|
|
wxDCOverlay overlaydc( m_overlay, (wxWindowDC*) DC );
|
2010-11-03 21:19:46 +00:00
|
|
|
overlaydc.Clear();
|
|
|
|
}
|
2013-01-25 17:29:54 +00:00
|
|
|
|
2010-09-21 23:46:02 +00:00
|
|
|
#endif
|
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
if( m_canvas->IsMouseCaptured() )
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
|
2008-04-01 05:21:50 +00:00
|
|
|
|
|
|
|
// Redraw the cursor
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->DrawCrossHair( DC );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-15 02:43:03 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
// Redraw the BOARD items but not cursors, axis or grid
|
2012-09-01 13:38:27 +00:00
|
|
|
void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* DC, GR_DRAWMODE 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
|
|
|
*/
|
2013-01-25 17:29:54 +00:00
|
|
|
for( TRACK* track = m_Track; track; track = track->Next() )
|
2009-05-29 16:26:07 +00:00
|
|
|
{
|
|
|
|
track->Draw( aPanel, DC, aDrawMode );
|
|
|
|
}
|
2007-08-15 02:43:03 +00:00
|
|
|
|
2013-01-25 17:29:54 +00:00
|
|
|
for( SEGZONE* zone = m_Zone; zone; zone = zone->Next() )
|
2009-05-29 16:26:07 +00:00
|
|
|
{
|
|
|
|
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
|
2013-01-25 17:29:54 +00:00
|
|
|
for( BOARD_ITEM* item = m_Drawings; item; item = item->Next() )
|
2007-08-15 02:43:03 +00:00
|
|
|
{
|
2011-12-21 13:42:02 +00:00
|
|
|
if( item->IsMoving() )
|
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
|
|
|
{
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_DIMENSION_T:
|
|
|
|
case PCB_TEXT_T:
|
2011-09-07 19:41:04 +00:00
|
|
|
case PCB_TARGET_T:
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_LINE_T:
|
2008-09-27 19:26:29 +00:00
|
|
|
item->Draw( aPanel, DC, aDrawMode );
|
2007-08-15 02:43:03 +00:00
|
|
|
break;
|
|
|
|
|
2013-01-25 17:29:54 +00:00
|
|
|
default:
|
2007-08-15 02:43:03 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
// Draw areas (i.e. zones)
|
2008-10-08 12:36:27 +00:00
|
|
|
for( int ii = 0; ii < GetAreaCount(); ii++ )
|
|
|
|
{
|
2013-01-25 17:29:54 +00:00
|
|
|
ZONE_CONTAINER* zone = GetArea( ii );
|
2008-10-08 12:36:27 +00:00
|
|
|
|
|
|
|
// Areas must be drawn here only if not moved or dragged,
|
|
|
|
// because these areas are drawn by ManageCursor() in a specific manner
|
2013-01-25 17:29:54 +00:00
|
|
|
if( ( zone->GetFlags() & (IN_EDIT | IS_DRAGGED | IS_MOVED) ) == 0 )
|
2008-10-08 12:36:27 +00:00
|
|
|
{
|
|
|
|
zone->Draw( aPanel, DC, aDrawMode );
|
|
|
|
zone->DrawFilledArea( aPanel, DC, aDrawMode );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-25 17:29:54 +00:00
|
|
|
for( MODULE* module = m_Modules; module; module = module->Next() )
|
2009-05-29 16:26:07 +00:00
|
|
|
{
|
2013-04-06 12:28:02 +00:00
|
|
|
bool display = true;
|
2013-03-30 17:24:04 +00:00
|
|
|
LAYER_MSK layerMask = ALL_CU_LAYERS;
|
2009-05-29 16:26:07 +00:00
|
|
|
|
2011-12-21 13:42:02 +00:00
|
|
|
if( module->IsMoving() )
|
2009-05-29 16:26:07 +00:00
|
|
|
continue;
|
|
|
|
|
2013-01-25 17:29:54 +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 )
|
2011-08-26 17:01:17 +00:00
|
|
|
display = false;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2009-12-21 13:05:11 +00:00
|
|
|
layerMask &= ~LAYER_FRONT;
|
2009-05-29 16:26:07 +00:00
|
|
|
}
|
|
|
|
|
2013-01-25 17:29:54 +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 )
|
2011-08-26 17:01:17 +00:00
|
|
|
display = false;
|
2013-01-25 17:29:54 +00:00
|
|
|
|
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
|
|
|
|
2011-09-14 20:04:58 +00:00
|
|
|
if( IsHighLightNetON() )
|
|
|
|
DrawHighLight( aPanel, DC, GetHighLightNetCode() );
|
2009-02-25 16:35:47 +00:00
|
|
|
|
2011-08-26 17:01:17 +00:00
|
|
|
// draw the BOARD's markers last, otherwise the high light will erase any marker on a pad
|
2013-01-25 17:29:54 +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
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
void BOARD::DrawHighLight( EDA_DRAW_PANEL* am_canvas, wxDC* DC, int aNetCode )
|
2009-02-25 16:35:47 +00:00
|
|
|
{
|
2012-09-01 13:38:27 +00:00
|
|
|
GR_DRAWMODE draw_mode;
|
2009-02-25 16:35:47 +00:00
|
|
|
|
2011-09-14 20:04:58 +00:00
|
|
|
if( IsHighLightNetON() )
|
2011-10-17 20:01:27 +00:00
|
|
|
draw_mode = GR_HIGHLIGHT | GR_OR;
|
2009-02-25 16:35:47 +00:00
|
|
|
else
|
2011-10-17 20:01:27 +00:00
|
|
|
draw_mode = GR_AND | GR_HIGHLIGHT;
|
2009-02-25 16:35:47 +00:00
|
|
|
|
|
|
|
// Redraw ZONE_CONTAINERS
|
|
|
|
BOARD::ZONE_CONTAINERS& zones = m_ZoneDescriptorList;
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2013-01-25 17:29:54 +00:00
|
|
|
for( BOARD::ZONE_CONTAINERS::iterator zc = zones.begin(); zc!=zones.end(); ++zc )
|
2009-02-25 16:35:47 +00:00
|
|
|
{
|
|
|
|
if( (*zc)->GetNet() == aNetCode )
|
|
|
|
{
|
2011-12-22 13:28:11 +00:00
|
|
|
(*zc)->Draw( am_canvas, DC, draw_mode );
|
2009-02-25 16:35:47 +00:00
|
|
|
}
|
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
|
2013-01-25 17:29:54 +00:00
|
|
|
for( MODULE* module = m_Modules; module; module = module->Next() )
|
2009-02-25 16:35:47 +00:00
|
|
|
{
|
2013-03-18 19:36:07 +00:00
|
|
|
for( D_PAD* pad = module->Pads(); pad; pad = pad->Next() )
|
2009-02-25 16:35:47 +00:00
|
|
|
{
|
|
|
|
if( pad->GetNet() == aNetCode )
|
|
|
|
{
|
2011-12-22 13:28:11 +00:00
|
|
|
pad->Draw( am_canvas, DC, draw_mode );
|
2009-02-25 16:35:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Redraw track and vias that have aNetCode
|
2013-01-25 17:29:54 +00:00
|
|
|
for( TRACK* seg = m_Track; seg; seg = seg->Next() )
|
2009-02-25 16:35:47 +00:00
|
|
|
{
|
|
|
|
if( seg->GetNet() == aNetCode )
|
|
|
|
{
|
2011-12-22 13:28:11 +00:00
|
|
|
seg->Draw( am_canvas, DC, draw_mode );
|
2009-02-25 16:35:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
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.
|
2011-09-07 19:41:04 +00:00
|
|
|
* The pads must appear on the layers selected in LayerMask
|
2010-01-28 13:10:46 +00:00
|
|
|
*/
|
2012-09-01 13:38:27 +00:00
|
|
|
static void Trace_Pads_Only( EDA_DRAW_PANEL* panel, wxDC* DC, MODULE* aModule,
|
2013-03-30 17:24:04 +00:00
|
|
|
int ox, int oy, LAYER_MSK aLayerMask, GR_DRAWMODE draw_mode )
|
2010-01-28 13:10:46 +00:00
|
|
|
{
|
2012-02-19 04:02:19 +00:00
|
|
|
PCB_BASE_FRAME* frame = (PCB_BASE_FRAME*) panel->GetParent();
|
2010-01-28 13:10:46 +00:00
|
|
|
|
2013-01-25 17:29:54 +00:00
|
|
|
int tmp = frame->m_DisplayPadFill;
|
2010-01-28 13:10:46 +00:00
|
|
|
|
2011-08-26 17:01:17 +00:00
|
|
|
frame->m_DisplayPadFill = false;
|
2010-01-28 13:10:46 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
// Draw pads.
|
2013-03-18 19:36:07 +00:00
|
|
|
for( D_PAD* pad = aModule->Pads(); pad; pad = pad->Next() )
|
2010-01-28 13:10:46 +00:00
|
|
|
{
|
2012-02-19 04:02:19 +00:00
|
|
|
if( (pad->GetLayerMask() & aLayerMask) == 0 )
|
2010-01-28 13:10:46 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
pad->Draw( panel, DC, draw_mode, wxPoint( ox, oy ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
frame->m_DisplayPadFill = tmp;
|
|
|
|
}
|