Commit f87577ca authored by unknown's avatar unknown Committed by jean-pierre charras

class PLOTTER: dash lines parameters in one place for plot. I made minor...

class PLOTTER: dash lines parameters in one place for plot. I made minor changes (values in mm and set to give the same size as dashed lines drawn by wxDC, using short dash.)
parent c586d973
......@@ -63,7 +63,8 @@ PLOTTER::PLOTTER( )
// Temporary init to avoid not initialized vars, will be set later
m_IUsPerDecimil = 1; // will be set later to the actual value
iuPerDeviceUnit = 1; // will be set later to the actual value
m_dashMarkLength_mm = 0.5; // Dashed line parameter in mm: segment
m_dashGapLength_mm = 0.25; // Dashed line parameter in mm: gap
}
PLOTTER::~PLOTTER()
......@@ -71,9 +72,7 @@ PLOTTER::~PLOTTER()
// Emergency cleanup, but closing the file is
// usually made in EndPlot().
if( outputFile )
{
fclose( outputFile );
}
}
......@@ -126,12 +125,24 @@ DPOINT PLOTTER::userToDeviceSize( const wxSize& size )
}
double PLOTTER::userToDeviceSize( double size )
double PLOTTER::userToDeviceSize( double size ) const
{
return size * plotScale * iuPerDeviceUnit;
}
double PLOTTER::GetDashMarkLenIU() const
{
double mark = userToDeviceSize( m_dashMarkLength_mm*10000/25.4*m_IUsPerDecimil - GetCurrentLineWidth() );
return ( mark < 0.0 ) ? 0.0 : mark;
}
double PLOTTER::GetDashGapLenIU() const
{
return userToDeviceSize( m_dashGapLength_mm*10000/25.4*m_IUsPerDecimil + GetCurrentLineWidth() );
}
void PLOTTER::Arc( const wxPoint& centre, double StAngle, double EndAngle, int radius,
FILL_T fill, int width )
{
......
......@@ -132,7 +132,8 @@ void PDF_PLOTTER::SetDash( bool dashed )
{
wxASSERT( workFile );
if( dashed )
fputs( "[200] 100 d\n", workFile );
fprintf( workFile, "[%d %d] 0 d\n",
(int) GetDashMarkLenIU(), (int) GetDashGapLenIU() );
else
fputs( "[] 0 d\n", workFile );
}
......
......@@ -228,7 +228,7 @@ void PSLIKE_PLOTTER::FlashPadTrapez( const wxPoint& aPadPos, const wxPoint *aCor
/**
* Write on a stream a string escaped for postscript/PDF
* Write on a stream a string escaped for postscript/PDF
*/
void PSLIKE_PLOTTER::fputsPostscriptString(FILE *fout, const wxString& txt)
{
......@@ -469,7 +469,8 @@ void PS_PLOTTER::SetDash( bool dashed )
{
wxASSERT( outputFile );
if( dashed )
fputs( "dashedline\n", outputFile );
fprintf( outputFile, "[%d %d] 0 setdash\n",
(int) GetDashMarkLenIU(), (int) GetDashGapLenIU() );
else
fputs( "solidline\n", outputFile );
}
......
......@@ -231,14 +231,8 @@ void SVG_PLOTTER::setSVGPlotStyle()
fputs( "stroke-linecap:round; stroke-linejoin:round;", outputFile );
if( m_dashed )
{
// Use a simple dash shape: a segment + a space
#define DASH_SIZE 0.3 // length in mm of a dash
double segm_len = DASH_SIZE * 10000/2.54 * m_IUsPerDecimil;
// Use a space to the same len as segment, between segments
double space_len = segm_len + pen_w;
fprintf( outputFile, "stroke-dasharray:%g,%g;", segm_len, space_len );
}
fprintf( outputFile, "stroke-dasharray:%g,%g;",
GetDashMarkLenIU(), GetDashGapLenIU() );
fputs( "\">\n", outputFile );
......
......@@ -82,6 +82,10 @@ enum PlotTextMode {
*/
class PLOTTER
{
private:
double m_dashMarkLength_mm ; ///< Dashed line parameter in mm: segment
double m_dashGapLength_mm; ///< Dashed line parameter in mm: gap
public:
static const int DEFAULT_LINE_WIDTH = -1;
......@@ -396,7 +400,11 @@ protected:
* Modifies size according to the plotter scale factors
* (simple double version)
*/
virtual double userToDeviceSize( double size );
virtual double userToDeviceSize( double size ) const;
double GetDashMarkLenIU() const;
double GetDashGapLenIU() const;
/// Plot scale - chosen by the user (even implicitly with 'fit in a4')
double plotScale;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment