hpgl plot parameters: use double instead of int to store the pen diameter to avoid truncation.
This parameter, always in mm in a hpgl file, is for historical reasons stored in mils, and using a int to store it created annoying rounding errors.
This commit is contained in:
parent
da061718e5
commit
7db88126c5
|
@ -125,7 +125,7 @@ void DIALOG_PLOT::init_Dialog()
|
|||
msg = StringFromValue( m_userUnits, board->GetDesignSettings().m_SolderMaskMinWidth, true );
|
||||
m_SolderMaskMinWidthCurrValue->SetLabel( msg );
|
||||
|
||||
// Set units and value for HPGL pen size (this param is in mils).
|
||||
// Set units and value for HPGL pen size (this param is stored in mils).
|
||||
AddUnitSymbol( *m_textPenSize, m_userUnits );
|
||||
|
||||
msg = StringFromValue( m_userUnits,
|
||||
|
@ -632,7 +632,7 @@ void DIALOG_PLOT::applyPlotSettings()
|
|||
|
||||
// read HPLG pen size (this param is stored in mils)
|
||||
wxString msg = m_HPGLPenSizeOpt->GetValue();
|
||||
int tmp = ValueFromString( m_userUnits, msg ) / IU_PER_MILS;
|
||||
double tmp = DoubleValueFromString( m_userUnits, msg ) / IU_PER_MILS;
|
||||
|
||||
if( !tempOptions.SetHPGLPenDiameter( tmp ) )
|
||||
{
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#define PLOT_LINEWIDTH_MAX (2*IU_PER_MM) // max value for default line thickness
|
||||
#define PLOT_LINEWIDTH_DEFAULT (0.15*IU_PER_MM) // def. value for default line thickness
|
||||
#define HPGL_PEN_DIAMETER_MIN 0
|
||||
#define HPGL_PEN_DIAMETER_MAX 100 // Unit = mil
|
||||
#define HPGL_PEN_DIAMETER_MAX 100.0 // Unit = mil
|
||||
#define HPGL_PEN_SPEED_MIN 1 // this param is always in cm/s
|
||||
#define HPGL_PEN_SPEED_MAX 99 // this param is always in cm/s
|
||||
#define HPGL_PEN_NUMBER_MIN 1
|
||||
|
@ -60,7 +60,7 @@ static const char* getTokenName( T aTok )
|
|||
}
|
||||
|
||||
|
||||
static bool setInt( int* aInt, int aValue, int aMin, int aMax )
|
||||
static bool setInt( int* aTarget, int aValue, int aMin, int aMax )
|
||||
{
|
||||
int temp = aValue;
|
||||
|
||||
|
@ -69,7 +69,21 @@ static bool setInt( int* aInt, int aValue, int aMin, int aMax )
|
|||
else if( aValue > aMax )
|
||||
temp = aMax;
|
||||
|
||||
*aInt = temp;
|
||||
*aTarget = temp;
|
||||
return (temp == aValue);
|
||||
}
|
||||
|
||||
|
||||
static bool setDouble( double* aTarget, double aValue, double aMin, double aMax )
|
||||
{
|
||||
double temp = aValue;
|
||||
|
||||
if( aValue < aMin )
|
||||
temp = aMin;
|
||||
else if( aValue > aMax )
|
||||
temp = aMax;
|
||||
|
||||
*aTarget = temp;
|
||||
return (temp == aValue);
|
||||
}
|
||||
|
||||
|
@ -182,7 +196,7 @@ void PCB_PLOT_PARAMS::Format( OUTPUTFORMATTER* aFormatter,
|
|||
|
||||
aFormatter->Print( aNestLevel+1, "(%s %d)\n", getTokenName( T_hpglpenspeed ),
|
||||
m_HPGLPenSpeed );
|
||||
aFormatter->Print( aNestLevel+1, "(%s %d)\n", getTokenName( T_hpglpendiameter ),
|
||||
aFormatter->Print( aNestLevel+1, "(%s %f)\n", getTokenName( T_hpglpendiameter ),
|
||||
m_HPGLPenDiam );
|
||||
aFormatter->Print( aNestLevel+1, "(%s %s)\n", getTokenName( T_psnegative ),
|
||||
m_negative ? trueStr : falseStr );
|
||||
|
@ -301,9 +315,9 @@ bool PCB_PLOT_PARAMS::IsSameAs( const PCB_PLOT_PARAMS &aPcbPlotParams, bool aCom
|
|||
}
|
||||
|
||||
|
||||
bool PCB_PLOT_PARAMS::SetHPGLPenDiameter( int aValue )
|
||||
bool PCB_PLOT_PARAMS::SetHPGLPenDiameter( double aValue )
|
||||
{
|
||||
return setInt( &m_HPGLPenDiam, aValue, HPGL_PEN_DIAMETER_MIN, HPGL_PEN_DIAMETER_MAX );
|
||||
return setDouble( &m_HPGLPenDiam, aValue, HPGL_PEN_DIAMETER_MIN, HPGL_PEN_DIAMETER_MAX );
|
||||
}
|
||||
|
||||
|
||||
|
@ -449,8 +463,7 @@ void PCB_PLOT_PARAMS_PARSER::Parse( PCB_PLOT_PARAMS* aPcbPlotParams )
|
|||
break;
|
||||
|
||||
case T_hpglpendiameter:
|
||||
aPcbPlotParams->m_HPGLPenDiam = parseInt( HPGL_PEN_DIAMETER_MIN,
|
||||
HPGL_PEN_DIAMETER_MAX );
|
||||
aPcbPlotParams->m_HPGLPenDiam = parseDouble();
|
||||
break;
|
||||
|
||||
case T_hpglpenoverlay:
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 1992-2015 KiCad Developers, see change_log.txt for contributors.
|
||||
* Copyright (C) 1992-2018 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
|
||||
|
@ -162,7 +162,8 @@ private:
|
|||
|
||||
int m_HPGLPenNum; ///< HPGL only: pen number selection(1 to 9)
|
||||
int m_HPGLPenSpeed; ///< HPGL only: pen speed, always in cm/s (1 to 99 cm/s)
|
||||
int 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.
|
||||
COLOR4D m_color; ///< Color for plotting the current layer. Provided, but not really used
|
||||
|
||||
public:
|
||||
|
@ -278,10 +279,15 @@ public:
|
|||
void SetA4Output( int aForce ) { m_A4Output = aForce; };
|
||||
bool GetA4Output() const { return m_A4Output; };
|
||||
|
||||
int GetHPGLPenDiameter() const { return m_HPGLPenDiam; };
|
||||
bool SetHPGLPenDiameter( int aValue );
|
||||
// For historical reasons, this parameter is stored in mils
|
||||
// (but is in mm in hpgl files...)
|
||||
double GetHPGLPenDiameter() const { return m_HPGLPenDiam; };
|
||||
bool SetHPGLPenDiameter( double aValue );
|
||||
|
||||
// This parameter is always in cm, due to hpgl file format constraint
|
||||
int GetHPGLPenSpeed() const { return m_HPGLPenSpeed; };
|
||||
bool SetHPGLPenSpeed( int aValue );
|
||||
|
||||
void SetHPGLPenNum( int aVal ) { m_HPGLPenNum = aVal; }
|
||||
int GetHPGLPenNum() const { return m_HPGLPenNum; }
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 1992-2011 KiCad Developers, see change_log.txt for contributors.
|
||||
* Copyright (C) 1992-2018 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
|
||||
|
|
Loading…
Reference in New Issue