mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Profile now correctly displays the planned dive.
But it doesn't move the handlers yet, and when you confirm it you also must click on the dive to select it or the profile will show garbage. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
c6ad04d076
commit
f99ccc8ac2
5 changed files with 58 additions and 34 deletions
|
@ -150,13 +150,6 @@ DivePlannerGraphics::DivePlannerGraphics(QWidget *parent) : QGraphicsView(parent
|
|||
ADD_ACTION(Qt::Key_Right, keyRightAction());
|
||||
#undef ADD_ACTION
|
||||
|
||||
connect(plannerModel, SIGNAL(dataChanged(QModelIndex, QModelIndex)), this, SLOT(drawProfile()));
|
||||
connect(plannerModel, SIGNAL(cylinderModelEdited()), this, SLOT(drawProfile()));
|
||||
|
||||
connect(plannerModel, SIGNAL(rowsInserted(const QModelIndex &, int, int)),
|
||||
this, SLOT(pointInserted(const QModelIndex &, int, int)));
|
||||
connect(plannerModel, SIGNAL(rowsRemoved(const QModelIndex &, int, int)),
|
||||
this, SLOT(pointsRemoved(const QModelIndex &, int, int)));
|
||||
setRenderHint(QPainter::Antialiasing);
|
||||
}
|
||||
|
||||
|
@ -504,23 +497,6 @@ void DivePlannerGraphics::drawProfile()
|
|||
depthLine->updateTicks();
|
||||
}
|
||||
|
||||
// Re-position the user generated dive handlers
|
||||
int last = 0;
|
||||
for (int i = 0; i < plannerModel->rowCount(); i++) {
|
||||
struct divedatapoint datapoint = plannerModel->at(i);
|
||||
if (datapoint.time == 0) // those are the magic entries for tanks
|
||||
continue;
|
||||
DiveHandler *h = handles.at(i);
|
||||
h->setPos(timeLine->posAtValue(datapoint.time / 60), depthLine->posAtValue(datapoint.depth));
|
||||
QPointF p1 = (last == i) ? QPointF(timeLine->posAtValue(0), depthLine->posAtValue(0)) : handles[last]->pos();
|
||||
QPointF p2 = handles[i]->pos();
|
||||
QLineF line(p1, p2);
|
||||
QPointF pos = line.pointAt(0.5);
|
||||
gases[i]->setPos(pos);
|
||||
gases[i]->setText(dpGasToStr(plannerModel->at(i)));
|
||||
last = i;
|
||||
}
|
||||
|
||||
// (re-) create the profile with different colors for segments that were
|
||||
// entered vs. segments that were calculated
|
||||
double lastx = timeLine->posAtValue(0);
|
||||
|
@ -1379,7 +1355,7 @@ void DivePlannerPointsModel::remove(const QModelIndex &index)
|
|||
endRemoveRows();
|
||||
}
|
||||
|
||||
struct diveplan DivePlannerPointsModel::getDiveplan()
|
||||
struct diveplan& DivePlannerPointsModel::getDiveplan()
|
||||
{
|
||||
return diveplan;
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ public:
|
|||
void editStop(int row, divedatapoint newData);
|
||||
divedatapoint at(int row);
|
||||
int size();
|
||||
struct diveplan getDiveplan();
|
||||
struct diveplan& getDiveplan();
|
||||
QStringList &getGasList();
|
||||
QVector<QPair<int, int> > collectGases(dive *d);
|
||||
int lastEnteredPoint();
|
||||
|
@ -276,4 +276,7 @@ private:
|
|||
Ui::DivePlanner ui;
|
||||
};
|
||||
|
||||
QString gasToStr(const int o2Permille, const int hePermille);
|
||||
QString dpGasToStr(const divedatapoint &p);
|
||||
|
||||
#endif // DIVEPLANNER_H
|
||||
|
|
|
@ -410,10 +410,11 @@ void MainWindow::on_actionAddDive_triggered()
|
|||
ui.InfoWidget->updateDiveInfo(selected_dive);
|
||||
ui.InfoWidget->addDiveStarted();
|
||||
ui.infoPane->setCurrentIndex(MAINTAB);
|
||||
|
||||
ui.newProfile->setAddState();
|
||||
DivePlannerPointsModel::instance()->clear();
|
||||
DivePlannerPointsModel::instance()->createSimpleDive();
|
||||
ui.ListWidget->reload(DiveTripModel::CURRENT);
|
||||
ui.newProfile->setAddState();
|
||||
}
|
||||
|
||||
void MainWindow::on_actionRenumber_triggered()
|
||||
|
|
|
@ -138,7 +138,7 @@ void ProfileWidget2::addItemsToScene()
|
|||
scene()->addItem(rulerItem);
|
||||
scene()->addItem(rulerItem->sourceNode());
|
||||
scene()->addItem(rulerItem->destNode());
|
||||
Q_FOREACH(DiveCalculatedTissue * tissue, allTissues) {
|
||||
Q_FOREACH (DiveCalculatedTissue * tissue, allTissues) {
|
||||
scene()->addItem(tissue);
|
||||
}
|
||||
}
|
||||
|
@ -343,6 +343,19 @@ void ProfileWidget2::plotDives(QList<dive *> dives)
|
|||
if (!d)
|
||||
return;
|
||||
|
||||
//TODO: This is a temporary hack to help me understand the Planner.
|
||||
// It seems that each time the 'createTemporaryPlan' runs, a new
|
||||
// dive is created, and thus, we can plot that. hm...
|
||||
if (currentState == ADD) {
|
||||
DivePlannerPointsModel *plannerModel = DivePlannerPointsModel::instance();
|
||||
plannerModel->createTemporaryPlan();
|
||||
if (!plannerModel->getDiveplan().dp) {
|
||||
plannerModel->deleteTemporaryPlan();
|
||||
return;
|
||||
}
|
||||
}
|
||||
//END
|
||||
|
||||
int animSpeedBackup = -1;
|
||||
if (firstCall && MainWindow::instance()->filesFromCommandLine()) {
|
||||
animSpeedBackup = prefs.animation;
|
||||
|
@ -478,6 +491,12 @@ void ProfileWidget2::plotDives(QList<dive *> dives)
|
|||
if (MainWindow::instance()->filesFromCommandLine() && animSpeedBackup != -1) {
|
||||
prefs.animation = animSpeedBackup;
|
||||
}
|
||||
|
||||
if (currentState == ADD) { // TODO: figure a way to move this from here.
|
||||
repositionDiveHandlers();
|
||||
DivePlannerPointsModel *model = DivePlannerPointsModel::instance();
|
||||
model->deleteTemporaryPlan();
|
||||
}
|
||||
}
|
||||
|
||||
void ProfileWidget2::settingsChanged()
|
||||
|
@ -644,11 +663,6 @@ void ProfileWidget2::setProfileState()
|
|||
if (currentState == PROFILE)
|
||||
return;
|
||||
|
||||
if (dive_table.nr == 0) { // oops, called to plot something with zero dives. bail out.
|
||||
setEmptyState();
|
||||
return;
|
||||
}
|
||||
|
||||
disconnectTemporaryConnections();
|
||||
currentState = PROFILE;
|
||||
MainWindow::instance()->setToolButtonsEnabled(true);
|
||||
|
@ -709,7 +723,15 @@ void ProfileWidget2::setAddState()
|
|||
if (currentState == ADD)
|
||||
return;
|
||||
|
||||
setProfileState();
|
||||
disconnectTemporaryConnections();
|
||||
DivePlannerPointsModel *plannerModel = DivePlannerPointsModel::instance();
|
||||
connect(plannerModel, SIGNAL(dataChanged(QModelIndex, QModelIndex)), this, SLOT(replot()));
|
||||
connect(plannerModel, SIGNAL(cylinderModelEdited()), this, SLOT(replot()));
|
||||
connect(plannerModel, SIGNAL(rowsInserted(const QModelIndex &, int, int)),
|
||||
this, SLOT(pointInserted(const QModelIndex &, int, int)));
|
||||
connect(plannerModel, SIGNAL(rowsRemoved(const QModelIndex &, int, int)),
|
||||
this, SLOT(pointsRemoved(const QModelIndex &, int, int)));
|
||||
/* show the same stuff that the profile shows. */
|
||||
currentState = ADD; /* enable the add state. */
|
||||
setBackgroundBrush(QColor(Qt::blue).light());
|
||||
|
@ -719,7 +741,7 @@ void ProfileWidget2::setPlanState()
|
|||
{
|
||||
if (currentState == PLAN)
|
||||
return;
|
||||
|
||||
setProfileState();
|
||||
disconnectTemporaryConnections();
|
||||
/* show the same stuff that the profile shows. */
|
||||
currentState = PLAN; /* enable the add state. */
|
||||
|
@ -964,3 +986,24 @@ void ProfileWidget2::pointsRemoved(const QModelIndex &, int start, int end)
|
|||
scene()->clearSelection();
|
||||
replot();
|
||||
}
|
||||
|
||||
void ProfileWidget2::repositionDiveHandlers()
|
||||
{
|
||||
DivePlannerPointsModel *plannerModel = DivePlannerPointsModel::instance();
|
||||
// Re-position the user generated dive handlers
|
||||
int last = 0;
|
||||
for (int i = 0; i < plannerModel->rowCount(); i++) {
|
||||
struct divedatapoint datapoint = plannerModel->at(i);
|
||||
if (datapoint.time == 0) // those are the magic entries for tanks
|
||||
continue;
|
||||
DiveHandler *h = handles.at(i);
|
||||
h->setPos(timeAxis->posAtValue(datapoint.time), profileYAxis->posAtValue(datapoint.depth));
|
||||
QPointF p1 = (last == i) ? QPointF(timeAxis->posAtValue(0), profileYAxis->posAtValue(0)) : handles[last]->pos();
|
||||
QPointF p2 = handles[i]->pos();
|
||||
QLineF line(p1, p2);
|
||||
QPointF pos = line.pointAt(0.5);
|
||||
gases[i]->setPos(pos);
|
||||
gases[i]->setText(dpGasToStr(plannerModel->at(i)));
|
||||
last = i;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -145,6 +145,7 @@ private:
|
|||
//specifics for ADD and PLAN
|
||||
QList<DiveHandler *> handles;
|
||||
QList<QGraphicsSimpleTextItem *> gases;
|
||||
void repositionDiveHandlers();
|
||||
};
|
||||
|
||||
#endif // PROFILEWIDGET2_H
|
||||
|
|
Loading…
Add table
Reference in a new issue