mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Added the first Partial Gas Pressure: PN2
This makes the beginning of the partial gas pressures, there's two more. but this code uses a good part of the Model View system, and it's way clearer than the old one. Luckly the other 2 missing items will be even more clear ( the diffs ) to do, because I just need to create a new PartialPressureGasItem and set the properties. <3 Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
fd45e646dc
commit
caa45a1539
6 changed files with 94 additions and 4 deletions
|
@ -36,6 +36,7 @@ QVariant DivePlotDataModel::data(const QModelIndex& index, int role) const
|
|||
case INTERPOLATED_PRESSURE: return item.pressure[1];
|
||||
case CEILING: return item.ceiling;
|
||||
case SAC: return item.sac;
|
||||
case PN2: return item.pn2;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -81,6 +82,7 @@ QVariant DivePlotDataModel::headerData(int section, Qt::Orientation orientation,
|
|||
case INTERPOLATED_PRESSURE: return tr("Pressure I");
|
||||
case CEILING: return tr("Ceiling");
|
||||
case SAC: return tr("SAC");
|
||||
case PN2: return tr("PN2");
|
||||
}
|
||||
if (role == Qt::DisplayRole && section >= TISSUE_1 && section <= TISSUE_16){
|
||||
return QString("Ceiling: %1").arg(section - TISSUE_1);
|
||||
|
|
|
@ -12,7 +12,7 @@ Q_OBJECT
|
|||
public:
|
||||
enum {DEPTH, TIME, PRESSURE, TEMPERATURE, USERENTERED, COLOR, CYLINDERINDEX, SENSOR_PRESSURE, INTERPOLATED_PRESSURE,
|
||||
SAC, CEILING, TISSUE_1,TISSUE_2,TISSUE_3,TISSUE_4,TISSUE_5,TISSUE_6,TISSUE_7,TISSUE_8,TISSUE_9,TISSUE_10,
|
||||
TISSUE_11,TISSUE_12,TISSUE_13,TISSUE_14,TISSUE_15,TISSUE_16,COLUMNS};
|
||||
TISSUE_11,TISSUE_12,TISSUE_13,TISSUE_14,TISSUE_15,TISSUE_16, PN2,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;
|
||||
|
|
|
@ -471,3 +471,53 @@ void MeanDepthLine::setMeanDepth(int value)
|
|||
leftText->setText(get_depth_string(value, false, false));
|
||||
rightText->setText(get_depth_string(value, false, false));
|
||||
}
|
||||
|
||||
void PartialPressureGasItem::modelDataChanged()
|
||||
{
|
||||
//AbstractProfilePolygonItem::modelDataChanged();
|
||||
if (!hAxis || !vAxis || !dataModel || hDataColumn == -1 || vDataColumn == -1 || dataModel->rowCount() == 0)
|
||||
return;
|
||||
|
||||
plot_data *entry = dataModel->data();
|
||||
QPolygonF poly;
|
||||
alertPoly.clear();
|
||||
QSettings s;
|
||||
s.beginGroup("TecDetails");
|
||||
double threshould = s.value(threshouldKey).toDouble();
|
||||
|
||||
for(int i = 0; i < dataModel->rowCount(); i++, entry++){
|
||||
double value = dataModel->index(i, vDataColumn).data().toDouble();
|
||||
int time = dataModel->index(i, hDataColumn).data().toInt();
|
||||
QPointF point(hAxis->posAtValue(time), vAxis->posAtValue(value));
|
||||
poly.push_back( point );
|
||||
if (value >= threshould)
|
||||
alertPoly.push_back(point);
|
||||
}
|
||||
|
||||
setPolygon(poly);
|
||||
/*
|
||||
createPPLegend(trUtf8("pN" UTF8_SUBSCRIPT_2),getColor(PN2), legendPos);
|
||||
*/
|
||||
}
|
||||
void PartialPressureGasItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
|
||||
{//TODO: fix the colors.
|
||||
painter->setPen(getColor(PN2));
|
||||
painter->drawPolyline(polygon());
|
||||
painter->setPen(getColor(PN2_ALERT));
|
||||
painter->drawPolyline(alertPoly);
|
||||
}
|
||||
|
||||
void PartialPressureGasItem::setThreshouldSettingsKey(const QString& threshouldSettingsKey)
|
||||
{
|
||||
threshouldKey = threshouldSettingsKey;
|
||||
}
|
||||
|
||||
PartialPressureGasItem::PartialPressureGasItem()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void PartialPressureGasItem::preferencesChanged()
|
||||
{
|
||||
AbstractProfilePolygonItem::preferencesChanged();
|
||||
}
|
||||
|
|
|
@ -121,4 +121,17 @@ private:
|
|||
DiveTextItem *leftText;
|
||||
DiveTextItem *rightText;
|
||||
};
|
||||
|
||||
class PartialPressureGasItem : public AbstractProfilePolygonItem{
|
||||
Q_OBJECT
|
||||
public:
|
||||
PartialPressureGasItem();
|
||||
virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0);
|
||||
virtual void modelDataChanged();
|
||||
virtual void preferencesChanged();
|
||||
void setThreshouldSettingsKey(const QString& threshouldSettingsKey);
|
||||
private:
|
||||
QPolygonF alertPoly;
|
||||
QString threshouldKey;
|
||||
};
|
||||
#endif
|
||||
|
|
|
@ -54,7 +54,6 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) :
|
|||
// Creating the needed items.
|
||||
// ORDER: {BACKGROUND, PROFILE_Y_AXIS, GAS_Y_AXIS, TIME_AXIS, DEPTH_CONTROLLER, TIME_CONTROLLER, COLUMNS};
|
||||
profileYAxis->setOrientation(DiveCartesianAxis::TopToBottom);
|
||||
gasYAxis->setOrientation(DiveCartesianAxis::TopToBottom);
|
||||
timeAxis->setOrientation(DiveCartesianAxis::LeftToRight);
|
||||
|
||||
// Defaults of the Axis Coordinates:
|
||||
|
@ -66,7 +65,14 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) :
|
|||
// Default Sizes of the Items.
|
||||
profileYAxis->setX(2);
|
||||
profileYAxis->setTickSize(1);
|
||||
|
||||
gasYAxis->setOrientation(DiveCartesianAxis::BottomToTop);
|
||||
gasYAxis->setX(3);
|
||||
gasYAxis->setLine(0, 0, 0, 20);
|
||||
gasYAxis->setTickInterval(1);
|
||||
gasYAxis->setTickSize(2);
|
||||
gasYAxis->setY(70);
|
||||
scene()->addItem(gasYAxis);
|
||||
|
||||
temperatureAxis->setOrientation(DiveCartesianAxis::BottomToTop);
|
||||
temperatureAxis->setLine(0, 60, 0, 90);
|
||||
|
@ -99,7 +105,7 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) :
|
|||
diveComputerText->setBrush(getColor(TIME_TEXT));
|
||||
|
||||
// insert in the same way it's declared on the Enum. This is needed so we don't use an map.
|
||||
QList<QGraphicsItem*> stateItems; stateItems << background << profileYAxis << gasYAxis <<
|
||||
QList<QGraphicsItem*> stateItems; stateItems << background << profileYAxis <<
|
||||
timeAxis << depthController << timeController <<
|
||||
temperatureAxis << cylinderPressureAxis << diveComputerText <<
|
||||
meanDepth;
|
||||
|
@ -164,6 +170,16 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) :
|
|||
diveProfileItem->setZValue(0);
|
||||
scene()->addItem(diveProfileItem);
|
||||
|
||||
pn2GasItem = new PartialPressureGasItem();
|
||||
pn2GasItem->setHorizontalAxis(timeAxis);
|
||||
pn2GasItem->setVerticalAxis(gasYAxis);
|
||||
pn2GasItem->setModel(dataModel);
|
||||
pn2GasItem->setVerticalDataColumn(DivePlotDataModel::PN2);
|
||||
pn2GasItem->setHorizontalDataColumn(DivePlotDataModel::TIME);
|
||||
pn2GasItem->setZValue(0);
|
||||
pn2GasItem->setThreshouldSettingsKey("pn2threshold");
|
||||
scene()->addItem(pn2GasItem);
|
||||
|
||||
background->setFlag(QGraphicsItem::ItemIgnoresTransformations);
|
||||
|
||||
//enum State{ EMPTY, PROFILE, EDIT, ADD, PLAN, INVALID };
|
||||
|
@ -245,7 +261,7 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) :
|
|||
profileState->assignProperty(background, "y", backgroundOffCanvas);
|
||||
profileState->assignProperty(profileYAxis, "x", profileYAxisOnCanvas);
|
||||
//profileState->assignProperty(profileYAxis, "line", profileYAxisExpanded);
|
||||
profileState->assignProperty(gasYAxis, "x", 0);
|
||||
profileState->assignProperty(gasYAxis, "x", profileYAxisOnCanvas);
|
||||
profileState->assignProperty(timeAxis, "y", timeAxisOnCanvas);
|
||||
profileState->assignProperty(depthController, "y", depthControllerOffCanvas);
|
||||
profileState->assignProperty(timeController, "y", timeControllerOffCanvas);
|
||||
|
@ -363,6 +379,13 @@ void ProfileWidget2::plotDives(QList<dive*> dives)
|
|||
cylinderPressureAxis->setMaximum(pInfo.maxpressure);
|
||||
meanDepth->setMeanDepth(pInfo.meandepth);
|
||||
meanDepth->animateMoveTo(3, profileYAxis->posAtValue(pInfo.meandepth));
|
||||
|
||||
qreal pp = floor(pInfo.maxpp * 10.0) / 10.0 + 0.2;
|
||||
gasYAxis->setMaximum(pp);
|
||||
gasYAxis->setMinimum(0);
|
||||
gasYAxis->setTickInterval(pp > 4 ? 0.5 : 0.25);
|
||||
gasYAxis->updateTicks();
|
||||
|
||||
dataModel->setDive(current_dive, pInfo);
|
||||
|
||||
// The event items are a bit special since we don't know how many events are going to
|
||||
|
|
|
@ -37,6 +37,7 @@ struct DiveGasPressureItem;
|
|||
struct DiveCalculatedCeiling;
|
||||
struct DiveReportedCeiling;
|
||||
struct DiveCalculatedTissue;
|
||||
struct PartialPressureGasItem;
|
||||
|
||||
class ProfileWidget2 : public QGraphicsView {
|
||||
Q_OBJECT
|
||||
|
@ -91,6 +92,7 @@ private:
|
|||
DiveCalculatedCeiling *diveCeiling;
|
||||
QList<DiveCalculatedTissue*> allTissues;
|
||||
DiveReportedCeiling *reportedCeiling;
|
||||
PartialPressureGasItem *pn2GasItem;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Reference in a new issue