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

Plot functions: some enhancements in mirror mode (Pcbnew specific): boards are...

Plot functions: some enhancements in mirror mode (Pcbnew specific): boards are mirrored horizontally, and the page layout is no more mirrored, and therefore is always readable.
parent 72e567f5
Loading
Loading
Loading
Loading
+22 −9
Original line number Original line Diff line number Diff line
@@ -30,7 +30,9 @@ PLOTTER::PLOTTER( )
    defaultPenWidth = 0;
    defaultPenWidth = 0;
    currentPenWidth = -1;       // To-be-set marker
    currentPenWidth = -1;       // To-be-set marker
    penState = 'Z';             // End-of-path idle
    penState = 'Z';             // End-of-path idle
    plotMirror = false;    		// Mirror flag
    m_plotMirror = false;    		// Mirror flag
    m_mirrorIsHorizontal = true;
    m_yaxisReversed = false;
    outputFile = 0;
    outputFile = 0;
    colorMode = false;          // Starts as a BW plot
    colorMode = false;          // Starts as a BW plot
    negativeMode = false;
    negativeMode = false;
@@ -74,16 +76,27 @@ bool PLOTTER::OpenFile( const wxString& aFullFilename )
 * scale factor, and offsets trace. Also convert from a wxPoint to DPOINT,
 * scale factor, and offsets trace. Also convert from a wxPoint to DPOINT,
 * since some output engines needs floating point coordinates.
 * since some output engines needs floating point coordinates.
 */
 */
DPOINT PLOTTER::userToDeviceCoordinates( const wxPoint& pos )
DPOINT PLOTTER::userToDeviceCoordinates( const wxPoint& aCoordinate )
{
{
    double x = (pos.x - plotOffset.x) * plotScale * iuPerDeviceUnit;
    wxPoint pos = aCoordinate - plotOffset;
    double y;


    if( plotMirror )
    double x = pos.x * plotScale;
        y = ( pos.y - plotOffset.y ) * plotScale * iuPerDeviceUnit ;
    double y = ( paperSize.y - pos.y * plotScale );

    if( m_plotMirror )
    {
        if( m_mirrorIsHorizontal )
            x = ( paperSize.x - pos.x * plotScale );
        else
        else
        y = ( paperSize.y - ( pos.y - plotOffset.y )
            y = pos.y * plotScale;
	      * plotScale ) * iuPerDeviceUnit ;
    }

    if( m_yaxisReversed )
        y = paperSize.y - y;

    x *= iuPerDeviceUnit;
    y *= iuPerDeviceUnit;

    return DPOINT( x, y );
    return DPOINT( x, y );
}
}


+1 −1
Original line number Original line Diff line number Diff line
@@ -44,7 +44,7 @@ void DXF_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
    iuPerDeviceUnit *= 0.00254;             // ... now in mm
    iuPerDeviceUnit *= 0.00254;             // ... now in mm


    SetDefaultLineWidth( 0 );               // No line width on DXF
    SetDefaultLineWidth( 0 );               // No line width on DXF
    plotMirror = false;                     // No mirroring on DXF
    m_plotMirror = false;                     // No mirroring on DXF
    m_currentColor = BLACK;
    m_currentColor = BLACK;
}
}


+1 −1
Original line number Original line Diff line number Diff line
@@ -21,7 +21,7 @@ void GERBER_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
{
{
    wxASSERT( !outputFile );
    wxASSERT( !outputFile );
    wxASSERT( aMirror == false );
    wxASSERT( aMirror == false );
    plotMirror = false;
    m_plotMirror = false;
    plotOffset = aOffset;
    plotOffset = aOffset;
    wxASSERT( aScale == 1 );
    wxASSERT( aScale == 1 );
    plotScale = 1;
    plotScale = 1;
+7 −8
Original line number Original line Diff line number Diff line
@@ -196,7 +196,7 @@ void HPGL_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
    paperSize.x *= 10.0 * aIusPerDecimil;
    paperSize.x *= 10.0 * aIusPerDecimil;
    paperSize.y *= 10.0 * aIusPerDecimil;
    paperSize.y *= 10.0 * aIusPerDecimil;
    SetDefaultLineWidth( 0 );    // HPGL has pen sizes instead
    SetDefaultLineWidth( 0 );    // HPGL has pen sizes instead
    plotMirror = aMirror;
    m_plotMirror = aMirror;
}
}




@@ -392,14 +392,15 @@ void HPGL_PLOTTER::Arc( const wxPoint& centre, double StAngle, double EndAngle,


    DPOINT centre_dev = userToDeviceCoordinates( centre );
    DPOINT centre_dev = userToDeviceCoordinates( centre );


    if( plotMirror )
    if( m_plotMirror )
        angle = StAngle - EndAngle;
        angle = StAngle - EndAngle;
    else
    else
        angle = EndAngle - StAngle;
        angle = EndAngle - StAngle;

    NORMALIZE_ANGLE_180( angle );
    NORMALIZE_ANGLE_180( angle );
    angle /= 10;
    angle /= 10;


    // Calculate start point,
    // Calculate arc start point:
    wxPoint cmap;
    wxPoint cmap;
    cmap.x  = centre.x + KiROUND( cosdecideg( radius, StAngle ) );
    cmap.x  = centre.x + KiROUND( cosdecideg( radius, StAngle ) );
    cmap.y  = centre.y - KiROUND( sindecideg( radius, StAngle ) );
    cmap.y  = centre.y - KiROUND( sindecideg( radius, StAngle ) );
@@ -407,10 +408,8 @@ void HPGL_PLOTTER::Arc( const wxPoint& centre, double StAngle, double EndAngle,


    fprintf( outputFile,
    fprintf( outputFile,
             "PU;PA %.0f,%.0f;PD;AA %.0f,%.0f,",
             "PU;PA %.0f,%.0f;PD;AA %.0f,%.0f,",
             cmap_dev.x,
             cmap_dev.x, cmap_dev.y,
             cmap_dev.y,
             centre_dev.x, centre_dev.y );
             centre_dev.x,
             centre_dev.y );
    fprintf( outputFile, "%.0f", angle );
    fprintf( outputFile, "%.0f", angle );
    fprintf( outputFile, ";PU;\n" );
    fprintf( outputFile, ";PU;\n" );
    PenFinish();
    PenFinish();
+1 −1
Original line number Original line Diff line number Diff line
@@ -71,7 +71,7 @@ void PDF_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
                              double aScale, bool aMirror )
                              double aScale, bool aMirror )
{
{
    wxASSERT( !workFile );
    wxASSERT( !workFile );
    plotMirror = aMirror;
    m_plotMirror = aMirror;
    plotOffset = aOffset;
    plotOffset = aOffset;
    plotScale = aScale;
    plotScale = aScale;
    m_IUsPerDecimil = aIusPerDecimil;
    m_IUsPerDecimil = aIusPerDecimil;
Loading