← Back to team overview

kicad-developers team mailing list archive

PATCH: (partial) bug 1255937

 

The attached file is a partial fix to bug 1255937. Patch is against r4684.

Changes:

1. The mirror is now along the Y axis rather than the X axis;
this maintains consistency with the plot functions and also with
common behavior of ECAD software.

2. Rendering of mirrored graphical arcs and module footprint arcs have been fixed.

A few questions from me:

1. do we wish to support printing across multiple pages in the future?

2. when the magnification is changed, I presume that the frame and title
block should not be altered? At the moment the frame is scaled.
This is related somewhat to question (1) since objects which overfill the
page could be printed on other pages. If multiple page outs is supported,
the frame must also obviously change as well since its reference point changes.

2. In mirror mode, how should text on the various comment layers behave?
At the moment such text is mirrored, but this is obviously not useful
to whoever attached those comments.

Regards,
Cirilo
=== modified file 'common/gr_basic.cpp'
--- common/gr_basic.cpp	2014-01-18 09:07:05 +0000
+++ common/gr_basic.cpp	2014-02-10 04:41:15 +0000
@@ -756,6 +756,17 @@
         DC->DrawLine( sx2, sy2, ex2, ey2 );
     }
 
+    int slx = DC->DeviceToLogicalX( 1 ) - DC->DeviceToLogicalX( 0 );
+    int sly = DC->DeviceToLogicalY( 1 ) - DC->DeviceToLogicalY( 0 );
+
+    if( (slx > 0 && sly < 0) || (slx < 0 && sly > 0) )
+    {
+        if( swap_ends )
+            swap_ends = false;
+        else
+            swap_ends = true;
+    }
+
     if( swap_ends )
     {
         DC->DrawArc( sx2, sy2, sx1, sy1, x1, y1 );

=== modified file 'common/worksheet.cpp'
--- common/worksheet.cpp	2014-01-07 19:27:51 +0000
+++ common/worksheet.cpp	2014-02-10 20:50:23 +0000
@@ -94,11 +94,22 @@
     TITLE_BLOCK t_block = GetTitleBlock();
     EDA_COLOR_T color = RED;
 
+    // if the page has been mirrored we need to set it to the normal
+    // orientation before printing the title block and frame. The
+    // mirror code is in:
+    // printout_controler.cpp -> BOARD_PRINTOUT_CONTROLLER::DrawPage()
     wxPoint origin = aDC->GetDeviceOrigin();
+    bool mirrorx = false;
+    wxCoord sizex = 0;
 
-    if( aScreen->m_IsPrinting && origin.y > 0 )
+    if( aScreen->m_IsPrinting
+        && ( aDC->DeviceToLogicalX( 1 ) - aDC->DeviceToLogicalX( 0 ) < 0 ) )
     {
-        aDC->SetDeviceOrigin( 0, 0 );
+        mirrorx = true;
+        wxCoord sizey;
+        aDC->GetSize( &sizex, &sizey );
+        // restore the normal orientation
+        aDC->SetDeviceOrigin( origin.x - sizex, origin.y );
         aDC->SetAxisOrientation( true, false );
     }
 
@@ -107,10 +118,11 @@
                     aScreen->m_NumberOfScreens, aScreen->m_ScreenNumber,
                     aLineWidth, aScalar, color, color );
 
-    if( aScreen->m_IsPrinting && origin.y > 0 )
+    if( aScreen->m_IsPrinting && mirrorx )
     {
+        // restore the mirrored orientation
         aDC->SetDeviceOrigin( origin.x, origin.y );
-        aDC->SetAxisOrientation( true, true );
+        aDC->SetAxisOrientation( false, false );
     }
 }
 

=== modified file 'pcbnew/class_edge_mod.cpp'
--- pcbnew/class_edge_mod.cpp	2013-12-20 09:15:00 +0000
+++ pcbnew/class_edge_mod.cpp	2014-02-10 21:24:02 +0000
@@ -200,8 +200,16 @@
         StAngle  = ArcTangente( dy - uy0, dx - ux0 );
         EndAngle = StAngle + m_Angle;
 
-        if( StAngle > EndAngle )
-            EXCHG( StAngle, EndAngle );
+        if( !panel->GetPrintMirrored() )
+        {
+            if( StAngle > EndAngle )
+                EXCHG( StAngle, EndAngle );
+        }
+        else    // Mirrored mode: arc orientation is reversed
+        {
+            if( StAngle < EndAngle )
+                EXCHG( StAngle, EndAngle );
+        }
 
         if( typeaff == LINE )
         {

=== modified file 'pcbnew/printout_controler.cpp'
--- pcbnew/printout_controler.cpp	2013-12-20 09:15:00 +0000
+++ pcbnew/printout_controler.cpp	2014-02-10 20:34:27 +0000
@@ -282,7 +282,7 @@
         if( printMirror )
         {
             // Calculate the mirrored center of the board.
-            center.y = m_Parent->GetPageSizeIU().y - boardBoundingBox.Centre().y;
+            center.x = m_Parent->GetPageSizeIU().x - boardBoundingBox.Centre().x;
         }
 
         offset += center;
@@ -303,19 +303,19 @@
 
     if( printMirror )
     {
-        // To plot mirror, we reverse the y axis, and modify the plot y origin
-        dc->SetAxisOrientation( true, true );
+        // To plot mirror, we reverse the x axis, and modify the plot x origin
+        dc->SetAxisOrientation( false, false);
 
-        /* Plot offset y is moved by the y plot area size in order to have
+        /* Plot offset x is moved by the x plot area size in order to have
          * the old draw area in the new draw area, because the draw origin has not moved
-         * (this is the upper left corner) but the Y axis is reversed, therefore the plotting area
-         * is the y coordinate values from  - PlotAreaSize.y to 0 */
-        int y_dc_offset = PlotAreaSizeInPixels.y;
-        y_dc_offset = KiROUND( y_dc_offset  * userscale );
-        dc->SetDeviceOrigin( 0, y_dc_offset );
+         * (this is the upper left corner) but the X axis is reversed, therefore the plotting area
+         * is the x coordinate values from  - PlotAreaSize.x to 0 */
+        int x_dc_offset = PlotAreaSizeInPixels.x;
+        x_dc_offset = KiROUND( x_dc_offset  * userscale );
+        dc->SetDeviceOrigin( x_dc_offset, 0 );
 
         wxLogTrace( tracePrinting, wxT( "Device origin:                    x=%d, y=%d" ),
-                    0, y_dc_offset );
+                    x_dc_offset, 0 );
 
         panel->SetClipBox( EDA_RECT( wxPoint( -MAX_VALUE/2, -MAX_VALUE/2 ),
                                      panel->GetClipBox()->GetSize() ) );