operators.js 114 KB
Newer Older
Alexander.Trofimov's avatar
Alexander.Trofimov committed
1 2
"use strict";

3 4
function CGlyphOperator()
{
Anna.Pavlova's avatar
Anna.Pavlova committed
5
    this.loc =  null;
6 7
    this.turn = null;

Anna.Pavlova's avatar
Anna.Pavlova committed
8
    this.size = null;
9
    this.stretch = 0;
Anna.Pavlova's avatar
Anna.Pavlova committed
10
    this.bStretch = true;
Anna.Pavlova's avatar
Anna.Pavlova committed
11

12 13
    this.MIN_AUG = 1;

Anna.Pavlova's avatar
Anna.Pavlova committed
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
    this.penW = 1; // px
}
CGlyphOperator.prototype.init = function(props)
{
    // location

    // 0 - up
    // 1 - down
    // 2 - left
    // 3 - right

    // turn

    // 0 - 0
    // 1 - Pi
    // 2 - Pi/2
    // 3 - 3*Pi/2

    this.loc = props.location;
    this.turn = props.turn;
Anna.Pavlova's avatar
Anna.Pavlova committed
34
    this.bStretch = (props.bStretch == true || props.bStretch == false) ? props.bStretch : true;
35 36 37 38 39

    if(this.loc == LOCATION_TOP || this.loc  == LOCATION_BOT)
        this.MIN_AUG = 0.8;
    else
        this.MIN_AUG = 1;
Anna.Pavlova's avatar
Anna.Pavlova committed
40
}
41
CGlyphOperator.prototype.fixSize = function(stretch)
Anna.Pavlova's avatar
Anna.Pavlova committed
42
{
43
    var sizeGlyph = this.calcSize(stretch);
44
    var width, height, ascent;
Anna.Pavlova's avatar
Anna.Pavlova committed
45 46

    //var betta = this.getTxtPrp().FontSize/36;
47
    var bHor = this.loc == LOCATION_TOP || this.loc  == LOCATION_BOT;
Anna.Pavlova's avatar
Anna.Pavlova committed
48 49 50 51 52 53

    if(bHor)
    {
        width = sizeGlyph.width;
        height = sizeGlyph.height;

54
        ascent = height/2;
Anna.Pavlova's avatar
Anna.Pavlova committed
55 56 57 58 59 60
        //
        if(this.bStretch)
            this.stretch = stretch > width ? stretch : width;
        else
            this.stretch = width;

Anna.Pavlova's avatar
Anna.Pavlova committed
61 62 63 64 65 66 67 68 69
    }
    else
    {
        width = sizeGlyph.height;
        height = sizeGlyph.width;

        // baseLine смещен чуть вверх, чтобы текст при вставке в скобки располагался по центру, относительно высоты скобок
        // плейсхолдер из-за этого располагается чуть выше, как в Ворде
        //center = height/2 - 1.234722222222222*betta;
70
        ascent = height/2;
71
        this.stretch = stretch > height ? stretch : height;
Anna.Pavlova's avatar
Anna.Pavlova committed
72 73
    }

74
    this.size = {width: width, height: height, ascent: ascent};
Anna.Pavlova's avatar
Anna.Pavlova committed
75 76 77
}
CGlyphOperator.prototype.draw_other = function() //  с выравниванием к краю (относительно аргумента)
{
78
    var coord = this.calcCoord(this.stretch);
Anna.Pavlova's avatar
Anna.Pavlova committed
79 80 81 82 83

    var X = coord.XX, Y = coord.YY,
        W =  this.size.width, H =  this.size.height,
        glW, glH;

84 85
    var a1, a2, b1, b2, c1, c2;

Anna.Pavlova's avatar
Anna.Pavlova committed
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
    var bHor = this.loc == 0 || this.loc  == 1;

    if(bHor)
    {
        glW = coord.W;
        glH = coord.H;
    }
    else
    {
        glW = coord.H;
        glH = coord.W;
    }

    var shW =  (W - glW)/ 2, // выравниваем глиф по длине
        shH =  (H - glH)/2; // при повороте на 90 градусовы

    if(this.loc == 0)
    {
        a1 = 1; b1 = 0; c1 = shW;
        a2 = 0; b2 = 1; c2 = 0;
    }
    else if(this.loc == 1)
    {
        a1 = 1; b1 = 0; c1 = shW;
        a2 = 0; b2 = 1; c2 = H - glH;
    }
    else if(this.loc == 2)
    {
        a1 = 0; b1 = 1; c1 = 0;
        a2 = 1; b2 = 0; c2 = shH;
    }
Anna.Pavlova's avatar
Anna.Pavlova committed
117
    else if(this.loc == 3)
Anna.Pavlova's avatar
Anna.Pavlova committed
118 119 120 121
    {
        a1 = 0; b1 = 1; c1 = W - glW;
        a2 = 1; b2 = 0; c2 = shH;
    }
Anna.Pavlova's avatar
Anna.Pavlova committed
122 123 124 125 126
    else if(this.loc == 4)
    {
        a1 = 0; b1 = 1; c1 = shW;
        a2 = 1; b2 = 0; c2 = 0;
    }
Anna.Pavlova's avatar
Anna.Pavlova committed
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179

    if(this.turn == 1)
    {
        a1 *= -1; b1 *= -1; c1 += glW;
    }
    else if(this.turn == 2)
    {
        a2 *= -1; b2 *= -1; c2 += glH;
    }
    else if(this.turn == 3)
    {
        a1 *= -1; b1 *= -1; c1 += glW;
        a2 *= -1; b2 *= -1; c2 += glH;
    }


    // A*x + B*y + C = 0

    if(bHor)
    {
        a1 = 1; b1 = 0; c1 = shW;
        a2 = 0; b2 = 1; c2 = 0;
    }
    else
    {
        a1 = 0; b1 = 1; c1 = 0;
        a2 = 1; b2 = 0; c2 = shH;
    }

    if(this.turn == 1)
    {
        a1 *= -1; b1 *= -1; c1 = W;
    }
    else if(this.turn == 2)
    {
        a2 *= -1; b2 *= -1; c2 = H;
    }
    else if(this.turn == 3)
    {
        a1 *= -1; b1 *= -1; c1 = W;
        a2 *= -1; b2 *= -1; c2 = H;
    }

    // смещение

    var gpX = 0,
        gpY = 0;

    if(this.loc == 1)
        gpY = this.penW*25.4/96;
    if(this.loc == 3)
        gpX = - this.penW*25.4/96;

180 181
    var XX = [],
        YY = [];
Anna.Pavlova's avatar
Anna.Pavlova committed
182

Alexander.Trofimov's avatar
Alexander.Trofimov committed
183 184
    var x = this.pos.x,
		y = this.pos.y;
Anna.Pavlova's avatar
Anna.Pavlova committed
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204

    for(var i = 0; i < X.length; i++)
    {
        XX[i] = x + X[i]*a1 + Y[i]*b1 + c1 + gpX;
        YY[i] = y + X[i]*a2 + Y[i]*b2 + c2 + gpY;
    }

    var intGrid = MathControl.pGraph.GetIntegerGrid();
    MathControl.pGraph.SetIntegerGrid(false);

    MathControl.pGraph.p_width(this.penW*1000);
    MathControl.pGraph.b_color1(0,0,0, 255);
    MathControl.pGraph._s();

    this.drawPath(XX,YY);

    MathControl.pGraph.df();
    MathControl.pGraph.SetIntegerGrid(intGrid);

}
205
CGlyphOperator.prototype.getCoordinateGlyph = function()
Anna.Pavlova's avatar
Anna.Pavlova committed
206
{
207
    var coord = this.calcCoord(this.stretch);
Anna.Pavlova's avatar
Anna.Pavlova committed
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225

    var X = coord.XX, Y = coord.YY,
        W =  this.size.width, H =  this.size.height;

    var bHor = this.loc == 0 || this.loc  == 1;
    var glW = 0, glH = 0;

     if(bHor)
     {
         glW = coord.W;
         glH = coord.H;
     }
     else
     {
         glW = coord.H;
         glH = coord.W;
     }

226 227
     /*var shW = (W - glW)/ 2, // выравниваем глиф по длине
         shH = (H - glH)/2; // при повороте на 90 градусовы*/
Anna.Pavlova's avatar
Anna.Pavlova committed
228 229 230

    // A*x + B*y + C = 0

231 232 233 234
    var bLine = this.Parent.typeOper == DELIMITER_LINE || this.Parent.typeOper == DELIMITER_DOUBLE_LINE, // если оператор линия, то размещаем оператор по середине
        bArrow = this.Parent.typeOper == ARROW_LEFT || this.Parent.typeOper == ARROW_RIGHT || this.Parent.typeOper == ARROW_LR,
        bDoubleArrow = this.Parent.typeOper == DOUBLE_LEFT_ARROW || this.Parent.typeOper == DOUBLE_RIGHT_ARROW || this.Parent.typeOper == DOUBLE_ARROW_LR;

Anna.Pavlova's avatar
Anna.Pavlova committed
235
    var a1, a2, b1, b2, c1, c2;
236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298

    if(bLine)
    {
        if(this.loc == LOCATION_TOP)
        {
            a1 = 1; b1 = 0; c1 = 0;
            a2 = 0; b2 = 1; c2 = (H - glH)/2;
        }
        else if(this.loc == LOCATION_BOT)
        {
            a1 = 1; b1 = 0; c1 = 0;
            a2 = 0; b2 = 1; c2 = (H - glH)/2;

        }
        else if(this.loc == LOCATION_LEFT)
        {
            a1 = 0; b1 = 1; c1 = (W - glW)/2;
            a2 = 1; b2 = 0; c2 = 0;
        }
        else if(this.loc == LOCATION_RIGHT)
        {

            a1 = 0; b1 = 1; c1 = (W - glW)/2;
            a2 = 1; b2 = 0; c2 = 0;
        }
        else if(this.loc == LOCATION_SEP)
        {
            a1 = 0; b1 = 1; c1 = (W - glW)/2;
            a2 = 1; b2 = 0; c2 = 0;
        }
    }
    else
    {
        if(this.loc == LOCATION_TOP)
        {
            a1 = 1; b1 = 0; c1 = 0;
            a2 = 0; b2 = 1; c2 = 0;
        }
        else if(this.loc == LOCATION_BOT)
        {
            a1 = 1; b1 = 0; c1 = 0;
            a2 = 0; b2 = 1; c2 = H - glH;

        }
        else if(this.loc == LOCATION_LEFT)
        {
            a1 = 0; b1 = 1; c1 = 0;
            a2 = 1; b2 = 0; c2 = 0;
        }
        else if(this.loc == LOCATION_RIGHT)
        {

            a1 = 0; b1 = 1; c1 = W - glW;
            a2 = 1; b2 = 0; c2 = 0;
        }
        else if(this.loc == LOCATION_SEP)
        {
            a1 = 0; b1 = 1; c1 = 0;
            a2 = 1; b2 = 0; c2 = 0;
        }
    }

    /*if(this.loc == LOCATION_TOP)
Anna.Pavlova's avatar
Anna.Pavlova committed
299 300
    {
        a1 = 1; b1 = 0; c1 = 0;
Anna.Pavlova's avatar
Anna.Pavlova committed
301
        a2 = 0; b2 = 1; c2 = 0;
Anna.Pavlova's avatar
Anna.Pavlova committed
302
    }
Anna.Pavlova's avatar
Anna.Pavlova committed
303
    else if(this.loc == LOCATION_BOT)
Anna.Pavlova's avatar
Anna.Pavlova committed
304 305
    {
        a1 = 1; b1 = 0; c1 = 0;
306 307 308 309 310 311 312 313 314

        if(bLine)
        {
            a2 = 0; b2 = 1; c2 = (H - glH)/2;
        }
        else
        {
            a2 = 0; b2 = 1; c2 = H - glH;
        }
Anna.Pavlova's avatar
Anna.Pavlova committed
315
    }
Anna.Pavlova's avatar
Anna.Pavlova committed
316
    else if(this.loc == LOCATION_LEFT)
Anna.Pavlova's avatar
Anna.Pavlova committed
317 318 319 320
    {
        a1 = 0; b1 = 1; c1 = 0;
        a2 = 1; b2 = 0; c2 = 0;
    }
Anna.Pavlova's avatar
Anna.Pavlova committed
321
    else if(this.loc == LOCATION_RIGHT)
Anna.Pavlova's avatar
Anna.Pavlova committed
322
    {
323 324 325 326 327 328 329 330 331
        if(bLine)
        {
            a1 = 0; b1 = 1; c1 = (W - glW)/2;
        }
        else
        {
            a1 = 0; b1 = 1; c1 = W - glW;
        }

332
        a2 = 1; b2 = 0; c2 = 0;
Anna.Pavlova's avatar
Anna.Pavlova committed
333
    }
Anna.Pavlova's avatar
Anna.Pavlova committed
334
    else if(this.loc == LOCATION_SEP)
Anna.Pavlova's avatar
Anna.Pavlova committed
335
    {
336 337
        a1 = 0; b1 = 1; c1 = 0;
        a2 = 1; b2 = 0; c2 = 0;
338 339
    }*/

Anna.Pavlova's avatar
Anna.Pavlova committed
340 341


342 343
    /*var shW = 0,
        shH = 0;
Anna.Pavlova's avatar
Anna.Pavlova committed
344 345 346 347

    if(bHor)
    {
        a1 = 1; b1 = 0; c1 = 0;
348
        a2 = 0; b2 = 1; c2 = 0;
Anna.Pavlova's avatar
Anna.Pavlova committed
349 350 351
    }
    else
    {
352
        a1 = 0; b1 = 1; c1 = 0;
Anna.Pavlova's avatar
Anna.Pavlova committed
353
        a2 = 1; b2 = 0; c2 = 0;
354
    }*/
Anna.Pavlova's avatar
Anna.Pavlova committed
355 356 357

    if(this.turn == 1)
    {
358
        a1 *= -1; b1 *= -1; c1 += glW;
Anna.Pavlova's avatar
Anna.Pavlova committed
359 360 361
    }
    else if(this.turn == 2)
    {
362
        a2 *= -1; b2 *= -1; c2 += glH;
Anna.Pavlova's avatar
Anna.Pavlova committed
363 364 365
    }
    else if(this.turn == 3)
    {
366 367
        a1 *= -1; b1 *= -1; c1 += glW;
        a2 *= -1; b2 *= -1; c2 += glH;
Anna.Pavlova's avatar
Anna.Pavlova committed
368 369 370 371 372 373 374 375
    }

    var gpX = 0,
        gpY = 0;

    if(this.loc == 3)
        gpX = - this.penW*25.4/96;

376 377
    var XX = [],
        YY = [];
Anna.Pavlova's avatar
Anna.Pavlova committed
378 379 380 381 382 383 384 385 386

    for(var i = 0; i < X.length; i++)
    {
        XX[i] = X[i]*a1 + Y[i]*b1 + c1 + gpX;
        YY[i] = X[i]*a2 + Y[i]*b2 + c2 + gpY;
    }

    return {XX: XX, YY: YY, Width: glW, Height: glH};
}
387
CGlyphOperator.prototype.draw = function(pGraphics, XX, YY)
Anna.Pavlova's avatar
Anna.Pavlova committed
388
{
389 390
    var intGrid = pGraphics.GetIntegerGrid();
    pGraphics.SetIntegerGrid(false);
Anna.Pavlova's avatar
Anna.Pavlova committed
391

392 393 394
    pGraphics.p_width(this.penW*1000);
    pGraphics.b_color1(0,0,0, 255);
    pGraphics._s();
Anna.Pavlova's avatar
Anna.Pavlova committed
395

396
    this.drawPath(pGraphics, XX,YY);
Anna.Pavlova's avatar
Anna.Pavlova committed
397

398 399
    pGraphics.df();
    pGraphics.SetIntegerGrid(intGrid);
Anna.Pavlova's avatar
Anna.Pavlova committed
400
}
401
CGlyphOperator.prototype.getCtrPrp = function()
Anna.Pavlova's avatar
Anna.Pavlova committed
402
{
403
    return this.Parent.Get_CompiledCtrPrp();
Anna.Pavlova's avatar
Anna.Pavlova committed
404
}
405
CGlyphOperator.prototype.relate = function(parent)
406
{
407
    this.Parent = parent;
408
}
Anna.Pavlova's avatar
Anna.Pavlova committed
409 410 411 412
CGlyphOperator.prototype.IsArrow = function()
{
    return false;
}
Anna.Pavlova's avatar
Anna.Pavlova committed
413

Anna.Pavlova's avatar
Anna.Pavlova committed
414

415 416 417 418 419
function COperatorBracket()
{
    CGlyphOperator.call(this);
}
extend(COperatorBracket, CGlyphOperator);
420
COperatorBracket.prototype.calcSize = function( stretch )
421
{
422
    var betta = this.getCtrPrp().FontSize/36;
423 424 425 426

    // перевернутая скобка
    var minBoxH = 4.917529296874999 *betta, //width of 0x28
        widthBr = 12.347222222222221*betta;
Alexander.Trofimov's avatar
Alexander.Trofimov committed
427
	var maxBoxH;
428

429
    var rx = stretch / widthBr;
430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446
    if(rx < 1)
        rx = 1;

    if(rx < 2.1)
        maxBoxH = minBoxH * 1.37;
    else if(rx < 3.22)
        maxBoxH = minBoxH * 1.06;
    else
        maxBoxH =   8.74 *betta;

    var delta = maxBoxH - minBoxH;

    var heightBr = delta/4.3 * (rx - 1) + minBoxH;
    heightBr = heightBr >  maxBoxH ? maxBoxH : heightBr;

    return {width: widthBr, height: heightBr};
}
447
COperatorBracket.prototype.calcCoord = function(stretch)
448
{
449 450
    var X = [],
        Y = [];
451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509

    X[0] = 26467; Y[0] = 18871;
    X[1] = 25967; Y[1] = 18871;
    X[2] = 25384; Y[2] = 16830;
    X[3] = 24737; Y[3] = 15476;
    X[4] = 24091; Y[4] = 14122;
    X[5] = 23341; Y[5] = 13309;
    X[6] = 22591; Y[6] = 12497;
    X[7] = 21778; Y[7] = 12164;
    X[8] = 20965; Y[8] = 11831;
    X[9] = 20089; Y[9] = 11831;
    X[10] = 19214; Y[10] = 11831;
    X[11] = 18317; Y[11] = 12083;
    X[12] = 17421; Y[12] = 12336;
    X[13] = 16441; Y[13] = 12652;
    X[14] = 15462; Y[14] = 12969;
    X[15] = 14357; Y[15] = 13243;
    X[16] = 13253; Y[16] = 13518;
    X[17] = 11961; Y[17] = 13518;
    X[18] = 9835; Y[18] = 13518;
    X[19] = 8292; Y[19] = 12621;
    X[20] = 6750; Y[20] = 11724;
    X[21] = 5750; Y[21] = 10055;
    X[22] = 4750; Y[22] = 8386;
    X[23] = 4270; Y[23] = 5987;
    X[24] = 3791; Y[24] = 3589;
    X[25] = 3791; Y[25] = 626;
    X[26] = 3791; Y[26] = 0;
    X[27] = 0; Y[27] = 0;
    X[28] = 0; Y[28] = 1084;
    X[29] = 83; Y[29] = 5963;
    X[30] = 1021; Y[30] = 9612;
    X[31] = 1959; Y[31] = 13261;
    X[32] = 3543; Y[32] = 15700;
    X[33] = 5127; Y[33] = 18139;
    X[34] = 7232; Y[34] = 19369;
    X[35] = 9337; Y[35] = 20599;
    X[36] = 11796; Y[36] = 20599;
    X[37] = 13338; Y[37] = 20599;
    X[38] = 14588; Y[38] = 20283;
    X[39] = 15839; Y[39] = 19968;
    X[40] = 16860; Y[40] = 19610;
    X[41] = 17882; Y[41] = 19252;
    X[42] = 18736; Y[42] = 18936;
    X[43] = 19590; Y[43] = 18621;
    X[44] = 20340; Y[44] = 18621;
    X[45] = 21091; Y[45] = 18621;
    X[46] = 21820; Y[46] = 18995;
    X[47] = 22550; Y[47] = 19370;
    X[48] = 23133; Y[48] = 20266;
    X[49] = 23717; Y[49] = 21162;
    X[50] = 24092; Y[50] = 22703;
    X[51] = 24467; Y[51] = 24245;
    X[52] = 24551; Y[52] = 26578;
    X[53] = 28133; Y[53] = 26578;

    //TODO
    // X[1] > X[52]

510
    var textScale = this.getCtrPrp().FontSize/1000; // 1000 pt
511
    var alpha = textScale*25.4/96 /64; // коэффициент используется для того, чтобы перевести координаты в миллиметры
512

513
    var augm = stretch/((X[52] + (X[0] - X[1])/2 + X[1] - X[52])*alpha*2);
514 515 516 517

    if(augm < 1)
        augm = 1;

518 519
    var YY = [],
        XX = [];
520

521 522
    var hh1 = [],
        hh2 = [];
523

524 525
    var c1 = [],
        c2 = [];
526 527 528 529 530

    var delta = augm < 7 ? augm : 7;

    if(augm < 7)
    {
531
        var RX = [],
532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665
            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] = (Y[52]*RX[52] - (Y[52] - Y[1]) )/Y[1];
        RX[0] = RX[1]*Y[1]/Y[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] = X[30 + 2*i] - X[28 + 2*i];
            c2[i] = X[23 - 2*i] - X[25 - 2*i];
        }

        c1[5] = X[48] - X[44];
        c2[5] = X[5] - X[9];


        c1[6] = X[52] - X[48];
        c2[6] = X[1] - X[5];


        c1[7] = (X[0] - X[1])/2 + X[1] - X[52];
        c2[7] = (X[0] - X[1])/2;

        c1[4] = X[44] - X[36];
        c2[4] = X[9] - X[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*(X[52] + c1[7]),
            H2 =  H1 - (X[26] - X[27]) ;

        hh1[4] = (H1 - rest1)/c1[4];
        hh2[4] = (H2 - rest2)/c2[4];

        XX[27] = X[27];
        XX[26] = X[26];

        XX[28] = X[27];
        XX[25] = X[26];

        for(var i = 0; i < 4; i++)
        {
            for(var j = 1; j < 3; j ++)
            {
Alexander.Trofimov's avatar
Alexander.Trofimov committed
666
                var t = j + i*2;
667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810
                XX[28 + t] = XX[27 + t] + (X[28+t] - X[27+t])*hh1[i];
                XX[25 - t] = XX[26 - t] + (X[25-t] - X[26-t])*hh2[i];
            }
        }

        //переопределяем 36 и 17
        for(var i = 1; i < 9; i++)
        {
            XX[36 + i] = XX[35+i] + (X[36+i] - X[35+i])*hh1[4];
            XX[17 - i] = XX[18-i] + (X[17-i] - X[18-i])*hh2[4];
        }

        for(var i = 0; i < 4; i++)
        {
            XX[45+i] = XX[44+i] + ( X[45+i] - X[44+i])*hh1[5];
            XX[8-i]  = XX[9-i] + (X[8-i] -X[9-i])*hh2[5];
        }

        for(var i = 0; i < 4; i++)
        {
            XX[49+i] = XX[48+i] + (X[49+i] - X[48+i])*hh1[6];
            XX[4-i]  = XX[5-i]  + (X[4-i] - X[5-i] )*hh2[6];
        }

        XX[53] = XX[52] + 2*c1[7]*hh1[7];
        XX[0]  = XX[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] = X[30+i] - X[29+i];
            c2[i] = X[24-i] - X[25-i];
        }

        c1[9] = X[48] - X[44];
        c2[9] = X[5] - X[9];

        c1[10] = X[52] - X[48];
        c2[10] = X[1] - X[5];


        c1[11] = (X[0] - X[1])/2 + X[1] - X[52];
        c2[11] = (X[0] - X[1])/2;

        c1[8] = X[44] - X[36];
        c2[8] = X[9] - X[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*(X[52] + c1[11]),
            H2 =  H1 - (X[26] - X[27]) ;

        hh1[8] = (H1 - rest1)/c1[8];
        hh2[8] = (H2 - rest2)/c2[8];

        XX[27] = X[27];
        XX[26] = X[26];

        XX[28] = X[27];
        XX[25] = X[26];

        for(var i = 0; i < 9; i++)
        {
            XX[28 + i] = XX[27 + i] + (X[28+i] - X[27+i])*hh1[i];
            XX[25 - i] = XX[26 - i] + (X[25-i] - X[26-i])*hh2[i];
        }

        //переопределяем 36 и 17
        for(var i = 1; i < 9; i++)
        {
            XX[36 + i] = XX[35+i] + (X[36+i] - X[35+i])*hh1[8];
            XX[17 - i] = XX[18-i] + (X[17-i] - X[18-i])*hh2[8];
        }

        // TODO
        // переделать
        for(var i = 0; i < 4; i++)
        {
            XX[45+i] = XX[44+i] + ( X[45+i] - X[44+i])*hh1[9];
            XX[8-i]  = XX[9-i] + (X[8-i] -X[9-i])*hh2[9];
        }

        for(var i = 0; i < 4; i++)
        {
            XX[49+i] = XX[48+i] + (X[49+i] - X[48+i])*hh1[10];
            XX[4-i]  = XX[5-i]  + (X[4-i] - X[5-i] )*hh2[10];
        }

        XX[53] = XX[52] + 2*c1[11]*hh1[11];
        XX[0]  = XX[1]  + 2*c2[11]*hh2[11];

811
        var RX = [];
812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868

        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] = (Y[52]*RX[52] - (Y[52] - Y[1]) )/Y[1];
        RX[0] = RX[1]*Y[1]/Y[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 = Y[33]*RX[33],
            w2 = Y[9]*RX[9] + 0.15*(Y[9]*RX[9] - Y[19]*RX[19]);

        for(var i = 0; i < 11; i++)
        {
            RX[34+i] = w/Y[34+i];
            RX[19-i] = w2/Y[19-i];
        }

        var _H1 = augm*(X[52] + c1[11]),
            _H2 =  _H1 - (X[26] - X[27]);

        var w3 = _H1 - (XX[52] + c1[11]),
            w4 = _H2 - (XX[1] - XX[26] + c2[11]);

        for(var i = 0; i < 10; i++)
        {
            XX[53 - i] = XX[53 - i] + w3;
            XX[i] = XX[i] + w4;
        }

    }

    var H =  Y[53]*RX[53];
    for(var i = 0; i < 54; i++)
    {
        YY[i] =  (H - Y[i]*RX[i])*alpha;
        XX[i] =  XX[i]*alpha;
    }

    for(var i = 0; i < 50; i++)
        YY[54 + i] = YY[51 - i];

    for(var i = 0; i < 50; i++)
        XX[54 + i] =  XX[53] + XX[52] - XX[51-i];

    var W = XX[77], // ширина глифа
        H = YY[26]; // высота глифа

    return {XX: XX, YY: YY, W: W, H: H};
}
869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928
COperatorBracket.prototype.drawPath = function(pGraphics, XX, YY)
{
    pGraphics._m(XX[0], YY[0]);
    pGraphics._l(XX[1], YY[1]);
    pGraphics._c(XX[1], YY[1], XX[2], YY[2], XX[3], YY[3] );
    pGraphics._c(XX[3], YY[3], XX[4], YY[4], XX[5], YY[5] );
    pGraphics._c(XX[5], YY[5], XX[6], YY[6], XX[7], YY[7] );
    pGraphics._c(XX[7], YY[7], XX[8], YY[8], XX[9], YY[9] );
    pGraphics._c(XX[9], YY[9], XX[10], YY[10], XX[11], YY[11] );
    pGraphics._c(XX[11], YY[11], XX[12], YY[12], XX[13], YY[13] );
    pGraphics._c(XX[13], YY[13], XX[14], YY[14], XX[15], YY[15] );
    pGraphics._c(XX[15], YY[15], XX[16], YY[16], XX[17], YY[17] );
    pGraphics._c(XX[17], YY[17], XX[18], YY[18], XX[19], YY[19] );
    pGraphics._c(XX[19], YY[19], XX[20], YY[20], XX[21], YY[21] );
    pGraphics._c(XX[21], YY[21], XX[22], YY[22], XX[23], YY[23] );
    pGraphics._c(XX[23], YY[23], XX[24], YY[24], XX[25], YY[25] );
    pGraphics._l(XX[26], YY[26]);
    pGraphics._l(XX[27], YY[27]);
    pGraphics._l(XX[28], YY[28]);
    pGraphics._c(XX[28], YY[28], XX[29], YY[29], XX[30], YY[30] );
    pGraphics._c(XX[30], YY[30], XX[31], YY[31], XX[32], YY[32] );
    pGraphics._c(XX[32], YY[32], XX[33], YY[33], XX[34], YY[34] );
    pGraphics._c(XX[34], YY[34], XX[35], YY[35], XX[36], YY[36] );
    pGraphics._c(XX[36], YY[36], XX[37], YY[37], XX[38], YY[38] );
    pGraphics._c(XX[38], YY[38], XX[39], YY[39], XX[40], YY[40] );
    pGraphics._c(XX[40], YY[40], XX[41], YY[41], XX[42], YY[42] );
    pGraphics._c(XX[42], YY[42], XX[43], YY[43], XX[44], YY[44] );
    pGraphics._c(XX[44], YY[44], XX[45], YY[45], XX[46], YY[46] );
    pGraphics._c(XX[46], YY[46], XX[47], YY[47], XX[48], YY[48] );
    pGraphics._c(XX[48], YY[48], XX[49], YY[49], XX[50], YY[50] );
    pGraphics._c(XX[50], YY[50], XX[51], YY[51], XX[52], YY[52] );
    pGraphics._l(XX[53], YY[53]);

    pGraphics._c(XX[53], YY[53], XX[54], YY[54], XX[55], YY[55] );
    pGraphics._c(XX[55], YY[55], XX[56], YY[56], XX[57], YY[57] );
    pGraphics._c(XX[57], YY[57], XX[58], YY[58], XX[59], YY[59] );
    pGraphics._c(XX[59], YY[59], XX[60], YY[60], XX[61], YY[61] );
    pGraphics._c(XX[61], YY[61], XX[62], YY[62], XX[63], YY[63] );
    pGraphics._c(XX[63], YY[63], XX[64], YY[64], XX[65], YY[65] );
    pGraphics._c(XX[65], YY[65], XX[66], YY[66], XX[67], YY[67] );
    pGraphics._c(XX[67], YY[67], XX[68], YY[68], XX[69], YY[69] );
    pGraphics._c(XX[69], YY[69], XX[70], YY[70], XX[71], YY[71] );
    pGraphics._c(XX[71], YY[71], XX[72], YY[72], XX[73], YY[73] );
    pGraphics._c(XX[73], YY[73], XX[74], YY[74], XX[75], YY[75] );
    pGraphics._c(XX[75], YY[75], XX[76], YY[76], XX[77], YY[77] );
    pGraphics._l(XX[78], YY[78]);
    pGraphics._l(XX[79], YY[79]);
    pGraphics._l(XX[80], YY[80]);
    pGraphics._c(XX[80], YY[80], XX[81], YY[81], XX[82], YY[82] );
    pGraphics._c(XX[82], YY[82], XX[83], YY[83], XX[84], YY[84] );
    pGraphics._c(XX[84], YY[84], XX[85], YY[85], XX[86], YY[86] );
    pGraphics._c(XX[86], YY[86], XX[87], YY[87], XX[88], YY[88] );
    pGraphics._c(XX[88], YY[88], XX[89], YY[89], XX[90], YY[90] );
    pGraphics._c(XX[90], YY[90], XX[91], YY[91], XX[92], YY[92] );
    pGraphics._c(XX[92], YY[92], XX[93], YY[93], XX[94], YY[94] );
    pGraphics._c(XX[94], YY[94], XX[95], YY[95], XX[96], YY[96] );
    pGraphics._c(XX[96], YY[96], XX[97], YY[97], XX[98], YY[98] );
    pGraphics._c(XX[98], YY[98], XX[99], YY[99], XX[100], YY[100] );
    pGraphics._c(XX[100], YY[100], XX[101], YY[101], XX[102], YY[102]);
    pGraphics._c(XX[102], YY[102], XX[103], YY[103], XX[0], YY[0]);
929 930 931 932 933 934 935 936 937
}

// TODO: сделать так, чтобы размер скобки совпадал в начальном случае (плейсхолдер), сейчас по размеру аргумента

function COperatorParenthesis()
{
    CGlyphOperator.call(this);
}
extend(COperatorParenthesis, CGlyphOperator);
938
COperatorParenthesis.prototype.calcSize = function(stretch)
939
{
940
    var betta = this.getCtrPrp().FontSize/36;
941

942 943 944 945
    var maxBoxH =   9.63041992187 *betta, //9.63 width of 0x239D
        minBoxH =   5.27099609375 *betta, //width of 0x28
        widthBr = 11.99444444444 *betta;

946
    var ry = stretch / widthBr,
947 948 949 950 951 952 953
        delta = maxBoxH - minBoxH;

    var heightBr = delta/4.3 * (ry - 1) + minBoxH;
    heightBr = heightBr >  maxBoxH ? maxBoxH : heightBr;

    return {height: heightBr, width : widthBr};
}
954
COperatorParenthesis.prototype.calcCoord = function(stretch)
955 956 957
{
    //cкобка перевернутая на 90 градусов

958 959
    var X = [],
        Y = [];
960 961 962 963 964 965 966 967 968 969 970 971

    X[0] = 39887; Y[0] = 18995;
    X[1] = 25314; Y[1] = 18995;
    X[2] = 15863; Y[2] = 14309;
    X[3] = 6412; Y[3] = 9623;
    X[4] = 3206; Y[4] = 0;
    X[5] = 0; Y[5] = 1000;
    X[6] = 3206; Y[6] = 13217;
    X[7] = 13802; Y[7] = 19722;
    X[8] = 24398; Y[8] = 26227;
    X[9] = 39470; Y[9] = 26227;

972
    var textScale = this.getCtrPrp().FontSize/1000; // 1000 pt
973 974
    var alpha = textScale*25.4/96 /64; // коэффициент используется для того, чтобы перевести координаты в миллиметры

975
    var aug = stretch/(X[9]*alpha)/2; //Y[9]*alpha - высота скобки
976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993
    var RX, RY;

    if(aug > 6.53)
    {
        RX = 6.53;
        RY = 2.05;
    }
    else if(aug < 1)
    {
        RX = 1;
        RY = 1;
    }
    else
    {
        RX = aug;
        RY = 1 + (aug - 1)*0.19;
    }

994
    var DistH = [];
995 996 997 998 999 1000 1001 1002 1003 1004
    for(var i= 0; i< 5; i++)
        DistH[i] = Y[9-i] - Y[i];

    for(var i = 5; i < 10; i++)
    {
        Y[i] = Y[i]*RY;               //точки правой дуги
        Y[9-i] = Y[i] - DistH[9-i];   //точки левой дуги
    }

    // X
1005
    var DistW = [];
1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017
    for(var j= 0; j< 5; j++)
        DistW[j] = X[18-j] - X[9+j];

    for(var i=0; i< 5; i++)
        DistW[i] = X[9-j] - X[j];

    for(var i=5; i<10; i++ )
    {
        X[i] = X[i]*RX;
        X[9-i] = X[i] + DistW[9-i];
    }

1018 1019
    var XX = [],
        YY = [];
1020 1021 1022 1023 1024 1025 1026 1027 1028 1029

    var shiftY =  1.1*Y[9]*alpha;

    // YY[0]  - YY[9]  - нижняя часть скобки
    // YY[9]  - YY[10] - отрезок прямой
    // YY[11] - YY[19] - верхняя часть скобки
    // YY[19] - YY[20] - отрезок прямой

    for(var i = 0; i < 10; i++)
    {
1030 1031
        YY[19 - i] = shiftY - Y[i]*alpha;
        YY[i] =  shiftY - Y[i]*alpha;
1032
        XX[19 - i] =  X[i]*alpha;
1033
        XX[i] = stretch - X[i]*alpha;
1034 1035
    }

1036 1037 1038 1039 1040
    YY[20] = YY[0];
    XX[20] = XX[0];

    var W = XX[5],
        H = YY[4];
1041

1042
    return {XX: XX, YY: YY, W: W, H: H };
1043
}
1044
COperatorParenthesis.prototype.drawPath = function(pGraphics, XX, YY)
1045
{
1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058
    pGraphics._m(XX[0], YY[0]); //mm
    pGraphics._c(XX[0], YY[0], XX[1], YY[1], XX[2], YY[2]);
    pGraphics._c(XX[2], YY[2], XX[3], YY[3], XX[4], YY[4]);
    pGraphics._l(XX[5], YY[5]);
    pGraphics._c(XX[5], YY[5], XX[6], YY[6], XX[7], YY[7]);
    pGraphics._c(XX[7], YY[7], XX[8], YY[8], XX[9], YY[9]);
    pGraphics._l(XX[10], YY[10]);
    pGraphics._c(XX[10], YY[10], XX[11], YY[11], XX[12], YY[12]);
    pGraphics._c(XX[12], YY[12], XX[13], YY[13], XX[14], YY[14]);
    pGraphics._l(XX[15], YY[15]);
    pGraphics._c(XX[15], YY[15], XX[16], YY[16], XX[17], YY[17]);
    pGraphics._c(XX[17], YY[17], XX[18], YY[18], XX[19], YY[19]);
    pGraphics._l(XX[20], YY[20]);
1059 1060
}

1061 1062
// TODO
// установить минимальный размер стрелок
1063 1064 1065 1066 1067 1068

function COperatorAngleBracket()
{
    CGlyphOperator.call(this);
}
extend(COperatorAngleBracket, CGlyphOperator);
1069
COperatorAngleBracket.prototype.calcSize = function(stretch)
1070 1071 1072
{
    //скобка перевернутая

1073
    var betta = this.getCtrPrp().FontSize/36;
1074
    var widthBr = 11.994444444444444*betta;
1075
    var heightBr;
1076

1077
    if( stretch/widthBr > 3.768 )
1078 1079 1080 1081 1082 1083
        heightBr = 5.3578125*betta;
    else
        heightBr = 4.828645833333333*betta;

    return {width : widthBr, height: heightBr};
}
1084
COperatorAngleBracket.prototype.calcCoord = function(stretch)
1085
{
1086 1087
    var X = [],
        Y = [];
1088 1089 1090 1091 1092 1093 1094 1095 1096 1097

    X[0] = 38990; Y[0] = 7665;
    X[1] = 1583; Y[1] = 21036;
    X[2] = 0; Y[2] = 16621;
    X[3] = 37449; Y[3] = 0;
    X[4] = 40531; Y[4] = 0;
    X[5] = 77938; Y[5] = 16621;
    X[6] = 76439; Y[6] = 21036;
    X[7] = 38990; Y[7] = 7665;

1098
    var textScale = this.getCtrPrp().FontSize/1000; // 1000 pt
1099 1100
    var alpha = textScale*25.4/96 /64; // коэффициент используется для того, чтобы перевести координаты в миллиметры

1101
    var augm = stretch/(X[5]*alpha);
1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131

    if(augm < 1)
        augm = 1;
    else if(augm > 4.7)
        augm = 4.7;

    var c1 = 1, c2 = 1;

    var ww1 = Y[0] - Y[3],
        ww2 = Y[1] - Y[2],
        ww3 = Y[1] - Y[0],
        ww4 = Y[2] - Y[3];

    if(augm > 3.768)
    {
        var WW = (Y[1] - Y[3])*1.3;
        c1 = (WW - ww1)/ww3;
        c2 = (WW - ww2)/ww4
    }

    Y[1] = Y[6] = Y[0] + ww3*c1;
    Y[2] = Y[5] = Y[3] + ww4*c2;


    var k1 = 0.01*augm;

    var hh1 = (X[0] - X[3])*k1,
        hh2 = X[1] - X[2],
        hh3 = X[3] - X[2],
        hh4 = X[0] - X[1],
1132 1133
        //HH = augm*(X[0] - X[2]);
        HH = augm*X[5]/2;
1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148

    var k2 = (HH -  hh1)/hh3,
        k3 = (HH - hh2)/hh4;

    X[7] = X[0] = X[1] + k3*hh4;
    X[3] = X[2] + k2*hh3;

    for(var i = 0; i < 3; i++)
    {
        X[4 + i] = 2*HH - X[3 - i];
    }

    /*var hh1 = 0.1*augm,
     hh2 = (augm*X[0] - X[])*/

1149 1150
    var XX = [],
        YY = [];
1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162

    for(var i = 0; i < X.length; i++)
    {
        XX[i] = X[i]*alpha;
        YY[i] = Y[i]*alpha;
    }

    var W = XX[5],
        H = YY[1];

    return {XX: XX, YY: YY, W: W, H: H};
}
1163
COperatorAngleBracket.prototype.drawPath = function(pGraphics, XX, YY)
1164
{
1165 1166 1167 1168 1169 1170 1171 1172
    pGraphics._m(XX[0], YY[0]);
    pGraphics._l(XX[1], YY[1]);
    pGraphics._l(XX[2], YY[2]);
    pGraphics._l(XX[3], YY[3]);
    pGraphics._l(XX[4], YY[4]);
    pGraphics._l(XX[5], YY[5]);
    pGraphics._l(XX[6], YY[6]);
    pGraphics._l(XX[7], YY[7]);
1173 1174 1175 1176 1177 1178 1179
}

