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

Pcbnew: simplify draw code in default canvas and plot functions by removing...

Pcbnew: simplify draw code in  default canvas and plot functions by removing the plot LINE option, which is not existing in all plotters, not existing in opengl/cairo canvas, and not usefull in default canvas.
parent 2ff623dc
Loading
Loading
Loading
Loading
+14 −42
Original line number Original line Diff line number Diff line
@@ -433,19 +433,16 @@ void PLOTTER::sketchOval( const wxPoint& pos, const wxSize& aSize, double orient
void PLOTTER::ThickSegment( const wxPoint& start, const wxPoint& end, int width,
void PLOTTER::ThickSegment( const wxPoint& start, const wxPoint& end, int width,
                            EDA_DRAW_MODE_T tracemode )
                            EDA_DRAW_MODE_T tracemode )
{
{
    switch( tracemode )
    if( tracemode == FILLED )
    {
    {
    case FILLED:
        SetCurrentLineWidth( width );
    case LINE:
        SetCurrentLineWidth( tracemode==FILLED ? width : -1 );
        MoveTo( start );
        MoveTo( start );
        FinishTo( end );
        FinishTo( end );
        break;
    }

    else
    case SKETCH:
    {
        SetCurrentLineWidth( -1 );
        SetCurrentLineWidth( -1 );
        segmentAsOval( start, end, width, tracemode );
        segmentAsOval( start, end, width, tracemode );
        break;
    }
    }
}
}


@@ -453,24 +450,15 @@ void PLOTTER::ThickSegment( const wxPoint& start, const wxPoint& end, int width,
void PLOTTER::ThickArc( const wxPoint& centre, double StAngle, double EndAngle,
void PLOTTER::ThickArc( const wxPoint& centre, double StAngle, double EndAngle,
                        int radius, int width, EDA_DRAW_MODE_T tracemode )
                        int radius, int width, EDA_DRAW_MODE_T tracemode )
{
{
    switch( tracemode )
    if( tracemode == FILLED )
    {
    case LINE:
        SetCurrentLineWidth( -1 );
        Arc( centre, StAngle, EndAngle, radius, NO_FILL, -1 );
        break;

    case FILLED:
        Arc( centre, StAngle, EndAngle, radius, NO_FILL, width );
        Arc( centre, StAngle, EndAngle, radius, NO_FILL, width );
        break;
    else

    {
    case SKETCH:
        SetCurrentLineWidth( -1 );
        SetCurrentLineWidth( -1 );
        Arc( centre, StAngle, EndAngle,
        Arc( centre, StAngle, EndAngle,
             radius - ( width - currentPenWidth ) / 2, NO_FILL, -1 );
             radius - ( width - currentPenWidth ) / 2, NO_FILL, -1 );
        Arc( centre, StAngle, EndAngle,
        Arc( centre, StAngle, EndAngle,
             radius + ( width - currentPenWidth ) / 2, NO_FILL, -1 );
             radius + ( width - currentPenWidth ) / 2, NO_FILL, -1 );
        break;
    }
    }
}
}


@@ -478,17 +466,10 @@ void PLOTTER::ThickArc( const wxPoint& centre, double StAngle, double EndAngle,
void PLOTTER::ThickRect( const wxPoint& p1, const wxPoint& p2, int width,
void PLOTTER::ThickRect( const wxPoint& p1, const wxPoint& p2, int width,
                         EDA_DRAW_MODE_T tracemode )
                         EDA_DRAW_MODE_T tracemode )
{
{
    switch( tracemode )
    if( tracemode == FILLED )
    {
    case LINE:
        Rect( p1, p2, NO_FILL, -1 );
        break;

    case FILLED:
        Rect( p1, p2, NO_FILL, width );
        Rect( p1, p2, NO_FILL, width );
        break;
    else

    {
    case SKETCH:
        SetCurrentLineWidth( -1 );
        SetCurrentLineWidth( -1 );
        wxPoint offsetp1( p1.x - (width - currentPenWidth) / 2,
        wxPoint offsetp1( p1.x - (width - currentPenWidth) / 2,
                          p1.y - (width - currentPenWidth) / 2 );
                          p1.y - (width - currentPenWidth) / 2 );
@@ -500,28 +481,19 @@ void PLOTTER::ThickRect( const wxPoint& p1, const wxPoint& p2, int width,
        offsetp2.x -= (width - currentPenWidth);
        offsetp2.x -= (width - currentPenWidth);
        offsetp2.y -= (width - currentPenWidth);
        offsetp2.y -= (width - currentPenWidth);
        Rect( offsetp1, offsetp2, NO_FILL, -1 );
        Rect( offsetp1, offsetp2, NO_FILL, -1 );
        break;
    }
    }
}
}




void PLOTTER::ThickCircle( const wxPoint& pos, int diametre, int width, EDA_DRAW_MODE_T tracemode )
void PLOTTER::ThickCircle( const wxPoint& pos, int diametre, int width, EDA_DRAW_MODE_T tracemode )
{
{
    switch( tracemode )
    if( tracemode == FILLED )
    {
    case LINE:
        Circle( pos, diametre, NO_FILL, -1 );
        break;

    case FILLED:
        Circle( pos, diametre, NO_FILL, width );
        Circle( pos, diametre, NO_FILL, width );
        break;
    else

    {
    case SKETCH:
        SetCurrentLineWidth( -1 );
        SetCurrentLineWidth( -1 );
        Circle( pos, diametre - width + currentPenWidth, NO_FILL, -1 );
        Circle( pos, diametre - width + currentPenWidth, NO_FILL, -1 );
        Circle( pos, diametre + width - currentPenWidth, NO_FILL, -1 );
        Circle( pos, diametre + width - currentPenWidth, NO_FILL, -1 );
        break;
    }
    }
}
}


+1 −9
Original line number Original line Diff line number Diff line
@@ -466,17 +466,9 @@ void DXF_PLOTTER::SetDash( bool dashed )


void DXF_PLOTTER::ThickSegment( const wxPoint& aStart, const wxPoint& aEnd, int aWidth,
void DXF_PLOTTER::ThickSegment( const wxPoint& aStart, const wxPoint& aEnd, int aWidth,
                                EDA_DRAW_MODE_T aPlotMode )
                                EDA_DRAW_MODE_T aPlotMode )
{
    if( aPlotMode == LINE )  // In line mode, just a line is OK
    {
        MoveTo( aStart );
        FinishTo( aEnd );
    }
    else
{
{
    segmentAsOval( aStart, aEnd, aWidth, aPlotMode );
    segmentAsOval( aStart, aEnd, aWidth, aPlotMode );
}
}
}


/* Plot an arc in DXF format
/* Plot an arc in DXF format
 * Filling is not supported
 * Filling is not supported
+8 −14
Original line number Original line Diff line number Diff line
@@ -432,19 +432,16 @@ void GERBER_PLOTTER::FlashPadCircle( const wxPoint& pos, int diametre, EDA_DRAW_
    wxASSERT( outputFile );
    wxASSERT( outputFile );
    wxSize size( diametre, diametre );
    wxSize size( diametre, diametre );


    switch( trace_mode )
    if( trace_mode == SKETCH )
    {
    {
    case LINE:
    case SKETCH:
        SetCurrentLineWidth( -1 );
        SetCurrentLineWidth( -1 );
        Circle( pos, diametre - currentPenWidth, NO_FILL );
        Circle( pos, diametre - currentPenWidth, NO_FILL );
        break;
    }

    else
    case FILLED:
    {
        DPOINT pos_dev = userToDeviceCoordinates( pos );
        DPOINT pos_dev = userToDeviceCoordinates( pos );
        selectAperture( size, APERTURE::Circle );
        selectAperture( size, APERTURE::Circle );
        emitDcode( pos_dev, 3 );
        emitDcode( pos_dev, 3 );
        break;
    }
    }
}
}


@@ -519,23 +516,20 @@ void GERBER_PLOTTER::FlashPadRect( const wxPoint& pos, const wxSize& aSize,
	// Pass through
	// Pass through
    case 0:
    case 0:
    case 1800:
    case 1800:
        switch( trace_mode )
        if( trace_mode == SKETCH )
        {
        {
        case LINE:
        case SKETCH:
            SetCurrentLineWidth( -1 );
            SetCurrentLineWidth( -1 );
            Rect( wxPoint( pos.x - (size.x - currentPenWidth) / 2,
            Rect( wxPoint( pos.x - (size.x - currentPenWidth) / 2,
                           pos.y - (size.y - currentPenWidth) / 2 ),
                           pos.y - (size.y - currentPenWidth) / 2 ),
                  wxPoint( pos.x + (size.x - currentPenWidth) / 2,
                  wxPoint( pos.x + (size.x - currentPenWidth) / 2,
                           pos.y + (size.y - currentPenWidth) / 2 ),
                           pos.y + (size.y - currentPenWidth) / 2 ),
                  NO_FILL );
                  NO_FILL );
            break;
        }

        else
        case FILLED:
        {
            DPOINT pos_dev = userToDeviceCoordinates( pos );
            DPOINT pos_dev = userToDeviceCoordinates( pos );
            selectAperture( size, APERTURE::Rect );
            selectAperture( size, APERTURE::Rect );
            emitDcode( pos_dev, 3 );
            emitDcode( pos_dev, 3 );
            break;
        }
        }
        break;
        break;


+5 −13
Original line number Original line Diff line number Diff line
@@ -388,8 +388,8 @@ void HPGL_PLOTTER::ThickSegment( const wxPoint& start, const wxPoint& end,
    wxPoint center;
    wxPoint center;
    wxSize  size;
    wxSize  size;


    // Suppress overlap if pen is too big or in line mode
    // Suppress overlap if pen is too big
    if( (penDiameter >= width) || (tracemode == LINE) )
    if( penDiameter >= width )
    {
    {
        MoveTo( start );
        MoveTo( start );
        FinishTo( end );
        FinishTo( end );
@@ -491,15 +491,10 @@ void HPGL_PLOTTER::FlashPadCircle( const wxPoint& pos, int diametre,
    int     delta   = KiROUND( penDiameter - penOverlap );
    int     delta   = KiROUND( penDiameter - penOverlap );
    int     radius  = diametre / 2;
    int     radius  = diametre / 2;


    if( trace_mode != LINE )
    {
    radius = ( diametre - KiROUND( penDiameter ) ) / 2;
    radius = ( diametre - KiROUND( penDiameter ) ) / 2;
    }


    if( radius < 0 )
    if( radius < 0 )
    {
        radius = 0;
        radius = 0;
    }


    double rsize = userToDeviceSize( radius );
    double rsize = userToDeviceSize( radius );


@@ -534,11 +529,8 @@ void HPGL_PLOTTER::FlashPadRect( const wxPoint& pos, const wxSize& padsize,
    size.x  = padsize.x / 2;
    size.x  = padsize.x / 2;
    size.y  = padsize.y / 2;
    size.y  = padsize.y / 2;


    if( trace_mode != LINE )
    {
    size.x  = (padsize.x - (int) penDiameter) / 2;
    size.x  = (padsize.x - (int) penDiameter) / 2;
    size.y  = (padsize.y - (int) penDiameter) / 2;
    size.y  = (padsize.y - (int) penDiameter) / 2;
    }


    if( size.x < 0 )
    if( size.x < 0 )
        size.x = 0;
        size.x = 0;
+0 −3
Original line number Original line Diff line number Diff line
@@ -346,9 +346,6 @@ void EDA_TEXT::drawOneLineOfText( EDA_RECT* aClipBox, wxDC* aDC,
{
{
    int width = m_Thickness;
    int width = m_Thickness;


    if( aFillMode == LINE )
        width = 0;

    if( aDrawMode != UNSPECIFIED_DRAWMODE )
    if( aDrawMode != UNSPECIFIED_DRAWMODE )
        GRSetDrawMode( aDC, aDrawMode );
        GRSetDrawMode( aDC, aDrawMode );


Loading