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 =
drawSelection: function(drawingDocument)
{
switch (this.curState.id)
{
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;
}
}
this.curState.drawSelection(drawingDocument);
},
isPointInDrawingObjects: function(x, y)
......
......@@ -214,6 +214,114 @@ CGroupShape.prototype =
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)
{
for(var i = 0; i < this.spTree.length; ++i)
......@@ -239,7 +347,7 @@ CGroupShape.prototype =
{
var arr_graphic_objects = this.spTree[i].getArrGraphicObjects();
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 =
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)
{
this.selected = false;
......@@ -447,5 +619,19 @@ CGroupShape.prototype =
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 =
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)
{
this.selected = true;
......
......@@ -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)
{
......
......@@ -128,6 +128,7 @@ function NullState(drawingObjectsController, drawingObjects)
if(!(e.ctrlKey || e.shiftKey) && !is_selected)
this.drawingObjectsController.resetSelection();
cur_drawing.select(this.drawingObjectsController);
this.drawingObjects.selectGraphicObject();
for(var j = 0; j < selected_objects.length; ++j)
{
this.drawingObjectsController.addPreTrackObject(selected_objects[j].createMoveTrack());
......@@ -155,6 +156,7 @@ function NullState(drawingObjectsController, drawingObjects)
if(!(e.ctrlKey || e.shiftKey))
this.drawingObjectsController.resetSelection();
cur_drawing.select(this.drawingObjectsController);
this.drawingObjects.selectGraphicObject();
for(var j = 0; j < selected_objects.length; ++j)
{
this.drawingObjectsController.addPreTrackObject(selected_objects[j].createMoveTrack());
......@@ -178,7 +180,12 @@ function NullState(drawingObjectsController, drawingObjects)
this.onMouseUp = function(e, x, y)
{
}
};
this.drawSelection = function(drawingDocument)
{
DrawDefaultSelection(this.drawingObjectsController, drawingDocument);
};
}
function PreRotateState(drawingObjectsController, drawingObjects, majorObject)
......@@ -202,7 +209,12 @@ function PreRotateState(drawingObjectsController, drawingObjects, majorObject)
{
this.drawingObjectsController.clearPreTrackObjects();
this.drawingObjectsController.changeCurrentState(new NullState(this.drawingObjectsController, this.drawingObjects));
}
};
this.drawSelection = function(drawingDocument)
{
DrawDefaultSelection(this.drawingObjectsController, drawingDocument);
};
}
......@@ -231,7 +243,12 @@ function RotateState(drawingObjectsController, drawingObjects, majorObject)
this.drawingObjects.selectGraphicObject();
this.drawingObjectsController.changeCurrentState(new NullState(this.drawingObjectsController, this.drawingObjects));
asc.editor.asc_endAddShape();
}
};
this.drawSelection = function(drawingDocument)
{
DrawDefaultSelection(this.drawingObjectsController, drawingDocument);
};
}
function PreResizeState(drawingObjectsController, drawingObjects, majorObject, cardDirection)
......@@ -255,7 +272,11 @@ function PreResizeState(drawingObjectsController, drawingObjects, majorObject, c
{
this.drawingObjectsController.clearPreTrackObjects();
this.drawingObjectsController.changeCurrentState(new NullState(this.drawingObjectsController, this.drawingObjects));
}
};
this.drawSelection = function(drawingDocument)
{
DrawDefaultSelection(this.drawingObjectsController, drawingDocument);
};
}
function ResizeState(drawingObjectsController, drawingObjects, majorObject, cardDirection)
......@@ -285,7 +306,12 @@ function ResizeState(drawingObjectsController, drawingObjects, majorObject, card
this.drawingObjects.selectGraphicObject();
this.drawingObjectsController.changeCurrentState(new NullState(this.drawingObjectsController, this.drawingObjects));
asc.editor.asc_endAddShape();
}
};
this.drawSelection = function(drawingDocument)
{
DrawDefaultSelection(this.drawingObjectsController, drawingDocument);
};
}
function StartTrackNewShapeState(drawingObjectsController, drawingObjects, presetGeom)
......@@ -307,7 +333,12 @@ function StartTrackNewShapeState(drawingObjectsController, drawingObjects, prese
this.onMouseUp = function(e, x, y)
{
//TODO
}
};
this.drawSelection = function(drawingDocument)
{
DrawDefaultSelection(this.drawingObjectsController, drawingDocument);
};
}
function BeginTrackNewShapeState(drawingObjectsController, drawingObjects, presetGeom, startX, startY)
......@@ -335,7 +366,12 @@ function BeginTrackNewShapeState(drawingObjectsController, drawingObjects, prese
this.onMouseUp = function(e, x, y)
{
this.drawingObjectsController.changeCurrentState(new NullState(this.drawingObjectsController, this.drawingObjects));
}
};
this.drawSelection = function(drawingDocument)
{
DrawDefaultSelection(this.drawingObjectsController, drawingDocument);
};
}
function TrackNewShapeState(drawingObjectsController, drawingObjects)
......@@ -363,7 +399,12 @@ function TrackNewShapeState(drawingObjectsController, drawingObjects)
this.drawingObjects.selectGraphicObject();
this.drawingObjectsController.changeCurrentState(new NullState(this.drawingObjectsController, this.drawingObjects));
asc.editor.asc_endAddShape();
}
};
this.drawSelection = function(drawingDocument)
{
DrawDefaultSelection(this.drawingObjectsController, drawingDocument);
};
}
function PreMoveState(drawingObjectsController, drawingObjects, startX, startY, shift, ctrl, majorObject, majorObjectIsSelected, bInside)
......@@ -433,6 +474,11 @@ function PreMoveState(drawingObjectsController, drawingObjects, startX, startY,
}
this.drawingObjectsController.changeCurrentState(new NullState(this.drawingObjectsController, this.drawingObjects));
};
this.drawSelection = function(drawingDocument)
{
DrawDefaultSelection(this.drawingObjectsController, drawingDocument);
};
}
function MoveState(drawingObjectsController, drawingObjects, startX, startY, rectX, rectY, rectW, rectH)
......@@ -468,7 +514,12 @@ function MoveState(drawingObjectsController, drawingObjects, startX, startY, rec
this.drawingObjects.selectGraphicObject();
this.drawingObjectsController.changeCurrentState(new NullState(this.drawingObjectsController, this.drawingObjects));
asc.editor.asc_endAddShape();
}
};
this.drawSelection = function(drawingDocument)
{
DrawDefaultSelection(this.drawingObjectsController, drawingDocument);
};
}
......@@ -494,7 +545,12 @@ function PreChangeAdjState(drawingObjectsController, drawingObjects)
{
this.drawingObjectsController.clearPreTrackObjects();
this.drawingObjectsController.changeCurrentState(new NullState(this.drawingObjectsController, this.drawingObjects));
}
};
this.drawSelection = function(drawingDocument)
{
DrawDefaultSelection(this.drawingObjectsController, drawingDocument);
};
}
function ChangeAdjState(drawingObjectsController, drawingObjects)
......@@ -522,6 +578,11 @@ function ChangeAdjState(drawingObjectsController, drawingObjects)
this.drawingObjects.selectGraphicObject();
this.drawingObjectsController.changeCurrentState(new NullState(this.drawingObjectsController, this.drawingObjects));
};
this.drawSelection = function(drawingDocument)
{
DrawDefaultSelection(this.drawingObjectsController, drawingDocument);
};
}
......@@ -605,6 +666,11 @@ function GroupState(drawingObjectsController, drawingObjects, group)
this.onMouseUp = function(e, x, y)
{};
this.drawSelection = function(drawingDocument)
{
DrawGroupSelection(this.group, drawingDocument);
};
}
......@@ -628,6 +694,11 @@ function PreMoveInGroupState(drawingObjectsController, drawingObjects, group, st
this.onMouseUp = function(e, x, y)
{};
this.drawSelection = function(drawingDocument)
{
DrawGroupSelection(this.group, drawingDocument);
};
}
function MoveInGroupState(drawingObjectsController, drawingObjects, group)
......@@ -651,6 +722,11 @@ function MoveInGroupState(drawingObjectsController, drawingObjects, group)
this.drawingObjectsController.clearTrackObjects();
this.drawingObjectsController.changeCurrentState(new GroupState(this.drawingObjectsController, this.drawingObjects, this.group));
};
this.drawSelection = function(drawingDocument)
{
DrawGroupSelection(this.group, drawingDocument);
};
}
function PreChangeAdjInGroupState(drawingObjectsController, drawingObjects, group)
......@@ -673,6 +749,11 @@ function PreChangeAdjInGroupState(drawingObjectsController, drawingObjects, grou
this.onMouseUp = function(e, x, y)
{};
this.drawSelection = function(drawingDocument)
{
DrawGroupSelection(this.group, drawingDocument);
};
}
function ChangeAdjInGroupState(drawingObjectsController, drawingObjects, group)
......@@ -698,6 +779,11 @@ function ChangeAdjInGroupState(drawingObjectsController, drawingObjects, group)
this.drawingObjectsController.clearTrackObjects();
this.drawingObjectsController.changeCurrentState(new GroupState(this.drawingObjectsController, this.drawingObjects, this.group));
};
this.drawSelection = function(drawingDocument)
{
DrawGroupSelection(this.group, drawingDocument);
};
}
function PreRotateInGroupState(drawingObjectsController, drawingObjects, group, majorObject)
......@@ -720,6 +806,11 @@ function PreRotateInGroupState(drawingObjectsController, drawingObjects, group,
this.onMouseUp = function(e, x, y)
{};
this.drawSelection = function(drawingDocument)
{
DrawGroupSelection(this.group, drawingDocument);
};
}
function RotateInGroupState(drawingObjectsController, drawingObjects, group, majorObject)
......@@ -742,6 +833,11 @@ function RotateInGroupState(drawingObjectsController, drawingObjects, group, maj
this.drawingObjectsController.clearTrackObjects();
this.drawingObjectsController.changeCurrentState(new GroupState(this.drawingObjectsController, this.drawingObjects, this.group));
};
this.drawSelection = function(drawingDocument)
{
DrawGroupSelection(this.group, drawingDocument);
};
}
......@@ -765,6 +861,11 @@ function PreResizeInGroupState(drawingObjectsController, drawingObjects, group,
this.onMouseUp = function(e, x, y)
{};
this.drawSelection = function(drawingDocument)
{
DrawGroupSelection(this.group, drawingDocument);
};
}
function ResizeInGroupState(drawingObjectsController, drawingObjects, group, majorObject)
......@@ -787,6 +888,35 @@ function ResizeInGroupState(drawingObjectsController, drawingObjects, group, maj
this.drawingObjectsController.clearTrackObjects();
this.drawingObjectsController.changeCurrentState(new GroupState(this.drawingObjectsController, this.drawingObjects, this.group));
};
this.drawSelection = function(drawingDocument)
{
DrawGroupSelection(this.group, drawingDocument);
};
}
function DrawDefaultSelection(drawingObjectsController, drawingDocument)
{
var selected_objects = drawingObjectsController.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()TODO*/);
}
if(selected_objects.length === 1)
{
selected_objects[0].drawAdjustments(drawingDocument);
}
}
function DrawGroupSelection(group, drawingDocument)
{
drawingDocument.DrawTrack(TYPE_TRACK_GROUP_PASSIVE, group.getTransform(), 0, 0, group.extX, group.extY, false/*, selected_objects[i].canRotate()TODO*/);
var group_selected_objects = group.selectedObjects;
for(var i = 0; i < group_selected_objects.length; ++i)
{
drawingDocument.DrawTrack(TYPE_TRACK_SHAPE, group_selected_objects[i].getTransform(), 0, 0, group_selected_objects[i].extX, group_selected_objects[i].extY, false/*, selected_objects[i].canRotate()TODO*/)
}
}
......
......@@ -94,4 +94,72 @@ function MoveShapeImageInGroupTrack(originalObject)
this.originalObject.recalculateTransform();
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();
};
}
......@@ -1126,4 +1126,763 @@ function ResizeTrackShapeImageInGroup(originalObject, cardDirection)
this.originalObject.recalculateTransform();
this.originalObject.updateDrawingBaseCoordinates();
};
}
function ResizeTrackGroup(originalObject, cardDirection, parentTrack)
{
this.original = originalObject;
this.parentTrack = parentTrack;
var numberHandle;
if(isRealNumber(cardDirection))
{
this.numberHandle = originalObject.getNumByCardDirection(cardDirection);
numberHandle = this.numberHandle;
}
this.x = originalObject.x;
this.y = originalObject.y;
this.extX = originalObject.extX;
this.extY = originalObject.extY;
this.rot = originalObject.rot;
this.flipH = originalObject.flipH;
this.flipV = originalObject.flipV;
this.transform = originalObject.transform.CreateDublicate();
this.bSwapCoef = !(this.rot < Math.PI*0.25 || this.rot>Math.PI*1.75 || (this.rot>Math.PI*0.75 && this.rot<Math.PI*1.25));
this.childs = [];
var a = originalObject.spTree;
for(var i = 0; i < a.length; ++i)
{
if(a[i].isGroup())
this.childs[i] = new ResizeTrackGroup(a[i], null, this);
else
this.childs[i] = new ShapeForResizeInGroup(a[i], this);
}
if(typeof numberHandle === "number")
{
var _translated_num_handle;
var _flip_h = this.flipH;
var _flip_v = this.flipV;
var _sin = Math.sin(this.rot);
var _cos = Math.cos(this.rot);
var _half_width = this.extX*0.5;
var _half_height = this.extY*0.5;
if(!_flip_h && !_flip_v)
{
_translated_num_handle = numberHandle;
}
else if(_flip_h && !_flip_v)
{
_translated_num_handle = TRANSLATE_HANDLE_FLIP_H[numberHandle];
}
else if(!_flip_h && _flip_v)
{
_translated_num_handle = TRANSLATE_HANDLE_FLIP_V[numberHandle];
}
else
{
_translated_num_handle = TRANSLATE_HANDLE_FLIP_H_AND_FLIP_V[numberHandle];
}
this.bAspect = numberHandle % 2 === 0;
this.aspect = this.bAspect === true ? this.original.getAspect(_translated_num_handle) : 0;
this.sin = _sin;
this.cos = _cos;
this.translatetNumberHandle = _translated_num_handle;
switch (_translated_num_handle)
{
case 0:
case 1:
{
this.fixedPointX = (_half_width*_cos - _half_height*_sin) + _half_width + this.x;
this.fixedPointY = (_half_width*_sin + _half_height*_cos) + _half_height + this.y;
break;
}
case 2:
case 3:
{
this.fixedPointX = (-_half_width*_cos - _half_height*_sin) + _half_width + this.x;
this.fixedPointY = (-_half_width*_sin + _half_height*_cos) + _half_height + this.y;
break;
}
case 4:
case 5:
{
this.fixedPointX = (-_half_width*_cos + _half_height*_sin) + _half_width + this.x;
this.fixedPointY = (-_half_width*_sin - _half_height*_cos) + _half_height + this.y;
break;
}
case 6:
case 7:
{
this.fixedPointX = (_half_width*_cos + _half_height*_sin) + _half_width + this.x;
this.fixedPointY = (_half_width*_sin - _half_height*_cos) + _half_height + this.y;
break;
}
}
this.mod = this.translatetNumberHandle % 4;
this.centerPointX = this.x + _half_width;
this.centerPointY = this.y + _half_height;
this.lineFlag = false;
this.originalExtX = this.extX;
this.originalExtY = this.extY;
this.originalFlipH = _flip_h;
this.originalFlipV = _flip_v;
this.usedExtX = this.originalExtX === 0 ? (/*this.lineFlag ? this.originalExtX :*/ 0.01) : this.originalExtX;
this.usedExtY = this.originalExtY === 0 ? (/*this.lineFlag ? this.originalExtY :*/ 0.01) : this.originalExtY;
this.resizedExtX = this.originalExtX;
this.resizedExtY = this.originalExtY;
this.resizedflipH = _flip_h;
this.resizedflipV = _flip_v;
this.resizedPosX = this.x;
this.resizedPosY = this.y;
this.resizedRot = this.rot;
this.bChangeCoef = this.translatetNumberHandle % 2 === 0 && this.originalFlipH !== this.originalFlipV;
}
if(this.parentTrack)
{
this.centerDistX = this.x + this.extX*0.5 - this.parentTrack.extX*0.5;
this.centerDistY = this.y + this.extY*0.5 - this.parentTrack.extY*0.5;
}
this.track = function(kd1, kd2, e)
{
if(!e.ctrlKey)
this.resize(kd1, kd2, e.shiftKey);
else
this.resizeRelativeCenter(kd1, kd2, e.shiftKey)
};
this.resize = function(kd1, kd2, shiftKey)
{
var _cos = this.cos;
var _sin = this.sin;
var _real_height, _real_width;
var _abs_height, _abs_width;
var _new_resize_half_width;
var _new_resize_half_height;
var _new_used_half_width;
var _new_used_half_height;
var _temp;
if(shiftKey === true && this.bAspect === true)
{
var _new_aspect = this.aspect*(Math.abs(kd1/ kd2));
if (_new_aspect >= this.aspect)
kd2 = Math.abs(kd1)*(kd2 >= 0 ? 1 : -1 );
else
kd1 = Math.abs(kd2)*(kd1 >= 0 ? 1 : -1);
}
if(this.bChangeCoef)
{
_temp = kd1;
kd1 = kd2;
kd2 = _temp;
}
switch (this.translatetNumberHandle)
{
case 0:
case 1:
{
if(this.translatetNumberHandle === 0)
{
_real_width = this.usedExtX*kd1;
_abs_width = Math.abs(_real_width);
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_width : MIN_SHAPE_SIZE;
if(_real_width < 0)
this.resizedflipH = !this.originalFlipH;
else
this.resizedflipH = this.originalFlipH;
}
if(this.translatetNumberHandle === 1)
{
_temp = kd1;
kd1 = kd2;
kd2 = _temp;
}
_real_height = this.usedExtY*kd2;
_abs_height = Math.abs(_real_height);
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_height : MIN_SHAPE_SIZE;
if(_real_height < 0)
this.resizedflipV = !this.originalFlipV;
else
this.resizedflipV = this.originalFlipV;
_new_resize_half_width = this.resizedExtX*0.5;
_new_resize_half_height = this.resizedExtY*0.5;
if(this.resizedflipH !== this.originalFlipH)
{
_new_used_half_width = -_new_resize_half_width;
}
else
{
_new_used_half_width = _new_resize_half_width;
}
if(this.resizedflipV !== this.originalFlipV)
{
_new_used_half_height = -_new_resize_half_height;
}
else
{
_new_used_half_height = _new_resize_half_height;
}
this.resizedPosX = this.fixedPointX + (-_new_used_half_width*_cos + _new_used_half_height*_sin) - _new_resize_half_width;
this.resizedPosY = this.fixedPointY + (-_new_used_half_width*_sin - _new_used_half_height*_cos) - _new_resize_half_height;
break;
}
case 2:
case 3:
{
if(this.translatetNumberHandle === 2)
{
_temp = kd2;
kd2 = kd1;
kd1 = _temp;
_real_height = this.usedExtY*kd2;
_abs_height = Math.abs(_real_height);
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_height : MIN_SHAPE_SIZE;
if(_real_height < 0)
this.resizedflipV = !this.originalFlipV;
else
this.resizedflipV = this.originalFlipV;
}
_real_width = this.usedExtX*kd1;
_abs_width = Math.abs(_real_width);
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_width : MIN_SHAPE_SIZE;
if(_real_width < 0)
this.resizedflipH = !this.originalFlipH;
else
this.resizedflipH = this.originalFlipH;
_new_resize_half_width = this.resizedExtX*0.5;
_new_resize_half_height = this.resizedExtY*0.5;
if(this.resizedflipH !== this.originalFlipH)
{
_new_used_half_width = -_new_resize_half_width;
}
else
{
_new_used_half_width = _new_resize_half_width;
}
if(this.resizedflipV !== this.originalFlipV)
{
_new_used_half_height = -_new_resize_half_height;
}
else
{
_new_used_half_height = _new_resize_half_height;
}
this.resizedPosX = this.fixedPointX + (_new_used_half_width*_cos + _new_used_half_height*_sin) - _new_resize_half_width;
this.resizedPosY = this.fixedPointY + (_new_used_half_width*_sin - _new_used_half_height*_cos) - _new_resize_half_height;
break;
}
case 4:
case 5:
{
if(this.translatetNumberHandle === 4)
{
_real_width = this.usedExtX*kd1;
_abs_width = Math.abs(_real_width);
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_width : MIN_SHAPE_SIZE;
if(_real_width < 0)
this.resizedflipH = !this.originalFlipH;
else
this.resizedflipH = this.originalFlipH;
}
else
{
_temp = kd2;
kd2 = kd1;
kd1 = _temp;
}
_real_height = this.usedExtY*kd2;
_abs_height = Math.abs(_real_height);
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_height : MIN_SHAPE_SIZE;
if(_real_height < 0)
this.resizedflipV = !this.originalFlipV;
else
this.resizedflipV = this.originalFlipV;
_new_resize_half_width = this.resizedExtX*0.5;
_new_resize_half_height = this.resizedExtY*0.5;
if(this.resizedflipH !== this.originalFlipH)
{
_new_used_half_width = -_new_resize_half_width;
}
else
{
_new_used_half_width = _new_resize_half_width;
}
if(this.resizedflipV !== this.originalFlipV)
{
_new_used_half_height = -_new_resize_half_height;
}
else
{
_new_used_half_height = _new_resize_half_height;
}
this.resizedPosX = this.fixedPointX + (_new_used_half_width*_cos - _new_used_half_height*_sin) - _new_resize_half_width;
this.resizedPosY = this.fixedPointY + (_new_used_half_width*_sin + _new_used_half_height*_cos) - _new_resize_half_height;
break;
}
case 6:
case 7:
{
if(this.translatetNumberHandle === 6)
{
_real_height = this.usedExtY*kd1;
_abs_height = Math.abs(_real_height);
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_height : MIN_SHAPE_SIZE;
if(_real_height < 0)
this.resizedflipV = !this.originalFlipV;
else
this.resizedflipV = this.originalFlipV;
}
else
{
_temp = kd2;
kd2 = kd1;
kd1 = _temp;
}
_real_width = this.usedExtX*kd2;
_abs_width = Math.abs(_real_width);
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_width : MIN_SHAPE_SIZE;
if(_real_width < 0)
this.resizedflipH = !this.originalFlipH;
else
this.resizedflipH = this.originalFlipH;
_new_resize_half_width = this.resizedExtX*0.5;
_new_resize_half_height = this.resizedExtY*0.5;
if(this.resizedflipH !== this.originalFlipH)
{
_new_used_half_width = -_new_resize_half_width;
}
else
{
_new_used_half_width = _new_resize_half_width;
}
if(this.resizedflipV !== this.originalFlipV)
{
_new_used_half_height = -_new_resize_half_height;
}
else
{
_new_used_half_height = _new_resize_half_height;
}
this.resizedPosX = this.fixedPointX + (-_new_used_half_width*_cos - _new_used_half_height*_sin) - _new_resize_half_width;
this.resizedPosY = this.fixedPointY + (-_new_used_half_width*_sin + _new_used_half_height*_cos) - _new_resize_half_height;
break;
}
}
this.x = this.resizedPosX;
this.y = this.resizedPosY;
this.extX = this.resizedExtX;
this.extY = this.resizedExtY;
this.flipH = this.resizedflipH;
this.flipV = this.resizedflipV;
var _transform = this.transform;
_transform.Reset();
var _horizontal_center = this.resizedExtX*0.5;
var _vertical_center = this.resizedExtY*0.5;
global_MatrixTransformer.TranslateAppend(_transform, -_horizontal_center, -_vertical_center);
if(this.resizedflipH)
{
global_MatrixTransformer.ScaleAppend(_transform, -1, 1);
}
if(this.resizedflipV)
{
global_MatrixTransformer.ScaleAppend(_transform, 1, -1);
}
global_MatrixTransformer.RotateRadAppend(_transform, -this.resizedRot);
global_MatrixTransformer.TranslateAppend(_transform, this.resizedPosX, this.resizedPosY);
global_MatrixTransformer.TranslateAppend(_transform, _horizontal_center, _vertical_center);
var xfrm = this.original.spPr.xfrm;
var kw = this.resizedExtX/xfrm.extX;
var kh = this.resizedExtY/xfrm.extY;
for(var i = 0; i < this.childs.length; ++i)
{
var cur_child = this.childs[i];
cur_child.updateSize(kw, kh);
}
};
this.resizeRelativeCenter = function(kd1, kd2, shiftKey)
{
kd1 = 2*kd1 - 1;
kd2 = 2*kd2 - 1;
var _real_height, _real_width;
var _abs_height, _abs_width;
if(shiftKey === true && this.bAspect === true)
{
var _new_aspect = this.aspect*(Math.abs(kd1/ kd2));
if (_new_aspect >= this.aspect)
kd2 = Math.abs(kd1)*(kd2 >= 0 ? 1 : -1 );
else
kd1 = Math.abs(kd2)*(kd1 >= 0 ? 1 : -1);
}
var _temp;
if(this.bChangeCoef)
{
_temp = kd1;
kd1 = kd2;
kd2 = _temp;
}
if(this.mod === 0 || this.mod === 1)
{
if(this.mod === 0)
{
_real_width = this.usedExtX*kd1;
_abs_width = Math.abs(_real_width);
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_width : MIN_SHAPE_SIZE;
this.resizedflipH = _real_width < 0 ? !this.originalFlipH : this.originalFlipH;
}
else
{
_temp = kd1;
kd1 = kd2;
kd2 = _temp;
}
_real_height = this.usedExtY*kd2;
_abs_height = Math.abs(_real_height);
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_height : MIN_SHAPE_SIZE;
this.resizedflipV = _real_height < 0 ? !this.originalFlipV : this.originalFlipV;
}
else
{
if(this.mod === 2)
{
_temp = kd1;
kd1 = kd2;
kd2 = _temp;
_real_height = this.usedExtY*kd2;
_abs_height = Math.abs(_real_height);
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_height : MIN_SHAPE_SIZE;
this.resizedflipV = _real_height < 0 ? !this.originalFlipV : this.originalFlipV;
}
_real_width = this.usedExtX*kd1;
_abs_width = Math.abs(_real_width);
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_width : MIN_SHAPE_SIZE;
this.resizedflipH = _real_width < 0 ? !this.originalFlipH : this.originalFlipH;
}
this.resizedPosX = this.centerPointX - this.resizedExtX*0.5;
this.resizedPosY = this.centerPointY - this.resizedExtY*0.5;
this.x = this.resizedPosX;
this.y = this.resizedPosY;
this.extX = this.resizedExtX;
this.extY = this.resizedExtY;
this.flipH = this.resizedflipH;
this.flipV = this.resizedflipV;
var _transform = this.transform;
_transform.Reset();
var _horizontal_center = this.resizedExtX*0.5;
var _vertical_center = this.resizedExtY*0.5;
global_MatrixTransformer.TranslateAppend(_transform, -_horizontal_center, -_vertical_center);
if(this.resizedflipH)
{
global_MatrixTransformer.ScaleAppend(_transform, -1, 1);
}
if(this.resizedflipV)
{
global_MatrixTransformer.ScaleAppend(_transform, 1, -1);
}
global_MatrixTransformer.RotateRadAppend(_transform, -this.resizedRot);
global_MatrixTransformer.TranslateAppend(_transform, this.resizedPosX, this.resizedPosY);
global_MatrixTransformer.TranslateAppend(_transform, _horizontal_center, _vertical_center);
var xfrm = this.original.spPr.xfrm;
var kw = this.resizedExtX/xfrm.extX;
var kh = this.resizedExtY/xfrm.extY;
for(var i = 0; i< this.childs.length; ++i)
{
this.childs[i].updateSize(kw, kh);
}
};
this.updateSize = function(kw, kh)
{
var _kw, _kh;
if(this.bSwapCoef)
{
_kw = kh;
_kh = kw;
}
else
{
_kw = kw;
_kh = kh;
}
var xfrm = this.original.spPr.xfrm;
this.extX = xfrm.extX*_kw;
this.extY = xfrm.extY*_kh;
this.x = this.centerDistX*kw + this.parentTrack.extX*0.5 - this.extX*0.5;
this.y = this.centerDistY*kh + this.parentTrack.extY*0.5 - this.extY*0.5;
this.transform.Reset();
var t = this.transform;
global_MatrixTransformer.TranslateAppend(t, -this.extX*0.5, -this.extY*0.5);
if(xfrm.flipH == null ? false : xfrm.flipH)
{
global_MatrixTransformer.ScaleAppend(t, -1, 1);
}
if(xfrm.flipV == null ? false : xfrm.flipV)
{
global_MatrixTransformer.ScaleAppend(t, 1, -1);
}
global_MatrixTransformer.RotateRadAppend(t, xfrm.rot == null ? 0 : -xfrm.rot);
global_MatrixTransformer.TranslateAppend(t, this.x + this.extX*0.5, this.y+this.extY*0.5);
global_MatrixTransformer.MultiplyAppend(t, this.parentTrack.transform);
for(var i = 0; i < this.childs.length; ++i)
{
this.childs[i].updateSize(_kw, _kh);
}
};
this.draw = function(graphics)
{
for(var i = 0; i < this.childs.length; ++i)
{
this.childs[i].draw(graphics);
}
};
this.getBoundsRect = function()
{
var t = this.transform;
var min_x, max_x, min_y, max_y;
min_x = t.TransformPointX(0, 0);
max_x = min_x;
min_y = t.TransformPointY(0, 0);
max_y = min_y;
var arr = [{x: this.extX, y: 0}, {x: this.extX, y: this.extY}, {x: 0, y: this.extY}];
var t_x, t_y;
for(var i = 0; i < arr.length; ++i)
{
var p = arr[i];
t_x = t.TransformPointX(p.x, p.y);
t_y = t.TransformPointY(p.x, p.y);
if(t_x < min_x)
min_x = t_x;
if(t_x > max_x)
max_x = t_x;
if(t_y < min_y)
min_y = t_y;
if(t_y > max_y)
max_y = t_y;
}
return {l: min_x, t: min_y, r: max_x, b: max_y};};
this.trackEnd = function()
{
this.original.setPosition(this.x, this.y);
this.original.setExtents(this.extX, this.extY);
this.original.setChildExtents(this.extX, this.extY);
this.original.setFlips(this.flipH, this.flipV);
for(var i = 0; i < this.childs.length; ++i)
{
this.childs[i].trackEnd();
}
if(this.parentTrack == null)
this.original.recalculateTransform();
};
this.updateTransform = function()
{
this.transform.Reset();
var t = this.transform;
global_MatrixTransformer.TranslateAppend(t, -this.extX*0.5, -this.extY*0.5);
if(xfrm.flipH == null ? false : xfrm.flipH)
{
global_MatrixTransformer.ScaleAppend(t, -1, 1);
}
if(xfrm.flipV == null ? false : xfrm.flipV)
{
global_MatrixTransformer.ScaleAppend(t, 1, -1);
}
global_MatrixTransformer.RotateRadAppend(t, -this.rot);
global_MatrixTransformer.TranslateAppend(t, this.x + this.extX*0.5, this.y+this.extY*0.5);
if(this.parentTrack)
global_MatrixTransformer.MultiplyAppend(t, this.parentTrack.transform);
for(var i = 0; i < this.childs.length; ++i)
{
this.childs[i].updateTransform();
}
};
}
function ShapeForResizeInGroup(originalObject, parentTrack)
{
this.originalObject = originalObject;
this.parentTrack = parentTrack;
this.x = originalObject.x;
this.y = originalObject.y;
this.extX = originalObject.extX;
this.extY = originalObject.extY;
this.rot = originalObject.rot;
this.flipH = originalObject.flipH;
this.flipV = originalObject.flipV;
this.transform = originalObject.transform.CreateDublicate();
this.bSwapCoef = !(this.rot < Math.PI*0.25 || this.rot>Math.PI*1.75 || (this.rot>Math.PI*0.75 && this.rot<Math.PI*1.25));
this.centerDistX = this.x + this.extX*0.5 - this.parentTrack.extX*0.5;
this.centerDistY = this.y + this.extY*0.5 - this.parentTrack.extY*0.5;
this.geometry = originalObject.spPr.geometry !== null ? originalObject.spPr.geometry.createDuplicate() : null;
if(this.geometry)
{
this.geometry.Recalculate(this.extX, this.extY);
}
this.overlayObject = new OverlayObject(this.geometry, this.extX, this.extY, originalObject.brush, originalObject.pen, this.transform);
this.updateSize = function(kw, kh)
{
var _kw, _kh;
if(this.bSwapCoef)
{
_kw = kh;
_kh = kw;
}
else
{
_kw = kw;
_kh = kh;
}
this.extX = this.originalObject.extX*_kw;
this.extY = this.originalObject.extY*_kh;
this.x = this.centerDistX*kw + this.parentTrack.extX*0.5 - this.extX*0.5;
this.y = this.centerDistY*kh + this.parentTrack.extY*0.5 - this.extY*0.5;
if(this.geometry)
{
this.geometry.Recalculate(this.extX, this.extY);
}
this.transform.Reset();
var t = this.transform;
global_MatrixTransformer.TranslateAppend(t, -this.extX*0.5, -this.extY*0.5);
if(this.flipH)
{
global_MatrixTransformer.ScaleAppend(t, -1, 1);
}
if(this.flipV)
{
global_MatrixTransformer.ScaleAppend(t, 1, -1);
}
global_MatrixTransformer.RotateRadAppend(t, this.rot);
global_MatrixTransformer.TranslateAppend(t, this.x + this.extX*0.5, this.y+this.extY*0.5);
global_MatrixTransformer.MultiplyAppend(t, this.parentTrack.transform);
};
this.draw = function(overlay)
{
this.overlayObject.draw(overlay);
};
this.getBounds = function()
{
var bounds_checker = new CSlideBoundsChecker();
bounds_checker.init(Page_Width, Page_Height, Page_Width, Page_Height);
this.draw(bounds_checker);
return {l: bounds_checker.Bounds.min_x, t: bounds_checker.Bounds.min_y, r: bounds_checker.Bounds.max_x , b: bounds_checker.Bounds.max_y};
};
this.trackEnd = function()
{
this.originalObject.setPosition(this.x, this.y);
this.originalObject.setExtents(this.extX, this.extY);
if(this.originalObject.spPr.geometry !== null)
this.originalObject.spPr.geometry.Recalculate(this.extX, this.extY);
};
this.updateTransform = function()
{
this.transform.Reset();
var t = this.transform;
global_MatrixTransformer.TranslateAppend(t, -this.extX*0.5, -this.extY*0.5);
if(this.flipH)
{
global_MatrixTransformer.ScaleAppend(t, -1, 1);
}
if(this.flipV)
{
global_MatrixTransformer.ScaleAppend(t, 1, -1);
}
global_MatrixTransformer.RotateRadAppend(t, this.rot);
global_MatrixTransformer.TranslateAppend(t, this.x + this.extX*0.5, this.y+this.extY*0.5);
if(this.parentTrack)
global_MatrixTransformer.MultiplyAppend(t, this.parentTrack.transform);
};
}
\ No newline at end of file
......@@ -34,6 +34,12 @@ function OverlayObject(geometry, extX, extY, brush, pen, transform)
this.geometry.Recalculate(extX, extY);
};
this.updateTransformMatrix = function(transform)
{
this.TransformMatrix = transform;
};
this.draw = function(overlay)
{
overlay.SaveGrState();
......@@ -171,6 +177,89 @@ function RotateTrackShapeImageInGroup(originalObject)
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.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