function CSquareBracket()
{
    CGlyphOperator.call(this);
}
extend(CSquareBracket, CGlyphOperator);
1180
CSquareBracket.prototype.calcCoord = function(stretch)
1181
{
1182 1183
    var X = [],
        Y = [];
1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194

    X[0] = 3200;  Y[0] = 6912;
    X[1] = 3200;  Y[1] = 18592;
    X[2] = 0;     Y[2] = 18592;
    X[3] = 0;     Y[3] = 0;
    X[4] = 79424; Y[4] = 0;
    X[5] = 79424; Y[5] = 18592;
    X[6] = 76224; Y[6] = 18592;
    X[7] = 76224; Y[7] = 6912;
    X[8] = 3200;  Y[8] = 6912;

1195
    var textScale = this.getCtrPrp().FontSize/1000; // 1000 pt
1196 1197
    var alpha = textScale*25.4/96 /64; // коэффициент используется для того, чтобы перевести координаты в миллиметры

1198
    var lng = stretch/alpha - X[4] - 2*X[0];
1199 1200 1201 1202 1203 1204 1205 1206

    if(lng < 0)
        lng = 0;

    for(var i = 0; i < 4; i++)
        X[4+i] += lng;


1207 1208
    var XX = [],
        YY = [];
1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222

    var shY =  Y[0]*alpha;

    for(var i = 0; i < X.length; i++)
    {
        XX[i] = X[i]*alpha;
        YY[i] = Y[i]*alpha + shY;
    }

    var W = XX[4],
        H = YY[1];

    return {XX: XX, YY: YY, W: W, H: H};
}
1223
CSquareBracket.prototype.drawPath = function(pGraphics, XX, YY)
1224
{
1225 1226 1227 1228 1229 1230 1231 1232 1233
    pGraphics._m(XX[0], YY[0]);
    pGraphics._l(XX[1], YY[1]);
    pGraphics._l(XX[2], YY[2]);
    pGraphics._l(XX[3], YY[3]);
    pGraphics._l(XX[4], YY[4]);
    pGraphics._l(XX[5], YY[5]);
    pGraphics._l(XX[6], YY[6]);
    pGraphics._l(XX[7], YY[7]);
    pGraphics._l(XX[8], YY[8]);
1234 1235 1236
}
CSquareBracket.prototype.calcSize = function()
{
1237
    var betta = this.getCtrPrp().FontSize/36;
1238

1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250
    var height = 4.446240234375*betta;
    //var width = 12.0*this.betta;
    var width = 12.347222222222221*betta;

    return {width: width, height: height};
}

function CHalfSquareBracket()
{
    CGlyphOperator.call(this);
}
extend(CHalfSquareBracket, CGlyphOperator);
1251
CHalfSquareBracket.prototype.calcCoord = function(stretch)
1252
{
1253 1254
    var X = [],
        Y = [];
1255 1256 1257 1258 1259 1260 1261 1262 1263

    X[0] = 0; Y[0] = 0;
    X[1] = 0; Y[1] = 7000;
    X[2] = 74106; Y[2] = 7000;
    X[3] = 74106; Y[3] = 18578;
    X[4] = 77522; Y[4] = 18578;
    X[5] = 77522; Y[5] = 0;
    X[6] = 0; Y[6] = 0;

1264
    var textScale = this.getCtrPrp().FontSize/1000; // 1000 pt
1265 1266 1267 1268
    var alpha = textScale*25.4/96 /64; // коэффициент используется для того, чтобы перевести координаты в миллиметры

    var w1 = X[4],
        w2 = X[4] - X[3];
1269
    var lng = stretch/alpha - w1 - w2;
1270 1271 1272 1273 1274 1275 1276

    if(lng < 0)
        lng = 0;

    for(var i = 0; i < 4; i++)
        X[2+i] += lng;

1277 1278
    var XX = [],
        YY = [];
1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294

    var shY = Y[1]*alpha;

    for(var i = 0; i < X.length; i++)
    {
        XX[i] = X[i]*alpha;
        YY[i] = Y[i]*alpha + shY;
    }

    var W = XX[4],
        H = YY[4];

    return {XX: XX, YY: YY, W: W, H: H};
}
CHalfSquareBracket.prototype.calcSize = function()
{
1295
    var betta = this.getCtrPrp().FontSize/36;
1296 1297 1298 1299 1300 1301

    var height = 4.446240234375*betta;
    var width = 11.99444444444*betta;

    return {width: width, height: height};
}
1302
CHalfSquareBracket.prototype.drawPath = function(pGraphics, XX, YY)
1303
{
1304 1305 1306 1307 1308 1309 1310
    pGraphics._m(XX[0], YY[0]);
    pGraphics._l(XX[1], YY[1]);
    pGraphics._l(XX[2], YY[2]);
    pGraphics._l(XX[3], YY[3]);
    pGraphics._l(XX[4], YY[4]);
    pGraphics._l(XX[5], YY[5]);
    pGraphics._l(XX[6], YY[6]);
1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324
}


function COperatorLine()
{
    CGlyphOperator.call(this);
}
extend(COperatorLine, CGlyphOperator);
COperatorLine.prototype.setContent = function()
{
    COperatorLine.superclass.setContent.call(this, this.calcSize, this.calcCoord, this.drawPath);
}
COperatorLine.prototype.calcSize = function()
{
1325
    var betta = this.getCtrPrp().FontSize/36;
1326 1327 1328 1329 1330 1331

    var height = 4.018359374999999*betta;
    var width = 11.99444444444*betta;

    return {width: width, height: height};
}
1332
COperatorLine.prototype.calcCoord = function(stretch)
1333
{
1334 1335
    var X = [],
        Y = [];
1336 1337 1338 1339 1340 1341 1342

    X[0] = 0;     Y[0] = 0;
    X[1] = 0;     Y[1] = 5520;
    X[2] = 77504; Y[2] = 5520;
    X[3] = 77504; Y[3] = 0;
    X[4] = 0;     Y[4] = 0;

1343
    var textScale = this.getCtrPrp().FontSize/1000; // 1000 pt
1344 1345
    var alpha = textScale*25.4/96 /64; // коэффициент используется для того, чтобы перевести координаты в миллиметры

1346 1347
    var XX = [],
        YY = [];
1348

1349 1350
    //var shY = 2*Y[1]*alpha;
    var shY = 0;
1351 1352 1353 1354 1355 1356 1357

    for(var i = 0; i < X.length; i++)
    {
        XX[i] = X[i]*alpha;
        YY[i] = Y[i]*alpha + shY;
    }

1358
    var lng = stretch - X[2]*alpha;
1359 1360 1361 1362 1363 1364 1365 1366 1367

    if(lng < 0)
        lng = 0;

    XX[2] += lng;
    XX[3] += lng;


    var W = XX[2],
Anna.Pavlova's avatar
Anna.Pavlova committed
1368
        H = YY[2] + shY;
1369 1370 1371 1372

    return {XX: XX, YY: YY, W: W, H: H};

}
1373
COperatorLine.prototype.drawPath = function(pGraphics, XX, YY)
1374
{
1375 1376 1377 1378 1379
    pGraphics._m(XX[0], YY[0]);
    pGraphics._l(XX[1], YY[1]);
    pGraphics._l(XX[2], YY[2]);
    pGraphics._l(XX[3], YY[3]);
    pGraphics._l(XX[4], YY[4]);
1380 1381 1382 1383 1384 1385 1386 1387 1388
}

function CWhiteSquareBracket()
{
    CGlyphOperator.call(this);
}
extend(CWhiteSquareBracket, CGlyphOperator);
CWhiteSquareBracket.prototype.calcSize = function()
{
1389
    var betta = this.getCtrPrp().FontSize/36;
1390 1391 1392 1393 1394 1395

    var height = 5.5872558593749995*betta;
    var width = 11.99444444444*betta;

    return {width: width, height: height};
}
1396
CWhiteSquareBracket.prototype.calcCoord = function(stretch)
1397
{
1398 1399
    var X = [],
        Y = [];
1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431

    /*X[0] = 77529; Y[0] = 26219;
     X[1] = 77529; Y[1] = 0;
     X[2] = 0; Y[2] = 0;
     X[3] = 0; Y[3] = 26219;
     X[4] = 4249; Y[4] = 26219;
     X[5] = 4249; Y[5] = 17055;
     X[6] = 73280; Y[6] = 17055;
     X[7] = 73280; Y[7] = 26219;
     X[8] = 77529; Y[8] = 26219;
     X[9] = 73280; Y[9] = 12431;
     X[10] = 4249; Y[10] = 12431;
     X[11] = 4249; Y[11] = 4623;
     X[12] = 73280; Y[12] = 4623;
     X[13] = 73280; Y[13] = 12431;*/

    X[0] = 3225;  Y[0] = 17055;
    X[1] = 3225;  Y[1] = 26219;
    X[2] = 0;     Y[2] = 26219;
    X[3] = 0;     Y[3] = 0;
    X[4] = 77529; Y[4] = 0;
    X[5] = 77529; Y[5] = 26219;
    X[6] = 74304; Y[6] = 26219;
    X[7] = 74304; Y[7] = 17055;
    X[8] = 3225;  Y[8] = 17055;

    X[9] = 74304; Y[9] = 12700;
    X[10] = 3225; Y[10] = 12700;
    X[11] = 3225; Y[11] = 4600;
    X[12] = 74304; Y[12] = 4600;
    X[13] = 74304; Y[13] = 12700;

1432
    var textScale = this.getCtrPrp().FontSize/1000; // 1000 pt
1433 1434
    var alpha = textScale*25.4/96 /64; // коэффициент используется для того, чтобы перевести координаты в миллиметры

1435 1436
    var XX = [],
        YY = [];
1437 1438 1439 1440 1441 1442 1443 1444 1445

    var shY = (Y[1] - Y[0])*alpha;

    for(var i = 0; i < X.length; i++)
    {
        XX[i] = X[i]*alpha;
        YY[i] = Y[i]*alpha + shY;
    }

1446
    var lngY = stretch - X[4]*alpha;
1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458

    for(var i = 0; i < 4; i++)
        XX[4+i] += lngY;

    XX[12] += lngY;
    XX[13] += lngY;

    var W = XX[4],
        H = YY[3];

    return {XX: XX, YY: YY, W: W, H: H};
}
1459
CWhiteSquareBracket.prototype.drawPath = function(pGraphics, XX, YY)
1460
{
1461 1462 1463 1464 1465 1466 1467 1468 1469 1470
    pGraphics._m(XX[0], YY[0]);
    pGraphics._l(XX[1], YY[1]);
    pGraphics._l(XX[2], YY[2]);
    pGraphics._l(XX[3], YY[3]);
    pGraphics._l(XX[4], YY[4]);
    pGraphics._l(XX[5], YY[5]);
    pGraphics._l(XX[6], YY[6]);
    pGraphics._l(XX[7], YY[7]);
    pGraphics._l(XX[8], YY[8]);
    pGraphics.df();
1471

1472 1473 1474 1475 1476 1477 1478
    pGraphics.b_color1(255,255,255, 255);
    pGraphics._s();
    pGraphics._m(XX[9], YY[9]);
    pGraphics._l(XX[10], YY[10]);
    pGraphics._l(XX[11], YY[11]);
    pGraphics._l(XX[12], YY[12]);
    pGraphics._l(XX[13], YY[13]);
1479 1480 1481 1482 1483 1484 1485 1486 1487
}

function COperatorDoubleLine()
{
    CGlyphOperator.call(this);
}
extend(COperatorDoubleLine, CGlyphOperator);
COperatorDoubleLine.prototype.calcSize = function()
{
1488
    var betta = this.getCtrPrp().FontSize/36;
1489 1490 1491 1492 1493 1494

    var height = 6.715869140624999*betta,
        width = 11.99444444444*betta;

    return {width: width, height: height};
}
1495
COperatorDoubleLine.prototype.calcCoord = function(stretch)
1496
{
1497 1498
    var X = [],
        Y = [];
1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513

    //X[0] = 77504; Y[0] = 6400;

    X[0] = 0;     Y[0] = 0;
    X[1] = 0;     Y[1] = 5900;
    X[2] = 77504; Y[2] = 5900;
    X[3] = 77504; Y[3] = 0;
    X[4] = 0;     Y[4] = 0;

    X[5] = 0;     Y[5] = 18112;
    X[6] = 0;     Y[6] = 24012;
    X[7] = 77504; Y[7] = 24012;
    X[8] = 77504; Y[8] = 18112;
    X[9] = 0;     Y[9] = 18112;

1514
    var textScale = this.getCtrPrp().FontSize/1000; // 1000 pt
1515 1516
    var alpha = textScale*25.4/96 /64; // коэффициент используется для того, чтобы перевести координаты в миллиметры

1517 1518
    var XX = [],
        YY = [];
1519

1520 1521
    //var shY = 1.5*Y[1]*alpha;
    var shY = 0;
1522 1523 1524 1525 1526 1527 1528 1529 1530

    for(var i = 0; i < X.length; i++)
    {
        XX[i] = X[i]*alpha;
        YY[i] = Y[i]*alpha + shY;
    }

    for(var i = 0; i < 2; i++)
    {
1531 1532
        XX[2+i] = stretch;
        XX[7+i] = stretch;
1533 1534 1535 1536 1537 1538 1539
    }

    var W = XX[7],
        H = YY[7];

    return {XX: XX, YY: YY, W: W, H: H};
}
1540
COperatorDoubleLine.prototype.drawPath = function(pGraphics, XX, YY)
1541
{
1542 1543 1544 1545 1546 1547
    pGraphics._m(XX[0], YY[0]);
    pGraphics._l(XX[1], YY[1]);
    pGraphics._l(XX[2], YY[2]);
    pGraphics._l(XX[3], YY[3]);
    pGraphics._l(XX[4], YY[4]);
    pGraphics.df();
1548

1549 1550 1551 1552 1553 1554
    pGraphics._s();
    pGraphics._m(XX[5], YY[5]);
    pGraphics._l(XX[6], YY[6]);
    pGraphics._l(XX[7], YY[7]);
    pGraphics._l(XX[8], YY[8]);
    pGraphics._l(XX[9], YY[9]);
1555 1556 1557 1558 1559 1560 1561 1562 1563 1564
}


function CSingleArrow()
{
    CGlyphOperator.call(this);
}
extend(CSingleArrow, CGlyphOperator);
CSingleArrow.prototype.calcSize = function()
{
1565
    var betta = this.getCtrPrp().FontSize/36;
1566 1567 1568 1569 1570
    var height = 5.946923828125*betta;
    var width = 10.641210937499999*betta;

    return {width: width, height: height};
}
1571
CSingleArrow.prototype.calcCoord = function(stretch)
1572
{
1573 1574
    var X = [],
        Y = [];
1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587

    X[0] = 56138; Y[0] = 12300;
    X[1] = 8363; Y[1] = 12300;
    X[2] = 16313; Y[2] = 2212;
    X[3] = 13950; Y[3] = 0;
    X[4] = 0; Y[4] = 13650;
    X[5] = 0; Y[5] = 16238;
    X[6] = 13950; Y[6] = 29925;
    X[7] = 16313; Y[7] = 27712;
    X[8] = 8363; Y[8] = 17625;
    X[9] = 56138; Y[9] = 17625;
    X[10] = 56138; Y[10] = 12300;

1588
    var textScale = this.getCtrPrp().FontSize/1000; // 1000 pt
1589 1590
    var alpha = textScale*25.4/96 /64; // коэффициент используется для того, чтобы перевести координаты в миллиметры

1591 1592
    var XX = [],
        YY = [];
1593 1594 1595 1596 1597 1598 1599

    for(var i = 0; i < X.length; i++)
    {
        XX[i] = X[i]*alpha;
        YY[i] = Y[i]*alpha;
    }

1600 1601
    //var lng = stretch - 10000*alpha;
    var lng = stretch;
1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614

    if(lng > XX[9])
    {
        XX[0]  = lng;
        XX[9]  = lng;
        XX[10] = lng;
    }

    var W = XX[9],
        H = YY[6];

    return {XX: XX, YY: YY, W: W, H: H};
}
1615
CSingleArrow.prototype.drawPath = function(pGraphics, XX, YY)
1616
{
1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627
    pGraphics._m(XX[0], YY[0]);
    pGraphics._l(XX[1], YY[1]);
    pGraphics._l(XX[2], YY[2]);
    pGraphics._l(XX[3], YY[3]);
    pGraphics._l(XX[4], YY[4]);
    pGraphics._l(XX[5], YY[5]);
    pGraphics._l(XX[6], YY[6]);
    pGraphics._l(XX[7], YY[7]);
    pGraphics._l(XX[8], YY[8]);
    pGraphics._l(XX[9], YY[9]);
    pGraphics._l(XX[10], YY[10]);
1628
}
Anna.Pavlova's avatar
Anna.Pavlova committed
1629 1630 1631 1632
CSingleArrow.prototype.IsArrow = function()
{
    return true;
}
1633 1634 1635 1636 1637 1638 1639 1640

function CLeftRightArrow()
{
    CGlyphOperator.call(this);
}
extend(CLeftRightArrow, CGlyphOperator);
CLeftRightArrow.prototype.calcSize = function()
{
1641
    var betta = this.getCtrPrp().FontSize/36;
1642 1643 1644 1645 1646 1647

    var height = 5.946923828125*betta;
    var width = 11.695410156249999*betta;

    return {width: width, height: height};
}
1648
CLeftRightArrow.prototype.calcCoord = function(stretch)
1649
{
1650 1651
    var X = [],
        Y = [];
1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670

    X[0] = 16950; Y[0] = 28912;
    X[1] = 14738; Y[1] = 30975;
    X[2] = 0; Y[2] = 16687;
    X[3] = 0; Y[3] = 14287;
    X[4] = 14738; Y[4] = 0;
    X[5] = 16950; Y[5] = 2062;
    X[6] = 8363; Y[6] = 12975;
    X[7] = 53738; Y[7] = 12975;
    X[8] = 45150; Y[8] = 2062;
    X[9] = 47363; Y[9] = 0;
    X[10] = 62100; Y[10] = 14287;
    X[11] = 62100; Y[11] = 16687;
    X[12] = 47363; Y[12] = 30975;
    X[13] = 45150; Y[13] = 28912;
    X[14] = 53738; Y[14] = 17962;
    X[15] = 8363; Y[15] = 17962;
    X[16] = 16950; Y[16] = 28912;

1671
    var textScale = this.getCtrPrp().FontSize/1000; // 1000 pt
1672 1673
    var alpha = textScale*25.4/96 /64; // коэффициент используется для того, чтобы перевести координаты в миллиметры

1674 1675
    var XX = [],
        YY = [];
1676 1677 1678 1679 1680 1681 1682 1683 1684

    for(var i = 0; i < X.length; i++)
    {
        XX[i] = X[i]*alpha;
        YY[i] = Y[i]*alpha;
    }

    var w = X[10]*alpha;

1685
    var lng = stretch - w;
1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696

    if(lng > 0)
        for(var i = 0; i < 8; i++)
            XX[7+i] += lng;


    var W = XX[10],
        H = YY[1];

    return {XX: XX, YY: YY, W: W, H: H};
}
1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715
CLeftRightArrow.prototype.drawPath = function(pGraphics, XX, YY)
{
    pGraphics._m(XX[0], YY[0]);
    pGraphics._l(XX[1], YY[1]);
    pGraphics._l(XX[2], YY[2]);
    pGraphics._l(XX[3], YY[3]);
    pGraphics._l(XX[4], YY[4]);
    pGraphics._l(XX[5], YY[5]);
    pGraphics._l(XX[6], YY[6]);
    pGraphics._l(XX[7], YY[7]);
    pGraphics._l(XX[8], YY[8]);
    pGraphics._l(XX[9], YY[9]);
    pGraphics._l(XX[10], YY[10]);
    pGraphics._l(XX[11], YY[11]);
    pGraphics._l(XX[12], YY[12]);
    pGraphics._l(XX[13], YY[13]);
    pGraphics._l(XX[14], YY[14]);
    pGraphics._l(XX[15], YY[15]);
    pGraphics._l(XX[16], YY[16]);
1716 1717

}
Anna.Pavlova's avatar
Anna.Pavlova committed
1718 1719 1720 1721
CLeftRightArrow.prototype.IsArrow = function()
{
    return true;
}
1722 1723 1724 1725 1726 1727 1728 1729

function CDoubleArrow()
{
    CGlyphOperator.call(this);
}
extend(CDoubleArrow, CGlyphOperator);
CDoubleArrow.prototype.calcSize = function()
{
1730
    var betta = this.getCtrPrp().FontSize/36;
1731 1732 1733 1734 1735 1736

    var height = 6.7027777777777775*betta;
    var width = 10.994677734375*betta;

    return {width: width, height: height};
}
1737
CDoubleArrow.prototype.calcCoord = function(stretch)
1738
{
1739 1740
    var X = [],
        Y = [];
1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761

    X[0] = 14738;  Y[0] = 29764;
    X[1] = 20775;  Y[1] = 37002;
    X[2] = 18338;  Y[2] = 39064;
    X[3] = 0;      Y[3] = 20731;
    X[4] = 0;      Y[4] = 18334;
    X[5] = 18338;  Y[5] = 0;
    X[6] = 20775;  Y[6] = 2063;
    X[7] = 14775;  Y[7] = 9225;
    X[8] = 57600;  Y[8] = 9225;
    X[9] = 57600;  Y[9] = 14213;
    X[10] = 10950; Y[10] = 14213;
    X[11] = 6638;  Y[11] = 19532;
    X[12] = 10875; Y[12] = 24777;
    X[13] = 57600; Y[13] = 24777;
    X[14] = 57600; Y[14] = 29764;
    X[15] = 14738; Y[15] = 29764;

    X[16] = 58950; Y[16] = 19495;
    X[17] = 58950; Y[17] = 19495;

1762
    var textScale = this.getCtrPrp().FontSize/1000; // 1000 pt
1763 1764
    var alpha = textScale*25.4/96 /64; // коэффициент используется для того, чтобы перевести координаты в миллиметры

1765 1766
    var XX = [],
        YY = [];
1767 1768 1769 1770 1771 1772 1773

    for(var i = 0; i < X.length; i++)
    {
        XX[i] = X[i]*alpha;
        YY[i] = Y[i]*alpha;
    }

1774
    var lng = stretch - 10000*alpha;
1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792

    if(lng > XX[16])
    {
        XX[8] = lng;
        XX[9] = lng;

        XX[13] = lng;
        XX[14] = lng;

        XX[16] = lng;
        XX[17] = lng;
    }

    var W = XX[16],
        H = YY[2];

    return {XX: XX, YY: YY, W: W, H: H};
}
1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815
CDoubleArrow.prototype.drawPath = function(pGraphics, XX, YY)
{
    pGraphics._m(XX[0], YY[0]);
    pGraphics._l(XX[1], YY[1]);
    pGraphics._l(XX[2], YY[2]);
    pGraphics._l(XX[3], YY[3]);
    pGraphics._l(XX[4], YY[4]);
    pGraphics._l(XX[5], YY[5]);
    pGraphics._l(XX[6], YY[6]);
    pGraphics._l(XX[7], YY[7]);
    pGraphics._l(XX[8], YY[8]);
    pGraphics._l(XX[9], YY[9]);
    pGraphics._l(XX[10], YY[10]);
    pGraphics._l(XX[11], YY[11]);
    pGraphics._l(XX[12], YY[12]);
    pGraphics._l(XX[13], YY[13]);
    pGraphics._l(XX[14], YY[14]);
    pGraphics._l(XX[15], YY[15]);
    pGraphics.df();

    pGraphics._s();
    pGraphics._m(XX[16], YY[16]);
    pGraphics._l(XX[17], YY[17]);
1816
}
Anna.Pavlova's avatar
Anna.Pavlova committed
1817 1818 1819 1820
CDoubleArrow.prototype.IsArrow = function()
{
    return true;
}
1821 1822 1823 1824 1825 1826 1827 1828

function CLR_DoubleArrow()
{
    CGlyphOperator.call(this);
}
extend(CLR_DoubleArrow, CGlyphOperator);
CLR_DoubleArrow.prototype.calcSize = function()
{
1829
    var betta = this.getCtrPrp().FontSize/36;
1830 1831 1832 1833 1834 1835

    var height = 6.7027777777777775*betta;
    var width = 13.146484375*betta;

    return {width: width, height: height};
}
1836
CLR_DoubleArrow.prototype.calcCoord = function(stretch)
1837
{
1838 1839
    var X = [],
        Y = [];
1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866

    X[0] = 14775; Y[0] = 9225;
    X[1] = 56063; Y[1] = 9225;
    X[2] = 50100; Y[2] = 2063;
    X[3] = 52538; Y[3] = 0;
    X[4] = 70875; Y[4] = 18334;
    X[5] = 70875; Y[5] = 20731;
    X[6] = 52538; Y[6] = 39064;
    X[7] = 50100; Y[7] = 37002;
    X[8] = 56138; Y[8] = 29764;
    X[9] = 14738; Y[9] = 29764;
    X[10] = 20775; Y[10] = 37002;
    X[11] = 18338; Y[11] = 39064;
    X[12] = 0; Y[12] = 20731;
    X[13] = 0; Y[13] = 18334;
    X[14] = 18338; Y[14] = 0;
    X[15] = 20775; Y[15] = 2063;
    X[16] = 14775; Y[16] = 9225;

    X[17] = 10950; Y[17] = 14213;
    X[18] = 6638;  Y[18] = 19532;
    X[19] = 10875; Y[19] = 24777;
    X[20] = 59963; Y[20] = 24777;
    X[21] = 64238; Y[21] = 19532;
    X[22] = 59925; Y[22] = 14213;
    X[23] = 59925; Y[23] = 14213;

1867
    var textScale = this.getCtrPrp().FontSize/1000; // 1000 pt
1868 1869
    var alpha = textScale*25.4/96 /64;

1870 1871
    var XX = [],
        YY = [];
1872 1873 1874 1875 1876 1877 1878 1879

    for(var i = 0; i < X.length; i++)
    {
        XX[i] = X[i]*alpha;
        YY[i] = Y[i]*alpha;
    }

    var w = XX[4];
1880
    var lng = stretch - 10000*alpha - w;
1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894

    for(var i = 1; i < 9; i++)
        XX[i] += lng;

    for(var i = 0; i < 3; i++)
    {
        XX[20 + i] += lng;
    }

    var W = XX[4],
        H = YY[11];

    return {XX: XX, YY: YY, W: W, H: H};
}
1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924
CLR_DoubleArrow.prototype.drawPath = function(pGraphics, XX, YY)
{
    pGraphics._m(XX[0], YY[0]);
    pGraphics._l(XX[1], YY[1]);
    pGraphics._l(XX[2], YY[2]);
    pGraphics._l(XX[3], YY[3]);
    pGraphics._l(XX[4], YY[4]);
    pGraphics._l(XX[5], YY[5]);
    pGraphics._l(XX[6], YY[6]);
    pGraphics._l(XX[7], YY[7]);
    pGraphics._l(XX[8], YY[8]);
    pGraphics._l(XX[9], YY[9]);
    pGraphics._l(XX[10], YY[10]);
    pGraphics._l(XX[11], YY[11]);
    pGraphics._l(XX[12], YY[12]);
    pGraphics._l(XX[13], YY[13]);
    pGraphics._l(XX[14], YY[14]);
    pGraphics._l(XX[15], YY[15]);
    pGraphics._l(XX[16], YY[16]);
    pGraphics.df();

    pGraphics.b_color1(255,255,255, 255);
    pGraphics._s();
    pGraphics._m(XX[17], YY[17]);
    pGraphics._l(XX[18], YY[18]);
    pGraphics._l(XX[19], YY[19]);
    pGraphics._l(XX[20], YY[20]);
    pGraphics._l(XX[21], YY[21]);
    pGraphics._l(XX[22], YY[22]);
    pGraphics._l(XX[23], YY[23]);
1925
}
Anna.Pavlova's avatar
Anna.Pavlova committed
1926 1927 1928 1929
CLR_DoubleArrow.prototype.IsArrow = function()
{
    return true;
}
1930 1931 1932 1933 1934 1935 1936 1937 1938 1939



function CCombiningArrow()
{
    CGlyphOperator.call(this);
}
extend(CCombiningArrow, CGlyphOperator);
CCombiningArrow.prototype.calcSize = function()
{
1940
    var betta = this.getCtrPrp().FontSize/36;
1941

1942
    var height = 3.9*betta;
1943 1944 1945 1946
    var width = 4.938*betta;

    return {width: width, height: height};
}
1947
CCombiningArrow.prototype.calcCoord = function(stretch)
1948 1949 1950 1951 1952 1953
{
    // px                       mm
    // XX[..]                   width
    // YY[..]                   height
    // penW

1954 1955
    var X = [],
        Y = [];
1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968

    X[0] = 0; Y[0] = 8137;
    X[1] = 9413; Y[1] = 0;
    X[2] = 11400; Y[2] = 2250;
    X[3] = 5400; Y[3] = 7462;
    X[4] = 28275; Y[4] = 7462;
    X[5] = 28275; Y[5] = 10987;
    X[6] = 5400; Y[6] = 10987;
    X[7] = 11400; Y[7] = 16200;
    X[8] = 9413; Y[8] = 18450;
    X[9] = 0; Y[9] = 10312;
    X[10] = 0; Y[10] = 8137;

1969
    var textScale =  this.getCtrPrp().FontSize/1000; // 1000 pt
1970 1971
    var alpha = textScale*25.4/96 /64; // коэффициент используется для того, чтобы перевести координаты в миллиметры

1972 1973
    var XX = [],
        YY = [];
1974 1975 1976 1977 1978 1979 1980

    for(var i = 0; i < X.length; i++)
    {
        XX[i] = X[i]*alpha;
        YY[i] = Y[i]*alpha;
    }

1981
    XX[4] = XX[5] = stretch;
1982 1983 1984 1985 1986 1987

    var W = XX[4],
        H = YY[8];

    return {XX: XX, YY: YY, W: W, H: H};
}
1988
CCombiningArrow.prototype.drawPath = function(pGraphics, XX, YY)
1989
{
1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000
    pGraphics._m(XX[0], YY[0]);
    pGraphics._l(XX[1], YY[1]);
    pGraphics._l(XX[2], YY[2]);
    pGraphics._l(XX[3], YY[3]);
    pGraphics._l(XX[4], YY[4]);
    pGraphics._l(XX[5], YY[5]);
    pGraphics._l(XX[6], YY[6]);
    pGraphics._l(XX[7], YY[7]);
    pGraphics._l(XX[8], YY[8]);
    pGraphics._l(XX[9], YY[9]);
    pGraphics._l(XX[10], YY[10]);
2001 2002 2003 2004 2005 2006 2007 2008 2009
}

function CCombiningHalfArrow()
{
    CGlyphOperator.call(this);
}
extend(CCombiningHalfArrow, CGlyphOperator);
CCombiningHalfArrow.prototype.calcSize = function()
{
2010
    var betta = this.getCtrPrp().FontSize/36;
2011 2012 2013 2014 2015 2016 2017 2018

    // 0x21BC half, down

    var height = 3.88*betta;
    var width = 4.938*betta;

    return {width: width, height: height};
}
2019
CCombiningHalfArrow.prototype.drawPath = function(pGraphics, XX, YY)
2020
{
2021 2022 2023 2024 2025 2026 2027 2028
    pGraphics._m(XX[0], YY[0]);
    pGraphics._l(XX[1], YY[1]);
    pGraphics._l(XX[2], YY[2]);
    pGraphics._l(XX[3], YY[3]);
    pGraphics._l(XX[4], YY[4]);
    pGraphics._l(XX[5], YY[5]);
    pGraphics._l(XX[6], YY[6]);
    pGraphics._l(XX[7], YY[7]);
2029
}
2030
CCombiningHalfArrow.prototype.calcCoord = function(stretch)
2031 2032 2033 2034 2035 2036
{
    // px                       mm
    // XX[..]                   width
    // YY[..]                   height
    // penW

2037 2038
    var X = [],
        Y = [];
2039 2040 2041 2042 2043 2044 2045 2046 2047 2048

    X[0] = 0; Y[0] = 8137;
    X[1] = 9413; Y[1] = 0;
    X[2] = 11400; Y[2] = 2250;
    X[3] = 5400; Y[3] = 7462;
    X[4] = 28275; Y[4] = 7462;
    X[5] = 28275; Y[5] = 10987;
    X[6] = 0; Y[6] = 10987;
    X[7] = 0; Y[7] = 8137;

2049
    var textScale = this.getCtrPrp().FontSize/1000; // 1000 pt
2050 2051
    var alpha = textScale*25.4/96 /64; // коэффициент используется для того, чтобы перевести координаты в миллиметры

2052 2053
    var XX = [],
        YY = [];
2054 2055 2056 2057 2058 2059 2060

    for(var i = 0; i < X.length; i++)
    {
        XX[i] = X[i]*alpha;
        YY[i] = Y[i]*alpha;
    }

2061
    XX[4] = XX[5] = stretch;
2062 2063 2064 2065 2066 2067 2068

    var W = XX[4],
        H = YY[5];

    return {XX: XX, YY: YY, W: W, H: H};
}

2069
function CCombining_LR_Arrow()
2070 2071 2072
{
    CGlyphOperator.call(this);
}
2073 2074
extend(CCombining_LR_Arrow, CGlyphOperator);
CCombining_LR_Arrow.prototype.calcSize = function()
2075
{
2076
    var betta = this.getCtrPrp().FontSize/36;
2077 2078 2079 2080 2081 2082

    var height = 3.88*betta;
    var width = 4.938*betta;

    return {width: width, height: height};
}
2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101
CCombining_LR_Arrow.prototype.drawPath = function(pGraphics, XX, YY)
{
    pGraphics._m(XX[0], YY[0]);
    pGraphics._l(XX[1], YY[1]);
    pGraphics._l(XX[2], YY[2]);
    pGraphics._l(XX[3], YY[3]);
    pGraphics._l(XX[4], YY[4]);
    pGraphics._l(XX[5], YY[5]);
    pGraphics._l(XX[6], YY[6]);
    pGraphics._l(XX[7], YY[7]);
    pGraphics._l(XX[8], YY[8]);
    pGraphics._l(XX[9], YY[9]);
    pGraphics._l(XX[10], YY[10]);
    pGraphics._l(XX[11], YY[11]);
    pGraphics._l(XX[12], YY[12]);
    pGraphics._l(XX[13], YY[13]);
    pGraphics._l(XX[14], YY[14]);
    pGraphics._l(XX[15], YY[15]);
    pGraphics._l(XX[16], YY[16]);
2102 2103

}
2104
CCombining_LR_Arrow.prototype.calcCoord = function(stretch)
2105
{
2106 2107
    var X = [],
        Y = [];
2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126

    X[0] = 0; Y[0] = 8137;
    X[1] = 9413; Y[1] = 0;
    X[2] = 11400; Y[2] = 2250;
    X[3] = 5400; Y[3] = 7462;
    X[4] = 42225; Y[4] = 7462;
    X[5] = 36225; Y[5] = 2250;
    X[6] = 38213; Y[6] = 0;
    X[7] = 47625; Y[7] = 8137;
    X[8] = 47625; Y[8] = 10312;
    X[9] = 38213; Y[9] = 18450;
    X[10] = 36225; Y[10] = 16200;
    X[11] = 42225; Y[11] = 10987;
    X[12] = 5400; Y[12] = 10987;
    X[13] = 11400; Y[13] = 16200;
    X[14] = 9413; Y[14] = 18450;
    X[15] = 0; Y[15] = 10312;
    X[16] = 0; Y[16] = 8137;

2127
    var textScale = this.getCtrPrp().FontSize/1000; // 1000 pt
2128 2129
    var alpha = textScale*25.4/96 /64; // коэффициент используется для того, чтобы перевести координаты в миллиметры

2130 2131
    var XX = [],
        YY = [];
2132 2133 2134 2135 2136 2137 2138

    for(var i = 0; i < X.length; i++)
    {
        XX[i] = X[i]*alpha;
        YY[i] = Y[i]*alpha;
    }

2139
    var lng = stretch - XX[7];
2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150

    for(var i = 0; i < 8; i++)
    {
        XX[4+i] += lng;
    }

    var W = XX[7],
        H = YY[9];

    return {XX: XX, YY: YY, W: W, H: H};

2151 2152 2153
}


2154
function COperator(type)
2155
{
2156
    this.type = type; // delimiter, separator, group character, accent
2157
    this.operator = null;
2158 2159

    this.code = null;
2160 2161
    this.typeOper = null;   // тип скобки : круглая и т.п.
    this.defaultType = null;
2162

2163 2164
    //this.pos = null;

2165
    this.Positions = [];
2166 2167
    this.coordGlyph = null;
    this.size = {width: 0, height: 0};
Anna.Pavlova's avatar
Anna.Pavlova committed
2168

Anna.Pavlova's avatar
Anna.Pavlova committed
2169 2170
    this.ParaMath = null;

Anna.Pavlova's avatar
Anna.Pavlova committed
2171
    this.shiftAccent = 0;
2172
}
2173
COperator.prototype.mergeProperties = function(properties, defaultProps)   // props (chr, type, location), defaultProps (chr, location)
2174
{
2175 2176
    var props = this.getProps(properties, defaultProps);

2177 2178 2179 2180
    var operator = null,
        typeOper = null,
        codeChr  = null;

Anna.Pavlova's avatar
Anna.Pavlova committed
2181 2182 2183
    var type = props.type,
        location = props.loc,
        code = props.code;
2184

Anna.Pavlova's avatar
Anna.Pavlova committed
2185
    var prp = {};
2186

Anna.Pavlova's avatar
Anna.Pavlova committed
2187
    //////////    delimiters    //////////
2188

2189 2190 2191 2192 2193 2194
    if( code === 0x28 || type === PARENTHESIS_LEFT)
    {
        codeChr = 0x28;
        typeOper = PARENTHESIS_LEFT;

        operator = new COperatorParenthesis();
Anna.Pavlova's avatar
Anna.Pavlova committed
2195
        prp =
2196 2197 2198 2199
        {
            location:   location,
            turn:       TURN_0
        };
Anna.Pavlova's avatar
Anna.Pavlova committed
2200
        operator.init(prp);
2201
    }
2202
    else if(code === 0x29 || type === PARENTHESIS_RIGHT)
2203 2204 2205 2206 2207
    {
        codeChr = 0x29;
        typeOper = PARENTHESIS_RIGHT;

        operator = new COperatorParenthesis();
Anna.Pavlova's avatar
Anna.Pavlova committed
2208
        prp =
2209 2210 2211 2212
        {
            location:   location,
            turn:       TURN_180
        };
Anna.Pavlova's avatar
Anna.Pavlova committed
2213
        operator.init(prp);
2214
    }
2215
    else if(code == 0x7B || type === BRACKET_CURLY_LEFT)
2216 2217 2218 2219 2220
    {
        codeChr = 0x7B;
        typeOper = BRACKET_CURLY_LEFT;

        operator = new COperatorBracket();
Anna.Pavlova's avatar
Anna.Pavlova committed
2221
        prp =
2222 2223 2224 2225
        {
            location:   location,
            turn:       TURN_0
        };
Anna.Pavlova's avatar
Anna.Pavlova committed
2226
        operator.init(prp);
2227
    }
2228
    else if(code === 0x7D || type === BRACKET_CURLY_RIGHT)
2229 2230 2231 2232 2233
    {
        codeChr = 0x7D;
        typeOper = BRACKET_CURLY_RIGHT;

        operator = new COperatorBracket();
Anna.Pavlova's avatar
Anna.Pavlova committed
2234
        prp =
2235 2236 2237 2238
        {
            location:   location,
            turn:       TURN_180
        };
Anna.Pavlova's avatar
Anna.Pavlova committed
2239
        operator.init(prp);
2240
    }
2241
    else if(code === 0x5B || type === BRACKET_SQUARE_LEFT)
2242 2243 2244 2245 2246
    {
        codeChr = 0x5B;
        typeOper = BRACKET_SQUARE_LEFT;

        operator = new CSquareBracket();
Anna.Pavlova's avatar
Anna.Pavlova committed
2247
        prp =
2248 2249 2250 2251
        {
            location:   location,
            turn:       TURN_0
        };
Anna.Pavlova's avatar
Anna.Pavlova committed
2252
        operator.init(prp);
2253
    }
2254
    else if(code === 0x5D || type === BRACKET_SQUARE_RIGHT)
2255 2256 2257 2258 2259
    {
        codeChr = 0x5D;
        typeOper = BRACKET_SQUARE_RIGHT;

        operator = new CSquareBracket();
Anna.Pavlova's avatar
Anna.Pavlova committed
2260
        prp =
2261 2262 2263 2264
        {
            location:   location,
            turn:       TURN_180
        };
Anna.Pavlova's avatar
Anna.Pavlova committed
2265
        operator.init(prp);
2266
    }
2267
    else if(code === 0x27E8 || type === BRACKET_ANGLE_LEFT) // 0x3C => 0x27E8
2268
    {
2269
        codeChr = 0x27E8;
2270 2271 2272
        typeOper = BRACKET_ANGLE_LEFT;

        operator = new COperatorAngleBracket();
Anna.Pavlova's avatar
Anna.Pavlova committed
2273
        prp =
2274 2275 2276 2277
        {
            location:   location,
            turn:       TURN_0
        };
Anna.Pavlova's avatar
Anna.Pavlova committed
2278
        operator.init(prp);
2279
    }
2280
    else if(code === 0x27E9 || type === BRACKET_ANGLE_RIGHT) // 0x3E => 0x27E9
2281
    {
2282
        codeChr = 0x27E9;
2283 2284 2285
        typeOper = BRACKET_ANGLE_RIGHT;

        operator = new COperatorAngleBracket();
Anna.Pavlova's avatar
Anna.Pavlova committed
2286
        prp =
2287 2288 2289 2290
        {
            location:   location,
            turn:       TURN_180
        };
Anna.Pavlova's avatar
Anna.Pavlova committed
2291
        operator.init(prp);
2292 2293 2294 2295 2296 2297 2298
    }
    else if(code === 0x7C || type === DELIMITER_LINE)
    {
        codeChr = 0x7C;
        typeOper = DELIMITER_LINE;

        operator = new COperatorLine();
Anna.Pavlova's avatar
Anna.Pavlova committed
2299
        prp =
2300 2301 2302 2303
        {
            location:   location,
            turn:       TURN_0
        };
Anna.Pavlova's avatar
Anna.Pavlova committed
2304
        operator.init(prp);
2305 2306 2307 2308 2309 2310 2311
    }
    else if(code === 0x230A || type === HALF_SQUARE_LEFT)
    {
        codeChr = 0x230A;
        typeOper = HALF_SQUARE_LEFT;

        operator = new CHalfSquareBracket();
Anna.Pavlova's avatar
Anna.Pavlova committed
2312
        prp =
2313 2314 2315 2316
        {
            location:   location,
            turn:       TURN_0
        };
Anna.Pavlova's avatar
Anna.Pavlova committed
2317
        operator.init(prp);
2318 2319 2320 2321 2322 2323 2324
    }
    else if(code === 0x230B || type == HALF_SQUARE_RIGHT)
    {
        codeChr = 0x230B;
        typeOper = HALF_SQUARE_RIGHT;

        operator = new CHalfSquareBracket();
Anna.Pavlova's avatar
Anna.Pavlova committed
2325
        prp =
2326 2327 2328 2329
        {
            location:   location,
            turn:       TURN_180
        };
Anna.Pavlova's avatar
Anna.Pavlova committed
2330
        operator.init(prp);
2331 2332 2333 2334 2335 2336 2337
    }
    else if(code === 0x2308 || type == HALF_SQUARE_LEFT_UPPER)
    {
        codeChr = 0x2308;
        typeOper = HALF_SQUARE_LEFT_UPPER;

        operator = new CHalfSquareBracket();
Anna.Pavlova's avatar
Anna.Pavlova committed
2338
        prp =
2339 2340 2341 2342
        {
            location:   location,
            turn:       TURN_MIRROR_0
        };
Anna.Pavlova's avatar
Anna.Pavlova committed
2343
        operator.init(prp);
2344 2345 2346 2347 2348 2349 2350
    }
    else if(code === 0x2309 || type == HALF_SQUARE_RIGHT_UPPER)
    {
        codeChr = 0x2309;
        typeOper = HALF_SQUARE_RIGHT_UPPER;

        operator = new CHalfSquareBracket();
Anna.Pavlova's avatar
Anna.Pavlova committed
2351
        prp =
2352 2353 2354 2355
        {
            location:   location,
            turn:       TURN_MIRROR_180
        };
Anna.Pavlova's avatar
Anna.Pavlova committed
2356
        operator.init(prp);
2357 2358 2359 2360 2361 2362 2363
    }
    else if(code === 0x2016 || type == DELIMITER_DOUBLE_LINE)
    {
        codeChr = 0x2016;
        typeOper = DELIMITER_DOUBLE_LINE;

        operator = new COperatorDoubleLine();
Anna.Pavlova's avatar
Anna.Pavlova committed
2364
        prp =
2365 2366 2367 2368
        {
            location:   location,
            turn:       TURN_0
        };
Anna.Pavlova's avatar
Anna.Pavlova committed
2369
        operator.init(prp);
2370 2371 2372 2373 2374 2375 2376
    }
    else if(code === 0x27E6 || type == WHITE_SQUARE_LEFT)
    {
        codeChr = 0x27E6;
        typeOper = WHITE_SQUARE_LEFT;

        operator = new CWhiteSquareBracket();
Anna.Pavlova's avatar
Anna.Pavlova committed
2377
        prp =
2378 2379 2380 2381
        {
            location:   location,
            turn:       TURN_0
        };
Anna.Pavlova's avatar
Anna.Pavlova committed
2382
        operator.init(prp);
2383 2384 2385 2386 2387 2388 2389
    }
    else if(code === 0x27E7 || type == WHITE_SQUARE_RIGHT)
    {
        codeChr = 0x27E7;
        typeOper = WHITE_SQUARE_RIGHT;

        operator = new CWhiteSquareBracket();
Anna.Pavlova's avatar
Anna.Pavlova committed
2390
        prp =
2391 2392 2393 2394
        {
            location:   location,
            turn:       TURN_180
        };
Anna.Pavlova's avatar
Anna.Pavlova committed
2395
        operator.init(prp);
2396
    }
2397
    else if(type === OPERATOR_EMPTY)
2398
    {
2399
        typeOper = OPERATOR_EMPTY;
2400 2401
        operator = -1;
    }
Anna.Pavlova's avatar
Anna.Pavlova committed
2402

2403
    //////////////////////////////////////////
Anna.Pavlova's avatar
Anna.Pavlova committed
2404

2405
    ////////////     accents     /////////////
Anna.Pavlova's avatar
Anna.Pavlova committed
2406

2407 2408 2409 2410 2411 2412 2413 2414
    /////// only arrows /////

    else if(code === 0x20D6 || type === ACCENT_ARROW_LEFT)
    {
        codeChr = 0x20D6;
        typeOper = ACCENT_ARROW_LEFT;

        operator = new CCombiningArrow();
Anna.Pavlova's avatar
Anna.Pavlova committed
2415
        prp =
2416 2417 2418 2419
        {
            location:   LOCATION_TOP,
            turn:       TURN_0
        };
Anna.Pavlova's avatar
Anna.Pavlova committed
2420
        operator.init(prp);
2421 2422 2423 2424 2425 2426 2427
    }
    else if(code === 0x20D7 || type === ACCENT_ARROW_RIGHT)
    {
        typeOper = ACCENT_ARROW_RIGHT;
        codeChr = 0x20D7;

        operator = new CCombiningArrow();
Anna.Pavlova's avatar
Anna.Pavlova committed
2428
        prp =
2429 2430 2431 2432
        {
            location:   LOCATION_TOP,
            turn:       TURN_180
        };
Anna.Pavlova's avatar
Anna.Pavlova committed
2433
        operator.init(prp);
2434 2435 2436 2437 2438 2439 2440
    }
    else if(code === 0x20E1 || type === ACCENT_ARROW_LR)
    {
        typeOper = ACCENT_ARROW_LR;
        codeChr = 0x20E1;

        operator = new CCombining_LR_Arrow();
Anna.Pavlova's avatar
Anna.Pavlova committed
2441
        prp =
2442 2443 2444 2445 2446
        {
            location:   LOCATION_TOP,
            turn:       TURN_0
        };

Anna.Pavlova's avatar
Anna.Pavlova committed
2447
        operator.init(prp);
2448 2449 2450 2451 2452 2453 2454
    }
    else if(code === 0x20D0 || type === ACCENT_HALF_ARROW_LEFT)
    {
        typeOper = ACCENT_HALF_ARROW_LEFT;
        codeChr = 0x20D0;

        operator = new CCombiningHalfArrow();
Anna.Pavlova's avatar
Anna.Pavlova committed
2455
        prp =
2456 2457 2458 2459
        {
            location:   LOCATION_TOP,
            turn:       TURN_0
        };
Anna.Pavlova's avatar
Anna.Pavlova committed
2460
        operator.init(prp);
2461 2462 2463 2464 2465 2466 2467
    }
    else if(code === 0x20D1 || type ===  ACCENT_HALF_ARROW_RIGHT)
    {
        typeOper = ACCENT_HALF_ARROW_RIGHT;
        codeChr = 0x20D1;

        operator = new CCombiningHalfArrow();
Anna.Pavlova's avatar
Anna.Pavlova committed
2468
        prp =
2469 2470 2471 2472
        {
            location:   LOCATION_TOP,
            turn:       TURN_180
        };
Anna.Pavlova's avatar
Anna.Pavlova committed
2473
        operator.init(prp);
2474 2475
    }

Anna.Pavlova's avatar
Anna.Pavlova committed
2476
    ///////////////////////////////
2477

Anna.Pavlova's avatar
Anna.Pavlova committed
2478
    else if(code === 0x302 || type === ACCENT_CIRCUMFLEX)
2479 2480 2481 2482
    {
        typeOper = ACCENT_CIRCUMFLEX;
        codeChr = 0x302;

Anna.Pavlova's avatar
Anna.Pavlova committed
2483 2484 2485 2486
        //operator = new CCircumflex();
        operator = new CAccentCircumflex();

        prp =
2487
        {
Anna.Pavlova's avatar
Anna.Pavlova committed
2488 2489 2490 2491
            location:   LOCATION_TOP,
            turn:       TURN_MIRROR_0,
            bStretch:   false

2492
        };
Anna.Pavlova's avatar
Anna.Pavlova committed
2493 2494
        operator.init(prp);

2495 2496 2497 2498 2499 2500
    }
    else if(code === 0x30C || type === ACCENT_COMB_CARON)
    {
        typeOper = ACCENT_COMB_CARON;
        codeChr = 0x30C;

Anna.Pavlova's avatar
Anna.Pavlova committed
2501 2502
        operator = new CAccentCircumflex();
        prp =
2503
        {
Anna.Pavlova's avatar
Anna.Pavlova committed
2504 2505 2506
            location:   LOCATION_TOP,
            turn:   TURN_0,
            bStretch:   false
2507
        };
Anna.Pavlova's avatar
Anna.Pavlova committed
2508 2509
        operator.init(prp);

2510
    }
Anna.Pavlova's avatar
Anna.Pavlova committed
2511
    else if(code === 0x305 || type === ACCENT_LINE)
2512 2513
    {
        typeOper = ACCENT_LINE;
Anna.Pavlova's avatar
Anna.Pavlova committed
2514 2515
        //codeChr = 0x332;
        codeChr = 0x305;
2516

Anna.Pavlova's avatar
Anna.Pavlova committed
2517 2518 2519 2520 2521 2522 2523
        operator = new CAccentLine();
        prp =
        {
            location:   LOCATION_TOP,
            turn:   TURN_0
        };
        operator.init(prp);
2524
    }
Anna.Pavlova's avatar
Anna.Pavlova committed
2525
    else if(code === 0x33F || type === ACCENT_DOUBLE_LINE)
2526 2527
    {
        typeOper = ACCENT_DOUBLE_LINE;
Anna.Pavlova's avatar
Anna.Pavlova committed
2528 2529
        //codeChr = 0x333;
        codeChr = 0x33F;
2530

Anna.Pavlova's avatar
Anna.Pavlova committed
2531 2532 2533 2534 2535 2536 2537
        operator = new CAccentDoubleLine();
        prp =
        {
            location:   LOCATION_TOP,
            turn:   TURN_0
        };
        operator.init(prp);
2538 2539 2540 2541 2542 2543
    }
    else if(code === 0x303 || type === ACCENT_TILDE)
    {
        typeOper = ACCENT_TILDE;
        codeChr = 0x303;

Anna.Pavlova's avatar
Anna.Pavlova committed
2544 2545 2546 2547 2548 2549 2550 2551
        operator = new CAccentTilde();
        prp =
        {
            location:   LOCATION_TOP,
            turn:   TURN_0,
            bStretch:   false
        };
        operator.init(prp);
2552 2553 2554 2555 2556 2557
    }
    else if(code === 0x306 || type === ACCENT_BREVE)
    {
        typeOper = ACCENT_BREVE;
        codeChr = 0x306;

Anna.Pavlova's avatar
Anna.Pavlova committed
2558 2559
        operator = new CAccentBreve();
        prp =
2560
        {
Anna.Pavlova's avatar
Anna.Pavlova committed
2561 2562 2563
            location:   LOCATION_TOP,
            turn:   TURN_MIRROR_0,
            bStretch:   false
2564
        };
Anna.Pavlova's avatar
Anna.Pavlova committed
2565 2566
        operator.init(prp);

2567 2568 2569 2570 2571 2572
    }
    else if(code == 0x311 || type == ACCENT_INVERT_BREVE)
    {
        typeOper = ACCENT_INVERT_BREVE;
        codeChr = 0x311;

Anna.Pavlova's avatar
Anna.Pavlova committed
2573 2574
        operator = new CAccentBreve();
        prp =
2575 2576
        {
            location:   LOCATION_TOP,
Anna.Pavlova's avatar
Anna.Pavlova committed
2577 2578
            turn:   TURN_0,
            bStretch:   false
2579
        };
Anna.Pavlova's avatar
Anna.Pavlova committed
2580
        operator.init(prp);
2581 2582 2583

    }

Anna.Pavlova's avatar
Anna.Pavlova committed
2584
    //////////////////////////////////////////////////////
2585

Anna.Pavlova's avatar
Anna.Pavlova committed
2586 2587 2588 2589
    /*else if(code === 0x302 || type === ACCENT_CIRCUMFLEX)
     {
     typeOper = ACCENT_CIRCUMFLEX;
     codeChr = 0x302;
2590

Anna.Pavlova's avatar
Anna.Pavlova committed
2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720
     operator = new CCircumflex();
     var props =
     {
     turn:   TURN_0
     };
     operator.init(props);
     }
     else if(code === 0x30C || type === ACCENT_COMB_CARON)
     {
     typeOper = ACCENT_COMB_CARON;
     codeChr = 0x30C;

     operator = new CCircumflex();
     var props =
     {
     turn:   TURN_MIRROR_0
     };
     operator.init(props);
     }
     else if(code === 0x332 || type === ACCENT_LINE)
     {
     typeOper = ACCENT_LINE;
     codeChr = 0x332;

     operator = new CLine();
     }
     else if(code === 0x333 || type === ACCENT_DOUBLE_LINE)
     {
     typeOper = ACCENT_DOUBLE_LINE;
     codeChr = 0x333;

     operator = new CDoubleLine();

     }
     else if(code === 0x303 || type === ACCENT_TILDE)
     {
     typeOper = ACCENT_TILDE;
     codeChr = 0x303;

     operator = new CTilde();
     }
     else if(code === 0x306 || type === ACCENT_BREVE)
     {
     typeOper = ACCENT_BREVE;
     codeChr = 0x306;

     operator = new CBreve();
     var props =
     {
     turn:   TURN_MIRROR_0
     };
     operator.init(props);
     }
     else if(code == 0x311 || type == ACCENT_INVERT_BREVE)
     {
     typeOper = ACCENT_INVERT_BREVE;
     codeChr = 0x311;

     operator = new CBreve();
     var props =
     {
     turn:   TURN_0
     };
     operator.init(props);
     }
     else if(code === 0x20D6 || type === ACCENT_ARROW_LEFT)
     {
     typeOper = ACCENT_ARROW_LEFT;
     codeChr = 0x20D6;

     operator = new CCombiningArrow();
     var props =
     {
     location:   LOCATION_TOP,
     turn:       TURN_0
     };
     operator.init(props);
     }
     else if(code === 0x20D7 || type === ACCENT_ARROW_RIGHT)
     {
     typeOper = ACCENT_ARROW_RIGHT;
     codeChr = 0x20D7;

     operator = new CCombiningArrow();
     var props =
     {
     location:   LOCATION_TOP,
     turn:       TURN_180
     };
     operator.init(props);
     }
     else if(code === 0x20E1 || type === ACCENT_ARROW_LR)
     {
     typeOper = ACCENT_ARROW_LR;
     codeChr = 0x20E1;

     operator = new CCombining_LR_Arrow();
     var props =
     {
     location:   LOCATION_TOP,
     turn:       TURN_0
     };
     operator.init(props);
     }
     else if(code === 0x20D0 || type === ACCENT_HALF_ARROW_LEFT)
     {
     typeOper = ACCENT_HALF_ARROW_LEFT;
     codeChr = 0x20D0;

     operator = new CCombiningHalfArrow();
     var props =
     {
     location:   LOCATION_TOP,
     turn:       TURN_0
     };
     operator.init(props);
     }
     else if(code === 0x20D1 || type ===  ACCENT_HALF_ARROW_RIGHT)
     {
     typeOper = ACCENT_HALF_ARROW_RIGHT;
     codeChr = 0x20D1;

     operator = new CCombiningHalfArrow();
     var props =
     {
     location:   LOCATION_TOP,
     turn:       TURN_180
     };
     operator.init(props);
     }*/
2721

2722
    //////////////////////////////////////////
Anna.Pavlova's avatar
Anna.Pavlova committed
2723 2724 2725 2726 2727 2728 2729 2730

    //////////   group characters   //////////

    else if(code === 0x23DE || type == BRACKET_CURLY_TOP)
    {
        codeChr = 0x23DE;
        typeOper = BRACKET_CURLY_TOP;

2731
        operator = new COperatorBracket();
2732
        prp =
Anna.Pavlova's avatar
Anna.Pavlova committed
2733
        {
2734
            location:   location,
Anna.Pavlova's avatar
Anna.Pavlova committed
2735 2736
            turn:       TURN_0
        };
2737
        operator.init(prp);
Anna.Pavlova's avatar
Anna.Pavlova committed
2738
    }
2739
    else if(code === 0x23DF || type === BRACKET_CURLY_BOTTOM)
Anna.Pavlova's avatar
Anna.Pavlova committed
2740
    {
2741 2742 2743 2744
        codeChr =  0x23DF;
        typeOper = BRACKET_CURLY_BOTTOM;

        operator = new COperatorBracket();
2745
        prp =
Anna.Pavlova's avatar
Anna.Pavlova committed
2746
        {
2747
            location:   location,
Anna.Pavlova's avatar
Anna.Pavlova committed
2748 2749
            turn:       TURN_MIRROR_0
        };
2750
        operator.init(prp);
Anna.Pavlova's avatar
Anna.Pavlova committed
2751 2752 2753
    }
    else if(code === 0x2190 || type === ARROW_LEFT)
    {
2754 2755
        codeChr =  0x2190;
        typeOper = ARROW_LEFT;
Anna.Pavlova's avatar
Anna.Pavlova committed
2756

2757 2758
        operator = new CSingleArrow();

2759
        prp =
Anna.Pavlova's avatar
Anna.Pavlova committed
2760
        {
2761
            location:   location,
Anna.Pavlova's avatar
Anna.Pavlova committed
2762 2763
            turn:       TURN_0
        };
2764
        operator.init(prp);
Anna.Pavlova's avatar
Anna.Pavlova committed
2765 2766 2767
    }
    else if(code === 0x2192 || type === ARROW_RIGHT)
    {
2768 2769 2770 2771
        codeChr =  0x2192;
        typeOper = ARROW_RIGHT;

        operator = new CSingleArrow();
2772
        prp =
Anna.Pavlova's avatar
Anna.Pavlova committed
2773
        {
2774
            location:   location,
Anna.Pavlova's avatar
Anna.Pavlova committed
2775 2776
            turn:       TURN_180
        };
2777
        operator.init(prp);
Anna.Pavlova's avatar
Anna.Pavlova committed
2778 2779 2780
    }
    else if(code === 0x2194 || type === ARROW_LR)
    {
2781 2782 2783 2784
        codeChr =  0x2194;
        typeOper = ARROW_LR;

        operator = new CLeftRightArrow();
2785
        prp =
Anna.Pavlova's avatar
Anna.Pavlova committed
2786
        {
2787
            location:   location,
Anna.Pavlova's avatar
Anna.Pavlova committed
2788 2789
            turn:       TURN_0
        };
2790
        operator.init(prp);
Anna.Pavlova's avatar
Anna.Pavlova committed
2791 2792 2793
    }
    else if(code === 0x21D0 || type === DOUBLE_LEFT_ARROW)
    {
2794 2795 2796 2797
        codeChr =  0x21D0;
        typeOper = DOUBLE_LEFT_ARROW;

        operator = new CDoubleArrow();
2798
        prp =
Anna.Pavlova's avatar
Anna.Pavlova committed
2799
        {
2800
            location:   location,
Anna.Pavlova's avatar
Anna.Pavlova committed
2801 2802
            turn:       TURN_0
        };
2803
        operator.init(prp);
Anna.Pavlova's avatar
Anna.Pavlova committed
2804 2805 2806
    }
    else if(code === 0x21D2 || type === DOUBLE_RIGHT_ARROW)
    {
2807 2808 2809 2810
        codeChr =  0x21D2;
        typeOper = DOUBLE_RIGHT_ARROW;

        operator = new CDoubleArrow();
2811
        prp =
Anna.Pavlova's avatar
Anna.Pavlova committed
2812
        {
2813
            location:   location,
Anna.Pavlova's avatar
Anna.Pavlova committed
2814 2815
            turn:       TURN_180
        };
2816
        operator.init(prp);
Anna.Pavlova's avatar
Anna.Pavlova committed
2817 2818 2819
    }
    else if(code === 0x21D4 || type === DOUBLE_ARROW_LR)
    {
2820 2821 2822 2823
        codeChr =  0x21D4;
        typeOper = DOUBLE_ARROW_LR;

        operator = new CLR_DoubleArrow();
2824
        prp =
Anna.Pavlova's avatar
Anna.Pavlova committed
2825
        {
2826
            location:   location,
Anna.Pavlova's avatar
Anna.Pavlova committed
2827 2828
            turn:       TURN_0
        };
2829
        operator.init(prp);
Anna.Pavlova's avatar
Anna.Pavlova committed
2830 2831
    }

Anna.Pavlova's avatar
Anna.Pavlova committed
2832
    //////////////////////////////////////////////////////
Anna.Pavlova's avatar
Anna.Pavlova committed
2833

2834 2835
    else if(code !== null)
    {
2836 2837 2838
        codeChr  = code;
        typeOper = OPERATOR_TEXT;

2839
        operator = new CMathText(true);
2840 2841 2842 2843 2844
        operator.add(code);
    }
    else
        operator = -1;

2845
    this.operator = operator;
2846 2847 2848
    this.code = codeChr;
    this.typeOper = typeOper;
}
2849 2850 2851 2852 2853 2854
COperator.prototype.getProps = function(props, defaultProps)
{
    var location = props.loc,
        chr = props.chr,
        type = props.type;

2855 2856 2857

    var code = props.chr;

2858 2859 2860
    this.defaultType = defaultProps.type;

    var bDelimiter = this.type == OPER_DELIMITER || this.type == OPER_SEPARATOR,
2861 2862 2863 2864 2865 2866 2867 2868 2869
        bNotType   = typeof(props.type) == "undefined" ||  props.type == null,
        bUnicodeChr    = props.chr !== null && props.chr+0 == props.chr;
        //bStr = typeof(chr) === "string",
        //bEmptyStr = bStr && chr.length == 0,
        //bCode = typeof(chr) === "string" && chr.length > 0;

    //var code = bCode ? chr.charCodeAt(0) : null;


2870
    if(bDelimiter && props.chr == -1) // empty operator
2871 2872 2873 2874 2875 2876 2877
    {
        type = OPERATOR_EMPTY;
    }
    else if(bNotType && !bUnicodeChr)   // default operator
    {
        type = defaultProps.type;
    }
2878 2879


2880
    /*var bDPrpDelim =  bDelimiter && bNotType && !bStr,
2881
        bDPrpOther =  !bDelimiter && bNotType && !bCode;
2882

2883 2884 2885 2886 2887
    var bDefault = bDPrpDelim || bDPrpOther,
        bEmpty = bDelimiter && bEmptyStr;


    if(bDefault)
2888 2889 2890
    {
        type = defaultProps.type;
    }
2891 2892 2893
    else if(bEmpty)
    {
        type = OPERATOR_EMPTY;
2894 2895 2896 2897
    }*/

    var bLoc        = props.loc !== null && typeof(props.loc)!== "undefined";
    var bDefaultLoc = defaultProps.loc !== null && typeof(defaultProps.loc)!== "undefined";
2898

2899 2900 2901 2902

    if(!bLoc && bDefaultLoc)
        location = defaultProps.loc;

2903 2904
    return  {loc: location, type: type, code: code};
}
2905
COperator.prototype.draw = function(x, y, pGraphics)
2906
{
2907 2908 2909 2910
    if(this.typeOper === OPERATOR_TEXT)
    {
        // выставляем font, если нужно отрисовать текст
        pGraphics.b_color1(0,0,0,255);
2911
        var ctrPrp = this.Get_CompiledCtrPrp();
2912

Anna.Pavlova's avatar
Anna.Pavlova committed
2913 2914
        var rPrp = new CTextPr();
        //var defaultRPrp = this.Parent.Composition.DEFAULT_RUN_PRP;
Anna.Pavlova's avatar
Anna.Pavlova committed
2915
        var defaultRPrp = this.Parent.ParaMath.Get_Default_TPrp();
2916
        rPrp.Merge(defaultRPrp);
2917 2918 2919 2920 2921 2922
        rPrp.Merge(ctrPrp);
        rPrp.Italic = false;
        pGraphics.SetFont(rPrp);

        ////////////////////////////////////////////////

2923
        this.operator.draw(x, y, pGraphics);
2924 2925 2926
    }
    else
    {
2927
        if(this.type === OPER_SEPARATOR)
Anna.Pavlova's avatar
Anna.Pavlova committed
2928
            this.drawSeparator(x, y, pGraphics);
2929 2930
        /*else if(this.type == OPER_ACCENT)
            this.drawAccent(x, y, pGraphics);*/
2931
        else
2932
            this.drawOperator(x, y, pGraphics);
2933
    }
2934
}
Anna.Pavlova's avatar
Anna.Pavlova committed
2935
COperator.prototype.drawOperator = function(absX, absY, pGraphics)
Anna.Pavlova's avatar
Anna.Pavlova committed
2936
{
2937
    if(this.typeOper !== OPERATOR_EMPTY)
2938 2939 2940
    {
        var lng = this.coordGlyph.XX.length;

2941 2942
        var X = [],
            Y = [];
2943 2944 2945

        var PosOper = this.Positions[0];

2946 2947
        for(var j = 0; j < lng; j++)
        {
2948 2949
            X.push(PosOper.x + absX + this.coordGlyph.XX[j]);
            Y.push(PosOper.y + absY + this.coordGlyph.YY[j]);
2950 2951
        }

2952
        this.operator.draw(pGraphics, X, Y);
2953
    }
Anna.Pavlova's avatar
Anna.Pavlova committed
2954
}
2955
COperator.prototype.drawSeparator = function(absX, absY, pGraphics)
2956
{
2957
    if(this.typeOper !== OPERATOR_EMPTY)
2958 2959 2960
    {
        var lng = this.coordGlyph.XX.length;

2961
        for(var i = 0; i < this.Positions.length; i++)
2962
        {
2963 2964
            var X = [],
                Y = [];
2965 2966 2967

            var PosOper = this.Positions[i];

2968 2969
            for(var j = 0; j < lng; j++)
            {
2970 2971
                X.push(PosOper.x + absX + this.coordGlyph.XX[j]);
                Y.push(PosOper.y + absY + this.coordGlyph.YY[j]);
2972 2973
            }

2974
            this.operator.draw(pGraphics, X, Y);
2975 2976 2977
        }
    }
}
2978
COperator.prototype.old_fixSize = function(oMeasure, stretch)
2979
{
2980
    if(this.operator !== -1)
2981
    {
2982
        var width, height, ascent;
2983

2984
        if(this.typeOper == OPERATOR_TEXT)
2985
        {
2986 2987
            var ctrPrp = this.getCtrPrp();

Anna.Pavlova's avatar
Anna.Pavlova committed
2988 2989 2990 2991 2992 2993 2994
            //var rPrp = new CMathTextPrp();
            //var defaultRPrp = this.Parent.Composition.DEFAULT_RUN_PRP;

            var rPrp = new CTextPr();
            //var defaultRPrp = this.Parent.Composition.DEFAULT_RUN_PRP;
            var defaultRPrp = this.Parent.Composition.Get_Default_TPrp();

2995
            rPrp.Merge(defaultRPrp);
2996 2997 2998 2999 3000
            rPrp.Merge(ctrPrp);
            rPrp.Italic = false;

            oMeasure.SetFont(rPrp);

3001
            this.operator.Resize(this, oMeasure);
3002

3003
            if(this.operator.loc == 0 || this.operator.loc == 1)
3004
            {
3005 3006
                height = this.operator.size.height;
                width  = stretch > this.operator.size.width ? stretch : this.operator.size.width;
3007
                ascent = height/2;
3008 3009 3010
            }
            else
            {
3011
                width = this.operator.size.width;
3012 3013 3014
                //height = stretch > this.operator.size.height ? stretch : this.operator.size.height;
                height = this.operator.size.height;
                ascent = height/2;
3015
            }
3016 3017 3018
        }
        else
        {
3019 3020
            this.operator.fixSize(stretch);
            var dims = this.operator.getCoordinateGlyph();
3021 3022
            this.coordGlyph = {XX: dims.XX, YY: dims.YY};

3023
            if(this.operator.loc == 0 || this.operator.loc == 1)
3024
            {
3025
                //width = stretch > this.operator.size.width ? stretch : this.operator.size.width;
3026
                width = dims.Width;
3027
                height = this.operator.size.height;
3028 3029 3030
            }
            else
            {
3031 3032
                width = this.operator.size.width;
                //height = stretch > this.operator.size.height ? stretch : this.operator.size.height;
3033 3034 3035
                height = dims.Height;
                //height = dims.Height > stretch ? stretch : dims.Height;
            }
3036

3037
            var betta = this.getCtrPrp().FontSize;
3038
            ascent = height/2 + 0.2*betta;
3039
        }
3040

3041
        this.size = { width: width, height: height, ascent: ascent};
3042 3043
    }
}
Anna.Pavlova's avatar
Anna.Pavlova committed
3044
COperator.prototype.fixSize = function(ParaMath, oMeasure, stretch)
3045
{
Anna.Pavlova's avatar
Anna.Pavlova committed
3046
    this.ParaMath = ParaMath;
3047
    if(this.typeOper !== OPERATOR_EMPTY)
3048 3049
    {
        var width, height, ascent;
3050
        var ascentSign = 0;
3051

3052

3053 3054
        if(this.typeOper == OPERATOR_TEXT) // отдельный случай для текста в качестве оператора
        {
3055
            var ctrPrp = this.Get_CompiledCtrPrp();
3056

Anna.Pavlova's avatar
Anna.Pavlova committed
3057 3058
            var rPrp = new CTextPr();
            //var defaultRPrp = this.Parent.Composition.DEFAULT_RUN_PRP;
Anna.Pavlova's avatar
Anna.Pavlova committed
3059
            var defaultRPrp = this.Parent.ParaMath.Get_Default_TPrp();
Anna.Pavlova's avatar
Anna.Pavlova committed
3060

3061 3062 3063 3064 3065 3066
            rPrp.Merge(defaultRPrp);
            rPrp.Merge(ctrPrp);
            rPrp.Italic = false;

            oMeasure.SetFont(rPrp);

3067
            this.operator.Resize(oMeasure, this);
3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078

            if(this.operator.loc == 0 || this.operator.loc == 1)
            {
                height = this.operator.size.height;
                width  = this.operator.size.width;
            }
            else
            {
                width = this.operator.size.width;
                height = this.operator.size.height;
            }
Anna.Pavlova's avatar
Anna.Pavlova committed
3079

3080 3081
            ascentSign = this.operator.size.ascent;

3082
            /*var letterX = new CMathText(true);
Anna.Pavlova's avatar
Anna.Pavlova committed
3083
            letterX.add(0x78);
3084
            letterX.Resize(null, oMeasure);
3085
            this.shiftAccent = letterX.size.ascent;*/
3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107
        }
        else
        {
            this.operator.fixSize(stretch);
            var dims = this.operator.getCoordinateGlyph();
            this.coordGlyph = {XX: dims.XX, YY: dims.YY};

            if(this.operator.loc == 0 || this.operator.loc == 1)
            {
                width = dims.Width;
                //width = this.operator.size.width;
                height = this.operator.size.height;
            }
            else
            {
                width = this.operator.size.width;
                height = dims.Height;
                //height = this.operator.size.height;
            }

        }

3108
        var mgCtrPrp = this.Parent.Get_CompiledCtrPrp();
Anna.Pavlova's avatar
Anna.Pavlova committed
3109
        var shCenter = this.Parent.ParaMath.GetShiftCenter(oMeasure, mgCtrPrp);
3110 3111 3112 3113 3114

        if(this.operator.loc == 0 || this.operator.loc  == 1) // horizontal
            ascent = dims.Height/2;
        else // vertical
            ascent = height/2 + shCenter;
3115

3116
        this.size = {width: width, height: height, ascent: ascent, ascentSign : ascentSign};
3117 3118
    }
}
3119
COperator.prototype.setPosition = function(Positions)
3120
{
3121 3122 3123 3124 3125 3126 3127 3128 3129 3130
    // для оператора, это будет просто позиция
    // для сепаратора - массив позиций

    if(this.type == OPER_SEPARATOR)
        this.Positions = Positions;
    else
    {
        this.Positions.length = 0;
        this.Positions[0] = Positions;
    }
3131 3132 3133

    if(this.typeOper == OPERATOR_TEXT)
    {
3134 3135 3136 3137 3138 3139 3140 3141 3142
        /*var ascent = this.size.ascent,
            height = this.size.height;

        var k = ascent/height > 0.1 ? ascent/height : 0.1;

        var x = pos.x,
            y = pos.y + ascent - k*this.operator.size.height;

        this.operator.setPosition({x: x, y: y});*/
Anna.Pavlova's avatar
Anna.Pavlova committed
3143

3144 3145 3146
        var NewPos = new CMathPosition();
        NewPos.x = this.Positions[0].x;

Anna.Pavlova's avatar
Anna.Pavlova committed
3147
        if(this.type == OPER_ACCENT)
3148 3149
            NewPos.y = this.Positions[0].y + this.shiftAccent + this.operator.size.height;
        else
3150
            NewPos.y = this.Positions[0].y;
3151 3152


3153
        /*var operator = this.operator;
3154
        if (!operator.bJDraw)                      // for text
Anna.Pavlova's avatar
Anna.Pavlova committed
3155
        {
3156 3157 3158 3159 3160 3161 3162 3163 3164
            operator.pos.x = NewPos.x + operator.GapLeft;
            operator.pos.y = NewPos.y;

            //this.pos = {x : pos.x + this.GapLeft, y: pos.y};
        }
        else                                    // for symbol only drawing
        {
            operator.pos.x = NewPos.x - operator.rasterOffsetX;
            operator.pos.y = NewPos.y - operator.rasterOffsetY;
3165
        }*/
3166

3167 3168
        this.operator.setPosition(NewPos);
    }
3169
}
3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195
COperator.prototype.old_setPosition = function(pos)
{
    this.pos = pos; // для оператора, это будет просто позиция
    // для сепаратора - массив позиций

    if(this.typeOper == OPERATOR_TEXT)
    {
        /*var ascent = this.size.ascent,
         height = this.size.height;

         var k = ascent/height > 0.1 ? ascent/height : 0.1;

         var x = pos.x,
         y = pos.y + ascent - k*this.operator.size.height;

         this.operator.setPosition({x: x, y: y});*/

        if(this.type == OPER_ACCENT)
        {
            this.operator.setPosition({x: pos.x, y: pos.y + this.shiftAccent + this.operator.size.height});
        }
        else
            this.operator.setPosition(pos);
    }

}
3196 3197 3198 3199
COperator.prototype.IsJustDraw = function()
{
    return true;
}
3200
COperator.prototype.Resize = function(Parent, ParaMath, oMeasure)
3201
{
Anna.Pavlova's avatar
Anna.Pavlova committed
3202
    this.ParaMath = ParaMath;
3203 3204
    this.Parent   = Parent;

3205
    if(this.typeOper !== OPERATOR_EMPTY)
3206
    {
3207
        var bHor = this.operator.loc == 0 || this.operator.loc  == 1;
3208 3209

        if(bHor)
Anna.Pavlova's avatar
Anna.Pavlova committed
3210
            this.fixSize(ParaMath, oMeasure, this.size.width);
3211
        else
Anna.Pavlova's avatar
Anna.Pavlova committed
3212
            this.fixSize(ParaMath, oMeasure, this.size.height);
3213 3214
    }
}
3215
COperator.prototype.relate = function(parent)
3216 3217
{
    this.Parent = parent;
3218
    if(this.typeOper !== OPERATOR_EMPTY)
3219
        this.operator.relate(this);
3220 3221
}
COperator.prototype.Get_CompiledCtrPrp = function()
3222
{
3223
    return this.Parent.Get_CompiledCtrPrp();
3224
}
3225
COperator.prototype.getChr = function()
3226
{
3227
    var chr = null; //если operator не определен, то this.code = null
3228

3229
    if(this.code !== null)
3230 3231 3232
        chr = this.typeOper == this.defaultType ? null : String.fromCharCode(this.code);
	if (this.operator == OPERATOR_EMPTY)
		chr = "";
3233 3234 3235

    return chr;
}
3236 3237
COperator.prototype.IsArrow = function()
{
3238
    return this.operator.IsArrow();
3239
}
3240

