2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 2005--2015 Han-Wen Nienhuys <hanwen@xs4all.nl>
6 LilyPond is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 LilyPond is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
20 #ifndef TIE_FORMATTING_PROBLEM_HH
21 #define TIE_FORMATTING_PROBLEM_HH
23 #include "drul-array.hh"
25 #include "tie-configuration.hh"
26 #include "tie-details.hh"
27 #include "tie-specification.hh"
33 typedef map< Tuple<int, 4>, Tie_configuration *> Tie_configuration_map;
35 struct Tie_configuration_variation
37 vector<pair<int, Tie_configuration *> > index_suggestion_pairs_;
38 void add_suggestion (int index, Tie_configuration *suggestion)
40 index_suggestion_pairs_.push_back (make_pair (index, suggestion));
44 typedef map < Tuple<int, 2>, Skyline> Chord_outline_map;
45 typedef map < Tuple<int, 2>, Box> Column_extent_map;
46 typedef map <int, Slice> Position_extent_map;
48 class Tie_formatting_problem
50 Chord_outline_map chord_outlines_;
51 Column_extent_map stem_extents_;
52 Column_extent_map head_extents_;
53 Position_extent_map head_positions_;
55 set<int> dot_positions_;
57 vector<Tie_specification> specifications_;
58 bool use_horizontal_spacing_;
60 Tie_configuration_map possibilities_;
65 Tie_configuration *get_configuration (int position, Direction dir, Drul_array<int> cols, bool tune_y) const;
66 Tie_configuration *generate_configuration (int position, Direction dir, Drul_array<int> cols, bool tune_y) const;
68 vector<Tie_configuration_variation> generate_collision_variations (Ties_configuration const &ties) const;
69 vector<Tie_configuration_variation> generate_extremal_tie_variations (Ties_configuration const &ties) const;
70 vector<Tie_configuration_variation> generate_single_tie_variations (Ties_configuration const &ties) const;
72 void score_configuration (Tie_configuration *) const;
73 Real score_aptitude (Tie_configuration *, Tie_specification const &,
74 Ties_configuration *, int) const;
75 void score_ties_aptitude (Ties_configuration *ties) const;
76 void score_ties_configuration (Ties_configuration *ties) const;
77 void set_ties_config_standard_directions (Ties_configuration *tie_configs_ptr);
78 void score_ties (Ties_configuration *) const;
80 Slice head_positions_slice (int) const;
81 Ties_configuration generate_base_chord_configuration ();
82 Ties_configuration find_best_variation (Ties_configuration const &base,
83 vector<Tie_configuration_variation> const &vars);
87 void print_ties_configuration (Ties_configuration const *);
89 Interval get_stem_extent (int, Direction, Axis) const;
90 Interval get_head_extent (int, Direction, Axis) const;
93 Tie_formatting_problem ();
94 ~Tie_formatting_problem ();
96 Tie_specification get_tie_specification (int) const;
97 Ties_configuration generate_optimal_configuration ();
98 Ties_configuration generate_ties_configuration (Ties_configuration const &);
100 void from_ties (vector<Grob *> const &ties);
101 void from_tie (Grob *tie);
102 void from_semi_ties (vector<Grob *> const &, Direction head_dir);
103 void set_chord_outline (vector<Item *>, Direction);
104 void set_column_chord_outline (vector<Item *>, Direction, int rank);
105 void set_manual_tie_configuration (SCM);
106 Interval get_attachment (Real, Drul_array<int>) const;
107 Grob *common_x_refpoint () const;
108 void set_debug_scoring (Ties_configuration const &);
111 #endif /* TIE_FORMATTING_PROBLEM_HH */