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 creategerberjobfile
disableapertmacros disableapertmacros
drillshape drillshape
dxfimperialunits
dxfpolygonmode
dxfusepcbnewfont
excludeedgelayer excludeedgelayer
false false
gerberprecision gerberprecision

View File

@ -754,14 +754,10 @@ void DIALOG_PLOT::applyPlotSettings()
dirStr.Replace( wxT( "\\" ), wxT( "/" ) ); dirStr.Replace( wxT( "\\" ), wxT( "/" ) );
tempOptions.SetOutputDirectory( dirStr ); 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->SetPlotSettings( tempOptions );
m_parent->OnModify();
m_plotOpts = tempOptions; m_plotOpts = tempOptions;
} }
} }

View File

@ -132,7 +132,6 @@ PCB_PLOT_PARAMS::PCB_PLOT_PARAMS()
m_fineScaleAdjustX = 1.0; m_fineScaleAdjustX = 1.0;
m_fineScaleAdjustY = 1.0; m_fineScaleAdjustY = 1.0;
m_widthAdjust = 0.; m_widthAdjust = 0.;
m_color = BLACK;
m_textMode = PLOT_TEXT_MODE::DEFAULT; m_textMode = PLOT_TEXT_MODE::DEFAULT;
m_outputDirectory.clear(); m_outputDirectory.clear();
m_layerSelection = LSET( 7, F_SilkS, B_SilkS, F_Mask, B_Mask, 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", aFormatter->Print( aNestLevel+1, "(%s %d)\n",
getTokenName( T_gerberprecision ), m_gerberPrecision ); getTokenName( T_gerberprecision ), m_gerberPrecision );
// Svg options // SVG options
aFormatter->Print( aNestLevel+1, "(%s %s)\n", getTokenName( T_svguseinch ), aFormatter->Print( aNestLevel+1, "(%s %s)\n", getTokenName( T_svguseinch ),
m_svgUseInch ? trueStr : falseStr ); m_svgUseInch ? trueStr : falseStr );
aFormatter->Print( aNestLevel+1, "(%s %d)\n", getTokenName( T_svgprecision ), 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 GetPlotMode() == SKETCH ? 2 : 1 ); // Value 0 (LINE mode) no more used
aFormatter->Print( aNestLevel+1, "(%s %s)\n", getTokenName( T_useauxorigin ), aFormatter->Print( aNestLevel+1, "(%s %s)\n", getTokenName( T_useauxorigin ),
m_useAuxOrigin ? trueStr : falseStr ); m_useAuxOrigin ? trueStr : falseStr );
// HPGL options
aFormatter->Print( aNestLevel+1, "(%s %d)\n", getTokenName( T_hpglpennumber ), aFormatter->Print( aNestLevel+1, "(%s %d)\n", getTokenName( T_hpglpennumber ),
m_HPGLPenNum ); 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 ), aFormatter->Print( aNestLevel+1, "(%s %d)\n", getTokenName( T_hpglpenspeed ),
m_HPGLPenSpeed ); m_HPGLPenSpeed );
aFormatter->Print( aNestLevel+1, "(%s %f)\n", getTokenName( T_hpglpendiameter ), aFormatter->Print( aNestLevel+1, "(%s %f)\n", getTokenName( T_hpglpendiameter ),
m_HPGLPenDiam ); 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 ), aFormatter->Print( aNestLevel+1, "(%s %s)\n", getTokenName( T_psnegative ),
m_negative ? trueStr : falseStr ); m_negative ? trueStr : falseStr );
aFormatter->Print( aNestLevel+1, "(%s %s)\n", getTokenName( T_psa4output ), 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 ) if( m_layerSelection != aPcbPlotParams.m_layerSelection )
return false; return false;
@ -284,13 +288,10 @@ bool PCB_PLOT_PARAMS::IsSameAs( const PCB_PLOT_PARAMS &aPcbPlotParams, bool aCom
return false; return false;
if( m_plotMode != aPcbPlotParams.m_plotMode ) if( m_plotMode != aPcbPlotParams.m_plotMode )
return false; return false;
if( !aCompareOnlySavedPrms )
{
if( m_DXFplotPolygonMode != aPcbPlotParams.m_DXFplotPolygonMode ) if( m_DXFplotPolygonMode != aPcbPlotParams.m_DXFplotPolygonMode )
return false; return false;
if( m_DXFplotUnits != aPcbPlotParams.m_DXFplotUnits ) if( m_DXFplotUnits != aPcbPlotParams.m_DXFplotUnits )
return false; return false;
}
if( m_svgPrecision != aPcbPlotParams.m_svgPrecision ) if( m_svgPrecision != aPcbPlotParams.m_svgPrecision )
return false; return false;
if( m_svgUseInch != aPcbPlotParams.m_svgUseInch ) if( m_svgUseInch != aPcbPlotParams.m_svgUseInch )
@ -335,11 +336,6 @@ bool PCB_PLOT_PARAMS::IsSameAs( const PCB_PLOT_PARAMS &aPcbPlotParams, bool aCom
return false; return false;
if( m_widthAdjust != aPcbPlotParams.m_widthAdjust ) if( m_widthAdjust != aPcbPlotParams.m_widthAdjust )
return false; return false;
if( !aCompareOnlySavedPrms )
{
if( m_color != aPcbPlotParams.m_color )
return false;
}
if( m_textMode != aPcbPlotParams.m_textMode ) if( m_textMode != aPcbPlotParams.m_textMode )
return false; return false;
if( !m_outputDirectory.IsSameAs( aPcbPlotParams.m_outputDirectory ) ) 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. 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.
/* It's not possible to convert a legacy Cu layer number to a new // We do not have that information here, so simply set all layers ON. User
Cu layer number without knowing the number or total Cu layers // can turn them off in the UI.
in the legacy board. We do not have that information here. aPcbPlotParams->m_layerSelection = LSET( 2, F_SilkS, B_SilkS)
So simply set all layers ON. User can turn them off in the UI. | LSET::AllCuMask();
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();
} }
else if( cur.find_first_of( "0x" ) == 0 ) // pretty ver. 4. 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; break;
case T_gerberprecision: case T_gerberprecision:
aPcbPlotParams->m_gerberPrecision = aPcbPlotParams->m_gerberPrecision = parseInt( gbrDefaultPrecision-1,
parseInt( gbrDefaultPrecision-1, gbrDefaultPrecision); gbrDefaultPrecision);
break; break;
case T_svgprecision: case T_svgprecision:
@ -501,6 +491,20 @@ void PCB_PLOT_PARAMS_PARSER::Parse( PCB_PLOT_PARAMS* aPcbPlotParams )
parseInt( 0, HPGL_PEN_DIAMETER_MAX ); parseInt( 0, HPGL_PEN_DIAMETER_MAX );
break; 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: case T_pscolor:
NeedSYMBOL(); // This actually was never used... NeedSYMBOL(); // This actually was never used...
break; break;

View File

@ -180,7 +180,6 @@ private:
int m_HPGLPenSpeed; ///< HPGL only: pen speed, always in cm/s (1 to 99 cm/s) 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 double m_HPGLPenDiam; ///< HPGL only: pen diameter in MILS, useful to fill areas
///< However, it is in mm in hpgl files. ///< 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 /// Pointer to active color settings to be used for plotting
COLOR_SETTINGS* m_colors; COLOR_SETTINGS* m_colors;
@ -204,10 +203,7 @@ public:
* and false to compare the full set of parameters. * and false to compare the full set of parameters.
* @return true is parameters are same, false if one (or more) parameter does not match * @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; bool IsSameAs( const PCB_PLOT_PARAMS &aPcbPlotParams ) const;
void SetColor( COLOR4D aVal ) { m_color = aVal; }
COLOR4D GetColor() const { return m_color; }
void SetColorSettings( COLOR_SETTINGS* aSettings ) { m_colors = aSettings; } 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; int soldermask_min_thickness = aBoard->GetDesignSettings().m_SolderMaskMinWidth;
// Set a default color and the text mode for this layer // Set a default color and the text mode for this layer
aPlotter->SetColor( aPlotOpt.GetColor() ); aPlotter->SetColor( BLACK );
aPlotter->SetTextMode( aPlotOpt.GetTextMode() ); aPlotter->SetTextMode( aPlotOpt.GetTextMode() );
// Specify that the contents of the "Edges Pcb" layer are to be plotted in addition to the // 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 <vector> // for vector, __vector_base<>...
#include <eda_item.h> #include <eda_item.h>
#include <convert_basic_shapes_to_polygon.h>
#include <geometry/seg.h> // for SEG #include <geometry/seg.h> // for SEG
#include <geometry/shape_circle.h> #include <geometry/shape_circle.h>
#include <geometry/shape_line_chain.h> // for SHAPE_LINE_CHAIN #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; break;
case PAD_SHAPE_OVAL: case PAD_SHAPE_OVAL:
m_plotter->FlashPadOval( shape_pos, aPad->GetSize(), m_plotter->FlashPadOval( shape_pos, aPad->GetSize(), aPad->GetOrientation(), aPlotMode,
aPad->GetOrientation(), aPlotMode, &gbr_metadata ); &gbr_metadata );
break; break;
case PAD_SHAPE_RECT: case PAD_SHAPE_RECT:
@ -521,10 +520,10 @@ void BRDITEMS_PLOTTER::PlotFootprintGraphicItems( FOOTPRINT* aFootprint )
{ {
for( BOARD_ITEM* item : aFootprint->GraphicalItems() ) 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() ] ) if( shape && m_layerMask[ shape->GetLayer() ] )
PlotFootprintGraphicItem( edge ); 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 // they are not used to connect items, so the aperture attribute cannot
// be set as conductor // be set as conductor
if( aZone->GetNetname().IsEmpty() ) if( aZone->GetNetname().IsEmpty() )
{
gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_NONCONDUCTOR ); gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_NONCONDUCTOR );
}
else else
{ {
gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CONDUCTOR ); 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( m_plotter->GetPlotterType() == PLOT_FORMAT::GERBER )
{ {
if( outline_thickness > 0 ) 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( static_cast<GERBER_PLOTTER*>( m_plotter )->PlotGerberRegion( cornerList,
cornerList, &gbr_metadata ); &gbr_metadata );
} }
else 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 else
{ {
@ -834,8 +839,7 @@ void BRDITEMS_PLOTTER::PlotFilledAreas( ZONE* aZone, SHAPE_POLY_SET& polysList )
for( unsigned jj = 1; jj < cornerList.size(); jj++ ) for( unsigned jj = 1; jj < cornerList.size(); jj++ )
{ {
m_plotter->ThickSegment( cornerList[jj -1], cornerList[jj], m_plotter->ThickSegment( cornerList[jj -1], cornerList[jj],
outline_thickness, outline_thickness, GetPlotMode(), &gbr_metadata );
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 ); m_plotter->FlashPadOval( aDrillPos, aDrillSize, aOrientation, GetPlotMode(), NULL );
} }
else else
{
m_plotter->FlashPadCircle( aDrillPos, aDrillSize.x, GetPlotMode(), NULL ); 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 /* If small drills marks were requested prepare a clamp value to pass
to the helper function */ to the helper function */
int small_drill = (GetDrillMarksType() == PCB_PLOT_PARAMS::SMALL_DRILL_SHAPE) ? int smallDrill = GetDrillMarksType() == PCB_PLOT_PARAMS::SMALL_DRILL_SHAPE ? SMALL_DRILL : 0;
SMALL_DRILL : 0;
/* In the filled trace mode drill marks are drawn white-on-black to scrape /* 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, the underlying pad. This works only for drivers supporting color change,
@ -1025,32 +1030,30 @@ void BRDITEMS_PLOTTER::PlotDrillMarks()
if( GetPlotMode() == FILLED ) if( GetPlotMode() == FILLED )
m_plotter->SetColor( WHITE ); 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 ) if( via )
{ {
plotOneDrillMark( PAD_DRILL_SHAPE_CIRCLE, via->GetStart(), plotOneDrillMark( PAD_DRILL_SHAPE_CIRCLE, via->GetStart(),
wxSize( via->GetDrillValue(), 0 ), wxSize( via->GetDrillValue(), 0 ),
wxSize( via->GetWidth(), 0 ), 0, small_drill ); 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 ) if( pad->GetDrillSize().x == 0 )
continue; continue;
plotOneDrillMark( pad->GetDrillShape(), plotOneDrillMark( pad->GetDrillShape(), pad->GetPosition(), pad->GetDrillSize(),
pad->GetPosition(), pad->GetDrillSize(), pad->GetSize(), pad->GetOrientation(), smallDrill );
pad->GetSize(), pad->GetOrientation(),
small_drill );
} }
} }
if( GetPlotMode() == FILLED ) if( GetPlotMode() == FILLED )
m_plotter->SetColor( GetColor() ); m_plotter->SetColor( BLACK );
} }