mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
New Profile: make axis labels smaller
Previously all text in the new profile was deawn in the same font. With this change the labels on all axes are smaller. It might be even better to allow per-axis configuration of the label size as along the time axis the bigger size looked better. But especially for partial pressures this looks much better. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
cb5ab4bc8e
commit
980737221d
3 changed files with 20 additions and 1 deletions
|
@ -164,6 +164,7 @@ void DiveCartesianAxis::updateTicks()
|
||||||
label->setText(textForValue(currValue));
|
label->setText(textForValue(currValue));
|
||||||
label->setBrush(QBrush(textColor));
|
label->setBrush(QBrush(textColor));
|
||||||
label->setBrush(colorForValue(currValue));
|
label->setBrush(colorForValue(currValue));
|
||||||
|
label->setScale(0.8);
|
||||||
labels.push_back(label);
|
labels.push_back(label);
|
||||||
if (orientation == RightToLeft || orientation == LeftToRight) {
|
if (orientation == RightToLeft || orientation == LeftToRight) {
|
||||||
label->setAlignment(Qt::AlignBottom | Qt::AlignHCenter);
|
label->setAlignment(Qt::AlignBottom | Qt::AlignHCenter);
|
||||||
|
|
|
@ -13,7 +13,8 @@ DiveTextItem::DiveTextItem(QGraphicsItem* parent): QGraphicsItemGroup(parent),
|
||||||
internalAlignFlags(Qt::AlignHCenter | Qt::AlignVCenter),
|
internalAlignFlags(Qt::AlignHCenter | Qt::AlignVCenter),
|
||||||
textBackgroundItem(NULL),
|
textBackgroundItem(NULL),
|
||||||
textItem(NULL),
|
textItem(NULL),
|
||||||
colorIndex(SAC_DEFAULT)
|
colorIndex(SAC_DEFAULT),
|
||||||
|
scale(1.0)
|
||||||
{
|
{
|
||||||
setFlag(ItemIgnoresTransformations);
|
setFlag(ItemIgnoresTransformations);
|
||||||
}
|
}
|
||||||
|
@ -30,6 +31,11 @@ void DiveTextItem::setBrush(const QBrush& b)
|
||||||
updateText();
|
updateText();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DiveTextItem::setScale(double newscale)
|
||||||
|
{
|
||||||
|
scale = newscale;
|
||||||
|
}
|
||||||
|
|
||||||
void DiveTextItem::setText(const QString& t)
|
void DiveTextItem::setText(const QString& t)
|
||||||
{
|
{
|
||||||
internalText = t;
|
internalText = t;
|
||||||
|
@ -43,6 +49,7 @@ const QString& DiveTextItem::text()
|
||||||
|
|
||||||
void DiveTextItem::updateText()
|
void DiveTextItem::updateText()
|
||||||
{
|
{
|
||||||
|
double size;
|
||||||
delete textItem;
|
delete textItem;
|
||||||
textItem = NULL;
|
textItem = NULL;
|
||||||
delete textBackgroundItem;
|
delete textBackgroundItem;
|
||||||
|
@ -52,6 +59,15 @@ void DiveTextItem::updateText()
|
||||||
}
|
}
|
||||||
|
|
||||||
QFont fnt(qApp->font());
|
QFont fnt(qApp->font());
|
||||||
|
if ((size = fnt.pixelSize()) > 0) {
|
||||||
|
// set in pixels - so the scale factor may not make a difference if it's too close to 1
|
||||||
|
size *= scale;
|
||||||
|
fnt.setPixelSize(size);
|
||||||
|
} else {
|
||||||
|
size = fnt.pointSizeF();
|
||||||
|
size *= scale;
|
||||||
|
fnt.setPointSizeF(size);
|
||||||
|
}
|
||||||
QFontMetrics fm(fnt);
|
QFontMetrics fm(fnt);
|
||||||
|
|
||||||
QPainterPath textPath;
|
QPainterPath textPath;
|
||||||
|
|
|
@ -15,6 +15,7 @@ public:
|
||||||
DiveTextItem(QGraphicsItem* parent = 0);
|
DiveTextItem(QGraphicsItem* parent = 0);
|
||||||
void setText(const QString& text);
|
void setText(const QString& text);
|
||||||
void setAlignment(int alignFlags);
|
void setAlignment(int alignFlags);
|
||||||
|
void setScale(double newscale);
|
||||||
void setBrush(const QBrush& brush);
|
void setBrush(const QBrush& brush);
|
||||||
void animatedHide();
|
void animatedHide();
|
||||||
void animateMoveTo(qreal x, qreal y);
|
void animateMoveTo(qreal x, qreal y);
|
||||||
|
@ -27,6 +28,7 @@ private:
|
||||||
QString internalText;
|
QString internalText;
|
||||||
color_indice_t colorIndex;
|
color_indice_t colorIndex;
|
||||||
QBrush brush;
|
QBrush brush;
|
||||||
|
double scale;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DIVETEXTITEM_H
|
#endif // DIVETEXTITEM_H
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue