소스 검색

comments

some comments for future rest placement and collision checking
Simon Schmid 5 년 전
부모
커밋
6caf2541d8
2개의 변경된 파일5개의 추가작업 그리고 1개의 파일을 삭제
  1. 4 1
      src/MusicalScore/Graphical/MusicSheetCalculator.ts
  2. 1 0
      src/MusicalScore/Graphical/VexFlow/VexFlowConverter.ts

+ 4 - 1
src/MusicalScore/Graphical/MusicSheetCalculator.ts

@@ -2275,18 +2275,21 @@ export abstract class MusicSheetCalculator {
     private calculateRestNotePlacementWithCollisionDetectionFromGraphicalNote(graphicalStaffEntry: GraphicalStaffEntry): void {
         let restNote: GraphicalNote;
         let graphicalNotes: GraphicalNote[];
-        if (graphicalStaffEntry.graphicalVoiceEntries[0].notes[0].sourceNote.Pitch === undefined) {
+        if (graphicalStaffEntry.graphicalVoiceEntries[0].notes[0].sourceNote.isRest()) {
             restNote = graphicalStaffEntry.graphicalVoiceEntries[0].notes[0];
             graphicalNotes = graphicalStaffEntry.graphicalVoiceEntries[1].notes;
         } else {
             graphicalNotes = graphicalStaffEntry.graphicalVoiceEntries[0].notes;
             restNote = graphicalStaffEntry.graphicalVoiceEntries[1].notes[0];
         }
+        //restNote.parallelVoiceEntryNotes = graphicalNotes; // TODO maybe save potentially colliding notes, check them in VexFlowConverter.StaveNote
         let collision: boolean = false;
         graphicalStaffEntry.PositionAndShape.calculateAbsolutePositionsRecursiveWithoutTopelement();
         for (let idx: number = 0, len: number = graphicalNotes.length; idx < len; ++idx) {
             const graphicalNote: GraphicalNote = graphicalNotes[idx];
             if (restNote.PositionAndShape.marginCollisionDetection(graphicalNote.PositionAndShape)) {
+                // TODO bounding box of graphical note isn't set correctly yet.
+                // we could do manual collision checking here
                 collision = true;
                 break;
             }

+ 1 - 0
src/MusicalScore/Graphical/VexFlow/VexFlowConverter.ts

@@ -191,6 +191,7 @@ export class VexFlowConverter {
             if (note.sourceNote.isRest()) {
                 isRest = true;
                 keys = ["b/4"];
+                // TODO do collision checking, place rest e.g. either below staff (A3, for stem direction below voice) or above (C5)
                 // if it is a full measure rest:
                 if (note.parentVoiceEntry.parentStaffEntry.parentMeasure.parentSourceMeasure.Duration.RealValue <= frac.RealValue) {
                     keys = ["d/5"];