summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--qt-ui/profile/diveplotdatamodel.cpp18
-rw-r--r--qt-ui/profile/diveplotdatamodel.h2
-rw-r--r--qt-ui/profile/diveprofileitem.cpp50
-rw-r--r--qt-ui/profile/diveprofileitem.h8
-rw-r--r--qt-ui/profile/profilewidget2.cpp14
-rw-r--r--qt-ui/profile/profilewidget2.h2
6 files changed, 80 insertions, 14 deletions
diff --git a/qt-ui/profile/diveplotdatamodel.cpp b/qt-ui/profile/diveplotdatamodel.cpp
index 09985b1ca..32067d3e0 100644
--- a/qt-ui/profile/diveplotdatamodel.cpp
+++ b/qt-ui/profile/diveplotdatamodel.cpp
@@ -34,6 +34,7 @@ QVariant DivePlotDataModel::data(const QModelIndex& index, int role) const
case CYLINDERINDEX: return item.cylinderindex;
case SENSOR_PRESSURE: return item.pressure[0];
case INTERPOLATED_PRESSURE: return item.pressure[1];
+ case SAC: return item.sac;
}
}
if (role == Qt::BackgroundRole) {
@@ -65,8 +66,9 @@ QVariant DivePlotDataModel::headerData(int section, Qt::Orientation orientation,
case COLOR: return tr("Color");
case USERENTERED: return tr("User Entered");
case CYLINDERINDEX: return tr("Cylinder Index");
- case SENSOR_PRESSURE: return tr("Sensor Pressure");
- case INTERPOLATED_PRESSURE: return tr("Interpolated Pressure");
+ case SENSOR_PRESSURE: return tr("Pressure S");
+ case INTERPOLATED_PRESSURE: return tr("Pressure I");
+ case SAC: return tr("SAC");
}
return QVariant();
}
@@ -88,16 +90,8 @@ void DivePlotDataModel::setDive(dive* d,const plot_info& pInfo)
if (d)
dc = select_dc(&d->dc);
-
- /* Create the new plot data */
- if (plotData)
- free((void *)plotData);
-
- plot_info info = pInfo;
- plotData = populate_plot_entries(d, dc, &info); // Create the plot data.
- analyze_plot_info(&info); // Get the Velocity Color information.
-
- sampleCount = info.nr;
+ plotData = pInfo.entry;
+ sampleCount = pInfo.nr;
beginInsertRows(QModelIndex(), 0, sampleCount-1);
endInsertRows();
}
diff --git a/qt-ui/profile/diveplotdatamodel.h b/qt-ui/profile/diveplotdatamodel.h
index 6d7191953..dc032734e 100644
--- a/qt-ui/profile/diveplotdatamodel.h
+++ b/qt-ui/profile/diveplotdatamodel.h
@@ -10,7 +10,7 @@ struct plot_info;
class DivePlotDataModel : public QAbstractTableModel{
Q_OBJECT
public:
- enum {DEPTH, TIME, PRESSURE, TEMPERATURE, USERENTERED, COLOR, CYLINDERINDEX, SENSOR_PRESSURE, INTERPOLATED_PRESSURE, COLUMNS};
+ enum {DEPTH, TIME, PRESSURE, TEMPERATURE, USERENTERED, COLOR, CYLINDERINDEX, SENSOR_PRESSURE, INTERPOLATED_PRESSURE, SAC, COLUMNS};
explicit DivePlotDataModel(QObject* parent = 0);
virtual int columnCount(const QModelIndex& parent = QModelIndex()) const;
virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
diff --git a/qt-ui/profile/diveprofileitem.cpp b/qt-ui/profile/diveprofileitem.cpp
index 44a3feb5e..3e6b05a09 100644
--- a/qt-ui/profile/diveprofileitem.cpp
+++ b/qt-ui/profile/diveprofileitem.cpp
@@ -2,6 +2,7 @@
#include "diveplotdatamodel.h"
#include "divecartesianaxis.h"
#include "graphicsview-common.h"
+#include "profile.h"
#include <QPen>
#include <QPainter>
@@ -132,3 +133,52 @@ void DiveTemperatureItem::paint(QPainter* painter, const QStyleOptionGraphicsIte
painter->setPen(pen());
painter->drawPolyline(polygon());
}
+
+
+void DiveGasPressureItem::modelDataChanged()
+{
+ // We don't have enougth data to calculate things, quit.
+ if (!hAxis || !vAxis || !dataModel || hDataColumn == -1 || vDataColumn == -1)
+ return;
+ int last_index = -1;
+ int lift_pen = false;
+ int first_plot = true;
+ QPolygonF boundingPoly; // This is the "Whole Item", but a pressure can be divided in N Polygons.
+ polygons.clear();
+
+#define M_PRESSURE( ROW )
+ for (int i = 0; i < dataModel->rowCount(); i++) {
+ int sPressure = dataModel->index(i, DivePlotDataModel::SENSOR_PRESSURE).data().toInt();
+ int iPressure = dataModel->index(i, DivePlotDataModel::INTERPOLATED_PRESSURE).data().toInt();
+ int cylIndex = dataModel->index(i, DivePlotDataModel::CYLINDERINDEX).data().toInt();
+ int sec = dataModel->index(i, DivePlotDataModel::TIME).data().toInt();
+ int mbar = sPressure ? sPressure : iPressure;
+
+ if (cylIndex != last_index) {
+ polygons.append(QPolygonF()); // this is the polygon that will be actually drawned on screen.
+ last_index = cylIndex;
+ }
+ if (!mbar) {
+ continue;
+ }
+
+ QPointF point(hAxis->posAtValue(sec), vAxis->posAtValue(mbar));
+ boundingPoly.push_back(point); // The BoundingRect
+ polygons.last().push_back(point); // The polygon thta will be plotted.
+ }
+ setPolygon(boundingPoly);
+}
+
+void DiveGasPressureItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
+{
+ QPen pen;
+ pen.setCosmetic(true);
+ pen.setWidth(2);
+ Q_FOREACH(const QPolygonF& poly, polygons){
+ for (int i = 1, count = poly.count(); i < count; i++) {
+ pen.setBrush(QBrush(Qt::red)); // TODO: Fix the color.
+ painter->setPen(pen);
+ painter->drawLine(poly[i-1],poly[i]);
+ }
+ }
+} \ No newline at end of file
diff --git a/qt-ui/profile/diveprofileitem.h b/qt-ui/profile/diveprofileitem.h
index 9d2893a65..ddecef947 100644
--- a/qt-ui/profile/diveprofileitem.h
+++ b/qt-ui/profile/diveprofileitem.h
@@ -59,4 +59,12 @@ public:
virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0);
};
+class DiveGasPressureItem : public AbstractProfilePolygonItem{
+ Q_OBJECT
+public:
+ virtual void modelDataChanged();
+ virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0);
+private:
+ QVector<QPolygonF> polygons;
+};
#endif \ No newline at end of file
diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp
index 3970e6f3a..201c68f41 100644
--- a/qt-ui/profile/profilewidget2.cpp
+++ b/qt-ui/profile/profilewidget2.cpp
@@ -70,7 +70,7 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) :
temperatureAxis->setTickSize(2);
temperatureAxis->setTickInterval(300);
- cylinderPressureAxis->setOrientation(DiveCartesianAxis::TopToBottom);
+ cylinderPressureAxis->setOrientation(DiveCartesianAxis::BottomToTop);
cylinderPressureAxis->setLine(0,20,0,60);
cylinderPressureAxis->setX(3);
cylinderPressureAxis->setTickSize(2);
@@ -336,6 +336,18 @@ void ProfileWidget2::plotDives(QList<dive*> dives)
temperatureItem->setHorizontalDataColumn(DivePlotDataModel::TIME);
scene()->addItem(temperatureItem);
+ 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);
+ scene()->addItem(gasPressureItem);
+
emit startProfileState();
}
diff --git a/qt-ui/profile/profilewidget2.h b/qt-ui/profile/profilewidget2.h
index b5d9f0a31..5f988651d 100644
--- a/qt-ui/profile/profilewidget2.h
+++ b/qt-ui/profile/profilewidget2.h
@@ -29,6 +29,7 @@ struct QStateMachine;
struct DiveCartesianPlane;
struct DiveTemperatureItem;
struct plot_info;
+struct DiveGasPressureItem;
class ProfileWidget2 : public QGraphicsView {
Q_OBJECT
@@ -76,6 +77,7 @@ private:
DiveCartesianPlane *cartesianPlane;
DiveTemperatureItem *temperatureItem;
DiveCartesianAxis *cylinderPressureAxis;
+ DiveGasPressureItem *gasPressureItem;
QList<DiveEventItem*> eventItems;
};