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.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
|
|
|
|
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
|
|
|
|
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
|
|
|
|
*
|
|
|
|
* 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>
|
|
|
|
#include <drawtxt.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>
|
|
|
|
#include <colors_selection.h>
|
|
|
|
#include <class_gerber_draw_item.h>
|
|
|
|
#include <class_GERBER.h>
|
2010-01-31 20:01:46 +00:00
|
|
|
|
2009-11-09 15:55:18 +00:00
|
|
|
|
2013-03-30 17:24:04 +00:00
|
|
|
void GERBVIEW_FRAME::PrintPage( wxDC* aDC, LAYER_MSK aPrintMasklayer,
|
2011-05-30 13:55:37 +00:00
|
|
|
bool aPrintMirrorMode, void* aData )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2011-10-17 20:01:27 +00:00
|
|
|
// Save current draw options, because print mode has specific options:
|
2013-03-30 17:24:04 +00:00
|
|
|
LAYER_MSK visiblemask = GetVisibleLayers();
|
2012-05-04 17:44:42 +00:00
|
|
|
GBR_DISPLAY_OPTIONS imgDisplayOptions = m_DisplayOptions;
|
2009-11-09 15:55:18 +00:00
|
|
|
|
2010-10-16 14:51:22 +00:00
|
|
|
// Set draw options for printing:
|
2012-05-04 17:44:42 +00:00
|
|
|
SetVisibleLayers( aPrintMasklayer );
|
|
|
|
m_DisplayOptions.m_DisplayFlashedItemsFill = true;
|
|
|
|
m_DisplayOptions.m_DisplayLinesFill = true;
|
|
|
|
m_DisplayOptions.m_DisplayPolygonsFill = true;
|
|
|
|
m_DisplayOptions.m_DisplayDCodes = false;
|
|
|
|
m_DisplayOptions.m_IsPrinting = true;
|
2008-12-29 20:05:47 +00:00
|
|
|
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetPrintMirrored( aPrintMirrorMode );
|
2008-12-29 20:05:47 +00:00
|
|
|
|
2012-09-01 13:38:27 +00:00
|
|
|
// XXX -1 as drawmode?
|
|
|
|
GetLayout()->Draw( m_canvas, aDC, UNSPECIFIED_DRAWMODE, wxPoint( 0, 0 ) );
|
2008-12-29 20:05:47 +00:00
|
|
|
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetPrintMirrored( false );
|
2008-12-29 20:05:47 +00:00
|
|
|
|
2010-10-16 14:51:22 +00:00
|
|
|
// Restore draw options:
|
2012-05-04 17:44:42 +00:00
|
|
|
SetVisibleLayers( visiblemask );
|
|
|
|
m_DisplayOptions = imgDisplayOptions;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-15 02:43:57 +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
|
|
|
|
2012-05-04 17:44:42 +00:00
|
|
|
if( !GetLayout() )
|
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.
|
2012-05-04 17:44:42 +00:00
|
|
|
GetLayout()->Draw( m_canvas, DC, drawMode, wxPoint( 0, 0 ) );
|
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
|
|
|
|
|
|
|
if( IsElementVisible( DCODES_VISIBLE ) )
|
2010-12-15 20:15:24 +00:00
|
|
|
DrawItemsDCodeID( DC, GR_COPY );
|
2010-09-13 14:45:19 +00:00
|
|
|
|
2012-08-29 16:59:50 +00:00
|
|
|
TraceWorkSheet( DC, screen, 0, IU_PER_MILS, wxEmptyString );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
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 );
|
2010-10-06 17:28:07 +00:00
|
|
|
|
|
|
|
// Display the filename and the layer name (found in the gerber files, if any)
|
|
|
|
// relative to the active layer
|
|
|
|
UpdateTitleAndInfo();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2010-10-16 14:51:22 +00:00
|
|
|
|
2010-12-18 18:47:58 +00:00
|
|
|
/*
|
2011-09-30 18:15:37 +00:00
|
|
|
* Redraw All GerbView layers, using a buffered mode or not
|
2010-12-18 18:47:58 +00:00
|
|
|
*/
|
2012-09-01 13:38:27 +00:00
|
|
|
void GBR_LAYOUT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMode,
|
|
|
|
const wxPoint& aOffset )
|
2008-09-27 19:26:29 +00:00
|
|
|
{
|
2010-10-16 14:51:22 +00:00
|
|
|
// Because Images can be negative (i.e with background filled in color) items are drawn
|
|
|
|
// graphic layer per graphic layer, after the background is filled
|
2011-10-17 20:01:27 +00:00
|
|
|
// to a temporary bitmap
|
2011-05-30 13:55:37 +00:00
|
|
|
// at least when aDrawMode = GR_COPY or aDrawMode = GR_OR
|
|
|
|
// If aDrawMode = -1, items are drawn to the main screen, and therefore
|
2011-10-17 20:01:27 +00:00
|
|
|
// artifacts can happen with negative items or negative images
|
2010-12-12 02:29:33 +00:00
|
|
|
|
2011-05-30 13:55:37 +00:00
|
|
|
wxColour bgColor = MakeColour( g_DrawBgColor );
|
|
|
|
wxBrush bgBrush( bgColor, wxSOLID );
|
2010-12-15 20:15:24 +00:00
|
|
|
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
GERBVIEW_FRAME* gerbFrame = (GERBVIEW_FRAME*) aPanel->GetParent();
|
|
|
|
|
2011-05-30 13:55:37 +00:00
|
|
|
int bitmapWidth, bitmapHeight;
|
|
|
|
wxDC* plotDC = aDC;
|
2010-12-15 20:15:24 +00:00
|
|
|
|
2010-12-12 02:29:33 +00:00
|
|
|
aPanel->GetClientSize( &bitmapWidth, &bitmapHeight );
|
|
|
|
|
2011-05-30 13:55:37 +00:00
|
|
|
wxBitmap* layerBitmap = NULL;
|
|
|
|
wxBitmap* screenBitmap = NULL;
|
|
|
|
wxMemoryDC layerDC; // used sequentially for each gerber layer
|
|
|
|
wxMemoryDC screenDC;
|
|
|
|
|
|
|
|
// When each image must be drawn using GR_OR (transparency mode)
|
|
|
|
// or GR_COPY (stacked mode) we must use a temporary bitmap
|
|
|
|
// to draw gerber images.
|
2011-10-17 20:01:27 +00:00
|
|
|
// this is due to negative objects (drawn using background color) that create artifacts
|
2011-05-30 13:55:37 +00:00
|
|
|
// on other images when drawn on screen
|
|
|
|
bool useBufferBitmap = false;
|
2011-10-17 20:01:27 +00:00
|
|
|
|
2012-11-20 19:19:24 +00:00
|
|
|
#ifndef __WXMAC__
|
|
|
|
// Can't work with MAC
|
|
|
|
// Don't try this with retina display
|
2011-05-30 13:55:37 +00:00
|
|
|
if( (aDrawMode == GR_COPY) || ( aDrawMode == GR_OR ) )
|
|
|
|
useBufferBitmap = true;
|
2012-11-20 19:19:24 +00:00
|
|
|
#endif
|
|
|
|
|
2011-05-30 13:55:37 +00:00
|
|
|
// these parameters are saved here, because they are modified
|
|
|
|
// and restored later
|
2011-12-29 20:11:42 +00:00
|
|
|
EDA_RECT drawBox = *aPanel->GetClipBox();
|
2011-05-30 13:55:37 +00:00
|
|
|
double scale;
|
|
|
|
aDC->GetUserScale(&scale, &scale);
|
|
|
|
wxPoint dev_org = aDC->GetDeviceOrigin();
|
|
|
|
wxPoint logical_org = aDC->GetLogicalOrigin( );
|
|
|
|
|
|
|
|
|
|
|
|
if( useBufferBitmap )
|
2010-12-15 20:15:24 +00:00
|
|
|
{
|
2011-05-30 13:55:37 +00:00
|
|
|
layerBitmap = new wxBitmap( bitmapWidth, bitmapHeight );
|
2010-12-15 20:15:24 +00:00
|
|
|
screenBitmap = new wxBitmap( bitmapWidth, bitmapHeight );
|
|
|
|
layerDC.SelectObject( *layerBitmap );
|
2011-02-08 14:48:38 +00:00
|
|
|
aPanel->DoPrepareDC( layerDC );
|
2011-12-29 20:11:42 +00:00
|
|
|
aPanel->SetClipBox( drawBox );
|
2010-12-15 20:15:24 +00:00
|
|
|
layerDC.SetBackground( bgBrush );
|
2011-02-08 14:48:38 +00:00
|
|
|
layerDC.SetBackgroundMode( wxSOLID );
|
2010-12-15 20:15:24 +00:00
|
|
|
layerDC.Clear();
|
2011-02-08 14:48:38 +00:00
|
|
|
|
2010-12-15 20:15:24 +00:00
|
|
|
screenDC.SelectObject( *screenBitmap );
|
|
|
|
screenDC.SetBackground( bgBrush );
|
2011-02-08 14:48:38 +00:00
|
|
|
screenDC.SetBackgroundMode( wxSOLID );
|
2010-12-15 20:15:24 +00:00
|
|
|
screenDC.Clear();
|
2011-05-30 13:55:37 +00:00
|
|
|
|
|
|
|
plotDC = &layerDC;
|
2010-12-15 20:15:24 +00:00
|
|
|
}
|
2010-12-12 02:29:33 +00:00
|
|
|
|
2011-10-17 20:01:27 +00:00
|
|
|
bool doBlit = false; // this flag requests an image transfer to actual screen when true.
|
2011-02-08 14:48:38 +00:00
|
|
|
|
2011-03-12 11:30:43 +00:00
|
|
|
bool end = false;
|
2011-10-17 20:01:27 +00:00
|
|
|
|
2013-03-31 13:27:46 +00:00
|
|
|
for( LAYER_NUM layer = FIRST_LAYER; !end; ++layer )
|
2009-10-28 11:48:47 +00:00
|
|
|
{
|
2013-03-31 13:27:46 +00:00
|
|
|
LAYER_NUM active_layer = gerbFrame->getActiveLayer();
|
2011-10-17 20:01:27 +00:00
|
|
|
|
2011-03-12 11:30:43 +00:00
|
|
|
if( layer == active_layer ) // active layer will be drawn after other layers
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if( layer == 32 ) // last loop: draw active layer
|
|
|
|
{
|
2011-05-30 13:55:37 +00:00
|
|
|
end = true;
|
2011-03-12 11:30:43 +00:00
|
|
|
layer = active_layer;
|
|
|
|
}
|
|
|
|
|
2012-05-04 17:44:42 +00:00
|
|
|
if( !gerbFrame->IsLayerVisible( layer ) )
|
2010-10-16 14:51:22 +00:00
|
|
|
continue;
|
2010-12-12 02:29:33 +00:00
|
|
|
|
2010-10-16 14:51:22 +00:00
|
|
|
GERBER_IMAGE* gerber = g_GERBER_List[layer];
|
2011-02-08 14:48:38 +00:00
|
|
|
|
2010-10-16 14:51:22 +00:00
|
|
|
if( gerber == NULL ) // Graphic layer not yet used
|
2009-10-28 11:48:47 +00:00
|
|
|
continue;
|
|
|
|
|
2011-05-30 13:55:37 +00:00
|
|
|
if( useBufferBitmap )
|
2010-12-15 20:15:24 +00:00
|
|
|
{
|
|
|
|
// Draw each layer into a bitmap first. Negative Gerber
|
|
|
|
// layers are drawn in background color.
|
2011-02-08 14:48:38 +00:00
|
|
|
if( gerber->HasNegativeItems() && doBlit )
|
2010-12-15 20:15:24 +00:00
|
|
|
{
|
2011-10-17 20:01:27 +00:00
|
|
|
// Set Device origin, logical origin and scale to default values
|
2011-05-30 13:55:37 +00:00
|
|
|
// This is needed by Blit function when using a mask.
|
|
|
|
// Beside, for Blit call, both layerDC and screenDc must have the same settings
|
|
|
|
layerDC.SetDeviceOrigin(0,0);
|
|
|
|
layerDC.SetLogicalOrigin( 0, 0 );
|
|
|
|
layerDC.SetUserScale( 1, 1 );
|
2011-10-17 20:01:27 +00:00
|
|
|
|
2011-02-08 14:48:38 +00:00
|
|
|
if( aDrawMode == GR_COPY )
|
|
|
|
{
|
|
|
|
// Use the layer bitmap itself as a mask when blitting. The bitmap
|
|
|
|
// cannot be referenced by a device context when setting the mask.
|
|
|
|
layerDC.SelectObject( wxNullBitmap );
|
|
|
|
layerBitmap->SetMask( new wxMask( *layerBitmap, bgColor ) );
|
|
|
|
layerDC.SelectObject( *layerBitmap );
|
2011-10-17 20:01:27 +00:00
|
|
|
screenDC.Blit( 0, 0, bitmapWidth, bitmapHeight, &layerDC, 0, 0, wxCOPY, true );
|
2011-02-08 14:48:38 +00:00
|
|
|
}
|
|
|
|
else if( aDrawMode == GR_OR )
|
|
|
|
{
|
|
|
|
// On Linux with a large screen, this version is much faster and without
|
2011-09-30 18:15:37 +00:00
|
|
|
// flicker, but gives a Pcbnew look where layer colors blend together.
|
2011-02-08 14:48:38 +00:00
|
|
|
// Plus it works only because the background color is black. But it may
|
2011-10-17 20:01:27 +00:00
|
|
|
// be more usable for some. The difference is due in part because of
|
2011-02-08 14:48:38 +00:00
|
|
|
// the cpu cycles needed to create the monochromatic bitmap above, and
|
|
|
|
// the extra time needed to do bit indexing into the monochromatic bitmap
|
|
|
|
// on the blit above.
|
2011-10-17 20:01:27 +00:00
|
|
|
screenDC.Blit( 0, 0, bitmapWidth, bitmapHeight, &layerDC, 0, 0, wxOR );
|
2010-12-15 20:15:24 +00:00
|
|
|
}
|
2011-10-17 20:01:27 +00:00
|
|
|
// Restore actual values and clear bitmap for next drawing
|
2011-05-31 06:24:56 +00:00
|
|
|
layerDC.SetDeviceOrigin( dev_org.x, dev_org.y );
|
|
|
|
layerDC.SetLogicalOrigin( logical_org.x, logical_org.y );
|
|
|
|
layerDC.SetUserScale( scale, scale );
|
|
|
|
layerDC.SetBackground( bgBrush );
|
|
|
|
layerDC.SetBackgroundMode( wxSOLID );
|
|
|
|
layerDC.Clear();
|
|
|
|
|
|
|
|
doBlit = false;
|
2010-12-15 20:15:24 +00:00
|
|
|
}
|
2011-02-08 14:48:38 +00:00
|
|
|
|
2010-12-15 20:15:24 +00:00
|
|
|
}
|
2010-12-12 02:29:33 +00:00
|
|
|
|
2010-10-16 14:51:22 +00:00
|
|
|
if( gerber->m_ImageNegative )
|
|
|
|
{
|
2010-12-12 02:29:33 +00:00
|
|
|
// Draw background negative (i.e. in graphic layer color) for negative images.
|
2012-09-02 12:06:47 +00:00
|
|
|
EDA_COLOR_T color = gerbFrame->GetLayerColor( layer );
|
2010-12-12 02:29:33 +00:00
|
|
|
|
2010-12-15 20:15:24 +00:00
|
|
|
GRSetDrawMode( &layerDC, GR_COPY );
|
2011-05-30 13:55:37 +00:00
|
|
|
GRFilledRect( &drawBox, plotDC, drawBox.GetX(), drawBox.GetY(),
|
|
|
|
drawBox.GetRight(), drawBox.GetBottom(),
|
|
|
|
0, color, color );
|
2010-12-12 02:29:33 +00:00
|
|
|
|
2010-12-15 20:15:24 +00:00
|
|
|
GRSetDrawMode( plotDC, GR_COPY );
|
|
|
|
doBlit = true;
|
2010-10-16 14:51:22 +00:00
|
|
|
}
|
2010-09-13 15:45:57 +00:00
|
|
|
|
2010-12-12 02:29:33 +00:00
|
|
|
int dcode_highlight = 0;
|
2011-02-08 14:48:38 +00:00
|
|
|
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
if( layer == gerbFrame->getActiveLayer() )
|
2010-12-12 02:29:33 +00:00
|
|
|
dcode_highlight = gerber->m_Selected_Tool;
|
|
|
|
|
2012-09-01 13:38:27 +00:00
|
|
|
GR_DRAWMODE layerdrawMode = GR_COPY;
|
2011-02-08 14:48:38 +00:00
|
|
|
|
2010-12-15 20:15:24 +00:00
|
|
|
if( aDrawMode == GR_OR && !gerber->HasNegativeItems() )
|
|
|
|
layerdrawMode = GR_OR;
|
2011-02-08 14:48:38 +00:00
|
|
|
|
2011-05-30 13:55:37 +00:00
|
|
|
// Now we can draw the current layer to the bitmap buffer
|
|
|
|
// When needed, the previous bitmap is already copied to the screen buffer.
|
2012-05-04 17:44:42 +00:00
|
|
|
for( GERBER_DRAW_ITEM* item = gerbFrame->GetItemsList(); item; item = item->Next() )
|
2010-10-16 14:51:22 +00:00
|
|
|
{
|
2012-05-04 17:44:42 +00:00
|
|
|
if( item->GetLayer() != layer )
|
2010-10-16 14:51:22 +00:00
|
|
|
continue;
|
2010-12-12 02:29:33 +00:00
|
|
|
|
2012-09-01 13:38:27 +00:00
|
|
|
GR_DRAWMODE drawMode = layerdrawMode;
|
2011-02-08 14:48:38 +00:00
|
|
|
|
2012-05-04 17:44:42 +00:00
|
|
|
if( dcode_highlight && dcode_highlight == item->m_DCode )
|
2012-09-01 13:38:27 +00:00
|
|
|
DrawModeAddHighlight( &drawMode);
|
2011-10-17 20:01:27 +00:00
|
|
|
|
2012-05-04 17:44:42 +00:00
|
|
|
item->Draw( aPanel, plotDC, drawMode, wxPoint(0,0) );
|
2010-12-15 20:15:24 +00:00
|
|
|
doBlit = true;
|
2010-10-16 14:51:22 +00:00
|
|
|
}
|
2010-12-15 20:15:24 +00:00
|
|
|
}
|
2010-12-12 02:29:33 +00:00
|
|
|
|
2011-05-30 13:55:37 +00:00
|
|
|
if( doBlit && useBufferBitmap ) // Blit is used only if aDrawMode >= 0
|
2010-12-15 20:15:24 +00:00
|
|
|
{
|
2011-05-30 13:55:37 +00:00
|
|
|
// For this Blit call, layerDC and screenDC must have the same settings
|
2011-10-17 20:01:27 +00:00
|
|
|
// So we set device origin, logical origin and scale to default values
|
2011-05-30 13:55:37 +00:00
|
|
|
// in layerDC
|
|
|
|
layerDC.SetDeviceOrigin(0,0);
|
|
|
|
layerDC.SetLogicalOrigin( 0, 0 );
|
|
|
|
layerDC.SetUserScale( 1, 1 );
|
2011-10-17 20:01:27 +00:00
|
|
|
|
|
|
|
// this is the last transfer to screenDC. If there are no negative items, this is
|
2011-02-08 14:48:38 +00:00
|
|
|
// the only one
|
2010-12-15 20:15:24 +00:00
|
|
|
if( aDrawMode == GR_COPY )
|
|
|
|
{
|
|
|
|
layerDC.SelectObject( wxNullBitmap );
|
|
|
|
layerBitmap->SetMask( new wxMask( *layerBitmap, bgColor ) );
|
|
|
|
layerDC.SelectObject( *layerBitmap );
|
2011-10-17 20:01:27 +00:00
|
|
|
screenDC.Blit( 0, 0, bitmapWidth, bitmapHeight, &layerDC, 0, 0, wxCOPY, true );
|
2011-05-30 13:55:37 +00:00
|
|
|
|
2010-12-15 20:15:24 +00:00
|
|
|
}
|
|
|
|
else if( aDrawMode == GR_OR )
|
2011-02-08 14:48:38 +00:00
|
|
|
{
|
2011-10-17 20:01:27 +00:00
|
|
|
screenDC.Blit( 0, 0, bitmapWidth, bitmapHeight, &layerDC, 0, 0, wxOR );
|
2011-02-08 14:48:38 +00:00
|
|
|
}
|
2010-12-15 20:15:24 +00:00
|
|
|
}
|
2010-12-12 02:29:33 +00:00
|
|
|
|
2011-05-30 13:55:37 +00:00
|
|
|
if( useBufferBitmap )
|
2010-12-15 20:15:24 +00:00
|
|
|
{
|
2011-05-30 13:55:37 +00:00
|
|
|
// For this Blit call, aDC and screenDC must have the same settings
|
2011-10-17 20:01:27 +00:00
|
|
|
// So we set device origin, logical origin and scale to default values
|
2011-05-30 13:55:37 +00:00
|
|
|
// in aDC
|
|
|
|
aDC->SetDeviceOrigin( 0, 0);
|
|
|
|
aDC->SetLogicalOrigin( 0, 0 );
|
|
|
|
aDC->SetUserScale( 1, 1 );
|
|
|
|
|
2011-10-17 20:01:27 +00:00
|
|
|
aDC->Blit( 0, 0, bitmapWidth, bitmapHeight, &screenDC, 0, 0, wxCOPY );
|
2011-05-30 13:55:37 +00:00
|
|
|
|
|
|
|
// Restore aDC values
|
|
|
|
aDC->SetDeviceOrigin(dev_org.x, dev_org.y);
|
|
|
|
aDC->SetLogicalOrigin( logical_org.x, logical_org.y );
|
|
|
|
aDC->SetUserScale( scale, scale );
|
|
|
|
|
2011-02-08 14:48:38 +00:00
|
|
|
layerDC.SelectObject( wxNullBitmap );
|
|
|
|
screenDC.SelectObject( wxNullBitmap );
|
2010-12-15 20:15:24 +00:00
|
|
|
delete layerBitmap;
|
|
|
|
delete screenBitmap;
|
2010-10-16 14:51:22 +00:00
|
|
|
}
|
2010-09-13 15:45:57 +00:00
|
|
|
}
|
2009-10-28 11:48:47 +00:00
|
|
|
|
2011-05-30 13:55:37 +00:00
|
|
|
|
2012-09-01 13:38:27 +00:00
|
|
|
void GERBVIEW_FRAME::DrawItemsDCodeID( wxDC* aDC, GR_DRAWMODE aDrawMode )
|
2009-10-28 11:48:47 +00:00
|
|
|
{
|
2010-10-16 14:51:22 +00:00
|
|
|
wxPoint pos;
|
|
|
|
int width, orient;
|
|
|
|
wxString Line;
|
2009-10-28 11:48:47 +00:00
|
|
|
|
2010-09-28 14:42:05 +00:00
|
|
|
GRSetDrawMode( aDC, aDrawMode );
|
2011-02-08 14:48:38 +00:00
|
|
|
|
2012-05-04 17:44:42 +00:00
|
|
|
for( GERBER_DRAW_ITEM* item = GetItemsList(); item != NULL; item = item->Next() )
|
2009-10-28 11:48:47 +00:00
|
|
|
{
|
2012-05-04 17:44:42 +00:00
|
|
|
if( IsLayerVisible( item->GetLayer() ) == false )
|
2010-09-28 14:42:05 +00:00
|
|
|
continue;
|
2011-02-08 14:48:38 +00:00
|
|
|
|
2012-05-04 17:44:42 +00:00
|
|
|
if( item->m_DCode <= 0 )
|
2009-11-09 15:55:18 +00:00
|
|
|
continue;
|
|
|
|
|
2012-05-04 17:44:42 +00:00
|
|
|
if( item->m_Flashed || item->m_Shape == GBR_ARC )
|
2011-10-17 20:01:27 +00:00
|
|
|
{
|
2012-05-04 17:44:42 +00:00
|
|
|
pos = item->m_Start;
|
2011-10-17 20:01:27 +00:00
|
|
|
}
|
2009-10-28 11:48:47 +00:00
|
|
|
else
|
|
|
|
{
|
2012-05-04 17:44:42 +00:00
|
|
|
pos.x = (item->m_Start.x + item->m_End.x) / 2;
|
|
|
|
pos.y = (item->m_Start.y + item->m_End.y) / 2;
|
2009-10-28 11:48:47 +00:00
|
|
|
}
|
|
|
|
|
2012-05-04 17:44:42 +00:00
|
|
|
pos = item->GetABPosition( pos );
|
2010-10-09 20:05:03 +00:00
|
|
|
|
2012-05-04 17:44:42 +00:00
|
|
|
Line.Printf( wxT( "D%d" ), item->m_DCode );
|
2009-10-28 11:48:47 +00:00
|
|
|
|
2012-05-04 17:44:42 +00:00
|
|
|
if( item->GetDcodeDescr() )
|
|
|
|
width = item->GetDcodeDescr()->GetShapeDim( item );
|
2010-10-23 18:12:11 +00:00
|
|
|
else
|
2012-05-04 17:44:42 +00:00
|
|
|
width = std::min( item->m_Size.x, item->m_Size.y );
|
2010-10-23 18:12:11 +00:00
|
|
|
|
2009-10-28 11:48:47 +00:00
|
|
|
orient = TEXT_ORIENT_HORIZ;
|
2011-02-08 14:48:38 +00:00
|
|
|
|
2012-05-04 17:44:42 +00:00
|
|
|
if( item->m_Flashed )
|
2009-10-28 11:48:47 +00:00
|
|
|
{
|
2011-10-17 20:01:27 +00:00
|
|
|
// A reasonable size for text is width/3 because most of time this text has 3 chars.
|
2009-10-28 11:48:47 +00:00
|
|
|
width /= 3;
|
|
|
|
}
|
2010-10-23 18:12:11 +00:00
|
|
|
else // this item is a line
|
2009-10-28 11:48:47 +00:00
|
|
|
{
|
2012-05-04 17:44:42 +00:00
|
|
|
wxPoint delta = item->m_Start - item->m_End;
|
2011-02-08 14:48:38 +00:00
|
|
|
|
2010-10-23 18:12:11 +00:00
|
|
|
if( abs( delta.x ) < abs( delta.y ) )
|
2009-10-28 11:48:47 +00:00
|
|
|
orient = TEXT_ORIENT_VERT;
|
2011-05-30 13:55:37 +00:00
|
|
|
|
2011-10-17 20:01:27 +00:00
|
|
|
// A reasonable size for text is width/2 because text needs margin below and above it.
|
2010-10-23 18:12:11 +00:00
|
|
|
// a margin = width/4 seems good
|
2009-10-28 11:48:47 +00:00
|
|
|
width /= 2;
|
|
|
|
}
|
2010-01-31 20:01:46 +00:00
|
|
|
|
2012-05-04 17:44:42 +00:00
|
|
|
int color = GetVisibleElementColor( DCODES_VISIBLE );
|
2009-10-28 11:48:47 +00:00
|
|
|
|
2012-03-26 23:47:08 +00:00
|
|
|
DrawGraphicText( m_canvas, aDC, pos, (EDA_COLOR_T) color, Line,
|
2009-10-28 11:48:47 +00:00
|
|
|
orient, wxSize( width, width ),
|
|
|
|
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
|
2010-11-20 19:53:00 +00:00
|
|
|
0, false, false );
|
2009-10-28 11:48:47 +00:00
|
|
|
}
|
|
|
|
}
|