On 11.03.2013 21:41, jp charras wrote:
Le 11/03/2013 15:17, Sergey A. Borshch a écrit :
This patch makes scale option "fit to page" do the same as in all
other programs worldwide - produce biggest image that still fits to page.
 Pcbnew generates 1:1-scaled centered image instead.


Sorry, your patch does not work:
- scale is evaluated as int, not double.
- page margins are not taken in account.
- crashes with void boards.

Yes, you're right, my fault.

  reworked patch attached.

Thanks for quick response and commiting other my patches.

 Sergey
=== modified file 'pcbnew/printout_controler.cpp'
--- pcbnew/printout_controler.cpp	2013-03-11 19:30:58 +0000
+++ pcbnew/printout_controler.cpp	2013-03-11 21:33:48 +0000
@@ -191,8 +191,14 @@
 
     if( m_PrintParams.m_PrintScale == 0 )   //  fit in page option
     {
-        // TODO: a better way to calculate the userscale
-        userscale = 1.0;
+        if(boardBoundingBox.GetWidth() && boardBoundingBox.GetWidth())
+        {
+            double scaleX = double(m_Parent->GetPageSizeIU().x) / boardBoundingBox.GetWidth();
+            double scaleY = double(m_Parent->GetPageSizeIU().y) / boardBoundingBox.GetHeight();
+            userscale = (scaleX < scaleY) ? scaleX : scaleY;
+        }
+        else
+            userscale = 1.0;
     }
 
     wxSize scaledPageSize = m_Parent->GetPageSizeIU();

_______________________________________________
Mailing list: https://launchpad.net/~kicad-developers
Post to     : kicad-developers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~kicad-developers
More help   : https://help.launchpad.net/ListHelp

Reply via email to