LEFT | RIGHT |
1 /* | 1 /* |
2 This file is part of LilyPond, the GNU music typesetter. | 2 This file is part of LilyPond, the GNU music typesetter. |
3 | 3 |
4 Copyright (C) 1997--2012 Han-Wen Nienhuys <hanwen@xs4all.nl> | 4 Copyright (C) 1997--2012 Han-Wen Nienhuys <hanwen@xs4all.nl> |
5 | 5 |
6 LilyPond is free software: you can redistribute it and/or modify | 6 LilyPond is free software: you can redistribute it and/or modify |
7 it under the terms of the GNU General Public License as published by | 7 it under the terms of the GNU General Public License as published by |
8 the Free Software Foundation, either version 3 of the License, or | 8 the Free Software Foundation, either version 3 of the License, or |
9 (at your option) any later version. | 9 (at your option) any later version. |
10 | 10 |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 if (dir != CENTER) | 353 if (dir != CENTER) |
354 { | 354 { |
355 Grob *stem = unsmob_grob (head_down->get_object ("stem")); | 355 Grob *stem = unsmob_grob (head_down->get_object ("stem")); |
356 extract_grob_set (stem, "note-heads", heads); | 356 extract_grob_set (stem, "note-heads", heads); |
357 for (vsize i = 0; i < heads.size (); i++) | 357 for (vsize i = 0; i < heads.size (); i++) |
358 unsmob_grob (heads[i]->get_object ("dot")) | 358 unsmob_grob (heads[i]->get_object ("dot")) |
359 ->set_property ("direction", scm_from_int (dir)); | 359 ->set_property ("direction", scm_from_int (dir)); |
360 } | 360 } |
361 } | 361 } |
362 | 362 |
363 for(UP_and_DOWN(d)) | 363 for (UP_and_DOWN (d)) |
364 { | 364 { |
365 for (vsize i = 0; i < clash_groups[d].size (); i++) | 365 for (vsize i = 0; i < clash_groups[d].size (); i++) |
366 (*offsets)[d][i] += d * shift_amount; | 366 (*offsets)[d][i] += d * shift_amount; |
367 } | 367 } |
368 } | 368 } |
369 | 369 |
370 MAKE_SCHEME_CALLBACK (Note_collision_interface, calc_positioning_done, 1) | 370 MAKE_SCHEME_CALLBACK (Note_collision_interface, calc_positioning_done, 1) |
371 SCM | 371 SCM |
372 Note_collision_interface::calc_positioning_done (SCM smob) | 372 Note_collision_interface::calc_positioning_done (SCM smob) |
373 { | 373 { |
374 Grob *me = unsmob_grob (smob); | 374 Grob *me = unsmob_grob (smob); |
375 me->set_property ("positioning-done", SCM_BOOL_T); | 375 me->set_property ("positioning-done", SCM_BOOL_T); |
376 | 376 |
377 Drul_array<vector<Grob *> > clash_groups = get_clash_groups (me); | 377 Drul_array<vector<Grob *> > clash_groups = get_clash_groups (me); |
378 | 378 |
379 for(UP_and_DOWN(d)) | 379 for (UP_and_DOWN (d)) |
380 { | 380 { |
381 for (vsize i = clash_groups[d].size (); i--;) | 381 for (vsize i = clash_groups[d].size (); i--;) |
382 { | 382 { |
383 /* | 383 /* |
384 Trigger positioning | 384 Trigger positioning |
385 */ | 385 */ |
386 clash_groups[d][i]->extent (me, X_AXIS); | 386 clash_groups[d][i]->extent (me, X_AXIS); |
387 } | 387 } |
388 } | 388 } |
389 | 389 |
390 SCM autos (automatic_shift (me, clash_groups)); | 390 SCM autos (automatic_shift (me, clash_groups)); |
391 SCM hand (forced_shift (me)); | 391 SCM hand (forced_shift (me)); |
392 | 392 |
393 Real wid = 0.0; | 393 Real wid = 0.0; |
394 for(UP_and_DOWN(d)) | 394 for (UP_and_DOWN (d)) |
395 { | 395 { |
396 if (clash_groups[d].size ()) | 396 if (clash_groups[d].size ()) |
397 { | 397 { |
398 Grob *h = clash_groups[d][0]; | 398 Grob *h = clash_groups[d][0]; |
399 Grob *fh = Note_column::first_head (h); | 399 Grob *fh = Note_column::first_head (h); |
400 if (fh) | 400 if (fh) |
401 wid = fh->extent (h, X_AXIS).length (); | 401 wid = fh->extent (h, X_AXIS).length (); |
402 } | 402 } |
403 } | 403 } |
404 | 404 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
448 Grob *se = elements[i]; | 448 Grob *se = elements[i]; |
449 if (Note_column::has_interface (se)) | 449 if (Note_column::has_interface (se)) |
450 { | 450 { |
451 if (!Note_column::dir (se)) | 451 if (!Note_column::dir (se)) |
452 se->programming_error ("note-column has no direction"); | 452 se->programming_error ("note-column has no direction"); |
453 else | 453 else |
454 clash_groups[Note_column::dir (se)].push_back (se); | 454 clash_groups[Note_column::dir (se)].push_back (se); |
455 } | 455 } |
456 } | 456 } |
457 | 457 |
458 for(UP_and_DOWN(d)) | 458 for (UP_and_DOWN (d)) |
459 { | 459 { |
460 vector<Grob *> &clashes (clash_groups[d]); | 460 vector<Grob *> &clashes (clash_groups[d]); |
461 vector_sort (clashes, Note_column::shift_less); | 461 vector_sort (clashes, Note_column::shift_less); |
462 } | 462 } |
463 | 463 |
464 return clash_groups; | 464 return clash_groups; |
465 } | 465 } |
466 | 466 |
467 /* | 467 /* |
468 This complicated routine moves note columns around horizontally to | 468 This complicated routine moves note columns around horizontally to |
469 ensure that notes don't clash. | 469 ensure that notes don't clash. |
470 */ | 470 */ |
471 SCM | 471 SCM |
472 Note_collision_interface::automatic_shift (Grob *me, | 472 Note_collision_interface::automatic_shift (Grob *me, |
473 Drul_array<vector<Grob *> > clash_gro
ups) | 473 Drul_array<vector<Grob *> > clash_gro
ups) |
474 { | 474 { |
475 Drul_array < vector<int> > shifts; | 475 Drul_array < vector<int> > shifts; |
476 SCM tups = SCM_EOL; | 476 SCM tups = SCM_EOL; |
477 | 477 |
478 for(UP_and_DOWN(d)) | 478 for (UP_and_DOWN (d)) |
479 { | 479 { |
480 vector<int> &shift (shifts[d]); | 480 vector<int> &shift (shifts[d]); |
481 vector<Grob *> &clashes (clash_groups[d]); | 481 vector<Grob *> &clashes (clash_groups[d]); |
482 | 482 |
483 for (vsize i = 0; i < clashes.size (); i++) | 483 for (vsize i = 0; i < clashes.size (); i++) |
484 { | 484 { |
485 SCM sh | 485 SCM sh |
486 = clashes[i]->get_property ("horizontal-shift"); | 486 = clashes[i]->get_property ("horizontal-shift"); |
487 | 487 |
488 if (scm_is_number (sh)) | 488 if (scm_is_number (sh)) |
489 shift.push_back (scm_to_int (sh)); | 489 shift.push_back (scm_to_int (sh)); |
490 else | 490 else |
491 shift.push_back (0); | 491 shift.push_back (0); |
492 } | 492 } |
493 | 493 |
494 for (vsize i = 1; i < shift.size (); i++) | 494 for (vsize i = 1; i < shift.size (); i++) |
495 { | 495 { |
496 if (shift[i - 1] == shift[i]) | 496 if (shift[i - 1] == shift[i]) |
497 { | 497 { |
498 clashes[0]->warning (_ ("ignoring too many clashing note columns")
); | 498 clashes[0]->warning (_ ("ignoring too many clashing note columns")
); |
499 return tups; | 499 return tups; |
500 } | 500 } |
501 } | 501 } |
502 } | 502 } |
503 | 503 |
504 Drul_array<vector<Slice> > extents; | 504 Drul_array<vector<Slice> > extents; |
505 Drul_array<vector<Real> > offsets; | 505 Drul_array<vector<Real> > offsets; |
506 for(UP_and_DOWN(d)) | 506 for (UP_and_DOWN (d)) |
507 { | 507 { |
508 for (vsize i = 0; i < clash_groups[d].size (); i++) | 508 for (vsize i = 0; i < clash_groups[d].size (); i++) |
509 { | 509 { |
510 Slice s (Note_column::head_positions_interval (clash_groups[d][i])); | 510 Slice s (Note_column::head_positions_interval (clash_groups[d][i])); |
511 s[LEFT]--; | 511 s[LEFT]--; |
512 s[RIGHT]++; | 512 s[RIGHT]++; |
513 extents[d].push_back (s); | 513 extents[d].push_back (s); |
514 offsets[d].push_back (d * 0.5 * i); | 514 offsets[d].push_back (d * 0.5 * i); |
515 } | 515 } |
516 } | 516 } |
517 | 517 |
518 /* | 518 /* |
519 * do horizontal shifts of each direction | 519 * do horizontal shifts of each direction |
520 * | 520 * |
521 * | | 521 * | |
522 * x|| | 522 * x|| |
523 * x|| | 523 * x|| |
524 * x| | 524 * x| |
525 */ | 525 */ |
526 | 526 |
527 for(UP_and_DOWN(d)) | 527 for (UP_and_DOWN (d)) |
528 { | 528 { |
529 for (vsize i = 1; i < clash_groups[d].size (); i++) | 529 for (vsize i = 1; i < clash_groups[d].size (); i++) |
530 { | 530 { |
531 Slice prev = extents[d][i - 1]; | 531 Slice prev = extents[d][i - 1]; |
532 prev.intersect (extents[d][i]); | 532 prev.intersect (extents[d][i]); |
533 if (prev.length () > 0 | 533 if (prev.length () > 0 |
534 || (extents[-d].size () && d * (extents[d][i][-d] - extents[-d][0]
[d]) < 0)) | 534 || (extents[-d].size () && d * (extents[d][i][-d] - extents[-d][0]
[d]) < 0)) |
535 for (vsize j = i; j < clash_groups[d].size (); j++) | 535 for (vsize j = i; j < clash_groups[d].size (); j++) |
536 offsets[d][j] += d * 0.5; | 536 offsets[d][j] += d * 0.5; |
537 } | 537 } |
(...skipping 14 matching lines...) Expand all Loading... |
552 Side_position_interface::add_support (dc, stem); | 552 Side_position_interface::add_support (dc, stem); |
553 } | 553 } |
554 } | 554 } |
555 | 555 |
556 /* | 556 /* |
557 Check if chords are meshing | 557 Check if chords are meshing |
558 */ | 558 */ |
559 | 559 |
560 check_meshing_chords (me, &offsets, extents, clash_groups); | 560 check_meshing_chords (me, &offsets, extents, clash_groups); |
561 | 561 |
562 for(UP_and_DOWN(d)) | 562 for (UP_and_DOWN (d)) |
563 { | 563 { |
564 for (vsize i = 0; i < clash_groups[d].size (); i++) | 564 for (vsize i = 0; i < clash_groups[d].size (); i++) |
565 tups = scm_cons (scm_cons (clash_groups[d][i]->self_scm (), | 565 tups = scm_cons (scm_cons (clash_groups[d][i]->self_scm (), |
566 scm_from_double (offsets[d][i])), | 566 scm_from_double (offsets[d][i])), |
567 tups); | 567 tups); |
568 } | 568 } |
569 | 569 |
570 return tups; | 570 return tups; |
571 } | 571 } |
572 | 572 |
(...skipping 28 matching lines...) Expand all Loading... |
601 " the interesting properties are to be set in" | 601 " the interesting properties are to be set in" |
602 " @ref{note-column-interface}: these are @code{force-hshift}" | 602 " @ref{note-column-interface}: these are @code{force-hshift}" |
603 " and @code{horizontal-shift}.", | 603 " and @code{horizontal-shift}.", |
604 | 604 |
605 /* properties */ | 605 /* properties */ |
606 "merge-differently-dotted " | 606 "merge-differently-dotted " |
607 "merge-differently-headed " | 607 "merge-differently-headed " |
608 "positioning-done " | 608 "positioning-done " |
609 "prefer-dotted-right " | 609 "prefer-dotted-right " |
610 ); | 610 ); |
LEFT | RIGHT |