Commit 2c8ed810 authored by Sergey.Luzyanin's avatar Sergey.Luzyanin Committed by Alexander.Trofimov

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@47682 954022d7-b5bf-4e40-9824-e11837661b57
parent b4d35f46
...@@ -121,13 +121,14 @@ DrawingObjectsController.prototype = ...@@ -121,13 +121,14 @@ DrawingObjectsController.prototype =
createGroup: function(drawingBase) createGroup: function(drawingBase)
{ {
var selected_objects = this.selectedObjects; var drawing_bases = this.drawingObjects.getDrawingObjects();
var grouped_objects = []; var grouped_objects = [];
for(var i = 0; i < selected_objects.length; ++i) for(var i = 0; i < drawing_bases.length; ++i)
{ {
if(selected_objects[i].canGroup()) var cur_drawing_base = drawing_bases[i];
if(cur_drawing_base.isGraphicObject() && cur_drawing_base.graphicObject.selected && cur_drawing_base.graphicObject.canGroup())
{ {
grouped_objects.push(selected_objects[i]); grouped_objects.push(cur_drawing_base.graphicObject);
} }
} }
if(grouped_objects.length < 2) if(grouped_objects.length < 2)
...@@ -156,6 +157,7 @@ DrawingObjectsController.prototype = ...@@ -156,6 +157,7 @@ DrawingObjectsController.prototype =
group.setPosition(min_x, min_y); group.setPosition(min_x, min_y);
group.setExtents(max_x - min_x, max_y - min_y); group.setExtents(max_x - min_x, max_y - min_y);
group.setChildExtents(max_x - min_x, max_y - min_y); group.setChildExtents(max_x - min_x, max_y - min_y);
group.setChildOffsets(0, 0);
for(i = 0; i < grouped_objects.length; ++i) for(i = 0; i < grouped_objects.length; ++i)
{ {
grouped_objects[i].setPosition(grouped_objects[i].x - min_x, grouped_objects[i].y - min_y); grouped_objects[i].setPosition(grouped_objects[i].x - min_x, grouped_objects[i].y - min_y);
......
...@@ -45,7 +45,6 @@ function CGroupShape(drawingBase, drawingObjects) ...@@ -45,7 +45,6 @@ function CGroupShape(drawingBase, drawingObjects)
this.pen = null; this.pen = null;
this.selected = false; this.selected = false;
} }
CGroupShape.prototype = CGroupShape.prototype =
...@@ -110,6 +109,11 @@ CGroupShape.prototype = ...@@ -110,6 +109,11 @@ CGroupShape.prototype =
this.spPr.xfrm.chExtY = chExtY; this.spPr.xfrm.chExtY = chExtY;
}, },
setChildOffsets: function(chOffX, chOffY)
{
this.spPr.xfrm.chOffX = chOffX;
this.spPr.xfrm.chOffY = chOffY;
},
updateDrawingBaseCoordinates: function() updateDrawingBaseCoordinates: function()
{ {
...@@ -401,6 +405,146 @@ CGroupShape.prototype = ...@@ -401,6 +405,146 @@ CGroupShape.prototype =
} }
}, },
normalize: function()
{
for(var i = 0; i < this.spTree.length; ++i)
{
this.spTree[i].normalize();
}
var new_off_x, new_off_y, new_ext_x, new_ext_y;
var xfrm = this.spPr.xfrm;
if(!isRealObject(this.group))
{
new_off_x = xfrm.offX;
new_off_y = xfrm.offY;
new_ext_x = xfrm.extX;
new_ext_y = xfrm.extY;
}
else
{
var scale_scale_coefficients = this.group.getResultScaleCoefficients();
new_off_x = scale_scale_coefficients.cx*(xfrm.offX - this.group.spPr.xfrm.chOffX);
new_off_y = scale_scale_coefficients.cy*(xfrm.offY - this.group.spPr.xfrm.chOffY);
new_ext_x = scale_scale_coefficients.cx*xfrm.extX;
new_ext_y = scale_scale_coefficients.cy*xfrm.extY;
}
this.setPosition(new_off_x, new_off_y);
this.setExtents(new_ext_x, new_ext_y);
this.setChildExtents(new_ext_x, new_ext_y);
this.setChildOffsets(0, 0);
},
updateCoordinatesAfterInternalResize: function()
{
for(var i = 0; i < this.spTree.length; ++i)
{
if(this.spTree[i].isGroup())
this.spTree[i].updateCoordinatesAfterInternalResize();
}
var sp_tree = this.spTree;
var min_x, max_x, min_y, max_y;
var sp = sp_tree[0];
var xfrm = sp.spPr.xfrm;
var rot = xfrm.rot == null ? 0 : xfrm.rot;
var xc, yc;
if(rot < Math.PI*0.25 || rot>Math.PI*1.75 || (rot>Math.PI*0.75 && rot<Math.PI*1.25))
{
min_x = xfrm.offX;
min_y = xfrm.offY;
max_x = xfrm.offX + xfrm.extX;
max_y = xfrm.offY + xfrm.extY;
}
else
{
xc = xfrm.offX + xfrm.extX*0.5;
yc = xfrm.offY + xfrm.extY*0.5;
min_x = xc - xfrm.extY*0.5;
min_y = yc - xfrm.extX*0.5;
max_x = xc + xfrm.extY*0.5;
max_y = yc + xfrm.extX*0.5;
}
var cur_max_x, cur_min_x, cur_max_y, cur_min_y;
for(i = 1; i < sp_tree.length; ++i)
{
sp = sp_tree[i];
xfrm = sp.spPr.xfrm;
rot = xfrm.rot == null ? 0 : xfrm.rot;
if(rot < Math.PI*0.25 || rot>Math.PI*1.75 || (rot>Math.PI*0.75 && rot<Math.PI*1.25))
{
cur_min_x = xfrm.offX;
cur_min_y = xfrm.offY;
cur_max_x = xfrm.offX + xfrm.extX;
cur_max_y = xfrm.offY + xfrm.extY;
}
else
{
xc = xfrm.offX + xfrm.extX*0.5;
yc = xfrm.offY + xfrm.extY*0.5;
cur_min_x = xc - xfrm.extY*0.5;
cur_min_y = yc - xfrm.extX*0.5;
cur_max_x = xc + xfrm.extY*0.5;
cur_max_y = yc + xfrm.extX*0.5;
}
if(cur_max_x > max_x)
max_x = cur_max_x;
if(cur_min_x < min_x)
min_x = cur_min_x;
if(cur_max_y > max_y)
max_y = cur_max_y;
if(cur_min_y < min_y)
min_y = cur_min_y;
}
var temp;
var x_min_clear = min_x;
var y_min_clear = min_y;
if(this.spPr.xfrm.flipH === true)
{
temp = max_x;
max_x = this.spPr.xfrm.extX - min_x;
min_x = this.spPr.xfrm.extX - temp;
}
if(this.spPr.xfrm.flipV === true)
{
temp = max_y;
max_y = this.spPr.xfrm.extY - min_y;
min_y = this.spPr.xfrm.extY - temp;
}
var old_x0, old_y0;
var xfrm = this.spPr.xfrm;
var rot = xfrm.rot == null ? 0 : xfrm.rot;
var hc = xfrm.extX*0.5;
var vc = xfrm.extY*0.5;
old_x0 = this.spPr.xfrm.offX + hc - (hc*Math.cos(rot) - vc*Math.sin(rot));
old_y0 = this.spPr.xfrm.offY + vc - (hc*Math.sin(rot) + vc*Math.cos(rot));
var t_dx = min_x*Math.cos(rot) - min_y*Math.sin(rot);
var t_dy = min_x*Math.sin(rot) + min_y*Math.cos(rot);
var new_x0, new_y0;
new_x0 = old_x0 + t_dx;
new_y0 = old_y0 + t_dy;
var new_hc = Math.abs(max_x - min_x)*0.5;
var new_vc = Math.abs(max_y - min_y)*0.5;
var new_xc = new_x0 + (new_hc*Math.cos(rot) - new_vc*Math.sin(rot));
var new_yc = new_y0 + (new_hc*Math.sin(rot) + new_vc*Math.cos(rot));
var pos_x, pos_y;
pos_x = new_xc - new_hc;
pos_y = new_yc - new_vc;
this.setPosition(pos_x, pos_y);
this.setExtents(Math.abs(max_x - min_x), Math.abs(max_y - min_y));
this.setChildExtents(Math.abs(max_x - min_x), Math.abs(max_y - min_y));
for(i = 0; i < sp_tree.length; ++i)
{
sp_tree[i].setPosition(sp_tree[i].spPr.xfrm.offX - x_min_clear, sp_tree[i].spPr.xfrm.offY - y_min_clear);
}
},
canRotate: function() canRotate: function()
{ {
...@@ -517,8 +661,8 @@ CGroupShape.prototype = ...@@ -517,8 +661,8 @@ CGroupShape.prototype =
getInvertTransform: function() getInvertTransform: function()
{ {
if(this.recalcInfo.recalculateTransform) //if(this.recalcInfo.recalculateTransform)
this.recalculateTransform(); //this.recalculateTransform();
return this.invertTransform; return this.invertTransform;
} , } ,
...@@ -621,6 +765,12 @@ CGroupShape.prototype = ...@@ -621,6 +765,12 @@ CGroupShape.prototype =
} }
}, },
resetSelection: function(drawingObjectsController)
{
while(this.selectedObjects.length > 0)
this.selectedObjects[0].deselect(drawingObjectsController);
},
createRotateTrack: function() createRotateTrack: function()
{ {
return new RotateTrackGroup(this); return new RotateTrackGroup(this);
......
...@@ -200,6 +200,29 @@ CImage.prototype = ...@@ -200,6 +200,29 @@ CImage.prototype =
} }
}, },
normalize: function()
{
var new_off_x, new_off_y, new_ext_x, new_ext_y;
var xfrm = this.spPr.xfrm;
if(!isRealObject(this.group))
{
new_off_x = xfrm.offX;
new_off_y = xfrm.offY;
new_ext_x = xfrm.extX;
new_ext_y = xfrm.extY;
}
else
{
var scale_scale_coefficients = this.group.getResultScaleCoefficients();
new_off_x = scale_scale_coefficients.cx*(xfrm.offX - this.group.spPr.xfrm.chOffX);
new_off_y = scale_scale_coefficients.cy*(xfrm.offY - this.group.spPr.xfrm.chOffY);
new_ext_x = scale_scale_coefficients.cx*xfrm.extX;
new_ext_y = scale_scale_coefficients.cy*xfrm.extY;
}
this.setPosition(new_off_x, new_off_y);
this.setExtents(new_ext_x, new_ext_y);
},
getTransform: function() getTransform: function()
{ {
if(this.recalcInfo.recalculateTransform) if(this.recalcInfo.recalculateTransform)
...@@ -501,10 +524,9 @@ CImage.prototype = ...@@ -501,10 +524,9 @@ CImage.prototype =
createMoveInGroupTrack: function() createMoveInGroupTrack: function()
{ {
return new MoveShapeImageInGroupTrack(this); return new MoveShapeImageTrackInGroup(this);
}, },
getRotateAngle: function(x, y) getRotateAngle: function(x, y)
{ {
var transform = this.getTransform(); var transform = this.getTransform();
......
...@@ -101,7 +101,7 @@ CShape.prototype = ...@@ -101,7 +101,7 @@ CShape.prototype =
if(this.recalcInfo.recalculateBrush) if(this.recalcInfo.recalculateBrush)
this.recalculateBrush(); this.recalculateBrush();
if(this.recalcInfo.recalculatePen) if(this.recalcInfo.recalculatePen)
this.recalculatePen() this.recalculatePen();
}, },
setPosition: function(x, y) setPosition: function(x, y)
...@@ -266,6 +266,29 @@ CShape.prototype = ...@@ -266,6 +266,29 @@ CShape.prototype =
this.invertTransform = global_MatrixTransformer.Invert(this.transform); this.invertTransform = global_MatrixTransformer.Invert(this.transform);
}, },
normalize: function()
{
var new_off_x, new_off_y, new_ext_x, new_ext_y;
var xfrm = this.spPr.xfrm;
if(!isRealObject(this.group))
{
new_off_x = xfrm.offX;
new_off_y = xfrm.offY;
new_ext_x = xfrm.extX;
new_ext_y = xfrm.extY;
}
else
{
var scale_scale_coefficients = this.group.getResultScaleCoefficients();
new_off_x = scale_scale_coefficients.cx*(xfrm.offX - this.group.spPr.xfrm.chOffX);
new_off_y = scale_scale_coefficients.cy*(xfrm.offY - this.group.spPr.xfrm.chOffY);
new_ext_x = scale_scale_coefficients.cx*xfrm.extX;
new_ext_y = scale_scale_coefficients.cy*xfrm.extY;
}
this.setPosition(new_off_x, new_off_y);
this.setExtents(new_ext_x, new_ext_y);
},
recalculateBrush: function() recalculateBrush: function()
{ {
var brush; var brush;
...@@ -763,6 +786,7 @@ CShape.prototype = ...@@ -763,6 +786,7 @@ CShape.prototype =
return new MoveShapeImageTrack(this); return new MoveShapeImageTrack(this);
}, },
createRotateInGroupTrack: function() createRotateInGroupTrack: function()
{ {
return new RotateTrackShapeImageInGroup(this); return new RotateTrackShapeImageInGroup(this);
...@@ -775,7 +799,7 @@ CShape.prototype = ...@@ -775,7 +799,7 @@ CShape.prototype =
createMoveInGroupTrack: function() createMoveInGroupTrack: function()
{ {
return new MoveShapeImageInGroupTrack(this); return new MoveShapeImageTrackInGroup(this);
} }
}; };
\ No newline at end of file
This diff is collapsed.
...@@ -51,49 +51,60 @@ function MoveShapeImageTrack(originalObject) ...@@ -51,49 +51,60 @@ function MoveShapeImageTrack(originalObject)
}; };
} }
function MoveShapeImageInGroupTrack(originalObject) function MoveShapeImageTrackInGroup(originalObject)
{ {
this.originalObject = originalObject; this.originalObject = originalObject;
this.transform = new CMatrix();
this.x = null; this.x = null;
this.y = null; this.y = null;
this.transform = new CMatrix();
this.overlayObject = new OverlayObject(this.originalObject.spPr.geometry, this.originalObject.extX, this.originalObject.extY, this.originalObject.brush, this.originalObject.pen, this.transform); this.overlayObject = new OverlayObject(this.originalObject.spPr.geometry, this.originalObject.extX, this.originalObject.extY, this.originalObject.brush, this.originalObject.pen, this.transform);
this.inv = global_MatrixTransformer.Invert(originalObject.group.transform);
this.inv.tx = 0;
this.getOriginalBoundsRect = function() this.inv.ty = 0;
this.draw = function(overlay)
{ {
return this.originalObject.getRectBounds(); this.overlayObject.draw(overlay);
}; };
this.track = function(dx, dy) this.track = function(dx, dy)
{ {
var original = this.originalObject; var dx_t = this.inv.TransformPointX(dx, dy);
this.x = original.x + dx; var dy_t = this.inv.TransformPointY(dx, dy);
this.y = original.y + dy; this.x = this.originalObject.x + dx_t;
this.transform.Reset(); this.y = this.originalObject.y + dy_t;
var hc = original.extX*0.5; this.calculateTransform();
var vc = original.extY*0.5; };
global_MatrixTransformer.TranslateAppend(this.transform, -hc, -vc); this.getOriginalBoundsRect = function()
if(original.flipH) {
global_MatrixTransformer.ScaleAppend(this.transform, -1, 1); return this.originalObject.getRectBounds();
if(original.flipV)
global_MatrixTransformer.ScaleAppend(this.transform, 1, -1);
global_MatrixTransformer.RotateRadAppend(this.transform, -original.rot);
global_MatrixTransformer.TranslateAppend(this.transform, this.x + hc, this.y + vc);
}; };
this.draw = function(overlay) this.calculateTransform = function()
{ {
this.overlayObject.draw(overlay); var t = this.transform;
t.Reset();
global_MatrixTransformer.TranslateAppend(t, -this.originalObject.extX*0.5, -this.originalObject.extY*0.5);
if(this.originalObject.flipH)
{
global_MatrixTransformer.ScaleAppend(t, -1, 1);
}
if(this.originalObject.flipV)
{
global_MatrixTransformer.ScaleAppend(t, 1, -1);
}
global_MatrixTransformer.RotateRadAppend(t, -this.originalObject.rot);
global_MatrixTransformer.TranslateAppend(t, this.x + this.originalObject.extX*0.5, this.y + this.originalObject.extY*0.5);
global_MatrixTransformer.MultiplyAppend(t, this.originalObject.group.getTransform());
}; };
this.trackEnd = function() this.trackEnd = function()
{ {
this.originalObject.setPosition(this.x, this.y); var scale_scale_coefficients = this.originalObject.group.getResultScaleCoefficients();
var xfrm = this.originalObject.group.spPr.xfrm;
this.originalObject.setPosition(this.x/scale_scale_coefficients.cx + xfrm.chOffX, this.y/scale_scale_coefficients.cy + xfrm.chOffY);
this.originalObject.recalculateTransform(); this.originalObject.recalculateTransform();
this.originalObject.updateDrawingBaseCoordinates(); }
};
} }
function MoveGroupTrack(originalObject) function MoveGroupTrack(originalObject)
......
...@@ -1880,7 +1880,7 @@ function ShapeForResizeInGroup(originalObject, parentTrack) ...@@ -1880,7 +1880,7 @@ function ShapeForResizeInGroup(originalObject, parentTrack)
{ {
global_MatrixTransformer.ScaleAppend(t, 1, -1); global_MatrixTransformer.ScaleAppend(t, 1, -1);
} }
global_MatrixTransformer.RotateRadAppend(t, this.rot); global_MatrixTransformer.RotateRadAppend(t, -this.rot);
global_MatrixTransformer.TranslateAppend(t, this.x + this.extX*0.5, this.y+this.extY*0.5); global_MatrixTransformer.TranslateAppend(t, this.x + this.extX*0.5, this.y+this.extY*0.5);
if(this.parentTrack) if(this.parentTrack)
global_MatrixTransformer.MultiplyAppend(t, this.parentTrack.transform); global_MatrixTransformer.MultiplyAppend(t, this.parentTrack.transform);
......
...@@ -133,7 +133,9 @@ function RotateTrackShapeImageInGroup(originalObject) ...@@ -133,7 +133,9 @@ function RotateTrackShapeImageInGroup(originalObject)
this.overlayObject = new OverlayObject(originalObject.spPr.geometry, originalObject.extX, originalObject.extY, originalObject.brush, originalObject.pen, this.transform); this.overlayObject = new OverlayObject(originalObject.spPr.geometry, originalObject.extX, originalObject.extY, originalObject.brush, originalObject.pen, this.transform);
this.angle = originalObject.rot; this.angle = originalObject.rot;
var full_flip_h = this.originalObject.getFullFlipH();
var full_flip_v = this.originalObject.getFullFlipV();
this.signum = !full_flip_h && !full_flip_v || full_flip_h && full_flip_v ? 1 : -1;
this.draw = function(overlay) this.draw = function(overlay)
{ {
this.overlayObject.draw(overlay); this.overlayObject.draw(overlay);
...@@ -141,7 +143,7 @@ function RotateTrackShapeImageInGroup(originalObject) ...@@ -141,7 +143,7 @@ function RotateTrackShapeImageInGroup(originalObject)
this.track = function(angle, e) this.track = function(angle, e)
{ {
var new_rot = angle + this.originalObject.rot; var new_rot = this.signum*angle + this.originalObject.rot;
while(new_rot < 0) while(new_rot < 0)
new_rot += 2*Math.PI; new_rot += 2*Math.PI;
while(new_rot >= 2*Math.PI) while(new_rot >= 2*Math.PI)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment