Finale PDK Framework 0.77
Power Up Your Finale Music Software
Loading...
Searching...
No Matches
ff_region.h
1/*
2 * File: ff_region.h
3 * Author: Jari Williamsson
4 *
5 * Created on den 7 november 2010, 13:52
6 */
7
8#ifndef FF_REGION_H
9#define FF_REGION_H
10
11
12class FCCell;
13class FCCells;
14
24class FCMusicRegion : public __FCBase
25{
26#ifndef DOXYGEN_SHOULD_IGNORE_THIS
27 EREGION _region;
28 EDOCID _documentid;
29
30 ECLIPFILETOKEN _clipfiletoken;
31#endif /* DOXYGEN_SHOULD_IGNORE_THIS */
32public:
33
34
35
41 {
43 REBARSTOP_NONE = REBAR_NO_STOP,
44
46 REBARSTOP_KEY = REBAR_STOP_KEYCHANGE,
47
49 REBARSTOP_TIME = REBAR_STOP_TIMECHANGE,
50
52 REBARSTOP_REGIONEND = REBAR_STOP_ENDOFREGION,
53
55 REBARSTOP_SPECIALBARLINE = REBAR_STOP_SPECIALBARLINE,
56
58 REBARSTOP_EMPTYFRAME = REBAR_STOP_EMPTYFRAME,
59
61 REBARSTOP_EMPTYFRAMEAFTERREGION = REBAR_STOP_EMPTYFRAMEAFTERREGION
62 };
63
64
65 const char* ClassName() const override { return "FCMusicRegion"; }
66
67#ifndef DOXYGEN_SHOULD_IGNORE_THIS
69 EREGION* _GetEREGION() { return &_region; }
70
72 EDOCID _GetDocumentID() { return _documentid; }
73#endif
74
75
82 FCMusicRegion(EREGION* pRegion = NULL);
83
85 virtual ~FCMusicRegion();
86
87
93 void AssureSortedStaves();
94
101 void Clear() { _region.ClearEnigmaRegion(); }
102
112 bool IsEmpty() const
113 {
114 /* The EREGION approach doesn't cover all cases,
115 since an empty region can be defined as startmeas=endmeas
116 and measstartpos=measendpos.
117 I have to do some additional checking to be safe.
118 Don't use getters here, since it will result in an endless
119 recursive chain.
120 */
121 if (_region.start.meas > _region.end.meas) return true;
122 if (_region.start.meas == _region.end.meas)
123 {
124 if (_region.start.duraPos >= _region.end.duraPos) return true;
125 }
126 return (_region.IsEnigmaRegionEmpty() != 0);
127 }
128
137 bool IsSinglePos() const
138 {
139 if (_region.start.meas < 1) return false;
140 if (_region.start.meas != _region.end.meas) return false;
141 if (_region.start.duraPos != _region.end.duraPos) return false;
142 return true;
143 }
144
152 {
153 return IsEmpty() && ! IsSinglePos();
154 }
155
161 bool IsMeasureIncluded(twobyte measureno);
162
169
174 bool IsFullMeasureIncluded(twobyte measureno);
175
183 bool IsStaffIncluded(twobyte staffnumber) const;
184
192 bool IsSlotIncluded(twobyte slotnumber) const;
193
199 bool IsMeasurePosWithin(int measure, TimeEdu32 pos);
200
206 bool IsStartPos(const int measure, const TimeEdu32 pos);
207
214 bool IsCellPosWithin(const FCCell* pCell, const TimeEdu32 pos);
215
223 bool IsIdentical(const __FCBase* pCompareObject) const override;
224
225#ifdef PDK_FRAMEWORK_ENTRIES
234 bool IsEntryPosWithin(const FCNoteEntry* pEntry);
235#endif // #ifdef PDK_FRAMEWORK_ENTRIES
236
241 bool IsPartial();
242
249 bool IsMeasurePartial(eMeas measure);
250
257 bool IsOverlapping(FCMusicRegion* pRegion);
258
264 bool IsFullDocumentSpan();
265
271 bool IsLastEndMeasure();
272
279 bool SetFullDocument();
280
288 bool SetCurrentSelection();
289
292 void SetEnigmaRegion(EREGION* pRegion);
293
298 void SetRegion(FCMusicRegion* pSourceRegion);
299
301 void GetEnigmaRegion(EREGION* pRegion);
302
309 void SetStartMeasure(twobyte measure) { _region.start.meas = measure; }
310
317 void SetStartMeasurePos(TimeEdu32 pos) { _region.start.duraPos = pos; }
318
325
332 void SetEndMeasure(twobyte measure) { _region.end.meas = measure; }
333
340 void SetEndMeasurePos(TimeEdu32 pos) { _region.end.duraPos = pos; }
341
349
361 bool SetFullMeasureStack();
362
371 void SetInstrumentList(twobyte list) { _region.start.IUlist = _region.end.IUlist = list; }
372
380 void SetStartStaff(twobyte staff) { _region.start.IUslot = FX_InstToSlot(staff, _region.start.IUlist); }
381
387 void SetStartSlot(twobyte slot) { _region.start.IUslot = slot; }
388
396 void SetEndStaff(twobyte staff) { _region.end.IUslot = FX_InstToSlot(staff, _region.end.IUlist); }
397
403 void SetEndSlot(twobyte slot) { _region.end.IUslot = slot; }
404
411 twobyte GetStartMeasure() const { return _region.start.meas; }
412
419 twobyte GetEndMeasure() const { return _region.end.meas; }
420
432 twobyte GetInstrumentList() const { return _region.start.IUlist; }
433
445 twobyte GetStartSlot() const { return _region.start.IUslot; }
446
458 twobyte GetEndSlot() const { return _region.end.IUslot; }
459
470 twobyte GetStartStaff() const { return FX_SlotToInst(_region.start.IUslot, _region.start.IUlist); }
471
478 twobyte GetEndStaff() const { return FX_SlotToInst(_region.end.IUslot, _region.end.IUlist); }
479
489 TimeEdu32 GetStartMeasurePos() const { return _region.start.duraPos; }
490
499 TimeEdu32 GetEndMeasurePos() const { return _region.end.duraPos; }
500
510 if (IsSinglePos()) return 1;
511 if (IsEmpty()) return 0;
512 return GetEndMeasure() - GetStartMeasure() + 1;
513 }
514
521 int CalcStaffSpan() { return GetEndSlot() - GetStartSlot() + 1; }
522
536 twobyte CalcStaffNumber(twobyte slot) { return FX_SlotToInst(slot, GetInstrumentList()); }
537
549 twobyte CalcSlotNumber(twobyte staff) const { return FX_InstToSlot(staff, GetInstrumentList()); }
550
556 TimeEdu32 CalcDuration();
557
566 bool SetDurationOffsetLeft(TimeEdu32 durationoffset);
567
577 bool SetDurationOffsetRight(TimeEdu32 durationoffset);
578
585 bool IsCurrentDocument();
586
596 void SetInDocument();
597
603
609 int ForEachStaff(FCIteratorHandler* pHandler);
610
622 bool CopyMusic();
623
635 bool CutMusic();
636
648 bool CutDeleteMusic();
649
660 bool PasteMusic();
661
669 bool ReleaseMusic();
670
675 void Redraw();
676
682 void RebeamMusic();
683
695 void RebarMusic(int stopflags, bool rebeam, bool padwithrests);
696
704 bool MusicMassMoverFrom(FCMusicRegion* pSourceRegion);
705
717 bool AddMeasureOffset(int offset)
718 {
719 if (IsEmptyAndNotSinglePos()) return false;
720 int newstart = GetStartMeasure() + offset;
721 int newend = GetEndMeasure() + offset;
722 if (newstart < 1) return false;
723 if (newend > 32767) return false;
724 SetStartMeasure(newstart);
725 SetEndMeasure(newend);
726 return true;
727 }
728
741
742#ifdef PDK_FRAMEWORK_LUAFRIENDLY_CPP
744 luabridge::RefCountedPtr<FCCells> CreateCells_GC()
745 { return makeLuaSharedPtr(CreateCells()); }
746#endif
747
786 bool Playback(bool playtoend = false) const;
787
799 bool PlaybackSingleStaff(eStaff staffnum, bool playtoend = false) const
800 {
801 if (!CalcSlotNumber(staffnum))
802 return false;
803 FX_Playback(GetStartMeasure(), (playtoend) ? 0 : GetEndMeasure(), staffnum, GetInstrumentList());
804 return true;
805 }
806
826 void FixMeasureWidthsInScore() const;
827
828#ifdef PDK_FRAMEWORK_DEBUG
829 void DebugDump() override
830 {
832 DebugOutInt("Start measure: ", GetStartMeasure());
833 DebugOutInt("Start measure pos: ", GetStartMeasurePos());
834 DebugOutInt("End measure: ", GetEndMeasure());
835 DebugOutInt("End measure pos: ", GetEndMeasurePos());
836 DebugOutInt("Instrument list: ", GetInstrumentList());
837 DebugOutInt("Start slot: ", GetStartSlot());
838 DebugOutInt("End slot: ", GetEndSlot());
839 DebugOutInt("Start staff: ", GetStartStaff());
840 DebugOutInt("End staff: ", GetEndStaff());
841 }
842#endif
843};
844
845#endif /* FF_REGION_H */
846
Base class for the Finale Framework classes.
Definition ff_base.h:71
static void DebugOutInt(const char *pszPrefixText, int i)
Static method that outputs a line for debugging purposes. The text appears with the extra digit (in d...
Definition finaleframework.cpp:335
virtual void DebugDump()
Outputs the class data/information for debugging purposes.
Definition finaleframework.cpp:609
The class that reference a cell (one measure on one staff) in the musical "grid".
Definition ff_cell.h:18
A collection of FCCell members.
Definition ff_cell.h:426
Class for iterator handlers.
Definition ff_iterator.h:26
Class that encapsulates EREGION and provides additional functionality to region handling.
Definition ff_region.h:25
bool IsOverlapping(FCMusicRegion *pRegion)
Returns true if the region overlaps with another region.
Definition finaleframework.cpp:15763
bool CutMusic()
Cuts out music to a clip file. It can then be pasted with PasteMusic.
Definition finaleframework.cpp:15942
bool IsIdentical(const __FCBase *pCompareObject) const override
Overridden virtual method.
Definition finaleframework.cpp:15710
void Redraw()
Redraws the music in the region.
Definition finaleframework.cpp:15976
bool PasteMusic()
Paste a clip file that has been created with CopyMusic or CutMusic.
Definition finaleframework.cpp:15960
bool IsLastEndMeasure()
Returns true if the end measure in the selection is the end measure of the document.
Definition finaleframework.cpp:15800
bool IsCurrentDocument()
Returns true if the region belongs to the current document.
Definition finaleframework.cpp:15787
void SetEndMeasurePosRight()
Sets the the end measure pos to the right-most edge of the region's end measure.
Definition ff_region.h:348
bool IsCellPosWithin(const FCCell *pCell, const TimeEdu32 pos)
Checks if a cell position is within the region. This checks for partial measures.
Definition finaleframework.cpp:15695
twobyte GetStartMeasure() const
Returns the start measure for the region.
Definition ff_region.h:411
bool SetFullDocument()
Sets the region to span the full document.
Definition finaleframework.cpp:15590
void RebeamMusic()
Rebeams the music in the region.
Definition finaleframework.cpp:15981
twobyte GetEndStaff() const
Returns the end staff number for the region.
Definition ff_region.h:478
bool IsSlotIncluded(twobyte slotnumber) const
Returns true if the slot number is with the region.
Definition finaleframework.cpp:15666
bool SetCurrentSelection()
Sets the region object to span the current selection in the document.
Definition finaleframework.cpp:15602
twobyte GetStartSlot() const
Returns the start slot (staff) for the region.
Definition ff_region.h:445
void SetEnigmaRegion(EREGION *pRegion)
Assigns an Enigma region to the document region.
Definition finaleframework.cpp:15612
void SetStartSlot(twobyte slot)
Sets the start slot for the region directly.
Definition ff_region.h:387
TimeEdu32 GetStartMeasurePos() const
Returns the start position of the region within the measure.
Definition ff_region.h:489
bool IsStaffIncluded(twobyte staffnumber) const
Returns true if the staff number is with the region.
Definition finaleframework.cpp:15658
REBARSTOPS
Stop constants for the FCMusicRegion::RebarMusic() method.
Definition ff_region.h:41
@ REBARSTOP_EMPTYFRAME
Definition ff_region.h:58
@ REBARSTOP_TIME
Definition ff_region.h:49
@ REBARSTOP_SPECIALBARLINE
Definition ff_region.h:55
@ REBARSTOP_KEY
Definition ff_region.h:46
@ REBARSTOP_REGIONEND
Definition ff_region.h:52
@ REBARSTOP_EMPTYFRAMEAFTERREGION
Definition ff_region.h:61
@ REBARSTOP_NONE
Definition ff_region.h:43
bool AddMeasureOffset(int offset)
"Moves" the music region horizontally by adding the offset to both the start and end measure values....
Definition ff_region.h:717
bool CutDeleteMusic()
Cuts out music to a clip file and deletes the area. It can then be pasted with PasteMusic.
Definition finaleframework.cpp:15951
bool IsSinglePos() const
Returns true if the region is empty, but represents a single horizontal location in the document.
Definition ff_region.h:137
virtual ~FCMusicRegion()
The destructor.
Definition finaleframework.cpp:15570
bool IsMeasurePartial(eMeas measure)
Returns true if a specific measure is partially selected.
Definition finaleframework.cpp:15749
twobyte CalcSlotNumber(twobyte staff) const
Calculates the slot number based on a staff number.
Definition ff_region.h:549
bool IsPartial()
Returns true if the region contains a partially selected measure.
Definition finaleframework.cpp:15741
bool IsStartPos(const int measure, const TimeEdu32 pos)
Returns true if the supplied measure/edu values are identical to the region's start position.
Definition finaleframework.cpp:15688
bool IsFullDocumentSpan()
Returns true if the "width" of the region is the same as the whole document span.
Definition finaleframework.cpp:15792
const char * ClassName() const override
Returns the name of the class, for diagnostic purposes. This method MUST be overwritten in each child...
Definition ff_region.h:65
twobyte GetStartStaff() const
Returns the start staff number for the region.
Definition ff_region.h:470
void Clear()
Empties the region.
Definition ff_region.h:101
int CalcStaffSpan()
Calculates the number of staves in the region.
Definition ff_region.h:521
void SetEndMeasure(twobyte measure)
Sets the end measure for the region.
Definition ff_region.h:332
bool SetFullMeasureStack()
Sets the full height of the measure stack for the current region.
Definition finaleframework.cpp:15921
void SetStartMeasurePosLeft()
Sets the start measure pos to the left-most edge of the region's start measure.
Definition ff_region.h:324
void SetInstrumentList(twobyte list)
Sets the instrument list for the selection. If this method is called,' the start/end staff must be mo...
Definition ff_region.h:371
void SetInDocument()
Updates the region visually in the document, if the region belongs to the current document.
Definition finaleframework.cpp:15809
void SetEndSlot(twobyte slot)
Sets the end slot for the region directly.
Definition ff_region.h:403
bool SetDurationOffsetLeft(TimeEdu32 durationoffset)
Sets position of the left side as a distance from the right region edge, in EDUs.
Definition finaleframework.cpp:15839
void SetStartStaff(twobyte staff)
Sets the start staff for the region. The staff must be available in the region's current instrument l...
Definition ff_region.h:380
bool IsMeasureIncluded(twobyte measureno)
Returns true if the measure number is with the region. Please note that it doesn't check for partial ...
Definition finaleframework.cpp:15637
bool IsMeasurePosWithin(int measure, TimeEdu32 pos)
Returns true if the measure/edu position is horizontally within the region span. This method doesn't ...
Definition finaleframework.cpp:15674
int CalcMeasureSpan()
Calculates the number of measures in the region.
Definition ff_region.h:509
void GetEnigmaRegion(EREGION *pRegion)
Assigns the document region to an Enigma region structure.
Definition finaleframework.cpp:15631
void DebugDump() override
Outputs the class data/information for debugging purposes.
Definition ff_region.h:829
void SetEndMeasurePos(TimeEdu32 pos)
Sets the end measure pos in the end measure.
Definition ff_region.h:340
void FixMeasureWidthsInScore() const
Works around a bug in Finale when modifying measure widths with a part in edit focus.
Definition finaleframework.cpp:16019
bool IsFullMeasureIncluded(twobyte measureno)
Returns true if the full measure is with the region.
Definition finaleframework.cpp:15649
void ConvertToGlobalInstrumentList()
Transforms the region to use the global instrument list (instrument list 0).
Definition finaleframework.cpp:15898
int ForEachStaff(FCIteratorHandler *pHandler)
Iterates through each staff in the current selection through an iterator handler.
Definition finaleframework.cpp:15907
bool ReleaseMusic()
Disposes a clip file that has been created with CopyMusic or CutMusic.
Definition finaleframework.cpp:15968
bool IsEmptyAndNotSinglePos() const
Returns true if the region is empty and it is not a single-position region. Finale itself treats sing...
Definition ff_region.h:151
void RebarMusic(int stopflags, bool rebeam, bool padwithrests)
Rebars the music in the region.
Definition finaleframework.cpp:15986
twobyte GetEndMeasure() const
Returns the end measure for the region.
Definition ff_region.h:419
bool MusicMassMoverFrom(FCMusicRegion *pSourceRegion)
Performs a Finale "mass mover" task from another FCMusicRegion to the object's region.
Definition finaleframework.cpp:15991
twobyte CalcStaffNumber(twobyte slot)
Calculates the staff number, based on the region's slot number.
Definition ff_region.h:536
bool PlaybackSingleStaff(eStaff staffnum, bool playtoend=false) const
Playback a single staff in the region. Only entire measures play back, so playback starts at the begi...
Definition ff_region.h:799
bool IsAbsoluteEndMeasurePos()
Returns true if the right-side measure position in the end measure is at the absolute far right end (...
Definition finaleframework.cpp:15644
TimeEdu32 GetEndMeasurePos() const
Returns the end position of the region within the measure.
Definition ff_region.h:499
FCCells * CreateCells()
Creates a FCCells object with all cells in the region.
Definition finaleframework.cpp:16003
bool Playback(bool playtoend=false) const
Playback the region. Only entire measures play back, so playback starts at the beginning of the first...
Definition finaleframework.cpp:16010
twobyte GetEndSlot() const
Returns the end slot (staff) for the region.
Definition ff_region.h:458
twobyte GetInstrumentList() const
Returns the instrument list number for the selection.
Definition ff_region.h:432
bool SetDurationOffsetRight(TimeEdu32 durationoffset)
Sets position of the right region side as a distance from the left region edge, in EDUs.
Definition finaleframework.cpp:15874
bool IsEmpty() const
Returns true if the region is empty.
Definition ff_region.h:112
void SetEndStaff(twobyte staff)
Sets the end staff for the region. The staff must be available in the region's current instrument lis...
Definition ff_region.h:396
void AssureSortedStaves()
Makes sure that the start staff is above the end staff in the instrument list for the region.
Definition finaleframework.cpp:15580
void SetStartMeasurePos(TimeEdu32 pos)
Sets the start measure pos in the start measure.
Definition ff_region.h:317
TimeEdu32 CalcDuration()
Calculates the duration of the selection, in EDUs.
Definition finaleframework.cpp:15821
void SetRegion(FCMusicRegion *pSourceRegion)
Copies another document region to the document region.
Definition finaleframework.cpp:15619
bool CopyMusic()
Copies music to a clip file. It can then be pasted with PasteMusic.
Definition finaleframework.cpp:15933
void SetStartMeasure(twobyte measure)
Sets the start measure.
Definition ff_region.h:309
bool IsEntryPosWithin(const FCNoteEntry *pEntry)
Checks if a entry is within the region. This checks for partial measures.
Definition finaleframework.cpp:15725
FCMusicRegion(EREGION *pRegion=NULL)
The constructor. Copies the EREGION data to the object, if available.
Definition finaleframework.cpp:15560
Encapsulates a note entry from an owner class (for example FCNoteEntryCell, FCNoteEntryLayer) class.
Definition ff_noteframe.h:940