Made graph scaling honour min/max Graph Preferences

This commit is contained in:
Mark Watkins 2014-05-21 00:52:29 +10:00
parent 5dd44a4f32
commit a9ffeac07f
4 changed files with 23 additions and 33 deletions

View File

@ -513,6 +513,19 @@ void gGraph::ToolTip(QString text, int x, int y, int timeout)
// YAxis Autoscaling code
void gGraph::roundY(EventDataType &miny, EventDataType &maxy)
{
if ((zoomY() == 0) && PROFILE.appearance->allowYAxisScaling()) {
if (rec_maxy > rec_miny) {
// Use graph preference settings only for this graph
miny = rec_miny;
maxy = rec_maxy;
return;
} // else use loader defined min/max settings
} else {
// Autoscale this graph
miny = min_y, maxy = max_y;
}
int m, t;
bool ymin_good = false, ymax_good = false;

View File

@ -173,7 +173,6 @@ void gLineChart::paint(QPainter &painter, gGraph &w, const QRegion &region)
top++;
EventDataType miny, maxy;
double minx, maxx;
@ -185,17 +184,12 @@ void gLineChart::paint(QPainter &painter, gGraph &w, const QRegion &region)
// hmmm.. subtract_offset..
/*if (miny<0) {
miny=-MAX(fabs(miny),fabs(maxy));
}*/
EventDataType miny = m_physminy;
EventDataType maxy = m_physmaxy;
if (w.zoomY() == 0 && PROFILE.appearance->allowYAxisScaling()) {
miny = m_physminy, maxy = m_physmaxy;
} else {
miny = w.min_y, maxy = w.max_y;
}
w.roundY(miny, maxy);
//#define DEBUG_AUTOSCALER
#ifdef DEBUG_AUTOSCALER
QString a = QString().sprintf("%.2f - %.2f",miny, maxy);

View File

@ -43,19 +43,8 @@ void gXGrid::paint(QPainter &painter, gGraph &w, const QRegion &region)
int x, y;
EventDataType miny, maxy;
if (w.zoomY() == 0 && PROFILE.appearance->allowYAxisScaling()) {
miny = w.physMinY();
maxy = w.physMaxY();
} else {
miny = w.min_y;
maxy = w.max_y;
if (miny < 0) { // even it up if it's starts negative
miny = -MAX(fabs(miny), fabs(maxy));
}
}
EventDataType miny = w.physMinY();
EventDataType maxy = w.physMaxY();
w.roundY(miny, maxy);
@ -297,16 +286,9 @@ void gYAxis::paint(QPainter &painter, gGraph &w, const QRegion &region)
int labelW = 0;
EventDataType miny;
EventDataType maxy;
if (w.zoomY() == 0 && PROFILE.appearance->allowYAxisScaling()) {
miny = w.physMinY();
maxy = w.physMaxY();
} else {
miny = w.min_y;
maxy = w.max_y;
}
EventDataType miny = w.physMinY();
EventDataType maxy = w.physMaxY();
w.roundY(miny, maxy);

View File

@ -821,9 +821,10 @@ void PreferencesDialog::on_resetGraphButton_clicked()
return;
}
gGraphView *views[3];
gGraphView *views[3] = {0};
views[0] = mainwin->getDaily()->graphView();
views[1] = mainwin->getOverview()->graphView();
if (mainwin->getOximetry())
views[2] = mainwin->getOximetry()->graphView();
// Iterate over all graph containers.