Fix more of Issue 338: rotations in opera do not collapse scales now
git-svn-id: http://svg-edit.googlecode.com/svn/trunk@970 eee81c28-f429-11dd-99c0-75d572ba1ddd
This commit is contained in:
@@ -4879,18 +4879,11 @@ function BatchCommand(text) {
|
|||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
|
||||||
In my opinion, this method does some questionable things.
|
|
||||||
|
|
||||||
What should it do?
|
|
||||||
|
|
||||||
If the element is already rotated, get the current rotational center
|
|
||||||
otherwise calculate the transformed rotational center.
|
|
||||||
|
|
||||||
Update the rotate() transform on the element.
|
|
||||||
*/
|
|
||||||
this.setRotationAngle = function(val,preventUndo) {
|
this.setRotationAngle = function(val,preventUndo) {
|
||||||
|
// ensure val is the proper type
|
||||||
|
val = parseFloat(val);
|
||||||
var elem = selectedElements[0];
|
var elem = selectedElements[0];
|
||||||
|
var oldTransform = elem.getAttribute("transform");
|
||||||
// we use the actual element's bbox (not the calculated one) since the
|
// we use the actual element's bbox (not the calculated one) since the
|
||||||
// calculated bbox's center can change depending on the angle
|
// calculated bbox's center can change depending on the angle
|
||||||
var bbox = elem.getBBox();
|
var bbox = elem.getBBox();
|
||||||
@@ -4910,37 +4903,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 = transformListToTransform(tlist).matrix;
|
var m = transformListToTransform(tlist).matrix;
|
||||||
var ctm = elem.getCTM();
|
var ctm = elem.getCTM();
|
||||||
// console.log("ctm");
|
|
||||||
// logMatrix(ctm);
|
|
||||||
// logMatrix(m);
|
|
||||||
// Opera bug sets a and d incorrectly.
|
|
||||||
// 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);///current_zoom, center.y/current_zoom);
|
newrot.setRotate(val, center.x, center.y);
|
||||||
tlist.insertItemBefore(newrot, rotIndex);
|
tlist.insertItemBefore(newrot, rotIndex);
|
||||||
// TODO: remove this seperate chunk of code where we replace the rotation transform
|
if (!preventUndo) {
|
||||||
// because calling setRotate() above changes the live transform in the list
|
// FIXME: we need to undo it, then redo it so it can be undo-able! :)
|
||||||
if (preventUndo) {
|
// TODO: figure out how to make changes to transform list undo-able cross-browser?
|
||||||
// we don't need to undo, just update the transform list
|
|
||||||
// Opera Bug: for whatever reason, sometimes Opera doesn't let you
|
|
||||||
// replace the 0th transform (perhaps if it's an identity matrix?)
|
|
||||||
// TODO: I don't think this block is needed anymore
|
|
||||||
try {
|
|
||||||
console.log('rotindex=' + rotIndex);
|
|
||||||
tlist.replaceItem(newrot, rotIndex);
|
|
||||||
} catch(e) {
|
|
||||||
console.log('in the catch: ' + e);
|
|
||||||
tlist.insertItemBefore(newrot,rotIndex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// FIXME: we need to do it, then undo it, then redo it so it can be undo-able! :)
|
|
||||||
// TODO: figure out how to make changes to transform list undo-able cross-browser
|
|
||||||
var oldTransform = elem.getAttribute("transform");
|
|
||||||
tlist.replaceItem(newrot, rotIndex);
|
|
||||||
var newTransform = elem.getAttribute("transform");
|
var newTransform = elem.getAttribute("transform");
|
||||||
elem.setAttribute("transform", oldTransform);
|
elem.setAttribute("transform", oldTransform);
|
||||||
this.changeSelectedAttribute("transform",newTransform,selectedElements);
|
this.changeSelectedAttribute("transform",newTransform,selectedElements);
|
||||||
|
|||||||
Reference in New Issue
Block a user