mirror of
https://gitlab.com/pholy/OSCAR-code.git
synced 2025-04-06 11:10:44 +00:00
Simplify gPressureChart upper label formatting.
This commit is contained in:
parent
d13109bbed
commit
c5768a64fe
@ -12,50 +12,53 @@
|
|||||||
gPressureChart::gPressureChart()
|
gPressureChart::gPressureChart()
|
||||||
: gSummaryChart("Pressure", MT_CPAP)
|
: gSummaryChart("Pressure", MT_CPAP)
|
||||||
{
|
{
|
||||||
addCalc(CPAP_Pressure, ST_SETMAX); // 00
|
addCalc(CPAP_Pressure, ST_SETMAX);
|
||||||
addCalc(CPAP_Pressure, ST_MID); // 01
|
addCalc(CPAP_Pressure, ST_MID);
|
||||||
addCalc(CPAP_Pressure, ST_90P); // 02
|
addCalc(CPAP_Pressure, ST_90P);
|
||||||
addCalc(CPAP_PressureMin, ST_SETMIN); // 03
|
addCalc(CPAP_PressureMin, ST_SETMIN);
|
||||||
addCalc(CPAP_PressureMax, ST_SETMAX); // 04
|
addCalc(CPAP_PressureMax, ST_SETMAX);
|
||||||
|
|
||||||
addCalc(CPAP_EPAP, ST_SETMAX); // 05
|
addCalc(CPAP_EPAP, ST_SETMAX);
|
||||||
addCalc(CPAP_IPAP, ST_SETMAX); // 06
|
addCalc(CPAP_IPAP, ST_SETMAX);
|
||||||
addCalc(CPAP_EPAPLo, ST_SETMAX); // 07
|
addCalc(CPAP_EPAPLo, ST_SETMAX);
|
||||||
addCalc(CPAP_IPAPHi, ST_SETMAX); // 08
|
addCalc(CPAP_IPAPHi, ST_SETMAX);
|
||||||
|
|
||||||
addCalc(CPAP_EPAP, ST_MID); // 09
|
addCalc(CPAP_EPAP, ST_MID);
|
||||||
addCalc(CPAP_EPAP, ST_90P); // 10
|
addCalc(CPAP_EPAP, ST_90P);
|
||||||
addCalc(CPAP_IPAP, ST_MID); // 11
|
addCalc(CPAP_IPAP, ST_MID);
|
||||||
addCalc(CPAP_IPAP, ST_90P); // 12
|
addCalc(CPAP_IPAP, ST_90P);
|
||||||
}
|
}
|
||||||
|
|
||||||
int gPressureChart::addCalc(ChannelID code, SummaryType type) {
|
|
||||||
|
int gPressureChart::addCalc(ChannelID code, SummaryType type)
|
||||||
|
{
|
||||||
QColor color = schema::channel[code].defaultColor();
|
QColor color = schema::channel[code].defaultColor();
|
||||||
if (type == ST_90P) {
|
if (type == ST_90P) {
|
||||||
color = brighten(color, 1.33f);
|
color = brighten(color, 1.33f);
|
||||||
}
|
}
|
||||||
|
|
||||||
int index = gSummaryChart::addCalc(code, type, color);
|
int index = gSummaryChart::addCalc(code, type, color);
|
||||||
|
|
||||||
|
// Save the code and type used to add this calculation so that getCalc()
|
||||||
|
// can retrieve it by code and type instead of by hard-coded index.
|
||||||
m_calcs[code][type] = index;
|
m_calcs[code][type] = index;
|
||||||
|
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SummaryCalcItem* gPressureChart::getCalc(ChannelID code, SummaryType type)
|
SummaryCalcItem* gPressureChart::getCalc(ChannelID code, SummaryType type)
|
||||||
{
|
{
|
||||||
return &calcitems[m_calcs[code][type]];
|
return &calcitems[m_calcs[code][type]];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void gPressureChart::afterDraw(QPainter &, gGraph &graph, QRectF rect)
|
void gPressureChart::afterDraw(QPainter &, gGraph &graph, QRectF rect)
|
||||||
{
|
{
|
||||||
QStringList presstr;
|
QStringList presstr;
|
||||||
SummaryCalcItem* calc;
|
|
||||||
|
|
||||||
calc = getCalc(CPAP_Pressure);
|
if (getCalc(CPAP_Pressure)->cnt > 0) {
|
||||||
if (calc->cnt > 0) {
|
presstr.append(channelRange(CPAP_Pressure, STR_TR_CPAP));
|
||||||
presstr.append(QString("%1 %2/%3/%4").
|
|
||||||
arg(STR_TR_CPAP).
|
|
||||||
arg(calc->min,0,'f',1).
|
|
||||||
arg(calc->mid(), 0, 'f', 1).
|
|
||||||
arg(calc->max,0,'f',1));
|
|
||||||
}
|
}
|
||||||
if (getCalc(CPAP_PressureMin, ST_SETMIN)->cnt > 0) {
|
if (getCalc(CPAP_PressureMin, ST_SETMIN)->cnt > 0) {
|
||||||
presstr.append(QString("%1 %2/%3/%4/%5").
|
presstr.append(QString("%1 %2/%3/%4/%5").
|
||||||
@ -66,37 +69,17 @@ void gPressureChart::afterDraw(QPainter &, gGraph &graph, QRectF rect)
|
|||||||
arg(getCalc(CPAP_PressureMax, ST_SETMAX)->max, 0, 'f', 1));
|
arg(getCalc(CPAP_PressureMax, ST_SETMAX)->max, 0, 'f', 1));
|
||||||
|
|
||||||
}
|
}
|
||||||
calc = getCalc(CPAP_EPAP);
|
if (getCalc(CPAP_EPAP)->cnt > 0) {
|
||||||
if (calc->cnt > 0) {
|
presstr.append(channelRange(CPAP_EPAP, STR_TR_EPAP));
|
||||||
presstr.append(QString("%1 %2/%3/%4").
|
|
||||||
arg(STR_TR_EPAP).
|
|
||||||
arg(calc->min,0,'f',1).
|
|
||||||
arg(calc->mid(), 0, 'f', 1).
|
|
||||||
arg(calc->max, 0, 'f', 1));
|
|
||||||
}
|
}
|
||||||
calc = getCalc(CPAP_IPAP);
|
if (getCalc(CPAP_IPAP)->cnt > 0) {
|
||||||
if (calc->cnt > 0) {
|
presstr.append(channelRange(CPAP_IPAP, STR_TR_IPAP));
|
||||||
presstr.append(QString("%1 %2/%3/%4").
|
|
||||||
arg(STR_TR_IPAP).
|
|
||||||
arg(calc->min,0,'f',1).
|
|
||||||
arg(calc->mid(), 0, 'f', 1).
|
|
||||||
arg(calc->max, 0, 'f', 1));
|
|
||||||
}
|
}
|
||||||
calc = getCalc(CPAP_EPAPLo);
|
if (getCalc(CPAP_EPAPLo)->cnt > 0) {
|
||||||
if (calc->cnt > 0) {
|
presstr.append(channelRange(CPAP_EPAPLo, STR_TR_EPAPLo));
|
||||||
presstr.append(QString("%1 %2/%3/%4").
|
|
||||||
arg(STR_TR_EPAPLo).
|
|
||||||
arg(calc->min,0,'f',1).
|
|
||||||
arg(calc->mid(), 0, 'f', 1).
|
|
||||||
arg(calc->max, 0, 'f', 1));
|
|
||||||
}
|
}
|
||||||
calc = getCalc(CPAP_IPAPHi);
|
if (getCalc(CPAP_IPAPHi)->cnt > 0) {
|
||||||
if (calc->cnt > 0) {
|
presstr.append(channelRange(CPAP_IPAPHi, STR_TR_IPAPHi));
|
||||||
presstr.append(QString("%1 %2/%3/%4").
|
|
||||||
arg(STR_TR_IPAPHi).
|
|
||||||
arg(calc->min,0,'f',1).
|
|
||||||
arg(calc->mid(), 0, 'f', 1).
|
|
||||||
arg(calc->max, 0, 'f', 1));
|
|
||||||
}
|
}
|
||||||
QString txt = presstr.join(" ");
|
QString txt = presstr.join(" ");
|
||||||
graph.renderText(txt, rect.left(), rect.top()-5*graph.printScaleY(), 0);
|
graph.renderText(txt, rect.left(), rect.top()-5*graph.printScaleY(), 0);
|
||||||
@ -104,6 +87,17 @@ void gPressureChart::afterDraw(QPainter &, gGraph &graph, QRectF rect)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString gPressureChart::channelRange(ChannelID code, const QString & label)
|
||||||
|
{
|
||||||
|
SummaryCalcItem* calc = getCalc(code);
|
||||||
|
return QString("%1 %2/%3/%4").
|
||||||
|
arg(label).
|
||||||
|
arg(calc->min, 0, 'f', 1).
|
||||||
|
arg(calc->mid(), 0, 'f', 1).
|
||||||
|
arg(calc->max, 0, 'f', 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void gPressureChart::populate(Day * day, int idx)
|
void gPressureChart::populate(Day * day, int idx)
|
||||||
{
|
{
|
||||||
float tmp;
|
float tmp;
|
||||||
|
@ -47,6 +47,7 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
SummaryCalcItem* getCalc(ChannelID code, SummaryType type = ST_SETMAX);
|
SummaryCalcItem* getCalc(ChannelID code, SummaryType type = ST_SETMAX);
|
||||||
|
QString channelRange(ChannelID code, const QString & label);
|
||||||
|
|
||||||
QHash<ChannelID,QHash<SummaryType,int>> m_calcs;
|
QHash<ChannelID,QHash<SummaryType,int>> m_calcs;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user