[fusion-commits] r2749 - trunk/widgets/QuickPlot

svn_fusion at osgeo.org svn_fusion at osgeo.org
Wed Jul 24 22:01:35 PDT 2013


Author: jng
Date: 2013-07-24 22:01:34 -0700 (Wed, 24 Jul 2013)
New Revision: 2749

Modified:
   trunk/widgets/QuickPlot/PlotAsPDF.php
   trunk/widgets/QuickPlot/QuickPlotPanel.js
Log:
#584: For portrait orientation, also flip the map view box as well when doing ratio calculations, otherwise portrait plots will be severely lacking in height. Also fix positioning of disclaimer in portrait mode when legend is present.

Modified: trunk/widgets/QuickPlot/PlotAsPDF.php
===================================================================
--- trunk/widgets/QuickPlot/PlotAsPDF.php	2013-07-24 08:46:05 UTC (rev 2748)
+++ trunk/widgets/QuickPlot/PlotAsPDF.php	2013-07-25 05:01:34 UTC (rev 2749)
@@ -10,7 +10,7 @@
     $generateLegend = "/GenerateLegend.php?";
     $pathString = implode('/',explode('/', $path,-1));
     $showLegend = array_key_exists("ShowLegend", $_POST) && $_POST["ShowLegend"] === "on";
-    $legendWidth = 0;
+    $legendWidth = 0; //Width of legend in inches
 
     // POST params
     // Title
@@ -98,12 +98,14 @@
     if("80" === $port)
     {
         $filelocation = $protocol.$host.$pathString.$generatePage.$query_string;
-        $legendfilelocation = $protocol.$host.$pathString.$generateLegend.$legend_query_string;
+        if ($showLegend)
+            $legendfilelocation = $protocol.$host.$pathString.$generateLegend.$legend_query_string;
     }
     else
     {
         $filelocation = $protocol.$host.":".$port.$pathString.$generatePage.$query_string;
-        $legendfilelocation = $protocol.$host.":".$port.$pathString.$generateLegend.$legend_query_string;
+        if ($showLegend)
+            $legendfilelocation = $protocol.$host.":".$port.$pathString.$generateLegend.$legend_query_string;
     }
     
     //Uncomment to see the legend image url
@@ -316,7 +318,7 @@
 
     function DrawDeclaration()
     {
-        global $pdf, $font, $margin, $printSize;
+        global $pdf, $font, $margin, $printSize, $legendWidth;
     
         $declaration= $_POST["legalNotice"];
         //$declaration_w = $pdf->GetStringWidth($declaration,$font,9);
@@ -326,7 +328,7 @@
         
         //Sometimes the declaration is too short, less than 100 unit, we could set the cell width as the string length
         //so it will align to the right
-        $SingleLineDeclarationWidth  = $pdf->GetStringWidth($declaration, $font, "", 9, false);
+        $SingleLineDeclarationWidth  = $pdf->GetStringWidth($declaration, $font, "", 9, false) + $legendWidth;
         $tolerance = 3;
         $w = 100;
         
@@ -339,7 +341,7 @@
         $border = 0; //no border
         $align = "L";//align left
         $tolerance = 2;
-        $x = ParseLocaleDouble($margin[2]) + $printSize->width - $w + $tolerance;
+        $x = ParseLocaleDouble($margin[2] + $legendWidth) + $printSize->width - $w + $tolerance;
         $cellTotalHeight = $pdf->getStringHeight($w,$declaration);
         $y = $pdf->getPageHeight() - $cellTotalHeight - $bottomPadding;
 

Modified: trunk/widgets/QuickPlot/QuickPlotPanel.js
===================================================================
--- trunk/widgets/QuickPlot/QuickPlotPanel.js	2013-07-24 08:46:05 UTC (rev 2748)
+++ trunk/widgets/QuickPlot/QuickPlotPanel.js	2013-07-25 05:01:34 UTC (rev 2749)
@@ -246,14 +246,12 @@
 {
     var value = document.getElementById("PaperList").value.split(",");
     var size;
-    if( getOrientation() === "P" ){
+    var orientation = getOrientation();
+    if (orientation  === "P" ){
         size = {w: parseFloat(value[0]), h: parseFloat(value[1])};
-    }else if (getOrientation() === "L"){
+    }else if (orientation === "L"){
         size = {w: parseFloat(value[1]), h: parseFloat(value[0])};
     }
-    var margins = getMargin();
-    size.h = size.h - margins.top - margins.buttom;
-    size.w = size.w - margins.left - margins.right;
     
     if (!advancedOptionsOn())
     {
@@ -261,7 +259,20 @@
         var map        = getParent().Fusion.getWidgetById("Map");
         var paperRatio = size.w / size.h;
         var viewSize   = map.getSize();
-        var viewRatio  = viewSize.w / viewSize.h;
+        var vs;
+        if (orientation === "P") {
+            vs = {
+                w: viewSize.h,
+                h: viewSize.w
+            };
+        }
+        if (orientation === "L") {
+            vs = {
+                w: viewSize.w,
+                h: viewSize.h
+            };
+        }
+        var viewRatio  = vs.w / vs.h;
 
         if (paperRatio > viewRatio){
             size.w     = size.h * viewRatio;
@@ -270,6 +281,10 @@
         } 
     }
     
+    var margins = getMargin();
+    size.h = size.h - margins.top - margins.buttom;
+    size.w = size.w - margins.left - margins.right;
+    
     document.getElementById("paperSize").value = document.getElementById("PaperList").value;
     return size;
 }



More information about the fusion-commits mailing list