GraphicalMusicPage.ts 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. private pageNumber: number;
  13. constructor(parent: GraphicalMusicSheet) {
  14. super();
  15. this.parent = parent;
  16. this.boundingBox = new BoundingBox(this, undefined);
  17. }
  18. public get MusicSystems(): MusicSystem[] {
  19. return this.musicSystems;
  20. }
  21. public set MusicSystems(value: MusicSystem[]) {
  22. this.musicSystems = value;
  23. }
  24. public get Labels(): GraphicalLabel[] {
  25. return this.labels;
  26. }
  27. public set Labels(value: GraphicalLabel[]) {
  28. this.labels = value;
  29. }
  30. public get Parent(): GraphicalMusicSheet {
  31. return this.parent;
  32. }
  33. public set Parent(value: GraphicalMusicSheet) {
  34. this.parent = value;
  35. }
  36. public get PageNumber(): number {
  37. return this.pageNumber;
  38. }
  39. public set PageNumber(value: number) {
  40. this.pageNumber = value;
  41. }
  42. /**
  43. * This method calculates the absolute Position of each GraphicalMusicPage according to a given placement
  44. * @param pageIndex
  45. * @param rules
  46. * @returns {PointF2D}
  47. */
  48. public setMusicPageAbsolutePosition(pageIndex: number, rules: EngravingRules): PointF2D {
  49. return new PointF2D(0.0, 0.0);
  50. // use this code if pages are rendered on only one canvas:
  51. // if (rules.PagePlacement === PagePlacementEnum.Down) {
  52. // return new PointF2D(0.0, pageIndex * rules.PageHeight);
  53. // } else if (rules.PagePlacement === PagePlacementEnum.Right) {
  54. // return new PointF2D(pageIndex * this.parent.ParentMusicSheet.pageWidth, 0.0);
  55. // } else {
  56. // // placement RightDown
  57. // if (pageIndex % 2 === 0) {
  58. // if (pageIndex === 0) {
  59. // return new PointF2D(0.0, pageIndex * rules.PageHeight);
  60. // } else {
  61. // return new PointF2D(0.0, (pageIndex - 1) * rules.PageHeight);
  62. // }
  63. // } else {
  64. // if (pageIndex === 1) {
  65. // return new PointF2D(this.parent.ParentMusicSheet.pageWidth, (pageIndex - 1) * rules.PageHeight);
  66. // } else {
  67. // return new PointF2D(this.parent.ParentMusicSheet.pageWidth, (pageIndex - 2) * rules.PageHeight);
  68. // }
  69. // }
  70. // }
  71. }
  72. }
  73. export enum PagePlacementEnum {
  74. Down,
  75. Right,
  76. RightDown
  77. }