Commit 48924b24 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@47587 954022d7-b5bf-4e40-9824-e11837661b57
parent 0bbb6ddf
......@@ -92,7 +92,7 @@ DrawingObjectsController.prototype =
trackAdjObject: function(x, y)
{
if(this.arrTrackObjects.length > 0)
this.arrPreTrackObjects[0].track(x, y);
this.arrTrackObjects[0].track(x, y);
},
trackResizeObjects: function(kd1, kd2, e)
......
......@@ -132,6 +132,36 @@ CGroupShape.prototypr =
return this.arrGraphicObjects;
},
getResizeCoefficients: function(numHandle, x, y)
{
var t_x, t_y;
var cx, cy;
cx= this.extX > 0 ? this.extX : 0.01;
cy= this.extY > 0 ? this.extY : 0.01;
var p = this.transformPointRelativeShape(x, y);
switch(numHandle)
{
case 0:
return {kd1: (cx-p.x)/cx, kd2: (cy-p.y)/cy};
case 1:
return {kd1: (cy-p.y)/cy, kd2: 0};
case 2:
return {kd1: (cy-p.y)/cy, kd2: p.x/cx};
case 3:
return {kd1: p.x/cx, kd2: 0};
case 4:
return {kd1: p.x/cx, kd2: p.y/cy};
case 5:
return {kd1: p.y/cy, kd2: 0};
case 6:
return {kd1: p.y/cy, kd2:(cx-p.x)/cx};
case 7:
return {kd1:(cx-p.x)/cx, kd2: 0};
}
return {kd1: 1, kd2: 1};
},
recalculateArrGraphicObjects: function()
{
this.arrGraphicObjects.length = 0;
......
......@@ -372,10 +372,12 @@ CImage.prototype =
if(Math.sqrt(sqr_x + sqr_y) < radius)
return 7;
var rotate_distance = 5;/*TODO*/
dist_y = t_y - rotate_distance;
var rotate_distance = 10;/*TODO*/
dist_y = t_y + rotate_distance;
sqr_y = dist_y*dist_y;
dist_x = t_x - hc;
sqr_x = dist_x*dist_x;
if(Math.sqrt(sqr_x + sqr_y) < radius)
return 8;
......@@ -449,6 +451,37 @@ CImage.prototype =
return Math.atan2( Math.abs(v1_x*v2_y - v1_y*v2_x), v1_x*v2_x + v1_y*v2_y);
},
getResizeCoefficients: function(numHandle, x, y)
{
var t_x, t_y;
var cx, cy;
cx= this.extX > 0 ? this.extX : 0.01;
cy= this.extY > 0 ? this.extY : 0.01;
var p = this.transformPointRelativeShape(x, y);
switch(numHandle)
{
case 0:
return {kd1: (cx-p.x)/cx, kd2: (cy-p.y)/cy};
case 1:
return {kd1: (cy-p.y)/cy, kd2: 0};
case 2:
return {kd1: (cy-p.y)/cy, kd2: p.x/cx};
case 3:
return {kd1: p.x/cx, kd2: 0};
case 4:
return {kd1: p.x/cx, kd2: p.y/cy};
case 5:
return {kd1: p.y/cy, kd2: 0};
case 6:
return {kd1: p.y/cy, kd2:(cx-p.x)/cx};
case 7:
return {kd1:(cx-p.x)/cx, kd2: 0};
}
return {kd1: 1, kd2: 1};
},
drawAdjustments: function(drawingDocument)
{
}
......
......@@ -431,6 +431,64 @@ CShape.prototype =
return (north_number - cardDirection + 8)%8;
},
getResizeCoefficients: function(numHandle, x, y)
{
var cx, cy;
cx= this.extX > 0 ? this.extX : 0.01;
cy= this.extY > 0 ? this.extY : 0.01;
var p = this.transformPointRelativeShape(x, y);
switch(numHandle)
{
case 0:
return {kd1: (cx-p.x)/cx, kd2: (cy-p.y)/cy};
case 1:
return {kd1: (cy-p.y)/cy, kd2: 0};
case 2:
return {kd1: (cy-p.y)/cy, kd2: p.x/cx};
case 3:
return {kd1: p.x/cx, kd2: 0};
case 4:
return {kd1: p.x/cx, kd2: p.y/cy};
case 5:
return {kd1: p.y/cy, kd2: 0};
case 6:
return {kd1: p.y/cy, kd2:(cx-p.x)/cx};
case 7:
return {kd1:(cx-p.x)/cx, kd2: 0};
}
return {kd1: 1, kd2: 1};
},
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;
return 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);
},
transformPointRelativeShape: function(x, y)
{
......@@ -515,10 +573,11 @@ CShape.prototype =
if(Math.sqrt(sqr_x + sqr_y) < radius)
return 7;
var rotate_distance = 5;/*TODO*/
dist_y = t_y - rotate_distance;
var rotate_distance = 10;/*TODO*/
dist_y = t_y + rotate_distance;
sqr_y = dist_y*dist_y;
dist_x = t_x - hc;
sqr_x = dist_x*dist_x;
if(Math.sqrt(sqr_x + sqr_y) < radius)
return 8;
......
......@@ -179,6 +179,7 @@ function RotateState(drawingObjectsController, drawingObjects, majorObject)
{
var angle = this.majorObject.getRotateAngle(x, y);
this.drawingObjectsController.rotateTrackObjects(angle, e);
this.drawingObjects.showOverlayGraphicObjects();
};
this.onMouseUp = function(e, x, y)
......@@ -218,20 +219,24 @@ function ResizeState(drawingObjectsController, drawingObjects, majorObject, card
this.drawingObjectsController = drawingObjectsController;
this.drawingObjects = drawingObjects;
this.majorObject = majorObject;
this.cardDirection = cardDirection;
this.handleNum = this.majorObject.getNumByCardDirection(cardDirection);
this.onMouseDown = function(e, x, y)
{};
this.onMouseMove = function(e, x, y)
{
//TODO
var resize_coefficients = this.majorObject.getResizeCoefficients(this.handleNum, x, y);
this.drawingObjectsController.trackResizeObjects(resize_coefficients.kd1, resize_coefficients.kd2, e);
this.drawingObjects.showOverlayGraphicObjects();
};
this.onMouseUp = function(e, x, y)
{
this.drawingObjectsController.trackEnd();
this.drawingObjectsController.changeCurrentState(new NullState(this.drawingObjectsController, this.drawingObjects));
asc.editor.asc_endAddShape();
}
}
......
......@@ -140,8 +140,8 @@ function ResizeTrackShapeImage(originalObject, cardDirection)
//this.lineFlag = originalObject.checkLine();
this.originalExtX = originalObject.absExtX;
this.originalExtY = originalObject.absExtY;
this.originalExtX = originalObject.extX;
this.originalExtY = originalObject.extY;
this.originalFlipH = _flip_h;
this.originalFlipV = _flip_v;
......
......@@ -99,6 +99,18 @@ function RotateTrackShapeImage(originalObject)
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);
};
this.trackEnd = function()
......
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