mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	New profile: try to pick better HR samples for which to print number
This simply tries to pick at least local minima / maxima. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
		
							parent
							
								
									21ed18816a
								
							
						
					
					
						commit
						67a1e3f3e0
					
				
					 1 changed files with 25 additions and 8 deletions
				
			
		| 
						 | 
					@ -228,6 +228,11 @@ DiveHeartrateItem::DiveHeartrateItem()
 | 
				
			||||||
void DiveHeartrateItem::modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
 | 
					void DiveHeartrateItem::modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int last = -300, last_printed_hr = 0, sec = 0;
 | 
						int last = -300, last_printed_hr = 0, sec = 0;
 | 
				
			||||||
 | 
						struct {
 | 
				
			||||||
 | 
							int sec;
 | 
				
			||||||
 | 
							int hr;
 | 
				
			||||||
 | 
						} hist[3] = {0};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// We don't have enougth data to calculate things, quit.
 | 
						// We don't have enougth data to calculate things, quit.
 | 
				
			||||||
	if (!shouldCalculateStuff(topLeft, bottomRight))
 | 
						if (!shouldCalculateStuff(topLeft, bottomRight))
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
| 
						 | 
					@ -243,18 +248,30 @@ void DiveHeartrateItem::modelDataChanged(const QModelIndex &topLeft, const QMode
 | 
				
			||||||
		sec = dataModel->index(i, hDataColumn).data().toInt();
 | 
							sec = dataModel->index(i, hDataColumn).data().toInt();
 | 
				
			||||||
		QPointF point( hAxis->posAtValue(sec), vAxis->posAtValue(hr));
 | 
							QPointF point( hAxis->posAtValue(sec), vAxis->posAtValue(hr));
 | 
				
			||||||
		poly.append(point);
 | 
							poly.append(point);
 | 
				
			||||||
 | 
							if (hr == hist[2].hr)
 | 
				
			||||||
		/* don't print a HR
 | 
								// same as last one, no point in looking at printing
 | 
				
			||||||
		 * if it's been less than 5min and less than a 20 beats change OR
 | 
								continue;
 | 
				
			||||||
		 * if it's been less than 2min OR if the change from the
 | 
							hist[0] = hist[1];
 | 
				
			||||||
		 * last print is less than 10 beats */
 | 
							hist[1] = hist[2];
 | 
				
			||||||
		if (((sec < last + 300) && (abs(hr - last_printed_hr) < 20)) ||
 | 
							hist[2].sec = sec;
 | 
				
			||||||
 | 
							hist[2].hr = hr;
 | 
				
			||||||
 | 
							// don't print a HR
 | 
				
			||||||
 | 
							// if it's not a local min / max
 | 
				
			||||||
 | 
							// if it's been less than 5min and less than a 20 beats change OR
 | 
				
			||||||
 | 
							// if it's been less than 2min OR if the change from the
 | 
				
			||||||
 | 
							// last print is less than 10 beats
 | 
				
			||||||
 | 
							// to test min / max requires three points, so we now look at the
 | 
				
			||||||
 | 
							// previous one
 | 
				
			||||||
 | 
							sec = hist[1].sec;
 | 
				
			||||||
 | 
							hr = hist[1].hr;
 | 
				
			||||||
 | 
							if ((hist[0].hr < hr && hr < hist[2].hr) ||
 | 
				
			||||||
 | 
							    (hist[0].hr > hr && hr > hist[2].hr) ||
 | 
				
			||||||
 | 
							    ((sec < last + 300) && (abs(hr - last_printed_hr) < 20)) ||
 | 
				
			||||||
		    (sec < last + 120) ||
 | 
							    (sec < last + 120) ||
 | 
				
			||||||
		    (abs(hr - last_printed_hr) < 10))
 | 
							    (abs(hr - last_printed_hr) < 10))
 | 
				
			||||||
			continue;
 | 
								continue;
 | 
				
			||||||
		last = sec;
 | 
							last = sec;
 | 
				
			||||||
		if (hr > 0)
 | 
							createTextItem(sec, hr);
 | 
				
			||||||
			createTextItem(sec, hr);
 | 
					 | 
				
			||||||
		last_printed_hr = hr;
 | 
							last_printed_hr = hr;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	setPolygon(poly);
 | 
						setPolygon(poly);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue