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

degree of root

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@47441 954022d7-b5bf-4e40-9824-e11837661b57
parent 8c48961a
...@@ -306,7 +306,7 @@ CControlComposition.prototype = ...@@ -306,7 +306,7 @@ CControlComposition.prototype =
{ {
editor.WordControl.m_oLogicDocument.DrawingDocument.OnRecalculatePage(0, editor.WordControl.m_oLogicDocument.Pages[0]); editor.WordControl.m_oLogicDocument.DrawingDocument.OnRecalculatePage(0, editor.WordControl.m_oLogicDocument.Pages[0]);
this.Content[this.CurPos].Add(code); this.Content[this.CurPos].AddLetter(code);
return true; return true;
} }
......
...@@ -1004,5 +1004,11 @@ CMathBase.prototype = ...@@ -1004,5 +1004,11 @@ CMathBase.prototype =
{ {
this.recalculateSize(); this.recalculateSize();
return this.Parent; return this.Parent;
},
hidePlaceholder: function(flag)
{
for(var i=0; i < this.nRow; i++)
for(var j = 0; j < this.nCol; j++)
this.elements[i][j].hidePlaceholder(flag);
} }
} }
function CBarFraction() function CBarFraction()
{ {
CMathBase.call(this,2,1); CMathBase.call(this,2,1);
...@@ -68,6 +66,54 @@ CNumerator.prototype.recalculateSize = function() ...@@ -68,6 +66,54 @@ CNumerator.prototype.recalculateSize = function()
this.size = {width : width, height: height, center: center}; this.size = {width : width, height: height, center: center};
} }
CNumerator.prototype.new_recalculateSize = function()
{
var arg = this.elements[0][0].size;
var metrics = this.params.font.metrics;
var penW = this.params.font.FontSize* 25.4/96 * 0.08;
var Descent = arg.height - arg.center - metrics.Placeholder.Height*DIV_CENTER; // baseLine
//var gap = metrics.Height - metrics.Placeholder.Height + metrics.Descender,
var gap = metrics.Descender + 2*penW *1.8,
minGap = 2*penW;
var delta = gap - Descent;
var GapNum = delta > minGap ? delta : minGap;
var width = arg.width;
var height = arg.height + GapNum;
var center = arg.center;
this.size = {width : width, height: height, center: center};
}
CNumerator.prototype.n_recalculateSize = function()
{
var arg = this.elements[0][0].size;
var metrics = this.params.font.metrics;
//var penW = this.params.font.FontSize* 25.4/96 * 0.08;
var DescentFirst = arg.height - arg.center - metrics.Placeholder.Height*DIV_CENTER; // baseLine
//var gap = metrics.Height - 2.8*metrics.Descender; // 8 pt
//var gap = metrics.Height - 1.5*metrics.Descender;
var gap = metrics.Height - (2.96 - 0.02*this.params.font.FontSize)*metrics.Descender;
var penW = this.params.font.FontSize/47;
// 20 7
// 60 21
var gapNum = DescentFirst - 2*penW < 0.55*gap ? 0.55*gap - DescentFirst : 2*penW;
var width = arg.width;
var height = arg.height + gapNum;
var center = arg.center;
this.size = {width : width, height: height, center: center};
}
CNumerator.prototype.findDisposition = function(mCoord) CNumerator.prototype.findDisposition = function(mCoord)
{ {
var arg = this.elements[0][0].size; var arg = this.elements[0][0].size;
...@@ -102,7 +148,6 @@ CDenominator.prototype.recalculateSize = function() ...@@ -102,7 +148,6 @@ CDenominator.prototype.recalculateSize = function()
Ascent = arg.center - metrics.Placeholder.Height/2, Ascent = arg.center - metrics.Placeholder.Height/2,
minGap = this.params.font.FontSize* 25.4/96 * 0.24; minGap = this.params.font.FontSize* 25.4/96 * 0.24;
var delta = 0.47*gap - Ascent; var delta = 0.47*gap - Ascent;
var GapDen = delta > minGap ? delta : minGap; var GapDen = delta > minGap ? delta : minGap;
...@@ -112,6 +157,52 @@ CDenominator.prototype.recalculateSize = function() ...@@ -112,6 +157,52 @@ CDenominator.prototype.recalculateSize = function()
this.size = {width : width, height: height, center: center}; this.size = {width : width, height: height, center: center};
} }
CDenominator.prototype.new_recalculateSize = function()
{
var arg = this.elements[0][0].size;
var metrics = this.params.font.metrics;
var gap = metrics.Height - metrics.Placeholder.Height - metrics.Descender,
Ascent = arg.center + metrics.Placeholder.Height*DIV_CENTER - metrics.Placeholder.Height,
minGap = this.params.font.FontSize* 25.4/96 * 0.24 * 1.23;
var delta = gap - Ascent;
var GapDen = delta > minGap ? delta : minGap;
var width = arg.width;
var height = arg.height + GapDen;
var center = arg.center + GapDen;
this.size = {width : width, height: height, center: center};
}
CDenominator.prototype.n_recalculateSize = function()
{
var arg = this.elements[0][0].size;
var metrics = this.params.font.metrics;
var AscentSecond = arg.center + metrics.Placeholder.Height*DIV_CENTER;
//var gap = metrics.Height - 2.8*metrics.Descender; // 8 pt
//var gap = metrics.Height - 1.5*metrics.Descender; // 72 pt
var gap = metrics.Height - (2.96 - 0.02*this.params.font.FontSize)*metrics.Descender;
// a*x + b = c
// a*8 + b = 2.8
// a*72 + b = 1.5
// a = - 1.3/64
// b = 2.96
var penW = this.params.font.FontSize/47;
var gapDen = AscentSecond - 3*penW < 0.45*gap ? 0.45*gap - AscentSecond : 3*penW;
var width = arg.width;
var height = arg.height + gapDen;
var center = arg.center + gapDen;
this.size = {width : width, height: height, center: center};
}
CDenominator.prototype.findDisposition = function(mCoord) CDenominator.prototype.findDisposition = function(mCoord)
{ {
var arg = this.elements[0][0].size; var arg = this.elements[0][0].size;
......
...@@ -82,7 +82,8 @@ function CMathContent() ...@@ -82,7 +82,8 @@ function CMathContent()
this.font = null; this.font = null;
this.indefSize = null; this.indefSize = null;
this.bMText = true; // default this.bMText = true; // default
this.bDot = false; this.bDot = false;
this.plhHide = false;
this.reduct = 0; // индефикатор для степени (уменьшение размера шрифта) this.reduct = 0; // индефикатор для степени (уменьшение размера шрифта)
...@@ -720,8 +721,9 @@ CMathContent.prototype = ...@@ -720,8 +721,9 @@ CMathContent.prototype =
}, },
draw: function() draw: function()
{ {
for(var i=1; i < this.content.length;i++) if( !(this.plhHide && this.IsTarget()) )
this.content[i].value.draw(); for(var i=1; i < this.content.length;i++)
this.content[i].value.draw();
}, },
update_widthContent: function() update_widthContent: function()
{ {
...@@ -1146,7 +1148,16 @@ CMathContent.prototype = ...@@ -1146,7 +1148,16 @@ CMathContent.prototype =
}, },
IsTarget: function() IsTarget: function()
{ {
return ( (this.content.length == 2) && (this.content[1].value.value === StartTextElement )); var bTarget = this.content.length == 2 && this.content[1].value.value === StartTextElement ;
return bTarget;
},
hidePlaceholder: function(flag)
{
this.plhHide = flag;
},
setPositionHideTgt: function()
{
this.CurPos = 0;
}, },
tgtSelect: function() tgtSelect: function()
{ {
...@@ -1243,6 +1254,164 @@ CMathContent.prototype = ...@@ -1243,6 +1254,164 @@ CMathContent.prototype =
return bIncline; return bIncline;
}, },
//// open ////
fillMComponent: function(id)
{
var component,
result = component;
switch(id)
{
case 0:
component = new CMathText();
result = this; // передаем указатель на данный контент, т.к. добавляем текст
break;
case 1:
component = new CBarFraction();
break;
case 2:
component = new CSkewedFraction();
break;
case 3:
component = new CLinearFraction();
break;
case 4:
component = new CSimpleFraction();
break;
case 5:
component = new CDegree(0);
break;
case 6:
component = new CDegree(1);
break;
case 7:
component = new CDegree(2);
break;
case 8:
component = new CDegree(3);
break;
case 9:
component = new CRadical();
break;
case 10:
component = new CNary();
break;
case 11:
component = new CDelimiter();
break;
case 12:
component = new CMathFunc(); // CMathMatrix(1, 2)
break;
}
component.init(this.params);
return result;
},
fillPlaceholder: function()
{
this.fillMComponent(0);
this.addCode(StartTextElement);
},
fillText: function(txt)
{
for(var i = 0; i < txt.length; i++)
{
this.addCode( txt.charCodeAt(i) );
}
// ?? this.recalculate();
this.setStart_Selection(this.CurPos);
this.selection.active = false;
},
gToUp: function()
{
this.recalculateSize(); // пересчитываем здесь размер
this.update_widthContent();
var upLevel = null;
if( ! this.bRoot ) // на всякий случай
upLevel = this.Parent;
else
upLevel = this.Root;
return upLevel;
},
////
//// edit ////
new_add: function(code)
{
if( this.IsTarget() ) //удаляем тагет
{
var empty = this.content[0]; //CEmpty
this.content.length = 0;
this.content.push( empty );
this.CurPos = 0;
}
else if( this.selection.startPos != this.selection.endPos ) //т.к. после того как удалили тагет у нас эти 2 значения не равны, равенство их выставляется позднее, после добавления символа
this.remove();
/*
var gps = null;
if(code == 0x002B || code == 0x002F || code == 0x002A || code == 0x002D)
{
//l_gap = r_gap = Math.floor( this.font.FontSize / 5 ) *g_dKoef_pix_to_mm;
l_gap = r_gap = 0;
gps = new dist(l_gap, r_gap, 0, 0);
}
else
gps = new dist(0,0,0,0);
*/
this.addCode(code);
this.setStart_Selection(this.CurPos);
this.selection.active = false;
},
new_addCode: function(code)
{
if(code == 42) // "*"
code = 8727;
else if(code == 45) // "-"
code = 8722;
if(this.bDot)
{
if(code === 0x69)
code = 0x1D6A4;
if(code === 0x6A)
code = 0x1D6A5;
}
var TParms =
{
font: this.font,
indefSize: this.indefSize,
bMText: this.bMText // для текста передаем тот параметр, который у контента (привемеры: тригонометрические ф-ии, логарифм и т.п.)
};
var symbol = new CMathText(TParms);
symbol.init(code, true);
var gps = new dist(0,0,0,0);
var tmp = this.content.splice(0, this.CurPos+1);
tmp.push( new mathElem(symbol, gps) );
tmp = tmp.concat( this.content.splice(0, this.content.length) );
this.content.length = 0;
this.content = tmp;
this.CurPos++;
//this.setStart_Selection(this.CurPos);
//this.selection.active = false;
},
////
addText: function(txt) addText: function(txt)
{ {
for(var i = 0; i < txt.length; i++) for(var i = 0; i < txt.length; i++)
...@@ -1332,7 +1501,8 @@ CMathContent.prototype = ...@@ -1332,7 +1501,8 @@ CMathContent.prototype =
this.setStart_Selection(this.CurPos); this.setStart_Selection(this.CurPos);
this.selection.active = false; this.selection.active = false;
}, },
fillContent: function(type)
old_fillContent: function(type)
{ {
var component, var component,
result; result;
...@@ -1341,7 +1511,6 @@ CMathContent.prototype = ...@@ -1341,7 +1511,6 @@ CMathContent.prototype =
{ {
component = new CMathText(); component = new CMathText();
component.init(this.params); component.init(this.params);
component.relate(this);
component.addCode(StartTextElement); component.addCode(StartTextElement);
result = this; result = this;
} }
...@@ -1349,57 +1518,55 @@ CMathContent.prototype = ...@@ -1349,57 +1518,55 @@ CMathContent.prototype =
{ {
component = new CMathText(); component = new CMathText();
component.init(this.params); component.init(this.params);
component.relate(this);
result = this; result = this;
} }
else else
{ {
component = this.getMathComponent(type); component = this.getMathComponent(type);
component.init(this.params); component.init(this.params);
component.relate(this);
result = component; result = component;
} }
return result; return result;
/*var component; /*var component;
switch(type) switch(type)
{ {
case 0: case 0:
component = new CMathText(); component = new CMathText();
component.addCode(StartTextElement); component.addCode(StartTextElement);
break; break;
case 1: case 1:
component = new CMathText(); component = new CMathText();
break; break;
case 2: case 2:
component = new CBarFraction(); component = new CBarFraction();
break; break;
case 3: case 3:
component = new CSkewedFraction(); component = new CSkewedFraction();
break; break;
case 4: case 4:
component = new CLinearFraction(); component = new CLinearFraction();
break; break;
case 5: case 5:
component = new CSimpleFraction(); component = new CSimpleFraction();
break; break;
case 6: case 6:
component = new CDegree(0); component = new CDegree(0);
break; break;
case 7: case 7:
component = new CDegree(1); component = new CDegree(1);
break; break;
case 8: case 8:
component = new CDegree(2); component = new CDegree(2);
break; break;
case 9: case 9:
component = new CDegree(3); component = new CDegree(3);
} }
component.setParams(this.params);*/ component.setParams(this.params);*/
}, },
getMathComponent: function(id) old_getMathComponent: function(id)
{ {
// 0 - placeholder // 0 - placeholder
// 1 - math text // 1 - math text
...@@ -1446,9 +1613,9 @@ CMathContent.prototype = ...@@ -1446,9 +1613,9 @@ CMathContent.prototype =
return component; return component;
}, },
gToUp: function() old_gToUp: function()
{ {
this.recalculateSize(); this.recalculateSize(); // пересчитываем здесь размер
this.update_widthContent(); this.update_widthContent();
var upLevel; var upLevel;
...@@ -1460,6 +1627,7 @@ CMathContent.prototype = ...@@ -1460,6 +1627,7 @@ CMathContent.prototype =
return upLevel; return upLevel;
} }
} }
//todo //todo
//разобраться с gaps //разобраться с gaps
...@@ -1560,7 +1728,7 @@ CMathComposition.prototype = ...@@ -1560,7 +1728,7 @@ CMathComposition.prototype =
this.SelectContent = move.SelectContent; this.SelectContent = move.SelectContent;
this.CurrentContent = move.CurrContent; this.CurrentContent = move.CurrContent;
this.СheckTarget(); this.CheckTarget();
} }
return move.state; return move.state;
...@@ -1575,7 +1743,7 @@ CMathComposition.prototype = ...@@ -1575,7 +1743,7 @@ CMathComposition.prototype =
this.SelectContent = move.SelectContent; this.SelectContent = move.SelectContent;
this.CurrentContent = move.CurrContent; this.CurrentContent = move.CurrContent;
this.СheckTarget(); this.CheckTarget();
} }
return move.state; return move.state;
...@@ -1591,7 +1759,7 @@ CMathComposition.prototype = ...@@ -1591,7 +1759,7 @@ CMathComposition.prototype =
this.CurrentContent = move.CurrContent; this.CurrentContent = move.CurrContent;
this.SelectContent = move.SelectContent; this.SelectContent = move.SelectContent;
this.СheckTarget(); this.CheckTarget();
return move.state; return move.state;
}, },
...@@ -1603,7 +1771,7 @@ CMathComposition.prototype = ...@@ -1603,7 +1771,7 @@ CMathComposition.prototype =
this.CurrentContent = move.CurrContent; this.CurrentContent = move.CurrContent;
this.SelectContent = move.SelectContent; this.SelectContent = move.SelectContent;
this.СheckTarget(); this.CheckTarget();
return move.state; return move.state;
}, },
...@@ -1612,7 +1780,12 @@ CMathComposition.prototype = ...@@ -1612,7 +1780,12 @@ CMathComposition.prototype =
this.ClearSelect(); this.ClearSelect();
this.CurrentContent = this.SelectContent = this.Root.mouseDown({x: mouseX, y: mouseY}, -1); this.CurrentContent = this.SelectContent = this.Root.mouseDown({x: mouseX, y: mouseY}, -1);
this.СheckTarget(); /*if(typeof(this.CurrentContent) == "undefined")
{
var stop = true;
}*/
this.CheckTarget();
}, },
MouseMove: function(mouseX, mouseY) MouseMove: function(mouseX, mouseY)
{ {
...@@ -1622,7 +1795,7 @@ CMathComposition.prototype = ...@@ -1622,7 +1795,7 @@ CMathComposition.prototype =
var movement = this.Root.mouseMove({x: mouseX, y: mouseY}); var movement = this.Root.mouseMove({x: mouseX, y: mouseY});
this.SelectContent = movement.SelectContent; this.SelectContent = movement.SelectContent;
this.СheckTarget(); this.CheckTarget();
} }
}, },
...@@ -1654,7 +1827,7 @@ CMathComposition.prototype = ...@@ -1654,7 +1827,7 @@ CMathComposition.prototype =
result = true; result = true;
} }
this.СheckTarget(); this.CheckTarget();
return result; return result;
}, },
...@@ -1669,7 +1842,9 @@ CMathComposition.prototype = ...@@ -1669,7 +1842,9 @@ CMathComposition.prototype =
this.SelectContent.drawSelect(); this.SelectContent.drawSelect();
}, },
Add: function(code)
//// edit ////
AddLetter: function(code)
{ {
this.ClearSelect(); this.ClearSelect();
...@@ -1695,6 +1870,8 @@ CMathComposition.prototype = ...@@ -1695,6 +1870,8 @@ CMathComposition.prototype =
this.ShowCursor(); this.ShowCursor();
}, },
////
HideCursor: function() HideCursor: function()
{ {
editor.WordControl.m_oLogicDocument.DrawingDocument.TargetEnd(); editor.WordControl.m_oLogicDocument.DrawingDocument.TargetEnd();
...@@ -1709,15 +1886,24 @@ CMathComposition.prototype = ...@@ -1709,15 +1886,24 @@ CMathComposition.prototype =
{ {
editor.WordControl.m_oLogicDocument.DrawingDocument.TargetStart(); editor.WordControl.m_oLogicDocument.DrawingDocument.TargetStart();
}, },
СheckTarget: function() CheckTarget: function()
{ {
var bSelect = this.SelectContent.selectUse(), var bSelect = this.SelectContent.selectUse(),
bTarget = this.SelectContent.IsTarget(); bTarget = this.SelectContent.IsTarget(),
bHideTgt = this.SelectContent.plhHide;
if(bTarget) if(bTarget)
{ {
this.SelectContent.tgtSelect(); if(!bHideTgt)
this.HideCursor(); {
this.SelectContent.tgtSelect();
this.HideCursor();
}
else
{
this.SelectContent.setPositionHideTgt();
this.ShowCursor();
}
} }
else if(bSelect) else if(bSelect)
this.HideCursor(); this.HideCursor();
...@@ -1736,10 +1922,8 @@ CMathComposition.prototype = ...@@ -1736,10 +1922,8 @@ CMathComposition.prototype =
editor.WordControl.m_oLogicDocument.DrawingDocument.SelectEnabled(false); editor.WordControl.m_oLogicDocument.DrawingDocument.SelectEnabled(false);
} }
}, },
/*TestFont: function(font)
{ //// test function ////
this.CurrentContent.TestFont(font);
},*/
TestSetPostion: function() TestSetPostion: function()
{ {
this.Root.setPosition(this.posCompos); this.Root.setPosition(this.posCompos);
...@@ -1748,16 +1932,42 @@ CMathComposition.prototype = ...@@ -1748,16 +1932,42 @@ CMathComposition.prototype =
{ {
this.Root.setFont(font); this.Root.setFont(font);
}, },
FillContent: function(type) /*TestFont: function(font)
{
this.CurrentContent.TestFont(font);
},*/
////
//// open ////
FillPlaceholder: function()
{
this.CurrentContent.fillPlaceholder();
this.GToUp(); //переходим на уровен выше, пересчитываем размер
//позицию рассчитаем позже
},
FillText: function()
{ {
this.CurrentContent = this.CurrentContent.fillContent(type); this.CurrentContent.fillText(); // CurrentContent не меняем, остается текущий
},
FillMComponent: function()
{
this.CurrentContent = this.CurrentContent.fillMComponent(type); // переходим в мат. компонент
this.SelectContent = this.CurrentContent; this.SelectContent = this.CurrentContent;
}, },
GToUp: function() GToUp: function()
{ {
this.CurrentContent = this.CurrentContent.gToUp(); this.CurrentContent = this.CurrentContent.gToUp(); // пересчитываем размер текущего контента в gToUp, в контенте уровнем выше пересчитаем в аналогичной ф-ии, когда достигнем конца контента
this.SelectContent = this.CurrentContent; this.SelectContent = this.CurrentContent;
},
SetEnd: function()
{
this.SelectContent = this.Root;
this.CurrentContent = this.Root;
this.Root.recalculateSize();
} }
////
} }
function CEmpty() function CEmpty()
...@@ -1837,6 +2047,7 @@ function AddEquation(ind) ...@@ -1837,6 +2047,7 @@ function AddEquation(ind)
mathElem = new CRadical(); mathElem = new CRadical();
break; break;
case 18: case 18:
mathElem = new CDegreeRadical();
break; break;
case 19: case 19:
break; break;
......
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
//api 2212: asc_docs_api.prototype.sync_TextPrFontFamilyCallBack //api 2212: asc_docs_api.prototype.sync_TextPrFontFamilyCallBack
// возвращает название шрифта // возвращает название шрифта
var DIV_CENTER = 0.375;
function CMathText(params) function CMathText(params)
{ {
this.pos = null; this.pos = null;
...@@ -58,7 +60,7 @@ CMathText.prototype = ...@@ -58,7 +60,7 @@ CMathText.prototype =
var _descent = (metricsTxt.Height - metricsTxt.Ascent); var _descent = (metricsTxt.Height - metricsTxt.Ascent);
var _height = _ascent + _descent; var _height = _ascent + _descent;
var placeholder = this.metrics.Placeholder; var placeholder = this.metrics.Placeholder;
var _center = _ascent - placeholder.Height*0.375; var _center = _ascent - placeholder.Height*DIV_CENTER;
this.sizeSymbol = {width: _width, height: _height, center: _center, ascent: _ascent, descent: _descent}; this.sizeSymbol = {width: _width, height: _height, center: _center, ascent: _ascent, descent: _descent};
this.size = {width: _width, height: _height, center: _center, ascent: _ascent, descent: _descent, gap: 0 }; this.size = {width: _width, height: _height, center: _center, ascent: _ascent, descent: _descent, gap: 0 };
......
...@@ -19,6 +19,8 @@ function CMathMatrix( numRow, numCol) ...@@ -19,6 +19,8 @@ function CMathMatrix( numRow, numCol)
minGap: 0 // minGap / 20 pt minGap: 0 // minGap / 20 pt
}; };
this.baseJc = 0;
} }
extend(CMathMatrix, CMathBase); extend(CMathMatrix, CMathBase);
CMathMatrix.prototype.init = function(params) CMathMatrix.prototype.init = function(params)
...@@ -29,6 +31,7 @@ CMathMatrix.prototype.setContent = function() ...@@ -29,6 +31,7 @@ CMathMatrix.prototype.setContent = function()
{ {
CMathMatrix.superclass.fillPlaceholders.call(this); CMathMatrix.superclass.fillPlaceholders.call(this);
} }
CMathMatrix.prototype.old_getLineGap = function(spaceLine) CMathMatrix.prototype.old_getLineGap = function(spaceLine)
{ {
var metrs = this.params.font.metrics; var metrs = this.params.font.metrics;
...@@ -74,16 +77,17 @@ CMathMatrix.prototype.old_recalculateSize = function() ...@@ -74,16 +77,17 @@ CMathMatrix.prototype.old_recalculateSize = function()
this.size = {width: width, height: height, center: height/2}; this.size = {width: width, height: height, center: height/2};
} }
CMathMatrix.prototype.setLineGapColumn = function(coeff) CMathMatrix.prototype.old_setLineGapColumn = function(coeff)
{ {
this.lineGapColumn = coeff; this.lineGapColumn = coeff;
this.recalculateSize(); this.recalculateSize();
} }
CMathMatrix.prototype.setLineGapRow = function(coeff) CMathMatrix.prototype.old_setLineGapRow = function(coeff)
{ {
this.lineGapRow = coeff; this.lineGapRow = coeff;
this.recalculateSize(); this.recalculateSize();
} }
CMathMatrix.prototype.recalculateSize = function() CMathMatrix.prototype.recalculateSize = function()
{ {
this.gaps = {row: new Array(), column: new Array()}; this.gaps = {row: new Array(), column: new Array()};
...@@ -115,7 +119,29 @@ CMathMatrix.prototype.recalculateSize = function() ...@@ -115,7 +119,29 @@ 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];
this.size = {width: width, height: height, center: height/2}; var center = 0;
if(this.baseJc == 1)
{
for(var j = 0; j < this.nCol; j++)
center = this.elements[0][j].size.center > center ? this.elements[0][j].size.center : center;
}
else if(this.baseJc == 2)
{
var descent = 0,
currDsc;
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;
descent = currDsc > descent ? currDsc : descent;
center = height - descent;
}
}
else /*this.baseJc == 0*/
center = height/2;
this.size = {width: width, height: height, center: center};
} }
CMathMatrix.prototype.setPosition = function(pos) CMathMatrix.prototype.setPosition = function(pos)
...@@ -144,6 +170,7 @@ CMathMatrix.prototype.setPosition = function(pos) ...@@ -144,6 +170,7 @@ CMathMatrix.prototype.setPosition = function(pos)
} }
} }
CMathMatrix.prototype.old_old_findDisposition = function( coord ) CMathMatrix.prototype.old_old_findDisposition = function( coord )
{ {
var pos_x = this.nRow - 1, pos_y = this.nCol - 1, var pos_x = this.nRow - 1, pos_y = this.nCol - 1,
...@@ -217,6 +244,7 @@ CMathMatrix.prototype.old_old_findDisposition = function( coord ) ...@@ -217,6 +244,7 @@ CMathMatrix.prototype.old_old_findDisposition = function( coord )
return {pos: {x: pos_x, y: pos_y }, mCoord: {x: mX, y: mY}, flag: flag}; return {pos: {x: pos_x, y: pos_y }, mCoord: {x: mX, y: mY}, flag: flag};
} }
CMathMatrix.prototype.findDisposition = function( coord ) CMathMatrix.prototype.findDisposition = function( coord )
{ {
var mouseCoord = {x: null, y: null}, var mouseCoord = {x: null, y: null},
...@@ -319,7 +347,7 @@ CMathMatrix.prototype.getMetrics = function() ...@@ -319,7 +347,7 @@ CMathMatrix.prototype.getMetrics = function()
return {ascents: Ascents, descents: Descents, widths: Widths} return {ascents: Ascents, descents: Descents, widths: Widths}
} }
CMathMatrix.prototype.findDistance = function() CMathMatrix.prototype.findDistance = function() // для получения позиции тагета
{ {
var w = 0, h = 0; var w = 0, h = 0;
//кол-во элементов gap равно кол-ву элементов в строке/столбце для удобства подсчета //кол-во элементов gap равно кол-ву элементов в строке/столбце для удобства подсчета
...@@ -393,7 +421,7 @@ CMathMatrix.prototype.getLineGap = function(space) ...@@ -393,7 +421,7 @@ CMathMatrix.prototype.getLineGap = function(space)
return lineGap; return lineGap;
} }
////
CMathMatrix.prototype.old_getRowSpace = function(space) CMathMatrix.prototype.old_getRowSpace = function(space)
{ {
var spLine; var spLine;
...@@ -415,9 +443,9 @@ CMathMatrix.prototype.old_getRowSpace = function(space) ...@@ -415,9 +443,9 @@ CMathMatrix.prototype.old_getRowSpace = function(space)
var lineGap; var lineGap;
/*if(space.rule == 3) /*if(space.rule == 3)
lineGap = spLine*g_dKoef_pt_to_mm; //pt lineGap = spLine*g_dKoef_pt_to_mm; //pt
else else
lineGap = spLine*this.params.font.FontSize*g_dKoef_pt_to_mm; //em*/ lineGap = spLine*this.params.font.FontSize*g_dKoef_pt_to_mm; //em*/
lineGap = spLine*g_dKoef_pt_to_mm; //pt lineGap = spLine*g_dKoef_pt_to_mm; //pt
...@@ -425,7 +453,6 @@ CMathMatrix.prototype.old_getRowSpace = function(space) ...@@ -425,7 +453,6 @@ CMathMatrix.prototype.old_getRowSpace = function(space)
return lineGap; return lineGap;
} }
CMathMatrix.prototype.getRowSpace = function(space) CMathMatrix.prototype.getRowSpace = function(space)
{ {
var spLine; var spLine;
...@@ -456,3 +483,15 @@ CMathMatrix.prototype.getRowSpace = function(space) ...@@ -456,3 +483,15 @@ CMathMatrix.prototype.getRowSpace = function(space)
return lineGap; return lineGap;
} }
CMathMatrix.prototype.baseJustification = function(type)
{
// 0 - center
// 1 - top
// 2 - bottom
this.baseJc = type;
}
////
...@@ -97,7 +97,6 @@ CBaseBracket.prototype.goToLowerLevel = function(coord){ ...@@ -97,7 +97,6 @@ CBaseBracket.prototype.goToLowerLevel = function(coord){
content = null; content = null;
return {bLow: bLow, content: content}; return {bLow: bLow, content: content};
} }
function CParenthesis() function CParenthesis()
......
...@@ -120,13 +120,17 @@ function getStateHeight_2(height, GFont) ...@@ -120,13 +120,17 @@ function getStateHeight_2(height, GFont)
return state; return state;
} }
function getTypeDegree(IFont) function getTypeDegree(IFont, flag)
{ {
var old_CONST_DEG = 0.728;
var CONST_DEG = 0.728;
var fontSize = null; var fontSize = null;
var sD = IFont.FontSize*CONST_DEG; if(flag)
CONST_INDEX = 0.62;
else
CONST_INDEX = 0.728;
var sD = IFont.FontSize*CONST_INDEX;
if( sD - Math.floor(sD) > 0.65 ) if( sD - Math.floor(sD) > 0.65 )
fontSize = Math.ceil(sD) - 0.5; fontSize = Math.ceil(sD) - 0.5;
else else
...@@ -164,13 +168,16 @@ function getStateHeight_3( height, GFont) //for radical ...@@ -164,13 +168,16 @@ function getStateHeight_3( height, GFont) //for radical
GenHeight; GenHeight;
var gap = metric.Height - metric.Placeholder.Height; var gap = metric.Height - metric.Placeholder.Height;
var H1 = metric.Height, var H0 = metric.Placeholder.Height,
H1 = metric.Height,
H2 = 2*metric.Placeholder.Height + 1.5*gap, H2 = 2*metric.Placeholder.Height + 1.5*gap,
H3 = 3*metric.Placeholder.Height + 2.4*gap, H3 = 3*metric.Placeholder.Height + 2.4*gap,
H4 = 4*metric.Placeholder.Height + 3*gap, H4 = 4*metric.Placeholder.Height + 3*gap,
H5 = 5*metric.Placeholder.Height + 4*gap; H5 = 5*metric.Placeholder.Height + 4*gap;
if( height < H1 ) if(height < H0)
GenHeight = H1*0.75;
else if( height < H1 )
GenHeight = H1; GenHeight = H1;
else if( height < H2 ) else if( height < H2 )
GenHeight = H2; GenHeight = H2;
......
function getHeightTick(metrics, height)
{
var minHgtRad = metrics.Height * 0.75,
maxHgtRad = 4*metrics.Height + metrics.Placeholder.Height;
var minHgtTick = metrics.Placeholder.Height*0.6,
maxHgtTick = metrics.Height;
var heightTick;
if ( height > maxHgtRad )
heightTick = maxHgtTick;
else
{
var alpha = (height - minHgtRad)/maxHgtRad;
heightTick = minHgtTick*(1 + alpha);
}
return heightTick;
}
function 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 penW = this.params.font.FontSize*g_dKoef_pt_to_mm*0.042;
var minHeight = this.params.font.metrics.Height * 0.75,
maxHeight = 4*this.params.font.metrics.Height + this.params.font.metrics.Placeholder.Height;
var maxWidth = 1.6*(this.params.font.metrics.Height - this.params.font.metrics.Placeholder.Height);
var coeff = 0.2*maxWidth/(maxHeight - minHeight),
b = maxWidth*0.3 - coeff*minHeight;
var heightTick = getHeightTick(this.params.font.metrics, Height);
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_DrawingRadical()
{
var x = this.pos.x,
y = this.pos.y;
var Height = this.size.height,
Width = this.size.width;
var penW = this.params.font.FontSize*g_dKoef_pt_to_mm*0.042;
var minHeight = this.params.font.metrics.Height,
maxHeight = 4*this.params.font.metrics.Height + this.params.font.metrics.Placeholder.Height;
var minHgtTick = this.params.font.metrics.Placeholder.Height*2/3,
maxHgtTick = this.params.font.metrics.Height;
var maxWidth = 1.6*(this.params.font.metrics.Height - this.params.font.metrics.Placeholder.Height);
if ( this.size.height > maxHeight )
heightTick = maxHgtTick;
else
{
var alpha = (this.size.height - minHeight)/maxHeight;
heightTick = minHgtTick*(1 + alpha);
}
var coeff = 0.2*maxWidth/(maxHeight - minHeight),
b = maxWidth*0.3 - coeff*minHeight;
var tX = 1.7*penW * 0.5 * 25.4/96,
tY = (-1)*tX * 11/25 *0.5; // 11/25 - тангенс угла наклона
var x1 = x,
x2 = x + 0.25*maxWidth;
var y2 = y + this.size.height - heightTick,
y1 = y2 + 0.11*maxWidth;
var x3 = x2 - tX,
y3 = y2 - tY;
if(this.size.height < maxHeight)
x4 = x3 + coeff*this.size.height + b;
else
x4 = x3 + coeff*maxHeight + b;
var y4 = y + this.size.height;
var x5 = x + maxWidth,
x6 = x + this.size.width;
var y5 = y,
y6 = 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 CRadical() function CRadical()
{ {
this.gapTop = 0; this.gapTop = 0;
this.gapLeft = 0; this.gapLeft = 0;
this.shRadical =
{
x: 0,
y: 0
};
this.heightTick = 0;
CMathBase.call(this, 1, 1); CMathBase.call(this, 1, 1);
} }
extend(CRadical, CMathBase); extend(CRadical, CMathBase);
...@@ -21,7 +198,7 @@ CRadical.prototype._old_old_recalculateSize = function() ...@@ -21,7 +198,7 @@ CRadical.prototype._old_old_recalculateSize = function()
this.gap_radical.left = 0.15*h + (0.1*sizeArg.height + 0.3*h)*0.8 - sizeArg.height*0.05 + (maxH - sizeArg.height)/20; this.gap_radical.left = 0.15*h + (0.1*sizeArg.height + 0.3*h)*0.8 - sizeArg.height*0.05 + (maxH - sizeArg.height)/20;
this.gap_radical.top = 2*w; this.gap_radical.top = 2*w;
var height = sizeArg.height + this.gap_radical.top, var height = sizeArg.height + this.gap_radical.top,
center = sizeArg.center + this.gap_radical.top, center = sizeArg.center + this.gap_radical.top,
width = sizeArg.width + this.gap_radical.left; width = sizeArg.width + this.gap_radical.left;
...@@ -41,8 +218,8 @@ CRadical.prototype.old_recalculateSize = function() ...@@ -41,8 +218,8 @@ CRadical.prototype.old_recalculateSize = function()
top *= 0.21; top *= 0.21;
/*var height, width, center, /*var height, width, center,
top = 3.5*this.params.type.font.FontSize/47, top = 3.5*this.params.type.font.FontSize/47,
left = 1.6*(this.params.type.metrics.Height - this.params.type.metrics.Placeholder.Height);*/ left = 1.6*(this.params.type.metrics.Height - this.params.type.metrics.Placeholder.Height);*/
var penW = 1; var penW = 1;
left += penW/2; left += penW/2;
...@@ -67,7 +244,6 @@ CRadical.prototype.old_recalculateSize = function() ...@@ -67,7 +244,6 @@ CRadical.prototype.old_recalculateSize = function()
CRadical.prototype.recalculateSize = function() CRadical.prototype.recalculateSize = function()
{ {
var arg = this.elements[0][0].size; var arg = this.elements[0][0].size;
//var minHeight = this.params.type.metrics.Height;
var height, width, center, var height, width, center,
left = 1.85*(this.params.font.metrics.Height - this.params.font.metrics.Placeholder.Height); left = 1.85*(this.params.font.metrics.Height - this.params.font.metrics.Placeholder.Height);
...@@ -110,17 +286,17 @@ CRadical.prototype.mouseMove = function(pos) ...@@ -110,17 +286,17 @@ CRadical.prototype.mouseMove = function(pos)
//context.fill() для заливки //context.fill() для заливки
//Graphics : df() //Graphics : df()
CRadical.prototype.old_draw = function() CRadical.prototype.old_old_draw = function()
{ {
var x = this.pos.x, var x = this.pos.x,
y = this.pos.y; y = this.pos.y;
/*var penW = this.params.type.font.FontSize/12.5; /*var penW = this.params.type.font.FontSize/12.5;
penW = parseInt(penW + 0.5); penW = parseInt(penW + 0.5);
penW = 72 / 25.4; penW = 72 / 25.4;
if(penW == 0) if(penW == 0)
penW = 1;*/ penW = 1;*/
//var penW = 96/25.4; //var penW = 96/25.4;
//var penW = 1; //px //var penW = 1; //px
...@@ -199,48 +375,541 @@ CRadical.prototype.old_draw = function() ...@@ -199,48 +375,541 @@ CRadical.prototype.old_draw = function()
/*MathControl.pGraph.p_width(1000); /*MathControl.pGraph.p_width(1000);
MathControl.pGraph.b_color1(255,0,0, 255); MathControl.pGraph.b_color1(255,0,0, 255);
MathControl.pGraph._s();
MathControl.pGraph._m(x1*100, y1*100);
MathControl.pGraph._l(x2*100, y2*100);
MathControl.pGraph.ds();
MathControl.pGraph.p_width(1000);
MathControl.pGraph._s();
MathControl.pGraph._m(x2*100, y2*100);
MathControl.pGraph._l(x3*100, y3*100);
MathControl.pGraph.ds();*/
/*MathControl.pGraph.p_width(penW*1000);
MathControl.pGraph._s();
MathControl.pGraph._m(x3*100, y3*100);
MathControl.pGraph._l(x4*100, y4*100);
MathControl.pGraph._l(x5*100,y5*100);
MathControl.pGraph.ds();*/
this.elements[0][0].draw();
}
CRadical.prototype.old_draw = function()
{
//this.elements[0][0].draw();
CRadical.superclass.draw.call(this);
var x = this.pos.x,
y = this.pos.y;
var penW = this.params.font.FontSize*g_dKoef_pt_to_mm*0.042;
var minHeight = this.params.font.metrics.Height,
maxHeight = 4*this.params.font.metrics.Height + this.params.font.metrics.Placeholder.Height;
var minHgtTick = this.params.font.metrics.Placeholder.Height*2/3,
maxHgtTick = this.params.font.metrics.Height;
var maxWidth = 1.6*(this.params.font.metrics.Height - this.params.font.metrics.Placeholder.Height);
if ( this.size.height > maxHeight )
heightTick = maxHgtTick;
else
{
var alpha = (this.size.height - minHeight)/maxHeight;
heightTick = minHgtTick*(1 + alpha);
}
var coeff = 0.2*maxWidth/(maxHeight - minHeight),
b = maxWidth*0.3 - coeff*minHeight;
var tX = 1.7*penW * 0.5 * 25.4/96,
tY = (-1)*tX * 11/25 *0.5; // 11/25 - тангенс угла наклона
var x1 = x,
x2 = x + 0.25*maxWidth;
var y2 = y + this.size.height - heightTick,
y1 = y2 + 0.11*maxWidth;
var x3 = x2 - tX,
y3 = y2 - tY;
if(this.size.height < maxHeight)
x4 = x3 + coeff*this.size.height + b;
else
x4 = x3 + coeff*maxHeight + b;
var y4 = y + this.size.height;
var x5 = x + maxWidth,
x6 = x + this.size.width;
var y5 = y,
y6 = 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();
}
CRadical.prototype.draw = function()
{
CRadical.superclass.draw.call(this);
DrawingRadical.call(this);
}
function 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(CDegreeRadical, CMathBase);
CDegreeRadical.prototype.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);
}
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 = getStateHeight_3(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)
{
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 });
}
CDegreeRadical.prototype.draw = function()
{
CDegreeRadical.superclass.draw.call(this);
DrawingRadical.call(this);
}
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};
}
function old_CRadical()
{
this.gapTop = 0;
this.gapLeft = 0;
CMathBase.call(this, 1, 1);
}
extend(old_CRadical, CMathBase);
old_CRadical.prototype.setContent = function()
{
this.fillPlaceholders();
}
old_CRadical.prototype._old_old_recalculateSize = function()
{
var sizeArg = this.elements[0][0].size;
var w = l = this.params.font.FontSize/47,
h = this.params.font.metrics.Height;
var maxH = getMaxHeight(this.params.font);
this.gap_radical.left = 0.15*h + (0.1*sizeArg.height + 0.3*h)*0.8 - sizeArg.height*0.05 + (maxH - sizeArg.height)/20;
this.gap_radical.top = 2*w;
var height = sizeArg.height + this.gap_radical.top,
center = sizeArg.center + this.gap_radical.top,
width = sizeArg.width + this.gap_radical.left;
height = height < h ? h : height;
this.size = {height: height, width: width, center: center};
}
old_CRadical.prototype.old_recalculateSize = function()
{
var sizeArg = this.elements[0][0].size;
var minHeight = this.params.font.metrics.Height;
var height, width, center,
top = this.params.font.FontSize*g_dKoef_pt_to_mm,
left = 1.6*(this.params.font.metrics.Height - this.params.font.metrics.Placeholder.Height);
top *= 0.21;
/*var height, width, center,
top = 3.5*this.params.type.font.FontSize/47,
left = 1.6*(this.params.type.metrics.Height - this.params.type.metrics.Placeholder.Height);*/
var penW = 1;
left += penW/2;
var sh = this.params.font.FontSize * 25.4/96;
left += sh * 0.1;
if(sizeArg.height < minHeight - top)
height = minHeight;
else
height = sizeArg.height + top;
ascentArg = sizeArg.height - sizeArg.center;
center = height - ascentArg;
width = left + sizeArg.width;
this.gapLeft = left;
this.gapTop = height - sizeArg.height;
this.size = {width: width, height: height, center: center};
}
old_CRadical.prototype.recalculateSize = function()
{
var arg = this.elements[0][0].size;
var height, width, center,
left = 1.85*(this.params.font.metrics.Height - this.params.font.metrics.Placeholder.Height);
var top = this.params.font.FontSize*g_dKoef_pt_to_mm*0.15;
var penW = this.params.font.FontSize*g_dKoef_pt_to_mm*0.042;
//var penW = 1* 25.4/96; //mm
height = getStateHeight_3(arg.height + top, this.params.font);
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.old_draw = function()
{
var x = this.pos.x,
y = this.pos.y;
/*var penW = this.params.type.font.FontSize/12.5;
penW = parseInt(penW + 0.5);
penW = 72 / 25.4;
if(penW == 0)
penW = 1;*/
//var penW = 96/25.4;
//var penW = 1; //px
var penW = this.params.font.FontSize*g_dKoef_pt_to_mm*0.042;
penW *= 96/25.4;
var minHeight = this.params.font.metrics.Height,
maxHeight = 4*this.params.font.metrics.Height + this.params.font.metrics.Placeholder.Height;
var minHgtTick = this.params.font.metrics.Placeholder.Height*2/3,
maxHgtTick = this.params.font.metrics.Height;
var maxWidth = 1.6*(this.params.font.metrics.Height - this.params.font.metrics.Placeholder.Height);
var coeff = 0.2*maxWidth/(maxHeight - minHeight),
b = maxWidth*0.3 - coeff*minHeight;
var x1 = x,
x2 = x + 0.2*maxWidth;
if(this.size.height < maxHeight)
x3 = x2 + coeff*this.size.height + b;
else
x3 = x2 + coeff*maxHeight + b;
var x4 = x + maxWidth,
x5 = x + this.size.width;
if ( this.size.height > maxHeight )
heightTick = maxHgtTick;
else
{
var alpha = (this.size.height - minHeight)/maxHeight;
heightTick = minHgtTick*(1 + alpha);
}
var y2 = y + this.size.height - heightTick,
y1 = y2 + 0.12*maxWidth,
y3 = y + this.size.height,
y4 = y,
y5 = y;
MathControl.pGraph.p_width(penW*0.8*1000);
MathControl.pGraph.b_color1(0,0,0, 255);
MathControl.pGraph._s(); MathControl.pGraph._s();
MathControl.pGraph._m(x1*100, y1*100); MathControl.pGraph._m(x1*100, y1*100);
MathControl.pGraph._l(x2*100, y2*100); MathControl.pGraph._l(x2*100, y2*100);
MathControl.pGraph.ds(); MathControl.pGraph.ds();
MathControl.pGraph.p_width(1000); MathControl.pGraph.p_width(penW*1000);
MathControl.pGraph._s(); MathControl.pGraph._s();
MathControl.pGraph._m(x2*100, y2*100); MathControl.pGraph._m(x2*100, y2*100);
MathControl.pGraph._l(x3*100, y3*100); MathControl.pGraph._l(x3*100, y3*100);
MathControl.pGraph.ds();*/ MathControl.pGraph.ds();
/*MathControl.pGraph.p_width(penW*1000); MathControl.pGraph.p_width(penW*1000);
MathControl.pGraph._s(); MathControl.pGraph._s();
MathControl.pGraph._m(x3*100, y3*100); MathControl.pGraph._m(x3*100, y3*100);
MathControl.pGraph._l(x4*100, y4*100); MathControl.pGraph._l(x4*100, y4*100);
MathControl.pGraph._l(x5*100,y5*100); MathControl.pGraph._l(x5*100,y5*100);
MathControl.pGraph.ds();*/ MathControl.pGraph.ds();
var tX = x2 + penW*0.5*25.4/96,
tY = y2 - penW*0.5*25.4/96*0.6;
MathControl.pGraph.p_width(penW*0.2*1000);
MathControl.pGraph.b_color1(255,0,0, 255);
MathControl.pGraph._s();
MathControl.pGraph._m(tX*100, tY*100);
MathControl.pGraph._l((tX+1)*100, tY*100);
MathControl.pGraph.ds();
/*MathControl.pGraph.p_width(1000);
MathControl.pGraph.b_color1(255,0,0, 255);
MathControl.pGraph._s();
MathControl.pGraph._m(x1*100, y1*100);
MathControl.pGraph._l(x2*100, y2*100);
MathControl.pGraph.ds();
MathControl.pGraph.p_width(1000);
MathControl.pGraph._s();
MathControl.pGraph._m(x2*100, y2*100);
MathControl.pGraph._l(x3*100, y3*100);
MathControl.pGraph.ds();*/
/*MathControl.pGraph.p_width(penW*1000);
MathControl.pGraph._s();
MathControl.pGraph._m(x3*100, y3*100);
MathControl.pGraph._l(x4*100, y4*100);
MathControl.pGraph._l(x5*100,y5*100);
MathControl.pGraph.ds();*/
this.elements[0][0].draw(); this.elements[0][0].draw();
} }
CRadical.prototype.draw = function() old_CRadical.prototype.draw = function()
{ {
this.elements[0][0].draw(); //this.elements[0][0].draw();
old_CRadical.superclass.draw.call(this);
var x = this.pos.x, var x = this.pos.x,
y = this.pos.y; y = this.pos.y;
/*var penW = this.params.type.font.FontSize/12.5;
penW = parseInt(penW + 0.5);
penW = 72 / 25.4;
if(penW == 0)
penW = 1;*/
//var penW = 96/25.4;
//var penW = 1; //px
var penW = this.params.font.FontSize*g_dKoef_pt_to_mm*0.042; var penW = this.params.font.FontSize*g_dKoef_pt_to_mm*0.042;
//penW *= 96/25.4;
var minHeight = this.params.font.metrics.Height, var minHeight = this.params.font.metrics.Height,
maxHeight = 4*this.params.font.metrics.Height + this.params.font.metrics.Placeholder.Height; maxHeight = 4*this.params.font.metrics.Height + this.params.font.metrics.Placeholder.Height;
...@@ -310,4 +979,4 @@ CRadical.prototype.draw = function() ...@@ -310,4 +979,4 @@ CRadical.prototype.draw = function()
MathControl.pGraph._l(x6,y6); MathControl.pGraph._l(x6,y6);
MathControl.pGraph.ds(); MathControl.pGraph.ds();
} }
\ No newline at end of file
...@@ -173,6 +173,7 @@ ...@@ -173,6 +173,7 @@
<script type="text/javascript" src ="Math/degree.js"></script> <script type="text/javascript" src ="Math/degree.js"></script>
<script type="text/javascript" src = "Math/matrix.js"></script> <script type="text/javascript" src = "Math/matrix.js"></script>
<script type="text/javascript" src = "Math/matrix.js"></script>
<script type="text/javascript" src = "Math/minimax.js"></script> <script type="text/javascript" src = "Math/minimax.js"></script>
<script type="text/javascript" src = "Math/logarithm.js"></script> <script type="text/javascript" src = "Math/logarithm.js"></script>
<script type="text/javascript" src = "Math/nary.js"></script> <script type="text/javascript" src = "Math/nary.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