3241
function CDelimiter(props)
3242 3243
{	
	this.Id = g_oIdCounter.Get_NewId();
3244 3245
    this.kind = MATH_DELIMITER;

3246 3247 3248
    this.begOper = new COperator (OPER_DELIMITER);
    this.endOper = new COperator (OPER_DELIMITER);
    this.sepOper = new COperator (OPER_SEPARATOR);
3249

3250 3251 3252 3253
    this.Pr =
    {
        begChr:         null,
        begChrType:     null,
3254

3255 3256
        endChr:         null,
        endChrType:     null,
Anna.Pavlova's avatar
Anna.Pavlova committed
3257

3258 3259 3260 3261 3262 3263 3264 3265 3266 3267
        sepChr:         null,
        sepChrType:     null,
        column:         0,

        shp:            DELIMITER_SHAPE_CENTERED,
        grow:           true
    };

    //this.shape = DELIMITER_SHAPE_CENTERED;
    //this.grow = true;
3268

Anna.Pavlova's avatar
Anna.Pavlova committed
3269

3270 3271 3272
    ////  special for "read"  ////
    this.column = 0;

3273
    CMathBase.call(this);
3274

3275 3276
    if(props !== null && typeof(props) !== "undefined")
        this.init(props);
3277

3278
	g_oTableId.Add( this, this.Id );
3279
}
3280
extend(CDelimiter, CMathBase);
Anna.Pavlova's avatar
Anna.Pavlova committed
3281
CDelimiter.prototype.init = function(props)
3282 3283 3284 3285 3286
{
    this.setProperties(props);
    this.fillContent();
}
CDelimiter.prototype.setProperties = function(props)
Anna.Pavlova's avatar
Anna.Pavlova committed
3287
{
3288
    if(props.grow == true || props.grow == 1)
3289
        this.Pr.grow = true;
3290
    else if(props.grow == false || props.grow == 0)
3291
        this.Pr.grow = false;
3292

3293 3294
    this.Pr.begChr     = props.begChr;
    this.Pr.begChrType = props.begChrType;
3295

3296 3297
    this.Pr.endChr     = props.endChr;
    this.Pr.endChrType = props.endChrType;
3298

3299 3300
    this.Pr.sepChr     = props.sepChr;
    this.Pr.sepChrType = props.sepChrType;
3301

3302 3303 3304 3305
    if(props.column !== null || typeof(props.column) !== "undefined")
        this.Pr.column = props.column;
    else
        this.Pr.column = 1;
Anna.Pavlova's avatar
Anna.Pavlova committed
3306

3307 3308
    if(props.shp == DELIMITER_SHAPE_MATH || props.shp == DELIMITER_SHAPE_CENTERED)
        this.Pr.shp = props.shp;
Anna.Pavlova's avatar
Anna.Pavlova committed
3309

3310 3311
    if(props.ctrPrp !== null && typeof(props.ctrPrp) !== "undefined")
        this.setCtrPrp(props.ctrPrp);
3312 3313 3314 3315
}
CDelimiter.prototype.fillContent = function()
{
    this.setDimension(1, this.Pr.column);
Anna.Pavlova's avatar
Anna.Pavlova committed
3316 3317
    this.setContent();
}
3318 3319 3320 3321 3322 3323 3324 3325
CDelimiter.prototype.fillMathComposition = function(props, contents /*array*/)
{
    this.setProperties(props);
    this.fillContent();

    for(var j = 0; j < this.nCol; j++)
        this.elements[0][j] = contents[j];
}
3326
CDelimiter.prototype.old_recalculateSize = function()
Anna.Pavlova's avatar
Anna.Pavlova committed
3327 3328 3329 3330
{
    var height = 0,
        width = 0, center = 0;

Anna.Pavlova's avatar
Anna.Pavlova committed
3331 3332 3333
    var ascent = 0,
        descent = 0;

3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344
    // временно

    var FontSize = this.getCtrPrp().FontSize;
    var Height = 0.4*FontSize; //  g_oTextMeasurer.GetHeight()

    var plH = 0.275*FontSize, // плейсхолдер
        H2 = 0.08*FontSize; // временно baseLine

    // временно
    var div = 0;

Anna.Pavlova's avatar
Anna.Pavlova committed
3345 3346 3347 3348 3349 3350 3351
    if(this.shape == DELIMITER_SHAPE_CENTERED)
    {
        for(var j = 0; j < this.nCol; j++)
        {
            var content = this.elements[0][j].size;
            width += content.width;
            ascent = content.center > ascent ? content.center : ascent;
Anna.Pavlova's avatar
Anna.Pavlova committed
3352
            descent = content.height - content.center > descent ? content.height - content.center: descent;
Anna.Pavlova's avatar
Anna.Pavlova committed
3353
        }
Anna.Pavlova's avatar
Anna.Pavlova committed
3354

Alexander.Trofimov's avatar
Alexander.Trofimov committed
3355
        var maxH = ascent > descent ? ascent : descent;
Anna.Pavlova's avatar
Anna.Pavlova committed
3356

3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377
        // для случая, когда в контенте степень и пр. элементы где нужно учитовать baseLine
        if(descent < plH || ascent < plH)
        {
            if(maxH < plH)
            {
                height = ascent + descent;
                center = ascent;
            }
            else
            {
                div = ascent - plH;

                height = ascent + descent + div;
                center = ascent;
            }
        }
        else
        {
            height = 2*maxH;
            center = height/2;
        }
Anna.Pavlova's avatar
Anna.Pavlova committed
3378 3379 3380 3381 3382 3383 3384
    }
    else
    {
        for(var j = 0; j < this.nCol; j++)
        {
            var content = this.elements[0][j].size;
            width += content.width;
Anna.Pavlova's avatar
Anna.Pavlova committed
3385 3386
            ascent = content.center > ascent ? content.center : ascent;
            descent = content.height - content.center > descent ? content.height - content.center: descent;
Anna.Pavlova's avatar
Anna.Pavlova committed
3387
        }
Anna.Pavlova's avatar
Anna.Pavlova committed
3388 3389 3390

        height = ascent + descent;
        center = ascent;
Anna.Pavlova's avatar
Anna.Pavlova committed
3391 3392
    }

Anna.Pavlova's avatar
Anna.Pavlova committed
3393 3394
    this.begOper.fixSize(height);
    width += this.begOper.size.width;
Anna.Pavlova's avatar
Anna.Pavlova committed
3395 3396 3397

    if(height < this.begOper.size.height)
    {
3398
        center = this.begOper.size.height - H2;
Anna.Pavlova's avatar
Anna.Pavlova committed
3399
        height = this.begOper.size.height;
3400 3401
        //center = this.begOper.size.center;

Anna.Pavlova's avatar
Anna.Pavlova committed
3402
    }
Anna.Pavlova's avatar
Anna.Pavlova committed
3403 3404 3405

    this.endOper.fixSize(height);
    width += this.endOper.size.width;
Anna.Pavlova's avatar
Anna.Pavlova committed
3406 3407
    if(height < this.endOper.size.height)
    {
3408 3409
        //center += (height - this.endOper.size.height)/2;
        center = this.endOper.size.height - H2;
Anna.Pavlova's avatar
Anna.Pavlova committed
3410
        height = this.endOper.size.height;
3411
        //center = this.endOper.size.center;
Anna.Pavlova's avatar
Anna.Pavlova committed
3412
    }
Anna.Pavlova's avatar
Anna.Pavlova committed
3413 3414 3415

    this.sepOper.fixSize(height);
    width += (this.nCol - 1)*this.sepOper.size.width;
Anna.Pavlova's avatar
Anna.Pavlova committed
3416 3417
    if(height < this.endOper.size.height)
    {
3418
        //center += (height - this.sepOper.size.height)/2;
Anna.Pavlova's avatar
Anna.Pavlova committed
3419
        height = this.sepOper.size.height;
3420
        //center = this.sepOper.size.center;
Anna.Pavlova's avatar
Anna.Pavlova committed
3421
    }
Anna.Pavlova's avatar
Anna.Pavlova committed
3422 3423


3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465
    /*if(this.begOper !== -1)
     {
     this.begOper.fixSize(height);
     width += this.begOper.size.width;

     if(height < this.begOper.size.height)
     {
     center = this.begOper.size.center;
     height = this.begOper.size.height;

     }

     //height = (height < this.begOper.size.height) ? this.begOper.size.height : height;
     //center = (center < this.begOper.size.center) ? this.begOper.size.center : center;
     }
     if(this.endOper !== -1)
     {
     this.endOper.fixSize(height);
     width += this.endOper.size.width;

     //height = (height < this.endOper.size.height) ? this.endOper.size.height : height;
     //center = (center < this.endOper.size.center) ? this.endOper.size.center : center;

     if(height < this.endOper.size.height)
     {
     center = this.endOper.size.center;
     height = this.endOper.size.height;

     }
     }
     if(this.sepOper !== -1)
     {
     this.sepOper.fixSize(height);
     width += (this.nCol - 1)*this.sepOper.size.width;

     height = (height < this.sepOper.size.height) ? this.sepOper.size.height : height;
     center = (center < this.sepOper.size.center) ? this.sepOper.size.center : center;
     }*/

    this.size = {width: width, height: height, center: center};

}
3466
CDelimiter.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize)
3467
{
3468
    this.Parent = Parent;
Anna.Pavlova's avatar
Anna.Pavlova committed
3469 3470
    this.ParaMath = ParaMath;

3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482
    if(this.RecalcInfo.bProps == true)
    {
        var begPrp =
        {
            chr:    this.Pr.begChr,
            type:   this.Pr.begChrType,
            loc:    LOCATION_LEFT
        };
        var begDefaultPrp =
        {
            type:  PARENTHESIS_LEFT
        };
3483
        this.begOper.mergeProperties(begPrp, begDefaultPrp);
3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496
        this.begOper.relate(this);

        var endPrp =
        {
            chr:    this.Pr.endChr,
            type:   this.Pr.endChrType,
            loc:    LOCATION_RIGHT
        };
        var endDefaultPrp =
        {
            type:  PARENTHESIS_RIGHT
        };

3497
        this.endOper.mergeProperties(endPrp, endDefaultPrp);
3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513
        this.endOper.relate(this);

        var sepPrp =
        {
            chr:    this.Pr.sepChr,
            type:   this.Pr.sepChrType,
            loc:    LOCATION_SEP
        };
        var sepDefaultPrp =
        {
            type:  DELIMITER_LINE
        };

        if(this.nCol == 1 )
            sepPrp.type = OPERATOR_EMPTY;

3514
        this.sepOper.mergeProperties(sepPrp, sepDefaultPrp);
3515 3516 3517 3518 3519 3520
        this.sepOper.relate(this);


        this.RecalcInfo.bProps = false;
    }

3521 3522 3523 3524 3525 3526 3527 3528
    // размеры аргумента
    var heightG = 0, widthG = 0,
        ascentG = 0, descentG = 0;

    // Аргумент

    for(var j = 0; j < this.nCol; j++)
    {
3529
        this.elements[0][j].Resize(oMeasure, this, ParaMath, RPI, ArgSize);
3530 3531 3532 3533 3534 3535 3536 3537
        var content = this.elements[0][j].size;
        widthG += content.width;
        ascentG = content.ascent > ascentG ? content.ascent : ascentG;
        descentG = content.height - content.ascent > descentG ? content.height - content.ascent: descentG;
    }

    heightG = ascentG + descentG;

3538
    var mgCtrPrp = this.Get_CompiledCtrPrp();
Anna.Pavlova's avatar
Anna.Pavlova committed
3539
    var shCenter = this.ParaMath.GetShiftCenter(oMeasure, mgCtrPrp);
3540 3541
    var maxAD = ascentG - shCenter  > descentG + shCenter ? ascentG - shCenter: descentG + shCenter;

3542
    var plH = 9.877777777777776 * mgCtrPrp.FontSize/36;
3543 3544
    //var bTextContent = ascentG < plH || descentG < plH ; // для текста операторы в случае центрирования не увеличиваем
    var bTextContent = ascentG < plH && heightG < 1.5*plH; // для текста операторы в случае центрирования не увеличиваем
3545

3546
    var bCentered = this.Pr.shp == DELIMITER_SHAPE_CENTERED,
3547 3548
        b2Max = bCentered && (2*maxAD - heightG > 0.001);

3549 3550

    var heightStretch = b2Max && !bTextContent ? 2*maxAD : ascentG + descentG;
3551

Anna.Pavlova's avatar
Anna.Pavlova committed
3552 3553 3554
    this.begOper.fixSize(ParaMath, oMeasure, heightStretch);
    this.endOper.fixSize(ParaMath, oMeasure, heightStretch);
    this.sepOper.fixSize(ParaMath, oMeasure, heightStretch);
3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571

    // Общая ширина
    var width = widthG + this.begOper.size.width + this.endOper.size.width + (this.nCol - 1)*this.sepOper.size.width;


    var maxDimOper;
    if(this.begOper.size.height > this.endOper.size.height && this.begOper.size.height > this.sepOper.size.height)
        maxDimOper = this.begOper.size;
    else if(this.endOper.size.height > this.sepOper.size.height)
        maxDimOper = this.endOper.size;
    else
        maxDimOper = this.sepOper.size;

    // Общие высота и ascent
    var height, ascent, descent;


3572
    if(this.Pr.shp == DELIMITER_SHAPE_CENTERED)
3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586
    {
        var deltaHeight = heightG - maxDimOper.height;
        if(deltaHeight < 0)
            deltaHeight = -deltaHeight;

        var deltaMaxAD = maxAD - maxDimOper.height/ 2;
        if(deltaMaxAD < 0)
            deltaMaxAD = -deltaMaxAD;

        var deltaMinAD = (heightG - maxAD)  - maxDimOper.height/2;

            var bLHeight = deltaHeight < 0.001,
                bLMaxAD = deltaMaxAD > 0.001,
                bLMinAD = deltaMinAD > 0.001,
3587
                bLText = deltaMinAD < - 0.001;
3588 3589 3590

            var bEqualOper = bLHeight,
                bMiddleOper = bLMaxAD && !bLMinAD,
3591 3592
                bLittleOper = bLMinAD,
                bText = bLText;
3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603

            if(bEqualOper)
            {
                height = 2*maxAD;
                ascent = maxAD + shCenter;
            }
            else if(bMiddleOper)
            {
                height = maxDimOper.height/2 + maxAD;
                ascent = ascentG > maxDimOper.ascent? ascentG : maxDimOper.ascent;
            }
3604
            else if(bText)
3605
            {
3606 3607
                //ascent = maxDimOper.ascent;
                ascent = ascentG > maxDimOper.ascent ? ascentG : maxDimOper.ascent;
3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624
                height = maxDimOper.height;
            }
            else
            {
                ascent = ascentG;
                height = ascentG + descentG;
            }

    }
    else
    {
        ascent = ascentG;
        height = ascentG + descentG;
    }

    this.size = {width: width, height: height, ascent: ascent};

Anna.Pavlova's avatar
Anna.Pavlova committed
3625
}
3626
CDelimiter.prototype.old_alignOperator = function(height)
Anna.Pavlova's avatar
Anna.Pavlova committed
3627 3628 3629
{
    var align = 0;

Anna.Pavlova's avatar
Anna.Pavlova committed
3630
    if(this.size.height > height)
Anna.Pavlova's avatar
Anna.Pavlova committed
3631 3632
    {
        if(this.shape == DELIMITER_SHAPE_CENTERED)
Anna.Pavlova's avatar
Anna.Pavlova committed
3633
            align = this.size.center - height/2;
Anna.Pavlova's avatar
Anna.Pavlova committed
3634 3635 3636
        else if(this.shape == DELIMITER_SHAPE_MATH)
        {
            var ascent = this.size.center,
Anna.Pavlova's avatar
Anna.Pavlova committed
3637
                descent = this.size.height - height/2;
Anna.Pavlova's avatar
Anna.Pavlova committed
3638 3639 3640 3641 3642 3643 3644 3645

            var k = ascent/descent;

            if(k < 0.2)
                k = 0.2;
            else if(k > 0.8)
                k = 0.8;

Anna.Pavlova's avatar
Anna.Pavlova committed
3646
            align = this.size.center - height*k;
Anna.Pavlova's avatar
Anna.Pavlova committed
3647 3648 3649 3650 3651
        }
    }

    return align;
}
3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662
CDelimiter.prototype.alignOperator = function(operator) // в качестве аргумента передаем высоту оператора
{
    var align = 0;
    var dimOper = operator.size;

    var bAlign = this.size.height - dimOper.height > 0.001;

    // ascent идет по бейзлайну, соответствено и сравнивать надо относительно бейзлайна (или центра)

    if(bAlign)
    {
3663
        if(this.Pr.shp == DELIMITER_SHAPE_CENTERED)
3664 3665 3666 3667
        {
            align = this.size.ascent > dimOper.ascent ? this.size.ascent - dimOper.ascent : 0;

        }
3668
        else if(this.Pr.shp === DELIMITER_SHAPE_MATH)
3669 3670 3671 3672 3673 3674 3675 3676 3677
        {
            var shCenter = dimOper.ascent - dimOper.height/2; // так получаем shCenter, иначе соотношение м/ду ascent и descent будет неверное


            var k = 2*(this.size.ascent - shCenter)/this.size.height ;

            // k/(k + 1)
            // 0.2/(0.2 + 1) = 1/6

Anna.Pavlova's avatar
Anna.Pavlova committed
3678
            k = k > 1/4 ? k : 1/4;
3679 3680 3681 3682 3683 3684
            align = this.size.ascent - shCenter - k*(dimOper.ascent - shCenter);
        }
    }

    return align;
}
Anna.Pavlova's avatar
Anna.Pavlova committed
3685
CDelimiter.prototype.setPosition = function(position)
Anna.Pavlova's avatar
Anna.Pavlova committed
3686
{
3687 3688
    this.pos.x = position.x;
    this.pos.y = position.y - this.size.ascent;
Anna.Pavlova's avatar
Anna.Pavlova committed
3689

3690
    var x = this.pos.x + this.GapLeft,
Anna.Pavlova's avatar
Anna.Pavlova committed
3691
        y = this.pos.y;
Anna.Pavlova's avatar
Anna.Pavlova committed
3692

3693 3694 3695 3696 3697 3698
    var PosBegOper = new CMathPosition();
    PosBegOper.x = x;
    PosBegOper.y = y + this.alignOperator(this.begOper);


    this.begOper.setPosition(PosBegOper);
Anna.Pavlova's avatar
Anna.Pavlova committed
3699
    x += this.begOper.size.width;
Anna.Pavlova's avatar
Anna.Pavlova committed
3700

Anna.Pavlova's avatar
Anna.Pavlova committed
3701
    var content = this.elements[0][0];
Anna.Pavlova's avatar
Anna.Pavlova committed
3702

3703 3704
    var PosContent = new CMathPosition();
    PosContent.x = x;
3705
    PosContent.y = y + this.align_2(content);
Anna.Pavlova's avatar
Anna.Pavlova committed
3706
    x += content.size.width;
Anna.Pavlova's avatar
Anna.Pavlova committed
3707

3708 3709
    content.setPosition(PosContent); // CMathContent

3710
    var Positions = [];
3711

Anna.Pavlova's avatar
Anna.Pavlova committed
3712
    for(var j = 1 ; j < this.nCol; j++)
Anna.Pavlova's avatar
Anna.Pavlova committed
3713
    {
3714 3715 3716 3717 3718
        var PosSep = new CMathPosition();
        PosSep.x = x;
        PosSep.y = y + this.alignOperator(this.sepOper);

        Positions.push(PosSep);
Anna.Pavlova's avatar
Anna.Pavlova committed
3719
        x += this.sepOper.size.width;
Anna.Pavlova's avatar
Anna.Pavlova committed
3720

Anna.Pavlova's avatar
Anna.Pavlova committed
3721
        content = this.elements[0][j];
3722 3723 3724

        var NewPosContent = new CMathPosition();
        NewPosContent.x = x;
3725
        NewPosContent.y = y + this.align_2(content);
3726 3727

        content.setPosition(NewPosContent);
Anna.Pavlova's avatar
Anna.Pavlova committed
3728
        x += content.size.width;
Anna.Pavlova's avatar
Anna.Pavlova committed
3729 3730
    }

Anna.Pavlova's avatar
Anna.Pavlova committed
3731 3732
    this.sepOper.setPosition(Positions);

3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753
    var PosEndOper = new CMathPosition();
    PosEndOper.x = x;
    PosEndOper.y = y + this.alignOperator(this.endOper);

    this.endOper.setPosition(PosEndOper);

    /*this.pos.x = position.x;
    this.pos.y = position.y - this.size.ascent;

    var x = this.pos.x + this.GapLeft,
        y = this.pos.y;

    var content = this.elements[0][0];

    var PosContent = new CMathPosition();
    PosContent.x = x;
    PosContent.y = y + this.align(content);
    x += content.size.width;

    content.setPosition(PosContent); // CMathContent*/

3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782
}
CDelimiter.prototype.Get_ParaContentPosByXY = function(SearchPos, Depth, _CurLine, _CurRange, StepEnd)
{
    var begWidth = this.begOper.size.width,
        sepWidth = this.sepOper.size.width,
        endWidth = this.endOper.size.width;

    SearchPos.Pos.Update(0, Depth);

    SearchPos.CurX += begWidth + this.GapLeft;

    var result;

    for(var j = 0; j < this.nCol; j++)
    {
        if(this.elements[0][j].Get_ParaContentPosByXY(SearchPos, Depth+2, _CurLine, _CurRange, StepEnd))
        {
            SearchPos.Pos.Update(j, Depth+1);
            result = true;
        }

        if(j < this.nCol - 1)
            SearchPos.CurX += sepWidth;
    }

    SearchPos.CurX += endWidth + this.GapRight;

    return result;

Anna.Pavlova's avatar
Anna.Pavlova committed
3783
}
3784
CDelimiter.prototype.draw = function(x, y, pGraphics)
Anna.Pavlova's avatar
Anna.Pavlova committed
3785
{
3786 3787 3788
    this.begOper.draw(x, y, pGraphics);
    this.sepOper.draw(x, y, pGraphics);
    this.endOper.draw(x, y, pGraphics);
Anna.Pavlova's avatar
Anna.Pavlova committed
3789

Anna.Pavlova's avatar
Anna.Pavlova committed
3790
    for(var j = 0; j < this.nCol; j++)
3791
        this.elements[0][j].draw(x, y,pGraphics);
Anna.Pavlova's avatar
Anna.Pavlova committed
3792
}
3793
CDelimiter.prototype.align_2 = function(element)
Anna.Pavlova's avatar
Anna.Pavlova committed
3794 3795 3796
{
    var align = 0;
    if(!element.IsJustDraw())
3797
        align = this.size.ascent - element.size.ascent;
Anna.Pavlova's avatar
Anna.Pavlova committed
3798 3799 3800
    else
        align = (this.size.height - element.size.height)/2;

3801

Anna.Pavlova's avatar
Anna.Pavlova committed
3802 3803
    return align;
}
Anna.Pavlova's avatar
Anna.Pavlova committed
3804 3805 3806 3807 3808 3809 3810 3811
CDelimiter.prototype.getBase = function(numb)
{
    if(numb !== numb - 0)
        numb = 0;

    return this.elements[0][numb];

}
3812
CDelimiter.prototype.getPropsForWrite = function()
Anna.Pavlova's avatar
Anna.Pavlova committed
3813
{
3814
    /*var props =
3815 3816 3817 3818 3819 3820 3821 3822
    {
        grow:       this.Pr.grow,
        column:     this.nCol,
        shp:        this.Pr.shp,
        begChr:     this.begOper.getChr(), // default: PARENTHESIS_LEFT
        endChr:     this.endOper.getChr(), // default: PARENTHESIS_RIGHT
        sepChr:     this.sepOper.getChr()  // default: DELIMITER_LINE
    };
3823

3824 3825 3826
    return props;*/

    return this.Pr;
Anna.Pavlova's avatar
Anna.Pavlova committed
3827
}
3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840
CDelimiter.prototype.Save_Changes = function(Data, Writer)
{
	Writer.WriteLong( historyitem_type_delimiter );
}
CDelimiter.prototype.Load_Changes = function(Reader)
{
}
CDelimiter.prototype.Refresh_RecalcData = function(Data)
{
}
CDelimiter.prototype.Write_ToBinary2 = function( Writer )
{
	Writer.WriteLong( historyitem_type_delimiter );
3841
	Writer.WriteLong(this.Pr.column);	
3842
	
3843
	for (var i=0; i<this.Pr.column; i++)
3844
		Writer.WriteString2( this.getBase(i).Id );
3845
	
3846
	this.CtrPrp.Write_ToBinary(Writer);
3847 3848 3849 3850
	
	var StartPos = Writer.GetCurPosition();
    Writer.Skip(4);
    var Flags = 0;
3851
	if ( undefined != this.Pr.begChr )
3852
    {
3853
		Writer.WriteLong(this.Pr.begChr);	
3854 3855
		Flags |= 1;
	}
3856
	if ( undefined != this.Pr.endChr )
3857
    {
3858
		Writer.WriteLong(this.Pr.endChr);	
3859 3860
		Flags |= 2;
	}
3861
	if ( undefined != this.Pr.grow )
3862
    {
3863
		Writer.WriteLong(this.Pr.grow);	
3864 3865
		Flags |= 4;
	}
3866
	if ( undefined != this.Pr.sepChr )
3867
    {
3868
		Writer.WriteLong(this.Pr.sepChr);	
3869 3870
		Flags |= 8;
	}
3871
	if ( undefined != this.Pr.shp )
3872
    {
3873
		Writer.WriteLong(this.Pr.shp);	
3874 3875 3876 3877 3878 3879
		Flags |= 16;
	}
	var EndPos = Writer.GetCurPosition();
    Writer.Seek( StartPos );
    Writer.WriteLong( Flags );
    Writer.Seek( EndPos );
3880 3881 3882
}
CDelimiter.prototype.Read_FromBinary2 = function( Reader )
{
3883 3884 3885 3886 3887 3888
	var props = {ctrPrp: new CTextPr()};
	var arrElems = [];
	props.column = Reader.GetLong();
	
	for (var i=0; i<props.column; i++)
		arrElems.push(g_oTableId.Get_ById( Reader.GetString2()));
3889

3890
	props.ctrPrp.Read_FromBinary(Reader);
3891 3892 3893
	
	var Flags = Reader.GetLong();
	if ( Flags & 1 )
3894
		props.begChr = Reader.GetLong();
3895
	if ( Flags & 2 )
3896
		props.endChr = Reader.GetLong();
3897
	if ( Flags & 4 )
3898
		props.grow = Reader.GetBool();
3899
	if ( Flags & 8 )
3900
		props.sepChr = Reader.GetLong();
3901
	if ( Flags & 16 )
3902 3903 3904
		props.shp = Reader.GetLong();
		
	this.fillMathComposition (props, arrElems);
3905 3906 3907 3908 3909
}
CDelimiter.prototype.Get_Id = function()
{
	return this.Id;
}
3910 3911 3912

