2005-05-04 Han-Wen Nienhuys <hanwen@xs4all.nl>
+ * lily/*.cc: more <? >? to min/max changes
+
* lily/include/interpretation-context-handle.hh: rename
Interpretation_context_handle to Context_handle.
Rest_collision::force_shift_callback (SCM element_smob, SCM axis)
{
Grob *them = unsmob_grob (element_smob);
- Axis a = (Axis) scm_to_int (axis);
- assert (a == Y_AXIS);
+ (void) axis;
+ assert (scm_to_int (axis) == Y_AXIS);
if (Note_column::has_rests (them))
{
}
Real dist
- = minimum_dist + dir * (notedim[dir] - restdim[-dir]) >? 0;
+ = minimum_dist + dir * max (notedim[dir] - restdim[-dir], 0.0);
int stafflines = Staff_symbol_referencer::line_count (me);
if (!stafflines)
#include "scm-hash.hh"
#include <cstdio>
+#include <algorithm>
#include "ly-smobs.icc"
+using namespace std;
+
/*
Return: number of objects.
*/
elt_count_ = 0;
smobify_self ();
- hash_tab_ = scm_make_vector (scm_int2num (src.elt_count_ >? 11), SCM_EOL);
+ hash_tab_ = scm_make_vector (scm_int2num (max ((int) src.elt_count_, 11)), SCM_EOL);
elt_count_ = copy_scm_hashes (hash_tab_, src.hash_tab_);
}
if (&src == this)
return;
- hash_tab_ = scm_make_vector (scm_int2num (src.elt_count_ >? 11), SCM_EOL);
+ hash_tab_ = scm_make_vector (scm_int2num (max ((int) src.elt_count_, 11)), SCM_EOL);
elt_count_ = copy_scm_hashes (hash_tab_, src.hash_tab_);
}
#include "side-position-interface.hh"
#include <math.h> // ceil.
+#include <algorithm>
+
#include "note-head.hh"
#include "warn.hh"
#include "staff-symbol-referencer.hh"
#include "string-convert.hh"
+using namespace std;
+
void
Side_position_interface::add_support (Grob *me, Grob *e)
{
Interval staff_size = st->extent (common, Y_AXIS);
Real diff = d*staff_size[d] + padding - d * (o + iv[-d]);
- o += (d * (diff >? 0));
+ o += d * max (diff, 0.0);
}
return scm_make_real (o);
Real block_stretch = dist - d;
Real block_force = c * block_stretch;
- force_ = force_ >? block_force;
+ force_ = max (force_, block_force);
for (int i = l; i < r; i++)
- springs_[i].block_force_ = block_force >?
- springs_[i].block_force_;
+ springs_[i].block_force_ = max (block_force, springs_[i].block_force_);
}
Real
for (int i = 0; i < springs_.size (); i++)
if (springs_[i].is_active_)
{
- bf = bf >? springs_[i].block_force_;
+ bf = max (bf, springs_[i].block_force_);
}
return bf;
}
while (is_active ())
{
- force_ = active_blocking_force () >? 0.0;
+ force_ = max (active_blocking_force (), 0.0);
Real conf = configuration_length ();
if (conf < line_len_)
w.intersect (clouds[j].width_);
if (!w.is_empty ())
- distance = distance >? (buildings[i].height_ - clouds[j].height_);
+ distance = max (distance, (buildings[i].height_ - clouds[j].height_));
if (i > 0 && buildings[i].width_[LEFT] >= clouds[j].width_[LEFT])
{
Real y = curve.get_other_coordinate (X_AXIS, p[X_AXIS]);
if (y)
{
- fit_factor = fit_factor >? (p[Y_AXIS] / y);
+ fit_factor = max (fit_factor, (p[Y_AXIS] / y));
}
}
return fit_factor;
continue;
Encompass_info inf (state.get_encompass_info (encompasses[i]));
- Real y = state.dir_ * ((state.dir_ * inf.head_) >? (state.dir_ * inf.stem_));
+ Real y = state.dir_ * (max (state.dir_ * inf.head_, state.dir_ * inf.stem_));
avoid.push (Offset (inf.x_, y + state.dir_ * state.parameters_.free_head_distance_));
}
(control3 - control0). */
Real max_indent = len / 3.1;
- indent = indent <? max_indent;
+ indent = min (indent, max_indent);
Real a1 = sqr (len) / 3.0;
Real a2 = 0.75 * sqr (indent + len / 3.0);
Real ff = fit_factor (dz_unit, dz_perp, curve, state.dir_, avoid);
- height = height >? ((height * ff) <? max_h);
+ height = max (height, min (height * ff, max_h));
curve.control_[0] = attachment_[LEFT];
curve.control_[1] = attachment_[LEFT] + dz_perp * height * state.dir_
Real hd = (head_dy)
? (1 / fabs (head_dy) - 1 / state.parameters_.free_head_distance_)
: state.parameters_.head_encompass_penalty_;
- hd = (hd >? 0)<? state.parameters_.head_encompass_penalty_;
+ hd = min (max (hd, 0.0), state.parameters_.head_encompass_penalty_);
demerit += hd;
}
{
Real closest
- = state.dir_ * (state.dir_ * state.encompass_infos_[j].get_point (state.dir_)
- >? state.dir_ * line_y);
+ = state.dir_ * max (state.dir_ * state.encompass_infos_[j].get_point (state.dir_), state.dir_ * line_y);
Real d = fabs (closest - y);
convex_head_distances.push (d);
// ?
demerit += -state.parameters_.closeness_factor_
* (state.dir_
- * (y - (ext[state.dir_] + state.dir_ * state.parameters_.free_head_distance_))
- <? 0)
+ * min (y - (ext[state.dir_] + state.dir_ * state.parameters_.free_head_distance_), 0.0))
/ state.encompass_infos_.size ();
}
}
Real min_dist = infinity_f;
for (int j = 0; j < convex_head_distances.size (); j++)
{
- min_dist = min_dist <? convex_head_distances[j];
+ min_dist = min (min_dist, convex_head_distances[j]);
avg_distance += convex_head_distances[j];
}
variance_penalty = state.parameters_.head_slur_distance_max_ratio_;
if (min_dist > 0.0)
variance_penalty
- = (avg_distance / (min_dist + state.parameters_.absolute_closeness_measure_) - 1.0)
- <? variance_penalty;
+ = min ((avg_distance / (min_dist + state.parameters_.absolute_closeness_measure_) - 1.0), variance_penalty);
- variance_penalty = variance_penalty >? 0.0;
+ variance_penalty = max (variance_penalty, 0.0);
variance_penalty *= state.parameters_.head_slur_distance_factor_;
}
Real dist = state.extra_encompass_infos_[j].extents_[Y_AXIS].distance (y);
demerit
- += fabs (0 >? (state.parameters_.extra_encompass_free_distance_ - dist))
+ += fabs (max (0.0, (state.parameters_.extra_encompass_free_distance_ - dist)))
/ state.parameters_.extra_encompass_free_distance_
* state.extra_encompass_infos_[j].penalty_;
}
Real slur_dy = slur_dz[Y_AXIS];
Real demerit = 0.0;
- demerit += ((fabs (slur_dy / slur_dz[X_AXIS])
- - state.parameters_.max_slope_) >? 0)
+ demerit += max ((fabs (slur_dy / slur_dz[X_AXIS])
+ - state.parameters_.max_slope_), 0.0)
* state.parameters_.max_slope_factor_;
/* 0.2: account for staffline offset. */
if (!state.is_broken_)
demerit += state.parameters_.steeper_slope_factor_
- * ((fabs (slur_dy) -max_dy) >? 0);
+ * (max (fabs (slur_dy) -max_dy, >? 0.0));
- demerit += ((fabs (slur_dy / slur_dz[X_AXIS])
- - state.parameters_.max_slope_) >? 0)
+ demerit += max ((fabs (slur_dy / slur_dz[X_AXIS])
+ - state.parameters_.max_slope_), 0.0)
* state.parameters_.max_slope_factor_;
if (sign (dy) == 0
if (extremes_[d].note_column_)
{
end_ys[d] = dir_
- * ((dir_ * (base_attachments_[d][Y_AXIS] + parameters_.region_size_ * dir_))
- >? (dir_ * (dir_ + extremes_[d].note_column_->extent (common_[Y_AXIS],
- Y_AXIS)[dir_]))
- >? (dir_ * base_attachments_[-d][Y_AXIS]));
+ * max (max (dir_ * (base_attachments_[d][Y_AXIS] + parameters_.region_size_ * dir_),
+ dir_ * (dir_ + extremes_[d].note_column_->extent (common_[Y_AXIS], Y_AXIS)[dir_])),
+ dir_ * base_attachments_[-d][Y_AXIS]);
}
else
end_ys[d] = base_attachments_[d][Y_AXIS] + parameters_.region_size_ * dir_;
{
Grob *script = unsmob_grob (grob);
Axis a = Axis (scm_to_int (axis));
+ (void) a;
assert (a == Y_AXIS);
Grob *slur = unsmob_grob (script->get_property ("slur"));
Direction dir = get_grob_direction (script);
for (int d = LEFT; d <= RIGHT; d++)
{
- offset = dir * (dir * offset >? dir
- * (ys[k] - yext[-dir] + dir * slur_padding));
+ offset = dir * (max (dir * offset,
+ dir * (ys[k] - yext[-dir] + dir * slur_padding)));
k++;
}
}
Span_bar::width_callback (SCM element_smob, SCM scm_axis)
{
Grob *se = unsmob_grob (element_smob);
- Axis a = (Axis) scm_to_int (scm_axis);
- assert (a == X_AXIS);
+ (void) scm_axis;
+
+ assert ( (Axis) scm_to_int (scm_axis) == X_AXIS);
String gl = ly_scm2string (se->get_property ("glyph"));
/*
Span_bar::center_on_spanned_callback (SCM element_smob, SCM axis)
{
Grob *me = unsmob_grob (element_smob);
- Axis a = (Axis) scm_to_int (axis);
- assert (a == Y_AXIS);
+ (void) axis;
+ assert (scm_to_int (axis) == Y_AXIS);
Interval i (get_spanned_interval (me));
/* Bar_line::print delivers a barline of y-extent (-h/2, h/2), so
return 0.0;
Item *col = dynamic_cast<Item *> (g)->get_column ();
- Real max_corr = 0. >? (- g->extent (col, X_AXIS)[LEFT]);
+ Real max_corr = max (0., (- g->extent (col, X_AXIS)[LEFT]));
/*
Duh. If this gets out of hand, we should invent something more generic.
else
v = a->extent (col, X_AXIS);
- max_corr = max_corr >? (- v[LEFT]);
+ max_corr = max (max_corr, (- v[LEFT]));
}
if (Grob *a = unsmob_grob (g->get_property ("arpeggio")))
{
- max_corr = max_corr >? (- a->extent (col, X_AXIS)[LEFT]);
+ max_corr = max (max_corr, - a->extent (col, X_AXIS)[LEFT]);
}
/*
{
Real stem_start = Stem::head_positions (stem) [DOWN];
Real stem_end = Stem::stem_end_position (stem);
- Interval stem_posns (stem_start <? stem_end,
- stem_end >? stem_start);
+ Interval stem_posns (min (stem_start, stem_end),
+ max (stem_end, stem_start));
stem_posns.intersect (bar_size);
- Real corr = abs (stem_posns.length () / 7.) <? 1.0;
+ Real corr = min (abs (stem_posns.length () / 7.0), 1.0);
corr
*= robust_scm2double (me->get_property ("stem-spacing-correction"), 1);
if (d != DOWN)
corr = 0.0;
- max_corr = max_corr >? corr;
+ max_corr = max (max_corr, corr);
}
}
return max_corr;
{
Grob *g = unsmob_grob (scm_car (s));
- max_corr = max_corr >? next_note_correction (me, g, bar_size);
+ max_corr = max (max_corr, next_note_correction (me, g, bar_size));
for (SCM t = g->get_property ("elements");
scm_is_pair (t); t = scm_cdr (t))
- max_corr = max_corr >? next_note_correction (me, unsmob_grob (scm_car (t)), bar_size);
+ max_corr = max (max_corr, next_note_correction (me, unsmob_grob (scm_car (t)), bar_size));
}
return max_corr;
}
else if (type == ly_symbol2scm ("minimum-space"))
{
- *space = last_ext[LEFT] + (last_ext.length () >? distance);
+ *space = last_ext[LEFT] + max (last_ext.length (), distance);
}
else if (type == ly_symbol2scm ("minimum-fixed-space"))
{
- *space = last_ext[LEFT] + (last_ext.length () >? distance);
+ *space = last_ext[LEFT] + max (last_ext.length (), distance);
*fixed = *space;
}
Real end_y
= Stem::stem_end_position (stem) * ss / 2
- stemdir * (beam_count * beamthickness
- + ((beam_count -1) >? 0) * beam_translation);
+ + (max (beam_count -1, 0) * beam_translation));
/* FIXME: the 0.33 ss is to compensate for the size of the note head. */
Real chord_start_y = Stem::chord_start_y (stem) + 0.33 * ss * stemdir;
{
SCM sshorten = me->get_property ("stem-shorten");
SCM scm_shorten = scm_is_pair (sshorten)
- ? robust_list_ref ((duration_log (me) - 2) >? 0, sshorten) : SCM_EOL;
+ ? robust_list_ref (max (duration_log (me) - 2, 0), sshorten) : SCM_EOL;
Real shorten = 2* robust_scm2double (scm_shorten, 0);
/* On boundary: shorten only half */
if (dir == DOWN)
minlen -= 1.0;
}
- length = length >? (minlen + 1.0);
+ length = max (length, minlen + 1.0);
}
Real st = dir ? hp[dir] + dir * length : 0;
SCM
Stem::width_callback (SCM e, SCM ax)
{
- Axis a = (Axis) scm_to_int (ax);
- assert (a == X_AXIS);
+ (void) ax;
+ assert (scm_to_int (ax) == X_AXIS);
Grob *me = unsmob_grob (e);
Interval r;
y2 -= d
* (0.5 * beam_thickness
- + beam_translation * (0 >? (beam_count - 1))
+ + beam_translation * max (0, (beam_count - 1))
+ stemlet_length) / half_space;
}
- Interval stem_y (y1 <? y2, y2 >? y1);
+ Interval stem_y (min (y1, y2), max (y2, y1));
if (Grob *hed = support_head (me))
{
/* stem only extends to center of beam */
- 0.5 * beam_thickness;
- ideal_length = ideal_length >? ideal_minimum_length;
+ ideal_length = max (ideal_length, ideal_minimum_length);
/* Convert to Y position, calculate for dir == UP */
Real note_start
{
/* Highest beam of (UP) beam must never be lower than middle
staffline */
- ideal_y = ideal_y >? 0;
+ ideal_y = max (ideal_y, 0.0);
/* Lowest beam of (UP) beam must never be lower than second staffline */
- ideal_y = ideal_y >? (-staff_space
- - beam_thickness + height_of_my_beams);
+ ideal_y = max (ideal_y, (-staff_space
+ - beam_thickness + height_of_my_beams));
}
ideal_y -= robust_scm2double (beam->get_property ("shorten"), 0);
{
Interval y_ext = tremolo->extent (tremolo, Y_AXIS);
y_ext.widen (0.5); // FIXME. Should be tunable?
- minimum_length = minimum_length >? y_ext.length ();
+ minimum_length = max (minimum_length, y_ext.length ());
}
ideal_y *= my_dir;
fm = select_font (me->get_layout (), scm_list_n (alist, SCM_UNDEFINED));
int lo = 0;
- int hi = (fm->count () - 1) >? 2;
+ int hi = max (fm->count () - 1,2);
Box b;
/* do a binary search for each Y, not very efficient, but passable? */
Real point_constant = 1 PT;
return Box (Interval (0, width_ * point_constant),
- Interval ((d <? height_) * point_constant,
- (d >? height_) * point_constant));
+ Interval (min (d, height_) * point_constant,
+ max (d, height_) * point_constant));
}
Tex_font_metric::Tex_font_metric ()
Tex_font_metric::name_to_index (String) const
{
assert (false);
+ return 0;
}
SCM s = get_property ("tupletSpannerDuration");
if (unsmob_moment (s))
- d.span_stop_ = d.span_stop_ <? (now_mom () + *unsmob_moment (s)).main_part_;
+ d.span_stop_ = min (d.span_stop_, (now_mom () + *unsmob_moment (s)).main_part_);
tuplets_.push (d);
}