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); ($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"; $output .= "<image id=\"$id\" x=\"$x\" y=\"$y\" width=\"".$width."px\" height=\"".$height."px\" \nxlink:href=\"$data\" />\n";
return $output; return $output;
} }
@ -337,15 +337,6 @@ sub _btIP_imgRescale {
return ($width,$height); 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 { sub btIP_itemLine {
my ($id,$x1,$y1,$x2,$y2,$th,%params)= @_; my ($id,$x1,$y1,$x2,$y2,$th,%params)= @_;
$id = ($id eq '-') ? createUniqueId() : $id; $id = ($id eq '-') ? createUniqueId() : $id;
@ -357,7 +348,7 @@ sub btIP_itemPlot {
my ($id,$x,$y,$scale,$inline,$arg) = @_; my ($id,$x,$y,$scale,$inline,$arg) = @_;
my (@plotName) = split(";",$arg); my (@plotName) = split(";",$arg);
$id = ($id eq '-') ? createUniqueId() : $id; $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"); @webs=devspec2array("TYPE=FHEMWEB");
foreach(@webs) { foreach(@webs) {
@ -368,48 +359,26 @@ sub btIP_itemPlot {
} }
($width,$height) = split(",", AttrVal($plotName[0],"plotsize","800,160")); ($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") { $FW_RET = undef;
# $FW_webArgs{dev} = $plotName[0];
# embed base64 data $FW_webArgs{logdev} = InternalVal($plotName[0], "LOGDEVICE", "");
# $FW_webArgs{gplotfile} = InternalVal($plotName[0], "GPLOTFILE", "");
$FW_RET = undef; $FW_webArgs{logfile} = InternalVal($plotName[0], "LOGFILE", "CURRENT");
$FW_webArgs{dev} = $plotName[0]; $FW_pos{zoom} = ($plotName[1]) ? $plotName[1] : 'day';
$FW_webArgs{logdev} = InternalVal($plotName[0], "LOGDEVICE", ""); $FW_pos{off} = ($plotName[2]) ? $plotName[2] : undef;
$FW_webArgs{gplotfile} = InternalVal($plotName[0], "GPLOTFILE", "");
$FW_webArgs{logfile} = InternalVal($plotName[0], "LOGFILE", "CURRENT");
$FW_pos{zoom} = ($plotName[1]) ? $plotName[1] : 'day';
$FW_pos{off} = ($plotName[2]) ? $plotName[2] : undef;
($mimetype, $svgdata) = SVG_showLog("unused"); ($mimetype, $svgdata) = SVG_showLog("unused");
$svgdata =~ s/<\/svg>/<polyline opacity="0" points="0,0 $width,$height"\/><\/svg>/; $attr{$plotName[0]}{plotsize} = "$width,$height";
($width,$height,$mimetype,$svgdata) = _btIP_imgData($svgdata,1); $svgdata =~ s/<\/svg>/<polyline opacity="0" points="0,0 $width,$height"\/><\/svg>/;
$scale = _btIP_svgRescale($width,$height,$scale); (undef,undef,undef,$svgdata) = _btIP_imgData($svgdata,1);
$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". $output = "<!-- w: $width h: $height nw: $newWidth nh: $newHeight t: $mimetype -->\n";
"<image id=\"$id\" x=\"$x\" y=\"$y\" width=\"".$width."px\" height=\"".$height."px\" ". $output .= "<image id=\"$id\" x=\"$x\" y=\"$y\" width=\"${newWidth}px\" height=\"${newHeight}px\" \n";
"xlink:href=\"$svgdata\" />\n</symbol></defs>\n". $output .= "xlink:href=\"$svgdata\" />\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";
}
return $output; return $output;
} }