[med-svn] [SCM] aghermann branch, master, updated. 551e213a23b59b71cba6a9c3a282d1b60e21b854
andrei zavada
jh at johnhommer.com
Sun Apr 21 23:18:06 UTC 2013
The following commit has been merged in the master branch:
commit cbccf5d5e48632510be69cfbe39be1a81058e80a
Author: andrei zavada <jh at johnhommer.com>
Date: Thu Apr 18 16:58:56 2013 +0000
WIP
diff --git a/src/libsigfile/edf.cc b/src/libsigfile/edf.cc
index bc9ca10..f59c753 100644
--- a/src/libsigfile/edf.cc
+++ b/src/libsigfile/edf.cc
@@ -196,9 +196,9 @@ CEDFFile (const string& fname_, int flags_)
continue;
while ( !thomas.eof() ) {
- size_t aa = (size_t)-1, az = (size_t)-1;
+ double aa = NAN, az = NAN;
thomas >> aa >> az;
- if ( aa == (size_t)-1 || az == (size_t)-1 )
+ if ( not isfinite(aa) || not isfinite(az) )
break;
H.artifacts.mark_artifact( aa, az);
}
@@ -210,19 +210,20 @@ CEDFFile (const string& fname_, int flags_)
if ( not fd.good() )
continue;
int type = -1;
- size_t aa = -1, az = -1;
+ double aa = NAN, az = NAN;
string an;
while ( fd.good() and not fd.eof() ) {
fd >> type >> aa >> az;
getline( fd, an, EOA);
- if ( aa < az and az < n_data_records * H.samples_per_record
+ if ( isfinite(aa) and isfinite(az) and
+ aa < az and az < n_data_records * data_record_size
and type < SAnnotation<size_t>::TType_total and type >= 0 )
H.annotations.emplace_back(
aa, az,
trim(an),
(SAnnotation<double>::TType)type);
else {
- fprintf( stderr, "Bad annotation: (%d %zu %zu %50s)\n", type, aa, az, an.c_str());
+ fprintf( stderr, "Bad annotation: (%d %g %g %50s)\n", type, aa, az, an.c_str());
break;
}
}
diff --git a/src/ui/sf/montage.cc b/src/ui/sf/montage.cc
index e0904c5..8b6051e 100644
--- a/src/ui/sf/montage.cc
+++ b/src/ui/sf/montage.cc
@@ -439,12 +439,10 @@ draw_page( cairo_t *cr,
}
}
- size_t half_pad = wd * _p.skirting_run_per1,
- ef = wd + 2*half_pad;
+ double half_pad = _p.pagesize() * _p.skirting_run_per1;
- int half_pad_samples = _p.skirting_run_per1 * _p.vpagesize() * samplerate(),
- cvpa = _p.cur_vpage_start() * samplerate() - half_pad_samples,
- cvpe = _p.cur_vpage_end() * samplerate() + half_pad_samples,
+ double cvpa = _p.cur_vpage_start() - half_pad,
+ cvpe = _p.cur_vpage_end() + half_pad,
evpz = cvpe - cvpa;
// artifacts (changed bg)
{
@@ -454,22 +452,23 @@ draw_page( cairo_t *cr,
.4);
for ( auto &A : Aa() ) {
if ( agh::alg::overlap(
- (int)A.a, (int)A.z,
+ A.a, A.z,
cvpa, cvpe) ) {
- int aa = (int)A.a - cvpa,
- ae = (int)A.z - cvpa;
- if ( aa < 0 ) aa = 0;
+ double aa = A.a - cvpa,
+ ae = A.z - cvpa;
+ if ( aa < 0. ) aa = 0.;
if ( ae > evpz ) ae = evpz;
- cairo_rectangle( cr,
- (float)(aa % evpz) / evpz * wd, ptop + _p.interchannel_gap * 1./3,
- (float)(ae - aa) / evpz * wd, _p.interchannel_gap * 1./3);
+ cairo_rectangle(
+ cr,
+ fmod(aa, evpz) / evpz * wd, ptop + _p.interchannel_gap * 1./3,
+ (ae - aa) / evpz * wd, _p.interchannel_gap * 1./3);
cairo_fill( cr);
cairo_stroke( cr);
- } else if ( (int)A.a > cvpe ) // no more artifacts up to and on current page
+ } else if ( A.a > cvpe ) // no more artifacts up to and on current page
break;
}
_p._p.CwB[SExpDesignUI::TColour::sf_labels].set_source_rgb( cr);
- cairo_move_to( cr, ef-70, y0 + 15);
+ cairo_move_to( cr, wd-70, y0 + 15);
cairo_set_font_size( cr, 8);
snprintf_buf( "%4.2f %% dirty", percent_dirty);
cairo_show_text( cr, __buf__);
@@ -480,21 +479,21 @@ draw_page( cairo_t *cr,
// annotations
if ( _p.mode == aghui::SScoringFacility::TMode::scoring
and not annotations.empty() ) {
- int last_z = 0;
+ double last_z = 0;
int overlap_count = 0;
for ( auto &A : annotations ) {
- if ( agh::alg::overlap( (int)A.span.a, (int)A.span.z, cvpa, cvpe) ) {
- int aa = (int)A.span.a - cvpa,
- ae = (int)A.span.z - cvpa;
- agh::alg::ensure_within( aa, -half_pad_samples, -half_pad_samples + evpz);
- agh::alg::ensure_within( ae, -half_pad_samples, -half_pad_samples + evpz);
+ if ( agh::alg::overlap( A.span.a, A.span.z, cvpa, cvpe) ) {
+ double aa = A.span.a - cvpa,
+ ae = A.span.z - cvpa;
+ agh::alg::ensure_within( aa, -half_pad, -half_pad + evpz);
+ agh::alg::ensure_within( ae, -half_pad, -half_pad + evpz);
- auto wa = (float)(aa % evpz) / evpz * wd,
- ww = (float)(ae - aa) / evpz * wd;
+ auto wa = fmod(aa, evpz) / evpz * wd,
+ ww = (ae - aa) / evpz * wd;
if ( A.type == sigfile::SAnnotation<double>::TType::plain ) {
int disp = ptop +
- ((last_z > (int)A.span.a)
+ ((last_z > A.span.a)
? ++overlap_count * 5
: (overlap_count = 0));
last_z = A.span.z;
@@ -512,7 +511,7 @@ draw_page( cairo_t *cr,
cairo_select_font_face( cr, "serif", CAIRO_FONT_SLANT_ITALIC, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size( cr, 11);
cairo_set_source_rgb( cr, 0., 0., 0.);
- cairo_move_to( cr, (float)(aa % evpz) / evpz * wd, disp + 12);
+ cairo_move_to( cr, fmod(aa, evpz) / evpz * wd, disp + 12);
cairo_show_text( cr, A.label.c_str());
} else if ( A.type == sigfile::SAnnotation<double>::TType::phasic_event_spindle
--
Sleep experiment manager
More information about the debian-med-commit
mailing list