mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
profile: avoid double recalculation of tick positions
The ticks were recalculated twice per plotDive() call: 1) When updating the position of the axes in updateChangeLine() 2) After setting the bounds in plotDive() via setBounds() Remove the first instance. updateChangeLine() is called in only one place [from plotDive()] and therefore, the recalculation is always redundant. Moreover, rename the function to setPosition(), since it doesn't do any animation at all. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
b0faf2e4b1
commit
99c4741508
4 changed files with 10 additions and 19 deletions
|
@ -289,13 +289,7 @@ void DiveCartesianAxis::updateTicks(int animSpeed)
|
||||||
changed = false;
|
changed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiveCartesianAxis::setLine(const QLineF &line)
|
void DiveCartesianAxis::setPosition(const QRectF &rectIn)
|
||||||
{
|
|
||||||
QGraphicsLineItem::setLine(line);
|
|
||||||
changed = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DiveCartesianAxis::animateChangeLine(const QRectF &rectIn, int animSpeed)
|
|
||||||
{
|
{
|
||||||
rect = rectIn;
|
rect = rectIn;
|
||||||
switch (position) {
|
switch (position) {
|
||||||
|
@ -310,7 +304,7 @@ void DiveCartesianAxis::animateChangeLine(const QRectF &rectIn, int animSpeed)
|
||||||
setLine(QLineF(rect.bottomLeft(), rect.bottomRight()));
|
setLine(QLineF(rect.bottomLeft(), rect.bottomRight()));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
updateTicks(animSpeed);
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
double DiveCartesianAxis::Transform::to(double x) const
|
double DiveCartesianAxis::Transform::to(double x) const
|
||||||
|
|
|
@ -44,10 +44,9 @@ public:
|
||||||
std::pair<double, double> screenMinMax() const;
|
std::pair<double, double> screenMinMax() const;
|
||||||
qreal valueAt(const QPointF &p) const;
|
qreal valueAt(const QPointF &p) const;
|
||||||
qreal posAtValue(qreal value) const;
|
qreal posAtValue(qreal value) const;
|
||||||
void animateChangeLine(const QRectF &rect, int animSpeed);
|
void setPosition(const QRectF &rect);
|
||||||
void setTextVisible(bool arg1);
|
void setTextVisible(bool arg1);
|
||||||
void setLinesVisible(bool arg1);
|
void setLinesVisible(bool arg1);
|
||||||
void setLine(const QLineF &line);
|
|
||||||
void updateTicks(int animSpeed);
|
void updateTicks(int animSpeed);
|
||||||
double width() const; // only for vertical axes
|
double width() const; // only for vertical axes
|
||||||
double height() const; // only for horizontal axes
|
double height() const; // only for horizontal axes
|
||||||
|
|
|
@ -218,10 +218,8 @@ struct VerticalAxisLayout {
|
||||||
bool visible;
|
bool visible;
|
||||||
};
|
};
|
||||||
|
|
||||||
void ProfileScene::updateAxes(bool instant, bool diveHasHeartBeat)
|
void ProfileScene::updateAxes(bool diveHasHeartBeat)
|
||||||
{
|
{
|
||||||
int animSpeed = instant || printMode ? 0 : qPrefDisplay::animation_speed();
|
|
||||||
|
|
||||||
// Calculate left and right border needed for the axes.
|
// Calculate left and right border needed for the axes.
|
||||||
// viz. the depth axis to the left and the partial pressure axis to the right.
|
// viz. the depth axis to the left and the partial pressure axis to the right.
|
||||||
// Thus, calculating the "border" of the graph is trivial.
|
// Thus, calculating the "border" of the graph is trivial.
|
||||||
|
@ -248,7 +246,7 @@ void ProfileScene::updateAxes(bool instant, bool diveHasHeartBeat)
|
||||||
}
|
}
|
||||||
|
|
||||||
bottomBorder -= timeAxis->height();
|
bottomBorder -= timeAxis->height();
|
||||||
timeAxis->animateChangeLine(QRectF(leftBorder, topBorder, width, bottomBorder - topBorder), animSpeed);
|
timeAxis->setPosition(QRectF(leftBorder, topBorder, width, bottomBorder - topBorder));
|
||||||
|
|
||||||
if (prefs.tankbar) {
|
if (prefs.tankbar) {
|
||||||
bottomBorder -= tankItem->height();
|
bottomBorder -= tankItem->height();
|
||||||
|
@ -290,14 +288,14 @@ void ProfileScene::updateAxes(bool instant, bool diveHasHeartBeat)
|
||||||
if (!l.visible)
|
if (!l.visible)
|
||||||
continue;
|
continue;
|
||||||
bottomBorder -= l.height * dpr;
|
bottomBorder -= l.height * dpr;
|
||||||
l.axis->animateChangeLine(QRectF(leftBorder, bottomBorder, width, l.height * dpr), animSpeed);
|
l.axis->setPosition(QRectF(leftBorder, bottomBorder, width, l.height * dpr));
|
||||||
}
|
}
|
||||||
|
|
||||||
height = bottomBorder - topBorder;
|
height = bottomBorder - topBorder;
|
||||||
profileYAxis->animateChangeLine(QRectF(leftBorder, topBorder, width, height), animSpeed);
|
profileYAxis->setPosition(QRectF(leftBorder, topBorder, width, height));
|
||||||
|
|
||||||
// The cylinders are displayed in the 24-80% region of the profile
|
// The cylinders are displayed in the 24-80% region of the profile
|
||||||
cylinderPressureAxis->animateChangeLine(QRectF(leftBorder, topBorder + 0.24 * height, width, 0.56 * height), animSpeed);
|
cylinderPressureAxis->setPosition(QRectF(leftBorder, topBorder + 0.24 * height, width, 0.56 * height));
|
||||||
|
|
||||||
// Set scale factors depending on locale.
|
// Set scale factors depending on locale.
|
||||||
// The conversion calls, such as mm_to_feet(), will be optimized away.
|
// The conversion calls, such as mm_to_feet(), will be optimized away.
|
||||||
|
@ -371,7 +369,7 @@ void ProfileScene::plotDive(const struct dive *dIn, int dcIn, DivePlannerPointsM
|
||||||
|
|
||||||
bool hasHeartBeat = plotInfo.maxhr;
|
bool hasHeartBeat = plotInfo.maxhr;
|
||||||
updateVisibility(hasHeartBeat);
|
updateVisibility(hasHeartBeat);
|
||||||
updateAxes(instant, hasHeartBeat);
|
updateAxes(hasHeartBeat);
|
||||||
|
|
||||||
int newMaxtime = get_maxtime(&plotInfo);
|
int newMaxtime = get_maxtime(&plotInfo);
|
||||||
if (calcMax || newMaxtime > maxtime)
|
if (calcMax || newMaxtime > maxtime)
|
||||||
|
|
|
@ -60,7 +60,7 @@ private:
|
||||||
PartialPressureGasItem *createPPGas(int column, color_index_t color, color_index_t colorAlert,
|
PartialPressureGasItem *createPPGas(int column, color_index_t color, color_index_t colorAlert,
|
||||||
const double *thresholdSettingsMin, const double *thresholdSettingsMax);
|
const double *thresholdSettingsMin, const double *thresholdSettingsMax);
|
||||||
void updateVisibility(bool diveHasHeartBeat); // Update visibility of non-interactive chart features according to preferences
|
void updateVisibility(bool diveHasHeartBeat); // Update visibility of non-interactive chart features according to preferences
|
||||||
void updateAxes(bool instant, bool diveHasHeartBeat); // Update axes according to preferences
|
void updateAxes(bool diveHasHeartBeat); // Update axes according to preferences
|
||||||
|
|
||||||
friend class ProfileWidget2; // For now, give the ProfileWidget full access to the objects on the scene
|
friend class ProfileWidget2; // For now, give the ProfileWidget full access to the objects on the scene
|
||||||
double dpr; // Device Pixel Ratio. A DPR of one corresponds to a "standard" PC screen.
|
double dpr; // Device Pixel Ratio. A DPR of one corresponds to a "standard" PC screen.
|
||||||
|
|
Loading…
Add table
Reference in a new issue