Commit 4b2366bd authored by Sergey.Luzyanin's avatar Sergey.Luzyanin

git-svn-id:...

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@47522 954022d7-b5bf-4e40-9824-e11837661b57
parent 1ced0dd9
......@@ -71,9 +71,19 @@ DrawingObjectsController.prototype =
this.arrTrackObjects[i].track(angle, e);
},
trackNewShape: function(e, x, y)
{
this.arrTrackObjects[0].track(e, x, y);
},
trackEnd: function()
{
for(var i = 0; i < this.arrTrackObjects.length; ++i)
this.arrTrackObjects[i].trackEnd();
},
startTrackNewShape: function(presetGeom)
{
this.changeCurrentState(new StartTrackNewShapeState(this, this.drawingObjects, presetGeom));
}
};
\ No newline at end of file
......@@ -52,5 +52,43 @@ CGroupShape.prototypr =
if(!isRealObject(this.group))
return this;
return this.group.getMainGroup();
},
getResultScaleCoefficients: function()
{
var cx, cy;
if(this.spPr.xfrm.chExtX > 0)
cx = this.spPr.xfrm.extX/this.spPr.xfrm.chExtX;
else
cx = 1;
if(this.spPr.xfrm.chExtY > 0)
cy = this.spPr.xfrm.extY/this.spPr.xfrm.chExtY;
else
cy = 1;
if(isRealObject(this.group))
{
var group_scale_coefficients = this.group.getResultScaleCoefficients();
cx *= group_scale_coefficients.cx;
cy *= group_scale_coefficients.cy;
}
return {cx: cx, cy: cy};
},
getFullFlipH: function()
{
if(!isRealObject(this.group))
return this.flipH;
else
return this.group.getFullFlipH() ? !this.flipH : this.flipH;
},
getFullFlipV: function()
{
if(!isRealObject(this.group))
return this.flipH;
else
return this.group.getFullFlipH() ? !this.flipH : this.flipH;
}
};
\ No newline at end of file
......@@ -72,7 +72,6 @@ CImage.prototype =
this.recalculate();
},
setPresetGeometry: function(preset)
{
this.spPr.geometry = CreateGeometry(preset);
......@@ -127,11 +126,11 @@ CImage.prototype =
}
else
{
//TODO
this.x = xfrm.offX;
this.y = xfrm.offY;
this.extX = xfrm.extX;
this.extY = xfrm.extY;
var scale_scale_coefficients = this.group.getResultScaleCoefficients();
this.x = scale_scale_coefficients.cx*(xfrm.offX - this.group.xfrm.chOffX);
this.y = scale_scale_coefficients.cy*(xfrm.offY - this.group.xfrm.chOffY);
this.extX = scale_scale_coefficients.cx*xfrm.extX;
this.extY = scale_scale_coefficients.cy*xfrm.extY;
this.rot = isRealNumber(xfrm.rot) ? xfrm.rot : 0;
this.flipH = xfrm.flipH === true;
this.flipV = xfrm.flipV === true;
......@@ -170,14 +169,75 @@ CImage.prototype =
getCardDirectionByNum: function(num)
{
//TODO
return CARD_DIRECTION_N;
var num_north = this.getNumByCardDirection(CARD_DIRECTION_N);
var full_flip_h = this.getFullFlipH();
var full_flip_v = this.getFullFlipV();
var same_flip = !full_flip_h && !full_flip_v || full_flip_h && full_flip_v;
if(same_flip)
return ((num - num_north) + CARD_DIRECTION_N + 8)%8;
return (CARD_DIRECTION_N - (num - num_north)+ 8)%8;
},
getNumByCardDirection: function(cardDirection)
{
//TODO
return 1;
var hc = this.extX*0.5;
var vc = this.extY*0.5;
var transform = this.getTransform();
var y1, y3, y5, y7;
y1 = transform.TransformPointY(hc, 0);
y3 = transform.TransformPointY(this.extX, vc);
y5 = transform.TransformPointY(hc, this.extY);
y7 = transform.TransformPointY(0, vc);
var north_number;
var full_flip_h = this.getFullFlipH();
var full_flip_v = this.getFullFlipV();
switch(Math.min(y1, y3, y5, y7))
{
case y1:
{
north_number = !full_flip_v ? 1 : 5;
break;
}
case y3:
{
north_number = !full_flip_h ? 3 : 7;
break;
}
case y5:
{
north_number = !full_flip_v ? 5 : 1;
break;
}
default:
{
north_number = !full_flip_h ? 7 : 3;
break;
}
}
var same_flip = !full_flip_h && !full_flip_v || full_flip_h && full_flip_v;
if(same_flip)
return (north_number + cardDirection)%8;
return (north_number - cardDirection + 8)%8;
},
getFullFlipH: function()
{
if(!isRealObject(this.group))
return this.flipH;
else
return this.group.getFullFlipH() ? !this.flipH : this.flipH;
},
getFullFlipV: function()
{
if(!isRealObject(this.group))
return this.flipH;
else
return this.group.getFullFlipH() ? !this.flipH : this.flipH;
},
setGroup: function(group)
......
......@@ -110,8 +110,19 @@ CShape.prototype =
recalculateBrush: function()
{
},
draw: function(graphics)
{
graphics.SetIntegerGrid(false);
graphics.transform3(this.transform, false);
var shape_drawer = new CShapeDrawer();
shape_drawer.fromShape(this, graphics);
shape_drawer.draw(this.spPr.geometry);
graphics.reset();
graphics.SetIntegerGrid(true);
},
getTransform: function()
{
......@@ -129,10 +140,27 @@ CShape.prototype =
getCardDirectionByNum: function(num)
{
//TODO
return CARD_DIRECTION_N;
},
getFullFlipH: function()
{
if(!isRealObject(this.group))
return this.flipH;
else
return this.group.getFullFlipH() ? !this.flipH : this.flipH;
},
getFullFlipV: function()
{
if(!isRealObject(this.group))
return this.flipH;
else
return this.group.getFullFlipH() ? !this.flipH : this.flipH;
},
getNumByCardDirection: function(cardDirection)
{
//TODO
......
......@@ -11,7 +11,9 @@ var STATES_ID_PRE_ROTATE = 0x01;
var STATES_ID_ROTATE = 0x02;
var STATES_ID_PRE_RESIZE = 0x03;
var STATES_ID_RESIZE = 0x04;
var STATES_ID_START_TRACK_NEW_SHAPE = 0x05;
var STATES_ID_BEGIN_TRACK_NEW_SHAPE = 0x06;
var STATES_ID_TRACK_NEW_SHAPE = 0x07;
function NullState(drawingObjectsController, drawingObjects)
{
......@@ -174,4 +176,76 @@ function ResizeState(drawingObjectsController, drawingObjects, majorObject, card
this.drawingObjectsController.trackEnd();
this.drawingObjectsController.changeCurrentState(new NullState(this.drawingObjectsController, this.drawingObjects));
}
}
\ No newline at end of file
}
function StartTrackNewShapeState(drawingObjectsController, drawingObjects, presetGeom)
{
this.id = STATES_ID_START_TRACK_NEW_SHAPE;
this.drawingObjectsController = drawingObjectsController;
this.drawingObjects = drawingObjects;
this.presetGeom = presetGeom;
this.onMouseDown = function(e, x, y)
{
this.drawingObjectsController.changeCurrentState(new BeginTrackNewShapeState(this.drawingObjectsController, this.drawingObjects, this.presetGeom, x, y));
};
this.onMouseMove = function(e, x, y)
{
};
this.onMouseUp = function(e, x, y)
{
//TODO
}
}
function BeginTrackNewShapeState(drawingObjectsController, drawingObjects, presetGeom, startX, startY)
{
this.id = STATES_ID_BEGIN_TRACK_NEW_SHAPE;
this.drawingObjectsController = drawingObjectsController;
this.drawingObjects = drawingObjects;
this.presetGeom = presetGeom;
this.startX = startX;
this.startY = startY;
this.onMouseDown = function(e, x, y)
{
};
this.onMouseMove = function(e, x, y)
{
this.drawingObjectsController.addTrackObject(new NewShapeTrack(this.drawingObjects, this.presetGeom, this.startX, this.startY));
this.drawingObjectsController.trackNewShape(e, x, y);
this.drawingObjectsController.changeCurrentState(new TrackNewShapeState(this.drawingObjectsController, this.drawingObjects));
};
this.onMouseUp = function(e, x, y)
{
this.drawingObjectsController.changeCurrentState(new NullState(this.drawingObjectsController, this.drawingObjects));
}
}
function TrackNewShapeState(drawingObjectsController, drawingObjects)
{
this.id = STATES_ID_TRACK_NEW_SHAPE;
this.drawingObjectsController = drawingObjectsController;
this.drawingObjects = drawingObjects;
this.onMouseDown = function(e, x, y)
{
};
this.onMouseMove = function(e, x, y)
{
this.drawingObjectsController.trackNewShape(e, x, y);
};
this.onMouseUp = function(e, x, y)
{
this.drawingObjectsController.changeCurrentState(new NullState(this.drawingObjectsController, this.drawingObjects));
}
}
/**
* Created with JetBrains WebStorm.
* User: Sergey.Luzyanin
* Date: 6/28/13
* Time: 11:18 AM
* To change this template use File | Settings | File Templates.
*/
function NewShapeTrack(drawingObjects, presetGeom, startX, startY)
{
this.drawingOjects = drawingObjects;
this.presetGeom = presetGeom;
this.startX = startX;
this.startY = startY;
this.x = null;
this.y = null;
this.extX = null;
this.extY = null;
this.transform = new CMatrix();
var geometry = CreateGeometry(presetGeom);
geometry.init(5, 5);
var brush = new CUniFill();
brush.fill = new CSolidFill();
brush.fill.color.color = new CRGBColor();
brush.fill.color.color.RGBA = {R:155, G:255, B:255, A:255};
var pen = new CLn();
pen.w = 38100;
pen.Fill = new CUniFill();
pen.Fill.fill = new CSolidFill();
pen.Fill.fill.color.color = new CRGBColor();
pen.Fill.fill.color.color.RGBA = {R:155, G:255, B:0, A:255};
this.overlayObject = new OverlayObject(geometry, 5, 5, brush, pen, this.transform);
this.track = function(e, x, y)
{
var _finished_x = x, _finished_y = 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(_real_dist_x >= 0)
{
this.x = this.startX;
}
else
{
this.x = _abs_dist_x >= MIN_SHAPE_SIZE ? x : this.startX - MIN_SHAPE_SIZE;
}
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.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.overlayObject.updateExtents(this.extX, this.extY);
this.transform.Reset();
global_MatrixTransformer.TranslateAppend(this.transform, this.x, this.y);
}
};
this.draw = function(overlay)
{
this.overlayObject.draw(overlay);
};
this.trackEnd = function()
{
};
}
\ No newline at end of file
......@@ -34,6 +34,7 @@ function OverlayObject(geometry, extX, extY, brush, pen, transform)
{
this.ext.cx = extX;
this.ext.cy = extY;
this.geometry.Recalculate(extX, extY);
};
this.draw = function(overlay)
......
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