Save DXF plot params to file and remove some dead code.

Fixes https://gitlab.com/kicad/code/kicad/issues/6720
This commit is contained in:
Jeff Young 2021-01-03 13:59:23 +00:00
parent a1d7a959f7
commit 491fc2c8f2
6 changed files with 77 additions and 75 deletions

View File

@ -1,6 +1,9 @@
creategerberjobfile
disableapertmacros
drillshape
dxfimperialunits
dxfpolygonmode
dxfusepcbnewfont
excludeedgelayer
false
gerberprecision

View File

@ -754,14 +754,10 @@ void DIALOG_PLOT::applyPlotSettings()
dirStr.Replace( wxT( "\\" ), wxT( "/" ) );
tempOptions.SetOutputDirectory( dirStr );
if( !m_plotOpts.IsSameAs( tempOptions, false ) )
if( !m_plotOpts.IsSameAs( tempOptions ) )
{
// First, mark board as modified only for parameters saved in file
if( !m_plotOpts.IsSameAs( tempOptions, true ) )
m_parent->OnModify();
// Now, save any change, for the session
m_parent->SetPlotSettings( tempOptions );
m_parent->OnModify();
m_plotOpts = tempOptions;
}
}

View File

@ -132,7 +132,6 @@ PCB_PLOT_PARAMS::PCB_PLOT_PARAMS()
m_fineScaleAdjustX = 1.0;
m_fineScaleAdjustY = 1.0;
m_widthAdjust = 0.;
m_color = BLACK;
m_textMode = PLOT_TEXT_MODE::DEFAULT;
m_outputDirectory.clear();
m_layerSelection = LSET( 7, F_SilkS, B_SilkS, F_Mask, B_Mask,
@ -197,7 +196,7 @@ void PCB_PLOT_PARAMS::Format( OUTPUTFORMATTER* aFormatter,
aFormatter->Print( aNestLevel+1, "(%s %d)\n",
getTokenName( T_gerberprecision ), m_gerberPrecision );
// Svg options
// SVG options
aFormatter->Print( aNestLevel+1, "(%s %s)\n", getTokenName( T_svguseinch ),
m_svgUseInch ? trueStr : falseStr );
aFormatter->Print( aNestLevel+1, "(%s %d)\n", getTokenName( T_svgprecision ),
@ -213,18 +212,23 @@ void PCB_PLOT_PARAMS::Format( OUTPUTFORMATTER* aFormatter,
GetPlotMode() == SKETCH ? 2 : 1 ); // Value 0 (LINE mode) no more used
aFormatter->Print( aNestLevel+1, "(%s %s)\n", getTokenName( T_useauxorigin ),
m_useAuxOrigin ? trueStr : falseStr );
// HPGL options
aFormatter->Print( aNestLevel+1, "(%s %d)\n", getTokenName( T_hpglpennumber ),
m_HPGLPenNum );
// Obsolete parameter, pen speed is no more managed, because hpgl format
// is now an export format, and for this, pen speed has no meaning
// aFormatter->Print( aNestLevel+1, "(%s %d)\n", getTokenName( T_hpglpenspeed ),
// m_HPGLPenSpeed );
aFormatter->Print( aNestLevel+1, "(%s %d)\n", getTokenName( T_hpglpenspeed ),
m_HPGLPenSpeed );
aFormatter->Print( aNestLevel+1, "(%s %f)\n", getTokenName( T_hpglpendiameter ),
m_HPGLPenDiam );
// DXF options
aFormatter->Print( aNestLevel+1, "(%s %s)\n", getTokenName( T_dxfpolygonmode ),
m_DXFplotPolygonMode ? trueStr : falseStr );
aFormatter->Print( aNestLevel+1, "(%s %s)\n", getTokenName( T_dxfimperialunits ),
m_DXFplotUnits == DXF_UNITS::INCHES ? trueStr : falseStr );
aFormatter->Print( aNestLevel+1, "(%s %s)\n", getTokenName( T_dxfusepcbnewfont ),
m_textMode == PLOT_TEXT_MODE::NATIVE ? falseStr : trueStr );
aFormatter->Print( aNestLevel+1, "(%s %s)\n", getTokenName( T_psnegative ),
m_negative ? trueStr : falseStr );
aFormatter->Print( aNestLevel+1, "(%s %s)\n", getTokenName( T_psa4output ),
@ -260,7 +264,7 @@ void PCB_PLOT_PARAMS::Parse( PCB_PLOT_PARAMS_PARSER* aParser )
}
bool PCB_PLOT_PARAMS::IsSameAs( const PCB_PLOT_PARAMS &aPcbPlotParams, bool aCompareOnlySavedPrms ) const
bool PCB_PLOT_PARAMS::IsSameAs( const PCB_PLOT_PARAMS &aPcbPlotParams ) const
{
if( m_layerSelection != aPcbPlotParams.m_layerSelection )
return false;
@ -284,13 +288,10 @@ bool PCB_PLOT_PARAMS::IsSameAs( const PCB_PLOT_PARAMS &aPcbPlotParams, bool aCom
return false;
if( m_plotMode != aPcbPlotParams.m_plotMode )
return false;
if( !aCompareOnlySavedPrms )
{
if( m_DXFplotPolygonMode != aPcbPlotParams.m_DXFplotPolygonMode )
return false;
if( m_DXFplotUnits != aPcbPlotParams.m_DXFplotUnits )
return false;
}
if( m_DXFplotPolygonMode != aPcbPlotParams.m_DXFplotPolygonMode )
return false;
if( m_DXFplotUnits != aPcbPlotParams.m_DXFplotUnits )
return false;
if( m_svgPrecision != aPcbPlotParams.m_svgPrecision )
return false;
if( m_svgUseInch != aPcbPlotParams.m_svgUseInch )
@ -335,11 +336,6 @@ bool PCB_PLOT_PARAMS::IsSameAs( const PCB_PLOT_PARAMS &aPcbPlotParams, bool aCom
return false;
if( m_widthAdjust != aPcbPlotParams.m_widthAdjust )
return false;
if( !aCompareOnlySavedPrms )
{
if( m_color != aPcbPlotParams.m_color )
return false;
}
if( m_textMode != aPcbPlotParams.m_textMode )
return false;
if( !m_outputDirectory.IsSameAs( aPcbPlotParams.m_outputDirectory ) )
@ -402,18 +398,12 @@ void PCB_PLOT_PARAMS_PARSER::Parse( PCB_PLOT_PARAMS* aPcbPlotParams )
if( token == T_NUMBER ) // pretty 3 format had legacy Cu stack.
{
// unsigned legacy_mask = atol( cur.c_str() );
/* It's not possible to convert a legacy Cu layer number to a new
Cu layer number without knowing the number or total Cu layers
in the legacy board. We do not have that information here.
So simply set all layers ON. User can turn them off in the UI.
This is one of the superiorities of the new Cu sequence.
aPcbPlotParams->m_layerSelection = LEGACY_PLUGIN::leg_mask2new( cu_count, legacy_mask );
*/
// sorry, use the UI once to fix:
aPcbPlotParams->m_layerSelection = LSET( 2, F_SilkS, B_SilkS) | LSET::AllCuMask();
// It's not possible to convert a legacy Cu layer number to a new Cu layer
// number without knowing the number or total Cu layers in the legacy board.
// We do not have that information here, so simply set all layers ON. User
// can turn them off in the UI.
aPcbPlotParams->m_layerSelection = LSET( 2, F_SilkS, B_SilkS)
| LSET::AllCuMask();
}
else if( cur.find_first_of( "0x" ) == 0 ) // pretty ver. 4.
{
@ -446,8 +436,8 @@ void PCB_PLOT_PARAMS_PARSER::Parse( PCB_PLOT_PARAMS* aPcbPlotParams )
break;
case T_gerberprecision:
aPcbPlotParams->m_gerberPrecision =
parseInt( gbrDefaultPrecision-1, gbrDefaultPrecision);
aPcbPlotParams->m_gerberPrecision = parseInt( gbrDefaultPrecision-1,
gbrDefaultPrecision);
break;
case T_svgprecision:
@ -501,6 +491,20 @@ void PCB_PLOT_PARAMS_PARSER::Parse( PCB_PLOT_PARAMS* aPcbPlotParams )
parseInt( 0, HPGL_PEN_DIAMETER_MAX );
break;
case T_dxfpolygonmode:
aPcbPlotParams->m_DXFplotPolygonMode = parseBool();
break;
case T_dxfimperialunits:
aPcbPlotParams->m_DXFplotUnits = parseBool() ? DXF_UNITS::INCHES
: DXF_UNITS::MILLIMETERS;
break;
case T_dxfusepcbnewfont:
aPcbPlotParams->m_textMode = parseBool() ? PLOT_TEXT_MODE::DEFAULT
: PLOT_TEXT_MODE::NATIVE;
break;
case T_pscolor:
NeedSYMBOL(); // This actually was never used...
break;

View File

@ -180,7 +180,6 @@ private:
int m_HPGLPenSpeed; ///< HPGL only: pen speed, always in cm/s (1 to 99 cm/s)
double m_HPGLPenDiam; ///< HPGL only: pen diameter in MILS, useful to fill areas
///< However, it is in mm in hpgl files.
COLOR4D m_color; ///< Color for plotting the current layer. Provided, but not really used
/// Pointer to active color settings to be used for plotting
COLOR_SETTINGS* m_colors;
@ -204,10 +203,7 @@ public:
* and false to compare the full set of parameters.
* @return true is parameters are same, false if one (or more) parameter does not match
*/
bool IsSameAs( const PCB_PLOT_PARAMS &aPcbPlotParams, bool aCompareOnlySavedPrms ) const;
void SetColor( COLOR4D aVal ) { m_color = aVal; }
COLOR4D GetColor() const { return m_color; }
bool IsSameAs( const PCB_PLOT_PARAMS &aPcbPlotParams ) const;
void SetColorSettings( COLOR_SETTINGS* aSettings ) { m_colors = aSettings; }

View File

@ -66,7 +66,7 @@ void PlotOneBoardLayer( BOARD *aBoard, PLOTTER* aPlotter, PCB_LAYER_ID aLayer,
int soldermask_min_thickness = aBoard->GetDesignSettings().m_SolderMaskMinWidth;
// Set a default color and the text mode for this layer
aPlotter->SetColor( aPlotOpt.GetColor() );
aPlotter->SetColor( BLACK );
aPlotter->SetTextMode( aPlotOpt.GetTextMode() );
// Specify that the contents of the "Edges Pcb" layer are to be plotted in addition to the

View File

@ -28,7 +28,6 @@
#include <vector> // for vector, __vector_base<>...
#include <eda_item.h>
#include <convert_basic_shapes_to_polygon.h>
#include <geometry/seg.h> // for SEG
#include <geometry/shape_circle.h>
#include <geometry/shape_line_chain.h> // for SHAPE_LINE_CHAIN
@ -223,8 +222,8 @@ void BRDITEMS_PLOTTER::PlotPad( PAD* aPad, COLOR4D aColor, OUTLINE_MODE aPlotMod
break;
case PAD_SHAPE_OVAL:
m_plotter->FlashPadOval( shape_pos, aPad->GetSize(),
aPad->GetOrientation(), aPlotMode, &gbr_metadata );
m_plotter->FlashPadOval( shape_pos, aPad->GetSize(), aPad->GetOrientation(), aPlotMode,
&gbr_metadata );
break;
case PAD_SHAPE_RECT:
@ -253,7 +252,7 @@ void BRDITEMS_PLOTTER::PlotPad( PAD* aPad, COLOR4D aColor, OUTLINE_MODE aPlotMod
coord[3] = wxPoint( -half_size.x + trap_delta.y, -half_size.y - trap_delta.x );
m_plotter->FlashPadTrapez( shape_pos, coord, aPad->GetOrientation(), aPlotMode,
&gbr_metadata );
&gbr_metadata );
}
break;
@ -521,10 +520,10 @@ void BRDITEMS_PLOTTER::PlotFootprintGraphicItems( FOOTPRINT* aFootprint )
{
for( BOARD_ITEM* item : aFootprint->GraphicalItems() )
{
FP_SHAPE* edge = dynamic_cast<FP_SHAPE*>( item );
FP_SHAPE* shape = dynamic_cast<FP_SHAPE*>( item );
if( edge && m_layerMask[ edge->GetLayer() ] )
PlotFootprintGraphicItem( edge );
if( shape && m_layerMask[ shape->GetLayer() ] )
PlotFootprintGraphicItem( shape );
}
}
@ -769,7 +768,9 @@ void BRDITEMS_PLOTTER::PlotFilledAreas( ZONE* aZone, SHAPE_POLY_SET& polysList )
// 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 );
@ -817,15 +818,19 @@ void BRDITEMS_PLOTTER::PlotFilledAreas( ZONE* aZone, SHAPE_POLY_SET& polysList )
if( m_plotter->GetPlotterType() == PLOT_FORMAT::GERBER )
{
if( outline_thickness > 0 )
m_plotter->PlotPoly( cornerList, FILL_TYPE::NO_FILL,
outline_thickness, &gbr_metadata );
{
m_plotter->PlotPoly( cornerList, FILL_TYPE::NO_FILL, outline_thickness,
&gbr_metadata );
}
static_cast<GERBER_PLOTTER*>( m_plotter )->PlotGerberRegion(
cornerList, &gbr_metadata );
static_cast<GERBER_PLOTTER*>( m_plotter )->PlotGerberRegion( cornerList,
&gbr_metadata );
}
else
m_plotter->PlotPoly( cornerList, FILL_TYPE::FILLED_SHAPE,
outline_thickness, &gbr_metadata );
{
m_plotter->PlotPoly( cornerList, FILL_TYPE::FILLED_SHAPE, outline_thickness,
&gbr_metadata );
}
}
else
{
@ -834,8 +839,7 @@ void BRDITEMS_PLOTTER::PlotFilledAreas( ZONE* aZone, SHAPE_POLY_SET& polysList )
for( unsigned jj = 1; jj < cornerList.size(); jj++ )
{
m_plotter->ThickSegment( cornerList[jj -1], cornerList[jj],
outline_thickness,
GetPlotMode(), &gbr_metadata );
outline_thickness, GetPlotMode(), &gbr_metadata );
}
}
@ -1000,7 +1004,9 @@ void BRDITEMS_PLOTTER::plotOneDrillMark( PAD_DRILL_SHAPE_T aDrillShape, const wx
m_plotter->FlashPadOval( aDrillPos, aDrillSize, aOrientation, GetPlotMode(), NULL );
}
else
{
m_plotter->FlashPadCircle( aDrillPos, aDrillSize.x, GetPlotMode(), NULL );
}
}
@ -1008,8 +1014,7 @@ 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;
int smallDrill = 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,
@ -1025,32 +1030,30 @@ void BRDITEMS_PLOTTER::PlotDrillMarks()
if( GetPlotMode() == FILLED )
m_plotter->SetColor( WHITE );
for( auto pts : m_board->Tracks() )
for( TRACK* tracks : m_board->Tracks() )
{
const VIA* via = dyn_cast<const VIA*>( pts );
const VIA* via = dyn_cast<const VIA*>( tracks );
if( via )
{
plotOneDrillMark( PAD_DRILL_SHAPE_CIRCLE, via->GetStart(),
wxSize( via->GetDrillValue(), 0 ),
wxSize( via->GetWidth(), 0 ), 0, small_drill );
wxSize( via->GetDrillValue(), 0 ),
wxSize( via->GetWidth(), 0 ), 0, smallDrill );
}
}
for( auto Module : m_board->Footprints() )
for( FOOTPRINT* footprint : m_board->Footprints() )
{
for( auto pad : Module->Pads() )
for( PAD* pad : footprint->Pads() )
{
if( pad->GetDrillSize().x == 0 )
continue;
plotOneDrillMark( pad->GetDrillShape(),
pad->GetPosition(), pad->GetDrillSize(),
pad->GetSize(), pad->GetOrientation(),
small_drill );
plotOneDrillMark( pad->GetDrillShape(), pad->GetPosition(), pad->GetDrillSize(),
pad->GetSize(), pad->GetOrientation(), smallDrill );
}
}
if( GetPlotMode() == FILLED )
m_plotter->SetColor( GetColor() );
m_plotter->SetColor( BLACK );
}