1 /* 2 This file is part of LilyPond, the GNU music typesetter. 3 4 Copyright (C) 2005--2020 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_CONFIGURATION_HH 21 #define TIE_CONFIGURATION_HH 22 23 #include "direction.hh" 24 #include "interval.hh" 25 #include "std-vector.hh" 26 #include "main.hh" // DEBUG_SLUR_SCORING 27 28 class Tie_configuration 29 { 30 #if DEBUG_SLUR_SCORING 31 std::string score_card_; 32 #endif 33 Real score_; 34 bool scored_; 35 friend class Tie_formatting_problem; 36 37 public: score() const38 Real score () const { return score_; } card() const39 std::string card () const { return score_card_; } 40 41 int position_; 42 Direction dir_; 43 Real delta_y_; 44 Drul_array<int> column_ranks_; 45 46 /* computed. */ 47 Interval attachment_x_; 48 49 void add_score (Real, const std::string &); 50 Tie_configuration (); 51 void center_tie_vertically (Tie_details const &); 52 Bezier get_transformed_bezier (Tie_details const &) const; 53 Bezier get_untransformed_bezier (Tie_details const &) const; 54 Real height (Tie_details const &) const; 55 int column_span_length () const; 56 57 static int compare (Tie_configuration const &a, 58 Tie_configuration const &b); 59 static Real distance (Tie_configuration const &a, 60 Tie_configuration const &b); 61 }; 62 63 INSTANTIATE_COMPARE (Tie_configuration, Tie_configuration::compare); 64 65 // TODO: Avoid public inheritance from STL containers because they don't have 66 // virtual destructors, which can lead to bugs if they are not used carefully. 67 class Ties_configuration : public std::vector<Tie_configuration> 68 { 69 Real score_; 70 std::string score_card_; 71 bool scored_; 72 std::vector<std::string> tie_score_cards_; 73 74 friend class Tie_formatting_problem; 75 public: 76 Ties_configuration (); 77 void add_score (Real amount, const std::string &description); 78 void add_tie_score (Real amount, vsize i, const std::string &description); 79 Real score () const; 80 void reset_score (); 81 std::string card () const; tie_card(vsize i) const82 std::string tie_card (vsize i) const { return tie_score_cards_[i]; } 83 std::string complete_tie_card (vsize i) const; 84 std::string complete_score_card () const; 85 }; 86 87 #endif /* TIE_CONFIGURATION_HH */ 88 89