Commit 086ff54e authored by jean-pierre charras's avatar jean-pierre charras
Browse files

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.
parent f2ce42dd
Loading
Loading
Loading
Loading
+22 −1
Original line number Diff line number Diff line
@@ -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();
}


+9 −8
Original line number Diff line number Diff line
@@ -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 );
}


+1 −1
Original line number Diff line number Diff line
@@ -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 );
}


+1 −1
Original line number Diff line number Diff line
@@ -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
}


+1 −0
Original line number Diff line number Diff line
@@ -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()
Loading