function CCharacter()
{
3913
    this.operator = new COperator(OPER_GROUP_CHAR);
3914

3915
    CMathBase.call(this);
3916
}
3917
extend(CCharacter, CMathBase);
3918
CCharacter.prototype.setCharacter = function(props, defaultProps)
3919
{
3920
    this.operator.mergeProperties(props, defaultProps);
3921
    this.operator.relate(this);
3922

3923 3924
    //this.setDimension(1, 1);
    //this.setContent();
3925
}
3926
CCharacter.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize)
3927
{
3928
    this.Parent = Parent;
Anna.Pavlova's avatar
Anna.Pavlova committed
3929 3930
    this.ParaMath = ParaMath;

3931
    /*if(this.RecalcInfo.bCtrPrp == true)
3932 3933 3934
    {
        this.Set_CompiledCtrPrp();
        this.RecalcInfo.bCtrPrp = false;
3935
    }*/
3936

3937
    var base = this.elements[0][0];
3938
    base.Resize(oMeasure, this, ParaMath, RPI, ArgSize);
3939

Anna.Pavlova's avatar
Anna.Pavlova committed
3940
    this.operator.fixSize(ParaMath, oMeasure, base.size.width);
3941

3942 3943
    var ctrPrp = this.Get_CompiledCtrPrp();
    oMeasure.SetFont(ctrPrp);
Anna.Pavlova's avatar
Anna.Pavlova committed
3944

3945
    var width  = base.size.width > this.operator.size.width ? base.size.width : this.operator.size.width,
3946
        height = base.size.height + this.operator.size.height,
3947
        ascent = this.getAscent(oMeasure);
3948

3949

3950
    this.size = {height: height, width: width, ascent: ascent};
3951 3952 3953
}
CCharacter.prototype.setPosition = function(pos)
{
3954 3955
    this.pos.x = pos.x;
    this.pos.y = pos.y - this.size.ascent;
3956

3957 3958
    var alignOp = (this.size.width - this.operator.size.width)/2,
        alignCnt = (this.size.width - this.elements[0][0].size.width)/2;
3959 3960 3961

    var PosOper = new CMathPosition(),
        PosBase = new CMathPosition();
3962

3963
    if(this.Pr.pos === LOCATION_TOP)
3964
    {
3965 3966
        PosOper.x = this.pos.x + this.GapLeft + alignOp;
        PosOper.y = this.pos.y;
3967

3968
        this.operator.setPosition(PosOper);
3969

3970 3971
        PosBase.x = this.pos.x + this.GapLeft + alignCnt;
        PosBase.y = this.pos.y + this.operator.size.height;
3972

3973
        this.elements[0][0].setPosition(PosBase);
3974
    }
3975
    else if(this.Pr.pos === LOCATION_BOT)
3976
    {
3977 3978
        PosBase.x = this.pos.x + this.GapLeft + alignCnt;
        PosBase.y = this.pos.y;
3979

3980
        this.elements[0][0].setPosition(PosBase);
3981

3982 3983
        PosOper.x = this.pos.x + this.GapLeft + alignOp;
        PosOper.y = this.pos.y + this.elements[0][0].size.height;
3984

3985
        this.operator.setPosition(PosOper);
3986 3987
    }
}
3988
CCharacter.prototype.Get_ParaContentPosByXY = function(SearchPos, Depth, _CurLine, _CurRange, StepEnd)
3989
{
3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001
    var align = (this.size.width - this.elements[0][0].size.width)/2;

    SearchPos.Pos.Update(0, Depth);
    SearchPos.Pos.Update(0, Depth+1);

    SearchPos.CurX += this.GapLeft + align;

    var result = this.elements[0][0].Get_ParaContentPosByXY(SearchPos, Depth+2, _CurLine, _CurRange, StepEnd);

    SearchPos.CurX += this.GapRight + align;

    return result;
4002
}
4003
CCharacter.prototype.draw = function(x, y, pGraphics)
4004
{
4005
    this.elements[0][0].draw(x, y, pGraphics);
4006

4007
    var mgCtrPrp = this.Get_CompiledCtrPrp();
4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020
    var FontSize = mgCtrPrp.FontSize,
        FontFamily = {Name: "Cambria Math", Index: -1};

    var obj = {FontSize: FontSize, FontFamily: FontFamily};

    var accFont = new CTextPr();
    accFont.Set_FromObject(obj);


    pGraphics.SetFont(accFont);
    pGraphics.p_color(0,0,0, 255);
    pGraphics.b_color1(0,0,0, 255);

4021
    this.operator.draw(x, y, pGraphics);
4022

4023
}
4024 4025 4026 4027
CCharacter.prototype.getBase = function()
{
    return this.elements[0][0];
}
4028 4029


