[Mapbender-commits] r3652 - in branches/print_dev/http:
extensions/fpdf print print/classes
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Mon Mar 9 10:08:32 EDT 2009
Author: mschulz
Date: 2009-03-09 10:08:32 -0400 (Mon, 09 Mar 2009)
New Revision: 3652
Modified:
branches/print_dev/http/extensions/fpdf/mb_fpdi.php
branches/print_dev/http/print/classes/mbImageDecorator.php
branches/print_dev/http/print/mod_printPDF_div.php
branches/print_dev/http/print/testConfigTemplate.json
Log:
added image rotation
Modified: branches/print_dev/http/extensions/fpdf/mb_fpdi.php
===================================================================
--- branches/print_dev/http/extensions/fpdf/mb_fpdi.php 2009-03-09 11:16:55 UTC (rev 3651)
+++ branches/print_dev/http/extensions/fpdf/mb_fpdi.php 2009-03-09 14:08:32 UTC (rev 3652)
@@ -20,7 +20,7 @@
* Public methods *
* *
*******************************************************************************/
- function Image($file,$x,$y,$w=0,$h=0,$type='',$link='', $isMask=false, $maskImg=0)
+ function Image($file,$x,$y,$w=0,$h=0,$type='',$link='', $isMask=false, $maskImg=0, $align='', $angle=0)
{
//Put an image on the page
if(!isset($this->images[$file]))
@@ -73,8 +73,55 @@
if($h==0)
$h=$w*$info['h']/$info['w'];
+ $x_rot = $x;
+ $y_rot = $y;
+
+ switch ($align) {
+ case 1:
+ break;
+ case 2:
+ $x=$x-$w/2;
+ break;
+ case 3:
+ $x=$x-$w;
+ break;
+ case 4:
+ $y=$y-$h/2;
+ break;
+ case 5:
+ $x=$x-$w/2;
+ $y=$y-$h/2;
+ break;
+ case 6:
+ $x=$x-$w;
+ $y=$y-$h/2;
+ break;
+ case 7:
+ $y=$y-$h;
+ break;
+ case 8:
+ $x=$x-$w/2;
+ $y=$y-$h;
+ break;
+ case 9:
+ $x=$x-$w;
+ $y=$y-$h;
+ break;
+ default:
+ break;
+ }
+
if ($isMask) $x = $this->fwPt + 10; // embed hidden, ouside the canvas
- $this->_out(sprintf('q %.2f 0 0 %.2f %.2f %.2f cm /I%d Do Q',$w*$this->k,$h*$this->k,$x*$this->k,($this->h-($y+$h))*$this->k,$info['i']));
+
+ if($angle!=0){
+ $this->_out('q');
+ $this->Rotation($angle, $x_rot, $y_rot);
+ $this->_out(sprintf('q %.2f 0 0 %.2f %.2f %.2f cm /I%d Do Q',$w*$this->k,$h*$this->k,$x*$this->k,($this->h-($y+$h))*$this->k,$info['i']));
+ $this->_out('Q');
+ }
+ else { $this->_out(sprintf('q %.2f 0 0 %.2f %.2f %.2f cm /I%d Do Q',$w*$this->k,$h*$this->k,$x*$this->k,($this->h-($y+$h))*$this->k,$info['i']));}
+
+ #$this->_out(sprintf('q %.2f 0 0 %.2f %.2f %.2f cm /I%d Do Q',$w*$this->k,$h*$this->k,$x*$this->k,($this->h-($y+$h))*$this->k,$info['i']));
if($link)
$this->Link($x,$y,$w,$h,$link);
@@ -461,7 +508,22 @@
$this->Cell($w, $h, $txt, '', $ln, $align, 0, $link);
$this->UnsetClipping();
}
-
+
+ function Rotation($grad, $x = '', $y = ''){
+ if ($x === '') $x = $this->x;
+ if ($y === '') $y = $this->y;
+ $y = ($this->h-$y) * $this->k;
+ $x *= $this->k;
+ $tm[0] = cos(deg2rad($grad));
+ $tm[1] = sin(deg2rad($grad));
+ $tm[2] = -$tm[1];
+ $tm[3] = $tm[0];
+ $tm[4] = $x+$tm[1]*$y-$tm[0]*$x;
+ $tm[5] = $y-$tm[0]*$y-$tm[1]*$x;
+ $this->_out(sprintf('%.3f %.3f %.3f %.3f %.3f %.3f cm', $tm[0],$tm[1],$tm[2],$tm[3],$tm[4],$tm[5]));
+ }
+
+
}
?>
\ No newline at end of file
Modified: branches/print_dev/http/print/classes/mbImageDecorator.php
===================================================================
--- branches/print_dev/http/print/classes/mbImageDecorator.php 2009-03-09 11:16:55 UTC (rev 3651)
+++ branches/print_dev/http/print/classes/mbImageDecorator.php 2009-03-09 14:08:32 UTC (rev 3652)
@@ -4,6 +4,8 @@
protected $pageElementType = "image";
protected $elementId;
+ protected $rotationAngle = 200;
+ protected $overrideMembersFromRequest = array("rotationAngle");
public function __construct($pdfObj, $elementId, $mapConf, $controls) {
parent::__construct($pdfObj, $mapConf, $controls);
@@ -12,14 +14,34 @@
$this->decorate();
}
- public function override() {}
+ public function override() {
+ /* returns an array of (request key, member id) arrays */
+ $idsFromRequest = $this->getPageElementLink($this->elementId);
+ foreach ($idsFromRequest as $requestKey => $memberId) {
+ $e = new mb_notice("mbImageDecorator: checking overrides: ".$requestKey.$memberId);
+ }
+ foreach ($_REQUEST as $k => $v) {
+ $e = new mb_notice("mbImageDecorator: checking Request: ".$k."=".$v);
+ }
+
+ foreach ($this->overrideMembersFromRequest as $overrideMemberFromRequest) {
+ foreach ($idsFromRequest as $requestKey => $memberId) {
+ $e = new mb_notice("mbImageDecorator: before override: set ".$memberId." to ".$requestKey);
+ if ($overrideMemberFromRequest==$memberId && isset($_REQUEST[$requestKey]) && $_REQUEST[$requestKey] != "") {
+ $this->{$overrideMemberFromRequest} = $_REQUEST[$requestKey];
+ $e = new mb_notice("mbImageDecorator: override from Request: ".$overrideMemberFromRequest." to ".$this->{$overrideMemberFromRequest});
+ }
+ else {
+ $this->{$overrideMemberFromRequest} = $this->conf->{$memberId};
+ $e = new mb_notice("mbImageDecorator: using conf: ".$overrideMemberFromRequest." to ".$this->conf->{$memberId});
+ }
+ }
+ }
+ }
public function decorate() {
- $width = $this->conf->width;
- $height = $this->conf->height;
- $filename = $this->conf->filename;
-
- $this->pdf->objPdf->Image($this->conf->filename, $this->conf->x_ul, $this->conf->y_ul);
+ #Image($file,$x,$y,$w=0,$h=0,$type='',$link='', $isMask=false, $maskImg=0, $angle=0)
+ $this->pdf->objPdf->Image($this->conf->filename, $this->conf->x_ul, $this->conf->y_ul, $this->conf->width, $this->conf->height,'','',false,0,5,$this->rotationAngle);
}
}
Modified: branches/print_dev/http/print/mod_printPDF_div.php
===================================================================
--- branches/print_dev/http/print/mod_printPDF_div.php 2009-03-09 11:16:55 UTC (rev 3651)
+++ branches/print_dev/http/print/mod_printPDF_div.php 2009-03-09 14:08:32 UTC (rev 3652)
@@ -188,12 +188,17 @@
for (var item in json.controls) {
var element = json.controls[item];
var element_id = myId + "_" + element.id;
- str += '<div class="print_option_dyn">\n';
- str += '<label class="print_label" for="'+element.id+'">'+element.label+'</label>\n';
+ if (element.type != "hidden") {
+ str += '<div class="print_option_dyn">\n';
+ str += '<label class="print_label" for="'+element.id+'">'+element.label+'</label>\n';
+ }
switch (element.type) {
case "text":
str += '<input type="'+element.type+'" name="'+element.id+'" id="'+element.id+'" size="'+element.size+'"><br>\n';
break;
+ case "hidden":
+ str += '<input type="'+element.type+'" name="'+element.id+'" id="'+element.id+'"><br>\n';
+ break;
case "textarea":
str += '<textarea id="'+element.id+'" name="'+element.id+'" size="'+element.size+'"></textarea><br>\n';
break;
@@ -206,7 +211,7 @@
str += '</select><br>\n';
break;
}
- str += '</div>\n';
+ if (element.type != "hidden") str += '</div>\n';
}
if (str) $("#"+myId+"_formsubmit").before(str);
}
Modified: branches/print_dev/http/print/testConfigTemplate.json
===================================================================
--- branches/print_dev/http/print/testConfigTemplate.json 2009-03-09 11:16:55 UTC (rev 3651)
+++ branches/print_dev/http/print/testConfigTemplate.json 2009-03-09 14:08:32 UTC (rev 3652)
@@ -42,6 +42,13 @@
"pageElementsLink" : {
"kommentar" : "value"
}
+ },
+ {
+ "id" : "rotation",
+ "type" : "hidden",
+ "pageElementsLink" : {
+ "nordpfeil" : "rotation"
+ }
}
],
"pages" : [
@@ -105,10 +112,11 @@
},
"nordpfeil" : {
"type" : "image",
- "x_ul" : 270.1,
- "y_ul" : 15.2,
- "width" : 37,
- "height" : 76,
+ "x_ul" : 280.1,
+ "y_ul" : 35.2,
+ "width" : 8,
+ "height" : 18,
+ "rotation" : 0,
"filename" : "./img/northarrow.png"
}
}
More information about the Mapbender_commits
mailing list