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
|
@ -57,14 +57,7 @@ DiveCartesianAxis::DiveCartesianAxis(Position position, bool inverted, int integ
|
|||
label.append('9');
|
||||
}
|
||||
|
||||
/* Use the label to estimate size of the labels.
|
||||
* Round up, because non-integers tend to give abysmal rendering.
|
||||
*/
|
||||
QFont fnt = DiveTextItem::getFont(dpr, labelScale);
|
||||
double outlineSpace = DiveTextItem::outlineSpace(dpr);
|
||||
QFontMetrics fm(fnt);
|
||||
labelWidth = ceil(fm.size(Qt::TextSingleLine, label).width() + outlineSpace);
|
||||
labelHeight = ceil(fm.height() + outlineSpace);
|
||||
std::tie(labelWidth, labelHeight) = DiveTextItem::getLabelSize(dpr, labelScale, label);
|
||||
}
|
||||
|
||||
DiveCartesianAxis::~DiveCartesianAxis()
|
||||
|
@ -96,6 +89,11 @@ double DiveCartesianAxis::height() const
|
|||
return labelHeight + labelSpaceVertical * dpr;
|
||||
}
|
||||
|
||||
double DiveCartesianAxis::horizontalOverhang() const
|
||||
{
|
||||
return labelWidth / 2.0;
|
||||
}
|
||||
|
||||
int DiveCartesianAxis::getMinLabelDistance(const DiveCartesianAxis &timeAxis) const
|
||||
{
|
||||
// For the plot not being to crowded we want at least two
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue