What's missing for 4.2?

Dirk Hohndel dirk at hohndel.org
Tue Jun 10 21:16:00 PDT 2014


On Wed, Jun 11, 2014 at 12:30:22AM +0200, Anton Lundin wrote:
> 
> Quite ugly thing but it kinda works. You hopefully get the idea.
> 
> //Anton
> 
> -- 
> Anton Lundin	+46702-161604

> diff --git i/helpers.h w/helpers.h
> index 392dcb5..36ceb1e 100644
> --- i/helpers.h
> +++ w/helpers.h
> @@ -33,7 +33,7 @@ QString get_dive_date_string(timestamp_t when);
>  QString get_short_dive_date_string(timestamp_t when);
>  QString get_trip_date_string(timestamp_t when, int nr);
>  QString uiLanguage(QLocale *callerLoc);
> -void selectedDivesGasUsed(QVector<QPair<QString, int> > &gasUsed);
> +void selectedDivesGasUsed(QVector<QPair<struct gasmix*, int> > &gasUsed);
>  
>  #define M_OR_FT(_m, _f) ((prefs.units.length == units::METERS) ? ((_m) * 1000) : (feet_to_mm(_f)))
>  
> diff --git i/qt-ui/maintab.cpp w/qt-ui/maintab.cpp
> index ae2876b..770fcb4 100644
> --- i/qt-ui/maintab.cpp
> +++ w/qt-ui/maintab.cpp
> @@ -531,18 +531,37 @@ void MainTab::updateDiveInfo(int dive)
>  		ui.timeLimits->setMaximum(get_time_string(stats_selection.longest_time.seconds, 0));
>  		ui.timeLimits->setMinimum(get_time_string(stats_selection.shortest_time.seconds, 0));
>  		// now let's get some gas use statistics
> -		QVector<QPair<QString, int> > gasUsed;
> +		QVector<QPair<struct gasmix*, int> > gasUsed;
>  		QString gasUsedString;
> -		QPair<QString, int> topGases[20] = { };
> -		volume_t vol;
> +		QPair<struct gasmix*, int> topGases[20] = { };
>  		selectedDivesGasUsed(gasUsed);
> +		volume_t vol;
> +		volume_t he = {}, o2 = {};
> +		struct gasmix *mix;
> +		QPair<struct gasmix*, int> gasPair;
> +		foreach (gasPair, gasUsed) {
> +			mix = gasPair.first;
> +			vol.mliter = gasPair.second;
> +			//Really naive gas computations here, but it gives the picture
> +			if (gasmix_is_air(mix))
> +				continue;
> +			if (get_he(mix) != 0) {
> +				o2.mliter += (get_he(mix) * get_o2(mix) * vol.mliter) / 1000000;

Can you explain this line to me?

> +				he.mliter += (get_he(mix) * vol.mliter) / 1000;
> +			} else if (get_o2(mix) == 1000) {
> +				o2.mliter += vol.mliter;
> +			} else
> +				o2.mliter += ((get_o2(mix) - O2_IN_AIR) * vol.mliter) / 1000;

I think that last one is wrong, too. You need to calculate how much N2 you
have in the mix. That gives you how much air is in the mix. And then the
rest is O2, right?

> +		}
> +		gasUsedString.append(QString("He: %1, O2: %2\n").arg(get_volume_string(he, true)).arg(get_volume_string(o2, true)));
>  		for (int j = 0; j < 20; j++) {
>  			if (gasUsed.isEmpty())
>  				break;
> -			QPair<QString, int> gasPair = gasUsed.last();
> +			gasPair = gasUsed.last();
>  			gasUsed.pop_back();
> +			mix = gasPair.first;
>  			vol.mliter = gasPair.second;
> -			gasUsedString.append(gasPair.first).append(": ").append(get_volume_string(vol, true)).append("\n");
> +			gasUsedString.append(gasname(mix)).append(": ").append(get_volume_string(vol, true)).append("\n");

I think the idea itself is workable. I would put the components at the end
with something like "these gases could be mixed from air and xxxx O2 and
yyyy He".

/D


More information about the subsurface mailing list