Commit 369b5c7d 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@60057 954022d7-b5bf-4e40-9824-e11837661b57
parent 45a51875
...@@ -6861,4 +6861,115 @@ function CreateImageDrawingObject(imageUrl, options, drawingObjects) { ...@@ -6861,4 +6861,115 @@ function CreateImageDrawingObject(imageUrl, options, drawingObjects) {
} }
} }
return null; return null;
}
function GetMinSnapDistanceXObject(pointX, arrGrObjects)
{
var min_dx = null;
var ret = null;
for(var i = 0; i < arrGrObjects.length; ++i)
{
var cur_snap_arr_x = arrGrObjects[i].snapArrayX;
var count = cur_snap_arr_x.length;
for(var snap_index = 0; snap_index < count; ++snap_index)
{
var dx = cur_snap_arr_x[snap_index] - pointX;
if(min_dx === null)
{
ret = {dist: dx, pos: cur_snap_arr_x[snap_index]};
min_dx = dx;
}
else
{
if(Math.abs(dx) < Math.abs(min_dx))
{
min_dx = dx;
ret = {dist: dx, pos: cur_snap_arr_x[snap_index]};
}
}
}
}
return ret;
}
function GetMinSnapDistanceYObject(pointY, arrGrObjects)
{
var min_dy = null;
var ret = null;
for(var i = 0; i < arrGrObjects.length; ++i)
{
var cur_snap_arr_y = arrGrObjects[i].snapArrayY;
var count = cur_snap_arr_y.length;
for(var snap_index = 0; snap_index < count; ++snap_index)
{
var dy = cur_snap_arr_y[snap_index] - pointY;
if(min_dy === null)
{
min_dy = dy;
ret = {dist: dy, pos: cur_snap_arr_y[snap_index]};
}
else
{
if(Math.abs(dy) < Math.abs(min_dy))
{
min_dy = dy;
ret = {dist: dy, pos: cur_snap_arr_y[snap_index]};
}
}
}
}
return ret;
}
function GetMinSnapDistanceXObjectByArrays(pointX, snapArrayX)
{
var min_dx = null;
var ret = null;
var cur_snap_arr_x = snapArrayX;
var count = cur_snap_arr_x.length;
for(var snap_index = 0; snap_index < count; ++snap_index)
{
var dx = cur_snap_arr_x[snap_index] - pointX;
if(min_dx === null)
{
ret = {dist: dx, pos: cur_snap_arr_x[snap_index]};
min_dx = dx;
}
else
{
if(Math.abs(dx) < Math.abs(min_dx))
{
min_dx = dx;
ret = {dist: dx, pos: cur_snap_arr_x[snap_index]};
}
}
}
return ret;
}
function GetMinSnapDistanceYObjectByArrays(pointY, snapArrayY)
{
var min_dy = null;
var ret = null;
var cur_snap_arr_y = snapArrayY;
var count = cur_snap_arr_y.length;
for(var snap_index = 0; snap_index < count; ++snap_index)
{
var dy = cur_snap_arr_y[snap_index] - pointY;
if(min_dy === null)
{
min_dy = dy;
ret = {dist: dy, pos: cur_snap_arr_y[snap_index]};
}
else
{
if(Math.abs(dy) < Math.abs(min_dy))
{
min_dy = dy;
ret = {dist: dy, pos: cur_snap_arr_y[snap_index]};
}
}
}
return ret;
} }
\ No newline at end of file
...@@ -1442,6 +1442,13 @@ CGroupShape.prototype = ...@@ -1442,6 +1442,13 @@ CGroupShape.prototype =
calculateSnapArrays: function(snapArrayX, snapArrayY) calculateSnapArrays: function(snapArrayX, snapArrayY)
{ {
if(!Array.isArray(snapArrayX) || !Array.isArray(snapArrayX))
{
snapArrayX = this.snapArrayX;
snapArrayY = this.snapArrayY;
snapArrayX.length = 0;
snapArrayY.length = 0;
}
var sp; var sp;
for(var i = 0; i < this.spTree.length; ++i) for(var i = 0; i < this.spTree.length; ++i)
{ {
......
...@@ -2979,6 +2979,13 @@ CShape.prototype = ...@@ -2979,6 +2979,13 @@ CShape.prototype =
calculateSnapArrays: function(snapArrayX, snapArrayY) calculateSnapArrays: function(snapArrayX, snapArrayY)
{ {
if(!Array.isArray(snapArrayX) || !Array.isArray(snapArrayX))
{
snapArrayX = this.snapArrayX;
snapArrayY = this.snapArrayY;
snapArrayX.length = 0;
snapArrayY.length = 0;
}
var t = this.transform; var t = this.transform;
snapArrayX.push(t.TransformPointX(0, 0)); snapArrayX.push(t.TransformPointX(0, 0));
snapArrayY.push(t.TransformPointY(0, 0)); snapArrayY.push(t.TransformPointY(0, 0));
......
...@@ -759,12 +759,12 @@ MoveState.prototype = ...@@ -759,12 +759,12 @@ MoveState.prototype =
var snap_x = null, snap_y = null; var snap_x = null, snap_y = null;
var snapHorArray = [], snapVerArray = []; var snapHorArray = [], snapVerArray = [];
snapHorArray.push(X_Left_Field); // snapHorArray.push(X_Left_Field);
snapHorArray.push(X_Right_Field); // snapHorArray.push(X_Right_Field);
snapHorArray.push(Page_Width/2); // snapHorArray.push(Page_Width/2);
snapVerArray.push(Y_Top_Field); // snapVerArray.push(Y_Top_Field);
snapVerArray.push(Y_Bottom_Field); // snapVerArray.push(Y_Bottom_Field);
snapVerArray.push(Page_Height/2); // snapVerArray.push(Page_Height/2);
if(result_x === this.startX) if(result_x === this.startX)
{ {
min_dx = 0; min_dx = 0;
...@@ -902,12 +902,11 @@ MoveState.prototype = ...@@ -902,12 +902,11 @@ MoveState.prototype =
} }
if(min_dx === null || Math.abs(min_dx) > SNAP_DISTANCE) if(min_dx === null || Math.abs(min_dx) > SNAP_DISTANCE)
min_dx = 0; min_dx = 0;
else else
{ {
if(isRealNumber(snap_x)) if(isRealNumber(snap_x) && this.drawingObjects.drawingObjects.cSld)
{ {
this.drawingObjects.getDrawingDocument().DrawVerAnchor(pageIndex, snap_x); this.drawingObjects.getDrawingDocument().DrawVerAnchor(pageIndex, snap_x);
} }
...@@ -917,7 +916,7 @@ MoveState.prototype = ...@@ -917,7 +916,7 @@ MoveState.prototype =
min_dy = 0; min_dy = 0;
else else
{ {
if(isRealNumber(snap_y)) if(isRealNumber(snap_y) && this.drawingObjects.drawingObjects.cSld)
{ {
this.drawingObjects.getDrawingDocument().DrawHorAnchor(pageIndex, snap_y); this.drawingObjects.getDrawingDocument().DrawHorAnchor(pageIndex, snap_y);
} }
......
...@@ -252,6 +252,7 @@ CChartSpace.prototype.recalculate = function() ...@@ -252,6 +252,7 @@ CChartSpace.prototype.recalculate = function()
if(this.recalcInfo.recalculateTransform) if(this.recalcInfo.recalculateTransform)
{ {
this.recalculateTransform(); this.recalculateTransform();
this.calculateSnapArrays();
this.rectGeometry.Recalculate(this.extX, this.extY); this.rectGeometry.Recalculate(this.extX, this.extY);
this.recalcInfo.recalculateTransform = false; this.recalcInfo.recalculateTransform = false;
b_transform = true; b_transform = true;
......
...@@ -203,6 +203,7 @@ CGroupShape.prototype.recalculate = function() ...@@ -203,6 +203,7 @@ CGroupShape.prototype.recalculate = function()
if(this.recalcInfo.recalculateTransform) if(this.recalcInfo.recalculateTransform)
{ {
this.recalculateTransform(); this.recalculateTransform();
this.calculateSnapArrays();
this.recalcInfo.recalculateTransform = false; this.recalcInfo.recalculateTransform = false;
} }
if(this.recalcInfo.recalculateArrGraphicObjects) if(this.recalcInfo.recalculateArrGraphicObjects)
......
...@@ -138,6 +138,7 @@ CImageShape.prototype.recalculate = function () ...@@ -138,6 +138,7 @@ CImageShape.prototype.recalculate = function ()
} }
if (this.recalcInfo.recalculateTransform) { if (this.recalcInfo.recalculateTransform) {
this.recalculateTransform(); this.recalculateTransform();
this.calculateSnapArrays();
this.recalcInfo.recalculateTransform = false; this.recalcInfo.recalculateTransform = false;
} }
......
...@@ -342,6 +342,7 @@ CShape.prototype.recalculate = function () ...@@ -342,6 +342,7 @@ CShape.prototype.recalculate = function ()
} }
if (this.recalcInfo.recalculateTransform) { if (this.recalcInfo.recalculateTransform) {
this.recalculateTransform(); this.recalculateTransform();
this.calculateSnapArrays();
this.recalcInfo.recalculateTransform = false; this.recalcInfo.recalculateTransform = false;
} }
......
...@@ -242,6 +242,7 @@ CChartSpace.prototype.recalculate = function() ...@@ -242,6 +242,7 @@ CChartSpace.prototype.recalculate = function()
this.recalculateTransform(); this.recalculateTransform();
this.rectGeometry.Recalculate(this.extX, this.extY); this.rectGeometry.Recalculate(this.extX, this.extY);
this.recalcInfo.recalculateTransform = false; this.recalcInfo.recalculateTransform = false;
this.calculateSnapArrays();
b_transform = true; b_transform = true;
} }
if(this.recalcInfo.recalculateReferences) if(this.recalcInfo.recalculateReferences)
......
...@@ -44,6 +44,7 @@ CGraphicFrame.prototype = ...@@ -44,6 +44,7 @@ CGraphicFrame.prototype =
getBase64Img: CShape.prototype.getBase64Img, getBase64Img: CShape.prototype.getBase64Img,
checkDrawingBaseCoords: CShape.prototype.checkDrawingBaseCoords, checkDrawingBaseCoords: CShape.prototype.checkDrawingBaseCoords,
getSlideIndex: CShape.prototype.getSlideIndex, getSlideIndex: CShape.prototype.getSlideIndex,
calculateSnapArrays: CShape.prototype.calculateSnapArrays,
Is_DrawingShape: function() Is_DrawingShape: function()
{ {
...@@ -353,6 +354,7 @@ CGraphicFrame.prototype = ...@@ -353,6 +354,7 @@ CGraphicFrame.prototype =
if(this.recalcInfo.recalculateTransform) if(this.recalcInfo.recalculateTransform)
{ {
this.recalculateTransform(); this.recalculateTransform();
this.calculateSnapArrays();
this.recalcInfo.recalculateTransform = false; this.recalcInfo.recalculateTransform = false;
this.transformText = this.transform; this.transformText = this.transform;
this.invertTransformText = this.invertTransform; this.invertTransformText = this.invertTransform;
......
...@@ -197,6 +197,7 @@ CGroupShape.prototype.recalculate = function() ...@@ -197,6 +197,7 @@ CGroupShape.prototype.recalculate = function()
if(this.recalcInfo.recalculateTransform) if(this.recalcInfo.recalculateTransform)
{ {
this.recalculateTransform(); this.recalculateTransform();
this.calculateSnapArrays();
this.recalcInfo.recalculateTransform = false; this.recalcInfo.recalculateTransform = false;
} }
if(this.recalcInfo.recalculateArrGraphicObjects) if(this.recalcInfo.recalculateArrGraphicObjects)
......
...@@ -140,6 +140,7 @@ CImageShape.prototype.recalculate = function () ...@@ -140,6 +140,7 @@ CImageShape.prototype.recalculate = function ()
} }
if (this.recalcInfo.recalculateTransform) { if (this.recalcInfo.recalculateTransform) {
this.recalculateTransform(); this.recalculateTransform();
this.calculateSnapArrays();
this.recalcInfo.recalculateTransform = false; this.recalcInfo.recalculateTransform = false;
} }
......
...@@ -2127,113 +2127,3 @@ AddPolyLine2State3.prototype = ...@@ -2127,113 +2127,3 @@ AddPolyLine2State3.prototype =
} }
} }
}; };
function GetMinSnapDistanceXObject(pointX, arrGrObjects)
{
var min_dx = null;
var ret = null;
for(var i = 0; i < arrGrObjects.length; ++i)
{
var cur_snap_arr_x = arrGrObjects[i].snapArrayX;
var count = cur_snap_arr_x.length;
for(var snap_index = 0; snap_index < count; ++snap_index)
{
var dx = cur_snap_arr_x[snap_index] - pointX;
if(min_dx === null)
{
ret = {dist: dx, pos: cur_snap_arr_x[snap_index]};
min_dx = dx;
}
else
{
if(Math.abs(dx) < Math.abs(min_dx))
{
min_dx = dx;
ret = {dist: dx, pos: cur_snap_arr_x[snap_index]};
}
}
}
}
return ret;
}
function GetMinSnapDistanceYObject(pointY, arrGrObjects)
{
var min_dy = null;
var ret = null;
for(var i = 0; i < arrGrObjects.length; ++i)
{
var cur_snap_arr_y = arrGrObjects[i].snapArrayY;
var count = cur_snap_arr_y.length;
for(var snap_index = 0; snap_index < count; ++snap_index)
{
var dy = cur_snap_arr_y[snap_index] - pointY;
if(min_dy === null)
{
min_dy = dy;
ret = {dist: dy, pos: cur_snap_arr_y[snap_index]};
}
else
{
if(Math.abs(dy) < Math.abs(min_dy))
{
min_dy = dy;
ret = {dist: dy, pos: cur_snap_arr_y[snap_index]};
}
}
}
}
return ret;
}
function GetMinSnapDistanceXObjectByArrays(pointX, snapArrayX)
{
var min_dx = null;
var ret = null;
var cur_snap_arr_x = snapArrayX;
var count = cur_snap_arr_x.length;
for(var snap_index = 0; snap_index < count; ++snap_index)
{
var dx = cur_snap_arr_x[snap_index] - pointX;
if(min_dx === null)
{
ret = {dist: dx, pos: cur_snap_arr_x[snap_index]};
min_dx = dx;
}
else
{
if(Math.abs(dx) < Math.abs(min_dx))
{
min_dx = dx;
ret = {dist: dx, pos: cur_snap_arr_x[snap_index]};
}
}
}
return ret;
}
function GetMinSnapDistanceYObjectByArrays(pointY, snapArrayY)
{
var min_dy = null;
var ret = null;
var cur_snap_arr_y = snapArrayY;
var count = cur_snap_arr_y.length;
for(var snap_index = 0; snap_index < count; ++snap_index)
{
var dy = cur_snap_arr_y[snap_index] - pointY;
if(min_dy === null)
{
min_dy = dy;
ret = {dist: dy, pos: cur_snap_arr_y[snap_index]};
}
else
{
if(Math.abs(dy) < Math.abs(min_dy))
{
min_dy = dy;
ret = {dist: dy, pos: cur_snap_arr_y[snap_index]};
}
}
}
return ret;
}
\ No newline at end of file
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