mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
profile: improve calculation of the right border
The time axis might need some space and the average depth item puts a formatted depth at to right of the profile. Consider these when calculating the right border. Since I found no way to turn of the average depth, this creates a permanent border, which might or might not be a good thing. Contains some refactoring of the label-size functions provided by DiveTextItem. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
6b33c3e721
commit
176a62f752
8 changed files with 50 additions and 43 deletions
|
@ -432,9 +432,12 @@ void DiveTemperatureItem::paint(QPainter *painter, const QStyleOptionGraphicsIte
|
|||
painter->restore();
|
||||
}
|
||||
|
||||
static const double diveMeanDepthItemLabelScale = 0.8;
|
||||
|
||||
DiveMeanDepthItem::DiveMeanDepthItem(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn,
|
||||
const DiveCartesianAxis &vAxis, int vColumn, double dpr) :
|
||||
AbstractProfilePolygonItem(model, hAxis, hColumn, vAxis, vColumn, dpr)
|
||||
AbstractProfilePolygonItem(model, hAxis, hColumn, vAxis, vColumn, dpr),
|
||||
labelWidth(DiveTextItem::getLabelSize(dpr, diveMeanDepthItemLabelScale, QStringLiteral("999.9ft")).first)
|
||||
{
|
||||
QPen pen;
|
||||
pen.setBrush(QBrush(getColor(::HR_AXIS)));
|
||||
|
@ -500,7 +503,6 @@ void DiveMeanDepthItem::replot(const dive *, int fromIn, int toIn, bool)
|
|||
createTextItem(prevSec, prevMeanDepth);
|
||||
}
|
||||
|
||||
|
||||
void DiveMeanDepthItem::paint(QPainter *painter, const QStyleOptionGraphicsItem*, QWidget*)
|
||||
{
|
||||
if (polygon().isEmpty())
|
||||
|
@ -515,7 +517,7 @@ void DiveMeanDepthItem::createTextItem(double lastSec, double lastMeanDepth)
|
|||
{
|
||||
qDeleteAll(texts);
|
||||
texts.clear();
|
||||
DiveTextItem *text = new DiveTextItem(dpr, 0.8, Qt::AlignRight | Qt::AlignTop, this);
|
||||
DiveTextItem *text = new DiveTextItem(dpr, diveMeanDepthItemLabelScale, Qt::AlignRight | Qt::AlignTop, this);
|
||||
text->set(get_depth_string(lrint(lastMeanDepth), true), getColor(TEMP_TEXT));
|
||||
text->setPos(QPointF(hAxis.posAtValue(lastSec) + dpr, vAxis.posAtValue(lastMeanDepth)));
|
||||
texts.append(text);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue