Commit 7ccd92ca 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@53246 954022d7-b5bf-4e40-9824-e11837661b57
parent 9d75a1bb
......@@ -1472,6 +1472,10 @@ CGeometry.prototype=
hitInInnerArea: function(canvasContext, x, y)
{
if(this.preset === "rect")
{
return x > 0 && x < this.gdLst["w"] && y > 0 && y < this.gdLst["h"];
}
var _path_list = this.pathLst;
var _path_count = _path_list.length;
var _path_index;
......@@ -1485,6 +1489,11 @@ CGeometry.prototype=
hitInPath: function(canvasContext, x, y)
{
if(this.preset === "rect")
{
if(x < -2 || x > this.gdLst["w"] + 2 || y < -2 || y > this.gdLst["h"] + 2)
return false;
}
var _path_list = this.pathLst;
var _path_count = _path_list.length;
var _path_index;
......
......@@ -38,6 +38,14 @@ function CImageShape(drawingBase, drawingObjects)
recalculateBrush: true
};
this.bounds =
{
x: 0,
y: 0,
w: 0,
h: 0
};
this.brush = null;
this.pen = null;
......@@ -362,6 +370,19 @@ CImageShape.prototype =
this.recalculateBrush(aImagesSync);
this.recalcInfo.recalculateBrush = false;
}
try
{
var boundsChecker = new CSlideBoundsChecker();
this.draw(boundsChecker);
boundsChecker.CorrectBounds();
this.bounds.x = boundsChecker.Bounds.min_x;
this.bounds.y = boundsChecker.Bounds.min_y;
this.bounds.w = boundsChecker.Bounds.max_x - boundsChecker.Bounds.min_x;
this.bounds.h = boundsChecker.Bounds.max_y - boundsChecker.Bounds.min_y;
}
catch(e)
{}
},
recalculateBrush: function(aImagesSync)
......@@ -443,6 +464,20 @@ CImageShape.prototype =
global_MatrixTransformer.MultiplyAppend(this.transform, this.group.getTransform());
}
this.invertTransform = global_MatrixTransformer.Invert(this.transform);
try
{
var boundsChecker = new CSlideBoundsChecker();
this.draw(boundsChecker);
boundsChecker.CorrectBounds();
this.bounds.x = boundsChecker.Bounds.min_x;
this.bounds.y = boundsChecker.Bounds.min_y;
this.bounds.w = boundsChecker.Bounds.max_x - boundsChecker.Bounds.min_x;
this.bounds.h = boundsChecker.Bounds.max_y - boundsChecker.Bounds.min_y;
}
catch(e)
{}
},
calculateTransformTextMatrix: function()
......@@ -732,6 +767,16 @@ CImageShape.prototype =
draw: function(graphics)
{
if(graphics.updatedRect && this.group)
{
var rect = graphics.updatedRect;
var bounds = this.bounds;
if(bounds.x > rect.x + rect.w
|| bounds.y > rect.y + rect.h
|| bounds.x + bounds.w < rect.x
|| bounds.y + bounds.h < rect.y)
return;
}
graphics.SetIntegerGrid(false);
graphics.transform3(this.transform, false);
var shape_drawer = new CShapeDrawer();
......@@ -861,6 +906,11 @@ CImageShape.prototype =
hitInInnerArea: function(x, y)
{
if(x < this.bounds.x
|| y < this.bounds.y
|| x > this.bounds.x + this.bounds.w
|| y > this.bounds.y + this.bounds.h)
return false;
var invert_transform = this.getInvertTransform();
var x_t = invert_transform.TransformPointX(x, y);
var y_t = invert_transform.TransformPointY(x, y);
......@@ -871,6 +921,11 @@ CImageShape.prototype =
hitInPath: function(x, y)
{
if(x < this.bounds.x
|| y < this.bounds.y
|| x > this.bounds.x + this.bounds.w
|| y > this.bounds.y + this.bounds.h)
return false;
var invert_transform = this.getInvertTransform();
var x_t = invert_transform.TransformPointX(x, y);
var y_t = invert_transform.TransformPointY(x, y);
......
......@@ -153,6 +153,13 @@ function CShape(drawingBase, drawingObjects, legendEntry)
this.transformText = new CMatrix();
this.invertTransformText = null;
this.cursorTypes = [];
this.bounds =
{
x: 0,
y: 0,
w: 0,
h: 0
};
this.brush = null;
this.pen = null;
......@@ -1220,6 +1227,19 @@ CShape.prototype =
this.spPr.geometry.Recalculate(this.extX, this.extY);
}
}
try
{
var boundsChecker = new CSlideBoundsChecker();
this.draw(boundsChecker);
boundsChecker.CorrectBounds();
this.bounds.x = boundsChecker.Bounds.min_x;
this.bounds.y = boundsChecker.Bounds.min_y;
this.bounds.w = boundsChecker.Bounds.max_x - boundsChecker.Bounds.min_x;
this.bounds.h = boundsChecker.Bounds.max_y - boundsChecker.Bounds.min_y;
}
catch(e)
{}
this.calculateContent();
this.calculateTransformTextMatrix();
},
......@@ -2098,6 +2118,19 @@ CShape.prototype =
global_MatrixTransformer.MultiplyAppend(this.transform, this.group.getTransform());
}
this.invertTransform = global_MatrixTransformer.Invert(this.transform);
try
{
var boundsChecker = new CSlideBoundsChecker();
this.draw(boundsChecker);
boundsChecker.CorrectBounds();
this.bounds.x = boundsChecker.Bounds.min_x;
this.bounds.y = boundsChecker.Bounds.min_y;
this.bounds.w = boundsChecker.Bounds.max_x - boundsChecker.Bounds.min_x;
this.bounds.h = boundsChecker.Bounds.max_y - boundsChecker.Bounds.min_y;
}
catch(e)
{}
},
normalize: function()
......@@ -2216,6 +2249,16 @@ CShape.prototype =
draw: function(graphics)
{
if(graphics.updatedRect && this.group)
{
var rect = graphics.updatedRect;
var bounds = this.bounds;
if(bounds.x > rect.x + rect.w
|| bounds.y > rect.y + rect.h
|| bounds.x + bounds.w < rect.x
|| bounds.y + bounds.h < rect.y)
return;
}
graphics.SetIntegerGrid(false);
graphics.transform3(this.transform, false);
var shape_drawer = new CShapeDrawer();
......@@ -2884,6 +2927,11 @@ CShape.prototype =
hitInPath: function(x, y)
{
if(x < this.bounds.x
|| y < this.bounds.y
|| x > this.bounds.x + this.bounds.w
|| y > this.bounds.y + this.bounds.h)
return false;
var invert_transform = this.getInvertTransform();
var x_t = invert_transform.TransformPointX(x, y);
var y_t = invert_transform.TransformPointY(x, y);
......@@ -2894,6 +2942,11 @@ CShape.prototype =
hitInInnerArea: function(x, y)
{
if(x < this.bounds.x
|| y < this.bounds.y
|| x > this.bounds.x + this.bounds.w
|| y > this.bounds.y + this.bounds.h)
return false;
var invert_transform = this.getInvertTransform();
var x_t = invert_transform.TransformPointX(x, y);
var y_t = invert_transform.TransformPointY(x, y);
......@@ -2904,6 +2957,11 @@ CShape.prototype =
hitInTextRect: function(x, y)
{
if(x < this.bounds.x
|| y < this.bounds.y
|| x > this.bounds.x + this.bounds.w
|| y > this.bounds.y + this.bounds.h)
return false;
if(isRealObject(this.txBody))
{
var t_x, t_y;
......
/*function PointToSegmentDistance( px, py, x0, y0, x1, y1)
{
var vx = x1 - x0;
var vy = y1 - y0;
var wx = px - x0;
var wy = py - y0;
var
var c1 = vx*wx + vy*wy;
if ( c1 <= 0 )
return Math.sqrt(wx*wx + wy*wy);
var c2 = vx*vx + vy*vy;
if ( c2 <= c1 )
return d(P, P1)
b = c1 / c2
Pb = P0 + bv
return d(P, Pb)
} */
function HitInLine(context, px, py, x0, y0, x1, y1)
{
var l = Math.min(x0, x1);
var t = Math.min(y0, y1);
var r = Math.max(x0, x1);
var b = Math.max(y0, y1);
if(px < l || px > r || py < t || py > b)
return false;
var tx, ty, dx, dy, d;
tx=x1-x0;
ty=y1-y0;
......@@ -21,6 +47,12 @@ function HitInLine(context, px, py, x0, y0, x1, y1)
function HitInBezier4(context, px, py, x0, y0, x1, y1, x2, y2, x3, y3)
{
var l = Math.min(x0, x1, x2, x3);
var t = Math.min(y0, y1, y2, y3);
var r = Math.max(x0, x1, x2, x3);
var b = Math.max(y0, y1, y2, y3);
if(px < l || px > r || py < t || py > b)
return false;
var tx, ty, dx, dy, d;
tx=x3-x0;
ty=y3-y0;
......@@ -42,6 +74,12 @@ function HitInBezier4(context, px, py, x0, y0, x1, y1, x2, y2, x3, y3)
function HitInBezier3(context, px, py, x0, y0, x1, y1, x2, y2)
{
var l = Math.min(x0, x1, x2);
var t = Math.min(y0, y1, y2);
var r = Math.max(x0, x1, x2);
var b = Math.max(y0, y1, y2);
if(px < l || px > r || py < t || py > b)
return false;
var tx, ty, dx, dy, d;
tx=x2-x0;
ty=y2-y0;
......
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