Commit 893d1574 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@47607 954022d7-b5bf-4e40-9824-e11837661b57
parent a26804be
...@@ -78,6 +78,11 @@ DrawingObjectsController.prototype = ...@@ -78,6 +78,11 @@ DrawingObjectsController.prototype =
this.clearPreTrackObjects(); this.clearPreTrackObjects();
}, },
getTrackObjects: function()
{
return this.arrTrackObjects;
},
rotateTrackObjects: function(angle, e) rotateTrackObjects: function(angle, e)
{ {
for(var i = 0; i < this.arrTrackObjects.length; ++i) for(var i = 0; i < this.arrTrackObjects.length; ++i)
...@@ -114,6 +119,57 @@ DrawingObjectsController.prototype = ...@@ -114,6 +119,57 @@ DrawingObjectsController.prototype =
this.drawingObjects.showDrawingObjects(true); this.drawingObjects.showDrawingObjects(true);
}, },
createGroup: function(drawingBase)
{
var selected_objects = this.selectedObjects;
var grouped_objects = [];
for(var i = 0; i < selected_objects.length; ++i)
{
if(selected_objects[i].canGroup())
{
grouped_objects.push(selected_objects[i]);
}
}
if(grouped_objects.length < 2)
return null;
var max_x, min_x, max_y, min_y;
var bounds = grouped_objects[0].getBoundsInGroup();
max_x = bounds.maxX;
max_y = bounds.maxY;
min_x = bounds.minX;
min_y = bounds.minY;
for(i = 0; i < grouped_objects.length; ++i)
{
bounds = grouped_objects[i].getBoundsInGroup();
if(max_x < bounds.maxX)
max_x = bounds.maxX;
if(max_y < bounds.maxY)
max_y = bounds.maxY;
if(min_x > bounds.minX)
min_x = bounds.minX;
if(min_y > bounds.minY)
min_y = bounds.minY;
}
var group = new CGroupShape(drawingBase, this.drawingObjects);
for(i = 0; i < grouped_objects.length; ++i)
{
group.addToSpTree(grouped_objects[i]);
}
},
canGroup: function()
{
return this.selectedObjects.length > 1;//TODO: сделать нормальную проверку
},
canUnGroup: function()
{
return false;
},
startTrackNewShape: function(presetGeom) startTrackNewShape: function(presetGeom)
{ {
this.changeCurrentState(new StartTrackNewShapeState(this, this.drawingObjects, presetGeom)); this.changeCurrentState(new StartTrackNewShapeState(this, this.drawingObjects, presetGeom));
......
...@@ -5,9 +5,10 @@ ...@@ -5,9 +5,10 @@
* Time: 12:06 PM * Time: 12:06 PM
* To change this template use File | Settings | File Templates. * To change this template use File | Settings | File Templates.
*/ */
function CGroupShape(drawingBase) function CGroupShape(drawingBase, drawingObjects)
{ {
this.drawingBase = drawingBase; this.drawingBase = drawingBase;
this.drawingObjects = drawingObjects;
this.nvSpPr = null; this.nvSpPr = null;
this.spPr = new CSpPr(); this.spPr = new CSpPr();
...@@ -87,6 +88,12 @@ CGroupShape.prototypr = ...@@ -87,6 +88,12 @@ CGroupShape.prototypr =
this.group = group; this.group = group;
}, },
addToSpTree: function(grObject)
{
this.spTree.push(grObject);
this.recalcInfo.recalculateArrGraphicObjects = true;
},
getMainGroup: function() getMainGroup: function()
{ {
if(!isRealObject(this.group)) if(!isRealObject(this.group))
...@@ -131,6 +138,11 @@ CGroupShape.prototypr = ...@@ -131,6 +138,11 @@ CGroupShape.prototypr =
return this.group.getFullFlipH() ? !this.flipH : this.flipH; return this.group.getFullFlipH() ? !this.flipH : this.flipH;
}, },
getFullRotate: function()
{
return !isRealObject(this.group) ? this.rot : this.rot + this.group.getFullRotate();
},
getArrGraphicObjects: function() getArrGraphicObjects: function()
{ {
if(this.recalcInfo.recalculateArrGraphicObjects) if(this.recalcInfo.recalculateArrGraphicObjects)
...@@ -200,6 +212,11 @@ CGroupShape.prototypr = ...@@ -200,6 +212,11 @@ CGroupShape.prototypr =
return true;//TODO return true;//TODO
}, },
canGroup: function()
{
return true;//TODO
},
hitInBoundingRect: function(x, y) hitInBoundingRect: function(x, y)
{ {
var invert_transform = this.getInvertTransform(); var invert_transform = this.getInvertTransform();
......
...@@ -421,6 +421,11 @@ CImage.prototype = ...@@ -421,6 +421,11 @@ CImage.prototype =
return true;//TODO return true;//TODO
}, },
canGroup: function()
{
return true;//TODO
},
createRotateTrack: function() createRotateTrack: function()
{ {
return new RotateTrackShapeImage(this); return new RotateTrackShapeImage(this);
...@@ -487,6 +492,11 @@ CImage.prototype = ...@@ -487,6 +492,11 @@ CImage.prototype =
return {kd1: 1, kd2: 1}; return {kd1: 1, kd2: 1};
}, },
getFullRotate: function()
{
return !isRealObject(this.group) ? this.rot : this.rot + this.group.getFullRotate();
},
drawAdjustments: function(drawingDocument) drawAdjustments: function(drawingDocument)
{ {
......
...@@ -107,7 +107,7 @@ CShape.prototype = ...@@ -107,7 +107,7 @@ CShape.prototype =
updateDrawingBaseCoordinates: function() updateDrawingBaseCoordinates: function()
{ {
if(isRealObject(this.drawingBase)) if(isRealObject(this.drawingBase))
this.drawingBase.setGraphicObjectCoords(); this.drawingBase.setGraphicObjectCoords()
}, },
setExtents: function(extX, extY) setExtents: function(extX, extY)
...@@ -367,8 +367,7 @@ CShape.prototype = ...@@ -367,8 +367,7 @@ CShape.prototype =
{ {
if(!isRealObject(this.group)) if(!isRealObject(this.group))
return this.flipH; return this.flipH;
else return this.group.getFullFlipH() ? !this.flipH : this.flipH;
return this.group.getFullFlipH() ? !this.flipH : this.flipH;
}, },
...@@ -376,8 +375,7 @@ CShape.prototype = ...@@ -376,8 +375,7 @@ CShape.prototype =
{ {
if(!isRealObject(this.group)) if(!isRealObject(this.group))
return this.flipH; return this.flipH;
else return this.group.getFullFlipH() ? !this.flipH : this.flipH;
return this.group.getFullFlipH() ? !this.flipH : this.flipH;
}, },
getAspect: function(num) getAspect: function(num)
...@@ -387,6 +385,30 @@ CShape.prototype = ...@@ -387,6 +385,30 @@ CShape.prototype =
return num === 0 || num === 4 ? _tmp_x/_tmp_y : _tmp_y/_tmp_x; return num === 0 || num === 4 ? _tmp_x/_tmp_y : _tmp_y/_tmp_x;
}, },
getFullRotate: function()
{
return !isRealObject(this.group) ? this.rot : this.rot + this.group.getFullRotate();
},
getBoundsInGroup: function()
{
var r = this.rot;
if((r >= 0 && r < Math.PI*0.25)
|| (r > 3*Math.PI*0.25 && r < 5*Math.PI*0.25)
|| (r > 7*Math.PI*0.25 && r < 2*Math.PI))
{
return {minX: this.x, minY: this.y, maxX: this.x + this.extX, maxY: this.y + this.extY};
}
else
{
var hc = this.extX*0.5;
var vc = this.extY*0.5;
var xc = this.x + hc;
var yc = this.y + vc;
return {minX: xc - vc, minY: yc - hc, maxX: xc + vc, maxY: yc + hc};
}
},
getCardDirectionByNum: function(num) getCardDirectionByNum: function(num)
{ {
var num_north = this.getNumByCardDirection(CARD_DIRECTION_N); var num_north = this.getNumByCardDirection(CARD_DIRECTION_N);
...@@ -497,6 +519,42 @@ CShape.prototype = ...@@ -497,6 +519,42 @@ CShape.prototype =
}, },
getRectBounds: function()
{
var transform = this.getTransform();
var w = this.extX;
var h = this.extY;
var rect_points = [{x:0, y:0}, {x: w, y: 0}, {x: w, y: h}, {x: 0, y: h}];
var min_x, max_x, min_y, max_y;
min_x = transform.TransformPointX(rect_points[0].x, rect_points[0].y);
min_y = transform.TransformPointY(rect_points[0].x, rect_points[0].y);
max_x = min_x;
max_y = min_y;
var cur_x, cur_y;
for(var i = 1; i < 4; ++i)
{
cur_x = transform.TransformPointX(rect_points[i].x, rect_points[i].y);
cur_y = transform.TransformPointY(rect_points[i].x, rect_points[i].y);
if(cur_x < min_x)
min_x = cur_x;
if(cur_x > max_x)
max_x = cur_x;
if(cur_y < min_y)
min_y = cur_y;
if(cur_y > max_y)
max_y = cur_y;
}
return {minX: min_x, maxX: max_x, minY: min_y, maxY: max_y};
},
getRectForGrouping: function()
{
},
transformPointRelativeShape: function(x, y) transformPointRelativeShape: function(x, y)
{ {
...@@ -653,6 +711,11 @@ CShape.prototype = ...@@ -653,6 +711,11 @@ CShape.prototype =
return true;//TODO return true;//TODO
}, },
canGroup: function()
{
return true;//TODO
},
createRotateTrack: function() createRotateTrack: function()
{ {
return new RotateTrackShapeImage(this); return new RotateTrackShapeImage(this);
......
...@@ -343,7 +343,26 @@ function PreMoveState(drawingObjectsController, drawingObjects, startX, startY, ...@@ -343,7 +343,26 @@ function PreMoveState(drawingObjectsController, drawingObjects, startX, startY,
this.onMouseMove = function(e, x, y) this.onMouseMove = function(e, x, y)
{ {
this.drawingObjectsController.swapTrackObjects(); this.drawingObjectsController.swapTrackObjects();
this.drawingObjectsController.changeCurrentState(new MoveState(this.drawingObjectsController, this.drawingObjects, this.startX, this.startY)) var track_objects = this.drawingObjectsController.getTrackObjects();
var max_x, min_x, max_y, min_y;
var cur_rect_bounds = track_objects[0].getOriginalBoundsRect();
max_x = cur_rect_bounds.maxX;
min_x = cur_rect_bounds.minX;
max_y = cur_rect_bounds.maxY;
min_y = cur_rect_bounds.minY;
for(var i = 0; i < track_objects.length; ++i)
{
cur_rect_bounds = track_objects[i].getOriginalBoundsRect();
if(max_x < cur_rect_bounds.maxX)
max_x = cur_rect_bounds.maxX;
if(min_x > cur_rect_bounds.minX)
min_x = cur_rect_bounds.minX;
if(max_y < cur_rect_bounds.maxY)
max_y = cur_rect_bounds.maxY;
if(min_y > cur_rect_bounds.minY)
min_y = cur_rect_bounds.minY;
}
this.drawingObjectsController.changeCurrentState(new MoveState(this.drawingObjectsController, this.drawingObjects, this.startX, this.startY, min_x, min_y, max_x - min_x, max_y - min_y));
}; };
this.onMouseUp = function(e, x, y) this.onMouseUp = function(e, x, y)
...@@ -353,13 +372,17 @@ function PreMoveState(drawingObjectsController, drawingObjects, startX, startY, ...@@ -353,13 +372,17 @@ function PreMoveState(drawingObjectsController, drawingObjects, startX, startY,
} }
} }
function MoveState(drawingObjectsController, drawingObjects, startX, startY) function MoveState(drawingObjectsController, drawingObjects, startX, startY, rectX, rectY, rectW, rectH)
{ {
this.id = STATES_ID_MOVE; this.id = STATES_ID_MOVE;
this.drawingObjectsController = drawingObjectsController; this.drawingObjectsController = drawingObjectsController;
this.drawingObjects = drawingObjects; this.drawingObjects = drawingObjects;
this.startX = startX; this.startX = startX;
this.startY = startY; this.startY = startY;
this.rectX = rectX;
this.rectY = rectY;
this.rectW = rectW;
this.rectH = rectH;
this.onMouseDown = function(e, x, y) this.onMouseDown = function(e, x, y)
{ {
...@@ -367,8 +390,13 @@ function MoveState(drawingObjectsController, drawingObjects, startX, startY) ...@@ -367,8 +390,13 @@ function MoveState(drawingObjectsController, drawingObjects, startX, startY)
this.onMouseMove = function(e, x, y) this.onMouseMove = function(e, x, y)
{ {
this.drawingObjectsController.trackMoveObjects(x - this.startX, y - this.startY); var dx = x - this.startX;
this.drawingObjects.showOverlayGraphicObjects(); var dy = y - this.startY;
if(this.drawingObjects.checkGraphicObjectPosition(this.rectX + dx, this.rectY + dy, this.rectW, this.rectH))
{
this.drawingObjectsController.trackMoveObjects(dx, dy);
this.drawingObjects.showOverlayGraphicObjects();
}
}; };
this.onMouseUp = function(e, x, y) this.onMouseUp = function(e, x, y)
......
...@@ -14,6 +14,12 @@ function MoveShapeImageTrack(originalObject) ...@@ -14,6 +14,12 @@ function MoveShapeImageTrack(originalObject)
this.y = null; this.y = null;
this.overlayObject = new OverlayObject(this.originalObject.spPr.geometry, this.originalObject.extX, this.originalObject.extY, this.originalObject.brush, this.originalObject.pen, this.transform); this.overlayObject = new OverlayObject(this.originalObject.spPr.geometry, this.originalObject.extX, this.originalObject.extY, this.originalObject.brush, this.originalObject.pen, this.transform);
this.getOriginalBoundsRect = function()
{
return this.originalObject.getRectBounds();
};
this.track = function(dx, dy) this.track = function(dx, dy)
{ {
var original = this.originalObject; var original = this.originalObject;
......
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