/// <summary> /// Writes a clef to the SVG file. /// The Character metrics have been set in SvgSystem.Justify() /// </summary> public override void WriteSVG(SvgWriter w, bool staffIsVisible) { if (this.Metrics != null && staffIsVisible) { ClefMetrics m = Metrics as ClefMetrics; if (m != null) { w.SvgUseXY("clef" + SvgScore.UniqueID_Number, m.ID_Type, m.OriginX, m.OriginY, m.FontHeight); } } }
public override Metrics NoteObjectMetrics(Graphics graphics, NoteObject noteObject, VerticalDir voiceStemDirection, float gap, float strokeWidth) { Metrics returnMetrics = null; ClefSymbol clef = noteObject as ClefSymbol; Barline barline = noteObject as Barline; CautionaryChordSymbol cautionaryChordSymbol = noteObject as CautionaryChordSymbol; ChordSymbol chord = noteObject as ChordSymbol; RestSymbol rest = noteObject as RestSymbol; if (barline != null) { returnMetrics = new BarlineMetrics(graphics, barline, gap); } else if (clef != null) { if (clef.ClefType != "n") { returnMetrics = new ClefMetrics(clef, gap); } } else if (cautionaryChordSymbol != null) { returnMetrics = new ChordMetrics(graphics, cautionaryChordSymbol, voiceStemDirection, gap, strokeWidth); } else if (chord != null) { returnMetrics = new ChordMetrics(graphics, chord, voiceStemDirection, gap, strokeWidth); } else if (rest != null) { // All rests are originally created on the centre line. // They are moved vertically later, if they are on a 2-Voice staff. returnMetrics = new RestMetrics(graphics, rest, gap, noteObject.Voice.Staff.NumberOfStafflines, strokeWidth); } return(returnMetrics); }
public override Metrics NoteObjectMetrics(Graphics graphics, NoteObject noteObject, VerticalDir voiceStemDirection, float gap, float strokeWidth) { Metrics returnMetrics = null; ClefSymbol clef = noteObject as ClefSymbol; Barline barline = noteObject as Barline; CautionaryOutputChordSymbol cautionaryOutputChordSymbol = noteObject as CautionaryOutputChordSymbol; CautionaryInputChordSymbol cautionaryInputChordSymbol = noteObject as CautionaryInputChordSymbol; ChordSymbol chord = noteObject as ChordSymbol; RestSymbol rest = noteObject as RestSymbol; if(barline != null) { returnMetrics = new BarlineMetrics(graphics, barline, gap); } else if(clef != null) { if(clef.ClefType != "n") returnMetrics = new ClefMetrics(clef, gap); } else if(cautionaryOutputChordSymbol != null) { returnMetrics = new ChordMetrics(graphics, cautionaryOutputChordSymbol, voiceStemDirection, gap, strokeWidth); } else if(cautionaryInputChordSymbol != null) { returnMetrics = new ChordMetrics(graphics, cautionaryInputChordSymbol, voiceStemDirection, gap, strokeWidth); } else if(chord != null) { returnMetrics = new ChordMetrics(graphics, chord, voiceStemDirection, gap, strokeWidth); } else if(rest != null) { // All rests are originally created on the centre line. // They are moved vertically later, if they are on a 2-Voice staff. returnMetrics = new RestMetrics(graphics, rest, gap, noteObject.Voice.Staff.NumberOfStafflines, strokeWidth); } return returnMetrics; }
/// <summary> /// Writes out an SVG Voice /// The following NoteObject types are only written if voiceIndex == 0: /// Barline, Clef, SmallClef, KeySignature, TimeSignature. /// </summary> /// <param name="w"></param> public virtual void WriteSVG(SvgWriter w, int voiceIndex, List <CarryMsgs> carryMsgsPerChannel, bool graphicsOnly) { bool suppressEndOfScoreBarline = false; for (int i = 0; i < NoteObjects.Count; ++i) { NoteObject noteObject = NoteObjects[i]; if (noteObject is Barline barline && voiceIndex == 0) { bool isLastNoteObject = (i == (NoteObjects.Count - 1)); double top = Staff.Metrics.StafflinesTop; double bottom = Staff.Metrics.StafflinesBottom; if (barline.IsVisible && !suppressEndOfScoreBarline) { barline.WriteSVG(w, top, bottom, isLastNoteObject, true); } barline.WriteDrawObjectsSVG(w); } if (noteObject is CautionaryChordSymbol cautionaryChordSymbol) { cautionaryChordSymbol.WriteSVG(w); } if (noteObject is OutputChordSymbol outputChordSymbol) { M.Assert(carryMsgsPerChannel != null); outputChordSymbol.WriteSVG(w, this.MidiChannel, carryMsgsPerChannel[this.MidiChannel], graphicsOnly); } if (noteObject is OutputRestSymbol outputRestSymbol) { M.Assert(carryMsgsPerChannel != null); outputRestSymbol.WriteSVG(w, this.MidiChannel, carryMsgsPerChannel[this.MidiChannel], graphicsOnly); } if (noteObject is Clef clef && voiceIndex == 0) { if (clef.Metrics != null) { // if this is the first barline, the staff name and (maybe) barnumber will be written. ClefMetrics cm = clef.Metrics as ClefMetrics; clef.WriteSVG(w, cm.ClefID, cm.OriginX, cm.OriginY); } } if (noteObject is SmallClef smallClef && voiceIndex == 0) { if (smallClef.Metrics != null) { SmallClefMetrics scm = smallClef.Metrics as SmallClefMetrics; smallClef.WriteSVG(w, scm.ClefID, scm.OriginX, scm.OriginY); } } if (noteObject is KeySignature keySignature && voiceIndex == 0) { keySignature.WriteSVG(w, keySignature.Fifths.ToString(), keySignature.Metrics.OriginX, keySignature.Metrics.OriginY); } if (noteObject is TimeSignature timeSignature && voiceIndex == 0) { timeSignature.WriteSVG(w, timeSignature.Signature, timeSignature.Metrics.OriginX, timeSignature.Metrics.OriginY); } if (noteObject is RepeatSymbol repeatSymbol && voiceIndex == 0) { bool isLastNoteObject = (i == (NoteObjects.Count - 1)); double top = Staff.Metrics.StafflinesTop; double bottom = Staff.Metrics.StafflinesBottom; repeatSymbol.WriteSVG(w, top, bottom, isLastNoteObject, true); suppressEndOfScoreBarline = (i == (NoteObjects.Count - 2)); } } }