| 690 | } |
| 691 | |
| 692 | void TextLabelPrivate::updateBoundingRect() { |
| 693 | // DEBUG(Q_FUNC_INFO) |
| 694 | // determine the size of the label in scene units. |
| 695 | double w, h; |
| 696 | if (textWrapper.mode == TextLabel::Mode::LaTeX) { |
| 697 | // image size is in pixel, convert to scene units. |
| 698 | // the image is scaled so we have a good image quality when the worksheet was zoomed, |
| 699 | // for the bounding rect we need to scale back since it's scaled again in paint() when drawing the rect |
| 700 | w = teXImage.width() * teXImageScaleFactor / zoomFactor; |
| 701 | h = teXImage.height() * teXImageScaleFactor / zoomFactor; |
| 702 | } else { |
| 703 | // size is in points, convert to scene units |
| 704 | // QDEBUG(" BOUNDING RECT = " << m_textItem->scaledBoundingRect()) |
| 705 | // TODO: the shift and scaling is just a workaround to avoid the big bounding box |
| 706 | // s.a. TextLabelPrivate::size() |
| 707 | |
| 708 | // double xShift = 23., yScale = 0.8; |
| 709 | // better scaling for multiline Markdown |
| 710 | // if (textWrapper.mode == TextLabel::Mode::Markdown && textWrapper.text.contains(QLatin1Char('\n'))) |
| 711 | // yScale = 0.95; |
| 712 | w = m_textItem->scaledBoundingRect().width(); // - xShift; |
| 713 | h = m_textItem->scaledBoundingRect().height(); // * yScale; |
| 714 | m_textItem->setPos(-w / 2, -h / 2); |
| 715 | } |
| 716 | |
| 717 | // DEBUG(Q_FUNC_INFO << ", scale factor = " << scaleFactor << ", w/h = " << w << " / " << h) |
| 718 | boundingRectangleText.setX(-w / 2); |
| 719 | boundingRectangleText.setY(-h / 2); |
| 720 | boundingRectangleText.setWidth(w); |
| 721 | boundingRectangleText.setHeight(h); |
| 722 | |
| 723 | updatePosition(); |
| 724 | updateBorder(); |
| 725 | } |
| 726 | |
| 727 | void TextLabelPrivate::updateTeXImage() { |
| 728 | if (zoomFactor == -1.0) { |