2 local-key-item.cc -- implement Local_key_item, Musical_pitch
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--1998 Han-Wen Nienhuys <hanwen@stack.nl>
9 #include "local-key-item.hh"
10 #include "molecule.hh"
13 #include "paper-def.hh"
14 #include "musical-request.hh"
15 #include "note-head.hh"
18 Local_key_item::Local_key_item (int i)
24 Local_key_item::add_support (Item*head_l)
26 if (support_items_.find_l(head_l))
28 support_items_.push (head_l);
29 add_dependency (head_l);
33 Local_key_item::add (Musical_pitch p)
35 for (int i=0; i< accs.size(); i++)
36 if (!Musical_pitch::compare (p, accs[i]))
43 Local_key_item::do_pre_processing()
45 accs.sort (Musical_pitch::compare);
49 Local_key_item::brew_molecule_p() const
51 Molecule*output = new Molecule;
53 Molecule *octave_mol_p = 0;
55 for (int i = 0; i < accs.size(); i++)
58 if (accs[i].octave_i_ != lastoct)
62 Real dy =lastoct*7*paper()->internote_f ();
63 octave_mol_p->translate_axis (dy, Y_AXIS);
64 output->add (*octave_mol_p);
67 octave_mol_p= new Molecule;
69 lastoct = accs[i].octave_i_;
70 Real dy = (accs[i].notename_i_ + c0_position) * paper()->internote_f ();
71 Atom a (paper()->lookup_l ()->accidental (accs[i].accidental_i_));
73 a.translate_axis (dy, Y_AXIS);
75 octave_mol_p->add_at_edge (X_AXIS, RIGHT, m);
80 Real dy =lastoct*7*paper()->internote_f ();
81 octave_mol_p->translate_axis (dy, Y_AXIS);
82 output->add (*octave_mol_p);
88 Box b(Interval (0, paper()->internote_f ()), Interval (0,0));
89 Molecule m (paper()->lookup_l ()->fill (b));
90 output->add_at_edge (X_AXIS, RIGHT, m);
94 for (int i=0; i < support_items_.size(); i++)
96 Axis_group_element *common =
97 common_group (support_items_[i], X_AXIS);
99 Real x = support_items_[i]->relative_coordinate (common, X_AXIS)
100 -relative_coordinate (common, X_AXIS);
102 x_int.unite (x + support_items_[i]->width());
104 if (x_int.empty_b ())
105 x_int = Interval(0,0);
107 output->translate_axis (-output->extent()[X_AXIS][RIGHT] + x_int[LEFT], X_AXIS);
112 IMPLEMENT_IS_TYPE_B1(Local_key_item,Item);
115 Local_key_item::do_substitute_dependency (Score_elem*o,Score_elem*n)
117 Item* o_l = o->item();
118 Item* n_l = n?n->item():0;
120 support_items_.substitute (o_l, n_l);