|
@@ -9,7 +9,7 @@ import {GraphicalLine} from "./GraphicalLine";
|
|
import {MusicSystem} from "./MusicSystem";
|
|
import {MusicSystem} from "./MusicSystem";
|
|
import {GraphicalStaffEntry} from "./GraphicalStaffEntry";
|
|
import {GraphicalStaffEntry} from "./GraphicalStaffEntry";
|
|
import {SourceStaffEntry} from "../VoiceData/SourceStaffEntry";
|
|
import {SourceStaffEntry} from "../VoiceData/SourceStaffEntry";
|
|
-import {PointF_2D} from "../../Common/DataObjects/PointF_2D";
|
|
|
|
|
|
+import {PointF2D} from "../../Common/DataObjects/PointF2D";
|
|
import {ClefInstruction} from "../VoiceData/Instructions/ClefInstruction";
|
|
import {ClefInstruction} from "../VoiceData/Instructions/ClefInstruction";
|
|
import {AbstractNotationInstruction} from "../VoiceData/Instructions/AbstractNotationInstruction";
|
|
import {AbstractNotationInstruction} from "../VoiceData/Instructions/AbstractNotationInstruction";
|
|
import {KeyInstruction} from "../VoiceData/Instructions/KeyInstruction";
|
|
import {KeyInstruction} from "../VoiceData/Instructions/KeyInstruction";
|
|
@@ -20,6 +20,8 @@ import {BoundingBox} from "./BoundingBox";
|
|
import {VoiceEntry} from "../VoiceData/VoiceEntry";
|
|
import {VoiceEntry} from "../VoiceData/VoiceEntry";
|
|
import {Note} from "../VoiceData/Note";
|
|
import {Note} from "../VoiceData/Note";
|
|
import {MusicSheetCalculator} from "./MusicSheetCalculator";
|
|
import {MusicSheetCalculator} from "./MusicSheetCalculator";
|
|
|
|
+import {Logging} from "../../Common/logging";
|
|
|
|
+
|
|
export class GraphicalMusicSheet {
|
|
export class GraphicalMusicSheet {
|
|
constructor(musicSheet: MusicSheet, calculator: MusicSheetCalculator) {
|
|
constructor(musicSheet: MusicSheet, calculator: MusicSheetCalculator) {
|
|
this.musicSheet = musicSheet;
|
|
this.musicSheet = musicSheet;
|
|
@@ -28,8 +30,9 @@ export class GraphicalMusicSheet {
|
|
this.SourceToGraphicalMeasureLinks = new Dictionary<SourceMeasure, StaffMeasure[]>();
|
|
this.SourceToGraphicalMeasureLinks = new Dictionary<SourceMeasure, StaffMeasure[]>();
|
|
this.calculator.initialize(this);
|
|
this.calculator.initialize(this);
|
|
}
|
|
}
|
|
|
|
+
|
|
private musicSheet: MusicSheet;
|
|
private musicSheet: MusicSheet;
|
|
- private fontInfo: FontInfo = this.FontInfo.Info;
|
|
|
|
|
|
+ private fontInfo: FontInfo = FontInfo.Info;
|
|
private calculator: MusicSheetCalculator;
|
|
private calculator: MusicSheetCalculator;
|
|
private musicPages: GraphicalMusicPage[] = [];
|
|
private musicPages: GraphicalMusicPage[] = [];
|
|
private measureList: StaffMeasure[][] = [];
|
|
private measureList: StaffMeasure[][] = [];
|
|
@@ -43,97 +46,127 @@ export class GraphicalMusicSheet {
|
|
private systemImages: Dictionary<MusicSystem, SystemImageProperties> = new Dictionary<MusicSystem, SystemImageProperties>();
|
|
private systemImages: Dictionary<MusicSystem, SystemImageProperties> = new Dictionary<MusicSystem, SystemImageProperties>();
|
|
private numberOfStaves: number;
|
|
private numberOfStaves: number;
|
|
private leadSheet: boolean = false;
|
|
private leadSheet: boolean = false;
|
|
|
|
+
|
|
public get ParentMusicSheet(): MusicSheet {
|
|
public get ParentMusicSheet(): MusicSheet {
|
|
return this.musicSheet;
|
|
return this.musicSheet;
|
|
}
|
|
}
|
|
|
|
+
|
|
public get GetCalculator(): MusicSheetCalculator {
|
|
public get GetCalculator(): MusicSheetCalculator {
|
|
return this.calculator;
|
|
return this.calculator;
|
|
}
|
|
}
|
|
|
|
+
|
|
public get MusicPages(): GraphicalMusicPage[] {
|
|
public get MusicPages(): GraphicalMusicPage[] {
|
|
return this.musicPages;
|
|
return this.musicPages;
|
|
}
|
|
}
|
|
|
|
+
|
|
public set MusicPages(value: GraphicalMusicPage[]) {
|
|
public set MusicPages(value: GraphicalMusicPage[]) {
|
|
this.musicPages = value;
|
|
this.musicPages = value;
|
|
}
|
|
}
|
|
|
|
+
|
|
public get FontInfo(): FontInfo {
|
|
public get FontInfo(): FontInfo {
|
|
return this.fontInfo;
|
|
return this.fontInfo;
|
|
}
|
|
}
|
|
|
|
+
|
|
public get MeasureList(): StaffMeasure[][] {
|
|
public get MeasureList(): StaffMeasure[][] {
|
|
return this.measureList;
|
|
return this.measureList;
|
|
}
|
|
}
|
|
|
|
+
|
|
public set MeasureList(value: StaffMeasure[][]) {
|
|
public set MeasureList(value: StaffMeasure[][]) {
|
|
this.measureList = value;
|
|
this.measureList = value;
|
|
}
|
|
}
|
|
|
|
+
|
|
public get VerticalGraphicalStaffEntryContainers(): VerticalGraphicalStaffEntryContainer[] {
|
|
public get VerticalGraphicalStaffEntryContainers(): VerticalGraphicalStaffEntryContainer[] {
|
|
return this.verticalGraphicalStaffEntryContainers;
|
|
return this.verticalGraphicalStaffEntryContainers;
|
|
}
|
|
}
|
|
|
|
+
|
|
public set VerticalGraphicalStaffEntryContainers(value: VerticalGraphicalStaffEntryContainer[]) {
|
|
public set VerticalGraphicalStaffEntryContainers(value: VerticalGraphicalStaffEntryContainer[]) {
|
|
this.verticalGraphicalStaffEntryContainers = value;
|
|
this.verticalGraphicalStaffEntryContainers = value;
|
|
}
|
|
}
|
|
|
|
+
|
|
public get Title(): GraphicalLabel {
|
|
public get Title(): GraphicalLabel {
|
|
return this.title;
|
|
return this.title;
|
|
}
|
|
}
|
|
|
|
+
|
|
public set Title(value: GraphicalLabel) {
|
|
public set Title(value: GraphicalLabel) {
|
|
this.title = value;
|
|
this.title = value;
|
|
}
|
|
}
|
|
|
|
+
|
|
public get Subtitle(): GraphicalLabel {
|
|
public get Subtitle(): GraphicalLabel {
|
|
return this.subtitle;
|
|
return this.subtitle;
|
|
}
|
|
}
|
|
|
|
+
|
|
public set Subtitle(value: GraphicalLabel) {
|
|
public set Subtitle(value: GraphicalLabel) {
|
|
this.subtitle = value;
|
|
this.subtitle = value;
|
|
}
|
|
}
|
|
|
|
+
|
|
public get Composer(): GraphicalLabel {
|
|
public get Composer(): GraphicalLabel {
|
|
return this.composer;
|
|
return this.composer;
|
|
}
|
|
}
|
|
|
|
+
|
|
public set Composer(value: GraphicalLabel) {
|
|
public set Composer(value: GraphicalLabel) {
|
|
this.composer = value;
|
|
this.composer = value;
|
|
}
|
|
}
|
|
|
|
+
|
|
public get Lyricist(): GraphicalLabel {
|
|
public get Lyricist(): GraphicalLabel {
|
|
return this.lyricist;
|
|
return this.lyricist;
|
|
}
|
|
}
|
|
|
|
+
|
|
public set Lyricist(value: GraphicalLabel) {
|
|
public set Lyricist(value: GraphicalLabel) {
|
|
this.lyricist = value;
|
|
this.lyricist = value;
|
|
}
|
|
}
|
|
|
|
+
|
|
public get ScoreFollowingLines(): GraphicalLine[] {
|
|
public get ScoreFollowingLines(): GraphicalLine[] {
|
|
return this.scoreFollowingLines;
|
|
return this.scoreFollowingLines;
|
|
}
|
|
}
|
|
|
|
+
|
|
public get MaxAllowedSystemWidth(): number {
|
|
public get MaxAllowedSystemWidth(): number {
|
|
return this.maxAllowedSystemWidth;
|
|
return this.maxAllowedSystemWidth;
|
|
}
|
|
}
|
|
|
|
+
|
|
public set MaxAllowedSystemWidth(value: number) {
|
|
public set MaxAllowedSystemWidth(value: number) {
|
|
this.maxAllowedSystemWidth = value;
|
|
this.maxAllowedSystemWidth = value;
|
|
}
|
|
}
|
|
|
|
+
|
|
public get SystemImages(): Dictionary<MusicSystem, SystemImageProperties> {
|
|
public get SystemImages(): Dictionary<MusicSystem, SystemImageProperties> {
|
|
return this.systemImages;
|
|
return this.systemImages;
|
|
}
|
|
}
|
|
- public SourceToGraphicalMeasureLinks: Dictionary<SourceMeasure, StaffMeasure[]>;
|
|
|
|
|
|
+
|
|
|
|
+ //public SourceToGraphicalMeasureLinks: Dictionary<SourceMeasure, StaffMeasure[]>;
|
|
|
|
+
|
|
public get NumberOfStaves(): number {
|
|
public get NumberOfStaves(): number {
|
|
return this.numberOfStaves;
|
|
return this.numberOfStaves;
|
|
}
|
|
}
|
|
|
|
+
|
|
public get LeadSheet(): boolean {
|
|
public get LeadSheet(): boolean {
|
|
return this.leadSheet;
|
|
return this.leadSheet;
|
|
}
|
|
}
|
|
|
|
+
|
|
public set LeadSheet(value: boolean) {
|
|
public set LeadSheet(value: boolean) {
|
|
this.leadSheet = value;
|
|
this.leadSheet = value;
|
|
}
|
|
}
|
|
|
|
+
|
|
public static transformRelativeToAbsolutePosition(graphicalMusicSheet: GraphicalMusicSheet): void {
|
|
public static transformRelativeToAbsolutePosition(graphicalMusicSheet: GraphicalMusicSheet): void {
|
|
for (let i: number = 0; i < graphicalMusicSheet.MusicPages.length; i++) {
|
|
for (let i: number = 0; i < graphicalMusicSheet.MusicPages.length; i++) {
|
|
- let pageAbsolute: PointF_2D = graphicalMusicSheet.MusicPages[i].setMusicPageAbsolutePosition(i, graphicalMusicSheet.ParentMusicSheet.Rules);
|
|
|
|
|
|
+ let pageAbsolute: PointF2D = graphicalMusicSheet.MusicPages[i].setMusicPageAbsolutePosition(i, graphicalMusicSheet.ParentMusicSheet.rules);
|
|
let page: GraphicalMusicPage = graphicalMusicSheet.MusicPages[i];
|
|
let page: GraphicalMusicPage = graphicalMusicSheet.MusicPages[i];
|
|
- page.PositionAndShape.calculateAbsolutePositionsRecursive(pageAbsolute.X, pageAbsolute.Y);
|
|
|
|
|
|
+ page.PositionAndShape.calculateAbsolutePositionsRecursive(pageAbsolute.x, pageAbsolute.y);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
public Initialize(): void {
|
|
public Initialize(): void {
|
|
this.verticalGraphicalStaffEntryContainers = [];
|
|
this.verticalGraphicalStaffEntryContainers = [];
|
|
this.musicPages = [];
|
|
this.musicPages = [];
|
|
this.measureList = [];
|
|
this.measureList = [];
|
|
}
|
|
}
|
|
|
|
+
|
|
public reCalculate(): void {
|
|
public reCalculate(): void {
|
|
this.calculator.calculate();
|
|
this.calculator.calculate();
|
|
}
|
|
}
|
|
|
|
+
|
|
public prepare(): void {
|
|
public prepare(): void {
|
|
this.calculator.prepareGraphicalMusicSheet();
|
|
this.calculator.prepareGraphicalMusicSheet();
|
|
}
|
|
}
|
|
|
|
+
|
|
public EnforceRedrawOfMusicSystems(): void {
|
|
public EnforceRedrawOfMusicSystems(): void {
|
|
for (let idx: number = 0, len: number = this.musicPages.length; idx < len; ++idx) {
|
|
for (let idx: number = 0, len: number = this.musicPages.length; idx < len; ++idx) {
|
|
let graphicalMusicPage: GraphicalMusicPage = this.musicPages[idx];
|
|
let graphicalMusicPage: GraphicalMusicPage = this.musicPages[idx];
|
|
@@ -143,62 +176,70 @@ export class GraphicalMusicSheet {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- public getClickedObject<T>(positionOnMusicSheet: PointF_2D): T {
|
|
|
|
|
|
+
|
|
|
|
+ public getClickedObject<T>(positionOnMusicSheet: PointF2D): T {
|
|
for (let idx: number = 0, len: number = this.MusicPages.length; idx < len; ++idx) {
|
|
for (let idx: number = 0, len: number = this.MusicPages.length; idx < len; ++idx) {
|
|
let graphicalMusicPage: GraphicalMusicPage = this.MusicPages[idx];
|
|
let graphicalMusicPage: GraphicalMusicPage = this.MusicPages[idx];
|
|
return graphicalMusicPage.PositionAndShape.getClickedObjectOfType<T>(positionOnMusicSheet);
|
|
return graphicalMusicPage.PositionAndShape.getClickedObjectOfType<T>(positionOnMusicSheet);
|
|
}
|
|
}
|
|
return undefined;
|
|
return undefined;
|
|
}
|
|
}
|
|
- public findGraphicalStaffEntryFromMeasureList(staffIndex: number, measureIndex: number,
|
|
|
|
- sourceStaffEntry: SourceStaffEntry): GraphicalStaffEntry {
|
|
|
|
|
|
+
|
|
|
|
+ public findGraphicalStaffEntryFromMeasureList(staffIndex: number, measureIndex: number, sourceStaffEntry: SourceStaffEntry): GraphicalStaffEntry {
|
|
for (let i: number = measureIndex; i < this.measureList.length; i++) {
|
|
for (let i: number = measureIndex; i < this.measureList.length; i++) {
|
|
let graphicalMeasure: StaffMeasure = this.measureList[i][staffIndex];
|
|
let graphicalMeasure: StaffMeasure = this.measureList[i][staffIndex];
|
|
for (let idx: number = 0, len: number = graphicalMeasure.StaffEntries.length; idx < len; ++idx) {
|
|
for (let idx: number = 0, len: number = graphicalMeasure.StaffEntries.length; idx < len; ++idx) {
|
|
let graphicalStaffEntry: GraphicalStaffEntry = graphicalMeasure.StaffEntries[idx];
|
|
let graphicalStaffEntry: GraphicalStaffEntry = graphicalMeasure.StaffEntries[idx];
|
|
- if (graphicalStaffEntry.SourceStaffEntry === sourceStaffEntry)
|
|
|
|
|
|
+ if (graphicalStaffEntry.SourceStaffEntry === sourceStaffEntry) {
|
|
return graphicalStaffEntry;
|
|
return graphicalStaffEntry;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return undefined;
|
|
return undefined;
|
|
}
|
|
}
|
|
- public findNextGraphicalStaffEntry(staffIndex: number, measureIndex: number,
|
|
|
|
- graphicalStaffEntry: GraphicalStaffEntry): GraphicalStaffEntry {
|
|
|
|
|
|
+
|
|
|
|
+ public findNextGraphicalStaffEntry(staffIndex: number, measureIndex: number, graphicalStaffEntry: GraphicalStaffEntry): GraphicalStaffEntry {
|
|
let graphicalMeasure: StaffMeasure = graphicalStaffEntry.ParentMeasure;
|
|
let graphicalMeasure: StaffMeasure = graphicalStaffEntry.ParentMeasure;
|
|
let graphicalStaffEntryIndex: number = graphicalMeasure.StaffEntries.indexOf(graphicalStaffEntry);
|
|
let graphicalStaffEntryIndex: number = graphicalMeasure.StaffEntries.indexOf(graphicalStaffEntry);
|
|
if (graphicalStaffEntryIndex < graphicalMeasure.StaffEntries.length - 1) {
|
|
if (graphicalStaffEntryIndex < graphicalMeasure.StaffEntries.length - 1) {
|
|
return graphicalMeasure.StaffEntries[graphicalStaffEntryIndex + 1];
|
|
return graphicalMeasure.StaffEntries[graphicalStaffEntryIndex + 1];
|
|
} else if (measureIndex < this.measureList.length - 1) {
|
|
} else if (measureIndex < this.measureList.length - 1) {
|
|
let nextMeasure: StaffMeasure = this.measureList[measureIndex + 1][staffIndex];
|
|
let nextMeasure: StaffMeasure = this.measureList[measureIndex + 1][staffIndex];
|
|
- if (nextMeasure.StaffEntries.length > 0)
|
|
|
|
|
|
+ if (nextMeasure.StaffEntries.length > 0) {
|
|
return nextMeasure.StaffEntries[0];
|
|
return nextMeasure.StaffEntries[0];
|
|
|
|
+ }
|
|
}
|
|
}
|
|
return undefined;
|
|
return undefined;
|
|
}
|
|
}
|
|
|
|
+
|
|
public getFirstVisibleMeasuresListFromIndeces(start: number, end: number): StaffMeasure[] {
|
|
public getFirstVisibleMeasuresListFromIndeces(start: number, end: number): StaffMeasure[] {
|
|
let graphicalMeasures: StaffMeasure[] = [];
|
|
let graphicalMeasures: StaffMeasure[] = [];
|
|
let numberOfStaves: number = this.measureList[0].length;
|
|
let numberOfStaves: number = this.measureList[0].length;
|
|
- for (let i: number = start; i <= end; i++)
|
|
|
|
- for (let j: number = 0; j < numberOfStaves; j++)
|
|
|
|
|
|
+ for (let i: number = start; i <= end; i++) {
|
|
|
|
+ for (let j: number = 0; j < numberOfStaves; j++) {
|
|
if (this.measureList[i][j].isVisible()) {
|
|
if (this.measureList[i][j].isVisible()) {
|
|
graphicalMeasures.push(this.measureList[i][j]);
|
|
graphicalMeasures.push(this.measureList[i][j]);
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
|
|
+ }
|
|
|
|
+ }
|
|
return graphicalMeasures;
|
|
return graphicalMeasures;
|
|
}
|
|
}
|
|
|
|
+
|
|
public orderMeasuresByStaffLine(measures: StaffMeasure[]): StaffMeasure[][] {
|
|
public orderMeasuresByStaffLine(measures: StaffMeasure[]): StaffMeasure[][] {
|
|
let orderedMeasures: StaffMeasure[][] = [];
|
|
let orderedMeasures: StaffMeasure[][] = [];
|
|
let mList: StaffMeasure[] = [];
|
|
let mList: StaffMeasure[] = [];
|
|
orderedMeasures.push(mList);
|
|
orderedMeasures.push(mList);
|
|
for (let i: number = 0; i < measures.length; i++) {
|
|
for (let i: number = 0; i < measures.length; i++) {
|
|
- if (i === 0)
|
|
|
|
|
|
+ if (i === 0) {
|
|
mList.push(measures[0]);
|
|
mList.push(measures[0]);
|
|
- else {
|
|
|
|
- if (measures[i].ParentStaffLine === measures[i - 1].ParentStaffLine)
|
|
|
|
|
|
+ } else {
|
|
|
|
+ if (measures[i].ParentStaffLine === measures[i - 1].ParentStaffLine) {
|
|
mList.push(measures[i]);
|
|
mList.push(measures[i]);
|
|
- else {
|
|
|
|
- if (!orderedMeasures.indexOf(mList) !== -1)
|
|
|
|
|
|
+ } else {
|
|
|
|
+ if (orderedMeasures.indexOf(mList) === -1) {
|
|
orderedMeasures.push(mList);
|
|
orderedMeasures.push(mList);
|
|
|
|
+ }
|
|
mList = [];
|
|
mList = [];
|
|
orderedMeasures.push(mList);
|
|
orderedMeasures.push(mList);
|
|
mList.push(measures[i]);
|
|
mList.push(measures[i]);
|
|
@@ -207,6 +248,7 @@ export class GraphicalMusicSheet {
|
|
}
|
|
}
|
|
return orderedMeasures;
|
|
return orderedMeasures;
|
|
}
|
|
}
|
|
|
|
+
|
|
public initializeActiveClefs(): ClefInstruction[] {
|
|
public initializeActiveClefs(): ClefInstruction[] {
|
|
let activeClefs: ClefInstruction[] = [];
|
|
let activeClefs: ClefInstruction[] = [];
|
|
let firstSourceMeasure: SourceMeasure = this.musicSheet.getFirstSourceMeasure();
|
|
let firstSourceMeasure: SourceMeasure = this.musicSheet.getFirstSourceMeasure();
|
|
@@ -222,6 +264,7 @@ export class GraphicalMusicSheet {
|
|
}
|
|
}
|
|
return activeClefs;
|
|
return activeClefs;
|
|
}
|
|
}
|
|
|
|
+
|
|
public GetMainKey(): KeyInstruction {
|
|
public GetMainKey(): KeyInstruction {
|
|
let firstSourceMeasure: SourceMeasure = this.musicSheet.getFirstSourceMeasure();
|
|
let firstSourceMeasure: SourceMeasure = this.musicSheet.getFirstSourceMeasure();
|
|
if (firstSourceMeasure !== undefined) {
|
|
if (firstSourceMeasure !== undefined) {
|
|
@@ -236,6 +279,7 @@ export class GraphicalMusicSheet {
|
|
}
|
|
}
|
|
return undefined;
|
|
return undefined;
|
|
}
|
|
}
|
|
|
|
+
|
|
public getOrCreateVerticalContainer(timestamp: Fraction): VerticalGraphicalStaffEntryContainer {
|
|
public getOrCreateVerticalContainer(timestamp: Fraction): VerticalGraphicalStaffEntryContainer {
|
|
if (this.verticalGraphicalStaffEntryContainers.length === 0 || timestamp > this.verticalGraphicalStaffEntryContainers.Last().AbsoluteTimestamp) {
|
|
if (this.verticalGraphicalStaffEntryContainers.length === 0 || timestamp > this.verticalGraphicalStaffEntryContainers.Last().AbsoluteTimestamp) {
|
|
let verticalGraphicalStaffEntryContainer: VerticalGraphicalStaffEntryContainer = new VerticalGraphicalStaffEntryContainer(this.numberOfStaves, timestamp);
|
|
let verticalGraphicalStaffEntryContainer: VerticalGraphicalStaffEntryContainer = new VerticalGraphicalStaffEntryContainer(this.numberOfStaves, timestamp);
|
|
@@ -249,28 +293,34 @@ export class GraphicalMusicSheet {
|
|
this.verticalGraphicalStaffEntryContainers.splice(i + 1, 0, verticalGraphicalStaffEntryContainer);
|
|
this.verticalGraphicalStaffEntryContainers.splice(i + 1, 0, verticalGraphicalStaffEntryContainer);
|
|
return verticalGraphicalStaffEntryContainer;
|
|
return verticalGraphicalStaffEntryContainer;
|
|
}
|
|
}
|
|
- if (this.verticalGraphicalStaffEntryContainers[i].AbsoluteTimestamp === timestamp)
|
|
|
|
|
|
+ if (this.verticalGraphicalStaffEntryContainers[i].AbsoluteTimestamp === timestamp) {
|
|
return this.verticalGraphicalStaffEntryContainers[i];
|
|
return this.verticalGraphicalStaffEntryContainers[i];
|
|
|
|
+ }
|
|
}
|
|
}
|
|
return undefined;
|
|
return undefined;
|
|
}
|
|
}
|
|
|
|
+
|
|
public GetVerticalContainerFromTimestamp(timestamp: Fraction, startIndex: number): VerticalGraphicalStaffEntryContainer {
|
|
public GetVerticalContainerFromTimestamp(timestamp: Fraction, startIndex: number): VerticalGraphicalStaffEntryContainer {
|
|
let index: number = this.verticalGraphicalStaffEntryContainers.BinarySearch(startIndex,
|
|
let index: number = this.verticalGraphicalStaffEntryContainers.BinarySearch(startIndex,
|
|
this.verticalGraphicalStaffEntryContainers.length - startIndex,
|
|
this.verticalGraphicalStaffEntryContainers.length - startIndex,
|
|
new VerticalGraphicalStaffEntryContainer(0,
|
|
new VerticalGraphicalStaffEntryContainer(0,
|
|
timestamp),
|
|
timestamp),
|
|
new VerticalGraphicalStaffEntryContainer.VgseContainerTimestampComparer());
|
|
new VerticalGraphicalStaffEntryContainer.VgseContainerTimestampComparer());
|
|
- if (index >= 0)
|
|
|
|
|
|
+ if (index >= 0) {
|
|
return this.verticalGraphicalStaffEntryContainers[index];
|
|
return this.verticalGraphicalStaffEntryContainers[index];
|
|
|
|
+ }
|
|
return undefined;
|
|
return undefined;
|
|
}
|
|
}
|
|
|
|
+
|
|
public GetVerticalContainerFromTimestamp(timestamp: Fraction): VerticalGraphicalStaffEntryContainer {
|
|
public GetVerticalContainerFromTimestamp(timestamp: Fraction): VerticalGraphicalStaffEntryContainer {
|
|
let index: number = this.verticalGraphicalStaffEntryContainers.BinarySearch(new VerticalGraphicalStaffEntryContainer(0, timestamp),
|
|
let index: number = this.verticalGraphicalStaffEntryContainers.BinarySearch(new VerticalGraphicalStaffEntryContainer(0, timestamp),
|
|
new VerticalGraphicalStaffEntryContainer.VgseContainerTimestampComparer());
|
|
new VerticalGraphicalStaffEntryContainer.VgseContainerTimestampComparer());
|
|
- if (index >= 0)
|
|
|
|
|
|
+ if (index >= 0) {
|
|
return this.verticalGraphicalStaffEntryContainers[index];
|
|
return this.verticalGraphicalStaffEntryContainers[index];
|
|
|
|
+ }
|
|
return undefined;
|
|
return undefined;
|
|
}
|
|
}
|
|
|
|
+
|
|
public GetInterpolatedIndexInVerticalContainers(musicTimestamp: Fraction): number {
|
|
public GetInterpolatedIndexInVerticalContainers(musicTimestamp: Fraction): number {
|
|
let containers: VerticalGraphicalStaffEntryContainer[] = this.verticalGraphicalStaffEntryContainers;
|
|
let containers: VerticalGraphicalStaffEntryContainer[] = this.verticalGraphicalStaffEntryContainers;
|
|
let leftIndex: number = 0;
|
|
let leftIndex: number = 0;
|
|
@@ -278,7 +328,7 @@ export class GraphicalMusicSheet {
|
|
let foundIndex: number;
|
|
let foundIndex: number;
|
|
let leftTS: Fraction = undefined;
|
|
let leftTS: Fraction = undefined;
|
|
let rightTS: Fraction = undefined;
|
|
let rightTS: Fraction = undefined;
|
|
- if (musicTimestamp <= containers.Last().AbsoluteTimestamp) {
|
|
|
|
|
|
+ if (musicTimestamp <= containers[containers.length - 1].AbsoluteTimestamp) {
|
|
while (rightIndex - leftIndex > 1) {
|
|
while (rightIndex - leftIndex > 1) {
|
|
let middleIndex: number = (rightIndex + leftIndex) / 2;
|
|
let middleIndex: number = (rightIndex + leftIndex) / 2;
|
|
if (containers[leftIndex].AbsoluteTimestamp === musicTimestamp) {
|
|
if (containers[leftIndex].AbsoluteTimestamp === musicTimestamp) {
|
|
@@ -295,13 +345,14 @@ export class GraphicalMusicSheet {
|
|
leftIndex = middleIndex;
|
|
leftIndex = middleIndex;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if (leftIndex === rightIndex)
|
|
|
|
|
|
+ if (leftIndex === rightIndex) {
|
|
return this.verticalGraphicalStaffEntryContainers.indexOf(containers[leftIndex]);
|
|
return this.verticalGraphicalStaffEntryContainers.indexOf(containers[leftIndex]);
|
|
|
|
+ }
|
|
leftTS = containers[leftIndex].AbsoluteTimestamp;
|
|
leftTS = containers[leftIndex].AbsoluteTimestamp;
|
|
rightTS = containers[rightIndex].AbsoluteTimestamp;
|
|
rightTS = containers[rightIndex].AbsoluteTimestamp;
|
|
} else {
|
|
} else {
|
|
- leftTS = containers.Last().AbsoluteTimestamp;
|
|
|
|
- rightTS = new Fraction(getLongestStaffEntryDuration(containers.length - 1) + leftTS);
|
|
|
|
|
|
+ leftTS = containers[containers.length - 1].AbsoluteTimestamp;
|
|
|
|
+ rightTS = new Fraction(this.getLongestStaffEntryDuration(containers.length - 1) + leftTS);
|
|
rightIndex = containers.length;
|
|
rightIndex = containers.length;
|
|
}
|
|
}
|
|
let diff: number = rightTS.RealValue - leftTS.RealValue;
|
|
let diff: number = rightTS.RealValue - leftTS.RealValue;
|
|
@@ -309,112 +360,129 @@ export class GraphicalMusicSheet {
|
|
foundIndex = rightIndex - (diffTS / diff);
|
|
foundIndex = rightIndex - (diffTS / diff);
|
|
return Math.min(foundIndex, this.verticalGraphicalStaffEntryContainers.length);
|
|
return Math.min(foundIndex, this.verticalGraphicalStaffEntryContainers.length);
|
|
}
|
|
}
|
|
|
|
+
|
|
private getLongestStaffEntryDuration(index: number): Fraction {
|
|
private getLongestStaffEntryDuration(index: number): Fraction {
|
|
let maxLength: Fraction = new Fraction(0, 1);
|
|
let maxLength: Fraction = new Fraction(0, 1);
|
|
for (let idx: number = 0, len: number = this.verticalGraphicalStaffEntryContainers[index].StaffEntries.length; idx < len; ++idx) {
|
|
for (let idx: number = 0, len: number = this.verticalGraphicalStaffEntryContainers[index].StaffEntries.length; idx < len; ++idx) {
|
|
let graphicalStaffEntry: GraphicalStaffEntry = this.verticalGraphicalStaffEntryContainers[index].StaffEntries[idx];
|
|
let graphicalStaffEntry: GraphicalStaffEntry = this.verticalGraphicalStaffEntryContainers[index].StaffEntries[idx];
|
|
- if (graphicalStaffEntry === undefined)
|
|
|
|
|
|
+ if (graphicalStaffEntry === undefined) {
|
|
continue;
|
|
continue;
|
|
|
|
+ }
|
|
for (let idx2: number = 0, len2: number = graphicalStaffEntry.Notes.length; idx2 < len2; ++idx2) {
|
|
for (let idx2: number = 0, len2: number = graphicalStaffEntry.Notes.length; idx2 < len2; ++idx2) {
|
|
let graphicalNotes: GraphicalNote[] = graphicalStaffEntry.Notes[idx2];
|
|
let graphicalNotes: GraphicalNote[] = graphicalStaffEntry.Notes[idx2];
|
|
for (let idx3: number = 0, len3: number = graphicalNotes.length; idx3 < len3; ++idx3) {
|
|
for (let idx3: number = 0, len3: number = graphicalNotes.length; idx3 < len3; ++idx3) {
|
|
let note: GraphicalNote = graphicalNotes[idx3];
|
|
let note: GraphicalNote = graphicalNotes[idx3];
|
|
- if (note.GraphicalNoteLength > maxLength)
|
|
|
|
|
|
+ if (note.GraphicalNoteLength > maxLength) {
|
|
maxLength = note.GraphicalNoteLength;
|
|
maxLength = note.GraphicalNoteLength;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return maxLength;
|
|
return maxLength;
|
|
}
|
|
}
|
|
|
|
+
|
|
public getVisibleStavesIndecesFromSourceMeasure(visibleMeasures: StaffMeasure[]): number[] {
|
|
public getVisibleStavesIndecesFromSourceMeasure(visibleMeasures: StaffMeasure[]): number[] {
|
|
let visibleInstruments: Instrument[] = [];
|
|
let visibleInstruments: Instrument[] = [];
|
|
let visibleStavesIndeces: number[] = [];
|
|
let visibleStavesIndeces: number[] = [];
|
|
for (let idx: number = 0, len: number = visibleMeasures.length; idx < len; ++idx) {
|
|
for (let idx: number = 0, len: number = visibleMeasures.length; idx < len; ++idx) {
|
|
let graphicalMeasure: StaffMeasure = visibleMeasures[idx];
|
|
let graphicalMeasure: StaffMeasure = visibleMeasures[idx];
|
|
let instrument: Instrument = graphicalMeasure.ParentStaff.ParentInstrument;
|
|
let instrument: Instrument = graphicalMeasure.ParentStaff.ParentInstrument;
|
|
- if (!visibleInstruments.indexOf(instrument) !== -1)
|
|
|
|
|
|
+ if (!visibleInstruments.indexOf(instrument) !== -1) {
|
|
visibleInstruments.push(instrument);
|
|
visibleInstruments.push(instrument);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
for (let idx: number = 0, len: number = visibleInstruments.length; idx < len; ++idx) {
|
|
for (let idx: number = 0, len: number = visibleInstruments.length; idx < len; ++idx) {
|
|
let instrument: Instrument = visibleInstruments[idx];
|
|
let instrument: Instrument = visibleInstruments[idx];
|
|
let index: number = this.musicSheet.GetGlobalStaffIndexOfFirstStaff(instrument);
|
|
let index: number = this.musicSheet.GetGlobalStaffIndexOfFirstStaff(instrument);
|
|
- for (let j: number = 0; j < instrument.Staves.length; j++)
|
|
|
|
|
|
+ for (let j: number = 0; j < instrument.Staves.length; j++) {
|
|
visibleStavesIndeces.push(index + j);
|
|
visibleStavesIndeces.push(index + j);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
return visibleStavesIndeces;
|
|
return visibleStavesIndeces;
|
|
}
|
|
}
|
|
|
|
+
|
|
public getGraphicalMeasureFromSourceMeasureAndIndex(sourceMeasure: SourceMeasure, index: number): StaffMeasure {
|
|
public getGraphicalMeasureFromSourceMeasureAndIndex(sourceMeasure: SourceMeasure, index: number): StaffMeasure {
|
|
for (let i: number = 0; i < this.measureList.length; i++) {
|
|
for (let i: number = 0; i < this.measureList.length; i++) {
|
|
- if (this.measureList[i][0].ParentSourceMeasure === sourceMeasure)
|
|
|
|
|
|
+ if (this.measureList[i][0].ParentSourceMeasure === sourceMeasure) {
|
|
return this.measureList[i][index];
|
|
return this.measureList[i][index];
|
|
|
|
+ }
|
|
}
|
|
}
|
|
return undefined;
|
|
return undefined;
|
|
}
|
|
}
|
|
|
|
+
|
|
public getMeasureIndex(graphicalMeasure: StaffMeasure, measureIndex: number, inListIndex: number): boolean {
|
|
public getMeasureIndex(graphicalMeasure: StaffMeasure, measureIndex: number, inListIndex: number): boolean {
|
|
measureIndex = 0;
|
|
measureIndex = 0;
|
|
inListIndex = 0;
|
|
inListIndex = 0;
|
|
for (; measureIndex < this.measureList.length; measureIndex++) {
|
|
for (; measureIndex < this.measureList.length; measureIndex++) {
|
|
for (let idx: number = 0, len: number = this.measureList[measureIndex].length; idx < len; ++idx) {
|
|
for (let idx: number = 0, len: number = this.measureList[measureIndex].length; idx < len; ++idx) {
|
|
let measure: StaffMeasure = this.measureList[measureIndex][idx];
|
|
let measure: StaffMeasure = this.measureList[measureIndex][idx];
|
|
- if (measure === graphicalMeasure)
|
|
|
|
|
|
+ if (measure === graphicalMeasure) {
|
|
return true;
|
|
return true;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
+
|
|
public getMeasureIndex(entry: GraphicalStaffEntry, measureIndex: number, inListIndex: number): boolean {
|
|
public getMeasureIndex(entry: GraphicalStaffEntry, measureIndex: number, inListIndex: number): boolean {
|
|
return this.getMeasureIndex(entry.ParentMeasure, measureIndex, inListIndex);
|
|
return this.getMeasureIndex(entry.ParentMeasure, measureIndex, inListIndex);
|
|
}
|
|
}
|
|
- public GetNearesNote(clickPosition: PointF_2D, maxClickDist: PointF_2D): GraphicalNote {
|
|
|
|
|
|
+
|
|
|
|
+ public GetNearesNote(clickPosition: PointF2D, maxClickDist: PointF2D): GraphicalNote {
|
|
let initialSearchArea: number = 10;
|
|
let initialSearchArea: number = 10;
|
|
let foundNotes: GraphicalNote[] = [];
|
|
let foundNotes: GraphicalNote[] = [];
|
|
let region: BoundingBox = new BoundingBox(undefined);
|
|
let region: BoundingBox = new BoundingBox(undefined);
|
|
- region.BorderLeft = clickPosition.X - initialSearchArea;
|
|
|
|
- region.BorderTop = clickPosition.Y - initialSearchArea;
|
|
|
|
- region.BorderRight = clickPosition.X + initialSearchArea;
|
|
|
|
- region.BorderBottom = clickPosition.Y + initialSearchArea;
|
|
|
|
- region.AbsolutePosition = new PointF_2D(0, 0);
|
|
|
|
|
|
+ region.BorderLeft = clickPosition.x - initialSearchArea;
|
|
|
|
+ region.BorderTop = clickPosition.y - initialSearchArea;
|
|
|
|
+ region.BorderRight = clickPosition.x + initialSearchArea;
|
|
|
|
+ region.BorderBottom = clickPosition.y + initialSearchArea;
|
|
|
|
+ region.AbsolutePosition = new PointF2D(0, 0);
|
|
for (let idx: number = 0, len: number = this.MusicPages.length; idx < len; ++idx) {
|
|
for (let idx: number = 0, len: number = this.MusicPages.length; idx < len; ++idx) {
|
|
let graphicalMusicPage: GraphicalMusicPage = this.MusicPages[idx];
|
|
let graphicalMusicPage: GraphicalMusicPage = this.MusicPages[idx];
|
|
let entries: GraphicalNote[] = graphicalMusicPage.PositionAndShape.getObjectsInRegion<GraphicalNote>(region);
|
|
let entries: GraphicalNote[] = graphicalMusicPage.PositionAndShape.getObjectsInRegion<GraphicalNote>(region);
|
|
- let entriesArr: GraphicalNote[] = __as__<GraphicalNote[]>(entries, GraphicalNote[]) ?? entries;
|
|
|
|
|
|
+ let entriesArr: GraphicalNote[] = __as__<GraphicalNote[]>(entries, GraphicalNote[]) ? ? entries;
|
|
if (entries === undefined) {
|
|
if (entries === undefined) {
|
|
continue;
|
|
continue;
|
|
} else {
|
|
} else {
|
|
for (let idx2: number = 0, len2: number = entriesArr.length; idx2 < len2; ++idx2) {
|
|
for (let idx2: number = 0, len2: number = entriesArr.length; idx2 < len2; ++idx2) {
|
|
let note: GraphicalNote = entriesArr[idx2];
|
|
let note: GraphicalNote = entriesArr[idx2];
|
|
- if (Math.abs(note.PositionAndShape.AbsolutePosition.X - clickPosition.X) < maxClickDist.X && Math.abs(note.PositionAndShape.AbsolutePosition.Y - clickPosition.Y) < maxClickDist.Y)
|
|
|
|
|
|
+ if (Math.abs(note.PositionAndShape.AbsolutePosition.x - clickPosition.x) < maxClickDist.x && Math.abs(note.PositionAndShape.AbsolutePosition.y - clickPosition.y) < maxClickDist.y) {
|
|
foundNotes.push(note);
|
|
foundNotes.push(note);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let closest: GraphicalNote = undefined;
|
|
let closest: GraphicalNote = undefined;
|
|
for (let idx: number = 0, len: number = foundNotes.length; idx < len; ++idx) {
|
|
for (let idx: number = 0, len: number = foundNotes.length; idx < len; ++idx) {
|
|
let note: GraphicalNote = foundNotes[idx];
|
|
let note: GraphicalNote = foundNotes[idx];
|
|
- if (closest === undefined)
|
|
|
|
|
|
+ if (closest === undefined) {
|
|
closest = note;
|
|
closest = note;
|
|
- else {
|
|
|
|
- if (note.ParentStaffEntry.RelInMeasureTimestamp === undefined)
|
|
|
|
|
|
+ } else {
|
|
|
|
+ if (note.ParentStaffEntry.RelInMeasureTimestamp === undefined) {
|
|
continue;
|
|
continue;
|
|
|
|
+ }
|
|
let deltaNew: number = this.CalculateDistance(note.PositionAndShape.AbsolutePosition, clickPosition);
|
|
let deltaNew: number = this.CalculateDistance(note.PositionAndShape.AbsolutePosition, clickPosition);
|
|
let deltaOld: number = this.CalculateDistance(closest.PositionAndShape.AbsolutePosition, clickPosition);
|
|
let deltaOld: number = this.CalculateDistance(closest.PositionAndShape.AbsolutePosition, clickPosition);
|
|
- if (deltaNew < deltaOld)
|
|
|
|
|
|
+ if (deltaNew < deltaOld) {
|
|
closest = note;
|
|
closest = note;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if (closest !== undefined)
|
|
|
|
|
|
+ if (closest !== undefined) {
|
|
return closest;
|
|
return closest;
|
|
|
|
+ }
|
|
return undefined;
|
|
return undefined;
|
|
}
|
|
}
|
|
- public GetClickableLabel(clickPosition: PointF_2D): GraphicalLabel {
|
|
|
|
|
|
+
|
|
|
|
+ public GetClickableLabel(clickPosition: PointF2D): GraphicalLabel {
|
|
let initialSearchAreaX: number = 4;
|
|
let initialSearchAreaX: number = 4;
|
|
let initialSearchAreaY: number = 4;
|
|
let initialSearchAreaY: number = 4;
|
|
let region: BoundingBox = new BoundingBox(undefined);
|
|
let region: BoundingBox = new BoundingBox(undefined);
|
|
- region.BorderLeft = clickPosition.X - initialSearchAreaX;
|
|
|
|
- region.BorderTop = clickPosition.Y - initialSearchAreaY;
|
|
|
|
- region.BorderRight = clickPosition.X + initialSearchAreaX;
|
|
|
|
- region.BorderBottom = clickPosition.Y + initialSearchAreaY;
|
|
|
|
- region.AbsolutePosition = new PointF_2D(0, 0);
|
|
|
|
|
|
+ region.BorderLeft = clickPosition.x - initialSearchAreaX;
|
|
|
|
+ region.BorderTop = clickPosition.y - initialSearchAreaY;
|
|
|
|
+ region.BorderRight = clickPosition.x + initialSearchAreaX;
|
|
|
|
+ region.BorderBottom = clickPosition.y + initialSearchAreaY;
|
|
|
|
+ region.AbsolutePosition = new PointF2D(0, 0);
|
|
for (let idx: number = 0, len: number = this.MusicPages.length; idx < len; ++idx) {
|
|
for (let idx: number = 0, len: number = this.MusicPages.length; idx < len; ++idx) {
|
|
let graphicalMusicPage: GraphicalMusicPage = this.MusicPages[idx];
|
|
let graphicalMusicPage: GraphicalMusicPage = this.MusicPages[idx];
|
|
let entries: GraphicalLabel[] = graphicalMusicPage.PositionAndShape.getObjectsInRegion<GraphicalLabel>(region);
|
|
let entries: GraphicalLabel[] = graphicalMusicPage.PositionAndShape.getObjectsInRegion<GraphicalLabel>(region);
|
|
@@ -429,15 +497,16 @@ export class GraphicalMusicSheet {
|
|
}
|
|
}
|
|
return undefined;
|
|
return undefined;
|
|
}
|
|
}
|
|
- public GetNearestStaffEntry(clickPosition: PointF_2D): GraphicalStaffEntry {
|
|
|
|
|
|
+
|
|
|
|
+ public GetNearestStaffEntry(clickPosition: PointF2D): GraphicalStaffEntry {
|
|
let initialSearchArea: number = 10;
|
|
let initialSearchArea: number = 10;
|
|
let foundEntries: GraphicalStaffEntry[] = [];
|
|
let foundEntries: GraphicalStaffEntry[] = [];
|
|
let region: BoundingBox = new BoundingBox(undefined);
|
|
let region: BoundingBox = new BoundingBox(undefined);
|
|
- region.BorderLeft = clickPosition.X - initialSearchArea;
|
|
|
|
- region.BorderTop = clickPosition.Y - initialSearchArea;
|
|
|
|
- region.BorderRight = clickPosition.X + initialSearchArea;
|
|
|
|
- region.BorderBottom = clickPosition.Y + initialSearchArea;
|
|
|
|
- region.AbsolutePosition = new PointF_2D(0, 0);
|
|
|
|
|
|
+ region.BorderLeft = clickPosition.x - initialSearchArea;
|
|
|
|
+ region.BorderTop = clickPosition.y - initialSearchArea;
|
|
|
|
+ region.BorderRight = clickPosition.x + initialSearchArea;
|
|
|
|
+ region.BorderBottom = clickPosition.y + initialSearchArea;
|
|
|
|
+ region.AbsolutePosition = new PointF2D(0, 0);
|
|
for (let idx: number = 0, len: number = this.MusicPages.length; idx < len; ++idx) {
|
|
for (let idx: number = 0, len: number = this.MusicPages.length; idx < len; ++idx) {
|
|
let graphicalMusicPage: GraphicalMusicPage = this.MusicPages[idx];
|
|
let graphicalMusicPage: GraphicalMusicPage = this.MusicPages[idx];
|
|
let entries: GraphicalStaffEntry[] = graphicalMusicPage.PositionAndShape.getObjectsInRegion<GraphicalStaffEntry>(region, false);
|
|
let entries: GraphicalStaffEntry[] = graphicalMusicPage.PositionAndShape.getObjectsInRegion<GraphicalStaffEntry>(region, false);
|
|
@@ -453,118 +522,137 @@ export class GraphicalMusicSheet {
|
|
let closest: GraphicalStaffEntry = undefined;
|
|
let closest: GraphicalStaffEntry = undefined;
|
|
for (let idx: number = 0, len: number = foundEntries.length; idx < len; ++idx) {
|
|
for (let idx: number = 0, len: number = foundEntries.length; idx < len; ++idx) {
|
|
let gse: GraphicalStaffEntry = foundEntries[idx];
|
|
let gse: GraphicalStaffEntry = foundEntries[idx];
|
|
- if (closest === undefined)
|
|
|
|
|
|
+ if (closest === undefined) {
|
|
closest = gse;
|
|
closest = gse;
|
|
- else {
|
|
|
|
- if (gse.RelInMeasureTimestamp === undefined)
|
|
|
|
|
|
+ } else {
|
|
|
|
+ if (gse.RelInMeasureTimestamp === undefined) {
|
|
continue;
|
|
continue;
|
|
|
|
+ }
|
|
let deltaNew: number = this.CalculateDistance(gse.PositionAndShape.AbsolutePosition, clickPosition);
|
|
let deltaNew: number = this.CalculateDistance(gse.PositionAndShape.AbsolutePosition, clickPosition);
|
|
let deltaOld: number = this.CalculateDistance(closest.PositionAndShape.AbsolutePosition, clickPosition);
|
|
let deltaOld: number = this.CalculateDistance(closest.PositionAndShape.AbsolutePosition, clickPosition);
|
|
- if (deltaNew < deltaOld)
|
|
|
|
|
|
+ if (deltaNew < deltaOld) {
|
|
closest = gse;
|
|
closest = gse;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if (closest !== undefined)
|
|
|
|
|
|
+ if (closest !== undefined) {
|
|
return closest;
|
|
return closest;
|
|
|
|
+ }
|
|
return undefined;
|
|
return undefined;
|
|
}
|
|
}
|
|
- public GetPossibleCommentAnchor(clickPosition: PointF_2D): SourceStaffEntry {
|
|
|
|
|
|
+
|
|
|
|
+ public GetPossibleCommentAnchor(clickPosition: PointF2D): SourceStaffEntry {
|
|
let entry: GraphicalStaffEntry = this.GetNearestStaffEntry(clickPosition);
|
|
let entry: GraphicalStaffEntry = this.GetNearestStaffEntry(clickPosition);
|
|
- if (entry === undefined)
|
|
|
|
|
|
+ if (entry === undefined) {
|
|
return undefined;
|
|
return undefined;
|
|
|
|
+ }
|
|
return entry.SourceStaffEntry;
|
|
return entry.SourceStaffEntry;
|
|
}
|
|
}
|
|
- public getClickedObjectOfType<T>(positionOnMusicSheet: PointF_2D): T {
|
|
|
|
|
|
+
|
|
|
|
+ public getClickedObjectOfType<T>(positionOnMusicSheet: PointF2D): T {
|
|
for (let idx: number = 0, len: number = this.musicPages.length; idx < len; ++idx) {
|
|
for (let idx: number = 0, len: number = this.musicPages.length; idx < len; ++idx) {
|
|
let page: GraphicalMusicPage = this.musicPages[idx];
|
|
let page: GraphicalMusicPage = this.musicPages[idx];
|
|
let o: Object = page.PositionAndShape.getClickedObjectOfType<T>(positionOnMusicSheet);
|
|
let o: Object = page.PositionAndShape.getClickedObjectOfType<T>(positionOnMusicSheet);
|
|
- if (o !== undefined)
|
|
|
|
|
|
+ if (o !== undefined) {
|
|
return (o as T);
|
|
return (o as T);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
return undefined;
|
|
return undefined;
|
|
}
|
|
}
|
|
- public tryGetTimestampFromPosition(positionOnMusicSheet: PointF_2D): Fraction {
|
|
|
|
|
|
+
|
|
|
|
+ public tryGetTimestampFromPosition(positionOnMusicSheet: PointF2D): Fraction {
|
|
let entry: GraphicalStaffEntry = this.getClickedObjectOfType<GraphicalStaffEntry>(positionOnMusicSheet);
|
|
let entry: GraphicalStaffEntry = this.getClickedObjectOfType<GraphicalStaffEntry>(positionOnMusicSheet);
|
|
- if (entry === undefined)
|
|
|
|
|
|
+ if (entry === undefined) {
|
|
return undefined;
|
|
return undefined;
|
|
|
|
+ }
|
|
return entry.getAbsoluteTimestamp();
|
|
return entry.getAbsoluteTimestamp();
|
|
}
|
|
}
|
|
- public tryGetClickableLabel(positionOnMusicSheet: PointF_2D): GraphicalLabel {
|
|
|
|
|
|
+
|
|
|
|
+ public tryGetClickableLabel(positionOnMusicSheet: PointF2D): GraphicalLabel {
|
|
try {
|
|
try {
|
|
return this.GetClickableLabel(positionOnMusicSheet);
|
|
return this.GetClickableLabel(positionOnMusicSheet);
|
|
}
|
|
}
|
|
catch (ex) {
|
|
catch (ex) {
|
|
- Logger.DefaultLogger.LogError(LogLevel.NORMAL, "GraphicalMusicSheet.tryGetClickableObject",
|
|
|
|
- "positionOnMusicSheet: " + positionOnMusicSheet, ex);
|
|
|
|
|
|
+ Logging.log("GraphicalMusicSheet.tryGetClickableObject", "positionOnMusicSheet: " + positionOnMusicSheet, ex);
|
|
}
|
|
}
|
|
|
|
|
|
return undefined;
|
|
return undefined;
|
|
}
|
|
}
|
|
- public tryGetTimeStampFromPosition(positionOnMusicSheet: PointF_2D): Fraction {
|
|
|
|
|
|
+
|
|
|
|
+ public tryGetTimeStampFromPosition(positionOnMusicSheet: PointF2D): Fraction {
|
|
try {
|
|
try {
|
|
let entry: GraphicalStaffEntry = this.GetNearestStaffEntry(positionOnMusicSheet);
|
|
let entry: GraphicalStaffEntry = this.GetNearestStaffEntry(positionOnMusicSheet);
|
|
- if (entry === undefined)
|
|
|
|
|
|
+ if (entry === undefined) {
|
|
return undefined;
|
|
return undefined;
|
|
|
|
+ }
|
|
return entry.getAbsoluteTimestamp();
|
|
return entry.getAbsoluteTimestamp();
|
|
- }
|
|
|
|
- catch (ex) {
|
|
|
|
- Logger.DefaultLogger.LogError(LogLevel.NORMAL, "GraphicalMusicSheet.tryGetTimeStampFromPosition",
|
|
|
|
|
|
+ } catch (ex) {
|
|
|
|
+ Logging.log("GraphicalMusicSheet.tryGetTimeStampFromPosition",
|
|
"positionOnMusicSheet: " + positionOnMusicSheet, ex);
|
|
"positionOnMusicSheet: " + positionOnMusicSheet, ex);
|
|
}
|
|
}
|
|
|
|
|
|
return undefined;
|
|
return undefined;
|
|
}
|
|
}
|
|
- private CalculateDistance(pt1: PointF_2D, pt2: PointF_2D): number {
|
|
|
|
- let deltaX: number = pt1.X - pt2.X;
|
|
|
|
- let deltaY: number = pt1.Y - pt2.Y;
|
|
|
|
|
|
+
|
|
|
|
+ private CalculateDistance(pt1: PointF2D, pt2: PointF2D): number {
|
|
|
|
+ let deltaX: number = pt1.x - pt2.x;
|
|
|
|
+ let deltaY: number = pt1.y - pt2.y;
|
|
return (deltaX * deltaX) + (deltaY * deltaY);
|
|
return (deltaX * deltaX) + (deltaY * deltaY);
|
|
}
|
|
}
|
|
|
|
+
|
|
public getStaffEntry(index: number): GraphicalStaffEntry {
|
|
public getStaffEntry(index: number): GraphicalStaffEntry {
|
|
return this.getStaffEntry(this.VerticalGraphicalStaffEntryContainers[index]);
|
|
return this.getStaffEntry(this.VerticalGraphicalStaffEntryContainers[index]);
|
|
}
|
|
}
|
|
|
|
+
|
|
public getStaffEntry(container: VerticalGraphicalStaffEntryContainer): GraphicalStaffEntry {
|
|
public getStaffEntry(container: VerticalGraphicalStaffEntryContainer): GraphicalStaffEntry {
|
|
let staffEntry: GraphicalStaffEntry = undefined;
|
|
let staffEntry: GraphicalStaffEntry = undefined;
|
|
try {
|
|
try {
|
|
for (let idx: number = 0, len: number = container.StaffEntries.length; idx < len; ++idx) {
|
|
for (let idx: number = 0, len: number = container.StaffEntries.length; idx < len; ++idx) {
|
|
let entry: GraphicalStaffEntry = container.StaffEntries[idx];
|
|
let entry: GraphicalStaffEntry = container.StaffEntries[idx];
|
|
- if (entry === undefined || !entry.SourceStaffEntry.ParentStaff.ParentInstrument.Visible)
|
|
|
|
|
|
+ if (entry === undefined || !entry.SourceStaffEntry.ParentStaff.ParentInstrument.Visible) {
|
|
continue;
|
|
continue;
|
|
|
|
+ }
|
|
if (staffEntry === undefined) {
|
|
if (staffEntry === undefined) {
|
|
staffEntry = entry;
|
|
staffEntry = entry;
|
|
} else if (entry.PositionAndShape !== undefined && staffEntry.PositionAndShape !== undefined) {
|
|
} else if (entry.PositionAndShape !== undefined && staffEntry.PositionAndShape !== undefined) {
|
|
- if (staffEntry.PositionAndShape.RelativePosition.X > entry.PositionAndShape.RelativePosition.X)
|
|
|
|
|
|
+ if (staffEntry.PositionAndShape.RelativePosition.x > entry.PositionAndShape.RelativePosition.x) {
|
|
staffEntry = entry;
|
|
staffEntry = entry;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- }
|
|
|
|
- catch (ex) {
|
|
|
|
- Logger.DefaultLogger.LogError(LogLevel.NORMAL, "GraphicalMusicSheet.getStaffEntry", ex);
|
|
|
|
|
|
+ } catch (ex) {
|
|
|
|
+ Logging.log("GraphicalMusicSheet.getStaffEntry", ex);
|
|
}
|
|
}
|
|
|
|
|
|
return staffEntry;
|
|
return staffEntry;
|
|
}
|
|
}
|
|
|
|
+
|
|
public GetPreviousVisibleContainerIndex(index: number): number {
|
|
public GetPreviousVisibleContainerIndex(index: number): number {
|
|
for (let i: number = index - 1; i >= 0; i--) {
|
|
for (let i: number = index - 1; i >= 0; i--) {
|
|
let entries: GraphicalStaffEntry[] = this.verticalGraphicalStaffEntryContainers[i].StaffEntries;
|
|
let entries: GraphicalStaffEntry[] = this.verticalGraphicalStaffEntryContainers[i].StaffEntries;
|
|
for (let idx: number = 0, len: number = entries.length; idx < len; ++idx) {
|
|
for (let idx: number = 0, len: number = entries.length; idx < len; ++idx) {
|
|
let entry: GraphicalStaffEntry = entries[idx];
|
|
let entry: GraphicalStaffEntry = entries[idx];
|
|
- if (entry !== undefined && entry.SourceStaffEntry.ParentStaff.ParentInstrument.Visible)
|
|
|
|
|
|
+ if (entry !== undefined && entry.SourceStaffEntry.ParentStaff.ParentInstrument.Visible) {
|
|
return i;
|
|
return i;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
+
|
|
public GetNextVisibleContainerIndex(index: number): number {
|
|
public GetNextVisibleContainerIndex(index: number): number {
|
|
for (let i: number = index + 1; i < this.verticalGraphicalStaffEntryContainers.length; ++i) {
|
|
for (let i: number = index + 1; i < this.verticalGraphicalStaffEntryContainers.length; ++i) {
|
|
let entries: GraphicalStaffEntry[] = this.verticalGraphicalStaffEntryContainers[i].StaffEntries;
|
|
let entries: GraphicalStaffEntry[] = this.verticalGraphicalStaffEntryContainers[i].StaffEntries;
|
|
for (let idx: number = 0, len: number = entries.length; idx < len; ++idx) {
|
|
for (let idx: number = 0, len: number = entries.length; idx < len; ++idx) {
|
|
let entry: GraphicalStaffEntry = entries[idx];
|
|
let entry: GraphicalStaffEntry = entries[idx];
|
|
- if (entry !== undefined && entry.SourceStaffEntry.ParentStaff.ParentInstrument.Visible)
|
|
|
|
|
|
+ if (entry !== undefined && entry.SourceStaffEntry.ParentStaff.ParentInstrument.Visible) {
|
|
return i;
|
|
return i;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
+
|
|
public findClosestLeftStaffEntry(fractionalIndex: number, searchOnlyVisibleEntries: boolean): GraphicalStaffEntry {
|
|
public findClosestLeftStaffEntry(fractionalIndex: number, searchOnlyVisibleEntries: boolean): GraphicalStaffEntry {
|
|
let foundEntry: GraphicalStaffEntry = undefined;
|
|
let foundEntry: GraphicalStaffEntry = undefined;
|
|
let leftIndex: number = <number>Math.floor(fractionalIndex);
|
|
let leftIndex: number = <number>Math.floor(fractionalIndex);
|
|
@@ -573,27 +661,35 @@ export class GraphicalMusicSheet {
|
|
foundEntry = this.getStaffEntry(i);
|
|
foundEntry = this.getStaffEntry(i);
|
|
if (foundEntry !== undefined) {
|
|
if (foundEntry !== undefined) {
|
|
if (searchOnlyVisibleEntries) {
|
|
if (searchOnlyVisibleEntries) {
|
|
- if (foundEntry.SourceStaffEntry.ParentStaff.ParentInstrument.Visible)
|
|
|
|
|
|
+ if (foundEntry.SourceStaffEntry.ParentStaff.ParentInstrument.Visible) {
|
|
return foundEntry;
|
|
return foundEntry;
|
|
- } else return foundEntry;
|
|
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ return foundEntry;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return undefined;
|
|
return undefined;
|
|
}
|
|
}
|
|
|
|
+
|
|
public findClosestRightStaffEntry(fractionalIndex: number, returnOnlyVisibleEntries: boolean): GraphicalStaffEntry {
|
|
public findClosestRightStaffEntry(fractionalIndex: number, returnOnlyVisibleEntries: boolean): GraphicalStaffEntry {
|
|
let foundEntry: GraphicalStaffEntry = undefined;
|
|
let foundEntry: GraphicalStaffEntry = undefined;
|
|
- let rightIndex: number = <number>Math.max(0, Math.ceiling(fractionalIndex));
|
|
|
|
|
|
+ let rightIndex: number = <number>Math.max(0, Math.ceil(fractionalIndex));
|
|
for (let i: number = rightIndex; i < this.VerticalGraphicalStaffEntryContainers.length; i++) {
|
|
for (let i: number = rightIndex; i < this.VerticalGraphicalStaffEntryContainers.length; i++) {
|
|
foundEntry = this.getStaffEntry(i);
|
|
foundEntry = this.getStaffEntry(i);
|
|
if (foundEntry !== undefined) {
|
|
if (foundEntry !== undefined) {
|
|
if (returnOnlyVisibleEntries) {
|
|
if (returnOnlyVisibleEntries) {
|
|
- if (foundEntry.SourceStaffEntry.ParentStaff.ParentInstrument.Visible)
|
|
|
|
|
|
+ if (foundEntry.SourceStaffEntry.ParentStaff.ParentInstrument.Visible) {
|
|
return foundEntry;
|
|
return foundEntry;
|
|
- } else return foundEntry;
|
|
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ return foundEntry;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return undefined;
|
|
return undefined;
|
|
}
|
|
}
|
|
|
|
+
|
|
public calculateXPositionFromTimestamp(timeStamp: Fraction, currentMusicSystem: MusicSystem): number {
|
|
public calculateXPositionFromTimestamp(timeStamp: Fraction, currentMusicSystem: MusicSystem): number {
|
|
let fractionalIndex: number = this.GetInterpolatedIndexInVerticalContainers(timeStamp);
|
|
let fractionalIndex: number = this.GetInterpolatedIndexInVerticalContainers(timeStamp);
|
|
let previousStaffEntry: GraphicalStaffEntry = this.findClosestLeftStaffEntry(fractionalIndex, true);
|
|
let previousStaffEntry: GraphicalStaffEntry = this.findClosestLeftStaffEntry(fractionalIndex, true);
|
|
@@ -621,18 +717,20 @@ export class GraphicalMusicSheet {
|
|
let previousStaffEntryPositionX: number;
|
|
let previousStaffEntryPositionX: number;
|
|
let nextStaffEntryPositionX: number;
|
|
let nextStaffEntryPositionX: number;
|
|
if (previousStaffEntry === undefined) {
|
|
if (previousStaffEntry === undefined) {
|
|
- previousStaffEntryPositionX = nextStaffEntryPositionX = nextStaffEntry.PositionAndShape.AbsolutePosition.X;
|
|
|
|
|
|
+ previousStaffEntryPositionX = nextStaffEntryPositionX = nextStaffEntry.PositionAndShape.AbsolutePosition.x;
|
|
fraction = 0;
|
|
fraction = 0;
|
|
} else if (nextStaffEntry === undefined) {
|
|
} else if (nextStaffEntry === undefined) {
|
|
- previousStaffEntryPositionX = previousStaffEntry.PositionAndShape.AbsolutePosition.X;
|
|
|
|
|
|
+ previousStaffEntryPositionX = previousStaffEntry.PositionAndShape.AbsolutePosition.x;
|
|
nextStaffEntryPositionX = currentMusicSystem.GetRightBorderAbsoluteXPosition();
|
|
nextStaffEntryPositionX = currentMusicSystem.GetRightBorderAbsoluteXPosition();
|
|
fraction = (currentTimeStamp - previousStaffEntry.getAbsoluteTimestamp().RealValue) / ((previousStaffEntry.ParentMeasure.ParentSourceMeasure.AbsoluteTimestamp + previousStaffEntry.ParentMeasure.ParentSourceMeasure.Duration).RealValue - previousStaffEntry.getAbsoluteTimestamp().RealValue);
|
|
fraction = (currentTimeStamp - previousStaffEntry.getAbsoluteTimestamp().RealValue) / ((previousStaffEntry.ParentMeasure.ParentSourceMeasure.AbsoluteTimestamp + previousStaffEntry.ParentMeasure.ParentSourceMeasure.Duration).RealValue - previousStaffEntry.getAbsoluteTimestamp().RealValue);
|
|
} else {
|
|
} else {
|
|
- previousStaffEntryPositionX = previousStaffEntry.PositionAndShape.AbsolutePosition.X;
|
|
|
|
- nextStaffEntryPositionX = nextStaffEntry.PositionAndShape.AbsolutePosition.X;
|
|
|
|
- if (previousStaffEntry === nextStaffEntry)
|
|
|
|
|
|
+ previousStaffEntryPositionX = previousStaffEntry.PositionAndShape.AbsolutePosition.x;
|
|
|
|
+ nextStaffEntryPositionX = nextStaffEntry.PositionAndShape.AbsolutePosition.x;
|
|
|
|
+ if (previousStaffEntry === nextStaffEntry) {
|
|
fraction = 0;
|
|
fraction = 0;
|
|
- else fraction = (currentTimeStamp - previousStaffEntry.getAbsoluteTimestamp().RealValue) / (nextStaffEntry.getAbsoluteTimestamp().RealValue - previousStaffEntry.getAbsoluteTimestamp().RealValue);
|
|
|
|
|
|
+ } else {
|
|
|
|
+ fraction = (currentTimeStamp - previousStaffEntry.getAbsoluteTimestamp().RealValue) / (nextStaffEntry.getAbsoluteTimestamp().RealValue - previousStaffEntry.getAbsoluteTimestamp().RealValue);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
fraction = Math.min(1, Math.max(0, fraction));
|
|
fraction = Math.min(1, Math.max(0, fraction));
|
|
let interpolatedXPosition: number = previousStaffEntryPositionX + fraction * (nextStaffEntryPositionX - previousStaffEntryPositionX);
|
|
let interpolatedXPosition: number = previousStaffEntryPositionX + fraction * (nextStaffEntryPositionX - previousStaffEntryPositionX);
|
|
@@ -643,14 +741,14 @@ export class GraphicalMusicSheet {
|
|
let interpolatedXPosition: number;
|
|
let interpolatedXPosition: number;
|
|
if (currentTimeStamp < nextSystemLeftBorderTimeStamp) {
|
|
if (currentTimeStamp < nextSystemLeftBorderTimeStamp) {
|
|
currentMusicSystem = previousStaffEntryMusicSystem;
|
|
currentMusicSystem = previousStaffEntryMusicSystem;
|
|
- let previousStaffEntryPositionX: number = previousStaffEntry.PositionAndShape.AbsolutePosition.X;
|
|
|
|
|
|
+ let previousStaffEntryPositionX: number = previousStaffEntry.PositionAndShape.AbsolutePosition.x;
|
|
let previousSystemRightBorderX: number = currentMusicSystem.GetRightBorderAbsoluteXPosition();
|
|
let previousSystemRightBorderX: number = currentMusicSystem.GetRightBorderAbsoluteXPosition();
|
|
fraction = (currentTimeStamp - previousStaffEntry.getAbsoluteTimestamp().RealValue) / (nextSystemLeftBorderTimeStamp - previousStaffEntry.getAbsoluteTimestamp().RealValue);
|
|
fraction = (currentTimeStamp - previousStaffEntry.getAbsoluteTimestamp().RealValue) / (nextSystemLeftBorderTimeStamp - previousStaffEntry.getAbsoluteTimestamp().RealValue);
|
|
fraction = Math.min(1, Math.max(0, fraction));
|
|
fraction = Math.min(1, Math.max(0, fraction));
|
|
interpolatedXPosition = previousStaffEntryPositionX + fraction * (previousSystemRightBorderX - previousStaffEntryPositionX);
|
|
interpolatedXPosition = previousStaffEntryPositionX + fraction * (previousSystemRightBorderX - previousStaffEntryPositionX);
|
|
} else {
|
|
} else {
|
|
currentMusicSystem = nextStaffEntryMusicSystem;
|
|
currentMusicSystem = nextStaffEntryMusicSystem;
|
|
- let nextStaffEntryPositionX: number = nextStaffEntry.PositionAndShape.AbsolutePosition.X;
|
|
|
|
|
|
+ let nextStaffEntryPositionX: number = nextStaffEntry.PositionAndShape.AbsolutePosition.x;
|
|
let nextSystemLeftBorderX: number = currentMusicSystem.GetLeftBorderAbsoluteXPosition();
|
|
let nextSystemLeftBorderX: number = currentMusicSystem.GetLeftBorderAbsoluteXPosition();
|
|
fraction = (currentTimeStamp - nextSystemLeftBorderTimeStamp) / (nextStaffEntry.getAbsoluteTimestamp().RealValue - nextSystemLeftBorderTimeStamp);
|
|
fraction = (currentTimeStamp - nextSystemLeftBorderTimeStamp) / (nextStaffEntry.getAbsoluteTimestamp().RealValue - nextSystemLeftBorderTimeStamp);
|
|
fraction = Math.min(1, Math.max(0, fraction));
|
|
fraction = Math.min(1, Math.max(0, fraction));
|
|
@@ -659,52 +757,63 @@ export class GraphicalMusicSheet {
|
|
return interpolatedXPosition;
|
|
return interpolatedXPosition;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
public GetNumberOfVisibleInstruments(): number {
|
|
public GetNumberOfVisibleInstruments(): number {
|
|
let visibleInstrumentCount: number = 0;
|
|
let visibleInstrumentCount: number = 0;
|
|
for (let idx: number = 0, len: number = this.musicSheet.Instruments.length; idx < len; ++idx) {
|
|
for (let idx: number = 0, len: number = this.musicSheet.Instruments.length; idx < len; ++idx) {
|
|
let instrument: Instrument = this.musicSheet.Instruments[idx];
|
|
let instrument: Instrument = this.musicSheet.Instruments[idx];
|
|
- if (instrument.Visible === true)
|
|
|
|
|
|
+ if (instrument.Visible === true) {
|
|
visibleInstrumentCount++;
|
|
visibleInstrumentCount++;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
return visibleInstrumentCount;
|
|
return visibleInstrumentCount;
|
|
}
|
|
}
|
|
|
|
+
|
|
public GetNumberOfFollowedInstruments(): number {
|
|
public GetNumberOfFollowedInstruments(): number {
|
|
let followedInstrumentCount: number = 0;
|
|
let followedInstrumentCount: number = 0;
|
|
for (let idx: number = 0, len: number = this.musicSheet.Instruments.length; idx < len; ++idx) {
|
|
for (let idx: number = 0, len: number = this.musicSheet.Instruments.length; idx < len; ++idx) {
|
|
let instrument: Instrument = this.musicSheet.Instruments[idx];
|
|
let instrument: Instrument = this.musicSheet.Instruments[idx];
|
|
- if (instrument.Following === true)
|
|
|
|
|
|
+ if (instrument.Following === true) {
|
|
followedInstrumentCount++;
|
|
followedInstrumentCount++;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
return followedInstrumentCount;
|
|
return followedInstrumentCount;
|
|
}
|
|
}
|
|
|
|
+
|
|
public GetGraphicalFromSourceMeasure(sourceMeasure: SourceMeasure): StaffMeasure[] {
|
|
public GetGraphicalFromSourceMeasure(sourceMeasure: SourceMeasure): StaffMeasure[] {
|
|
return this.SourceToGraphicalMeasureLinks[sourceMeasure];
|
|
return this.SourceToGraphicalMeasureLinks[sourceMeasure];
|
|
}
|
|
}
|
|
|
|
+
|
|
public GetGraphicalFromSourceStaffEntry(sourceStaffEntry: SourceStaffEntry): GraphicalStaffEntry {
|
|
public GetGraphicalFromSourceStaffEntry(sourceStaffEntry: SourceStaffEntry): GraphicalStaffEntry {
|
|
- let graphicalMeasure: StaffMeasure = this.SourceToGraphicalMeasureLinks[sourceStaffEntry.VerticalContainerParent.ParentMeasure][sourceStaffEntry.ParentStaff.IdInMusicSheet];
|
|
|
|
|
|
+ let graphicalMeasure: StaffMeasure = this.SourceToGraphicalMeasureLinks
|
|
|
|
+ [sourceStaffEntry.VerticalContainerParent.ParentMeasure][sourceStaffEntry.ParentStaff.idInMusicSheet];
|
|
return graphicalMeasure.findGraphicalStaffEntryFromTimestamp(sourceStaffEntry.Timestamp);
|
|
return graphicalMeasure.findGraphicalStaffEntryFromTimestamp(sourceStaffEntry.Timestamp);
|
|
}
|
|
}
|
|
|
|
+
|
|
public GetGraphicalFromSourceStaffEntry(voiceEntries: VoiceEntry[]): GraphicalStaffEntry {
|
|
public GetGraphicalFromSourceStaffEntry(voiceEntries: VoiceEntry[]): GraphicalStaffEntry {
|
|
- if (voiceEntries.length === 0)
|
|
|
|
|
|
+ if (voiceEntries.length === 0) {
|
|
return undefined;
|
|
return undefined;
|
|
|
|
+ }
|
|
let sse: SourceStaffEntry = voiceEntries[0].ParentSourceStaffEntry;
|
|
let sse: SourceStaffEntry = voiceEntries[0].ParentSourceStaffEntry;
|
|
- let graphicalMeasure: StaffMeasure = this.SourceToGraphicalMeasureLinks[sse.VerticalContainerParent.ParentMeasure][sse.ParentStaff.IdInMusicSheet];
|
|
|
|
|
|
+ let graphicalMeasure: StaffMeasure = this.SourceToGraphicalMeasureLinks[sse.VerticalContainerParent.ParentMeasure][sse.ParentStaff.idInMusicSheet];
|
|
return graphicalMeasure.findGraphicalStaffEntryFromTimestamp(sse.Timestamp);
|
|
return graphicalMeasure.findGraphicalStaffEntryFromTimestamp(sse.Timestamp);
|
|
}
|
|
}
|
|
|
|
+
|
|
public GetGraphicalNoteFromSourceNote(note: Note, containingGse: GraphicalStaffEntry): GraphicalNote {
|
|
public GetGraphicalNoteFromSourceNote(note: Note, containingGse: GraphicalStaffEntry): GraphicalNote {
|
|
for (let idx: number = 0, len: number = containingGse.Notes.length; idx < len; ++idx) {
|
|
for (let idx: number = 0, len: number = containingGse.Notes.length; idx < len; ++idx) {
|
|
let graphicalNotes: GraphicalNote[] = containingGse.Notes[idx];
|
|
let graphicalNotes: GraphicalNote[] = containingGse.Notes[idx];
|
|
for (let idx2: number = 0, len2: number = graphicalNotes.length; idx2 < len2; ++idx2) {
|
|
for (let idx2: number = 0, len2: number = graphicalNotes.length; idx2 < len2; ++idx2) {
|
|
let graphicalNote: GraphicalNote = graphicalNotes[idx2];
|
|
let graphicalNote: GraphicalNote = graphicalNotes[idx2];
|
|
- if (graphicalNote.SourceNote === note)
|
|
|
|
|
|
+ if (graphicalNote.SourceNote === note) {
|
|
return graphicalNote;
|
|
return graphicalNote;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return undefined;
|
|
return undefined;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
export class SystemImageProperties {
|
|
export class SystemImageProperties {
|
|
- public PositionInPixels: PointF_2D;
|
|
|
|
- public SystemImageId: number;
|
|
|
|
- public System: MusicSystem;
|
|
|
|
-}
|
|
|
|
|
|
+ public positionInPixels: PointF2D;
|
|
|
|
+ public systemImageId: number;
|
|
|
|
+ public system: MusicSystem;
|
|
|
|
+}
|