Commit 3d86bfce 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@47662 954022d7-b5bf-4e40-9824-e11837661b57
parent 153f8cb2
...@@ -190,22 +190,7 @@ DrawingObjectsController.prototype = ...@@ -190,22 +190,7 @@ DrawingObjectsController.prototype =
drawSelection: function(drawingDocument) drawSelection: function(drawingDocument)
{ {
switch (this.curState.id) this.curState.drawSelection(drawingDocument);
{
default :
{
var selected_objects = this.selectedObjects;
for(var i = 0; i < selected_objects.length; ++i)
{
drawingDocument.DrawTrack(TYPE_TRACK_SHAPE, selected_objects[i].getTransform(), 0, 0, selected_objects[i].extX, selected_objects[i].extY, false, selected_objects[i].canRotate());
}
if(selected_objects.length === 1)
{
selected_objects[0].drawAdjustments(drawingDocument);
}
break;
}
}
}, },
isPointInDrawingObjects: function(x, y) isPointInDrawingObjects: function(x, y)
......
...@@ -214,6 +214,114 @@ CGroupShape.prototype = ...@@ -214,6 +214,114 @@ CGroupShape.prototype =
return {kd1: 1, kd2: 1}; return {kd1: 1, kd2: 1};
}, },
getFullOffset: function()
{
if(!isRealObject(this.group))
return {offX: this.x, offY: this.y};
var group_offset = this.group.getFullOffset();
return {offX: this.x + group_offset.offX, offY: this.y + group_offset.offY};
},
transformPointRelativeShape: function(x, y)
{
var _horizontal_center = this.extX*0.5;
var _vertical_enter = this.extY*0.5;
var _sin = Math.sin(this.rot);
var _cos = Math.cos(this.rot);
var _temp_x = x - (-_horizontal_center*_cos + _vertical_enter*_sin +this.x + _horizontal_center);
var _temp_y = y - (-_horizontal_center*_sin - _vertical_enter*_cos +this.y + _vertical_enter);
var _relative_x = _temp_x*_cos + _temp_y*_sin;
var _relative_y = -_temp_x*_sin + _temp_y*_cos;
if(this.absFlipH)
_relative_x = this.extX - _relative_x;
if(this.absFlipV)
_relative_y = this.extY - _relative_y;
return {x: _relative_x, y: _relative_y};
},
getRectBounds: function()
{
var transform = this.getTransform();
var w = this.extX;
var h = this.extY;
var rect_points = [{x:0, y:0}, {x: w, y: 0}, {x: w, y: h}, {x: 0, y: h}];
var min_x, max_x, min_y, max_y;
min_x = transform.TransformPointX(rect_points[0].x, rect_points[0].y);
min_y = transform.TransformPointY(rect_points[0].x, rect_points[0].y);
max_x = min_x;
max_y = min_y;
var cur_x, cur_y;
for(var i = 1; i < 4; ++i)
{
cur_x = transform.TransformPointX(rect_points[i].x, rect_points[i].y);
cur_y = transform.TransformPointY(rect_points[i].x, rect_points[i].y);
if(cur_x < min_x)
min_x = cur_x;
if(cur_x > max_x)
max_x = cur_x;
if(cur_y < min_y)
min_y = cur_y;
if(cur_y > max_y)
max_y = cur_y;
}
return {minX: min_x, maxX: max_x, minY: min_y, maxY: max_y};
},
getBoundsInGroup: function()
{
var r = this.rot;
if((r >= 0 && r < Math.PI*0.25)
|| (r > 3*Math.PI*0.25 && r < 5*Math.PI*0.25)
|| (r > 7*Math.PI*0.25 && r < 2*Math.PI))
{
return {minX: this.x, minY: this.y, maxX: this.x + this.extX, maxY: this.y + this.extY};
}
else
{
var hc = this.extX*0.5;
var vc = this.extY*0.5;
var xc = this.x + hc;
var yc = this.y + vc;
return {minX: xc - vc, minY: yc - hc, maxX: xc + vc, maxY: yc + hc};
}
},
getRotateAngle: function(x, y)
{
var transform = this.getTransform();
var rotate_distance = 5;/*TODO*/
var hc = this.extX*0.5;
var vc = this.extY*0.5;
var xc_t = transform.TransformPointX(hc, vc);
var yc_t = transform.TransformPointY(hc, vc);
var rot_x_t = transform.TransformPointX(hc, - rotate_distance);
var rot_y_t = transform.TransformPointY(hc, - rotate_distance);
var invert_transform = this.getInvertTransform();
var rel_x = invert_transform.TransformPointX(x, y);
var v1_x, v1_y, v2_x, v2_y;
v1_x = x - xc_t;
v1_y = y - yc_t;
v2_x = rot_x_t - xc_t;
v2_y = rot_y_t - yc_t;
var flip_h = this.getFullFlipH();
var flip_v = this.getFullFlipV();
var same_flip = flip_h && flip_v || !flip_h && !flip_v;
var angle = rel_x > this.extX*0.5 ? Math.atan2( Math.abs(v1_x*v2_y - v1_y*v2_x), v1_x*v2_x + v1_y*v2_y) : -Math.atan2( Math.abs(v1_x*v2_y - v1_y*v2_x), v1_x*v2_x + v1_y*v2_y);
return same_flip ? angle : -angle;
},
draw: function(graphics) draw: function(graphics)
{ {
for(var i = 0; i < this.spTree.length; ++i) for(var i = 0; i < this.spTree.length; ++i)
...@@ -239,7 +347,7 @@ CGroupShape.prototype = ...@@ -239,7 +347,7 @@ CGroupShape.prototype =
{ {
var arr_graphic_objects = this.spTree[i].getArrGraphicObjects(); var arr_graphic_objects = this.spTree[i].getArrGraphicObjects();
for(var j = 0; j < arr_graphic_objects.length; ++j) for(var j = 0; j < arr_graphic_objects.length; ++j)
this.arrGraphicObjects.push(arr_graphic_objects[i]); this.arrGraphicObjects.push(arr_graphic_objects[j]);
} }
} }
}, },
...@@ -431,6 +539,70 @@ CGroupShape.prototype = ...@@ -431,6 +539,70 @@ CGroupShape.prototype =
selected_objects.push(this); selected_objects.push(this);
}, },
getCardDirectionByNum: function(num)
{
var num_north = this.getNumByCardDirection(CARD_DIRECTION_N);
var full_flip_h = this.getFullFlipH();
var full_flip_v = this.getFullFlipV();
var same_flip = !full_flip_h && !full_flip_v || full_flip_h && full_flip_v;
if(same_flip)
return ((num - num_north) + CARD_DIRECTION_N + 8)%8;
return (CARD_DIRECTION_N - (num - num_north)+ 8)%8;
},
getNumByCardDirection: function(cardDirection)
{
var hc = this.extX*0.5;
var vc = this.extY*0.5;
var transform = this.getTransform();
var y1, y3, y5, y7;
y1 = transform.TransformPointY(hc, 0);
y3 = transform.TransformPointY(this.extX, vc);
y5 = transform.TransformPointY(hc, this.extY);
y7 = transform.TransformPointY(0, vc);
var north_number;
var full_flip_h = this.getFullFlipH();
var full_flip_v = this.getFullFlipV();
switch(Math.min(y1, y3, y5, y7))
{
case y1:
{
north_number = !full_flip_v ? 1 : 5;
break;
}
case y3:
{
north_number = !full_flip_h ? 3 : 7;
break;
}
case y5:
{
north_number = !full_flip_v ? 5 : 1;
break;
}
default:
{
north_number = !full_flip_h ? 7 : 3;
break;
}
}
var same_flip = !full_flip_h && !full_flip_v || full_flip_h && full_flip_v;
if(same_flip)
return (north_number + cardDirection)%8;
return (north_number - cardDirection + 8)%8;
},
getAspect: function(num)
{
var _tmp_x = this.extX != 0 ? this.extX : 0.1;
var _tmp_y = this.extY != 0 ? this.extY : 0.1;
return num === 0 || num === 4 ? _tmp_x/_tmp_y : _tmp_y/_tmp_x;
},
deselect: function(drawingObjectsController) deselect: function(drawingObjectsController)
{ {
this.selected = false; this.selected = false;
...@@ -447,5 +619,19 @@ CGroupShape.prototype = ...@@ -447,5 +619,19 @@ CGroupShape.prototype =
break; break;
} }
} }
},
createRotateTrack: function()
{
return new RotateTrackGroup(this);
},
createMoveTrack: function()
{
return new MoveGroupTrack(this);
},
createResizeTrack: function(cardDirection)
{
return new ResizeTrackGroup(this, cardDirection);
} }
}; };
\ No newline at end of file
...@@ -300,6 +300,43 @@ CImage.prototype = ...@@ -300,6 +300,43 @@ CImage.prototype =
this.group = group; this.group = group;
}, },
getFullOffset: function()
{
if(!isRealObject(this.group))
return {offX: this.x, offY: this.y};
var group_offset = this.group.getFullOffset();
return {offX: this.x + group_offset.offX, offY: this.y + group_offset.offY};
},
getRectBounds: function()
{
var transform = this.getTransform();
var w = this.extX;
var h = this.extY;
var rect_points = [{x:0, y:0}, {x: w, y: 0}, {x: w, y: h}, {x: 0, y: h}];
var min_x, max_x, min_y, max_y;
min_x = transform.TransformPointX(rect_points[0].x, rect_points[0].y);
min_y = transform.TransformPointY(rect_points[0].x, rect_points[0].y);
max_x = min_x;
max_y = min_y;
var cur_x, cur_y;
for(var i = 1; i < 4; ++i)
{
cur_x = transform.TransformPointX(rect_points[i].x, rect_points[i].y);
cur_y = transform.TransformPointY(rect_points[i].x, rect_points[i].y);
if(cur_x < min_x)
min_x = cur_x;
if(cur_x > max_x)
max_x = cur_x;
if(cur_y < min_y)
min_y = cur_y;
if(cur_y > max_y)
max_y = cur_y;
}
return {minX: min_x, maxX: max_x, minY: min_y, maxY: max_y};
},
select: function(drawingObjectsController) select: function(drawingObjectsController)
{ {
this.selected = true; this.selected = true;
......
...@@ -573,6 +573,14 @@ CShape.prototype = ...@@ -573,6 +573,14 @@ CShape.prototype =
}, },
getFullOffset: function()
{
if(!isRealObject(this.group))
return {offX: this.x, offY: this.y};
var group_offset = this.group.getFullOffset();
return {offX: this.x + group_offset.offX, offY: this.y + group_offset.offY};
},
transformPointRelativeShape: function(x, y) transformPointRelativeShape: function(x, y)
{ {
......
This diff is collapsed.
...@@ -94,4 +94,72 @@ function MoveShapeImageInGroupTrack(originalObject) ...@@ -94,4 +94,72 @@ function MoveShapeImageInGroupTrack(originalObject)
this.originalObject.recalculateTransform(); this.originalObject.recalculateTransform();
this.originalObject.updateDrawingBaseCoordinates(); this.originalObject.updateDrawingBaseCoordinates();
}; };
} }
\ No newline at end of file
function MoveGroupTrack(originalObject)
{
this.x = null;
this.y = null;
this.originalObject = originalObject;
this.transform = new CMatrix();
this.overlayObjects = [];
this.arrTransforms2 = [];
var arr_graphic_objects = originalObject.getArrGraphicObjects();
var group_invert_transform = originalObject.getInvertTransform();
for(var i = 0; i < arr_graphic_objects.length; ++i)
{
var gr_obj_transform_copy = arr_graphic_objects[i].getTransform().CreateDublicate();
global_MatrixTransformer.MultiplyAppend(gr_obj_transform_copy, group_invert_transform);
this.arrTransforms2[i] = gr_obj_transform_copy;
this.overlayObjects[i] = new OverlayObject(arr_graphic_objects[i].spPr.geometry, arr_graphic_objects[i].extX, arr_graphic_objects[i].extY,
arr_graphic_objects[i].brush, arr_graphic_objects[i].pen, new CMatrix());
}
this.getOriginalBoundsRect = function()
{
return this.originalObject.getRectBounds();
};
this.track = function(dx, dy)
{
var original = this.originalObject;
this.x = original.x + dx;
this.y = original.y + dy;
this.transform.Reset();
var hc = original.extX*0.5;
var vc = original.extY*0.5;
global_MatrixTransformer.TranslateAppend(this.transform, -hc, -vc);
if(original.flipH)
global_MatrixTransformer.ScaleAppend(this.transform, -1, 1);
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);
for(var i = 0; i < this.overlayObjects.length; ++i)
{
var new_transform = this.arrTransforms2[i].CreateDublicate();
global_MatrixTransformer.MultiplyAppend(new_transform, this.transform);
this.overlayObjects[i].updateTransformMatrix(new_transform);
}
};
this.draw = function(overlay)
{
for(var i = 0; i < this.overlayObjects.length; ++i)
{
this.overlayObjects[i].draw(overlay);
}
};
this.trackEnd = function()
{
this.originalObject.setPosition(this.x, this.y);
this.originalObject.recalculateTransform();
this.originalObject.updateDrawingBaseCoordinates();
};
}
...@@ -34,6 +34,12 @@ function OverlayObject(geometry, extX, extY, brush, pen, transform) ...@@ -34,6 +34,12 @@ function OverlayObject(geometry, extX, extY, brush, pen, transform)
this.geometry.Recalculate(extX, extY); this.geometry.Recalculate(extX, extY);
}; };
this.updateTransformMatrix = function(transform)
{
this.TransformMatrix = transform;
};
this.draw = function(overlay) this.draw = function(overlay)
{ {
overlay.SaveGrState(); overlay.SaveGrState();
...@@ -171,6 +177,89 @@ function RotateTrackShapeImageInGroup(originalObject) ...@@ -171,6 +177,89 @@ function RotateTrackShapeImageInGroup(originalObject)
global_MatrixTransformer.MultiplyAppend(this.transform, this.originalObject.group.getTransform()); global_MatrixTransformer.MultiplyAppend(this.transform, this.originalObject.group.getTransform());
}; };
this.trackEnd = function()
{
this.originalObject.setRotate(this.angle);
this.originalObject.recalculateTransform();
}
}
function RotateTrackGroup(originalObject)
{
this.originalObject = originalObject;
this.transform = new CMatrix();
this.overlayObjects = [];
this.arrTransforms = [];
this.arrTransforms2 = [];
var arr_graphic_objects = originalObject.getArrGraphicObjects();
var group_invert_transform = originalObject.getInvertTransform();
for(var i = 0; i < arr_graphic_objects.length; ++i)
{
var gr_obj_transform_copy = arr_graphic_objects[i].getTransform().CreateDublicate();
global_MatrixTransformer.MultiplyAppend(gr_obj_transform_copy, group_invert_transform);
this.arrTransforms2[i] = gr_obj_transform_copy;
this.overlayObjects[i] = new OverlayObject(arr_graphic_objects[i].spPr.geometry, arr_graphic_objects[i].extX, arr_graphic_objects[i].extY,
arr_graphic_objects[i].brush, arr_graphic_objects[i].pen, new CMatrix());
}
this.angle = originalObject.rot;
this.draw = function(overlay)
{
for(var i = 0; i < this.overlayObjects.length; ++i)
{
this.overlayObjects[i].draw(overlay);
}
};
this.track = function(angle, e)
{
var new_rot = angle + this.originalObject.rot;
while(new_rot < 0)
new_rot += 2*Math.PI;
while(new_rot >= 2*Math.PI)
new_rot -= 2*Math.PI;
if(new_rot < MIN_ANGLE || new_rot > 2*Math.PI - MIN_ANGLE)
new_rot = 0;
if(Math.abs(new_rot-Math.PI*0.5) < MIN_ANGLE)
new_rot = Math.PI*0.5;
if(Math.abs(new_rot-Math.PI) < MIN_ANGLE)
new_rot = Math.PI;
if(Math.abs(new_rot-1.5*Math.PI) < MIN_ANGLE)
new_rot = 1.5*Math.PI;
if(e.shiftKey)
new_rot = (Math.PI/12)*Math.floor(12*new_rot/(Math.PI));
this.angle = new_rot;
var hc, vc;
hc = this.originalObject.extX*0.5;
vc = this.originalObject.extY*0.5;
this.transform.Reset();
global_MatrixTransformer.TranslateAppend(this.transform, -hc, -vc);
if(this.originalObject.flipH)
global_MatrixTransformer.ScaleAppend(this.transform, -1, 1);
if(this.originalObject.flipV)
global_MatrixTransformer.ScaleAppend(this.transform, 1, -1);
global_MatrixTransformer.RotateRadAppend(this.transform, -this.angle);
global_MatrixTransformer.TranslateAppend(this.transform, this.originalObject.x + hc, this.originalObject.y + vc);
for(var i = 0; i < this.overlayObjects.length; ++i)
{
var new_transform = this.arrTransforms2[i].CreateDublicate();
global_MatrixTransformer.MultiplyAppend(new_transform, this.transform);
this.overlayObjects[i].updateTransformMatrix(new_transform);
}
};
this.trackEnd = function() this.trackEnd = function()
{ {
this.originalObject.setRotate(this.angle); this.originalObject.setRotate(this.angle);
......
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