MusicSheetDrawer.ts 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513
  1. import {EngravingRules} from "./EngravingRules";
  2. import {ITextMeasurer} from "../Interfaces/ITextMeasurer";
  3. import {GraphicalMusicSheet} from "./GraphicalMusicSheet";
  4. import {BoundingBox} from "./BoundingBox";
  5. import {GraphicalLayers, OutlineAndFillStyleEnum} from "./DrawingEnums";
  6. import {DrawingParameters} from "./DrawingParameters";
  7. import {GraphicalLine} from "./GraphicalLine";
  8. import {RectangleF2D} from "../../Common/DataObjects/RectangleF2D";
  9. import {PointF2D} from "../../Common/DataObjects/PointF2D";
  10. import {GraphicalRectangle} from "./GraphicalRectangle";
  11. import {GraphicalLabel} from "./GraphicalLabel";
  12. import {Label} from "../Label";
  13. import {TextAlignment} from "../../Common/Enums/TextAlignment";
  14. import {ArgumentOutOfRangeException} from "../Exceptions";
  15. import {SelectionStartSymbol} from "./SelectionStartSymbol";
  16. import {SelectionEndSymbol} from "./SelectionEndSymbol";
  17. import {MusicSystem} from "./MusicSystem";
  18. import {StaffMeasure} from "./StaffMeasure";
  19. import {StaffLine} from "./StaffLine";
  20. import {SystemLine} from "./SystemLine";
  21. import {MusicSymbol} from "./MusicSymbol";
  22. import {GraphicalMusicPage} from "./GraphicalMusicPage";
  23. import {Instrument} from "../Instrument";
  24. import {MusicSymbolDrawingStyle, PhonicScoreModes} from "./DrawingMode";
  25. import {GraphicalOctaveShift} from "./GraphicalOctaveShift";
  26. import {GraphicalObject} from "./GraphicalObject";
  27. /**
  28. * Draw a [[GraphicalMusicSheet]] (through the .drawSheet method)
  29. *
  30. * The drawing is implemented with a top-down approach, starting from a music sheet, going through pages, systems, staffs...
  31. * ... and ending in notes, beams, accidentals and other symbols.
  32. * It's worth to say, that this class just draws the symbols and graphical elements, using the positions that have been computed before.
  33. * But in any case, some of these previous positioning algorithms need the sizes of the concrete symbols (NoteHeads, sharps, flats, keys...).
  34. * Therefore, there are some static functions on the 'Bounding Boxes' section used to compute these symbol boxes at the
  35. * beginning for the later use in positioning algorithms.
  36. *
  37. * This class also includes the resizing and positioning of the symbols due to user interaction like zooming or panning.
  38. */
  39. export abstract class MusicSheetDrawer {
  40. public drawingParameters: DrawingParameters = new DrawingParameters();
  41. public splitScreenLineColor: number;
  42. public midiPlaybackAvailable: boolean;
  43. protected rules: EngravingRules;
  44. protected graphicalMusicSheet: GraphicalMusicSheet;
  45. protected textMeasurer: ITextMeasurer;
  46. private phonicScoreMode: PhonicScoreModes = PhonicScoreModes.Manual;
  47. constructor(textMeasurer: ITextMeasurer,
  48. isPreviewImageDrawer: boolean = false) {
  49. this.textMeasurer = textMeasurer;
  50. this.splitScreenLineColor = -1;
  51. if (isPreviewImageDrawer) {
  52. this.drawingParameters.setForThumbmail();
  53. } else {
  54. this.drawingParameters.setForAllOn();
  55. }
  56. }
  57. public set Mode(value: PhonicScoreModes) {
  58. this.phonicScoreMode = value;
  59. }
  60. public drawSheet(graphicalMusicSheet: GraphicalMusicSheet): void {
  61. this.graphicalMusicSheet = graphicalMusicSheet;
  62. this.rules = graphicalMusicSheet.ParentMusicSheet.Rules;
  63. this.drawSplitScreenLine();
  64. if (this.drawingParameters.drawCursors) {
  65. for (let line of graphicalMusicSheet.Cursors) {
  66. let psi: BoundingBox = new BoundingBox(line);
  67. psi.AbsolutePosition = line.Start;
  68. psi.BorderBottom = line.End.y - line.Start.y;
  69. psi.BorderRight = line.Width / 2.0;
  70. psi.BorderLeft = -line.Width / 2.0;
  71. if (this.isVisible(psi)) {
  72. this.drawLineAsVerticalRectangle(line, <number>GraphicalLayers.Cursor);
  73. }
  74. }
  75. }
  76. // Draw the vertical ScrollIndicator
  77. if (this.drawingParameters.drawScrollIndicator) {
  78. this.drawScrollIndicator();
  79. }
  80. // Draw all the pages
  81. for (let page of this.graphicalMusicSheet.MusicPages) {
  82. this.drawPage(page);
  83. }
  84. }
  85. public drawLineAsHorizontalRectangle(line: GraphicalLine, layer: number): void {
  86. let rectangle: RectangleF2D = new RectangleF2D(line.Start.x, line.End.y - line.Width / 2, line.End.x - line.Start.x, line.Width);
  87. rectangle = this.applyScreenTransformationForRect(rectangle);
  88. this.renderRectangle(rectangle, layer, line.styleId);
  89. }
  90. public drawLineAsVerticalRectangle(line: GraphicalLine, layer: number): void {
  91. let lineStart: PointF2D = line.Start;
  92. let lineWidth: number = line.Width;
  93. let rectangle: RectangleF2D = new RectangleF2D(lineStart.x - lineWidth / 2, lineStart.y, lineWidth, line.End.y - lineStart.y);
  94. rectangle = this.applyScreenTransformationForRect(rectangle);
  95. this.renderRectangle(rectangle, layer, line.styleId);
  96. }
  97. public drawLineAsHorizontalRectangleWithOffset(line: GraphicalLine, offset: PointF2D, layer: number): void {
  98. let start: PointF2D = new PointF2D(line.Start.x + offset.x, line.Start.y + offset.y);
  99. let end: PointF2D = new PointF2D(line.End.x + offset.x, line.End.y + offset.y);
  100. let width: number = line.Width;
  101. let rectangle: RectangleF2D = new RectangleF2D(start.x, end.y - width / 2, end.x - start.x, width);
  102. rectangle = this.applyScreenTransformationForRect(rectangle);
  103. this.renderRectangle(rectangle, layer, line.styleId);
  104. }
  105. public drawLineAsVerticalRectangleWithOffset(line: GraphicalLine, offset: PointF2D, layer: number): void {
  106. let start: PointF2D = new PointF2D(line.Start.x + offset.x, line.Start.y + offset.y);
  107. let end: PointF2D = new PointF2D(line.End.x + offset.x, line.End.y + offset.y);
  108. let width: number = line.Width;
  109. let rectangle: RectangleF2D = new RectangleF2D(start.x, start.y, width, end.y - start.y);
  110. rectangle = this.applyScreenTransformationForRect(rectangle);
  111. this.renderRectangle(rectangle, layer, line.styleId);
  112. }
  113. public drawRectangle(rect: GraphicalRectangle, layer: number): void {
  114. let psi: BoundingBox = rect.PositionAndShape;
  115. let rectangle: RectangleF2D = new RectangleF2D(psi.AbsolutePosition.x, psi.AbsolutePosition.y, psi.BorderRight, psi.BorderBottom);
  116. rectangle = this.applyScreenTransformationForRect(rectangle);
  117. this.renderRectangle(rectangle, layer, <number>rect.style);
  118. }
  119. public calculatePixelDistance(unitDistance: number): number {
  120. throw new Error("not implemented");
  121. }
  122. public drawLabel(graphicalLabel: GraphicalLabel, layer: number): void {
  123. if (!this.isVisible(graphicalLabel.PositionAndShape)) {
  124. return;
  125. }
  126. let label: Label = graphicalLabel.Label;
  127. if (label.text.trim() === "") {
  128. return;
  129. }
  130. let screenPosition: PointF2D = this.applyScreenTransformation(graphicalLabel.PositionAndShape.AbsolutePosition);
  131. let heightInPixel: number = this.calculatePixelDistance(label.fontHeight);
  132. let widthInPixel: number = heightInPixel * this.textMeasurer.computeTextWidthToHeightRatio(label.text, label.font, label.fontStyle);
  133. let bitmapWidth: number = <number>Math.ceil(widthInPixel);
  134. let bitmapHeight: number = <number>Math.ceil(heightInPixel * 1.2);
  135. switch (label.textAlignment) {
  136. case TextAlignment.LeftTop:
  137. break;
  138. case TextAlignment.LeftCenter:
  139. screenPosition.y -= <number>bitmapHeight / 2;
  140. break;
  141. case TextAlignment.LeftBottom:
  142. screenPosition.y -= bitmapHeight;
  143. break;
  144. case TextAlignment.CenterTop:
  145. screenPosition.x -= <number>bitmapWidth / 2;
  146. break;
  147. case TextAlignment.CenterCenter:
  148. screenPosition.x -= <number>bitmapWidth / 2;
  149. screenPosition.y -= <number>bitmapHeight / 2;
  150. break;
  151. case TextAlignment.CenterBottom:
  152. screenPosition.x -= <number>bitmapWidth / 2;
  153. screenPosition.y -= bitmapHeight;
  154. break;
  155. case TextAlignment.RightTop:
  156. screenPosition.x -= bitmapWidth;
  157. break;
  158. case TextAlignment.RightCenter:
  159. screenPosition.x -= bitmapWidth;
  160. screenPosition.y -= <number>bitmapHeight / 2;
  161. break;
  162. case TextAlignment.RightBottom:
  163. screenPosition.x -= bitmapWidth;
  164. screenPosition.y -= bitmapHeight;
  165. break;
  166. default:
  167. throw new ArgumentOutOfRangeException("");
  168. }
  169. this.renderLabel(graphicalLabel, layer, bitmapWidth, bitmapHeight, heightInPixel, screenPosition);
  170. }
  171. protected applyScreenTransformation(point: PointF2D): PointF2D {
  172. throw new Error("not implemented");
  173. }
  174. protected applyScreenTransformations(points: PointF2D[]): PointF2D[] {
  175. let transformedPoints: PointF2D[] = [];
  176. for (let point of points) {
  177. transformedPoints.push(this.applyScreenTransformation(point));
  178. }
  179. return transformedPoints;
  180. }
  181. protected applyScreenTransformationForRect(rectangle: RectangleF2D): RectangleF2D {
  182. throw new Error("not implemented");
  183. }
  184. protected drawSplitScreenLine(): void {
  185. // empty
  186. }
  187. protected renderRectangle(rectangle: RectangleF2D, layer: number, styleId: number): void {
  188. throw new Error("not implemented");
  189. }
  190. protected drawScrollIndicator(): void {
  191. // empty
  192. }
  193. protected drawSelectionStartSymbol(symbol: SelectionStartSymbol): void {
  194. // empty
  195. }
  196. protected drawSelectionEndSymbol(symbol: SelectionEndSymbol): void {
  197. // empty
  198. }
  199. protected renderLabel(graphicalLabel: GraphicalLabel, layer: number, bitmapWidth: number,
  200. bitmapHeight: number, heightInPixel: number, screenPosition: PointF2D): void {
  201. throw new Error("not implemented");
  202. }
  203. protected renderSystemToScreen(system: MusicSystem, systemBoundingBoxInPixels: RectangleF2D,
  204. absBoundingRectWithMargin: RectangleF2D): void {
  205. // empty
  206. }
  207. protected drawMeasure(measure: StaffMeasure): void {
  208. throw new Error("not implemented");
  209. }
  210. protected drawSkyLine(staffLine: StaffLine): void {
  211. // empty
  212. }
  213. protected drawBottomLine(staffLine: StaffLine): void {
  214. // empty
  215. }
  216. protected drawInstrumentBracket(bracket: GraphicalObject, system: MusicSystem): void {
  217. // empty
  218. }
  219. protected drawGroupBracket(bracket: GraphicalObject, system: MusicSystem): void {
  220. // empty
  221. }
  222. protected isVisible(psi: BoundingBox): boolean {
  223. return true;
  224. }
  225. protected drawMusicSystem(system: MusicSystem): void {
  226. let absBoundingRectWithMargin: RectangleF2D = this.getSystemAbsBoundingRect(system);
  227. let systemBoundingBoxInPixels: RectangleF2D = this.getSytemBoundingBoxInPixels(absBoundingRectWithMargin);
  228. this.drawMusicSystemComponents(system, systemBoundingBoxInPixels, absBoundingRectWithMargin);
  229. }
  230. protected getSytemBoundingBoxInPixels(absBoundingRectWithMargin: RectangleF2D): RectangleF2D {
  231. let systemBoundingBoxInPixels: RectangleF2D = this.applyScreenTransformationForRect(absBoundingRectWithMargin);
  232. systemBoundingBoxInPixels.x = Math.round(systemBoundingBoxInPixels.x);
  233. systemBoundingBoxInPixels.y = Math.round(systemBoundingBoxInPixels.y);
  234. return systemBoundingBoxInPixels;
  235. }
  236. protected getSystemAbsBoundingRect(system: MusicSystem): RectangleF2D {
  237. let relBoundingRect: RectangleF2D = system.PositionAndShape.BoundingRectangle;
  238. let absBoundingRectWithMargin: RectangleF2D = new RectangleF2D(
  239. system.PositionAndShape.AbsolutePosition.x + system.PositionAndShape.BorderLeft - 1,
  240. system.PositionAndShape.AbsolutePosition.y + system.PositionAndShape.BorderTop - 1,
  241. (relBoundingRect.width + 6), (relBoundingRect.height + 2)
  242. );
  243. return absBoundingRectWithMargin;
  244. }
  245. protected drawMusicSystemComponents(musicSystem: MusicSystem, systemBoundingBoxInPixels: RectangleF2D,
  246. absBoundingRectWithMargin: RectangleF2D): void {
  247. let selectStartSymb: SelectionStartSymbol = this.graphicalMusicSheet.SelectionStartSymbol;
  248. let selectEndSymb: SelectionEndSymbol = this.graphicalMusicSheet.SelectionEndSymbol;
  249. if (this.drawingParameters.drawSelectionStartSymbol) {
  250. if (selectStartSymb !== undefined && this.isVisible(selectStartSymb.PositionAndShape)) {
  251. this.drawSelectionStartSymbol(selectStartSymb);
  252. }
  253. }
  254. if (this.drawingParameters.drawSelectionEndSymbol) {
  255. if (selectEndSymb !== undefined && this.isVisible(selectEndSymb.PositionAndShape)) {
  256. this.drawSelectionEndSymbol(selectEndSymb);
  257. }
  258. }
  259. for (let staffLine of musicSystem.StaffLines) {
  260. this.drawStaffLine(staffLine);
  261. }
  262. for (let systemLine of musicSystem.SystemLines) {
  263. this.drawSystemLineObject(systemLine);
  264. }
  265. if (musicSystem === musicSystem.Parent.MusicSystems[0] && musicSystem.Parent === musicSystem.Parent.Parent.MusicPages[0]) {
  266. for (let label of musicSystem.Labels) {
  267. this.drawLabel(label, <number>GraphicalLayers.Notes);
  268. }
  269. }
  270. for (let bracket of musicSystem.InstrumentBrackets) {
  271. this.drawInstrumentBracket(bracket, musicSystem);
  272. }
  273. for (let bracket of musicSystem.GroupBrackets) {
  274. this.drawGroupBracket(bracket, musicSystem);
  275. }
  276. if (!this.leadSheet) {
  277. for (let measureNumberLabel of musicSystem.MeasureNumberLabels) {
  278. this.drawLabel(measureNumberLabel, <number>GraphicalLayers.Notes);
  279. }
  280. }
  281. for (let staffLine of musicSystem.StaffLines) {
  282. this.drawStaffLineSymbols(staffLine);
  283. }
  284. if (this.drawingParameters.drawMarkedAreas) {
  285. this.drawMarkedAreas(musicSystem);
  286. }
  287. if (this.drawingParameters.drawComments) {
  288. this.drawComment(musicSystem);
  289. }
  290. }
  291. protected activateSystemRendering(systemId: number, absBoundingRect: RectangleF2D,
  292. systemBoundingBoxInPixels: RectangleF2D, createNewImage: boolean): boolean {
  293. return true;
  294. }
  295. protected drawSystemLineObject(systemLine: SystemLine): void {
  296. // empty
  297. }
  298. protected drawStaffLine(staffLine: StaffLine): void {
  299. for (let measure of staffLine.Measures) {
  300. this.drawMeasure(measure);
  301. }
  302. }
  303. // protected drawSlur(slur: GraphicalSlur, abs: PointF2D): void {
  304. //
  305. // }
  306. protected drawOctaveShift(staffLine: StaffLine, graphicalOctaveShift: GraphicalOctaveShift): void {
  307. this.drawSymbol(graphicalOctaveShift.octaveSymbol, MusicSymbolDrawingStyle.Normal, graphicalOctaveShift.PositionAndShape.AbsolutePosition);
  308. let absolutePos: PointF2D = staffLine.PositionAndShape.AbsolutePosition;
  309. if (graphicalOctaveShift.dashesStart.x < graphicalOctaveShift.dashesEnd.x) {
  310. let horizontalLine: GraphicalLine = new GraphicalLine(graphicalOctaveShift.dashesStart, graphicalOctaveShift.dashesEnd,
  311. this.rules.OctaveShiftLineWidth);
  312. this.drawLineAsHorizontalRectangleWithOffset(horizontalLine, absolutePos, <number>GraphicalLayers.Notes);
  313. }
  314. if (!graphicalOctaveShift.endsOnDifferentStaffLine || graphicalOctaveShift.isSecondPart) {
  315. let verticalLine: GraphicalLine;
  316. let dashEnd: PointF2D = graphicalOctaveShift.dashesEnd;
  317. let octShiftVertLineLength: number = this.rules.OctaveShiftVerticalLineLength;
  318. let octShiftLineWidth: number = this.rules.OctaveShiftLineWidth;
  319. if (graphicalOctaveShift.octaveSymbol === MusicSymbol.VA8 || graphicalOctaveShift.octaveSymbol === MusicSymbol.MA15) {
  320. verticalLine = new GraphicalLine(dashEnd, new PointF2D(dashEnd.x, dashEnd.y + octShiftVertLineLength), octShiftLineWidth);
  321. } else {
  322. verticalLine = new GraphicalLine(new PointF2D(dashEnd.x, dashEnd.y - octShiftVertLineLength), dashEnd, octShiftLineWidth);
  323. }
  324. this.drawLineAsVerticalRectangleWithOffset(verticalLine, absolutePos, <number>GraphicalLayers.Notes);
  325. }
  326. }
  327. protected drawStaffLines(staffLine: StaffLine): void {
  328. if (staffLine.StaffLines !== undefined) {
  329. let position: PointF2D = staffLine.PositionAndShape.AbsolutePosition;
  330. for (let i: number = 0; i < 5; i++) {
  331. this.drawLineAsHorizontalRectangleWithOffset(staffLine.StaffLines[i], position, <number>GraphicalLayers.Notes);
  332. }
  333. }
  334. }
  335. // protected drawEnding(ending: GraphicalRepetitionEnding, absolutePosition: PointF2D): void {
  336. // if (undefined !== ending.Left)
  337. // drawLineAsVerticalRectangle(ending.Left, absolutePosition, <number>GraphicalLayers.Notes);
  338. // this.drawLineAsHorizontalRectangle(ending.Top, absolutePosition, <number>GraphicalLayers.Notes);
  339. // if (undefined !== ending.Right)
  340. // drawLineAsVerticalRectangle(ending.Right, absolutePosition, <number>GraphicalLayers.Notes);
  341. // this.drawLabel(ending.Label, <number>GraphicalLayers.Notes);
  342. // }
  343. // protected drawInstantaniousDynamic(expression: GraphicalInstantaniousDynamicExpression): void {
  344. // expression.ExpressionSymbols.forEach(function (expressionSymbol) {
  345. // let position: PointF2D = expressionSymbol.PositionAndShape.AbsolutePosition;
  346. // let symbol: MusicSymbol = expressionSymbol.GetSymbol;
  347. // drawSymbol(symbol, MusicSymbolDrawingStyle.Normal, position);
  348. // });
  349. // }
  350. // protected drawContinuousDynamic(expression: GraphicalContinuousDynamicExpression,
  351. // absolute: PointF2D): void {
  352. // throw new Error("not implemented");
  353. // }
  354. protected drawSymbol(symbol: MusicSymbol, symbolStyle: MusicSymbolDrawingStyle, position: PointF2D,
  355. scalingFactor: number = 1, layer: number = <number>GraphicalLayers.Notes): void {
  356. //empty
  357. }
  358. protected get leadSheet(): boolean {
  359. return this.graphicalMusicSheet.LeadSheet;
  360. }
  361. protected set leadSheet(value: boolean) {
  362. this.graphicalMusicSheet.LeadSheet = value;
  363. }
  364. private drawPage(page: GraphicalMusicPage): void {
  365. if (!this.isVisible(page.PositionAndShape)) {
  366. return;
  367. }
  368. for (let system of page.MusicSystems) {
  369. if (this.isVisible(system.PositionAndShape)) {
  370. this.drawMusicSystem(system);
  371. }
  372. }
  373. if (page === page.Parent.MusicPages[0]) {
  374. for (let label of page.Labels) {
  375. this.drawLabel(label, <number>GraphicalLayers.Notes);
  376. }
  377. }
  378. }
  379. private drawMarkedAreas(system: MusicSystem): void {
  380. for (let markedArea of system.GraphicalMarkedAreas) {
  381. if (markedArea !== undefined) {
  382. if (markedArea.systemRectangle !== undefined) {
  383. this.drawRectangle(markedArea.systemRectangle, <number>GraphicalLayers.Background);
  384. }
  385. if (markedArea.settings !== undefined) {
  386. this.drawLabel(markedArea.settings, <number>GraphicalLayers.Comment);
  387. }
  388. if (markedArea.labelRectangle !== undefined) {
  389. this.drawRectangle(markedArea.labelRectangle, <number>GraphicalLayers.Background);
  390. }
  391. if (markedArea.label !== undefined) {
  392. this.drawLabel(markedArea.label, <number>GraphicalLayers.Comment);
  393. }
  394. }
  395. }
  396. }
  397. private drawComment(system: MusicSystem): void {
  398. for (let comment of system.GraphicalComments) {
  399. if (comment !== undefined) {
  400. if (comment.settings !== undefined) {
  401. this.drawLabel(comment.settings, <number>GraphicalLayers.Comment);
  402. }
  403. if (comment.label !== undefined) {
  404. this.drawLabel(comment.label, <number>GraphicalLayers.Comment);
  405. }
  406. }
  407. }
  408. }
  409. private drawStaffLineSymbols(staffLine: StaffLine): void {
  410. let parentInst: Instrument = staffLine.ParentStaff.ParentInstrument;
  411. let absX: number = staffLine.PositionAndShape.AbsolutePosition.x;
  412. let absY: number = staffLine.PositionAndShape.AbsolutePosition.y + 2;
  413. let borderRight: number = staffLine.PositionAndShape.BorderRight;
  414. if (parentInst.highlight && this.drawingParameters.drawHighlights) {
  415. this.drawLineAsHorizontalRectangle(
  416. new GraphicalLine(
  417. new PointF2D(absX, absY),
  418. new PointF2D(absX + borderRight, absY),
  419. 4,
  420. OutlineAndFillStyleEnum.Highlighted
  421. ),
  422. <number>GraphicalLayers.Highlight
  423. );
  424. }
  425. let style: MusicSymbolDrawingStyle = MusicSymbolDrawingStyle.Disabled;
  426. let symbol: MusicSymbol = MusicSymbol.PLAY;
  427. let drawSymbols: boolean = this.drawingParameters.drawActivitySymbols;
  428. switch (this.phonicScoreMode) {
  429. case PhonicScoreModes.Midi:
  430. symbol = MusicSymbol.PLAY;
  431. if (this.midiPlaybackAvailable && staffLine.ParentStaff.audible) {
  432. style = MusicSymbolDrawingStyle.PlaybackSymbols;
  433. }
  434. break;
  435. case PhonicScoreModes.Following:
  436. symbol = MusicSymbol.MIC;
  437. if (staffLine.ParentStaff.following) {
  438. style = MusicSymbolDrawingStyle.FollowSymbols;
  439. }
  440. break;
  441. default:
  442. drawSymbols = false;
  443. break;
  444. }
  445. if (drawSymbols) {
  446. let p: PointF2D = new PointF2D(absX + borderRight + 2, absY);
  447. this.drawSymbol(symbol, style, p);
  448. }
  449. if (this.drawingParameters.drawErrors) {
  450. for (let measure of staffLine.Measures) {
  451. let measurePSI: BoundingBox = measure.PositionAndShape;
  452. let absXPSI: number = measurePSI.AbsolutePosition.x;
  453. let absYPSI: number = measurePSI.AbsolutePosition.y + 2;
  454. if (measure.hasError && this.graphicalMusicSheet.ParentMusicSheet.DrawErroneousMeasures) {
  455. this.drawLineAsHorizontalRectangle(
  456. new GraphicalLine(
  457. new PointF2D(absXPSI, absYPSI),
  458. new PointF2D(absXPSI + measurePSI.BorderRight, absYPSI),
  459. 4,
  460. OutlineAndFillStyleEnum.ErrorUnderlay
  461. ),
  462. <number>GraphicalLayers.MeasureError
  463. );
  464. }
  465. }
  466. }
  467. }
  468. }