[PATCH] For CCR dives, prevent overprinting of cylinder pressure data on dive profile

Dirk Hohndel dirk at hohndel.org
Mon Jan 12 10:53:33 PST 2015


On Mon, Jan 12, 2015 at 07:47:04AM +0200, Willem Ferguson wrote:
> Print CCR cylinder pressure labels in a nonoverlapping way.
> 
> The oxygen and diluent cylinder pressures with CCR dives are often fairly
> similar, within the
> range 100-180 bar. This causes the cylinder pressure text for the two
> cylinders to be
> overprinted, either with the labels at the start of the dive or with the
> pressure labels at
> the end of the dive. This patch minimises the overprinting by writing
> cylinder info for the top
> graph above the graph, and the cylinder information for the bottom graph
> below the graph. The
> text for the bottom graph will therefore not overlap with the top graph and
> vice versa. See
> attached image of before-this-patch (above) and after-this_patch (below)
> dive profile.

That seems like a good idea.

> +
> +	double print_y_offset[8][3] = { { 0, -0.5, -0.5 }, { 0, -0.5, -0.5 }, { 0, -0.5, -0.5 }, { 0, -0.5, -0.5 },
> +					{ 0, -0.5, -0.5 } ,{ 0, -0.5, -0.5 }, { 0, -0.5, -0.5 }, { 0, -0.5, -0.5 } };

So that's eight times the same value - not very intuitive, but fine. I'm
sure there's a clever way to write this more compact :-)

> +	// CCR dives: These are offset values used to print the gas lables and pressures on a CCR dive profile at
> +	// appropriate Y-coordinates: One triplet of values for each of 8 cylinders.
> +	// Order within a triplet: start gas lable, start gas pressure, end gas pressure.
> +	// The array is initialised with default values that apply to non-CCR dives.

It's unclear to me why this is what we have today...  Never mind, found
it...

>  		if (o2mbar) {
> +			// The first time an o2 value is detected, see if the oxygen cyl pressure graph starts above or below the dil graph
> +			if (!offsets_initialised) {
> +				o2cyl = displayed_dive.oxygen_cylinder_index;
> +				dilcyl = displayed_dive.diluent_cylinder_index;
> +				if ((o2mbar > mbar)) {	// If above, write o2 start cyl pressure above graph and diluent pressure below graph:
> +					print_y_offset[o2cyl][0] = -5; // y offset for oxygen gas lable
> +					print_y_offset[o2cyl][1] = -3; // y offset for oxygen start pressure value
> +					print_y_offset[dilcyl][0] = 2; // y offset for diluent gas lable
> +					print_y_offset[dilcyl][1] = 2; // y offset for diluent start pressure value

So can you say more about these constants? Are these relative to font size
by any chance?

> @@ -694,30 +718,38 @@ void DiveGasPressureItem::modelDataChanged(const QModelIndex &topLeft, const QMo
>  		last_time[cyl] = entry->sec;
>  	}
>  
> +	if ((o2cyl + dilcyl < 14) && (o2cyl + dilcyl >= 0)) { // At first, skip uninitialised values of o2cyl and dilcyl

Hmm. That's an odd condition. Any more insight into what this tells me? So
o2cyl = -8 and dilcyl = 10 are OK values?

> -void DiveGasPressureItem::plotPressureValue(int mbar, int sec, QFlags<Qt::AlignmentFlag> flags)
> +void DiveGasPressureItem::plotPressureValue(int mbar, double pressure_offset, int sec, QFlags<Qt::AlignmentFlag> flags)
>  {
>  	const char *unit;
>  	int pressure = get_pressure_units(mbar, &unit);
>  	DiveTextItem *text = new DiveTextItem(this);
> -	text->setPos(hAxis->posAtValue(sec), vAxis->posAtValue(mbar) - 0.5);

Ahh, this answers my question from above... this is the "-0.5"

And just as before, the offsets are absolute, not font size specific. So
while I think this is wrong, you're not really making it any worse, so
this is mostly a comment... it would be better if these offsets were
scaled by font size... but I need to ask Tomaz here... some of our
coordinates are actually scaled, independent of resolution and then fixed
values are fine...


Overall this looks good. I'd like to understand that weird condition a bit
better, though :-)

/D


More information about the subsurface mailing list