4030
function CGroupCharacter(props)
4031
{
4032
	this.Id   = g_oIdCounter.Get_NewId();
4033 4034
    this.kind = MATH_GROUP_CHARACTER;

4035 4036 4037 4038 4039 4040 4041 4042 4043 4044
    this.Pr =
    {
        chr:      null,
        chrType:  null,
        vertJc:   VJUST_TOP,
        pos:      LOCATION_BOT
    };

    //this.vertJust = VJUST_TOP;
    //this.loc = LOCATION_BOT;
4045 4046

    CCharacter.call(this);
4047

4048 4049 4050 4051 4052
    if(props !== null && typeof(props)!== "undefined")
        this.init(props);

    /// вызов этой функции обязательно в конце
    g_oTableId.Add( this, this.Id );
4053 4054 4055 4056
}
extend(CGroupCharacter, CCharacter);
CGroupCharacter.prototype.init = function(props)
{
4057

4058 4059
    this.setProperties(props);
    this.fillContent();
4060

4061
    /*var operDefaultPrp =
4062 4063 4064 4065 4066 4067 4068
    {
        type:   BRACKET_CURLY_BOTTOM,
        loc:    LOCATION_BOT
    };

    var operProps =
    {
4069 4070 4071
        type:   this.Pr.chrType,
        chr:    this.Pr.chr,
        loc:    this.Pr.pos
4072 4073
    };

4074
    this.setCharacter(operProps, operDefaultPrp);
4075

4076
    this.Pr.chrType = this.operator.typeOper;
4077
    this.Pr.chr     = String.fromCharCode(this.operator.code);*/
4078

4079
}
4080
CGroupCharacter.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize)
4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101
{
    if(this.RecalcInfo.bProps == true)
    {
        var operDefaultPrp =
        {
            type:   BRACKET_CURLY_BOTTOM,
            loc:    LOCATION_BOT
        };

        var operProps =
        {
            type:   this.Pr.chrType,
            chr:    this.Pr.chr,
            loc:    this.Pr.pos
        };

        this.setCharacter(operProps, operDefaultPrp);

        this.RecalcInfo.bProps = false;
    }

4102
    CGroupCharacter.superclass.Resize.call(this, oMeasure, Parent, ParaMath, RPI, ArgSize);
4103
}
4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128
CGroupCharacter.prototype.setProperties = function(props)
{
    if(props.vertJc === VJUST_TOP || props.vertJc === VJUST_BOT)
        this.Pr.vertJc = props.vertJc;

    if(props.pos === LOCATION_TOP || props.pos === LOCATION_BOT)
        this.Pr.pos = props.pos;

    this.Pr.chr     = props.chr;
    this.Pr.chrType = props.chrType;

    this.setCtrPrp(props.ctrPrp);
}
CGroupCharacter.prototype.fillContent = function()
{
    this.setDimension(1, 1);
    this.setContent();
}
CGroupCharacter.prototype.fillMathComposition = function(props, contents /*array*/)
{
    this.setProperties(props);
    this.fillContent();

    this.elements[0][0] = contents[0];
}
4129
CGroupCharacter.prototype.getAscent = function(oMeasure)
4130
{
4131 4132
    var ascent;

4133
    //var shCent = DIV_CENT*this.getCtrPrp().FontSize;
4134

4135
    var ctrPrp = this.Get_CompiledCtrPrp();
Anna.Pavlova's avatar
Anna.Pavlova committed
4136
    var shCent = this.ParaMath.GetShiftCenter(oMeasure, ctrPrp);
4137

4138
    if(this.Pr.vertJc === VJUST_TOP && this.Pr.pos === LOCATION_TOP)
4139
        ascent =  this.operator.size.ascent + shCent;
4140
    else if(this.Pr.vertJc === VJUST_BOT && this.Pr.pos === LOCATION_TOP )
4141
        ascent = this.operator.size.height + this.elements[0][0].size.ascent;
4142
    else if(this.Pr.vertJc === VJUST_TOP && this.Pr.pos === LOCATION_BOT )
4143
        ascent = this.elements[0][0].size.ascent;
4144
    else if(this.Pr.vertJc === VJUST_BOT && this.Pr.pos === LOCATION_BOT )
4145 4146
        ascent = this.elements[0][0].size.height + shCent + this.operator.size.height - this.operator.size.ascent;
        //ascent = this.operator.size.height/2 + shCent + this.elements[0][0].size.height;
4147

4148
    return ascent;
4149
}
4150
CGroupCharacter.prototype.old_getGlyph = function(code, type)
4151
{
Alexander.Trofimov's avatar
Alexander.Trofimov committed
4152
    var operator, props, accent;
4153 4154 4155

    if(code === 0x23DE || type == BRACKET_CURLY_TOP)
    {
4156
        operator = new COperatorBracket();
4157 4158 4159 4160 4161
        props =
        {
            location:   this.loc,
            turn:       TURN_0
        };
4162
        operator.init(props);
4163 4164 4165
    }
    else if(code === 0x23DF || type === BRACKET_CURLY_BOTTOM  )
    {
4166
        operator = new COperatorBracket();
4167 4168 4169 4170 4171
        props =
        {
            location:   this.loc,
            turn:       TURN_MIRROR_0
        };
4172
        operator.init(props);
4173 4174 4175
    }
    else if(code === 0x2190 || type === ARROW_LEFT)
    {
4176
        operator = new CSingleArrow();
4177 4178 4179 4180 4181 4182

        props =
        {
            location:   this.loc,
            turn:       TURN_0
        };
4183
        operator.init(props);
4184 4185 4186
    }
    else if(code === 0x2192 || type === ARROW_RIGHT)
    {
4187
        operator = new CSingleArrow();
4188 4189 4190 4191 4192
        props =
        {
            location:   this.loc,
            turn:       TURN_180
        };
4193
        operator.init(props);
4194 4195 4196
    }
    else if(code === 0x2194 || type === ARROW_LR)
    {
4197
        operator = new CLeftRightArrow();
4198 4199 4200 4201 4202
        props =
        {
            location:   this.loc,
            turn:       TURN_0
        };
4203
        operator.init(props);
4204 4205 4206
    }
    else if(code === 0x21D0 || type === DOUBLE_LEFT_ARROW)
    {
4207
        operator = new CDoubleArrow();
4208 4209 4210 4211 4212
        props =
        {
            location:   this.loc,
            turn:       TURN_0
        };
4213
        operator.init(props);
4214 4215 4216
    }
    else if(code === 0x21D2 || type === DOUBLE_RIGHT_ARROW)
    {
4217
        operator = new CDoubleArrow();
4218 4219 4220 4221 4222
        props =
        {
            location:   this.loc,
            turn:       TURN_180
        };
4223
        operator.init(props);
4224 4225 4226
    }
    else if(code === 0x21D4 || type === DOUBLE_ARROW_LR)
    {
4227
        operator = new CLR_DoubleArrow();
4228 4229 4230 4231 4232
        props =
        {
            location:   this.loc,
            turn:       TURN_0
        };
4233
        operator.init(props);
4234 4235 4236 4237
    }
    /////    accents     /////
    else if(code === 0x20D6 || type === ACCENT_ARROW_LEFT)
    {
4238
        operator = new CCombiningArrow();
4239 4240 4241 4242 4243
        props =
        {
            location:   LOCATION_TOP,
            turn:       TURN_0
        };
4244 4245
        operator.init(props);
        accent = new COperator(operator);
4246 4247 4248
    }
    else if(code === 0x20D7 || type === ACCENT_ARROW_RIGHT)
    {
4249
        operator = new CCombiningArrow();
4250 4251 4252 4253 4254
        props =
        {
            location:   LOCATION_TOP,
            turn:       TURN_180
        };
4255 4256
        operator.init(props);
        accent = new COperator(operator);
4257 4258 4259
    }
    else if(code === 0x20E1 || type === ACCENT_ARROW_LR)
    {
4260
        operator = new CCombining_LR_Arrow();
4261 4262 4263 4264 4265
        props =
        {
            location:   LOCATION_TOP,
            turn:       TURN_0
        };
4266 4267
        operator.init(props);
        accent = new COperator(operator);
4268 4269 4270
    }
    else if(code === 0x20D0 || type === ACCENT_HALF_ARROW_LEFT)
    {
4271
        operator = new CCombiningHalfArrow();
4272 4273 4274 4275 4276
        props =
        {
            location:   LOCATION_TOP,
            turn:       TURN_0
        };
4277 4278
        operator.init(props);
        accent = new COperator(operator);
4279 4280 4281
    }
    else if(code === 0x20D1 || type ===  ACCENT_HALF_ARROW_RIGHT)
    {
4282
        operator = new CCombiningHalfArrow();
4283 4284 4285 4286 4287
        props =
        {
            location:   LOCATION_TOP,
            turn:       TURN_180
        };
4288 4289
        operator.init(props);
        accent = new COperator(operator);
4290 4291 4292 4293
    }
    /////
    else if(typeof(code) !=="undefined" && code !== null)
    {
4294
        operator = new CMathText(true);
4295
        operator.add(code);
4296 4297 4298
    }
    else
    {
4299
        operator = new COperatorBracket();
4300 4301 4302 4303 4304
        props =
        {
            location:   LOCATION_BOT,
            turn:       TURN_MIRROR_0
        };
4305
        operator.init(props);
4306 4307
    }

4308
    return operator;
4309 4310 4311
}
CGroupCharacter.prototype.getPropsForWrite = function()
{
4312
    return this.Pr;
4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326
}
CGroupCharacter.prototype.Save_Changes = function(Data, Writer)
{
	Writer.WriteLong( historyitem_type_groupChr );
}
CGroupCharacter.prototype.Load_Changes = function(Reader)
{
}
CGroupCharacter.prototype.Refresh_RecalcData = function(Data)
{
}
CGroupCharacter.prototype.Write_ToBinary2 = function( Writer )
{
	Writer.WriteLong( historyitem_type_groupChr );
4327
	Writer.WriteString2( this.getBase().Id );
4328 4329 4330 4331 4332 4333
	
	this.CtrPrp.Write_ToBinary(Writer);
	
	var StartPos = Writer.GetCurPosition();
    Writer.Skip(4);
    var Flags = 0;
4334
	if ( undefined != this.Pr.chr )
4335
    {
4336
		Writer.WriteLong(this.Pr.chr);
4337 4338
		Flags |= 1;
	}
4339
	if ( undefined != this.Pr.pos )
4340
    {
4341
		Writer.WriteLong(this.Pr.pos);
4342 4343
		Flags |= 2;
	}
4344
	if ( undefined != this.Pr.vertJc )
4345
    {
4346
		Writer.WriteLong(this.Pr.vertJc);
4347 4348 4349 4350 4351 4352
		Flags |= 4;
	}
	var EndPos = Writer.GetCurPosition();
    Writer.Seek( StartPos );
    Writer.WriteLong( Flags );
    Writer.Seek( EndPos );
4353 4354 4355
}
CGroupCharacter.prototype.Read_FromBinary2 = function( Reader )
{
4356 4357 4358 4359
	var props = {ctrPrp: new CTextPr()};
	var arrElems = [];
	
	arrElems.push(g_oTableId.Get_ById( Reader.GetString2()));
4360
	
4361
	props.ctrPrp.Read_FromBinary(Reader);
4362 4363 4364
	
	var Flags = Reader.GetLong();
	if ( Flags & 1 )
4365
		props.chr = Reader.GetLong();
4366
	if ( Flags & 2 )
4367
		props.pos = Reader.GetLong();
4368
	if ( Flags & 4 )
4369 4370 4371
		props.vertJc = Reader.GetLong();
		
	this.fillMathComposition (props, arrElems);
4372 4373 4374 4375
}
CGroupCharacter.prototype.Get_Id = function()
{
	return this.Id;
4376
}