2014-01-14 16:30:13 +00:00
|
|
|
#include "profilewidget2.h"
|
2014-01-15 14:00:23 +00:00
|
|
|
#include "diveplotdatamodel.h"
|
|
|
|
#include "divepixmapitem.h"
|
|
|
|
#include "diverectitem.h"
|
|
|
|
#include "divecartesianaxis.h"
|
|
|
|
#include "diveprofileitem.h"
|
2014-01-15 14:23:40 +00:00
|
|
|
#include "helpers.h"
|
2014-01-15 15:34:55 +00:00
|
|
|
#include "profile.h"
|
2014-01-16 17:02:32 +00:00
|
|
|
#include "diveeventitem.h"
|
2014-01-21 12:48:26 +00:00
|
|
|
#include "divetextitem.h"
|
2014-01-15 14:00:23 +00:00
|
|
|
#include <QStateMachine>
|
2014-01-15 14:34:42 +00:00
|
|
|
#include <QSignalTransition>
|
2014-01-15 15:01:29 +00:00
|
|
|
#include <QPropertyAnimation>
|
2014-01-15 15:04:01 +00:00
|
|
|
#include <QMenu>
|
|
|
|
#include <QContextMenuEvent>
|
2014-01-16 20:39:13 +00:00
|
|
|
#include <QDebug>
|
2014-01-16 17:02:32 +00:00
|
|
|
|
2014-01-15 15:20:05 +00:00
|
|
|
#ifndef QT_NO_DEBUG
|
|
|
|
#include <QTableView>
|
|
|
|
#endif
|
2014-01-16 05:28:33 +00:00
|
|
|
#include "mainwindow.h"
|
2014-01-15 15:20:05 +00:00
|
|
|
|
2014-01-15 14:00:23 +00:00
|
|
|
ProfileWidget2::ProfileWidget2(QWidget *parent) :
|
|
|
|
QGraphicsView(parent),
|
|
|
|
dataModel(new DivePlotDataModel(this)),
|
|
|
|
currentState(INVALID),
|
|
|
|
stateMachine(new QStateMachine(this)),
|
|
|
|
background (new DivePixmapItem()),
|
|
|
|
profileYAxis(new DepthAxis()),
|
|
|
|
gasYAxis(new DiveCartesianAxis()),
|
2014-01-16 23:30:47 +00:00
|
|
|
temperatureAxis(new TemperatureAxis()),
|
2014-01-15 14:00:23 +00:00
|
|
|
timeAxis(new TimeAxis()),
|
|
|
|
depthController(new DiveRectItem()),
|
|
|
|
timeController(new DiveRectItem()),
|
2014-01-17 12:15:41 +00:00
|
|
|
diveProfileItem(NULL),
|
2014-01-17 16:28:59 +00:00
|
|
|
cylinderPressureAxis(new DiveCartesianAxis()),
|
2014-01-17 12:15:41 +00:00
|
|
|
temperatureItem(NULL),
|
2014-01-18 09:35:35 +00:00
|
|
|
gasPressureItem(NULL),
|
2014-01-18 22:38:21 +00:00
|
|
|
cartesianPlane(new DiveCartesianPlane()),
|
2014-01-22 17:08:19 +00:00
|
|
|
meanDepth(new MeanDepthLine()),
|
2014-01-21 16:59:19 +00:00
|
|
|
diveComputerText(new DiveTextItem()),
|
2014-01-21 19:34:36 +00:00
|
|
|
diveCeiling(NULL),
|
|
|
|
reportedCeiling(NULL)
|
2014-01-14 16:30:13 +00:00
|
|
|
{
|
2014-01-15 14:00:23 +00:00
|
|
|
setScene(new QGraphicsScene());
|
|
|
|
scene()->setSceneRect(0, 0, 100, 100);
|
|
|
|
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
|
|
|
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
|
|
|
scene()->setItemIndexMethod(QGraphicsScene::NoIndex);
|
|
|
|
setOptimizationFlags(QGraphicsView::DontSavePainterState);
|
|
|
|
setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
|
|
|
|
setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform);
|
|
|
|
|
|
|
|
// Creating the needed items.
|
|
|
|
// ORDER: {BACKGROUND, PROFILE_Y_AXIS, GAS_Y_AXIS, TIME_AXIS, DEPTH_CONTROLLER, TIME_CONTROLLER, COLUMNS};
|
2014-01-16 21:28:33 +00:00
|
|
|
profileYAxis->setOrientation(DiveCartesianAxis::TopToBottom);
|
|
|
|
gasYAxis->setOrientation(DiveCartesianAxis::TopToBottom);
|
|
|
|
timeAxis->setOrientation(DiveCartesianAxis::LeftToRight);
|
2014-01-15 14:23:40 +00:00
|
|
|
|
2014-01-16 04:50:56 +00:00
|
|
|
// Defaults of the Axis Coordinates:
|
2014-01-15 14:23:40 +00:00
|
|
|
profileYAxis->setMinimum(0);
|
|
|
|
profileYAxis->setTickInterval(M_OR_FT(10,30)); //TODO: This one should be also hooked up on the Settings change.
|
|
|
|
timeAxis->setMinimum(0);
|
|
|
|
timeAxis->setTickInterval(600); // 10 to 10 minutes?
|
|
|
|
|
|
|
|
// Default Sizes of the Items.
|
|
|
|
profileYAxis->setLine(0, 0, 0, 90);
|
|
|
|
profileYAxis->setX(2);
|
|
|
|
profileYAxis->setTickSize(1);
|
|
|
|
gasYAxis->setLine(0, 0, 0, 20);
|
2014-01-16 20:39:13 +00:00
|
|
|
|
2014-01-16 21:28:33 +00:00
|
|
|
temperatureAxis->setOrientation(DiveCartesianAxis::BottomToTop);
|
2014-01-16 20:39:13 +00:00
|
|
|
temperatureAxis->setLine(0, 60, 0, 90);
|
|
|
|
temperatureAxis->setX(3);
|
|
|
|
temperatureAxis->setTickSize(2);
|
|
|
|
temperatureAxis->setTickInterval(300);
|
|
|
|
|
2014-01-17 17:34:15 +00:00
|
|
|
cylinderPressureAxis->setOrientation(DiveCartesianAxis::BottomToTop);
|
2014-01-17 16:28:59 +00:00
|
|
|
cylinderPressureAxis->setLine(0,20,0,60);
|
|
|
|
cylinderPressureAxis->setX(3);
|
|
|
|
cylinderPressureAxis->setTickSize(2);
|
|
|
|
cylinderPressureAxis->setTickInterval(30000);
|
|
|
|
|
2014-01-15 14:23:40 +00:00
|
|
|
timeAxis->setLine(0,0,96,0);
|
|
|
|
timeAxis->setX(3);
|
|
|
|
timeAxis->setTickSize(1);
|
|
|
|
depthController->setRect(0, 0, 10, 5);
|
|
|
|
timeController->setRect(0, 0, 10, 5);
|
|
|
|
timeController->setX(sceneRect().width() - timeController->boundingRect().width()); // Position it on the right spot.
|
2014-01-18 22:38:21 +00:00
|
|
|
meanDepth->setLine(0,0,96,0);
|
|
|
|
meanDepth->setX(3);
|
|
|
|
meanDepth->setPen(QPen(QBrush(Qt::red), 0, Qt::SolidLine));
|
2014-01-22 17:29:25 +00:00
|
|
|
meanDepth->setZValue(1);
|
2014-01-15 14:23:40 +00:00
|
|
|
|
2014-01-16 14:32:45 +00:00
|
|
|
cartesianPlane->setBottomAxis(timeAxis);
|
|
|
|
cartesianPlane->setLeftAxis(profileYAxis);
|
|
|
|
scene()->addItem(cartesianPlane);
|
|
|
|
|
2014-01-21 12:48:26 +00:00
|
|
|
diveComputerText->setAlignment(Qt::AlignLeft | Qt::AlignTop);
|
|
|
|
diveComputerText->setBrush(getColor(TIME_TEXT));
|
|
|
|
|
2014-01-15 14:23:40 +00:00
|
|
|
// insert in the same way it's declared on the Enum. This is needed so we don't use an map.
|
2014-01-16 04:50:56 +00:00
|
|
|
QList<QGraphicsItem*> stateItems; stateItems << background << profileYAxis << gasYAxis <<
|
2014-01-18 22:38:21 +00:00
|
|
|
timeAxis << depthController << timeController <<
|
2014-01-21 12:48:26 +00:00
|
|
|
temperatureAxis << cylinderPressureAxis << diveComputerText <<
|
2014-01-18 22:38:21 +00:00
|
|
|
meanDepth;
|
2014-01-16 04:50:56 +00:00
|
|
|
Q_FOREACH(QGraphicsItem *item, stateItems) {
|
2014-01-15 14:23:40 +00:00
|
|
|
scene()->addItem(item);
|
|
|
|
}
|
|
|
|
|
2014-01-15 14:32:51 +00:00
|
|
|
background->setFlag(QGraphicsItem::ItemIgnoresTransformations);
|
2014-01-15 14:34:42 +00:00
|
|
|
|
2014-01-16 04:50:56 +00:00
|
|
|
//enum State{ EMPTY, PROFILE, EDIT, ADD, PLAN, INVALID };
|
2014-01-15 14:34:42 +00:00
|
|
|
stateMachine = new QStateMachine(this);
|
|
|
|
|
|
|
|
// TopLevel States
|
|
|
|
QState *emptyState = new QState();
|
|
|
|
QState *profileState = new QState();
|
|
|
|
QState *editState = new QState();
|
|
|
|
QState *addState = new QState();
|
|
|
|
QState *planState = new QState();
|
|
|
|
|
|
|
|
// Conections:
|
|
|
|
stateMachine->addState(emptyState);
|
|
|
|
stateMachine->addState(profileState);
|
|
|
|
stateMachine->addState(editState);
|
|
|
|
stateMachine->addState(addState);
|
|
|
|
stateMachine->addState(planState);
|
|
|
|
stateMachine->setInitialState(emptyState);
|
|
|
|
|
|
|
|
// All Empty State Connections.
|
|
|
|
QSignalTransition *tEmptyToProfile = emptyState->addTransition(this, SIGNAL(startProfileState()), profileState);
|
|
|
|
QSignalTransition *tEmptyToAdd = emptyState->addTransition(this, SIGNAL(startAddState()), addState);
|
|
|
|
QSignalTransition *tEmptyToPlan = emptyState->addTransition(this, SIGNAL(startPlanState()), planState);
|
|
|
|
|
|
|
|
// All Plan Connections
|
|
|
|
QSignalTransition *tPlanToEmpty = planState->addTransition(this, SIGNAL(startEmptyState()), emptyState);
|
|
|
|
QSignalTransition *tPlanToProfile = planState->addTransition(this, SIGNAL(startProfileState()), profileState);
|
|
|
|
QSignalTransition *tPlanToAdd = planState->addTransition(this, SIGNAL(startAddState()), addState);
|
|
|
|
|
|
|
|
// All Add Dive Connections
|
|
|
|
QSignalTransition *tAddToEmpty = addState->addTransition(this, SIGNAL(startEmptyState()), emptyState);
|
|
|
|
QSignalTransition *tAddToPlan = addState->addTransition(this, SIGNAL(startPlanState()), planState);
|
|
|
|
QSignalTransition *tAddToProfile = addState->addTransition(this, SIGNAL(startProfileState()), profileState);
|
|
|
|
|
|
|
|
// All Profile State Connections
|
|
|
|
QSignalTransition *tProfileToEdit = profileState->addTransition(this, SIGNAL(startEditState()), editState);
|
|
|
|
QSignalTransition *tProfileToEmpty = profileState->addTransition(this, SIGNAL(startEmptyState()), emptyState);
|
|
|
|
QSignalTransition *tProfileToPlan = profileState->addTransition(this, SIGNAL(startPlanState()), planState);
|
|
|
|
QSignalTransition *tProfileToAdd = profileState->addTransition(this, SIGNAL(startAddState()), addState);
|
|
|
|
|
|
|
|
// All "Edit" state connections
|
|
|
|
QSignalTransition *tEditToEmpty = editState->addTransition(this, SIGNAL(startEmptyState()), emptyState);
|
|
|
|
QSignalTransition *tEditToPlan = editState->addTransition(this, SIGNAL(startPlanState()), planState);
|
|
|
|
QSignalTransition *tEditToProfile = editState->addTransition(this, SIGNAL(startProfileState()), profileState);
|
|
|
|
QSignalTransition *tEditToAdd = editState->addTransition(this, SIGNAL(startAddState()), addState);
|
2014-01-15 14:36:09 +00:00
|
|
|
|
2014-01-16 05:44:18 +00:00
|
|
|
// Constants:
|
2014-01-15 14:36:09 +00:00
|
|
|
const int backgroundOnCanvas = 0;
|
|
|
|
const int backgroundOffCanvas = 110;
|
|
|
|
const int profileYAxisOnCanvas = 3;
|
|
|
|
const int profileYAxisOffCanvas = profileYAxis->boundingRect().width() - 10;
|
2014-01-16 05:44:18 +00:00
|
|
|
// unused so far:
|
|
|
|
// const int gasYAxisOnCanvas = gasYAxis->boundingRect().width();
|
2014-01-15 14:36:09 +00:00
|
|
|
const int depthControllerOnCanvas = sceneRect().height() - depthController->boundingRect().height();
|
|
|
|
const int timeControllerOnCanvas = sceneRect().height() - timeController->boundingRect().height();
|
|
|
|
const int gasYAxisOffCanvas = gasYAxis->boundingRect().width() - 10;
|
|
|
|
const int timeAxisOnCanvas = sceneRect().height() - timeAxis->boundingRect().height() - 4;
|
|
|
|
const int timeAxisOffCanvas = sceneRect().height() + timeAxis->boundingRect().height();
|
|
|
|
const int timeAxisEditMode = sceneRect().height() - timeAxis->boundingRect().height() - depthController->boundingRect().height();
|
|
|
|
const int depthControllerOffCanvas = sceneRect().height() + depthController->boundingRect().height();
|
|
|
|
const int timeControllerOffCanvas = sceneRect().height() + timeController->boundingRect().height();
|
|
|
|
const QLineF profileYAxisExpanded = QLineF(0,0,0,timeAxisOnCanvas);
|
2014-01-16 05:44:18 +00:00
|
|
|
// unused so far:
|
|
|
|
// const QLineF timeAxisLine = QLineF(0, 0, 96, 0);
|
2014-01-15 14:36:09 +00:00
|
|
|
|
2014-01-16 04:50:56 +00:00
|
|
|
// State Defaults:
|
2014-01-15 14:43:44 +00:00
|
|
|
// Empty State, everything but the background is hidden.
|
|
|
|
emptyState->assignProperty(this, "backgroundBrush", QBrush(Qt::white));
|
|
|
|
emptyState->assignProperty(background, "y", backgroundOnCanvas);
|
|
|
|
emptyState->assignProperty(profileYAxis, "x", profileYAxisOffCanvas);
|
|
|
|
emptyState->assignProperty(gasYAxis, "x", gasYAxisOffCanvas);
|
|
|
|
emptyState->assignProperty(timeAxis, "y", timeAxisOffCanvas);
|
|
|
|
emptyState->assignProperty(depthController, "y", depthControllerOffCanvas);
|
|
|
|
emptyState->assignProperty(timeController, "y", timeControllerOffCanvas);
|
|
|
|
|
2014-01-16 04:50:56 +00:00
|
|
|
// Profile, everything but the background, depthController and timeController are shown.
|
2014-01-15 14:43:44 +00:00
|
|
|
profileState->assignProperty(this, "backgroundBrush", getColor(::BACKGROUND));
|
|
|
|
profileState->assignProperty(background, "y", backgroundOffCanvas);
|
|
|
|
profileState->assignProperty(profileYAxis, "x", profileYAxisOnCanvas);
|
|
|
|
profileState->assignProperty(profileYAxis, "line", profileYAxisExpanded);
|
|
|
|
profileState->assignProperty(gasYAxis, "x", 0);
|
|
|
|
profileState->assignProperty(timeAxis, "y", timeAxisOnCanvas);
|
|
|
|
profileState->assignProperty(depthController, "y", depthControllerOffCanvas);
|
|
|
|
profileState->assignProperty(timeController, "y", timeControllerOffCanvas);
|
2014-01-16 14:32:45 +00:00
|
|
|
profileState->assignProperty(cartesianPlane, "verticalLine", profileYAxisExpanded);
|
|
|
|
profileState->assignProperty(cartesianPlane, "horizontalLine", timeAxis->line());
|
2014-01-15 14:43:44 +00:00
|
|
|
|
|
|
|
// Edit, everything but the background and gasYAxis are shown.
|
|
|
|
editState->assignProperty(this, "backgroundBrush", QBrush(Qt::darkGray));
|
|
|
|
editState->assignProperty(background, "y", backgroundOffCanvas);
|
|
|
|
editState->assignProperty(profileYAxis, "x", profileYAxisOnCanvas);
|
|
|
|
editState->assignProperty(profileYAxis, "line", profileYAxisExpanded);
|
|
|
|
editState->assignProperty(gasYAxis, "x", gasYAxisOffCanvas);
|
|
|
|
editState->assignProperty(timeAxis, "y", timeAxisEditMode);
|
|
|
|
editState->assignProperty(depthController, "y", depthControllerOnCanvas);
|
|
|
|
editState->assignProperty(timeController, "y", timeControllerOnCanvas);
|
|
|
|
|
|
|
|
// Add, everything but the background and gasYAxis are shown.
|
|
|
|
addState->assignProperty(this, "backgroundBrush", QBrush(Qt::darkGray));
|
|
|
|
addState->assignProperty(background, "y", backgroundOffCanvas);
|
|
|
|
addState->assignProperty(profileYAxis, "x", profileYAxisOnCanvas);
|
|
|
|
addState->assignProperty(profileYAxis, "rect", profileYAxisExpanded);
|
|
|
|
addState->assignProperty(gasYAxis, "x", gasYAxisOffCanvas);
|
|
|
|
addState->assignProperty(timeAxis, "y", timeAxisEditMode);
|
|
|
|
addState->assignProperty(depthController, "y", depthControllerOnCanvas);
|
|
|
|
addState->assignProperty(timeController, "y", timeControllerOnCanvas);
|
|
|
|
|
|
|
|
// Plan, everything but the background and gasYAxis are shown.
|
|
|
|
planState->assignProperty(this, "backgroundBrush", QBrush(Qt::darkGray));
|
|
|
|
planState->assignProperty(background, "y", backgroundOffCanvas);
|
|
|
|
planState->assignProperty(profileYAxis, "x", profileYAxisOnCanvas);
|
|
|
|
planState->assignProperty(profileYAxis, "line", profileYAxisExpanded);
|
|
|
|
planState->assignProperty(gasYAxis, "x", gasYAxisOffCanvas);
|
|
|
|
planState->assignProperty(timeAxis, "y", timeAxisEditMode);
|
|
|
|
planState->assignProperty(depthController, "y", depthControllerOnCanvas);
|
|
|
|
planState->assignProperty(timeController, "y", timeControllerOnCanvas);
|
|
|
|
|
2014-01-15 15:01:29 +00:00
|
|
|
// All animations for the State Transitions.
|
|
|
|
QPropertyAnimation *backgroundYAnim = new QPropertyAnimation(background, "y");
|
|
|
|
QPropertyAnimation *depthAxisAnim = new QPropertyAnimation(profileYAxis, "x");
|
|
|
|
QPropertyAnimation *gasAxisanim = new QPropertyAnimation(gasYAxis, "x");
|
|
|
|
QPropertyAnimation *timeAxisAnim = new QPropertyAnimation(timeAxis, "y");
|
|
|
|
QPropertyAnimation *depthControlAnim = new QPropertyAnimation(depthController, "y");
|
|
|
|
QPropertyAnimation *timeControlAnim = new QPropertyAnimation(timeController, "y");
|
|
|
|
QPropertyAnimation *profileAxisAnim = new QPropertyAnimation(profileYAxis, "line");
|
|
|
|
|
|
|
|
// Animations
|
|
|
|
QList<QSignalTransition*> transitions;
|
2014-01-16 04:50:56 +00:00
|
|
|
transitions << tAddToEmpty << tAddToPlan << tAddToProfile << tEditToAdd << tEditToEmpty << tEditToPlan <<
|
|
|
|
tEditToProfile << tEmptyToAdd << tEmptyToPlan << tEmptyToProfile << tProfileToAdd <<
|
|
|
|
tProfileToEdit << tProfileToEmpty << tProfileToPlan << tPlanToAdd << tPlanToEmpty << tPlanToProfile;
|
|
|
|
Q_FOREACH(QSignalTransition *s, transitions) {
|
2014-01-15 15:01:29 +00:00
|
|
|
s->addAnimation(backgroundYAnim);
|
|
|
|
s->addAnimation(depthAxisAnim);
|
|
|
|
s->addAnimation(gasAxisanim);
|
|
|
|
s->addAnimation(timeAxisAnim);
|
|
|
|
s->addAnimation(depthControlAnim);
|
|
|
|
s->addAnimation(timeControlAnim);
|
|
|
|
s->addAnimation(profileAxisAnim);
|
|
|
|
}
|
|
|
|
|
2014-01-15 15:05:14 +00:00
|
|
|
// Configuration so we can search for the States later, and it helps debugging.
|
|
|
|
emptyState->setObjectName("Empty State");
|
|
|
|
profileState->setObjectName("Profile State");
|
|
|
|
addState->setObjectName("Add State");
|
|
|
|
editState->setObjectName("Edit State");
|
|
|
|
planState->setObjectName("Plan State");
|
2014-01-15 15:06:56 +00:00
|
|
|
|
|
|
|
// Starting the transitions:
|
|
|
|
stateMachine->start();
|
2014-01-15 15:20:05 +00:00
|
|
|
|
|
|
|
#ifndef QT_NO_DEBUG
|
|
|
|
QTableView *diveDepthTableView = new QTableView();
|
|
|
|
diveDepthTableView->setModel(dataModel);
|
|
|
|
mainWindow()->tabWidget()->addTab(diveDepthTableView, "Depth Model");
|
|
|
|
#endif
|
2014-01-14 16:30:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Currently just one dive, but the plan is to enable All of the selected dives.
|
|
|
|
void ProfileWidget2::plotDives(QList<dive*> dives)
|
|
|
|
{
|
2014-01-15 15:34:55 +00:00
|
|
|
// I Know that it's a list, but currently we are
|
|
|
|
// using just the first.
|
|
|
|
struct dive *d = dives.first();
|
2014-01-16 04:50:56 +00:00
|
|
|
if (!d)
|
2014-01-15 15:34:55 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
// Here we need to probe for the limits of the dive.
|
|
|
|
// There's already a function that does exactly that,
|
|
|
|
// but it's using the graphics context, and I need to
|
|
|
|
// replace that.
|
|
|
|
struct divecomputer *currentdc = select_dc(&d->dc);
|
|
|
|
Q_ASSERT(currentdc);
|
|
|
|
|
|
|
|
/* This struct holds all the data that's about to be plotted.
|
|
|
|
* I'm not sure this is the best approach ( but since we are
|
|
|
|
* interpolating some points of the Dive, maybe it is... )
|
|
|
|
* The Calculation of the points should be done per graph,
|
|
|
|
* so I'll *not* calculate everything if something is not being
|
|
|
|
* shown.
|
|
|
|
*/
|
|
|
|
struct plot_info pInfo = calculate_max_limits_new(d, currentdc);
|
2014-01-17 16:43:25 +00:00
|
|
|
create_plot_info_new(d, currentdc, &pInfo);
|
2014-01-15 20:03:58 +00:00
|
|
|
int maxtime = get_maxtime(&pInfo);
|
|
|
|
int maxdepth = get_maxdepth(&pInfo);
|
2014-01-15 15:34:55 +00:00
|
|
|
|
2014-01-16 17:02:32 +00:00
|
|
|
// It seems that I'll have a lot of boilerplate setting the model / axis for
|
|
|
|
// each item, I'll mostly like to fix this in the future, but I'll keep at this for now.
|
2014-01-18 22:33:12 +00:00
|
|
|
profileYAxis->setMaximum(maxdepth);
|
2014-01-15 15:34:55 +00:00
|
|
|
profileYAxis->updateTicks();
|
2014-01-16 20:39:13 +00:00
|
|
|
temperatureAxis->setMinimum(pInfo.mintemp);
|
|
|
|
temperatureAxis->setMaximum(pInfo.maxtemp);
|
2014-01-15 20:03:58 +00:00
|
|
|
timeAxis->setMaximum(maxtime);
|
2014-01-15 15:34:55 +00:00
|
|
|
timeAxis->updateTicks();
|
2014-01-17 16:28:59 +00:00
|
|
|
cylinderPressureAxis->setMinimum(pInfo.minpressure);
|
|
|
|
cylinderPressureAxis->setMaximum(pInfo.maxpressure);
|
2014-01-22 17:08:19 +00:00
|
|
|
meanDepth->setMeanDepth(pInfo.meandepth);
|
2014-01-18 22:38:21 +00:00
|
|
|
meanDepth->animateMoveTo(3, profileYAxis->posAtValue(pInfo.meandepth));
|
2014-01-15 15:34:55 +00:00
|
|
|
dataModel->setDive(current_dive, pInfo);
|
|
|
|
|
2014-01-16 04:50:56 +00:00
|
|
|
if (diveProfileItem) {
|
2014-01-15 15:34:55 +00:00
|
|
|
//diveProfileItem->animateDelete();
|
|
|
|
scene()->removeItem(diveProfileItem);
|
|
|
|
delete diveProfileItem;
|
|
|
|
}
|
|
|
|
diveProfileItem = new DiveProfileItem();
|
|
|
|
diveProfileItem->setHorizontalAxis(timeAxis);
|
|
|
|
diveProfileItem->setVerticalAxis(profileYAxis);
|
|
|
|
diveProfileItem->setModel(dataModel);
|
|
|
|
diveProfileItem->setVerticalDataColumn(DivePlotDataModel::DEPTH);
|
|
|
|
diveProfileItem->setHorizontalDataColumn(DivePlotDataModel::TIME);
|
2014-01-22 17:29:25 +00:00
|
|
|
diveProfileItem->setZValue(0);
|
2014-01-15 15:34:55 +00:00
|
|
|
scene()->addItem(diveProfileItem);
|
2014-01-16 17:02:32 +00:00
|
|
|
|
|
|
|
qDeleteAll(eventItems);
|
|
|
|
eventItems.clear();
|
|
|
|
|
|
|
|
struct event *event = currentdc->events;
|
|
|
|
while (event) {
|
|
|
|
DiveEventItem *item = new DiveEventItem();
|
|
|
|
item->setHorizontalAxis(timeAxis);
|
|
|
|
item->setVerticalAxis(profileYAxis);
|
|
|
|
item->setModel(dataModel);
|
|
|
|
item->setEvent(event);
|
2014-01-19 22:16:08 +00:00
|
|
|
item->setZValue(2);
|
2014-01-16 17:02:32 +00:00
|
|
|
scene()->addItem(item);
|
|
|
|
eventItems.push_back(item);
|
|
|
|
event = event->next;
|
|
|
|
}
|
2014-01-16 20:39:13 +00:00
|
|
|
|
|
|
|
if(temperatureItem){
|
|
|
|
scene()->removeItem(temperatureItem);
|
|
|
|
delete temperatureItem;
|
|
|
|
}
|
|
|
|
temperatureItem = new DiveTemperatureItem();
|
|
|
|
temperatureItem->setHorizontalAxis(timeAxis);
|
|
|
|
temperatureItem->setVerticalAxis(temperatureAxis);
|
|
|
|
temperatureItem->setModel(dataModel);
|
|
|
|
temperatureItem->setVerticalDataColumn(DivePlotDataModel::TEMPERATURE);
|
|
|
|
temperatureItem->setHorizontalDataColumn(DivePlotDataModel::TIME);
|
2014-01-22 17:29:25 +00:00
|
|
|
temperatureItem->setZValue(1);
|
2014-01-16 20:39:13 +00:00
|
|
|
scene()->addItem(temperatureItem);
|
|
|
|
|
2014-01-17 17:34:15 +00:00
|
|
|
if(gasPressureItem){
|
|
|
|
scene()->removeItem(gasPressureItem);
|
|
|
|
delete gasPressureItem;
|
|
|
|
}
|
|
|
|
gasPressureItem = new DiveGasPressureItem();
|
|
|
|
gasPressureItem->setHorizontalAxis(timeAxis);
|
|
|
|
gasPressureItem->setVerticalAxis(cylinderPressureAxis);
|
|
|
|
gasPressureItem->setModel(dataModel);
|
|
|
|
gasPressureItem->setVerticalDataColumn(DivePlotDataModel::TEMPERATURE);
|
|
|
|
gasPressureItem->setHorizontalDataColumn(DivePlotDataModel::TIME);
|
2014-01-22 17:29:25 +00:00
|
|
|
gasPressureItem->setZValue(1);
|
2014-01-17 17:34:15 +00:00
|
|
|
scene()->addItem(gasPressureItem);
|
|
|
|
|
2014-01-21 16:59:19 +00:00
|
|
|
if(diveCeiling){
|
|
|
|
scene()->removeItem(diveCeiling);
|
|
|
|
delete diveCeiling;
|
|
|
|
}
|
|
|
|
diveCeiling = new DiveCalculatedCeiling();
|
|
|
|
diveCeiling->setHorizontalAxis(timeAxis);
|
|
|
|
diveCeiling->setVerticalAxis(profileYAxis);
|
|
|
|
diveCeiling->setModel(dataModel);
|
|
|
|
diveCeiling->setVerticalDataColumn(DivePlotDataModel::CEILING);
|
|
|
|
diveCeiling->setHorizontalDataColumn(DivePlotDataModel::TIME);
|
2014-01-22 17:29:25 +00:00
|
|
|
diveCeiling->setZValue(1);
|
2014-01-21 16:59:19 +00:00
|
|
|
scene()->addItem(diveCeiling);
|
|
|
|
|
2014-01-21 12:48:26 +00:00
|
|
|
diveComputerText->setText(currentdc->model);
|
2014-01-21 15:27:08 +00:00
|
|
|
diveComputerText->animateMoveTo(1 , sceneRect().height());
|
2014-01-21 12:48:26 +00:00
|
|
|
|
2014-01-21 17:31:56 +00:00
|
|
|
qDeleteAll(allTissues);
|
2014-01-21 17:42:33 +00:00
|
|
|
allTissues.clear();
|
2014-01-21 17:31:56 +00:00
|
|
|
for(int i = 0; i < 16; i++){
|
|
|
|
DiveCalculatedCeiling *tissueItem = new DiveCalculatedCeiling();
|
|
|
|
tissueItem->setHorizontalAxis(timeAxis);
|
|
|
|
tissueItem->setVerticalAxis(profileYAxis);
|
|
|
|
tissueItem->setModel(dataModel);
|
|
|
|
tissueItem->setVerticalDataColumn(DivePlotDataModel::TISSUE_1 + i);
|
|
|
|
tissueItem->setHorizontalDataColumn(DivePlotDataModel::TIME);
|
2014-01-22 17:29:25 +00:00
|
|
|
tissueItem->setZValue(1);
|
2014-01-21 17:42:33 +00:00
|
|
|
allTissues.append(tissueItem);
|
2014-01-21 17:31:56 +00:00
|
|
|
scene()->addItem(tissueItem);
|
|
|
|
}
|
2014-01-21 19:34:36 +00:00
|
|
|
|
|
|
|
if(reportedCeiling){
|
|
|
|
scene()->removeItem(reportedCeiling);
|
|
|
|
delete reportedCeiling;
|
|
|
|
}
|
|
|
|
reportedCeiling = new DiveReportedCeiling();
|
|
|
|
reportedCeiling->setHorizontalAxis(timeAxis);
|
|
|
|
reportedCeiling->setVerticalAxis(profileYAxis);
|
|
|
|
reportedCeiling->setModel(dataModel);
|
|
|
|
reportedCeiling->setVerticalDataColumn(DivePlotDataModel::CEILING);
|
|
|
|
reportedCeiling->setHorizontalDataColumn(DivePlotDataModel::TIME);
|
2014-01-22 17:29:25 +00:00
|
|
|
reportedCeiling->setZValue(1);
|
2014-01-21 19:34:36 +00:00
|
|
|
scene()->addItem(reportedCeiling);
|
2014-01-15 15:34:55 +00:00
|
|
|
emit startProfileState();
|
2014-01-14 16:30:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ProfileWidget2::settingsChanged()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void ProfileWidget2::contextMenuEvent(QContextMenuEvent* event)
|
|
|
|
{
|
2014-01-15 15:04:01 +00:00
|
|
|
// this menu should be completely replaced when things are working.
|
|
|
|
QMenu m;
|
|
|
|
m.addAction("Set Empty", this, SIGNAL(startEmptyState()));
|
|
|
|
m.addAction("Set Profile", this, SIGNAL(startProfileState()));
|
|
|
|
m.addAction("Set Add", this, SIGNAL(startAddState()));
|
|
|
|
m.addAction("Set Edit", this, SIGNAL(startEditState()));
|
|
|
|
m.addAction("Set Plan", this, SIGNAL(startPlanState()));
|
|
|
|
m.exec(event->globalPos());
|
2014-01-14 16:30:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ProfileWidget2::resizeEvent(QResizeEvent* event)
|
|
|
|
{
|
2014-01-15 14:55:33 +00:00
|
|
|
QGraphicsView::resizeEvent(event);
|
|
|
|
fitInView(sceneRect(), Qt::IgnoreAspectRatio);
|
2014-01-14 16:30:13 +00:00
|
|
|
|
2014-01-16 04:50:56 +00:00
|
|
|
if (!stateMachine->configuration().count())
|
2014-01-15 14:55:33 +00:00
|
|
|
return;
|
|
|
|
|
2014-01-16 04:50:56 +00:00
|
|
|
if ((*stateMachine->configuration().begin())->objectName() == "Empty State") {
|
2014-01-15 14:55:33 +00:00
|
|
|
fixBackgroundPos();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ProfileWidget2::fixBackgroundPos()
|
|
|
|
{
|
2014-01-17 12:18:03 +00:00
|
|
|
QPixmap toBeScaled(":background");
|
|
|
|
if (toBeScaled.isNull())
|
|
|
|
return;
|
|
|
|
QPixmap p = toBeScaled.scaledToHeight(viewport()->height());
|
|
|
|
|
2014-01-16 04:50:56 +00:00
|
|
|
int x = viewport()->width() / 2 - p.width() / 2;
|
2014-01-15 14:55:33 +00:00
|
|
|
DivePixmapItem *bg = background;
|
|
|
|
bg->setPixmap(p);
|
|
|
|
bg->setX(mapToScene(x, 0).x());
|
2014-01-14 16:30:13 +00:00
|
|
|
}
|