2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 18:59:33 +00:00

contrib/InfoPanel: fixed plot resize

git-svn-id: https://svn.fhem.de/fhem/trunk@7834 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
betateilchen 2015-02-02 17:22:06 +00:00
parent 700799a041
commit 49a9ec1008

View File

@ -305,7 +305,7 @@ sub btIP_itemImg {
}
($width,$height,$mimetype,$data) = _btIP_imgData($data,$scale);
$output = "<!-- w: $width h: $height t: $mimetype -->\n";
$output = "<!-- s: $scale w: $width h: $height t: $mimetype -->\n";
$output .= "<image id=\"$id\" x=\"$x\" y=\"$y\" width=\"".$width."px\" height=\"".$height."px\" \nxlink:href=\"$data\" />\n";
return $output;
}
@ -337,15 +337,6 @@ sub _btIP_imgRescale {
return ($width,$height);
}
sub _btIP_svgRescale {
my ($width,$height,$scale) = @_;
if ($scale =~ s/([whWH])([\d]*)/$2/) {
$scale = (uc($1) eq "W") ? $scale/$width : $scale/$height;
}
return $scale;
}
sub btIP_itemLine {
my ($id,$x1,$y1,$x2,$y2,$th,%params)= @_;
$id = ($id eq '-') ? createUniqueId() : $id;
@ -357,7 +348,7 @@ sub btIP_itemPlot {
my ($id,$x,$y,$scale,$inline,$arg) = @_;
my (@plotName) = split(";",$arg);
$id = ($id eq '-') ? createUniqueId() : $id;
my (@webs,$width,$height,$output,$mimetype,$svgdata);
my (@webs,$width,$height,$newWidth,$newHeight,$output,$mimetype,$svgdata);
@webs=devspec2array("TYPE=FHEMWEB");
foreach(@webs) {
@ -368,12 +359,9 @@ sub btIP_itemPlot {
}
($width,$height) = split(",", AttrVal($plotName[0],"plotsize","800,160"));
($width,$height) = _btIP_imgRescale($width,$height,$scale) unless $scale eq '1';
($newWidth,$newHeight) = _btIP_imgRescale($width,$height,$scale);
$attr{$plotName[0]}{plotsize} = "$newWidth,$newHeight";
if($inline eq "1") {
#
# embed base64 data
#
$FW_RET = undef;
$FW_webArgs{dev} = $plotName[0];
$FW_webArgs{logdev} = InternalVal($plotName[0], "LOGDEVICE", "");
@ -383,33 +371,14 @@ sub btIP_itemPlot {
$FW_pos{off} = ($plotName[2]) ? $plotName[2] : undef;
($mimetype, $svgdata) = SVG_showLog("unused");
$attr{$plotName[0]}{plotsize} = "$width,$height";
$svgdata =~ s/<\/svg>/<polyline opacity="0" points="0,0 $width,$height"\/><\/svg>/;
(undef,undef,undef,$svgdata) = _btIP_imgData($svgdata,1);
($width,$height,$mimetype,$svgdata) = _btIP_imgData($svgdata,1);
$scale = _btIP_svgRescale($width,$height,$scale);
$output = "<!-- w: $width h: $height t: $mimetype -->\n";
# $output .= "<image id=\"$id\" x=\"$x\" y=\"$y\" width=\"".$width."px\" height=\"".$height."px\" \n";
# $output .= "xlink:href=\"$svgdata\" />\n";
$output .= "<defs><symbol id=\"sym_$id\">\n".
"<image id=\"$id\" x=\"$x\" y=\"$y\" width=\"".$width."px\" height=\"".$height."px\" ".
"xlink:href=\"$svgdata\" />\n</symbol></defs>\n".
"<use xlink:href=\"#sym_$id\" x=\"$x\" y=\"$y\" transform=\"scale($scale)\" />\n";
} else {
#
# embed link to plot
#
my $url;
$url = "$FW_ME/SVG_showLog?dev=". $plotName[0].
"&amp;logdev=". InternalVal($plotName[0], "LOGDEVICE", "").
"&amp;gplotfile=". InternalVal($plotName[0], "GPLOTFILE", "").
"&amp;logfile=". InternalVal($plotName[0], "LOGFILE", "CURRENT");
$url .= "&amp;pos=". ($plotName[1]) ? $plotName[1] : 'day';
$url .= "&amp;zoom=". ($plotName[2]) ? $plotName[2] : undef;
$output = "<image id=\"$id\" x=\"$x\" y=\"$y\" width=\"".$width."px\" height=\"".$height."px\" \nxlink:href=\"$url\" />\n";
}
$output = "<!-- w: $width h: $height nw: $newWidth nh: $newHeight t: $mimetype -->\n";
$output .= "<image id=\"$id\" x=\"$x\" y=\"$y\" width=\"${newWidth}px\" height=\"${newHeight}px\" \n";
$output .= "xlink:href=\"$svgdata\" />\n";
return $output;
}