Fix minor issues: plot svg did not handle dashed lines.

Eeschema now uses dashed lines for graphic lines (to be consistent with plot functions and toolbal icon).
Fix an old bug in some envionments which warp the mouse on a bad monitor when opening eeschema, pcbnew and some other windows, only noticeable guys who are lucky enough to have more than one monitor.
This commit is contained in:
jean-pierre charras 2015-03-06 18:46:04 +01:00
parent f2ce42ddb5
commit 086ff54ef0
8 changed files with 37 additions and 14 deletions

View File

@ -165,6 +165,7 @@ SVG_PLOTTER::SVG_PLOTTER()
m_fillMode = NO_FILL; // or FILLED_SHAPE or FILLED_WITH_BG_BODYCOLOR
m_pen_rgb_color = 0; // current color value (black)
m_brush_rgb_color = 0; // current color value (black)
m_dashed = false;
}
@ -227,7 +228,19 @@ void SVG_PLOTTER::setSVGPlotStyle()
double pen_w = userToDeviceSize( GetCurrentLineWidth() );
fprintf( outputFile, "\nstroke:#%6.6lX; stroke-width:%g; stroke-opacity:1; \n",
m_pen_rgb_color, pen_w );
fputs( "stroke-linecap:round; stroke-linejoin:round;\">\n", outputFile );
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 );
}
fputs( "\">\n", outputFile );
m_graphics_changed = false;
}
@ -281,6 +294,14 @@ void SVG_PLOTTER::emitSetRGBColor( double r, double g, double b )
*/
void SVG_PLOTTER::SetDash( bool dashed )
{
if( m_dashed != dashed )
{
m_graphics_changed = true;
m_dashed = dashed;
}
if( m_graphics_changed )
setSVGPlotStyle();
}

View File

@ -172,8 +172,7 @@ static bool clipLine( const EDA_RECT *aClipBox, int &x1, int &y1, int &x2, int &
return false;
}
static void WinClipAndDrawLine( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
EDA_COLOR_T Color, int width = 1 )
static void WinClipAndDrawLine( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, int width )
{
GRLastMoveToX = x2;
GRLastMoveToY = y2;
@ -186,7 +185,6 @@ static void WinClipAndDrawLine( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int
return;
}
GRSetColorPen( DC, Color, width );
DC->DrawLine( x1, y1, x2, y2 );
}
@ -374,7 +372,8 @@ void GRLine( EDA_RECT* ClipBox,
int width,
EDA_COLOR_T Color )
{
WinClipAndDrawLine( ClipBox, DC, x1, y1, x2, y2, Color, width );
GRSetColorPen( DC, Color, width );
WinClipAndDrawLine( ClipBox, DC, x1, y1, x2, y2, width );
GRLastMoveToX = x2;
GRLastMoveToY = y2;
}
@ -390,7 +389,7 @@ void GRDashedLineTo( EDA_RECT* ClipBox, wxDC* DC, int x2, int y2, int width, EDA
{
s_DC_lastcolor = UNSPECIFIED_COLOR;
GRSetColorPen( DC, Color, width, wxPENSTYLE_SHORT_DASH );
GRLine( ClipBox, DC, GRLastMoveToX, GRLastMoveToY, x2, y2, width, Color );
WinClipAndDrawLine( ClipBox, DC, GRLastMoveToX, GRLastMoveToY, x2, y2, width );
s_DC_lastcolor = UNSPECIFIED_COLOR;
GRSetColorPen( DC, Color, width );
GRLastMoveToX = x2;
@ -411,7 +410,7 @@ void GRDashedLine( EDA_RECT* ClipBox,
GRLastMoveToY = y2;
s_DC_lastcolor = UNSPECIFIED_COLOR;
GRSetColorPen( DC, Color, width, wxPENSTYLE_SHORT_DASH );
GRLine( ClipBox, DC, x1, y1, x2, y2, width, Color );
WinClipAndDrawLine( ClipBox, DC, x1, y1, x2, y2, width );
s_DC_lastcolor = UNSPECIFIED_COLOR;
GRSetColorPen( DC, Color, width );
}
@ -590,14 +589,16 @@ void GRCSegm( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd,
void GRFillCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
int width, EDA_COLOR_T Color )
{
WinClipAndDrawLine( ClipBox, DC, x1, y1, x2, y2, Color, width );
GRSetColorPen( DC, Color, width );
WinClipAndDrawLine( ClipBox, DC, x1, y1, x2, y2, width );
}
void GRFilledSegment( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd,
int aWidth, EDA_COLOR_T aColor )
{
WinClipAndDrawLine( aClipBox, aDC, aStart.x, aStart.y, aEnd.x, aEnd.y, aColor, aWidth );
GRSetColorPen( aDC, aColor, aWidth );
WinClipAndDrawLine( aClipBox, aDC, aStart.x, aStart.y, aEnd.x, aEnd.y, aWidth );
}

View File

@ -397,7 +397,7 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ):
// Now Drawpanel is sized, we can use BestZoom to show the component (if any)
GetScreen()->SetZoom( BestZoom() );
Zoom_Automatique( true );
Zoom_Automatique( false );
}

View File

@ -175,7 +175,7 @@ GERBVIEW_FRAME::GERBVIEW_FRAME( KIWAY* aKiway, wxWindow* aParent ):
m_auimgr.Update();
setActiveLayer( 0, true );
Zoom_Automatique( true ); // Gives a default zoom value
Zoom_Automatique( false ); // Gives a default zoom value
}

View File

@ -813,6 +813,7 @@ protected:
bool m_graphics_changed; // true if a pen/brush parameter is modified
// color, pen size, fil mode ...
// the new SVG stype must be output on file
bool m_dashed; // true to use plot dashed line style
/**
* function emitSetRGBColor()

View File

@ -774,7 +774,7 @@ void PL_EDITOR_FRAME::OnNewPageLayout()
GetScreen()->ClrModify();
m_propertiesPagelayout->CopyPrmsFromGeneralToPanel();
RebuildDesignTree();
Zoom_Automatique( true );
Zoom_Automatique( false );
m_canvas->Refresh();
}

View File

@ -344,7 +344,7 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
m_auimgr.Update();
Zoom_Automatique( true );
Zoom_Automatique( false );
}

View File

@ -450,7 +450,7 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
setupTools();
Zoom_Automatique( true );
Zoom_Automatique( false );
}