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

git-svn-id:...

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@47649 954022d7-b5bf-4e40-9824-e11837661b57
parent 25e12807
...@@ -133,6 +133,7 @@ DrawingObjectsController.prototype = ...@@ -133,6 +133,7 @@ DrawingObjectsController.prototype =
if(grouped_objects.length < 2) if(grouped_objects.length < 2)
return null; return null;
this.resetSelection();
var max_x, min_x, max_y, min_y; var max_x, min_x, max_y, min_y;
var bounds = grouped_objects[0].getBoundsInGroup(); var bounds = grouped_objects[0].getBoundsInGroup();
max_x = bounds.maxX; max_x = bounds.maxX;
...@@ -157,10 +158,12 @@ DrawingObjectsController.prototype = ...@@ -157,10 +158,12 @@ DrawingObjectsController.prototype =
group.setChildExtents(max_x - min_x, max_y - min_y); group.setChildExtents(max_x - min_x, max_y - min_y);
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.y - min_y); grouped_objects[i].setPosition(grouped_objects[i].x - min_x, grouped_objects[i].y - min_y);
grouped_objects[i].setGroup(group);
group.addToSpTree(grouped_objects[i]); group.addToSpTree(grouped_objects[i]);
} }
group.recalculate(); group.recalculate();
group.select(this);
return group; return group;
}, },
......
...@@ -35,7 +35,7 @@ function CGroupShape(drawingBase, drawingObjects) ...@@ -35,7 +35,7 @@ function CGroupShape(drawingBase, drawingObjects)
this.rot = null; this.rot = null;
this.flipH = null; this.flipH = null;
this.flipV = null; this.flipV = null;
this.transform = null; this.transform = new CMatrix();
this.invertTransform = null; this.invertTransform = null;
this.transformText = null; this.transformText = null;
this.invertTransformText = null; this.invertTransformText = null;
...@@ -48,7 +48,7 @@ function CGroupShape(drawingBase, drawingObjects) ...@@ -48,7 +48,7 @@ function CGroupShape(drawingBase, drawingObjects)
} }
CGroupShape.prototypr = CGroupShape.prototype =
{ {
isShape: function() isShape: function()
{ {
...@@ -260,8 +260,8 @@ CGroupShape.prototypr = ...@@ -260,8 +260,8 @@ CGroupShape.prototypr =
else else
{ {
var scale_scale_coefficients = this.group.getResultScaleCoefficients(); var scale_scale_coefficients = this.group.getResultScaleCoefficients();
this.x = scale_scale_coefficients.cx*(xfrm.offX - this.group.xfrm.chOffX); this.x = scale_scale_coefficients.cx*(xfrm.offX - this.group.spPr.xfrm.chOffX);
this.y = scale_scale_coefficients.cy*(xfrm.offY - this.group.xfrm.chOffY); this.y = scale_scale_coefficients.cy*(xfrm.offY - this.group.spPr.xfrm.chOffY);
this.extX = scale_scale_coefficients.cx*xfrm.extX; this.extX = scale_scale_coefficients.cx*xfrm.extX;
this.extY = scale_scale_coefficients.cy*xfrm.extY; this.extY = scale_scale_coefficients.cy*xfrm.extY;
this.rot = isRealNumber(xfrm.rot) ? xfrm.rot : 0; this.rot = isRealNumber(xfrm.rot) ? xfrm.rot : 0;
...@@ -289,7 +289,7 @@ CGroupShape.prototypr = ...@@ -289,7 +289,7 @@ CGroupShape.prototypr =
this.invertTransform = global_MatrixTransformer.Invert(this.transform); this.invertTransform = global_MatrixTransformer.Invert(this.transform);
for(var i = 0; i < this.spTree.length; ++i) for(var i = 0; i < this.spTree.length; ++i)
{ {
this.spTree.recalculateTransform(); this.spTree[i].recalculateTransform();
} }
}, },
...@@ -320,23 +320,90 @@ CGroupShape.prototypr = ...@@ -320,23 +320,90 @@ CGroupShape.prototypr =
var x_t = invert_transform.TransformPointX(x, y); var x_t = invert_transform.TransformPointX(x, y);
var y_t = invert_transform.TransformPointY(x, y); var y_t = invert_transform.TransformPointY(x, y);
var _hit_context = this.drawingDocument.CanvasHitContext; var _hit_context = this.drawingObjects.getCanvasContext();
return (HitInLine(_hit_context, x_t, y_t, 0, 0, this.extX, 0) || return (HitInLine(_hit_context, x_t, y_t, 0, 0, this.extX, 0) ||
HitInLine(_hit_context, x_t, y_t, this.extX, 0, this.extX, this.extY)|| HitInLine(_hit_context, x_t, y_t, this.extX, 0, this.extX, this.extY)||
HitInLine(_hit_context, x_t, y_t, this.extX, this.extY, 0, this.extY)|| HitInLine(_hit_context, x_t, y_t, this.extX, this.extY, 0, this.extY)||
HitInLine(_hit_context, x_t, y_t, 0, this.extY, 0, 0) || HitInLine(_hit_context, x_t, y_t, 0, this.extY, 0, 0) /*||
HitInLine(_hit_context, x_t, y_t, this.extX*0.5, 0, this.extX*0.5, -this.drawingDocument.GetMMPerDot(TRACK_DISTANCE_ROTATE))); HitInLine(_hit_context, x_t, y_t, this.extX*0.5, 0, this.extX*0.5, -this.drawingDocument.GetMMPerDot(TRACK_DISTANCE_ROTATE))*/);
}, },
hitToAdjustment: function()
{
return {hit: false};
},
hitToHandles: function(x, y)
{
var invert_transform = this.getInvertTransform();
var t_x, t_y;
t_x = invert_transform.TransformPointX(x, y);
t_y = invert_transform.TransformPointY(x, y);
var radius = 5;/*TODO*/
var sqr_x = t_x*t_y, sqr_y = t_y*t_y;
if(Math.sqrt(sqr_x + sqr_y) < radius)
return 0;
var hc = this.extX*0.5;
var dist_x = t_x - hc;
sqr_x = dist_x*dist_x;
if(Math.sqrt(sqr_x + sqr_y) < radius)
return 1;
dist_x = t_x - this.extX;
sqr_x = dist_x*dist_x;
if(Math.sqrt(sqr_x + sqr_y) < radius)
return 2;
var vc = this.extY*0.5;
var dist_y = t_y - vc;
sqr_y = dist_y*dist_y;
if(Math.sqrt(sqr_x + sqr_y) < radius)
return 3;
dist_y = t_y - this.extY;
sqr_y = dist_y*dist_y;
if(Math.sqrt(sqr_x + sqr_y) < radius)
return 4;
dist_x = t_x - hc;
sqr_x = dist_x*dist_x;
if(Math.sqrt(sqr_x + sqr_y) < radius)
return 5;
dist_x = t_x;
sqr_x = dist_x*dist_x;
if(Math.sqrt(sqr_x + sqr_y) < radius)
return 6;
dist_y = t_y - vc;
sqr_y = dist_y*dist_y;
if(Math.sqrt(sqr_x + sqr_y) < radius)
return 7;
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;
return -1;
},
drawAdjustments: function(drawingDocument) drawAdjustments: function(drawingDocument)
{ {
}, },
getTransform: function() getTransform: function()
{ {
if(this.recalcInfo.recalculateTransform) //if(this.recalcInfo.recalculateTransform)
this.recalculateTransform(); // this.recalculateTransform();
return this.transform; return this.transform;
}, },
...@@ -345,5 +412,40 @@ CGroupShape.prototypr = ...@@ -345,5 +412,40 @@ CGroupShape.prototypr =
if(this.recalcInfo.recalculateTransform) if(this.recalcInfo.recalculateTransform)
this.recalculateTransform(); this.recalculateTransform();
return this.invertTransform; return this.invertTransform;
} ,
select: function(drawingObjectsController)
{
this.selected = true;
var selected_objects;
if(!isRealObject(this.group))
selected_objects = drawingObjectsController.selectedObjects;
else
selected_objects = this.group.getMainGroup().selectedObjects;
for(var i = 0; i < selected_objects.length; ++i)
{
if(selected_objects[i] === this)
break;
}
if(i === selected_objects.length)
selected_objects.push(this);
},
deselect: function(drawingObjectsController)
{
this.selected = false;
var selected_objects;
if(!isRealObject(this.group))
selected_objects = drawingObjectsController.selectedObjects;
else
selected_objects = this.group.getMainGroup().selectedObjects;
for(var i = 0; i < selected_objects.length; ++i)
{
if(selected_objects[i] === this)
{
selected_objects.splice(i, 1);
break;
}
}
} }
}; };
\ No newline at end of file
...@@ -176,8 +176,8 @@ CImage.prototype = ...@@ -176,8 +176,8 @@ CImage.prototype =
else else
{ {
var scale_scale_coefficients = this.group.getResultScaleCoefficients(); var scale_scale_coefficients = this.group.getResultScaleCoefficients();
this.x = scale_scale_coefficients.cx*(xfrm.offX - this.group.xfrm.chOffX); this.x = scale_scale_coefficients.cx*(xfrm.offX - this.group.spPr.xfrm.chOffX);
this.y = scale_scale_coefficients.cy*(xfrm.offY - this.group.xfrm.chOffY); this.y = scale_scale_coefficients.cy*(xfrm.offY - this.group.spPr.xfrm.chOffY);
this.extX = scale_scale_coefficients.cx*xfrm.extX; this.extX = scale_scale_coefficients.cx*xfrm.extX;
this.extY = scale_scale_coefficients.cy*xfrm.extY; this.extY = scale_scale_coefficients.cy*xfrm.extY;
this.rot = isRealNumber(xfrm.rot) ? xfrm.rot : 0; this.rot = isRealNumber(xfrm.rot) ? xfrm.rot : 0;
...@@ -205,14 +205,20 @@ CImage.prototype = ...@@ -205,14 +205,20 @@ CImage.prototype =
getTransform: function() getTransform: function()
{ {
if(this.recalcInfo.recalculateTransform) if(this.recalcInfo.recalculateTransform)
{
this.recalculateTransform(); this.recalculateTransform();
this.recalcInfo.recalculateTransform = false;
}
return this.transform; return this.transform;
}, },
getInvertTransform: function() getInvertTransform: function()
{ {
if(this.recalcInfo.recalculateTransform) if(this.recalcInfo.recalculateTransform)
{
this.recalculateTransform(); this.recalculateTransform();
this.recalcInfo.recalculateTransform = false;
}
return this.invertTransform; return this.invertTransform;
}, },
......
...@@ -237,8 +237,8 @@ CShape.prototype = ...@@ -237,8 +237,8 @@ CShape.prototype =
else else
{ {
var scale_scale_coefficients = this.group.getResultScaleCoefficients(); var scale_scale_coefficients = this.group.getResultScaleCoefficients();
this.x = scale_scale_coefficients.cx*(xfrm.offX - this.group.xfrm.chOffX); this.x = scale_scale_coefficients.cx*(xfrm.offX - this.group.spPr.xfrm.chOffX);
this.y = scale_scale_coefficients.cy*(xfrm.offY - this.group.xfrm.chOffY); this.y = scale_scale_coefficients.cy*(xfrm.offY - this.group.spPr.xfrm.chOffY);
this.extX = scale_scale_coefficients.cx*xfrm.extX; this.extX = scale_scale_coefficients.cx*xfrm.extX;
this.extY = scale_scale_coefficients.cy*xfrm.extY; this.extY = scale_scale_coefficients.cy*xfrm.extY;
this.rot = isRealNumber(xfrm.rot) ? xfrm.rot : 0; this.rot = isRealNumber(xfrm.rot) ? xfrm.rot : 0;
...@@ -358,14 +358,20 @@ CShape.prototype = ...@@ -358,14 +358,20 @@ CShape.prototype =
getTransform: function() getTransform: function()
{ {
if(this.recalcInfo.recalculateTransform) if(this.recalcInfo.recalculateTransform)
{
this.recalculateTransform(); this.recalculateTransform();
this.recalcInfo.recalculateTransform = false;
}
return this.transform; return this.transform;
}, },
getInvertTransform: function() getInvertTransform: function()
{ {
if(this.recalcInfo.recalculateTransform) if(this.recalcInfo.recalculateTransform)
{
this.recalculateTransform(); this.recalculateTransform();
this.recalcInfo.recalculateTransform = false;
}
return this.invertTransform; return this.invertTransform;
}, },
...@@ -476,26 +482,29 @@ CShape.prototype = ...@@ -476,26 +482,29 @@ CShape.prototype =
var cx, cy; var cx, cy;
cx= this.extX > 0 ? this.extX : 0.01; cx= this.extX > 0 ? this.extX : 0.01;
cy= this.extY > 0 ? this.extY : 0.01; cy= this.extY > 0 ? this.extY : 0.01;
var p = this.transformPointRelativeShape(x, y);
var invert_transform = this.getInvertTransform();
var t_x = invert_transform.TransformPointX(x, y);
var t_y = invert_transform.TransformPointY(x, y);
switch(numHandle) switch(numHandle)
{ {
case 0: case 0:
return {kd1: (cx-p.x)/cx, kd2: (cy-p.y)/cy}; return {kd1: (cx-t_x)/cx, kd2: (cy-t_y)/cy};
case 1: case 1:
return {kd1: (cy-p.y)/cy, kd2: 0}; return {kd1: (cy-t_y)/cy, kd2: 0};
case 2: case 2:
return {kd1: (cy-p.y)/cy, kd2: p.x/cx}; return {kd1: (cy-t_y)/cy, kd2: t_x/cx};
case 3: case 3:
return {kd1: p.x/cx, kd2: 0}; return {kd1: t_x/cx, kd2: 0};
case 4: case 4:
return {kd1: p.x/cx, kd2: p.y/cy}; return {kd1: t_x/cx, kd2: t_y/cy};
case 5: case 5:
return {kd1: p.y/cy, kd2: 0}; return {kd1: t_y/cy, kd2: 0};
case 6: case 6:
return {kd1: p.y/cy, kd2:(cx-p.x)/cx}; return {kd1: t_y/cy, kd2:(cx-t_x)/cx};
case 7: case 7:
return {kd1:(cx-p.x)/cx, kd2: 0}; return {kd1:(cx-t_x)/cx, kd2: 0};
} }
return {kd1: 1, kd2: 1}; return {kd1: 1, kd2: 1};
}, },
...@@ -580,10 +589,10 @@ CShape.prototype = ...@@ -580,10 +589,10 @@ CShape.prototype =
var _relative_y = -_temp_x*_sin + _temp_y*_cos; var _relative_y = -_temp_x*_sin + _temp_y*_cos;
if(this.absFlipH) if(this.absFlipH)
_relative_x = this.absExtX - _relative_x; _relative_x = this.extX - _relative_x;
if(this.absFlipV) if(this.absFlipV)
_relative_y = this.absExtY - _relative_y; _relative_y = this.extY - _relative_y;
return {x: _relative_x, y: _relative_y}; return {x: _relative_x, y: _relative_y};
}, },
......
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