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:
Dirk Hohndel 2014-02-15 07:03:41 -08:00
parent cb5ab4bc8e
commit 980737221d
3 changed files with 20 additions and 1 deletions

View file

@ -164,6 +164,7 @@ void DiveCartesianAxis::updateTicks()
label->setText(textForValue(currValue));
label->setBrush(QBrush(textColor));
label->setBrush(colorForValue(currValue));
label->setScale(0.8);
labels.push_back(label);
if (orientation == RightToLeft || orientation == LeftToRight) {
label->setAlignment(Qt::AlignBottom | Qt::AlignHCenter);

View file

@ -13,7 +13,8 @@ DiveTextItem::DiveTextItem(QGraphicsItem* parent): QGraphicsItemGroup(parent),
internalAlignFlags(Qt::AlignHCenter | Qt::AlignVCenter),
textBackgroundItem(NULL),
textItem(NULL),
colorIndex(SAC_DEFAULT)
colorIndex(SAC_DEFAULT),
scale(1.0)
{
setFlag(ItemIgnoresTransformations);
}
@ -30,6 +31,11 @@ void DiveTextItem::setBrush(const QBrush& b)
updateText();
}
void DiveTextItem::setScale(double newscale)
{
scale = newscale;
}
void DiveTextItem::setText(const QString& t)
{
internalText = t;
@ -43,6 +49,7 @@ const QString& DiveTextItem::text()
void DiveTextItem::updateText()
{
double size;
delete textItem;
textItem = NULL;
delete textBackgroundItem;
@ -52,6 +59,15 @@ void DiveTextItem::updateText()
}
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);
QPainterPath textPath;

View file

@ -15,6 +15,7 @@ public:
DiveTextItem(QGraphicsItem* parent = 0);
void setText(const QString& text);
void setAlignment(int alignFlags);
void setScale(double newscale);
void setBrush(const QBrush& brush);
void animatedHide();
void animateMoveTo(qreal x, qreal y);
@ -27,6 +28,7 @@ private:
QString internalText;
color_indice_t colorIndex;
QBrush brush;
double scale;
};
#endif // DIVETEXTITEM_H