Move scaling font size to appropriate class.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2017-06-19 15:26:29 +03:00
parent 8e0a7250df
commit e982df63c0
4 changed files with 21 additions and 16 deletions

View File

@ -45,6 +45,7 @@
#include "vmaingraphicsscene.h"
#include "vmaingraphicsview.h"
#include "global.h"
//---------------------------------------------------------------------------------------------------------------------
/**
@ -87,6 +88,23 @@ VGraphicsSimpleTextItem::~VGraphicsSimpleTextItem()
RestoreOverrideCursor(cursorArrowOpenHand);
}
//---------------------------------------------------------------------------------------------------------------------
void VGraphicsSimpleTextItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
const qreal scale = SceneScale(scene());
qreal fontSize = BaseFontSize();
if (scale > 1)
{
fontSize = qMax(0.1, fontSize/scale);
}
QFont font = this->font();
font.setPointSizeF(fontSize);
setFont(font);
QGraphicsSimpleTextItem::paint(painter, option, widget);
}
//---------------------------------------------------------------------------------------------------------------------
void VGraphicsSimpleTextItem::setEnabled(bool enabled)
{

View File

@ -56,6 +56,9 @@ public:
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Vis::GraphicsSimpleTextItem)};
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
void setEnabled(bool enabled);
void LabelSelectionType(const SelectionType &type);
signals:

View File

@ -72,7 +72,6 @@ void VScenePoint::paint(QPainter *painter, const QStyleOptionGraphicsItem *optio
m_namePoint->setVisible(true);
m_lineName->setVisible(true);
ScaleLabelFontSize(scale);
ScaleLinePenWidth(m_lineName, scale);
RefreshLine();
@ -170,20 +169,6 @@ void VScenePoint::ScaleMainPenWidth(qreal scale)
setPen(QPen(CorrectColor(this, m_baseColor), width));
}
//---------------------------------------------------------------------------------------------------------------------
void VScenePoint::ScaleLabelFontSize(qreal scale) const
{
qreal fontSize = m_namePoint->BaseFontSize();
if (scale > 1)
{
fontSize = qMax(0.1, fontSize/scale);
}
QFont font = m_namePoint->font();
font.setPointSizeF(fontSize);
m_namePoint->setFont(font);
}
//---------------------------------------------------------------------------------------------------------------------
void VScenePoint::ScaleLinePenWidth(QGraphicsLineItem *line, qreal scale)
{

View File

@ -72,7 +72,6 @@ private:
Q_DISABLE_COPY(VScenePoint)
void ScaleMainPenWidth(qreal scale);
void ScaleLabelFontSize(qreal scale) const;
};
#endif // VSCENEPOINT_H