Commit b9ef67d6 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@53414 954022d7-b5bf-4e40-9824-e11837661b57
parent 3d58a574
...@@ -11,6 +11,8 @@ function NewShapeTrack(drawingObjects, presetGeom, startX, startY) ...@@ -11,6 +11,8 @@ function NewShapeTrack(drawingObjects, presetGeom, startX, startY)
this.y = null; this.y = null;
this.extX = null; this.extX = null;
this.extY = null; this.extY = null;
this.flipH = null;
this.flipV = null;
this.transform = new CMatrix(); this.transform = new CMatrix();
...@@ -144,22 +146,38 @@ function NewShapeTrack(drawingObjects, presetGeom, startX, startY) ...@@ -144,22 +146,38 @@ function NewShapeTrack(drawingObjects, presetGeom, startX, startY)
this.overlayObject = new OverlayObject(geometry, 5, 5, brush, pen, this.transform); this.overlayObject = new OverlayObject(geometry, 5, 5, brush, pen, this.transform);
this.lineFlag = CheckLinePreset(final_preset); this.lineFlag = CheckLinePreset(final_preset);
this.isLine = this.lineFlag;
this.track = function(e, x, y) this.track = function(e, x, y)
{ {
this.flipH = false;
this.flipV = false;
var real_dist_x = x - this.startX; var real_dist_x = x - this.startX;
var abs_dist_x = Math.abs(real_dist_x); var abs_dist_x = Math.abs(real_dist_x);
var real_dist_y = y - this.startY; var real_dist_y = y - this.startY;
var abs_dist_y = Math.abs(real_dist_y); var abs_dist_y = Math.abs(real_dist_y);
if(this.isLine)
if(!(e.ctrlKey || e.shiftKey))
{ {
if(x < this.startX)
{
this.flipH = true;
}
if(y < this.startY)
{
this.flipV = true;
}
}
if(!(e.ctrlKey || e.shiftKey) || (e.CtrlKey && !e.ShiftKey && this.isLine))
{
this.extX = abs_dist_x >= MIN_SHAPE_SIZE ? abs_dist_x : (this.isLine ? 0 : MIN_SHAPE_SIZE);
this.extY = abs_dist_y >= MIN_SHAPE_SIZE ? abs_dist_y : (this.isLine ? 0 : MIN_SHAPE_SIZE);
if(real_dist_x >= 0) if(real_dist_x >= 0)
{ {
this.x = this.startX; this.x = this.startX;
} }
else else
{ {
this.x = abs_dist_x >= MIN_SHAPE_SIZE ? x : this.startX - MIN_SHAPE_SIZE; this.x = abs_dist_x >= MIN_SHAPE_SIZE ? x : this.startX - this.extX;
} }
if(real_dist_y >= 0) if(real_dist_y >= 0)
...@@ -168,12 +186,8 @@ function NewShapeTrack(drawingObjects, presetGeom, startX, startY) ...@@ -168,12 +186,8 @@ function NewShapeTrack(drawingObjects, presetGeom, startX, startY)
} }
else else
{ {
this.y = abs_dist_y >= MIN_SHAPE_SIZE ? y : this.startY - MIN_SHAPE_SIZE; this.y = abs_dist_y >= MIN_SHAPE_SIZE ? y : this.startY - this.extY;
} }
this.extX = abs_dist_x >= MIN_SHAPE_SIZE ? abs_dist_x : MIN_SHAPE_SIZE;
this.extY = abs_dist_y >= MIN_SHAPE_SIZE ? abs_dist_y : MIN_SHAPE_SIZE;
} }
else if(e.ctrlKey && !e.shiftKey) else if(e.ctrlKey && !e.shiftKey)
{ {
...@@ -261,6 +275,25 @@ function NewShapeTrack(drawingObjects, presetGeom, startX, startY) ...@@ -261,6 +275,25 @@ function NewShapeTrack(drawingObjects, presetGeom, startX, startY)
this.y = this.startY; this.y = this.startY;
else else
this.y = this.startY - this.extY; this.y = this.startY - this.extY;
if(this.isLine)
{
var angle = Math.atan2(real_dist_y, real_dist_x);
if(angle >=0 && angle <= Math.PI/8
|| angle <= 0 && angle >= -Math.PI/8
|| angle >= 7*Math.PI/8 && angle <= Math.PI )
{
this.extY = 0;
this.y = this.startY;
}
else if(angle >= 3*Math.PI/8 && angle <= 5*Math.PI/8
|| angle <= -3*Math.PI/8 && angle >= -5*Math.PI/8)
{
this.extX = 0;
this.x = this.startX;
}
}
} }
else else
{ {
...@@ -320,7 +353,14 @@ function NewShapeTrack(drawingObjects, presetGeom, startX, startY) ...@@ -320,7 +353,14 @@ function NewShapeTrack(drawingObjects, presetGeom, startX, startY)
} }
this.overlayObject.updateExtents(this.extX, this.extY); this.overlayObject.updateExtents(this.extX, this.extY);
this.transform.Reset(); this.transform.Reset();
global_MatrixTransformer.TranslateAppend(this.transform, this.x, this.y); var hc = this.extX * 0.5;
var vc = this.extY * 0.5;
global_MatrixTransformer.TranslateAppend(this.transform, -hc, -vc);
if (this.flipH)
global_MatrixTransformer.ScaleAppend(this.transform, -1, 1);
if (this.flipV)
global_MatrixTransformer.ScaleAppend(this.transform, 1, -1);
global_MatrixTransformer.TranslateAppend(this.transform, this.x + hc, this.y + vc);
}; };
this.ctrlDown = function() this.ctrlDown = function()
...@@ -338,7 +378,7 @@ function NewShapeTrack(drawingObjects, presetGeom, startX, startY) ...@@ -338,7 +378,7 @@ function NewShapeTrack(drawingObjects, presetGeom, startX, startY)
{ {
var shape = new CShape(null, this.drawingObjects); var shape = new CShape(null, this.drawingObjects);
if(this.presetGeom !== "textRect") if(this.presetGeom !== "textRect")
shape.initDefault(this.x, this.y, this.extX, this.extY, false, false, this.finalPreset, this.tailEnd, this.headEnd); shape.initDefault(this.x, this.y, this.extX, this.extY, this.flipH === true, this.flipV === true, this.finalPreset, this.tailEnd, this.headEnd);
else else
shape.initDefaultTextRect(this.x, this.y, this.extX, this.extY, false, false); shape.initDefaultTextRect(this.x, this.y, this.extX, this.extY, false, false);
shape.select(this.drawingObjects.controller); shape.select(this.drawingObjects.controller);
......
...@@ -153,12 +153,12 @@ function ResizeTrackShapeImage(originalObject, cardDirection) ...@@ -153,12 +153,12 @@ function ResizeTrackShapeImage(originalObject, cardDirection)
this.geometry = originalObject.spPr.geometry.createDuplicate(); this.geometry = originalObject.spPr.geometry.createDuplicate();
this.brush = originalObject.brush; this.brush = originalObject.brush;
this.pen = originalObject.pen; this.pen = originalObject.pen;
this.isLine = originalObject.spPr.geometry && originalObject.spPr.geometry.preset === "line";
this.bChangeCoef = this.translatetNumberHandle % 2 === 0 && this.originalFlipH !== this.originalFlipV; this.bChangeCoef = this.translatetNumberHandle % 2 === 0 && this.originalFlipH !== this.originalFlipV;
this.overlayObject = new OverlayObject(this.geometry, this.resizedExtX, this.resizedExtY, this.brush, this.pen, this.transform); this.overlayObject = new OverlayObject(this.geometry, this.resizedExtX, this.resizedExtY, this.brush, this.pen, this.transform);
this.track = function(kd1, kd2, e) this.track = function(kd1, kd2, e)
{ {
if(!e.ctrlKey) if(!e.ctrlKey)
...@@ -167,7 +167,7 @@ function ResizeTrackShapeImage(originalObject, cardDirection) ...@@ -167,7 +167,7 @@ function ResizeTrackShapeImage(originalObject, cardDirection)
this.resizeRelativeCenter(kd1, kd2, e.shiftKey) this.resizeRelativeCenter(kd1, kd2, e.shiftKey)
}; };
this.resize = function(kd1, kd2, shiftKey) this.resize = function(kd1, kd2, ShiftKey)
{ {
var _cos = this.cos; var _cos = this.cos;
var _sin = this.sin; var _sin = this.sin;
...@@ -180,7 +180,7 @@ function ResizeTrackShapeImage(originalObject, cardDirection) ...@@ -180,7 +180,7 @@ function ResizeTrackShapeImage(originalObject, cardDirection)
var _new_used_half_height; var _new_used_half_height;
var _temp; var _temp;
if(shiftKey === true && this.bAspect === true) if(ShiftKey === true && this.bAspect === true)
{ {
var _new_aspect = this.aspect*(Math.abs(kd1/ kd2)); var _new_aspect = this.aspect*(Math.abs(kd1/ kd2));
...@@ -205,9 +205,11 @@ function ResizeTrackShapeImage(originalObject, cardDirection) ...@@ -205,9 +205,11 @@ function ResizeTrackShapeImage(originalObject, cardDirection)
{ {
_real_width = this.usedExtX*kd1; _real_width = this.usedExtX*kd1;
_abs_width = Math.abs(_real_width); _abs_width = Math.abs(_real_width);
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE ? _abs_width : MIN_SHAPE_SIZE; this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE || this.isLine ? _abs_width : MIN_SHAPE_SIZE;
if(_real_width < 0) if(_real_width < 0 )
{
this.resizedflipH = !this.originalFlipH; this.resizedflipH = !this.originalFlipH;
}
else else
this.resizedflipH = this.originalFlipH; this.resizedflipH = this.originalFlipH;
} }
...@@ -220,11 +222,23 @@ function ResizeTrackShapeImage(originalObject, cardDirection) ...@@ -220,11 +222,23 @@ function ResizeTrackShapeImage(originalObject, cardDirection)
_real_height = this.usedExtY*kd2; _real_height = this.usedExtY*kd2;
_abs_height = Math.abs(_real_height); _abs_height = Math.abs(_real_height);
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE ? _abs_height : MIN_SHAPE_SIZE; this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE || this.isLine ? _abs_height : MIN_SHAPE_SIZE;
if(_real_height < 0) if(_real_height < 0 )
{
this.resizedflipV = !this.originalFlipV; this.resizedflipV = !this.originalFlipV;
if(this.isLine && ShiftKey)
{
this.resizedflipH = !this.originalFlipH;
}
}
else else
{
this.resizedflipV = this.originalFlipV; this.resizedflipV = this.originalFlipV;
if(this.isLine && ShiftKey && this.resizedflipH !== this.originalFlipH)
{
this.resizedflipV = !this.originalFlipV;
}
}
_new_resize_half_width = this.resizedExtX*0.5; _new_resize_half_width = this.resizedExtX*0.5;
...@@ -261,8 +275,8 @@ function ResizeTrackShapeImage(originalObject, cardDirection) ...@@ -261,8 +275,8 @@ function ResizeTrackShapeImage(originalObject, cardDirection)
kd1 = _temp; kd1 = _temp;
_real_height = this.usedExtY*kd2; _real_height = this.usedExtY*kd2;
_abs_height = Math.abs(_real_height); _abs_height = Math.abs(_real_height);
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE ? _abs_height : MIN_SHAPE_SIZE; this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE || this.isLine ? _abs_height : MIN_SHAPE_SIZE;
if(_real_height < 0) if(_real_height < 0 )
this.resizedflipV = !this.originalFlipV; this.resizedflipV = !this.originalFlipV;
else else
this.resizedflipV = this.originalFlipV; this.resizedflipV = this.originalFlipV;
...@@ -270,11 +284,23 @@ function ResizeTrackShapeImage(originalObject, cardDirection) ...@@ -270,11 +284,23 @@ function ResizeTrackShapeImage(originalObject, cardDirection)
_real_width = this.usedExtX*kd1; _real_width = this.usedExtX*kd1;
_abs_width = Math.abs(_real_width); _abs_width = Math.abs(_real_width);
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE ? _abs_width : MIN_SHAPE_SIZE; this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE || this.isLine ? _abs_width : MIN_SHAPE_SIZE;
if(_real_width < 0) if(_real_width < 0 )
{
this.resizedflipH = !this.originalFlipH; this.resizedflipH = !this.originalFlipH;
if(this.isLine && ShiftKey)
{
this.resizedflipV = !this.originalFlipV;
}
}
else else
{
this.resizedflipH = this.originalFlipH; this.resizedflipH = this.originalFlipH;
if(this.isLine && ShiftKey && this.resizedflipV !== this.originalFlipV)
{
this.resizedflipH = !this.originalFlipH;
}
}
_new_resize_half_width = this.resizedExtX*0.5; _new_resize_half_width = this.resizedExtX*0.5;
...@@ -310,8 +336,8 @@ function ResizeTrackShapeImage(originalObject, cardDirection) ...@@ -310,8 +336,8 @@ function ResizeTrackShapeImage(originalObject, cardDirection)
{ {
_real_width = this.usedExtX*kd1; _real_width = this.usedExtX*kd1;
_abs_width = Math.abs(_real_width); _abs_width = Math.abs(_real_width);
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE ? _abs_width : MIN_SHAPE_SIZE; this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE || this.isLine ? _abs_width : MIN_SHAPE_SIZE;
if(_real_width < 0) if(_real_width < 0 )
this.resizedflipH = !this.originalFlipH; this.resizedflipH = !this.originalFlipH;
else else
this.resizedflipH = this.originalFlipH; this.resizedflipH = this.originalFlipH;
...@@ -325,11 +351,23 @@ function ResizeTrackShapeImage(originalObject, cardDirection) ...@@ -325,11 +351,23 @@ function ResizeTrackShapeImage(originalObject, cardDirection)
_real_height = this.usedExtY*kd2; _real_height = this.usedExtY*kd2;
_abs_height = Math.abs(_real_height); _abs_height = Math.abs(_real_height);
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE ? _abs_height : MIN_SHAPE_SIZE; this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE || this.isLine ? _abs_height : MIN_SHAPE_SIZE;
if(_real_height < 0) if(_real_height < 0 )
{
this.resizedflipV = !this.originalFlipV; this.resizedflipV = !this.originalFlipV;
if(this.isLine && ShiftKey)
{
this.resizedflipH = !this.originalFlipH;
}
}
else else
{
this.resizedflipV = this.originalFlipV; this.resizedflipV = this.originalFlipV;
if(this.isLine && ShiftKey && this.resizedflipH !== this.originalFlipH)
{
this.resizedflipV = !this.originalFlipV;
}
}
_new_resize_half_width = this.resizedExtX*0.5; _new_resize_half_width = this.resizedExtX*0.5;
_new_resize_half_height = this.resizedExtY*0.5; _new_resize_half_height = this.resizedExtY*0.5;
...@@ -364,8 +402,8 @@ function ResizeTrackShapeImage(originalObject, cardDirection) ...@@ -364,8 +402,8 @@ function ResizeTrackShapeImage(originalObject, cardDirection)
{ {
_real_height = this.usedExtY*kd1; _real_height = this.usedExtY*kd1;
_abs_height = Math.abs(_real_height); _abs_height = Math.abs(_real_height);
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE ? _abs_height : MIN_SHAPE_SIZE; this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE || this.isLine ? _abs_height : MIN_SHAPE_SIZE;
if(_real_height < 0) if(_real_height < 0 )
this.resizedflipV = !this.originalFlipV; this.resizedflipV = !this.originalFlipV;
else else
this.resizedflipV = this.originalFlipV; this.resizedflipV = this.originalFlipV;
...@@ -379,11 +417,23 @@ function ResizeTrackShapeImage(originalObject, cardDirection) ...@@ -379,11 +417,23 @@ function ResizeTrackShapeImage(originalObject, cardDirection)
_real_width = this.usedExtX*kd2; _real_width = this.usedExtX*kd2;
_abs_width = Math.abs(_real_width); _abs_width = Math.abs(_real_width);
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE ? _abs_width : MIN_SHAPE_SIZE; this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE || this.isLine ? _abs_width : MIN_SHAPE_SIZE;
if(_real_width < 0) if(_real_width < 0 )
{
this.resizedflipH = !this.originalFlipH; this.resizedflipH = !this.originalFlipH;
if(this.isLine && ShiftKey)
{
this.resizedflipV = !this.originalFlipV;
}
}
else else
{
this.resizedflipH = this.originalFlipH; this.resizedflipH = this.originalFlipH;
if(this.isLine && ShiftKey && this.resizedflipV !== this.originalFlipV)
{
this.resizedflipH = !this.originalFlipH;
}
}
_new_resize_half_width = this.resizedExtX*0.5; _new_resize_half_width = this.resizedExtX*0.5;
_new_resize_half_height = this.resizedExtY*0.5; _new_resize_half_height = this.resizedExtY*0.5;
...@@ -440,6 +490,11 @@ function ResizeTrackShapeImage(originalObject, cardDirection) ...@@ -440,6 +490,11 @@ function ResizeTrackShapeImage(originalObject, cardDirection)
this.resizeRelativeCenter = function(kd1, kd2, shiftKey) this.resizeRelativeCenter = function(kd1, kd2, shiftKey)
{ {
if(this.isLine)
{
this.resize(kd1, kd2, shiftKey);
return;
}
kd1 = 2*kd1 - 1; kd1 = 2*kd1 - 1;
kd2 = 2*kd2 - 1; kd2 = 2*kd2 - 1;
var _real_height, _real_width; var _real_height, _real_width;
......
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