Commit 4b1e19a1 authored by Oleg.Korshul's avatar Oleg.Korshul Committed by Alexander.Trofimov

cool AddSmartRect & overlay Excel

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@58189 954022d7-b5bf-4e40-9824-e11837661b57
parent 8613922f
......@@ -2500,7 +2500,92 @@ CGraphics.prototype =
{
if (!global_MatrixTransformer.IsIdentity2(this.m_oTransform))
{
// проверим - может все-таки можно нарисовать как надо?
var r = x + w;
var b = y + h;
var dx1 = this.m_oFullTransform.TransformPointX(x, y);
var dy1 = this.m_oFullTransform.TransformPointY(x, y);
var dx2 = this.m_oFullTransform.TransformPointX(r, y);
var dy2 = this.m_oFullTransform.TransformPointY(r, y);
var dx3 = this.m_oFullTransform.TransformPointX(x, b);
var dy3 = this.m_oFullTransform.TransformPointY(x, b);
var dx4 = this.m_oFullTransform.TransformPointX(r, b);
var dy4 = this.m_oFullTransform.TransformPointY(r, b);
var _eps = 0.001;
var bIsClever = false;
var _type = 1;
if (Math.abs(dx1 - dx3) < _eps &&
Math.abs(dx2 - dx4) < _eps &&
Math.abs(dy1 - dy2) < _eps &&
Math.abs(dy3 - dy4) < _eps)
{
bIsClever = true;
_type = 1;
}
if (!bIsClever &&
Math.abs(dx1 - dx2) < _eps &&
Math.abs(dx3 - dx4) < _eps &&
Math.abs(dy1 - dy3) < _eps &&
Math.abs(dy2 - dy4) < _eps)
{
_type = 2;
bIsClever = true;
}
if (!bIsClever)
{
this.ds();
return;
}
var _xI = (_type == 1) ? Math.min(dx1, dx2) : Math.min(dx1, dx3);
var _rI = (_type == 1) ? Math.max(dx1, dx2) : Math.max(dx1, dx3);
var _yI = (_type == 1) ? Math.min(dy1, dy3) : Math.min(dy1, dy2);
var _bI = (_type == 1) ? Math.max(dy1, dy3) : Math.max(dy1, dy2);
var bIsSmartAttack = false;
if (!this.m_bIntegerGrid)
{
this.SetIntegerGrid(true);
bIsSmartAttack = true;
}
var _pen_w = (pen_w * this.m_oCoordTransform.sx + 0.5) >> 0;
if (0 >= _pen_w)
_pen_w = 1;
this._s();
if ((_pen_w & 0x01) == 0x01)
{
var _x = (_xI >> 0) + 0.5;
var _y = (_yI >> 0) + 0.5;
var _r = (_rI >> 0) + 0.5;
var _b = (_bI >> 0) + 0.5;
this.m_oContext.rect(_x, _y, _r - _x, _b - _y);
}
else
{
var _x = (_xI + 0.5) >> 0;
var _y = (_yI + 0.5) >> 0;
var _r = (_rI + 0.5) >> 0;
var _b = (_bI + 0.5) >> 0;
this.m_oContext.rect(_x, _y, _r - _x, _b - _y);
}
this.m_oContext.lineWidth = _pen_w;
this.ds();
if (bIsSmartAttack)
{
this.SetIntegerGrid(false);
}
return;
}
......
......@@ -859,17 +859,17 @@ CAutoshapeTrack.prototype =
var _style_green = "#84E036";
var _style_white = "#FFFFFF";
var _len_x = Math.sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));
var _len_y = Math.sqrt((x1 - x3)*(x1 - x3) + (y1 - y3)*(y1 - y3));
var _len_x = Math.sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));
var _len_y = Math.sqrt((x1 - x3)*(x1 - x3) + (y1 - y3)*(y1 - y3));
if (_len_x < 1)
_len_x = 1;
if (_len_y < 1)
_len_y = 1;
if (_len_x < 1)
_len_x = 1;
if (_len_y < 1)
_len_y = 1;
var bIsRectsTrackX = (_len_x >= 30) ? true : false;
var bIsRectsTrackY = (_len_y >= 30) ? true : false;
var bIsRectsTrack = (bIsRectsTrackX || bIsRectsTrackY) ? true : false;
var bIsRectsTrackX = (_len_x >= 30) ? true : false;
var bIsRectsTrackY = (_len_y >= 30) ? true : false;
var bIsRectsTrack = (bIsRectsTrackX || bIsRectsTrackY) ? true : false;
if (nType == 2)
{
......@@ -878,11 +878,11 @@ CAutoshapeTrack.prototype =
bIsRectsTrackY = _tmp;
}
ctx.lineWidth = 1;
ctx.beginPath();
ctx.lineWidth = 1;
ctx.beginPath();
var _oldGlobalAlpha = ctx.globalAlpha;
ctx.globalAlpha = 1;
var _oldGlobalAlpha = ctx.globalAlpha;
ctx.globalAlpha = 1;
switch (type)
{
......@@ -983,54 +983,54 @@ CAutoshapeTrack.prototype =
}
else
{
var _x1 = x1;
var _y1 = y1;
var _x2 = x2;
var _y2 = y2;
var _x3 = x3;
var _y3 = y3;
var _x4 = x4;
var _y4 = y4;
if (nIsCleverWithTransform)
{
var _x1 = x1;
if (x2 < _x1)
_x1 = x2;
if (x3 < _x1)
_x1 = x3;
if (x4 < _x1)
_x1 = x4;
var _x4 = x1;
if (x2 > _x4)
_x4 = x2;
if (x3 > _x4)
_x4 = x3;
if (x4 > _x4)
_x4 = x4;
var _y1 = y1;
if (y2 < _y1)
_y1 = y2;
if (y3 < _y1)
_y1 = y3;
if (y4 < _y1)
_y1 = y4;
var _y4 = y1;
if (y2 > _y4)
_y4 = y2;
if (y3 > _y4)
_y4 = y3;
if (y4 > _y4)
_y4 = y4;
_x2 = _x4;
_y2 = _y1;
_x3 = _x1;
_y3 = _y4;
}
var _x1 = x1;
var _y1 = y1;
var _x2 = x2;
var _y2 = y2;
var _x3 = x3;
var _y3 = y3;
var _x4 = x4;
var _y4 = y4;
if (nIsCleverWithTransform)
{
var _x1 = x1;
if (x2 < _x1)
_x1 = x2;
if (x3 < _x1)
_x1 = x3;
if (x4 < _x1)
_x1 = x4;
var _x4 = x1;
if (x2 > _x4)
_x4 = x2;
if (x3 > _x4)
_x4 = x3;
if (x4 > _x4)
_x4 = x4;
var _y1 = y1;
if (y2 < _y1)
_y1 = y2;
if (y3 < _y1)
_y1 = y3;
if (y4 < _y1)
_y1 = y4;
var _y4 = y1;
if (y2 > _y4)
_y4 = y2;
if (y3 > _y4)
_y4 = y3;
if (y4 > _y4)
_y4 = y4;
_x2 = _x4;
_y2 = _y1;
_x3 = _x1;
_y3 = _y4;
}
ctx.strokeStyle = _style_blue;
......@@ -1114,27 +1114,27 @@ CAutoshapeTrack.prototype =
var _w = IMAGE_ROTATE_TRACK_W;
var _w2 = IMAGE_ROTATE_TRACK_W / 2;
if (nIsCleverWithTransform)
{
_xI >>= 0;
_yI >>= 0;
_w2 >>= 0;
_w2 += 1;
}
//ctx.setTransform(ex1, ey1, -ey1, ex1, _xI, _yI);
var _matrix = matrix.CreateDublicate();
_matrix.tx = 0;
_matrix.ty = 0;
var _xx = _matrix.TransformPointX(0, 1);
var _yy = _matrix.TransformPointY(0, 1);
var _angle = Math.atan2(_xx, -_yy) - Math.PI;
var _px = Math.cos(_angle);
var _py = Math.sin(_angle);
ctx.translate(_xI, _yI);
ctx.transform(_px, _py, -_py, _px, 0, 0);
if (nIsCleverWithTransform)
{
_xI >>= 0;
_yI >>= 0;
_w2 >>= 0;
_w2 += 1;
}
//ctx.setTransform(ex1, ey1, -ey1, ex1, _xI, _yI);
var _matrix = matrix.CreateDublicate();
_matrix.tx = 0;
_matrix.ty = 0;
var _xx = _matrix.TransformPointX(0, 1);
var _yy = _matrix.TransformPointY(0, 1);
var _angle = Math.atan2(_xx, -_yy) - Math.PI;
var _px = Math.cos(_angle);
var _py = Math.sin(_angle);
ctx.translate(_xI, _yI);
ctx.transform(_px, _py, -_py, _px, 0, 0);
ctx.drawImage(window.g_track_rotate_marker, -_w2, -_w2, _w, _w);
ctx.setTransform(1, 0, 0, 1, 0, 0);
......@@ -1144,16 +1144,16 @@ CAutoshapeTrack.prototype =
ctx.beginPath();
if (!nIsCleverWithTransform)
{
ctx.moveTo(xc1, yc1);
ctx.lineTo(xc1 + ex2 * TRACK_DISTANCE_ROTATE2, yc1 + ey2 * TRACK_DISTANCE_ROTATE2);
}
else
{
ctx.moveTo((xc1 >> 0) + 0.5, (yc1 >> 0) + 0.5);
ctx.lineTo(((xc1 + ex2 * TRACK_DISTANCE_ROTATE2) >> 0) + 0.5, ((yc1 + ey2 * TRACK_DISTANCE_ROTATE2) >> 0) + 0.5);
}
if (!nIsCleverWithTransform)
{
ctx.moveTo(xc1, yc1);
ctx.lineTo(xc1 + ex2 * TRACK_DISTANCE_ROTATE2, yc1 + ey2 * TRACK_DISTANCE_ROTATE2);
}
else
{
ctx.moveTo((xc1 >> 0) + 0.5, (yc1 >> 0) + 0.5);
ctx.lineTo(((xc1 + ex2 * TRACK_DISTANCE_ROTATE2) >> 0) + 0.5, ((yc1 + ey2 * TRACK_DISTANCE_ROTATE2) >> 0) + 0.5);
}
ctx.stroke();
......@@ -1162,43 +1162,43 @@ CAutoshapeTrack.prototype =
ctx.fillStyle = _style_white;
if (!nIsCleverWithTransform)
{
if (bIsEllipceCorner)
{
overlay.AddEllipse(x1, y1, TRACK_CIRCLE_RADIUS);
if (!isLine)
{
overlay.AddEllipse(x2, y2, TRACK_CIRCLE_RADIUS);
overlay.AddEllipse(x3, y3, TRACK_CIRCLE_RADIUS);
}
overlay.AddEllipse(x4, y4, TRACK_CIRCLE_RADIUS);
}
else
{
overlay.AddRect3(x1, y1, TRACK_RECT_SIZE, ex1, ey1, ex2, ey2);
if (!isLine)
{
overlay.AddRect3(x2, y2, TRACK_RECT_SIZE, ex1, ey1, ex2, ey2);
overlay.AddRect3(x3, y3, TRACK_RECT_SIZE, ex1, ey1, ex2, ey2);
}
overlay.AddRect3(x4, y4, TRACK_RECT_SIZE, ex1, ey1, ex2, ey2);
}
}
else
{
if (bIsEllipceCorner)
{
overlay.AddEllipse(_x1, _y1, TRACK_CIRCLE_RADIUS);
if (!isLine)
{
overlay.AddEllipse(_x2, _y2, TRACK_CIRCLE_RADIUS);
overlay.AddEllipse(_x3, _y3, TRACK_CIRCLE_RADIUS);
}
overlay.AddEllipse(_x4, _y4, TRACK_CIRCLE_RADIUS);
}
else
{
if (!nIsCleverWithTransform)
{
if (bIsEllipceCorner)
{
overlay.AddEllipse(x1, y1, TRACK_CIRCLE_RADIUS);
if (!isLine)
{
overlay.AddEllipse(x2, y2, TRACK_CIRCLE_RADIUS);
overlay.AddEllipse(x3, y3, TRACK_CIRCLE_RADIUS);
}
overlay.AddEllipse(x4, y4, TRACK_CIRCLE_RADIUS);
}
else
{
overlay.AddRect3(x1, y1, TRACK_RECT_SIZE, ex1, ey1, ex2, ey2);
if (!isLine)
{
overlay.AddRect3(x2, y2, TRACK_RECT_SIZE, ex1, ey1, ex2, ey2);
overlay.AddRect3(x3, y3, TRACK_RECT_SIZE, ex1, ey1, ex2, ey2);
}
overlay.AddRect3(x4, y4, TRACK_RECT_SIZE, ex1, ey1, ex2, ey2);
}
}
else
{
if (bIsEllipceCorner)
{
overlay.AddEllipse(_x1, _y1, TRACK_CIRCLE_RADIUS);
if (!isLine)
{
overlay.AddEllipse(_x2, _y2, TRACK_CIRCLE_RADIUS);
overlay.AddEllipse(_x3, _y3, TRACK_CIRCLE_RADIUS);
}
overlay.AddEllipse(_x4, _y4, TRACK_CIRCLE_RADIUS);
}
else
{
if (!isLine)
{
overlay.AddRect2(_x1 + 0.5, _y1 + 0.5, TRACK_RECT_SIZE);
......@@ -1211,8 +1211,8 @@ CAutoshapeTrack.prototype =
overlay.AddRect2(x1 + 0.5, y1 + 0.5, TRACK_RECT_SIZE);
overlay.AddRect2(x4 + 0.5, y4 + 0.5, TRACK_RECT_SIZE);
}
}
}
}
}
if (!isLine)
{
......@@ -1347,68 +1347,68 @@ CAutoshapeTrack.prototype =
}
else
{
var _x1 = x1;
var _y1 = y1;
var _x2 = x2;
var _y2 = y2;
var _x3 = x3;
var _y3 = y3;
var _x4 = x4;
var _y4 = y4;
if (nIsCleverWithTransform)
{
var _x1 = x1;
if (x2 < _x1)
_x1 = x2;
if (x3 < _x1)
_x1 = x3;
if (x4 < _x1)
_x1 = x4;
var _x4 = x1;
if (x2 > _x4)
_x4 = x2;
if (x3 > _x4)
_x4 = x3;
if (x4 > _x4)
_x4 = x4;
var _y1 = y1;
if (y2 < _y1)
_y1 = y2;
if (y3 < _y1)
_y1 = y3;
if (y4 < _y1)
_y1 = y4;
var _y4 = y1;
if (y2 > _y4)
_y4 = y2;
if (y3 > _y4)
_y4 = y3;
if (y4 > _y4)
_y4 = y4;
_x2 = _x4;
_y2 = _y1;
_x3 = _x1;
_y3 = _y4;
}
var _x1 = x1;
var _y1 = y1;
var _x2 = x2;
var _y2 = y2;
var _x3 = x3;
var _y3 = y3;
var _x4 = x4;
var _y4 = y4;
if (nIsCleverWithTransform)
{
var _x1 = x1;
if (x2 < _x1)
_x1 = x2;
if (x3 < _x1)
_x1 = x3;
if (x4 < _x1)
_x1 = x4;
var _x4 = x1;
if (x2 > _x4)
_x4 = x2;
if (x3 > _x4)
_x4 = x3;
if (x4 > _x4)
_x4 = x4;
var _y1 = y1;
if (y2 < _y1)
_y1 = y2;
if (y3 < _y1)
_y1 = y3;
if (y4 < _y1)
_y1 = y4;
var _y4 = y1;
if (y2 > _y4)
_y4 = y2;
if (y3 > _y4)
_y4 = y3;
if (y4 > _y4)
_y4 = y4;
_x2 = _x4;
_y2 = _y1;
_x3 = _x1;
_y3 = _y4;
}
overlay.CheckPoint(x1, y1);
overlay.CheckPoint(x2, y2);
overlay.CheckPoint(x3, y3);
overlay.CheckPoint(x4, y4);
if (!nIsCleverWithTransform)
{
this.AddRectDash(ctx, x1, y1, x2, y2, x3, y3, x4, y4, 8, 3);
}
else
{
this.AddRectDashClever(ctx, _x1, _y1, _x4, _y4, 8, 3);
}
if (!nIsCleverWithTransform)
{
this.AddRectDash(ctx, x1, y1, x2, y2, x3, y3, x4, y4, 8, 3);
}
else
{
this.AddRectDashClever(ctx, _x1, _y1, _x4, _y4, 8, 3);
}
ctx.strokeStyle = _style_blue;
ctx.stroke();
......@@ -1469,29 +1469,29 @@ CAutoshapeTrack.prototype =
var _w = IMAGE_ROTATE_TRACK_W;
var _w2 = IMAGE_ROTATE_TRACK_W / 2;
if (nIsCleverWithTransform)
{
_xI >>= 0;
_yI >>= 0;
_w2 >>= 0;
_w2 += 1;
}
//ctx.setTransform(ex1, ey1, -ey1, ex1, _xI, _yI);
var _matrix = matrix.CreateDublicate();
_matrix.tx = 0;
_matrix.ty = 0;
var _xx = _matrix.TransformPointX(0, 1);
var _yy = _matrix.TransformPointY(0, 1);
var _angle = Math.atan2(_xx, -_yy) - Math.PI;
var _px = Math.cos(_angle);
var _py = Math.sin(_angle);
ctx.translate(_xI, _yI);
ctx.transform(_px, _py, -_py, _px, 0, 0);
ctx.drawImage(window.g_track_rotate_marker, -_w2, -_w2, _w, _w);
ctx.setTransform(1, 0, 0, 1, 0, 0);
if (nIsCleverWithTransform)
{
_xI >>= 0;
_yI >>= 0;
_w2 >>= 0;
_w2 += 1;
}
//ctx.setTransform(ex1, ey1, -ey1, ex1, _xI, _yI);
var _matrix = matrix.CreateDublicate();
_matrix.tx = 0;
_matrix.ty = 0;
var _xx = _matrix.TransformPointX(0, 1);
var _yy = _matrix.TransformPointY(0, 1);
var _angle = Math.atan2(_xx, -_yy) - Math.PI;
var _px = Math.cos(_angle);
var _py = Math.sin(_angle);
ctx.translate(_xI, _yI);
ctx.transform(_px, _py, -_py, _px, 0, 0);
ctx.drawImage(window.g_track_rotate_marker, -_w2, -_w2, _w, _w);
ctx.setTransform(1, 0, 0, 1, 0, 0);
overlay.CheckRect(_xI - _w2, _yI - _w2, _w, _w);
}
......@@ -1499,16 +1499,16 @@ CAutoshapeTrack.prototype =
ctx.beginPath();
if (!nIsCleverWithTransform)
{
ctx.moveTo(xc1, yc1);
ctx.lineTo(xc1 + ex2 * TRACK_DISTANCE_ROTATE2, yc1 + ey2 * TRACK_DISTANCE_ROTATE2);
}
else
{
ctx.moveTo((xc1 >> 0) + 0.5, (yc1 >> 0) + 0.5);
ctx.lineTo(((xc1 + ex2 * TRACK_DISTANCE_ROTATE2) >> 0) + 0.5, ((yc1 + ey2 * TRACK_DISTANCE_ROTATE2) >> 0) + 0.5);
}
if (!nIsCleverWithTransform)
{
ctx.moveTo(xc1, yc1);
ctx.lineTo(xc1 + ex2 * TRACK_DISTANCE_ROTATE2, yc1 + ey2 * TRACK_DISTANCE_ROTATE2);
}
else
{
ctx.moveTo((xc1 >> 0) + 0.5, (yc1 >> 0) + 0.5);
ctx.lineTo(((xc1 + ex2 * TRACK_DISTANCE_ROTATE2) >> 0) + 0.5, ((yc1 + ey2 * TRACK_DISTANCE_ROTATE2) >> 0) + 0.5);
}
ctx.stroke();
......@@ -1518,76 +1518,76 @@ CAutoshapeTrack.prototype =
ctx.fillStyle = _style_white;
if (!nIsCleverWithTransform)
{
if (bIsEllipceCorner)
{
overlay.AddEllipse(x1, y1, TRACK_CIRCLE_RADIUS);
overlay.AddEllipse(x2, y2, TRACK_CIRCLE_RADIUS);
overlay.AddEllipse(x3, y3, TRACK_CIRCLE_RADIUS);
overlay.AddEllipse(x4, y4, TRACK_CIRCLE_RADIUS);
}
else
{
overlay.AddRect3(x1, y1, TRACK_RECT_SIZE, ex1, ey1, ex2, ey2);
overlay.AddRect3(x2, y2, TRACK_RECT_SIZE, ex1, ey1, ex2, ey2);
overlay.AddRect3(x3, y3, TRACK_RECT_SIZE, ex1, ey1, ex2, ey2);
overlay.AddRect3(x4, y4, TRACK_RECT_SIZE, ex1, ey1, ex2, ey2);
}
}
else
{
if (bIsEllipceCorner)
{
overlay.AddEllipse(x1, y1, TRACK_CIRCLE_RADIUS);
overlay.AddEllipse(x2, y2, TRACK_CIRCLE_RADIUS);
overlay.AddEllipse(x3, y3, TRACK_CIRCLE_RADIUS);
overlay.AddEllipse(x4, y4, TRACK_CIRCLE_RADIUS);
}
else
{
overlay.AddRect2(_x1 + 0.5, _y1 + 0.5, TRACK_RECT_SIZE);
overlay.AddRect2(_x2 + 0.5, _y2 + 0.5, TRACK_RECT_SIZE);
overlay.AddRect2(_x3 + 0.5, _y3 + 0.5, TRACK_RECT_SIZE);
overlay.AddRect2(_x4 + 0.5, _y4 + 0.5, TRACK_RECT_SIZE);
}
}
if (!nIsCleverWithTransform)
{
if (bIsRectsTrack)
{
if (bIsRectsTrackX)
{
overlay.AddRect3((x1 + x2) / 2, (y1 + y2) / 2, TRACK_RECT_SIZE, ex1, ey1, ex2, ey2);
overlay.AddRect3((x3 + x4) / 2, (y3 + y4) / 2, TRACK_RECT_SIZE, ex1, ey1, ex2, ey2);
}
if (bIsRectsTrackY)
{
overlay.AddRect3((x2 + x4) / 2, (y2 + y4) / 2, TRACK_RECT_SIZE, ex1, ey1, ex2, ey2);
overlay.AddRect3((x3 + x1) / 2, (y3 + y1) / 2, TRACK_RECT_SIZE, ex1, ey1, ex2, ey2);
}
}
}
else
{
if (bIsRectsTrack)
{
var _xC = (((_x1 + _x2) / 2) >> 0) + 0.5;
var _yC = (((_y1 + _y3) / 2) >> 0) + 0.5;
if (bIsRectsTrackX)
{
overlay.AddRect2(_xC, _y1+0.5, TRACK_RECT_SIZE);
overlay.AddRect2(_xC, _y3+0.5, TRACK_RECT_SIZE);
}
if (bIsRectsTrackY)
{
overlay.AddRect2(_x2+0.5, _yC, TRACK_RECT_SIZE);
overlay.AddRect2(_x1+0.5, _yC, TRACK_RECT_SIZE);
}
}
}
if (!nIsCleverWithTransform)
{
if (bIsEllipceCorner)
{
overlay.AddEllipse(x1, y1, TRACK_CIRCLE_RADIUS);
overlay.AddEllipse(x2, y2, TRACK_CIRCLE_RADIUS);
overlay.AddEllipse(x3, y3, TRACK_CIRCLE_RADIUS);
overlay.AddEllipse(x4, y4, TRACK_CIRCLE_RADIUS);
}
else
{
overlay.AddRect3(x1, y1, TRACK_RECT_SIZE, ex1, ey1, ex2, ey2);
overlay.AddRect3(x2, y2, TRACK_RECT_SIZE, ex1, ey1, ex2, ey2);
overlay.AddRect3(x3, y3, TRACK_RECT_SIZE, ex1, ey1, ex2, ey2);
overlay.AddRect3(x4, y4, TRACK_RECT_SIZE, ex1, ey1, ex2, ey2);
}
}
else
{
if (bIsEllipceCorner)
{
overlay.AddEllipse(x1, y1, TRACK_CIRCLE_RADIUS);
overlay.AddEllipse(x2, y2, TRACK_CIRCLE_RADIUS);
overlay.AddEllipse(x3, y3, TRACK_CIRCLE_RADIUS);
overlay.AddEllipse(x4, y4, TRACK_CIRCLE_RADIUS);
}
else
{
overlay.AddRect2(_x1 + 0.5, _y1 + 0.5, TRACK_RECT_SIZE);
overlay.AddRect2(_x2 + 0.5, _y2 + 0.5, TRACK_RECT_SIZE);
overlay.AddRect2(_x3 + 0.5, _y3 + 0.5, TRACK_RECT_SIZE);
overlay.AddRect2(_x4 + 0.5, _y4 + 0.5, TRACK_RECT_SIZE);
}
}
if (!nIsCleverWithTransform)
{
if (bIsRectsTrack)
{
if (bIsRectsTrackX)
{
overlay.AddRect3((x1 + x2) / 2, (y1 + y2) / 2, TRACK_RECT_SIZE, ex1, ey1, ex2, ey2);
overlay.AddRect3((x3 + x4) / 2, (y3 + y4) / 2, TRACK_RECT_SIZE, ex1, ey1, ex2, ey2);
}
if (bIsRectsTrackY)
{
overlay.AddRect3((x2 + x4) / 2, (y2 + y4) / 2, TRACK_RECT_SIZE, ex1, ey1, ex2, ey2);
overlay.AddRect3((x3 + x1) / 2, (y3 + y1) / 2, TRACK_RECT_SIZE, ex1, ey1, ex2, ey2);
}
}
}
else
{
if (bIsRectsTrack)
{
var _xC = (((_x1 + _x2) / 2) >> 0) + 0.5;
var _yC = (((_y1 + _y3) / 2) >> 0) + 0.5;
if (bIsRectsTrackX)
{
overlay.AddRect2(_xC, _y1+0.5, TRACK_RECT_SIZE);
overlay.AddRect2(_xC, _y3+0.5, TRACK_RECT_SIZE);
}
if (bIsRectsTrackY)
{
overlay.AddRect2(_x2+0.5, _yC, TRACK_RECT_SIZE);
overlay.AddRect2(_x1+0.5, _yC, TRACK_RECT_SIZE);
}
}
}
ctx.fill();
ctx.stroke();
......@@ -1814,7 +1814,7 @@ CAutoshapeTrack.prototype =
break;
}
ctx.globalAlpha = _oldGlobalAlpha;
ctx.globalAlpha = _oldGlobalAlpha;
},
DrawTrackSelectShapes : function(x, y, w, h)
......
......@@ -2831,7 +2831,92 @@ CGraphics.prototype =
{
if (!global_MatrixTransformer.IsIdentity2(this.m_oTransform))
{
// проверим - может все-таки можно нарисовать как надо?
var r = x + w;
var b = y + h;
var dx1 = this.m_oFullTransform.TransformPointX(x, y);
var dy1 = this.m_oFullTransform.TransformPointY(x, y);
var dx2 = this.m_oFullTransform.TransformPointX(r, y);
var dy2 = this.m_oFullTransform.TransformPointY(r, y);
var dx3 = this.m_oFullTransform.TransformPointX(x, b);
var dy3 = this.m_oFullTransform.TransformPointY(x, b);
var dx4 = this.m_oFullTransform.TransformPointX(r, b);
var dy4 = this.m_oFullTransform.TransformPointY(r, b);
var _eps = 0.001;
var bIsClever = false;
var _type = 1;
if (Math.abs(dx1 - dx3) < _eps &&
Math.abs(dx2 - dx4) < _eps &&
Math.abs(dy1 - dy2) < _eps &&
Math.abs(dy3 - dy4) < _eps)
{
bIsClever = true;
_type = 1;
}
if (!bIsClever &&
Math.abs(dx1 - dx2) < _eps &&
Math.abs(dx3 - dx4) < _eps &&
Math.abs(dy1 - dy3) < _eps &&
Math.abs(dy2 - dy4) < _eps)
{
_type = 2;
bIsClever = true;
}
if (!bIsClever)
{
this.ds();
return;
}
var _xI = (_type == 1) ? Math.min(dx1, dx2) : Math.min(dx1, dx3);
var _rI = (_type == 1) ? Math.max(dx1, dx2) : Math.max(dx1, dx3);
var _yI = (_type == 1) ? Math.min(dy1, dy3) : Math.min(dy1, dy2);
var _bI = (_type == 1) ? Math.max(dy1, dy3) : Math.max(dy1, dy2);
var bIsSmartAttack = false;
if (!this.m_bIntegerGrid)
{
this.SetIntegerGrid(true);
bIsSmartAttack = true;
}
var _pen_w = (pen_w * this.m_oCoordTransform.sx + 0.5) >> 0;
if (0 >= _pen_w)
_pen_w = 1;
this._s();
if ((_pen_w & 0x01) == 0x01)
{
var _x = (_xI >> 0) + 0.5;
var _y = (_yI >> 0) + 0.5;
var _r = (_rI >> 0) + 0.5;
var _b = (_bI >> 0) + 0.5;
this.m_oContext.rect(_x, _y, _r - _x, _b - _y);
}
else
{
var _x = (_xI + 0.5) >> 0;
var _y = (_yI + 0.5) >> 0;
var _r = (_rI + 0.5) >> 0;
var _b = (_bI + 0.5) >> 0;
this.m_oContext.rect(_x, _y, _r - _x, _b - _y);
}
this.m_oContext.lineWidth = _pen_w;
this.ds();
if (bIsSmartAttack)
{
this.SetIntegerGrid(false);
}
return;
}
......
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