void QtGnuplotEnhanced::addText(const QString& fontName, double fontSize, double base, bool widthFlag, bool showFlag, int overprint, const QString& text, QColor color) { if ((overprint == 1) && !(m_overprintMark)) // Underprint { m_overprintPos = m_currentPos.x(); m_overprintMark = true; } if (overprint == 3) // Save position m_savedPos = m_currentPos; else if (overprint == 4) // Recall saved position m_currentPos = m_savedPos; QFont font(fontName, fontSize); QtGnuplotEnhancedFragment* item = new QtGnuplotEnhancedFragment(font, text, this); item->setPos(m_currentPos + QPointF(0., -base)); if (showFlag) item->setPen(color); else item->setPen(Qt::NoPen); if (overprint == 2) // Overprint { item->setPos(QPointF((m_overprintPos + m_currentPos.x())/2. - (item->boundingRect().right() + item->boundingRect().left())/2., -base)); m_overprintMark = false; } if (widthFlag && (overprint != 2)) m_currentPos += QPointF(item->boundingRect().right(), 0.); }
void QtGnuplotEnhanced::addText(const QString& fontName, double fontSize, QFont::Style fontStyle, QFont::Weight fontWeight, double base, bool widthFlag, bool showFlag, int overprint, const QString& text, QColor color) { if ((overprint == 1) && !(m_overprintMark)) // Underprint { m_overprintPos = m_currentPos.x(); m_overprintMark = true; } if (overprint == 3) // Save position m_savedPos = m_currentPos; else if (overprint == 4) // Recall saved position m_currentPos = m_savedPos; QFont font(fontName, fontSize); if (fontName.isEmpty()) { // qDebug() << "Empty font name"; font.setFamily("Sans"); // FIXME: use default? use previous? } font.setStyle(fontStyle); font.setWeight(fontWeight); QtGnuplotEnhancedFragment* item = new QtGnuplotEnhancedFragment(font, text, this); item->setPos(m_currentPos + QPointF(0., -base)); if (showFlag) item->setPen(color); else item->setPen(Qt::NoPen); if (overprint == 2) // Overprint { item->setPos(QPointF((m_overprintPos + m_currentPos.x())/2. - (item->boundingRect().right() + item->boundingRect().left())/2., -base)); m_overprintMark = false; } if (widthFlag && (overprint != 2)) m_currentPos += QPointF(item->boundingRect().right(), 0.); }