Пример #1
0
static void plot_cylinder_pressure(struct dive *dive, cairo_t *cr,
	double topx, double topy, double maxx, double maxy)
{
	int i;
	double scalex, scaley;

	if (!get_cylinder_pressure_range(dive, &scalex, &scaley))
		return;

	cairo_set_source_rgba(cr, 0.2, 1.0, 0.2, 0.80);

	cairo_move_to(cr, SCALE(0, dive->beginning_pressure.mbar));
	for (i = 1; i < dive->samples; i++) {
		int sec, mbar;
		struct sample *sample = dive->sample + i;

		sec = sample->time.seconds;
		mbar = sample->cylinderpressure.mbar;
		if (!mbar)
			continue;
		cairo_line_to(cr, SCALE(sec, mbar));
	}
	cairo_line_to(cr, SCALE(dive->duration.seconds, dive->end_pressure.mbar));
	cairo_stroke(cr);
}
Пример #2
0
void ProfileGraphicsView::plot_cylinder_pressure()
{
    int i;
    int last_index = -1;
    int lift_pen = FALSE;
    int first_plot = TRUE;

    if (!get_cylinder_pressure_range(&gc))
        return;

    QPointF from, to;
    for (i = 0; i < gc.pi.nr; i++) {
        int mbar;
        struct plot_data *entry = gc.pi.entry + i;

        mbar = GET_PRESSURE(entry);
        if (entry->cylinderindex != last_index) {
            lift_pen = TRUE;
        }
        if (!mbar) {
            lift_pen = TRUE;
            continue;
        }

        QColor c = get_sac_color(entry->sac, dive->sac);

        if (lift_pen) {
            if (!first_plot && entry->cylinderindex == last_index) {
                /* if we have a previous event from the same tank,
                 * draw at least a short line */
                int prev_pr;
                prev_pr = GET_PRESSURE(entry - 1);

                QGraphicsLineItem *item = new QGraphicsLineItem(SCALEGC((entry-1)->sec, prev_pr), SCALEGC(entry->sec, mbar));
                QPen pen(defaultPen);
                pen.setColor(c);
                item->setPen(pen);
                scene()->addItem(item);
            } else {
                first_plot = FALSE;
                from = QPointF(SCALEGC(entry->sec, mbar));
            }
            lift_pen = FALSE;
        } else {
            to = QPointF(SCALEGC(entry->sec, mbar));
            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 = QPointF(SCALEGC(entry->sec, mbar));
        last_index = entry->cylinderindex;
    }
}
Пример #3
0
void ProfileGraphicsView::plot_cylinder_pressure_text()
{
    int i;
    int mbar, cyl;
    int seen_cyl[MAX_CYLINDERS] = { FALSE, };
    int last_pressure[MAX_CYLINDERS] = { 0, };
    int last_time[MAX_CYLINDERS] = { 0, };
    struct plot_data *entry;
    struct plot_info *pi = &gc.pi;

    if (!get_cylinder_pressure_range(&gc))
        return;

    cyl = -1;
    for (i = 0; i < pi->nr; i++) {
        entry = pi->entry + i;
        mbar = GET_PRESSURE(entry);

        if (!mbar)
            continue;
        if (cyl != entry->cylinderindex) {
            cyl = entry->cylinderindex;
            if (!seen_cyl[cyl]) {
                plot_pressure_value(mbar, entry->sec, LEFT, BOTTOM);
                plot_gas_value(mbar, entry->sec, LEFT, TOP,
                               get_o2(&dive->cylinder[cyl].gasmix),
                               get_he(&dive->cylinder[cyl].gasmix));
                seen_cyl[cyl] = TRUE;
            }
        }
        last_pressure[cyl] = mbar;
        last_time[cyl] = entry->sec;
    }

    for (cyl = 0; cyl < MAX_CYLINDERS; cyl++) {
        if (last_time[cyl]) {
            plot_pressure_value(last_pressure[cyl], last_time[cyl], CENTER, TOP);
        }
    }
}
Пример #4
0
void ProfileGraphicsView::plot_cylinder_pressure(struct divecomputer *dc)
{
	int i;
	int last = -1, last_index = -1;
	int lift_pen = FALSE;
	int first_plot = TRUE;
	int sac = 0;
	struct plot_data *last_entry = NULL;

	if (!get_cylinder_pressure_range(&gc))
		return;

	QPointF from, to;
	for (i = 0; i < gc.pi.nr; i++) {
		int mbar;
		struct plot_data *entry = gc.pi.entry + i;

		mbar = GET_PRESSURE(entry);
		if (entry->cylinderindex != last_index) {
			lift_pen = TRUE;
			last_entry = NULL;
		}
		if (!mbar) {
			lift_pen = TRUE;
			continue;
		}
		if (!last_entry) {
			last = i;
			last_entry = entry;
			sac = get_local_sac(entry, gc.pi.entry + i + 1, dive);
		} else {
			int j;
			sac = 0;
			for (j = last; j < i; j++)
				sac += get_local_sac(gc.pi.entry + j, gc.pi.entry + j + 1, dive);
			sac /= (i - last);
			if (entry->sec - last_entry->sec >= SAC_WINDOW) {
				last++;
				last_entry = gc.pi.entry + last;
			}
		}

		QColor c = get_sac_color(sac, dive->sac);

		if (lift_pen) {
			if (!first_plot && entry->cylinderindex == last_index) {
				/* if we have a previous event from the same tank,
				 * draw at least a short line */
				int prev_pr;
				prev_pr = GET_PRESSURE(entry - 1);

				QGraphicsLineItem *item = new QGraphicsLineItem(SCALEGC((entry-1)->sec, prev_pr), SCALEGC(entry->sec, mbar));
				QPen pen(defaultPen);
				pen.setColor(c);
				item->setPen(pen);
				scene()->addItem(item);
			} else {
				first_plot = FALSE;
				from = QPointF(SCALEGC(entry->sec, mbar));
			}
			lift_pen = FALSE;
		} else {
			to = QPointF(SCALEGC(entry->sec, mbar));
			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 = QPointF(SCALEGC(entry->sec, mbar));
		last_index = entry->cylinderindex;
	}
}