GraphicalMusicPage.ts 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import {BoundingBox} from "./BoundingBox";
  2. import {GraphicalObject} from "./GraphicalObject";
  3. import {GraphicalLabel} from "./GraphicalLabel";
  4. import {MusicSystem} from "./MusicSystem";
  5. import {EngravingRules} from "./EngravingRules";
  6. import {PointF2D} from "../../Common/DataObjects/PointF2D";
  7. import {GraphicalMusicSheet} from "./GraphicalMusicSheet";
  8. export class GraphicalMusicPage extends GraphicalObject {
  9. private musicSystems: MusicSystem[] = [];
  10. private labels: GraphicalLabel[] = [];
  11. private parent: GraphicalMusicSheet;
  12. constructor(parent: GraphicalMusicSheet) {
  13. super();
  14. this.parent = parent;
  15. this.boundingBox = new BoundingBox(this, undefined);
  16. }
  17. public get MusicSystems(): MusicSystem[] {
  18. return this.musicSystems;
  19. }
  20. public set MusicSystems(value: MusicSystem[]) {
  21. this.musicSystems = value;
  22. }
  23. public get Labels(): GraphicalLabel[] {
  24. return this.labels;
  25. }
  26. public set Labels(value: GraphicalLabel[]) {
  27. this.labels = value;
  28. }
  29. public get Parent(): GraphicalMusicSheet {
  30. return this.parent;
  31. }
  32. public set Parent(value: GraphicalMusicSheet) {
  33. this.parent = value;
  34. }
  35. public setMusicPageAbsolutePosition(pageIndex: number, rules: EngravingRules): PointF2D {
  36. if (rules.PagePlacement === PagePlacementEnum.Down) {
  37. return new PointF2D(0.0, pageIndex * rules.PageHeight);
  38. } else if (rules.PagePlacement === PagePlacementEnum.Right) {
  39. return new PointF2D(pageIndex * this.parent.ParentMusicSheet.pageWidth, 0.0);
  40. } else {
  41. if (pageIndex % 2 === 0) {
  42. if (pageIndex === 0) {
  43. return new PointF2D(0.0, pageIndex * rules.PageHeight);
  44. } else {
  45. return new PointF2D(0.0, (pageIndex - 1) * rules.PageHeight);
  46. }
  47. } else {
  48. if (pageIndex === 1) {
  49. return new PointF2D(this.parent.ParentMusicSheet.pageWidth, (pageIndex - 1) * rules.PageHeight);
  50. } else {
  51. return new PointF2D(this.parent.ParentMusicSheet.pageWidth, (pageIndex - 2) * rules.PageHeight);
  52. }
  53. }
  54. }
  55. }
  56. }
  57. export enum PagePlacementEnum {
  58. Down,
  59. Right,
  60. RightDown
  61. }