2007-06-05 12:10:51 +00:00
|
|
|
/*
|
2011-10-17 20:01:27 +00:00
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2013-06-27 19:12:01 +00:00
|
|
|
* Copyright (C) 2013 Jean-Pierre Charras, jpierre.charras at wanadoo
|
2015-02-28 20:50:35 +00:00
|
|
|
* Copyright (C) 2013-2015 Wayne Stambaugh <stambaughw@verizon.net>
|
|
|
|
* Copyright (C) 1992-2015 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
|
2007-08-15 02:43:57 +00:00
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2011-10-17 20:01:27 +00:00
|
|
|
/**
|
|
|
|
* @file draw_gerber_screen.cpp
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <gr_basic.h>
|
|
|
|
#include <common.h>
|
|
|
|
#include <class_drawpanel.h>
|
2018-01-28 21:02:31 +00:00
|
|
|
#include <draw_graphic_text.h>
|
2012-04-16 01:25:26 +00:00
|
|
|
#include <base_units.h>
|
2009-02-04 15:25:03 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <gerbview.h>
|
2014-06-27 17:07:42 +00:00
|
|
|
#include <gerbview_frame.h>
|
2018-01-29 12:26:58 +00:00
|
|
|
#include <gerber_file_image.h>
|
|
|
|
#include <gerber_file_image_list.h>
|
2018-09-19 13:06:29 +00:00
|
|
|
#include "gerbview_printout.h"
|
2010-01-31 20:01:46 +00:00
|
|
|
|
2009-11-09 15:55:18 +00:00
|
|
|
|
2011-03-12 09:50:21 +00:00
|
|
|
void GERBVIEW_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2012-05-04 17:44:42 +00:00
|
|
|
GBR_SCREEN* screen = (GBR_SCREEN*) GetScreen();
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2013-06-27 19:12:01 +00:00
|
|
|
if( !GetGerberLayout() )
|
2008-12-29 20:05:47 +00:00
|
|
|
return;
|
2010-12-15 20:15:24 +00:00
|
|
|
|
2010-12-17 20:34:29 +00:00
|
|
|
wxBusyCursor dummy;
|
|
|
|
|
2012-09-01 13:38:27 +00:00
|
|
|
GR_DRAWMODE drawMode = UNSPECIFIED_DRAWMODE;
|
2011-01-30 22:22:38 +00:00
|
|
|
|
2011-05-30 13:55:37 +00:00
|
|
|
switch( GetDisplayMode() )
|
2010-12-15 20:15:24 +00:00
|
|
|
{
|
2011-05-30 13:55:37 +00:00
|
|
|
default:
|
|
|
|
case 0:
|
|
|
|
break;
|
2010-12-15 20:15:24 +00:00
|
|
|
|
2011-05-30 13:55:37 +00:00
|
|
|
case 1:
|
|
|
|
drawMode = GR_COPY;
|
|
|
|
break;
|
2010-12-15 20:15:24 +00:00
|
|
|
|
2011-05-30 13:55:37 +00:00
|
|
|
case 2:
|
|
|
|
drawMode = GR_OR;
|
|
|
|
break;
|
2010-12-15 20:15:24 +00:00
|
|
|
}
|
2011-02-08 14:48:38 +00:00
|
|
|
|
|
|
|
// Draw according to the current setting. This needs to be GR_COPY or GR_OR.
|
2016-06-02 09:30:39 +00:00
|
|
|
m_DisplayOptions.m_NegativeDrawColor = GetNegativeItemsColor();
|
|
|
|
m_DisplayOptions.m_BgDrawColor = GetDrawBgColor();
|
|
|
|
GetGerberLayout()->Draw( m_canvas, DC, drawMode, wxPoint( 0, 0 ), &m_DisplayOptions );
|
|
|
|
|
|
|
|
if( m_DisplayOptions.m_DisplayDCodes )
|
|
|
|
{
|
2017-03-13 03:19:33 +00:00
|
|
|
COLOR4D dcode_color = GetVisibleElementColor( LAYER_DCODES );
|
2016-06-02 09:30:39 +00:00
|
|
|
GetGerberLayout()->DrawItemsDCodeID( m_canvas, DC, GR_COPY, dcode_color );
|
|
|
|
}
|
2010-12-15 20:15:24 +00:00
|
|
|
|
|
|
|
// Draw the "background" now, i.e. grid and axis after gerber layers
|
2011-10-17 20:01:27 +00:00
|
|
|
// because most of time the actual background is erased by successive drawings of each gerber
|
2011-02-03 19:27:28 +00:00
|
|
|
// layer mainly in COPY mode
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->DrawBackGround( DC );
|
2010-10-16 14:51:22 +00:00
|
|
|
|
2013-05-22 08:45:25 +00:00
|
|
|
DrawWorkSheet( DC, screen, 0, IU_PER_MILS, wxEmptyString );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2014-06-16 16:32:23 +00:00
|
|
|
#ifdef USE_WX_OVERLAY
|
|
|
|
if( IsShown() )
|
|
|
|
{
|
|
|
|
m_overlay.Reset();
|
2017-09-17 22:43:20 +00:00
|
|
|
|
|
|
|
// On macOS, the call to create overlaydc fails for some reason due to
|
|
|
|
// the DC having zero size initially.
|
|
|
|
wxCoord w = 0, h = 0;
|
2017-09-20 08:30:48 +00:00
|
|
|
static_cast<wxWindowDC*>( DC )->GetSize( &w, &h );
|
|
|
|
|
2017-09-17 22:43:20 +00:00
|
|
|
if( w == 0 || h == 0)
|
|
|
|
{
|
|
|
|
w = h = 1;
|
|
|
|
}
|
2017-09-20 08:30:48 +00:00
|
|
|
|
2017-09-17 22:43:20 +00:00
|
|
|
wxDCOverlay overlaydc( m_overlay, (wxWindowDC*)DC, 0, 0, 1, 1 );
|
2014-06-16 16:32:23 +00:00
|
|
|
overlaydc.Clear();
|
|
|
|
}
|
|
|
|
#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-08-15 02:43:57 +00:00
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->DrawCrossHair( DC );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|