Commit 486ec890 authored by Oleg.Korshul's avatar Oleg.Korshul Committed by Alexander.Trofimov

smart overlay track 90/180/270

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@57323 954022d7-b5bf-4e40-9824-e11837661b57
parent 1dcc6879
......@@ -779,6 +779,19 @@ CAutoshapeTrack.prototype =
if (x1 == x3 && x2 == x4 && y1 == y2 && y3 == y4 && x1 < x2 && y1 < y3)
bIsClever = true;
var nIsCleverWithTransform = bIsClever;
var nType = 0;
if (!nIsCleverWithTransform && x1 == x3 && x2 == x4 && y1 == y2 && y3 == y4)
{
nIsCleverWithTransform = true;
nType = 1;
}
if (!nIsCleverWithTransform && x1 == x2 && x3 == x4 && y1 == y3 && y2 == y4)
{
nIsCleverWithTransform = true;
nType = 2;
}
var bIsEllipceCorner = false;
//var _style_blue = "#4D7399";
//var _style_blue = "#B2B2B2";
......@@ -798,6 +811,13 @@ CAutoshapeTrack.prototype =
var bIsRectsTrackY = (_len_y >= 30) ? true : false;
var bIsRectsTrack = (bIsRectsTrackX || bIsRectsTrackY) ? true : false;
if (nType == 2)
{
var _tmp = bIsRectsTrackX;
bIsRectsTrackX = bIsRectsTrackY;
bIsRectsTrackY = _tmp;
}
ctx.lineWidth = 1;
ctx.beginPath();
......@@ -903,8 +923,65 @@ 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;
}
ctx.strokeStyle = _style_blue;
if (nIsCleverWithTransform)
{
ctx.rect(_x1 + 0.5, _y2 + 0.5, _x4 - _x1, _y4 - _y1);
ctx.stroke();
ctx.beginPath();
}
else
{
if (!isLine)
{
ctx.moveTo(x1, y1);
......@@ -914,6 +991,7 @@ CAutoshapeTrack.prototype =
ctx.closePath();
ctx.stroke();
}
}
overlay.CheckPoint(x1, y1);
overlay.CheckPoint(x2, y2);
......@@ -976,6 +1054,14 @@ 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);
ctx.drawImage(window.g_track_rotate_marker, -_w2, -_w2, _w, _w);
ctx.setTransform(1, 0, 0, 1, 0, 0);
......@@ -986,8 +1072,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);
}
ctx.stroke();
......@@ -996,6 +1090,8 @@ CAutoshapeTrack.prototype =
ctx.fillStyle = _style_white;
if (!nIsCleverWithTransform)
{
if (bIsEllipceCorner)
{
overlay.AddEllipse(x1, y1, TRACK_CIRCLE_RADIUS);
......@@ -1016,7 +1112,33 @@ CAutoshapeTrack.prototype =
}
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
{
overlay.AddRect2(_x1 + 0.5, _y1 + 0.5, TRACK_RECT_SIZE);
if (!isLine)
{
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 && !isLine)
{
if (bIsRectsTrackX)
......@@ -1030,6 +1152,24 @@ CAutoshapeTrack.prototype =
overlay.AddRect3((x3 + x1) / 2, (y3 + y1) / 2, TRACK_RECT_SIZE, ex1, ey1, ex2, ey2);
}
}
}
else
{
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();
......@@ -1127,12 +1267,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;
}
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);
}
ctx.strokeStyle = _style_blue;
ctx.stroke();
......@@ -1193,6 +1389,14 @@ 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);
ctx.drawImage(window.g_track_rotate_marker, -_w2, -_w2, _w, _w);
ctx.setTransform(1, 0, 0, 1, 0, 0);
......@@ -1203,8 +1407,17 @@ 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);
}
ctx.stroke();
ctx.beginPath();
......@@ -1213,6 +1426,8 @@ CAutoshapeTrack.prototype =
ctx.fillStyle = _style_white;
if (!nIsCleverWithTransform)
{
if (bIsEllipceCorner)
{
overlay.AddEllipse(x1, y1, TRACK_CIRCLE_RADIUS);
......@@ -1227,7 +1442,27 @@ CAutoshapeTrack.prototype =
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)
......@@ -1241,6 +1476,26 @@ CAutoshapeTrack.prototype =
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();
......
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