2012-09-24 16:03:03 +00:00
|
|
|
/**
|
|
|
|
* @file plot_brditems_plotter.cpp
|
|
|
|
* @brief basic plot functions to plot board items, or a group of board items.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2017-05-03 18:04:31 +00:00
|
|
|
* Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors.
|
2012-09-24 16:03:03 +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
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <fctsys.h>
|
|
|
|
#include <common.h>
|
2018-01-28 18:12:26 +00:00
|
|
|
#include <plotter.h>
|
2012-09-24 16:03:03 +00:00
|
|
|
#include <base_struct.h>
|
2018-01-28 21:02:31 +00:00
|
|
|
#include <draw_graphic_text.h>
|
2012-09-24 16:03:03 +00:00
|
|
|
#include <trigo.h>
|
2013-05-02 18:06:58 +00:00
|
|
|
#include <macros.h>
|
2018-01-29 15:39:40 +00:00
|
|
|
#include <pcb_base_frame.h>
|
2012-09-24 16:03:03 +00:00
|
|
|
|
|
|
|
#include <class_board.h>
|
|
|
|
#include <class_module.h>
|
|
|
|
#include <class_track.h>
|
|
|
|
#include <class_edge_mod.h>
|
|
|
|
#include <class_pcb_text.h>
|
|
|
|
#include <class_zone.h>
|
|
|
|
#include <class_drawsegment.h>
|
2017-10-31 15:38:10 +00:00
|
|
|
#include <class_pcb_target.h>
|
2012-09-24 16:03:03 +00:00
|
|
|
#include <class_dimension.h>
|
|
|
|
|
|
|
|
#include <pcbnew.h>
|
|
|
|
#include <pcbplot.h>
|
2016-09-19 11:01:36 +00:00
|
|
|
#include <plot_auxiliary_data.h>
|
2012-09-24 16:03:03 +00:00
|
|
|
|
|
|
|
/* class BRDITEMS_PLOTTER is a helper class to plot board items
|
|
|
|
* and a group of board items
|
|
|
|
*/
|
|
|
|
|
2017-02-20 16:57:41 +00:00
|
|
|
COLOR4D BRDITEMS_PLOTTER::getColor( LAYER_NUM aLayer )
|
2012-09-24 16:03:03 +00:00
|
|
|
{
|
2017-08-04 12:43:02 +00:00
|
|
|
COLOR4D color = m_board->Colors().GetLayerColor( ToLAYER_ID( aLayer ) );
|
2017-10-08 14:08:42 +00:00
|
|
|
|
|
|
|
// A hack to avoid plotting ahite itmen in white color, expecting the paper
|
|
|
|
// is also white: use a non white color:
|
2017-02-20 17:48:27 +00:00
|
|
|
if( color == COLOR4D::WHITE )
|
2017-02-20 16:57:41 +00:00
|
|
|
color = COLOR4D( LIGHTGRAY );
|
2017-10-08 14:08:42 +00:00
|
|
|
|
2012-09-24 16:03:03 +00:00
|
|
|
return color;
|
|
|
|
}
|
|
|
|
|
2013-03-20 14:50:12 +00:00
|
|
|
|
2017-02-20 16:57:41 +00:00
|
|
|
void BRDITEMS_PLOTTER::PlotPad( D_PAD* aPad, COLOR4D aColor, EDA_DRAW_MODE_T aPlotMode )
|
2012-09-25 07:49:29 +00:00
|
|
|
{
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
wxPoint shape_pos = aPad->ShapePos();
|
2016-09-19 11:01:36 +00:00
|
|
|
GBR_METADATA gbr_metadata;
|
|
|
|
|
|
|
|
bool isOnCopperLayer = ( m_layerMask & LSET::AllCuMask() ).any();
|
|
|
|
bool isOnExternalCopperLayer = ( m_layerMask & LSET::ExternalCuMask() ).any();
|
|
|
|
bool isPadOnBoardTechLayers = ( aPad->GetLayerSet() & LSET::AllBoardTechMask() ).any();
|
|
|
|
|
|
|
|
gbr_metadata.SetCmpReference( aPad->GetParent()->GetReference() );
|
|
|
|
|
|
|
|
if( isOnCopperLayer )
|
|
|
|
{
|
|
|
|
gbr_metadata.SetNetAttribType( GBR_NETINFO_ALL );
|
2017-05-03 18:04:31 +00:00
|
|
|
gbr_metadata.SetCopper( true );
|
2016-09-19 11:01:36 +00:00
|
|
|
|
|
|
|
if( isOnExternalCopperLayer )
|
2017-08-11 09:22:13 +00:00
|
|
|
gbr_metadata.SetPadName( aPad->GetName() );
|
2016-09-19 11:01:36 +00:00
|
|
|
|
|
|
|
gbr_metadata.SetNetName( aPad->GetNetname() );
|
|
|
|
|
|
|
|
// Some pads are mechanical pads ( through hole or smd )
|
|
|
|
// when this is the case, they have no pad name and/or are not plated.
|
|
|
|
// In this case gerber files have slightly different attributes.
|
|
|
|
if( aPad->GetAttribute() == PAD_ATTRIB_HOLE_NOT_PLATED ||
|
2017-08-11 09:22:13 +00:00
|
|
|
aPad->GetName().IsEmpty() )
|
2016-09-19 11:01:36 +00:00
|
|
|
gbr_metadata.m_NetlistMetadata.m_NotInNet = true;
|
|
|
|
|
|
|
|
if( !isOnExternalCopperLayer || !isPadOnBoardTechLayers )
|
|
|
|
{
|
|
|
|
// On internal layers one cannot use the GBR_NETLIST_METADATA::GBR_INFO_FLASHED_PAD
|
|
|
|
// attribute when the component is on an external layer (most of the case)
|
|
|
|
// Also, if a SMD pad is not on a tech layer (masks) use also net+cmp attribute, because
|
|
|
|
// it is not really a pad (can be a "pad", actually a node in a virtual component)
|
|
|
|
gbr_metadata.SetNetAttribType( GBR_NETLIST_METADATA::GBR_NETINFO_NET |
|
|
|
|
GBR_NETLIST_METADATA::GBR_NETINFO_CMP );
|
|
|
|
|
|
|
|
if( !isPadOnBoardTechLayers )
|
|
|
|
// such a pad is not soldered and is not a connecting point.
|
|
|
|
// Just set aperture attribute as conductor
|
|
|
|
// If it is a through hole pad, it will be adjusted later
|
|
|
|
gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CONDUCTOR );
|
|
|
|
|
|
|
|
switch( aPad->GetAttribute() )
|
|
|
|
{
|
|
|
|
case PAD_ATTRIB_HOLE_NOT_PLATED: // Mechanical pad through hole
|
|
|
|
gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_WASHERPAD );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PAD_ATTRIB_STANDARD : // Pad through hole, a hole is also expected
|
|
|
|
gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_VIAPAD );
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else // Some attributes are reserved to the external copper layers
|
|
|
|
{
|
|
|
|
switch( aPad->GetAttribute() )
|
|
|
|
{
|
|
|
|
case PAD_ATTRIB_HOLE_NOT_PLATED: // Mechanical pad through hole
|
|
|
|
gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_WASHERPAD );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PAD_ATTRIB_STANDARD : // Pad through hole, a hole is also expected
|
|
|
|
gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_COMPONENTPAD );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PAD_ATTRIB_CONN: // Connector pads have no solder paste.
|
|
|
|
gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CONNECTORPAD );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PAD_ATTRIB_SMD: // SMD pads (One external copper layer only) with solder paste
|
|
|
|
if( aPad->GetShape() == PAD_SHAPE_CIRCLE ) // perhaps a BGA pad
|
|
|
|
gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_BGAPAD_CUDEF );
|
|
|
|
else
|
|
|
|
gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_SMDPAD_CUDEF );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( aPad->GetAttribute() == PAD_ATTRIB_HOLE_NOT_PLATED )
|
|
|
|
gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_WASHERPAD );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gbr_metadata.SetNetAttribType( GBR_NETLIST_METADATA::GBR_NETINFO_CMP );
|
|
|
|
}
|
2012-09-25 07:49:29 +00:00
|
|
|
|
|
|
|
// Set plot color (change WHITE to LIGHTGRAY because
|
|
|
|
// the white items are not seen on a white paper or screen
|
|
|
|
m_plotter->SetColor( aColor != WHITE ? aColor : LIGHTGRAY);
|
|
|
|
|
|
|
|
switch( aPad->GetShape() )
|
|
|
|
{
|
2015-08-23 19:40:33 +00:00
|
|
|
case PAD_SHAPE_CIRCLE:
|
2016-09-19 11:01:36 +00:00
|
|
|
m_plotter->FlashPadCircle( shape_pos, aPad->GetSize().x, aPlotMode, &gbr_metadata );
|
2012-09-25 07:49:29 +00:00
|
|
|
break;
|
|
|
|
|
2015-08-23 19:40:33 +00:00
|
|
|
case PAD_SHAPE_OVAL:
|
2012-09-25 07:49:29 +00:00
|
|
|
m_plotter->FlashPadOval( shape_pos, aPad->GetSize(),
|
2016-09-19 11:01:36 +00:00
|
|
|
aPad->GetOrientation(), aPlotMode, &gbr_metadata );
|
2012-09-25 07:49:29 +00:00
|
|
|
break;
|
|
|
|
|
2015-08-23 19:40:33 +00:00
|
|
|
case PAD_SHAPE_TRAPEZOID:
|
2012-09-25 07:49:29 +00:00
|
|
|
{
|
2016-04-06 18:15:49 +00:00
|
|
|
wxPoint coord[4];
|
|
|
|
aPad->BuildPadPolygon( coord, wxSize(0,0), 0 );
|
|
|
|
m_plotter->FlashPadTrapez( shape_pos, coord,
|
2016-09-19 11:01:36 +00:00
|
|
|
aPad->GetOrientation(), aPlotMode, &gbr_metadata );
|
2012-09-25 07:49:29 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2016-04-06 18:15:49 +00:00
|
|
|
case PAD_SHAPE_ROUNDRECT:
|
|
|
|
m_plotter->FlashPadRoundRect( shape_pos, aPad->GetSize(), aPad->GetRoundRectCornerRadius(),
|
2016-09-19 11:01:36 +00:00
|
|
|
aPad->GetOrientation(), aPlotMode, &gbr_metadata );
|
2016-04-06 18:15:49 +00:00
|
|
|
break;
|
|
|
|
|
2017-01-13 17:51:22 +00:00
|
|
|
case PAD_SHAPE_CUSTOM:
|
|
|
|
{
|
|
|
|
SHAPE_POLY_SET polygons;
|
2017-09-20 08:28:52 +00:00
|
|
|
aPad->MergePrimitivesAsPolygon(&polygons, 64 );
|
2017-01-13 17:51:22 +00:00
|
|
|
|
|
|
|
if( polygons.OutlineCount() == 0 )
|
|
|
|
break;
|
|
|
|
|
2017-09-20 08:28:52 +00:00
|
|
|
aPad->CustomShapeAsPolygonToBoardPosition( &polygons, shape_pos, aPad->GetOrientation() );
|
2017-01-13 17:51:22 +00:00
|
|
|
m_plotter->FlashPadCustom( shape_pos, aPad->GetSize(), &polygons, aPlotMode, &gbr_metadata );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2015-08-23 19:40:33 +00:00
|
|
|
case PAD_SHAPE_RECT:
|
2012-09-25 07:49:29 +00:00
|
|
|
default:
|
|
|
|
m_plotter->FlashPadRect( shape_pos, aPad->GetSize(),
|
2016-09-19 11:01:36 +00:00
|
|
|
aPad->GetOrientation(), aPlotMode, &gbr_metadata );
|
2012-09-25 07:49:29 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-20 14:50:12 +00:00
|
|
|
|
2012-09-24 16:03:03 +00:00
|
|
|
bool BRDITEMS_PLOTTER::PlotAllTextsModule( MODULE* aModule )
|
|
|
|
{
|
|
|
|
// see if we want to plot VALUE and REF fields
|
|
|
|
bool trace_val = GetPlotValue();
|
|
|
|
bool trace_ref = GetPlotReference();
|
|
|
|
|
2013-03-13 18:53:58 +00:00
|
|
|
TEXTE_MODULE* textModule = &aModule->Reference();
|
2013-03-31 13:27:46 +00:00
|
|
|
LAYER_NUM textLayer = textModule->GetLayer();
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2017-03-13 03:19:33 +00:00
|
|
|
if( textLayer >= PCB_LAYER_ID_COUNT ) // how will this ever be true?
|
2012-09-24 16:03:03 +00:00
|
|
|
return false;
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
if( !m_layerMask[textLayer] )
|
2012-09-24 16:03:03 +00:00
|
|
|
trace_ref = false;
|
|
|
|
|
|
|
|
if( !textModule->IsVisible() && !GetPlotInvisibleText() )
|
|
|
|
trace_ref = false;
|
|
|
|
|
2013-03-13 18:53:58 +00:00
|
|
|
textModule = &aModule->Value();
|
2012-09-24 16:03:03 +00:00
|
|
|
textLayer = textModule->GetLayer();
|
|
|
|
|
2017-03-13 03:19:33 +00:00
|
|
|
if( textLayer > PCB_LAYER_ID_COUNT ) // how will this ever be true?
|
2012-09-24 16:03:03 +00:00
|
|
|
return false;
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
if( !m_layerMask[textLayer] )
|
2012-09-24 16:03:03 +00:00
|
|
|
trace_val = false;
|
|
|
|
|
|
|
|
if( !textModule->IsVisible() && !GetPlotInvisibleText() )
|
|
|
|
trace_val = false;
|
|
|
|
|
|
|
|
// Plot text fields, if allowed
|
|
|
|
if( trace_ref )
|
|
|
|
{
|
2017-07-31 12:28:35 +00:00
|
|
|
PlotTextModule( &aModule->Reference(), getColor( textLayer ) );
|
2012-09-24 16:03:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( trace_val )
|
|
|
|
{
|
2017-07-31 12:28:35 +00:00
|
|
|
PlotTextModule( &aModule->Value(), getColor( textLayer ) );
|
2012-09-24 16:03:03 +00:00
|
|
|
}
|
|
|
|
|
2017-06-23 11:56:28 +00:00
|
|
|
for( BOARD_ITEM* item = aModule->GraphicalItemsList().GetFirst(); item; item = item->Next() )
|
2012-09-24 16:03:03 +00:00
|
|
|
{
|
2014-06-06 09:44:21 +00:00
|
|
|
textModule = dyn_cast<TEXTE_MODULE*>( item );
|
|
|
|
|
2014-04-30 19:16:22 +00:00
|
|
|
if( !textModule )
|
2012-09-24 16:03:03 +00:00
|
|
|
continue;
|
|
|
|
|
2014-05-19 18:24:07 +00:00
|
|
|
if( !textModule->IsVisible() )
|
2012-09-24 16:03:03 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
textLayer = textModule->GetLayer();
|
|
|
|
|
2017-03-13 03:19:33 +00:00
|
|
|
if( textLayer >= PCB_LAYER_ID_COUNT )
|
2012-09-24 16:03:03 +00:00
|
|
|
return false;
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
if( !m_layerMask[textLayer] )
|
2012-09-24 16:03:03 +00:00
|
|
|
continue;
|
|
|
|
|
2018-02-21 18:44:28 +00:00
|
|
|
if( textModule->GetText() == wxT( "%R" ) && !GetPlotReference() )
|
2018-02-10 20:47:19 +00:00
|
|
|
continue;
|
|
|
|
|
2018-02-21 18:44:28 +00:00
|
|
|
if( textModule->GetText() == wxT( "%V" ) && !GetPlotValue() )
|
2018-02-10 20:47:19 +00:00
|
|
|
continue;
|
|
|
|
|
2012-09-24 16:03:03 +00:00
|
|
|
PlotTextModule( textModule, getColor( textLayer ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// plot items like text and graphics, but not tracks and module
|
|
|
|
void BRDITEMS_PLOTTER::PlotBoardGraphicItems()
|
|
|
|
{
|
2016-09-27 18:04:30 +00:00
|
|
|
for( auto item : m_board->Drawings() )
|
2012-09-24 16:03:03 +00:00
|
|
|
{
|
|
|
|
switch( item->Type() )
|
|
|
|
{
|
|
|
|
case PCB_LINE_T:
|
|
|
|
PlotDrawSegment( (DRAWSEGMENT*) item);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PCB_TEXT_T:
|
|
|
|
PlotTextePcb( (TEXTE_PCB*) item );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PCB_DIMENSION_T:
|
|
|
|
PlotDimension( (DIMENSION*) item );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PCB_TARGET_T:
|
|
|
|
PlotPcbTarget( (PCB_TARGET*) item );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PCB_MARKER_T:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-20 16:57:41 +00:00
|
|
|
void BRDITEMS_PLOTTER::PlotTextModule( TEXTE_MODULE* pt_texte, COLOR4D aColor )
|
2012-09-24 16:03:03 +00:00
|
|
|
{
|
|
|
|
wxSize size;
|
|
|
|
wxPoint pos;
|
2013-05-05 07:17:48 +00:00
|
|
|
double orient;
|
|
|
|
int thickness;
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2017-02-20 17:48:27 +00:00
|
|
|
if( aColor == COLOR4D::WHITE )
|
2017-02-20 16:57:41 +00:00
|
|
|
aColor = COLOR4D( LIGHTGRAY );
|
2013-03-20 14:50:12 +00:00
|
|
|
|
2012-09-24 16:03:03 +00:00
|
|
|
m_plotter->SetColor( aColor );
|
|
|
|
|
|
|
|
// calculate some text parameters :
|
2017-01-23 20:30:11 +00:00
|
|
|
size = pt_texte->GetTextSize();
|
|
|
|
pos = pt_texte->GetTextPos();
|
2012-09-24 16:03:03 +00:00
|
|
|
|
|
|
|
orient = pt_texte->GetDrawRotation();
|
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
thickness = pt_texte->GetThickness();
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
if( pt_texte->IsMirrored() )
|
2015-06-26 13:41:56 +00:00
|
|
|
size.x = -size.x; // Text is mirrored
|
2012-09-24 16:03:03 +00:00
|
|
|
|
|
|
|
// Non bold texts thickness is clamped at 1/6 char size by the low level draw function.
|
|
|
|
// but in Pcbnew we do not manage bold texts and thickness up to 1/4 char size
|
|
|
|
// (like bold text) and we manage the thickness.
|
|
|
|
// So we set bold flag to true
|
2013-03-18 19:36:07 +00:00
|
|
|
bool allow_bold = pt_texte->IsBold() || thickness;
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2016-09-19 11:01:36 +00:00
|
|
|
GBR_METADATA gbr_metadata;
|
|
|
|
gbr_metadata.SetNetAttribType( GBR_NETLIST_METADATA::GBR_NETINFO_CMP );
|
|
|
|
MODULE* parent = static_cast<MODULE*> ( pt_texte->GetParent() );
|
|
|
|
gbr_metadata.SetCmpReference( parent->GetReference() );
|
|
|
|
|
2012-09-24 16:03:03 +00:00
|
|
|
m_plotter->Text( pos, aColor,
|
2014-09-13 18:15:45 +00:00
|
|
|
pt_texte->GetShownText(),
|
2013-03-13 18:53:58 +00:00
|
|
|
orient, size,
|
2013-03-18 19:36:07 +00:00
|
|
|
pt_texte->GetHorizJustify(), pt_texte->GetVertJustify(),
|
2016-09-19 11:01:36 +00:00
|
|
|
thickness, pt_texte->IsItalic(), allow_bold, false, &gbr_metadata );
|
2012-09-24 16:03:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BRDITEMS_PLOTTER::PlotDimension( DIMENSION* aDim )
|
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
if( !m_layerMask[aDim->GetLayer()] )
|
2012-09-24 16:03:03 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
DRAWSEGMENT draw;
|
|
|
|
|
2015-02-02 08:06:39 +00:00
|
|
|
draw.SetWidth( aDim->GetWidth() );
|
2012-09-24 16:03:03 +00:00
|
|
|
draw.SetLayer( aDim->GetLayer() );
|
|
|
|
|
2017-08-04 12:43:02 +00:00
|
|
|
COLOR4D color = m_board->Colors().GetLayerColor( aDim->GetLayer() );
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2017-08-04 12:43:02 +00:00
|
|
|
// Set plot color (change WHITE to LIGHTGRAY because
|
|
|
|
// the white items are not seen on a white paper or screen
|
|
|
|
m_plotter->SetColor( color != WHITE ? color : LIGHTGRAY);
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2013-03-13 18:53:58 +00:00
|
|
|
PlotTextePcb( &aDim->Text() );
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2012-12-19 19:31:36 +00:00
|
|
|
draw.SetStart( aDim->m_crossBarO );
|
|
|
|
draw.SetEnd( aDim->m_crossBarF );
|
2012-09-24 16:03:03 +00:00
|
|
|
PlotDrawSegment( &draw );
|
|
|
|
|
2012-12-19 19:31:36 +00:00
|
|
|
draw.SetStart( aDim->m_featureLineGO);
|
|
|
|
draw.SetEnd( aDim->m_featureLineGF );
|
2012-09-24 16:03:03 +00:00
|
|
|
PlotDrawSegment( &draw );
|
|
|
|
|
2012-12-19 19:31:36 +00:00
|
|
|
draw.SetStart( aDim->m_featureLineDO );
|
|
|
|
draw.SetEnd( aDim->m_featureLineDF );
|
2012-09-24 16:03:03 +00:00
|
|
|
PlotDrawSegment( &draw );
|
|
|
|
|
2014-02-11 12:22:30 +00:00
|
|
|
draw.SetStart( aDim->m_crossBarF );
|
2012-12-19 19:31:36 +00:00
|
|
|
draw.SetEnd( aDim->m_arrowD1F );
|
2012-09-24 16:03:03 +00:00
|
|
|
PlotDrawSegment( &draw );
|
|
|
|
|
2014-02-11 12:22:30 +00:00
|
|
|
draw.SetStart( aDim->m_crossBarF );
|
2012-12-19 19:31:36 +00:00
|
|
|
draw.SetEnd( aDim->m_arrowD2F );
|
2012-09-24 16:03:03 +00:00
|
|
|
PlotDrawSegment( &draw );
|
|
|
|
|
2014-02-11 12:22:30 +00:00
|
|
|
draw.SetStart( aDim->m_crossBarO );
|
2012-12-19 19:31:36 +00:00
|
|
|
draw.SetEnd( aDim->m_arrowG1F );
|
2012-09-24 16:03:03 +00:00
|
|
|
PlotDrawSegment( &draw );
|
|
|
|
|
2014-02-11 12:22:30 +00:00
|
|
|
draw.SetStart( aDim->m_crossBarO );
|
2012-12-19 19:31:36 +00:00
|
|
|
draw.SetEnd( aDim->m_arrowG2F );
|
2012-09-24 16:03:03 +00:00
|
|
|
PlotDrawSegment( &draw );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BRDITEMS_PLOTTER::PlotPcbTarget( PCB_TARGET* aMire )
|
|
|
|
{
|
|
|
|
int dx1, dx2, dy1, dy2, radius;
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
if( !m_layerMask[aMire->GetLayer()] )
|
2012-09-24 16:03:03 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
m_plotter->SetColor( getColor( aMire->GetLayer() ) );
|
|
|
|
|
|
|
|
DRAWSEGMENT draw;
|
|
|
|
|
|
|
|
draw.SetShape( S_CIRCLE );
|
2015-02-02 08:06:39 +00:00
|
|
|
draw.SetWidth( aMire->GetWidth() );
|
2012-09-24 16:03:03 +00:00
|
|
|
draw.SetLayer( aMire->GetLayer() );
|
|
|
|
draw.SetStart( aMire->GetPosition() );
|
|
|
|
radius = aMire->GetSize() / 3;
|
2013-03-20 14:50:12 +00:00
|
|
|
|
2012-09-24 16:03:03 +00:00
|
|
|
if( aMire->GetShape() ) // shape X
|
|
|
|
radius = aMire->GetSize() / 2;
|
|
|
|
|
|
|
|
// Draw the circle
|
|
|
|
draw.SetEnd( wxPoint( draw.GetStart().x + radius, draw.GetStart().y ));
|
|
|
|
|
|
|
|
PlotDrawSegment( &draw );
|
|
|
|
|
|
|
|
draw.SetShape( S_SEGMENT );
|
|
|
|
|
|
|
|
radius = aMire->GetSize() / 2;
|
|
|
|
dx1 = radius;
|
|
|
|
dy1 = 0;
|
|
|
|
dx2 = 0;
|
|
|
|
dy2 = radius;
|
|
|
|
|
|
|
|
if( aMire->GetShape() ) // Shape X
|
|
|
|
{
|
|
|
|
dx1 = dy1 = radius;
|
|
|
|
dx2 = dx1;
|
|
|
|
dy2 = -dy1;
|
|
|
|
}
|
|
|
|
|
|
|
|
wxPoint mirePos( aMire->GetPosition() );
|
|
|
|
|
|
|
|
// Draw the X or + shape:
|
|
|
|
draw.SetStart( wxPoint( mirePos.x - dx1, mirePos.y - dy1 ));
|
|
|
|
draw.SetEnd( wxPoint( mirePos.x + dx1, mirePos.y + dy1 ));
|
|
|
|
PlotDrawSegment( &draw );
|
|
|
|
|
|
|
|
draw.SetStart( wxPoint( mirePos.x - dx2, mirePos.y - dy2 ));
|
|
|
|
draw.SetEnd( wxPoint( mirePos.x + dx2, mirePos.y + dy2 ));
|
|
|
|
PlotDrawSegment( &draw );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Plot footprints graphic items (outlines)
|
|
|
|
void BRDITEMS_PLOTTER::Plot_Edges_Modules()
|
|
|
|
{
|
|
|
|
for( MODULE* module = m_board->m_Modules; module; module = module->Next() )
|
|
|
|
{
|
2017-04-25 09:06:24 +00:00
|
|
|
for( BOARD_ITEM* item = module->GraphicalItemsList().GetFirst(); item; item = item->Next() )
|
2012-09-24 16:03:03 +00:00
|
|
|
{
|
2014-06-06 09:44:21 +00:00
|
|
|
EDGE_MODULE* edge = dyn_cast<EDGE_MODULE*>( item );
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2016-04-18 15:48:39 +00:00
|
|
|
if( edge && m_layerMask[edge->GetLayer()] )
|
|
|
|
Plot_1_EdgeModule( edge );
|
2012-09-24 16:03:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//* Plot a graphic item (outline) relative to a footprint
|
|
|
|
void BRDITEMS_PLOTTER::Plot_1_EdgeModule( EDGE_MODULE* aEdge )
|
|
|
|
{
|
|
|
|
int type_trace; // Type of item to plot.
|
|
|
|
int thickness; // Segment thickness.
|
|
|
|
int radius; // Circle radius.
|
|
|
|
|
|
|
|
if( aEdge->Type() != PCB_MODULE_EDGE_T )
|
|
|
|
return;
|
|
|
|
|
|
|
|
m_plotter->SetColor( getColor( aEdge->GetLayer() ) );
|
|
|
|
|
|
|
|
type_trace = aEdge->GetShape();
|
|
|
|
thickness = aEdge->GetWidth();
|
|
|
|
|
|
|
|
wxPoint pos( aEdge->GetStart() );
|
|
|
|
wxPoint end( aEdge->GetEnd() );
|
|
|
|
|
2016-09-19 11:01:36 +00:00
|
|
|
GBR_METADATA gbr_metadata;
|
|
|
|
gbr_metadata.SetNetAttribType( GBR_NETLIST_METADATA::GBR_NETINFO_CMP );
|
|
|
|
MODULE* parent = static_cast<MODULE*> ( aEdge->GetParent() );
|
|
|
|
gbr_metadata.SetCmpReference( parent->GetReference() );
|
|
|
|
|
|
|
|
bool isOnCopperLayer = ( m_layerMask & LSET::AllCuMask() ).any();
|
|
|
|
|
|
|
|
if( isOnCopperLayer )
|
|
|
|
{
|
|
|
|
gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_ETCHEDCMP );
|
2017-05-03 18:04:31 +00:00
|
|
|
gbr_metadata.SetCopper( true );
|
2016-09-19 11:01:36 +00:00
|
|
|
}
|
|
|
|
else if( aEdge->GetLayer() == Edge_Cuts ) // happens also when plotting copper layers
|
|
|
|
{
|
|
|
|
gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_NONCONDUCTOR );
|
|
|
|
}
|
|
|
|
|
2012-09-24 16:03:03 +00:00
|
|
|
switch( type_trace )
|
|
|
|
{
|
|
|
|
case S_SEGMENT:
|
2016-09-19 11:01:36 +00:00
|
|
|
m_plotter->ThickSegment( pos, end, thickness, GetPlotMode(), &gbr_metadata );
|
2012-09-24 16:03:03 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case S_CIRCLE:
|
2013-05-01 17:32:36 +00:00
|
|
|
radius = KiROUND( GetLineLength( end, pos ) );
|
2016-09-19 11:01:36 +00:00
|
|
|
m_plotter->ThickCircle( pos, radius * 2, thickness, GetPlotMode(), &gbr_metadata );
|
2012-09-24 16:03:03 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case S_ARC:
|
2013-03-20 14:50:12 +00:00
|
|
|
{
|
2013-05-01 17:32:36 +00:00
|
|
|
radius = KiROUND( GetLineLength( end, pos ) );
|
2013-03-20 14:50:12 +00:00
|
|
|
double startAngle = ArcTangente( end.y - pos.y, end.x - pos.x );
|
|
|
|
double endAngle = startAngle + aEdge->GetAngle();
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2018-02-04 16:22:14 +00:00
|
|
|
// when startAngle == endAngle ThickArc() doesn't know whether it's 0 deg and 360 deg
|
|
|
|
if( std::abs( aEdge->GetAngle() ) == 3600.0 )
|
|
|
|
m_plotter->ThickCircle( pos, radius * 2, thickness, GetPlotMode(), &gbr_metadata );
|
|
|
|
else
|
|
|
|
m_plotter->ThickArc( pos, -endAngle, -startAngle, radius, thickness, GetPlotMode(), &gbr_metadata );
|
2013-03-20 14:50:12 +00:00
|
|
|
}
|
|
|
|
break;
|
2012-09-24 16:03:03 +00:00
|
|
|
|
|
|
|
case S_POLYGON:
|
2018-01-24 13:22:43 +00:00
|
|
|
if( aEdge->IsPolyShapeValid() )
|
|
|
|
{
|
|
|
|
const std::vector<wxPoint>& polyPoints = aEdge->BuildPolyPointsList();
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2018-01-24 13:22:43 +00:00
|
|
|
// We must compute true coordinates from m_PolyList
|
|
|
|
// which are relative to module position, orientation 0
|
|
|
|
MODULE* module = aEdge->GetParentModule();
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2018-01-24 13:22:43 +00:00
|
|
|
std::vector< wxPoint > cornerList;
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2018-01-24 13:22:43 +00:00
|
|
|
cornerList.reserve( polyPoints.size() );
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2018-01-24 13:22:43 +00:00
|
|
|
for( unsigned ii = 0; ii < polyPoints.size(); ii++ )
|
|
|
|
{
|
|
|
|
wxPoint corner = polyPoints[ii];
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2018-01-24 13:22:43 +00:00
|
|
|
if( module )
|
|
|
|
{
|
|
|
|
RotatePoint( &corner, module->GetOrientation() );
|
|
|
|
corner += module->GetPosition();
|
|
|
|
}
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2018-01-24 13:22:43 +00:00
|
|
|
cornerList.push_back( corner );
|
2012-09-24 16:03:03 +00:00
|
|
|
}
|
|
|
|
|
2018-01-24 13:22:43 +00:00
|
|
|
m_plotter->PlotPoly( cornerList, FILLED_SHAPE, thickness, &gbr_metadata );
|
2012-09-24 16:03:03 +00:00
|
|
|
}
|
2013-03-20 14:50:12 +00:00
|
|
|
break;
|
2012-09-24 16:03:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-09-19 11:01:36 +00:00
|
|
|
// Plot a PCB Text, i.e. a text found on a copper or technical layer
|
2012-09-24 16:03:03 +00:00
|
|
|
void BRDITEMS_PLOTTER::PlotTextePcb( TEXTE_PCB* pt_texte )
|
|
|
|
{
|
2013-05-05 07:17:48 +00:00
|
|
|
double orient;
|
|
|
|
int thickness;
|
2012-09-24 16:03:03 +00:00
|
|
|
wxPoint pos;
|
|
|
|
wxSize size;
|
2014-09-13 18:15:45 +00:00
|
|
|
wxString shownText( pt_texte->GetShownText() );
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2014-09-13 18:15:45 +00:00
|
|
|
if( shownText.IsEmpty() )
|
2012-09-24 16:03:03 +00:00
|
|
|
return;
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
if( !m_layerMask[pt_texte->GetLayer()] )
|
2012-09-24 16:03:03 +00:00
|
|
|
return;
|
|
|
|
|
2016-09-19 11:01:36 +00:00
|
|
|
GBR_METADATA gbr_metadata;
|
|
|
|
|
|
|
|
if( IsCopperLayer( pt_texte->GetLayer() ) )
|
|
|
|
{
|
|
|
|
gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_NONCONDUCTOR );
|
|
|
|
}
|
|
|
|
|
2017-07-31 12:28:35 +00:00
|
|
|
COLOR4D color = getColor( pt_texte->GetLayer() );
|
|
|
|
m_plotter->SetColor( color );
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
size = pt_texte->GetTextSize();
|
|
|
|
pos = pt_texte->GetTextPos();
|
|
|
|
orient = pt_texte->GetTextAngle();
|
2015-02-02 08:06:39 +00:00
|
|
|
thickness = pt_texte->GetThickness();
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
if( pt_texte->IsMirrored() )
|
2012-09-24 16:03:03 +00:00
|
|
|
size.x = -size.x;
|
|
|
|
|
|
|
|
// Non bold texts thickness is clamped at 1/6 char size by the low level draw function.
|
|
|
|
// but in Pcbnew we do not manage bold texts and thickness up to 1/4 char size
|
|
|
|
// (like bold text) and we manage the thickness.
|
|
|
|
// So we set bold flag to true
|
2013-03-18 19:36:07 +00:00
|
|
|
bool allow_bold = pt_texte->IsBold() || thickness;
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
if( pt_texte->IsMultilineAllowed() )
|
2012-09-24 16:03:03 +00:00
|
|
|
{
|
2013-11-29 08:13:43 +00:00
|
|
|
std::vector<wxPoint> positions;
|
2015-01-15 20:01:53 +00:00
|
|
|
wxArrayString strings_list;
|
|
|
|
wxStringSplit( shownText, strings_list, '\n' );
|
|
|
|
positions.reserve( strings_list.Count() );
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2015-01-15 20:01:53 +00:00
|
|
|
pt_texte->GetPositionsOfLinesOfMultilineText( positions, strings_list.Count() );
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2015-01-15 20:01:53 +00:00
|
|
|
for( unsigned ii = 0; ii < strings_list.Count(); ii++ )
|
2012-09-24 16:03:03 +00:00
|
|
|
{
|
2015-01-15 20:01:53 +00:00
|
|
|
wxString& txt = strings_list.Item( ii );
|
2017-07-31 12:28:35 +00:00
|
|
|
m_plotter->Text( positions[ii], color, txt, orient, size,
|
2013-03-18 19:36:07 +00:00
|
|
|
pt_texte->GetHorizJustify(), pt_texte->GetVertJustify(),
|
2016-09-19 11:01:36 +00:00
|
|
|
thickness, pt_texte->IsItalic(), allow_bold, false, &gbr_metadata );
|
2012-09-24 16:03:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-07-31 12:28:35 +00:00
|
|
|
m_plotter->Text( pos, color, shownText, orient, size,
|
2013-03-18 19:36:07 +00:00
|
|
|
pt_texte->GetHorizJustify(), pt_texte->GetVertJustify(),
|
2016-09-19 11:01:36 +00:00
|
|
|
thickness, pt_texte->IsItalic(), allow_bold, false, &gbr_metadata );
|
2012-09-24 16:03:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Plot areas (given by .m_FilledPolysList member) in a zone
|
|
|
|
*/
|
|
|
|
void BRDITEMS_PLOTTER::PlotFilledAreas( ZONE_CONTAINER* aZone )
|
|
|
|
{
|
2015-07-27 19:45:57 +00:00
|
|
|
const SHAPE_POLY_SET& polysList = aZone->GetFilledPolysList();
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2015-07-27 19:45:57 +00:00
|
|
|
if( polysList.IsEmpty() )
|
2012-09-24 16:03:03 +00:00
|
|
|
return;
|
|
|
|
|
2016-09-19 11:01:36 +00:00
|
|
|
GBR_METADATA gbr_metadata;
|
|
|
|
|
|
|
|
bool isOnCopperLayer = aZone->IsOnCopperLayer();
|
|
|
|
|
|
|
|
if( isOnCopperLayer )
|
|
|
|
{
|
|
|
|
gbr_metadata.SetNetName( aZone->GetNetname() );
|
2017-05-03 18:04:31 +00:00
|
|
|
gbr_metadata.SetCopper( true );
|
2016-09-19 11:01:36 +00:00
|
|
|
|
|
|
|
// Zones with no net name can exist.
|
|
|
|
// they are not used to connect items, so the aperture attribute cannot
|
|
|
|
// be set as conductor
|
|
|
|
if( aZone->GetNetname().IsEmpty() )
|
|
|
|
gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_NONCONDUCTOR );
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CONDUCTOR );
|
|
|
|
gbr_metadata.SetNetAttribType( GBR_NETLIST_METADATA::GBR_NETINFO_NET );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-24 16:03:03 +00:00
|
|
|
// We need a buffer to store corners coordinates:
|
|
|
|
static std::vector< wxPoint > cornerList;
|
|
|
|
cornerList.clear();
|
|
|
|
|
|
|
|
m_plotter->SetColor( getColor( aZone->GetLayer() ) );
|
|
|
|
|
|
|
|
/* Plot all filled areas: filled areas have a filled area and a thick
|
|
|
|
* outline we must plot the filled area itself ( as a filled polygon
|
|
|
|
* OR a set of segments ) and plot the thick outline itself
|
|
|
|
*
|
|
|
|
* in non filled mode the outline is plotted, but not the filling items
|
|
|
|
*/
|
2017-03-07 12:06:00 +00:00
|
|
|
for( auto ic = polysList.CIterate(); ic; ++ic )
|
2012-09-24 16:03:03 +00:00
|
|
|
{
|
2015-07-27 19:45:57 +00:00
|
|
|
wxPoint pos( ic->x, ic->y );
|
2013-05-08 18:20:58 +00:00
|
|
|
cornerList.push_back( pos );
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2015-07-27 19:45:57 +00:00
|
|
|
if( ic.IsEndContour() ) // Plot the current filled area outline
|
2012-09-24 16:03:03 +00:00
|
|
|
{
|
|
|
|
// First, close the outline
|
|
|
|
if( cornerList[0] != cornerList[cornerList.size() - 1] )
|
|
|
|
{
|
|
|
|
cornerList.push_back( cornerList[0] );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Plot the current filled area and its outline
|
2015-02-02 08:06:39 +00:00
|
|
|
if( GetPlotMode() == FILLED )
|
2012-09-24 16:03:03 +00:00
|
|
|
{
|
2014-05-16 19:03:45 +00:00
|
|
|
// Plot the filled area polygon.
|
|
|
|
// The area can be filled by segments or uses solid polygons
|
|
|
|
if( aZone->GetFillMode() == 0 ) // We are using solid polygons
|
|
|
|
{
|
2016-09-19 11:01:36 +00:00
|
|
|
m_plotter->PlotPoly( cornerList, FILLED_SHAPE, aZone->GetMinThickness(), &gbr_metadata );
|
2012-09-24 16:03:03 +00:00
|
|
|
}
|
2014-05-16 19:03:45 +00:00
|
|
|
else // We are using areas filled by segments: plot segments and outline
|
|
|
|
{
|
2013-03-20 14:50:12 +00:00
|
|
|
for( unsigned iseg = 0; iseg < aZone->FillSegments().size(); iseg++ )
|
2012-09-24 16:03:03 +00:00
|
|
|
{
|
2017-12-04 18:06:47 +00:00
|
|
|
wxPoint start = (wxPoint) aZone->FillSegments()[iseg].A;
|
|
|
|
wxPoint end = (wxPoint) aZone->FillSegments()[iseg].B;
|
2012-09-24 16:03:03 +00:00
|
|
|
m_plotter->ThickSegment( start, end,
|
2013-03-18 19:36:07 +00:00
|
|
|
aZone->GetMinThickness(),
|
2016-09-19 11:01:36 +00:00
|
|
|
GetPlotMode(), &gbr_metadata );
|
2012-09-24 16:03:03 +00:00
|
|
|
}
|
|
|
|
|
2014-05-16 19:03:45 +00:00
|
|
|
// Plot the area outline only
|
2013-03-18 19:36:07 +00:00
|
|
|
if( aZone->GetMinThickness() > 0 )
|
|
|
|
m_plotter->PlotPoly( cornerList, NO_FILL, aZone->GetMinThickness() );
|
2014-05-16 19:03:45 +00:00
|
|
|
}
|
2012-09-24 16:03:03 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-03-18 19:36:07 +00:00
|
|
|
if( aZone->GetMinThickness() > 0 )
|
2012-09-24 16:03:03 +00:00
|
|
|
{
|
|
|
|
for( unsigned jj = 1; jj<cornerList.size(); jj++ )
|
|
|
|
m_plotter->ThickSegment( cornerList[jj -1], cornerList[jj],
|
2013-03-18 19:36:07 +00:00
|
|
|
aZone->GetMinThickness(),
|
2016-09-19 11:01:36 +00:00
|
|
|
GetPlotMode(), &gbr_metadata );
|
2012-09-24 16:03:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
m_plotter->SetCurrentLineWidth( -1 );
|
|
|
|
}
|
|
|
|
|
|
|
|
cornerList.clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Plot items type DRAWSEGMENT on layers allowed by aLayerMask
|
|
|
|
*/
|
2014-06-24 16:17:18 +00:00
|
|
|
void BRDITEMS_PLOTTER::PlotDrawSegment( DRAWSEGMENT* aSeg )
|
2012-09-24 16:03:03 +00:00
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
if( !m_layerMask[aSeg->GetLayer()] )
|
2012-09-24 16:03:03 +00:00
|
|
|
return;
|
|
|
|
|
2015-02-02 08:06:39 +00:00
|
|
|
int radius = 0;
|
|
|
|
double StAngle = 0, EndAngle = 0;
|
|
|
|
int thickness = aSeg->GetWidth();
|
2012-09-24 16:03:03 +00:00
|
|
|
|
|
|
|
m_plotter->SetColor( getColor( aSeg->GetLayer() ) );
|
|
|
|
|
|
|
|
wxPoint start( aSeg->GetStart() );
|
2016-09-19 11:01:36 +00:00
|
|
|
wxPoint end( aSeg->GetEnd() );
|
|
|
|
|
|
|
|
GBR_METADATA gbr_metadata;
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2016-09-19 11:01:36 +00:00
|
|
|
bool isOnCopperLayer = ( m_layerMask & LSET::AllCuMask() ).any();
|
|
|
|
|
|
|
|
if( isOnCopperLayer && aSeg->GetLayer() == Edge_Cuts ) // can happens when plotting copper layers
|
|
|
|
{
|
|
|
|
gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_NONCONDUCTOR );
|
|
|
|
}
|
2012-09-24 16:03:03 +00:00
|
|
|
|
|
|
|
switch( aSeg->GetShape() )
|
|
|
|
{
|
|
|
|
case S_CIRCLE:
|
2013-05-01 17:32:36 +00:00
|
|
|
radius = KiROUND( GetLineLength( end, start ) );
|
2016-09-19 11:01:36 +00:00
|
|
|
m_plotter->ThickCircle( start, radius * 2, thickness, GetPlotMode(), &gbr_metadata );
|
2012-09-24 16:03:03 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case S_ARC:
|
2013-05-01 17:32:36 +00:00
|
|
|
radius = KiROUND( GetLineLength( end, start ) );
|
2012-09-24 16:03:03 +00:00
|
|
|
StAngle = ArcTangente( end.y - start.y, end.x - start.x );
|
|
|
|
EndAngle = StAngle + aSeg->GetAngle();
|
2018-02-04 16:22:14 +00:00
|
|
|
|
|
|
|
// when startAngle == endAngle ThickArc() doesn't know whether it's 0 deg and 360 deg
|
|
|
|
if( std::abs( aSeg->GetAngle() ) == 3600.0 )
|
|
|
|
m_plotter->ThickCircle( start, radius * 2, thickness, GetPlotMode(), &gbr_metadata );
|
|
|
|
else
|
|
|
|
m_plotter->ThickArc( start, -EndAngle, -StAngle, radius, thickness, GetPlotMode(), &gbr_metadata );
|
2012-09-24 16:03:03 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case S_CURVE:
|
|
|
|
{
|
2016-09-19 11:01:36 +00:00
|
|
|
m_plotter->SetCurrentLineWidth( thickness, &gbr_metadata );
|
2012-09-24 16:03:03 +00:00
|
|
|
const std::vector<wxPoint>& bezierPoints = aSeg->GetBezierPoints();
|
|
|
|
|
|
|
|
for( unsigned i = 1; i < bezierPoints.size(); i++ )
|
2016-09-19 11:01:36 +00:00
|
|
|
m_plotter->ThickSegment( bezierPoints[i - 1], bezierPoints[i],
|
|
|
|
thickness, GetPlotMode(), &gbr_metadata );
|
2012-09-24 16:03:03 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2017-11-16 11:09:24 +00:00
|
|
|
case S_POLYGON:
|
|
|
|
{
|
|
|
|
m_plotter->SetCurrentLineWidth( thickness, &gbr_metadata );
|
|
|
|
// Draw the polygon: only one polygon is expected
|
|
|
|
// However we provide a multi polygon shape drawing
|
|
|
|
// ( for the future or to show a non expected shape )
|
|
|
|
for( int jj = 0; jj < aSeg->GetPolyShape().OutlineCount(); ++jj )
|
|
|
|
{
|
|
|
|
SHAPE_LINE_CHAIN& poly = aSeg->GetPolyShape().Outline( jj );
|
|
|
|
m_plotter->PlotPoly( poly, FILLED_SHAPE, thickness, &gbr_metadata );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2012-09-24 16:03:03 +00:00
|
|
|
default:
|
2016-09-19 11:01:36 +00:00
|
|
|
m_plotter->ThickSegment( start, end, thickness, GetPlotMode(), &gbr_metadata );
|
2012-09-24 16:03:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-20 14:50:12 +00:00
|
|
|
|
2012-09-24 16:03:03 +00:00
|
|
|
/** Helper function to plot a single drill mark. It compensate and clamp
|
|
|
|
* the drill mark size depending on the current plot options
|
|
|
|
*/
|
2014-01-26 14:20:58 +00:00
|
|
|
void BRDITEMS_PLOTTER::plotOneDrillMark( PAD_DRILL_SHAPE_T aDrillShape,
|
2012-09-24 16:03:03 +00:00
|
|
|
const wxPoint &aDrillPos, wxSize aDrillSize,
|
|
|
|
const wxSize &aPadSize,
|
|
|
|
double aOrientation, int aSmallDrill )
|
|
|
|
{
|
|
|
|
// Small drill marks have no significance when applied to slots
|
2015-08-23 19:40:33 +00:00
|
|
|
if( aSmallDrill && aDrillShape == PAD_DRILL_SHAPE_CIRCLE )
|
2012-09-24 16:03:03 +00:00
|
|
|
aDrillSize.x = std::min( aSmallDrill, aDrillSize.x );
|
|
|
|
|
|
|
|
// Round holes only have x diameter, slots have both
|
|
|
|
aDrillSize.x -= getFineWidthAdj();
|
|
|
|
aDrillSize.x = Clamp( 1, aDrillSize.x, aPadSize.x - 1 );
|
2013-03-20 14:50:12 +00:00
|
|
|
|
2015-08-23 19:40:33 +00:00
|
|
|
if( aDrillShape == PAD_DRILL_SHAPE_OBLONG )
|
2012-09-24 16:03:03 +00:00
|
|
|
{
|
|
|
|
aDrillSize.y -= getFineWidthAdj();
|
|
|
|
aDrillSize.y = Clamp( 1, aDrillSize.y, aPadSize.y - 1 );
|
2016-09-19 11:01:36 +00:00
|
|
|
m_plotter->FlashPadOval( aDrillPos, aDrillSize, aOrientation, GetPlotMode(), NULL );
|
2012-09-24 16:03:03 +00:00
|
|
|
}
|
|
|
|
else
|
2016-09-19 11:01:36 +00:00
|
|
|
m_plotter->FlashPadCircle( aDrillPos, aDrillSize.x, GetPlotMode(), NULL );
|
2012-09-24 16:03:03 +00:00
|
|
|
}
|
|
|
|
|
2013-03-20 14:50:12 +00:00
|
|
|
|
2012-09-24 16:03:03 +00:00
|
|
|
void BRDITEMS_PLOTTER::PlotDrillMarks()
|
|
|
|
{
|
|
|
|
/* If small drills marks were requested prepare a clamp value to pass
|
|
|
|
to the helper function */
|
|
|
|
int small_drill = (GetDrillMarksType() == PCB_PLOT_PARAMS::SMALL_DRILL_SHAPE) ?
|
|
|
|
SMALL_DRILL : 0;
|
|
|
|
|
|
|
|
/* In the filled trace mode drill marks are drawn white-on-black to scrape
|
|
|
|
the underlying pad. This works only for drivers supporting color change,
|
|
|
|
obviously... it means that:
|
|
|
|
- PS, SVG and PDF output is correct (i.e. you have a 'donut' pad)
|
|
|
|
- In HPGL you can't see them
|
|
|
|
- In gerbers you can't see them, too. This is arguably the right thing to
|
|
|
|
do since having drill marks and high speed drill stations is a sure
|
|
|
|
recipe for broken tools and angry manufacturers. If you *really* want them
|
|
|
|
you could start a layer with negative polarity to scrape the film.
|
|
|
|
- In DXF they go into the 'WHITE' layer. This could be useful.
|
|
|
|
*/
|
2015-02-02 08:06:39 +00:00
|
|
|
if( GetPlotMode() == FILLED )
|
2012-09-24 16:03:03 +00:00
|
|
|
m_plotter->SetColor( WHITE );
|
|
|
|
|
2017-06-23 11:56:28 +00:00
|
|
|
for( TRACK* pts = m_board->m_Track; pts != NULL; pts = pts->Next() )
|
2012-09-24 16:03:03 +00:00
|
|
|
{
|
2014-06-06 09:44:21 +00:00
|
|
|
const VIA* via = dyn_cast<const VIA*>( pts );
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2014-04-25 06:00:04 +00:00
|
|
|
if( via )
|
2015-08-23 19:40:33 +00:00
|
|
|
plotOneDrillMark( PAD_DRILL_SHAPE_CIRCLE, via->GetStart(),
|
2014-04-25 06:00:04 +00:00
|
|
|
wxSize( via->GetDrillValue(), 0 ),
|
|
|
|
wxSize( via->GetWidth(), 0 ), 0, small_drill );
|
2012-09-24 16:03:03 +00:00
|
|
|
}
|
|
|
|
|
2017-06-23 11:56:28 +00:00
|
|
|
for( MODULE* Module = m_board->m_Modules; Module != NULL; Module = Module->Next() )
|
2012-09-24 16:03:03 +00:00
|
|
|
{
|
2017-06-23 11:56:28 +00:00
|
|
|
for( D_PAD* pad = Module->PadsList(); pad != NULL; pad = pad->Next() )
|
2012-09-24 16:03:03 +00:00
|
|
|
{
|
|
|
|
if( pad->GetDrillSize().x == 0 )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
plotOneDrillMark( pad->GetDrillShape(),
|
2013-03-20 14:50:12 +00:00
|
|
|
pad->GetPosition(), pad->GetDrillSize(),
|
|
|
|
pad->GetSize(), pad->GetOrientation(),
|
|
|
|
small_drill );
|
2012-09-24 16:03:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-02 08:06:39 +00:00
|
|
|
if( GetPlotMode() == FILLED )
|
2012-09-24 16:03:03 +00:00
|
|
|
m_plotter->SetColor( GetColor() );
|
|
|
|
}
|