mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-19 14:25:27 +00:00
profile: unconditionally replot chart when settings change
The code tried to only replot the profile if necessary, notably when in edit mode or the ceilings are shown. That seems like pointless premature optimization, which only complicates things: The profile is replot every time a "dive handle" is moved, which means that we depend on the replotting being reasonably fast. Why should it then not be redrawn if the settings change? Let's remove this, as it makes control flow easier to reason about. This makes the isPlotZoomed member variable redundant. Remove it. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
f5e60b9618
commit
9560dbf8db
2 changed files with 1 additions and 21 deletions
|
@ -118,7 +118,6 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) : QGraphicsView(parent),
|
|||
#ifndef SUBSURFACE_MOBILE
|
||||
toolTipItem(new ToolTipItem()),
|
||||
#endif
|
||||
isPlotZoomed(prefs.zoomed_plot),// no! bad use of prefs. 'PreferencesDialog::loadSettings' NOT CALLED yet.
|
||||
profileYAxis(new DepthAxis(this)),
|
||||
gasYAxis(new PartialGasPressureAxis(*dataModel, this)),
|
||||
temperatureAxis(new TemperatureAxis(this)),
|
||||
|
@ -155,9 +154,6 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) : QGraphicsView(parent),
|
|||
shouldCalculateMaxDepth(true),
|
||||
fontPrintScale(1.0)
|
||||
{
|
||||
// would like to be able to ASSERT here that PreferencesDialog::loadSettings has been called.
|
||||
isPlotZoomed = prefs.zoomed_plot; // now it seems that 'prefs' has loaded our preferences
|
||||
|
||||
init_plot_info(&plotInfo);
|
||||
|
||||
setupSceneAndFlags();
|
||||
|
@ -830,16 +826,6 @@ void ProfileWidget2::actionRequestedReplot(bool)
|
|||
|
||||
void ProfileWidget2::settingsChanged()
|
||||
{
|
||||
// if we are showing calculated ceilings then we have to replot()
|
||||
// because the GF could have changed; otherwise we try to avoid replot()
|
||||
// but always replot in PLAN/ADD/EDIT mode to avoid a bug of DiveHandlers not
|
||||
// being redrawn on setting changes, causing them to become unattached
|
||||
// to the profile
|
||||
bool needReplot;
|
||||
if (currentState == ADD || currentState == PLAN || currentState == EDIT)
|
||||
needReplot = true;
|
||||
else
|
||||
needReplot = prefs.calcceiling;
|
||||
#ifndef SUBSURFACE_MOBILE
|
||||
gasYAxis->update(); // Initialize ticks of partial pressure graph
|
||||
if ((prefs.percentagegraph||prefs.hrgraph) && PP_GRAPHS_ENABLED) {
|
||||
|
@ -896,12 +882,7 @@ void ProfileWidget2::settingsChanged()
|
|||
}
|
||||
|
||||
tankItem->setVisible(prefs.tankbar);
|
||||
if (prefs.zoomed_plot != isPlotZoomed) {
|
||||
isPlotZoomed = prefs.zoomed_plot;
|
||||
needReplot = true;
|
||||
}
|
||||
if (needReplot)
|
||||
replot();
|
||||
replot();
|
||||
}
|
||||
|
||||
void ProfileWidget2::resizeEvent(QResizeEvent *event)
|
||||
|
|
|
@ -184,7 +184,6 @@ private:
|
|||
#ifndef SUBSURFACE_MOBILE
|
||||
ToolTipItem *toolTipItem;
|
||||
#endif
|
||||
bool isPlotZoomed;
|
||||
// All those here should probably be merged into one structure,
|
||||
// So it's esyer to replicate for more dives later.
|
||||
// In the meantime, keep it here.
|
||||
|
|
Loading…
Add table
Reference in a new issue