Ejemplo n.º 1
0
void ProfileGraphicsView::create_ruler()
{
    int x,y;
    struct plot_info *pi = &gc.pi;
    struct plot_data *data = pi->entry;

    RulerNodeItem *first = new RulerNodeItem(0, gc);
    RulerNodeItem *second = new RulerNodeItem(0, gc);

    x = SCALEXGC(data->sec);
    y = data->depth;

    first->setPos(x,y);

    data = pi->entry+(pi->nr-1);
    x = SCALEXGC(data->sec);
    y = data->depth;

    second->setPos(x,y);
    //Make sure that both points already have their entries
    first->recalculate();
    second->recalculate();

    rulerItem = new RulerItem(0, first, second);
    first->setRuler(rulerItem);
    second->setRuler(rulerItem);
}
Ejemplo n.º 2
0
void ProfileGraphicsView::plot_one_event(struct event *ev)
{
	int i, depth = 0;
	struct plot_info *pi = &gc.pi;

	/* is plotting of this event disabled? */
	if (ev->name) {
		for (i = 0; i < evn_used; i++) {
			if (! strcmp(ev->name, ev_namelist[i].ev_name)) {
				if (ev_namelist[i].plot_ev)
					break;
				else
					return;
			}
		}
	}

	if (ev->time.seconds < 30 && !strcmp(ev->name, "gaschange"))
		/* a gas change in the first 30 seconds is the way of some dive computers
		 * to tell us the gas that is used; let's not plot a marker for that */
		return;

	for (i = 0; i < pi->nr; i++) {
		struct plot_data *data = pi->entry + i;
		if (ev->time.seconds < data->sec)
			break;
		depth = data->depth;
	}

	/* draw a little triangular marker and attach tooltip */

	int x = SCALEXGC(ev->time.seconds);
	int y = SCALEYGC(depth);

	EventItem *item = new EventItem();
	item->setPos(x, y);
	scene()->addItem(item);

	/* we display the event on screen - so translate */
	QString name = tr(ev->name);
	if (ev->value) {
		if (ev->name && name == "gaschange") {
			unsigned int he = ev->value >> 16;
			unsigned int o2 = ev->value & 0xffff;

			name += ": ";
			name += (he) ? QString("%1/%2").arg(o2, he)
				  : (o2 == 21) ? name += tr("air")
				  : QString("%1% %2").arg(o2).arg("O" UTF8_SUBSCRIPT_2);

		} else if (ev->name && !strcmp(ev->name, "SP change")) {
Ejemplo n.º 3
0
void ProfileGraphicsView::plot_one_event(struct event *ev)
{
    int i;
    struct plot_info *pi = &gc.pi;
    struct plot_data *entry;

    /* is plotting of this event disabled? */
    if (ev->name) {
        for (i = 0; i < evn_used; i++) {
            if (! strcmp(ev->name, ev_namelist[i].ev_name)) {
                if (ev_namelist[i].plot_ev)
                    break;
                else
                    return;
            }
        }
    }

    if (ev->time.seconds < 30 && !strcmp(ev->name, "gaschange"))
        /* a gas change in the first 30 seconds is the way of some dive computers
         * to tell us the gas that is used; let's not plot a marker for that */
        return;

    for (i = 0; i < pi->nr; i++) {
        entry = pi->entry + i;
        if (ev->time.seconds < entry->sec)
            break;
    }

    /* draw a little triangular marker and attach tooltip */

    int x = SCALEXGC(ev->time.seconds);
    int y = SCALEYGC(entry->depth);

    EventItem *item = new EventItem(0, isGrayscale);
    item->setPos(x, y);
    scene()->addItem(item);

    /* we display the event on screen - so translate */
    QString name = tr(ev->name);
    if (ev->value) {
        if (ev->name && name == "gaschange") {
            int he = get_he(&dive->cylinder[entry->cylinderindex].gasmix);
            int o2 = get_o2(&dive->cylinder[entry->cylinderindex].gasmix);

            name += ": ";
            name += (he) ? QString("%1/%2").arg((o2 + 5) / 10).arg((he + 5) / 10)
                    : is_air(o2, he) ? name += tr("air")
                                               : QString(tr("EAN%1")).arg((o2 + 5) / 10);

        } else if (ev->name && !strcmp(ev->name, "SP change")) {
            name += QString(":%1").arg((double) ev->value / 1000);
        } else {
            name += QString(":%1").arg(ev->value);
        }
    } else if (ev->name && name == "SP change") {
        name += tr("Bailing out to OC");
    } else {
        name += ev->flags == SAMPLE_FLAGS_BEGIN ? tr(" begin", "Starts with space!") :
                ev->flags == SAMPLE_FLAGS_END ? tr(" end", "Starts with space!") : "";
    }

    //item->setToolTipController(toolTip);
    //item->addToolTip(name);
    item->setToolTip(name);
}