← Back to team overview

kicad-developers team mailing list archive

Plotting/exporting in nanometres, take 2

 

I looked in depth in the affected code. Some refactoring, too.

What's changed:

- Public functions with CamelCase names (I liked more the standard_library
  ones, but we just need to decide once);

- The dummy PlotImage (drawing only a rectangle) was moved to the base since
  everyone except the Postscript engine uses the same implementation;

- The userToDevice stuff uses return by value;

- Comment formatting changed, most duplicate comment removed and put in the
  header;

- Used the DEG2RAD / RAD2DEG macros instead of explicitly computing 180.0/M_PI
  and so on

- Completely reworked the marker code (I hit the 13 symbol limit more than one
  time...); Now it's bitmask based and there are 58 symbols defined (and a
  class constant to define this limit);

- To discuss: something a construction like this was used in the routines:

    static std::vector< wxPoint > corner_list;                                             
    corner_list.clear();

  I suppose that would be to avoid reconstructing a vector at each call?
  However, the clear() simply junk the memory and forces reallocation so I
  don't see a gain in doing this... if it was a fixed vector and the elements
  were simply reassigned it could be an idea; for now I simply removed the
  static and the clear call (i.e. a fresh vector for each call);

- Tried to give a better name to some scaling factor (for example in the
  worksheet plotting code I renamed conv_unit to iusPerMil);

There still the plot width adjustment which I don't like... OTOH I've seen the
polyline code used for the 'filled circle' in the DXF engine: I think its a
clever solution. Wide tracks could be generated with the sketched oval code...

The issue is that DXF has no under/over relationship between primitives (and
neither between layers; a DXF layer doesn't work like a layer in gimp or
photoshop). In the newer acad this was fixed with scripts and/or commands which
change the internal display list (handle renumbering maybe? the newer DXF have
a DRAWORDER command and the SORTENTSTABLE and it's specified that the entities
are drawn in handle order otherwise) but AFAIK there is no way in a 'classic'
DXF (i.e. R13 or R14) to say 'this entity has to go over that one'.

