Commit 35e9fd01 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@47580 954022d7-b5bf-4e40-9824-e11837661b57
parent 3776963e
......@@ -48,41 +48,189 @@ function NewShapeTrack(drawingObjects, presetGeom, startX, startY)
this.track = function(e, x, y)
{
var _finished_x = x, _finished_y = y;
var real_dist_x = x - this.startX;
var abs_dist_x = Math.abs(real_dist_x);
var real_dist_y = y - this.startY;
var abs_dist_y = Math.abs(real_dist_y);
var _real_dist_x = _finished_x - this.startX;
var _abs_dist_x = Math.abs(_real_dist_x);
var _real_dist_y = _finished_y - this.startY;
var _abs_dist_y = Math.abs(_real_dist_y);
//if( (!ctrlKey && !shiftKey) )
if(!(e.ctrlKey || e.shiftKey))
{
if(_real_dist_x >= 0)
if(real_dist_x >= 0)
{
this.x = this.startX;
}
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 - MIN_SHAPE_SIZE;
}
if(_real_dist_y >= 0)
if(real_dist_y >= 0)
{
this.y = this.startY;
}
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 - MIN_SHAPE_SIZE;
}
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;
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)
{
if(abs_dist_x >= MIN_SHAPE_SIZE_DIV2)
{
this.x = this.startX - abs_dist_x;
this.extX = 2*abs_dist_x;
}
else
{
this.x = this.startX - MIN_SHAPE_SIZE_DIV2;
this.extX = MIN_SHAPE_SIZE;
}
if(abs_dist_y >= MIN_SHAPE_SIZE_DIV2)
{
this.y = this.startY - abs_dist_y;
this.extY = 2*abs_dist_y;
}
else
{
this.y = this.startY - MIN_SHAPE_SIZE_DIV2;
this.extY = MIN_SHAPE_SIZE;
}
}
else if(!e.ctrlKey && e.shiftKey)
{
var new_width, new_height;
var prop_coefficient = (typeof SHAPE_ASPECTS[this.presetGeom] === "number" ? SHAPE_ASPECTS[this.presetGeom] : 1);
if(abs_dist_y === 0)
{
new_width = abs_dist_x > MIN_SHAPE_SIZE ? abs_dist_x : MIN_SHAPE_SIZE;
new_height = abs_dist_x/prop_coefficient;
}
else
{
var new_aspect = abs_dist_x/abs_dist_y;
if (new_aspect >= prop_coefficient)
{
new_width = abs_dist_x;
new_height = abs_dist_x/prop_coefficient;
}
else
{
new_height = abs_dist_y;
new_width = abs_dist_y*prop_coefficient;
}
}
if(new_width < MIN_SHAPE_SIZE || new_height < MIN_SHAPE_SIZE)
{
var k_wh = new_width/new_height;
if(new_height < MIN_SHAPE_SIZE && new_width < MIN_SHAPE_SIZE)
{
if(new_height < new_width)
{
new_height = MIN_SHAPE_SIZE;
new_width = new_height*k_wh;
}
else
{
new_width = MIN_SHAPE_SIZE;
new_height = new_width/k_wh;
}
}
else if(new_height < MIN_SHAPE_SIZE)
{
new_height = MIN_SHAPE_SIZE;
new_width = new_height*k_wh;
}
else
{
new_width = MIN_SHAPE_SIZE;
new_height = new_width/k_wh;
}
}
this.extX = new_width;
this.extY = new_height;
if(real_dist_x >= 0)
this.x = this.startX;
else
this.x = this.startX - this.extX;
if(real_dist_y >= 0)
this.y = this.startY;
else
this.y = this.startY - this.extY;
}
else
{
var new_width, new_height;
var prop_coefficient = (typeof SHAPE_ASPECTS[this.presetGeom] === "number" ? SHAPE_ASPECTS[this.presetGeom] : 1);
if(abs_dist_y === 0)
{
new_width = abs_dist_x > MIN_SHAPE_SIZE_DIV2 ? abs_dist_x*2 : MIN_SHAPE_SIZE;
new_height = new_width/prop_coefficient;
}
else
{
var new_aspect = abs_dist_x/abs_dist_y;
if (new_aspect >= prop_coefficient)
{
new_width = abs_dist_x*2;
new_height = new_width/prop_coefficient;
}
else
{
new_height = abs_dist_y*2;
new_width = new_height*prop_coefficient;
}
}
if(new_width < MIN_SHAPE_SIZE || new_height < MIN_SHAPE_SIZE)
{
var k_wh = new_width/new_height;
if(new_height < MIN_SHAPE_SIZE && new_width < MIN_SHAPE_SIZE)
{
if(new_height < new_width)
{
new_height = MIN_SHAPE_SIZE;
new_width = new_height*k_wh;
}
else
{
new_width = MIN_SHAPE_SIZE;
new_height = new_width/k_wh;
}
}
else if(new_height < MIN_SHAPE_SIZE)
{
new_height = MIN_SHAPE_SIZE;
new_width = new_height*k_wh;
}
else
{
new_width = MIN_SHAPE_SIZE;
new_height = new_width/k_wh;
}
}
this.extX = new_width;
this.extY = new_height;
this.x = this.startX - this.extX*0.5;
this.y = this.startY - this.extY*0.5;
}
this.overlayObject.updateExtents(this.extX, this.extY);
this.transform.Reset();
global_MatrixTransformer.TranslateAppend(this.transform, this.x, this.y);
}
};
this.ctrlDown = function()
{};
this.shiftDown = function()
{};
this.draw = function(overlay)
{
this.overlayObject.draw(overlay);
......
......@@ -138,7 +138,7 @@ function ResizeTrackShapeImage(originalObject, cardDirection)
this.centerPointX = originalObject.x + _half_width;
this.centerPointY = originalObject.y + _half_height;
this.lineFlag = originalObject.checkLine();
//this.lineFlag = originalObject.checkLine();
this.originalExtX = originalObject.absExtX;
this.originalExtY = originalObject.absExtY;
......
......@@ -7,9 +7,6 @@
*/
var MIN_SHAPE_SIZE = 1.27;//размер меньше которого нельзя уменшить автофигуру или картинку по горизонтали или вертикали
var MIN_SHAPE_SIZE_DIV2 = MIN_SHAPE_SIZE/2.0;
var MIN_ANGLE = 0.07;
function OverlayObject(geometry, extX, extY, brush, pen, transform)
//({check_bounds: function(){},brush: this.originalShape.brush, pen: this.originalShape.pen, ext:{cx:this.originalShape.absExtX, cy:this.originalShape.absExtY}, geometry: this.geometry, TransformMatrix: this.originalShape.transform})
......
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