Planner: Change when we recalculate deco

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Robert C. Helling 2014-04-24 16:42:10 +02:00 committed by Dirk Hohndel
parent 84414baece
commit 00e7ef2cf8
2 changed files with 19 additions and 6 deletions

View file

@ -454,6 +454,15 @@ QStringList &DivePlannerPointsModel::getGasList()
return list; return list;
} }
void DivePlannerPointsModel::removeDeco()
{
QVector<int> computedPoints;
for (int i = 0; i < plannerModel->rowCount(); i++)
if (!plannerModel->at(i).entered)
computedPoints.push_back(i);
removeSelectedPoints(computedPoints);
}
void DivePlannerGraphics::drawProfile() void DivePlannerGraphics::drawProfile()
{ {
if (!plannerModel->recalcQ()) if (!plannerModel->recalcQ())
@ -514,11 +523,7 @@ void DivePlannerGraphics::drawProfile()
poly.append(QPointF(lastx, lasty)); poly.append(QPointF(lastx, lasty));
bool oldRecalc = plannerModel->setRecalc(false); bool oldRecalc = plannerModel->setRecalc(false);
QVector<int> computedPoints; plannerModel->removeDeco();
for (int i = 0; i < plannerModel->rowCount(); i++)
if (!plannerModel->at(i).entered)
computedPoints.push_back(i);
plannerModel->removeSelectedPoints(computedPoints);
unsigned int lastdepth = 0; unsigned int lastdepth = 0;
for (dp = diveplan.dp; dp != NULL; dp = dp->next) { for (dp = diveplan.dp; dp != NULL; dp = dp->next) {
@ -1529,7 +1534,8 @@ void DivePlannerPointsModel::createTemporaryPlan()
#if DEBUG_PLAN #if DEBUG_PLAN
dump_plan(&diveplan); dump_plan(&diveplan);
#endif #endif
plan(&diveplan, &cache, &tempDive, isPlanner()); if (plannerModel->recalcQ())
plan(&diveplan, &cache, &tempDive, isPlanner());
if (mode == ADD) { if (mode == ADD) {
// copy the samples and events, but don't overwrite the cylinders // copy the samples and events, but don't overwrite the cylinders
copy_samples(tempDive, current_dive); copy_samples(tempDive, current_dive);
@ -1569,7 +1575,11 @@ void DivePlannerPointsModel::createPlan()
if (!diveplan.dp) if (!diveplan.dp)
return cancelPlan(); return cancelPlan();
bool oldRecalc = plannerModel->setRecalc(false);
removeDeco();
createTemporaryPlan(); createTemporaryPlan();
plannerModel->setRecalc(oldRecalc);
//TODO: C-based function here? //TODO: C-based function here?
plan(&diveplan, &cache, &tempDive, isPlanner()); plan(&diveplan, &cache, &tempDive, isPlanner());
copy_cylinders(stagingDive, tempDive); copy_cylinders(stagingDive, tempDive);
@ -1601,8 +1611,10 @@ void DivePlannerPointsModel::createPlan()
setPlanMode(NOTHING); setPlanMode(NOTHING);
free(stagingDive); free(stagingDive);
stagingDive = NULL; stagingDive = NULL;
oldRecalc = plannerModel->setRecalc(false);
CylindersModel::instance()->setDive(current_dive); CylindersModel::instance()->setDive(current_dive);
CylindersModel::instance()->update(); CylindersModel::instance()->update();
plannerModel->setRecalc(oldRecalc);
} }
ExpanderGraphics::ExpanderGraphics(QGraphicsItem *parent) : QGraphicsRectItem(parent), ExpanderGraphics::ExpanderGraphics(QGraphicsItem *parent) : QGraphicsRectItem(parent),

View file

@ -58,6 +58,7 @@ public:
QStringList &getGasList(); QStringList &getGasList();
QVector<QPair<int, int> > collectGases(dive *d); QVector<QPair<int, int> > collectGases(dive *d);
int lastEnteredPoint(); int lastEnteredPoint();
void removeDeco();
static bool addingDeco; static bool addingDeco;
public public