Weight yAxis.. not finished yet. harddrive is crashing here.. :(

This commit is contained in:
Mark Watkins 2011-12-21 14:25:01 +10:00
parent 8242fbab6e
commit 8198c5b811
7 changed files with 63 additions and 24 deletions

View File

@ -248,15 +248,6 @@ bool gYAxis::mouseMoveEvent(QMouseEvent * event)
return false;
}
gYAxisTime::gYAxisTime(QColor col):
gYAxis(col)
{
show_12hr=true;
}
gYAxisTime::~gYAxisTime()
{
}
const QString gYAxisTime::Format(EventDataType v, int dp)
{
@ -277,3 +268,15 @@ const QString gYAxisTime::Format(EventDataType v, int dp)
if (dp>2) return QString().sprintf("%02i:%02i:%02i%s",h,m,s,pm);
return QString().sprintf("%i:%02i%s",h,m,pm);
}
const QString gYAxisWeight::Format(EventDataType v, int dp)
{
if (m_unitsystem==US_Metric) {
return QString("%1kg").arg(v,0,'f',2);
} else if (m_unitsystem==US_Archiac) {
int oz=v / (float)ounce_convert;
int lb=oz / 16;
oz = oz % 16;
return QString("%1lb %2oz").arg(lb).arg(oz);
}
}

View File

@ -121,8 +121,8 @@ class gYAxisTime:public gYAxis
{
public:
//! \brief Construct a gYAxisTime object, with QColor col for tickers & times
gYAxisTime(QColor col=Qt::black);
virtual ~gYAxisTime();
gYAxisTime(bool hr12=true, QColor col=Qt::black) : gYAxis(col), show_12hr(hr12) {}
virtual ~gYAxisTime() {}
protected:
//! \brief Overrides gYAxis Format to display Time format
virtual const QString Format(EventDataType v, int dp);
@ -131,4 +131,27 @@ protected:
bool show_12hr;
};
/*! \class gYAxisWeight
\brief Draws the YAxis tick markers, and labels in weight format
*/
class gYAxisWeight:public gYAxis
{
public:
//! \brief Construct a gYAxisWeight object, with QColor col for tickers & weight values
gYAxisWeight(UnitSystem us=US_Metric, QColor col=Qt::black) :gYAxis(col), m_unitsystem(us) {}
virtual ~gYAxisWeight() {}
//! \brief Returns the current UnitSystem displayed (eg, US_Metric (the rest of the world), US_Archiac (American) )
UnitSystem unitSystem() { return m_unitsystem; }
//! \brief Set the unit system displayed by this YTicker
void setUnitSystem(UnitSystem us) { m_unitsystem=us; }
protected:
//! \brief Overrides gYAxis Format to display Time format
virtual const QString Format(EventDataType v, int dp);
UnitSystem m_unitsystem;
};
#endif // GYAXIS_H

View File

@ -472,6 +472,7 @@ int ResmedLoader::Open(QString & path,Profile *profile)
}
}
if (m) {
m->Save();
}

View File

@ -43,6 +43,10 @@ enum SummaryType { ST_CNT, ST_SUM, ST_AVG, ST_WAVG, ST_90P, ST_MIN, ST_MAX, ST_C
enum MachineType { MT_UNKNOWN=0,MT_CPAP,MT_OXIMETER,MT_SLEEPSTAGE,MT_JOURNAL };
//void InitMapsWithoutAwesomeInitializerLists();
enum UnitSystem { US_Metric, US_Archiac };
const float ounce_convert=28.3495231;
const float pound_convert=ounce_convert*16;
/*! \enum CPAPMode
\brief CPAP Machines mode of operation

View File

@ -38,8 +38,6 @@
extern MainWindow * mainwin;
const int min_height=150;
const float ounce_convert=28.3495231;
const float pound_convert=ounce_convert*16;
Daily::Daily(QWidget *parent,gGraphView * shared)
:QWidget(parent), ui(new Ui::Daily)

View File

@ -93,14 +93,8 @@ Overview::Overview(QWidget *parent,gGraphView * shared) :
AHI=createGraph("AHI","Apnea\nHypopnea\nIndex");
UC=createGraph("Usage","Usage\n(hours)");
int default_height=PROFILE["GraphHeight"].toInt();
US=new gGraph(GraphView,"Session Times","Session Times\n(hours)",default_height,0);
US->AddLayer(new gYAxisTime(),LayerLeft,gYAxis::Margin);
gXAxis *x=new gXAxis();
x->setUtcFix(true);
US->AddLayer(x,LayerBottom,0,gXAxis::Margin);
US->AddLayer(new gXGrid());
US=createGraph(tr("Session Times"),tr("Session Times\n(hours)"),YT_Time);
PR=createGraph(tr("Pressure"),tr("Pressure\n(cmH2O)"));
SET=createGraph(tr("Settings"),("Settings"));
LK=createGraph(tr("Leaks"),tr("Leak Rate\n(L/min)"));
@ -113,7 +107,7 @@ Overview::Overview(QWidget *parent,gGraphView * shared) :
SES=createGraph(tr("Sessions"),tr("Sessions\n(count)"));
PULSE=createGraph(tr("Pulse Rate"),tr("Pulse Rate\n(bpm)"));
SPO2=createGraph(tr("SpO2"),tr("Oxygen Saturation\n(%)"));
WEIGHT=createGraph(tr("Weight"),tr("Weight\n(kg)"));
WEIGHT=createGraph(tr("Weight"),tr("Weight\n(kg)"),YT_Weight);
BMI=createGraph(tr("BMI"),tr("Body\nMass\nIndex"));
ZOMBIE=createGraph(tr("Zombie"),tr("How you felt\n(0-10)"));
@ -237,11 +231,25 @@ Overview::~Overview()
disconnect(this,SLOT(dateEnd_currentPageChanged(int,int)));
delete ui;
}
gGraph * Overview::createGraph(QString name,QString units)
gGraph * Overview::createGraph(QString name,QString units, YTickerType yttype)
{
int default_height=PROFILE["GraphHeight"].toInt();
gGraph *g=new gGraph(GraphView,name,units,default_height,0);
g->AddLayer(new gYAxis(),LayerLeft,gYAxis::Margin);
gYAxis *yt;
switch (yttype) {
case YT_Time:
yt=new gYAxisTime(true); // Time scale
break;
case YT_Weight:
yt=new gYAxisWeight(US_Archiac); // Weight scale, which adjusts for UnitSystem
break;
default:
yt=new gYAxis(); // Plain numeric scale
break;
}
g->AddLayer(yt,LayerLeft,gYAxis::Margin);
gXAxis *x=new gXAxis();
x->setUtcFix(true);
g->AddLayer(x,LayerBottom,0,gXAxis::Margin);

View File

@ -21,6 +21,8 @@ namespace Ui {
class Report;
enum YTickerType { YT_Number, YT_Time, YT_Weight };
/*! \class Overview
\author Mark Watkins <jedimark_at_users.sourceforge.net>
\brief Overview tab, showing overall summary data
@ -48,7 +50,7 @@ public:
/*! \brief Create an overview graph, adding it to the overview gGraphView object
\param QString name The title of the graph
\param QString units The units of measurements to show in the popup */
gGraph * createGraph(QString name,QString units="");
gGraph * createGraph(QString name,QString units="",YTickerType yttype=YT_Number);
gGraph *AHI, *AHIHR, *UC, *US, *PR,*LK,*NPB,*SET,*SES,*RR,*MV,*TV,*PTB,*PULSE,*SPO2,*WEIGHT,*ZOMBIE, *BMI;
SummaryChart *bc,*uc, *us, *pr,*lk,*npb,*set,*ses,*rr,*mv,*tv,*ptb,*pulse,*spo2,*weight,*zombie, *bmi, *ahihr;