[med-svn] [SCM] aghermann branch, master, updated. 551e213a23b59b71cba6a9c3a282d1b60e21b854
Andrei Zavada
johnhommer at gmail.com
Sun Apr 21 23:17:58 UTC 2013
The following commit has been merged in the master branch:
commit 87b65a8023f50a30ddf201bcd7a442771c7b3498
Author: Andrei Zavada <johnhommer at gmail.com>
Date: Sun Apr 14 00:44:22 2013 +0300
ensure profile_scale_* get calculated
diff --git a/src/ui/mw/measurements.cc b/src/ui/mw/measurements.cc
index c5ed48f..3bdcaf6 100644
--- a/src/ui/mw/measurements.cc
+++ b/src/ui/mw/measurements.cc
@@ -103,6 +103,8 @@ draw_timeline( cairo_t *cr) const
case metrics::TType::mc : scale = _p._p.profile_scale_mc; break;
default: break;
}
+ if ( !isfinite(scale) || scale <= 0. )
+ scale = _p._p.calculate_profile_scale();
// profile
auto& episodes = csubject.measurements[*_p._p._AghDi].episodes;
diff --git a/src/ui/mw/mw.cc b/src/ui/mw/mw.cc
index 0545e44..5389505 100644
--- a/src/ui/mw/mw.cc
+++ b/src/ui/mw/mw.cc
@@ -507,7 +507,7 @@ adjust_op_freq_spinbuttons()
-void
+double
aghui::SExpDesignUI::
calculate_profile_scale()
{
@@ -516,24 +516,33 @@ calculate_profile_scale()
for ( auto& G : groups )
for ( auto &J : G )
if ( J.cprofile && !J.cprofile->mm_list().empty() ) {
- avg_profile_height += J.cprofile->metric_avg();
- ++valid_episodes;
+ auto this_episode_avg = J.cprofile->metric_avg();
+ if ( isfinite(this_episode_avg) ) {
+ avg_profile_height += this_episode_avg;
+ printf( "this_episode_avg %g\n", this_episode_avg);
+ ++valid_episodes;
+ }
}
- avg_profile_height /= valid_episodes;
+ double value =
+ unlikely (valid_episodes == 0)
+ ? 1.
+ : timeline_height / valid_episodes / avg_profile_height * .3;
switch ( display_profile_type ) {
case metrics::TType::psd:
- profile_scale_psd = timeline_height / avg_profile_height * .3;
+ profile_scale_psd = value;
break;
case metrics::TType::swu:
- profile_scale_swu = timeline_height / avg_profile_height * .3;
+ profile_scale_swu = value;
break;
case metrics::TType::mc:
- profile_scale_mc = timeline_height / avg_profile_height * .3;
+ profile_scale_mc = value;
break;
default:
break;
}
+
+ return value;
}
diff --git a/src/ui/mw/mw.hh b/src/ui/mw/mw.hh
index 3af454e..2d694f1 100644
--- a/src/ui/mw/mw.hh
+++ b/src/ui/mw/mw.hh
@@ -261,7 +261,7 @@ class SExpDesignUI
double profile_scale_psd,
profile_scale_swu,
profile_scale_mc;
- void calculate_profile_scale();
+ double calculate_profile_scale();
void modify_profile_scales( GdkScrollDirection);
bool autoscale;
diff --git a/src/ui/mw/populate.cc b/src/ui/mw/populate.cc
index b08efe0..2fdca87 100644
--- a/src/ui/mw/populate.cc
+++ b/src/ui/mw/populate.cc
@@ -421,9 +421,6 @@ populate_1()
timeline_width = (timeline_end - timeline_start) / 3600 * timeline_pph;
timeline_pages = (timeline_end - timeline_start) / ED->fft_params.pagesize;
- if ( profile_scale_psd == 0. || profile_scale_mc == 0. || profile_scale_swu == 0. ) // not previously saved
- calculate_profile_scale();
-
printf( "SExpDesignUI::populate_1(): common timeline:\n");
fputs( asctime( localtime(&earliest_start)), stdout);
fputs( asctime( localtime(&latest_end)), stdout);
--
Sleep experiment manager
More information about the debian-med-commit
mailing list