mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	cylindermodel: remove in_planner() use
in_planner() is problematic, since it is uses desktop-only application state. Since the cylinder-model already has an appropriate inPlanner flag, use this instead. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
		
							parent
							
								
									e47b812fd0
								
							
						
					
					
						commit
						b36178a00a
					
				
					 3 changed files with 7 additions and 7 deletions
				
			
		| 
						 | 
				
			
			@ -3118,10 +3118,10 @@ void split_divecomputer(const struct dive *src, int num, struct dive **out1, str
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
//Calculate O2 in best mix
 | 
			
		||||
fraction_t best_o2(depth_t depth, const struct dive *dive)
 | 
			
		||||
fraction_t best_o2(depth_t depth, const struct dive *dive, bool in_planner)
 | 
			
		||||
{
 | 
			
		||||
	fraction_t fo2;
 | 
			
		||||
	int po2 = in_planner() ? prefs.bottompo2 : prefs.modpO2 * 1000;
 | 
			
		||||
	int po2 = in_planner ? prefs.bottompo2 : prefs.modpO2 * 1000;
 | 
			
		||||
 | 
			
		||||
	fo2.permille = (po2 * 100 / depth_to_mbar(depth.mm, dive)) * 10;	//use integer arithmetic to round down to nearest percent
 | 
			
		||||
	// Don't permit >100% O2
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -95,7 +95,7 @@ struct dive_components {
 | 
			
		|||
extern bool has_gaschange_event(const struct dive *dive, const struct divecomputer *dc, int idx);
 | 
			
		||||
extern int explicit_first_cylinder(const struct dive *dive, const struct divecomputer *dc);
 | 
			
		||||
 | 
			
		||||
extern fraction_t best_o2(depth_t depth, const struct dive *dive);
 | 
			
		||||
extern fraction_t best_o2(depth_t depth, const struct dive *dive, bool in_planner);
 | 
			
		||||
extern fraction_t best_he(depth_t depth, const struct dive *dive, bool o2narcotic, fraction_t fo2);
 | 
			
		||||
 | 
			
		||||
extern int get_surface_pressure_in_mbar(const struct dive *dive, bool non_null);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -230,7 +230,7 @@ QVariant CylindersModel::data(const QModelIndex &index, int role) const
 | 
			
		|||
				return QStringLiteral("*");
 | 
			
		||||
			} else {
 | 
			
		||||
				pressure_t modpO2;
 | 
			
		||||
				modpO2.mbar = in_planner() ? prefs.bottompo2 : prefs.modpO2 * 1000;
 | 
			
		||||
				modpO2.mbar = inPlanner ? prefs.bottompo2 : prefs.modpO2 * 1000;
 | 
			
		||||
				return get_depth_string(gas_mod(cyl->gasmix, modpO2, d, M_OR_FT(1,1)), true);
 | 
			
		||||
			}
 | 
			
		||||
		case MND:
 | 
			
		||||
| 
						 | 
				
			
			@ -429,11 +429,11 @@ bool CylindersModel::setData(const QModelIndex &index, const QVariant &value, in
 | 
			
		|||
			if (QString::compare(qPrintable(vString), "*") == 0) {
 | 
			
		||||
				cyl.bestmix_o2 = true;
 | 
			
		||||
				// Calculate fO2 for max. depth
 | 
			
		||||
				cyl.gasmix.o2 = best_o2(d->maxdepth, d);
 | 
			
		||||
				cyl.gasmix.o2 = best_o2(d->maxdepth, d, inPlanner);
 | 
			
		||||
			} else {
 | 
			
		||||
				cyl.bestmix_o2 = false;
 | 
			
		||||
				// Calculate fO2 for input depth
 | 
			
		||||
				cyl.gasmix.o2 = best_o2(string_to_depth(qPrintable(vString)), d);
 | 
			
		||||
				cyl.gasmix.o2 = best_o2(string_to_depth(qPrintable(vString)), d, inPlanner);
 | 
			
		||||
			}
 | 
			
		||||
			pressure_t modpO2;
 | 
			
		||||
			modpO2.mbar = prefs.decopo2;
 | 
			
		||||
| 
						 | 
				
			
			@ -643,7 +643,7 @@ bool CylindersModel::updateBestMixes()
 | 
			
		|||
	for (int i = 0; i < d->cylinders.nr; i++) {
 | 
			
		||||
		cylinder_t *cyl = get_cylinder(d, i);
 | 
			
		||||
		if (cyl->bestmix_o2) {
 | 
			
		||||
			cyl->gasmix.o2 = best_o2(d->maxdepth, d);
 | 
			
		||||
			cyl->gasmix.o2 = best_o2(d->maxdepth, d, inPlanner);
 | 
			
		||||
			// fO2 + fHe must not be greater than 1
 | 
			
		||||
			if (get_o2(cyl->gasmix) + get_he(cyl->gasmix) > 1000)
 | 
			
		||||
				cyl->gasmix.he.permille = 1000 - get_o2(cyl->gasmix);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue