Fixed issue 330 (rotation on zoom) and other small bug

git-svn-id: http://svg-edit.googlecode.com/svn/trunk@960 eee81c28-f429-11dd-99c0-75d572ba1ddd
master
Alexis Deveria 2009-11-20 15:40:05 +00:00
parent afabb249cb
commit 2441b75477
1 changed files with 13 additions and 10 deletions

View File

@ -441,7 +441,7 @@ function BatchCommand(text) {
bFoundRotate = true; bFoundRotate = true;
} }
if (bFoundRotate) { if (bFoundRotate) {
tstr = transformToObj(xform).text + " " + tstr; tstr = transformToObj(xform, true).text + " " + tstr;
} }
else if(!bFoundRotate) { else if(!bFoundRotate) {
m = matrixMultiply(xform.matrix,m); m = matrixMultiply(xform.matrix,m);
@ -1694,8 +1694,8 @@ function BatchCommand(text) {
{ {
case "rect": case "rect":
case "image": case "image":
changes.x = changes.x + Math.min(0,changes.width); changes.x = changes.x-0 + Math.min(0,changes.width);
changes.y = changes.y + Math.min(0,changes.height); changes.y = changes.y-0 + Math.min(0,changes.height);
changes.width = Math.abs(changes.width); changes.width = Math.abs(changes.width);
changes.height = Math.abs(changes.height); changes.height = Math.abs(changes.height);
assignAttributes(selected, changes, 1000); assignAttributes(selected, changes, 1000);
@ -2131,14 +2131,15 @@ function BatchCommand(text) {
// converts a tiny object equivalent of a SVGTransform // converts a tiny object equivalent of a SVGTransform
// has the following properties: // has the following properties:
// - tx, ty, sx, sy, angle, cx, cy, string // - tx, ty, sx, sy, angle, cx, cy, string
var transformToObj = function(xform) { var transformToObj = function(xform, mZoom) {
var m = xform.matrix; var m = xform.matrix;
var tobj = {tx:0,ty:0,sx:1,sy:1,angle:0,cx:0,cy:0,text:""}; var tobj = {tx:0,ty:0,sx:1,sy:1,angle:0,cx:0,cy:0,text:""};
var z = mZoom?current_zoom:1;
switch(xform.type) { switch(xform.type) {
case 2: // TRANSFORM case 2: // TRANSLATE
tobj.tx = m.e; tobj.tx = m.e;
tobj.ty = m.f; tobj.ty = m.f;
tobj.text = "translate(" + m.e + "," + m.f + ")"; tobj.text = "translate(" + m.e*z + "," + m.f*z + ")";
break; break;
case 3: // SCALE case 3: // SCALE
tobj.sx = m.a; tobj.sx = m.a;
@ -2154,7 +2155,7 @@ function BatchCommand(text) {
tobj.cy = ( K * m.f + m.b*m.e ) / ( K*K + m.b*m.b ); tobj.cy = ( K * m.f + m.b*m.e ) / ( K*K + m.b*m.b );
tobj.cx = ( m.e - m.b * tobj.cy ) / K; tobj.cx = ( m.e - m.b * tobj.cy ) / K;
} }
tobj.text = "rotate(" + xform.angle + " " + tobj.cx + "," + tobj.cy + ")"; tobj.text = "rotate(" + xform.angle + " " + tobj.cx*z + "," + tobj.cy*z + ")";
break; break;
// TODO: matrix, skewX, skewY // TODO: matrix, skewX, skewY
} }
@ -4995,11 +4996,13 @@ function BatchCommand(text) {
// if we are not rotated yet, insert a dummy xform // if we are not rotated yet, insert a dummy xform
var m = elem.getCTM(); var m = elem.getCTM();
// Opera bug sets a and d to 0. // Opera bug sets a and d incorrectly.
if(!m.a) m.a = 1; if(!m.d) m.d = 1; if(window.opera) {
m.a = m.d = current_zoom;
}
var center = transformPoint(cx,cy,m); var center = transformPoint(cx,cy,m);
var newrot = svgroot.createSVGTransform(); var newrot = svgroot.createSVGTransform();
newrot.setRotate(val, center.x, center.y); newrot.setRotate(val, center.x/current_zoom, center.y/current_zoom);
tlist.insertItemBefore(newrot, rotIndex); tlist.insertItemBefore(newrot, rotIndex);
// TODO: remove this seperate chunk of code where we replace the rotation transform // TODO: remove this seperate chunk of code where we replace the rotation transform