Commit 7f121523 authored by Anna.Pavlova's avatar Anna.Pavlova Committed by Alexander.Trofimov

1. тестовая версия center~> baseline

getCenter() -> getAscent()
degree
accent
matrix
bar
groupCharacter
limit
2. Поправила для CDegree выравнивание итераторов по baseline (recalculateSize, setPosition, findDisposition)


git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@53351 954022d7-b5bf-4e40-9824-e11837661b57
parent 4d08edde
...@@ -73,10 +73,10 @@ CCircumflex.prototype.fixSize = function(oMeasure, stretch, bIncl) ...@@ -73,10 +73,10 @@ CCircumflex.prototype.fixSize = function(oMeasure, stretch, bIncl)
this.size = {width: width, height: height}; this.size = {width: width, height: height};
} }
CCircumflex.prototype.draw = function(pGraphics) CCircumflex.prototype.draw = function(x, y, pGraphics)
{ {
var x = this.pos.x, var xx = this.pos.x + x,
y = this.pos.y; yy = this.pos.y + y;
var fontSize = this.Parent.getCtrPrp().FontSize; var fontSize = this.Parent.getCtrPrp().FontSize;
var penW = fontSize*g_dKoef_pt_to_mm*this.PEN_W; var penW = fontSize*g_dKoef_pt_to_mm*this.PEN_W;
...@@ -145,8 +145,8 @@ CCircumflex.prototype.draw = function(pGraphics) ...@@ -145,8 +145,8 @@ CCircumflex.prototype.draw = function(pGraphics)
for(var i = 0; i < XX.length; i++) for(var i = 0; i < XX.length; i++)
{ {
XX[i] = x + XX[i]*alpha ; XX[i] = xx + XX[i]*alpha ;
YY[i] = y + (a + b*YY[i])*alpha; YY[i] = yy + (a + b*YY[i])*alpha;
} }
var intGrid = pGraphics.GetIntegerGrid(); var intGrid = pGraphics.GetIntegerGrid();
...@@ -204,7 +204,7 @@ CLine.prototype.fixSize = function(oMeasure, stretch) ...@@ -204,7 +204,7 @@ CLine.prototype.fixSize = function(oMeasure, stretch)
this.size = {width: width, height: height} this.size = {width: width, height: height}
} }
CLine.prototype.draw = function(pGraphics) CLine.prototype.draw = function(x, y, pGraphics)
{ {
var fontSize = this.Parent.getCtrPrp().FontSize; var fontSize = this.Parent.getCtrPrp().FontSize;
var penW = fontSize*g_dKoef_pt_to_mm*this.PEN_W; var penW = fontSize*g_dKoef_pt_to_mm*this.PEN_W;
...@@ -217,8 +217,8 @@ CLine.prototype.draw = function(pGraphics) ...@@ -217,8 +217,8 @@ CLine.prototype.draw = function(pGraphics)
var shY = this.size.height * 0.15386904761904763; // чтобы линии совпадали var shY = this.size.height * 0.15386904761904763; // чтобы линии совпадали
var x1 = this.pos.x, var x1 = this.pos.x + x,
y1 = this.pos.y + penY + shY, y1 = this.pos.y + y + penY + shY,
x2 = x1 + this.size.width, x2 = x1 + this.size.width,
y2 = y1; y2 = y1;
...@@ -263,7 +263,7 @@ CDoubleLine.prototype.setPosition = function(pos) ...@@ -263,7 +263,7 @@ CDoubleLine.prototype.setPosition = function(pos)
{ {
this.pos = pos; this.pos = pos;
} }
CDoubleLine.prototype.draw = function(pGraphics) CDoubleLine.prototype.draw = function(x, y, pGraphics)
{ {
var fontSize = this.Parent.getCtrPrp().FontSize; var fontSize = this.Parent.getCtrPrp().FontSize;
var penW = fontSize*g_dKoef_pt_to_mm*this.PEN_W; var penW = fontSize*g_dKoef_pt_to_mm*this.PEN_W;
...@@ -272,8 +272,8 @@ CDoubleLine.prototype.draw = function(pGraphics) ...@@ -272,8 +272,8 @@ CDoubleLine.prototype.draw = function(pGraphics)
//var penY = penW/2*25.4/96; //для того чтобы линии совпадали (для одинарной и двойной черты) //var penY = penW/2*25.4/96; //для того чтобы линии совпадали (для одинарной и двойной черты)
var penY = penW/2; //для того чтобы линии совпадали (для одинарной и двойной черты) var penY = penW/2; //для того чтобы линии совпадали (для одинарной и двойной черты)
var x1 = this.pos.x, var x1 = this.pos.x + x,
y1 = this.pos.y + penY, y1 = this.pos.y + y + penY,
x2 = x1 + this.size.width, x2 = x1 + this.size.width,
y2 = y1, y2 = y1,
x3 = x1, x3 = x1,
...@@ -312,7 +312,7 @@ CTilde.prototype.fixSize = function() ...@@ -312,7 +312,7 @@ CTilde.prototype.fixSize = function()
this.size = {width: width, height: height}; this.size = {width: width, height: height};
} }
CTilde.prototype.draw = function(pGraphics) CTilde.prototype.draw = function(x, y, pGraphics)
{ {
var X = new Array(), var X = new Array(),
Y = new Array(); Y = new Array();
...@@ -355,13 +355,13 @@ CTilde.prototype.draw = function(pGraphics) ...@@ -355,13 +355,13 @@ CTilde.prototype.draw = function(pGraphics)
var align = this.size.width - X[13]*alpha; var align = this.size.width - X[13]*alpha;
var x = this.pos.x + align/2, var xx = this.pos.x + x + align/2,
y = this.pos.y; yy = this.pos.y + y;
for(var i = 0; i < X.length; i++) for(var i = 0; i < X.length; i++)
{ {
XX[i] = x + X[i]*alpha; XX[i] = xx + X[i]*alpha;
YY[i] = y + (Y[5] - Y[i])*alpha*0.65; // сжали ! YY[i] = yy + (Y[5] - Y[i])*alpha*0.65; // сжали !
} }
...@@ -425,7 +425,7 @@ CBreve.prototype.setPosition = function(pos) ...@@ -425,7 +425,7 @@ CBreve.prototype.setPosition = function(pos)
{ {
this.pos = pos; this.pos = pos;
} }
CBreve.prototype.draw = function(pGraphics) CBreve.prototype.draw = function(x, y, pGraphics)
{ {
var X = new Array(), var X = new Array(),
Y = new Array(); Y = new Array();
...@@ -464,8 +464,8 @@ CBreve.prototype.draw = function(pGraphics) ...@@ -464,8 +464,8 @@ CBreve.prototype.draw = function(pGraphics)
var align = this.size.width - X[22]*alpha; var align = this.size.width - X[22]*alpha;
var x = this.pos.x + align/2, var xx = this.pos.x + x + align/2,
y = this.pos.y; yy = this.pos.y + y;
var a, b; var a, b;
if(this.turn == TURN_0) if(this.turn == TURN_0)
...@@ -481,8 +481,8 @@ CBreve.prototype.draw = function(pGraphics) ...@@ -481,8 +481,8 @@ CBreve.prototype.draw = function(pGraphics)
for(var i = 0; i < X.length; i++) for(var i = 0; i < X.length; i++)
{ {
XX[i] = x + X[i]*alpha ; XX[i] = xx + X[i]*alpha ;
YY[i] = y + (a + b*Y[i])*alpha ; YY[i] = yy + (a + b*Y[i])*alpha ;
} }
...@@ -627,9 +627,9 @@ CSign.prototype.fixSize = function(oMeasure, stretch, bIncline) ...@@ -627,9 +627,9 @@ CSign.prototype.fixSize = function(oMeasure, stretch, bIncline)
this.size = {width: width, height: height}; this.size = {width: width, height: height};
} }
CSign.prototype.draw = function(pGraphics) CSign.prototype.draw = function(x, y, pGraphics)
{ {
this.sign.draw(pGraphics); this.sign.draw(x, y, pGraphics);
} }
CSign.prototype.relate = function(parent) CSign.prototype.relate = function(parent)
{ {
...@@ -1172,16 +1172,16 @@ CAccent.prototype.init = function(properties) ...@@ -1172,16 +1172,16 @@ CAccent.prototype.init = function(properties)
//this.setOperator(accent); //this.setOperator(accent);
this.elements[0][0].SetDot(true); this.elements[0][0].SetDot(true);
} }
CAccent.prototype.getCenter = function() CAccent.prototype.getAscent = function()
{ {
var center; var ascent;
if(this.loc === LOCATION_TOP ) if(this.loc === LOCATION_TOP )
center = this.operator.size.height + this.elements[0][0].size.center; ascent = this.operator.size.height + this.elements[0][0].size.ascent;
else if(this.loc === LOCATION_BOT ) else if(this.loc === LOCATION_BOT )
center = this.elements[0][0].size.center; ascent = this.elements[0][0].size.ascent;
return center; return ascent;
} }
CAccent.prototype.getPropsForWrite = function() CAccent.prototype.getPropsForWrite = function()
{ {
......
...@@ -3,7 +3,7 @@ function CDegree() ...@@ -3,7 +3,7 @@ function CDegree()
this.kind = MATH_DEGREE; this.kind = MATH_DEGREE;
this.type = DEGREE_SUPERSCRIPT ; this.type = DEGREE_SUPERSCRIPT ;
this.shiftDegree = 0; this.upper = 0;
this.alnScr = false; // не выровнены, итераторы идут в соответствии с наклоном буквы/мат. объекта this.alnScr = false; // не выровнены, итераторы идут в соответствии с наклоном буквы/мат. объекта
CMathBase.call(this); CMathBase.call(this);
...@@ -37,38 +37,82 @@ CDegree.prototype.init_2 = function(props, oBase) ...@@ -37,38 +37,82 @@ CDegree.prototype.init_2 = function(props, oBase)
} }
CDegree.prototype.recalculateSize = function() CDegree.prototype.recalculateSize = function()
{ {
var Widths = this.getWidthsHeights().widths; if(this.type === DEGREE_SUPERSCRIPT)
this.recalculateSup();
else if(this.type === DEGREE_SUBSCRIPT)
this.recalculateSubScript();
}
CDegree.prototype.recalculateSup = function()
{
var base = this.elements[0][0].size,
iter = this.elements[0][1].size;
var Heights = []; var width = base.width + iter.width;
Heights[0] = this.elements[0][0].size.height;
Heights[1] = this.elements[0][1].size.height;
var _center; var height = 0,
ascent = 0;
var middle = ((Heights[0] > Heights[1]) ? Heights[1] : Heights[0])* 2/3; /// 2/3 от высоты var descIter = iter.height - iter.ascent;
var FontSize = this.getCtrPrp().FontSize,
shiftCenter = DIV_CENT*FontSize;
var _height = Heights[0] + Heights[1] - middle; var upper = 0;
var _width = 0; if(descIter + shiftCenter > 2/3*base.height)
for( var i = 0; i < Widths.length; i++ ) {
_width += Widths[i]; upper = iter.height - 2/3*base.height;
}
else
{
upper = iter.ascent - shiftCenter;
}
_width += this.dW; this.upper = upper;
if(this.type === DEGREE_SUPERSCRIPT) if(upper > 0)
{ {
this.shiftDegree = 0; height = this.upper + base.height;
_center = _height - (this.elements[0][0].size.height - this.elements[0][0].size.center); ascent = this.upper + base.ascent;
} }
else if(this.type === DEGREE_SUBSCRIPT) else
{
height = base.height;
ascent = base.ascent;
}
this.size = {width: width, height: height, ascent: ascent};
}
CDegree.prototype.recalculateSubScript = function()
{
var base = this.elements[0][0].size,
iter = this.elements[0][1].size;
var width = base.width + iter.width;
var height = 0,
ascent = 0;
var FontSize = this.getCtrPrp().FontSize,
shiftCenter = 0.5*DIV_CENT*FontSize;
var low = 0;
if(iter.ascent - shiftCenter > 2/3*base.height)
{
low = iter.height - 2/3*base.height;
}
else
{ {
this.shiftDegree = _height - this.elements[0][1].size.height; low = iter.height - iter.ascent + shiftCenter;
_center = this.elements[0][0].size.center;
} }
this.size = {width: _width,height: _height, center: _center}; height = base.height + low;
ascent = base.ascent;
this.upper = -(height - iter.height);
this.size = {width: width, height: height, ascent: ascent};
} }
CDegree.prototype.setPosition = function(_pos) CDegree.prototype.old_setPosition = function(_pos)
{ {
var pos = _pos; var pos = _pos;
if(this.bMObjs === true) if(this.bMObjs === true)
...@@ -79,6 +123,21 @@ CDegree.prototype.setPosition = function(_pos) ...@@ -79,6 +123,21 @@ CDegree.prototype.setPosition = function(_pos)
this.elements[0][0].setPosition({x: pos.x, y: pos.y - this.elements[0][0].size.center }); this.elements[0][0].setPosition({x: pos.x, y: pos.y - this.elements[0][0].size.center });
this.elements[0][1].setPosition({x: pos.x + this.elements[0][0].size.width + this.dW, y: pos.y + this.shiftDegree - this.size.center}); this.elements[0][1].setPosition({x: pos.x + this.elements[0][0].size.width + this.dW, y: pos.y + this.shiftDegree - this.size.center});
} }
CDegree.prototype.setPosition = function(pos)
{
this.pos = {x: pos.x, y: pos.y - this.size.ascent};
var shBase = 0,
shIter = 0;
if(this.upper > 0)
shBase = this.upper;
else
shIter = - this.upper;
this.elements[0][0].setPosition({x: this.pos.x, y: this.pos.y + shBase});
this.elements[0][1].setPosition({x: this.pos.x + this.elements[0][0].size.width + this.dW, y: this.pos.y + shIter});
}
CDegree.prototype.findDisposition = function(mCoord) CDegree.prototype.findDisposition = function(mCoord)
{ {
var coordX, coordY; var coordX, coordY;
...@@ -86,6 +145,74 @@ CDegree.prototype.findDisposition = function(mCoord) ...@@ -86,6 +145,74 @@ CDegree.prototype.findDisposition = function(mCoord)
var inside_flag = -1; var inside_flag = -1;
var shBase = 0,
shIter = 0;
if(this.upper > 0)
shBase = this.upper;
else
shIter = - this.upper;
if( mCoord.x < this.elements[0][0].size.width)
{
if( this.elements[0][0].IsJustDraw() )
{
X = 0; Y = 1; // встаем во второй элемент
coordX = 0;
coordY = mCoord.y - shIter;
inside_flag = 0;
}
else
{
X = 0; Y = 0; // встаем в первый элемент
coordX = mCoord.x;
coordY = mCoord.y - shBase;
}
}
else if(mCoord.x < (this.elements[0][0].size.width + this.dW ))
{
X = 0; Y = 1; // встаем во второй элемент
coordX = 0;
coordY = mCoord.y - shIter;
inside_flag = 0;
}
else if(mCoord.x > this.size.width)
{
X = 0; Y = 1; // встаем во второй элемент
coordX = this.size.width;
coordY = mCoord.y - shIter;
inside_flag = 1;
}
else
{
X = 0; Y = 1; // встаем во второй элемент
coordX = mCoord.x - (this.elements[0][0].size.width + this.dW);
coordY = mCoord.y - shIter;
}
if(coordY < 0)
{
coordY = 0;
inside_flag = 2;
}
else if(coordY > this.elements[X][Y].size.height)
{
coordY = this.elements[X][Y].size.height;
inside_flag = 2;
}
var mCoord = {x: coordX, y: coordY};
return {pos: {x: X, y: Y}, mCoord: mCoord, inside_flag: inside_flag};
}
CDegree.prototype.old_findDisposition = function(mCoord)
{
var coordX, coordY;
var X, Y;
var inside_flag = -1;
if( mCoord.x < this.elements[0][0].size.width) if( mCoord.x < this.elements[0][0].size.width)
{ {
if( this.elements[0][0].IsJustDraw() ) if( this.elements[0][0].IsJustDraw() )
......
...@@ -23,15 +23,15 @@ CLimit.prototype.init = function(props) ...@@ -23,15 +23,15 @@ CLimit.prototype.init = function(props)
else if(this.type == LIMIT_UP) else if(this.type == LIMIT_UP)
this.addMCToContent(oIter, oBase); this.addMCToContent(oIter, oBase);
} }
CLimit.prototype.getCenter = function() CLimit.prototype.getAscent = function()
{ {
var center; var ascent;
if(this.type == LIMIT_LOW) if(this.type == LIMIT_LOW)
center = this.elements[0][0].size.center; ascent = this.elements[0][0].size.ascent;
else if(this.type == LIMIT_UP) else if(this.type == LIMIT_UP)
center = this.elements[0][0].size.height + this.dH + this.elements[1][0].size.center; ascent = this.elements[0][0].size.height + this.dH + this.elements[1][0].size.ascent;
return center; return ascent;
} }
CLimit.prototype.getFName = function() CLimit.prototype.getFName = function()
{ {
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
// 0. Пересмотреть схему для findDisposition(base.js), т.к. если нажали за границами элемента, то происходит селект, т.к. теперь на mouseDown и mouseDown одни и те же функции // 0. Пересмотреть схему для findDisposition(base.js), т.к. если нажали за границами элемента, то происходит селект, т.к. теперь на mouseDown и mouseDown одни и те же функции
// 1. центр => baseline // 1. центр => baseline
// 2. поправить центр для delimiters (когда оператор текст) // 2. поправить центр для delimiters (когда оператор текст)
// 3. Поправить пересчет размера для delimiters (для скобок (control object) идет смещение для baseline) // 3. поправить accent расположение глифов в случае небольшого размера шрифта (н-р, 14)
// 5. сделать gaps для мат. объектов, +, - в зависимости от расположения в контенте // 5. сделать gaps для мат. объектов, +, - в зависимости от расположения в контенте
// 6. Размер разделительной черты для линейной дроби ограничить также как и для наклонной дроби // 6. Размер разделительной черты для линейной дроби ограничить также как и для наклонной дроби
// 7. баг с отрисовкой кругового интеграла // 7. баг с отрисовкой кругового интеграла
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
// 11. Для управляющих символов запрашивать не getCtrPrp, getPrpToControlLetter (реализована, нужно только протащить для всех управляющих элементов) // 11. Для управляющих символов запрашивать не getCtrPrp, getPrpToControlLetter (реализована, нужно только протащить для всех управляющих элементов)
// 12. объединение формул на remove и add // 12. объединение формул на remove и add
// TODO Refactoring // TODO Refactoring
// 1. CAccent ~> COperator // 1. CAccent ~> COperator
// 2. COperator : объединить все классы связанные с отрисовкой и пересчетом операторов в один // 2. COperator : объединить все классы связанные с отрисовкой и пересчетом операторов в один
...@@ -156,7 +157,7 @@ CMPrp.prototype = ...@@ -156,7 +157,7 @@ CMPrp.prototype =
this.italic = false; this.italic = false;
this.bold = true; this.bold = true;
} }
else if(mPrp === "p") else if(mPrp.sty === "p")
{ {
this.plain = true; this.plain = true;
} }
......
...@@ -200,12 +200,12 @@ CMathMatrix.prototype.recalculateSize = function() ...@@ -200,12 +200,12 @@ CMathMatrix.prototype.recalculateSize = function()
for(var j = 0; j < this.nRow; j++) for(var j = 0; j < this.nRow; j++)
height += this.gaps.row[j] + metrics.ascents[j] + metrics.descents[j]; height += this.gaps.row[j] + metrics.ascents[j] + metrics.descents[j];
var center = 0; var ascent = 0;
if(this.baseJc == BASEJC_TOP) if(this.baseJc == BASEJC_TOP)
{ {
for(var j = 0; j < this.nCol; j++) for(var j = 0; j < this.nCol; j++)
center = this.elements[0][j].size.center > center ? this.elements[0][j].size.center : center; ascent = this.elements[0][j].size.ascent > ascent ? this.elements[0][j].size.ascent : ascent;
} }
else if(this.baseJc == BASEJC_BOTTOM) else if(this.baseJc == BASEJC_BOTTOM)
{ {
...@@ -213,17 +213,17 @@ CMathMatrix.prototype.recalculateSize = function() ...@@ -213,17 +213,17 @@ CMathMatrix.prototype.recalculateSize = function()
currDsc; currDsc;
for(var j = 0; j < this.nCol; j++) for(var j = 0; j < this.nCol; j++)
{ {
currDsc = this.elements[this.nRow -1][j].size.height - this.elements[this.nRow -1][j].size.center; currDsc = this.elements[this.nRow -1][j].size.height - this.elements[this.nRow -1][j].size.ascent;
descent = currDsc > descent ? currDsc : descent; descent = currDsc > descent ? currDsc : descent;
center = height - descent; ascent = height - descent;
} }
} }
else /*this.baseJc == 0*/ else /*this.baseJc == 0*/
center = this.getCenter(height); ascent = this.getAscent(height);
//center = height/2; //center = height/2;
this.size = {width: width, height: height, center: center}; this.size = {width: width, height: height, ascent: ascent};
} }
CMathMatrix.prototype.setPosition = function(pos) CMathMatrix.prototype.setPosition = function(pos)
...@@ -231,7 +231,7 @@ CMathMatrix.prototype.setPosition = function(pos) ...@@ -231,7 +231,7 @@ CMathMatrix.prototype.setPosition = function(pos)
if(this.bMObjs === true) if(this.bMObjs === true)
this.pos = pos; this.pos = pos;
else else
this.pos = {x: pos.x, y: pos.y - this.size.center}; ///!!!!!!!!!!!!!!!!!!!!!!!!!! this.pos = {x: pos.x, y: pos.y - this.size.ascent}; ///!!!!!!!!!!!!!!!!!!!!!!!!!!
var maxWH = this.getWidthsHeights(); var maxWH = this.getWidthsHeights();
var Widths = maxWH.widths; var Widths = maxWH.widths;
...@@ -348,8 +348,8 @@ CMathMatrix.prototype.getMetrics = function() ...@@ -348,8 +348,8 @@ CMathMatrix.prototype.getMetrics = function()
{ {
var size = this.elements[i][j].size; var size = this.elements[i][j].size;
Widths[j] = ( Widths[j] > size.width ) ? Widths[j] : size.width; Widths[j] = ( Widths[j] > size.width ) ? Widths[j] : size.width;
Ascents[i] = (Ascents[i] > size.center ) ? Ascents[i] : size.center; Ascents[i] = (Ascents[i] > size.ascent ) ? Ascents[i] : size.ascent;
Descents[i] = (Descents[i] > size.height - size.center ) ? Descents[i] : size.height - size.center; Descents[i] = (Descents[i] > size.height - size.ascent ) ? Descents[i] : size.height - size.ascent;
} }
return {ascents: Ascents, descents: Descents, widths: Widths} return {ascents: Ascents, descents: Descents, widths: Widths}
......
...@@ -240,7 +240,6 @@ extend(CNaryUnd, CMathBase); ...@@ -240,7 +240,6 @@ extend(CNaryUnd, CMathBase);
CNaryUnd.prototype.init = function(sign) CNaryUnd.prototype.init = function(sign)
{ {
this.setDimension(2,1); this.setDimension(2,1);
var iter = new CMathContent(); var iter = new CMathContent();
//iter.setReduct(DEGR_REDUCT); //iter.setReduct(DEGR_REDUCT);
...@@ -251,7 +250,7 @@ CNaryUnd.prototype.setDistance = function() ...@@ -251,7 +250,7 @@ CNaryUnd.prototype.setDistance = function()
var zetta = this.getCtrPrp().FontSize* 25.4/96; var zetta = this.getCtrPrp().FontSize* 25.4/96;
this.dH = zetta*0.25; this.dH = zetta*0.25;
} }
CNaryUnd.prototype.getCenter = function() CNaryUnd.prototype.getAscent = function()
{ {
return this.elements[0][0].size.height + this.dH + this.elements[1][0].size.ascent; return this.elements[0][0].size.height + this.dH + this.elements[1][0].size.ascent;
} }
...@@ -280,7 +279,7 @@ CNaryOvr.prototype.setDistance = function() ...@@ -280,7 +279,7 @@ CNaryOvr.prototype.setDistance = function()
var zetta = this.getCtrPrp().FontSize* 25.4/96; var zetta = this.getCtrPrp().FontSize* 25.4/96;
this.dH = zetta*0.1; this.dH = zetta*0.1;
} }
CNaryOvr.prototype.getCenter = function() CNaryOvr.prototype.getAscent = function()
{ {
return this.elements[0][0].size.ascent; return this.elements[0][0].size.ascent;
} }
...@@ -337,9 +336,9 @@ CNaryUndOvr.prototype.setPosition = function(pos) ...@@ -337,9 +336,9 @@ CNaryUndOvr.prototype.setPosition = function(pos)
x3 = pos.x + this.align(2,0).x, x3 = pos.x + this.align(2,0).x,
y3 = y2 + this.elements[1][0].size.height + this.gapBottom; y3 = y2 + this.elements[1][0].size.height + this.gapBottom;
this.elements[0][0].setPosition({x: x1, y :y1 }); this.elements[0][0].setPosition({x: x1, y :y1});
this.elements[1][0].setPosition({x: x2, y :y2 }); this.elements[1][0].setPosition({x: x2, y :y2});
this.elements[2][0].setPosition({x: x3, y :y3 }); this.elements[2][0].setPosition({x: x3, y :y3});
} }
CNaryUndOvr.prototype.findDisposition = function(mCoord) CNaryUndOvr.prototype.findDisposition = function(mCoord)
{ {
...@@ -2830,7 +2829,7 @@ function CContourIntegral() ...@@ -2830,7 +2829,7 @@ function CContourIntegral()
CNaryOperator.call(this); CNaryOperator.call(this);
} }
extend(CContourIntegral, CNaryOperator); extend(CContourIntegral, CNaryOperator);
CContourIntegral.prototype.draw = function(pGraphics) CContourIntegral.prototype.draw = function(x, y, pGraphics)
{ {
var circle = new CCircle(); var circle = new CCircle();
var coord = circle.getCoord(); var coord = circle.getCoord();
...@@ -2858,15 +2857,15 @@ CContourIntegral.prototype.draw = function(pGraphics) ...@@ -2858,15 +2857,15 @@ CContourIntegral.prototype.draw = function(pGraphics)
for(var i = 0; i < X.length; i++) for(var i = 0; i < X.length; i++)
{ {
X[i] = this.pos.x + shX + X[i]*alpha; X[i] = this.pos.x + x + shX + X[i]*alpha;
Y[i] = this.pos.y + shY + Y[i]*alpha; Y[i] = this.pos.y + y + shY + Y[i]*alpha;
} }
for(var i = 0; i < XX.length; i++) for(var i = 0; i < XX.length; i++)
{ {
XX[i] = this.pos.x + XX[i]*alpha; XX[i] = this.pos.x + x + XX[i]*alpha;
YY[i] = this.pos.y + YY[i]*alpha; YY[i] = this.pos.y + y + YY[i]*alpha;
} }
...@@ -3334,7 +3333,7 @@ function CSurfaceIntegral() ...@@ -3334,7 +3333,7 @@ function CSurfaceIntegral()
CNaryOperator.call(this); CNaryOperator.call(this);
} }
extend(CSurfaceIntegral, CNaryOperator); extend(CSurfaceIntegral, CNaryOperator);
CSurfaceIntegral.prototype.draw = function(pGraphics) CSurfaceIntegral.prototype.draw = function(x, y, pGraphics)
{ {
var surf = new CSurface(); var surf = new CSurface();
var coord = surf.getCoord(); var coord = surf.getCoord();
...@@ -3364,16 +3363,15 @@ CSurfaceIntegral.prototype.draw = function(pGraphics) ...@@ -3364,16 +3363,15 @@ CSurfaceIntegral.prototype.draw = function(pGraphics)
for(var i = 0; i < X.length; i++) for(var i = 0; i < X.length; i++)
{ {
X[i] = this.pos.x + shX + X[i]*alpha; X[i] = this.pos.x + x + shX + X[i]*alpha;
Y[i] = this.pos.y + shY + Y[i]*alpha; Y[i] = this.pos.y + y + shY + Y[i]*alpha;
} }
for(var i = 0; i < XX.length; i++) for(var i = 0; i < XX.length; i++)
{ {
XX[i] = this.pos.x + XX[i]*alpha; XX[i] = this.pos.x + x + XX[i]*alpha;
YY[i] = this.pos.y + YY[i]*alpha; YY[i] = this.pos.y + y + YY[i]*alpha;
} }
...@@ -3911,7 +3909,7 @@ function CVolumeIntegral() ...@@ -3911,7 +3909,7 @@ function CVolumeIntegral()
CNaryOperator.call(this); CNaryOperator.call(this);
} }
extend(CVolumeIntegral, CNaryOperator); extend(CVolumeIntegral, CNaryOperator);
CVolumeIntegral.prototype.draw = function(pGraphics) CVolumeIntegral.prototype.draw = function(x, y, pGraphics)
{ {
var volume = new CVolume(); var volume = new CVolume();
var coord = volume.getCoord(); var coord = volume.getCoord();
...@@ -3940,16 +3938,14 @@ CVolumeIntegral.prototype.draw = function(pGraphics) ...@@ -3940,16 +3938,14 @@ CVolumeIntegral.prototype.draw = function(pGraphics)
for(var i = 0; i < X.length; i++) for(var i = 0; i < X.length; i++)
{ {
X[i] = this.pos.x + shX + X[i]*alpha; X[i] = this.pos.x + x + shX + X[i]*alpha;
Y[i] = this.pos.y + shY + Y[i]*alpha; Y[i] = this.pos.y + y + shY + Y[i]*alpha;
} }
for(var i = 0; i < XX.length; i++) for(var i = 0; i < XX.length; i++)
{ {
XX[i] = this.pos.x + XX[i]*alpha; XX[i] = this.pos.x + x + XX[i]*alpha;
YY[i] = this.pos.y + YY[i]*alpha; YY[i] = this.pos.y + y + YY[i]*alpha;
} }
......
...@@ -2877,7 +2877,7 @@ COperator.prototype.fixSize = function(oMeasure, stretch) ...@@ -2877,7 +2877,7 @@ COperator.prototype.fixSize = function(oMeasure, stretch)
oMeasure.SetFont(rPrp); oMeasure.SetFont(rPrp);
this.operator.Resize(); this.operator.Resize(oMeasure);
if(this.operator.loc == 0 || this.operator.loc == 1) if(this.operator.loc == 0 || this.operator.loc == 1)
{ {
...@@ -3231,7 +3231,7 @@ CDelimiter.prototype.Resize = function(oMeasure) ...@@ -3231,7 +3231,7 @@ CDelimiter.prototype.Resize = function(oMeasure)
var height = 0, var height = 0,
width = 0; width = 0;
var ascent = 0, var ascent = 0,
descent = 0; descent = 0;
...@@ -3246,8 +3246,6 @@ CDelimiter.prototype.Resize = function(oMeasure) ...@@ -3246,8 +3246,6 @@ CDelimiter.prototype.Resize = function(oMeasure)
var plH = 0.275*FontSize, // плейсхолдер var plH = 0.275*FontSize, // плейсхолдер
H2 = 0.08*FontSize; // временно baseLine H2 = 0.08*FontSize; // временно baseLine
// временно
var div = 0;
if(this.shape == DELIMITER_SHAPE_CENTERED) if(this.shape == DELIMITER_SHAPE_CENTERED)
{ {
...@@ -3259,25 +3257,28 @@ CDelimiter.prototype.Resize = function(oMeasure) ...@@ -3259,25 +3257,28 @@ CDelimiter.prototype.Resize = function(oMeasure)
descent = content.height - content.ascent > descent ? content.height - content.ascent: descent; descent = content.height - content.ascent > descent ? content.height - content.ascent: descent;
} }
maxH = ascent > descent ? ascent : descent; _ascent = ascent - DIV_CENT*FontSize;
_descent = descent + DIV_CENT*FontSize;
maxH = _ascent > _descent ? _ascent : _descent;
// для случая, когда в контенте степень и пр. элементы где нужно учитовать baseLine // для случая, когда в контенте степень и пр. элементы где нужно учитовать baseLine
if(descent < plH || ascent < plH) if(_descent < plH || _ascent < plH)
{ {
if(maxH < plH) if(maxH < plH)
{ {
height = ascent + descent; height = _ascent + _descent;
} }
else else
{ {
div = ascent - plH; var div = _ascent - plH;
height = ascent + descent + div; height = _ascent + _descent + div;
} }
} }
else else
{ {
height = 2*maxH; height = 2*maxH;
ascent = height/2; ascent = height/2 + DIV_CENT*FontSize;
} }
} }
else else
...@@ -3564,13 +3565,13 @@ CCharacter.prototype.Resize = function(oMeasure) ...@@ -3564,13 +3565,13 @@ CCharacter.prototype.Resize = function(oMeasure)
var width = base.size.width > this.operator.size.width ? base.size.width : this.operator.size.width, var width = base.size.width > this.operator.size.width ? base.size.width : this.operator.size.width,
height = base.size.height + this.operator.size.height, height = base.size.height + this.operator.size.height,
center = this.getCenter(); ascent = this.getAscent();
this.size = {height: height, width: width, center: center}; this.size = {height: height, width: width, ascent: ascent};
} }
CCharacter.prototype.setPosition = function(pos) CCharacter.prototype.setPosition = function(pos)
{ {
this.pos = {x: pos.x, y: pos.y - this.size.center}; this.pos = {x: pos.x, y: pos.y - this.size.ascent};
var alignOp = this.align(this.operator), var alignOp = this.align(this.operator),
alignCnt = this.align(this.elements[0][0]); alignCnt = this.align(this.elements[0][0]);
...@@ -3596,10 +3597,10 @@ CCharacter.prototype.align = function(element) ...@@ -3596,10 +3597,10 @@ CCharacter.prototype.align = function(element)
{ {
return (this.size.width - element.size.width)/2; return (this.size.width - element.size.width)/2;
} }
CCharacter.prototype.draw = function(pGraphics) CCharacter.prototype.draw = function(x, y, pGraphics)
{ {
this.elements[0][0].draw(pGraphics); this.elements[0][0].draw(x, y, pGraphics);
this.operator.draw(pGraphics); this.operator.draw(x, y, pGraphics);
} }
CCharacter.prototype.findDisposition = function(pos) CCharacter.prototype.findDisposition = function(pos)
{ {
...@@ -3712,20 +3713,22 @@ CGroupCharacter.prototype.init = function(props) ...@@ -3712,20 +3713,22 @@ CGroupCharacter.prototype.init = function(props)
/*if(this.operator.IsArrow()) /*if(this.operator.IsArrow())
this.setReduct(DEGR_REDUCT);*/ this.setReduct(DEGR_REDUCT);*/
} }
CGroupCharacter.prototype.getCenter = function() CGroupCharacter.prototype.getAscent = function()
{ {
var center; var ascent;
var shCent = DIV_CENT*this.getCtrPrp().FontSize;
if(this.vertJust === VJUST_TOP && this.loc === LOCATION_TOP) if(this.vertJust === VJUST_TOP && this.loc === LOCATION_TOP)
center = this.operator.size.height/2; ascent = this.operator.size.height/2 + shCent;
else if(this.vertJust === VJUST_BOT && this.loc === LOCATION_TOP ) else if(this.vertJust === VJUST_BOT && this.loc === LOCATION_TOP )
center = this.operator.size.height + this.elements[0][0].size.center; ascent = this.operator.size.height + this.elements[0][0].size.ascent;
else if(this.vertJust === VJUST_TOP && this.loc === LOCATION_BOT ) else if(this.vertJust === VJUST_TOP && this.loc === LOCATION_BOT )
center = this.elements[0][0].size.center; ascent = this.elements[0][0].size.ascent;
else if(this.vertJust === VJUST_BOT && this.loc === LOCATION_BOT ) else if(this.vertJust === VJUST_BOT && this.loc === LOCATION_BOT )
center = this.operator.size.height/2 + this.elements[0][0].size.height; ascent = this.operator.size.height/2 + shCent + this.elements[0][0].size.height;
return center; return ascent;
} }
CGroupCharacter.prototype.old_getGlyph = function(code, type) CGroupCharacter.prototype.old_getGlyph = function(code, type)
{ {
......
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