mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Plot cleanup
Use a helper to make things easier to read. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
788c513dd4
commit
5e51d1e354
2 changed files with 31 additions and 59 deletions
|
@ -296,7 +296,7 @@ void ProfileGraphicsView::plot(struct dive *d, bool forceRedraw)
|
||||||
gc.maxx = (profile_grid_area.width() - 2 * profile_grid_area.x());
|
gc.maxx = (profile_grid_area.width() - 2 * profile_grid_area.x());
|
||||||
gc.maxy = (profile_grid_area.height() - 2 * profile_grid_area.y());
|
gc.maxy = (profile_grid_area.height() - 2 * profile_grid_area.y());
|
||||||
|
|
||||||
/* This is per-dive-computer. Right now we just do the first one */
|
/* This is per-dive-computer */
|
||||||
gc.pi = *create_plot_info(dive, dc, &gc);
|
gc.pi = *create_plot_info(dive, dc, &gc);
|
||||||
|
|
||||||
/* Depth profile */
|
/* Depth profile */
|
||||||
|
@ -427,6 +427,17 @@ void ProfileGraphicsView::plot_pp_text()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ProfileGraphicsView::plot_add_line(int sec, double val, QColor c, QPointF &from)
|
||||||
|
{
|
||||||
|
QPointF to = QPointF(SCALEGC(sec, val));
|
||||||
|
QGraphicsLineItem *item = new QGraphicsLineItem(from.x(), from.y(), to.x(), to.y());
|
||||||
|
QPen pen(defaultPen);
|
||||||
|
pen.setColor(c);
|
||||||
|
item->setPen(pen);
|
||||||
|
scene()->addItem(item);
|
||||||
|
from = to;
|
||||||
|
}
|
||||||
|
|
||||||
void ProfileGraphicsView::plot_pp_gas_profile()
|
void ProfileGraphicsView::plot_pp_gas_profile()
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
@ -442,17 +453,10 @@ void ProfileGraphicsView::plot_pp_gas_profile()
|
||||||
from = QPointF(SCALEGC(entry->sec, entry->pn2));
|
from = QPointF(SCALEGC(entry->sec, entry->pn2));
|
||||||
for (i = 1; i < pi->nr; i++) {
|
for (i = 1; i < pi->nr; i++) {
|
||||||
entry++;
|
entry++;
|
||||||
if (entry->pn2 < prefs.pp_graphs.pn2_threshold) {
|
if (entry->pn2 < prefs.pp_graphs.pn2_threshold)
|
||||||
to = QPointF(SCALEGC(entry->sec, entry->pn2));
|
plot_add_line(entry->sec, entry->pn2, c, from);
|
||||||
QGraphicsLineItem *item = new QGraphicsLineItem(from.x(), from.y(), to.x(), to.y());
|
else
|
||||||
QPen pen(defaultPen);
|
|
||||||
pen.setColor(c);
|
|
||||||
item->setPen(pen);
|
|
||||||
scene()->addItem(item);
|
|
||||||
from = to;
|
|
||||||
} else {
|
|
||||||
from = QPointF(SCALEGC(entry->sec, entry->pn2));
|
from = QPointF(SCALEGC(entry->sec, entry->pn2));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
c = profile_color[PN2_ALERT].first();
|
c = profile_color[PN2_ALERT].first();
|
||||||
|
@ -460,17 +464,10 @@ void ProfileGraphicsView::plot_pp_gas_profile()
|
||||||
from = QPointF(SCALEGC(entry->sec, entry->pn2));
|
from = QPointF(SCALEGC(entry->sec, entry->pn2));
|
||||||
for (i = 1; i < pi->nr; i++) {
|
for (i = 1; i < pi->nr; i++) {
|
||||||
entry++;
|
entry++;
|
||||||
if (entry->pn2 >= prefs.pp_graphs.pn2_threshold) {
|
if (entry->pn2 >= prefs.pp_graphs.pn2_threshold)
|
||||||
to = QPointF(SCALEGC(entry->sec, entry->pn2));
|
plot_add_line(entry->sec, entry->pn2, c, from);
|
||||||
QGraphicsLineItem *item = new QGraphicsLineItem(from.x(), from.y(), to.x(), to.y());
|
else
|
||||||
QPen pen(defaultPen);
|
|
||||||
pen.setColor(c);
|
|
||||||
item->setPen(pen);
|
|
||||||
scene()->addItem(item);
|
|
||||||
from = to;
|
|
||||||
} else {
|
|
||||||
from = QPointF(SCALEGC(entry->sec, entry->pn2));
|
from = QPointF(SCALEGC(entry->sec, entry->pn2));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -481,17 +478,10 @@ void ProfileGraphicsView::plot_pp_gas_profile()
|
||||||
from = QPointF(SCALEGC(entry->sec, entry->phe));
|
from = QPointF(SCALEGC(entry->sec, entry->phe));
|
||||||
for (i = 1; i < pi->nr; i++) {
|
for (i = 1; i < pi->nr; i++) {
|
||||||
entry++;
|
entry++;
|
||||||
if (entry->phe < prefs.pp_graphs.phe_threshold) {
|
if (entry->phe < prefs.pp_graphs.phe_threshold)
|
||||||
to = QPointF(SCALEGC(entry->sec, entry->phe));
|
plot_add_line(entry->sec, entry->phe, c, from);
|
||||||
QGraphicsLineItem *item = new QGraphicsLineItem(from.x(), from.y(), to.x(), to.y());
|
else
|
||||||
QPen pen(defaultPen);
|
|
||||||
pen.setColor(c);
|
|
||||||
item->setPen(pen);
|
|
||||||
scene()->addItem(item);
|
|
||||||
from = to;
|
|
||||||
} else {
|
|
||||||
from = QPointF(SCALEGC(entry->sec, entry->phe));
|
from = QPointF(SCALEGC(entry->sec, entry->phe));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
c = profile_color[PHE_ALERT].first();
|
c = profile_color[PHE_ALERT].first();
|
||||||
|
@ -499,17 +489,10 @@ void ProfileGraphicsView::plot_pp_gas_profile()
|
||||||
from = QPointF(SCALEGC(entry->sec, entry->phe));
|
from = QPointF(SCALEGC(entry->sec, entry->phe));
|
||||||
for (i = 1; i < pi->nr; i++) {
|
for (i = 1; i < pi->nr; i++) {
|
||||||
entry++;
|
entry++;
|
||||||
if (entry->phe >= prefs.pp_graphs.phe_threshold) {
|
if (entry->phe >= prefs.pp_graphs.phe_threshold)
|
||||||
to = QPointF(SCALEGC(entry->sec, entry->phe));
|
plot_add_line(entry->sec, entry->phe, c, from);
|
||||||
QGraphicsLineItem *item = new QGraphicsLineItem(from.x(), from.y(), to.x(), to.y());
|
else
|
||||||
QPen pen(defaultPen);
|
|
||||||
pen.setColor(c);
|
|
||||||
item->setPen(pen);
|
|
||||||
scene()->addItem(item);
|
|
||||||
from = to;
|
|
||||||
} else {
|
|
||||||
from = QPointF(SCALEGC(entry->sec, entry->phe));
|
from = QPointF(SCALEGC(entry->sec, entry->phe));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (prefs.pp_graphs.po2) {
|
if (prefs.pp_graphs.po2) {
|
||||||
|
@ -518,17 +501,10 @@ void ProfileGraphicsView::plot_pp_gas_profile()
|
||||||
from = QPointF(SCALEGC(entry->sec, entry->po2));
|
from = QPointF(SCALEGC(entry->sec, entry->po2));
|
||||||
for (i = 1; i < pi->nr; i++) {
|
for (i = 1; i < pi->nr; i++) {
|
||||||
entry++;
|
entry++;
|
||||||
if (entry->po2 < prefs.pp_graphs.po2_threshold) {
|
if (entry->po2 < prefs.pp_graphs.po2_threshold)
|
||||||
to = QPointF(SCALEGC(entry->sec, entry->po2));
|
plot_add_line(entry->sec, entry->po2, c, from);
|
||||||
QGraphicsLineItem *item = new QGraphicsLineItem(from.x(), from.y(), to.x(), to.y());
|
else
|
||||||
QPen pen(defaultPen);
|
|
||||||
pen.setColor(c);
|
|
||||||
item->setPen(pen);
|
|
||||||
scene()->addItem(item);
|
|
||||||
from = to;
|
|
||||||
} else {
|
|
||||||
from = QPointF(SCALEGC(entry->sec, entry->po2));
|
from = QPointF(SCALEGC(entry->sec, entry->po2));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
c = profile_color[PO2_ALERT].first();
|
c = profile_color[PO2_ALERT].first();
|
||||||
|
@ -536,15 +512,10 @@ void ProfileGraphicsView::plot_pp_gas_profile()
|
||||||
from = QPointF(SCALEGC(entry->sec, entry->po2));
|
from = QPointF(SCALEGC(entry->sec, entry->po2));
|
||||||
for (i = 1; i < pi->nr; i++) {
|
for (i = 1; i < pi->nr; i++) {
|
||||||
entry++;
|
entry++;
|
||||||
if (entry->po2 >= prefs.pp_graphs.po2_threshold) {
|
if (entry->po2 >= prefs.pp_graphs.po2_threshold)
|
||||||
to = QPointF(SCALEGC(entry->sec, entry->po2));
|
plot_add_line(entry->sec, entry->po2, c, from);
|
||||||
QGraphicsLineItem *item = new QGraphicsLineItem(from.x(), from.y(), to.x(), to.y());
|
else
|
||||||
item->setPen(QPen(c));
|
|
||||||
scene()->addItem(item);
|
|
||||||
from = to;
|
|
||||||
} else {
|
|
||||||
from = QPointF(SCALEGC(entry->sec, entry->po2));
|
from = QPointF(SCALEGC(entry->sec, entry->po2));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,6 +118,7 @@ private:
|
||||||
void plot_pressure_value(int mbar, int sec, double xalign, double yalign);
|
void plot_pressure_value(int mbar, int sec, double xalign, double yalign);
|
||||||
void plot_gas_value(int mbar, int sec, double xalign, double yalign, int o2, int he);
|
void plot_gas_value(int mbar, int sec, double xalign, double yalign, int o2, int he);
|
||||||
void plot_deco_text();
|
void plot_deco_text();
|
||||||
|
void plot_add_line(int sec, double val, QColor c, QPointF &from);
|
||||||
void plot_pp_gas_profile();
|
void plot_pp_gas_profile();
|
||||||
void plot_pp_text();
|
void plot_pp_text();
|
||||||
void plot_depth_scale();
|
void plot_depth_scale();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue