@@ -508,23 +508,21 @@ void TextAnnotation::parseShapeAnnotation(QString shape, OMCProxy *omc)
508508 shape = shape.replace (" }" , " " );
509509 // parse the shape to get the list of attributes of Text Annotation.
510510 QStringList list = StringHandler::getStrings (shape);
511- if (list.size () < 17 )
511+ if (list.size () < 18 )
512512 {
513513 return ;
514514 }
515- // if first item of list is true then the Text Annotation should be visible.
516- mVisible = static_cast <QString>(list.at (0 )).contains (" true" );
517-
518515 int index = 0 ;
516+ // if first item of list is true then the Text Annotation should be visible.
517+ mVisible = static_cast <QString>(list.at (index)).contains (" true" );
519518 if (omc->mAnnotationVersion == OMCProxy::ANNOTATION_VERSION3X)
520519 {
521520 mOrigin .setX (static_cast <QString>(list.at (1 )).toFloat ());
522521 mOrigin .setY (static_cast <QString>(list.at (2 )).toFloat ());
523-
524522 mRotation = static_cast <QString>(list.at (3 )).toFloat ();
525523 index = 3 ;
526524 }
527- // 2,3,4 items of list contains the line color.
525+ // 4,5,6 items of list contains the line color.
528526 index = index + 1 ;
529527 int red, green, blue;
530528 red = static_cast <QString>(list.at (index)).toInt ();
@@ -533,15 +531,15 @@ void TextAnnotation::parseShapeAnnotation(QString shape, OMCProxy *omc)
533531 index = index + 1 ;
534532 blue = static_cast <QString>(list.at (index)).toInt ();
535533 mLineColor = QColor (red, green, blue);
536- // 5,6,7 items of list contains the fill color.
534+ // 7,8,9 items of list contains the fill color.
537535 index = index + 1 ;
538536 red = static_cast <QString>(list.at (index)).toInt ();
539537 index = index + 1 ;
540538 green = static_cast <QString>(list.at (index)).toInt ();
541539 index = index + 1 ;
542540 blue = static_cast <QString>(list.at (index)).toInt ();
543541 mFillColor = QColor (red, green, blue);
544- // 8 item of the list contains the line pattern.
542+ // 10 item of the list contains the line pattern.
545543 index = index + 1 ;
546544 QString linePattern = StringHandler::getLastWordAfterDot (list.at (index));
547545 QMap<QString, Qt::PenStyle>::iterator it;
@@ -553,7 +551,7 @@ void TextAnnotation::parseShapeAnnotation(QString shape, OMCProxy *omc)
553551 break ;
554552 }
555553 }
556- // 9 item of the list contains the fill pattern.
554+ // 11 item of the list contains the fill pattern.
557555 index = index + 1 ;
558556 QString fillPattern = StringHandler::getLastWordAfterDot (list.at (index));
559557 QMap<QString, Qt::BrushStyle>::iterator fill_it;
@@ -565,10 +563,10 @@ void TextAnnotation::parseShapeAnnotation(QString shape, OMCProxy *omc)
565563 break ;
566564 }
567565 }
568- // 10 item of the list contains the thickness.
566+ // 12 item of the list contains the thickness.
569567 index = index + 1 ;
570568 mThickness = static_cast <QString>(list.at (index)).toFloat ();
571- // 11, 12, 13, 14 items of the list contains the extent points of Text.
569+ // 13, 14, 15, 16 items of the list contains the extent points of Text.
572570 index = index + 1 ;
573571 qreal x = static_cast <QString>(list.at (index)).toFloat ();
574572 index = index + 1 ;
@@ -581,7 +579,7 @@ void TextAnnotation::parseShapeAnnotation(QString shape, OMCProxy *omc)
581579 QPointF p2 (x, y);
582580 mExtent .append (p1);
583581 mExtent .append (p2);
584- // 15 item of the list contains the text string.
582+ // 17 item of the list contains the text string.
585583 index = index + 1 ;
586584 if (mIsCustomShape )
587585 mTextString = StringHandler::removeFirstLastQuotes (list.at (index));
@@ -591,11 +589,15 @@ void TextAnnotation::parseShapeAnnotation(QString shape, OMCProxy *omc)
591589 checkNameString ();
592590 checkParameterString ();
593591 }
594- index++;
595- // Now comes the optional parameters.
592+ // 18 item of the list contains the text size.
593+ index = index + 1 ;
594+ mFontSize = static_cast <QString>(list.at (index)).toFloat ();
595+ index = index + 1 ;
596+ // Now comes the optional parameters; fontName and textStyle.
596597 while (index < list.size ())
597598 {
598599 QString line = StringHandler::removeFirstLastQuotes (list.at (index));
600+ // check textStyles enumeration.
599601 if (line == " TextStyle.Italic" )
600602 {
601603 mFontItalic = true ;
@@ -611,33 +613,25 @@ void TextAnnotation::parseShapeAnnotation(QString shape, OMCProxy *omc)
611613 mFontUnderLine = true ;
612614 index++;
613615 }
614- else if (line.length () < 3 )
615- {
616- mFontSize = line.toInt ();
617- index++;
618- }
619- else if (line == " TextAlignment.Center" )
616+ // check textAlignment enumeration.
617+ else if (line == " TextAlignment.Center" )
620618 {
621619 mHorizontalAlignment = Qt::AlignCenter;
622620 index++;
623621 }
624- else if (line == " TextAlignment.Left" )
622+ else if (line == " TextAlignment.Left" )
625623 {
626624 mHorizontalAlignment = Qt::AlignLeft;
627625 index++;
628626 }
629- else if (line == " TextAlignment.Right" )
627+ else if (line == " TextAlignment.Right" )
630628 {
631629 mHorizontalAlignment = Qt::AlignRight;
632630 index++;
633631 }
634- else if (line.length () > 3 )
635- {
636- mFontName = line;
637- index++;
638- }
639632 else
640633 {
634+ mFontName = line;
641635 index++;
642636 }
643637 }
0 commit comments