+ for (Marks::iterator x = metric_marks.begin(); x != metric_marks.end(); ++x) {
+ TempoMarker* tempo_marker;
+ MeterMarker* meter_marker;
+ TempoSection *ts;
+ const MeterSection *ms;
+
+ if ((tempo_marker = dynamic_cast<TempoMarker*> (*x)) != 0) {
+ if ((ts = &tempo_marker->tempo()) != 0) {
+
+ tempo_marker->set_position (ts->sample ());
+
+ if (prev_ts && abs (prev_ts->end_note_types_per_minute() - ts->note_types_per_minute()) < 1.0) {
+ tempo_marker->set_points_color (UIConfiguration::instance().color ("tempo marker music"));
+ } else {
+ tempo_marker->set_points_color (UIConfiguration::instance().color ("tempo marker"));
+ }
+
+ max_tempo = max (max_tempo, ts->note_types_per_minute());
+ max_tempo = max (max_tempo, ts->end_note_types_per_minute());
+ min_tempo = min (min_tempo, ts->note_types_per_minute());
+ min_tempo = min (min_tempo, ts->end_note_types_per_minute());
+
+ prev_ts = ts;
+ }
+ }
+ if ((meter_marker = dynamic_cast<MeterMarker*> (*x)) != 0) {
+ if ((ms = &meter_marker->meter()) != 0) {
+ meter_marker->set_position (ms->sample ());
+ }
+ }
+ }
+
+ tempo_curves.sort (CurveComparator());
+
+ const double min_tempo_range = 5.0;
+ const double tempo_delta = fabs (max_tempo - min_tempo);
+
+ if (tempo_delta < min_tempo_range) {
+ max_tempo += min_tempo_range - tempo_delta;
+ min_tempo += tempo_delta - min_tempo_range;
+ }
+
+ for (Curves::iterator x = tempo_curves.begin(); x != tempo_curves.end(); ) {
+ Curves::iterator tmp = x;
+ (*x)->set_max_tempo (max_tempo);
+ (*x)->set_min_tempo (min_tempo);
+ ++tmp;
+ if (tmp != tempo_curves.end()) {
+ (*x)->set_position ((*x)->tempo().sample(), (*tmp)->tempo().sample());
+ } else {
+ (*x)->set_position ((*x)->tempo().sample(), UINT32_MAX);
+ }
+
+ if (!(*x)->tempo().active()) {
+ (*x)->hide();
+ } else {
+ (*x)->show();
+ }
+
+ ++x;
+ }
+
+ for (Marks::iterator x = metric_marks.begin(); x != metric_marks.end(); ++x) {
+ TempoMarker* tempo_marker;
+ if ((tempo_marker = dynamic_cast<TempoMarker*> (*x)) != 0) {
+ tempo_marker->update_height_mark ((tempo_marker->tempo().note_types_per_minute() - min_tempo) / max (max_tempo - min_tempo, 10.0));
+ }