diff --git a/common/common_plotSVG_functions.cpp b/common/common_plotSVG_functions.cpp index 857d93f67b..5610b7cac9 100644 --- a/common/common_plotSVG_functions.cpp +++ b/common/common_plotSVG_functions.cpp @@ -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(); } diff --git a/common/gr_basic.cpp b/common/gr_basic.cpp index c554b57a86..3f464a512f 100644 --- a/common/gr_basic.cpp +++ b/common/gr_basic.cpp @@ -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 ); } diff --git a/eeschema/schframe.cpp b/eeschema/schframe.cpp index 9e802aa6b4..9118ec3a97 100644 --- a/eeschema/schframe.cpp +++ b/eeschema/schframe.cpp @@ -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 ); } diff --git a/gerbview/gerbview_frame.cpp b/gerbview/gerbview_frame.cpp index e2d46afc26..fc76c954a1 100644 --- a/gerbview/gerbview_frame.cpp +++ b/gerbview/gerbview_frame.cpp @@ -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 } diff --git a/include/plot_common.h b/include/plot_common.h index 37ef0e51f7..e0dd660e90 100644 --- a/include/plot_common.h +++ b/include/plot_common.h @@ -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() diff --git a/pagelayout_editor/pl_editor_frame.cpp b/pagelayout_editor/pl_editor_frame.cpp index e418191708..0fd9a745e6 100644 --- a/pagelayout_editor/pl_editor_frame.cpp +++ b/pagelayout_editor/pl_editor_frame.cpp @@ -774,7 +774,7 @@ void PL_EDITOR_FRAME::OnNewPageLayout() GetScreen()->ClrModify(); m_propertiesPagelayout->CopyPrmsFromGeneralToPanel(); RebuildDesignTree(); - Zoom_Automatique( true ); + Zoom_Automatique( false ); m_canvas->Refresh(); } diff --git a/pcbnew/moduleframe.cpp b/pcbnew/moduleframe.cpp index 4c268b1f6d..7c0a8a78d1 100644 --- a/pcbnew/moduleframe.cpp +++ b/pcbnew/moduleframe.cpp @@ -344,7 +344,7 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : m_auimgr.Update(); - Zoom_Automatique( true ); + Zoom_Automatique( false ); } diff --git a/pcbnew/pcbframe.cpp b/pcbnew/pcbframe.cpp index b74dc527ca..54c23d4ea9 100644 --- a/pcbnew/pcbframe.cpp +++ b/pcbnew/pcbframe.cpp @@ -450,7 +450,7 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : setupTools(); - Zoom_Automatique( true ); + Zoom_Automatique( false ); }