mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Prevent redundant replanning
Planning dives is heavy on CPU, so better be sure we only do it when needed. In particular, when moving around dive points, we only want a new plan once per move and not three times (triggered at various points in the chain of events). This should significantly improve planner snappiness. Signed-off-by: Robert C. Helling <helling@atdotde.de>
This commit is contained in:
parent
e06b507230
commit
4d605ce51f
2 changed files with 19 additions and 3 deletions
|
@ -914,7 +914,6 @@ void ProfileWidget2::divePlannerHandlerClicked()
|
||||||
if (zoomLevel)
|
if (zoomLevel)
|
||||||
return;
|
return;
|
||||||
shouldCalculateMaxDepth = false;
|
shouldCalculateMaxDepth = false;
|
||||||
replot();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProfileWidget2::divePlannerHandlerReleased()
|
void ProfileWidget2::divePlannerHandlerReleased()
|
||||||
|
@ -1827,9 +1826,12 @@ void ProfileWidget2::recreatePlannedDive()
|
||||||
timeAxis->setMaximum(timeAxis->maximum() * 1.02);
|
timeAxis->setMaximum(timeAxis->maximum() * 1.02);
|
||||||
|
|
||||||
divedatapoint data = plannerModel->at(index);
|
divedatapoint data = plannerModel->at(index);
|
||||||
|
depth_t oldDepth = data.depth;
|
||||||
|
int oldtime = data.time;
|
||||||
data.depth.mm = lrint(profileYAxis->valueAt(activeHandler->pos()) / M_OR_FT(1, 1)) * M_OR_FT(1, 1);
|
data.depth.mm = lrint(profileYAxis->valueAt(activeHandler->pos()) / M_OR_FT(1, 1)) * M_OR_FT(1, 1);
|
||||||
data.time = lrint(timeAxis->valueAt(activeHandler->pos()));
|
data.time = lrint(timeAxis->valueAt(activeHandler->pos()));
|
||||||
|
|
||||||
|
if (data.depth.mm != oldDepth.mm || data.time != oldtime)
|
||||||
plannerModel->editStop(index, data);
|
plannerModel->editStop(index, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1839,6 +1841,8 @@ void ProfileWidget2::keyDownAction()
|
||||||
return;
|
return;
|
||||||
|
|
||||||
DivePlannerPointsModel *plannerModel = DivePlannerPointsModel::instance();
|
DivePlannerPointsModel *plannerModel = DivePlannerPointsModel::instance();
|
||||||
|
bool oldRecalc = plannerModel->setRecalc(false);
|
||||||
|
|
||||||
Q_FOREACH (QGraphicsItem *i, scene()->selectedItems()) {
|
Q_FOREACH (QGraphicsItem *i, scene()->selectedItems()) {
|
||||||
if (DiveHandler *handler = qgraphicsitem_cast<DiveHandler *>(i)) {
|
if (DiveHandler *handler = qgraphicsitem_cast<DiveHandler *>(i)) {
|
||||||
int row = handles.indexOf(handler);
|
int row = handles.indexOf(handler);
|
||||||
|
@ -1850,6 +1854,8 @@ void ProfileWidget2::keyDownAction()
|
||||||
plannerModel->editStop(row, dp);
|
plannerModel->editStop(row, dp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
plannerModel->setRecalc(oldRecalc);
|
||||||
|
replot();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProfileWidget2::keyUpAction()
|
void ProfileWidget2::keyUpAction()
|
||||||
|
@ -1858,6 +1864,7 @@ void ProfileWidget2::keyUpAction()
|
||||||
return;
|
return;
|
||||||
|
|
||||||
DivePlannerPointsModel *plannerModel = DivePlannerPointsModel::instance();
|
DivePlannerPointsModel *plannerModel = DivePlannerPointsModel::instance();
|
||||||
|
bool oldRecalc = plannerModel->setRecalc(false);
|
||||||
Q_FOREACH (QGraphicsItem *i, scene()->selectedItems()) {
|
Q_FOREACH (QGraphicsItem *i, scene()->selectedItems()) {
|
||||||
if (DiveHandler *handler = qgraphicsitem_cast<DiveHandler *>(i)) {
|
if (DiveHandler *handler = qgraphicsitem_cast<DiveHandler *>(i)) {
|
||||||
int row = handles.indexOf(handler);
|
int row = handles.indexOf(handler);
|
||||||
|
@ -1870,6 +1877,8 @@ void ProfileWidget2::keyUpAction()
|
||||||
plannerModel->editStop(row, dp);
|
plannerModel->editStop(row, dp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
plannerModel->setRecalc(oldRecalc);
|
||||||
|
replot();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProfileWidget2::keyLeftAction()
|
void ProfileWidget2::keyLeftAction()
|
||||||
|
@ -1878,6 +1887,7 @@ void ProfileWidget2::keyLeftAction()
|
||||||
return;
|
return;
|
||||||
|
|
||||||
DivePlannerPointsModel *plannerModel = DivePlannerPointsModel::instance();
|
DivePlannerPointsModel *plannerModel = DivePlannerPointsModel::instance();
|
||||||
|
bool oldRecalc = plannerModel->setRecalc(false);
|
||||||
Q_FOREACH (QGraphicsItem *i, scene()->selectedItems()) {
|
Q_FOREACH (QGraphicsItem *i, scene()->selectedItems()) {
|
||||||
if (DiveHandler *handler = qgraphicsitem_cast<DiveHandler *>(i)) {
|
if (DiveHandler *handler = qgraphicsitem_cast<DiveHandler *>(i)) {
|
||||||
int row = handles.indexOf(handler);
|
int row = handles.indexOf(handler);
|
||||||
|
@ -1903,6 +1913,8 @@ void ProfileWidget2::keyLeftAction()
|
||||||
plannerModel->editStop(row, dp);
|
plannerModel->editStop(row, dp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
plannerModel->setRecalc(oldRecalc);
|
||||||
|
replot();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProfileWidget2::keyRightAction()
|
void ProfileWidget2::keyRightAction()
|
||||||
|
@ -1911,6 +1923,7 @@ void ProfileWidget2::keyRightAction()
|
||||||
return;
|
return;
|
||||||
|
|
||||||
DivePlannerPointsModel *plannerModel = DivePlannerPointsModel::instance();
|
DivePlannerPointsModel *plannerModel = DivePlannerPointsModel::instance();
|
||||||
|
bool oldRecalc = plannerModel->setRecalc(false);
|
||||||
Q_FOREACH (QGraphicsItem *i, scene()->selectedItems()) {
|
Q_FOREACH (QGraphicsItem *i, scene()->selectedItems()) {
|
||||||
if (DiveHandler *handler = qgraphicsitem_cast<DiveHandler *>(i)) {
|
if (DiveHandler *handler = qgraphicsitem_cast<DiveHandler *>(i)) {
|
||||||
int row = handles.indexOf(handler);
|
int row = handles.indexOf(handler);
|
||||||
|
@ -1935,6 +1948,8 @@ void ProfileWidget2::keyRightAction()
|
||||||
plannerModel->editStop(row, dp);
|
plannerModel->editStop(row, dp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
plannerModel->setRecalc(oldRecalc);
|
||||||
|
replot();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProfileWidget2::keyDeleteAction()
|
void ProfileWidget2::keyDeleteAction()
|
||||||
|
|
|
@ -648,6 +648,7 @@ bool CylindersModel::updateBestMixes()
|
||||||
}
|
}
|
||||||
/* This slot is called when the bottom pO2 and END preferences are updated, we want to
|
/* This slot is called when the bottom pO2 and END preferences are updated, we want to
|
||||||
* emit dataChanged so MOD and MND are refreshed, even if the gas mix hasn't been changed */
|
* emit dataChanged so MOD and MND are refreshed, even if the gas mix hasn't been changed */
|
||||||
|
if (gasUpdated)
|
||||||
emit dataChanged(createIndex(0, 0), createIndex(MAX_CYLINDERS - 1, COLUMNS - 1));
|
emit dataChanged(createIndex(0, 0), createIndex(MAX_CYLINDERS - 1, COLUMNS - 1));
|
||||||
return gasUpdated;
|
return gasUpdated;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue