Commit 6fe7be67 authored by Anna.Pavlova's avatar Anna.Pavlova Committed by Alexander.Trofimov

объединила классы (дробь, радикал, степень)

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@49163 954022d7-b5bf-4e40-9824-e11837661b57
parent 1c244bc3
function CDegreeOrdinary()
function CDegree()
{
this.type = null;
this.shiftDegree = null;
CMathBase.call(this);
}
extend(CDegree, CMathBase);
CDegree.prototype.init = function(props)
{
this.type = props.type;
this.setDimension(1, 2);
var oBase = new CMathContent();
var oDegree = new CMathContent();
oDegree.setReduct(DEGR_REDUCT);
this.addMCToContent(oBase, oDegree);
}
CDegree.prototype.init_2 = function(props, oBase)
{
this.type = props.type;
this.setDimension(1, 2);
var oDegree = new CMathContent();
oDegree.setReduct(DEGR_REDUCT);
this.addMCToContent(oBase, oDegree);
}
CDegree.prototype.recalculateSize = function()
{
var Widths = this.getWidthsHeights().widths;
var Heights = [this.elements[0][0].size.height, this.elements[0][1].size.height];
var _center;
var middle = ((Heights[0] > Heights[1]) ? Heights[1] : Heights[0])* 2/3; /// 2/3 от высоты
var _height = Heights[0] + Heights[1] - middle;
var _width = 0;
for( var i = 0; i < Widths.length; i++ )
_width += Widths[i];
_width += this.dW;
if(this.type === 1 )
{
this.shiftDegree = 0;
_center = _height - (this.elements[0][0].size.height - this.elements[0][0].size.center);
}
else if(this.type === -1 )
{
this.shiftDegree = _height - this.elements[0][1].size.height;
_center = this.elements[0][0].size.center;
}
this.size = {width: _width,height: _height, center: _center};
}
CDegree.prototype.setPosition = function(_pos)
{
var pos = _pos;
if(this.bMObjs === true)
{
pos = {x: pos.x, y: pos.y + this.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});
}
CDegree.prototype.findDisposition = function( mCoord )
{
var coordX, coordY;
var X, Y;
var inside_flag = -1;
if( mCoord.x < this.elements[0][0].size.width)
{
if( this.elements[0][0].IsJustDraw() )
{
X = 0; Y = 1; // встаем во второй элемент
coordX = 0;
coordY = mCoord.y - this.shiftDegree;
inside_flag = 0;
}
else
{
X = 0; Y = 0; // встаем в первый элемент
coordX = mCoord.x;
coordY = mCoord.y - ( this.size.center - this.elements[0][0].size.center);
}
}
else if(mCoord.x < (this.elements[0][0].size.width + this.dW ))
{
X = 0; Y = 1; // встаем во второй элемент
coordX = 0;
coordY = mCoord.y - this.shiftDegree;
inside_flag = 0;
}
else if(mCoord.x > this.size.width)
{
X = 0; Y = 1; // встаем во второй элемент
coordX = this.size.width;
coordY = mCoord.y - this.shiftDegree;
inside_flag = 1;
}
else
{
X = 0; Y = 1; // встаем во второй элемент
coordX = mCoord.x - (this.elements[0][0].size.width + this.dW);
coordY = mCoord.y - this.shiftDegree;
}
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.getIterator = function()
{
return this.elements[0][1];
}
CDegree.prototype.getUpperIterator = function()
{
return this.elements[0][1];
}
CDegree.prototype.getLowerIterator = function()
{
return this.elements[0][1];
}
CDegree.prototype.getBase = function()
{
return this.elements[0][0];
}
function old_CDegreeOrdinary()
{
this.index = null;
this.shiftDegree = null;
CMathBase.call(this);
}
extend(CDegreeOrdinary, CMathBase);
CDegreeOrdinary.prototype.init = function()
extend(old_CDegreeOrdinary, CMathBase);
old_CDegreeOrdinary.prototype.init = function()
{
var oBase = new CMathContent();
this.init_2(oBase);
}
CDegreeOrdinary.prototype.init_2 = function(base)
old_CDegreeOrdinary.prototype.init_2 = function(base)
{
this.setDimension(1, 2);
......@@ -19,18 +163,18 @@ CDegreeOrdinary.prototype.init_2 = function(base)
this.addMCToContent(base, degree);
}
CDegreeOrdinary.prototype.setIndex = function(index)
old_CDegreeOrdinary.prototype.setIndex = function(index)
{
this.index = index;
}
CDegreeOrdinary.prototype.recalculateSize = function()
old_CDegreeOrdinary.prototype.recalculateSize = function()
{
var Widths = this.getWidthsHeights().widths;
var Heights = [this.elements[0][0].size.height, this.elements[0][1].size.height];
var _center;
var middle = ((Heights[0] > Heights[1]) ? Heights[1] : Heights[0])* 2/3; /// 2/3 от высоты
var _height = Heights[0] + Heights[1] - middle;
var _width = 0;
......@@ -52,7 +196,7 @@ CDegreeOrdinary.prototype.recalculateSize = function()
this.size = {width: _width,height: _height, center: _center};
}
CDegreeOrdinary.prototype.setPosition = function(_pos)
old_CDegreeOrdinary.prototype.setPosition = function(_pos)
{
var pos = _pos;
if(this.bMObjs === true)
......@@ -63,7 +207,7 @@ CDegreeOrdinary.prototype.setPosition = function(_pos)
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});
}
CDegreeOrdinary.prototype.old_findDisposition = function( mCoord )
old_CDegreeOrdinary.prototype.old_findDisposition = function( mCoord )
{
var posCurs = null, mouseCoord = null, inside_flag = -1;
......@@ -98,7 +242,7 @@ CDegreeOrdinary.prototype.old_findDisposition = function( mCoord )
return {pos: posCurs, mCoord: mouseCoord, inside_flag: inside_flag};
}
CDegreeOrdinary.prototype.findDisposition = function( mCoord )
old_CDegreeOrdinary.prototype.findDisposition = function( mCoord )
{
var coordX, coordY;
var X, Y;
......@@ -157,24 +301,23 @@ CDegreeOrdinary.prototype.findDisposition = function( mCoord )
return {pos: {x: X, y: Y}, mCoord: mCoord, inside_flag: inside_flag};
}
CDegreeOrdinary.prototype.getIterator = function()
old_CDegreeOrdinary.prototype.getIterator = function()
{
return this.elements[0][1];
}
CDegreeOrdinary.prototype.getUpperIterator = function()
old_CDegreeOrdinary.prototype.getUpperIterator = function()
{
return this.elements[0][1];
}
CDegreeOrdinary.prototype.getLowerIterator = function()
old_CDegreeOrdinary.prototype.getLowerIterator = function()
{
return this.elements[0][1];
}
CDegreeOrdinary.prototype.getBase = function()
old_CDegreeOrdinary.prototype.getBase = function()
{
return this.elements[0][0];
}
function CIterators()
{
CMathBase.call(this);
......@@ -227,19 +370,20 @@ CIterators.prototype.setReduct = function(reduct)
this.elements[1][0].setReduct(reduct);
}
function CDegreeSubSup(type)
function CDegreeSubSup()
{
this.type = type;
this.type = null;
CSubMathBase.call(this);
}
extend(CDegreeSubSup, CSubMathBase);
CDegreeSubSup.prototype.init = function()
CDegreeSubSup.prototype.init = function(props)
{
var oBase = new CMathContent();
this.init_2(oBase);
this.init_2(props, oBase);
}
CDegreeSubSup.prototype.init_2 = function(oBase)
CDegreeSubSup.prototype.init_2 = function(props, oBase)
{
this.type = props.type;
this.setDimension(1, 2);
var oIters = new CIterators();
......@@ -249,12 +393,12 @@ CDegreeSubSup.prototype.init_2 = function(oBase)
oIters.lUp = 0;
oIters.lD = 0;
if(this.type == 0)
if(this.type == SubSup)
{
oIters.alignHor(-1, 0);
this.addMCToContent(oBase, oIters);
}
else
else if(this.type == PreSubSup)
{
oIters.alignHor(-1, 1);
this.addMCToContent(oIters, oBase);
......@@ -262,14 +406,14 @@ CDegreeSubSup.prototype.init_2 = function(oBase)
}
CDegreeSubSup.prototype.recalculateSize = function()
{
if(this.type == 0)
if(this.type == SubSup)
{
this.elements[0][1].lUp = this.elements[0][0].size.center;
this.elements[0][1].lD = this.elements[0][0].size.height - this.elements[0][0].size.center;
this.elements[0][1].setDistance();
this.elements[0][1].recalculateSize();
}
else
else if(this.type == PreSubSup)
{
this.elements[0][0].lUp = this.elements[0][1].size.center;
this.elements[0][0].lD = this.elements[0][1].size.height - this.elements[0][1].size.center;
......@@ -283,9 +427,9 @@ CDegreeSubSup.prototype.getBase = function()
{
var base;
if(this.type == 0)
if(this.type == SubSup)
base = this.elements[0][0];
else
else if(this.type == PreSubSup)
base = this.elements[0][1];
return base;
......@@ -294,9 +438,9 @@ CDegreeSubSup.prototype.getUpperIterator = function()
{
var iter;
if(this.type == 0)
if(this.type == SubSup)
iter = this.elements[0][1].getUpperIterator();
else
else if(this.type == PreSubSup)
iter = this.elements[0][0].getUpperIterator();
return iter;
......@@ -305,9 +449,9 @@ CDegreeSubSup.prototype.getLowerIterator = function()
{
var iter;
if(this.type == 0)
if(this.type == SubSup)
iter = this.elements[0][1].getLowerIterator();
else
else if(this.type == PreSubSup)
iter = this.elements[0][0].getLowerIterator();
return iter;
......
function CBarFraction()
function CFraction()
{
this.bHide = false;
this.bSimple = false;
this.type = null;
this.bHideBar = false;
CMathBase.call(this);
}
extend(CBarFraction, CMathBase);
CBarFraction.prototype.init = function()
extend(CFraction, CMathBase);
CFraction.prototype.init = function(props)
{
var num = new CNumerator();
num.init();
if( typeof(props.type) !== "undefined" || props.type !== null )
this.type = props.type;
else
this.type = BAR_FRACTION;
var den = new CDenominator();
den.init();
if(this.type == BAR_FRACTION || this.type == NO_BAR_FRACTION)
{
var num = new CNumerator();
num.init();
this.setDimension(2, 1);
this.addMCToContent(num, den);
var den = new CDenominator();
den.init();
this.setDimension(2, 1);
if(this.type == NO_BAR_FRACTION)
this.bHideBar = true;
this.addMCToContent(num, den);
}
else if(this.type == SKEWED_FRACTION)
{
this.setDimension(1, 2);
this.setContent();
}
else if(this.type == LINEAR_FRACTION)
{
this.setDimension(1, 2);
this.setContent();
}
}
CBarFraction.prototype.getCenter = function()
CFraction.prototype.getType = function()
{
var penW = this.getTxtPrp().FontSize* 25.4/96 * 0.08 /2;
return this.elements[0][0].size.height + penW;
return this.type;
}
CBarFraction.prototype.draw = function()
CFraction.prototype.getCenter = function()
{
var center;
if(this.type == BAR_FRACTION || this.type == NO_BAR_FRACTION)
{
var penW = this.getTxtPrp().FontSize* 25.4/96 * 0.08 /2;
center = this.elements[0][0].size.height + penW;
}
else if(this.type == SKEWED_FRACTION)
{
center = this.elements[0][0].size.height;
}
else if(this.type == LINEAR_FRACTION)
{
center = CFraction.superclass.getCenter.call(this);
}
return center;
}
CFraction.prototype.draw = function()
{
if(this.type == BAR_FRACTION || this.type == NO_BAR_FRACTION)
this.drawBarFraction();
else if(this.type == SKEWED_FRACTION)
this.drawSkewedFraction();
else if(this.type == LINEAR_FRACTION)
this.drawLinearFraction();
}
CFraction.prototype.drawBarFraction = function()
{
var penW = this.getTxtPrp().FontSize* this.reduct* 25.4/96 * 0.08;
......@@ -29,58 +79,293 @@ CBarFraction.prototype.draw = function()
x2 = this.pos.x + this.size.width,
y1 = y2 = this.pos.y + this.size.center - penW/2;
if(!this.bHide)
if( !this.bHideBar )
{
MathControl.pGraph.p_color(0,0,0, 255);
MathControl.pGraph.b_color1(0,0,0, 255);
MathControl.pGraph.drawHorLine(0, y1, x1, x2, penW);
}
CBarFraction.superclass.draw.call(this);
CFraction.superclass.draw.call(this);
}
CBarFraction.prototype.getNumerator = function()
CFraction.prototype.drawSkewedFraction = function()
{
return this.elements[0][0].getElement();
var fontSize = this.getTxtPrp().FontSize;
var penW = fontSize/12.5*g_dKoef_pix_to_mm;
var gap = this.gapSlash/2 - penW/7.5;
var plh = 9.877777777777776 * fontSize / 36;
var minHeight = 2*this.gapSlash,
middleHeight = plh*4/3,
maxHeight = (3*this.gapSlash + 5*plh)*2/3;
var tg1 = -2.22,
tg2 = -3.7;
var heightSlash = this.size.height*2/3;
if(heightSlash < maxHeight)
{
if(heightSlash < minHeight)
{
heightSlash = minHeight;
tg = tg1;
}
else
{
heightSlash = this.size.height*2/3;
tg = (heightSlash - maxHeight)*(tg1 - tg2)/(middleHeight - maxHeight) + tg2;
}
var b = this.elements[0][0].size.height - tg*(this.elements[0][0].size.width + gap);
var y1 = this.elements[0][0].size.height/3,
y2 = this.elements[0][0].size.height/3 + heightSlash;
var x1 = (y1 - b)/tg,
x2 = (y2 - b)/tg;
var xx1 = this.pos.x + x1,
xx2 = this.pos.x + x2;
var yy1 = this.pos.y + y1,
yy2 = this.pos.y + y2;
}
else
{
heightSlash = maxHeight;
tg = tg2;
var coeff = this.elements[0][0].size.height/this.size.height;
shift = heightSlash*coeff;
var minVal = plh/2,
maxVal = heightSlash - minVal;
if(shift < minVal)
shift = minVal;
else if(shift > maxVal)
shift = maxVal;
var y0 = this.elements[0][0].size.height - shift;
var b = this.elements[0][0].size.height - tg*(this.elements[0][0].size.width + gap);
var y1 = y0,
y2 = y0 + heightSlash;
var x1 = (y1 - b)/tg,
x2 = (y2 - b)/tg;
var xx1 = this.pos.x + x1,
xx2 = this.pos.x + x2;
var yy1 = this.pos.y + y1 ,
yy2 = this.pos.y + y2;
}
MathControl.pGraph.p_width(penW*1000);
MathControl.pGraph.p_color(0,0,0, 255);
MathControl.pGraph.b_color1(0,0,0, 255);
MathControl.pGraph._s();
MathControl.pGraph._m(xx1, yy1);
MathControl.pGraph._l(xx2, yy2);
MathControl.pGraph.ds();
CFraction.superclass.draw.call(this);
}
CBarFraction.prototype.getDenominator = function()
CFraction.prototype.drawLinearFraction = function()
{
return this.elements[1][0].getElement();
var first = this.elements[0][0].size,
sec = this.elements[0][1].size;
var cent = first.center > sec.center ? first.center : sec.center,
desc1 = first.height - first.center, desc2 = sec.height - sec.center,
desc = desc1 > desc2 ? desc1 : desc2;
var shift = 0.1*this.dW;
var x1 = this.pos.x + this.elements[0][0].size.width + this.dW - shift,
y1 = this.pos.y + this.size.center - cent,
x2 = this.pos.x + this.elements[0][0].size.width + shift,
y2 = this.pos.y + this.size.center + desc;
var penW = this.getTxtPrp().FontSize/12.5*g_dKoef_pix_to_mm;
MathControl.pGraph.p_width(penW*1000);
MathControl.pGraph.p_color(0,0,0, 255);
MathControl.pGraph.b_color1(0,0,0, 255);
MathControl.pGraph._s();
MathControl.pGraph._m(x1, y1);
MathControl.pGraph._l(x2, y2);
MathControl.pGraph.ds();
CFraction.superclass.draw.call(this);
}
CBarFraction.prototype.hideBar = function(flag)
CFraction.prototype.getNumerator = function()
{
this.bHide = flag;
var numerator;
if(this.type == BAR_FRACTION || this.type == NO_BAR_FRACTION)
numerator = this.elements[0][0].getElement();
else
numerator = this.elements[0][0];
return numerator;
}
CBarFraction.prototype.setSimple = function(flag)
CFraction.prototype.getDenominator = function()
{
this.bSimple = flag;
var denominator;
if(flag)
this.setReduct(DEGR_REDUCT);
if(this.type == BAR_FRACTION || this.type == NO_BAR_FRACTION)
denominator = this.elements[1][0].getElement();
else
this.setReduct(1);
denominator = this.elements[0][1];
this.Resize();
return denominator;
}
CFraction.prototype.recalculateSize = function()
{
if(this.type == BAR_FRACTION || this.type == NO_BAR_FRACTION)
CFraction.superclass.recalculateSize.call(this);
else if(this.type == SKEWED_FRACTION)
this.recalculateSkewed();
else if(this.type == LINEAR_FRACTION)
this.recalculateLinear();
}
CFraction.prototype.recalculateSkewed = function()
{
this.gapSlash = 5.011235894097222 * this.getTxtPrp().FontSize/36;
var _width = this.elements[0][0].size.width + this.gapSlash + this.elements[0][1].size.width;
var _height = this.elements[0][0].size.height + this.elements[0][1].size.height;
var _center = this.getCenter();
this.size = {width: _width, height: _height, center: _center};
}
CFraction.prototype.recalculateLinear = function()
{
var H = this.elements[0][0].size.center + this.elements[0][1].size.height - this.elements[0][1].size.center;
var txtPrp = this.getTxtPrp();
var gap = 5.011235894097222*txtPrp.FontSize/36;
var H3 = gap*4.942252165543792,
H4 = gap*7.913378248315688,
H5 = gap*9.884504331087584;
if( H < H3 )
this.dW = gap;
else if( H < H4 )
this.dW = 2*gap;
else if( H < H5 )
this.dW = 2.8*gap;
else
this.dW = 3.4*gap;
var h1 = this.elements[0][0].size.height,
h2 = this.elements[0][1].size.height;
/*CBarFraction.prototype.getTxtPrp_2 = function()
var c1 = this.elements[0][0].size.center,
c2 = this.elements[0][1].size.center;
var asc = c1 > c2 ? c1 : c2;
var desc = h1 - c1 > h2 - c2 ? h1- c1 : h2 - c2;
var height = asc + desc;
var width = this.elements[0][0].size.width + this.dW + this.elements[0][1].size.width;
var center = this.getCenter();
this.size = {height: height, width: width, center: center};
}
CFraction.prototype.setPosition = function(pos)
{
var txtPrp = new CMathTextPrp();
txtPrp.Merge(this.TxtPrp);
if(this.type == SKEWED_FRACTION)
{
this.pos = {x: pos.x, y: pos.y - this.size.center};
this.elements[0][0].setPosition(this.pos);
txtPrp.FontSze *= this.reduct;
var x = this.pos.x + this.elements[0][0].size.width + this.gapSlash,
y = this.pos.y + this.size.center;
return txtPrp;
}*/
/*CBarFraction.prototype.getTxtPrp = function()
this.elements[0][1].setPosition({x: x, y: y});
}
else
CFraction.superclass.setPosition.call(this, pos);
}
CFraction.prototype.findDisposition = function( mCoord )
{
var txtPrp = CBarFraction.superclass.getTxtPrp.call(this);
var disposition;
if(this.bSimple)
txtPrp.FontSize *= DEGR_REDUCT; // делаем здес, чтобы учесть при пересчете расстояний
if(this.type == SKEWED_FRACTION)
{
var mouseCoord = {x: mCoord.x, y: mCoord.y},
posCurs = {x: null, y: null},
inside_flag = -1;
posCurs.x = 0;
if( mCoord.x < (this.elements[0][0].size.width + this.gapSlash/2))
{
var sizeFirst = this.elements[0][0].size;
if(sizeFirst.width < mCoord.x)
{
mouseCoord.x = sizeFirst.width;
inside_flag = 1;
}
if(sizeFirst.height < mCoord.y)
{
mouseCoord.y = sizeFirst.height;
inside_flag = 2;
}
posCurs.y = 0;
}
else
{
var sizeSec = this.elements[0][1].size;
if(mCoord.x < this.size.width - sizeSec.width)
{
mouseCoord.x = 0;
inside_flag = 0;
}
else if( mCoord.x > this.size.width)
{
mouseCoord.x = sizeSec.width;
inside_flag = 1;
}
else
mouseCoord.x = mCoord.x - this.elements[0][0].size.width - this.gapSlash;
if( mCoord.y < this.size.height - this.elements[0][1].size.height)
{
mouseCoord.y = 0;
inside_flag = 2;
}
else if(mCoord.y > this.size.height)
{
mouseCoord.y = sizeSec.height;
inside_flag = 2;
}
else
mouseCoord.y = mCoord.y - this.elements[0][0].size.height;
posCurs.y = 1;
}
disposition = {pos: posCurs, mCoord: mouseCoord, inside_flag: inside_flag};
}
else
disposition = CFraction.superclass.findDisposition.call(this, mCoord);
return disposition;
}
return txtPrp;
}*/
//////////
function CNumerator()
{
......@@ -207,6 +492,72 @@ CDenominator.prototype.getReduct = function()
//////////
function CBarFraction()
{
this.bHide = false;
this.bSimple = false;
CMathBase.call(this);
}
extend(CBarFraction, CMathBase);
CBarFraction.prototype.init = function()
{
var num = new CNumerator();
num.init();
var den = new CDenominator();
den.init();
this.setDimension(2, 1);
this.addMCToContent(num, den);
}
CBarFraction.prototype.getCenter = function()
{
var penW = this.getTxtPrp().FontSize* 25.4/96 * 0.08 /2;
return this.elements[0][0].size.height + penW;
}
CBarFraction.prototype.draw = function()
{
var penW = this.getTxtPrp().FontSize* this.reduct* 25.4/96 * 0.08;
var x1 = this.pos.x,
x2 = this.pos.x + this.size.width,
y1 = y2 = this.pos.y + this.size.center - penW/2;
if(!this.bHide)
{
MathControl.pGraph.p_color(0,0,0, 255);
MathControl.pGraph.b_color1(0,0,0, 255);
MathControl.pGraph.drawHorLine(0, y1, x1, x2, penW);
}
CBarFraction.superclass.draw.call(this);
}
CBarFraction.prototype.getNumerator = function()
{
return this.elements[0][0].getElement();
}
CBarFraction.prototype.getDenominator = function()
{
return this.elements[1][0].getElement();
}
CBarFraction.prototype.hideBar = function(flag)
{
this.bHide = flag;
}
CBarFraction.prototype.setSimple = function(flag)
{
this.bSimple = flag;
if(flag)
this.setReduct(DEGR_REDUCT);
else
this.setReduct(1);
this.Resize();
}
//////////
function CSkewedFraction()
{
this.gapSlash = 0;
......@@ -236,7 +587,7 @@ CSkewedFraction.prototype.setPosition = function(pos)
this.elements[0][1].setPosition({x: this.pos.x + this.elements[0][0].size.width - shiftWidth, y: this.pos.y + shiftHeight });
this.elements[0][2].setPosition({x: this.pos.x + this.elements[0][0].size.width + WidthSlash, y: this.pos.y + this.size.center});*/
};
}
CSkewedFraction.prototype.recalculateSize = function()
{
this.gapSlash = 5.011235894097222 * this.getTxtPrp().FontSize/36;
......@@ -245,7 +596,7 @@ CSkewedFraction.prototype.recalculateSize = function()
var _center = this.getCenter();
this.size = {width: _width, height: _height, center: _center};
};
}
CSkewedFraction.prototype.getCenter = function()
{
return this.elements[0][0].size.height;
......@@ -308,10 +659,9 @@ CSkewedFraction.prototype.findDisposition = function( mCoord )
return {pos: posCurs, mCoord: mouseCoord, inside_flag: inside_flag};
};
}
CSkewedFraction.prototype.draw = function()
{
CSkewedFraction.superclass.draw.call(this);
var fontSize = this.getTxtPrp().FontSize;
var penW = fontSize/12.5*g_dKoef_pix_to_mm;
......@@ -398,6 +748,8 @@ CSkewedFraction.prototype.draw = function()
MathControl.pGraph._m(xx1, yy1);
MathControl.pGraph._l(xx2, yy2);
MathControl.pGraph.ds();
CSkewedFraction.superclass.draw.call(this);
}
CSkewedFraction.prototype.getNumerator = function()
{
......@@ -485,7 +837,6 @@ CLinearFraction.prototype.draw = function()
MathControl.pGraph.ds();
CLinearFraction.superclass.draw.call(this);
}
CLinearFraction.prototype.getNumerator = function()
{
......
This source diff could not be displayed because it is too large. You can view the blob instead.
var MATH_FRACTION = 0;
var MATH_DEGREE = 1;
var MATH_DEGREESubSup = 2;
var MATH_RADICAL = 3;
var MATH_NARY = 4;
var MATH_DELIMITER = 5;
var MATH_GROUP_CHARACTER = 6;
var MATH_FUNCTION = 7;
var MATH_ACCENT = 8;
var MATH_BORDER_BOX = 9;
var MATH_LIMIT = 10;
var MATH_MATRIX = 11;
var MATH_BOX = 12;
var BAR_FRACTION = 0;
var SKEWED_FRACTION = 1;
var LINEAR_FRACTION = 2;
var NO_BAR_FRACTION = 3;
var SUPERSCRIPT = 1;
var SUBSCRIPT = -1;
var SubSup = 1;
var PreSubSup = -1;
var SQUARE_RADICAL = 0;
var DEGREE_RADICAL = 1;
var LIMIT_LOW = 0;
var LIMIT_UP = 1;
\ No newline at end of file
......@@ -46,78 +46,74 @@ CLogarithm.prototype.getArgument = function()
return this.elements[0][1];
}
function CMinimaxFunc()
function CLimLowUp()
{
CMathBase.call(this);
}
extend(CMinimaxFunc, CMathBase);
CMinimaxFunc.prototype.init = function()
extend(CLimLowUp, CMathBase);
CLimLowUp.prototype.init = function(props)
{
this.type = props.type;
this.setDimension(2, 1);
var oBase = new CMathContent();
//oBase.mergeTxtPrp({Italic: false});
oBase.setOwnTPrp({Italic: false});
var oIter = new CMathContent();
oIter.setReduct(DEGR_REDUCT);
this.addMCToContent(oBase, oIter);
if(props.type == LIMIT_LOW)
this.addMCToContent(oBase, oIter);
else if(props.type == LIMIT_UP)
this.addMCToContent(oIter, oBase);
}
CMinimaxFunc.prototype.getCenter = function()
CLimLowUp.prototype.getCenter = function()
{
return this.elements[0][0].size.center;
}
CMinimaxFunc.prototype.getBase = function()
CLimLowUp.prototype.getFName = function()
{
return this.elements[0][0];
}
CMinimaxFunc.prototype.getIterator = function()
CLimLowUp.prototype.getIterator = function()
{
return this.elements[1][0];
}
CMinimaxFunc.prototype.old_setDistance = function()
{
var iter = this.elements[1][0].size,
ascent = iter.center + this.params.font.metrics.Placeholder.Height*DIV_CENTER;
this.dH = this.params.font.metrics.Placeholder.Height - ascent;
this.dW = 0;
//this.dH = this.params.font.FontSize/16*g_dKoef_pt_to_mm;
}
CMinimaxFunc.prototype.setDistance = function()
CLimLowUp.prototype.setDistance = function()
{
this.dH = 0.03674768518518519*this.getTxtPrp().FontSize;
}
function CMinimax()
function old_CMinimax()
{
CSubMathBase.call(this);
}
extend(CMinimax, CSubMathBase);
CMinimax.prototype.init = function()
extend(old_CMinimax, CSubMathBase);
old_CMinimax.prototype.init = function()
{
this.setDimension(1, 2);
var oFunc = new CMinimaxFunc();
var oFunc = new old_CMinimaxFunc();
oFunc.init();
var oArg = new CMathContent();
this.addMCToContent(oFunc, oArg);
}
CMinimax.prototype.getFunction = function()
old_CMinimax.prototype.getFName = function()
{
return this.elements[0][0].getBase();
}
CMinimax.prototype.getIterator = function()
old_CMinimax.prototype.getIterator = function()
{
return this.elements[0][0].getIterator();
}
CMinimax.prototype.getArgument = function()
old_CMinimax.prototype.getArgument = function()
{
return this.elements[0][1];
}
CMinimax.prototype.setDistance = function()
old_CMinimax.prototype.setDistance = function()
{
this.dW = this.getTxtPrp().FontSize/6*g_dKoef_pt_to_mm;
this.dH = 0;
......@@ -140,7 +136,7 @@ CMathFunc.prototype.setDistance = function()
{
this.dW = this.getTxtPrp().FontSize/6*g_dKoef_pt_to_mm;
}
CMathFunc.prototype.getFunction = function()
CMathFunc.prototype.getFName = function()
{
return this.elements[0][0];
}
......
......@@ -11,14 +11,26 @@
// 0 - итраторы по прямой линии
// 1 - итераторы расположены также, как у степени
function CNary()
{
}
extend(CNary, CSubMathBase);
CNary.prototype.init = function(props)
{
this.typeSign = props.sign;
this.limLoc = props.limLoc;
this.supHide = props.supHide;
this.subHide = props.subHide;
}
function CNary()
function old_CNary()
{
CSubMathBase.call(this);
}
extend(CNary, CSubMathBase);
CNary.prototype.init = function(index, orderType, iterType)
extend(old_CNary, CSubMathBase);
old_CNary.prototype.init = function(index, orderType, iterType)
{
this.setDimension(1, 2);
......@@ -96,19 +108,19 @@ CNary.prototype.init = function(index, orderType, iterType)
this.addMCToContent(base, arg);
}
CNary.prototype.setDistance = function()
old_CNary.prototype.setDistance = function()
{
this.dW = this.getTxtPrp().FontSize/36*2.45;
}
CNary.prototype.getBase = function()
old_CNary.prototype.getBase = function()
{
return this.elements[0][1];
}
CNary.prototype.getUpperIterator = function()
old_CNary.prototype.getUpperIterator = function()
{
return this.elements[0][0].getUpperIterator();
}
CNary.prototype.getLowerIterator = function()
old_CNary.prototype.getLowerIterator = function()
{
return this.elements[0][0].getLowerIterator();
}
......
......@@ -160,6 +160,8 @@ CSignRadical.prototype.relate = function(parent)
this.Parent = parent;
}
//context.fill() для заливки
//Graphics : df()
function CRadical()
{
......@@ -167,18 +169,275 @@ function CRadical()
CMathBase.call(this);
}
extend(CRadical, CMathBase);
CRadical.prototype.init = function()
CRadical.prototype.init = function(props)
{
this.type = props.type;
this.setDimension(1, 1);
this.setContent();
this.signRadical = new CSignRadical();
this.signRadical.relate(this);
if(this.type == SQUARE_RADICAL)
{
this.setDimension(1, 1);
this.setContent();
}
else if(this.type == DEGREE_RADICAL)
{
this.setDimension(1, 2);
var oBase = new CMathContent();
var oDegree = new CMathContent();
oDegree.setReduct(DEGR_REDUCT);
this.addMCToContent(oDegree, oBase);
}
}
CRadical.prototype.recalculateSize = function()
{
this.signRadical.recalculateSize();
if(this.type == SQUARE_RADICAL)
{
var sign = this.signRadical.size;
var arg = this.elements[0][0].size;
var height = sign.height,
width = sign.width,
center = (height - arg.height)*0.6 + arg.center;
this.size = {width: width, height: height, center: center};
}
else if(this.type == DEGREE_RADICAL)
{
var degr = this.elements[0][0].size,
base = this.elements[0][1].size,
sign = this.signRadical.size;
var wTick = this.signRadical.sizeTick.width,
hTick = this.signRadical.sizeTick.height;
var width = degr.width - wTick + sign.width;
var txtPrp = this.getTxtPrp();
var plH = 9.877777777777776 * txtPrp.FontSize /36;
if( sign.height < plH )
this.gap = 1.5*txtPrp.FontSize/36;
else
this.gap = 3.5*txtPrp.FontSize/36;
var h1 = degr.height + this.gap + hTick,
h2 = sign.height;
var height, center;
if(h1 > h2)
{
height = h1;
center = h1 - h2 + (sign.height - base.height)*0.6 + base.center;
}
else
{
height = h2;
center = (sign.height - base.height)*0.6 + base.center;
}
this.size = {width: width, height: height, center: center};
}
}
CRadical.prototype.setPosition = function(pos)
{
if(this.type == SQUARE_RADICAL)
{
this.pos = {x: pos.x, y: pos.y - this.size.center};
this.gapLeft = this.size.width - this.elements[0][0].size.width;
this.gapTop = this.size.center - this.elements[0][0].size.center;
var x = this.pos.x + this.gapLeft,
y = this.pos.y + this.gapTop;
this.signRadical.setPosition(this.pos);
this.elements[0][0].setPosition({x: x, y: y });
}
else if(this.type == DEGREE_RADICAL)
{
this.pos = {x: pos.x, y: pos.y - this.size.center};
var degr = this.elements[0][0].size,
base = this.elements[0][1].size,
sign = this.signRadical.size;
var hDg = degr.height + this.gap + this.signRadical.sizeTick.height;
this.topDegr = this.size.height - hDg;
var x1 = this.pos.x,
y1 = this.pos.y + this.topDegr;
this.elements[0][0].setPosition({x: x1, y: y1});
var x2 = this.pos.x + degr.width - this.signRadical.sizeTick.width,
y2 = this.pos.y + this.size.height - sign.height;
this.signRadical.setPosition({x: x2, y: y2});
var x3 = this.pos.x + this.size.width - base.width,
y3 = this.pos.y + this.size.center - base.center;
this.elements[0][1].setPosition({x: x3, y: y3});
}
}
CRadical.prototype.findDisposition = function(mCoord)
{
var disposition;
if(this.type == SQUARE_RADICAL)
{
var sizeBase = this.elements[0][0].size;
var X, Y;
var inside_flag = -1;
if(mCoord.x < this.gapLeft)
{
X = 0;
inside_flag = 0;
}
else if(mCoord.x > this.gapLeft + sizeBase.width)
{
X = sizeBase.width;
inside_flag = 1;
}
else
X = mCoord.x - this.gapLeft;
if(mCoord.y < this.gapTop)
{
Y = 0;
inside_flag = 2;
}
else if(mCoord.y > this.gapTop + sizeBase.height)
{
Y = sizeBase.height;
inside_flag = 2;
}
else
Y = mCoord.y - this.gapTop;
disposition = {pos: {x:0, y:0}, mCoord: {x: X, y: Y}, inside_flag: inside_flag};
}
else if(this.type == DEGREE_RADICAL)
{
var mouseCoord = {x: null, y: null},
posCurs = {x: 0, y: null},
inside_flag = -1;
var degr = this.elements[0][0].size,
base = this.elements[0][1].size;
if(mCoord.x < this.size.width - base.width)
{
posCurs.y = 0;
if(mCoord.x > degr.width)
{
mouseCoord.x = degr.width;
inside_flag = 1;
}
else
{
mouseCoord.x = mCoord.x;
}
mouseCoord.x = mCoord.x;
if(mCoord.y < this.topDegr)
{
mouseCoord.y = 0;
inside_flag = 2;
}
else if(mCoord.y > degr.height + this.topDegr)
{
mouseCoord.y = degr.height;
inside_flag = 2;
}
else
{
mouseCoord.y = mCoord.y - this.topDegr;
}
}
else
{
posCurs.y = 1;
mouseCoord.x = mCoord.x - (this.size.width - base.width);
var topBase = this.size.center - base.center;
if(mCoord.y < topBase)
{
mouseCoord.y = 0;
inside_flag = 2;
}
else if(mCoord.y > base.height + topBase)
{
mouseCoord.y = base.height;
inside_flag = 2;
}
else
mouseCoord.y = mCoord.y - topBase;
}
disposition = {pos: posCurs, mCoord: mouseCoord, inside_flag: inside_flag};
}
return disposition;
}
CRadical.prototype.draw = function()
{
this.signRadical.draw();
old_CDegreeRadical.superclass.draw.call(this);
}
CRadical.prototype.getBase = function()
{
var base = null;
if(this.type == SQUARE_RADICAL)
base = this.elements[0][0];
else if(this.type == DEGREE_RADICAL)
base = this.elements[0][1];
return base;
}
CRadical.prototype.getDegree = function()
{
var degree = null;
if(this.type == DEGREE_RADICAL)
degree = this.elements[0][0];
return degree;
}
function old_CRadical()
{
this.signRadical = null;
CMathBase.call(this);
}
extend(old_CRadical, CMathBase);
old_CRadical.prototype.init = function()
{
this.setDimension(1, 1);
this.setContent();
this.signRadical = new CSignRadical();
this.signRadical.relate(this);
}
old_CRadical.prototype.recalculateSize = function()
{
this.signRadical.recalculateSize();
var sign = this.signRadical.size;
var arg = this.elements[0][0].size;
......@@ -188,7 +447,7 @@ CRadical.prototype.recalculateSize = function()
this.size = {width: width, height: height, center: center};
}
CRadical.prototype.setPosition = function(pos)
old_CRadical.prototype.setPosition = function(pos)
{
this.pos = {x: pos.x, y: pos.y - this.size.center};
this.gapLeft = this.size.width - this.elements[0][0].size.width;
......@@ -200,7 +459,7 @@ CRadical.prototype.setPosition = function(pos)
this.signRadical.setPosition(this.pos);
this.elements[0][0].setPosition({x: x, y: y });
}
CRadical.prototype.findDisposition = function(mCoord)
old_CRadical.prototype.findDisposition = function(mCoord)
{
var sizeBase = this.elements[0][0].size;
var X, Y;
......@@ -235,27 +494,25 @@ CRadical.prototype.findDisposition = function(mCoord)
return {pos: {x:0, y:0}, mCoord: {x: X, y: Y}, inside_flag: inside_flag};
}
//context.fill() для заливки
//Graphics : df()
CRadical.prototype.draw = function()
old_CRadical.prototype.draw = function()
{
this.elements[0][0].draw();
this.signRadical.draw();
}
CRadical.prototype.getBase = function()
old_CRadical.prototype.getBase = function()
{
return this.elements[0][0];
}
function CDegreeRadical()
function old_CDegreeRadical()
{
this.signRadical = null;
this.gap = null;
this.topDegr = null;
CMathBase.call(this);
}
extend(CDegreeRadical, CMathBase);
CDegreeRadical.prototype.init = function()
extend(old_CDegreeRadical, CMathBase);
old_CDegreeRadical.prototype.init = function()
{
this.setDimension(1, 2);
......@@ -269,7 +526,7 @@ CDegreeRadical.prototype.init = function()
this.addMCToContent(oDegree, oBase);
}
CDegreeRadical.prototype.recalculateSize = function()
old_CDegreeRadical.prototype.recalculateSize = function()
{
this.signRadical.recalculateSize();
......@@ -305,72 +562,10 @@ CDegreeRadical.prototype.recalculateSize = function()
height = h2;
center = (sign.height - base.height)*0.6 + base.center;
}
/*var metrics = this.params.font.metrics,
fontSize = this.params.font.FontSize;
// ширина
var width, height, center;
var widthToBase = 1.85*(metrics.Height - metrics.Placeholder.Height);
var tickWidth = 0.1196002747872799*fontSize, *//*расстояение значка радикала, над которым рисуется степень*//*
tGap = widthToBase - tickWidth;
width = degr.width + tGap + base.width;
this.shBase.x = degr.width + tGap;
this.shRadical.x = degr.width - tickWidth; // смещаем на ширину степени минус то расстояние радикала, над которым рисуется степень
this.shDegr.x = 0;
// высота
var top = fontSize*g_dKoef_pt_to_mm*0.15; // gap сверху от аргумента
var penW = fontSize*g_dKoef_pt_to_mm*0.042;
// высота значка радикала
var heightRadical = getHeightRadical(base.height + top, this.params.font);
heightRadical += penW;
// высота "галки" радикала
var heightTick = getHeightTick(metrics, heightRadical);
// высота "степени" + "галка"
if( base.height + top < metrics.Placeholder.Height )
gap = 1.5*fontSize/36;
else
gap = 3.5*fontSize/36;
var shift = gap + heightTick;
var hDgr = shift + degr.height,
jDegr = (heightRadical - base.height + top + penW)/2;
// общая высота
if( hDgr > heightRadical)
{
height = hDgr;
this.shBase.y = hDgr - heightRadical + jDegr;
this.shDegr.y = 0;
this.shRadical.y = hDgr - heightRadical;
}
else
{
height = heightRadical;
this.shDegr.y = heightRadical - hDgr;
this.shBase.y = jDegr;
this.shRadical.y = 0;
}
center = this.shBase.y + base.center;*/
this.size = {width: width, height: height, center: center};
}
CDegreeRadical.prototype.setPosition = function(pos)
old_CDegreeRadical.prototype.setPosition = function(pos)
{
this.pos = {x: pos.x, y: pos.y - this.size.center};
......@@ -396,12 +591,12 @@ CDegreeRadical.prototype.setPosition = function(pos)
this.elements[0][1].setPosition({x: x3, y: y3});
}
CDegreeRadical.prototype.draw = function()
old_CDegreeRadical.prototype.draw = function()
{
this.signRadical.draw();
CDegreeRadical.superclass.draw.call(this);
old_CDegreeRadical.superclass.draw.call(this);
}
CDegreeRadical.prototype.findDisposition = function(mCoord)
old_CDegreeRadical.prototype.findDisposition = function(mCoord)
{
var mouseCoord = {x: null, y: null},
posCurs = {x: 0, y: null},
......@@ -465,436 +660,6 @@ CDegreeRadical.prototype.findDisposition = function(mCoord)
return {pos: posCurs, mCoord: mouseCoord, inside_flag: inside_flag};
}
CDegreeRadical.prototype.getBase = function()
{
return this.elements[0][1];
}
CDegreeRadical.prototype.getDegree = function()
{
return this.elements[0][0];
}
function old_getHeightTick(height, txtPrp)
{
var plH = 9.877777777777776 * txtPrp.FontSize /36;
var minHgtRad = plH * 1.1304931640625,
maxHgtRad = plH * 7.029296875;
var minHgtTick = plH*0.6,
maxHgtTick = plH * 1.50732421875;
var heightTick;
if ( height > maxHgtRad )
heightTick = maxHgtTick;
else
{
var alpha = (height - minHgtRad)/maxHgtRad;
heightTick = minHgtTick*(1 + alpha);
}
return heightTick;
}
function old_getHeightRadical(height, txtPrp)
{
//var GFont = GetMathFont(txtPrp);
/*var metric = GFont.metrics,
GenHeight;
var gap = metric.Height - metric.Placeholder.Height;*/
/*var H0 = metric.Placeholder.Height,
H1 = metric.Height,
H2 = 2*metric.Placeholder.Height + 1.5*gap,
H3 = 3*metric.Placeholder.Height + 2.4*gap,
H4 = 4*metric.Placeholder.Height + 3*gap,
H5 = 5*metric.Placeholder.Height + 4*gap;*/
var plh = 9.877777777777776*txtPrp.FontSize/36;
var H0 = plh,
H1 = plh*1.50732421875,
H2 = plh*2.760986328125,
H3 = plh*4.217578125,
H4 = plh*5.52197265625,
H5 = plh*7.029296875;
if(height < H0)
GenHeight = H1*0.75;
else if( height < H1 )
GenHeight = H1;
else if( height < H2 )
GenHeight = H2;
else if( height < H3 )
GenHeight = H3;
else if( height < H4 )
GenHeight = H4;
else if(height < H5)
GenHeight = H5;
else
GenHeight = height;
return GenHeight;
}
function old_DrawingRadical()
{
var x = this.pos.x,
y = this.pos.y;
var Height = this.size.height - this.shRadical.y,
Width = this.size.width - this.shRadical.x;
var txtPrp = this.getTxtPrp();
var penW = txtPrp.FontSize*g_dKoef_pt_to_mm*0.042;
var plH = 9.877777777777776 * txtPrp.FontSize /36;
var minHeight = plH * 1.1304931640625,
maxHeight = plH * 7.029296875;
var maxWidth = plH * 0.81171875;
var coeff = 0.2*maxWidth/(maxHeight - minHeight),
b = maxWidth*0.3 - coeff*minHeight;
var heightTick = getHeightTick(Height, txtPrp);
var tX = 1.7*penW * 0.5 * 25.4/96,
tY = (-1)*tX * 11/25 *0.5; // 11/25 - тангенс угла наклона
var x1 = x + this.shRadical.x,
x2 = x1 + 0.25*maxWidth;
var y2 = y + this.size.height - heightTick,
y1 = y2 + 0.11*maxWidth;
var x3 = x2 - tX,
y3 = y2 - tY;
if(Height < maxHeight)
x4 = x3 + coeff*Height + b;
else
x4 = x3 + coeff*maxHeight + b;
var y4 = y + this.size.height - penW;
var x5 = x1 + maxWidth,
x6 = x + this.size.width;
var y5 = y + this.shRadical.y,
y6 = y + this.shRadical.y;
MathControl.pGraph.p_width(penW*0.8*1000);
MathControl.pGraph.p_color(0,0,0, 255);
MathControl.pGraph.b_color1(0,0,0, 255);
MathControl.pGraph._s();
MathControl.pGraph._m(x1, y1);
MathControl.pGraph._l(x2, y2);
MathControl.pGraph.ds();
MathControl.pGraph.p_width(1.7*penW*1000);
MathControl.pGraph._s();
MathControl.pGraph._m(x3, y3);
MathControl.pGraph._l(x4, y4);
MathControl.pGraph.ds();
MathControl.pGraph.p_width(penW*1000);
MathControl.pGraph._s();
MathControl.pGraph._m(x4, y4);
MathControl.pGraph._l(x5, y5);
MathControl.pGraph._l(x6,y6);
MathControl.pGraph.ds();
}
function old_CRadical()
{
this.gapTop = 0;
this.gapLeft = 0;
this.shRadical =
{
x: 0,
y: 0
};
CMathBase.call(this);
}
extend(old_CRadical, CMathBase);
old_CRadical.prototype.init = function()
{
this.setDimension(1, 1);
this.setContent();
}
old_CRadical.prototype.recalculateSize = function()
{
var arg = this.elements[0][0].size;
var txtPrp = this.getTxtPrp();
//var font = GetMathFont(txtPrp);
//var l = 1.85*(font.metrics.Height - font.metrics.Placeholder.Height);
var height, width, center,
left = 9.270786404079862 * txtPrp.FontSize/ 36;
var top = txtPrp.FontSize*g_dKoef_pt_to_mm*0.15;
var penW = txtPrp.FontSize*g_dKoef_pt_to_mm*0.042;
//var penW = 1* 25.4/96; //mm
height = getHeightRadical(arg.height + top, txtPrp);
height += penW;
width = arg.width + left;
this.gapTop = (height - arg.height + penW + top)/2;
this.gapLeft = left;
center = this.gapTop + arg.center;
this.size = {width: width, height: height, center: center};
}
old_CRadical.prototype.setPosition = function(pos)
{
this.pos = {x: pos.x, y: pos.y - this.size.center};
var x = this.pos.x + this.gapLeft,
y = this.pos.y + this.gapTop;
this.elements[0][0].setPosition({x: x, y: y });
}
old_CRadical.prototype.mouseDown = function(pos)
{
var coord = {x: pos.x - this.gapLeft, y: pos.y - this.gapTop};
return old_CRadical.superclass.mouseDown.call(this, coord);
}
old_CRadical.prototype.mouseMove = function(pos)
{
var coord = {x: pos.x - this.gapLeft, y: pos.y - this.gapTop};
return old_CRadical.superclass.mouseMove.call(this, coord);
}
//context.fill() для заливки
//Graphics : df()
old_CRadical.prototype.draw = function()
{
old_CRadical.superclass.draw.call(this);
DrawingRadical.call(this);
}
old_CRadical.prototype.getBase = function()
{
return this.elements[0][0];
}
function old_CDegreeRadical()
{
this.shDegr =
{
x: 0,
y: 0
};
this.shBase =
{
x: 0,
y: 0
};
this.shRadical =
{
x: 0,
y: 0
};
CMathBase.call(this, 1, 2);
}
extend(old_CDegreeRadical, CMathBase);
old_CDegreeRadical.prototype.old_setContent = function()
{
var oBase = new CMathBase(1, 1);
oBase.init( this.params );
oBase.relate(this);
oBase.fillPlaceholders();
var oDegree = new CMathBase(1, 1);
oDegree.init( this.params );
oDegree.relate(this);
oDegree.fillPlaceholders();
var fontDgr = getTypeDegree(this.params.font, true);
oDegree.setFont(fontDgr, -1);
CDegreeOrdinary.superclass.setContent.call(this, oDegree, oBase);
}
old_CDegreeRadical.prototype.setContent = function()
{
var oBase = new CMathContent(1, 1);
oBase.init( this.params );
oBase.relate(this);
oBase.fillPlaceholders();
var oDegree = new CMathContent(1, 1);
oDegree.init( this.params );
oDegree.relate(this);
oDegree.fillPlaceholders();
var fontDgr = getTypeDegree(this.params.font, true);
oDegree.setFont(fontDgr, -1);
CDegreeOrdinary.superclass.setContent.call(this, oDegree, oBase);
}
old_CDegreeRadical.prototype.recalculateSize = function()
{
var degr = this.elements[0][0].size,
base = this.elements[0][1].size;
var metrics = this.params.font.metrics,
fontSize = this.params.font.FontSize;
//var penW = 1* 25.4/96; //mm
// ширина
var width, height, center;
var widthToBase = 1.85*(metrics.Height - metrics.Placeholder.Height);
var tickWidth = 0.1196002747872799*fontSize, /*расстояение значка радикала, над которым рисуется степень*/
tGap = widthToBase - tickWidth;
width = degr.width + tGap + base.width;
this.shBase.x = degr.width + tGap;
this.shRadical.x = degr.width - tickWidth; // смещаем на ширину степени минус то расстояние радикала, над которым рисуется степень
this.shDegr.x = 0;
// высота
var top = fontSize*g_dKoef_pt_to_mm*0.15; // gap сверху от аргумента
var penW = fontSize*g_dKoef_pt_to_mm*0.042;
// высота значка радикала
var heightRadical = getHeightRadical(base.height + top, this.params.font);
heightRadical += penW;
// высота "галки" радикала
var heightTick = getHeightTick(metrics, heightRadical);
// высота "степени" + "галка"
if( base.height + top < metrics.Placeholder.Height )
gap = 1.5*fontSize/36;
else
gap = 3.5*fontSize/36;
var shift = gap + heightTick;
var hDgr = shift + degr.height,
jDegr = (heightRadical - base.height + top + penW)/2;
// общая высота
if( hDgr > heightRadical)
{
height = hDgr;
this.shBase.y = hDgr - heightRadical + jDegr;
this.shDegr.y = 0;
this.shRadical.y = hDgr - heightRadical;
}
else
{
height = heightRadical;
this.shDegr.y = heightRadical - hDgr;
this.shBase.y = jDegr;
this.shRadical.y = 0;
}
center = this.shBase.y + base.center;
this.size = {width: width, height: height, center: center};
}
old_CDegreeRadical.prototype.setPosition = function(pos)
{
this.pos = {x: pos.x, y: pos.y - this.size.center};
var x1 = this.pos.x + this.shDegr.x,
y1 = this.pos.y + this.shDegr.y;
this.elements[0][0].setPosition({x: x1, y: y1 });
var x2 = this.pos.x + this.shBase.x,
y2 = this.pos.y + this.shBase.y;
this.elements[0][1].setPosition({x: x2, y: y2 });
}
old_CDegreeRadical.prototype.draw = function()
{
old_CDegreeRadical.superclass.draw.call(this);
DrawingRadical.call(this);
}
old_CDegreeRadical.prototype.findDisposition = function(mCoord)
{
var mouseCoord = {x: null, y: null},
posCurs = {x: 0, y: null},
inside_flag = -1;
var degr = this.elements[0][0].size,
base = this.elements[0][1].size;
if(mCoord.x < this.size.width - base.width)
{
posCurs.y = 0;
if(mCoord.x > degr.width)
{
mouseCoord.x = degr.width;
inside_flag = 1;
}
else
{
mouseCoord.x = mCoord.x;
}
mouseCoord.x = mCoord.x;
if(mCoord.y < this.shDegr.y)
{
mouseCoord.y = 0;
inside_flag = 2;
}
else if(mCoord.y > degr.height + this.shDegr.y)
{
mouseCoord.y = degr.height;
inside_flag = 2;
}
else
{
mouseCoord.y = mCoord.y - this.shDegr.y;
}
}
else
{
posCurs.y = 1;
mouseCoord.x = mCoord.x - this.shBase.x;
if(mCoord.y < this.shBase.y)
{
mouseCoord.y = 0;
inside_flag = false;
}
else if(mCoord.y > base.height + this.shBase.y)
{
mouseCoord.y = base.height;
inside_flag = false;
}
else
mouseCoord.y = mCoord.y - this.shBase.y;
}
return {pos: posCurs, mCoord: mouseCoord, inside_flag: inside_flag};
}
old_CDegreeRadical.prototype.getBase = function()
{
return this.elements[0][1];
......@@ -903,3 +668,4 @@ old_CDegreeRadical.prototype.getDegree = function()
{
return this.elements[0][0];
}
......@@ -193,6 +193,7 @@
<script type="text/javascript" src = "Math/operators.js"></script>
<script type="text/javascript" src = "Math/drawingUnion.js"></script>
<script type="text/javascript" src = "Math/borderBox.js"></script>
<script type="text/javascript" src = "Math/mathTypes.js"></script>
<!---->
......
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