mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
profile: add width() function to DiveCartesian axis
To properly layout the profile we need to know the expected space required by the vertical axes. In the general case, format the the text "999". For the partial-pressure-axis, use "0.99". Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
f713858ba4
commit
7dd9b65df0
4 changed files with 36 additions and 7 deletions
|
@ -8,6 +8,8 @@
|
|||
#include "profile-widget/divelineitem.h"
|
||||
#include "profile-widget/profilescene.h"
|
||||
|
||||
static const double labelSpace = 2.0; // space between label and ticks
|
||||
|
||||
QPen DiveCartesianAxis::gridPen() const
|
||||
{
|
||||
QPen pen;
|
||||
|
@ -117,6 +119,18 @@ void emptyList(QList<T *> &list, int steps, int speed)
|
|||
}
|
||||
}
|
||||
|
||||
double DiveCartesianAxis::textWidth(const QString &s) const
|
||||
{
|
||||
QFont fnt = DiveTextItem::getFont(dpr, labelScale);
|
||||
QFontMetrics fm(fnt);
|
||||
return fm.size(Qt::TextSingleLine, s).width() + labelSpace * dpr;
|
||||
}
|
||||
|
||||
double DiveCartesianAxis::width() const
|
||||
{
|
||||
return textWidth("999");
|
||||
}
|
||||
|
||||
void DiveCartesianAxis::updateTicks(int animSpeed, color_index_t color)
|
||||
{
|
||||
if (!changed && !printMode)
|
||||
|
@ -401,3 +415,8 @@ void PartialGasPressureAxis::update(int animSpeed)
|
|||
setTickInterval(pp > 4 ? 0.5 : 0.25);
|
||||
updateTicks(animSpeed);
|
||||
}
|
||||
|
||||
double PartialGasPressureAxis::width() const
|
||||
{
|
||||
return textWidth(textForValue(0.99));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue