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

Сделала базовый класс для CMathMatrix и CEqArray

Перенесла файлы с тестовыми функциями в отдельную папку

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@58700 954022d7-b5bf-4e40-9824-e11837661b57
parent 6dd2342c
function CMathPosition()
{
this.x = 0;
this.y = 0;
}
function C_CAccent2(val)
{
this.typeTest = val;
this.Content = new Array();
this.Run = null;
this.Test_ParaRun = null;
this.TestRun = new Array();
this.A = null;
this.X = null;
this.operator = new CTestMathText(true);
this.init();
}
C_CAccent2.prototype.init = function()
{
var A = new CTestMathText(false);
//A.addTxt("a");
var X = new CTestMathText(false);
//X.addTxt("x");
this.A = A;
this.X = X;
this.TestRun = new CTestRun();
this.TestRun.Content.push(this.A);
this.TestRun.Content.push(this.X);
}
C_CAccent2.prototype.setPosition = function(pos)
{
var PosOper = new CMathPosition();
PosOper.x = pos.x;
PosOper.y = pos.y;
this.operator.setPosition(PosOper);
var PosBase = new CMathPosition();
PosBase.x = pos.x;
PosBase.y = pos.y;
this.TestRun.setPosition(PosBase);
}
C_CAccent2.prototype.Resize = function()
{
this.A.size =
{
height: 0,
width: 2.234
};
this.X.size =
{
height: 0,
width: 2.234
};
}
C_CAccent2.prototype.getPosition = function()
{
return this.TestRun.getPosition();
}
function CTestRun()
{
this.Content = new Array();
}
CTestRun.prototype.setPosition = function(pos)
{
var NewPos = new CMathPosition();
NewPos.x = pos.x;
NewPos.y = pos.y;
for(var i = 0; i < this.Content.length; i++)
{
this.Content[i].setPosition(NewPos);
NewPos.x += this.Content[i].size.width;
}
}
CTestRun.prototype.getPosition = function()
{
return "Type 4, First position " + this.Content[0].pos.x + " second position " + this.Content[1].pos.x;
}
function CTestMathText(bJDraw)
{
this.pos = new CMathPosition();
this.bJDraw = bJDraw;
this.GapLeft = 0;
this.rasterOffsetX = 0;
this.rasterOffsetY = 0;
}
CTestMathText.prototype.setPosition = function(pos)
{
if (!this.bJDraw) // for text
{
this.pos.x = pos.x + this.GapLeft;
this.pos.y = pos.y;
}
else // for symbol only drawing
{
this.pos.x = pos.x - this.rasterOffsetX;
this.pos.y = pos.y - this.rasterOffsetY;
}
}
/**
* Created with JetBrains WebStorm.
* User: Anna.Pavlova
* Date: 10/7/14
* Time: 5:37 PM
* To change this template use File | Settings | File Templates.
*/
/*
var metricsTxt = g_oTextMeasurer.Measure2Code(letter);
var _width = metricsTxt.Width;
height = g_oTextMeasurer.GetHeight();
*/
// смена хентов
// editor.SetFontRenderingMode(2);
//change FontSize
//editor.put_TextPrFontSize(parseInt("37"));
function TEST_MATH_JUCTIFICATION(mcJc)
{
MATH_MC_JC = mcJc;
editor.WordControl.m_oLogicDocument.Content[0].Content[0].Root.Resize(null, editor.WordControl.m_oLogicDocument.Content[0].Content[0] , g_oTextMeasurer);
var pos = new CMathPosition();
pos.x = 0;
pos.y = 0;
editor.WordControl.m_oLogicDocument.Content[0].Content[0].Root.setPosition(pos);
editor.WordControl.m_oLogicDocument.DrawingDocument.ClearCachePages();
editor.WordControl.m_oLogicDocument.DrawingDocument.FirePaint();
}
function TEST_MATH_EDIT()
{
//MathComposition.test_for_edit();
MathComposition.test_for_edit();
MathComposition.RecalculateComposition(g_oTextMeasurer, MathComposition.DEFAULT_RUN_PRP);
//MathComposition.Draw_2(x, y, )
editor.WordControl.m_oLogicDocument.DrawingDocument.OnRecalculatePage(0, { Width : Page_Width, Height : Page_Height, Margins : {
Left : X_Left_Field,
Right : X_Right_Field,
Top : Y_Top_Field,
Bottom : Y_Bottom_Field
} } );
}
function TEST_COEFF_ITERATORS()
{
// a*36*36 + b*36 + c = 0.728*tPrp.FontSize = 26
// a*14*14 + b*14 + c = 9
// a*72*72 + b*72 + c = 55
//FSize = 0.0006*FSize*FSize + 0.743*FSize - 1.53;
// argSize = -1
//var x1 = 36, x2 = 14, x3 = 72;
//var d1 = 26, d2 = 10, d3 = 54; // если еще подгонять, то можно d3 = 53,52 взять
var x1 = 36, x2 = 14, x3 = 72;
var d1 = 24, d2 = 10, d3 = 47;
// || x1*x1 x1 1 ||
// || x2*x2 x2 1 ||
// || x3*x3 x3 1 ||
var D = x1*x1*x2 + x1*x3*x3 + x2*x2*x3 - x3*x3*x2 - x3*x1*x1 - x2*x2*x1,
Da = d1*x2 + x1*d3 + d2*x3 - d3*x2 - x3*d1 - d2*x1,
Db = x1*x1*d2 + d1*x3*x3 + x2*x2*d3 - x3*x3*d2 - d3*x1*x1 - x2*x2*d1,
Dc = x1*x1*x2*d3 + x1*x3*x3*d2 + x2*x2*x3*d1 - x3*x3*x2*d1 - x3*x1*x1*d2 - x2*x2*x1*d3;
var a = Da/D,
b = Db/D,
c = Dc/D;
console.log("a: " + a + " b: " + b + " c: " + c);
var check1 = a*x1*x1 + b*x1 + c - d1,
check2 = a*x2*x2 + b*x2 + c - d2,
check3 = a*x3*x3 + b*x3 + c - d3;
console.log("check1: " + check1);
console.log("check2: " + check2);
console.log("check3: " + check3);
var aa = Math.round(a*10000)/10000;
var dd1 = d1 - a*x1*x1,
dd2 = d2 - a*x2*x2;
var DD = x1 - x2,
Dbb = dd1 - dd2,
Dcc = x1*dd2 - x2*dd1;
var bb = Dbb/DD,
cc = Dcc/DD;
bb = Math.round(bb*100)/100;
cc = Math.round(cc*100)/100;
console.log("aa: " + aa + " bb: " + bb + " cc: " + cc);
var check11 = aa*x1*x1 + bb*x1 + cc - d1,
check22 = aa*x2*x2 + bb*x2 + cc - d2,
check33 = aa*x3*x3 + bb*x3 + cc - d3;
console.log("check11: " + check11);
console.log("check22: " + check22);
console.log("check33: " + check33);
}
This diff is collapsed.
"use strict";
var CF_X1 = 0.29;
var CF_X2 = 0.34;
var CF_X3 = 0.07;
var CF_X4 = 0.36;
var CF_X5 = 0;
var CF_X6 = 0.36;
var CF_Y1 = 0.78;
var CF_Y2 = 0.79;
/*var CF_Y3 = 0.84;
var CF_Y4 = 1.0;
var CF_Y5 = 0.77;
var CF_Y6 = 0.85;*/
var CF_Y3 = 0.75;
var CF_Y4 = 1.0;
var CF_Y5 = 0.75;
var CF_Y6 = 0.84;
//var COEFF_TH = 0.73;
var COEFF_TH = 0.81;
var CF_WIDTH = 1.3;
var CF_HEIGHT = 1;
var U_SIZE = 36/0.76;
function DrawUnion()
{
/*var augm = + document.getElementById("CoeffUnion").value;
augm = augm/100;*/
var x = 23,
y = 27;
var betta = U_SIZE/36;
//var _width = 1.3*9.6159*betta,
var _width = CF_WIDTH*9.6159*betta,
//var _width = 10.312548828125*betta,
_height = 11.994444444444444*betta;
var gap = 0.93*betta;
var X = [],
Y = [];
/*X[0] = 10125; Y[0] = 56563;
X[1] = 10125; Y[1] = 0;
X[2] = 0; Y[2] = 0;
X[3] = 0; Y[3] = 56313;
X[4] = 0; Y[4] = 76750;
X[5] = 9031; Y[5] = 87032;
X[6] = 18063; Y[6] = 97313;
X[7] = 35438; Y[7] = 97313;
X[8] = 52813; Y[8] = 97313;
X[9] = 61875; Y[9] = 87251;
X[10] = 70938; Y[10] = 77188;
X[11] = 70938; Y[11] = 58938;
X[12] = 70938; Y[12] = 0;
X[13] = 60813; Y[13] = 0;
X[14] = 60813; Y[14] = 56563;
X[15] = 60813; Y[15] = 72938;
X[16] = 54375; Y[16] = 80782;
X[17] = 47938; Y[17] = 88625;
X[18] = 35438; Y[18] = 88625;
X[19] = 22938; Y[19] = 88625;
X[20] = 16531; Y[20] = 80782;
X[21] = 10125; Y[21] = 72938;
X[22] = 10125; Y[22] = 56563;*/
X[0] = 35438; Y[0] = 88625;
X[1] = 22938; Y[1] = 88625;
X[2] = 16531; Y[2] = 80782;
X[3] = 10125; Y[3] = 72938;
X[4] = 10125; Y[4] = 56563;
X[5] = 10125; Y[5] = 0;
X[6] = 0; Y[6] = 0;
X[7] = 0; Y[7] = 56313;
X[8] = 0; Y[8] = 76750;
X[9] = 9031; Y[9] = 87032;
X[10] = 18063; Y[10] = 97313;
X[11] = 35438; Y[11] = 97313;
var textScale = U_SIZE/1000, // 1000 pt
alpha = textScale*25.4/96 /64;
//var thick = X[1] - X[2];
var thick = (X[5] - X[6])*COEFF_TH;
var Width_1 = (_width - gap)/alpha - 2*thick,
Height = _height/alpha;
var w1 = X[2] - X[4],
w2 = X[0] - X[2],
w3 = X[3] - X[4],
w4 = X[1] - X[2];
/*var k1 = w3/w1,
k2 = w4/w2;*/
var k1 = CF_X3,
k2 = CF_X4;
var WW1 = CF_X1*Width_1/2,
WW2 = WW1*k1,
WW3 = (1- CF_X1)*Width_1/2 *k2;
X[4] *= COEFF_TH;
X[5] *= COEFF_TH;
X[2] = X[4] + WW1;
X[3] = X[4] + WW2;
X[1] = X[4] + WW3 + WW1;
X[0] = X[4] + Width_1/2;
var Width_2 = (_width - gap)/alpha;
var w5 = X[9] - X[7],
w6 = X[11] - X[9],
w7 = X[8] - X[7],
w8 = X[10] - X[9];
/*var k3 = w7/w5,
k4 = w8/w6;*/
var k3 = CF_X5,
k4 = CF_X6;
var WW4 = CF_X2*Width_2/ 2,
WW5 = WW4*k3,
WW6 = (1- CF_X2)*Width_2/2 *k4;
X[8] = X[7] + WW5;
X[9] = X[7] + WW4;
X[10] = X[7] + WW4 + WW6;
X[11] = X[7] + Width_2/2;
var Width = (_width - gap)/alpha;
var HH = (Y[0] - Y[4])*CF_HEIGHT,
h1 = (Y[2] - Y[4])*CF_HEIGHT,
h2 = (Y[0] - Y[2])*CF_HEIGHT;
Y[2] = Y[4] + HH*CF_Y1;
Y[3] = Y[4] + h1*CF_Y3;
Y[1] = Y[4] + HH*CF_Y1 +h2*CF_Y4;
Y[0] = Y[4] + HH;
var HH2 = (Y[11] - Y[7])*CF_HEIGHT,
h3 = (Y[9] - Y[7])*CF_HEIGHT,
h4 = (Y[11] - Y[9])*CF_HEIGHT;
Y[9] = Y[7] + HH2*CF_Y2;
Y[8] = Y[7] + h3*CF_Y5;
Y[10] = Y[7] + HH2*CF_Y2 + h4*CF_Y6;
Y[11] = Y[7] + HH2;
var HH = Y[4]*0.68;
for(var i = 0; i < 5; i++)
{
Y[i] += HH;
Y[7+i] += HH;
}
for(var i = 0; i < 11; i++)
{
X[22 - i] = Width - X[i];
Y[22 - i] = Y[i];
}
var XX = [],
YY = [];
for(var i = 0; i < 23; i++)
{
var xxx = X[i] + 7100;
var str = "X[" + i +"] = " + xxx + "; Y[" + i + "] = " + Y[i] + ";";
console.log(str);
}
for(var i = 0; i < 23; i++)
{
XX[i] = x + X[i]*alpha;
YY[i] = y + Y[i]*alpha;
}
var intGrid = MathControl.pGraph.GetIntegerGrid();
MathControl.pGraph.SetIntegerGrid(false);
MathControl.pGraph.p_width(1000);
MathControl.pGraph.b_color1(0,0,0, 255);
MathControl.pGraph.p_color(0,0,0, 255);
MathControl.pGraph._s();
MathControl.pGraph._m(XX[0], YY[0]);
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._l(XX[6], YY[6]);
MathControl.pGraph._l(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._l(XX[16], YY[16]);
MathControl.pGraph._l(XX[17], YY[17]);
MathControl.pGraph._l(XX[18], YY[18]);
MathControl.pGraph._c(XX[18], YY[18], XX[19], YY[19], XX[20], YY[20]);
MathControl.pGraph._c(XX[20], YY[20], XX[21], YY[21], XX[22], YY[22]);
MathControl.pGraph.df();
MathControl.pGraph.SetIntegerGrid(intGrid);
}
"use strict";
var DEGR_REDUCT = 0.728;
var default_font = {FontFamily : {Name : "Cambria Math", Index : -1 }, FontSize : 36};
//var metricsDF = {};
function GetMathFont(GFont)
{
g_oTextMeasurer.SetFont(GFont);
var metrics =
{
Height: g_oTextMeasurer.GetHeight(),
Descender: (-1)*g_oTextMeasurer.GetDescender(),
Placeholder: g_oTextMeasurer.Measure2Code( StartTextElement )
};
var Fnt =
{
FontSize: GFont.FontSize,
FontFamily : Common_CopyObj(GFont.FontFamily),
metrics: metrics
};
return Fnt;
}
/*function GetMetrics(value, font)
{
g_oTextMeasurer.SetFont(type.font);
return g_oTextMeasurer.Measure2Code(value);
}*/
/*function getTypeHeight(h)
{
var H1 = metricsDF.Height + metricsDF.Descender + metricsDF.Placeholder.Height,
H2 = 2.5*metricsDF.Placeholder.Height,
H3 = H1 + metricsDF.Placeholder.Height,
H4 = H3 + metricsDF.Descender,
H5 = H3 + H1;
var type = null;
if(h < H2)
type = 0;
else if(h < H4)
type = 1;
else if(h < H5)
type = 2;
else
type = 3;
return type;
}*/
function getStateHeight(height, print)
{
var metric = print.metrics;
var state = null;
var H1 = metric.Height + metric.Descender + metric.Placeholder.Height,
H2 = 2.5*metric.Placeholder.Height,
H3 = H1 + metric.Placeholder.Height,
H4 = H3 + metric.Descender,
H5 = H3 + H1;
if(height < H2)
state = 0;
else if(height < H4)
state = 1;
else if(height < H5)
state = 2;
else
state = 3;
return state;
}
function getMaxHeight(print)
{
var metric = print.metrics;
var H1 = metric.Height + metric.Descender + metric.Placeholder.Height,
H2 = 2.5*metric.Placeholder.Height,
H3 = H1 + metric.Placeholder.Height,
H4 = H3 + metric.Descender,
H5 = H3 + H1;
return H5;
}
function getStateHeight_2(height, GFont)
{
var metric = GFont.metrics;
var state = null;
var gap = metric.Height - metric.Placeholder.Height;
var H1 = metric.Height,
H2 = H1 + gap,
H3 = 2*metric.Placeholder.Height + gap,
H4 = 3*metric.Placeholder.Height + 2*gap,
H5 = 4*metric.Placeholder.Height + 2*gap;
if( height < H1 )
state = 0;
else if( height < H3 )
state = 1;
else if( height < H4 )
state = 2;
else if( height < H5 )
state = 3;
else
state = 4;
return state;
}
function getTypeDegree(IFont, flag)
{
var fontSize = null;
var CONST_INDEX = flag ? 0.62 : 0.728;
var sD = IFont.FontSize*CONST_INDEX;
if( sD - Math.floor(sD) > 0.65 )
fontSize = Math.ceil(sD) - 0.5;
else
fontSize = Math.floor(sD);
var GFont = {FontFamily: IFont.FontFamily, FontSize: fontSize};
var IFont = GetMathFont(GFont);
return IFont;
}
function getStateHeight_1(height, GFont)
{
var metric = GFont.metrics,
state = 0;
var gap = metric.Height - metric.Placeholder.Height;
var H5 = 5*metric.Placeholder.Height + 4*gap;
if(H5 < height)
state = 3;
return state;
}
function getMaxHeight_1(print)
{
var metric = print.metrics;
var gap = metric.Height - metric.Placeholder.Height;
return 5*metric.Placeholder.Height + 4*gap;
}
function getStateHeight_3( height, GFont) //for radical
{
var metric = GFont.metrics,
GenHeight;
var gap = metric.Height - metric.Placeholder.Height;
var H0 = metric.Placeholder.Height,
H1 = metric.Height,
H2 = 2*metric.Placeholder.Height + 1.5*gap,
H3 = 3*metric.Placeholder.Height + 2.4*gap,
H4 = 4*metric.Placeholder.Height + 3*gap,
H5 = 5*metric.Placeholder.Height + 4*gap;
if(height < H0)
GenHeight = H1*0.75;
else if( height < H1 )
GenHeight = H1;
else if( height < H2 )
GenHeight = H2;
else if( height < H3 )
GenHeight = H3;
else if( height < H4 )
GenHeight = H4;
else if(height < H5)
GenHeight = H5;
else
GenHeight = height;
return GenHeight;
}
\ No newline at end of file
...@@ -4668,89 +4668,3 @@ CMathContent.prototype = ...@@ -4668,89 +4668,3 @@ CMathContent.prototype =
} }
} }
function TEST_MATH_EDIT()
{
//MathComposition.test_for_edit();
MathComposition.test_for_edit();
MathComposition.RecalculateComposition(g_oTextMeasurer, MathComposition.DEFAULT_RUN_PRP);
//MathComposition.Draw_2(x, y, )
editor.WordControl.m_oLogicDocument.DrawingDocument.OnRecalculatePage(0, { Width : Page_Width, Height : Page_Height, Margins : {
Left : X_Left_Field,
Right : X_Right_Field,
Top : Y_Top_Field,
Bottom : Y_Bottom_Field
} } );
}
function TEST_COEFF_ITERATORS()
{
// a*36*36 + b*36 + c = 0.728*tPrp.FontSize = 26
// a*14*14 + b*14 + c = 9
// a*72*72 + b*72 + c = 55
//FSize = 0.0006*FSize*FSize + 0.743*FSize - 1.53;
// argSize = -1
//var x1 = 36, x2 = 14, x3 = 72;
//var d1 = 26, d2 = 10, d3 = 54; // если еще подгонять, то можно d3 = 53,52 взять
var x1 = 36, x2 = 14, x3 = 72;
var d1 = 24, d2 = 10, d3 = 47;
// || x1*x1 x1 1 ||
// || x2*x2 x2 1 ||
// || x3*x3 x3 1 ||
var D = x1*x1*x2 + x1*x3*x3 + x2*x2*x3 - x3*x3*x2 - x3*x1*x1 - x2*x2*x1,
Da = d1*x2 + x1*d3 + d2*x3 - d3*x2 - x3*d1 - d2*x1,
Db = x1*x1*d2 + d1*x3*x3 + x2*x2*d3 - x3*x3*d2 - d3*x1*x1 - x2*x2*d1,
Dc = x1*x1*x2*d3 + x1*x3*x3*d2 + x2*x2*x3*d1 - x3*x3*x2*d1 - x3*x1*x1*d2 - x2*x2*x1*d3;
var a = Da/D,
b = Db/D,
c = Dc/D;
console.log("a: " + a + " b: " + b + " c: " + c);
var check1 = a*x1*x1 + b*x1 + c - d1,
check2 = a*x2*x2 + b*x2 + c - d2,
check3 = a*x3*x3 + b*x3 + c - d3;
console.log("check1: " + check1);
console.log("check2: " + check2);
console.log("check3: " + check3);
var aa = Math.round(a*10000)/10000;
var dd1 = d1 - a*x1*x1,
dd2 = d2 - a*x2*x2;
var DD = x1 - x2,
Dbb = dd1 - dd2,
Dcc = x1*dd2 - x2*dd1;
var bb = Dbb/DD,
cc = Dcc/DD;
bb = Math.round(bb*100)/100;
cc = Math.round(cc*100)/100;
console.log("aa: " + aa + " bb: " + bb + " cc: " + cc);
var check11 = aa*x1*x1 + bb*x1 + cc - d1,
check22 = aa*x2*x2 + bb*x2 + cc - d2,
check33 = aa*x3*x3 + bb*x3 + cc - d3;
console.log("check11: " + check11);
console.log("check22: " + check22);
console.log("check33: " + check33);
}
\ No newline at end of file
This diff is collapsed.
"use strict"; "use strict";
/*var SIGN_GAP = 0;
var RADICAL_GAP = 0.2513;
var RADICAL_H4 = 1.1715;
var RADICAL_H0 = 0;
var RADICAL_H1 = 0;
var RADICAL_H2 = 0;
var RADICAL_H3 = 0;
var RADICAL_H5 = 0;*/
/*var SIGN_GAP = 0.05;
var RADICAL_GAP = 0.1216;
var RADICAL_H4 = 1.2393;
var RADICAL_H0 = 0;
var RADICAL_H1 = 1.1588;
var RADICAL_H2 = 1.1673;
var RADICAL_H3 = 1.0232;
var RADICAL_H5 = 0;*/
//var SIGN_GAP = 0.05;
//var RADICAL_GAP = 0.1216;
//var GAP_TOP = 0.05;
//var SIGN_GAP = 0.1216;
//var GAP_TOP = 0.01822;
var GAP_TOP = 0.094492; var GAP_TOP = 0.094492;
var SIGN_GAP = 0.077108; var SIGN_GAP = 0.077108;
/*var RADICAL_H0 = 0;
var RADICAL_H1 = 0.1589;
var RADICAL_H2 = 0.1674;
var RADICAL_H3 = 0.038;
var RADICAL_H4 = 0.303;
var RADICAL_H5 = 0.2394;*/
var RADICAL_H0 = 1.2; var RADICAL_H0 = 1.2;
var RADICAL_H1 = 1.50732421875; var RADICAL_H1 = 1.50732421875;
var RADICAL_H2 = 2.8; var RADICAL_H2 = 2.8;
......
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