Commit 7cef5395 authored by Lorenzo Marcantonio's avatar Lorenzo Marcantonio
Browse files

Minor plot driver enhancements

parent 715af961
Loading
Loading
Loading
Loading
+13 −6
Original line number Diff line number Diff line
@@ -29,13 +29,20 @@ void DXF_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
    wxASSERT( !outputFile );
    plotOffset  = aOffset;
    plotScale   = aScale;
    // XXX Need to think about this: what is the 'native' unit used for DXF? 

    /* DXF paper is 'virtual' so there is no need of a paper size.
       Also this way we can handle the aux origin which can be useful
       (for example when aligning to a mechanical drawing) */
    paperSize.x = 0;
    paperSize.y = 0;

    /* Like paper size DXF units are abstract too. Anyway there is a
     * system variable (MEASUREMENT) which will be set to 1 to indicate
     * metric units */
    m_IUsPerDecimil = aIusPerDecimil;
    iuPerDeviceUnit = 1.0 / aIusPerDecimil; // Gives a DXF in decimils
    iuPerDeviceUnit *= 0.00254;             // DXF in mm (I like it best)
    // Compute the paper size in IUs 
    paperSize = pageInfo.GetSizeMils();
    paperSize.x *= 10.0 * aIusPerDecimil;
    paperSize.y *= 10.0 * aIusPerDecimil;
    iuPerDeviceUnit *= 0.00254;             // ... now in mm

    SetDefaultLineWidth( 0 );    // No line width on DXF
    plotMirror = false;             // No mirroring on DXF 
    currentColor = BLACK;
+1 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ void GERBER_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
    plotOffset = aOffset;
    wxASSERT( aScale == 1 );
    plotScale = 1;
    m_IUsPerDecimil = aIusPerDecimil;
    iuPerDeviceUnit = 1.0 / aIusPerDecimil;
    /* We don't handle the filmbox, and it's more useful to keep the
     * origin at the origin */
+1 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ void HPGL_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
    wxASSERT( !outputFile );
    plotOffset  = aOffset;
    plotScale = aScale;
    m_IUsPerDecimil = aIusPerDecimil;
    iuPerDeviceUnit = PLUsPERDECIMIL / aIusPerDecimil;
    /* Compute the paper size in IUs */
    paperSize = pageInfo.GetSizeMils();
+5 −8
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ void PDF_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
    plotMirror = aMirror;
    plotOffset = aOffset;
    plotScale = aScale;
    m_IUsPerDecimil = aIusPerDecimil;

    // The CTM is set to 1 user unit per decimil
    iuPerDeviceUnit = 1.0 / aIusPerDecimil;
@@ -425,10 +426,6 @@ int PDF_PLOTTER::startPdfStream(int handle)

/**
 * Finish the current PDF stream (writes the deferred length, too)
 * XXX the compression code is not very elegant... is slurps the
 * whole stream in RAM, allocates an output buffer of the same size
 * and try to FLATE it. Asserts if it couldn't... enhancements are
 * welcome but for now it simply works
 */
void PDF_PLOTTER::closePdfStream()
{
@@ -730,7 +727,7 @@ void PDF_PLOTTER::Text( const wxPoint& aPos,
                        bool                        aBold )
{
    // Emit native PDF text (if requested)
    if( psTextMode != PSTEXTMODE_STROKE )
    if( m_textMode != PLOTTEXTMODE_STROKE )
    {
        const char *fontname = aItalic ? (aBold ? "/KicadFontBI" : "/KicadFontI")
            : (aBold ? "/KicadFontB" : "/KicadFont");
@@ -754,7 +751,7 @@ void PDF_PLOTTER::Text( const wxPoint& aPos,
        fprintf( workFile, "q %f %f %f %f %g %g cm BT %s %g Tf %d Tr %g Tz ",
                ctm_a, ctm_b, ctm_c, ctm_d, ctm_e, ctm_f,
                fontname, heightFactor,
                (psTextMode == PSTEXTMODE_NATIVE) ? 0 : 3,
                (m_textMode == PLOTTEXTMODE_NATIVE) ? 0 : 3,
                wideningFactor * 100 );

        // The text must be escaped correctly
@@ -763,7 +760,7 @@ void PDF_PLOTTER::Text( const wxPoint& aPos,

        /* We are still in text coordinates, plot the overbars (if we're
         * not doing phantom text) */
        if( psTextMode == PSTEXTMODE_NATIVE )
        if( m_textMode == PLOTTEXTMODE_NATIVE )
        {
            std::vector<int> pos_pairs;
            postscriptOverlinePositions( aText, aSize.x, aItalic, aBold, &pos_pairs );
@@ -786,7 +783,7 @@ void PDF_PLOTTER::Text( const wxPoint& aPos,
    }

    // Plot the stroked text (if requested)
    if( psTextMode != PSTEXTMODE_NATIVE )
    if( m_textMode != PLOTTEXTMODE_NATIVE )
    {
        PLOTTER::Text( aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify,
                aWidth, aItalic, aBold );
+4 −3
Original line number Diff line number Diff line
@@ -308,6 +308,7 @@ void PS_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
    plotMirror = aMirror;
    plotOffset = aOffset;
    plotScale = aScale;
    m_IUsPerDecimil = aIusPerDecimil;
    iuPerDeviceUnit = 1.0 / aIusPerDecimil;
    /* Compute the paper size in IUs */
    paperSize = pageInfo.GetSizeMils();
@@ -818,7 +819,7 @@ void PS_PLOTTER::Text( const wxPoint& aPos,
    SetColor( aColor );

    // Draw the native postscript text (if requested)
    if( psTextMode == PSTEXTMODE_NATIVE )
    if( m_textMode == PLOTTEXTMODE_NATIVE )
    {
        const char *fontname = aItalic ? (aBold ? "/KicadFont-BoldOblique"
                : "/KicadFont-Oblique")
@@ -862,7 +863,7 @@ void PS_PLOTTER::Text( const wxPoint& aPos,
    }

    // Draw the hidden postscript text (if requested)
    if( psTextMode == PSTEXTMODE_PHANTOM )
    if( m_textMode == PLOTTEXTMODE_PHANTOM )
    {
        fputsPostscriptString( outputFile, aText );
	DPOINT pos_dev = userToDeviceCoordinates( aPos );
@@ -871,7 +872,7 @@ void PS_PLOTTER::Text( const wxPoint& aPos,
    }

    // Draw the stroked text (if requested)
    if( psTextMode != PSTEXTMODE_NATIVE )
    if( m_textMode != PLOTTEXTMODE_NATIVE )
    {
        PLOTTER::Text( aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify,
                aWidth, aItalic, aBold );
Loading