2014-10-21 18:36:45 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2012-2014 Jean-Pierre Charras jp.charras at wanadoo.fr
|
|
|
|
* Copyright (C) 1992-2014 KiCad Developers, see change_log.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
|
|
|
|
*/
|
|
|
|
|
2012-05-04 17:44:42 +00:00
|
|
|
/**
|
2018-01-29 12:26:58 +00:00
|
|
|
* @file gbr_layout.cpp
|
2012-05-04 17:44:42 +00:00
|
|
|
* @brief GBR_LAYOUT class functions.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <fctsys.h>
|
2016-05-25 14:48:38 +00:00
|
|
|
#include <gr_basic.h>
|
2018-01-28 21:02:31 +00:00
|
|
|
#include <draw_graphic_text.h>
|
2016-05-25 14:48:38 +00:00
|
|
|
#include <gerbview_frame.h>
|
|
|
|
#include <class_drawpanel.h>
|
2018-01-29 12:26:58 +00:00
|
|
|
#include <gbr_layout.h>
|
|
|
|
#include <gerber_file_image.h>
|
|
|
|
#include <gerber_file_image_list.h>
|
2012-05-04 17:44:42 +00:00
|
|
|
|
2017-09-17 22:43:20 +00:00
|
|
|
GBR_LAYOUT::GBR_LAYOUT() :
|
|
|
|
EDA_ITEM( (EDA_ITEM*)NULL, GERBER_LAYOUT_T )
|
2012-05-04 17:44:42 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
GBR_LAYOUT::~GBR_LAYOUT()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-06-17 18:00:29 +00:00
|
|
|
// Accessor to the list of gerber files (and drill files) images
|
2017-09-17 22:43:20 +00:00
|
|
|
GERBER_FILE_IMAGE_LIST* GBR_LAYOUT::GetImagesList() const
|
2016-06-17 18:00:29 +00:00
|
|
|
{
|
|
|
|
return &GERBER_FILE_IMAGE_LIST::GetImagesList();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-06-02 09:30:39 +00:00
|
|
|
bool GBR_LAYOUT::IsLayerPrintable( int aLayer ) const
|
|
|
|
{
|
|
|
|
for( unsigned ii = 0; ii < m_printLayersList.size(); ++ii )
|
|
|
|
{
|
|
|
|
if( m_printLayersList[ii] == aLayer )
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2012-05-04 17:44:42 +00:00
|
|
|
|
2016-06-17 18:00:29 +00:00
|
|
|
|
2017-09-17 22:43:20 +00:00
|
|
|
EDA_RECT GBR_LAYOUT::ComputeBoundingBox() const
|
2012-05-04 17:44:42 +00:00
|
|
|
{
|
|
|
|
EDA_RECT bbox;
|
2016-06-15 08:26:41 +00:00
|
|
|
bool first_item = true;
|
2012-05-04 17:44:42 +00:00
|
|
|
|
2016-06-17 18:00:29 +00:00
|
|
|
for( unsigned layer = 0; layer < GetImagesList()->ImagesMaxCount(); ++layer )
|
2016-05-26 11:57:43 +00:00
|
|
|
{
|
2016-06-17 18:00:29 +00:00
|
|
|
GERBER_FILE_IMAGE* gerber = GetImagesList()->GetGbrImage( layer );
|
2016-05-26 11:57:43 +00:00
|
|
|
|
|
|
|
if( gerber == NULL ) // Graphic layer not yet used
|
|
|
|
continue;
|
|
|
|
|
|
|
|
for( GERBER_DRAW_ITEM* item = gerber->GetItemsList(); item; item = item->Next() )
|
2016-06-15 08:26:41 +00:00
|
|
|
{
|
|
|
|
if( first_item )
|
|
|
|
{
|
|
|
|
bbox = item->GetBoundingBox();
|
|
|
|
first_item = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
bbox.Merge( item->GetBoundingBox() );
|
|
|
|
}
|
2016-05-26 11:57:43 +00:00
|
|
|
}
|
2012-05-04 17:44:42 +00:00
|
|
|
|
2017-09-17 22:43:20 +00:00
|
|
|
bbox.Inflate( ( bbox.GetWidth() / 10 ) + 100 );
|
|
|
|
bbox.Normalize();
|
|
|
|
|
|
|
|
m_BoundingBox = bbox;
|
2012-05-04 17:44:42 +00:00
|
|
|
return bbox;
|
|
|
|
}
|
2016-05-25 14:48:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Redraw All GerbView layers, using a buffered mode or not
|
|
|
|
void GBR_LAYOUT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMode,
|
2016-06-02 09:30:39 +00:00
|
|
|
const wxPoint& aOffset, GBR_DISPLAY_OPTIONS* aDisplayOptions )
|
2016-05-25 14:48:38 +00:00
|
|
|
{
|
|
|
|
GERBVIEW_FRAME* gerbFrame = (GERBVIEW_FRAME*) aPanel->GetParent();
|
|
|
|
|
2016-08-16 10:56:20 +00:00
|
|
|
// Collect the highlight selections
|
|
|
|
wxString cmpHighlight;
|
|
|
|
|
|
|
|
if( gerbFrame->m_SelComponentBox->GetSelection() > 0 )
|
|
|
|
cmpHighlight = gerbFrame->m_SelComponentBox->GetStringSelection();
|
|
|
|
|
|
|
|
wxString netHighlight;
|
|
|
|
|
|
|
|
if( gerbFrame->m_SelNetnameBox->GetSelection() > 0 )
|
|
|
|
netHighlight = gerbFrame->m_SelNetnameBox->GetStringSelection();
|
|
|
|
|
|
|
|
wxString aperAttrHighlight = gerbFrame->m_SelAperAttributesBox->GetStringSelection();
|
|
|
|
|
|
|
|
if( gerbFrame->m_SelAperAttributesBox->GetSelection() > 0 )
|
|
|
|
aperAttrHighlight = gerbFrame->m_SelAperAttributesBox->GetStringSelection();
|
|
|
|
|
|
|
|
|
2016-05-25 14:48:38 +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
|
|
|
|
// to a temporary bitmap
|
|
|
|
// at least when aDrawMode = GR_COPY or aDrawMode = GR_OR
|
|
|
|
// If aDrawMode = UNSPECIFIED_DRAWMODE, items are drawn to the main screen, and therefore
|
|
|
|
// artifacts can happen with negative items or negative images
|
|
|
|
|
|
|
|
int bitmapWidth, bitmapHeight;
|
|
|
|
wxDC* plotDC = aDC;
|
|
|
|
|
|
|
|
aPanel->GetClientSize( &bitmapWidth, &bitmapHeight );
|
|
|
|
|
|
|
|
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.
|
|
|
|
// this is due to negative objects (drawn using background color) that create artifacts
|
|
|
|
// on other images when drawn on screen
|
|
|
|
bool useBufferBitmap = false;
|
|
|
|
|
|
|
|
#ifndef __WXMAC__
|
|
|
|
// Can't work with MAC
|
|
|
|
// Don't try this with retina display
|
|
|
|
if( (aDrawMode == GR_COPY) || ( aDrawMode == GR_OR ) )
|
|
|
|
useBufferBitmap = true;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// these parameters are saved here, because they are modified
|
|
|
|
// and restored later
|
|
|
|
EDA_RECT drawBox = *aPanel->GetClipBox();
|
|
|
|
double scale;
|
|
|
|
aDC->GetUserScale(&scale, &scale);
|
|
|
|
wxPoint dev_org = aDC->GetDeviceOrigin();
|
|
|
|
wxPoint logical_org = aDC->GetLogicalOrigin( );
|
|
|
|
|
2017-02-20 16:57:41 +00:00
|
|
|
COLOR4D bgColor = aDisplayOptions->m_BgDrawColor;
|
|
|
|
wxBrush bgBrush( bgColor.ToColour(), wxBRUSHSTYLE_SOLID );
|
2016-05-25 14:48:38 +00:00
|
|
|
|
|
|
|
if( useBufferBitmap )
|
|
|
|
{
|
|
|
|
layerBitmap = new wxBitmap( bitmapWidth, bitmapHeight );
|
|
|
|
screenBitmap = new wxBitmap( bitmapWidth, bitmapHeight );
|
|
|
|
layerDC.SelectObject( *layerBitmap );
|
|
|
|
aPanel->DoPrepareDC( layerDC );
|
|
|
|
aPanel->SetClipBox( drawBox );
|
|
|
|
layerDC.SetBackground( bgBrush );
|
|
|
|
layerDC.SetBackgroundMode( wxSOLID );
|
|
|
|
layerDC.Clear();
|
|
|
|
|
|
|
|
screenDC.SelectObject( *screenBitmap );
|
|
|
|
screenDC.SetBackground( bgBrush );
|
|
|
|
screenDC.SetBackgroundMode( wxSOLID );
|
|
|
|
screenDC.Clear();
|
|
|
|
|
|
|
|
plotDC = &layerDC;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool doBlit = false; // this flag requests an image transfer to actual screen when true.
|
|
|
|
|
|
|
|
bool end = false;
|
|
|
|
|
2016-06-02 09:30:39 +00:00
|
|
|
// Draw graphic layers from bottom to top, and the active layer is on the top of others.
|
|
|
|
// In non transparent modes, the last layer drawn masks others layers
|
2016-05-25 14:48:38 +00:00
|
|
|
for( int layer = GERBER_DRAWLAYERS_COUNT-1; !end; --layer )
|
|
|
|
{
|
2017-09-17 22:43:20 +00:00
|
|
|
int active_layer = gerbFrame->GetActiveLayer();
|
2016-05-25 14:48:38 +00:00
|
|
|
|
|
|
|
if( layer == active_layer ) // active layer will be drawn after other layers
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if( layer < 0 ) // last loop: draw active layer
|
|
|
|
{
|
|
|
|
end = true;
|
|
|
|
layer = active_layer;
|
|
|
|
}
|
|
|
|
|
2016-06-17 18:00:29 +00:00
|
|
|
GERBER_FILE_IMAGE* gerber = GetImagesList()->GetGbrImage( layer );
|
2016-05-25 14:48:38 +00:00
|
|
|
|
|
|
|
if( gerber == NULL ) // Graphic layer not yet used
|
|
|
|
continue;
|
|
|
|
|
2016-06-02 09:30:39 +00:00
|
|
|
if( aDisplayOptions->m_IsPrinting )
|
|
|
|
gerber->m_IsVisible = IsLayerPrintable( layer );
|
|
|
|
else
|
2017-09-17 22:43:20 +00:00
|
|
|
gerber->m_IsVisible = gerbFrame->IsLayerVisible( GERBER_DRAW_LAYER( layer ) );
|
2016-06-02 09:30:39 +00:00
|
|
|
|
|
|
|
if( !gerber->m_IsVisible )
|
|
|
|
continue;
|
|
|
|
|
2017-09-17 22:43:20 +00:00
|
|
|
gerber->m_PositiveDrawColor = gerbFrame->GetLayerColor( GERBER_DRAW_LAYER( layer ) );
|
2016-06-02 09:30:39 +00:00
|
|
|
|
|
|
|
// Force black and white draw mode on request:
|
|
|
|
if( aDisplayOptions->m_ForceBlackAndWhite )
|
|
|
|
gerber->m_PositiveDrawColor = ( aDisplayOptions->m_BgDrawColor == BLACK ) ? WHITE : BLACK;
|
2016-05-25 14:48:38 +00:00
|
|
|
|
|
|
|
if( useBufferBitmap )
|
|
|
|
{
|
|
|
|
// Draw each layer into a bitmap first. Negative Gerber
|
|
|
|
// layers are drawn in background color.
|
|
|
|
if( gerber->HasNegativeItems() && doBlit )
|
|
|
|
{
|
|
|
|
// Set Device origin, logical origin and scale to default values
|
|
|
|
// 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 );
|
|
|
|
|
|
|
|
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 );
|
2017-02-20 16:57:41 +00:00
|
|
|
layerBitmap->SetMask( new wxMask( *layerBitmap, bgColor.ToColour() ) );
|
2016-05-25 14:48:38 +00:00
|
|
|
layerDC.SelectObject( *layerBitmap );
|
|
|
|
screenDC.Blit( 0, 0, bitmapWidth, bitmapHeight, &layerDC, 0, 0, wxCOPY, true );
|
|
|
|
}
|
|
|
|
else if( aDrawMode == GR_OR )
|
|
|
|
{
|
|
|
|
// On Linux with a large screen, this version is much faster and without
|
|
|
|
// flicker, but gives a Pcbnew look where layer colors blend together.
|
|
|
|
// Plus it works only because the background color is black. But it may
|
|
|
|
// be more usable for some. The difference is due in part because of
|
|
|
|
// 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.
|
|
|
|
screenDC.Blit( 0, 0, bitmapWidth, bitmapHeight, &layerDC, 0, 0, wxOR );
|
|
|
|
}
|
|
|
|
// Restore actual values and clear bitmap for next drawing
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if( gerber->m_ImageNegative )
|
|
|
|
{
|
|
|
|
// Draw background negative (i.e. in graphic layer color) for negative images.
|
2017-02-20 16:57:41 +00:00
|
|
|
COLOR4D neg_color = gerber->GetPositiveDrawColor();
|
2016-05-25 14:48:38 +00:00
|
|
|
|
|
|
|
GRSetDrawMode( &layerDC, GR_COPY );
|
|
|
|
GRFilledRect( &drawBox, plotDC, drawBox.GetX(), drawBox.GetY(),
|
|
|
|
drawBox.GetRight(), drawBox.GetBottom(),
|
|
|
|
0, neg_color, neg_color );
|
|
|
|
|
|
|
|
GRSetDrawMode( plotDC, GR_COPY );
|
|
|
|
doBlit = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
int dcode_highlight = 0;
|
|
|
|
|
2017-09-17 22:43:20 +00:00
|
|
|
if( layer == gerbFrame->GetActiveLayer() )
|
2016-05-25 14:48:38 +00:00
|
|
|
dcode_highlight = gerber->m_Selected_Tool;
|
|
|
|
|
|
|
|
GR_DRAWMODE layerdrawMode = GR_COPY;
|
|
|
|
|
|
|
|
if( aDrawMode == GR_OR && !gerber->HasNegativeItems() )
|
|
|
|
layerdrawMode = GR_OR;
|
|
|
|
|
|
|
|
// Now we can draw the current layer to the bitmap buffer
|
|
|
|
// When needed, the previous bitmap is already copied to the screen buffer.
|
2016-05-26 11:57:43 +00:00
|
|
|
for( GERBER_DRAW_ITEM* item = gerber->GetItemsList(); item; item = item->Next() )
|
2016-05-25 14:48:38 +00:00
|
|
|
{
|
|
|
|
if( item->GetLayer() != layer )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
GR_DRAWMODE drawMode = layerdrawMode;
|
|
|
|
|
|
|
|
if( dcode_highlight && dcode_highlight == item->m_DCode )
|
|
|
|
DrawModeAddHighlight( &drawMode);
|
|
|
|
|
2016-08-16 10:56:20 +00:00
|
|
|
if( !aperAttrHighlight.IsEmpty() && item->GetDcodeDescr() &&
|
|
|
|
item->GetDcodeDescr()->m_AperFunction == aperAttrHighlight )
|
|
|
|
DrawModeAddHighlight( &drawMode);
|
|
|
|
|
|
|
|
if( !cmpHighlight.IsEmpty() &&
|
|
|
|
cmpHighlight == item->GetNetAttributes().m_Cmpref )
|
|
|
|
DrawModeAddHighlight( &drawMode);
|
|
|
|
|
|
|
|
if( !netHighlight.IsEmpty() &&
|
|
|
|
netHighlight == item->GetNetAttributes().m_Netname )
|
|
|
|
DrawModeAddHighlight( &drawMode);
|
|
|
|
|
2016-06-02 09:30:39 +00:00
|
|
|
item->Draw( aPanel, plotDC, drawMode, wxPoint(0,0), aDisplayOptions );
|
2016-05-25 14:48:38 +00:00
|
|
|
doBlit = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( doBlit && useBufferBitmap ) // Blit is used only if aDrawMode >= 0
|
|
|
|
{
|
|
|
|
// For this Blit call, layerDC and screenDC must have the same settings
|
|
|
|
// So we set device origin, logical origin and scale to default values
|
|
|
|
// in layerDC
|
|
|
|
layerDC.SetDeviceOrigin(0,0);
|
|
|
|
layerDC.SetLogicalOrigin( 0, 0 );
|
|
|
|
layerDC.SetUserScale( 1, 1 );
|
|
|
|
|
|
|
|
// this is the last transfer to screenDC. If there are no negative items, this is
|
|
|
|
// the only one
|
|
|
|
if( aDrawMode == GR_COPY )
|
|
|
|
{
|
|
|
|
layerDC.SelectObject( wxNullBitmap );
|
2017-02-20 16:57:41 +00:00
|
|
|
layerBitmap->SetMask( new wxMask( *layerBitmap, bgColor.ToColour() ) );
|
2016-05-25 14:48:38 +00:00
|
|
|
layerDC.SelectObject( *layerBitmap );
|
|
|
|
screenDC.Blit( 0, 0, bitmapWidth, bitmapHeight, &layerDC, 0, 0, wxCOPY, true );
|
|
|
|
|
|
|
|
}
|
|
|
|
else if( aDrawMode == GR_OR )
|
|
|
|
{
|
|
|
|
screenDC.Blit( 0, 0, bitmapWidth, bitmapHeight, &layerDC, 0, 0, wxOR );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( useBufferBitmap )
|
|
|
|
{
|
|
|
|
// For this Blit call, aDC and screenDC must have the same settings
|
|
|
|
// So we set device origin, logical origin and scale to default values
|
|
|
|
// in aDC
|
|
|
|
aDC->SetDeviceOrigin( 0, 0);
|
|
|
|
aDC->SetLogicalOrigin( 0, 0 );
|
|
|
|
aDC->SetUserScale( 1, 1 );
|
|
|
|
|
|
|
|
aDC->Blit( 0, 0, bitmapWidth, bitmapHeight, &screenDC, 0, 0, wxCOPY );
|
|
|
|
|
|
|
|
// Restore aDC values
|
|
|
|
aDC->SetDeviceOrigin(dev_org.x, dev_org.y);
|
|
|
|
aDC->SetLogicalOrigin( logical_org.x, logical_org.y );
|
|
|
|
aDC->SetUserScale( scale, scale );
|
|
|
|
|
|
|
|
layerDC.SelectObject( wxNullBitmap );
|
|
|
|
screenDC.SelectObject( wxNullBitmap );
|
|
|
|
delete layerBitmap;
|
|
|
|
delete screenBitmap;
|
|
|
|
}
|
|
|
|
}
|
2016-06-02 09:30:39 +00:00
|
|
|
|
|
|
|
|
|
|
|
void GBR_LAYOUT::DrawItemsDCodeID( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
|
2017-02-20 16:57:41 +00:00
|
|
|
GR_DRAWMODE aDrawMode, COLOR4D aDrawColor )
|
2016-06-02 09:30:39 +00:00
|
|
|
{
|
|
|
|
wxString Line;
|
|
|
|
|
|
|
|
GRSetDrawMode( aDC, aDrawMode );
|
|
|
|
|
2016-06-17 18:00:29 +00:00
|
|
|
for( unsigned layer = 0; layer < GetImagesList()->ImagesMaxCount(); ++layer )
|
2016-06-02 09:30:39 +00:00
|
|
|
{
|
2016-06-17 18:00:29 +00:00
|
|
|
GERBER_FILE_IMAGE* gerber = GetImagesList()->GetGbrImage( layer );
|
2016-06-02 09:30:39 +00:00
|
|
|
|
|
|
|
if( gerber == NULL ) // Graphic layer not yet used
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if( ! gerber->m_IsVisible )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
for( GERBER_DRAW_ITEM* item = gerber->GetItemsList(); item != NULL; item = item->Next() )
|
|
|
|
{
|
2017-11-13 10:30:23 +00:00
|
|
|
wxPoint pos;
|
|
|
|
int size;
|
|
|
|
double orient;
|
2016-06-02 09:30:39 +00:00
|
|
|
|
2017-11-13 10:30:23 +00:00
|
|
|
if( ! item->GetTextD_CodePrms( size, pos, orient ) )
|
2016-06-02 09:30:39 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
Line.Printf( wxT( "D%d" ), item->m_DCode );
|
|
|
|
|
2017-11-13 08:11:54 +00:00
|
|
|
// Avoid to draw text, if it is too small (size in pixel < 5 pixels)
|
|
|
|
// to be readable:
|
2017-11-13 10:30:23 +00:00
|
|
|
int size_pixel = aDC->LogicalToDeviceXRel( size );
|
2017-11-13 08:11:54 +00:00
|
|
|
const int threshold = 5;
|
|
|
|
|
|
|
|
if( size_pixel >= threshold )
|
|
|
|
{
|
|
|
|
DrawGraphicText( aPanel->GetClipBox(), aDC, pos, aDrawColor, Line,
|
2017-11-13 10:30:23 +00:00
|
|
|
orient, wxSize( size, size ),
|
2017-11-13 08:11:54 +00:00
|
|
|
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
|
|
|
|
0, false, false );
|
|
|
|
}
|
2016-06-02 09:30:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-09-17 22:43:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
SEARCH_RESULT GBR_LAYOUT::Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] )
|
|
|
|
{
|
|
|
|
KICAD_T stype;
|
|
|
|
SEARCH_RESULT result = SEARCH_CONTINUE;
|
|
|
|
const KICAD_T* p = scanTypes;
|
|
|
|
bool done = false;
|
|
|
|
|
|
|
|
#if 0 && defined(DEBUG)
|
|
|
|
std::cout << GetClass().mb_str() << ' ';
|
|
|
|
#endif
|
|
|
|
|
|
|
|
while( !done )
|
|
|
|
{
|
|
|
|
stype = *p;
|
|
|
|
|
|
|
|
switch( stype )
|
|
|
|
{
|
|
|
|
case GERBER_IMAGE_LIST_T:
|
|
|
|
for( unsigned layer = 0; layer < GetImagesList()->ImagesMaxCount(); ++layer )
|
|
|
|
{
|
|
|
|
GERBER_FILE_IMAGE* gerber = GetImagesList()->GetGbrImage( layer );
|
|
|
|
|
|
|
|
if( gerber == NULL ) // Graphic layer not yet used
|
|
|
|
continue;
|
|
|
|
|
|
|
|
result = gerber->Visit( inspector, testData, p );
|
|
|
|
|
|
|
|
if( result == SEARCH_QUIT )
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
++p;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default: // catch EOT or ANY OTHER type here and return.
|
|
|
|
done = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( result == SEARCH_QUIT )
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|