Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(13)

Delta Between Two Patch Sets: lily/skyline-pair.cc

Issue 5626052: Gets vertical skylines from grob stencils (Closed)
Left Patch Set: Incorporates suggestions from Keith. Created 12 years, 7 months ago
Right Patch Set: Run astyle on c++ files Created 12 years, 6 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« lily/skyline.cc ('K') | « lily/skyline.cc ('k') | lily/slur.cc » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 /* 1 /*
2 This file is part of LilyPond, the GNU music typesetter. 2 This file is part of LilyPond, the GNU music typesetter.
3 3
4 Copyright (C) 2008--2012 Han-Wen Nienhuys <hanwen@lilypond.org> 4 Copyright (C) 2008--2012 Han-Wen Nienhuys <hanwen@lilypond.org>
5 5
6 6
7 LilyPond is free software: you can redistribute it and/or modify 7 LilyPond is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by 8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or 9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version. 10 (at your option) any later version.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 } 49 }
50 50
51 void 51 void
52 Skyline_pair::raise (Real r) 52 Skyline_pair::raise (Real r)
53 { 53 {
54 skylines_[UP].raise (r); 54 skylines_[UP].raise (r);
55 skylines_[DOWN].raise (r); 55 skylines_[DOWN].raise (r);
56 } 56 }
57 57
58 void 58 void
59 Skyline_pair::grow (Real r)
60 {
61 skylines_[UP].raise (r);
62 skylines_[DOWN].raise (-r);
63 }
64
65 void
66 Skyline_pair::deholify () 59 Skyline_pair::deholify ()
67 { 60 {
68 skylines_[UP].deholify (); 61 skylines_[UP].deholify ();
69 skylines_[DOWN].deholify (); 62 skylines_[DOWN].deholify ();
70 } 63 }
71 64
72 void 65 void
73 Skyline_pair::shift (Real r) 66 Skyline_pair::shift (Real r)
74 { 67 {
75 skylines_[UP].shift (r); 68 skylines_[UP].shift (r);
76 skylines_[DOWN].shift (r); 69 skylines_[DOWN].shift (r);
77 } 70 }
78 71
79 void 72 void
80 Skyline_pair::insert (Box const &b, Axis a) 73 Skyline_pair::insert (Box const &b, Axis a)
81 { 74 {
82 skylines_[UP].insert (b, a); 75 skylines_[UP].insert (b, a);
83 skylines_[DOWN].insert (b, a); 76 skylines_[DOWN].insert (b, a);
84 } 77 }
85 78
86 Real 79 Real
87 Skyline_pair::left () 80 Skyline_pair::left () const
88 { 81 {
89 return min (skylines_[UP].left (), skylines_[DOWN].left ()); 82 return min (skylines_[UP].left (), skylines_[DOWN].left ());
90 } 83 }
91 84
92 Real 85 Real
93 Skyline_pair::right () 86 Skyline_pair::right () const
94 { 87 {
95 return max (skylines_[UP].right (), skylines_[DOWN].right ()); 88 return max (skylines_[UP].right (), skylines_[DOWN].right ());
96 } 89 }
97 90
91 // This function comes with the same caveats as smallest_shift:
92 // if the skylines are not contiguous, we may report false
93 // intersections.
94 bool
95 Skyline_pair::intersects (Skyline_pair const &other) const
96 {
97 return skylines_[UP].distance (other[DOWN]) > 0
98 && other[UP].distance (skylines_[DOWN]) > 0;
99 }
100
98 Real 101 Real
99 Skyline_pair::smallest_shift (Skyline_pair const& other, Direction d, 102 Skyline_pair::smallest_shift (Skyline_pair const &other, Direction d,
100 Real h_pad, Real v_pad) 103 Real h_pad, Real v_pad)
101 { 104 {
102 // If skylines_[UP] avoids other[DOWN] or skylines_[DOWN] avoids 105 // If skylines_[UP] avoids other[DOWN] or skylines_[DOWN] avoids
103 // other[UP] then we will not intersect. Substitue LEFT for DOWN 106 // other[UP] then we will not intersect.
104 // and RIGHT for UP in the case where the skyline is horizontal.
105 // Note that this is not guaranteed to return the smallest shift 107 // Note that this is not guaranteed to return the smallest shift
106 // if one Skyline_pair is not connected: the smallest_shift left 108 // if one Skyline_pair is not connected: the smallest_shift left
107 // in the case of 109 // in the case of
108 // AAA 110 // AAA
109 // BBBBBB 111 // BBBBBB
110 // AAA 112 // AAA
111 // will result in 113 // will result in
112 // AAA 114 // AAA
113 // BBBBBB 115 // BBBBBB
114 // AAA 116 // AAA
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 Direction dir = robust_scm2dir (dir_scm, UP); 197 Direction dir = robust_scm2dir (dir_scm, UP);
196 198
197 if (dir == CENTER) 199 if (dir == CENTER)
198 { 200 {
199 warning (_f ("direction must not be CENTER in ly:skyline-pair::skyline")); 201 warning (_f ("direction must not be CENTER in ly:skyline-pair::skyline"));
200 dir = UP; 202 dir = UP;
201 } 203 }
202 204
203 return (*sp)[dir].smobbed_copy (); 205 return (*sp)[dir].smobbed_copy ();
204 } 206 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b