changeset 3906:ec1d91fdd6a2

fairway_profile: print template edited and print mechanism improved
author Thomas Junk <thomas.junk@intevation.de>
date Wed, 10 Jul 2019 17:08:28 +0200
parents 3c095749efb2
children 7b172a1fd9e7
files client/src/components/fairway/Fairwayprofile.vue client/src/lib/mixins.js
diffstat 2 files changed, 21 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/client/src/components/fairway/Fairwayprofile.vue	Wed Jul 10 17:01:36 2019 +0200
+++ b/client/src/components/fairway/Fairwayprofile.vue	Wed Jul 10 17:08:28 2019 +0200
@@ -188,8 +188,8 @@
             type: "diagram",
             position: "topleft",
             offset: { x: 20, y: 60 },
-            width: 290,
-            height: 100
+            width: 280,
+            height: 90
           },
           {
             type: "diagramtitle",
@@ -368,18 +368,17 @@
     addDiagram(position, offset, width, height) {
       let x = offset.x,
         y = offset.y;
-      const svgWidth = this.millimeter2pixels(width, 80);
-      const svgHeight = this.millimeter2pixels(height, 80);
-      // check if there are tow diagrams on the screen
-      // draw the diagram in a separated html element to get the full size
+      const resolution = this.templateData.properties.resolution || 80;
+      const svgWidth = this.millimeter2pixels(width, resolution);
+      const svgHeight = this.millimeter2pixels(height, resolution);
       const offScreen = document.querySelector("#offScreen");
       offScreen.style.width = `${svgWidth}px`;
       offScreen.style.height = `${svgHeight}px`;
       this.renderTo({
         element: offScreen,
         dimensions: {
-          svgWidth: svgWidth - this.margin.right - this.margin.left,
-          svgHeight: svgHeight - this.margin.top - this.margin.bottom
+          svgWidth: svgWidth,
+          svgHeight: svgHeight
         }
       });
       var svg = offScreen.querySelector("svg");
@@ -400,7 +399,7 @@
         xOffset: x,
         yOffset: y,
         // TODO depend on the size and aspect ration on paper
-        scale: 0.2
+        scale: this.templateData.properties.paperSize === "a3" ? 0.3 : 0.27
       });
       offScreen.removeChild(svg);
     },
--- a/client/src/lib/mixins.js	Wed Jul 10 17:01:36 2019 +0200
+++ b/client/src/lib/mixins.js	Wed Jul 10 17:08:28 2019 +0200
@@ -132,6 +132,19 @@
     ...mapState("user", ["user"])
   },
   methods: {
+    getPaperDimensions(format) {
+      const dims = {
+        A3: {
+          height: 297,
+          width: 420
+        },
+        A4: {
+          height: 210,
+          width: 297
+        }
+      };
+      return dims[format.toUpperCase()];
+    },
     millimeter2pixels(length, dpi) {
       return (dpi * length) / 25.4;
     },