Remove dependency of dot size on linear mils
Changes a dot to be a square pixel (linewidth x linewidth). This allows the removal of IU dependencies and ensures that a dot is always visible on screen. Also makes sure that cairo is setting the current linewidth during its stroke routines Fixes https://gitlab.com/kicad/code/kicad/issues/9362
This commit is contained in:
parent
93bbad6acf
commit
52bbfb9109
|
@ -1075,13 +1075,19 @@ void CAIRO_GAL_BASE::flushPath()
|
|||
m_fillColor.a );
|
||||
|
||||
if( m_isStrokeEnabled )
|
||||
{
|
||||
cairo_set_line_width( m_currentContext, m_lineWidthInPixels );
|
||||
cairo_fill_preserve( m_currentContext );
|
||||
}
|
||||
else
|
||||
{
|
||||
cairo_fill( m_currentContext );
|
||||
}
|
||||
}
|
||||
|
||||
if( m_isStrokeEnabled )
|
||||
{
|
||||
cairo_set_line_width( m_currentContext, m_lineWidthInPixels );
|
||||
cairo_set_source_rgba( m_currentContext, m_strokeColor.r, m_strokeColor.g, m_strokeColor.b,
|
||||
m_strokeColor.a );
|
||||
cairo_stroke( m_currentContext );
|
||||
|
|
|
@ -138,19 +138,19 @@ double PLOTTER::userToDeviceSize( double size ) const
|
|||
|
||||
double PLOTTER::GetDotMarkLenIU() const
|
||||
{
|
||||
return userToDeviceSize( DOT_MARK_LEN( GetCurrentLineWidth() ) );
|
||||
return userToDeviceSize( dot_mark_len( GetCurrentLineWidth() ) );
|
||||
}
|
||||
|
||||
|
||||
double PLOTTER::GetDashMarkLenIU() const
|
||||
{
|
||||
return userToDeviceSize( DASH_MARK_LEN( GetCurrentLineWidth() ) );
|
||||
return userToDeviceSize( dash_mark_len( GetCurrentLineWidth() ) );
|
||||
}
|
||||
|
||||
|
||||
double PLOTTER::GetDashGapLenIU() const
|
||||
{
|
||||
return userToDeviceSize( DASH_GAP_LEN( GetCurrentLineWidth() ) );
|
||||
return userToDeviceSize( dash_gap_len( GetCurrentLineWidth() ) );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -244,20 +244,20 @@ void SCH_BUS_ENTRY_BASE::Print( const RENDER_SETTINGS* aSettings, const wxPoint&
|
|||
clip.Normalize();
|
||||
|
||||
double theta = atan2( end.y - start.y, end.x - start.x );
|
||||
double strokes[] = { 1.0, DASH_GAP_LEN( penWidth ), 1.0, DASH_GAP_LEN( penWidth ) };
|
||||
double strokes[] = { 1.0, dash_gap_len( penWidth ), 1.0, dash_gap_len( penWidth ) };
|
||||
|
||||
switch( GetStrokeStyle() )
|
||||
{
|
||||
default:
|
||||
case PLOT_DASH_TYPE::DASH:
|
||||
strokes[0] = strokes[2] = DASH_MARK_LEN( penWidth );
|
||||
strokes[0] = strokes[2] = dash_mark_len( penWidth );
|
||||
break;
|
||||
case PLOT_DASH_TYPE::DOT:
|
||||
strokes[0] = strokes[2] = DOT_MARK_LEN( penWidth );
|
||||
strokes[0] = strokes[2] = dot_mark_len( penWidth );
|
||||
break;
|
||||
case PLOT_DASH_TYPE::DASHDOT:
|
||||
strokes[0] = DASH_MARK_LEN( penWidth );
|
||||
strokes[2] = DOT_MARK_LEN( penWidth );
|
||||
strokes[0] = dash_mark_len( penWidth );
|
||||
strokes[2] = dot_mark_len( penWidth );
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -343,20 +343,20 @@ void SCH_LINE::Print( const RENDER_SETTINGS* aSettings, const wxPoint& offset )
|
|||
clip.Normalize();
|
||||
|
||||
double theta = atan2( end.y - start.y, end.x - start.x );
|
||||
double strokes[] = { 1.0, DASH_GAP_LEN( penWidth ), 1.0, DASH_GAP_LEN( penWidth ) };
|
||||
double strokes[] = { 1.0, dash_gap_len( penWidth ), 1.0, dash_gap_len( penWidth ) };
|
||||
|
||||
switch( lineStyle )
|
||||
{
|
||||
default:
|
||||
case PLOT_DASH_TYPE::DASH:
|
||||
strokes[0] = strokes[2] = DASH_MARK_LEN( penWidth );
|
||||
strokes[0] = strokes[2] = dash_mark_len( penWidth );
|
||||
break;
|
||||
case PLOT_DASH_TYPE::DOT:
|
||||
strokes[0] = strokes[2] = DOT_MARK_LEN( penWidth );
|
||||
strokes[0] = strokes[2] = dot_mark_len( penWidth );
|
||||
break;
|
||||
case PLOT_DASH_TYPE::DASHDOT:
|
||||
strokes[0] = DASH_MARK_LEN( penWidth );
|
||||
strokes[2] = DOT_MARK_LEN( penWidth );
|
||||
strokes[0] = dash_mark_len( penWidth );
|
||||
strokes[2] = dot_mark_len( penWidth );
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -1305,20 +1305,20 @@ void SCH_PAINTER::draw( const SCH_LINE *aLine, int aLayer )
|
|||
clip.Normalize();
|
||||
|
||||
double theta = atan2( end.y - start.y, end.x - start.x );
|
||||
double strokes[] = { 1.0, DASH_GAP_LEN( width ), 1.0, DASH_GAP_LEN( width ) };
|
||||
double strokes[] = { 1.0, dash_gap_len( width ), 1.0, dash_gap_len( width ) };
|
||||
|
||||
switch( lineStyle )
|
||||
{
|
||||
default:
|
||||
case PLOT_DASH_TYPE::DASH:
|
||||
strokes[0] = strokes[2] = DASH_MARK_LEN( width );
|
||||
strokes[0] = strokes[2] = dash_mark_len( width );
|
||||
break;
|
||||
case PLOT_DASH_TYPE::DOT:
|
||||
strokes[0] = strokes[2] = DOT_MARK_LEN( width );
|
||||
strokes[0] = strokes[2] = dot_mark_len( width );
|
||||
break;
|
||||
case PLOT_DASH_TYPE::DASHDOT:
|
||||
strokes[0] = DASH_MARK_LEN( width );
|
||||
strokes[2] = DOT_MARK_LEN( width );
|
||||
strokes[0] = dash_mark_len( width );
|
||||
strokes[2] = dot_mark_len( width );
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -151,23 +151,22 @@ bool ClipLine( const EDA_RECT *aClipBox, int &x1, int &y1, int &x2, int &y2 );
|
|||
|
||||
/**
|
||||
* Dashed and dotted line patterns.
|
||||
*
|
||||
* Note: these are all macros because they're included from files with different
|
||||
* IU definitions.
|
||||
*/
|
||||
|
||||
#define DOT_WIDTH_MILS 0.0254
|
||||
|
||||
#define DOT_MARK_LEN( aLineWidth ) \
|
||||
( std::max( 1.0, IU_PER_MILS * DOT_WIDTH_MILS - aLineWidth ) )
|
||||
|
||||
#define DASH_GAP_LEN( aLineWidth ) \
|
||||
( 3.0 * DOT_MARK_LEN( aLineWidth ) + ( 2.0 * aLineWidth ) )
|
||||
|
||||
#define DASH_MARK_LEN( aLineWidth ) \
|
||||
( std::max( DASH_GAP_LEN( aLineWidth ), 5.0 * DOT_MARK_LEN( aLineWidth ) ) )
|
||||
constexpr double dot_mark_len( double aLineWidth )
|
||||
{
|
||||
return std::max( 1.0, aLineWidth );
|
||||
}
|
||||
|
||||
constexpr double dash_gap_len( double aLineWidth )
|
||||
{
|
||||
return 3.0 * dot_mark_len( aLineWidth ) + ( 2.0 * aLineWidth );
|
||||
}
|
||||
|
||||
constexpr double dash_mark_len( double aLineWidth )
|
||||
{
|
||||
return std::max( dash_gap_len( aLineWidth ), 5.0 * dot_mark_len( aLineWidth ) );
|
||||
}
|
||||
|
||||
#endif // #ifndef GEOMETRY_UTILS_H
|
||||
|
||||
|
|
Loading…
Reference in New Issue