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

trigonometric function (new)

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@48152 954022d7-b5bf-4e40-9824-e11837661b57
parent e0bb9f95
...@@ -80,15 +80,17 @@ CMathBase.prototype = ...@@ -80,15 +80,17 @@ CMathBase.prototype =
txtPrp.Merge(this.textPrp); txtPrp.Merge(this.textPrp);
txtPrp.FontSize *= this.reduct;
return txtPrp; return txtPrp;
}, },
getTxtPrp_2: function() /*getTxtPrp_2: function()
{ {
var txtPrp = this.getTxtPrp(); var txtPrp = this.getTxtPrp();
txtPrp.FontSize *= this.reduct; txtPrp.FontSize *= this.reduct;
return txtPrp; return txtPrp;
}, },*/
setComposition: function(Compos) setComposition: function(Compos)
{ {
this.Composition = Compos; this.Composition = Compos;
......
...@@ -18,12 +18,12 @@ CBarFraction.prototype.init = function() ...@@ -18,12 +18,12 @@ CBarFraction.prototype.init = function()
} }
CBarFraction.prototype.getCenter = function() CBarFraction.prototype.getCenter = function()
{ {
var penW = this.getTxtPrp_2().FontSize* 25.4/96 * 0.08 /2; var penW = this.getTxtPrp().FontSize* 25.4/96 * 0.08 /2;
return this.elements[0][0].size.height + penW; return this.elements[0][0].size.height + penW;
} }
CBarFraction.prototype.draw = function() CBarFraction.prototype.draw = function()
{ {
var penW = this.getTxtPrp_2().FontSize* this.reduct* 25.4/96 * 0.08; var penW = this.getTxtPrp().FontSize* this.reduct* 25.4/96 * 0.08;
var x1 = this.pos.x, var x1 = this.pos.x,
x2 = this.pos.x + this.size.width, x2 = this.pos.x + this.size.width,
...@@ -73,7 +73,7 @@ CNumerator.prototype.init = function() ...@@ -73,7 +73,7 @@ CNumerator.prototype.init = function()
CNumerator.prototype.recalculateSize = function() CNumerator.prototype.recalculateSize = function()
{ {
var arg = this.elements[0][0].size; var arg = this.elements[0][0].size;
var txtPrp = this.getTxtPrp_2(); var txtPrp = this.getTxtPrp();
var Descent = arg.height - arg.ascent; // baseLine var Descent = arg.height - arg.ascent; // baseLine
var gap = 7.832769097222222 * txtPrp.FontSize/36, var gap = 7.832769097222222 * txtPrp.FontSize/36,
...@@ -177,7 +177,7 @@ CDenominator.prototype.init = function() ...@@ -177,7 +177,7 @@ CDenominator.prototype.init = function()
CDenominator.prototype.recalculateSize = function() CDenominator.prototype.recalculateSize = function()
{ {
var arg = this.elements[0][0].size; var arg = this.elements[0][0].size;
var txtPrp = this.getTxtPrp_2(); var txtPrp = this.getTxtPrp();
var gap = 7.832769097222222 * txtPrp.FontSize/36, var gap = 7.832769097222222 * txtPrp.FontSize/36,
Ascent = arg.ascent, Ascent = arg.ascent,
......
...@@ -150,10 +150,16 @@ CMinimax.prototype.setDistance = function() ...@@ -150,10 +150,16 @@ CMinimax.prototype.setDistance = function()
function CMathFunc() function CMathFunc()
{ {
CMathBase.call(this, 1,2); CMathBase.call(this);
} }
extend(CMathFunc, CMathBase); extend(CMathFunc, CMathBase);
CMathFunc.prototype.setContent = function() CMathFunc.prototype.init = function()
{
this.setDimension(1, 2);
this.setContent();
this.elements[0][0].mergeTxtPrp({Italic: false}); // trigonometrical function
}
CMathFunc.prototype.old_setContent = function()
{ {
var oFunc = new CMathContent(); var oFunc = new CMathContent();
var GParms = Common_CopyObj(this.params); var GParms = Common_CopyObj(this.params);
...@@ -169,8 +175,7 @@ CMathFunc.prototype.setContent = function() ...@@ -169,8 +175,7 @@ CMathFunc.prototype.setContent = function()
} }
CMathFunc.prototype.setDistance = function() CMathFunc.prototype.setDistance = function()
{ {
this.dW = this.params.font.FontSize/6*g_dKoef_pt_to_mm; this.dW = this.getTxtPrp().FontSize/6*g_dKoef_pt_to_mm;
this.dH = 0;
} }
CMathFunc.prototype.getFunction = function() CMathFunc.prototype.getFunction = function()
{ {
......
...@@ -117,6 +117,10 @@ CMathContent.prototype = ...@@ -117,6 +117,10 @@ CMathContent.prototype =
{ {
this.textPrp.Set(txtPrp); this.textPrp.Set(txtPrp);
}, },
mergeTxtPrp: function(txtPrp)
{
this.textPrp.Merge(txtPrp);
},
setComposition: function(Compos) setComposition: function(Compos)
{ {
this.Composition = Compos; this.Composition = Compos;
...@@ -128,8 +132,8 @@ CMathContent.prototype = ...@@ -128,8 +132,8 @@ CMathContent.prototype =
this.addLetter( txt.charCodeAt(i)); this.addLetter( txt.charCodeAt(i));
} }
this.rInterval.startPos = this.CurPos - txt.length + 1; //this.rInterval.startPos = this.CurPos - txt.length + 1;
this.rInterval.endPos = this.CurPos + 1; //this.rInterval.endPos = this.rInterval.endPos + txt.length - 1;
this.setStart_Selection(this.CurPos); this.setStart_Selection(this.CurPos);
this.selection.active = false; this.selection.active = false;
...@@ -167,8 +171,8 @@ CMathContent.prototype = ...@@ -167,8 +171,8 @@ CMathContent.prototype =
this.addElementToContent(symb, gps); this.addElementToContent(symb, gps);
this.rInterval.startPos = this.CurPos; //this.rInterval.startPos = this.CurPos;
this.rInterval.endPos = this.CurPos + 1; // max количество элементов this.CurPos this.rInterval.endPos += 2; // max количество элементов this.CurPos
}, },
createMComponent: function(ind) createMComponent: function(ind)
{ {
...@@ -211,6 +215,9 @@ CMathContent.prototype = ...@@ -211,6 +215,9 @@ CMathContent.prototype =
case 10: case 10:
mathElem = new CSeparatorDelimiter(); mathElem = new CSeparatorDelimiter();
break; break;
case 11:
mathElem = new CMathFunc();
break;
case 30: case 30:
mathElem = new CMathBase(); mathElem = new CMathBase();
break; break;
...@@ -226,8 +233,10 @@ CMathContent.prototype = ...@@ -226,8 +233,10 @@ CMathContent.prototype =
this.addElementToContent( mathElem, new dist(l_gap, r_gap, 0, 0) ); this.addElementToContent( mathElem, new dist(l_gap, r_gap, 0, 0) );
this.addElementToContent(new CEmpty()); this.addElementToContent(new CEmpty());
this.rInterval.startPos = this.CurPos - 1; //this.rInterval.startPos = this.CurPos - 1;
this.rInterval.endPos = this.CurPos; //this.rInterval.endPos = this.CurPos;
this.rInterval.endPos++;
} }
return mathElem; // for finished equation return mathElem; // for finished equation
...@@ -1011,6 +1020,323 @@ CMathContent.prototype = ...@@ -1011,6 +1020,323 @@ CMathContent.prototype =
var den = fract.getDenominator(); var den = fract.getDenominator();
den.addTxt("k"); den.addTxt("k");
break; break;
case 124:
var trig = this.createMComponent(11);
trig.init();
var func = trig.getFunction();
func.addTxt("sin");
var arg = trig.getArgument();
arg.fillPlaceholders();
break;
case 125:
var trig = this.createMComponent(11);
trig.init();
var func = trig.getFunction();
func.addTxt("cos");
var arg = trig.getArgument();
arg.fillPlaceholders();
break;
case 126:
var trig = this.createMComponent(11);
trig.init();
var func = trig.getFunction();
func.addTxt("tan");
var arg = trig.getArgument();
arg.fillPlaceholders();
break;
case 127:
var trig = this.createMComponent(11);
trig.init();
var func = trig.getFunction();
func.addTxt("csc");
var arg = trig.getArgument();
arg.fillPlaceholders();
break;
case 128:
var trig = this.createMComponent(11);
trig.init();
var func = trig.getFunction();
func.addTxt("sec");
var arg = trig.getArgument();
arg.fillPlaceholders();
break;
case 129:
var trig = this.createMComponent(11);
trig.init();
var func = trig.getFunction();
func.addTxt("cot");
var arg = trig.getArgument();
arg.fillPlaceholders();
break;
case 130:
var trig = this.createMComponent(11);
trig.init();
var func = trig.getFunction();
var degr = func.createMComponent(3);
degr.init();
degr.setIndex(1);
var base = degr.getBase();
base.mergeTxtPrp({Italic: false});
base.addTxt("sin");
var iter = degr.getIterator();
iter.addTxt("-1");
var arg = trig.getArgument();
arg.fillPlaceholders();
break;
case 131:
var trig = this.createMComponent(11);
trig.init();
var func = trig.getFunction();
var degr = func.createMComponent(3);
degr.init();
degr.setIndex(1);
var base = degr.getBase();
base.mergeTxtPrp({Italic: false});
base.addTxt("cos");
var iter = degr.getIterator();
iter.addTxt("-1");
var arg = trig.getArgument();
arg.fillPlaceholders();
break;
case 132:
var trig = this.createMComponent(11);
trig.init();
var func = trig.getFunction();
var degr = func.createMComponent(3);
degr.init();
degr.setIndex(1);
var base = degr.getBase();
base.mergeTxtPrp({Italic: false});
base.addTxt("tan");
var iter = degr.getIterator();
iter.addTxt("-1");
var arg = trig.getArgument();
arg.fillPlaceholders();
break;
case 133:
var trig = this.createMComponent(11);
trig.init();
var func = trig.getFunction();
var degr = func.createMComponent(3);
degr.init();
degr.setIndex(1);
var base = degr.getBase();
base.mergeTxtPrp({Italic: false});
base.addTxt("csc");
var iter = degr.getIterator();
iter.addTxt("-1");
var arg = trig.getArgument();
arg.fillPlaceholders();
break;
case 134:
var trig = this.createMComponent(11);
trig.init();
var func = trig.getFunction();
var degr = func.createMComponent(3);
degr.init();
degr.setIndex(1);
var base = degr.getBase();
base.mergeTxtPrp({Italic: false});
base.addTxt("sec");
var iter = degr.getIterator();
iter.addTxt("-1");
var arg = trig.getArgument();
arg.fillPlaceholders();
break;
case 135:
var trig = this.createMComponent(11);
trig.init();
var func = trig.getFunction();
var degr = func.createMComponent(3);
degr.init();
degr.setIndex(1);
var base = degr.getBase();
base.mergeTxtPrp({Italic: false});
base.addTxt("cot");
var iter = degr.getIterator();
iter.addTxt("-1");
var arg = trig.getArgument();
arg.fillPlaceholders();
break;
case 136:
var trig = this.createMComponent(11);
trig.init();
var func = trig.getFunction();
func.addTxt("sinh");
var arg = trig.getArgument();
arg.fillPlaceholders();
break;
case 137:
var trig = this.createMComponent(11);
trig.init();
var func = trig.getFunction();
func.addTxt("cosh");
var arg = trig.getArgument();
arg.fillPlaceholders();
break;
case 138:
var trig = this.createMComponent(11);
trig.init();
var func = trig.getFunction();
func.addTxt("tanh");
var arg = trig.getArgument();
arg.fillPlaceholders();
break;
case 139:
var trig = this.createMComponent(11);
trig.init();
var func = trig.getFunction();
func.addTxt("csch");
var arg = trig.getArgument();
arg.fillPlaceholders();
break;
case 140:
var trig = this.createMComponent(11);
trig.init();
var func = trig.getFunction();
func.addTxt("sech");
var arg = trig.getArgument();
arg.fillPlaceholders();
break;
case 141:
var trig = this.createMComponent(11);
trig.init();
var func = trig.getFunction();
func.addTxt("coth");
var arg = trig.getArgument();
arg.fillPlaceholders();
break;
case 142:
var trig = this.createMComponent(11);
trig.init();
var func = trig.getFunction();
var degr = func.createMComponent(3);
degr.init();
degr.setIndex(1);
var base = degr.getBase();
base.mergeTxtPrp({Italic: false});
base.addTxt("sinh");
var iter = degr.getIterator();
iter.addTxt("-1");
var arg = trig.getArgument();
arg.fillPlaceholders();
break;
case 143:
var trig = this.createMComponent(11);
trig.init();
var func = trig.getFunction();
var degr = func.createMComponent(3);
degr.init();
degr.setIndex(1);
var base = degr.getBase();
base.mergeTxtPrp({Italic: false});
base.addTxt("cosh");
var iter = degr.getIterator();
iter.addTxt("-1");
var arg = trig.getArgument();
arg.fillPlaceholders();
break;
case 144:
var trig = this.createMComponent(11);
trig.init();
var func = trig.getFunction();
var degr = func.createMComponent(3);
degr.init();
degr.setIndex(1);
var base = degr.getBase();
base.mergeTxtPrp({Italic: false});
base.addTxt("tanh");
var iter = degr.getIterator();
iter.addTxt("-1");
var arg = trig.getArgument();
arg.fillPlaceholders();
break;
case 145:
var trig = this.createMComponent(11);
trig.init();
var func = trig.getFunction();
var degr = func.createMComponent(3);
degr.init();
degr.setIndex(1);
var base = degr.getBase();
base.mergeTxtPrp({Italic: false});
base.addTxt("csch");
var iter = degr.getIterator();
iter.addTxt("-1");
var arg = trig.getArgument();
arg.fillPlaceholders();
break;
case 146:
var trig = this.createMComponent(11);
trig.init();
var func = trig.getFunction();
var degr = func.createMComponent(3);
degr.init();
degr.setIndex(1);
var base = degr.getBase();
base.mergeTxtPrp({Italic: false});
base.addTxt("sech");
var iter = degr.getIterator();
iter.addTxt("-1");
var arg = trig.getArgument();
arg.fillPlaceholders();
break;
case 147:
var trig = this.createMComponent(11);
trig.init();
var func = trig.getFunction();
var degr = func.createMComponent(3);
degr.init();
degr.setIndex(1);
var base = degr.getBase();
base.mergeTxtPrp({Italic: false});
base.addTxt("coth");
var iter = degr.getIterator();
iter.addTxt("-1");
var arg = trig.getArgument();
arg.fillPlaceholders();
break;
case 148:
var trig = this.createMComponent(11);
trig.init();
var func = trig.getFunction();
func.addTxt("sin");
var arg = trig.getArgument();
arg.addTxt("θ");
break;
case 149:
var trig = this.createMComponent(11);
trig.init();
var func = trig.getFunction();
func.addTxt("cos");
var arg = trig.getArgument();
arg.addTxt("2x");
break;
case 150:
var trig = this.createMComponent(11);
trig.init();
var func = trig.getFunction();
func.addTxt("tan");
var arg = trig.getArgument();
arg.addTxt("θ");
this.addTxt("=");
var fract = this.createMComponent(0);
fract.init();
var num = fract.getNumerator();
var sin = num.createMComponent(11);
sin.init();
sin.getFunction().addTxt("sin");
sin.getArgument().addTxt("θ");
var den = fract.getDenominator();
var cos = den.createMComponent(11);
cos.init();
cos.getFunction().addTxt("cos");
cos.getArgument().addTxt("θ");
break;
} }
}, },
removeAreaSelect: function() removeAreaSelect: function()
...@@ -1572,12 +1898,12 @@ CMathContent.prototype = ...@@ -1572,12 +1898,12 @@ CMathContent.prototype =
RecalculateReverse: function() RecalculateReverse: function()
{ {
// for add component, set Txt Properties // for add component, set Txt Properties
var start = this.rInterval.startPos, var start = this.rInterval.startPos + 1,
end = this.rInterval.endPos; end = this.rInterval.endPos + 1;
for(var i = start; i < end; i++) for(var i = start; i < end; i++)
this.content[i].value.Resize(); this.content[i].value.Resize();
this.rInterval.startPos = this.rInterval.endPos; this.rInterval.startPos = this.rInterval.endPos = this.CurPos;
this.recalculateSize(); this.recalculateSize();
if(! this.bRoot ) if(! this.bRoot )
......
...@@ -20,7 +20,7 @@ CMathTextPrp.prototype = ...@@ -20,7 +20,7 @@ CMathTextPrp.prototype =
Merge: function(prp) Merge: function(prp)
{ {
if(prp.FontFamily !== undefined) if(prp.FontFamily !== undefined)
this.FontFamily = prp.FontFamily; this.FontFamily = Common_CopyObj(prp.FontFamily);
if(prp.FontSize !== undefined) if(prp.FontSize !== undefined)
this.FontSize = prp.FontSize; this.FontSize = prp.FontSize;
...@@ -31,6 +31,13 @@ CMathTextPrp.prototype = ...@@ -31,6 +31,13 @@ CMathTextPrp.prototype =
if(prp.Italic !== undefined) if(prp.Italic !== undefined)
this.Italic = prp.Italic; this.Italic = prp.Italic;
},
Set: function(prp)
{
this.FontFamily = Common_CopyObj(prp.FontFamily);
this.FontSize = prp.FontSize;
this.Bold = prp.Bold;
this.Italic = prp.Italic;
} }
} }
...@@ -130,13 +137,6 @@ CMathText.prototype = ...@@ -130,13 +137,6 @@ CMathText.prototype =
return txtPrp; return txtPrp;
}, },
getTxtPrp_Out: function()
{
var txtPrp = this.Parent.getTxtPrp();
txtPrp.Merge(this.TextPrp);
return txtPrp;
},
setTxtPrp: function(txtPrp) setTxtPrp: function(txtPrp)
{ {
this.textPrp.Set(txtPrp); this.textPrp.Set(txtPrp);
......
...@@ -548,123 +548,6 @@ CDelimiter.prototype.init_2 = function(params, base) ...@@ -548,123 +548,6 @@ CDelimiter.prototype.init_2 = function(params, base)
this.alignVer(2, 0.5); this.alignVer(2, 0.5);
} }
} }
CDelimiter.prototype.old_setContent = function(arg)
{
var operator1, operator2,
loc1, loc2;
if(this.loc == 0)
loc1 = 0;
else if(this.loc == 1)
loc2 = 1;
else if(this.loc == 2)
loc1 = 2;
else if(this.loc == 3)
loc2 = 3;
else if(this.loc == 4)
{
loc1 = 2;
loc2 = 3;
}
else
{
loc1 = 0;
loc2 = 1;
}
if(this.type == 0)
{
operator1 = new COperatorParenthesis();
operator2 = new COperatorParenthesis();
}
else if(this.type == 1)
{
operator1 = new COperatorBracket();
operator2 = new COperatorBracket();
}
else if(this.type == 2)
{
operator1 = new CSquareBracket();
operator2 = new CSquareBracket();
}
else if(this.type == 3)
{
operator1 = new COperatorAngleBracket();
operator2 = new COperatorAngleBracket();
}
else if(this.type == 4)
{
operator1 = new CHalfSquareBracket();
operator2 = new CHalfSquareBracket();
}
else if(this.type == 5)
{
operator1 = new COperatorLine();
operator2 = new COperatorLine();
}
else if(this.type == 6)
{
operator1 = new COperatorDoubleLine();
operator2 = new COperatorDoubleLine();
}
else
{
operator1 = new CWhiteSquareBracket();
operator2 = new CWhiteSquareBracket();
}
var params1 = Common_CopyObj(this.params),
params2 = Common_CopyObj(this.params);
operator1.init(params1);
operator1.setLocation(loc1, this.turn1);
operator2.init(params2);
operator2.setLocation(loc2, this.turn2);
var argument;
if(arg !== null && typeof(arg)!== "undefined")
argument = arg;
else
{
argument = new CMathContent();
argument.init(this.params);
argument.relate(this);
argument.fillPlaceholders();
}
this.base = argument;
if(this.loc == 0 || this.loc == 2)
{
CDelimiter.superclass.setContent.call(this, operator1, argument);
}
else if(this.loc == 1 || this.loc == 3)
{
CDelimiter.superclass.setContent.call(this, argument, operator2);
}
else
{
CDelimiter.superclass.setContent.call(this, operator1, argument, operator2);
}
//выравнивание для случая когда центр смещен (не середина), для вложенных дробей и т.п.
if(this.loc == 2)
{
this.alignVer(0, 0.5);
}
else if(this.loc == 3)
{
this.alignVer(1, 0.5);
}
if(this.loc == 4)
{
this.alignVer(0, 0.5);
this.alignVer(2, 0.5);
}
}
CDelimiter.prototype.recalculateSize = function() CDelimiter.prototype.recalculateSize = function()
{ {
var width, height, center; var width, height, center;
...@@ -2968,15 +2851,6 @@ CSeparatorDelimiter.prototype.init = function(type, column) ...@@ -2968,15 +2851,6 @@ CSeparatorDelimiter.prototype.init = function(type, column)
}; };
this.init_2(params, base); this.init_2(params, base);
} }
CSeparatorDelimiter.prototype.old_setContent = function()
{
var arg = new CSeparator(this.column);
arg.init(this.params);
arg.relate(this);
arg.fillPlaceholders();
CSeparatorDelimiter.superclass.setContent.call(this, arg);
}
CSeparatorDelimiter.prototype.mouseMove = function(mCoord) CSeparatorDelimiter.prototype.mouseMove = function(mCoord)
{ {
var elem = this.findDisposition( mCoord); var elem = this.findDisposition( mCoord);
......
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