GraphicalMusicPage.ts 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. /**
  36. * This method calculates the absolute Position of each GraphicalMusicPage according to a given placement
  37. * @param pageIndex
  38. * @param rules
  39. * @returns {PointF2D}
  40. */
  41. public setMusicPageAbsolutePosition(pageIndex: number, rules: EngravingRules): PointF2D {
  42. return new PointF2D(0.0, 0.0);
  43. // use this code if pages are rendered on only one canvas:
  44. // if (rules.PagePlacement === PagePlacementEnum.Down) {
  45. // return new PointF2D(0.0, pageIndex * rules.PageHeight);
  46. // } else if (rules.PagePlacement === PagePlacementEnum.Right) {
  47. // return new PointF2D(pageIndex * this.parent.ParentMusicSheet.pageWidth, 0.0);
  48. // } else {
  49. // // placement RightDown
  50. // if (pageIndex % 2 === 0) {
  51. // if (pageIndex === 0) {
  52. // return new PointF2D(0.0, pageIndex * rules.PageHeight);
  53. // } else {
  54. // return new PointF2D(0.0, (pageIndex - 1) * rules.PageHeight);
  55. // }
  56. // } else {
  57. // if (pageIndex === 1) {
  58. // return new PointF2D(this.parent.ParentMusicSheet.pageWidth, (pageIndex - 1) * rules.PageHeight);
  59. // } else {
  60. // return new PointF2D(this.parent.ParentMusicSheet.pageWidth, (pageIndex - 2) * rules.PageHeight);
  61. // }
  62. // }
  63. // }
  64. }
  65. }
  66. export enum PagePlacementEnum {
  67. Down,
  68. Right,
  69. RightDown
  70. }