Finale PDK Framework  0.54
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 
12 class FCCell;
13 class FCCells;
14 
24 class 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 */
32 public:
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  virtual const char* ClassName() { return "FCMusicRegion"; }
66 
67 #ifndef DOXYGEN_SHOULD_IGNORE_THIS
68 
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 
150  bool IsMeasureIncluded(twobyte measureno);
151 
158 
163  bool IsFullMeasureIncluded(twobyte measureno);
164 
172  bool IsStaffIncluded(twobyte staffnumber);
173 
181  bool IsSlotIncluded(twobyte slotnumber);
182 
188  bool IsMeasurePosWithin(int measure, TimeEdu32 pos);
189 
195  bool IsStartPos(int measure, TimeEdu32 pos);
196 
203  bool IsCellPosWithin(FCCell* pCell, TimeEdu32 pos);
204 
212  virtual bool IsIdentical(FCMusicRegion* pMusicRegion);
213 
214 #ifdef PDK_FRAMEWORK_ENTRIES
215 
223  bool IsEntryPosWithin(FCNoteEntry* pEntry);
224 #endif // #ifdef PDK_FRAMEWORK_ENTRIES
225 
230  bool IsPartial();
231 
238  bool IsMeasurePartial(eMeas measure);
239 
246  bool IsOverlapping(FCMusicRegion* pRegion);
247 
253  bool IsFullDocumentSpan();
254 
260  bool IsLastEndMeasure();
261 
268  bool SetFullDocument();
269 
277  bool SetCurrentSelection();
278 
281  void SetEnigmaRegion(EREGION* pRegion);
282 
287  void SetRegion(FCMusicRegion* pSourceRegion);
288 
290  void GetEnigmaRegion(EREGION* pRegion);
291 
298  void SetStartMeasure(twobyte measure) { _region.start.meas = measure; }
299 
306  void SetStartMeasurePos(TimeEdu32 pos) { _region.start.duraPos = pos; }
307 
314 
321  void SetEndMeasure(twobyte measure) { _region.end.meas = measure; }
322 
329  void SetEndMeasurePos(TimeEdu32 pos) { _region.end.duraPos = pos; }
330 
337  void SetEndMeasurePosRight() { SetEndMeasurePos(0x7fffffff); }
338 
350  bool SetFullMeasureStack();
351 
360  void SetInstrumentList(twobyte list) { _region.start.IUlist = _region.end.IUlist = list; }
361 
369  void SetStartStaff(twobyte staff) { _region.start.IUslot = FX_InstToSlot(staff, _region.start.IUlist); }
370 
376  void SetStartSlot(twobyte slot) { _region.start.IUslot = slot; }
377 
385  void SetEndStaff(twobyte staff) { _region.end.IUslot = FX_InstToSlot(staff, _region.end.IUlist); }
386 
392  void SetEndSlot(twobyte slot) { _region.end.IUslot = slot; }
393 
400  twobyte GetStartMeasure() const { return _region.start.meas; }
401 
408  twobyte GetEndMeasure() const { return _region.end.meas; }
409 
422  twobyte GetInstrumentList() const { return _region.start.IUlist; }
423 
435  twobyte GetStartSlot() const { return _region.start.IUslot; }
436 
448  twobyte GetEndSlot() const { return _region.end.IUslot; }
449 
456  twobyte GetStartStaff() const { return FX_SlotToInst(_region.start.IUslot, _region.start.IUlist); }
457 
464  twobyte GetEndStaff() const { return FX_SlotToInst(_region.end.IUslot, _region.end.IUlist); }
465 
475  TimeEdu32 GetStartMeasurePos() const { return _region.start.duraPos; }
476 
485  TimeEdu32 GetEndMeasurePos() const { return _region.end.duraPos; }
486 
496  if (IsSinglePos()) return 1;
497  if (IsEmpty()) return 0;
498  return GetEndMeasure() - GetStartMeasure() + 1;
499  }
500 
507  int CalcStaffSpan() { return GetEndSlot() - GetStartSlot() + 1; }
508 
522  twobyte CalcStaffNumber(twobyte slot) { return FX_SlotToInst(slot, GetInstrumentList()); }
523 
535  twobyte CalcSlotNumber(twobyte staff) { return FX_InstToSlot(staff, GetInstrumentList()); }
536 
542  TimeEdu32 CalcDuration();
543 
552  bool SetDurationOffsetLeft(TimeEdu32 durationoffset);
553 
563  bool SetDurationOffsetRight(TimeEdu32 durationoffset);
564 
572  bool IsCurrentDocument();
573 
583  void SetInDocument();
584 
590 
596  int ForEachStaff(FCIteratorHandler* pHandler);
597 
609  bool CopyMusic();
610 
622  bool CutMusic();
623 
635  bool CutDeleteMusic();
636 
647  bool PasteMusic();
648 
656  bool ReleaseMusic();
657 
662  void Redraw();
663 
669  void RebeamMusic();
670 
682  void RebarMusic(int stopflags, bool rebeam, bool padwithrests);
683 
691  bool MusicMassMoverFrom(FCMusicRegion* pSourceRegion);
692 
704  bool AddMeasureOffset(int offset)
705  {
706  if (IsEmpty() && (!IsSinglePos())) return false;
707  int newstart = GetStartMeasure() + offset;
708  int newend = GetEndMeasure() + offset;
709  if (newstart < 1) return false;
710  if (newend > 32767) return false;
711  SetStartMeasure(newstart);
712  SetEndMeasure(newend);
713  return true;
714  }
715 
727  FCCells* CreateCells();
728 
729 #ifdef PDK_FRAMEWORK_LUAFRIENDLY
730 
731  FCCells* CreateCells_GC();
732 #endif
733 
734 #ifdef PDK_FRAMEWORK_DEBUG
735  virtual void DebugDump()
736  {
738  DebugOutDigit("Start measure: ", GetStartMeasure());
739  DebugOutDigit("Start measure pos: ", GetStartMeasurePos());
740  DebugOutDigit("End measure: ", GetEndMeasure());
741  DebugOutDigit("End measure pos: ", GetEndMeasurePos());
742  DebugOutDigit("Instrument list: ", GetInstrumentList());
743  DebugOutDigit("Start slot: ", GetStartSlot());
744  DebugOutDigit("End slot: ", GetEndSlot());
745  DebugOutDigit("Start staff: ", GetStartStaff());
746  DebugOutDigit("End staff: ", GetEndStaff());
747  }
748 #endif
749 };
750 
751 #endif /* FF_REGION_H */
752 
void SetInDocument()
Updates the region visually in the document, if the region belongs to the current document...
Definition: finaleframework.cpp:14756
Definition: ff_region.h:46
Definition: ff_region.h:55
twobyte GetEndMeasure() const
Returns the end measure for the region.
Definition: ff_region.h:408
bool IsCellPosWithin(FCCell *pCell, TimeEdu32 pos)
Checks if a cell position is within the region. This checks for partial measures. ...
Definition: finaleframework.cpp:14644
REBARSTOPS
Stop constants for the FCMusicRegion::RebarMusic() method.
Definition: ff_region.h:40
bool PasteMusic()
Paste a clip file that has been created with CopyMusic or CutMusic.
Definition: finaleframework.cpp:14901
int CalcMeasureSpan()
Calculates the number of measures in the region.
Definition: ff_region.h:495
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:360
void SetEndMeasurePosRight()
Sets the the end measure pos to the right-most edge of the region's end measure.
Definition: ff_region.h:337
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:385
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:14623
bool IsEntryPosWithin(FCNoteEntry *pEntry)
Checks if a entry is within the region. This checks for partial measures.
Definition: finaleframework.cpp:14672
void SetStartMeasure(twobyte measure)
Sets the start measure.
Definition: ff_region.h:298
twobyte CalcSlotNumber(twobyte staff)
Calculates the slot number based on a staff number.
Definition: ff_region.h:535
virtual ~FCMusicRegion()
The destructor.
Definition: finaleframework.cpp:14524
void SetStartMeasurePos(TimeEdu32 pos)
Sets the start measure pos in the start measure.
Definition: ff_region.h:306
static void DebugOutDigit(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:274
bool SetCurrentSelection()
Sets the region object to span the current selection in the document.
Definition: finaleframework.cpp:14556
void Clear()
Empties the region.
Definition: ff_region.h:101
twobyte CalcStaffNumber(twobyte slot)
Calculates the staff number, based on the region's slot number.
Definition: ff_region.h:522
bool IsStaffIncluded(twobyte staffnumber)
Returns true if the staff number is with the region.
Definition: finaleframework.cpp:14607
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:704
bool SetDurationOffsetRight(TimeEdu32 durationoffset)
Sets position of the right region side as a distance from the left region edge, in EDUs...
Definition: finaleframework.cpp:14815
TimeEdu32 GetEndMeasurePos() const
Returns the end position of the region within the measure.
Definition: ff_region.h:485
virtual const char * ClassName()
Returns the name of the class, for diagnostic purposes. This method MUST be overwritten in each child...
Definition: ff_region.h:65
bool IsEmpty() const
Returns true if the region is empty.
Definition: ff_region.h:112
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:369
void SetEnigmaRegion(EREGION *pRegion)
Assigns an Enigma region to the document region.
Definition: finaleframework.cpp:14566
bool IsPartial()
Returns true if the region contains a partially selected measure.
Definition: finaleframework.cpp:14688
bool CutMusic()
Cuts out music to a clip file. It can then be pasted with PasteMusic.
Definition: finaleframework.cpp:14883
bool SetDurationOffsetLeft(TimeEdu32 durationoffset)
Sets position of the left side as a distance from the right region edge, in EDUs. ...
Definition: finaleframework.cpp:14780
void AssureSortedStaves()
Makes sure that the start staff is above the end staff in the instrument list for the region...
Definition: finaleframework.cpp:14534
void RebeamMusic()
Rebeams the music in the region.
Definition: finaleframework.cpp:14925
bool IsCurrentDocument()
Returns true if the region belongs to the current document.
Definition: finaleframework.cpp:14734
bool IsSinglePos() const
Returns true if the region is empty, but represents a single horizontal location in the document...
Definition: ff_region.h:137
Definition: ff_region.h:52
The class that reference a cell (one measure on one staff) in the musical "grid". ...
Definition: ff_cell.h:17
bool ReleaseMusic()
Disposes a clip file that has been created with CopyMusic or CutMusic.
Definition: finaleframework.cpp:14909
Base class for the Finale Framework classes.
Definition: ff_base.h:47
bool CutDeleteMusic()
Cuts out music to a clip file and deletes the area. It can then be pasted with PasteMusic.
Definition: finaleframework.cpp:14892
void SetEndMeasure(twobyte measure)
Sets the end measure for the region.
Definition: ff_region.h:321
bool IsFullMeasureIncluded(twobyte measureno)
Returns true if the full measure is with the region.
Definition: finaleframework.cpp:14598
void SetEndMeasurePos(TimeEdu32 pos)
Sets the end measure pos in the end measure.
Definition: ff_region.h:329
bool SetFullDocument()
Sets the region to span the full document.
Definition: finaleframework.cpp:14544
virtual void DebugDump()
Outputs the class data/information for debugging purposes.
Definition: ff_region.h:735
twobyte GetStartStaff() const
Returns the start staff number for the region.
Definition: ff_region.h:456
bool IsSlotIncluded(twobyte slotnumber)
Returns true if the slot number is with the region.
Definition: finaleframework.cpp:14615
void SetRegion(FCMusicRegion *pSourceRegion)
Copies another document region to the document region.
Definition: finaleframework.cpp:14573
Definition: ff_region.h:58
void Redraw()
Redraws the music in the region.
Definition: finaleframework.cpp:14917
TimeEdu32 CalcDuration()
Calculates the duration of the selection, in EDUs.
Definition: finaleframework.cpp:14762
void RebarMusic(int stopflags, bool rebeam, bool padwithrests)
Rebars the music in the region.
Definition: finaleframework.cpp:14930
bool IsMeasurePartial(eMeas measure)
Returns true if a specific measure is partially selected.
Definition: finaleframework.cpp:14696
bool MusicMassMoverFrom(FCMusicRegion *pSourceRegion)
Performs a Finale "mass mover" task from another FCMusicRegion to the object's region.
Definition: finaleframework.cpp:14935
bool IsStartPos(int measure, TimeEdu32 pos)
Returns true if the supplied measure/edu values are identical to the region's start position...
Definition: finaleframework.cpp:14637
bool IsFullDocumentSpan()
Returns true if the "width" of the region is the same as the whole document span. ...
Definition: finaleframework.cpp:14739
void ConvertToGlobalInstrumentList()
Transforms the region to use the global instrument list (instrument list 0).
Definition: finaleframework.cpp:14839
int ForEachStaff(FCIteratorHandler *pHandler)
Iterates through each staff in the current selection through an iterator handler. ...
Definition: finaleframework.cpp:14848
Class for iterator handlers.
Definition: ff_iterator.h:25
bool IsLastEndMeasure()
Returns true if the end measure in the selection is the end measure of the document.
Definition: finaleframework.cpp:14747
Encapsulates a note entry from an owner class (for example FCNoteEntryCell, FCNoteEntryLayer) class...
Definition: ff_noteframe.h:808
FCCells * CreateCells()
Creates a FCCells object with all cells in the region.
Definition: finaleframework.cpp:14947
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:14586
FCMusicRegion(EREGION *pRegion=NULL)
The constructor. Copies the EREGION data to the object, if available.
Definition: finaleframework.cpp:14514
bool IsOverlapping(FCMusicRegion *pRegion)
Returns true if the region overlaps with another region.
Definition: finaleframework.cpp:14710
A collection of FCCell members.
Definition: ff_cell.h:323
Class that encapsulates EREGION and provides additional functionality to region handling.
Definition: ff_region.h:24
TimeEdu32 GetStartMeasurePos() const
Returns the start position of the region within the measure.
Definition: ff_region.h:475
void SetStartMeasurePosLeft()
Sets the start measure pos to the left-most edge of the region's start measure.
Definition: ff_region.h:313
twobyte GetStartSlot() const
Returns the start slot (staff) for the region.
Definition: ff_region.h:435
int CalcStaffSpan()
Calculates the number of staves in the region.
Definition: ff_region.h:507
void GetEnigmaRegion(EREGION *pRegion)
Assigns the document region to an Enigma region structure.
Definition: finaleframework.cpp:14580
twobyte GetEndSlot() const
Returns the end slot (staff) for the region.
Definition: ff_region.h:448
bool IsAbsoluteEndMeasurePos()
Returns true if the right-side measure position in the end measure is at the absolute far right end (...
Definition: finaleframework.cpp:14593
virtual bool IsIdentical(FCMusicRegion *pMusicRegion)
Overridden virtual method.
Definition: finaleframework.cpp:14659
void SetStartSlot(twobyte slot)
Sets the start slot for the region directly.
Definition: ff_region.h:376
void SetEndSlot(twobyte slot)
Sets the end slot for the region directly.
Definition: ff_region.h:392
twobyte GetInstrumentList() const
Returns the instrument list number for the selection.
Definition: ff_region.h:422
twobyte GetEndStaff() const
Returns the end staff number for the region.
Definition: ff_region.h:464
twobyte GetStartMeasure() const
Returns the start measure for the region.
Definition: ff_region.h:400
Definition: ff_region.h:49
bool SetFullMeasureStack()
Sets the full height of the measure stack for the current region.
Definition: finaleframework.cpp:14862
bool CopyMusic()
Copies music to a clip file. It can then be pasted with PasteMusic.
Definition: finaleframework.cpp:14874
virtual void DebugDump()
Outputs the class data/information for debugging purposes.
Definition: finaleframework.cpp:547