]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/tie-formatting-problem.hh
3f21dba6a11b3a7df5ca5f93c1c4e126993128bb
[lilypond.git] / lily / include / tie-formatting-problem.hh
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 2005--2012 Han-Wen Nienhuys <hanwen@xs4all.nl>
5
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.
10
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.
15
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/>.
18 */
19
20 #ifndef TIE_FORMATTING_PROBLEM_HH
21 #define TIE_FORMATTING_PROBLEM_HH
22
23 #include "drul-array.hh"
24 #include "skyline.hh"
25 #include "tie-configuration.hh"
26 #include "tie-details.hh"
27 #include "tie-specification.hh"
28 #include "tuple.hh"
29
30 #include <map>
31 #include <set>
32
33 typedef map< Tuple<int, 4>, Tie_configuration *> Tie_configuration_map;
34
35 struct Tie_configuration_variation
36 {
37   vector<pair<int, Tie_configuration *> > index_suggestion_pairs_;
38   void add_suggestion (int index, Tie_configuration *suggestion)
39   {
40     index_suggestion_pairs_.push_back (make_pair (index, suggestion));
41   }
42 };
43
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;
47
48 class Tie_formatting_problem
49 {
50   Chord_outline_map chord_outlines_;
51   Column_extent_map stem_extents_;
52   Column_extent_map head_extents_;
53   Position_extent_map head_positions_;
54
55   set<int> dot_positions_;
56   Interval dot_x_;
57   vector<Tie_specification> specifications_;
58   bool use_horizontal_spacing_;
59
60   Tie_configuration_map possibilities_;
61
62   Grob *x_refpoint_;
63   Grob *y_refpoint_;
64
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;
67
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;
71
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;
79
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);
84
85 public:
86   Tie_details details_;
87   void print_ties_configuration (Ties_configuration const *);
88
89   Interval get_stem_extent (int, Direction, Axis) const;
90   Interval get_head_extent (int, Direction, Axis) const;
91
92 public:
93   Tie_formatting_problem ();
94   ~Tie_formatting_problem ();
95
96   Tie_specification get_tie_specification (int) const;
97   Ties_configuration generate_optimal_configuration ();
98   Ties_configuration generate_ties_configuration (Ties_configuration const &);
99
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 &);
109 };
110
111 #endif /* TIE_FORMATTING_PROBLEM_HH */