mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
profile: don't show 0m label
The old profile code didn't show the 0m label, because that was cut off. This was lost when redoing the axis code. Reimplement this. The code is very ugly: it recognizes the depth axis by the fact that is the only "inverted" axis. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
725fda3cd1
commit
3579e36b7d
2 changed files with 14 additions and 8 deletions
|
@ -220,24 +220,24 @@ QLineF DiveCartesianAxis::linePos(double pos) const
|
|||
|
||||
void DiveCartesianAxis::updateLabel(Label &label, double opacityEnd, double pos) const
|
||||
{
|
||||
label.opacityStart = textVisibility ? label.label->opacity()
|
||||
label.opacityStart = label.label ? label.label->opacity()
|
||||
: label.line->opacity();
|
||||
label.opacityEnd = opacityEnd;
|
||||
if (textVisibility) {
|
||||
if (label.label) {
|
||||
label.labelPosStart = label.label->pos();
|
||||
label.labelPosEnd = labelPos(pos);
|
||||
}
|
||||
if (lineVisibility) {
|
||||
if (label.line) {
|
||||
label.lineStart = label.line->line();
|
||||
label.lineEnd = linePos(pos);
|
||||
}
|
||||
}
|
||||
|
||||
DiveCartesianAxis::Label DiveCartesianAxis::createLabel(double value, double pos, double dataMinOld, double dataMaxOld, int animSpeed)
|
||||
DiveCartesianAxis::Label DiveCartesianAxis::createLabel(double value, double pos, double dataMinOld, double dataMaxOld, int animSpeed, bool noLabel)
|
||||
{
|
||||
Label label { value, 0.0, 1.0 };
|
||||
double posStart = posAtValue(value, dataMaxOld, dataMinOld);
|
||||
if (textVisibility) {
|
||||
if (textVisibility && !noLabel) {
|
||||
label.labelPosStart = labelPos(posStart);
|
||||
label.labelPosEnd = labelPos(pos);
|
||||
int alignFlags = position == Position::Bottom ? Qt::AlignTop | Qt::AlignHCenter :
|
||||
|
@ -271,6 +271,7 @@ void DiveCartesianAxis::updateLabels(int numTicks, double firstPosScreen, double
|
|||
newLabels.reserve(numTicks);
|
||||
auto actOld = labels.begin();
|
||||
double value = firstValue;
|
||||
|
||||
for (int i = 0; i < numTicks; i++, value += stepValue) {
|
||||
|
||||
// Check if we already got that label. If we find unused labels, mark them for deletion.
|
||||
|
@ -291,8 +292,13 @@ void DiveCartesianAxis::updateLabels(int numTicks, double firstPosScreen, double
|
|||
newLabels.push_back(std::move(*actOld));
|
||||
++actOld;
|
||||
} else {
|
||||
// This is horrible: for the depth axis, we don't want to show the first label (0).
|
||||
// We recognize this by the fact that the depth axis is the only "inverted" axis.
|
||||
// This really should be replaced by a general flag to avoid surprises!
|
||||
bool noLabel = inverted && i == 0;
|
||||
|
||||
// Create new label
|
||||
newLabels.push_back(createLabel(value, pos, dataMinOld, dataMaxOld, animSpeed));
|
||||
newLabels.push_back(createLabel(value, pos, dataMinOld, dataMaxOld, animSpeed, noLabel));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ private:
|
|||
QPointF labelPos(double pos) const;
|
||||
QLineF linePos(double pos) const;
|
||||
void updateLabel(Label &label, double opacityEnd, double pos) const;
|
||||
Label createLabel(double value, double pos, double dataMinOld, double dataMaxOld, int animSpeed);
|
||||
Label createLabel(double value, double pos, double dataMinOld, double dataMaxOld, int animSpeed, bool noLabel);
|
||||
QString textForValue(double value) const;
|
||||
std::vector<Label> labels;
|
||||
double dataMin, dataMax;
|
||||
|
|
Loading…
Reference in a new issue