Example #1
0
        /// <summary>
        /// Creates one System per bar (=list of VoiceDefs) in the argument.
        /// The Systems are complete with staves and voices of the correct type:
        /// Each InputStaff is allocated parallel (empty) InputVoice fields.
        /// Each OutputStaff is allocated parallel (empty) OutputVoice fields.
        /// Each Voice has a VoiceDef field that is allocated to the corresponding
        /// VoiceDef from the argument.
        /// The OutputVoices are arranged according to _pageFormat.OutputVoiceIndicesPerStaff.
        /// The InputVoices are arranged according to _pageFormat.InputVoiceIndicesPerStaff.
        /// OutputVoices are given a midi channel allocated from top to bottom in the printed score.
        /// </summary>
        public void CreateEmptySystems(List<List<VoiceDef>> barDefsInOneSystem, int numberOfVisibleInputStaves)
        {
            foreach(List<VoiceDef> barVoiceDefs in barDefsInOneSystem)
            {
                SvgSystem system = new SvgSystem(this);
                this.Systems.Add(system);
            }

            CreateEmptyOutputStaves(barDefsInOneSystem, numberOfVisibleInputStaves);
            CreateEmptyInputStaves(barDefsInOneSystem);
        }
Example #2
0
        private void AddExtendersAtTheEndsOfStaves(List<Staff> staves, float rightMarginPos, float gap, float extenderStrokeWidth,
            float hairlinePadding, SvgSystem nextSystem)
        {
            for(int staffIndex = 0; staffIndex < staves.Count; ++staffIndex)
            {
                Staff staff = staves[staffIndex];
                if(!(staff is HiddenOutputStaff))
                {
                    for(int voiceIndex = 0; voiceIndex < staff.Voices.Count; ++voiceIndex)
                    {
                        Voice voice = staff.Voices[voiceIndex];
                        List<NoteObject> noteObjects = voice.NoteObjects;
                        ChordSymbol lastChord = null;
                        RestSymbol lastRest = null;
                        CautionaryOutputChordSymbol cautionaryOutputChordsymbol = null;
                        CautionaryInputChordSymbol cautionaryInputChordsymbol = null;
                        for(int index = noteObjects.Count - 1; index >= 0; --index)
                        {
                            lastChord = noteObjects[index] as ChordSymbol;
                            lastRest = noteObjects[index] as RestSymbol;
                            cautionaryOutputChordsymbol = noteObjects[index] as CautionaryOutputChordSymbol;
                            cautionaryInputChordsymbol = noteObjects[index] as CautionaryInputChordSymbol;
                            if(cautionaryOutputChordsymbol != null)
                            {
                                cautionaryOutputChordsymbol.Visible = false;
                                // a CautionaryChordSymbol is a ChordSymbol, but we have not found a real one yet.
                            }
                            else if(cautionaryInputChordsymbol != null)
                            {
                                cautionaryInputChordsymbol.Visible = false;
                                // a CautionaryChordSymbol is a ChordSymbol, but we have not found a real one yet.
                            }
                            else if(lastChord != null || lastRest != null)
                                break;
                        }

                        if(lastChord != null && lastChord.MsDurationToNextBarline != null)
                        {
                            List<float> x1s = GetX1sFromChord1(lastChord.ChordMetrics, hairlinePadding);
                            List<float> x2s;
                            List<float> ys = lastChord.ChordMetrics.HeadsOriginYs;
                            if(nextSystem != null && FirstDurationSymbolOnNextSystemIsCautionary(nextSystem.Staves[staffIndex].Voices[voiceIndex]))
                            {
                                x2s = GetEqualFloats(rightMarginPos + gap, x1s.Count);
                            }
                            else
                            {
                                x2s = GetEqualFloats(rightMarginPos, x1s.Count);
                            }
                            lastChord.ChordMetrics.NoteheadExtendersMetrics =
                                CreateExtenders(x1s, x2s, ys, lastChord.ChordMetrics.HeadsMetrics, extenderStrokeWidth, gap, true);
                        }
                    }
                }
            }
        }
Example #3
0
 /// <summary>
 /// Feb. 2012: Currently only the StandardSymbolSet supports notehead extender lines. 
 /// </summary>
 public virtual void AddNoteheadExtenderLines(List<Staff> staves,
     float rightMarginPos, float gap, float extenderStrokeWidth, float hairlinePadding, SvgSystem nextSystem)
 {
 }
Example #4
0
 private void GetNumbersOfVoices(SvgSystem svgSystem, ref int nOutputVoices, ref int nInputVoices)
 {
     nOutputVoices = 0;
     nInputVoices = 0;
     foreach(Staff staff in svgSystem.Staves)
     {
         foreach(Voice voice in staff.Voices)
         {
             if(voice is OutputVoice)
             {
                 nOutputVoices++;
             }
             else if(voice is InputVoice)
             {
                 nInputVoices++;
             }
         }
     }
 }
Example #5
0
 public override void AddNoteheadExtenderLines(List<Staff> staves, float rightMarginPos, float gap, float extenderStrokeWidth, float hairlinePadding, SvgSystem nextSystem)
 {
     AddExtendersAtTheBeginningsofStaves(staves, rightMarginPos, gap, extenderStrokeWidth, hairlinePadding);
     AddExtendersInStaves(staves, extenderStrokeWidth, gap, hairlinePadding);
     AddExtendersAtTheEndsOfStaves(staves, rightMarginPos, gap, extenderStrokeWidth, hairlinePadding, nextSystem);
 }
Example #6
0
 /// <summary>
 /// The current msPosition of a voice will be retrievable as currentMsPositionPerVoicePerStaff[staffIndex][voiceIndex].
 /// </summary>
 /// <param name="system"></param>
 /// <returns></returns>
 private List<List<int>> InitializeCurrentMsPositionPerVoicePerStaff(SvgSystem system)
 {
     List<List<int>> currentMsPositionPerVoicePerStaff = new List<List<int>>();
     foreach(Staff staff in system.Staves)
     {
         List<int> currentVoiceMsPositions = new List<int>();
         currentMsPositionPerVoicePerStaff.Add(currentVoiceMsPositions);
         foreach(Voice voice in staff.Voices)
         {
             currentVoiceMsPositions.Add(0);
         }
     }
     return currentMsPositionPerVoicePerStaff;
 }
Example #7
0
        private float GetLeftMarginPos(SvgSystem system, Graphics graphics, PageFormat pageFormat)
        {
            float leftMarginPos = pageFormat.LeftMarginPos;
            float maxNameWidth = 0;
            foreach(Staff staff in system.Staves)
            {
                foreach(NoteObject noteObject in staff.Voices[0].NoteObjects)
                {
                    Barline firstBarline = noteObject as Barline;
                    if(firstBarline != null)
                    {
                        foreach(DrawObject drawObject in firstBarline.DrawObjects)
                        {
                            StaffNameText staffName = drawObject as StaffNameText;
                            if(staffName != null)
                            {
                                Debug.Assert(staffName.TextInfo != null);

                                TextMetrics staffNameMetrics = new TextMetrics(graphics, null, staffName.TextInfo);
                                float nameWidth = staffNameMetrics.Right - staffNameMetrics.Left;
                                maxNameWidth = (maxNameWidth > nameWidth) ? maxNameWidth : nameWidth;
                            }
                        }
                        break;
                    }
                }
            }
            leftMarginPos = maxNameWidth + (pageFormat.Gap * 2.0F);
            leftMarginPos = (leftMarginPos > pageFormat.LeftMarginPos) ? leftMarginPos : pageFormat.LeftMarginPos;

            return leftMarginPos;
        }
Example #8
0
 public OutputStaff(SvgSystem svgSystem, string staffName, int numberOfStafflines, float gap, float stafflineStemStrokeWidth)
     : base(svgSystem, staffName, numberOfStafflines, gap, stafflineStemStrokeWidth)
 {
 }
Example #9
0
 // These default values will never be used.
 public HiddenOutputStaff(SvgSystem svgSystem)
     : base(svgSystem, "", 1, 1, 1)
 {
 }
Example #10
0
 // These default values will never be used.
 public InvisibleOutputStaff(SvgSystem svgSystem)
     : base(svgSystem, "", 1, 1, 1)
 {
 }