transformlist branch: update comments/notes, remove logging
git-svn-id: http://svg-edit.googlecode.com/svn/branches/transformlist@921 eee81c28-f429-11dd-99c0-75d572ba1ddd
This commit is contained in:
@@ -1383,7 +1383,7 @@ function BatchCommand(text) {
|
|||||||
// always remove translates by transferring them down to the children
|
// always remove translates by transferring them down to the children
|
||||||
// otherwise just reduce adjacent scales
|
// otherwise just reduce adjacent scales
|
||||||
|
|
||||||
// The first pass is to flatten all translates into one
|
// The first pass is to collapse all translates
|
||||||
var n = tlist.numberOfItems;
|
var n = tlist.numberOfItems;
|
||||||
while (n--) {
|
while (n--) {
|
||||||
var xform = tlist.getItem(n);
|
var xform = tlist.getItem(n);
|
||||||
@@ -1401,15 +1401,39 @@ function BatchCommand(text) {
|
|||||||
tlist.removeItem(n);
|
tlist.removeItem(n);
|
||||||
}
|
}
|
||||||
// now restore just the one translate
|
// now restore just the one translate
|
||||||
|
// its matrix before transferring down
|
||||||
if (tx != 0 || ty != 0) {
|
if (tx != 0 || ty != 0) {
|
||||||
var newxlate = svgroot.createSVGTransform();
|
var newxlate = svgroot.createSVGTransform();
|
||||||
newxlate.setTranslate(tx,ty);
|
newxlate.setTranslate(tx,ty);
|
||||||
tlist.insertItemBefore(newxlate, 0);
|
tlist.insertItemBefore(newxlate, 0);
|
||||||
|
// TODO: can we pass the translates down to the individual children?
|
||||||
|
/*
|
||||||
|
// get the matrix of the remaining transformlist
|
||||||
|
var mat = svgroot.createSVGMatrix();
|
||||||
|
var m = tlist.numberOfItems;
|
||||||
|
while (m--) {
|
||||||
|
mat = matrixMultiply(tlist.getItem(m).matrix, mat);
|
||||||
|
}
|
||||||
|
mat = mat.inverse();
|
||||||
|
var mv = transformPoint(tx,ty,mat);
|
||||||
|
var children = selected.childNodes;
|
||||||
|
var c = children.length;
|
||||||
|
while (c--) {
|
||||||
|
var child = children.item(c);
|
||||||
|
if (child.nodeType == 1) {
|
||||||
|
var childTlist = canvas.getTransformList(child);
|
||||||
|
var newxlate = svgroot.createSVGTransform();
|
||||||
|
newxlate.setTranslate(mv.x,mv.y);
|
||||||
|
childTlist.insertItemBefore(newxlate, 0);
|
||||||
|
batchCmd.addSubCommand( recalculateDimensions(child) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// TODO: The second pass is to find all adjacent transform sets of the form:
|
// The second pass is to find all adjacent transform sets of the form:
|
||||||
// translate(tx,ty) scale(sx,sy) translate(-tx,-ty) and reduce them
|
// translate(tx,ty) scale(sx,sy) translate(-tx,-ty) and collapse them
|
||||||
// to one set (multiply sx and sy)
|
|
||||||
tx = 0;
|
tx = 0;
|
||||||
ty = 0;
|
ty = 0;
|
||||||
var bGotOffset = false;
|
var bGotOffset = false;
|
||||||
@@ -1423,7 +1447,6 @@ function BatchCommand(text) {
|
|||||||
var sobj = transformToObj(xform);
|
var sobj = transformToObj(xform);
|
||||||
sx *= sobj.sx;
|
sx *= sobj.sx;
|
||||||
sy *= sobj.sy;
|
sy *= sobj.sy;
|
||||||
console.log([sx,sy]);
|
|
||||||
if (!bGotOffset) {
|
if (!bGotOffset) {
|
||||||
var tobj = transformToObj(tlist.getItem(n-1));
|
var tobj = transformToObj(tlist.getItem(n-1));
|
||||||
tx = tobj.tx;
|
tx = tobj.tx;
|
||||||
@@ -1434,10 +1457,11 @@ function BatchCommand(text) {
|
|||||||
tlist.removeItem(n+1);
|
tlist.removeItem(n+1);
|
||||||
tlist.removeItem(n);
|
tlist.removeItem(n);
|
||||||
tlist.removeItem(n-1);
|
tlist.removeItem(n-1);
|
||||||
|
// decrement one more so that we're not off the end of the transformlist
|
||||||
|
// after removing three transforms above
|
||||||
n--;
|
n--;
|
||||||
}
|
}
|
||||||
// now restore just the one scale and its offset translates
|
// now restore just the one scale and its offset translates
|
||||||
console.log('final scales: ' + sx + ',' + sy);
|
|
||||||
if (sx != 1 || sy != 1) {
|
if (sx != 1 || sy != 1) {
|
||||||
var newscale = svgroot.createSVGTransform(),
|
var newscale = svgroot.createSVGTransform(),
|
||||||
offset_p = svgroot.createSVGTransform(),
|
offset_p = svgroot.createSVGTransform(),
|
||||||
@@ -5035,8 +5059,7 @@ function BatchCommand(text) {
|
|||||||
// place to insert a rotate. This would be searching from the end of the tlist and
|
// place to insert a rotate. This would be searching from the end of the tlist and
|
||||||
// going back until we either:
|
// going back until we either:
|
||||||
// - find an existing rotate OR
|
// - find an existing rotate OR
|
||||||
// - find a translate that is not part of a scale (in the reduced case, this will mean
|
// - find a translate that is not part of a scale
|
||||||
// two translates next to each other)
|
|
||||||
this.setRotationAngle = function(val,preventUndo) {
|
this.setRotationAngle = function(val,preventUndo) {
|
||||||
var elem = selectedElements[0];
|
var elem = selectedElements[0];
|
||||||
// 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
|
||||||
|
|||||||
Reference in New Issue
Block a user