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
|
|
|
/**
|
2018-01-31 16:09:26 +00:00
|
|
|
* @file pcb_legacy_draw_utils.cpp
|
|
|
|
* @brief functions (and helper functions) to redraw the current board in legacy canvas.
|
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>
|
2018-01-29 20:58:58 +00:00
|
|
|
#include <pcb_edit_frame.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>
|
2018-01-29 20:58:58 +00:00
|
|
|
#include <footprint_edit_frame.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <pcbplot.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,
|
2014-06-24 16:17:18 +00:00
|
|
|
int ox, int oy, LSET 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
|
|
|
{
|
2015-09-03 07:44:30 +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 );
|
2014-09-24 16:56:20 +00:00
|
|
|
DrawWorkSheet( 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() )
|
2015-01-10 10:27:49 +00:00
|
|
|
module->Draw( m_canvas, DC, GR_OR | GR_ALLOW_HIGHCONTRAST );
|
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
|
|
|
|
2013-05-22 08:45:25 +00:00
|
|
|
DrawWorkSheet( 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
|
|
|
{
|
2014-09-24 16:56:20 +00:00
|
|
|
if( track->IsMoving() )
|
|
|
|
continue;
|
|
|
|
|
2009-05-29 16:26:07 +00:00
|
|
|
track->Draw( aPanel, DC, aDrawMode );
|
|
|
|
}
|
2007-08-15 02:43:03 +00:00
|
|
|
|
2018-08-26 19:40:22 +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->GetFlags() & (IN_EDIT | IS_DRAGGED | IS_MOVED) ) == 0 )
|
|
|
|
{
|
|
|
|
zone->Draw( aPanel, DC, aDrawMode );
|
|
|
|
zone->DrawFilledArea( aPanel, DC, aDrawMode );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
LSET all_cu = LSET::AllCuMask();
|
|
|
|
|
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
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
bool display = true;
|
|
|
|
LSET layerMask = all_cu;
|
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;
|
|
|
|
|
2017-03-13 03:19:33 +00:00
|
|
|
if( !IsElementVisible( LAYER_MOD_FR ) )
|
2009-05-29 16:26:07 +00:00
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
if( module->GetLayer() == F_Cu )
|
2011-08-26 17:01:17 +00:00
|
|
|
display = false;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
layerMask.set( F_Cu, false );
|
2009-05-29 16:26:07 +00:00
|
|
|
}
|
|
|
|
|
2017-03-13 03:19:33 +00:00
|
|
|
if( !IsElementVisible( LAYER_MOD_BK ) )
|
2009-05-29 16:26:07 +00:00
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
if( module->GetLayer() == B_Cu )
|
2011-08-26 17:01:17 +00:00
|
|
|
display = false;
|
2013-01-25 17:29:54 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
layerMask.set( B_Cu, false );
|
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
|
|
|
|
2014-09-30 18:23:27 +00:00
|
|
|
// Redraw zones
|
|
|
|
for( int ii = 0; ii < GetAreaCount(); ii++ )
|
2009-02-25 16:35:47 +00:00
|
|
|
{
|
2014-09-30 18:23:27 +00:00
|
|
|
ZONE_CONTAINER* zone = GetArea( ii );
|
|
|
|
|
|
|
|
if( zone->GetNetCode() == aNetCode )
|
2009-02-25 16:35:47 +00:00
|
|
|
{
|
2014-09-30 18:23:27 +00:00
|
|
|
zone->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
|
|
|
{
|
2017-04-25 09:06:24 +00:00
|
|
|
for( D_PAD* pad = module->PadsList(); pad; pad = pad->Next() )
|
2009-02-25 16:35:47 +00:00
|
|
|
{
|
2014-02-25 10:40:34 +00:00
|
|
|
if( pad->GetNetCode() == aNetCode )
|
2009-02-25 16:35:47 +00:00
|
|
|
{
|
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
|
|
|
{
|
2014-02-25 10:40:34 +00:00
|
|
|
if( seg->GetNetCode() == aNetCode )
|
2009-02-25 16:35:47 +00:00
|
|
|
{
|
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,
|
2014-06-24 16:17:18 +00:00
|
|
|
int ox, int oy, LSET aLayerMask, GR_DRAWMODE draw_mode )
|
2010-01-28 13:10:46 +00:00
|
|
|
{
|
2017-10-30 17:21:07 +00:00
|
|
|
auto displ_opts = (PCB_DISPLAY_OPTIONS*)( panel->GetDisplayOptions() );
|
2010-01-28 13:10:46 +00:00
|
|
|
|
2015-01-10 10:27:49 +00:00
|
|
|
int tmp = displ_opts->m_DisplayPadFill;
|
2010-01-28 13:10:46 +00:00
|
|
|
|
2015-01-10 10:27:49 +00:00
|
|
|
displ_opts->m_DisplayPadFill = false;
|
2010-01-28 13:10:46 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
// Draw pads.
|
2017-04-25 09:06:24 +00:00
|
|
|
for( D_PAD* pad = aModule->PadsList(); pad; pad = pad->Next() )
|
2010-01-28 13:10:46 +00:00
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
if( (pad->GetLayerSet() & aLayerMask) == 0 )
|
2010-01-28 13:10:46 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
pad->Draw( panel, DC, draw_mode, wxPoint( ox, oy ) );
|
|
|
|
}
|
|
|
|
|
2015-01-10 10:27:49 +00:00
|
|
|
displ_opts->m_DisplayPadFill = tmp;
|
2010-01-28 13:10:46 +00:00
|
|
|
}
|