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

finished equation

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@47507 954022d7-b5bf-4e40-9824-e11837661b57
parent 8e4fa62a
...@@ -359,7 +359,8 @@ CControlComposition.prototype = ...@@ -359,7 +359,8 @@ CControlComposition.prototype =
}, },
AddMathComponent: function(indef) AddMathComponent: function(indef)
{ {
this.Content[this.CurPos].AddMathComponent(indef); this.Content[this.CurPos].AddMathEquation(indef);
//this.Content[this.CurPos].AddMathComponent(indef);
}, },
Paragraph_Add: function(TextPr) Paragraph_Add: function(TextPr)
{ {
...@@ -369,6 +370,10 @@ CControlComposition.prototype = ...@@ -369,6 +370,10 @@ CControlComposition.prototype =
font[i] = TextPr[i]; font[i] = TextPr[i];
this.Content[this.CurPos].updateTextPrp(font); this.Content[this.CurPos].updateTextPrp(font);
},
DrawSelect2: function()
{
this.Content[0].DrawSelect2();
} }
} }
var MathControl = new CControlComposition(); var MathControl = new CControlComposition();
...@@ -1004,7 +1009,7 @@ function Create_Structures() ...@@ -1004,7 +1009,7 @@ function Create_Structures()
}; };
path = "url('Math/img/bracket_2.png')"; path = "url('Math/img/bracket_2.png')";
Set_Container(dim, path, 118); Set_Container(dim, path, 121);
dim = dim =
{ {
...@@ -1015,7 +1020,7 @@ function Create_Structures() ...@@ -1015,7 +1020,7 @@ function Create_Structures()
}; };
path = "url('Math/img/bracket_3.png')"; path = "url('Math/img/bracket_3.png')";
Set_Container(dim, path, 119); Set_Container(dim, path, 122);
} }
...@@ -1053,7 +1058,7 @@ function Create_Structures() ...@@ -1053,7 +1058,7 @@ function Create_Structures()
}; };
var path = "url('Math/img/trig_function.png')"; var path = "url('Math/img/trig_function.png')";
Set_Container(dim, path, 121); Set_Container(dim, path, 124);
dim = dim =
{ {
...@@ -1064,7 +1069,7 @@ function Create_Structures() ...@@ -1064,7 +1069,7 @@ function Create_Structures()
}; };
path = "url('Math/img/trig_function_1.png')"; path = "url('Math/img/trig_function_1.png')";
Set_Container(dim, path, 147); Set_Container(dim, path, 150);
} }
var Accent = document.createElement("div"); var Accent = document.createElement("div");
...@@ -1100,7 +1105,7 @@ function Create_Structures() ...@@ -1100,7 +1105,7 @@ function Create_Structures()
}; };
var path = "url('Math/img/accent.png')"; var path = "url('Math/img/accent.png')";
Set_Container(dim, path, 148); Set_Container(dim, path, 151);
dim = dim =
{ {
...@@ -1110,7 +1115,7 @@ function Create_Structures() ...@@ -1110,7 +1115,7 @@ function Create_Structures()
heightEqt: 80 heightEqt: 80
} }
path = "url('Math/img/accent_1.png')"; path = "url('Math/img/accent_1.png')";
Set_Container(dim, path, 168); Set_Container(dim, path, 171);
dim = dim =
{ {
...@@ -1120,7 +1125,7 @@ function Create_Structures() ...@@ -1120,7 +1125,7 @@ function Create_Structures()
heightEqt: 80 heightEqt: 80
} }
path = "url('Math/img/accent_2.png')"; path = "url('Math/img/accent_2.png')";
Set_Container(dim, path, 170); Set_Container(dim, path, 173);
dim = dim =
{ {
...@@ -1130,7 +1135,7 @@ function Create_Structures() ...@@ -1130,7 +1135,7 @@ function Create_Structures()
heightEqt: 80 heightEqt: 80
} }
path = "url('Math/img/accent_3.png')"; path = "url('Math/img/accent_3.png')";
Set_Container(dim, path, 171); Set_Container(dim, path, 174);
dim = dim =
{ {
...@@ -1150,7 +1155,7 @@ function Create_Structures() ...@@ -1150,7 +1155,7 @@ function Create_Structures()
heightEqt: 80 heightEqt: 80
} }
path = "url('Math/img/accent_4.png')"; path = "url('Math/img/accent_4.png')";
Set_Container(dim, path, 172); Set_Container(dim, path, 175);
dim = dim =
{ {
...@@ -1160,7 +1165,7 @@ function Create_Structures() ...@@ -1160,7 +1165,7 @@ function Create_Structures()
heightEqt: 80 heightEqt: 80
} }
path = "url('Math/img/accent_5.png')"; path = "url('Math/img/accent_5.png')";
Set_Container(dim, path, 173); Set_Container(dim, path, 176);
} }
...@@ -1198,7 +1203,7 @@ function Create_Structures() ...@@ -1198,7 +1203,7 @@ function Create_Structures()
}; };
var path = "url('Math/img/logarithm.png')"; var path = "url('Math/img/logarithm.png')";
Set_Container(dim, path, 174); Set_Container(dim, path, 177);
dim = dim =
{ {
...@@ -1209,7 +1214,7 @@ function Create_Structures() ...@@ -1209,7 +1214,7 @@ function Create_Structures()
}; };
path = "url('Math/img/logarithm_1.png')"; path = "url('Math/img/logarithm_1.png')";
Set_Container(dim, path, 180); Set_Container(dim, path, 183);
dim = dim =
{ {
...@@ -1220,7 +1225,7 @@ function Create_Structures() ...@@ -1220,7 +1225,7 @@ function Create_Structures()
}; };
path = "url('Math/img/logarithm_2.png')"; path = "url('Math/img/logarithm_2.png')";
Set_Container(dim, path, 181); Set_Container(dim, path, 184);
} }
var Operator = document.createElement("div"); var Operator = document.createElement("div");
...@@ -1256,7 +1261,7 @@ function Create_Structures() ...@@ -1256,7 +1261,7 @@ function Create_Structures()
}; };
var path = "url('Math/img/operators.png')"; var path = "url('Math/img/operators.png')";
Set_Container(dim, path, 182); Set_Container(dim, path, 185);
dim = dim =
{ {
...@@ -1267,7 +1272,7 @@ function Create_Structures() ...@@ -1267,7 +1272,7 @@ function Create_Structures()
}; };
path = "url('Math/img/operators_1.png')"; path = "url('Math/img/operators_1.png')";
Set_Container(dim, path, 189); Set_Container(dim, path, 192);
dim = dim =
{ {
...@@ -1278,7 +1283,7 @@ function Create_Structures() ...@@ -1278,7 +1283,7 @@ function Create_Structures()
}; };
path = "url('Math/img/operators_2.png')"; path = "url('Math/img/operators_2.png')";
Set_Container(dim, path, 201); Set_Container(dim, path, 204);
dim = dim =
{ {
...@@ -1289,7 +1294,7 @@ function Create_Structures() ...@@ -1289,7 +1294,7 @@ function Create_Structures()
}; };
path = "url('Math/img/operators_3.png')"; path = "url('Math/img/operators_3.png')";
Set_Container(dim, path, 202); Set_Container(dim, path, 205);
} }
...@@ -1326,7 +1331,7 @@ function Create_Structures() ...@@ -1326,7 +1331,7 @@ function Create_Structures()
}; };
var path = "url('Math/img/matrix.png')"; var path = "url('Math/img/matrix.png')";
Set_Container(dim, path, 203); Set_Container(dim, path, 206);
dim = dim =
{ {
...@@ -1337,7 +1342,7 @@ function Create_Structures() ...@@ -1337,7 +1342,7 @@ function Create_Structures()
}; };
path = "url('Math/img/matrix_1.png')"; path = "url('Math/img/matrix_1.png')";
Set_Container(dim, path, 223); Set_Container(dim, path, 226);
} }
MathDesign.bStruct = false; MathDesign.bStruct = false;
......
...@@ -913,6 +913,23 @@ CMathBase.prototype = ...@@ -913,6 +913,23 @@ CMathBase.prototype =
this.recalculateSize(); this.recalculateSize();
this.Parent.ResizeReverse(); this.Parent.ResizeReverse();
}, },
ResizeReverse_2: function() //for finished equation
{
this.ResizeDirect();
this.Parent.ResizeReverse();
},
ResizeDirect: function()
{
for(var i=0; i < this.nRow; i++)
for(var j = 0; j < this.nCol; j++)
{
if(! this.elements[i][j].IsJustDraw() )
this.elements[i][j].ResizeDirect();
}
this.recalculateSize();
},
getCenter: function(_height) getCenter: function(_height)
{ {
var res = 0; var res = 0;
...@@ -1010,5 +1027,9 @@ CMathBase.prototype = ...@@ -1010,5 +1027,9 @@ CMathBase.prototype =
for(var i=0; i < this.nRow; i++) for(var i=0; i < this.nRow; i++)
for(var j = 0; j < this.nCol; j++) for(var j = 0; j < this.nCol; j++)
this.elements[i][j].hidePlaceholder(flag); this.elements[i][j].hidePlaceholder(flag);
},
getElement: function(x, y)
{
return this.elements[x][y];
} }
} }
...@@ -213,4 +213,8 @@ CBorderBox.prototype.findDisposition = function(mCoord) ...@@ -213,4 +213,8 @@ CBorderBox.prototype.findDisposition = function(mCoord)
return {pos: posCurs, mCoord: coord, inside_flag: inside_flag}; return {pos: posCurs, mCoord: coord, inside_flag: inside_flag};
}
CBorderBox.prototype.getElement = function()
{
return this.elements[0][0];
} }
\ No newline at end of file
...@@ -12,6 +12,7 @@ function CDegree(type) ...@@ -12,6 +12,7 @@ function CDegree(type)
return degr; return degr;
} }
function CDegreeOrdinary(index) function CDegreeOrdinary(index)
{ {
this.index = index; this.index = index;
...@@ -20,7 +21,7 @@ function CDegreeOrdinary(index) ...@@ -20,7 +21,7 @@ function CDegreeOrdinary(index)
} }
extend(CDegreeOrdinary, CMathBase); extend(CDegreeOrdinary, CMathBase);
CDegreeOrdinary.prototype.SH_DEGR = 2/3; CDegreeOrdinary.prototype.SH_DEGR = 2/3;
CDegreeOrdinary.prototype.setContent = function() CDegreeOrdinary.prototype.old_setContent = function()
{ {
var oBase = null; var oBase = null;
if(arguments.length > 0) if(arguments.length > 0)
...@@ -41,6 +42,28 @@ CDegreeOrdinary.prototype.setContent = function() ...@@ -41,6 +42,28 @@ CDegreeOrdinary.prototype.setContent = function()
CDegreeOrdinary.superclass.setContent.call(this, oBase, oDegree); CDegreeOrdinary.superclass.setContent.call(this, oBase, oDegree);
}
CDegreeOrdinary.prototype.setContent = function()
{
var oBase = null;
if(arguments.length > 0)
oBase = arguments[0];
else
{
oBase = new CMathContent();
oBase.init( this.params );
oBase.relate(this);
oBase.fillPlaceholders();
}
var oDegree = new CMathContent();
oDegree.init( this.params );
oDegree.relate(this);
oDegree.fillPlaceholders();
oDegree.setFont(getTypeDegree(this.params.font), -1);
CDegreeOrdinary.superclass.setContent.call(this, oBase, oDegree);
} }
CDegreeOrdinary.prototype.recalculateSize = function() CDegreeOrdinary.prototype.recalculateSize = function()
{ {
...@@ -176,6 +199,65 @@ CDegreeOrdinary.prototype.findDisposition = function( mCoord ) ...@@ -176,6 +199,65 @@ CDegreeOrdinary.prototype.findDisposition = function( mCoord )
return {pos: {x: X, y: Y}, mCoord: mCoord, inside_flag: inside_flag}; return {pos: {x: X, y: Y}, mCoord: mCoord, inside_flag: inside_flag};
} }
CDegreeOrdinary.prototype.getIterator = function()
{
return this.elements[0][1];
}
CDegreeOrdinary.prototype.getUpperIterator = function()
{
return this.elements[0][1];
}
CDegreeOrdinary.prototype.getLowerIterator = function()
{
return this.elements[0][1];
}
CDegreeOrdinary.prototype.getBase = function()
{
return this.elements[0][0];
}
function CIterators()
{
CMathBase.call(this, 2, 1);
}
extend(CIterators, CMathBase);
CIterators.prototype.setDistance = function()
{
var descF = this.elements[0][0].size.height - this.elements[0][0].size.center ,
ascS = this.elements[1][0].size.center ;
var up = 0;
var down = 0;
if(this.lUp > descF)
up = this.lUp - descF;
if( this.lD > ascS )
down = this.lD - ascS;
this.dH = up + down;
this.dW = 0;
}
CIterators.prototype.getCenter = function()
{
var center = 0;
var descF = this.elements[0][0].size.height - this.elements[0][0].size.center;
if( this.lUp > descF )
center = this.elements[0][0].size.center + this.lUp;
else
center = this.elements[0][0].size.height;
return center;
}
CIterators.prototype.getUpperIterator = function()
{
return this.elements[0][0];
}
CIterators.prototype.getLowerIterator = function()
{
return this.elements[1][0];
}
function CDegreeSubSup(type) function CDegreeSubSup(type)
{ {
...@@ -183,7 +265,7 @@ function CDegreeSubSup(type) ...@@ -183,7 +265,7 @@ function CDegreeSubSup(type)
this.type = type; this.type = type;
} }
extend(CDegreeSubSup, CSubMathBase); extend(CDegreeSubSup, CSubMathBase);
CDegreeSubSup.prototype.setContent = function() CDegreeSubSup.prototype.old_setContent = function()
{ {
var oBase = null; var oBase = null;
...@@ -197,54 +279,58 @@ CDegreeSubSup.prototype.setContent = function() ...@@ -197,54 +279,58 @@ CDegreeSubSup.prototype.setContent = function()
oBase.fillPlaceholders(); oBase.fillPlaceholders();
} }
var oDegree = new CMathBase(2, 1); var oIters = new CIterators();
oDegree.init( this.params ); oIters.init( this.params );
oDegree.relate(this); oIters.relate(this);
oDegree.fillPlaceholders(); oIters.fillPlaceholders();
oDegree.setFont(getTypeDegree(this.params.font), -1); oIters.setFont(getTypeDegree(this.params.font), -1);
oDegree.setDistance = function() {
var metrics = this.params.font.metrics;
var descF = this.elements[0][0].size.height - this.elements[0][0].size.center ,
ascS = this.elements[1][0].size.center ;
var up = 0; oIters.lUp = 0;
var down = 0; oIters.lD = 0;
if(this.lUp > descF)
up = this.lUp - descF;
if( this.lD > ascS )
down = this.lD - ascS;
this.dH = up + down; if(this.type == 0)
this.dW = 0; {
oIters.alignHor(-1, 0);
}; CDegreeSubSup.superclass.setContent.call(this, oBase, oIters);
oDegree.getCenter = function() }
else
{ {
var center = 0; oIters.alignHor(-1, 1);
var descF = this.elements[0][0].size.height - this.elements[0][0].size.center; CDegreeSubSup.superclass.setContent.call(this, oIters, oBase);
}
}
CDegreeSubSup.prototype.setContent = function()
{
if( this.lUp > descF ) var oBase = null;
center = this.elements[0][0].size.center + this.lUp; if(arguments.length > 0)
else oBase = arguments[0];
center = this.elements[0][0].size.height; else
{
oBase = new CMathContent(1, 1);
oBase.init( this.params );
oBase.relate(this);
oBase.fillPlaceholders();
}
return center; var oIters = new CIterators();
}; oIters.init( this.params );
oIters.relate(this);
oIters.fillPlaceholders();
oIters.setFont(getTypeDegree(this.params.font), -1);
oDegree.lUp = 0; oIters.lUp = 0;
oDegree.lD = 0; oIters.lD = 0;
if(this.type == 0) if(this.type == 0)
{ {
oDegree.alignHor(-1, 0); oIters.alignHor(-1, 0);
CDegreeSubSup.superclass.setContent.call(this, oBase, oDegree); CDegreeSubSup.superclass.setContent.call(this, oBase, oIters);
} }
else else
{ {
oDegree.alignHor(-1, 1); oIters.alignHor(-1, 1);
CDegreeSubSup.superclass.setContent.call(this, oDegree, oBase); CDegreeSubSup.superclass.setContent.call(this, oIters, oBase);
} }
} }
CDegreeSubSup.prototype.recalculateSize = function() CDegreeSubSup.prototype.recalculateSize = function()
...@@ -266,6 +352,40 @@ CDegreeSubSup.prototype.recalculateSize = function() ...@@ -266,6 +352,40 @@ CDegreeSubSup.prototype.recalculateSize = function()
CSubMathBase.superclass.recalculateSize.call(this); CSubMathBase.superclass.recalculateSize.call(this);
} }
CDegreeSubSup.prototype.getBase = function()
{
var base;
if(this.type == 0)
base = this.elements[0][0];
else
base = this.elements[0][1];
return base;
}
CDegreeSubSup.prototype.getUpperIterator = function()
{
var iter;
if(this.type == 0)
iter = this.elements[0][1].getUpperIterator();
else
iter = this.elements[0][0].getUpperIterator();
return iter;
}
CDegreeSubSup.prototype.getLowerIterator = function()
{
var iter;
if(this.type == 0)
iter = this.elements[0][1].getLowerIterator();
else
iter = this.elements[0][0].getLowerIterator();
return iter;
}
//выяcнить: почему и с этой ф-ией и без нее работает всё ok... //выяcнить: почему и с этой ф-ией и без нее работает всё ok...
//всё ok, т.к. в контенте 2 элемента, и их center сравниваем //всё ok, т.к. в контенте 2 элемента, и их center сравниваем
/*CDegreeSubSup.prototype.getCenter = function() /*CDegreeSubSup.prototype.getCenter = function()
......
...@@ -78,6 +78,10 @@ CBaseDiacritic.prototype.IsIncline = function() ...@@ -78,6 +78,10 @@ CBaseDiacritic.prototype.IsIncline = function()
return this.elements[0][0].IsIncline(); return this.elements[0][0].IsIncline();
} }
CBaseDiacritic.prototype.getBase = function()
{
return this.elements[0][0];
}
function CCircumflex(id) function CCircumflex(id)
{ {
......
...@@ -10381,5 +10381,11 @@ CDocument.prototype = ...@@ -10381,5 +10381,11 @@ CDocument.prototype =
var Coords = this.DrawingDocument.ConvertCoordsToCursorWR( Comment_X, Comment_Y, Comment_PageNum ); var Coords = this.DrawingDocument.ConvertCoordsToCursorWR( Comment_X, Comment_Y, Comment_PageNum );
editor.sync_UpdateCommentPosition( Comment.Get_Id(), Coords.X, Coords.Y ); editor.sync_UpdateCommentPosition( Comment.Get_Id(), Coords.X, Coords.Y );
} }
},
Selection_Draw_Page: function()
{
//var i = 100;
MathControl.DrawSelect2();
} }
}; };
...@@ -39,7 +39,14 @@ CBarFraction.prototype.draw = function() ...@@ -39,7 +39,14 @@ CBarFraction.prototype.draw = function()
CBarFraction.superclass.draw.call(this); 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();
}
////////// //////////
function CNumerator() function CNumerator()
...@@ -132,6 +139,10 @@ CNumerator.prototype.setPosition = function(pos) ...@@ -132,6 +139,10 @@ CNumerator.prototype.setPosition = function(pos)
this.elements[0][0].setPosition({x: x, y: y}); this.elements[0][0].setPosition({x: x, y: y});
} }
CNumerator.prototype.getElement = function(txt)
{
return this.elements[0][0];
}
function CDenominator() function CDenominator()
{ {
...@@ -232,6 +243,10 @@ CDenominator.prototype.setGapCoeff = function(coeff) ...@@ -232,6 +243,10 @@ CDenominator.prototype.setGapCoeff = function(coeff)
this.recalculateSize(); this.recalculateSize();
} }
} }
CDenominator.prototype.getElement = function(txt)
{
return this.elements[0][0];
}
////////// //////////
...@@ -425,6 +440,14 @@ CSkewedFraction.prototype.draw = function() ...@@ -425,6 +440,14 @@ CSkewedFraction.prototype.draw = function()
MathControl.pGraph._l(xx2, yy2); MathControl.pGraph._l(xx2, yy2);
MathControl.pGraph.ds(); MathControl.pGraph.ds();
} }
CSkewedFraction.prototype.getNumerator = function()
{
return this.elements[0][0];
}
CSkewedFraction.prototype.getDenominator = function()
{
return this.elements[0][1];
}
////////// //////////
...@@ -503,6 +526,14 @@ CLinearFraction.prototype.draw = function() ...@@ -503,6 +526,14 @@ CLinearFraction.prototype.draw = function()
CLinearFraction.superclass.draw.call(this); CLinearFraction.superclass.draw.call(this);
} }
CLinearFraction.prototype.getNumerator = function()
{
return this.elements[0][0];
}
CLinearFraction.prototype.getDenominator = function()
{
return this.elements[0][1];
}
///////// /////////
......
var NameFunctions = ["min", "max", "lim", "log", "ln", "sin", "cos", "tg", "ctg", "ch", "sh", "th", "cth", "sec", "csc", "cot", "csch", "sech", "coth"]; //var NameFunctions = ["min", "max", "lim", "log", "ln", "sin", "cos", "tg", "ctg", "ch", "sh", "th", "cth", "sec", "csc", "cot", "csch", "sech", "coth"];
//var NameFunctions = ["min", "max", "lim", "log", "ln", "sin", "cos", "tan", "ctg", "cosh", "sinh", "tanh", "cth", "sec", "csc", "cot", "csch", "sech", "coth"];
var Diff = ["dx","dy",""]; var Diff = ["dx","dy",""];
function CLogarithm() function CLogarithm()
...@@ -13,7 +14,7 @@ CLogarithm.prototype.setContent = function() ...@@ -13,7 +14,7 @@ CLogarithm.prototype.setContent = function()
GParams.bMText = false; GParams.bMText = false;
oBase.init(GParams); oBase.init(GParams);
oBase.relate(this); oBase.relate(this);
oBase.addText(NameFunctions[3]); oBase.addText("log");
//oBase.setContent.apply(oBase, NameFunctions.minimax[3] ); //oBase.setContent.apply(oBase, NameFunctions.minimax[3] );
...@@ -32,40 +33,81 @@ CLogarithm.prototype.setContent = function() ...@@ -32,40 +33,81 @@ CLogarithm.prototype.setContent = function()
CLogarithm.superclass.setContent.call(this, oFunc, oArg); CLogarithm.superclass.setContent.call(this, oFunc, oArg);
} }
CLogarithm.prototype.getFunction = function()
function CMinimax(num)
{ {
CSubMathBase.call(this, 1, 2); return this.elements[0][0].getBase();
if(this.num !== this.num - 0 && this.num < 0 && this.num > 2) }
this.num = 0; CLogarithm.prototype.getBase = function()
else {
this.num = num; return this.elements[0][0].getIterator();
}
CLogarithm.prototype.getArgument = function()
{
return this.elements[0][1];
}
function CMinimaxFunc(num)
{
this.num = num;
CMathBase.call(this, 2, 1);
} }
extend(CMinimax, CSubMathBase); extend(CMinimaxFunc, CMathBase);
CMinimax.prototype.setContent = function() CMinimaxFunc.prototype.setContent = function()
{ {
var oBase = new CMathContent(); var oBase = new CMathContent();
var GParams = Common_CopyObj(this.params); var GParams = Common_CopyObj(this.params);
GParams.bMText = false; GParams.bMText = false;
oBase.init(GParams); oBase.init(GParams);
oBase.relate(this); oBase.relate(this);
oBase.addText(NameFunctions[this.num]);
var oIter = new CMathBase(1,1); if(this.num == 0)
oBase.addText("min");
else if(this.num == 1)
oBase.addText("max");
else
oBase.addText("lim");
var oIter = new CMathContent();
GParams = Common_CopyObj(this.params); GParams = Common_CopyObj(this.params);
GParams.font = getTypeDegree(this.params.font); GParams.font = getTypeDegree(this.params.font);
oIter.init(GParams); oIter.init(GParams);
oIter.relate(this); oIter.relate(this);
oIter.fillPlaceholders(); oIter.fillPlaceholders();
var oFunc = new CMathBase(2, 1); CMinimaxFunc.superclass.setContent.call(this, oBase, oIter);
oFunc.getCenter = function() { return this.elements[0][0].size.center; }; }
CMinimaxFunc.prototype.getCenter = function()
{
return this.elements[0][0].size.center;
}
CMinimaxFunc.prototype.getBase = function()
{
return this.elements[0][0];
}
CMinimaxFunc.prototype.getIterator = function()
{
return this.elements[1][0];
}
function CMinimax(num)
{
CSubMathBase.call(this, 1, 2);
if(this.num !== this.num - 0 && this.num < 0 && this.num > 2)
this.num = 0;
else
this.num = num;
}
extend(CMinimax, CSubMathBase);
CMinimax.prototype.setContent = function()
{
var oFunc = new CMinimaxFunc(this.num);
oFunc.init(this.params); oFunc.init(this.params);
oFunc.relate(this); oFunc.relate(this);
oFunc.setContent(oBase, oIter); oFunc.setContent();
var oArg = new CMathBase(1, 1);
var oArg = new CMathContent();
oArg.init(this.params); oArg.init(this.params);
oArg.relate(this); oArg.relate(this);
oArg.fillPlaceholders(); oArg.fillPlaceholders();
...@@ -80,8 +122,20 @@ CMinimax.prototype.setDistance = function() ...@@ -80,8 +122,20 @@ CMinimax.prototype.setDistance = function()
this.dW = slashWidth(this.params.font); this.dW = slashWidth(this.params.font);
this.dH = 0; this.dH = 0;
} }
CMinimax.prototype.getFunction = function()
{
return this.elements[0][0].getBase();
}
CMinimax.prototype.getIterator = function()
{
return this.elements[0][0].getIterator();
}
CMinimax.prototype.getArgument = function()
{
return this.elements[0][1];
}
function CMathFunc(num) function old_CMathFunc(num)
{ {
if(num > 19) if(num > 19)
return; return;
...@@ -90,9 +144,9 @@ function CMathFunc(num) ...@@ -90,9 +144,9 @@ function CMathFunc(num)
CMathBase.call(this, 1,2); CMathBase.call(this, 1,2);
} }
//extend(CMathFunc,CSubMathBase); //extend(old_CMathFunc,CSubMathBase);
extend(CMathFunc, CMathBase); extend(old_CMathFunc, CMathBase);
CMathFunc.prototype.setContent = function() old_CMathFunc.prototype.setContent = function()
{ {
var oFunc = new CMathContent(); var oFunc = new CMathContent();
var GParms = Common_CopyObj(this.params); var GParms = Common_CopyObj(this.params);
...@@ -105,16 +159,16 @@ CMathFunc.prototype.setContent = function() ...@@ -105,16 +159,16 @@ CMathFunc.prototype.setContent = function()
oArg.init(this.params); oArg.init(this.params);
oArg.fillPlaceholders(); oArg.fillPlaceholders();
CMathFunc.superclass.setContent.call(this, oFunc, oArg); old_CMathFunc.superclass.setContent.call(this, oFunc, oArg);
} }
CMathFunc.prototype.setDistance = function() old_CMathFunc.prototype.setDistance = function()
{ {
//todo //todo
//переделать! //переделать!
this.dW = slashWidth(this.params.font); this.dW = slashWidth(this.params.font);
this.dH = 0; this.dH = 0;
} }
CMathFunc.prototype.addText = function(txt) old_CMathFunc.prototype.addText = function(txt)
{ {
this.elements[0][1].addText(txt); this.elements[0][1].addText(txt);
} }
...@@ -131,5 +185,38 @@ CDifferential.prototype.setContent = function() ...@@ -131,5 +185,38 @@ CDifferential.prototype.setContent = function()
oDiff.init(this.params); oDiff.init(this.params);
oDiff.addText(Diff[this.num]); oDiff.addText(Diff[this.num]);
CMathFunc.superclass.setContent.call(this, oDiff); old_CMathFunc.superclass.setContent.call(this, oDiff);
}
function CMathFunc()
{
CMathBase.call(this, 1,2);
}
extend(CMathFunc, CMathBase);
CMathFunc.prototype.setContent = function()
{
var oFunc = new CMathContent();
var GParms = Common_CopyObj(this.params);
GParms.bMText = false; //!!
oFunc.init(GParms);
var oArg = new CMathContent();
oArg.init(this.params);
oArg.fillPlaceholders();
CMathFunc.superclass.setContent.call(this, oFunc, oArg);
}
CMathFunc.prototype.setDistance = function()
{
this.dW = this.params.font.FontSize/6*g_dKoef_pt_to_mm;
this.dH = 0;
}
CMathFunc.prototype.getFunction = function()
{
return this.elements[0][0];
}
CMathFunc.prototype.getArgument = function()
{
return this.elements[0][1];
} }
\ No newline at end of file
...@@ -10,8 +10,8 @@ function dist(_left, _right, _top, _low) ...@@ -10,8 +10,8 @@ function dist(_left, _right, _top, _low)
function mathElem(_val, _gps, _w ) function mathElem(_val, _gps, _w )
{ {
this.value = _val; this.value = _val;
this.widthToEl = _w; // with this element
this.g_mContext = _gps; //mm this.g_mContext = _gps; //mm
this.widthToEl = _w; // with this element
} }
//TODO //TODO
...@@ -719,6 +719,7 @@ CMathContent.prototype = ...@@ -719,6 +719,7 @@ CMathContent.prototype =
this.recalculateSize(); this.recalculateSize();
this.update_widthContent(); this.update_widthContent();
}, },
draw: function() draw: function()
{ {
if( !(this.plhHide && this.IsTarget()) ) if( !(this.plhHide && this.IsTarget()) )
...@@ -1051,6 +1052,13 @@ CMathContent.prototype = ...@@ -1051,6 +1052,13 @@ CMathContent.prototype =
if(! this.bRoot ) if(! this.bRoot )
this.Parent.ResizeReverse(); this.Parent.ResizeReverse();
}, },
ResizeDirect: function() //for finished equation
{
for(var i = 0; i < this.content.length; i++)
this.content[i].value.ResizeDirect();
this.recalculate();
},
selectUse: function() selectUse: function()
{ {
return (this.selection.startPos !== this.selection.endPos); return (this.selection.startPos !== this.selection.endPos);
...@@ -1107,7 +1115,7 @@ CMathContent.prototype = ...@@ -1107,7 +1115,7 @@ CMathContent.prototype =
editor.WordControl.m_oLogicDocument.DrawingDocument.SelectEnabled(true); // select editor.WordControl.m_oLogicDocument.DrawingDocument.SelectEnabled(true); // select
/// ...Selectenabled(false) deselect, убираем слой /// ...Selectenabled(false) deselect, убираем слой
//editor.WordControl.m_oLogicDocument.DrawingDocument.TargetEnd(); //editor.WordControl.m_oLogicDocument.DrawingDocument.TargetEnd();
editor.WordControl.m_oLogicDocument.DrawingDocument.AddPageSelection(0,this.pos.x + this.content[start-1].widthToEl, this.pos.y, widthSelect, heightSelect ); //editor.WordControl.m_oLogicDocument.DrawingDocument.AddPageSelection(0,this.pos.x + this.content[start-1].widthToEl, this.pos.y, widthSelect, heightSelect );
editor.WordControl.m_oLogicDocument.DrawingDocument.SelectShow(); editor.WordControl.m_oLogicDocument.DrawingDocument.SelectShow();
//editor.WordControl.m_oLogicDocument.DrawingDocument.TargetStart(); //editor.WordControl.m_oLogicDocument.DrawingDocument.TargetStart();
} }
...@@ -1301,7 +1309,7 @@ CMathContent.prototype = ...@@ -1301,7 +1309,7 @@ CMathContent.prototype =
component = new CDelimiter(); component = new CDelimiter();
break; break;
case 12: case 12:
component = new CMathFunc(); // CMathMatrix(1, 2) component = new old_CMathFunc();
break; break;
} }
...@@ -1607,7 +1615,7 @@ CMathContent.prototype = ...@@ -1607,7 +1615,7 @@ CMathContent.prototype =
component = new CDelimiter(); component = new CDelimiter();
break; break;
case 13: case 13:
component = new CMathFunc(); // CMathMatrix(1, 2) component = new old_CMathFunc();
break; break;
} }
...@@ -1626,6 +1634,38 @@ CMathContent.prototype = ...@@ -1626,6 +1634,38 @@ CMathContent.prototype =
upLevel = this.Root; upLevel = this.Root;
return upLevel; return upLevel;
},
//// finished equation ////
addMathComponent_2: function(ind)
{
this.add_mathComponent(ind);
return this.content[this.CurPos - 1].value;
},
////
drawSelect2: function()
{
var start = this.selection.startPos;
var end = this.selection.endPos ;
if( start > end)
{
var tmp = start;
start = end;
end = tmp;
}
//var heightSelect = this.size.ascent + this.size.descent;
var heightSelect = this.size.height;
var widthSelect = 0;
for(var j= start; j < end ; j++)
widthSelect += this.content[j].widthToEl - this.content[j-1].widthToEl;
if( widthSelect != 0)
editor.WordControl.m_oLogicDocument.DrawingDocument.AddPageSelection(0,this.pos.x + this.content[start-1].widthToEl, this.pos.y, widthSelect, heightSelect );
} }
} }
...@@ -1871,7 +1911,6 @@ CMathComposition.prototype = ...@@ -1871,7 +1911,6 @@ CMathComposition.prototype =
this.ShowCursor(); this.ShowCursor();
}, },
//// ////
HideCursor: function() HideCursor: function()
{ {
editor.WordControl.m_oLogicDocument.DrawingDocument.TargetEnd(); editor.WordControl.m_oLogicDocument.DrawingDocument.TargetEnd();
...@@ -1934,7 +1973,7 @@ CMathComposition.prototype = ...@@ -1934,7 +1973,7 @@ CMathComposition.prototype =
}, },
/*TestFont: function(font) /*TestFont: function(font)
{ {
this.CurrentContent.TestFont(font); this.CurrentContent.TestFont(font);
},*/ },*/
//// ////
...@@ -1966,7 +2005,735 @@ CMathComposition.prototype = ...@@ -1966,7 +2005,735 @@ CMathComposition.prototype =
this.SelectContent = this.Root; this.SelectContent = this.Root;
this.CurrentContent = this.Root; this.CurrentContent = this.Root;
this.Root.recalculateSize(); this.Root.recalculateSize();
},
////
DrawSelect2: function()
{
this.SelectContent.drawSelect2();
},
//// finished equation ////
AddMathEquation: function (ind)
{
this.ClearSelect();
switch(ind)
{
case 4:
fraction = this.SelectContent.addMathComponent_2(0);
numerator = fraction.getNumerator();
numerator.addText("dy");
denominator = fraction.getDenominator();
denominator.addText("dx");
fraction.ResizeReverse_2();
break;
case 5:
fraction = this.SelectContent.addMathComponent_2(0);
numerator = fraction.getNumerator();
numerator.addText("Δy");
denominator = fraction.getDenominator();
denominator.addText("Δx");
fraction.ResizeReverse_2();
break;
case 6:
fraction = this.SelectContent.addMathComponent_2(0);
numerator = fraction.getNumerator();
numerator.addText("∂y");
denominator = fraction.getDenominator();
denominator.addText("∂x");
fraction.ResizeReverse_2();
break;
case 7:
fraction = this.SelectContent.addMathComponent_2(0);
numerator = fraction.getNumerator();
numerator.addText("δy");
denominator = fraction.getDenominator();
denominator.addText("δx");
fraction.ResizeReverse_2();
break;
case 8:
fraction = this.SelectContent.addMathComponent_2(0);
numerator = fraction.getNumerator();
numerator.addText("π");
denominator = fraction.getDenominator();
denominator.addText("2");
fraction.ResizeReverse_2();
break;
case 13:
degree = this.SelectContent.addMathComponent_2(10);
base = degree.getBase();
base.addText("x");
iterator = degree.getIterator();
degr_2 = iterator.addMathComponent_2(9);
base_2 = degr_2.getBase();
base_2.addText("y");
iter_2 = degr_2.getIterator();
iter_2.addText("2");
degr_2.ResizeReverse_2();
degree.ResizeReverse_2();
break;
case 14:
degree = this.SelectContent.addMathComponent_2(9);
base = degree.getBase();
base.addText("e");
iterator = degree.getIterator();
iterator.addText("-iωt");
degree.ResizeReverse_2();
break;
case 15:
degree = this.SelectContent.addMathComponent_2(9);
base = degree.getBase();
base.addText("x");
iterator = degree.getIterator();
iterator.addText("2");
degree.ResizeReverse_2();
break;
case 16:
degree = this.SelectContent.addMathComponent_2(12);
base = degree.getBase();
base.addText("Y");
iterator = degree.getUpperIterator();
iterator.addText("n");
iterator = degree.getLowerIterator();
iterator.addText("1");
degree.ResizeReverse_2();
break;
case 19:
radical = this.SelectContent.addMathComponent_2(18);
degr = radical.getDegree();
degr.addText("2");
radical.ResizeReverse_2();
break;
case 20:
radical = this.SelectContent.addMathComponent_2(18);
degr = radical.getDegree();
degr.addText("3");
radical.ResizeReverse_2();
break;
case 21:
fraction = this.SelectContent.addMathComponent_2(0);
numerator = fraction.getNumerator();
numerator.addText("-b±");
radical = numerator.addMathComponent_2(17);
baseRad = radical.getBase();
degree = baseRad.addMathComponent_2(9);
base = degree.getBase();
base.addText("b");
iter = degree.getIterator();
iter.addText("2");
baseRad.addText("-4ac");
denominator = fraction.getDenominator();
denominator.addText("2a");
fraction.ResizeReverse_2();
break;
case 22:
radical = this.SelectContent.addMathComponent_2(17);
baseRad = radical.getBase();
degree = baseRad.addMathComponent_2(9);
base = degree.getBase();
base.addText("a");
iter = degree.getIterator();
iter.addText("2");
baseRad.addText("+");
degree2 = baseRad.addMathComponent_2(9);
base2 = degree2.getBase();
base2.addText("b");
iter2 = degree2.getIterator();
iter2.addText("2");
radical.ResizeReverse_2();
break;
case 79:
nary = this.SelectContent.addMathComponent_2(47);
iter = nary.getLowerIterator();
iter.addText("k");
base = nary.getBase();
delimiter = base.addMathComponent_2(83);
delimBase = delimiter.getBase();
matrix = delimBase.addMathComponent_2(207);
matrElem = matrix.getElement(0, 0);
matrElem.addText("n");
matrElem2 = matrix.getElement(1, 0);
matrElem2.addText("k");
nary.ResizeReverse_2();
break;
case 80:
nary = this.SelectContent.addMathComponent_2(45);
iter = nary.getUpperIterator();
iter.addText("n");
iter = nary.getLowerIterator();
iter.addText("i=0");
nary.ResizeReverse_2();
break;
case 82:
nary = this.SelectContent.addMathComponent_2(60);
iterUp = nary.getUpperIterator();
iterUp.addText("m");
iterLow = nary.getLowerIterator();
iterLow.addText("n=1");
base = nary.getBase();
delimiter = base.addMathComponent_2(83);
delimBase = delimiter.getBase();
degr = delimBase.addMathComponent_2(10);
degrBase = degr.getBase();
degrBase.addText("X");
degrIter = degr.getIterator();
degrIter.addText("n");
delimBase.addText("");
degr2 = delimBase.addMathComponent_2(10);
degrBase2 = degr2.getBase();
degrBase2.addText("Y");
degrIter2 = degr2.getIterator();
degrIter2.addText("n");
nary.ResizeReverse_2();
break;
case 117:
delimiter = this.SelectContent.addMathComponent_2(103);
delimBase = delimiter.getBase();
delimBase.addMathComponent_2(207);
delimiter.ResizeReverse_2();
break;
case 118:
delimiter = this.SelectContent.addMathComponent_2(103);
delimBase = delimiter.getBase();
delimBase.addMathComponent_2(209);
delimiter.ResizeReverse_2();
break;
case 122:
delimiter = this.SelectContent.addMathComponent_2(83);
delimBase = delimiter.getBase();
matrix = delimBase.addMathComponent_2(207);
matrElem = matrix.getElement(0, 0);
matrElem.addText("n");
matrElem2 = matrix.getElement(1, 0);
matrElem2.addText("k");
delimiter.ResizeReverse_2();
break;
case 123:
delimiter = this.SelectContent.addMathComponent_2(86);
delimBase = delimiter.getBase();
matrix = delimBase.addMathComponent_2(207);
matrElem = matrix.getElement(0, 0);
matrElem.addText("n");
matrElem2 = matrix.getElement(1, 0);
matrElem2.addText("k");
delimiter.ResizeReverse_2();
break;
case 124:
this.SetTrigonometricFunc("sin");
break;
case 125:
this.SetTrigonometricFunc("cos");
break;
case 126:
this.SetTrigonometricFunc("tan");
break;
case 127:
this.SetTrigonometricFunc("csc");
break;
case 128:
this.SetTrigonometricFunc("sec");
break;
case 129:
this.SetTrigonometricFunc("cot");
break;
case 130:
this.SetDegrTrigFunc("sin");
break;
case 131:
this.SetDegrTrigFunc("cos");
break;
case 132:
this.SetDegrTrigFunc("tan");
break;
case 133:
this.SetDegrTrigFunc("csc");
break;
case 134:
this.SetDegrTrigFunc("sec");
break;
case 135:
this.SetDegrTrigFunc("cot");
break;
case 136:
this.SetTrigonometricFunc("sinh");
break;
case 137:
this.SetTrigonometricFunc("cosh");
break;
case 138:
this.SetTrigonometricFunc("tanh");
break;
case 139:
this.SetTrigonometricFunc("csch");
break;
case 140:
this.SetTrigonometricFunc("sech");
break;
case 141:
this.SetTrigonometricFunc("coth");
break;
case 142:
this.SetDegrTrigFunc("sinh");
break;
case 143:
this.SetDegrTrigFunc("cosh");
break;
case 144:
this.SetDegrTrigFunc("tanh");
break;
case 145:
this.SetDegrTrigFunc("csch");
break;
case 146:
this.SetDegrTrigFunc("sech");
break;
case 147:
this.SetDegrTrigFunc("coth");
break;
case 148:
mathFunc = this.SelectContent.addMathComponent_2(228);
func = mathFunc.getFunction();
func.addText("sin");
arg = mathFunc.getArgument();
arg.addText("θ");
mathFunc.ResizeReverse_2();
break;
case 149:
mathFunc = this.SelectContent.addMathComponent_2(228);
func = mathFunc.getFunction();
func.addText("cos");
arg = mathFunc.getArgument();
arg.addText("2x");
mathFunc.ResizeReverse_2();
break;
case 150:
mathFunc = this.SelectContent.addMathComponent_2(228);
func = mathFunc.getFunction();
func.addText("tan");
arg = mathFunc.getArgument();
arg.addText("θ");
this.SelectContent.addText("=");
fract = this.SelectContent.addMathComponent_2(0);
numer = fract.getNumerator();
mathFunc2 = numer.addMathComponent_2(228);
func2 = mathFunc2.getFunction();
func2.addText("sin");
arg2 = mathFunc2.getArgument();
arg2.addText("θ");
den = fract.getDenominator();
mathFunc3 = den.addMathComponent_2(228);
func3 = mathFunc3.getFunction();
func3.addText("cos");
arg3 = mathFunc3.getArgument();
arg3.addText("θ");
mathFunc.ResizeReverse_2();
fract.ResizeReverse_2();
break;
case 174:
box = this.SelectContent.addMathComponent_2(173);
borderBox = box.getElement();
aDegr = borderBox.addMathComponent_2(9);
aBase = aDegr.getBase();
aBase.addText("a");
aIter = aDegr.getIterator();
aIter.addText("2");
borderBox.addText("=");
bDegr = borderBox.addMathComponent_2(9);
bBase = bDegr.getBase();
bBase.addText("b");
bIter = bDegr.getIterator();
bIter.addText("2");
borderBox.addText("+");
cDegr = borderBox.addMathComponent_2(9);
cBase = cDegr.getBase();
cBase.addText("c");
cIter = cDegr.getIterator();
cIter.addText("2");
box.ResizeReverse_2();
break;
case 178:
this.SetTrigonometricFunc("log");
break;
case 182:
this.SetTrigonometricFunc("ln");
break;
case 183:
lim = this.SelectContent.addMathComponent_2(179);
iter = lim.getIterator();
iter.addText("n→∞");
base = lim.getArgument();
degree = base.addMathComponent_2(9);
iter2 = degree.getIterator();
iter2.addText("n");
base2 = degree.getBase();
delim = base2.addMathComponent_2(83);
delimBase = delim.getBase();
delimBase.addText("1+");
fract = delimBase.addMathComponent_2(0);
num = fract.getNumerator();
num.addText("1");
den = fract.getDenominator();
den.addText("n");
lim.ResizeReverse_2();
break;
case 184:
maximum = this.SelectContent.addMathComponent_2(181);
iter = maximum.getIterator();
iter.addText("0≤x≤1");
base = maximum.getArgument();
base.addText("x");
degree = base.addMathComponent_2(9);
base2 = degree.getBase();
base2.addText("e");
iter2 = degree.getIterator();
iter2.addText("-");
degree3 = iter2.addMathComponent_2(9);
base3 = degree3.getBase();
base3.addText("x");
iter3 = degree3.getIterator();
iter3.addText("2");
maximum.ResizeReverse_2();
break;
case 185:
matr = this.SelectContent.addMathComponent_2(229);
elemMatr = matr.getElement(0,0);
elemMatr.addText("∶=");
matr.ResizeReverse_2();
break;
case 186:
matr = this.SelectContent.addMathComponent_2(229);
elemMatr = matr.getElement(0,0);
elemMatr.addText("==");
matr.ResizeReverse_2();
break;
case 187:
matr = this.SelectContent.addMathComponent_2(229);
elemMatr = matr.getElement(0,0);
elemMatr.addText("+=");
matr.ResizeReverse_2();
break;
case 188:
matr = this.SelectContent.addMathComponent_2(229);
elemMatr = matr.getElement(0,0);
elemMatr.addText("-=");
matr.ResizeReverse_2();
break;
case 189:
matr = this.SelectContent.addMathComponent_2(229);
elemMatr = matr.getElement(0,0);
elemMatr.addText("");
matr.ResizeReverse_2();
break;
case 190:
matr = this.SelectContent.addMathComponent_2(229);
elemMatr = matr.getElement(0,0);
elemMatr.addText("");
matr.ResizeReverse_2();
break;
case 191:
matr = this.SelectContent.addMathComponent_2(229);
elemMatr = matr.getElement(0,0);
elemMatr.addText("");
matr.ResizeReverse_2();
break;
case 204:
arrow = this.SelectContent.addMathComponent_2(195);
base = arrow.getBase();
base.addText("yields");
arrow.ResizeReverse_2();
break;
case 205:
arrow = this.SelectContent.addMathComponent_2(195);
base = arrow.getBase();
base.addText("");
arrow.ResizeReverse_2();
break;
case 214:
this.SelectContent.addText("");
break;
case 215:
this.SelectContent.addText("");
break;
case 216:
this.SelectContent.addText("");
break;
case 217:
this.SelectContent.addText("");
break;
break;
case 218:
matr = this.SelectContent.addMathComponent_2(210);
elem1 = matr.getElement(0,0);
elem1.addText("1");
elem2 = matr.getElement(0,1);
elem2.addText("0");
elem3 = matr.getElement(1,0);
elem3.addText("0");
elem4 = matr.getElement(1,1);
elem4.addText("1");
matr.ResizeReverse_2();
break;
case 219:
matr = this.SelectContent.addMathComponent_2(210);
matr.hidePlaceholder(true);
elem1 = matr.getElement(0,0);
elem1.addText("1");
elem4 = matr.getElement(1,1);
elem4.addText("1");
matr.ResizeReverse_2();
break;
case 220:
matr = this.SelectContent.addMathComponent_2(213);
elem1 = matr.getElement(0,0);
elem1.addText("1");
elem2 = matr.getElement(0,1);
elem2.addText("0");
elem3 = matr.getElement(0,2);
elem3.addText("0");
elem4 = matr.getElement(1,0);
elem4.addText("0");
elem5 = matr.getElement(1,1);
elem5.addText("1");
elem6 = matr.getElement(1,2);
elem6.addText("0");
elem7 = matr.getElement(2,0);
elem7.addText("0");
elem8 = matr.getElement(2,1);
elem8.addText("0");
elem9 = matr.getElement(2,2);
elem9.addText("1");
matr.ResizeReverse_2();
break;
case 221:
matr = this.SelectContent.addMathComponent_2(213);
matr.hidePlaceholder(true);
elem1 = matr.getElement(0,0);
elem1.addText("1");
elem5 = matr.getElement(1,1);
elem5.addText("1");
elem9 = matr.getElement(2,2);
elem9.addText("1");
matr.ResizeReverse_2();
break;
case 222:
delimiter = this.SelectContent.addMathComponent_2(83);
base = delimiter.getBase();
base.addMathComponent_2(210);
delimiter.ResizeReverse_2();
break;
case 223:
delimiter = this.SelectContent.addMathComponent_2(84);
base = delimiter.getBase();
base.addMathComponent_2(210);
delimiter.ResizeReverse_2();
break;
case 224:
delimiter = this.SelectContent.addMathComponent_2(89);
base = delimiter.getBase();
base.addMathComponent_2(210);
delimiter.ResizeReverse_2();
break;
case 225:
delimiter = this.SelectContent.addMathComponent_2(90);
base = delimiter.getBase();
base.addMathComponent_2(210);
delimiter.ResizeReverse_2();
break;
case 226:
delimiter = this.SelectContent.addMathComponent_2(83);
base = delimiter.getBase();
matr = base.addMathComponent_2(213);
elem2 = matr.getElement(0,1);
elem2.addText("");
elem4 = matr.getElement(1,0);
elem4.addText("");
elem5 = matr.getElement(1,1);
elem5.addText("");
elem6 = matr.getElement(1,2);
elem6.addText("");
elem8 = matr.getElement(2,1);
elem8.addText("");
delimiter.ResizeReverse_2();
break;
case 227:
delimiter = this.SelectContent.addMathComponent_2(84);
base = delimiter.getBase();
matr = base.addMathComponent_2(213);
elem2 = matr.getElement(0,1);
elem2.addText("");
elem4 = matr.getElement(1,0);
elem4.addText("");
elem5 = matr.getElement(1,1);
elem5.addText("");
elem6 = matr.getElement(1,2);
elem6.addText("");
elem8 = matr.getElement(2,1);
elem8.addText("");
delimiter.ResizeReverse_2();
break;
default:
this.SelectContent.add_mathComponent(ind);
break;
}
this.SelectContent.ResizeReverse();
this.Root.setPosition(this.posCompos);
this.CurrentContent = this.SelectContent;
this.CurrentContent.update_Cursor();
this.ShowCursor();
},
SetDegrTrigFunc: function(txt)
{
mathFunc = this.SelectContent.addMathComponent_2(228);
//setColumnGapRule(3, 120);
func = mathFunc.getFunction();
degr = func.addMathComponent_2(9);
base = degr.getBase();
base.bMText = false;
base.addText(txt);
iter = degr.getIterator();
iter.addText("-1");
mathFunc.ResizeReverse_2();
},
SetTrigonometricFunc: function(txt)
{
mathFunc = this.SelectContent.addMathComponent_2(228);
func = mathFunc.getFunction();
func.addText(txt);
mathFunc.ResizeReverse_2();
} }
//// ////
} }
...@@ -1989,6 +2756,7 @@ function CEmpty() ...@@ -1989,6 +2756,7 @@ function CEmpty()
this.setFont = function() {} this.setFont = function() {}
this.setPosition = function (_pos) { this.pos = _pos; } this.setPosition = function (_pos) { this.pos = _pos; }
this.ResizeDirect = function(){}
this.IsHighElement = function() { return false; } this.IsHighElement = function() { return false; }
} }
...@@ -2376,30 +3144,30 @@ function AddEquation(ind) ...@@ -2376,30 +3144,30 @@ function AddEquation(ind)
break; break;
case 120: case 120:
break; break;
case 121: case 121:
mathElem = new CMathFunc(5);
break; break;
case 122: case 122:
mathElem = new CMathFunc(6);
break; break;
case 123: case 123:
mathElem = new CMathFunc(7);
break; break;
case 124: case 124:
mathElem = new CMathFunc(14);
break; break;
case 125: case 125:
mathElem = new CMathFunc(13);
break; break;
case 126: case 126:
mathElem = new CMathFunc(15);
break; break;
case 127: case 127:
break; break;
case 128: case 128:
break; break;
case 129: case 129:
break; break;
case 130: case 130:
break; break;
...@@ -2408,28 +3176,28 @@ function AddEquation(ind) ...@@ -2408,28 +3176,28 @@ function AddEquation(ind)
case 132: case 132:
break; break;
case 133: case 133:
mathElem = new CMathFunc(10);
break; break;
case 134: case 134:
mathElem = new CMathFunc(9);
break; break;
case 135: case 135:
mathElem = new CMathFunc(11);
break; break;
case 136: case 136:
mathElem = new CMathFunc(16);
break; break;
case 137: case 137:
mathElem = new CMathFunc(17);
break; break;
case 138: case 138:
mathElem = new CMathFunc(18);
break; break;
case 139: case 139:
break; break;
case 140: case 140:
break; break;
case 141: case 141:
break; break;
case 142: case 142:
break; break;
...@@ -2438,124 +3206,124 @@ function AddEquation(ind) ...@@ -2438,124 +3206,124 @@ function AddEquation(ind)
case 144: case 144:
break; break;
case 145: case 145:
/*mathElem = new CMathFunc(5);
mathElem.addText("θ");*/
break; break;
case 146: case 146:
break; break;
case 147: case 147:
break; break;
case 148: case 148:
mathElem = new CAccent(3); /*
mathElem.addText("θ");*/
break; break;
case 149: case 149:
mathElem = new CAccent(4);
break; break;
case 150: case 150:
mathElem = new CAccent(5);
break; break;
case 151: case 151:
mathElem = new CCircumflex(-1); mathElem = new CAccent(3);
break; break;
case 152: case 152:
mathElem = new CCircumflex(1); mathElem = new CAccent(4);
break; break;
case 153: case 153:
mathElem = new CAccent(2); mathElem = new CAccent(5);
break; break;
case 154: case 154:
mathElem = new CAccent(1); mathElem = new CCircumflex(-1);
break; break;
case 155: case 155:
mathElem = new CSign(1); mathElem = new CCircumflex(1);
break; break;
case 156: case 156:
mathElem = new CSign(2); mathElem = new CAccent(2);
break; break;
case 157: case 157:
mathElem = new CLine(0); mathElem = new CAccent(1);
break; break;
case 158: case 158:
mathElem = new CLine(1); mathElem = new CSign(1);
break; break;
case 159: case 159:
mathElem = new CSign(2);
break;
case 160:
mathElem = new CLine(0);
break;
case 161:
mathElem = new CLine(1);
break;
case 162:
//mathElem = new COperatorBracket(0); //mathElem = new COperatorBracket(0);
mathElem = new CDelimiter(1, 0, 0); // bracket mathElem = new CDelimiter(1, 0, 0); // bracket
break; break;
case 160: case 163:
mathElem = new CDelimiter(1, 1, 2); // bracket mathElem = new CDelimiter(1, 1, 2); // bracket
//mathElem = new COperatorBracket(1); //mathElem = new COperatorBracket(1);
break; break;
case 161: case 164:
mathElem = new GroupCharacter(1); mathElem = new GroupCharacter(1);
break; break;
case 162: case 165:
mathElem = new GroupCharacter(-1); mathElem = new GroupCharacter(-1);
break; break;
case 163: case 166:
mathElem = new CStructCombiningArrow(1,0,0); mathElem = new CStructCombiningArrow(1,0,0);
//mathElem = new COperatorArrow(1,0,0); //mathElem = new COperatorArrow(1,0,0);
break; break;
case 164: case 167:
mathElem = new CStructCombiningArrow(1,0,1); mathElem = new CStructCombiningArrow(1,0,1);
//mathElem = new COperatorArrow(1,0,1); //mathElem = new COperatorArrow(1,0,1);
break; break;
case 165: case 168:
mathElem = new CStructCombiningArrow(2,0,0); mathElem = new CStructCombiningArrow(2,0,0);
//mathElem = new COperatorArrow(2,0,0); //mathElem = new COperatorArrow(2,0,0);
break; break;
case 166: case 169:
mathElem = new CStructCombiningArrow(0,0,0); mathElem = new CStructCombiningArrow(0,0,0);
//mathElem = new COperatorArrow(0,0,2); //mathElem = new COperatorArrow(0,0,2);
break; break;
case 167: case 170:
mathElem = new CStructCombiningArrow(0,0,1); mathElem = new CStructCombiningArrow(0,0,1);
//mathElem = new COperatorArrow(0,0,3); //mathElem = new COperatorArrow(0,0,3);
break; break;
case 168:
break;
case 169:
break;
case 170:
mathElem = new CBorderBox();
break;
case 171: case 171:
break; break;
case 172: case 172:
break; break;
case 173: case 173:
mathElem = new CBorderBox();
break; break;
case 174: case 174:
mathElem = new CLogarithm();
break; break;
case 175: case 175:
mathElem = new CMathFunc(3);
break; break;
case 176: case 176:
mathElem = new CMinimax(2);
break; break;
case 177: case 177:
mathElem = new CMinimax(0); mathElem = new CLogarithm();
break; break;
case 178: case 178:
mathElem = new CMinimax(1);
break; break;
case 179: case 179:
mathElem = new CMathFunc(4); mathElem = new CMinimax(2);
break; break;
case 180: case 180:
mathElem = new CMinimax(0);
break; break;
case 181: case 181:
mathElem = new CMinimax(1);
break; break;
case 182: case 182:
break; break;
case 183: case 183:
break; break;
case 184: case 184:
break; break;
case 185: case 185:
break; break;
case 186: case 186:
...@@ -2565,89 +3333,89 @@ function AddEquation(ind) ...@@ -2565,89 +3333,89 @@ function AddEquation(ind)
case 188: case 188:
break; break;
case 189: case 189:
break;
case 190:
break;
case 191:
break;
case 192:
//mathElem = new CSingleArrow(0,0); //mathElem = new CSingleArrow(0,0);
mathElem = new CStructArrow(1, 0, 0); // left arrow top mathElem = new CStructArrow(1, 0, 0); // left arrow top
break; break;
case 190: case 193:
//mathElem = new CSingleArrow(0,1); //mathElem = new CSingleArrow(0,1);
mathElem = new CStructArrow(1, 0, 1); // right arrow top mathElem = new CStructArrow(1, 0, 1); // right arrow top
break; break;
case 191: case 194:
//mathElem = new CSingleArrow(1,2); //mathElem = new CSingleArrow(1,2);
mathElem = new CStructArrow(1, 1, 2); // "переворачиваем", чтобы стрелка была выравнена mathElem = new CStructArrow(1, 1, 2); // "переворачиваем", чтобы стрелка была выравнена
// left arrow bottom // left arrow bottom
break; break;
case 192: case 195:
//mathElem = new CSingleArrow(1,3); //mathElem = new CSingleArrow(1,3);
mathElem = new CStructArrow(1, 1, 3); // "переворачиваем", чтобы стрелка была выравнена mathElem = new CStructArrow(1, 1, 3); // "переворачиваем", чтобы стрелка была выравнена
// right arrow bottom // right arrow bottom
break; break;
case 193: case 196:
mathElem = new CStructArrow(3, 0, 0); // double mathematical left arrow top mathElem = new CStructArrow(3, 0, 0); // double mathematical left arrow top
//mathElem = new CDoubleArrow(0,0); //mathElem = new CDoubleArrow(0,0);
break; break;
case 194: case 197:
//mathElem = new CDoubleArrow(0,1); //mathElem = new CDoubleArrow(0,1);
mathElem = new CStructArrow(3, 0, 1); // double mathematical right arrow top mathElem = new CStructArrow(3, 0, 1); // double mathematical right arrow top
break; break;
case 195: case 198:
//mathElem = new CDoubleArrow(1,2); //mathElem = new CDoubleArrow(1,2);
mathElem = new CStructArrow(3, 1, 2); // double mathematical left arrow bottom mathElem = new CStructArrow(3, 1, 2); // double mathematical left arrow bottom
break; break;
case 196: case 199:
//mathElem = new CDoubleArrow(1,3); //mathElem = new CDoubleArrow(1,3);
mathElem = new CStructArrow(3, 1, 3); // double mathematical right arrow bottom mathElem = new CStructArrow(3, 1, 3); // double mathematical right arrow bottom
break; break;
case 197: case 200:
//mathElem = new CLeftRightArrow(0, 0); //mathElem = new CLeftRightArrow(0, 0);
mathElem = new CStructArrow(2, 0, 0); // left/right arrow top mathElem = new CStructArrow(2, 0, 0); // left/right arrow top
break; break;
case 198: case 201:
//mathElem = new CLeftRightArrow(1, 2); //mathElem = new CLeftRightArrow(1, 2);
mathElem = new CStructArrow(2, 1, 2); // left/right arrow bottom mathElem = new CStructArrow(2, 1, 2); // left/right arrow bottom
break; break;
case 199: case 202:
//mathElem = new CLR_DoubleArrow(0, 0); //mathElem = new CLR_DoubleArrow(0, 0);
mathElem = new CStructArrow(4, 0, 0); // left/right double mathematica arrow top mathElem = new CStructArrow(4, 0, 0); // left/right double mathematica arrow top
break; break;
case 200: case 203:
//mathElem = new CLR_DoubleArrow(1, 2); //mathElem = new CLR_DoubleArrow(1, 2);
mathElem = new CStructArrow(4, 1, 2); // left/right double mathematica arrow bottom mathElem = new CStructArrow(4, 1, 2); // left/right double mathematica arrow bottom
break; break;
case 201:
break;
case 202:
break;
case 203:
mathElem = new CMathMatrix(1, 2);
break;
case 204: case 204:
mathElem = new CMathMatrix(2, 1);
break; break;
case 205: case 205:
mathElem = new CMathMatrix(1, 3);
break; break;
case 206: case 206:
mathElem = new CMathMatrix(3, 1); mathElem = new CMathMatrix(1, 2);
break; break;
case 207: case 207:
mathElem = new CMathMatrix(2, 2); mathElem = new CMathMatrix(2, 1);
break; break;
case 208: case 208:
mathElem = new CMathMatrix(2, 3); mathElem = new CMathMatrix(1, 3);
break; break;
case 209: case 209:
mathElem = new CMathMatrix(3, 2); mathElem = new CMathMatrix(3, 1);
break; break;
case 210: case 210:
mathElem = new CMathMatrix(3, 3); mathElem = new CMathMatrix(2, 2);
break; break;
case 211: case 211:
mathElem = new CMathMatrix(2, 3);
break; break;
case 212: case 212:
mathElem = new CMathMatrix(3, 2);
break; break;
case 213: case 213:
mathElem = new CMathMatrix(3, 3);
break; break;
case 214: case 214:
break; break;
...@@ -2671,12 +3439,27 @@ function AddEquation(ind) ...@@ -2671,12 +3439,27 @@ function AddEquation(ind)
break; break;
case 224: case 224:
break; break;
case 225:
break;
case 226:
break;
case 227:
break;
case 228:
mathElem = new CMathFunc();
break;
case 229:
mathElem = new CMathMatrix(1, 1);
break;
} }
return mathElem; return mathElem;
} }
function AddMEtoContent(type) function AddMEtoContent(type)
{ {
......
...@@ -422,7 +422,11 @@ CMathText.prototype = ...@@ -422,7 +422,11 @@ CMathText.prototype =
flag = true; flag = true;
return flag; return flag;
} },
ResizeDirect: function()
{
this.recalculateSize();
}
} }
function CSymbol(IFont) function CSymbol(IFont)
......
...@@ -376,10 +376,7 @@ CMathMatrix.prototype.addRow = function() ...@@ -376,10 +376,7 @@ CMathMatrix.prototype.addRow = function()
//this.setDistance(); //this.setDistance();
this.recalculateSize(); this.recalculateSize();
} }
CMathMatrix.prototype.getElement = function(x, y)
{
return this.elements[x][y];
}
CMathMatrix.prototype.setRowGapRule = function(rule, gap) CMathMatrix.prototype.setRowGapRule = function(rule, gap)
{ {
this.spaceRow.rule = rule; this.spaceRow.rule = rule;
...@@ -389,7 +386,8 @@ CMathMatrix.prototype.setColumnGapRule = function(rule, gap, minGap) ...@@ -389,7 +386,8 @@ CMathMatrix.prototype.setColumnGapRule = function(rule, gap, minGap)
{ {
this.spaceColumn.rule = rule; this.spaceColumn.rule = rule;
this.spaceColumn.gap = gap; this.spaceColumn.gap = gap;
this.spaceColumn.minGap = minGap; if(minGap != null && typeof(minGap) !== "undefined")
this.spaceColumn.minGap = minGap;
} }
CMathMatrix.prototype.getLineGap = function(space) CMathMatrix.prototype.getLineGap = function(space)
{ {
......
...@@ -74,6 +74,18 @@ CNary.prototype.setContent = function() ...@@ -74,6 +74,18 @@ CNary.prototype.setContent = function()
CNary.superclass.setContent.call(this, oBase, oArg); CNary.superclass.setContent.call(this, oBase, oArg);
} }
CNary.prototype.getBase = function()
{
return this.elements[0][1];
}
CNary.prototype.getUpperIterator = function()
{
return this.elements[0][0].getUpperIterator();
}
CNary.prototype.getLowerIterator = function()
{
return this.elements[0][0].getLowerIterator();
}
function CBaseNaryOrder(id, IterType ) function CBaseNaryOrder(id, IterType )
{ {
...@@ -148,6 +160,21 @@ CBaseNaryOrder.prototype.IsJustDraw = function() ...@@ -148,6 +160,21 @@ CBaseNaryOrder.prototype.IsJustDraw = function()
{ {
return this.IterType == 0; // если только один значок n-арного оператора return this.IterType == 0; // если только один значок n-арного оператора
} }
CBaseNaryOrder.prototype.getUpperIterator = function()
{
return this.elements[0][0];
}
CBaseNaryOrder.prototype.getLowerIterator = function()
{
var iter = null;
if(this.IterType == 2)
iter = this.elements[1][0];
else if(this.IterType == 3)
iter = this.elements[2][0];
return iter;
}
function CNaryOperator(flip) function CNaryOperator(flip)
{ {
......
...@@ -377,7 +377,7 @@ function CDelimiter(type, loc, turn1, turn2) ...@@ -377,7 +377,7 @@ function CDelimiter(type, loc, turn1, turn2)
this.type = type; this.type = type;
this.loc = loc; this.loc = loc;
this.base = null;
var countRow, countCol; var countRow, countCol;
...@@ -505,6 +505,8 @@ CDelimiter.prototype.setContent = function() ...@@ -505,6 +505,8 @@ CDelimiter.prototype.setContent = function()
argument.relate(this); argument.relate(this);
argument.fillPlaceholders(); argument.fillPlaceholders();
this.base = argument;
if(this.loc == 0 || this.loc == 2) if(this.loc == 0 || this.loc == 2)
{ {
CDelimiter.superclass.setContent.call(this, operator1, argument); CDelimiter.superclass.setContent.call(this, operator1, argument);
...@@ -612,32 +614,9 @@ CDelimiter.prototype.recalculateSize = function() ...@@ -612,32 +614,9 @@ CDelimiter.prototype.recalculateSize = function()
this.size = {width: width, height: height, center: center}; this.size = {width: width, height: height, center: center};
} }
CDelimiter.prototype.getBase = function()
function CStructOperator(type, loc, turn)
{
this.type = type;
this.loc = loc;
this.turn = turn;
var countRow, countCol;
if(loc == 0 || loc == 1)
{
countRow = 2;
countCol = 1;
}
else
{
countRow = 1;
countCol = 2;
}
CMathBase.call(this, countRow, countCol);
}
extend(CStructOperator, CMathBase);
CStructOperator.prototype.setContent = function()
{ {
return this.base;
} }
function COperatorBracket() function COperatorBracket()
...@@ -2126,6 +2105,16 @@ CStructArrow.prototype.recalculateSize = function() ...@@ -2126,6 +2105,16 @@ CStructArrow.prototype.recalculateSize = function()
CStructArrow.superclass.recalculateSize.call(this); CStructArrow.superclass.recalculateSize.call(this);
} }
CStructArrow.prototype.getBase = function()
{
var res;
if(this.loc == 0)
res = this.elements[1][0];
else
res = this.elements[0][0];
return res;
}
function CSingleArrow() function CSingleArrow()
{ {
......
function CBaseBracket()
{
this.gapBrack = null;
this.gapTop = null;
CMathBase.call(this, 1, 1);
}
extend(CBaseBracket, CMathBase);
/*CBaseBracket.prototype.setContent = function()
{
this.fillPlaceholders();
}*/
//TODO
//мы не встаем в контент после мат элемента (например, матрицы), т.к. расстояние(widthToEl) до этого элемента равно растоянию до CEmpty после этого элемента
CBaseBracket.prototype.findDisposition = function(mCoord)
{
var X = null,
Y = null,
inside_flag = true; // остаемя в пределах данного элемента( за границы элемента не вышли )
if(mCoord.x < this.gapBrack)
{
X = 0;
inside_flag = 0;
}
else if(mCoord.x > this.size.width - this.gapBrack)
{
//X = this.size.width - 2*this.gapBrack;
X = this.elements[0][0].size.width; // разницы никакой
inside_flag = 1;
}
else
{
X = mCoord.x - this.gapBrack;
}
if(Y < this.gapTop)
{
Y = 0;
inside_flag = 2;
}
else if(Y > this.size.height - this.gapTop)
{
Y = this.size.height - 2*this.gapTop;
inside_flag = 2;
}
else
{
Y = mCoord.y - this.gapTop;
}
var coord = {x: X, y: Y},
posCurs = {x: 0, y: 0};
return {pos: posCurs, mCoord: coord, inside_flag: inside_flag};
}
CBaseBracket.prototype.setPosition = function(pos)
{
this.pos = {x: pos.x, y: pos.y - this.size.center};
//TODO
//вот здесь лажа, возможно из-за этого неправильно обрабатывается событие клик мыши (findDisposition)
var x = this.pos.x + this.gapBrack,
y = this.pos.y + this.gapTop;
this.elements[0][0].setPosition({x: x, y: y});
}
// переделать для всех элементов c отрисовкой!
CBaseBracket.prototype.goToUpperLevel = function(coord)
{
var content = null;
var x = coord.x + this.gapBrack,
y = coord.y + this.gapTop;
var crd = {x: x, y: y};
var upLevel = this.Parent.goToUpperLevel(crd);
var bUp = upLevel.bUp;
if(bUp)
content = upLevel.content;
else
content = null;
return {bUp: bUp, content: content};
}
CBaseBracket.prototype.goToLowerLevel = function(coord){
var content = null;
var x = coord.x + this.gapBrack,
y = coord.y + this.gapTop;
var crd = {x: x, y: y};
var lowLevel = this.Parent.goToLowerLevel(crd);
var bLow = lowLevel.bLow;
if(bLow)
content = lowLevel.content;
else
content = null;
return {bLow: bLow, content: content};
}
function CParenthesis()
{
CBaseBracket.call(this);
}
extend(CParenthesis, CBaseBracket);
CParenthesis.prototype.recalculateSize = function()
{
var height, width, center;
var betta = this.params.font.FontSize /36;
var maxBoxW = 9.63041992187 *betta, //9.63 width of 0x239D
minBoxW = 5.27099609375 *betta, //width of 0x28
heightBr = 11.99444444444 *betta;
var argSize = this.elements[0][0].size;
var rx = argSize.height / heightBr,
delta = maxBoxW - minBoxW;
var widthBr = delta/4.3 * (rx - 1) + minBoxW;
widthBr = widthBr > maxBoxW ? maxBoxW : widthBr;
this.gapBrack = widthBr;
this.gapTop = heightBr > argSize.height ? (heightBr - argSize.height)/2 : 0;
height = argSize.height + 2*this.gapTop;
center = argSize.center + this.gapTop;
width = argSize.width + 2*this.gapBrack;
this.size = {height: height, width: width, center: center};
}
CParenthesis.prototype.draw = function()
{
this.elements[0][0].draw();
var x = this.pos.x,
y = this.pos.y;
var penW = 1; //px
//25.4/96
//resolution 72
//lineTo, moveTo в mm
var X = new Array(),
Y = new Array();
X[0] = 20672; Y[0] = 21068;
X[1] = 20672; Y[1] = 6495;
X[2] = 15986; Y[2] = -2956;
X[3] = 11300; Y[3] = -12407;
X[4] = 1677; Y[4] = -15613;
X[5] = 2677; Y[5] = -18819;
X[6] = 14894; Y[6] = -15613;
X[7] = 21399; Y[7] = -5017;
X[8] = 27904; Y[8] = 5579;
X[9] = 27904; Y[9] = 20651;
var tmpY = Y[5],
tmpX = X[4];
for(var i=0; i< 10; i++)
{
X[i] = X[i] - tmpX;
Y[i] = Y[i] - tmpY; // ( X[4], Y[5] ) => (0,0)
}
var textScale = this.params.font.FontSize/1000, // 1000 pt
alpha = textScale*25.4/96 /64; // коэффициент; используется для того чтобы перевести координаты в миллиметры
// при рисовании используем координаты в миллиметрах, умноженные на 100
// g_dKoef_px_to_mm = 25.4/96
// 6 тагетов (ориентировочно)
var aug = this.size.height/(Y[9]*alpha)/2, //Y[9]*alpha - высота скобки
RX, RY; // коэффициент растяжения вычисляем исходя из высоты половины скобки : всё остальное дорисовываем трансформацией
// 9.63 - ширина скобки (max) для размера 36
// 6 px - gap
if(aug > 6.53)
{
RY = 6.53;
RX = 2.05;
}
else if(aug < 1)
{
RY = 1;
RX = 1;
}
else
{
RY = aug;
RX = 1 + (aug - 1)*0.19;
}
var DistW = new Array();
for(var i= 0; i< 5; i++)
DistW[i] = X[9-i] - X[i];
for(var i = 5; i < 10; i++)
{
X[i] = X[i]*RX; //точки правой дуги
X[9-i] = X[i] - DistW[9-i]; //точки левой дуги
}
// Y
var DistH = new Array();
for(var j= 0; j< 5; j++)
DistH[j] = Y[18-j] - Y[9+j];
var DistH = new Array();
for(var i=0; i< 5; i++)
DistH[i] = Y[9-j] - Y[j];
for(var i=5; i<10; i++ )
{
Y[i] = Y[i]*RY;
Y[9-i] = Y[i] + DistH[9-i];
}
var XX = new Array(),
YY = new Array();
var shiftX = this.size.width - 0.9*this.gapBrack;
var Width = this.size.width,
Height = this.size.height;
// XX[0] - XX[9] - нижняя часть скобки
// XX[9] - XX[10] - отрезок прямой
// XX[11] - XX[19] - верхняя часть скобки
// XX[19] - XX[20] - отрезок прямой
for(var i = 0; i < 10; i++)
{
XX[19 - i] = XX[i] = (x + shiftX + X[i]*alpha );
YY[19 - i] = (y + Y[i]*alpha);
YY[i] = (y + Height - Y[i]*alpha);
}
XX[20] = XX[0];
YY[20] = YY[0];
var intGrid = MathControl.pGraph.GetIntegerGrid();
MathControl.pGraph.SetIntegerGrid(false);
MathControl.pGraph.p_width(penW*1000);
MathControl.pGraph.b_color1(0,0,0, 255);
MathControl.pGraph._s();
MathControl.pGraph._m(XX[0], YY[0]); //mm
MathControl.pGraph._c(XX[0], YY[0], XX[1], YY[1], XX[2], YY[2]);
MathControl.pGraph._c(XX[2], YY[2], XX[3], YY[3], XX[4], YY[4]);
MathControl.pGraph._l(XX[5], YY[5]);
MathControl.pGraph._c(XX[5], YY[5], XX[6], YY[6], XX[7], YY[7]);
MathControl.pGraph._c(XX[7], YY[7], XX[8], YY[8], XX[9], YY[9]);
MathControl.pGraph._l(XX[10], YY[10]);
MathControl.pGraph._c(XX[10], YY[10], XX[11], YY[11], XX[12], YY[12]);
MathControl.pGraph._c(XX[12], YY[12], XX[13], YY[13], XX[14], YY[14]);
MathControl.pGraph._l(XX[15], YY[15]);
MathControl.pGraph._c(XX[15], YY[15], XX[16], YY[16], XX[17], YY[17]);
MathControl.pGraph._c(XX[17], YY[17], XX[18], YY[18], XX[19], YY[19]);
MathControl.pGraph._l(XX[20], YY[20]);
MathControl.pGraph.df();
var shiftX = 0.87*this.gapBrack;
for(var i = 0; i < 10; i++)
{
XX[19 - i] = XX[i] = (x + shiftX - X[i]*alpha ); // YY[..] те же
}
XX[20] = XX[0];
MathControl.pGraph.p_width(penW*1000);
MathControl.pGraph.b_color1(0,0,0, 255);
MathControl.pGraph._s();
MathControl.pGraph._m(XX[0], YY[0]); //mm
MathControl.pGraph._c(XX[0], YY[0], XX[1], YY[1], XX[2], YY[2]);
MathControl.pGraph._c(XX[2], YY[2], XX[3], YY[3], XX[4], YY[4]);
MathControl.pGraph._l(XX[5], YY[5]);
MathControl.pGraph._c(XX[5], YY[5], XX[6], YY[6], XX[7], YY[7]);
MathControl.pGraph._c(XX[7], YY[7], XX[8], YY[8], XX[9], YY[9]);
MathControl.pGraph._l(XX[10], YY[10]);
MathControl.pGraph._c(XX[10], YY[10], XX[11], YY[11], XX[12], YY[12]);
MathControl.pGraph._c(XX[12], YY[12], XX[13], YY[13], XX[14], YY[14]);
MathControl.pGraph._l(XX[15], YY[15]);
MathControl.pGraph._c(XX[15], YY[15], XX[16], YY[16], XX[17], YY[17]);
MathControl.pGraph._c(XX[17], YY[17], XX[18], YY[18], XX[19], YY[19]);
MathControl.pGraph._l(XX[20], YY[20]);
MathControl.pGraph.df();
MathControl.pGraph.SetIntegerGrid(intGrid);
}
function CBracket()
{
CBaseBracket.call(this);
}
extend(CBracket, CBaseBracket);
CBracket.prototype.recalculateSize = function()
{
var height, width, center;
var betta = this.params.font.FontSize /36;
var minBoxW = 4.917529296874999 *betta, //width of 0x28
heightBr = 12.347222222222221*betta;
var argSize = this.elements[0][0].size;
var rx = argSize.height / heightBr;
if(rx < 1)
rx = 1;
if(rx < 2.1)
maxBoxW = minBoxW * 1.37;
else if(rx < 3.22)
maxBoxW = minBoxW * 1.06;
else
maxBoxW = 8.74 *betta;
var delta = maxBoxW - minBoxW;
var widthBr = delta/4.3 * (rx - 1) + minBoxW;
widthBr = widthBr > maxBoxW ? maxBoxW : widthBr;
this.gapBrack = widthBr;
this.gapTop = heightBr > argSize.height ? (heightBr - argSize.height)/2 : 0;
height = argSize.height + 2*this.gapTop;
center = argSize.center + this.gapTop;
width = argSize.width + 2*this.gapBrack;
this.size = {height: height, width: width, center: center};
}
CBracket.prototype.draw = function()
{
this.elements[0][0].draw();
var x = this.pos.x,
y = this.pos.y;
var X = new Array(),
Y = new Array();
Y[0] = 26467; X[0] = 18871;
Y[1] = 25967; X[1] = 18871;
Y[2] = 25384; X[2] = 16830;
Y[3] = 24737; X[3] = 15476;
Y[4] = 24091; X[4] = 14122;
Y[5] = 23341; X[5] = 13309;
Y[6] = 22591; X[6] = 12497;
Y[7] = 21778; X[7] = 12164;
Y[8] = 20965; X[8] = 11831;
Y[9] = 20089; X[9] = 11831;
Y[10] = 19214; X[10] = 11831;
Y[11] = 18317; X[11] = 12083;
Y[12] = 17421; X[12] = 12336;
Y[13] = 16441; X[13] = 12652;
Y[14] = 15462; X[14] = 12969;
Y[15] = 14357; X[15] = 13243;
Y[16] = 13253; X[16] = 13518;
Y[17] = 11961; X[17] = 13518;
Y[18] = 9835; X[18] = 13518;
Y[19] = 8292; X[19] = 12621;
Y[20] = 6750; X[20] = 11724;
Y[21] = 5750; X[21] = 10055;
Y[22] = 4750; X[22] = 8386;
Y[23] = 4270; X[23] = 5987;
Y[24] = 3791; X[24] = 3589;
Y[25] = 3791; X[25] = 626;
Y[26] = 3791; X[26] = 0;
Y[27] = 0; X[27] = 0;
Y[28] = 0; X[28] = 1084;
Y[29] = 83; X[29] = 5963;
Y[30] = 1021; X[30] = 9612;
Y[31] = 1959; X[31] = 13261;
Y[32] = 3543; X[32] = 15700;
Y[33] = 5127; X[33] = 18139;
Y[34] = 7232; X[34] = 19369;
Y[35] = 9337; X[35] = 20599;
Y[36] = 11796; X[36] = 20599;
Y[37] = 13338; X[37] = 20599;
Y[38] = 14588; X[38] = 20283;
Y[39] = 15839; X[39] = 19968;
Y[40] = 16860; X[40] = 19610;
Y[41] = 17882; X[41] = 19252;
Y[42] = 18736; X[42] = 18936;
Y[43] = 19590; X[43] = 18621;
Y[44] = 20340; X[44] = 18621;
Y[45] = 21091; X[45] = 18621;
Y[46] = 21820; X[46] = 18995;
Y[47] = 22550; X[47] = 19370;
Y[48] = 23133; X[48] = 20266;
Y[49] = 23717; X[49] = 21162;
Y[50] = 24092; X[50] = 22703;
Y[51] = 24467; X[51] = 24245;
Y[52] = 24551; X[52] = 26578;
Y[53] = 28133; X[53] = 26578;
/* Y[54] = 28216; X[54] = 24245;
Y[55] = 28612; X[55] = 22703;
Y[56] = 29008; X[56] = 21162;
Y[57] = 29612; X[57] = 20266;
Y[58] = 30216; X[58] = 19370;
Y[59] = 30965; X[59] = 18995;
Y[60] = 31714; X[60] = 18621;
Y[61] = 32548; X[61] = 18621;
Y[62] = 33381; X[62] = 18621;
Y[63] = 34276; X[63] = 18936;
Y[64] = 35172; X[64] = 19252;
Y[65] = 36255; X[65] = 19610;
Y[66] = 37338; X[66] = 19968;
Y[67] = 38670; X[67] = 20283;
Y[68] = 40003; X[68] = 20599;
Y[69] = 41669; X[69] = 20599;
Y[70] = 46917; X[70] = 20599;
Y[71] = 49749; X[71] = 15741;
Y[72] = 52581; X[72] = 10883;
Y[73] = 52665; X[73] = 1084;
Y[74] = 52665; X[74] = 0;
Y[75] = 48749; X[75] = 0;
Y[76] = 48749; X[76] = 626;
Y[77] = 48749; X[77] = 3589;
Y[78] = 48311; X[78] = 5987;
Y[79] = 47874; X[79] = 8386;
Y[80] = 46916; X[80] = 10055;
Y[81] = 45959; X[81] = 11724;
Y[82] = 44480; X[82] = 12621;
Y[83] = 43001; X[83] = 13518;
Y[84] = 40877; X[84] = 13518;
Y[85] = 39545; X[85] = 13518;
Y[86] = 38399; X[86] = 13243;
Y[87] = 37254; X[87] = 12969;
Y[88] = 36191; X[88] = 12652;
Y[89] = 35129; X[89] = 12336;
Y[90] = 34171; X[90] = 12083;
Y[91] = 33214; X[91] = 11831;
Y[92] = 32339; X[92] = 11831;
Y[93] = 31464; X[93] = 11831;
Y[94] = 30652; X[94] = 12164;
Y[95] = 29840; X[95] = 12497;
Y[96] = 29090; X[96] = 13309;
Y[97] = 28341; X[97] = 14122;
Y[98] = 27674; X[98] = 15476;
Y[99] = 27008; X[99] = 16830;
Y[100] = 26467; X[100] = 18871;*/
var textScale = this.params.font.FontSize/1000, // 1000 pt
alpha = textScale*25.4/96 /64; // коэффициент; используется для того чтобы перевести координаты в миллиметры
// при рисовании используем координаты в миллиметрах, умноженные на 100
// g_dKoef_px_to_mm = 25.4/96
var augm = this.size.height/((Y[52] + (Y[0] - Y[1])/2 + Y[1] - Y[52])*alpha*2);
var XX = new Array(),
YY = new Array();
var hh1 = new Array(),
hh2 = new Array();
var c1 = new Array(),
c2 = new Array();
var delta = augm < 7 ? augm : 7;
if(augm < 7)
{
var RX = new Array(),
RX1, RX2;
if(delta < 5.1)
{
hh1[0] = 1.89;
hh2[0] = 2.58;
hh1[1] = 1.55;
hh2[1] = 1.72;
hh1[2] = 1.5;
hh2[2] = 1.64;
hh1[3] = 1.92;
hh2[3] = 1.97;
// (!)
hh1[4] = 1;
hh2[4] = 1;
//
hh1[5] = 2.5;
hh2[5] = 2.5;
hh1[6] = 2.1;
hh2[6] = 2.1;
hh1[7] = 1;
hh2[7] = 1;
RX1 = 0.033*delta + 0.967;
RX2 = 0.033*delta + 0.967;
}
else
{
hh1[0] = 1.82;
hh2[0] = 2.09;
hh1[1] = 1.64;
hh2[1] = 1.65;
hh1[2] = 1.57;
hh2[2] = 1.92;
hh1[3] = 1.48;
hh2[3] = 2.16;
// (!)
hh1[4] = 1;
hh2[4] = 1;
//
hh1[5] = 2.5;
hh2[5] = 2.5;
hh1[6] = 2.1;
hh2[6] = 2.1;
hh1[7] = 1;
hh2[7] = 1;
RX1 = 0.22*delta + 0.78;
RX2 = 0.17*delta + 0.83;
}
for(var i = 0; i < 27; i++)
RX[i] = RX1;
for(var i = 27; i < 54; i++)
RX[i] = RX2;
RX[1] = (X[52]*RX[52] - (X[52] - X[1]) )/X[1];
RX[0] = RX[1]*X[1]/X[0];
RX[27] = 1;
RX[26] = 1;
for(var i = 0; i < 8; i++ )
RX[26-i] = 1 + i*((RX2+RX1)/2 - 1)/7;
for(var i = 0; i < 4; i++)
{
c1[i] = Y[30 + 2*i] - Y[28 + 2*i];
c2[i] = Y[23 - 2*i] - Y[25 - 2*i];
}
c1[5] = Y[48] - Y[44];
c2[5] = Y[5] - Y[9];
c1[6] = Y[52] - Y[48];
c2[6] = Y[1] - Y[5];
c1[7] = (Y[0] - Y[1])/2 + Y[1] - Y[52];
c2[7] = (Y[0] - Y[1])/2;
c1[4] = Y[44] - Y[36];
c2[4] = Y[9] - Y[17];
var rest1 = 0,
rest2 = 0;
for(var i = 0; i < 8; i++)
{
if(i == 4)
continue;
hh1[i] = (hh1[i] - 1)*(delta - 1) + 1;
hh2[i] = (hh2[i] - 1)*(delta - 1) + 1;
rest1 += hh1[i]*c1[i];
rest2 += hh2[i]*c2[i];
}
var H1 = delta*(Y[52] + c1[7]),
H2 = H1 - (Y[26] - Y[27]) ;
hh1[4] = (H1 - rest1)/c1[4];
hh2[4] = (H2 - rest2)/c2[4];
YY[27] = Y[27];
YY[26] = Y[26];
YY[28] = Y[27];
YY[25] = Y[26];
for(var i = 0; i < 4; i++)
{
for(var j = 1; j < 3; j ++)
{
t = j + i*2;
YY[28 + t] = YY[27 + t] + (Y[28+t] - Y[27+t])*hh1[i];
YY[25 - t] = YY[26 - t] + (Y[25-t] - Y[26-t])*hh2[i];
}
}
//переопределяем 36 и 17
for(var i = 1; i < 9; i++)
{
YY[36 + i] = YY[35+i] + (Y[36+i] - Y[35+i])*hh1[4];
YY[17 - i] = YY[18-i] + (Y[17-i] - Y[18-i])*hh2[4];
}
for(var i = 0; i < 4; i++)
{
YY[45+i] = YY[44+i] + ( Y[45+i] - Y[44+i])*hh1[5];
YY[8-i] = YY[9-i] + (Y[8-i] -Y[9-i])*hh2[5];
}
for(var i = 0; i < 4; i++)
{
YY[49+i] = YY[48+i] + (Y[49+i] - Y[48+i])*hh1[6];
YY[4-i] = YY[5-i] + (Y[4-i] - Y[5-i] )*hh2[6];
}
YY[53] = YY[52] + 2*c1[7]*hh1[7];
YY[0] = YY[1] + 2*c2[7]*hh2[7];
}
else
{
hh1[0] = 1.75;
hh2[0] = 2.55;
hh1[1] = 1.62;
hh2[1] = 1.96;
hh1[2] = 1.97;
hh2[2] = 1.94;
hh1[3] = 1.53;
hh2[3] = 1.0;
hh1[4] = 2.04;
hh2[4] = 3.17;
hh1[5] = 2.0;
hh2[5] = 2.58;
hh1[6] = 2.3;
hh2[6] = 1.9;
hh1[7] = 2.3;
hh2[7] = 1.9;
// (!)
hh1[8] = 1;
hh2[8] = 1;
//
hh1[9] = 2.5;
hh2[9] = 2.5;
hh1[10] = 2.1;
hh2[10] = 2.1;
hh1[11] = 1;
hh2[11] = 1;
var rest1 = 0,
rest2 = 0;
for(var i=0; i<8; i++)
{
c1[i] = Y[30+i] - Y[29+i];
c2[i] = Y[24-i] - Y[25-i];
}
c1[9] = Y[48] - Y[44];
c2[9] = Y[5] - Y[9];
c1[10] = Y[52] - Y[48];
c2[10] = Y[1] - Y[5];
c1[11] = (Y[0] - Y[1])/2 + Y[1] - Y[52];
c2[11] = (Y[0] - Y[1])/2;
c1[8] = Y[44] - Y[36];
c2[8] = Y[9] - Y[17];
for(var i = 0; i < 12; i++)
{
if(i == 8)
continue;
hh1[i] = (hh1[i] - 1)*(delta - 1) + 1;
hh2[i] = (hh2[i] - 1)*(delta - 1) + 1;
rest1 += hh1[i]*c1[i];
rest2 += hh2[i]*c2[i];
}
var H1 = delta*(Y[52] + c1[11]),
H2 = H1 - (Y[26] - Y[27]) ;
hh1[8] = (H1 - rest1)/c1[8];
hh2[8] = (H2 - rest2)/c2[8];
YY[27] = Y[27];
YY[26] = Y[26];
YY[28] = Y[27];
YY[25] = Y[26];
for(var i = 0; i < 9; i++)
{
YY[28 + i] = YY[27 + i] + (Y[28+i] - Y[27+i])*hh1[i];
YY[25 - i] = YY[26 - i] + (Y[25-i] - Y[26-i])*hh2[i];
}
//переопределяем 36 и 17
for(var i = 1; i < 9; i++)
{
YY[36 + i] = YY[35+i] + (Y[36+i] - Y[35+i])*hh1[8];
YY[17 - i] = YY[18-i] + (Y[17-i] - Y[18-i])*hh2[8];
}
// TODO
// переделать
for(var i = 0; i < 4; i++)
{
YY[45+i] = YY[44+i] + ( Y[45+i] - Y[44+i])*hh1[9];
YY[8-i] = YY[9-i] + (Y[8-i] -Y[9-i])*hh2[9];
}
for(var i = 0; i < 4; i++)
{
YY[49+i] = YY[48+i] + (Y[49+i] - Y[48+i])*hh1[10];
YY[4-i] = YY[5-i] + (Y[4-i] - Y[5-i] )*hh2[10];
}
YY[53] = YY[52] + 2*c1[11]*hh1[11];
YY[0] = YY[1] + 2*c2[11]*hh2[11];
var RX = new Array();
for(var i = 0; i < 27; i++)
RX[i] = 0.182*delta + 0.818;
for(var i = 27; i < 54; i++)
RX[i] = 0.145*delta + 0.855;
RX[1] = (X[52]*RX[52] - (X[52] - X[1]) )/X[1];
RX[0] = RX[1]*X[1]/X[0];
RX[27] = 1;
RX[26] = 1;
for(var i = 0; i < 7; i++ )
RX[28-i] = 1 + i*(0.145*delta + 0.855 - 1)/8;
var w = X[33]*RX[33],
w2 = X[9]*RX[9] + 0.15*(X[9]*RX[9] - X[19]*RX[19]);
for(var i = 0; i < 11; i++)
{
RX[34+i] = w/X[34+i];
RX[19-i] = w2/X[19-i];
}
var _H1 = augm*(Y[52] + c1[11]),
_H2 = _H1 - (Y[26] - Y[27]);
var w3 = _H1 - (YY[52] + c1[11]),
w4 = _H2 - (YY[1] - YY[26] + c2[11]);
for(var i = 0; i < 10; i++)
{
YY[53 - i] = YY[53 - i] + w3;
YY[i] = YY[i] + w4;
}
}
var shiftX = this.size.width - this.gapBrack;
for(var i = 0; i < 54; i++)
{
XX[i] = (x + shiftX + X[i]*RX[i]*alpha );
YY[i] = (y + YY[i]*alpha );
}
for(var i = 0; i < 50; i++)
XX[54 + i] = XX[51 - i];
for(var i = 0; i < 50; i++)
YY[54 + i] = YY[53] + YY[52] - YY[51-i];
var penW = 1; //px
var intGrid = MathControl.pGraph.GetIntegerGrid();
MathControl.pGraph.SetIntegerGrid(false);
MathControl.pGraph.p_width(penW*1000);
MathControl.pGraph.b_color1(0,0,0, 255);
MathControl.pGraph._s();
MathControl.pGraph._m(XX[0], YY[0]);
MathControl.pGraph._l(XX[1], YY[1]);
MathControl.pGraph._c(XX[1], YY[1], XX[2], YY[2], XX[3], YY[3] );
MathControl.pGraph._c(XX[3], YY[3], XX[4], YY[4], XX[5], YY[5] );
MathControl.pGraph._c(XX[5], YY[5], XX[6], YY[6], XX[7], YY[7] );
MathControl.pGraph._c(XX[7], YY[7], XX[8], YY[8], XX[9], YY[9] );
MathControl.pGraph._c(XX[9], YY[9], XX[10], YY[10], XX[11], YY[11] );
MathControl.pGraph._c(XX[11], YY[11], XX[12], YY[12], XX[13], YY[13] );
MathControl.pGraph._c(XX[13], YY[13], XX[14], YY[14], XX[15], YY[15] );
MathControl.pGraph._c(XX[15], YY[15], XX[16], YY[16], XX[17], YY[17] );
MathControl.pGraph._c(XX[17], YY[17], XX[18], YY[18], XX[19], YY[19] );
MathControl.pGraph._c(XX[19], YY[19], XX[20], YY[20], XX[21], YY[21] );
MathControl.pGraph._c(XX[21], YY[21], XX[22], YY[22], XX[23], YY[23] );
MathControl.pGraph._c(XX[23], YY[23], XX[24], YY[24], XX[25], YY[25] );
MathControl.pGraph._l(XX[26], YY[26]);
MathControl.pGraph._l(XX[27], YY[27]);
MathControl.pGraph._l(XX[28], YY[28]);
MathControl.pGraph._c(XX[28], YY[28], XX[29], YY[29], XX[30], YY[30] );
MathControl.pGraph._c(XX[30], YY[30], XX[31], YY[31], XX[32], YY[32] );
MathControl.pGraph._c(XX[32], YY[32], XX[33], YY[33], XX[34], YY[34] );
MathControl.pGraph._c(XX[34], YY[34], XX[35], YY[35], XX[36], YY[36] );
MathControl.pGraph._c(XX[36], YY[36], XX[37], YY[37], XX[38], YY[38] );
MathControl.pGraph._c(XX[38], YY[38], XX[39], YY[39], XX[40], YY[40] );
MathControl.pGraph._c(XX[40], YY[40], XX[41], YY[41], XX[42], YY[42] );
MathControl.pGraph._c(XX[42], YY[42], XX[43], YY[43], XX[44], YY[44] );
MathControl.pGraph._c(XX[44], YY[44], XX[45], YY[45], XX[46], YY[46] );
MathControl.pGraph._c(XX[46], YY[46], XX[47], YY[47], XX[48], YY[48] );
MathControl.pGraph._c(XX[48], YY[48], XX[49], YY[49], XX[50], YY[50] );
MathControl.pGraph._c(XX[50], YY[50], XX[51], YY[51], XX[52], YY[52] );
MathControl.pGraph._l(XX[53], YY[53]);
MathControl.pGraph._c(XX[53], YY[53], XX[54], YY[54], XX[55], YY[55] );
MathControl.pGraph._c(XX[55], YY[55], XX[56], YY[56], XX[57], YY[57] );
MathControl.pGraph._c(XX[57], YY[57], XX[58], YY[58], XX[59], YY[59] );
MathControl.pGraph._c(XX[59], YY[59], XX[60], YY[60], XX[61], YY[61] );
MathControl.pGraph._c(XX[61], YY[61], XX[62], YY[62], XX[63], YY[63] );
MathControl.pGraph._c(XX[63], YY[63], XX[64], YY[64], XX[65], YY[65] );
MathControl.pGraph._c(XX[65], YY[65], XX[66], YY[66], XX[67], YY[67] );
MathControl.pGraph._c(XX[67], YY[67], XX[68], YY[68], XX[69], YY[69] );
MathControl.pGraph._c(XX[69], YY[69], XX[70], YY[70], XX[71], YY[71] );
MathControl.pGraph._c(XX[71], YY[71], XX[72], YY[72], XX[73], YY[73] );
MathControl.pGraph._c(XX[73], YY[73], XX[74], YY[74], XX[75], YY[75] );
MathControl.pGraph._c(XX[75], YY[75], XX[76], YY[76], XX[77], YY[77] );
MathControl.pGraph._l(XX[78], YY[78]);
MathControl.pGraph._l(XX[79], YY[79]);
MathControl.pGraph._l(XX[80], YY[80]);
MathControl.pGraph._c(XX[80], YY[80], XX[81], YY[81], XX[82], YY[82] );
MathControl.pGraph._c(XX[82], YY[82], XX[83], YY[83], XX[84], YY[84] );
MathControl.pGraph._c(XX[84], YY[84], XX[85], YY[85], XX[86], YY[86] );
MathControl.pGraph._c(XX[86], YY[86], XX[87], YY[87], XX[88], YY[88] );
MathControl.pGraph._c(XX[88], YY[88], XX[89], YY[89], XX[90], YY[90] );
MathControl.pGraph._c(XX[90], YY[90], XX[91], YY[91], XX[92], YY[92] );
MathControl.pGraph._c(XX[92], YY[92], XX[93], YY[93], XX[94], YY[94] );
MathControl.pGraph._c(XX[94], YY[94], XX[95], YY[95], XX[96], YY[96] );
MathControl.pGraph._c(XX[96], YY[96], XX[97], YY[97], XX[98], YY[98] );
MathControl.pGraph._c(XX[98], YY[98], XX[99], YY[99], XX[100], YY[100] );
MathControl.pGraph._c(XX[100], YY[100], XX[101], YY[101], XX[102], YY[102]);
MathControl.pGraph._c(XX[102], YY[102], XX[103], YY[103], XX[0], YY[0]);
MathControl.pGraph.df();
shiftX = this.gapBrack;
for(var i = 0 ; i < 54; i++)
{
XX[i] = (x + shiftX - X[i]*RX[i]*alpha);
}
for(var i = 0; i < 50; i++)
XX[54 + i] = XX[51 - i];
MathControl.pGraph.p_width(penW*1000);
MathControl.pGraph.b_color1(0,0,0, 255);
MathControl.pGraph._s();
MathControl.pGraph._m(XX[0], YY[0]);
MathControl.pGraph._l(XX[1], YY[1]);
MathControl.pGraph._c(XX[1], YY[1], XX[2], YY[2], XX[3], YY[3] );
MathControl.pGraph._c(XX[3], YY[3], XX[4], YY[4], XX[5], YY[5] );
MathControl.pGraph._c(XX[5], YY[5], XX[6], YY[6], XX[7], YY[7] );
MathControl.pGraph._c(XX[7], YY[7], XX[8], YY[8], XX[9], YY[9] );
MathControl.pGraph._c(XX[9], YY[9], XX[10], YY[10], XX[11], YY[11] );
MathControl.pGraph._c(XX[11], YY[11], XX[12], YY[12], XX[13], YY[13] );
MathControl.pGraph._c(XX[13], YY[13], XX[14], YY[14], XX[15], YY[15] );
MathControl.pGraph._c(XX[15], YY[15], XX[16], YY[16], XX[17], YY[17] );
MathControl.pGraph._c(XX[17], YY[17], XX[18], YY[18], XX[19], YY[19] );
MathControl.pGraph._c(XX[19], YY[19], XX[20], YY[20], XX[21], YY[21] );
MathControl.pGraph._c(XX[21], YY[21], XX[22], YY[22], XX[23], YY[23] );
MathControl.pGraph._c(XX[23], YY[23], XX[24], YY[24], XX[25], YY[25] );
MathControl.pGraph._l(XX[26], YY[26]);
MathControl.pGraph._l(XX[27], YY[27]);
MathControl.pGraph._l(XX[28], YY[28]);
MathControl.pGraph._c(XX[28], YY[28], XX[29], YY[29], XX[30], YY[30] );
MathControl.pGraph._c(XX[30], YY[30], XX[31], YY[31], XX[32], YY[32] );
MathControl.pGraph._c(XX[32], YY[32], XX[33], YY[33], XX[34], YY[34] );
MathControl.pGraph._c(XX[34], YY[34], XX[35], YY[35], XX[36], YY[36] );
MathControl.pGraph._c(XX[36], YY[36], XX[37], YY[37], XX[38], YY[38] );
MathControl.pGraph._c(XX[38], YY[38], XX[39], YY[39], XX[40], YY[40] );
MathControl.pGraph._c(XX[40], YY[40], XX[41], YY[41], XX[42], YY[42] );
MathControl.pGraph._c(XX[42], YY[42], XX[43], YY[43], XX[44], YY[44] );
MathControl.pGraph._c(XX[44], YY[44], XX[45], YY[45], XX[46], YY[46] );
MathControl.pGraph._c(XX[46], YY[46], XX[47], YY[47], XX[48], YY[48] );
MathControl.pGraph._c(XX[48], YY[48], XX[49], YY[49], XX[50], YY[50] );
MathControl.pGraph._c(XX[50], YY[50], XX[51], YY[51], XX[52], YY[52] );
MathControl.pGraph._l(XX[53], YY[53]);
MathControl.pGraph._c(XX[53], YY[53], XX[54], YY[54], XX[55], YY[55] );
MathControl.pGraph._c(XX[55], YY[55], XX[56], YY[56], XX[57], YY[57] );
MathControl.pGraph._c(XX[57], YY[57], XX[58], YY[58], XX[59], YY[59] );
MathControl.pGraph._c(XX[59], YY[59], XX[60], YY[60], XX[61], YY[61] );
MathControl.pGraph._c(XX[61], YY[61], XX[62], YY[62], XX[63], YY[63] );
MathControl.pGraph._c(XX[63], YY[63], XX[64], YY[64], XX[65], YY[65] );
MathControl.pGraph._c(XX[65], YY[65], XX[66], YY[66], XX[67], YY[67] );
MathControl.pGraph._c(XX[67], YY[67], XX[68], YY[68], XX[69], YY[69] );
MathControl.pGraph._c(XX[69], YY[69], XX[70], YY[70], XX[71], YY[71] );
MathControl.pGraph._c(XX[71], YY[71], XX[72], YY[72], XX[73], YY[73] );
MathControl.pGraph._c(XX[73], YY[73], XX[74], YY[74], XX[75], YY[75] );
MathControl.pGraph._c(XX[75], YY[75], XX[76], YY[76], XX[77], YY[77] );
MathControl.pGraph._l(XX[78], YY[78]);
MathControl.pGraph._l(XX[79], YY[79]);
MathControl.pGraph._l(XX[80], YY[80]);
MathControl.pGraph._c(XX[80], YY[80], XX[81], YY[81], XX[82], YY[82] );
MathControl.pGraph._c(XX[82], YY[82], XX[83], YY[83], XX[84], YY[84] );
MathControl.pGraph._c(XX[84], YY[84], XX[85], YY[85], XX[86], YY[86] );
MathControl.pGraph._c(XX[86], YY[86], XX[87], YY[87], XX[88], YY[88] );
MathControl.pGraph._c(XX[88], YY[88], XX[89], YY[89], XX[90], YY[90] );
MathControl.pGraph._c(XX[90], YY[90], XX[91], YY[91], XX[92], YY[92] );
MathControl.pGraph._c(XX[92], YY[92], XX[93], YY[93], XX[94], YY[94] );
MathControl.pGraph._c(XX[94], YY[94], XX[95], YY[95], XX[96], YY[96] );
MathControl.pGraph._c(XX[96], YY[96], XX[97], YY[97], XX[98], YY[98] );
MathControl.pGraph._c(XX[98], YY[98], XX[99], YY[99], XX[100], YY[100] );
MathControl.pGraph._c(XX[100], YY[100], XX[101], YY[101], XX[102], YY[102]);
MathControl.pGraph._c(XX[102], YY[102], XX[103], YY[103], XX[0], YY[0]);
MathControl.pGraph.df();
MathControl.pGraph.SetIntegerGrid(intGrid);
}
...@@ -88,85 +88,6 @@ function DrawingRadical() ...@@ -88,85 +88,6 @@ function DrawingRadical()
MathControl.pGraph.ds(); 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;
...@@ -178,8 +99,6 @@ function CRadical() ...@@ -178,8 +99,6 @@ function CRadical()
y: 0 y: 0
}; };
this.heightTick = 0;
CMathBase.call(this, 1, 1); CMathBase.call(this, 1, 1);
} }
extend(CRadical, CMathBase); extend(CRadical, CMathBase);
...@@ -187,60 +106,6 @@ CRadical.prototype.setContent = function() ...@@ -187,60 +106,6 @@ CRadical.prototype.setContent = function()
{ {
this.fillPlaceholders(); this.fillPlaceholders();
} }
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};
}
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};
}
CRadical.prototype.recalculateSize = function() CRadical.prototype.recalculateSize = function()
{ {
var arg = this.elements[0][0].size; var arg = this.elements[0][0].size;
...@@ -286,202 +151,15 @@ CRadical.prototype.mouseMove = function(pos) ...@@ -286,202 +151,15 @@ CRadical.prototype.mouseMove = function(pos)
//context.fill() для заливки //context.fill() для заливки
//Graphics : df() //Graphics : df()
CRadical.prototype.old_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._m(x1*100, y1*100);
MathControl.pGraph._l(x2*100, y2*100);
MathControl.pGraph.ds();
MathControl.pGraph.p_width(penW*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();
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();
}
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.prototype.draw = function()
{ {
CRadical.superclass.draw.call(this); CRadical.superclass.draw.call(this);
DrawingRadical.call(this); DrawingRadical.call(this);
} }
CRadical.prototype.getBase = function()
{
return this.elements[0][0];
}
function CDegreeRadical() function CDegreeRadical()
{ {
...@@ -506,7 +184,7 @@ function CDegreeRadical() ...@@ -506,7 +184,7 @@ function CDegreeRadical()
CMathBase.call(this, 1, 2); CMathBase.call(this, 1, 2);
} }
extend(CDegreeRadical, CMathBase); extend(CDegreeRadical, CMathBase);
CDegreeRadical.prototype.setContent = function() CDegreeRadical.prototype.old_setContent = function()
{ {
var oBase = new CMathBase(1, 1); var oBase = new CMathBase(1, 1);
oBase.init( this.params ); oBase.init( this.params );
...@@ -520,6 +198,22 @@ CDegreeRadical.prototype.setContent = function() ...@@ -520,6 +198,22 @@ CDegreeRadical.prototype.setContent = function()
var fontDgr = getTypeDegree(this.params.font, true); var fontDgr = getTypeDegree(this.params.font, true);
oDegree.setFont(fontDgr, -1); oDegree.setFont(fontDgr, -1);
CDegreeOrdinary.superclass.setContent.call(this, oDegree, oBase);
}
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); CDegreeOrdinary.superclass.setContent.call(this, oDegree, oBase);
} }
...@@ -676,307 +370,11 @@ CDegreeRadical.prototype.findDisposition = function(mCoord) ...@@ -676,307 +370,11 @@ CDegreeRadical.prototype.findDisposition = function(mCoord)
return {pos: posCurs, mCoord: mouseCoord, inside_flag: inside_flag}; return {pos: posCurs, mCoord: mouseCoord, inside_flag: inside_flag};
} }
CDegreeRadical.prototype.getBase = function()
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; return this.elements[0][1];
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() CDegreeRadical.prototype.getDegree = function()
{ {
var arg = this.elements[0][0].size; return this.elements[0][0];
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._m(x1*100, y1*100);
MathControl.pGraph._l(x2*100, y2*100);
MathControl.pGraph.ds();
MathControl.pGraph.p_width(penW*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();
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();
}
old_CRadical.prototype.draw = function()
{
//this.elements[0][0].draw();
old_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();
} }
...@@ -32,4 +32,11 @@ CTrigFunc.prototype.setDistance = function() ...@@ -32,4 +32,11 @@ CTrigFunc.prototype.setDistance = function()
this.dW = slashWidth(this.params.font); this.dW = slashWidth(this.params.font);
this.dH = 0; this.dH = 0;
} }
CTrigFunc.prototype.getFunction = function()
{
return this.elemens[0][0];
}
CTrigFunc.prototype.getArgument = function()
{
return this.elemens[0][1];
}
...@@ -174,14 +174,15 @@ ...@@ -174,14 +174,15 @@
<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/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>
<script type="text/javascript" src = "Math/radical.js"></script> <script type="text/javascript" src = "Math/radical.js"></script>
<script type="text/javascript" src = "Math/diacritical.js"></script> <script type="text/javascript" src = "Math/diacritical.js"></script>
<script type="text/javascript" src = "Math/parenthesis.js"></script> <!--<script type="text/javascript" src = "Math/parenthesis.js"></script>-->
<script type="text/javascript" src = "Math/operators.js"></script> <script type="text/javascript" src = "Math/operators.js"></script>
<script type="text/javascript" src = "Math/drawingUnion.js"></script> <script type="text/javascript" src = "Math/drawingUnion.js"></script>
<script type="text/javascript" src = "Math/borderBox.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