Browse Source

fixed errors of tests
fixed little bug at the extra instruction measure.

Matthias Uiberacker 7 years ago
parent
commit
da0ba9d403

+ 5 - 3
src/MusicalScore/Graphical/MusicSheetCalculator.ts

@@ -1541,11 +1541,13 @@ export abstract class MusicSheetCalculator {
         // if there are no staffEntries in this measure, create a rest for the whole measure:
         if (measure.staffEntries.length === 0) {
             const sourceStaffEntry: SourceStaffEntry = new SourceStaffEntry(undefined, staff);
-            const note: Note = new Note(undefined, sourceStaffEntry, Fraction.createFromFraction(sourceMeasure.Duration), undefined);
+            const voiceEntry: VoiceEntry = new VoiceEntry(new Fraction(0, 1), staff.Voices[0], sourceStaffEntry);
+            const note: Note = new Note(voiceEntry, sourceStaffEntry, Fraction.createFromFraction(sourceMeasure.Duration), undefined);
+            voiceEntry.Notes.push(note);
             const graphicalStaffEntry: GraphicalStaffEntry = this.symbolFactory.createStaffEntry(sourceStaffEntry, measure);
             measure.addGraphicalStaffEntry(graphicalStaffEntry);
-            graphicalStaffEntry.relInMeasureTimestamp = new Fraction(0, 1);
-            const gve: GraphicalVoiceEntry = new GraphicalVoiceEntry(undefined, graphicalStaffEntry);
+            graphicalStaffEntry.relInMeasureTimestamp = voiceEntry.Timestamp;
+            const gve: GraphicalVoiceEntry = new GraphicalVoiceEntry(voiceEntry, graphicalStaffEntry);
             graphicalStaffEntry.graphicalVoiceEntries.push(gve);
             const graphicalNote: GraphicalNote = this.symbolFactory.createNote( note,
                                                                                 gve,

+ 0 - 1
src/MusicalScore/Graphical/MusicSystemBuilder.ts

@@ -627,7 +627,6 @@ export class MusicSystemBuilder {
         const width: number = this.rules.MeasureLeftMargin + measure.beginInstructionsWidth + this.rules.MeasureRightMargin;
         measure.PositionAndShape.BorderRight = width;
         currentSystem.StaffLines[visStaffIdx].Measures.push(measure);
-        measure.ParentStaffLine = currentSystem.StaffLines[visStaffIdx];
         return width;
     }
 

+ 13 - 10
src/MusicalScore/Graphical/VexFlow/VexFlowConverter.ts

@@ -177,16 +177,19 @@ export class VexFlowConverter {
             duration: duration,
             keys: keys,
         });
-        const wantedStemDirection: StemDirectionType = notes[0].sourceNote.ParentVoiceEntry.StemDirection;
-        switch (wantedStemDirection) {
-            case(StemDirectionType.Up):
-                vfnote.setStemDirection(Vex.Flow.Stem.UP);
-                break;
-            case (StemDirectionType.Down):
-                vfnote.setStemDirection(Vex.Flow.Stem.DOWN);
-                break;
-            default:
-                break;
+
+        if (notes[0].sourceNote.ParentVoiceEntry !== undefined) {
+            const wantedStemDirection: StemDirectionType = notes[0].sourceNote.ParentVoiceEntry.StemDirection;
+            switch (wantedStemDirection) {
+                case(StemDirectionType.Up):
+                    vfnote.setStemDirection(Vex.Flow.Stem.UP);
+                    break;
+                case (StemDirectionType.Down):
+                    vfnote.setStemDirection(Vex.Flow.Stem.DOWN);
+                    break;
+                default:
+                    break;
+            }
         }
 
         for (let i: number = 0, len: number = notes.length; i < len; i += 1) {

+ 0 - 3
src/MusicalScore/Graphical/VexFlow/VexFlowStaffEntry.ts

@@ -2,15 +2,12 @@ import {GraphicalStaffEntry} from "../GraphicalStaffEntry";
 import {VexFlowMeasure} from "./VexFlowMeasure";
 import {SourceStaffEntry} from "../../VoiceData/SourceStaffEntry";
 import {unitInPixels} from "./VexFlowMusicSheetDrawer";
-import { GraphicalVoiceEntry } from "../GraphicalVoiceEntry";
 
 export class VexFlowStaffEntry extends GraphicalStaffEntry {
     constructor(measure: VexFlowMeasure, sourceStaffEntry: SourceStaffEntry, staffEntryParent: VexFlowStaffEntry) {
         super(measure, sourceStaffEntry, staffEntryParent);
     }
 
-    // The Graphical Notes belonging to this StaffEntry, sorted by voiceID
-    public psVoiceEntries: { [voiceID: number]: GraphicalVoiceEntry; } = {};
     // The corresponding VexFlow.StaveNotes
     public vfNotes: { [voiceID: number]: Vex.Flow.StaveNote; } = {};