Another thing is that seems that nothing else but acad handles polyline width :(

I also toyed with text export as DXF entities with mixed results: importing
into acad gives good results (probably because I'm using a very similar ISO
font), qcad/librecad instead get the alignment wrong (maybe is a qcad issue,
and it uses another font, anyway). If someone is interested I can finish this
(it would be an option for the DXF plotter, like "export text as text
entities"). Putting references/fields on other layers would be probably a lot
more useful. Just tell me what you think about it.

-- 
Lorenzo Marcantonio
Logos Srl
=== modified file 'common/class_bitmap_base.cpp'
--- common/class_bitmap_base.cpp	2012-04-19 06:55:45 +0000
+++ common/class_bitmap_base.cpp	2012-04-30 09:18:58 +0000
@@ -251,18 +251,18 @@
 }
 
 
-void BITMAP_BASE::PlotImage( PLOTTER* aPlotter,
-                             wxPoint  aPos,
-                             int      aDefaultColor,
-                             int      aDefaultPensize )
+void BITMAP_BASE::PlotImage( PLOTTER*       aPlotter,
+                             const wxPoint& aPos,
+                             EDA_COLOR_T    aDefaultColor,
+                             int            aDefaultPensize )
 {
     if( m_image == NULL )
         return;
 
     // These 2 lines are useful only fot plotters that cannot plot a bitmap
     // and plot arectangle instead of.
-    aPlotter->set_color( aDefaultColor );
-    aPlotter->set_current_line_width( aDefaultPensize );
+    aPlotter->SetColor( aDefaultColor );
+    aPlotter->SetCurrentLineWidth( aDefaultPensize );
 
     aPlotter->PlotImage( *m_image, aPos, GetScalingFactor() );
 }

=== modified file 'common/class_plotter.cpp'
--- common/class_plotter.cpp	2012-04-19 06:55:45 +0000
+++ common/class_plotter.cpp	2012-04-30 09:18:58 +0000
@@ -1,13 +1,17 @@
-/******************************************
-* class_plotter.cpp
-* the class PLOTTER handle basic functions to plot schematic and boards
-* with different plot formats.
-* currently formats are:*
-* HPGL
-* POSTSCRIPT
-* GERBER
-* DXF
-******************************************/
+/**
+ * @file class_plotter.cpp
+ * @brief KiCad: Base of all the plot routines
+ * the class PLOTTER handle basic functions to plot schematic and boards
+ * with different plot formats.
+ *
+ * There are currently engines for:
+ * HPGL
+ * POSTSCRIPT
+ * GERBER
+ * DXF
+ * an SVG 'plot' is also provided along with the 'print' function by wx, but 
+ * is not handled here.
+ */
 
 #include <fctsys.h>
 
@@ -21,112 +25,152 @@
 #include <class_base_screen.h>
 #include <drawtxt.h>
 
-PLOTTER::PLOTTER( PlotFormat aPlotType )
+PLOTTER::PLOTTER( )
 {
-    m_PlotType = aPlotType;
-    plot_scale = 1;
-    default_pen_width = 0;
-    current_pen_width = -1;     /* To-be-set marker */
-    pen_state = 'Z';            /* End-of-path idle */
-    plotMirror = 0;    /* Mirror flag */
-    output_file   = 0;
-    color_mode    = false;      /* Start as a BW plot */
-    negative_mode = false;
+    plotScale = 1;
+    defaultPenWidth = 0;
+    currentPenWidth = -1;       // To-be-set marker 
+    penState = 'Z';             // End-of-path idle
+    plotMirror = 0;    		// Mirror flag 
+    outputFile = 0;
+    colorMode = false;          // Starts as a BW plot 
+    negativeMode = false;
 }
 
 
-/* Modifies coordinates pos.x and pos.y trace according to the orientation,
- * scale factor, and offsets trace
+/**
+ * Modifies coordinates according to the orientation,
+ * scale factor, and offsets trace. Also convert from a wxPoint to DPOINT,
+ * since some output engines needs floating point coordinates.
  */
-void PLOTTER::user_to_device_coordinates( wxPoint& pos )
+DPOINT PLOTTER::userToDeviceCoordinates( const wxPoint& pos )
 {
-    pos.x = (int) ( (pos.x - plot_offset.x) * plot_scale * device_scale );
+    double x = (pos.x - plotOffset.x) * plotScale * iuPerDeviceUnit;
+    double y;
 
     if( plotMirror )
-        pos.y = (int) ( ( pos.y - plot_offset.y ) * plot_scale * device_scale );
+        y = ( pos.y - plotOffset.y ) * plotScale * iuPerDeviceUnit ;
     else
-        pos.y = (int) ( ( paper_size.y - ( pos.y - plot_offset.y )
-                          * plot_scale ) * device_scale );
-}
-
-
-/* Generic arc rendered as a polyline */
-void PLOTTER::arc( wxPoint centre, int StAngle, int EndAngle, int radius,
+        y = ( paperSize.y - ( pos.y - plotOffset.y )
+	      * plotScale ) * iuPerDeviceUnit ;
+    return DPOINT( x, y );		
+}
+
+/**
+ * Modifies size according to the plotter scale factors
+ * (wxSize version, returns a DPOINT)
+ */
+DPOINT PLOTTER::userToDeviceSize( const wxSize& size )
+{
+    return DPOINT( size.x * plotScale * iuPerDeviceUnit,
+	           size.y * plotScale * iuPerDeviceUnit );
+}
+
+/**
+ * Modifies size according to the plotter scale factors
+ * (simple double version)
+ */
+double PLOTTER::userToDeviceSize( double size )
+{
+    return size * plotScale * iuPerDeviceUnit;
+}
+
+
+/** 
+ * Generic fallback: arc rendered as a polyline 
+ */
+void PLOTTER::Arc( const wxPoint& centre, int StAngle, int EndAngle, int radius,
                    FILL_T fill, int width )
 {
     wxPoint   start, end;
-    const int delta = 50;   /* increment (in 0.1 degrees) to draw circles */
+    const int delta = 50;   // increment (in 0.1 degrees) to draw circles 
     double    alpha;
 
     if( StAngle > EndAngle )
         EXCHG( StAngle, EndAngle );
 
-    set_current_line_width( width );
+    SetCurrentLineWidth( width );
     /* Please NOTE the different sign due to Y-axis flip */
-    alpha   = StAngle / 1800.0 * M_PI;
+    alpha   = DEG2RAD( StAngle / 10.0 );
     start.x = centre.x + (int) ( radius * cos( -alpha ) );
     start.y = centre.y + (int) ( radius * sin( -alpha ) );
-    move_to( start );
+    MoveTo( start );
     for( int ii = StAngle + delta; ii < EndAngle; ii += delta )
     {
-        alpha = ii / 1800.0 * M_PI;
+        alpha = DEG2RAD( ii / 10.0 );
         end.x = centre.x + (int) ( radius * cos( -alpha ) );
         end.y = centre.y + (int) ( radius * sin( -alpha ) );
-        line_to( end );
+        LineTo( end );
     }
 
-    alpha = EndAngle / 1800.0 * M_PI;
+    alpha = DEG2RAD( EndAngle / 10.0 );
     end.x = centre.x + (int) ( radius * cos( -alpha ) );
     end.y = centre.y + (int) ( radius * sin( -alpha ) );
-    finish_to( end );
-}
-
-
-/* Modifies size size.x and size.y trace according to the scale factor. */
-void PLOTTER::user_to_device_size( wxSize& size )
-{
-    size.x = (int) ( size.x * plot_scale * device_scale );
-    size.y = (int) ( size.y * plot_scale * device_scale );
-}
-
-
-double PLOTTER::user_to_device_size( double size )
-{
-    return size * plot_scale * device_scale;
-}
-
-
-void PLOTTER::center_square( const wxPoint& position, int diametre, FILL_T fill )
-{
-    int radius     = KiROUND( diametre / 2.8284 );
-    static std::vector< wxPoint > corner_list;
-    corner_list.clear();
+    FinishTo( end );
+}
+
+/**
+ * Fallback: if it doesn't handle bitmaps, we plot a rectangle
+ */
+void PLOTTER::PlotImage(const wxImage & aImage, const wxPoint& aPos, 
+                        double aScaleFactor )
+{
+    wxSize size( aImage.GetWidth() * aScaleFactor,
+	         aImage.GetHeight() * aScaleFactor );
+
+    wxPoint start = aPos;
+    start.x -= size.x / 2;
+    start.y -= size.y / 2;
+
+    wxPoint end = start;
+    end.x += size.x;
+    end.y += size.y;
+
+    Rect( start, end, NO_FILL );
+}
+
+
+/**
+ * Plot a square centered on the position. Building block for markers
+ */
+void PLOTTER::markerSquare( const wxPoint& position, int radius )
+{
+    double r = KiROUND( radius / 1.4142 );
+    std::vector< wxPoint > corner_list;
     wxPoint corner;
-    corner.x = position.x + radius;
-    corner.y = position.y + radius;
-    corner_list.push_back( corner );
-    corner.x = position.x + radius;
-    corner.y = position.y - radius;
-    corner_list.push_back( corner );
-    corner.x = position.x - radius;
-    corner.y = position.y - radius;
-    corner_list.push_back( corner );
-    corner.x = position.x - radius;
-    corner.y = position.y + radius;
-    corner_list.push_back( corner );
-    corner.x = position.x + radius;
-    corner.y = position.y + radius;
-    corner_list.push_back( corner );
-
-    PlotPoly( corner_list, fill );
-}
-
-
-void PLOTTER::center_lozenge( const wxPoint& position, int diametre, FILL_T fill )
-{
-    int radius     = diametre / 2;
-    static std::vector< wxPoint > corner_list;
-    corner_list.clear();
+    corner.x = position.x + r;
+    corner.y = position.y + r;
+    corner_list.push_back( corner );
+    corner.x = position.x + r;
+    corner.y = position.y - r;
+    corner_list.push_back( corner );
+    corner.x = position.x - r;
+    corner.y = position.y - r;
+    corner_list.push_back( corner );
+    corner.x = position.x - r;
+    corner.y = position.y + r;
+    corner_list.push_back( corner );
+    corner.x = position.x + r;
+    corner.y = position.y + r;
+    corner_list.push_back( corner );
+
+    PlotPoly( corner_list, NO_FILL );
+}
+
+/**
+ * Plot a circle centered on the position. Building block for markers
+ */
+void PLOTTER::markerCircle( const wxPoint& position, int radius )
+{
+    Circle( position, radius * 2, NO_FILL );
+}
+
+/**
+ * Plot a lozenge centered on the position. Building block for markers
+ */
+void PLOTTER::markerLozenge( const wxPoint& position, int radius )
+{
+    std::vector< wxPoint > corner_list;
     wxPoint corner;
     corner.x = position.x;
     corner.y = position.y + radius;
@@ -144,115 +188,163 @@
     corner.y = position.y + radius;
     corner_list.push_back( corner );
 
-    PlotPoly( corner_list, fill );
-}
-
-
-/* Draw a pattern shape number aShapeId, to coord x0, y0.
+    PlotPoly( corner_list, NO_FILL );
+}
+
+/**
+ * Plot a - bar centered on the position. Building block for markers
+ */
+void PLOTTER::markerHBar( const wxPoint& pos, int radius )
+{
+    MoveTo( wxPoint( pos.x - radius, pos.y ) );
+    FinishTo( wxPoint( pos.x + radius, pos.y ) );
+}
+
+/**
+ * Plot a / bar centered on the position. Building block for markers
+ */
+void PLOTTER::markerSlash( const wxPoint& pos, int radius )
+{
+    MoveTo( wxPoint( pos.x - radius, pos.y - radius ) );
+    FinishTo( wxPoint( pos.x + radius, pos.y + radius ) );
+}
+
+/**
+ * Plot a \ bar centered on the position. Building block for markers
+ */
+void PLOTTER::markerBackSlash( const wxPoint& pos, int radius )
+{
+    MoveTo( wxPoint( pos.x + radius, pos.y - radius ) );
+    FinishTo( wxPoint( pos.x - radius, pos.y + radius ) );
+}
+
+/**
+ * Plot a | bar centered on the position. Building block for markers
+ */
+void PLOTTER::markerVBar( const wxPoint& pos, int radius )
+{
+    MoveTo( wxPoint( pos.x, pos.y - radius ) );
+    FinishTo( wxPoint( pos.x, pos.y + radius ) );
+}
+
+/**
+ * Draw a pattern shape number aShapeId, to coord x0, y0.
  * x0, y0 = coordinates tables
  * Diameter diameter = (coord table) hole
  * AShapeId = index (used to generate forms characters)
  */
-void PLOTTER::marker( const wxPoint& position, int diametre, int aShapeId )
+void PLOTTER::Marker( const wxPoint& position, int diametre, unsigned aShapeId )
 {
     int radius = diametre / 2;
-
-    int x0, y0;
-
-    x0 = position.x; y0 = position.y;
-
-    switch( aShapeId )
-    {
-    case 0:     /* vias : X shape */
-        move_to( wxPoint( x0 - radius, y0 - radius ) );
-        line_to( wxPoint( x0 + radius, y0 + radius ) );
-        move_to( wxPoint( x0 + radius, y0 - radius ) );
-        finish_to( wxPoint( x0 - radius, y0 + radius ) );
-        break;
-
-    case 1:     /* Circle */
-        circle( position, diametre, NO_FILL );
-        break;
-
-    case 2:     /* + shape */
-        move_to( wxPoint( x0, y0 - radius ) );
-        line_to( wxPoint( x0, y0 + radius ) );
-        move_to( wxPoint( x0 + radius, y0 ) );
-        finish_to( wxPoint( x0 - radius, y0 ) );
-        break;
-
-    case 3:     /* X shape in circle */
-        circle( position, diametre, NO_FILL );
-        move_to( wxPoint( x0 - radius, y0 - radius ) );
-        line_to( wxPoint( x0 + radius, y0 + radius ) );
-        move_to( wxPoint( x0 + radius, y0 - radius ) );
-        finish_to( wxPoint( x0 - radius, y0 + radius ) );
-        break;
-
-    case 4:     /* circle with bar - shape */
-        circle( position, diametre, NO_FILL );
-        move_to( wxPoint( x0 - radius, y0 ) );
-        finish_to( wxPoint( x0 + radius, y0 ) );
-        break;
-
-    case 5:     /* circle with bar | shape */
-        circle( position, diametre, NO_FILL );
-        move_to( wxPoint( x0, y0 - radius ) );
-        finish_to( wxPoint( x0, y0 + radius ) );
-        break;
-
-    case 6:     /* square */
-        center_square( position, diametre, NO_FILL );
-        break;
-
-    case 7:     /* diamond */
-        center_lozenge( position, diametre, NO_FILL );
-        break;
-
-    case 8:     /* square with an X*/
-        center_square( position, diametre, NO_FILL );
-        move_to( wxPoint( x0 - radius, y0 - radius ) );
-        line_to( wxPoint( x0 + radius, y0 + radius ) );
-        move_to( wxPoint( x0 + radius, y0 - radius ) );
-        finish_to( wxPoint( x0 - radius, y0 + radius ) );
-        break;
-
-    case 9:     /* diamond with a +*/
-        center_lozenge( position, diametre, NO_FILL );
-        move_to( wxPoint( x0, y0 - radius ) );
-        line_to( wxPoint( x0, y0 + radius ) );
-        move_to( wxPoint( x0 + radius, y0 ) );
-        finish_to( wxPoint( x0 - radius, y0 ) );
-        break;
-
-    case 10:     /* square with a '/' */
-        center_square( position, diametre, NO_FILL );
-        move_to( wxPoint( x0 - radius, y0 - radius ) );
-        finish_to( wxPoint( x0 + radius, y0 + radius ) );
-        break;
-
-    case 11:     /* square with a |*/
-        center_lozenge( position, diametre, NO_FILL );
-        move_to( wxPoint( x0, y0 - radius ) );
-        finish_to( wxPoint( x0, y0 + radius ) );
-        break;
-
-    case 12:     /* square with a -*/
-        center_lozenge( position, diametre, NO_FILL );
-        move_to( wxPoint( x0 - radius, y0 ) );
-        finish_to( wxPoint( x0 + radius, y0 ) );
-        break;
-
-    default:
-        circle( position, diametre, NO_FILL );
-        break;
+    /* Marker are composed by a series of 'parts' superimposed; not every 
+       combination make sense, obviously. Since they are used in order I
+       tried to keep the uglier/more complex constructions at the end.
+       Also I avoided the |/ |\ -/ -\ construction because they're *very*
+       ugly... if needed they could be added anyway... I'd like to see
+       a board with more than 58 drilling/slotting tools!
+       If Visual C++ supported the 0b literals they would be optimally
+       and easily encoded as an integer array. We have to do with octal */
+    static const unsigned char marker_patterns[MARKER_COUNT] = {
+	// Bit order:  O Square Lozenge - | \ / 
+	// First choice: simple shapes
+	0003,  // X
+	0100,  // O
+	0014,  // +
+	0040,  // Sq
+	0020,  // Lz
+	// Two simple shapes
+	0103,  // X O
+	0017,  // X +
+	0043,  // X Sq
+	0023,  // X Lz
+	0114,  // O +
+	0140,  // O Sq
+	0120,  // O Lz
+	0054,  // + Sq
+	0034,  // + Lz
+	0060,  // Sq Lz
+	// Three simple shapes
+	0117,  // X O +
+	0143,  // X O Sq
+	0123,  // X O Lz
+	0057,  // X + Sq
+	0037,  // X + Lz
+	0063,  // X Sq Lz
+	0154,  // O + Sq
+	0134,  // O + Lz
+	0074,  // + Sq Lz
+	// Four simple shapes
+	0174,  // O Sq Lz +
+	0163,  // X O Sq Lz
+	0157,  // X O Sq +
+	0137,  // X O Lz +
+	0077,  // X Sq Lz +
+	// This draws *everything *
+	0177,  // X O Sq Lz +
+	// Here we use the single bars... so the cross is forbidden
+	0110,  // O -
+	0104,  // O |
+	0101,  // O /
+	0050,  // Sq -
+	0044,  // Sq |
+	0041,  // Sq /
+	0030,  // Lz -
+	0024,  // Lz |
+	0021,  // Lz /
+	0150,  // O Sq -
+	0144,  // O Sq |
+	0141,  // O Sq /
+	0130,  // O Lz -
+	0124,  // O Lz |
+	0121,  // O Lz /
+	0070,  // Sq Lz -
+	0064,  // Sq Lz |
+	0061,  // Sq Lz /
+	0170,  // O Sq Lz -
+	0164,  // O Sq Lz |
+	0161,  // O Sq Lz /
+	// Last resort: the backlash component (easy to confound)
+	0102,  // \ O
+	0042,  // \ Sq
+	0022,  // \ Lz
+	0142,  // \ O Sq
+	0122,  // \ O Lz
+	0062,  // \ Sq Lz
+	0162   // \ O Sq Lz
+    };
+    if( aShapeId >= MARKER_COUNT )
+    {
+	// Fallback shape
+	markerCircle( position, radius );
+    } 
+    else 
+    {
+	// Decode the pattern and draw the corresponding parts
+	unsigned char pat = marker_patterns[aShapeId];
+	if( pat & 0001 ) 
+	    markerSlash( position, radius );   
+	if( pat & 0002 ) 
+	    markerBackSlash( position, radius );   
+	if( pat & 0004 ) 
+	    markerVBar( position, radius );   
+	if( pat & 0010 ) 
+	    markerHBar( position, radius );   
+	if( pat & 0020 ) 
+	    markerLozenge( position, radius );   
+	if( pat & 0040 ) 
+	    markerSquare( position, radius );   
+	if( pat & 0100 ) 
+	    markerCircle( position, radius );   
     }
+
 }
 
 
-/* Convert a thick segment and plot it as an oval */
-void PLOTTER::segment_as_oval( wxPoint start, wxPoint end, int width,
-                               EDA_DRAW_MODE_T tracemode )
+/**
+ * Convert a thick segment and plot it as an oval 
+ */
+void PLOTTER::segmentAsOval( const wxPoint& start, const wxPoint& end, int width,
+                             EDA_DRAW_MODE_T tracemode )
 {
     wxPoint center( (start.x + end.x) / 2, (start.y + end.y) / 2 );
     wxSize  size( end.x - start.x, end.y - start.y );
@@ -263,22 +355,22 @@
     else if( size.x == 0 )
         orient = 900;
     else
-        orient = -(int) ( atan2( (double) size.y,
-                                 (double) size.x ) * 1800.0 / M_PI );
+        orient = -(int) ( RAD2DEG( atan2( size.y, size.x ) ) * 10.0 );
     size.x = (int) sqrt( ( (double) size.x * size.x )
                        + ( (double) size.y * size.y ) ) + width;
     size.y = width;
 
-    flash_pad_oval( center, size, orient, tracemode );
+    FlashPadOval( center, size, orient, tracemode );
 }
 
 
-void PLOTTER::sketch_oval( wxPoint pos, wxSize size, int orient,
-                           int width )
+void PLOTTER::sketchOval( const wxPoint& pos, const wxSize& aSize, int orient,
+                          int width )
 {
-    set_current_line_width( width );
-    width = current_pen_width;
+    SetCurrentLineWidth( width );
+    width = currentPenWidth;
     int radius, deltaxy, cx, cy;
+    wxSize size( aSize );
 
     if( size.x > size.y )
     {
@@ -293,31 +385,31 @@
     cx = -radius;
     cy = -deltaxy / 2;
     RotatePoint( &cx, &cy, orient );
-    move_to( wxPoint( cx + pos.x, cy + pos.y ) );
+    MoveTo( wxPoint( cx + pos.x, cy + pos.y ) );
     cx = -radius;
     cy = deltaxy / 2;
     RotatePoint( &cx, &cy, orient );
-    finish_to( wxPoint( cx + pos.x, cy + pos.y ) );
+    FinishTo( wxPoint( cx + pos.x, cy + pos.y ) );
 
     cx = radius;
     cy = -deltaxy / 2;
     RotatePoint( &cx, &cy, orient );
-    move_to( wxPoint( cx + pos.x, cy + pos.y ) );
+    MoveTo( wxPoint( cx + pos.x, cy + pos.y ) );
     cx = radius;
     cy = deltaxy / 2;
     RotatePoint( &cx, &cy, orient );
-    finish_to( wxPoint( cx + pos.x, cy + pos.y ) );
+    FinishTo( wxPoint( cx + pos.x, cy + pos.y ) );
 
     cx = 0;
     cy = deltaxy / 2;
     RotatePoint( &cx, &cy, orient );
-    arc( wxPoint( cx + pos.x, cy + pos.y ),
+    Arc( wxPoint( cx + pos.x, cy + pos.y ),
          orient + 1800, orient + 3600,
          radius, NO_FILL );
     cx = 0;
     cy = -deltaxy / 2;
     RotatePoint( &cx, &cy, orient );
-    arc( wxPoint( cx + pos.x, cy + pos.y ),
+    Arc( wxPoint( cx + pos.x, cy + pos.y ),
          orient, orient + 1800,
          radius, NO_FILL );
 }
@@ -325,98 +417,98 @@
 
 /* Plot 1 segment like a track segment
  */
-void PLOTTER::thick_segment( wxPoint start, wxPoint end, int width,
-                             EDA_DRAW_MODE_T tracemode )
-{
-    switch( tracemode )
-    {
-    case FILLED:
-    case LINE:
-        set_current_line_width( tracemode==FILLED ? width : -1 );
-        move_to( start );
-        finish_to( end );
-        break;
-
-    case SKETCH:
-        set_current_line_width( -1 );
-        segment_as_oval( start, end, width, tracemode );
-        break;
-    }
-}
-
-
-void PLOTTER::thick_arc( wxPoint centre, int StAngle, int EndAngle, int radius,
-                         int width, EDA_DRAW_MODE_T tracemode )
-{
-    switch( tracemode )
-    {
-    case LINE:
-        set_current_line_width( -1 );
-        arc( centre, StAngle, EndAngle, radius, NO_FILL, -1 );
-        break;
-
-    case FILLED:
-        arc( centre, StAngle, EndAngle, radius, NO_FILL, width );
-        break;
-
-    case SKETCH:
-        set_current_line_width( -1 );
-        arc( centre, StAngle, EndAngle,
-             radius - ( width - current_pen_width ) / 2, NO_FILL, -1 );
-        arc( centre, StAngle, EndAngle,
-             radius + ( width - current_pen_width ) / 2, NO_FILL, -1 );
-        break;
-    }
-}
-
-
-void PLOTTER::thick_rect( wxPoint p1, wxPoint p2, int width,
-                          EDA_DRAW_MODE_T tracemode )
-{
-    switch( tracemode )
-    {
-    case LINE:
-        rect( p1, p2, NO_FILL, -1 );
-        break;
-
-    case FILLED:
-        rect( p1, p2, NO_FILL, width );
-        break;
-
-    case SKETCH:
-        set_current_line_width( -1 );
-        p1.x -= (width - current_pen_width) / 2;
-        p1.y -= (width - current_pen_width) / 2;
-        p2.x += (width - current_pen_width) / 2;
-        p2.y += (width - current_pen_width) / 2;
-        rect( p1, p2, NO_FILL, -1 );
-        p1.x += (width - current_pen_width);
-        p1.y += (width - current_pen_width);
-        p2.x -= (width - current_pen_width);
-        p2.y -= (width - current_pen_width);
-        rect( p1, p2, NO_FILL, -1 );
-        break;
-    }
-}
-
-
-void PLOTTER::thick_circle( wxPoint pos, int diametre, int width,
+void PLOTTER::ThickSegment( const wxPoint& start, const wxPoint& end, int width,
                             EDA_DRAW_MODE_T tracemode )
 {
     switch( tracemode )
     {
-    case LINE:
-        circle( pos, diametre, NO_FILL, -1 );
-        break;
-
-    case FILLED:
-        circle( pos, diametre, NO_FILL, width );
-        break;
-
-    case SKETCH:
-        set_current_line_width( -1 );
-        circle( pos, diametre - width + current_pen_width, NO_FILL, -1 );
-        circle( pos, diametre + width - current_pen_width, NO_FILL, -1 );
+    case FILLED:
+    case LINE:
+        SetCurrentLineWidth( tracemode==FILLED ? width : -1 );
+        MoveTo( start );
+        FinishTo( end );
+        break;
+
+    case SKETCH:
+        SetCurrentLineWidth( -1 );
+        segmentAsOval( start, end, width, tracemode );
+        break;
+    }
+}
+
+
+void PLOTTER::ThickArc( const wxPoint& centre, int StAngle, int EndAngle, int radius,
+                        int width, EDA_DRAW_MODE_T tracemode )
+{
+    switch( tracemode )
+    {
+    case LINE:
+        SetCurrentLineWidth( -1 );
+        Arc( centre, StAngle, EndAngle, radius, NO_FILL, -1 );
+        break;
+
+    case FILLED:
+        Arc( centre, StAngle, EndAngle, radius, NO_FILL, width );
+        break;
+
+    case SKETCH:
+        SetCurrentLineWidth( -1 );
+        Arc( centre, StAngle, EndAngle,
+             radius - ( width - currentPenWidth ) / 2, NO_FILL, -1 );
+        Arc( centre, StAngle, EndAngle,
+             radius + ( width - currentPenWidth ) / 2, NO_FILL, -1 );
+        break;
+    }
+}
+
+
+void PLOTTER::ThickRect( const wxPoint& p1, const wxPoint& p2, int width,
+                         EDA_DRAW_MODE_T tracemode )
+{
+    switch( tracemode )
+    {
+    case LINE:
+        Rect( p1, p2, NO_FILL, -1 );
+        break;
+
+    case FILLED:
+        Rect( p1, p2, NO_FILL, width );
+        break;
+
+    case SKETCH:
+        SetCurrentLineWidth( -1 );
+        wxPoint offsetp1( p1.x - (width - currentPenWidth) / 2,
+                          p1.y - (width - currentPenWidth) / 2 );
+        wxPoint offsetp2( p2.x + (width - currentPenWidth) / 2,
+			  p2.y + (width - currentPenWidth) / 2 );
+        Rect( offsetp1, offsetp2, NO_FILL, -1 );
+        offsetp1.x += (width - currentPenWidth);
+        offsetp1.y += (width - currentPenWidth);
+        offsetp2.x -= (width - currentPenWidth);
+        offsetp2.y -= (width - currentPenWidth);
+        Rect( offsetp1, offsetp2, NO_FILL, -1 );
+        break;
+    }
+}
+
+
+void PLOTTER::ThickCircle( const wxPoint& pos, int diametre, int width,
+                           EDA_DRAW_MODE_T tracemode )
+{
+    switch( tracemode )
+    {
+    case LINE:
+        Circle( pos, diametre, NO_FILL, -1 );
+        break;
+
+    case FILLED:
+        Circle( pos, diametre, NO_FILL, width );
+        break;
+
+    case SKETCH:
+        SetCurrentLineWidth( -1 );
+        Circle( pos, diametre - width + currentPenWidth, NO_FILL, -1 );
+        Circle( pos, diametre + width - currentPenWidth, NO_FILL, -1 );
         break;
     }
 }
@@ -424,10 +516,7 @@
 
 void PLOTTER::SetPageSettings( const PAGE_INFO& aPageSettings )
 {
-    wxASSERT( !output_file );
+    wxASSERT( !outputFile );
     pageInfo = aPageSettings;
-
-    // PAGE_INFO is in mils, plotter works with deci-mils
-    paper_size = pageInfo.GetSizeMils() * 10;
 }
 

=== modified file 'common/common_plotDXF_functions.cpp'
--- common/common_plotDXF_functions.cpp	2012-04-19 06:55:45 +0000
+++ common/common_plotDXF_functions.cpp	2012-04-30 09:18:58 +0000
@@ -13,251 +13,235 @@
 #include <kicad_string.h>
 
 
-/* Set the plot offset for the current plotting
+/**
+ * Set the scale/position for the DXF plot
+ * The DXF engine doesn't support line widths and mirroring. The output
+ * coordinate system is in the first quadrant (in mm)
  */
-void DXF_PLOTTER::set_viewport( wxPoint aOffset, double aScale, bool aMirror )
+void DXF_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
+			       double aScale, bool aMirror )
 {
-    wxASSERT( !output_file );
-    plot_offset  = aOffset;
-    plot_scale   = aScale;
-    device_scale = 1;
-    set_default_line_width( 0 );    /* No line width on DXF */
-    plotMirror = false;             /* No mirroring on DXF */
-    current_color = BLACK;
+    wxASSERT( !outputFile );
+    plotOffset  = aOffset;
+    plotScale   = aScale;
+    // XXX Need to think about this: what is the 'native' unit used for DXF? 
+    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;
+    SetDefaultLineWidth( 0 );    // No line width on DXF
+    plotMirror = false;             // No mirroring on DXF 
+    currentColor = BLACK;
 }
 
-
-bool DXF_PLOTTER::start_plot( FILE* fout )
+/**
+ * Opens the DXF plot with a skeleton header
+ */
+bool DXF_PLOTTER::StartPlot( FILE* fout )
 {
-    wxASSERT( !output_file );
-    output_file = fout;
-    /* DXF HEADER - Boilerplate */
-    fputs( "0\nSECTION\n2\nHEADER\n9\n$ANGBASE\n50\n0.0\n9\n$ANGDIR\n70\n0\n0\nENDSEC\n0\nSECTION\n2\nTABLES\n0\nTABLE\n2\nLTYPE\n70\n1\n0\nLTYPE\n2\nCONTINUOUS\n70\n0\n3\nSolid line\n72\n65\n73\n0\n40\n0.0\n0\nENDTAB\n",
-           output_file );
-    /* Layer table - one layer per color */
-    fprintf( output_file, "0\nTABLE\n2\nLAYER\n70\n%d\n", NBCOLOR );
+    wxASSERT( !outputFile );
+    outputFile = fout;
+
+    // DXF HEADER - Boilerplate 
+    fputs( "0\nSECTION\n2\nHEADER\n9\n$ANGBASE\n50\n0.0\n9\n$ANGDIR\n70\n0\n0\nENDSEC\n"
+           "0\nSECTION\n2\nTABLES\n0\nTABLE\n2\nLTYPE\n70\n1\n0\nLTYPE\n2\nCONTINUOUS\n"
+	   "70\n0\n3\nSolid line\n72\n65\n73\n0\n40\n0.0\n0\nENDTAB\n",
+           outputFile );
+
+    // Layer table - one layer per color 
+    fprintf( outputFile, "0\nTABLE\n2\nLAYER\n70\n%d\n", NBCOLOR );
     for( int i = 0; i<NBCOLOR; i++ )
     {
         wxString cname = ColorRefs[i].m_Name;
-        fprintf( output_file, "0\nLAYER\n2\n%s\n70\n0\n62\n%d\n6\nCONTINUOUS\n",
+        fprintf( outputFile, "0\nLAYER\n2\n%s\n70\n0\n62\n%d\n6\nCONTINUOUS\n",
                  TO_UTF8( cname ), i + 1 );
     }
 
-    /* End of layer table, begin entities */
-    fputs( "0\nENDTAB\n0\nENDSEC\n0\nSECTION\n2\nENTITIES\n", output_file );
+    // End of layer table, begin entities
+    fputs( "0\nENDTAB\n0\nENDSEC\n0\nSECTION\n2\nENTITIES\n", outputFile );
 
     return true;
 }
 
 
-bool DXF_PLOTTER::end_plot()
+bool DXF_PLOTTER::EndPlot()
 {
-    wxASSERT( output_file );
-    /* DXF FOOTER */
-    fputs( "0\nENDSEC\n0\nEOF\n", output_file );
-    fclose( output_file );
-    output_file = NULL;
+    wxASSERT( outputFile );
+    // DXF FOOTER 
+    fputs( "0\nENDSEC\n0\nEOF\n", outputFile );
+    fclose( outputFile );
+    outputFile = NULL;
 
     return true;
 }
 
 
-/*
- * color = color index in ColorRefs[]
+/**
+ * The DXF exporter handles 'colors' as layers...
  */
-void DXF_PLOTTER::set_color( int color )
+void DXF_PLOTTER::SetColor( EDA_COLOR_T color )
 {
-    wxASSERT( output_file );
-    if( ( color >= 0 && color_mode )
+    wxASSERT( outputFile );
+    if( ( color >= 0 && colorMode )
        || ( color == BLACK )
        || ( color == WHITE ) )
     {
-        current_color = color;
+        currentColor = color;
     }
 }
 
-
-void DXF_PLOTTER::rect( wxPoint p1, wxPoint p2, FILL_T fill, int width )
+/**
+ * DXF rectangle: fill not supported
+ */
+void DXF_PLOTTER::Rect( const wxPoint& p1, const wxPoint& p2, FILL_T fill, int width )
 {
-    wxASSERT( output_file );
-    move_to( p1 );
-    line_to( wxPoint( p1.x, p2.y ) );
-    line_to( wxPoint( p2.x, p2.y ) );
-    line_to( wxPoint( p2.x, p1.y ) );
-    finish_to( wxPoint( p1.x, p1.y ) );
+    wxASSERT( outputFile );
+    MoveTo( p1 );
+    LineTo( wxPoint( p1.x, p2.y ) );
+    LineTo( wxPoint( p2.x, p2.y ) );
+    LineTo( wxPoint( p2.x, p1.y ) );
+    FinishTo( wxPoint( p1.x, p1.y ) );
 }
 
 
-void DXF_PLOTTER::circle( wxPoint centre, int diameter, FILL_T fill, int width )
+/** 
+ * DXF circle: full functionality; it even does 'fills' drawing a 
+ * circle with a dual-arc polyline wide as the radius.
+ *
+ * I could use this trick to do other filled primitives
+ */
+void DXF_PLOTTER::Circle( const wxPoint& centre, int diameter, FILL_T fill, int width )
 {
-    wxASSERT( output_file );
-    double radius = user_to_device_size( diameter / 2 );
-    user_to_device_coordinates( centre );
+    wxASSERT( outputFile );
+    double radius = userToDeviceSize( diameter / 2 );
+    DPOINT centre_dev = userToDeviceCoordinates( centre );
     if( radius > 0 )
     {
-        wxString cname = ColorRefs[current_color].m_Name;
+        wxString cname = ColorRefs[currentColor].m_Name;
         if (!fill) {
-          fprintf( output_file, "0\nCIRCLE\n8\n%s\n10\n%d.0\n20\n%d.0\n40\n%g\n",
+          fprintf( outputFile, "0\nCIRCLE\n8\n%s\n10\n%g\n20\n%g\n40\n%g\n",
                   TO_UTF8( cname ),
-                  centre.x, centre.y, radius );
+                  centre_dev.x, centre_dev.y, radius );
         }
         if (fill == FILLED_SHAPE) {
-            int r = (int)(radius*0.5);
-            fprintf( output_file, "0\nPOLYLINE\n");
-            fprintf( output_file, "8\n%s\n66\n1\n70\n1\n", TO_UTF8( cname ));
-            fprintf( output_file, "40\n%g\n41\n%g\n", radius,radius);
-            fprintf( output_file, "0\nVERTEX\n8\n%s\n", TO_UTF8( cname ));
-            fprintf( output_file, "10\n%d.0\n 20\n%d.0\n42\n1.0\n", centre.x-r,centre.y);
-            fprintf( output_file, "0\nVERTEX\n8\n%s\n", TO_UTF8( cname ));
-            fprintf( output_file, "10\n%d.0\n 20\n%d.0\n42\n1.0\n", centre.x+r,centre.y);
-            fprintf( output_file, "0\nSEQEND\n");
-    }
+            double r = radius*0.5;
+            fprintf( outputFile, "0\nPOLYLINE\n");
+            fprintf( outputFile, "8\n%s\n66\n1\n70\n1\n", TO_UTF8( cname ));
+            fprintf( outputFile, "40\n%g\n41\n%g\n", radius, radius);
+            fprintf( outputFile, "0\nVERTEX\n8\n%s\n", TO_UTF8( cname ));
+            fprintf( outputFile, "10\n%g\n 20\n%g\n42\n1.0\n", 
+		     centre_dev.x-r, centre_dev.y );
+            fprintf( outputFile, "0\nVERTEX\n8\n%s\n", TO_UTF8( cname ));
+            fprintf( outputFile, "10\n%g\n 20\n%g\n42\n1.0\n", 
+	             centre_dev.x+r, centre_dev.y );
+            fprintf( outputFile, "0\nSEQEND\n");
+	}
      }
 }
 
 
-/* Draw a polygon (closed if filled) in DXF format
- * nb = number of coord (coord 1 = 2 elements: X and Y table)
- * aFill: if != 0 filled polygon
+/** 
+ * DXF polygon: doesn't fill it but at least it close the filled ones
  */
-void DXF_PLOTTER::PlotPoly( std::vector< wxPoint >& aCornerList, FILL_T aFill, int aWidth)
+void DXF_PLOTTER::PlotPoly( const std::vector< wxPoint >& aCornerList, 
+                            FILL_T aFill, int aWidth)
 {
     if( aCornerList.size() <= 1 )
         return;
 
-    move_to( aCornerList[0] );
+    MoveTo( aCornerList[0] );
     for( unsigned ii = 1; ii < aCornerList.size(); ii++ )
-        line_to( aCornerList[ii] );
+        LineTo( aCornerList[ii] );
 
-    /* Close polygon. */
+    // Close polygon if 'fill' requested
     if( aFill )
     {
         unsigned ii = aCornerList.size() - 1;
         if( aCornerList[ii] != aCornerList[0] )
-            line_to( aCornerList[0] );
+            LineTo( aCornerList[0] );
     }
-    pen_finish();
-}
-
-/*
- * Function PlotImage
- * Only Postscript plotters can plot bitmaps
- * for plotters that cannot plot a bitmap, a rectangle is plotted
- * For DXF_PLOTTER, currently: draws a rectangle
- * param aImage = the bitmap
- * param aPos = position of the center of the bitmap
- * param aScaleFactor = the scale factor to apply to the bitmap size
- *                      (this is not the plot scale factor)
- */
-void DXF_PLOTTER::PlotImage( wxImage & aImage, wxPoint aPos, double aScaleFactor )
-{
-    wxSize size;
-    size.x = aImage.GetWidth();
-    size.y = aImage.GetHeight();
-
-    size.x = KiROUND( size.x * aScaleFactor );
-    size.y = KiROUND( size.y * aScaleFactor );
-
-    wxPoint start = aPos;
-    start.x -= size.x / 2;
-    start.y -= size.y / 2;
-
-    wxPoint end = start;
-    end.x += size.x;
-    end.y += size.y;
-
-    rect( start, end, NO_FILL );
-
-}
-
-
-
-/*
- * Move the pen up (pen = 'U') or down (feather = 'D') at position x, y
- * Unit to unit DRAWING
- * If pen = 'Z' without lifting pen displacement
- */
-void DXF_PLOTTER::pen_to( wxPoint pos, char plume )
-{
-    wxASSERT( output_file );
+    PenFinish();
+}
+
+
+void DXF_PLOTTER::PenTo( const wxPoint& pos, char plume )
+{
+    wxASSERT( outputFile );
     if( plume == 'Z' )
     {
         return;
     }
-    user_to_device_coordinates( pos );
+    DPOINT pos_dev = userToDeviceCoordinates( pos );
+    DPOINT pen_lastpos_dev = userToDeviceCoordinates( penLastpos );
 
-    if( pen_lastpos != pos && plume == 'D' )
+    if( penLastpos != pos && plume == 'D' )
     {
-        /* DXF LINE */
-        wxString cname = ColorRefs[current_color].m_Name;
-        fprintf( output_file, "0\nLINE\n8\n%s\n10\n%d.0\n20\n%d.0\n11\n%d.0\n21\n%d.0\n",
+        // DXF LINE 
+        wxString cname = ColorRefs[currentColor].m_Name;
+        fprintf( outputFile, "0\nLINE\n8\n%s\n10\n%g\n20\n%g\n11\n%g\n21\n%g\n",
                  TO_UTF8( cname ),
-                 pen_lastpos.x, pen_lastpos.y, pos.x, pos.y );
+                 pen_lastpos_dev.x, pen_lastpos_dev.y, pos_dev.x, pos_dev.y );
     }
-    pen_lastpos = pos;
-}
-
-
-void DXF_PLOTTER::set_dash( bool dashed )
-{
-    /* NOP for now */
+    penLastpos = pos;
 }
 
 
 /**
- * Function thick_segment
- * Plot a filled segment (track)
- * @param aStart = starting point
- * @param aEnd = ending point
- * @param aWidth = segment width (thickness)
- * @param aPlotMode = FILLED, SKETCH ..
+ * Dashed lines are not (yet) supported by DXF_PLOTTER
  */
-void DXF_PLOTTER::thick_segment( wxPoint aStart, wxPoint aEnd, int aWidth,
-                                 EDA_DRAW_MODE_T aPlotMode )
-{
-    if( aPlotMode == LINE )  /* just a line is Ok */
+void DXF_PLOTTER::SetDash( bool dashed )
+{
+    // NOP for now
+}
+
+
+void DXF_PLOTTER::ThickSegment( const wxPoint& aStart, const wxPoint& aEnd, int aWidth,
+                                EDA_DRAW_MODE_T aPlotMode )
+{
+    if( aPlotMode == LINE )  // In line mode, just a line is OK
     {
-        move_to( aStart );
-        finish_to( aEnd );
+        MoveTo( aStart );
+        FinishTo( aEnd );
     }
     else
     {
-        segment_as_oval( aStart, aEnd, aWidth, aPlotMode );
+        segmentAsOval( aStart, aEnd, aWidth, aPlotMode );
     }
 }
 
-
-/* Plot an arc in DXF format.
- * center = center coord
- * StAngle, EndAngle = angle of beginning and end
- * Radius = radius of the arc
+/** Plot an arc in DXF format
+ * Filling is not supported
  */
-void DXF_PLOTTER::arc( wxPoint centre, int StAngle, int EndAngle, int radius,
+void DXF_PLOTTER::Arc( const wxPoint& centre, int StAngle, int EndAngle, int radius,
                        FILL_T fill, int width )
 {
-    wxASSERT( output_file );
+    wxASSERT( outputFile );
 
     if( radius <= 0 )
         return;
 
-    user_to_device_coordinates( centre );
-    radius = KiROUND( user_to_device_size( radius ) );
+    DPOINT centre_dev = userToDeviceCoordinates( centre );
+    double radius_dev = userToDeviceSize( radius );
 
-    /* DXF ARC */
-    wxString cname = ColorRefs[current_color].m_Name;
-    fprintf( output_file,
-             "0\nARC\n8\n%s\n10\n%d.0\n20\n%d.0\n40\n%d.0\n50\n%d.0\n51\n%d.0\n",
+    // Emit a DXF ARC entity
+    wxString cname = ColorRefs[currentColor].m_Name;
+    fprintf( outputFile,
+             "0\nARC\n8\n%s\n10\n%g\n20\n%g\n40\n%g\n50\n%g\n51\n%g\n",
              TO_UTF8( cname ),
-             centre.x, centre.y, radius,
-             StAngle / 10, EndAngle / 10 );
+             centre_dev.x, centre_dev.y, radius_dev,
+             StAngle / 10.0, EndAngle / 10.0 );
 }
 
-
-/* Plot oval pad at position. */
-void DXF_PLOTTER::flash_pad_oval( wxPoint pos, wxSize size, int orient,
-                                  EDA_DRAW_MODE_T trace_mode )
+/** 
+ * DXF oval pad: always done in sketch mode
+ */
+void DXF_PLOTTER::FlashPadOval( const wxPoint& pos, const wxSize& aSize, int orient,
+                                EDA_DRAW_MODE_T trace_mode )
 {
-    wxASSERT( output_file );
+    wxASSERT( outputFile );
+    wxSize size( aSize );
 
     /* The chip is reduced to an oval tablet with size.y > size.x
      * (Oval vertical orientation 0) */
@@ -268,37 +252,41 @@
         if( orient >= 3600 )
             orient -= 3600;
     }
-    sketch_oval( pos, size, orient, -1 );
+    sketchOval( pos, size, orient, -1 );
 }
 
 
-/* Plot round pad or via. */
-void DXF_PLOTTER::flash_pad_circle( wxPoint pos, int diametre,
+/** 
+ * DXF round pad: always done in sketch mode; it could be filled but it isn't
+ * pretty if other kinds of pad aren't...
+ */
+void DXF_PLOTTER::FlashPadCircle( const wxPoint& pos, int diametre,
                                     EDA_DRAW_MODE_T trace_mode )
 {
-    wxASSERT( output_file );
-    circle( pos, diametre, NO_FILL );
+    wxASSERT( outputFile );
+    Circle( pos, diametre, NO_FILL );
 }
 
 
-/*
- * Plot rectangular pad vertical or horizontal (rectangular Pad)
+/**
+ * DXF rectangular pad: alwayd done in sketch mode
  */
-void DXF_PLOTTER::flash_pad_rect( wxPoint pos, wxSize padsize,
-                                  int orient, EDA_DRAW_MODE_T trace_mode )
+void DXF_PLOTTER::FlashPadRect( const wxPoint& pos, const wxSize& padsize,
+                                int orient, EDA_DRAW_MODE_T trace_mode )
 {
-    wxASSERT( output_file );
+    wxASSERT( outputFile );
     wxSize size;
     int    ox, oy, fx, fy;
 
-    size.x = padsize.x / 2;  size.y = padsize.y / 2;
+    size.x = padsize.x / 2;  
+    size.y = padsize.y / 2;
 
     if( size.x < 0 )
         size.x = 0;
     if( size.y < 0 )
         size.y = 0;
 
-    /* If a dimension is zero, the trace is reduced to 1 line. */
+    // If a dimension is zero, the trace is reduced to 1 line
     if( size.x == 0 )
     {
         ox = pos.x;
@@ -307,8 +295,8 @@
         fx = pos.x;
         fy = pos.y + size.y;
         RotatePoint( &fx, &fy, pos.x, pos.y, orient );
-        move_to( wxPoint( ox, oy ) );
-        finish_to( wxPoint( fx, fy ) );
+        MoveTo( wxPoint( ox, oy ) );
+        FinishTo( wxPoint( fx, fy ) );
         return;
     }
     if( size.y == 0 )
@@ -319,45 +307,42 @@
         fx = pos.x + size.x;
         fy = pos.y;
         RotatePoint( &fx, &fy, pos.x, pos.y, orient );
-        move_to( wxPoint( ox, oy ) );
-        finish_to( wxPoint( fx, fy ) );
+        MoveTo( wxPoint( ox, oy ) );
+        FinishTo( wxPoint( fx, fy ) );
         return;
     }
 
     ox = pos.x - size.x;
     oy = pos.y - size.y;
     RotatePoint( &ox, &oy, pos.x, pos.y, orient );
-    move_to( wxPoint( ox, oy ) );
+    MoveTo( wxPoint( ox, oy ) );
 
     fx = pos.x - size.x;
     fy = pos.y + size.y;
     RotatePoint( &fx, &fy, pos.x, pos.y, orient );
-    line_to( wxPoint( fx, fy ) );
+    LineTo( wxPoint( fx, fy ) );
 
     fx = pos.x + size.x;
     fy = pos.y + size.y;
     RotatePoint( &fx, &fy, pos.x, pos.y, orient );
-    line_to( wxPoint( fx, fy ) );
+    LineTo( wxPoint( fx, fy ) );
 
     fx = pos.x + size.x;
     fy = pos.y - size.y;
     RotatePoint( &fx, &fy, pos.x, pos.y, orient );
-    line_to( wxPoint( fx, fy ) );
+    LineTo( wxPoint( fx, fy ) );
 
-    finish_to( wxPoint( ox, oy ) );
+    FinishTo( wxPoint( ox, oy ) );
 }
 
 
-/*
- * Plot trapezoidal pad.
- * aPadPos is pad position, aCorners the corners position of the basic shape
- * Orientation aPadOrient in 0.1 degrees
- * Plot mode = FILLED, SKETCH (unused)
+/**
+ * DXF trapezoidal pad: only sketch mode is supported
  */
-void DXF_PLOTTER::flash_pad_trapez( wxPoint aPadPos, wxPoint aCorners[4],
-                                    int aPadOrient, EDA_DRAW_MODE_T aTrace_Mode )
+void DXF_PLOTTER::FlashPadTrapez( const wxPoint& aPadPos, const wxPoint *aCorners,
+                                  int aPadOrient, EDA_DRAW_MODE_T aTrace_Mode )
 {
-    wxASSERT( output_file );
+    wxASSERT( outputFile );
     wxPoint coord[4];       /* coord actual corners of a trapezoidal trace */
 
     for( int ii = 0; ii < 4; ii++ )
@@ -368,9 +353,10 @@
     }
 
     // Plot edge:
-    move_to( coord[0] );
-    line_to( coord[1] );
-    line_to( coord[2] );
-    line_to( coord[3] );
-    finish_to( coord[0] );
+    MoveTo( coord[0] );
+    LineTo( coord[1] );
+    LineTo( coord[2] );
+    LineTo( coord[3] );
+    FinishTo( coord[0] );
 }
+

=== modified file 'common/common_plotGERBER_functions.cpp'
--- common/common_plotGERBER_functions.cpp	2012-04-19 06:55:45 +0000
+++ common/common_plotGERBER_functions.cpp	2012-04-30 09:18:58 +0000
@@ -16,25 +16,34 @@
 #include <build_version.h>
 
 
-/**
- * Function set_viewport
- * Set the plot offset for the current plotting
- * @param aOffset = plot offset
- * @param aScale = coordinate scale (scale coefficient for coordinates)
- * @param aMirror - Mirror plot if true.
- */
-void GERBER_PLOTTER::set_viewport( wxPoint aOffset, double aScale, bool aMirror )
+void GERBER_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
+				  double aScale, bool aMirror )
 {
-    wxASSERT( !output_file );
+    wxASSERT( !outputFile );
     wxASSERT( aMirror == false );
     plotMirror = false;
-    plot_offset = aOffset;
+    plotOffset = aOffset;
     wxASSERT( aScale == 1 );
-    plot_scale   = 1;
-    device_scale = 1;
-    set_default_line_width( 100 );  /* line thickness in 1 / 1000 inch */
-}
-
+    plotScale = 1;
+    iuPerDeviceUnit = 1.0 / aIusPerDecimil;
+    /* We don't handle the filmbox, and it's more useful to keep the
+     * origin at the origin */
+    paperSize.x = 0;
+    paperSize.y = 0;
+    SetDefaultLineWidth( 100 * aIusPerDecimil ); // Arbitrary default
+}
+
+/**
+ * Emit a D-Code record, using proper conversions
+ * to format a leading zero omitted gerber coordinate 
+ * (for 4 decimal positions, see header generation in start_plot
+ */
+void GERBER_PLOTTER::emitDcode( const DPOINT& pt, int dcode )
+{
+
+    fprintf( outputFile, "X%dY%dD%02d*\n", 
+	    int( pt.x ), int( pt.y ), dcode );
+}
 
 /**
  * Function start_plot
@@ -42,106 +51,102 @@
  * initialize global variable g_Plot_PlotOutputFile
  * @param aFile: an opened file to write to
  */
-bool GERBER_PLOTTER::start_plot( FILE* aFile )
+bool GERBER_PLOTTER::StartPlot( FILE* aFile )
 {
-    wxASSERT( !output_file );
-    final_file  = aFile;
+    wxASSERT( !outputFile );
+    finalFile = aFile;
 
     // Create a temporary filename to store gerber file
     // note tmpfile() does not work under Vista and W7 in user mode
     m_workFilename = filename + wxT(".tmp");
-    work_file   = wxFopen( m_workFilename, wxT( "wt" ));
-    output_file = work_file;
-    wxASSERT( output_file );
+    workFile   = wxFopen( m_workFilename, wxT( "wt" ));
+    outputFile = workFile;
+    wxASSERT( outputFile );
 
-    if( output_file == NULL )
+    if( outputFile == NULL )
         return false;
 
     wxString Title = creator + wxT( " " ) + GetBuildVersion();
-    fprintf( output_file, "G04 (created by %s) date %s*\n",
+    fprintf( outputFile, "G04 (created by %s) date %s*\n",
              TO_UTF8( Title ), TO_UTF8( DateAndTime() ) );
 
-    // Specify linear interpol (G01), unit = INCH (G70), abs format (G90):
-    fputs( "G01*\nG70*\nG90*\n", output_file );
-    fputs( "%MOIN*%\n", output_file );     // set unites = INCHES
+    /* Mass parameter: unit = INCHES */
+    fputs( "%MOIN*%\n", outputFile );
 
-    /* Set gerber format to 3.4 */
+    /* Set coordinate format to 3.4 absolute, leading zero omitted */
     fputs( "G04 Gerber Fmt 3.4, Leading zero omitted, Abs format*\n%FSLAX34Y34*%\n",
-           output_file );
+           outputFile );
 
-    fputs( "G04 APERTURE LIST*\n", output_file );
+    /* Specify linear interpol (G01), unit = INCH (G70), abs format (G90) */
+    fputs( "G01*\nG70*\nG90*\n", outputFile );
+    fputs( "G04 APERTURE LIST*\n", outputFile );
     /* Select the default aperture */
-    set_current_line_width( -1 );
+    SetCurrentLineWidth( -1 );
 
     return true;
 }
 
 
-bool GERBER_PLOTTER::end_plot()
+bool GERBER_PLOTTER::EndPlot()
 {
     char     line[1024];
     wxString msg;
 
-    wxASSERT( output_file );
-
-    /* Outfile is actually a temporary file! */
-    fputs( "M02*\n", output_file );
-    fflush( output_file );
-
-//    rewind( work_file ); // work_file == output_file !!!
-    fclose( work_file );
-    work_file   = wxFopen( m_workFilename, wxT( "rt" ));
-    wxASSERT( work_file );
-    output_file = final_file;
+    wxASSERT( outputFile );
+
+    /* Outfile is actually a temporary file i.e. workFile */
+    fputs( "M02*\n", outputFile );
+    fflush( outputFile );
+
+    fclose( workFile );
+    workFile   = wxFopen( m_workFilename, wxT( "rt" ));
+    wxASSERT( workFile );
+    outputFile = finalFile;
 
     // Placement of apertures in RS274X
-    while( fgets( line, 1024, work_file ) )
+    while( fgets( line, 1024, workFile ) )
     {
-        fputs( line, output_file );
+        fputs( line, outputFile );
 
         if( strcmp( strtok( line, "\n\r" ), "G04 APERTURE LIST*" ) == 0 )
         {
-            write_aperture_list();
-            fputs( "G04 APERTURE END LIST*\n", output_file );
+            writeApertureList();
+            fputs( "G04 APERTURE END LIST*\n", outputFile );
         }
     }
 
-    fclose( work_file );
-    fclose( final_file );
+    fclose( workFile );
+    fclose( finalFile );
     ::wxRemoveFile( m_workFilename );
-    output_file = 0;
+    outputFile = 0;
 
     return true;
 }
 
 
-/* Set the default line width (in 1/1000 inch) for the current plotting
- */
-void GERBER_PLOTTER::set_default_line_width( int width )
+void GERBER_PLOTTER::SetDefaultLineWidth( int width )
 {
-    default_pen_width = width;
-    current_aperture  = apertures.end();
+    defaultPenWidth = width;
+    currentAperture = apertures.end();
 }
 
 
-/* Set the Current line width (in 1/1000 inch) for the next plot
- */
-void GERBER_PLOTTER::set_current_line_width( int width )
+void GERBER_PLOTTER::SetCurrentLineWidth( int width )
 {
     int pen_width;
 
     if( width > 0 )
         pen_width = width;
     else
-        pen_width = default_pen_width;
+        pen_width = defaultPenWidth;
 
-    select_aperture( wxSize( pen_width, pen_width ), APERTURE::Plotting );
-    current_pen_width = pen_width;
+    selectAperture( wxSize( pen_width, pen_width ), APERTURE::Plotting );
+    currentPenWidth = pen_width;
 }
 
 
-std::vector<APERTURE>::iterator GERBER_PLOTTER::get_aperture( const wxSize&           size,
-                                                              APERTURE::Aperture_Type type )
+std::vector<APERTURE>::iterator GERBER_PLOTTER::getAperture( const wxSize&           size,
+                                                             APERTURE::APERTURE_TYPE type )
 {
     int last_D_code = 9;
 
@@ -150,9 +155,9 @@
 
     while( tool != apertures.end() )
     {
-        last_D_code = tool->D_code;
+        last_D_code = tool->DCode;
 
-        if( (tool->type == type) && (tool->size == size) )
+        if( (tool->Type == type) && (tool->Size == size) )
             return tool;
 
         tool++;
@@ -160,76 +165,78 @@
 
     // Allocate a new aperture
     APERTURE new_tool;
-    new_tool.size   = size;
-    new_tool.type   = type;
-    new_tool.D_code = last_D_code + 1;
+    new_tool.Size  = size;
+    new_tool.Type  = type;
+    new_tool.DCode = last_D_code + 1;
     apertures.push_back( new_tool );
     return apertures.end() - 1;
 }
 
 
-void GERBER_PLOTTER::select_aperture( const wxSize&           size,
-                                      APERTURE::Aperture_Type type )
+void GERBER_PLOTTER::selectAperture( const wxSize&           size,
+                                     APERTURE::APERTURE_TYPE type )
 {
-    wxASSERT( output_file );
+    wxASSERT( outputFile );
 
-    if( ( current_aperture == apertures.end() )
-       || ( current_aperture->type != type )
-       || ( current_aperture->size != size ) )
+    if( ( currentAperture == apertures.end() )
+       || ( currentAperture->Type != type )
+       || ( currentAperture->Size != size ) )
     {
         /* Pick an existing aperture or create a new one */
-        current_aperture = get_aperture( size, type );
-        fprintf( output_file, "G54D%d*\n", current_aperture->D_code );
+        currentAperture = getAperture( size, type );
+        fprintf( outputFile, "G54D%d*\n", currentAperture->DCode );
     }
 }
 
 
-/*Generate list of D_CODES.
- * Returns the number of D_Codes generated in RS274X format.
+/**
+ * Generate the table of D codes
  */
-void GERBER_PLOTTER::write_aperture_list()
+void GERBER_PLOTTER::writeApertureList()
 {
-    wxASSERT( output_file );
+    wxASSERT( outputFile );
     char cbuf[1024];
 
     /* Init : */
     for( std::vector<APERTURE>::iterator tool = apertures.begin();
          tool != apertures.end(); tool++ )
     {
-        const float fscale = 0.0001f * plot_scale; // For 3.4 format
-        char*       text;
-
-        text = cbuf + sprintf( cbuf, "%%ADD%d", tool->D_code );
-
-        switch( tool->type )
+        const double fscale = 0.0001f * plotScale
+				* iuPerDeviceUnit ; // For 3.4 format
+        char* text = cbuf + sprintf( cbuf, "%%ADD%d", tool->DCode );
+
+        switch( tool->Type )
         {
         case APERTURE::Circle:
-            sprintf( text, "C,%f*%%\n", tool->size.x * fscale );
+            sprintf( text, "C,%g*%%\n", tool->Size.x * fscale );
             break;
 
         case APERTURE::Rect:
-            sprintf( text, "R,%fX%f*%%\n", tool->size.x * fscale,
-                     tool->size.y * fscale );
+            sprintf( text, "R,%gX%g*%%\n", 
+	             tool->Size.x * fscale,
+                     tool->Size.y * fscale );
             break;
 
         case APERTURE::Plotting:
-            sprintf( text, "C,%f*%%\n", tool->size.x * fscale );
+            sprintf( text, "C,%g*%%\n", tool->Size.x * fscale );
             break;
 
         case APERTURE::Oval:
-            sprintf( text, "O,%fX%f*%%\n", tool->size.x * fscale, tool->size.y * fscale );
+            sprintf( text, "O,%gX%g*%%\n", 
+	            tool->Size.x * fscale, 
+		    tool->Size.y * fscale );
             break;
         }
 
-        fputs( cbuf, output_file );
+        fputs( cbuf, outputFile );
     }
 }
 
 
-void GERBER_PLOTTER::pen_to( wxPoint aPos, char plume )
+void GERBER_PLOTTER::PenTo( const wxPoint& aPos, char plume )
 {
-    wxASSERT( output_file );
-    user_to_device_coordinates( aPos );
+    wxASSERT( outputFile );
+    DPOINT pos_dev = userToDeviceCoordinates( aPos );
 
     switch( plume )
     {
@@ -237,21 +244,21 @@
         break;
 
     case 'U':
-        fprintf( output_file, "X%5.5dY%5.5dD02*\n", aPos.x, aPos.y );
+	emitDcode( pos_dev, 2 );
         break;
 
     case 'D':
-        fprintf( output_file, "X%5.5dY%5.5dD01*\n", aPos.x, aPos.y );
+	emitDcode( pos_dev, 1 );
     }
 
-    pen_state = plume;
+    penState = plume;
 }
 
 
-void GERBER_PLOTTER::rect( wxPoint p1, wxPoint p2, FILL_T fill, int width )
+void GERBER_PLOTTER::Rect( const wxPoint& p1, const wxPoint& p2, FILL_T fill, 
+                           int width )
 {
-    static std::vector< wxPoint > cornerList;
-    cornerList.clear();
+    std::vector< wxPoint > cornerList;
 
     // Build corners list
     cornerList.push_back( p1 );
@@ -267,141 +274,98 @@
 }
 
 
-/**
- * Function circle
- * writes a non filled circle to output file
- * Plot one circle as segments (6 to 16 depending on its radius
- * @param aCentre = center coordinates
- * @param aDiameter = diameter of the circle
- * @param aFill = plot option (NO_FILL, FILLED_SHAPE, FILLED_WITH_BG_BODYCOLOR)
- * not used here: circles are always not filled the gerber. Filled circles are flashed
- * @param aWidth = line width
- */
-void GERBER_PLOTTER::circle( wxPoint aCentre, int aDiameter, FILL_T aFill, int aWidth )
+void GERBER_PLOTTER::Circle( const wxPoint& aCentre, int aDiameter, FILL_T aFill, 
+			     int aWidth )
 {
-    wxASSERT( output_file );
+    wxASSERT( outputFile );
     wxPoint   start, end;
     double    radius = aDiameter / 2;
     const int delta  = 3600 / 32; /* increment (in 0.1 degrees) to draw circles */
 
     start.x = aCentre.x + KiROUND( radius );
     start.y = aCentre.y;
-    set_current_line_width( aWidth );
-    move_to( start );
+    SetCurrentLineWidth( aWidth );
+    MoveTo( start );
 
     for( int ii = delta; ii < 3600; ii += delta )
     {
-        end.x = aCentre.x + (int) ( radius * cos( DEG2RAD( (double)ii / 10.0 ) ) );
-        end.y = aCentre.y + (int) ( radius * sin( DEG2RAD( (double)ii / 10.0 ) ) );
-        line_to( end );
+        end.x = aCentre.x + (int) ( radius * cos( DEG2RAD( ii / 10.0 ) ) );
+        end.y = aCentre.y + (int) ( radius * sin( DEG2RAD( ii / 10.0 ) ) );
+        LineTo( end );
     }
 
-    finish_to( start );
+    FinishTo( start );
 }
 
 
-/*
- * Function PlotPoly
- * writes a filled or not filled polyline to output file
- * @param aCornerList = buffer of corners coordinates
- * @param aFill = plot option (NO_FILL, FILLED_SHAPE, FILLED_WITH_BG_BODYCOLOR)
- * @param aWidth = Width of the line to plot.
+/**
+ * Gerber polygon: they can (and *should*) be filled with the
+ * appropriate G36/G37 sequence (raster fills are deprecated)
  */
-void GERBER_PLOTTER::PlotPoly( std::vector< wxPoint >& aCornerList, FILL_T aFill, int aWidth )
+void GERBER_PLOTTER::PlotPoly( const std::vector< wxPoint >& aCornerList, 
+                               FILL_T aFill, int aWidth )
 {
     if( aCornerList.size() <= 1 )
         return;
 
-    set_current_line_width( aWidth );
+    SetCurrentLineWidth( aWidth );
 
     if( aFill )
-        fputs( "G36*\n", output_file );
+        fputs( "G36*\n", outputFile );
 
-    move_to( aCornerList[0] );
+    MoveTo( aCornerList[0] );
 
     for( unsigned ii = 1; ii < aCornerList.size(); ii++ )
     {
-        line_to( aCornerList[ii] );
+        LineTo( aCornerList[ii] );
     }
 
     if( aFill )
     {
-        finish_to( aCornerList[0] );
-        fputs( "G37*\n", output_file );
+        FinishTo( aCornerList[0] );
+        fputs( "G37*\n", outputFile );
     }
     else
     {
-        pen_finish();
+        PenFinish();
     }
 }
 
-/*
- * Function PlotImage
- * Only Postscript plotters can plot bitmaps
- * for plotters that cannot plot a bitmap, a rectangle is plotted
- * For GERBER_PLOTTER, draws a rectangle
- * param aImage = the bitmap
- * param aPos = position of the center of the bitmap
- * param aScaleFactor = the scale factor to apply to the bitmap size
- *                      (this is not the plot scale factor)
- */
-void GERBER_PLOTTER::PlotImage( wxImage & aImage, wxPoint aPos, double aScaleFactor )
-{
-    wxSize size;
-    size.x = aImage.GetWidth();
-    size.y = aImage.GetHeight();
-
-    size.x = KiROUND( size.x * aScaleFactor );
-    size.y = KiROUND( size.y * aScaleFactor );
-
-    wxPoint start = aPos;
-    start.x -= size.x / 2;
-    start.y -= size.y / 2;
-
-    wxPoint end = start;
-    end.x += size.x;
-    end.y += size.y;
-
-    rect( start, end, NO_FILL );
-
-}
-
-/* Function flash_pad_circle
- * Plot a circular pad or via at the user position pos
- */
-void GERBER_PLOTTER::flash_pad_circle( wxPoint pos, int diametre, EDA_DRAW_MODE_T trace_mode )
-{
-    wxASSERT( output_file );
+/**
+ * Filled circular flashes are stored as apertures
+ */
+void GERBER_PLOTTER::FlashPadCircle( const wxPoint& pos, int diametre, 
+				     EDA_DRAW_MODE_T trace_mode )
+{
+    wxASSERT( outputFile );
     wxSize size( diametre, diametre );
 
     switch( trace_mode )
     {
     case LINE:
     case SKETCH:
-        set_current_line_width( -1 );
-        circle( pos, diametre - current_pen_width, NO_FILL );
+        SetCurrentLineWidth( -1 );
+        Circle( pos, diametre - currentPenWidth, NO_FILL );
         break;
 
     case FILLED:
-        user_to_device_coordinates( pos );
-        select_aperture( size, APERTURE::Circle );
-        fprintf( output_file, "X%5.5dY%5.5dD03*\n", pos.x, pos.y );
+	DPOINT pos_dev = userToDeviceCoordinates( pos );
+        selectAperture( size, APERTURE::Circle );
+	emitDcode( pos_dev, 3 );
         break;
     }
 }
 
 
-/* Plot oval pad at position pos:
- * Dimensions dx, dy,
- * Orient Orient
- * For a vertical or horizontal orientation, the shape is flashed
- * For any orientation the shape is drawn as a segment
+/**
+ * Filled oval flashes are handled as aperture in the 90 degree positions only
  */
-void GERBER_PLOTTER::flash_pad_oval( wxPoint pos, wxSize size, int orient,
-                                     EDA_DRAW_MODE_T trace_mode )
+void GERBER_PLOTTER::FlashPadOval( const wxPoint& pos, const wxSize& aSize, int orient,
+                                   EDA_DRAW_MODE_T trace_mode )
 {
-    wxASSERT( output_file );
+    wxASSERT( outputFile );
     int x0, y0, x1, y1, delta;
+    wxSize size( aSize );
 
     /* Plot a flashed shape. */
     if( ( orient == 0 || orient == 900 || orient == 1800 || orient == 2700 )
@@ -409,10 +373,10 @@
     {
         if( orient == 900 || orient == 2700 ) /* orientation turned 90 deg. */
             EXCHG( size.x, size.y );
-
-        user_to_device_coordinates( pos );
-        select_aperture( size, APERTURE::Oval );
-        fprintf( output_file, "X%5.5dY%5.5dD03*\n", pos.x, pos.y );
+	
+	DPOINT pos_dev = userToDeviceCoordinates( pos );
+        selectAperture( size, APERTURE::Oval );
+	emitDcode( pos_dev, 3 );
     }
     else /* Plot pad as a segment. */
     {
@@ -428,6 +392,7 @@
 
         if( trace_mode == FILLED )
         {
+	    /* XXX to do: use an aperture macro to declare the rotated pad */
             /* The pad  is reduced to an oval with dy > dx */
             delta = size.y - size.x;
             x0    = 0;
@@ -436,104 +401,100 @@
             y1    = delta / 2;
             RotatePoint( &x0, &y0, orient );
             RotatePoint( &x1, &y1, orient );
-            thick_segment( wxPoint( pos.x + x0, pos.y + y0 ),
+            ThickSegment( wxPoint( pos.x + x0, pos.y + y0 ),
                            wxPoint( pos.x + x1, pos.y + y1 ),
                            size.x, trace_mode );
         }
         else
         {
-            sketch_oval( pos, size, orient, -1 );
+            sketchOval( pos, size, orient, -1 );
         }
     }
 }
 
 
-/* Plot rectangular pad.
- * Gives its center, size, and orientation
- * For a vertical or horizontal shape, the shape is an aperture (Dcode) and
- * it is flashed.
- * For others shape the direction is plotted as a polygon.
+/**
+ * Filled rect flashes are handled as aperture in the 90 degree positions only
  */
-void GERBER_PLOTTER::flash_pad_rect( wxPoint pos, wxSize size,
-                                     int orient, EDA_DRAW_MODE_T trace_mode )
+void GERBER_PLOTTER::FlashPadRect( const wxPoint& pos, const wxSize& aSize,
+                                   int orient, EDA_DRAW_MODE_T trace_mode )
 
 {
-    wxASSERT( output_file );
+    wxASSERT( outputFile );
+    wxSize size( aSize );
 
     /* Plot as flashed. */
     switch( orient )
     {
     case 900:
-    case 2700:        /* rotation of 90 degrees or 270 returns dimensions */
-        EXCHG( size.x, size.y );
+    case 2700:        /* rotation of 90 degrees or 270 swaps dimensions */
+	EXCHG( size.x, size.y );
 
-    // Pass through
+	// Pass through
     case 0:
     case 1800:
-        switch( trace_mode )
-        {
-        case LINE:
-        case SKETCH:
-            set_current_line_width( -1 );
-            rect( wxPoint( pos.x - (size.x - current_pen_width) / 2,
-                           pos.y - (size.y - current_pen_width) / 2 ),
-                  wxPoint( pos.x + (size.x - current_pen_width) / 2,
-                           pos.y + (size.y - current_pen_width) / 2 ),
-                  NO_FILL );
-            break;
-
-        case FILLED:
-            user_to_device_coordinates( pos );
-            select_aperture( size, APERTURE::Rect );
-            fprintf( output_file, "X%5.5dY%5.5dD03*\n", pos.x, pos.y );
-            break;
-        }
-
-        break;
-
-    default: /* plot pad shape as polygon */
-    {
-        wxPoint coord[4];
-        // coord[0] is assumed the lower left
-        // coord[1] is assumed the upper left
-        // coord[2] is assumed the upper right
-        // coord[3] is assumed the lower right
-
-        /* Trace the outline. */
-        coord[0].x = -size.x/2;   // lower left
-        coord[0].y = size.y/2;
-        coord[1].x = -size.x/2;   // upper left
-        coord[1].y = -size.y/2;
-        coord[2].x = size.x/2;    // upper right
-        coord[2].y = -size.y/2;
-        coord[3].x = size.x/2;    //lower right
-        coord[3].y = size.y/2;
-
-        flash_pad_trapez( pos, coord, orient, trace_mode );
-    }
-        break;
+	switch( trace_mode )
+	{
+	case LINE:
+	case SKETCH:
+	    SetCurrentLineWidth( -1 );
+	    Rect( wxPoint( pos.x - (size.x - currentPenWidth) / 2,
+			pos.y - (size.y - currentPenWidth) / 2 ),
+		    wxPoint( pos.x + (size.x - currentPenWidth) / 2,
+			pos.y + (size.y - currentPenWidth) / 2 ),
+		    NO_FILL );
+	    break;
+
+	case FILLED:
+	    DPOINT pos_dev = userToDeviceCoordinates( pos );
+	    selectAperture( size, APERTURE::Rect );
+	    emitDcode( pos_dev, 3 );
+	    break;
+	}
+	break;
+
+    default: // plot pad shape as polygon 
+	{
+	    // XXX to do: use an aperture macro to declare the rotated pad 
+	    wxPoint coord[4];
+	    // coord[0] is assumed the lower left
+	    // coord[1] is assumed the upper left
+	    // coord[2] is assumed the upper right
+	    // coord[3] is assumed the lower right
+
+	    /* Trace the outline. */
+	    coord[0].x = -size.x/2;   // lower left
+	    coord[0].y = size.y/2;
+	    coord[1].x = -size.x/2;   // upper left
+	    coord[1].y = -size.y/2;
+	    coord[2].x = size.x/2;    // upper right
+	    coord[2].y = -size.y/2;
+	    coord[3].x = size.x/2;    // lower right
+	    coord[3].y = size.y/2;
+
+	    FlashPadTrapez( pos, coord, orient, trace_mode );
+	}
+	break;
     }
 }
 
 
-/* Plot trapezoidal pad.
- * aPadPos is pad position, aCorners the corners positions of the basic shape
- * Orientation aPadOrient in 0.1 degrees
- * Plot mode  = FILLED or SKETCH
+/**
+ * Trapezoidal pad at the moment are *never* handled as aperture, since
+ * they require aperture macros
  */
- void GERBER_PLOTTER::flash_pad_trapez( wxPoint aPadPos,  wxPoint aCorners[4],
-                                        int aPadOrient, EDA_DRAW_MODE_T aTrace_Mode )
+void GERBER_PLOTTER::FlashPadTrapez( const wxPoint& aPadPos,  const wxPoint* aCorners,
+                                     int aPadOrient, EDA_DRAW_MODE_T aTrace_Mode )
 
 {
+    // XXX to do: use an aperture macro to declare the pad 
     // polygon corners list
-    static std::vector< wxPoint > cornerList;
-    cornerList.clear();
-
+    std::vector< wxPoint > cornerList;
 
     for( int ii = 0; ii < 4; ii++ )
         cornerList.push_back( aCorners[ii] );
 
-   /* Draw the polygon and fill the interior as required. */
+    // Draw the polygon and fill the interior as required
     for( unsigned ii = 0; ii < 4; ii++ )
     {
         RotatePoint( &cornerList[ii], aPadOrient );
@@ -543,15 +504,19 @@
     // Close the polygon
     cornerList.push_back( cornerList[0] );
 
-    set_current_line_width( -1 );
+    SetCurrentLineWidth( -1 );
     PlotPoly( cornerList, aTrace_Mode==FILLED ? FILLED_SHAPE : NO_FILL );
 }
 
-
+/** 
+ * Change the plot polarity and begin a new layer
+ * Used to 'scratch off' silk screen away from solder mask
+ */
 void GERBER_PLOTTER::SetLayerPolarity( bool aPositive )
 {
     if( aPositive )
-        fprintf( output_file, "%%LPD*%%\n" );
+        fprintf( outputFile, "%%LPD*%%\n" );
     else
-        fprintf( output_file, "%%LPC*%%\n" );
+        fprintf( outputFile, "%%LPC*%%\n" );
 }
+

=== modified file 'common/common_plotHPGL_functions.cpp'
--- common/common_plotHPGL_functions.cpp	2012-04-19 06:55:45 +0000
+++ common/common_plotHPGL_functions.cpp	2012-04-30 09:18:58 +0000
@@ -1,6 +1,10 @@
 /**
  * @file common_plotHPGL_functions.cpp
  * @brief KiCad: Common plot HPGL Routines
+ * Filled primitive are not supported, but some could be using HPGL/2
+ * Since this plot engine is mostly intended for import in external programs,
+ * sadly HPGL/2 isn't supported a lot... some of the primitives use overlapped
+ * strokes to fill the shape
  */
 
 #include <fctsys.h>
@@ -12,184 +16,163 @@
 #include <macros.h>
 #include <kicad_string.h>
 
-// HPGL scale factor.
-const double SCALE_HPGL = 0.102041;
-
-
-void HPGL_PLOTTER::set_viewport( wxPoint aOffset, double aScale, bool aMirror )
+// HPGL scale factor (1 PLU = 1/40mm IIRC)
+static const double PLUsPERDECIMIL = 0.102041;
+
+
+void HPGL_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
+				double aScale, bool aMirror )
 {
-    wxASSERT( !output_file );
-    plot_offset  = aOffset;
-    plot_scale   = aScale;
-    device_scale = SCALE_HPGL;
-    set_default_line_width( 100 ); // default line width in 1 / 1000 inch
+    wxASSERT( !outputFile );
+    plotOffset  = aOffset;
+    plotScale = aScale;
+    iuPerDeviceUnit = PLUsPERDECIMIL / aIusPerDecimil;
+    /* Compute the paper size in IUs */
+    paperSize = pageInfo.GetSizeMils();
+    paperSize.x *= 10.0 * aIusPerDecimil;
+    paperSize.y *= 10.0 * aIusPerDecimil;
+    SetDefaultLineWidth( 0 ); // HPGL has pen sizes instead
     plotMirror = aMirror;
 }
 
-
-bool HPGL_PLOTTER::start_plot( FILE* fout )
-{
-    wxASSERT( !output_file );
-    output_file = fout;
-    fprintf( output_file, "IN;VS%d;PU;PA;SP%d;\n", pen_speed, pen_number );
-    return true;
-}
-
-
-bool HPGL_PLOTTER::end_plot()
-{
-    wxASSERT( output_file );
-    fputs( "PU;PA;SP0;\n", output_file );
-    fclose( output_file );
-    output_file = NULL;
-    return true;
-}
-
-
-void HPGL_PLOTTER::rect( wxPoint p1, wxPoint p2, FILL_T fill, int width )
-{
-    wxASSERT( output_file );
-    user_to_device_coordinates( p2 );
-    move_to( p1 );
-    fprintf( output_file, "EA %d,%d;\n", p2.x, p2.y );
-    pen_finish();
-}
-
-
-void HPGL_PLOTTER::circle( wxPoint centre,
-                           int     diameter,
-                           FILL_T  fill,
-                           int     width )
-{
-    wxASSERT( output_file );
-    double rayon = user_to_device_size( diameter / 2 );
-
-    if( rayon > 0 )
+/**
+ * At the start of the HPGL plot pen speed and number are requested
+ */
+bool HPGL_PLOTTER::StartPlot( FILE* fout )
+{
+    wxASSERT( !outputFile );
+    outputFile = fout;
+    fprintf( outputFile, "IN;VS%d;PU;PA;SP%d;\n", penSpeed, penNumber );
+    return true;
+}
+
+/**
+ * HPGL end of plot: pen return and release
+ */
+bool HPGL_PLOTTER::EndPlot()
+{
+    wxASSERT( outputFile );
+    fputs( "PU;PA;SP0;\n", outputFile );
+    fclose( outputFile );
+    outputFile = NULL;
+    return true;
+}
+
+/**
+ * HPGL rectangle: fill not supported
+ */
+void HPGL_PLOTTER::Rect( const wxPoint& p1, const wxPoint& p2, FILL_T fill, int width )
+{
+    wxASSERT( outputFile );
+    DPOINT p2dev = userToDeviceCoordinates( p2 );
+    MoveTo( p1 );
+    fprintf( outputFile, "EA %.0f,%.0f;\n", p2dev.x, p2dev.y );
+    PenFinish();
+}
+
+
+/**
+ * HPGL circle: fill not supported
+ */
+void HPGL_PLOTTER::Circle( const wxPoint& centre, int diameter, FILL_T fill,
+                           int width )
+{
+    wxASSERT( outputFile );
+    double radius = userToDeviceSize( diameter / 2 );
+
+    if( radius > 0 )
     {
-        move_to( centre );
-        fprintf( output_file, "CI %g;\n", rayon );
-        pen_finish();
+        MoveTo( centre );
+        fprintf( outputFile, "CI %g;\n", radius );
+        PenFinish();
     }
 }
 
 
-/* Plot a polygon (closed if completed) in HPGL
- * aCornerList = a wxPoint list of corner
- * aFill: if != 0 filled polygon
+/** 
+ * HPGL polygon: fill not supported (but closed, at least)
  */
-void HPGL_PLOTTER::PlotPoly( std::vector< wxPoint >& aCornerList, FILL_T aFill, int aWidth)
+void HPGL_PLOTTER::PlotPoly( const std::vector< wxPoint >& aCornerList, 
+                             FILL_T aFill, int aWidth)
 {
     if( aCornerList.size() <= 1 )
         return;
 
-    move_to( aCornerList[0] );
+    MoveTo( aCornerList[0] );
     for( unsigned ii = 1; ii < aCornerList.size(); ii++ )
-        line_to( aCornerList[ii] );
+        LineTo( aCornerList[ii] );
 
     // Close polygon if filled.
     if( aFill )
     {
         int ii = aCornerList.size() - 1;
         if( aCornerList[ii] != aCornerList[0] )
-            line_to( aCornerList[0] );
+            LineTo( aCornerList[0] );
     }
-    pen_finish();
-}
-
-/*
- * Function PlotImage
- * Only Postscript plotters can plot bitmaps
- * for plotters that cannot plot a bitmap, a rectangle is plotted
- * For HPGL_PLOTTER, draws a rectangle
- * param aImage = the bitmap
- * param aPos = position of the center of the bitmap
- * param aScaleFactor = the scale factor to apply to the bitmap size
- *                      (this is not the plot scale factor)
- */
-void HPGL_PLOTTER::PlotImage( wxImage & aImage, wxPoint aPos, double aScaleFactor )
-{
-    wxSize size;
-    size.x = aImage.GetWidth();
-    size.y = aImage.GetHeight();
-
-    size.x = KiROUND( size.x * aScaleFactor );
-    size.y = KiROUND( size.y * aScaleFactor );
-
-    wxPoint start = aPos;
-    start.x -= size.x / 2;
-    start.y -= size.y / 2;
-
-    wxPoint end = start;
-    end.x += size.x;
-    end.y += size.y;
-
-    rect( start, end, NO_FILL );
-
-}
-
-
-/* Set pen up ('U') or down ('D').
- */
-void HPGL_PLOTTER::pen_control( int plume )
-{
-    wxASSERT( output_file );
+    PenFinish();
+}
+
+
+/**
+ * Pen control logic (remove redundant pen activations)
+ */
+void HPGL_PLOTTER::penControl( char plume )
+{
+    wxASSERT( outputFile );
     switch( plume )
     {
     case 'U':
-        if( pen_state != 'U' )
+        if( penState != 'U' )
         {
-            fputs( "PU;", output_file );
-            pen_state = 'U';
+            fputs( "PU;", outputFile );
+            penState = 'U';
         }
         break;
 
     case 'D':
-        if( pen_state != 'D' )
+        if( penState != 'D' )
         {
-            fputs( "PD;", output_file );
-            pen_state = 'D';
+            fputs( "PD;", outputFile );
+            penState = 'D';
         }
         break;
 
     case 'Z':
-        fputs( "PU;", output_file );
-        pen_state     = 'U';
-        pen_lastpos.x = -1;
-        pen_lastpos.y = -1;
+        fputs( "PU;", outputFile );
+        penState = 'U';
+        penLastpos.x = -1;
+        penLastpos.y = -1;
         break;
     }
 }
 
 
-/*
- * Move the pen to position with pen up or down.
- * At position x, y
- * Unit to unit DRAWING
- * If pen = 'Z' without changing pen during move.
- */
-void HPGL_PLOTTER::pen_to( wxPoint pos, char plume )
+void HPGL_PLOTTER::PenTo( const wxPoint& pos, char plume )
 {
-    wxASSERT( output_file );
+    wxASSERT( outputFile );
 
     if( plume == 'Z' )
     {
-        pen_control( 'Z' );
+        penControl( 'Z' );
         return;
     }
 
-    pen_control( plume );
-    user_to_device_coordinates( pos );
-
-    if( pen_lastpos != pos )
-        fprintf( output_file, "PA %d,%d;\n", pos.x, pos.y );
-
-    pen_lastpos = pos;
+    penControl( plume );
+    DPOINT pos_dev = userToDeviceCoordinates( pos );
+
+    if( penLastpos != pos )
+        fprintf( outputFile, "PA %.0f,%.0fd;\n", pos_dev.x, pos_dev.y );
+
+    penLastpos = pos;
 }
 
 
-void HPGL_PLOTTER::set_dash( bool dashed )
+/**
+ * HPGL supports dashed lines
+ */
+void HPGL_PLOTTER::SetDash( bool dashed )
 {
-    wxASSERT( output_file );
+    wxASSERT( outputFile );
     if( dashed )
         fputs( "LI 2;\n", stderr );
     else
@@ -197,27 +180,21 @@
 }
 
 
-/**
- * Function Plot a filled segment (track)
- * @param start = starting point
- * @param end = ending point
- * @param width = segment width (thickness)
- * @param tracemode = FILLED, SKETCH ..
- */
-void HPGL_PLOTTER::thick_segment( wxPoint start, wxPoint end, int width, EDA_DRAW_MODE_T tracemode )
+void HPGL_PLOTTER::ThickSegment( const wxPoint& start, const wxPoint& end, 
+                                 int width, EDA_DRAW_MODE_T tracemode )
 {
-    wxASSERT( output_file );
+    wxASSERT( outputFile );
     wxPoint center;
     wxSize  size;
 
-    if( (pen_diameter >= width) || (tracemode == LINE) )  /* just a line is
-                                                              * Ok */
+    // Suppress overlap if pen is too big or in line mode
+    if( (penDiameter >= width) || (tracemode == LINE) ) 
     {
-        move_to( start );
-        finish_to( end );
+        MoveTo( start );
+        FinishTo( end );
     }
     else
-        segment_as_oval( start, end, width, tracemode );
+        segmentAsOval( start, end, width, tracemode );
 }
 
 
@@ -229,48 +206,48 @@
  * PU PY x, y; PD start_arc_X AA, start_arc_Y, angle, NbSegm; PU;
  * Or PU PY x, y; PD start_arc_X AA, start_arc_Y, angle, PU;
  */
-void HPGL_PLOTTER::arc( wxPoint centre, int StAngle, int EndAngle, int rayon,
+void HPGL_PLOTTER::Arc( const wxPoint& centre, int StAngle, int EndAngle, int radius,
                         FILL_T fill, int width )
 {
-    wxASSERT( output_file );
-    wxPoint cmap;
-    wxPoint cpos;
-    float   angle;
+    wxASSERT( outputFile );
+    double angle;
 
-    if( rayon <= 0 )
+    if( radius <= 0 )
         return;
 
-    cpos = centre;
-    user_to_device_coordinates( cpos );
+    DPOINT centre_dev = userToDeviceCoordinates( centre );
 
     if( plotMirror )
         angle = (StAngle - EndAngle) / 10.0;
     else
         angle = (EndAngle - StAngle) / 10.0;
+
     // Calculate start point,
-    cmap.x = (int) ( centre.x + ( rayon * cos( StAngle * M_PI / 1800 ) ) );
-    cmap.y = (int) ( centre.y - ( rayon * sin( StAngle * M_PI / 1800 ) ) );
-    user_to_device_coordinates( cmap );
+    wxPoint cmap;
+    cmap.x = (int) ( centre.x + ( radius * cos( RAD2DEG( StAngle / 10.0 ) ) ) );
+    cmap.y = (int) ( centre.y - ( radius * sin( RAD2DEG( StAngle / 10.0 ) ) ) );
+    DPOINT cmap_dev = userToDeviceCoordinates( cmap );
 
-    fprintf( output_file,
-             "PU;PA %d,%d;PD;AA %d,%d, ",
-             cmap.x,
-             cmap.y,
-             cpos.x,
-             cpos.y );
-    fprintf( output_file, "%f", angle );
-    fprintf( output_file, ";PU;\n" );
-    pen_finish();
+    fprintf( outputFile,
+             "PU;PA %.0f,%.0f;PD;AA %.0f,%.0f,",
+             cmap_dev.x,
+             cmap_dev.y,
+             centre_dev.x,
+             centre_dev.y );
+    fprintf( outputFile, "%.0f", angle );
+    fprintf( outputFile, ";PU;\n" );
+    PenFinish();
 }
 
 
 /* Plot oval pad.
  */
-void HPGL_PLOTTER::flash_pad_oval( wxPoint pos, wxSize size, int orient,
-                                   EDA_DRAW_MODE_T trace_mode )
+void HPGL_PLOTTER::FlashPadOval( const wxPoint& pos, const wxSize& aSize, int orient,
+                                 EDA_DRAW_MODE_T trace_mode )
 {
-    wxASSERT( output_file );
+    wxASSERT( outputFile );
     int deltaxy, cx, cy;
+    wxSize size( aSize );
 
     /* The pad is reduced to an oval with size.y > size.x
      * (Oval vertical orientation 0)
@@ -285,82 +262,68 @@
 
     if( trace_mode == FILLED )
     {
-        flash_pad_rect( pos, wxSize( size.x, deltaxy + KiROUND( pen_diameter ) ),
-                        orient, trace_mode );
+        FlashPadRect( pos, wxSize( size.x, deltaxy + KiROUND( penDiameter ) ),
+                      orient, trace_mode );
         cx = 0; cy = deltaxy / 2;
         RotatePoint( &cx, &cy, orient );
-        flash_pad_circle( wxPoint( cx + pos.x,
-                                   cy + pos.y ), size.x, trace_mode );
+        FlashPadCircle( wxPoint( cx + pos.x, cy + pos.y ), size.x, trace_mode );
         cx = 0; cy = -deltaxy / 2;
         RotatePoint( &cx, &cy, orient );
-        flash_pad_circle( wxPoint( cx + pos.x,
-                                   cy + pos.y ), size.x, trace_mode );
+        FlashPadCircle( wxPoint( cx + pos.x, cy + pos.y ), size.x, trace_mode );
     }
     else    // Plot in SKETCH mode.
     {
-        sketch_oval( pos, size, orient, KiROUND( pen_diameter ) );
+        sketchOval( pos, size, orient, KiROUND( penDiameter ) );
     }
 }
 
 
 /* Plot round pad or via.
  */
-void HPGL_PLOTTER::flash_pad_circle( wxPoint pos, int diametre,
-                                     EDA_DRAW_MODE_T trace_mode )
+void HPGL_PLOTTER::FlashPadCircle( const wxPoint& pos, int diametre,
+                                   EDA_DRAW_MODE_T trace_mode )
 {
-    wxASSERT( output_file );
-    int rayon, delta;
-
-    user_to_device_coordinates( pos );
-
-    delta = KiROUND( pen_diameter - pen_overlap );
-    rayon = diametre / 2;
+    wxASSERT( outputFile );
+    DPOINT pos_dev = userToDeviceCoordinates( pos );
+
+    int delta = KiROUND( penDiameter - penOverlap );
+    int radius = diametre / 2;
 
     if( trace_mode != LINE )
     {
-        rayon = ( diametre - KiROUND( pen_diameter ) ) / 2;
+        radius = ( diametre - KiROUND( penDiameter ) ) / 2;
     }
 
-    if( rayon < 0 )
+    if( radius < 0 )
     {
-        rayon = 0;
+        radius = 0;
     }
-    wxSize rsize( rayon, rayon );
-
-    user_to_device_size( rsize );
-
-    fprintf( output_file, "PA %d,%d;CI %d;\n", pos.x, pos.y, rsize.x );
+
+    double rsize = userToDeviceSize( radius );
+
+    fprintf( outputFile, "PA %.0f,%.0fd;CI %.0f;\n", 
+             pos_dev.x, pos_dev.y, rsize );
 
     if( trace_mode == FILLED )        // Plot in filled mode.
     {
         if( delta > 0 )
         {
-            while( (rayon -= delta ) >= 0 )
+            while( (radius -= delta ) >= 0 )
             {
-                rsize.x = rsize.y = rayon;
-                user_to_device_size( rsize );
-                fprintf( output_file,
-                         "PA %d,%d; CI %d;\n",
-                         pos.x,
-                         pos.y,
-                         rsize.x );
+                rsize = userToDeviceSize( radius );
+                fprintf( outputFile, "PA %.0f,%.0f;CI %.0f;\n",
+                         pos_dev.x, pos_dev.y, rsize );
             }
         }
     }
-    pen_finish();
-    return;
+    PenFinish();
 }
 
 
-/*
- * Plot rectangular pad vertical or horizontal.
- * Gives its center and its dimensions X and Y
- * Units are user units
- */
-void HPGL_PLOTTER::flash_pad_rect( wxPoint pos, wxSize padsize,
-                                   int orient, EDA_DRAW_MODE_T trace_mode )
+void HPGL_PLOTTER::FlashPadRect( const wxPoint& pos, const wxSize& padsize,
+                                 int orient, EDA_DRAW_MODE_T trace_mode )
 {
-    wxASSERT( output_file );
+    wxASSERT( outputFile );
     wxSize size;
     int    delta;
     int    ox, oy, fx, fy;
@@ -370,8 +333,8 @@
 
     if( trace_mode != LINE )
     {
-        size.x = (padsize.x - (int) pen_diameter) / 2;
-        size.y = (padsize.y - (int) pen_diameter) / 2;
+        size.x = (padsize.x - (int) penDiameter) / 2;
+        size.y = (padsize.y - (int) penDiameter) / 2;
     }
 
     if( size.x < 0 )
@@ -388,8 +351,8 @@
         fx = pos.x;
         fy = pos.y + size.y;
         RotatePoint( &fx, &fy, pos.x, pos.y, orient );
-        move_to( wxPoint( ox, oy ) );
-        finish_to( wxPoint( fx, fy ) );
+        MoveTo( wxPoint( ox, oy ) );
+        FinishTo( wxPoint( fx, fy ) );
         return;
     }
     if( size.y == 0 )
@@ -400,37 +363,37 @@
         fx = pos.x + size.x;
         fy = pos.y;
         RotatePoint( &fx, &fy, pos.x, pos.y, orient );
-        move_to( wxPoint( ox, oy ) );
-        finish_to( wxPoint( fx, fy ) );
+        MoveTo( wxPoint( ox, oy ) );
+        FinishTo( wxPoint( fx, fy ) );
         return;
     }
 
     ox = pos.x - size.x;
     oy = pos.y - size.y;
     RotatePoint( &ox, &oy, pos.x, pos.y, orient );
-    move_to( wxPoint( ox, oy ) );
+    MoveTo( wxPoint( ox, oy ) );
 
     fx = pos.x - size.x;
     fy = pos.y + size.y;
     RotatePoint( &fx, &fy, pos.x, pos.y, orient );
-    line_to( wxPoint( fx, fy ) );
+    LineTo( wxPoint( fx, fy ) );
 
     fx = pos.x + size.x;
     fy = pos.y + size.y;
     RotatePoint( &fx, &fy, pos.x, pos.y, orient );
-    line_to( wxPoint( fx, fy ) );
+    LineTo( wxPoint( fx, fy ) );
 
     fx = pos.x + size.x;
     fy = pos.y - size.y;
     RotatePoint( &fx, &fy, pos.x, pos.y, orient );
-    line_to( wxPoint( fx, fy ) );
+    LineTo( wxPoint( fx, fy ) );
 
-    finish_to( wxPoint( ox, oy ) );
+    FinishTo( wxPoint( ox, oy ) );
 
     if( trace_mode == FILLED )
     {
         // Plot in filled mode.
-        delta = (int) (pen_diameter - pen_overlap);
+        delta = (int) (penDiameter - penOverlap);
 
         if( delta > 0 )
             while( (size.x > 0) && (size.y > 0) )
@@ -446,44 +409,39 @@
                 ox = pos.x - size.x;
                 oy = pos.y - size.y;
                 RotatePoint( &ox, &oy, pos.x, pos.y, orient );
-                move_to( wxPoint( ox, oy ) );
+                MoveTo( wxPoint( ox, oy ) );
 
                 fx = pos.x - size.x;
                 fy = pos.y + size.y;
                 RotatePoint( &fx, &fy, pos.x, pos.y, orient );
-                line_to( wxPoint( fx, fy ) );
+                LineTo( wxPoint( fx, fy ) );
 
                 fx = pos.x + size.x;
                 fy = pos.y + size.y;
                 RotatePoint( &fx, &fy, pos.x, pos.y, orient );
-                line_to( wxPoint( fx, fy ) );
+                LineTo( wxPoint( fx, fy ) );
 
                 fx = pos.x + size.x;
                 fy = pos.y - size.y;
                 RotatePoint( &fx, &fy, pos.x, pos.y, orient );
-                line_to( wxPoint( fx, fy ) );
+                LineTo( wxPoint( fx, fy ) );
 
-                finish_to( wxPoint( ox, oy ) );
+                FinishTo( wxPoint( ox, oy ) );
             }
 
     }
 }
 
 
-/* Plot trapezoidal pad.
- * aPadPos is pad position, aCorners the corners position of the basic shape
- * Orientation aPadOrient in 0.1 degrees
- * Plot mode FILLED or SKETCH
- */
-void HPGL_PLOTTER::flash_pad_trapez( wxPoint aPadPos, wxPoint aCorners[4],
-                                     int aPadOrient, EDA_DRAW_MODE_T aTrace_Mode )
+void HPGL_PLOTTER::FlashPadTrapez( const wxPoint& aPadPos, const wxPoint *aCorners,
+                                   int aPadOrient, EDA_DRAW_MODE_T aTrace_Mode )
 {
-    wxASSERT( output_file );
+    wxASSERT( outputFile );
     wxPoint polygone[4];        // coordinates of corners relatives to the pad
     wxPoint coord[4];           // absolute coordinates of corners (coordinates in plotter space)
     int     move;
 
-    move = KiROUND( pen_diameter );
+    move = KiROUND( penDiameter );
 
     for( int ii = 0; ii < 4; ii++ )
         polygone[ii] = aCorners[ii];
@@ -500,11 +458,11 @@
         RotatePoint( &coord[ii], aPadOrient );
         coord[ii] += aPadPos;
     }
-    move_to( coord[0] );
-    line_to( coord[1] );
-    line_to( coord[2] );
-    line_to( coord[3] );
-    finish_to( coord[0] );
+    MoveTo( coord[0] );
+    LineTo( coord[1] );
+    LineTo( coord[2] );
+    LineTo( coord[3] );
+    FinishTo( coord[0] );
 
     // Fill shape:
     if( aTrace_Mode == FILLED )
@@ -512,20 +470,20 @@
         // TODO: replace this par the HPGL plot polygon.
         int jj;
         // Fill the shape
-        move = KiROUND( pen_diameter - pen_overlap );
+        move = KiROUND( penDiameter - penOverlap );
         // Calculate fill height.
 
         if( polygone[0].y == polygone[3].y ) // Horizontal
         {
-            jj = polygone[3].y - (int) ( pen_diameter + ( 2 * pen_overlap ) );
+            jj = polygone[3].y - (int) ( penDiameter + ( 2 * penOverlap ) );
         }
         else    // vertical
         {
-            jj = polygone[3].x - (int) ( pen_diameter + ( 2 * pen_overlap ) );
+            jj = polygone[3].x - (int) ( penDiameter + ( 2 * penOverlap ) );
         }
 
         // Calculation of dd = number of segments was traced to fill.
-        jj = jj / (int) ( pen_diameter - pen_overlap );
+        jj = jj / (int) ( penDiameter - penOverlap );
 
         // Trace the outline.
         for( ; jj > 0; jj-- )
@@ -568,11 +526,12 @@
                 coord[ii] += aPadPos;
             }
 
-            move_to( coord[0] );
-            line_to( coord[1] );
-            line_to( coord[2] );
-            line_to( coord[3] );
-            finish_to( coord[0] );
+            MoveTo( coord[0] );
+            LineTo( coord[1] );
+            LineTo( coord[2] );
+            LineTo( coord[3] );
+            FinishTo( coord[0] );
         }
     }
 }
+

=== modified file 'common/common_plotPS_functions.cpp'
--- common/common_plotPS_functions.cpp	2012-04-19 06:55:45 +0000
+++ common/common_plotPS_functions.cpp	2012-04-30 09:18:58 +0000
@@ -12,74 +12,78 @@
 #include <macros.h>
 #include <kicad_string.h>
 
-
-/* Set the plot offset for the current plotting */
-void PS_PLOTTER::set_viewport( wxPoint aOffset, double aScale, bool aMirror )
+void PS_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
+			      double aScale, bool aMirror )
 {
-    wxASSERT( !output_file );
+    wxASSERT( !outputFile );
     plotMirror = aMirror;
-    plot_offset  = aOffset;
-    plot_scale   = aScale;
-    device_scale = 1;               /* PS references in decimals */
-    set_default_line_width( 100 );  /* default line width in 1/1000 inch */
-}
-
-
-/* Set the default line width (in 1/1000 inch) for the current plotting
- */
-void PS_PLOTTER::set_default_line_width( int width )
-{
-    default_pen_width = width;   // line width in 1/1000 inch
-    current_pen_width = -1;
-}
-
-
-/* Set the current line width (in 1/1000 inch) for the next plot
- */
-void PS_PLOTTER::set_current_line_width( int width )
-{
-    wxASSERT( output_file );
+    plotOffset = aOffset;
+    plotScale = aScale;
+    iuPerDeviceUnit = 1.0 / aIusPerDecimil; 
+    /* Compute the paper size in IUs */
+    paperSize = pageInfo.GetSizeMils();
+    paperSize.x *= 10.0 * aIusPerDecimil;
+    paperSize.y *= 10.0 * aIusPerDecimil;
+    SetDefaultLineWidth( 100 * aIusPerDecimil );  // arbitrary default
+}
+
+
+/* Set the default line width (in IUs) for the current plotting
+ */
+void PS_PLOTTER::SetDefaultLineWidth( int width )
+{
+    defaultPenWidth = width;
+    currentPenWidth = -1;
+}
+
+
+/* Set the current line width (in IUs) for the next plot
+ */
+void PS_PLOTTER::SetCurrentLineWidth( int width )
+{
+    wxASSERT( outputFile );
     int pen_width;
 
     if( width >= 0 )
         pen_width = width;
     else
-        pen_width = default_pen_width;
-
-    if( pen_width != current_pen_width )
-        fprintf( output_file, "%g setlinewidth\n",
-                 user_to_device_size( pen_width ) );
-
-    current_pen_width = pen_width;
+        pen_width = defaultPenWidth;
+
+    if( pen_width != currentPenWidth )
+        fprintf( outputFile, "%g setlinewidth\n",
+                 userToDeviceSize( pen_width ) );
+
+    currentPenWidth = pen_width;
 }
 
 
-/* Print the postscript set color command:
+/**
+ * Emit the postscript set color command:
  * r g b setrgbcolor,
  * r, g, b  = color values (= 0 .. 1.0 )
  *
  * color = color index in ColorRefs[]
  */
-void PS_PLOTTER::set_color( int color )
+void PS_PLOTTER::SetColor( EDA_COLOR_T color )
 {
-    wxASSERT( output_file );
+    wxASSERT( outputFile );
 
-    /* Return at invalid color index */
+    // Return at invalid color index 
     if( color < 0 )
         return;
 
-    if( color_mode )
+    if( colorMode )
     {
-        if( negative_mode )
+        if( negativeMode )
         {
-            fprintf( output_file, "%.3g %.3g %.3g setrgbcolor\n",
+            fprintf( outputFile, "%.3g %.3g %.3g setrgbcolor\n",
                      (double) 1.0 - ColorRefs[color].m_Red / 255,
                      (double) 1.0 - ColorRefs[color].m_Green / 255,
                      (double) 1.0 - ColorRefs[color].m_Blue / 255 );
         }
         else
         {
-            fprintf( output_file, "%.3g %.3g %.3g setrgbcolor\n",
+            fprintf( outputFile, "%.3g %.3g %.3g setrgbcolor\n",
                      (double) ColorRefs[color].m_Red / 255,
                      (double) ColorRefs[color].m_Green / 255,
                      (double) ColorRefs[color].m_Blue / 255 );
@@ -94,130 +98,114 @@
         int bwcolor = WHITE;
         if( color != WHITE )
             bwcolor = BLACK;
-        if( negative_mode )
-            fprintf( output_file, "%.3g %.3g %.3g setrgbcolor\n",
+        if( negativeMode )
+            fprintf( outputFile, "%.3g %.3g %.3g setrgbcolor\n",
                      (double) 1.0 - ColorRefs[bwcolor].m_Red / 255,
                      (double) 1.0 - ColorRefs[bwcolor].m_Green / 255,
                      (double) 1.0 - ColorRefs[bwcolor].m_Blue / 255 );
         else
-            fprintf( output_file, "%.3g %.3g %.3g setrgbcolor\n",
+            fprintf( outputFile, "%.3g %.3g %.3g setrgbcolor\n",
                      (double) ColorRefs[bwcolor].m_Red / 255,
                      (double) ColorRefs[bwcolor].m_Green / 255,
                      (double) ColorRefs[bwcolor].m_Blue / 255 );
     }
 }
 
-
-void PS_PLOTTER::set_dash( bool dashed )
+/**
+ * Postscript supports dashed lines
+ * (but for some reason (probably scale) it doesn't work...
+ * XXX fix me in the PS prologue
+ */
+void PS_PLOTTER::SetDash( bool dashed )
 {
-    wxASSERT( output_file );
+    wxASSERT( outputFile );
     if( dashed )
-        fputs( "dashedline\n", stderr );
+        fputs( "dashedline\n", outputFile );
     else
-        fputs( "solidline\n", stderr );
-}
-
-
-void PS_PLOTTER::rect( wxPoint p1, wxPoint p2, FILL_T fill, int width )
-{
-    user_to_device_coordinates( p1 );
-    user_to_device_coordinates( p2 );
-
-    set_current_line_width( width );
-    fprintf( output_file, "%d %d %d %d rect%d\n", p1.x, p1.y,
-             p2.x - p1.x, p2.y - p1.y, fill );
-}
-
-
-void PS_PLOTTER::circle( wxPoint pos, int diametre, FILL_T fill, int width )
-{
-    wxASSERT( output_file );
-    user_to_device_coordinates( pos );
-    double radius = user_to_device_size( diametre / 2.0 );
-
-    if( radius < 1 )
-        radius = 1;
-
-    set_current_line_width( width );
-    fprintf( output_file, "%d %d %g cir%d\n", pos.x, pos.y, radius, fill );
-}
-
-
-/* Plot an arc:
- * StAngle, EndAngle = start and end arc in 0.1 degree
- */
-void PS_PLOTTER::arc( wxPoint centre, int StAngle, int EndAngle, int radius,
+        fputs( "solidline\n", outputFile );
+}
+
+
+void PS_PLOTTER::Rect( const wxPoint& p1, const wxPoint& p2, FILL_T fill, int width )
+{
+    DPOINT p1_dev = userToDeviceCoordinates( p1 );
+    DPOINT p2_dev = userToDeviceCoordinates( p2 );
+
+    SetCurrentLineWidth( width );
+    fprintf( outputFile, "%g %g %g %g rect%d\n", p1_dev.x, p1_dev.y,
+             p2_dev.x - p1_dev.x, p2_dev.y - p1_dev.y, fill );
+}
+
+
+void PS_PLOTTER::Circle( const wxPoint& pos, int diametre, FILL_T fill, int width )
+{
+    wxASSERT( outputFile );
+    DPOINT pos_dev = userToDeviceCoordinates( pos );
+    double radius = userToDeviceSize( diametre / 2.0 );
+
+    SetCurrentLineWidth( width );
+    fprintf( outputFile, "%g %g %g cir%d\n", pos_dev.x, pos_dev.y, radius, fill );
+}
+
+
+void PS_PLOTTER::Arc( const wxPoint& centre, int StAngle, int EndAngle, int radius,
                       FILL_T fill, int width )
 {
-    wxASSERT( output_file );
+    wxASSERT( outputFile );
     if( radius <= 0 )
         return;
 
     if( StAngle > EndAngle )
         EXCHG( StAngle, EndAngle );
 
-    set_current_line_width( width );
+    SetCurrentLineWidth( width );
 
     // Calculate start point.
-    user_to_device_coordinates( centre );
-    radius = KiROUND( user_to_device_size( radius ) );
+    DPOINT centre_dev = userToDeviceCoordinates( centre );
+    double radius_dev = userToDeviceSize( radius );
     if( plotMirror )
-        fprintf( output_file, "%d %d %d %g %g arc%d\n", centre.x, centre.y,
-                 radius, (double) -EndAngle / 10, (double) -StAngle / 10,
+        fprintf( outputFile, "%g %g %g %g %g arc%d\n", centre_dev.x, centre_dev.y,
+                 radius_dev, -EndAngle / 10.0, -StAngle / 10.0,
                  fill );
     else
-        fprintf( output_file, "%d %d %d %g %g arc%d\n", centre.x, centre.y,
-                 radius, (double) StAngle / 10, (double) EndAngle / 10,
+        fprintf( outputFile, "%g %g %g %g %g arc%d\n", centre_dev.x, centre_dev.y,
+                 radius_dev, StAngle / 10.0, EndAngle / 10.0,
                  fill );
 }
 
 
-/*
- * Function PlotPoly
- * Draw a polygon (filled or not) in POSTSCRIPT format
- * param aCornerList = corners list
- * param aFill :if true : filled polygon
- * param aWidth = line width
- */
-void PS_PLOTTER::PlotPoly( std::vector< wxPoint >& aCornerList, FILL_T aFill, int aWidth )
+void PS_PLOTTER::PlotPoly( const std::vector< wxPoint >& aCornerList, 
+                           FILL_T aFill, int aWidth )
 {
     if( aCornerList.size() <= 1 )
         return;
 
-    set_current_line_width( aWidth );
+    SetCurrentLineWidth( aWidth );
 
-    wxPoint pos = aCornerList[0];
-    user_to_device_coordinates( pos );
-    fprintf( output_file, "newpath\n%d %d moveto\n", pos.x, pos.y );
+    DPOINT pos = userToDeviceCoordinates( aCornerList[0] );
+    fprintf( outputFile, "newpath\n%g %g moveto\n", pos.x, pos.y );
 
     for( unsigned ii = 1; ii < aCornerList.size(); ii++ )
     {
-        pos = aCornerList[ii];
-        user_to_device_coordinates( pos );
-        fprintf( output_file, "%d %d lineto\n", pos.x, pos.y );
+        pos = userToDeviceCoordinates( aCornerList[ii] );
+        fprintf( outputFile, "%g %g lineto\n", pos.x, pos.y );
     }
 
     // Close path
-    fprintf( output_file, "poly%d\n", aFill );
+    fprintf( outputFile, "poly%d\n", aFill );
 }
 
-/*
- * Function PlotImage
- * Only some plotters can plot image bitmaps
- * for plotters that cannot plot a bitmap, a rectangle is plotted
- * param aImage = the bitmap
- * param aPos = position of the center of the bitmap
- * param aScaleFactor = the scale factor to apply to the bitmap size
- *                      (this is not the plot scale factor)
+/**
+ * Postscript at the moment is the only plot engine supporting bitmaps...
  */
-void PS_PLOTTER::PlotImage( wxImage & aImage, wxPoint aPos, double aScaleFactor )
+void PS_PLOTTER::PlotImage( const wxImage & aImage, const wxPoint& aPos, 
+                            double aScaleFactor )
 {
     wxSize pix_size;                // size of the bitmap in pixels
     pix_size.x = aImage.GetWidth();
     pix_size.y = aImage.GetHeight();
-    wxSize drawsize;                // requested size of image
-    drawsize.x = KiROUND( aScaleFactor * pix_size.x );
-    drawsize.y = KiROUND( aScaleFactor * pix_size.y );
+    DPOINT drawsize( aScaleFactor * pix_size.x,
+                     aScaleFactor * pix_size.y ); // requested size of image
 
     // calculate the bottom left corner position of bitmap
     wxPoint start = aPos;
@@ -229,25 +217,25 @@
     end.x = start.x + drawsize.x;
     end.y = start.y - drawsize.y;
 
-    fprintf( output_file, "/origstate save def\n" );
-    fprintf( output_file, "/pix %d string def\n", pix_size.x );
-    fprintf( output_file, "/greys %d string def\n", pix_size.x );
+    fprintf( outputFile, "/origstate save def\n" );
+    fprintf( outputFile, "/pix %d string def\n", pix_size.x );
+    fprintf( outputFile, "/greys %d string def\n", pix_size.x );
 
     // Locate lower-left corner of image
-    user_to_device_coordinates( start );
-    fprintf( output_file, "%d %d translate\n", start.x, start.y );
+    DPOINT start_dev = userToDeviceCoordinates( start );
+    fprintf( outputFile, "%g %g translate\n", start_dev.x, start_dev.y );
     // Map image size to device
-    user_to_device_coordinates( end );
-    fprintf( output_file, "%d %d scale\n",
-            ABS(end.x - start.x), ABS(end.y - start.y));
+    DPOINT end_dev = userToDeviceCoordinates( end );
+    fprintf( outputFile, "%g %g scale\n",
+            ABS(end_dev.x - start_dev.x), ABS(end_dev.y - start_dev.y));
 
     // Dimensions of source image (in pixels
-    fprintf( output_file, "%d %d 8", pix_size.x, pix_size.y );
+    fprintf( outputFile, "%d %d 8", pix_size.x, pix_size.y );
     //  Map unit square to source
-    fprintf( output_file, " [%d 0 0 %d 0 %d]\n", pix_size.x, -pix_size.y , pix_size.y);
+    fprintf( outputFile, " [%d 0 0 %d 0 %d]\n", pix_size.x, -pix_size.y , pix_size.y);
     // include image data in ps file
-    fprintf( output_file, "{currentfile pix readhexstring pop}\n" );
-    fprintf( output_file, "false 3 colorimage\n");
+    fprintf( outputFile, "{currentfile pix readhexstring pop}\n" );
+    fprintf( outputFile, "false 3 colorimage\n");
     // Single data source, 3 colors, Output RGB data (hexadecimal)
     int jj = 0;
     for( int yy = 0; yy < pix_size.y; yy ++ )
@@ -257,55 +245,53 @@
             if( jj >= 16 )
             {
                 jj = 0;
-                fprintf( output_file, "\n");
+                fprintf( outputFile, "\n");
             }
             int red, green, blue;
             red = aImage.GetRed( xx, yy) & 0xFF;
             green = aImage.GetGreen( xx, yy) & 0xFF;
             blue = aImage.GetBlue( xx, yy) & 0xFF;
-            fprintf( output_file, "%2.2X%2.2X%2.2X", red, green, blue);
+            fprintf( outputFile, "%2.2X%2.2X%2.2X", red, green, blue);
         }
     }
-    fprintf( output_file, "\n");
-    fprintf( output_file, "origstate restore\n" );
+    fprintf( outputFile, "\n");
+    fprintf( outputFile, "origstate restore\n" );
 }
 
 
-
-/* Routine to draw to a new position
- */
-void PS_PLOTTER::pen_to( wxPoint pos, char plume )
+void PS_PLOTTER::PenTo( const wxPoint& pos, char plume )
 {
-    wxASSERT( output_file );
+    wxASSERT( outputFile );
     if( plume == 'Z' )
     {
-        if( pen_state != 'Z' )
+        if( penState != 'Z' )
         {
-            fputs( "stroke\n", output_file );
-            pen_state     = 'Z';
-            pen_lastpos.x = -1;
-            pen_lastpos.y = -1;
+            fputs( "stroke\n", outputFile );
+            penState     = 'Z';
+            penLastpos.x = -1;
+            penLastpos.y = -1;
         }
         return;
     }
 
-    user_to_device_coordinates( pos );
-    if( pen_state == 'Z' )
+    if( penState == 'Z' )
     {
-        fputs( "newpath\n", output_file );
+        fputs( "newpath\n", outputFile );
     }
-    if( pen_state != plume || pos != pen_lastpos )
-        fprintf( output_file,
-                 "%d %d %sto\n",
-                 pos.x,
-                 pos.y,
+    if( penState != plume || pos != penLastpos )
+    {
+	DPOINT pos_dev = userToDeviceCoordinates( pos );
+        fprintf( outputFile, "%g %g %sto\n",
+                 pos_dev.x, pos_dev.y,
                  ( plume=='D' ) ? "line" : "move" );
-    pen_state   = plume;
-    pen_lastpos = pos;
+    }
+    penState   = plume;
+    penLastpos = pos;
 }
 
 
-/* The code within this function (and the CloseFilePS function)
+/** 
+ * The code within this function (and the CloseFilePS function)
  * creates postscript files whose contents comply with Adobe's
  * Document Structuring Convention, as documented by assorted
  * details described within the following URLs:
@@ -317,72 +303,71 @@
  * BBox is the boundary box (position and size of the "client rectangle"
  * for drawings (page - margins) in mils (0.001 inch)
  */
-bool PS_PLOTTER::start_plot( FILE* fout )
+bool PS_PLOTTER::StartPlot( FILE* fout )
 {
-    wxASSERT( !output_file );
+    wxASSERT( !outputFile );
     wxString           msg;
 
-    output_file = fout;
+    outputFile = fout;
     static const char* PSMacro[] =
     {
-        "/line {\n",
-        "    newpath\n",
-        "    moveto\n",
-        "    lineto\n",
-        "    stroke\n",
-        "} bind def\n",
-        "/cir0 { newpath 0 360 arc stroke } bind def\n",
-        "/cir1 { newpath 0 360 arc gsave fill grestore stroke } bind def\n",
-        "/cir2 { newpath 0 360 arc gsave fill grestore stroke } bind def\n",
-        "/arc0 { newpath arc stroke } bind def\n",
-        "/arc1 { newpath 4 index 4 index moveto arc closepath gsave fill ",
-        "grestore stroke } bind def\n",
-        "/arc2 { newpath 4 index 4 index moveto arc closepath gsave fill ",
-        "grestore stroke } bind def\n",
-        "/poly0 { stroke } bind def\n",
-        "/poly1 { closepath gsave fill grestore stroke } bind def\n",
-        "/poly2 { closepath gsave fill grestore stroke } bind def\n",
-        "/rect0 { rectstroke } bind def\n",
-        "/rect1 { rectfill } bind def\n",
-        "/rect2 { rectfill } bind def\n",
-        "/linemode0 { 0 setlinecap 0 setlinejoin 0 setlinewidth } bind def\n",
-        "/linemode1 { 1 setlinecap 1 setlinejoin } bind def\n",
-        "/dashedline { [50 50] 0 setdash } bind def\n",
-        "/solidline { [] 0 setdash } bind def\n",
-        "gsave\n",
-        "0.0072 0.0072 scale\n",   // Configure postscript for decimals.
-        "linemode1\n",
-        NULL
+	"/line {\n",
+	"    newpath\n",
+	"    moveto\n",
+	"    lineto\n",
+	"    stroke\n",
+	"} bind def\n",
+	"/cir0 { newpath 0 360 arc stroke } bind def\n",
+	"/cir1 { newpath 0 360 arc gsave fill grestore stroke } bind def\n",
+	"/cir2 { newpath 0 360 arc gsave fill grestore stroke } bind def\n",
+	"/arc0 { newpath arc stroke } bind def\n",
+	"/arc1 { newpath 4 index 4 index moveto arc closepath gsave fill ",
+	"grestore stroke } bind def\n",
+	"/arc2 { newpath 4 index 4 index moveto arc closepath gsave fill ",
+	"grestore stroke } bind def\n",
+	"/poly0 { stroke } bind def\n",
+	"/poly1 { closepath gsave fill grestore stroke } bind def\n",
+	"/poly2 { closepath gsave fill grestore stroke } bind def\n",
+	"/rect0 { rectstroke } bind def\n",
+	"/rect1 { rectfill } bind def\n",
+	"/rect2 { rectfill } bind def\n",
+	"/linemode0 { 0 setlinecap 0 setlinejoin 0 setlinewidth } bind def\n",
+	"/linemode1 { 1 setlinecap 1 setlinejoin } bind def\n",
+	"/dashedline { [50 50] 0 setdash } bind def\n",
+	"/solidline { [] 0 setdash } bind def\n",
+	"gsave\n",
+	"0.0072 0.0072 scale\n",   // Configure postscript for decimils coordinates
+	"linemode1\n",
+	NULL
     };
 
-    const double       DECIMIL_TO_INCH = 0.0001;
-    time_t             time1970 = time( NULL );
-
-    fputs( "%!PS-Adobe-3.0\n", output_file );    // Print header
-
-    fprintf( output_file, "%%%%Creator: %s\n", TO_UTF8( creator ) );
-
-    // A "newline" character ("\n") is not included in the following string,
-    // because it is provided by the ctime() function.
-    fprintf( output_file, "%%%%CreationDate: %s", ctime( &time1970 ) );
-    fprintf( output_file, "%%%%Title: %s\n", TO_UTF8( filename ) );
-    fprintf( output_file, "%%%%Pages: 1\n" );
-    fprintf( output_file, "%%%%PageOrder: Ascend\n" );
-
-    // Print boundary box in 1/72 pixels per inch, box is in deci-mils
-    const double CONV_SCALE = DECIMIL_TO_INCH * 72;
-
-    // The coordinates of the lower left corner of the boundary
-    // box need to be "rounded down", but the coordinates of its
-    // upper right corner need to be "rounded up" instead.
-    wxSize  psPaperSize = paper_size;
+    time_t time1970 = time( NULL );
+
+    fputs( "%!PS-Adobe-3.0\n", outputFile );    // Print header
+
+    fprintf( outputFile, "%%%%Creator: %s\n", TO_UTF8( creator ) );
+
+    /* A "newline" character ("\n") is not included in the following string,
+       because it is provided by the ctime() function. */
+    fprintf( outputFile, "%%%%CreationDate: %s", ctime( &time1970 ) );
+    fprintf( outputFile, "%%%%Title: %s\n", TO_UTF8( filename ) );
+    fprintf( outputFile, "%%%%Pages: 1\n" );
+    fprintf( outputFile, "%%%%PageOrder: Ascend\n" );
+
+    // Print boundary box in 1/72 pixels per inch, box is in mils
+    const double BIGPTsPERMIL = 0.072;
+
+    /* The coordinates of the lower left corner of the boundary
+       box need to be "rounded down", but the coordinates of its
+       upper right corner need to be "rounded up" instead. */
+    wxSize psPaperSize = pageInfo.GetSizeMils();
 
     if( !pageInfo.IsPortrait() )
-        psPaperSize.Set( paper_size.y, paper_size.x );
-
-    fprintf( output_file, "%%%%BoundingBox: 0 0 %d %d\n",
-            (int) ceil( psPaperSize.x * CONV_SCALE ),
-            (int) ceil( psPaperSize.y * CONV_SCALE ) );
+        psPaperSize.Set( pageInfo.GetHeightMils(), pageInfo.GetWidthMils() );
+    
+    fprintf( outputFile, "%%%%BoundingBox: 0 0 %d %d\n",
+	    (int) ceil( psPaperSize.x * BIGPTsPERMIL ),
+	    (int) ceil( psPaperSize.y * BIGPTsPERMIL ) );
 
     // Specify the size of the sheet and the name associated with that size.
     // (If the "User size" option has been selected for the sheet size,
@@ -398,28 +383,24 @@
     // the order in which they are specified is not wrong!)
     // Also note pageSize is given in mils, not in internal units and must be
     // converted to internal units.
-    wxSize psPageSize = pageInfo.GetSizeMils();
-
-    if( !pageInfo.IsPortrait() )
-        psPageSize.Set( pageInfo.GetHeightMils(), pageInfo.GetWidthMils() );
 
     if( pageInfo.IsCustom() )
-        fprintf( output_file, "%%%%DocumentMedia: Custom %d %d 0 () ()\n",
-                 KiROUND( psPageSize.x * 10 * CONV_SCALE ),
-                 KiROUND( psPageSize.y * 10 * CONV_SCALE ) );
+        fprintf( outputFile, "%%%%DocumentMedia: Custom %d %d 0 () ()\n",
+                 KiROUND( psPaperSize.x * BIGPTsPERMIL ),
+                 KiROUND( psPaperSize.y * BIGPTsPERMIL ) );
 
     else  // a standard paper size
-        fprintf( output_file, "%%%%DocumentMedia: %s %d %d 0 () ()\n",
+        fprintf( outputFile, "%%%%DocumentMedia: %s %d %d 0 () ()\n",
                  TO_UTF8( pageInfo.GetType() ),
-                 KiROUND( psPageSize.x * 10 * CONV_SCALE ),
-                 KiROUND( psPageSize.y * 10 * CONV_SCALE ) );
+                 KiROUND( psPaperSize.x * BIGPTsPERMIL ),
+                 KiROUND( psPaperSize.y * BIGPTsPERMIL ) );
 
     if( pageInfo.IsPortrait() )
-        fprintf( output_file, "%%%%Orientation: Portrait\n" );
+        fprintf( outputFile, "%%%%Orientation: Portrait\n" );
     else
-        fprintf( output_file, "%%%%Orientation: Landscape\n" );
+        fprintf( outputFile, "%%%%Orientation: Landscape\n" );
 
-    fprintf( output_file, "%%%%EndComments\n" );
+    fprintf( outputFile, "%%%%EndComments\n" );
 
     // Now specify various other details.
 
@@ -427,54 +408,47 @@
     // PSMacro[]) to highlight that it has been provided to ensure that the
     // contents of the postscript file comply with the details specified
     // within the Document Structuring Convention.
-    fprintf( output_file, "%%%%Page: 1 1\n" );
+    fprintf( outputFile, "%%%%Page: 1 1\n" );
 
     for( int ii = 0; PSMacro[ii] != NULL; ii++ )
     {
-        fputs( PSMacro[ii], output_file );
+        fputs( PSMacro[ii], outputFile );
     }
 
-    // (If support for creating postscript files with a portrait orientation
-    // is ever provided, determine whether it would be necessary to provide
-    // an "else" command and then an appropriate "sprintf" command here.)
+    // Rototranslate the coordinate to achieve the landscape layout 
     if( !pageInfo.IsPortrait() )
-        fprintf( output_file, "%d 0 translate 90 rotate\n", paper_size.y );
-
-    // Apply the scale adjustments
-    if( plot_scale_adjX != 1.0 || plot_scale_adjY != 1.0 )
-        fprintf( output_file, "%g %g scale\n",
-                 plot_scale_adjX, plot_scale_adjY );
-
-    // Set default line width ( g_Plot_DefaultPenWidth is in user units )
-    fprintf( output_file, "%g setlinewidth\n",
-             user_to_device_size( default_pen_width ) );
+        fprintf( outputFile, "%d 0 translate 90 rotate\n", 10 * psPaperSize.x );
+
+    // Apply the user fine scale adjustments
+    if( plotScaleAdjX != 1.0 || plotScaleAdjY != 1.0 )
+        fprintf( outputFile, "%g %g scale\n",
+                 plotScaleAdjX, plotScaleAdjY );
+
+    // Set default line width 
+    fprintf( outputFile, "%g setlinewidth\n",
+             userToDeviceSize( defaultPenWidth ) );
 
     return true;
 }
 
 
-bool PS_PLOTTER::end_plot()
+bool PS_PLOTTER::EndPlot()
 {
-    wxASSERT( output_file );
-    fputs( "showpage\ngrestore\n%%EOF\n", output_file );
-    fclose( output_file );
-    output_file = NULL;
+    wxASSERT( outputFile );
+    fputs( "showpage\ngrestore\n%%EOF\n", outputFile );
+    fclose( outputFile );
+    outputFile = NULL;
 
     return true;
 }
 
 
-/* Plot oval pad:
- * pos - Position of pad.
- * Dimensions dx, dy,
- * Orient Orient
- * The shape is drawn as a segment
- */
-void PS_PLOTTER::flash_pad_oval( wxPoint pos, wxSize size, int orient,
+void PS_PLOTTER::FlashPadOval( const wxPoint& pos, const wxSize& aSize, int orient,
                                  EDA_DRAW_MODE_T modetrace )
 {
-    wxASSERT( output_file );
+    wxASSERT( outputFile );
     int x0, y0, x1, y1, delta;
+    wxSize size( aSize );
 
     // The pad is reduced to an oval by dy > dx
     if( size.x > size.y )
@@ -494,45 +468,42 @@
     RotatePoint( &x1, &y1, orient );
 
     if( modetrace == FILLED )
-        thick_segment( wxPoint( pos.x + x0, pos.y + y0 ),
-                       wxPoint( pos.x + x1, pos.y + y1 ), size.x, modetrace );
+        ThickSegment( wxPoint( pos.x + x0, pos.y + y0 ),
+                      wxPoint( pos.x + x1, pos.y + y1 ), size.x, modetrace );
     else
-        sketch_oval( pos, size, orient, -1 );
+        sketchOval( pos, size, orient, -1 );
 }
 
 
-/* Plot round pad or via.
- */
-void PS_PLOTTER::flash_pad_circle( wxPoint pos, int diametre,
-                                   EDA_DRAW_MODE_T modetrace )
+void PS_PLOTTER::FlashPadCircle( const wxPoint& pos, int diametre,
+                                 EDA_DRAW_MODE_T modetrace )
 {
     int current_line_width;
-    wxASSERT( output_file );
+    wxASSERT( outputFile );
 
-    set_current_line_width( -1 );
-    current_line_width = get_current_line_width();
+    SetCurrentLineWidth( -1 );
+    current_line_width = GetCurrentLineWidth();
     if( current_line_width > diametre )
         current_line_width = diametre;
 
     if( modetrace == FILLED )
-        circle( pos, diametre - current_pen_width, FILLED_SHAPE, current_line_width );
+        Circle( pos, diametre - currentPenWidth, FILLED_SHAPE, current_line_width );
     else
-        circle( pos, diametre - current_pen_width, NO_FILL, current_line_width );
+        Circle( pos, diametre - currentPenWidth, NO_FILL, current_line_width );
 
-    set_current_line_width( -1 );
+    SetCurrentLineWidth( -1 );
 }
 
 
-/* Plot rectangular pad in any orientation.
- */
-void PS_PLOTTER::flash_pad_rect( wxPoint pos, wxSize size,
-                                 int orient, EDA_DRAW_MODE_T trace_mode )
+void PS_PLOTTER::FlashPadRect( const wxPoint& pos, const wxSize& aSize,
+                               int orient, EDA_DRAW_MODE_T trace_mode )
 {
     static std::vector< wxPoint > cornerList;
+    wxSize size( aSize );
     cornerList.clear();
 
-    set_current_line_width( -1 );
-    int w = current_pen_width;
+    SetCurrentLineWidth( -1 );
+    int w = currentPenWidth;
     size.x -= w;
     if( size.x < 1 )
         size.x = 1;
@@ -568,13 +539,8 @@
 }
 
 
-/* Plot trapezoidal pad.
- * aPadPos is pad position, aCorners the corners position of the basic shape
- * Orientation aPadOrient in 0.1 degrees
- * Plot mode FILLED or SKETCH
- */
-void PS_PLOTTER::flash_pad_trapez( wxPoint aPadPos, wxPoint aCorners[4],
-                                   int aPadOrient, EDA_DRAW_MODE_T aTrace_Mode )
+void PS_PLOTTER::FlashPadTrapez( const wxPoint& aPadPos, const wxPoint *aCorners,
+                                 int aPadOrient, EDA_DRAW_MODE_T aTrace_Mode )
 {
     static std::vector< wxPoint > cornerList;
     cornerList.clear();
@@ -584,12 +550,12 @@
 
     if( aTrace_Mode == FILLED )
     {
-        set_current_line_width( 0 );
+        SetCurrentLineWidth( 0 );
     }
     else
     {
-        set_current_line_width( -1 );
-        int w = current_pen_width;
+        SetCurrentLineWidth( -1 );
+        int w = currentPenWidth;
         // offset polygon by w
         // coord[0] is assumed the lower left
         // coord[1] is assumed the upper left
@@ -617,21 +583,3 @@
     PlotPoly( cornerList, ( aTrace_Mode == FILLED ) ? FILLED_SHAPE : NO_FILL );
 }
 
-
-void PS_PLOTTER::user_to_device_coordinates( wxPoint& pos )
-{
-    if( pageInfo.IsPortrait() )
-    {
-        pos.y = (int) ( ( paper_size.y - ( pos.y - plot_offset.y )
-                        * plot_scale ) * device_scale );
-
-        if( plotMirror )
-            pos.x = (int) ( ( paper_size.x - ( pos.x - plot_offset.x )
-                          * plot_scale ) * device_scale );
-        else
-            pos.x = (int) ( (pos.x - plot_offset.x) * plot_scale * device_scale );
-    }
-    else
-        PLOTTER::user_to_device_coordinates( pos );
-}
-

=== modified file 'common/common_plot_functions.cpp'
--- common/common_plot_functions.cpp	2012-04-16 23:31:29 +0000
+++ common/common_plot_functions.cpp	2012-04-30 09:18:58 +0000
@@ -1,6 +1,6 @@
 /**
  * @file common_plot_functions.cpp
- * @brief Kicad: Common plot Postscript Routines
+ * @brief Kicad: Common plotting Routines
  */
 
 #include <fctsys.h>
@@ -31,7 +31,7 @@
     EDA_COLOR_T         color;
 
     // Paper is sized in mils.  Here is a conversion factor to scale mils to internal units.
-    int      conv_unit = screen->MilsToIuScalar();
+    int      iusPerMil = screen->MilsToIuScalar();
 
     wxString msg;
     wxSize   text_size;
@@ -49,59 +49,59 @@
     bool     thickness = 0;      //@todo : use current pen
 
     color = BLACK;
-    plotter->set_color( color );
+    plotter->SetColor( color );
 
     // Plot edge.
-    ref.x = pageInfo.GetLeftMarginMils() * conv_unit;
-    ref.y = pageInfo.GetTopMarginMils()  * conv_unit;
+    ref.x = pageInfo.GetLeftMarginMils() * iusPerMil;
+    ref.y = pageInfo.GetTopMarginMils()  * iusPerMil;
 
-    xg    = ( pageSize.x - pageInfo.GetRightMarginMils() )  * conv_unit;
-    yg    = ( pageSize.y - pageInfo.GetBottomMarginMils() ) * conv_unit;
+    xg    = ( pageSize.x - pageInfo.GetRightMarginMils() )  * iusPerMil;
+    yg    = ( pageSize.y - pageInfo.GetBottomMarginMils() ) * iusPerMil;
 
 #if defined(KICAD_GOST)
-    plotter->move_to( ref );
+    plotter->MoveTo( ref );
     pos.x = xg;
     pos.y = ref.y;
-    plotter->line_to( pos );
+    plotter->LineTo( pos );
     pos.x = xg;
     pos.y = yg;
-    plotter->line_to( pos );
+    plotter->LineTo( pos );
     pos.x = ref.x;
     pos.y = yg;
-    plotter->line_to( pos );
-    plotter->finish_to( ref );
+    plotter->LineTo( pos );
+    plotter->FinishTo( ref );
 
 #else
 
     for( unsigned ii = 0; ii < 2; ii++ )
     {
-        plotter->move_to( ref );
+        plotter->MoveTo( ref );
 
         pos.x = xg;
         pos.y = ref.y;
-        plotter->line_to( pos );
+        plotter->LineTo( pos );
 
         pos.x = xg;
         pos.y = yg;
-        plotter->line_to( pos );
+        plotter->LineTo( pos );
 
         pos.x = ref.x;
         pos.y = yg;
-        plotter->line_to( pos );
-
-        plotter->finish_to( ref );
-
-        ref.x += GRID_REF_W * conv_unit;
-        ref.y += GRID_REF_W * conv_unit;
-
-        xg    -= GRID_REF_W * conv_unit;
-        yg    -= GRID_REF_W * conv_unit;
+        plotter->LineTo( pos );
+
+        plotter->FinishTo( ref );
+
+        ref.x += GRID_REF_W * iusPerMil;
+        ref.y += GRID_REF_W * iusPerMil;
+
+        xg    -= GRID_REF_W * iusPerMil;
+        yg    -= GRID_REF_W * iusPerMil;
     }
 
 #endif
 
-    text_size.x = WSTEXTSIZE * conv_unit;
-    text_size.y = WSTEXTSIZE * conv_unit;
+    text_size.x = WSTEXTSIZE * iusPerMil;
+    text_size.y = WSTEXTSIZE * iusPerMil;
 
     // upper left corner in mils
     ref.x = pageInfo.GetLeftMarginMils();
@@ -116,8 +116,8 @@
          WsItem != NULL;
          WsItem = WsItem->Pnext )
     {
-        pos.x = ( ref.x - WsItem->m_Posx ) * conv_unit;
-        pos.y = ( yg - WsItem->m_Posy ) * conv_unit;
+        pos.x = ( ref.x - WsItem->m_Posx ) * iusPerMil;
+        pos.y = ( yg - WsItem->m_Posy ) * iusPerMil;
         msg.Empty();
         switch( WsItem->m_Type )
         {
@@ -127,17 +127,17 @@
         case WS_PODPIS_LU:
             if( WsItem->m_Legende )
                 msg = WsItem->m_Legende;
-            plotter->text( pos, color,
+            plotter->Text( pos, color,
                            msg, TEXT_ORIENT_VERT, text_size,
                            GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM,
                            thickness, italic, false );
             break;
 
         case WS_SEGMENT_LU:
-            plotter->move_to( pos );
-            pos.x = ( ref.x - WsItem->m_Endx ) * conv_unit;
-            pos.y = ( yg - WsItem->m_Endy ) * conv_unit;
-            plotter->finish_to( pos );
+            plotter->MoveTo( pos );
+            pos.x = ( ref.x - WsItem->m_Endx ) * iusPerMil;
+            pos.y = ( yg - WsItem->m_Endy ) * iusPerMil;
+            plotter->FinishTo( pos );
             break;
         }
     }
@@ -146,16 +146,16 @@
          WsItem != NULL;
          WsItem = WsItem->Pnext )
     {
-        pos.x = ( ref.x + WsItem->m_Posx ) * conv_unit;
-        pos.y = ( ref.y + WsItem->m_Posy ) * conv_unit;
+        pos.x = ( ref.x + WsItem->m_Posx ) * iusPerMil;
+        pos.y = ( ref.y + WsItem->m_Posy ) * iusPerMil;
         msg.Empty();
         switch( WsItem->m_Type )
         {
         case WS_SEGMENT_LT:
-            plotter->move_to( pos );
-            pos.x = ( ref.x + WsItem->m_Endx ) * conv_unit;
-            pos.y = ( ref.y + WsItem->m_Endy ) * conv_unit;
-            plotter->finish_to( pos );
+            plotter->MoveTo( pos );
+            pos.x = ( ref.x + WsItem->m_Endx ) * iusPerMil;
+            pos.y = ( ref.y + WsItem->m_Endy ) * iusPerMil;
+            plotter->FinishTo( pos );
             break;
         }
     }
@@ -172,33 +172,33 @@
 
         if( ii < xg - PAS_REF / 2 )
         {
-            pos.x = ii * conv_unit;
-            pos.y = ref.y * conv_unit;
-            plotter->move_to( pos );
-            pos.x = ii * conv_unit;
-            pos.y = ( ref.y + GRID_REF_W ) * conv_unit;
-            plotter->finish_to( pos );
+            pos.x = ii * iusPerMil;
+            pos.y = ref.y * iusPerMil;
+            plotter->MoveTo( pos );
+            pos.x = ii * iusPerMil;
+            pos.y = ( ref.y + GRID_REF_W ) * iusPerMil;
+            plotter->FinishTo( pos );
         }
 
-        pos.x = ( ii - gxpas / 2 ) * conv_unit;
-        pos.y = ( ref.y + GRID_REF_W / 2 ) * conv_unit;
-        plotter->text( pos, color,
+        pos.x = ( ii - gxpas / 2 ) * iusPerMil;
+        pos.y = ( ref.y + GRID_REF_W / 2 ) * iusPerMil;
+        plotter->Text( pos, color,
                        msg, TEXT_ORIENT_HORIZ, text_size,
                        GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
                        thickness, italic, false );
 
         if( ii < xg - PAS_REF / 2 )
         {
-            pos.x = ii * conv_unit;
-            pos.y = yg * conv_unit;
-            plotter->move_to( pos );
-            pos.x = ii * conv_unit;
-            pos.y = (yg - GRID_REF_W) * conv_unit;
-            plotter->finish_to( pos );
+            pos.x = ii * iusPerMil;
+            pos.y = yg * iusPerMil;
+            plotter->MoveTo( pos );
+            pos.x = ii * iusPerMil;
+            pos.y = (yg - GRID_REF_W) * iusPerMil;
+            plotter->FinishTo( pos );
         }
-        pos.x = ( ii - gxpas / 2 ) * conv_unit;
-        pos.y = ( yg - GRID_REF_W / 2 ) * conv_unit;
-        plotter->text( pos, color,
+        pos.x = ( ii - gxpas / 2 ) * iusPerMil;
+        pos.y = ( yg - GRID_REF_W / 2 ) * iusPerMil;
+        plotter->Text( pos, color,
                        msg, TEXT_ORIENT_HORIZ, text_size,
                        GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
                        thickness, italic, false );
@@ -215,33 +215,33 @@
             msg.Printf( wxT( "%c" ), 'a' + jj - 26 );
         if( ii < yg - PAS_REF / 2 )
         {
-            pos.x = ref.x * conv_unit;
-            pos.y = ii * conv_unit;
-            plotter->move_to( pos );
-            pos.x = ( ref.x + GRID_REF_W ) * conv_unit;
-            pos.y = ii * conv_unit;
-            plotter->finish_to( pos );
+            pos.x = ref.x * iusPerMil;
+            pos.y = ii * iusPerMil;
+            plotter->MoveTo( pos );
+            pos.x = ( ref.x + GRID_REF_W ) * iusPerMil;
+            pos.y = ii * iusPerMil;
+            plotter->FinishTo( pos );
         }
-        pos.x = ( ref.x + GRID_REF_W / 2 ) * conv_unit;
-        pos.y = ( ii - gypas / 2 ) * conv_unit;
-        plotter->text( pos, color,
+        pos.x = ( ref.x + GRID_REF_W / 2 ) * iusPerMil;
+        pos.y = ( ii - gypas / 2 ) * iusPerMil;
+        plotter->Text( pos, color,
                        msg, TEXT_ORIENT_HORIZ, text_size,
                        GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
                        thickness, italic, false );
 
         if( ii < yg - PAS_REF / 2 )
         {
-            pos.x = xg * conv_unit;
-            pos.y = ii * conv_unit;
-            plotter->move_to( pos );
-            pos.x = ( xg - GRID_REF_W ) * conv_unit;
-            pos.y = ii * conv_unit;
-            plotter->finish_to( pos );
+            pos.x = xg * iusPerMil;
+            pos.y = ii * iusPerMil;
+            plotter->MoveTo( pos );
+            pos.x = ( xg - GRID_REF_W ) * iusPerMil;
+            pos.y = ii * iusPerMil;
+            plotter->FinishTo( pos );
         }
 
-        pos.x = ( xg - GRID_REF_W / 2 ) * conv_unit;
-        pos.y = ( ii - gypas / 2 ) * conv_unit;
-        plotter->text( pos, color, msg, TEXT_ORIENT_HORIZ, text_size,
+        pos.x = ( xg - GRID_REF_W / 2 ) * iusPerMil;
+        pos.y = ( ii - gypas / 2 ) * iusPerMil;
+        plotter->Text( pos, color, msg, TEXT_ORIENT_HORIZ, text_size,
                        GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
                        thickness, italic, false );
     }
@@ -249,16 +249,16 @@
 #endif
 
     // Plot the worksheet.
-    text_size.x = SIZETEXT * conv_unit;
-    text_size.y = SIZETEXT * conv_unit;
+    text_size.x = SIZETEXT * iusPerMil;
+    text_size.y = SIZETEXT * iusPerMil;
 
 #if defined(KICAD_GOST)
-    text_size2.x = SIZETEXT * conv_unit * 2;
-    text_size2.y = SIZETEXT * conv_unit * 2;
-    text_size3.x = SIZETEXT * conv_unit * 3;
-    text_size3.y = SIZETEXT * conv_unit * 3;
-    text_size1_5.x = SIZETEXT * conv_unit * 1.5;
-    text_size1_5.y = SIZETEXT * conv_unit * 1.5;
+    text_size2.x = SIZETEXT * iusPerMil * 2;
+    text_size2.y = SIZETEXT * iusPerMil * 2;
+    text_size3.x = SIZETEXT * iusPerMil * 3;
+    text_size3.y = SIZETEXT * iusPerMil * 3;
+    text_size1_5.x = SIZETEXT * iusPerMil * 1.5;
+    text_size1_5.y = SIZETEXT * iusPerMil * 1.5;
 
     ref.x = pageSize.x - pageInfo.GetRightMarginMils();
     ref.y = pageSize.y - pageInfo.GetBottomMarginMils();
@@ -269,8 +269,8 @@
              WsItem != NULL;
              WsItem = WsItem->Pnext )
         {
-            pos.x = ( ref.x - WsItem->m_Posx ) * conv_unit;
-            pos.y = ( ref.y - WsItem->m_Posy ) * conv_unit;
+            pos.x = ( ref.x - WsItem->m_Posx ) * iusPerMil;
+            pos.y = ( ref.y - WsItem->m_Posy ) * iusPerMil;
             msg.Empty();
 
             switch( WsItem->m_Type )
@@ -287,7 +287,7 @@
             case WS_PODPIS:
                 if( WsItem->m_Legende )
                     msg = WsItem->m_Legende;
-                plotter->text( pos, color,
+                plotter->Text( pos, color,
                                msg, TEXT_ORIENT_HORIZ, text_size,
                                GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
                                thickness, italic, false );
@@ -301,7 +301,7 @@
                     msg = WsItem->m_Legende;
                 if( screen->m_NumberOfScreen > 1 )
                     msg << screen->m_ScreenNumber;
-                plotter->text( pos, color,
+                plotter->Text( pos, color,
                                msg, TEXT_ORIENT_HORIZ, text_size,
                                GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
                                thickness, italic, false );
@@ -311,7 +311,7 @@
                 if( WsItem->m_Legende )
                     msg = WsItem->m_Legende;
             msg << screen->m_NumberOfScreen;
-                plotter->text( pos, color,
+                plotter->Text( pos, color,
                                msg, TEXT_ORIENT_HORIZ, text_size,
                                GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
                                thickness, italic, false );
@@ -321,7 +321,7 @@
             msg = GetTitleBlock().GetCompany();
                 if( !msg.IsEmpty() )
                 {
-                    plotter->text( pos, color,
+                    plotter->Text( pos, color,
                                    msg, TEXT_ORIENT_HORIZ, text_size1_5,
                                    GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
                                    thickness, italic, false );
@@ -332,7 +332,7 @@
             msg = GetTitleBlock().GetTitle();
                 if( !msg.IsEmpty() )
                 {
-                    plotter->text( pos, color,
+                    plotter->Text( pos, color,
                                    msg, TEXT_ORIENT_HORIZ, text_size1_5,
                                    GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
                                    thickness, italic, false );
@@ -343,13 +343,13 @@
             msg = GetTitleBlock().GetComment1();
                 if( !msg.IsEmpty() )
                 {
-                    plotter->text( pos, color,
+                    plotter->Text( pos, color,
                                    msg, TEXT_ORIENT_HORIZ, text_size3,
                                    GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
                                    thickness, italic, false );
-                    pos.x = (pageInfo.GetLeftMarginMils() + 1260) * conv_unit;
-                    pos.y = (pageInfo.GetTopMarginMils() + 270) * conv_unit;
-                    plotter->text( pos, color,
+                    pos.x = (pageInfo.GetLeftMarginMils() + 1260) * iusPerMil;
+                    pos.y = (pageInfo.GetTopMarginMils() + 270) * iusPerMil;
+                    plotter->Text( pos, color,
                                    msg.GetData(), 1800, text_size2,
                                    GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
                                    thickness, italic, false );
@@ -360,7 +360,7 @@
             msg = GetTitleBlock().GetComment2();
                 if( !msg.IsEmpty() )
                 {
-                    plotter->text( pos, color,
+                    plotter->Text( pos, color,
                                    msg, TEXT_ORIENT_HORIZ, text_size,
                                    GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
                                    thickness, italic, false );
@@ -371,7 +371,7 @@
             msg = GetTitleBlock().GetComment3();
                 if( !msg.IsEmpty() )
                 {
-                    plotter->text( pos, color,
+                    plotter->Text( pos, color,
                                    msg, TEXT_ORIENT_HORIZ, text_size,
                                    GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
                                    thickness, italic, false );
@@ -382,7 +382,7 @@
             msg = GetTitleBlock().GetComment4();
                 if( !msg.IsEmpty() )
                 {
-                    plotter->text( pos, color,
+                    plotter->Text( pos, color,
                                    msg, TEXT_ORIENT_HORIZ, text_size,
                                    GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
                                    thickness, italic, false );
@@ -392,10 +392,10 @@
             case WS_UPPER_SEGMENT:
             case WS_LEFT_SEGMENT:
             case WS_SEGMENT:
-                plotter->move_to( pos );
-                pos.x = ( ref.x - WsItem->m_Endx ) * conv_unit;
-                pos.y = ( ref.y - WsItem->m_Endy ) * conv_unit;
-                plotter->finish_to( pos );
+                plotter->MoveTo( pos );
+                pos.x = ( ref.x - WsItem->m_Endx ) * iusPerMil;
+                pos.y = ( ref.y - WsItem->m_Endy ) * iusPerMil;
+                plotter->FinishTo( pos );
                 break;
             }
         }
@@ -406,8 +406,8 @@
              WsItem != NULL;
              WsItem = WsItem->Pnext )
         {
-            pos.x = ( ref.x - WsItem->m_Posx ) * conv_unit;
-            pos.y = ( ref.y - WsItem->m_Posy ) * conv_unit;
+            pos.x = ( ref.x - WsItem->m_Posx ) * iusPerMil;
+            pos.y = ( ref.y - WsItem->m_Posy ) * iusPerMil;
             msg.Empty();
 
             switch( WsItem->m_Type )
@@ -417,13 +417,13 @@
             msg = GetTitleBlock().GetComment1();
                 if( !msg.IsEmpty() )
                 {
-                    plotter->text( pos, color,
+                    plotter->Text( pos, color,
                                    msg, TEXT_ORIENT_HORIZ, text_size3,
                                    GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
                                    thickness, italic, false );
-                    pos.x = (pageInfo.GetLeftMarginMils() + 1260) * conv_unit;
-                    pos.y = (pageInfo.GetTopMarginMils() + 270) * conv_unit;
-                    plotter->text( pos, color,
+                    pos.x = (pageInfo.GetLeftMarginMils() + 1260) * iusPerMil;
+                    pos.y = (pageInfo.GetTopMarginMils() + 270) * iusPerMil;
+                    plotter->Text( pos, color,
                                    msg, 1800, text_size2,
                                    GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
                                    thickness, italic, false );
@@ -433,7 +433,7 @@
             case WS_PODPIS_D:
                 if( WsItem->m_Legende )
                     msg = WsItem->m_Legende;
-                plotter->text( pos, color, msg, TEXT_ORIENT_HORIZ, text_size,
+                plotter->Text( pos, color, msg, TEXT_ORIENT_HORIZ, text_size,
                                GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
                                thickness, italic, false );
                 break;
@@ -442,17 +442,17 @@
                 if( WsItem->m_Legende )
                     msg = WsItem->m_Legende;
                 msg << screen->m_ScreenNumber;
-                plotter->text( pos, color, msg, TEXT_ORIENT_HORIZ, text_size,
+                plotter->Text( pos, color, msg, TEXT_ORIENT_HORIZ, text_size,
                                GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
                                thickness, italic, false );
                 break;
 
             case WS_LEFT_SEGMENT_D:
             case WS_SEGMENT_D:
-                plotter->move_to( pos );
-                pos.x = ( ref.x - WsItem->m_Endx ) * conv_unit;
-                pos.y = ( ref.y - WsItem->m_Endy ) * conv_unit;
-                plotter->finish_to( pos );
+                plotter->MoveTo( pos );
+                pos.x = ( ref.x - WsItem->m_Endx ) * iusPerMil;
+                pos.y = ( ref.y - WsItem->m_Endy ) * iusPerMil;
+                plotter->FinishTo( pos );
                 break;
             }
         }
@@ -467,8 +467,8 @@
          WsItem != NULL;
          WsItem = WsItem->Pnext )
     {
-        pos.x = ( ref.x - WsItem->m_Posx ) * conv_unit;
-        pos.y = ( ref.y - WsItem->m_Posy ) * conv_unit;
+        pos.x = ( ref.x - WsItem->m_Posx ) * iusPerMil;
+        pos.y = ( ref.y - WsItem->m_Posy ) * iusPerMil;
         bold  = false;
         if( WsItem->m_Legende )
             msg = WsItem->m_Legende;
@@ -558,22 +558,22 @@
         case WS_LEFT_SEGMENT:
             WS_MostUpperLine.m_Posy = WS_MostUpperLine.m_Endy
                 = WS_MostLeftLine.m_Posy = UpperLimit;
-            pos.y = (ref.y - WsItem->m_Posy) * conv_unit;
+            pos.y = (ref.y - WsItem->m_Posy) * iusPerMil;
 
         case WS_SEGMENT:
         {
             wxPoint auxpos;
-            auxpos.x = ( ref.x - WsItem->m_Endx ) * conv_unit;
-            auxpos.y = ( ref.y - WsItem->m_Endy ) * conv_unit;
-            plotter->move_to( pos );
-            plotter->finish_to( auxpos );
+            auxpos.x = ( ref.x - WsItem->m_Endx ) * iusPerMil;
+            auxpos.y = ( ref.y - WsItem->m_Endy ) * iusPerMil;
+            plotter->MoveTo( pos );
+            plotter->FinishTo( auxpos );
         }
         break;
         }
 
         if( !msg.IsEmpty() )
         {
-            plotter->text( pos, color,
+            plotter->Text( pos, color,
                            msg, TEXT_ORIENT_HORIZ, text_size,
                            GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
                            thickness, italic, bold );

=== modified file 'common/drawtxt.cpp'
--- common/drawtxt.cpp	2012-04-19 06:55:45 +0000
+++ common/drawtxt.cpp	2012-04-30 09:21:42 +0000
@@ -164,13 +164,13 @@
 {
     if( aPlotter )
     {
-        aPlotter->move_to( coord[0] );
+        aPlotter->MoveTo( coord[0] );
         for( int ik = 1; ik < point_count; ik++ )
         {
-            aPlotter->line_to( coord[ik] );
+            aPlotter->LineTo( coord[ik] );
         }
 
-        aPlotter->pen_finish();
+        aPlotter->PenFinish();
     }
     else if( aCallback )
     {
@@ -357,8 +357,8 @@
 
         if( aPlotter )
         {
-            aPlotter->move_to( current_char_pos );
-            aPlotter->finish_to( end );
+            aPlotter->MoveTo( current_char_pos );
+            aPlotter->FinishTo( end );
         }
         else if( aCallback )
         {
@@ -515,7 +515,7 @@
  *  @param aItalic = true to simulate an italic font
  *  @param aBold = true to use a bold font Useful only with default width value (aWidth = 0)
  */
-void PLOTTER::text( const wxPoint&              aPos,
+void PLOTTER::Text( const wxPoint&              aPos,
                     enum EDA_COLOR_T            aColor,
                     const wxString&             aText,
                     int                         aOrient,
@@ -534,11 +534,11 @@
     else
         aWidth = -Clamp_Text_PenSize( -aWidth, aSize, aBold );
 
-    set_current_line_width( aWidth );
+    SetCurrentLineWidth( aWidth );
 
 
     if( aColor >= 0 )
-        set_color( aColor );
+        SetColor( aColor );
 
     DrawGraphicText( NULL, NULL, aPos, aColor, aText,
                      aOrient, aSize,

=== modified file 'eeschema/class_libentry.cpp'
--- eeschema/class_libentry.cpp	2012-01-23 04:33:36 +0000
+++ eeschema/class_libentry.cpp	2012-04-30 09:18:58 +0000
@@ -391,8 +391,8 @@
         if( aConvert && item.m_Convert && ( item.m_Convert != aConvert ) )
             continue;
 
-        aPlotter->set_color( ReturnLayerColor( LAYER_DEVICE ) );
-        bool fill = aPlotter->get_color_mode();
+        aPlotter->SetColor( ReturnLayerColor( LAYER_DEVICE ) );
+        bool fill = aPlotter->GetColorMode();
 
         item.Plot( aPlotter, aOffset, fill, aTransform );
     }

=== modified file 'eeschema/dialogs/dialog_plot_schematic_DXF.cpp'
--- eeschema/dialogs/dialog_plot_schematic_DXF.cpp	2012-01-23 04:33:36 +0000
+++ eeschema/dialogs/dialog_plot_schematic_DXF.cpp	2012-04-30 09:18:58 +0000
@@ -185,14 +185,12 @@
             sheetpath = SheetList.GetNext();
         }
 
-        double scale = 10;
-
         plot_offset.x = 0;
         plot_offset.y = 0;
 
         plotFileName = schframe->GetUniqueFilenameForCurrentSheet() + wxT( ".dxf" );
 
-        PlotOneSheetDXF( plotFileName, screen, plot_offset, scale );
+        PlotOneSheetDXF( plotFileName, screen, plot_offset, 1 );
 
         if( !m_select_PlotAll )
             break;
@@ -232,24 +230,24 @@
     const PAGE_INFO&   pageInfo = screen->GetPageSettings();
     plotter->SetPageSettings( pageInfo );
 
-    plotter->set_viewport( plot_offset, scale, 0 );
-    plotter->set_color_mode( m_plotColorOpt );
+    plotter->SetViewport( plot_offset, IU_PER_DECIMILS, scale, 0 );
+    plotter->SetColorMode( m_plotColorOpt );
 
     // Init :
-    plotter->set_creator( wxT( "Eeschema-DXF" ) );
-    plotter->set_filename( FileName );
-    plotter->start_plot( output_file );
+    plotter->SetCreator( wxT( "Eeschema-DXF" ) );
+    plotter->SetFilename( FileName );
+    plotter->StartPlot( output_file );
 
     if( m_plot_Sheet_Ref )
     {
-        plotter->set_color( BLACK );
+        plotter->SetColor( BLACK );
         m_Parent->PlotWorkSheet( plotter, screen );
     }
 
     screen->Plot( plotter );
 
     // finish
-    plotter->end_plot();
+    plotter->EndPlot();
     delete plotter;
 
     m_MsgBox->AppendText( wxT( "Ok\n" ) );

=== modified file 'eeschema/dialogs/dialog_plot_schematic_HPGL.cpp'
--- eeschema/dialogs/dialog_plot_schematic_HPGL.cpp	2012-04-16 17:39:32 +0000
+++ eeschema/dialogs/dialog_plot_schematic_HPGL.cpp	2012-04-30 09:18:58 +0000
@@ -330,7 +330,7 @@
         // Calculation of conversion scales.
 
         // 10x because Eeschema works in mils, not deci-mils
-        double plot_scale = 10 * (double) plotPage.GetWidthMils() / curPage.GetWidthMils();
+        double plot_scale = (double) plotPage.GetWidthMils() / curPage.GetWidthMils();
 
         // Calculate offsets
         plotOffset.x = -s_Offset.x;
@@ -380,26 +380,26 @@
 
     plotter->SetPageSettings( pageInfo );
 
-    plotter->set_viewport( offset, plot_scale, 0 );
-    plotter->set_default_line_width( g_DrawDefaultLineThickness );
+    plotter->SetViewport( offset, IU_PER_DECIMILS, plot_scale, 0 );
+    plotter->SetDefaultLineWidth( g_DrawDefaultLineThickness );
 
     // Init :
-    plotter->set_creator( wxT( "Eeschema-HPGL" ) );
-    plotter->set_filename( FileName );
-    plotter->set_pen_speed( g_HPGL_Pen_Descr.m_Pen_Speed );
-    plotter->set_pen_number( g_HPGL_Pen_Descr.m_Pen_Num );
-    plotter->set_pen_diameter( g_HPGL_Pen_Descr.m_Pen_Diam );
-    plotter->set_pen_overlap( g_HPGL_Pen_Descr.m_Pen_Diam / 2 );
-    plotter->start_plot( output_file );
+    plotter->SetCreator( wxT( "Eeschema-HPGL" ) );
+    plotter->SetFilename( FileName );
+    plotter->SetPenSpeed( g_HPGL_Pen_Descr.m_Pen_Speed );
+    plotter->SetPenNumber( g_HPGL_Pen_Descr.m_Pen_Num );
+    plotter->SetPenDiameter( g_HPGL_Pen_Descr.m_Pen_Diam );
+    plotter->SetPenOverlap( g_HPGL_Pen_Descr.m_Pen_Diam / 2 );
+    plotter->StartPlot( output_file );
 
-    plotter->set_color( BLACK );
+    plotter->SetColor( BLACK );
 
     if( s_plot_Sheet_Ref )
         m_Parent->PlotWorkSheet( plotter, screen );
 
     screen->Plot( plotter );
 
-    plotter->end_plot();
+    plotter->EndPlot();
     delete plotter;
 
     m_MsgBox->AppendText( wxT( "Ok\n" ) );

=== modified file 'eeschema/dialogs/dialog_plot_schematic_PS.cpp'
--- eeschema/dialogs/dialog_plot_schematic_PS.cpp	2012-04-16 17:39:32 +0000
+++ eeschema/dialogs/dialog_plot_schematic_PS.cpp	2012-04-30 09:18:58 +0000
@@ -237,7 +237,7 @@
         double scalex = (double) plotPage.GetWidthMils()  / actualPage.GetWidthMils();
         double scaley = (double) plotPage.GetHeightMils() / actualPage.GetHeightMils();
 
-        double scale  = 10 * MIN( scalex, scaley );
+        double scale  = MIN( scalex, scaley );
 
         plot_offset.x = 0;
         plot_offset.y = 0;
@@ -281,24 +281,24 @@
 
     PS_PLOTTER* plotter = new PS_PLOTTER();
     plotter->SetPageSettings( pageInfo );
-    plotter->set_viewport( plot_offset, scale, 0 );
-    plotter->set_default_line_width( g_DrawDefaultLineThickness );
-    plotter->set_color_mode( m_plotColorOpt );
+    plotter->SetViewport( plot_offset, IU_PER_DECIMILS, scale, 0 );
+    plotter->SetDefaultLineWidth( g_DrawDefaultLineThickness );
+    plotter->SetColorMode( m_plotColorOpt );
 
     // Init :
-    plotter->set_creator( wxT( "Eeschema-PS" ) );
-    plotter->set_filename( FileName );
-    plotter->start_plot( output_file );
+    plotter->SetCreator( wxT( "Eeschema-PS" ) );
+    plotter->SetFilename( FileName );
+    plotter->StartPlot( output_file );
 
     if( m_plot_Sheet_Ref )
     {
-        plotter->set_color( BLACK );
+        plotter->SetColor( BLACK );
         m_Parent->PlotWorkSheet( plotter, screen );
     }
 
     screen->Plot( plotter );
 
-    plotter->end_plot();
+    plotter->EndPlot();
     delete plotter;
     SetLocaleTo_Default();
 

=== modified file 'eeschema/lib_arc.cpp'
--- eeschema/lib_arc.cpp	2012-04-19 06:55:45 +0000
+++ eeschema/lib_arc.cpp	2012-04-30 09:18:58 +0000
@@ -325,13 +325,14 @@
 
     if( aFill && m_Fill == FILLED_WITH_BG_BODYCOLOR )
     {
-        aPlotter->set_color( ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
-        aPlotter->arc( pos, -t2, -t1, m_Radius, FILLED_SHAPE, 0 );
+        aPlotter->SetColor( ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
+        aPlotter->Arc( pos, -t2, -t1, m_Radius, FILLED_SHAPE, 0 );
     }
 
     bool already_filled = m_Fill == FILLED_WITH_BG_BODYCOLOR;
-    aPlotter->set_color( ReturnLayerColor( LAYER_DEVICE ) );
-    aPlotter->arc( pos, -t2, -t1, m_Radius, already_filled ? NO_FILL : m_Fill, GetPenSize() );
+    aPlotter->SetColor( ReturnLayerColor( LAYER_DEVICE ) );
+    aPlotter->Arc( pos, -t2, -t1, m_Radius, 
+                   already_filled ? NO_FILL : m_Fill, GetPenSize() );
 }
 
 

=== modified file 'eeschema/lib_bezier.cpp'
--- eeschema/lib_bezier.cpp	2012-04-13 18:51:24 +0000
+++ eeschema/lib_bezier.cpp	2012-04-30 09:18:58 +0000
@@ -270,12 +270,12 @@
 
     if( aFill && m_Fill == FILLED_WITH_BG_BODYCOLOR )
     {
-        aPlotter->set_color( ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
+        aPlotter->SetColor( ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
         aPlotter->PlotPoly( cornerList, FILLED_WITH_BG_BODYCOLOR, 0 );
     }
 
     bool already_filled = m_Fill == FILLED_WITH_BG_BODYCOLOR;
-    aPlotter->set_color( ReturnLayerColor( LAYER_DEVICE ) );
+    aPlotter->SetColor( ReturnLayerColor( LAYER_DEVICE ) );
     aPlotter->PlotPoly( cornerList, already_filled ? NO_FILL : m_Fill, GetPenSize() );
 }
 

=== modified file 'eeschema/lib_circle.cpp'
--- eeschema/lib_circle.cpp	2012-04-19 06:55:45 +0000
+++ eeschema/lib_circle.cpp	2012-04-30 09:18:58 +0000
@@ -193,13 +193,13 @@
 
     if( aFill && m_Fill == FILLED_WITH_BG_BODYCOLOR )
     {
-        aPlotter->set_color( ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
-        aPlotter->circle( pos, m_Radius * 2, FILLED_SHAPE, 0 );
+        aPlotter->SetColor( ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
+        aPlotter->Circle( pos, m_Radius * 2, FILLED_SHAPE, 0 );
     }
 
     bool already_filled = m_Fill == FILLED_WITH_BG_BODYCOLOR;
-    aPlotter->set_color( ReturnLayerColor( LAYER_DEVICE ) );
-    aPlotter->circle( pos, m_Radius * 2, already_filled ? NO_FILL : m_Fill, GetPenSize() );
+    aPlotter->SetColor( ReturnLayerColor( LAYER_DEVICE ) );
+    aPlotter->Circle( pos, m_Radius * 2, already_filled ? NO_FILL : m_Fill, GetPenSize() );
 }
 
 

=== modified file 'eeschema/lib_pin.cpp'
--- eeschema/lib_pin.cpp	2012-04-19 06:55:45 +0000
+++ eeschema/lib_pin.cpp	2012-04-30 09:18:58 +0000
@@ -1275,7 +1275,7 @@
 
     color = ReturnLayerColor( LAYER_PIN );
 
-    aPlotter->set_color( color );
+    aPlotter->SetColor( color );
 
     MapX1 = MapY1 = 0;
     x1 = aPosition.x; y1 = aPosition.y;
@@ -1305,35 +1305,35 @@
 
     if( m_shape & INVERT )
     {
-        aPlotter->circle( wxPoint( MapX1 * INVERT_PIN_RADIUS + x1,
+        aPlotter->Circle( wxPoint( MapX1 * INVERT_PIN_RADIUS + x1,
                                    MapY1 * INVERT_PIN_RADIUS + y1 ),
                           INVERT_PIN_RADIUS * 2, // diameter
                           NO_FILL,               // fill
                           -1 );                  // width
 
-        aPlotter->move_to( wxPoint( MapX1 * INVERT_PIN_RADIUS * 2 + x1,
+        aPlotter->MoveTo( wxPoint( MapX1 * INVERT_PIN_RADIUS * 2 + x1,
                                     MapY1 * INVERT_PIN_RADIUS * 2 + y1 ) );
-        aPlotter->finish_to( aPosition );
+        aPlotter->FinishTo( aPosition );
     }
     else
     {
-        aPlotter->move_to( wxPoint( x1, y1 ) );
-        aPlotter->finish_to( aPosition );
+        aPlotter->MoveTo( wxPoint( x1, y1 ) );
+        aPlotter->FinishTo( aPosition );
     }
 
     if( m_shape & CLOCK )
     {
         if( MapY1 == 0 ) /* MapX1 = +- 1 */
         {
-            aPlotter->move_to( wxPoint( x1, y1 + CLOCK_PIN_DIM ) );
-            aPlotter->line_to( wxPoint( x1 - MapX1 * CLOCK_PIN_DIM, y1 ) );
-            aPlotter->finish_to( wxPoint( x1, y1 - CLOCK_PIN_DIM ) );
+            aPlotter->MoveTo( wxPoint( x1, y1 + CLOCK_PIN_DIM ) );
+            aPlotter->LineTo( wxPoint( x1 - MapX1 * CLOCK_PIN_DIM, y1 ) );
+            aPlotter->FinishTo( wxPoint( x1, y1 - CLOCK_PIN_DIM ) );
         }
         else    /* MapX1 = 0 */
         {
-            aPlotter->move_to( wxPoint( x1 + CLOCK_PIN_DIM, y1 ) );
-            aPlotter->line_to( wxPoint( x1, y1 - MapY1 * CLOCK_PIN_DIM ) );
-            aPlotter->finish_to( wxPoint( x1 - CLOCK_PIN_DIM, y1 ) );
+            aPlotter->MoveTo( wxPoint( x1 + CLOCK_PIN_DIM, y1 ) );
+            aPlotter->LineTo( wxPoint( x1, y1 - MapY1 * CLOCK_PIN_DIM ) );
+            aPlotter->FinishTo( wxPoint( x1 - CLOCK_PIN_DIM, y1 ) );
         }
     }
 
@@ -1341,17 +1341,17 @@
     {
         if( MapY1 == 0 )        /* MapX1 = +- 1 */
         {
-            aPlotter->move_to( wxPoint( x1 + MapX1 * IEEE_SYMBOL_PIN_DIM * 2, y1 ) );
-            aPlotter->line_to( wxPoint( x1 + MapX1 * IEEE_SYMBOL_PIN_DIM * 2,
+            aPlotter->MoveTo( wxPoint( x1 + MapX1 * IEEE_SYMBOL_PIN_DIM * 2, y1 ) );
+            aPlotter->LineTo( wxPoint( x1 + MapX1 * IEEE_SYMBOL_PIN_DIM * 2,
                                         y1 - IEEE_SYMBOL_PIN_DIM ) );
-            aPlotter->finish_to( wxPoint( x1, y1 ) );
+            aPlotter->FinishTo( wxPoint( x1, y1 ) );
         }
         else    /* MapX1 = 0 */
         {
-            aPlotter->move_to( wxPoint( x1, y1 + MapY1 * IEEE_SYMBOL_PIN_DIM * 2 ) );
-            aPlotter->line_to( wxPoint( x1 - IEEE_SYMBOL_PIN_DIM,
+            aPlotter->MoveTo( wxPoint( x1, y1 + MapY1 * IEEE_SYMBOL_PIN_DIM * 2 ) );
+            aPlotter->LineTo( wxPoint( x1 - IEEE_SYMBOL_PIN_DIM,
                                         y1 + MapY1 * IEEE_SYMBOL_PIN_DIM * 2 ) );
-            aPlotter->finish_to( wxPoint( x1, y1 ) );
+            aPlotter->FinishTo( wxPoint( x1, y1 ) );
         }
     }
 
@@ -1360,13 +1360,13 @@
     {
         if( MapY1 == 0 )        /* MapX1 = +- 1 */
         {
-            aPlotter->move_to( wxPoint( x1, y1 - IEEE_SYMBOL_PIN_DIM ) );
-            aPlotter->finish_to( wxPoint( x1 + MapX1 * IEEE_SYMBOL_PIN_DIM * 2, y1 ) );
+            aPlotter->MoveTo( wxPoint( x1, y1 - IEEE_SYMBOL_PIN_DIM ) );
+            aPlotter->FinishTo( wxPoint( x1 + MapX1 * IEEE_SYMBOL_PIN_DIM * 2, y1 ) );
         }
         else    /* MapX1 = 0 */
         {
-            aPlotter->move_to( wxPoint( x1 - IEEE_SYMBOL_PIN_DIM, y1 ) );
-            aPlotter->finish_to( wxPoint( x1, y1 + MapY1 * IEEE_SYMBOL_PIN_DIM * 2 ) );
+            aPlotter->MoveTo( wxPoint( x1 - IEEE_SYMBOL_PIN_DIM, y1 ) );
+            aPlotter->FinishTo( wxPoint( x1, y1 + MapY1 * IEEE_SYMBOL_PIN_DIM * 2 ) );
         }
     }
 }
@@ -1427,7 +1427,7 @@
                 if( orient == PIN_RIGHT )
                 {
                     x = x1 + TextInside;
-                    plotter->text( wxPoint( x, y1 ), NameColor,
+                    plotter->Text( wxPoint( x, y1 ), NameColor,
                                    m_name,
                                    TEXT_ORIENT_HORIZ,
                                    PinNameSize,
@@ -1440,7 +1440,7 @@
                     x = x1 - TextInside;
 
                     if( DrawPinName )
-                        plotter->text( wxPoint( x, y1 ),
+                        plotter->Text( wxPoint( x, y1 ),
                                        NameColor, m_name, TEXT_ORIENT_HORIZ,
                                        PinNameSize,
                                        GR_TEXT_HJUSTIFY_RIGHT,
@@ -1450,7 +1450,7 @@
             }
             if( DrawPinNum )
             {
-                plotter->text( wxPoint( (x1 + pin_pos.x) / 2, y1 - TXTMARGE ),
+                plotter->Text( wxPoint( (x1 + pin_pos.x) / 2, y1 - TXTMARGE ),
                                NumColor, StringPinNum,
                                TEXT_ORIENT_HORIZ, PinNumSize,
                                GR_TEXT_HJUSTIFY_CENTER,
@@ -1465,7 +1465,7 @@
                 y = y1 + TextInside;
 
                 if( DrawPinName )
-                    plotter->text( wxPoint( x1, y ), NameColor,
+                    plotter->Text( wxPoint( x1, y ), NameColor,
                                    m_name,
                                    TEXT_ORIENT_VERT, PinNameSize,
                                    GR_TEXT_HJUSTIFY_RIGHT,
@@ -1474,7 +1474,7 @@
 
                 if( DrawPinNum )
                 {
-                    plotter->text( wxPoint( x1 - TXTMARGE, (y1 + pin_pos.y) / 2 ),
+                    plotter->Text( wxPoint( x1 - TXTMARGE, (y1 + pin_pos.y) / 2 ),
                                    NumColor, StringPinNum,
                                    TEXT_ORIENT_VERT, PinNumSize,
                                    GR_TEXT_HJUSTIFY_CENTER,
@@ -1487,7 +1487,7 @@
                 y = y1 - TextInside;
 
                 if( DrawPinName )
-                    plotter->text( wxPoint( x1, y ), NameColor,
+                    plotter->Text( wxPoint( x1, y ), NameColor,
                                    m_name,
                                    TEXT_ORIENT_VERT, PinNameSize,
                                    GR_TEXT_HJUSTIFY_LEFT,
@@ -1496,7 +1496,7 @@
 
                 if( DrawPinNum )
                 {
-                    plotter->text( wxPoint( x1 - TXTMARGE, (y1 + pin_pos.y) / 2 ),
+                    plotter->Text( wxPoint( x1 - TXTMARGE, (y1 + pin_pos.y) / 2 ),
                                    NumColor, StringPinNum,
                                    TEXT_ORIENT_VERT, PinNumSize,
                                    GR_TEXT_HJUSTIFY_CENTER,
@@ -1514,7 +1514,7 @@
             if( DrawPinName )
             {
                 x = (x1 + pin_pos.x) / 2;
-                plotter->text( wxPoint( x, y1 - TXTMARGE ),
+                plotter->Text( wxPoint( x, y1 - TXTMARGE ),
                                NameColor, m_name,
                                TEXT_ORIENT_HORIZ, PinNameSize,
                                GR_TEXT_HJUSTIFY_CENTER,
@@ -1525,7 +1525,7 @@
             if( DrawPinNum )
             {
                 x = ( x1 + pin_pos.x ) / 2;
-                plotter->text( wxPoint( x, y1 + TXTMARGE ),
+                plotter->Text( wxPoint( x, y1 + TXTMARGE ),
                                NumColor, StringPinNum,
                                TEXT_ORIENT_HORIZ, PinNumSize,
                                GR_TEXT_HJUSTIFY_CENTER,
@@ -1538,7 +1538,7 @@
             if( DrawPinName )
             {
                 y = ( y1 + pin_pos.y ) / 2;
-                plotter->text( wxPoint( x1 - TXTMARGE, y ),
+                plotter->Text( wxPoint( x1 - TXTMARGE, y ),
                                NameColor, m_name,
                                TEXT_ORIENT_VERT, PinNameSize,
                                GR_TEXT_HJUSTIFY_CENTER,
@@ -1548,7 +1548,7 @@
 
             if( DrawPinNum )
             {
-                plotter->text( wxPoint( x1 + TXTMARGE, ( y1 + pin_pos.y ) / 2 ),
+                plotter->Text( wxPoint( x1 + TXTMARGE, ( y1 + pin_pos.y ) / 2 ),
                                NumColor, StringPinNum,
                                TEXT_ORIENT_VERT, PinNumSize,
                                GR_TEXT_HJUSTIFY_CENTER,
@@ -1808,7 +1808,7 @@
 
     wxPoint pos = aTransform.TransformCoordinate( m_position ) + offset;
 
-    plotter->set_current_line_width( GetPenSize() );
+    plotter->SetCurrentLineWidth( GetPenSize() );
     PlotSymbol( plotter, pos, orient );
     PlotPinTexts( plotter, pos, orient, GetParent()->GetPinNameOffset(),
                   GetParent()->ShowPinNumbers(), GetParent()->ShowPinNames(),

=== modified file 'eeschema/lib_polyline.cpp'
--- eeschema/lib_polyline.cpp	2012-04-13 18:51:24 +0000
+++ eeschema/lib_polyline.cpp	2012-04-30 09:18:58 +0000
@@ -241,13 +241,13 @@
 
     if( aFill && m_Fill == FILLED_WITH_BG_BODYCOLOR )
     {
-        aPlotter->set_color( ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
+        aPlotter->SetColor( ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
         aPlotter->PlotPoly( cornerList, FILLED_WITH_BG_BODYCOLOR, 0 );
         aFill = false;  // body is now filled, do not fill it later.
     }
 
     bool already_filled = m_Fill == FILLED_WITH_BG_BODYCOLOR;
-    aPlotter->set_color( ReturnLayerColor( LAYER_DEVICE ) );
+    aPlotter->SetColor( ReturnLayerColor( LAYER_DEVICE ) );
     aPlotter->PlotPoly( cornerList, already_filled ? NO_FILL : m_Fill, GetPenSize() );
 }
 

=== modified file 'eeschema/lib_rectangle.cpp'
--- eeschema/lib_rectangle.cpp	2012-04-13 18:51:24 +0000
+++ eeschema/lib_rectangle.cpp	2012-04-30 09:18:58 +0000
@@ -178,13 +178,13 @@
 
     if( aFill && m_Fill == FILLED_WITH_BG_BODYCOLOR )
     {
-        aPlotter->set_color( ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
-        aPlotter->rect( pos, end, FILLED_WITH_BG_BODYCOLOR, 0 );
+        aPlotter->SetColor( ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
+        aPlotter->Rect( pos, end, FILLED_WITH_BG_BODYCOLOR, 0 );
     }
 
     bool already_filled = m_Fill == FILLED_WITH_BG_BODYCOLOR;
-    aPlotter->set_color( ReturnLayerColor( LAYER_DEVICE ) );
-    aPlotter->rect( pos, end, already_filled ? NO_FILL : m_Fill, GetPenSize() );
+    aPlotter->SetColor( ReturnLayerColor( LAYER_DEVICE ) );
+    aPlotter->Rect( pos, end, already_filled ? NO_FILL : m_Fill, GetPenSize() );
 }
 
 

=== modified file 'eeschema/lib_text.cpp'
--- eeschema/lib_text.cpp	2012-04-13 18:51:24 +0000
+++ eeschema/lib_text.cpp	2012-04-30 09:18:58 +0000
@@ -318,7 +318,7 @@
     int t1  = ( aTransform.x1 != 0 ) ^ ( m_Orient != 0 );
     wxPoint pos = aTransform.TransformCoordinate( m_Pos ) + offset;
 
-    plotter->text( pos, UNSPECIFIED, m_Text,
+    plotter->Text( pos, UNSPECIFIED, m_Text,
                    t1 ? TEXT_ORIENT_HORIZ : TEXT_ORIENT_VERT,
                    m_Size, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
                    GetPenSize(), m_Italic, m_Bold );

=== modified file 'eeschema/sch_bus_entry.cpp'
--- eeschema/sch_bus_entry.cpp	2012-04-19 06:55:45 +0000
+++ eeschema/sch_bus_entry.cpp	2012-04-30 09:18:58 +0000
@@ -281,10 +281,10 @@
 
 void SCH_BUS_ENTRY::Plot( PLOTTER* aPlotter )
 {
-    aPlotter->set_current_line_width( GetPenSize() );
-    aPlotter->set_color( ReturnLayerColor( GetLayer() ) );
-    aPlotter->move_to( m_pos );
-    aPlotter->finish_to( m_End() );
+    aPlotter->SetCurrentLineWidth( GetPenSize() );
+    aPlotter->SetColor( ReturnLayerColor( GetLayer() ) );
+    aPlotter->MoveTo( m_pos );
+    aPlotter->FinishTo( m_End() );
 }
 
 /* SetBusEntryShape:

=== modified file 'eeschema/sch_field.cpp'
--- eeschema/sch_field.cpp	2012-03-26 23:47:08 +0000
+++ eeschema/sch_field.cpp	2012-04-30 09:18:58 +0000
@@ -579,7 +579,7 @@
 
     if( (parent->GetPartCount() <= 1) || (m_id != REFERENCE) )
     {
-        aPlotter->text( textpos, color, m_Text, orient, m_Size, hjustify, vjustify,
+        aPlotter->Text( textpos, color, m_Text, orient, m_Size, hjustify, vjustify,
                         thickness, m_Italic, m_Bold );
     }
     else    /* We plot the reference, for a multiple parts per package */
@@ -587,7 +587,7 @@
         /* Adding A, B ... to the reference */
         wxString Text = m_Text + LIB_COMPONENT::ReturnSubReference( parent->GetUnit() );
 
-        aPlotter->text( textpos, color, Text, orient, m_Size, hjustify, vjustify,
+        aPlotter->Text( textpos, color, Text, orient, m_Size, hjustify, vjustify,
                         thickness, m_Italic, m_Bold );
     }
 }

=== modified file 'eeschema/sch_junction.cpp'
--- eeschema/sch_junction.cpp	2012-03-17 14:39:27 +0000
+++ eeschema/sch_junction.cpp	2012-04-30 09:18:58 +0000
@@ -238,6 +238,6 @@
 
 void SCH_JUNCTION::Plot( PLOTTER* aPlotter )
 {
-    aPlotter->set_color( ReturnLayerColor( GetLayer() ) );
-    aPlotter->circle( m_pos, m_size.x, FILLED_SHAPE );
+    aPlotter->SetColor( ReturnLayerColor( GetLayer() ) );
+    aPlotter->Circle( m_pos, m_size.x, FILLED_SHAPE );
 }

=== modified file 'eeschema/sch_line.cpp'
--- eeschema/sch_line.cpp	2012-04-19 06:55:45 +0000
+++ eeschema/sch_line.cpp	2012-04-30 09:18:58 +0000
@@ -603,17 +603,17 @@
 
 void SCH_LINE::Plot( PLOTTER* aPlotter )
 {
-    aPlotter->set_color( ReturnLayerColor( GetLayer() ) );
-    aPlotter->set_current_line_width( GetPenSize() );
-
-    if( m_Layer == LAYER_NOTES )
-        aPlotter->set_dash( true );
-
-    aPlotter->move_to( m_start );
-    aPlotter->finish_to( m_end );
-
-    if( m_Layer == LAYER_NOTES )
-        aPlotter->set_dash( false );
+    aPlotter->SetColor( ReturnLayerColor( GetLayer() ) );
+    aPlotter->SetCurrentLineWidth( GetPenSize() );
+
+    if( m_Layer == LAYER_NOTES )
+        aPlotter->SetDash( true );
+
+    aPlotter->MoveTo( m_start );
+    aPlotter->FinishTo( m_end );
+
+    if( m_Layer == LAYER_NOTES )
+        aPlotter->SetDash( false );
 }
 
 

=== modified file 'eeschema/sch_no_connect.cpp'
--- eeschema/sch_no_connect.cpp	2012-03-17 14:39:27 +0000
+++ eeschema/sch_no_connect.cpp	2012-04-30 09:18:58 +0000
@@ -241,10 +241,11 @@
     pX = m_pos.x;
     pY = m_pos.y;
 
-    aPlotter->set_current_line_width( GetPenSize() );
-    aPlotter->set_color( ReturnLayerColor( GetLayer() ) );
-    aPlotter->move_to( wxPoint( pX - delta, pY - delta ) );
-    aPlotter->finish_to( wxPoint( pX + delta, pY + delta ) );
-    aPlotter->move_to( wxPoint( pX + delta, pY - delta ) );
-    aPlotter->finish_to( wxPoint( pX - delta, pY + delta ) );
+    aPlotter->SetCurrentLineWidth( GetPenSize() );
+    aPlotter->SetColor( ReturnLayerColor( GetLayer() ) );
+    aPlotter->MoveTo( wxPoint( pX - delta, pY - delta ) );
+    aPlotter->FinishTo( wxPoint( pX + delta, pY + delta ) );
+    aPlotter->MoveTo( wxPoint( pX + delta, pY - delta ) );
+    aPlotter->FinishTo( wxPoint( pX - delta, pY + delta ) );
 }
+

=== modified file 'eeschema/sch_screen.cpp'
--- eeschema/sch_screen.cpp	2012-04-12 21:31:31 +0000
+++ eeschema/sch_screen.cpp	2012-04-30 09:18:58 +0000
@@ -554,7 +554,7 @@
 {
     for( SCH_ITEM* item = m_drawList.begin();  item;  item = item->Next() )
     {
-        aPlotter->set_current_line_width( item->GetPenSize() );
+        aPlotter->SetCurrentLineWidth( item->GetPenSize() );
         item->Plot( aPlotter );
     }
 }

=== modified file 'eeschema/sch_sheet.cpp'
--- eeschema/sch_sheet.cpp	2012-04-19 06:55:45 +0000
+++ eeschema/sch_sheet.cpp	2012-04-30 09:18:58 +0000
@@ -1111,24 +1111,24 @@
     wxPoint     pos_sheetname, pos_filename;
     wxPoint     pos;
 
-    aPlotter->set_color( ReturnLayerColor( GetLayer() ) );
+    aPlotter->SetColor( ReturnLayerColor( GetLayer() ) );
 
     int thickness = GetPenSize();
-    aPlotter->set_current_line_width( thickness );
+    aPlotter->SetCurrentLineWidth( thickness );
 
-    aPlotter->move_to( m_pos );
+    aPlotter->MoveTo( m_pos );
     pos = m_pos;
     pos.x += m_size.x;
 
-    aPlotter->line_to( pos );
+    aPlotter->LineTo( pos );
     pos.y += m_size.y;
 
-    aPlotter->line_to( pos );
+    aPlotter->LineTo( pos );
     pos = m_pos;
     pos.y += m_size.y;
 
-    aPlotter->line_to( pos );
-    aPlotter->finish_to( m_pos );
+    aPlotter->LineTo( pos );
+    aPlotter->FinishTo( m_pos );
 
     if( IsVerticalOrientation() )
     {
@@ -1151,10 +1151,10 @@
     thickness = g_DrawDefaultLineThickness;
     thickness = Clamp_Text_PenSize( thickness, size, false );
 
-    aPlotter->set_color( ReturnLayerColor( LAYER_SHEETNAME ) );
+    aPlotter->SetColor( ReturnLayerColor( LAYER_SHEETNAME ) );
 
     bool italic = false;
-    aPlotter->text( pos_sheetname, txtcolor, Text, name_orientation, size,
+    aPlotter->Text( pos_sheetname, txtcolor, Text, name_orientation, size,
                     GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_BOTTOM,
                     thickness, italic, false );
 
@@ -1164,13 +1164,13 @@
     thickness = g_DrawDefaultLineThickness;
     thickness = Clamp_Text_PenSize( thickness, size, false );
 
-    aPlotter->set_color( ReturnLayerColor( LAYER_SHEETFILENAME ) );
+    aPlotter->SetColor( ReturnLayerColor( LAYER_SHEETFILENAME ) );
 
-    aPlotter->text( pos_filename, txtcolor, Text, name_orientation, size,
+    aPlotter->Text( pos_filename, txtcolor, Text, name_orientation, size,
                     GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_TOP,
                     thickness, italic, false );
 
-    aPlotter->set_color( ReturnLayerColor( GetLayer() ) );
+    aPlotter->SetColor( ReturnLayerColor( GetLayer() ) );
 
     /* Draw texts : SheetLabel */
     for( size_t i = 0; i < m_pins.size(); i++ )

=== modified file 'eeschema/sch_text.cpp'
--- eeschema/sch_text.cpp	2012-04-19 06:55:45 +0000
+++ eeschema/sch_text.cpp	2012-04-30 09:18:58 +0000
@@ -691,7 +691,7 @@
     wxPoint     textpos   = m_Pos + GetSchematicTextOffset();
     int         thickness = GetPenSize();
 
-    aPlotter->set_current_line_width( thickness );
+    aPlotter->SetCurrentLineWidth( thickness );
 
     if( m_MultilineAllowed )
     {
@@ -706,7 +706,7 @@
         for( unsigned i = 0; i<list->Count(); i++ )
         {
             wxString txt = list->Item( i );
-            aPlotter->text( pos, color, txt, m_Orient, m_Size, m_HJustify,
+            aPlotter->Text( pos, color, txt, m_Orient, m_Size, m_HJustify,
                             m_VJustify, thickness, m_Italic, m_Bold );
             pos += offset;
         }
@@ -715,14 +715,14 @@
     }
     else
     {
-        aPlotter->text( textpos, color, m_Text, m_Orient, m_Size, m_HJustify,
+        aPlotter->Text( textpos, color, m_Text, m_Orient, m_Size, m_HJustify,
                         m_VJustify, thickness, m_Italic, m_Bold );
     }
 
     /* Draw graphic symbol for global or hierarchical labels */
     CreateGraphicShape( Poly, m_Pos );
 
-    aPlotter->set_current_line_width( GetPenSize() );
+    aPlotter->SetCurrentLineWidth( GetPenSize() );
 
     if( Poly.size() )
         aPlotter->PlotPoly( Poly, NO_FILL );

=== modified file 'include/class_bitmap_base.h'
--- include/class_bitmap_base.h	2012-01-23 04:33:36 +0000
+++ include/class_bitmap_base.h	2012-04-30 09:18:58 +0000
@@ -191,7 +191,8 @@
      * @param aDefaultColor = the color used to plot the rectangle when bitmap is not supported
      * @param aDefaultPensize = the pen size used to plot the rectangle when bitmap is not supported
      */
-    void     PlotImage( PLOTTER* aPlotter, wxPoint aPos, int aDefaultColor, int aDefaultPensize );
+    void     PlotImage( PLOTTER* aPlotter, const wxPoint& aPos, 
+		        EDA_COLOR_T aDefaultColor, int aDefaultPensize );
 };
 
 


=== modified file 'include/convert_to_biu.h'
--- include/convert_to_biu.h	2012-04-26 21:34:20 +0000
+++ include/convert_to_biu.h	2012-04-30 09:18:58 +0000
@@ -55,6 +55,7 @@
 }
 
 #else            // Eeschema and anything else.
+#define IU_PER_DECIMILS  0.1
 #define IU_PER_MILS   1.0
 #define IU_PER_MM   (IU_PER_MILS / 0.0254)
 

=== modified file 'include/plot_common.h'
--- include/plot_common.h	2012-04-19 06:55:45 +0000
+++ include/plot_common.h	2012-04-30 09:18:58 +0000
@@ -1,6 +1,6 @@
 /**
  * Common plot library \n
- * Plot settings, postscript plotting, gerber plotting.
+ * Plot settings, and plotting engines (Postscript, Gerber, HPGL and DXF)
  *
  * @file plot_common.h
  */
@@ -9,6 +9,7 @@
 #define PLOT_COMMON_H_
 
 #include <vector>
+#include <vector2d.h>
 #include <drawtxt.h>
 #include <common.h>         // PAGE_INFO
 #include <eda_text.h>       // FILL_T
@@ -26,95 +27,160 @@
 };
 
 
+/**
+ * Base plotter engine class. General rule: all the interface with the caller
+ * is done in IU, the IU size is specified with SetViewport. Internal and
+ * output processing is usually done in decimils (or whatever unit the
+ * effective engine class need to use)
+ */
 class PLOTTER
 {
 public:
-    PLOTTER( PlotFormat aPlotType );
+    PLOTTER( );
 
     virtual ~PLOTTER()
     {
         // Emergency cleanup
-        if( output_file )
+        if( outputFile )
         {
-            fclose( output_file );
+            fclose( outputFile );
         }
     }
 
-
     /**
-     * Function GetPlotterType
-     * @return the format of the plot file
+     * Returns the effective plot engine in use. It's not very OO but for
+     * now is required since some things are only done with some output devices
+     * (like drill marks, emitted only for postscript
      */
-    PlotFormat GetPlotterType()    { return m_PlotType; }
-
-    virtual bool start_plot( FILE* fout ) = 0;
-    virtual bool end_plot() = 0;
-
-    virtual void set_negative( bool _negative )
-    {
-        negative_mode = _negative;
-    }
-
-    virtual void set_color_mode( bool _color_mode )
-    {
-        color_mode = _color_mode;
-    }
-
-    bool get_color_mode() const
-    {
-        return color_mode;
+    virtual PlotFormat GetPlotterType() const = 0;
+
+    virtual bool StartPlot( FILE* fout ) = 0;
+    virtual bool EndPlot() = 0;
+
+    virtual void SetNegative( bool _negative )
+    {
+        negativeMode = _negative;
+    }
+
+    virtual void SetColorMode( bool _color_mode )
+    {
+        colorMode = _color_mode;
+    }
+
+    bool GetColorMode() const
+    {
+        return colorMode;
     }
 
     void SetPageSettings( const PAGE_INFO& aPageSettings );
 
-    virtual void set_current_line_width( int width ) = 0;
-    virtual void set_default_line_width( int width ) = 0;
-    virtual void set_color( int color )  = 0;
-    virtual void set_dash( bool dashed ) = 0;
-
-    virtual int get_current_line_width()
-    {
-        return current_pen_width;
-    }
-
-    virtual void set_plot_width_adj( double width )
-    {
-    }
-
-    virtual double get_plot_width_adj()
+    /**
+     * Set the line width for the next drawing. 
+     * @param width is specified in IUs
+     */
+    virtual void SetCurrentLineWidth( int width ) = 0;
+
+    /**
+     * Set the default line width. Used at the beginning and when a width 
+     * of -1 is requested. 
+     * @param width is specified in IUs
+     */
+    virtual void SetDefaultLineWidth( int width ) = 0;
+
+    virtual int GetCurrentLineWidth() const
+    {
+        return currentPenWidth;
+    }
+
+    virtual void SetColor( EDA_COLOR_T color ) = 0;
+
+    virtual void SetDash( bool dashed ) = 0;
+
+    /** PLEASE NOTE: the plot width adjustment is actually done by the
+     * pcbnew routines, the plotter class only carry it along! 
+     * XXX In fact it's only used during postscript plot, I'd move this
+     * variable as a static in pcbnew/plot_rtn.cpp. Also: why it's double?
+     * it's added to pad/track size and it's specified in IU, so it should
+     * be an int */
+    virtual void SetPlotWidthAdj( double width )
+    {
+    }
+
+    virtual double GetPlotWidthAdj()
     {
         return 0.;
     }
 
-    virtual void set_creator( const wxString& _creator )
+    virtual void SetCreator( const wxString& _creator )
     {
         creator = _creator;
     }
 
-    virtual void set_filename( const wxString& _filename )
+    virtual void SetFilename( const wxString& _filename )
     {
         filename = _filename;
     }
 
-    /// Set the plot offset for the current plotting
-    virtual void set_viewport( wxPoint aOffset, double aScale, bool aMirror ) = 0;
+    /**
+     * Set the plot offset and scaling for the current plot
+     * @param aIusPerDecimil gives the scaling factor from IUs to device
+     *		units
+     * @param aScale is the user set plot scaling factor (either explicitly
+     * 		or using 'fit to A4')
+     * @param aMirror flips the plot in the Y direction (useful for toner
+     * 		transfers or some kind of film)
+     */
+    virtual void SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
+	    double aScale, bool aMirror ) = 0;
 
-    // Standard primitives
-    virtual void rect( wxPoint p1, wxPoint p2, FILL_T fill,
+    // Low level primitives
+    virtual void Rect( const wxPoint& p1, const wxPoint& p2, FILL_T fill,
                        int width = -1 ) = 0;
-    virtual void circle( wxPoint pos, int diametre, FILL_T fill,
+    virtual void Circle( const wxPoint& pos, int diametre, FILL_T fill,
                          int width = -1 ) = 0;
-    virtual void arc( wxPoint centre, int StAngle, int EndAngle, int rayon,
+    virtual void Arc( const wxPoint& centre, int StAngle, int EndAngle, int rayon,
                       FILL_T fill, int width = -1 );
 
     /**
+     * moveto/lineto primitive, moves the 'pen' to the specified direction
+     * @param plume specifies the kind of motion: 'U' only moves the pen,
+     * 		'D' draw a line from the current position and 'Z' finish
+     *		the drawing and returns the 'pen' to rest (flushes the trace)
+     */
+    virtual void PenTo( const wxPoint& pos, char plume ) = 0;
+
+    // Convenience functions for PenTo
+    void MoveTo( const wxPoint& pos )
+    {
+        PenTo( pos, 'U' );
+    }
+
+    void LineTo( const wxPoint& pos )
+    {
+        PenTo( pos, 'D' );
+    }
+
+    void FinishTo( const wxPoint& pos )
+    {
+        PenTo( pos, 'D' );
+        PenTo( pos, 'Z' );
+    }
+
+    void PenFinish()
+    {
+        // The point is not important with Z motion
+        PenTo( wxPoint( 0, 0 ), 'Z' );
+    }
+
+    /**
      * Function PlotPoly
      * @brief Draw a polygon ( filled or not )
      * @param aCornerList = corners list
-     * @param aFill :if true : filled polygon
+     * @param aFill = type of fill
      * @param aWidth = line width
      */
-    virtual void PlotPoly( std::vector< wxPoint >& aCornerList, FILL_T aFill, int aWidth = -1 ) = 0;
+    virtual void PlotPoly( const std::vector< wxPoint >& aCornerList, FILL_T aFill, 
+			   int aWidth = -1 ) = 0;
 
     /**
      * Function PlotImage
@@ -126,60 +192,43 @@
      * @param aScaleFactor = the scale factor to apply to the bitmap size
      *                      (this is not the plot scale factor)
      */
-    virtual void PlotImage( wxImage & aImage, wxPoint aPos, double aScaleFactor ) = 0;
+    virtual void PlotImage( const wxImage & aImage, const wxPoint& aPos, 
+                            double aScaleFactor );
 
-    virtual void thick_segment( wxPoint start, wxPoint end, int width,
-                                EDA_DRAW_MODE_T tracemode );
-    virtual void thick_arc( wxPoint centre, int StAngle, int EndAngle, int rayon,
-                            int width, EDA_DRAW_MODE_T tracemode );
-    virtual void thick_rect( wxPoint p1, wxPoint p2, int width,
-                             EDA_DRAW_MODE_T tracemode );
-    virtual void thick_circle( wxPoint pos, int diametre, int width,
+    // Higher level primitives -- can be drawn as line, sketch or 'filled' 
+    virtual void ThickSegment( const wxPoint& start, const wxPoint& end, int width,
                                EDA_DRAW_MODE_T tracemode );
-    virtual void pen_to( wxPoint pos, char plume ) = 0;
+    virtual void ThickArc( const wxPoint& centre, int StAngle, int EndAngle, int rayon,
+                           int width, EDA_DRAW_MODE_T tracemode );
+    virtual void ThickRect( const wxPoint& p1, const wxPoint& p2, int width,
+                            EDA_DRAW_MODE_T tracemode );
+    virtual void ThickCircle( const wxPoint& pos, int diametre, int width,
+                              EDA_DRAW_MODE_T tracemode );
 
     // Flash primitives
-    virtual void flash_pad_circle( wxPoint pos, int diametre,
-                                   EDA_DRAW_MODE_T trace_mode ) = 0;
-    virtual void flash_pad_oval( wxPoint pos, wxSize size, int orient,
+    virtual void FlashPadCircle( const wxPoint& pos, int diametre,
                                  EDA_DRAW_MODE_T trace_mode ) = 0;
-    virtual void flash_pad_rect( wxPoint pos, wxSize size,
-                                 int orient, EDA_DRAW_MODE_T trace_mode ) = 0;
+    virtual void FlashPadOval( const wxPoint& pos, const wxSize& size, int orient,
+                               EDA_DRAW_MODE_T trace_mode ) = 0;
+    virtual void FlashPadRect( const wxPoint& pos, const wxSize& size,
+                               int orient, EDA_DRAW_MODE_T trace_mode ) = 0;
 
-    /** virtual function flash_pad_trapez
+    /** virtual function FlashPadTrapez
      * flash a trapezoidal pad
      * @param aPadPos = the position of the shape
-     * @param aCorners = the list of 4 corners positions, relative to the shape position, pad orientation 0
+     * @param aCorners = the list of 4 corners positions, 
+     * 		relative to the shape position, pad orientation 0
      * @param aPadOrient = the rotation of the shape
      * @param aTrace_Mode = FILLED or SKETCH
      */
-    virtual void flash_pad_trapez( wxPoint aPadPos, wxPoint aCorners[4],
-                                   int aPadOrient, EDA_DRAW_MODE_T aTrace_Mode ) = 0;
-
-    // Convenience functions
-    void move_to( wxPoint pos )
-    {
-        pen_to( pos, 'U' );
-    }
-
-    void line_to( wxPoint pos )
-    {
-        pen_to( pos, 'D' );
-    }
-
-    void finish_to( wxPoint pos )
-    {
-        pen_to( pos, 'D' );
-        pen_to( pos, 'Z' );
-    }
-
-    void pen_finish()
-    {
-        // Shortcut
-        pen_to( wxPoint( 0, 0 ), 'Z' );
-    }
-
-    void text( const wxPoint&              aPos,
+    virtual void FlashPadTrapez( const wxPoint& aPadPos, const wxPoint *aCorners,
+                                 int aPadOrient, EDA_DRAW_MODE_T aTrace_Mode ) = 0;
+
+
+    /**
+     * Draws text with the plotter. For convenience it accept the color to use
+     */
+    void Text( const wxPoint&              aPos,
                enum EDA_COLOR_T            aColor,
                const wxString&             aText,
                int                         aOrient,
@@ -190,234 +239,234 @@
                bool                        aItalic,
                bool                        aBold );
 
-    void marker( const wxPoint& position, int diametre, int aShapeId );
+    /**
+     * Draw a marker (used for the drill map)
+     */
+    static const unsigned MARKER_COUNT = 58;
+    void Marker( const wxPoint& position, int diametre, unsigned aShapeId );
 
     /**
      * Function SetLayerPolarity
      * sets current Gerber layer polarity to positive or negative
      * by writing \%LPD*\% or \%LPC*\% to the Gerber file, respectively.
+     * (obviously starts a new Gerber layer, too)
      * @param aPositive is the layer polarity and true for positive.
+     * It's not useful with most other plotter since they can't 'scratch'
+     * the film like photoplotter imagers do
      */
-    virtual void   SetLayerPolarity( bool aPositive ) = 0;
+    virtual void SetLayerPolarity( bool aPositive ) = 0;
 
 protected:
     // These are marker subcomponents
-    void           center_square( const wxPoint& position, int diametre, FILL_T fill );
-    void           center_lozenge( const wxPoint& position, int diametre, FILL_T fill );
+    void markerCircle( const wxPoint& pos, int radius );
+    void markerHBar( const wxPoint& pos, int radius );
+    void markerSlash( const wxPoint& pos, int radius );
+    void markerBackSlash( const wxPoint& pos, int radius );
+    void markerVBar( const wxPoint& pos, int radius );
+    void markerSquare( const wxPoint& position, int radius );
+    void markerLozenge( const wxPoint& position, int radius );
 
     // Helper function for sketched filler segment
-    void           segment_as_oval( wxPoint start, wxPoint end, int width,
-                                    EDA_DRAW_MODE_T tracemode );
-    void           sketch_oval( wxPoint pos, wxSize size, int orient, int width );
-
-    virtual void   user_to_device_coordinates( wxPoint& pos );
-    virtual void   user_to_device_size( wxSize& size );
-    virtual double user_to_device_size( double size );
-
-    PlotFormat    m_PlotType;
-
-    /// Plot scale
-    double        plot_scale;
-
-    /// Device scale (from decimils to device units)
-    double        device_scale;
-
-    /// Plot offset (in decimils)
-    wxPoint       plot_offset;
+    void segmentAsOval( const wxPoint& start, const wxPoint& end, int width,
+                          EDA_DRAW_MODE_T tracemode );
+    void sketchOval( const wxPoint& pos, const wxSize& size, int orient, 
+                      int width );
+
+    // Coordinate and scaling conversion functions
+    virtual DPOINT userToDeviceCoordinates( const wxPoint& pos );
+    virtual DPOINT userToDeviceSize( const wxSize& size );
+    virtual double userToDeviceSize( double size );
+
+    /// Plot scale - chosen by the user (even implicitly with 'fit in a4')
+    double        plotScale;
+
+    /// Device scale (from IUs to device units - usually decimils)
+    double        iuPerDeviceUnit;
+
+    /// Plot offset (in IUs)
+    wxPoint       plotOffset;
 
     /// Output file
-    FILE*         output_file;
+    FILE*         outputFile;
 
     // Pen handling
-    bool          color_mode, negative_mode;
-    int           default_pen_width;
-    int           current_pen_width;
-    char          pen_state;
-    wxPoint       pen_lastpos;
+    bool          colorMode, negativeMode;
+    int           defaultPenWidth;
+    int           currentPenWidth;
+    /// Current pen state: 'U', 'D' or 'Z' (see PenTo)
+    char          penState;
+    /// Last pen positions; set to -1,-1 when the pen is at rest
+    wxPoint       penLastpos;
     bool          plotMirror;
     wxString      creator;
     wxString      filename;
     PAGE_INFO     pageInfo;
-    wxSize        paper_size;
+    /// Paper size in IU - not in mils
+    wxSize        paperSize;
 };
 
 
 class HPGL_PLOTTER : public PLOTTER
 {
 public:
-    HPGL_PLOTTER() :
-        PLOTTER( PLOT_FORMAT_HPGL )
-    {
-    }
-
-    virtual bool start_plot( FILE* fout );
-    virtual bool end_plot();
-
-    // HPGL doesn't handle line thickness or color
-    virtual void set_current_line_width( int width )
-    {
-        // Handy override
-        current_pen_width = KiROUND( pen_diameter );
-    }
-
-    virtual void set_default_line_width( int width ) {};
-    virtual void set_dash( bool dashed );
-
-    virtual void set_color( int color ) {};
-
-    virtual void set_pen_speed( int speed )
-    {
-        wxASSERT( output_file == 0 );
-        pen_speed = speed;
-    }
-
-    virtual void set_pen_number( int number )
-    {
-        wxASSERT( output_file == 0 );
-        pen_number = number;
-    }
-
-    virtual void set_pen_diameter( double diameter )
-    {
-        wxASSERT( output_file == 0 );
-        pen_diameter = diameter;
-    }
-
-    virtual void set_pen_overlap( double overlap )
-    {
-        wxASSERT( output_file == 0 );
-        pen_overlap = overlap;
-    }
-
-    virtual void set_viewport( wxPoint aOffset, double aScale, bool aMirror );
-    virtual void rect( wxPoint p1, wxPoint p2, FILL_T fill, int width = -1 );
-    virtual void circle( wxPoint pos, int diametre, FILL_T fill, int width = -1 );
-
-    /*
-     * Function PlotPoly
-     * Draw a polygon (filled or not) in HPGL format
-     * param aCornerList = corners list
-     * param aFill :if true : filled polygon
-     * param aWidth = line width
-     */
-    virtual void PlotPoly( std::vector< wxPoint >& aCornerList, FILL_T aFill, int aWidth = -1);
-
-    /*
-     * Function PlotImage
-     * Only Postscript plotters can plot bitmaps
-     * for plotters that cannot plot a bitmap, a rectangle is plotted
-     * Draw an image bitmap
-     * param aImage = the bitmap
-     * param aPos = position of the center of the bitmap
-     * param aScaleFactor = the scale factor to apply to the bitmap size
-     *                      (this is not the plot scale factor)
-     */
-    virtual void PlotImage( wxImage & aImage, wxPoint aPos, double aScaleFactor );
-
-    virtual void thick_segment( wxPoint start, wxPoint end, int width,
-                                EDA_DRAW_MODE_T tracemode );
-    virtual void arc( wxPoint centre, int StAngle, int EndAngle, int rayon,
+    HPGL_PLOTTER() 
+    {
+    }
+
+    virtual PlotFormat GetPlotterType() const
+    {
+	return PLOT_FORMAT_HPGL;
+    }
+
+    virtual bool StartPlot( FILE* fout );
+    virtual bool EndPlot();
+
+    /// HPGL doesn't handle line thickness or color
+    virtual void SetCurrentLineWidth( int width )
+    {
+        // This is the truth
+        currentPenWidth = userToDeviceSize( penDiameter );
+    }
+
+    virtual void SetDefaultLineWidth( int width ) {};
+    virtual void SetDash( bool dashed );
+
+    virtual void SetColor( EDA_COLOR_T color ) {};
+
+    virtual void SetPenSpeed( int speed )
+    {
+        wxASSERT( outputFile == 0 );
+        penSpeed = speed;
+    }
+
+    virtual void SetPenNumber( int number )
+    {
+        wxASSERT( outputFile == 0 );
+        penNumber = number;
+    }
+
+    virtual void SetPenDiameter( double diameter )
+    {
+        wxASSERT( outputFile == 0 );
+        penDiameter = diameter;
+    }
+
+    virtual void SetPenOverlap( double overlap )
+    {
+        wxASSERT( outputFile == 0 );
+        penOverlap = overlap;
+    }
+
+    virtual void SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
+			      double aScale, bool aMirror );
+    virtual void Rect( const wxPoint& p1, const wxPoint& p2, FILL_T fill, 
+		       int width = -1 );
+    virtual void Circle( const wxPoint& pos, int diametre, FILL_T fill, 
+                         int width = -1 );
+    virtual void PlotPoly( const std::vector< wxPoint >& aCornerList, 
+                           FILL_T aFill, int aWidth = -1);
+
+    virtual void ThickSegment( const wxPoint& start, const wxPoint& end, int width,
+                               EDA_DRAW_MODE_T tracemode );
+    virtual void Arc( const wxPoint& centre, int StAngle, int EndAngle, int rayon,
                       FILL_T fill, int width = -1 );
-    virtual void pen_to( wxPoint pos, char plume );
-    virtual void flash_pad_circle( wxPoint pos, int diametre,
-                                   EDA_DRAW_MODE_T trace_mode );
-    virtual void flash_pad_oval( wxPoint pos, wxSize size, int orient,
+    virtual void PenTo( const wxPoint& pos, char plume );
+    virtual void FlashPadCircle( const wxPoint& pos, int diametre,
                                  EDA_DRAW_MODE_T trace_mode );
-    virtual void flash_pad_rect( wxPoint pos, wxSize size,
-                                 int orient, EDA_DRAW_MODE_T trace_mode );
-
-    virtual void flash_pad_trapez( wxPoint aPadPos, wxPoint aCorners[4],
-                                   int aPadOrient, EDA_DRAW_MODE_T aTrace_Mode );
+    virtual void FlashPadOval( const wxPoint& pos, const wxSize& size, int orient,
+                               EDA_DRAW_MODE_T trace_mode );
+    virtual void FlashPadRect( const wxPoint& pos, const wxSize& size,
+                               int orient, EDA_DRAW_MODE_T trace_mode );
+    virtual void FlashPadTrapez( const wxPoint& aPadPos, const wxPoint *aCorners,
+                                 int aPadOrient, EDA_DRAW_MODE_T aTrace_Mode );
 
     virtual void SetLayerPolarity( bool aPositive ) {}
 
 protected:
-    void pen_control( int plume );
+    void penControl( char plume );
 
-    int    pen_speed;
-    int    pen_number;
-    double pen_diameter;
-    double pen_overlap;
+    int    penSpeed;
+    int    penNumber;
+    double penDiameter;
+    double penOverlap;
 };
 
 
 class PS_PLOTTER : public PLOTTER
 {
 public:
-    PS_PLOTTER() :
-        PLOTTER( PLOT_FORMAT_POST )
-    {
-        plot_scale_adjX = 1;
-        plot_scale_adjY = 1;
-    }
-
-    virtual bool start_plot( FILE* fout );
-    virtual bool end_plot();
-    virtual void set_current_line_width( int width );
-    virtual void set_default_line_width( int width );
-    virtual void set_dash( bool dashed );
-    virtual void set_color( int color );
-
-    void set_scale_adjust( double scaleX, double scaleY )
-    {
-        plot_scale_adjX = scaleX;
-        plot_scale_adjY = scaleY;
-    }
-
-    virtual void set_plot_width_adj( double width )
-    {
-        plot_width_adj = width;
-    }
-
-    virtual double get_plot_width_adj()
-    {
-        return plot_width_adj;
-    }
-
-    virtual void set_viewport( wxPoint aOffset, double aScale, bool aMirror );
-    virtual void rect( wxPoint p1, wxPoint p2, FILL_T fill, int width = -1 );
-    virtual void circle( wxPoint pos, int diametre, FILL_T fill, int width = -1 );
-    virtual void arc( wxPoint centre, int StAngle, int EndAngle, int rayon,
-                      FILL_T fill, int width = -1 );
-    /*
-     * Function PlotPoly
-     * Draw a polygon (filled or not) in POSTSCRIPT format
-     * param aCornerList = corners list
-     * param aFill :if true : filled polygon
-     * param aWidth = line width
-     */
-    virtual void PlotPoly( std::vector< wxPoint >& aCornerList, FILL_T aFill, int aWidth = -1);
-
-    /*
-     * Function PlotImage
-     * Only Postscript plotters can plot bitmaps
-     * for plotters that cannot plot a bitmap, a rectangle is plotted
-     * Draw an image bitmap
-     * param aImage = the bitmap
-     * param aPos = position of the center of the bitmap
-     * param aScaleFactor = the scale factor to apply to the bitmap size
-     *                      (this is not the plot scale factor)
-     */
-    virtual void PlotImage( wxImage & aImage, wxPoint aPos, double aScaleFactor );
-
-    virtual void pen_to( wxPoint pos, char plume );
-    virtual void flash_pad_circle( wxPoint pos, int diametre,
+    PS_PLOTTER()
+    {
+        plotScaleAdjX = 1;
+        plotScaleAdjY = 1;
+    }
+
+    virtual PlotFormat GetPlotterType() const
+    {
+	return PLOT_FORMAT_POST;
+    }
+
+    virtual bool StartPlot( FILE* fout );
+    virtual bool EndPlot();
+    virtual void SetCurrentLineWidth( int width );
+    virtual void SetDefaultLineWidth( int width );
+    virtual void SetDash( bool dashed );
+    virtual void SetColor( EDA_COLOR_T color );
+
+    /** 
+     * Set the 'fine' scaling for the postscript engine 
+     */
+    void SetScaleAdjust( double scaleX, double scaleY )
+    {
+        plotScaleAdjX = scaleX;
+        plotScaleAdjY = scaleY;
+    }
+
+    /**
+     * Set the 'width adjustment' for the postscript engine 
+     * (useful for controlling toner bleeding during direct transfer)
+     */
+    virtual void SetPlotWidthAdj( double width )
+    {
+        plotWidthAdj = width;
+    }
+
+    virtual double GetPlotWidthAdj() const
+    {
+        return plotWidthAdj;
+    }
+
+    virtual void SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
+			      double aScale, bool aMirror );
+    virtual void Rect( const wxPoint& p1, const wxPoint& p2, FILL_T fill, 
+                       int width = -1 );
+    virtual void Circle( const wxPoint& pos, int diametre, FILL_T fill, 
+                         int width = -1 );
+    virtual void Arc( const wxPoint& centre, int StAngle, int EndAngle, 
+		      int rayon, FILL_T fill, int width = -1 );
+
+    virtual void PlotPoly( const std::vector< wxPoint >& aCornerList, 
+                           FILL_T aFill, int aWidth = -1);
+
+    virtual void PlotImage( const wxImage& aImage, const wxPoint& aPos, 
+                            double aScaleFactor );
+
+    virtual void PenTo( const wxPoint& pos, char plume );
+    virtual void FlashPadCircle( const wxPoint& pos, int diametre,
                                    EDA_DRAW_MODE_T trace_mode );
-    virtual void flash_pad_oval( wxPoint pos, wxSize size, int orient,
+    virtual void FlashPadOval( const wxPoint& pos, const wxSize& size, int orient,
                                  EDA_DRAW_MODE_T trace_mode );
-    virtual void flash_pad_rect( wxPoint pos, wxSize size,
+    virtual void FlashPadRect( const wxPoint& pos, const wxSize& size,
                                  int orient, EDA_DRAW_MODE_T trace_mode );
 
-    virtual void flash_pad_trapez( wxPoint aPadPos, wxPoint aCorners[4],
+    virtual void FlashPadTrapez( const wxPoint& aPadPos, const wxPoint *aCorners,
                                    int aPadOrient, EDA_DRAW_MODE_T aTrace_Mode );
 
     virtual void SetLayerPolarity( bool aPositive ) {}
 
-    void   user_to_device_coordinates( wxPoint& pos );      // overload
-
 protected:
-    double plot_scale_adjX, plot_scale_adjY;
-    double plot_width_adj;
+    double plotScaleAdjX, plotScaleAdjY;
+    double plotWidthAdj;
 };
 
 /* Class to handle a D_CODE when plotting a board : */
@@ -425,166 +474,142 @@
 
 struct APERTURE
 {
-    enum Aperture_Type {
+    enum APERTURE_TYPE {
         Circle   = 1,
         Rect     = 2,
         Plotting = 3,
         Oval     = 4
     };
 
-    wxSize        size;     // horiz and Vert size
-    Aperture_Type type;     // Type ( Line, rect , circulaire , ovale .. )
-    int           D_code;   // code number ( >= 10 );
+    wxSize        Size;     // horiz and Vert size
+    APERTURE_TYPE Type;     // Type ( Line, rect , circulaire , ovale .. )
+    int           DCode;    // code number ( >= 10 );
 
     /* Trivia question: WHY Gerber decided to use D instead of the usual T for
-     *  tool change? */
+     * tool change? */
 };
 
 
 class GERBER_PLOTTER : public PLOTTER
 {
 public:
-    GERBER_PLOTTER() :
-        PLOTTER( PLOT_FORMAT_GERBER )
-    {
-        work_file  = 0;
-        final_file = 0;
-        current_aperture = apertures.end();
-    }
-
-    virtual bool start_plot( FILE* fout );
-    virtual bool end_plot();
-    virtual void set_current_line_width( int width );
-    virtual void set_default_line_width( int width );
+    GERBER_PLOTTER()
+    {
+        workFile  = 0;
+        finalFile = 0;
+        currentAperture = apertures.end();
+    }
+
+    virtual PlotFormat GetPlotterType() const
+    {
+	return PLOT_FORMAT_GERBER;
+    }
+
+    virtual bool StartPlot( FILE* fout );
+    virtual bool EndPlot();
+    virtual void SetCurrentLineWidth( int width );
+    virtual void SetDefaultLineWidth( int width );
 
     // RS274X has no dashing, nor colours
-    virtual void set_dash( bool dashed ) {};
-    virtual void set_color( int color ) {};
-    virtual void set_viewport( wxPoint aOffset, double aScale, bool aMirror );
-    virtual void rect( wxPoint p1, wxPoint p2, FILL_T fill, int width = -1 );
-    virtual void circle( wxPoint pos, int diametre, FILL_T fill, int width = -1 );
-    /*
-     * Function PlotPoly
-     * Draw a polygon (filled or not) in GERBER format
-     * param aCornerList = corners list
-     * param aFill :if true : filled polygon
-     * param aWidth = line width
-     */
-    virtual void PlotPoly( std::vector< wxPoint >& aCornerList, FILL_T aFill, int aWidth = -1);
-
-    /*
-     * Function PlotImage
-     * Only Postscript plotters can plot bitmaps
-     * for plotters that cannot plot a bitmap, a rectangle is plotted
-     * Draw an image bitmap
-     * param aImage = the bitmap
-     * param aPos = position of the center of the bitmap
-     * param aScaleFactor = the scale factor to apply to the bitmap size
-     *                      (this is not the plot scale factor)
-     */
-    virtual void PlotImage( wxImage & aImage, wxPoint aPos, double aScaleFactor );
-
-    virtual void pen_to( wxPoint pos, char plume );
-    virtual void flash_pad_circle( wxPoint pos, int diametre,
-                                   EDA_DRAW_MODE_T trace_mode );
-    virtual void flash_pad_oval( wxPoint pos, wxSize size, int orient,
+    virtual void SetDash( bool dashed ) {};
+    virtual void SetColor( EDA_COLOR_T color ) {};
+    virtual void SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
+	                      double aScale, bool aMirror );
+    virtual void Rect( const wxPoint& p1, const wxPoint& p2, FILL_T fill, 
+                       int width = -1 );
+    virtual void Circle( const wxPoint& pos, int diametre, FILL_T fill, 
+                         int width = -1 );
+    virtual void PlotPoly( const std::vector< wxPoint >& aCornerList, 
+                           FILL_T aFill, int aWidth = -1);
+
+    virtual void PenTo( const wxPoint& pos, char plume );
+    virtual void FlashPadCircle( const wxPoint& pos, int diametre,
                                  EDA_DRAW_MODE_T trace_mode );
-    virtual void flash_pad_rect( wxPoint pos, wxSize size,
-                                 int orient, EDA_DRAW_MODE_T trace_mode );
-
-    virtual void flash_pad_trapez( wxPoint aPadPos, wxPoint aCorners[4],
-                                   int aPadOrient, EDA_DRAW_MODE_T aTrace_Mode );
-
-    virtual void                    SetLayerPolarity( bool aPositive );
+    virtual void FlashPadOval( const wxPoint& pos, const wxSize& size, int orient,
+                               EDA_DRAW_MODE_T trace_mode );
+    virtual void FlashPadRect( const wxPoint& pos, const wxSize& size,
+                               int orient, EDA_DRAW_MODE_T trace_mode );
+
+    virtual void FlashPadTrapez( const wxPoint& aPadPos, const wxPoint *aCorners,
+                                 int aPadOrient, EDA_DRAW_MODE_T aTrace_Mode );
+
+    virtual void SetLayerPolarity( bool aPositive );
 
 protected:
-    void  select_aperture( const wxSize& size, APERTURE::Aperture_Type type );
+    void selectAperture( const wxSize& size, APERTURE::APERTURE_TYPE type );
+    void emitDcode( const DPOINT& pt, int dcode );
 
     std::vector<APERTURE>::iterator
-                        get_aperture( const wxSize& size, APERTURE::Aperture_Type type );
+	getAperture( const wxSize& size, APERTURE::APERTURE_TYPE type );
 
-    FILE*    work_file, * final_file;
+    FILE* workFile;
+    FILE* finalFile;
     wxString m_workFilename;
 
-    void write_aperture_list();
+    void writeApertureList();
 
     std::vector<APERTURE>           apertures;
-    std::vector<APERTURE>::iterator current_aperture;
+    std::vector<APERTURE>::iterator currentAperture;
 };
 
 
 class DXF_PLOTTER : public PLOTTER
 {
 public:
-    DXF_PLOTTER() :
-        PLOTTER( PLOT_FORMAT_DXF )
-    {
-    }
-
-
-    virtual bool start_plot( FILE* fout );
-    virtual bool end_plot();
+    DXF_PLOTTER()
+    {
+    }
+
+    virtual PlotFormat GetPlotterType() const
+    {
+	return PLOT_FORMAT_DXF;
+    }
+
+    virtual bool StartPlot( FILE* fout );
+    virtual bool EndPlot();
 
     // For now we don't use 'thick' primitives, so no line width
-    virtual void set_current_line_width( int width )
+    virtual void SetCurrentLineWidth( int width )
     {
-        // Handy override
-        current_pen_width = 0;
+        currentPenWidth = 0;
     }
 
-    virtual void set_default_line_width( int width )
+    virtual void SetDefaultLineWidth( int width )
     {
         // DXF lines are infinitesimal
-        default_pen_width = 0;
+        defaultPenWidth = 0;
     }
 
-    virtual void set_dash( bool dashed );
-
-    virtual void set_color( int color );
-
-    virtual void set_viewport( wxPoint aOffset, double aScale, bool aMirror );
-    virtual void rect( wxPoint p1, wxPoint p2, FILL_T fill, int width = -1 );
-    virtual void circle( wxPoint pos, int diametre, FILL_T fill, int width = -1 );
-    /*
-     * Function PlotPoly
-     * Draw a polygon (filled or not) in DXF format
-     * param aCornerList = corners list
-     * param aFill :if true : filled polygon
-     * param aWidth = line width
-     */
-    virtual void PlotPoly( std::vector< wxPoint >& aCornerList, FILL_T aFill, int aWidth = -1 );
-
-    /*
-     * Function PlotImage
-     * Only Postscript plotters can plot bitmaps
-     * for plotters that cannot plot a bitmap, a rectangle is plotted
-     * Draw an image bitmap
-     * param aImage = the bitmap
-     * param aPos = position of the center of the bitmap
-     * param aScaleFactor = the scale factor to apply to the bitmap size
-     *                      (this is not the plot scale factor)
-     */
-    virtual void PlotImage( wxImage & aImage, wxPoint aPos, double aScaleFactor );
-
-    virtual void thick_segment( wxPoint start, wxPoint end, int width,
-                                EDA_DRAW_MODE_T tracemode );
-    virtual void arc( wxPoint centre, int StAngle, int EndAngle, int rayon,
+    virtual void SetDash( bool dashed );
+
+    virtual void SetColor( EDA_COLOR_T color );
+
+    virtual void SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
+			      double aScale, bool aMirror );
+    virtual void Rect( const wxPoint& p1, const wxPoint& p2, FILL_T fill, 
+                       int width = -1 );
+    virtual void Circle( const wxPoint& pos, int diametre, FILL_T fill, 
+                         int width = -1 );
+    virtual void PlotPoly( const std::vector< wxPoint >& aCornerList, 
+                           FILL_T aFill, int aWidth = -1 );
+    virtual void ThickSegment( const wxPoint& start, const wxPoint& end, int width,
+                               EDA_DRAW_MODE_T tracemode );
+    virtual void Arc( const wxPoint& centre, int StAngle, int EndAngle, int rayon,
                       FILL_T fill, int width = -1 );
-    virtual void pen_to( wxPoint pos, char plume );
-    virtual void flash_pad_circle( wxPoint pos, int diametre,
-                                   EDA_DRAW_MODE_T trace_mode );
-    virtual void flash_pad_oval( wxPoint pos, wxSize size, int orient,
+    virtual void PenTo( const wxPoint& pos, char plume );
+    virtual void FlashPadCircle( const wxPoint& pos, int diametre,
                                  EDA_DRAW_MODE_T trace_mode );
-    virtual void flash_pad_rect( wxPoint pos, wxSize size,
-                                 int orient, EDA_DRAW_MODE_T trace_mode );
-
-    virtual void flash_pad_trapez( wxPoint aPadPos, wxPoint aCorners[4],
-                                   int aPadOrient, EDA_DRAW_MODE_T aTrace_Mode );
+    virtual void FlashPadOval( const wxPoint& pos, const wxSize& size, int orient,
+                               EDA_DRAW_MODE_T trace_mode );
+    virtual void FlashPadRect( const wxPoint& pos, const wxSize& size,
+                               int orient, EDA_DRAW_MODE_T trace_mode );
+    virtual void FlashPadTrapez( const wxPoint& aPadPos, const wxPoint *aCorners,
+                                 int aPadOrient, EDA_DRAW_MODE_T aTrace_Mode );
 
     virtual void SetLayerPolarity( bool aPositive ) {}
 
 protected:
-    int current_color;
+    int currentColor;
 };
 
 #endif  // PLOT_COMMON_H_

=== modified file 'pcbnew/export_gencad.cpp'
--- pcbnew/export_gencad.cpp	2012-02-19 04:02:19 +0000
+++ pcbnew/export_gencad.cpp	2012-04-30 09:18:58 +0000
@@ -97,7 +97,7 @@
 
 /* GerbTool chokes on units different than INCH so this is the conversion
  *  factor */
-const static double SCALE_FACTOR = 10000.0;
+const static double SCALE_FACTOR = 10000.0 * IU_PER_DECIMILS;
 
 
 /* Two helper functions to calculate coordinates of modules in gencad values

=== modified file 'pcbnew/gen_drill_report_files.cpp'
--- pcbnew/gen_drill_report_files.cpp	2012-04-05 18:27:56 +0000
+++ pcbnew/gen_drill_report_files.cpp	2012-04-30 09:18:58 +0000
@@ -18,6 +18,17 @@
 #include <pcbplot.h>
 #include <gendrill.h>
 
+/* Conversion utilities - these will be used often in there... */
+static double diameter_in_inches(double ius)
+{
+    return ius * 0.001 / IU_PER_MILS;
+}
+
+static double diameter_in_mm(double ius)
+{
+    return ius / IU_PER_MM;
+}
+
 
 void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName,
                       const PAGE_INFO& aSheet,
@@ -57,7 +68,7 @@
         scale   = 1;
         offset  = auxoffset;
         plotter = new GERBER_PLOTTER();
-        plotter->set_viewport( offset, scale, 0 );
+        plotter->SetViewport( offset, IU_PER_DECIMILS, scale, 0 );
         break;
 
     case PLOT_FORMAT_HPGL:  // Scale for HPGL format.
@@ -67,11 +78,11 @@
             scale    = 1;
             HPGL_PLOTTER* hpgl_plotter = new HPGL_PLOTTER;
             plotter = hpgl_plotter;
-            hpgl_plotter->set_pen_number( plot_opts.m_HPGLPenNum );
-            hpgl_plotter->set_pen_speed( plot_opts.m_HPGLPenSpeed );
-            hpgl_plotter->set_pen_overlap( 0 );
+            hpgl_plotter->SetPenNumber( plot_opts.m_HPGLPenNum );
+            hpgl_plotter->SetPenSpeed( plot_opts.m_HPGLPenSpeed );
+            hpgl_plotter->SetPenOverlap( 0 );
             plotter->SetPageSettings( aSheet );
-            plotter->set_viewport( offset, scale, 0 );
+            plotter->SetViewport( offset, IU_PER_DECIMILS, scale, 0 );
         }
         break;
 
@@ -93,7 +104,7 @@
             PS_PLOTTER* ps_plotter = new PS_PLOTTER;
             plotter = ps_plotter;
             ps_plotter->SetPageSettings( pageA4 );
-            plotter->set_viewport( offset, scale, 0 );
+            plotter->SetViewport( offset, IU_PER_DECIMILS, scale, 0 );
         }
         break;
 
@@ -105,7 +116,7 @@
             DXF_PLOTTER* dxf_plotter = new DXF_PLOTTER;
             plotter = dxf_plotter;
             plotter->SetPageSettings( aSheet );
-            plotter->set_viewport( offset, scale, 0 );
+            plotter->SetViewport( offset, IU_PER_DECIMILS, scale, 0 );
         }
         break;
 
@@ -113,10 +124,10 @@
         wxASSERT( false );
     }
 
-    plotter->set_creator( wxT( "PCBNEW" ) );
-    plotter->set_filename( aFullFileName );
-    plotter->set_default_line_width( 10 );
-    plotter->start_plot( aFile );
+    plotter->SetCreator( wxT( "PCBNEW" ) );
+    plotter->SetFilename( aFullFileName );
+    plotter->SetDefaultLineWidth( 10 * IU_PER_DECIMILS );
+    plotter->StartPlot( aFile );
 
     // Draw items on edge layer
 
@@ -150,14 +161,14 @@
     }
 
     // Set Drill Symbols width in 1/10000 mils
-    plotter->set_default_line_width( 10 );
-    plotter->set_current_line_width( -1 );
+    plotter->SetDefaultLineWidth( 10 * IU_PER_DECIMILS );
+    plotter->SetCurrentLineWidth( -1 );
 
     // Plot board outlines and drill map
     Gen_Drill_PcbMap( aPcb, plotter, aHoleListBuffer, aToolListBuffer );
 
     // Print a list of symbols used.
-    CharSize = 800;                        // text size in 1/10000 mils
+    CharSize = 50 * IU_PER_MILS; // text size in IUs
     double CharScale = 1.0 / scale;        /* real scale will be CharScale
                                             * scale_x, because the global
                                             * plot scale is scale_x */
@@ -165,12 +176,12 @@
     intervalle = (int) ( CharSize * CharScale ) + TextWidth;
 
     // Trace information.
-    plotX = (int) ( (double) bbbox.GetX() + 200.0 * CharScale );
+    plotX = (int) ( (double) bbbox.GetX() + 20 * IU_PER_MILS * CharScale );
     plotY = bbbox.GetBottom() + intervalle;
 
     // Plot title  "Info"
     wxString Text = wxT( "Drill Map:" );
-    plotter->text( wxPoint( plotX, plotY ), BLACK, Text, 0,
+    plotter->Text( wxPoint( plotX, plotY ), BLACK, Text, 0,
                    wxSize( (int) ( CharSize * CharScale ),
                            (int) ( CharSize * CharScale ) ),
                    GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
@@ -186,9 +197,10 @@
         plotY += intervalle;
 
         plot_diam = (int) aToolListBuffer[ii].m_Diameter;
-        x = (int) ( (double) plotX - 200.0 * CharScale - (double)plot_diam / 2.0 );
+        x = (int) ( (double) plotX - 20.0 * IU_PER_MILS * CharScale 
+                - (double)plot_diam / 2.0 );
         y = (int) ( (double) plotY + (double) CharSize * CharScale );
-        plotter->marker( wxPoint( x, y ), plot_diam, ii );
+        plotter->Marker( wxPoint( x, y ), plot_diam, ii );
 
         // Trace the legends.
 
@@ -196,12 +208,12 @@
         // and then its diameter in the other Drill Unit.
         if( aUnit_Drill_is_Inch )
             sprintf( line, "%2.3f\" / %2.2fmm ",
-                     double (aToolListBuffer[ii].m_Diameter) * 0.0001,
-                     double (aToolListBuffer[ii].m_Diameter) * 0.00254 );
+                    diameter_in_inches( aToolListBuffer[ii].m_Diameter ),
+                    diameter_in_mm( aToolListBuffer[ii].m_Diameter ) );
         else
             sprintf( line, "%2.2fmm / %2.3f\" ",
-                     double (aToolListBuffer[ii].m_Diameter) * 0.00254,
-                     double (aToolListBuffer[ii].m_Diameter) * 0.0001 );
+                    diameter_in_mm( aToolListBuffer[ii].m_Diameter ),
+                    diameter_in_inches( aToolListBuffer[ii].m_Diameter ) );
 
         msg = FROM_UTF8( line );
 
@@ -222,7 +234,7 @@
                      aToolListBuffer[ii].m_OvalCount );
 
         msg += FROM_UTF8( line );
-        plotter->text( wxPoint( plotX, y ), BLACK,
+        plotter->Text( wxPoint( plotX, y ), BLACK,
                        msg,
                        0, wxSize( (int) ( CharSize * CharScale ), (int) ( CharSize * CharScale ) ),
                        GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
@@ -235,7 +247,7 @@
             intervalle = plot_diam + 200 + TextWidth;
     }
 
-    plotter->end_plot();
+    plotter->EndPlot();
     delete plotter;
 }
 
@@ -253,10 +265,10 @@
     wxPoint pos;
 
     // create the drill list
-    if( aToolListBuffer.size() > 13 )
+    if( aToolListBuffer.size() > PLOTTER::MARKER_COUNT )
     {
         DisplayInfoMessage( NULL,
-                            _( " Drill map: Too many diameter values to draw to draw one symbol per drill value (max 13)\nPlot uses circle shape for some drill values" ),
+                            _( " Drill map: Too many diameter values to draw to draw one symbol per drill value\nPlot will use circle shape for some drill values" ),
                             10 );
     }
 
@@ -267,15 +279,15 @@
 
         /* Always plot the drill symbol (for slots identifies the needed
          * cutter!) */
-        aPlotter->marker( pos, aHoleListBuffer[ii].m_Hole_Diameter,
+        aPlotter->Marker( pos, aHoleListBuffer[ii].m_Hole_Diameter,
                           aHoleListBuffer[ii].m_Tool_Reference - 1 );
 
         if( aHoleListBuffer[ii].m_Hole_Shape != 0 )
         {
             wxSize oblong_size;
             oblong_size = aHoleListBuffer[ii].m_Hole_Size;
-            aPlotter->flash_pad_oval( pos, oblong_size,
-                                      aHoleListBuffer[ii].m_Hole_Orient, LINE );
+            aPlotter->FlashPadOval( pos, oblong_size,
+                                    aHoleListBuffer[ii].m_Hole_Orient, LINE );
         }
     }
 }
@@ -304,7 +316,7 @@
     // List which Drill Unit option had been selected for the associated
     // drill aFile.
     if( aUnit_Drill_is_Inch )
-        fputs( "Selected Drill Unit: Imperial (\")\n\n", aFile );
+        fputs( "Selected Drill Unit: Imperial (inches)\n\n", aFile );
     else
         fputs( "Selected Drill Unit: Metric (mm)\n\n", aFile );
 
@@ -327,12 +339,12 @@
 
         if( gen_NPTH_holes )
         {
-            sprintf( line, "Drill report for Not Plated through holes :\n" );
+            sprintf( line, "Drill report for unplated through holes :\n" );
         }
 
         else if( gen_through_holes )
         {
-            sprintf( line, "Drill report for through holes :\n" );
+            sprintf( line, "Drill report for plated through holes :\n" );
         }
         else
         {
@@ -342,7 +354,7 @@
                 fputs( line, aFile );
             }
 
-            sprintf( line, "Drill report for holes from layer %s to layer %s\n",
+            sprintf( line, "Drill report for holes from layer %s to layer %s :\n",
                      TO_UTF8( aPcb->GetLayerName( layer1 ) ),
                      TO_UTF8( aPcb->GetLayerName( layer2 ) ) );
         }
@@ -355,15 +367,19 @@
             // then its diameter in the selected Drill Unit,
             // and then its diameter in the other Drill Unit.
             if( aUnit_Drill_is_Inch )
+            {
                 sprintf( line, "T%d  %2.3f\"  %2.2fmm  ",
                          ii + 1,
-                         double (aToolListBuffer[ii].m_Diameter) * 0.0001,
-                         double (aToolListBuffer[ii].m_Diameter) * 0.00254 );
+                         diameter_in_inches( aToolListBuffer[ii].m_Diameter ),
+                         diameter_in_mm( aToolListBuffer[ii].m_Diameter ) );
+            }
             else
+            {
                 sprintf( line, "T%d  %2.2fmm  %2.3f\"  ",
                          ii + 1,
-                         double (aToolListBuffer[ii].m_Diameter) * 0.00254,
-                         double (aToolListBuffer[ii].m_Diameter) * 0.0001 );
+                         diameter_in_mm( aToolListBuffer[ii].m_Diameter ),
+                         diameter_in_inches( aToolListBuffer[ii].m_Diameter ) );
+            }
 
             fputs( line, aFile );
 
@@ -372,13 +388,13 @@
                && ( aToolListBuffer[ii].m_OvalCount == 0 ) )
                 sprintf( line, "(1 hole)\n" );
             else if( aToolListBuffer[ii].m_TotalCount == 1 )
-                sprintf( line, "(1 hole)  (with 1 oblong)\n" );
+                sprintf( line, "(1 hole)  (with 1 slot)\n" );
             else if( aToolListBuffer[ii].m_OvalCount == 0 )
                 sprintf( line, "(%d holes)\n", aToolListBuffer[ii].m_TotalCount );
             else if( aToolListBuffer[ii].m_OvalCount == 1 )
-                sprintf( line, "(%d holes)  (with 1 oblong)\n", aToolListBuffer[ii].m_TotalCount );
+                sprintf( line, "(%d holes)  (with 1 slot)\n", aToolListBuffer[ii].m_TotalCount );
             else  //  if ( buffer[ii]m_OvalCount > 1 )
-                sprintf( line, "(%d holes)  (with %d oblongs)\n",
+                sprintf( line, "(%d holes)  (with %d slots)\n",
                          aToolListBuffer[ii].m_TotalCount,
                          aToolListBuffer[ii].m_OvalCount );
 
@@ -388,9 +404,9 @@
         }
 
         if( gen_NPTH_holes )
-            sprintf( line, "\ntotal Not Plated holes count %d\n\n\n", TotalHoleCount );
+            sprintf( line, "\nTotal unplated holes count %d\n\n\n", TotalHoleCount );
         else
-            sprintf( line, "\ntotal plated holes count %d\n\n\n", TotalHoleCount );
+            sprintf( line, "\nTotal plated holes count %d\n\n\n", TotalHoleCount );
 
         fputs( line, aFile );
 

=== modified file 'pcbnew/gen_modules_placefile.cpp'
--- pcbnew/gen_modules_placefile.cpp	2012-04-17 01:35:43 +0000
+++ pcbnew/gen_modules_placefile.cpp	2012-04-30 09:18:58 +0000
@@ -212,10 +212,10 @@
     if( singleFile )
     {
         side = 2;
-        fn.SetName( fn.GetName() + wxT( "_" ) + wxT("all") );
+        fn.SetName( fn.GetName() + wxT( "-" ) + wxT("all") );
     }
      else
-        fn.SetName( fn.GetName() + wxT( "_" ) + frontLayerName );
+        fn.SetName( fn.GetName() + wxT( "-" ) + frontLayerName );
 
     fn.SetExt( FootprintPlaceFileExtension );
 
@@ -252,7 +252,7 @@
     side = 0;
     fn = screen->GetFileName();
     fn.SetPath( GetOutputDirectory() );
-    fn.SetName( fn.GetName() + wxT( "_" ) + backLayerName );
+    fn.SetName( fn.GetName() + wxT( "-" ) + backLayerName );
     fn.SetExt( wxT( "pos" ) );
 
     fpcount = m_parent->DoGenFootprintsPositionFile( fn.GetFullPath(), UnitsMM(),
@@ -286,10 +286,10 @@
 }
 
 // Defined values to write coordinates using inches or mm:
-static const double conv_unit_inch = 0.0001;      // units = INCHES
+static const double conv_unit_inch = 0.001 / IU_PER_MILS ;      // units = INCHES
 static const char unit_text_inch[] = "## Unit = inches, Angle = deg.\n";
 
-static const double conv_unit_mm = 0.00254;    // units = mm
+static const double conv_unit_mm = 1.0 / IU_PER_MM;    // units = mm
 static const char unit_text_mm[] = "## Unit = mm, Angle = deg.\n";
 
 static wxPoint File_Place_Offset;  // Offset coordinates for generated file.
@@ -451,23 +451,27 @@
     fputs( line, file );
 
     sprintf( line,
-             "# Ref    Val                  PosX       PosY        Rot     Side\n" );
+             "# Ref    Val                  Package         PosX       PosY        Rot     Side\n" );
     fputs( line, file );
 
     for( int ii = 0; ii < moduleCount; ii++ )
     {
         wxPoint  module_pos;
-        wxString ref = list[ii].m_Reference;
-        wxString val = list[ii].m_Value;
-        sprintf( line, "%-8.8s %-16.16s ", TO_UTF8( ref ), TO_UTF8( val ) );
+        const wxString& ref = list[ii].m_Reference;
+        const wxString& val = list[ii].m_Value;
+        const wxString& pkg = list[ii].m_Module->m_LibRef;
+        sprintf( line, "%-8.8s %-16.16s %-16.16s", 
+	         TO_UTF8( ref ), TO_UTF8( val ), TO_UTF8( pkg ) );
 
         module_pos    = list[ii].m_Module->m_Pos;
         module_pos -= File_Place_Offset;
 
         char* text = line + strlen( line );
+        /* Keep the coordinates in the first quadrant, like the gerbers
+         * (i.e. change sign to y) */
         sprintf( text, " %9.4f  %9.4f  %8.1f    ",
                  module_pos.x * conv_unit,
-                 module_pos.y * conv_unit,
+                 -module_pos.y * conv_unit,
                  double(list[ii].m_Module->m_Orient) / 10 );
 
         int layer = list[ii].m_Module->GetLayer();

=== modified file 'pcbnew/gendrill.cpp'
--- pcbnew/gendrill.cpp	2012-04-19 06:55:45 +0000
+++ pcbnew/gendrill.cpp	2012-04-30 09:18:58 +0000
@@ -405,9 +405,9 @@
 
     /* Set conversion scale depending on drill file units */
     if( m_unitsDecimal )
-        m_conversionUnits = 0.00254;        // EXCELLON units = mm
+        m_conversionUnits = 1.0 / IU_PER_MM; // EXCELLON units = mm
     else
-        m_conversionUnits = 0.0001;         // EXCELLON units = INCHES
+        m_conversionUnits = 0.001 / IU_PER_MILS; // EXCELLON units = INCHES
 
     m_precision.m_lhs = aLeftDigits;
     m_precision.m_rhs = aRightDigits;

=== modified file 'pcbnew/pcb_plot_params.cpp'
--- pcbnew/pcb_plot_params.cpp	2012-04-05 18:27:56 +0000
+++ pcbnew/pcb_plot_params.cpp	2012-04-30 09:18:58 +0000
@@ -31,9 +31,9 @@
 
 
 #define PLOT_LINEWIDTH_MIN        0
-#define PLOT_LINEWIDTH_MAX        200
+#define PLOT_LINEWIDTH_MAX        (200*IU_PER_DECIMILS)
 #define HPGL_PEN_DIAMETER_MIN     0
-#define HPGL_PEN_DIAMETER_MAX     100
+#define HPGL_PEN_DIAMETER_MAX     (100*IU_PER_DECIMILS)
 #define HPGL_PEN_SPEED_MIN        0
 #define HPGL_PEN_SPEED_MAX        1000
 #define HPGL_PEN_NUMBER_MIN       1

=== modified file 'pcbnew/pcbnew.h'
--- pcbnew/pcbnew.h	2012-04-11 09:47:57 +0000
+++ pcbnew/pcbnew.h	2012-04-30 09:18:58 +0000
@@ -10,8 +10,6 @@
 #include <base_struct.h>    // IS_DRAGGED and IN_EDIT definitions.
 #include <convert_to_biu.h> // to define DMils2iu() conversion function
 
-#define U_PCB (PCB_INTERNAL_UNIT / EESCHEMA_INTERNAL_UNIT)
-
 // Arcs are approximated by segments: define the number of segments per 360 deg (KiCad uses 0.1
 // deg approximation).  Be aware 3600 / ARC_APPROX_SEGMENTS_COUNT_LOW_DEF is an integer.
 #define ARC_APPROX_SEGMENTS_COUNT_LOW_DEF 16

=== modified file 'pcbnew/plot_rtn.cpp'
--- pcbnew/plot_rtn.cpp	2012-04-05 18:27:56 +0000
+++ pcbnew/plot_rtn.cpp	2012-04-30 09:18:58 +0000
@@ -98,24 +98,27 @@
                 switch( pad->GetShape() )
                 {
                 case PAD_CIRCLE:
-                    aPlotter->flash_pad_circle( shape_pos, pad->GetSize().x, LINE );
+                    aPlotter->FlashPadCircle( shape_pos, pad->GetSize().x, LINE );
                     break;
 
                 case PAD_OVAL:
-                    aPlotter->flash_pad_oval( shape_pos, pad->GetSize(), pad->GetOrientation(), LINE );
+                    aPlotter->FlashPadOval( shape_pos, pad->GetSize(), 
+		                            pad->GetOrientation(), LINE );
                     break;
 
                 case PAD_TRAPEZOID:
                     {
                         wxPoint coord[4];
                         pad->BuildPadPolygon( coord, wxSize(0,0), 0 );
-                        aPlotter->flash_pad_trapez( shape_pos, coord, pad->GetOrientation(), LINE );
+                        aPlotter->FlashPadTrapez( shape_pos, coord, 
+			                          pad->GetOrientation(), LINE );
                     }
                     break;
 
                 case PAD_RECT:
                 default:
-                    aPlotter->flash_pad_rect( shape_pos, pad->GetSize(), pad->GetOrientation(), LINE );
+                    aPlotter->FlashPadRect( shape_pos, pad->GetSize(), 
+		                            pad->GetOrientation(), LINE );
                     break;
                 }
             }
@@ -228,7 +231,7 @@
         if( ( ( 1 << seg->GetLayer() ) & aLayerMask ) == 0 )
             continue;
 
-        aPlotter->thick_segment( seg->m_Start, seg->m_End, seg->m_Width, trace_mode );
+        aPlotter->ThickSegment( seg->m_Start, seg->m_End, seg->m_Width, trace_mode );
     }
 }
 
@@ -259,7 +262,7 @@
     // So we set bold flag to true
     bool allow_bold = pt_texte->m_Bold || thickness;
 
-    aPlotter->text( pos, BLACK,
+    aPlotter->Text( pos, BLACK,
                    pt_texte->m_Text,
                    orient, size,
                    pt_texte->m_HJustify, pt_texte->m_VJustify,
@@ -396,13 +399,13 @@
     switch( type_trace )
     {
     case S_SEGMENT:
-        aPlotter->thick_segment( pos, end, thickness, trace_mode );
+        aPlotter->ThickSegment( pos, end, thickness, trace_mode );
         break;
 
     case S_CIRCLE:
         radius = (int) hypot( (double) ( end.x - pos.x ),
                               (double) ( end.y - pos.y ) );
-        aPlotter->thick_circle( pos, radius * 2, thickness, trace_mode );
+        aPlotter->ThickCircle( pos, radius * 2, thickness, trace_mode );
         break;
 
     case S_ARC:
@@ -416,19 +419,11 @@
 
             if ( ( aPlotOpts.GetPlotFormat() == PLOT_FORMAT_DXF ) &&
                ( masque_layer & ( SILKSCREEN_LAYER_BACK | DRAW_LAYER | COMMENT_LAYER ) ) )
-                aPlotter->thick_arc( pos,
-                                -startAngle,
-                                -endAngle,
-                                radius,
-                                thickness,
-                                trace_mode );
+                aPlotter->ThickArc( pos, -startAngle, -endAngle, radius,
+                                thickness, trace_mode );
             else
-                aPlotter->thick_arc( pos,
-                                -endAngle,
-                                -startAngle,
-                                radius,
-                                thickness,
-                                trace_mode );
+                aPlotter->ThickArc( pos, -endAngle, -startAngle, radius,
+                                thickness, trace_mode );
         }
         break;
 
@@ -507,9 +502,7 @@
         for( unsigned i = 0; i < list->Count(); i++ )
         {
             wxString txt = list->Item( i );
-            aPlotter->text( pos, BLACK,
-                           txt,
-                           orient, size,
+            aPlotter->Text( pos, BLACK, txt, orient, size,
                            pt_texte->m_HJustify, pt_texte->m_VJustify,
                            thickness, pt_texte->m_Italic, allow_bold );
             pos += offset;
@@ -519,9 +512,7 @@
     }
     else
     {
-        aPlotter->text( pos, BLACK,
-                       pt_texte->m_Text,
-                       orient, size,
+        aPlotter->Text( pos, BLACK, pt_texte->m_Text, orient, size,
                        pt_texte->m_HJustify, pt_texte->m_VJustify,
                        thickness, pt_texte->m_Italic, allow_bold );
     }
@@ -574,8 +565,7 @@
                     {
                         wxPoint start = aZone->m_FillSegmList[iseg].m_Start;
                         wxPoint end   = aZone->m_FillSegmList[iseg].m_End;
-                        aPlotter->thick_segment( start,
-                                                end,
+                        aPlotter->ThickSegment( start, end,
                                                 aZone->m_ZoneMinThickness,
                                                 trace_mode );
                     }
@@ -590,12 +580,12 @@
                 if( aZone->m_ZoneMinThickness > 0 )
                 {
                     for( unsigned jj = 1; jj<cornerList.size(); jj++ )
-                        aPlotter->thick_segment( cornerList[jj -1], cornerList[jj],
+                        aPlotter->ThickSegment( cornerList[jj -1], cornerList[jj],
                                                 ( trace_mode == LINE ) ? -1 : aZone->m_ZoneMinThickness,
                                                 trace_mode );
                 }
 
-                aPlotter->set_current_line_width( -1 );
+                aPlotter->SetCurrentLineWidth( -1 );
             }
 
             cornerList.clear();
@@ -623,14 +613,14 @@
     wxPoint start( aSeg->GetStart() );
     wxPoint end(   aSeg->GetEnd() );
 
-    aPlotter->set_current_line_width( thickness );
+    aPlotter->SetCurrentLineWidth( thickness );
 
     switch( aSeg->GetShape() )
     {
     case S_CIRCLE:
         radius = (int) hypot( (double) ( end.x - start.x ),
                               (double) ( end.y - start.y ) );
-        aPlotter->thick_circle( start, radius * 2, thickness, trace_mode );
+        aPlotter->ThickCircle( start, radius * 2, thickness, trace_mode );
         break;
 
     case S_ARC:
@@ -638,7 +628,7 @@
                               (double) ( end.y - start.y ) );
         StAngle  = ArcTangente( end.y - start.y, end.x - start.x );
         EndAngle = StAngle + aSeg->GetAngle();
-        aPlotter->thick_arc( start, -EndAngle, -StAngle, radius, thickness, trace_mode );
+        aPlotter->ThickArc( start, -EndAngle, -StAngle, radius, thickness, trace_mode );
         break;
 
     case S_CURVE:
@@ -646,7 +636,7 @@
             const std::vector<wxPoint>& bezierPoints = aSeg->GetBezierPoints();
 
             for( unsigned i = 1; i < bezierPoints.size(); i++ )
-                aPlotter->thick_segment( bezierPoints[i - 1],
+                aPlotter->ThickSegment( bezierPoints[i - 1],
                                         bezierPoints[i],
                                         thickness,
                                         trace_mode );
@@ -654,7 +644,7 @@
         break;
 
     default:
-        aPlotter->thick_segment( start, end, thickness, trace_mode );
+        aPlotter->ThickSegment( start, end, thickness, trace_mode );
     }
 }
 
@@ -827,7 +817,7 @@
 
             if( aLayerMask & ALL_CU_LAYERS )
             {
-                width_adj =  aPlotter->get_plot_width_adj();
+                width_adj =  aPlotter->GetPlotWidthAdj();
             }
 
             switch( aLayerMask &
@@ -863,7 +853,7 @@
                     (pad->GetAttribute() == PAD_HOLE_NOT_PLATED) )
                     break;
 
-                aPlotter->flash_pad_circle( pos, size.x, aPlotMode );
+                aPlotter->FlashPadCircle( pos, size.x, aPlotMode );
                 break;
 
             case PAD_OVAL:
@@ -872,20 +862,20 @@
                     (pad->GetAttribute() == PAD_HOLE_NOT_PLATED) )
                     break;
 
-                aPlotter->flash_pad_oval( pos, size, pad->GetOrientation(), aPlotMode );
+                aPlotter->FlashPadOval( pos, size, pad->GetOrientation(), aPlotMode );
                 break;
 
             case PAD_TRAPEZOID:
             {
                 wxPoint coord[4];
                 pad->BuildPadPolygon( coord, margin, 0 );
-                aPlotter->flash_pad_trapez( pos, coord, pad->GetOrientation(), aPlotMode );
+                aPlotter->FlashPadTrapez( pos, coord, pad->GetOrientation(), aPlotMode );
             }
             break;
 
             case PAD_RECT:
             default:
-                aPlotter->flash_pad_rect( pos, size, pad->GetOrientation(), aPlotMode );
+                aPlotter->FlashPadRect( pos, size, pad->GetOrientation(), aPlotMode );
                 break;
             }
         }
@@ -925,7 +915,7 @@
 
             if( aLayerMask & ALL_CU_LAYERS )
             {
-                width_adj =  aPlotter->get_plot_width_adj();
+                width_adj =  aPlotter->GetPlotWidthAdj();
             }
 
             pos    = Via->m_Start;
@@ -935,7 +925,7 @@
             if( size.x <= 0 )
                 continue;
 
-            aPlotter->flash_pad_circle( pos, size.x, aPlotMode );
+            aPlotter->FlashPadCircle( pos, size.x, aPlotMode );
         }
     }
 
@@ -950,11 +940,11 @@
         if( (GetLayerMask( track->GetLayer() ) & aLayerMask) == 0 )
             continue;
 
-        size.x = size.y = track->m_Width + aPlotter->get_plot_width_adj();
+        size.x = size.y = track->m_Width + aPlotter->GetPlotWidthAdj();
         pos    = track->m_Start;
         end    = track->m_End;
 
-        aPlotter->thick_segment( pos, end, size.x, aPlotMode );
+        aPlotter->ThickSegment( pos, end, size.x, aPlotMode );
     }
 
     // Plot zones (outdated, for old boards compatibility):
@@ -965,11 +955,11 @@
         if( (GetLayerMask( track->GetLayer() ) & aLayerMask) == 0 )
             continue;
 
-        size.x = size.y = track->m_Width + aPlotter->get_plot_width_adj();
+        size.x = size.y = track->m_Width + aPlotter->GetPlotWidthAdj();
         pos    = track->m_Start;
         end    = track->m_End;
 
-        aPlotter->thick_segment( pos, end, size.x, aPlotMode );
+        aPlotter->ThickSegment( pos, end, size.x, aPlotMode );
     }
 
     // Plot filled ares
@@ -1010,7 +1000,7 @@
 
     if( aTraceMode == FILLED )
     {
-        aPlotter->set_color( WHITE );
+        aPlotter->SetColor( WHITE );
     }
 
     for( pts = m_Pcb->m_Track; pts != NULL; pts = pts->Next() )
@@ -1026,9 +1016,9 @@
         else
             diam.x = diam.y = pts->GetDrillValue();
 
-        diam.x -= aPlotter->get_plot_width_adj();
+        diam.x -= aPlotter->GetPlotWidthAdj();
         diam.x = Clamp( 1, diam.x, pts->m_Width - 1 );
-        aPlotter->flash_pad_circle( pos, diam.x, aTraceMode );
+        aPlotter->FlashPadCircle( pos, diam.x, aTraceMode );
     }
 
     for( Module = m_Pcb->m_Modules; Module != NULL; Module = Module->Next() )
@@ -1044,25 +1034,25 @@
             if( pad->GetDrillShape() == PAD_OVAL )
             {
                 diam = pad->GetDrillSize();
-                diam.x -= aPlotter->get_plot_width_adj();
+                diam.x -= aPlotter->GetPlotWidthAdj();
                 diam.x = Clamp( 1, diam.x, pad->GetSize().x - 1 );
-                diam.y -= aPlotter->get_plot_width_adj();
+                diam.y -= aPlotter->GetPlotWidthAdj();
                 diam.y = Clamp( 1, diam.y, pad->GetSize().y - 1 );
-                aPlotter->flash_pad_oval( pos, diam, pad->GetOrientation(), aTraceMode );
+                aPlotter->FlashPadOval( pos, diam, pad->GetOrientation(), aTraceMode );
             }
             else
             {
                 // It is quite possible that the real pad drill value is less then small drill value.
                 diam.x = aSmallDrillShape ? MIN( SMALL_DRILL, pad->GetDrillSize().x ) : pad->GetDrillSize().x;
-                diam.x -= aPlotter->get_plot_width_adj();
+                diam.x -= aPlotter->GetPlotWidthAdj();
                 diam.x = Clamp( 1, diam.x, pad->GetSize().x - 1 );
-                aPlotter->flash_pad_circle( pos, diam.x, aTraceMode );
+                aPlotter->FlashPadCircle( pos, diam.x, aTraceMode );
             }
         }
     }
 
     if( aTraceMode == FILLED )
     {
-        aPlotter->set_color( BLACK );
+        aPlotter->SetColor( BLACK );
     }
 }

=== modified file 'pcbnew/plotdxf.cpp'
--- pcbnew/plotdxf.cpp	2012-04-05 18:27:56 +0000
+++ pcbnew/plotdxf.cpp	2012-04-30 09:18:58 +0000
@@ -31,16 +31,16 @@
 
     DXF_PLOTTER* plotter = new DXF_PLOTTER();
     plotter->SetPageSettings( GetPageSettings() );
-    plotter->set_viewport( wxPoint( 0, 0 ), 1, 0 );
-    plotter->set_creator( wxT( "PCBNEW-DXF" ) );
-    plotter->set_filename( aFullFileName );
-    plotter->start_plot( output_file );
+    plotter->SetViewport( wxPoint( 0, 0 ), IU_PER_DECIMILS, 1, 0 );
+    plotter->SetCreator( wxT( "PCBNEW-DXF" ) );
+    plotter->SetFilename( aFullFileName );
+    plotter->StartPlot( output_file );
 
     if( plot_opts.m_PlotFrameRef )
         PlotWorkSheet( plotter, GetScreen() );
 
     Plot_Layer( plotter, aLayer, aTraceMode );
-    plotter->end_plot();
+    plotter->EndPlot();
     delete plotter;
     return true;
 }

=== modified file 'pcbnew/plotgerb.cpp'
--- pcbnew/plotgerb.cpp	2012-04-05 18:27:56 +0000
+++ pcbnew/plotgerb.cpp	2012-04-30 09:18:58 +0000
@@ -54,12 +54,12 @@
     PLOTTER* plotter = new GERBER_PLOTTER();
 
     // No mirror and scaling for gerbers!
-    plotter->set_viewport( offset, scale, 0 );
-    plotter->set_default_line_width( plot_opts.m_PlotLineWidth );
-    plotter->set_creator( wxT( "PCBNEW-RS274X" ) );
-    plotter->set_filename( aFullFileName );
+    plotter->SetViewport( offset, IU_PER_DECIMILS, scale, 0 );
+    plotter->SetDefaultLineWidth( plot_opts.m_PlotLineWidth );
+    plotter->SetCreator( wxT( "PCBNEW-RS274X" ) );
+    plotter->SetFilename( aFullFileName );
 
-    if( plotter->start_plot( output_file ) )
+    if( plotter->StartPlot( output_file ) )
     {
         // Skip NPTH pads on copper layers
         // ( only if hole size == pad size ):
@@ -74,7 +74,7 @@
 
         Plot_Layer( plotter, aLayer, aTraceMode );
 
-        plotter->end_plot();
+        plotter->EndPlot();
 
         plot_opts.m_SkipNPTH_Pads = false;
 

=== modified file 'pcbnew/plothpgl.cpp'
--- pcbnew/plothpgl.cpp	2012-04-19 06:55:45 +0000
+++ pcbnew/plothpgl.cpp	2012-04-30 09:18:58 +0000
@@ -38,7 +38,7 @@
     // Compute pen_dim (from g_m_HPGLPenDiam in mils) in pcb units,
     // with plot scale (if Scale is 2, pen diameter is always g_m_HPGLPenDiam
     // so apparent pen diam is real pen diam / Scale
-    int pen_diam = KiROUND( (plot_opts.m_HPGLPenDiam * U_PCB) /
+    int pen_diam = KiROUND( plot_opts.m_HPGLPenDiam /
                             plot_opts.m_PlotScale );
 
     // compute pen_overlay (from g_m_HPGLPenOvr in mils) with plot scale
@@ -100,22 +100,23 @@
     // why did we have to change these settings above?
     SetPlotSettings( plot_opts );
 
-    plotter->set_viewport( offset, scale, plot_opts.m_PlotMirror );
-    plotter->set_default_line_width( plot_opts.m_PlotLineWidth );
-    plotter->set_creator( wxT( "PCBNEW-HPGL" ) );
-    plotter->set_filename( aFullFileName );
-    plotter->set_pen_speed( plot_opts.m_HPGLPenSpeed );
-    plotter->set_pen_number( plot_opts.m_HPGLPenNum );
-    plotter->set_pen_overlap( pen_overlay );
-    plotter->set_pen_diameter( pen_diam );
-    plotter->start_plot( output_file );
+    plotter->SetViewport( offset, IU_PER_DECIMILS, scale, 
+	                  plot_opts.m_PlotMirror );
+    plotter->SetDefaultLineWidth( plot_opts.m_PlotLineWidth );
+    plotter->SetCreator( wxT( "PCBNEW-HPGL" ) );
+    plotter->SetFilename( aFullFileName );
+    plotter->SetPenSpeed( plot_opts.m_HPGLPenSpeed );
+    plotter->SetPenNumber( plot_opts.m_HPGLPenNum );
+    plotter->SetPenOverlap( pen_overlay );
+    plotter->SetPenDiameter( pen_diam );
+    plotter->StartPlot( output_file );
 
     // The worksheet is not significant with scale!=1... It is with paperscale!=1, anyway
     if( plot_opts.m_PlotFrameRef && !center )
         PlotWorkSheet( plotter, GetScreen() );
 
     Plot_Layer( plotter, aLayer, aTraceMode );
-    plotter->end_plot();
+    plotter->EndPlot();
     delete plotter;
 
     return true;

=== modified file 'pcbnew/plotps.cpp'
--- pcbnew/plotps.cpp	2012-04-19 06:55:45 +0000
+++ pcbnew/plotps.cpp	2012-04-30 09:18:58 +0000
@@ -108,14 +108,15 @@
     // why did we have to change these settings?
     SetPlotSettings( plotOpts );
 
-    plotter->set_scale_adjust( plotOpts.m_FineScaleAdjustX,
+    plotter->SetScaleAdjust( plotOpts.m_FineScaleAdjustX,
                                plotOpts.m_FineScaleAdjustY );
-    plotter->set_plot_width_adj( plotOpts.m_FineWidthAdjust );
-    plotter->set_viewport( offset, scale, plotOpts.m_PlotMirror );
-    plotter->set_default_line_width( plotOpts.m_PlotLineWidth );
-    plotter->set_creator( wxT( "PCBNEW-PS" ) );
-    plotter->set_filename( aFullFileName );
-    plotter->start_plot( output_file );
+    plotter->SetPlotWidthAdj( plotOpts.m_FineWidthAdjust );
+    plotter->SetViewport( offset, IU_PER_DECIMILS, scale, 
+	                  plotOpts.m_PlotMirror );
+    plotter->SetDefaultLineWidth( plotOpts.m_PlotLineWidth );
+    plotter->SetCreator( wxT( "PCBNEW-PS" ) );
+    plotter->SetFilename( aFullFileName );
+    plotter->StartPlot( output_file );
 
     /* The worksheet is not significant with scale!=1... It is with paperscale!=1, anyway */
     if( plotOpts.m_PlotFrameRef && !center )
@@ -127,18 +128,18 @@
     if( plotOpts.m_PlotPSNegative )
     {
         int margin = 500;              // Add a 0.5 inch margin around the board
-        plotter->set_negative( true );
-        plotter->set_color( WHITE );   // Which will be plotted as black
-        plotter->rect( wxPoint( bbbox.GetX() - margin,
+        plotter->SetNegative( true );
+        plotter->SetColor( WHITE );   // Which will be plotted as black
+        plotter->Rect( wxPoint( bbbox.GetX() - margin,
                                 bbbox.GetY() - margin ),
                        wxPoint( bbbox.GetRight() + margin,
                                 bbbox.GetBottom() + margin ),
                        FILLED_SHAPE );
-        plotter->set_color( BLACK );
+        plotter->SetColor( BLACK );
     }
 
     Plot_Layer( plotter, aLayer, aTraceMode );
-    plotter->end_plot();
+    plotter->EndPlot();
     delete plotter;
 
     return true;


Follow ups