[PATCH] For CCR dives show O2 setpoint graph.

Dirk Hohndel dirk at hohndel.org
Sat Jan 3 10:24:43 PST 2015


On Sat, Jan 03, 2015 at 08:32AM -0800, Willem Ferguson wrote:
> 
> Subject: [PATCH] Show the o2 setpoint graph
> 
> When a CCR dive is viewed and the toolbar button for PO2 is activated,
> both the PO2 (green line) and the O2 setpoint (red line) are shown.
> This allows evaluation of the PO2 in the CCR loop with respect to the
> pre-configured O2 setpoint.
> 
> I need someone who is conversant with Qt to check this code, Please!

Tomaz is traveling, I'm sure he'll look at it when he's back (I didn't
approve his 2MB email showing his massive new tattoo where he said that).

But here are a few comments from me...

> diff --git a/profile.c b/profile.c
> index 74d4936..54ee84e 100644
> --- a/profile.c
> +++ b/profile.c
> @@ -608,7 +607,7 @@ struct plot_data *populate_plot_entries(struct dive *dive, struct divecomputer *
>  		entry->in_deco = sample->in_deco;
>  		entry->cns = sample->cns;
>  		if (dc->dctype == CCR) {
> -			entry->o2pressure.mbar = sample->setpoint.mbar;     // for rebreathers
> +			entry->o2pressure.mbar = entry->o2setpoint.mbar = sample->setpoint.mbar;     // for rebreathers

So why do we need a second field in the entry to hold this information?

> diff --git a/qt-ui/graphicsview-common.cpp b/qt-ui/graphicsview-common.cpp
> index 4beab9d..982cb84 100644
> --- a/qt-ui/graphicsview-common.cpp
> +++ b/qt-ui/graphicsview-common.cpp
> @@ -26,7 +26,8 @@ void fill_profile_color()
>  	profile_color[PN2] = COLOR(BLACK1_LOW_TRANS, BLACK1_LOW_TRANS, BLACK1_LOW_TRANS);
>  	profile_color[PN2_ALERT] = COLOR(RED1, BLACK1_LOW_TRANS, RED1);
>  	profile_color[PHE] = COLOR(PEANUT, BLACK1_LOW_TRANS, PEANUT);
> -	profile_color[PHE_ALERT] = COLOR(RED1, BLACK1_LOW_TRANS, RED1);
> +	profile_color[PHE] = COLOR(PEANUT, BLACK1_LOW_TRANS, PEANUT);
> +	profile_color[O2SETPOINT] = COLOR(RED1, BLACK1_LOW_TRANS, RED1);

So this delete's the PHE_ALERT color and duplicates the PHE color.
Why is that a good thing?

> diff --git a/qt-ui/profile/diveplotdatamodel.cpp b/qt-ui/profile/diveplotdatamodel.cpp
> index 51aea1b..aff9ebe 100644
> --- a/qt-ui/profile/diveplotdatamodel.cpp
> +++ b/qt-ui/profile/diveplotdatamodel.cpp
> @@ -52,6 +52,11 @@ QVariant DivePlotDataModel::data(const QModelIndex &index, int role) const
>  			return item.pressures.he;
>  		case PO2:
>  			return item.pressures.o2;
> +		case O2SETPOINT:
> +			if (item.o2setpoint.mbar > 5000)
> +				return(0);

What is special about setpoints larger than 5bar (except that it might
kill you, I mean)? How could we ever get such a setpoint? And if we did,
why would we want to hide that by returning 0?

> +				return item.o2setpoint.mbar / 1000.0;

Why are you returning bar? The other entries here appear to return a
pressure_t

> diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp
> index d631e3c..c1bc402 100644
> --- a/qt-ui/profile/profilewidget2.cpp
> +++ b/qt-ui/profile/profilewidget2.cpp
> @@ -521,6 +525,11 @@ void ProfileWidget2::plotDive(struct dive *d, bool force)
>  		currentdc = fake_dc(currentdc);
>  	}
>  
> +	if (currentdc->dctype == CCR) {
> +		o2SetpointGasItem->setVisible(true);
> +	} else {
> +		o2SetpointGasItem->setVisible(false);
> +	}

So the user doesn't get to turn this off if it's a CCR dive? Or is this
somewhere else turned of if the user doesn't want to see partial
pressures? I only see it turned off below for the empty state...


/D


More information about the subsurface mailing list