GUIDOLib  1.7.7
Guido Engine Internal Documentation
GRStaffManager.h
1 #ifndef GRStaffManager_H
2 #define GRStaffManager_H
3 
4 /*
5  GUIDO Library
6  Copyright (C) 2002 Holger Hoos, Juergen Kilian, Kai Renz
7  Copyright (C) 2002-2017 Grame
8 
9  This Source Code Form is subject to the terms of the Mozilla Public
10  License, v. 2.0. If a copy of the MPL was not distributed with this
11  file, You can obtain one at http://mozilla.org/MPL/2.0/.
12 
13  Grame Research Laboratory, 11, cours de Verdun Gensoul 69002 Lyon - France
14  research@grame.fr
15 
16 */
17 
18 #include "kf_ilist.h" // required (should be replaced by STL containers)
19 #include "kf_vect.h" // idem
20 #include "kr_hash.h" // idem
21 
22 template <class T> class KF_IVector;
23 
24 #include "defines.h" // For TYPE_TIMEPOSITION
25 
26 #include "GRBeginSpaceForceFunction2.h"
27 #include "GRSpring.h"
28 #include "GRRod.h"
29 
30 class ARMusicalTag;
31 class ARMusic;
32 class ARMusicalVoice;
33 class ARPageFormat;
34 class ARBarFormat;
35 class ARSystemFormat;
36 class ARAuto;
37 class ARAccolade;
38 
39 class GRClef;
40 class GREvent;
41 class GRKey;
42 class GRPage;
43 class GRSystem;
44 class GRSystemSlice;
45 class GRMusic;
47 class GRVoice;
48 class GRStaff;
49 class GRStaffState;
50 class GRVoiceManager;
51 class GRGlobalStem;
52 
56 
57 
62 class SubHash
63 {
64 public:
65  SubHash() : grel( 0 ), grstaff( 0 ), voice( 0 ), voiceID( -1 ) { }
66 
70  int voiceID;
71 };
72 
74 
75 class HashEntry
76 {
77 public:
78  HashEntry(int tmp)
79  {
80  assert(false);
81  data = 0;
82  mSpringID = tmp;
83  }
85  {
86  data = 0;
87  mSpringID = -1;
88  }
90  int mSpringID;
91  //
92  int operator>(const HashEntry &h) const
93  {
94  if (mSpringID > h.mSpringID)
95  return 1;
96  return 0;
97  }
98 };
99 
100 
101 
104 typedef SystemHash PageHash;
105 
106 
107 
109 {
110 public:
113 };
114 
117 // typedef KF_IPointerList<GREvent> GREventList;
123 
127 
128 
130  {
131  // this class represents the entries in a list for determining, which springs
132  // are stretched by InitialSpringStretch.
133  // The Entries are later sorted by space-rods (and start-springIDs)
134  // and further by force ...
135  public:
136 
137  GRForceRodEntry() : force( 0 ), rod( 0 ) { }
138 
139  // the routine to compare the entries against each other ..
140  // returns:
141  // -1: e1<e2
142  // 0: e1 == e2
143  // 1: e1 > e2
144  static int comp( const GRForceRodEntry * e1, const GRForceRodEntry * e2 );
145  float force;
147  };
148 
149 
161 {
162  friend class GRSystem;
163  friend class GRPossibleBreakState;
164 
165  public:
166 
167  GRStaffManager(GRMusic * p_grmusic, ARPageFormat * inPageFormat = 0, const GuidoLayoutSettings * settings = 0);
168  virtual ~GRStaffManager();
169 
170  // this routine is used to get the current beginning_sff
171  // This is used by the constructor of GRSystemSlice to save a pointer to the value, which is then used later
172  // to calculate the actual optimum linebreaks ....
174 
175  int IsAutoPageBreak() const;
176  void setAutoTag (const ARAuto *p_arauto);
177  void setBarFormat (const ARBarFormat * barfrmt,GRStaff * curstaff);
178  void setSystemDistance(float distance, const GRVoiceManager & p_vcmgr);
179  void setPageFormat (const ARPageFormat * pform);
180  void setSystemFormat(const ARSystemFormat * sysfrm);
181  void NewPage (GRPage *newpage);
182 
183 
184  void addElementToSpring(GRNotationElement *grne,int springid);
185  static float InitialSpringStretch(int start, int end, IRodList * simplerods, IRodList * complerods, ISpringVector *sprvect, std::ofstream *springlog = 0);
186  int deleteRod(GRRod *rod);
187  int addRod(GRRod *rod,bool spaceactive, bool atHead = false, int voiceID = -1);
189  int AddGRSyncElement(GRNotationElement *grel, GRStaff *grstaff,int voiceid, GRVoice *vce, GRNotationElement * sameel = 0);
190  int AddSystemTag(GRNotationElement * grel, GRStaff * grstaff,int voiceid);
191  int AddPageTag(GRNotationElement * grel, GRStaff * grstaff,int voiceid);
192  int getNewLinePage() const;
193 
194  virtual bool setStaffStateTag(const ARMusicalTag * tag, int staffnum);
195  virtual float getSystemWidthCm();
196 // virtual void EndPage(ARMusicalVoice * voice, GuidoPos pos);
197 // virtual void EndSystem(ARMusicalVoice * arVoice, GuidoPos pos);
198 // virtual void setRelativeEndTimePosition(const TYPE_TIMEPOSITION & tp);
200  virtual GRStaff * getStaff(int staff);
201  virtual void prepareStaff(int staff);
202 
204  GRGlobalStem * getOtherGlobalStem(GRSystemSlice * psys, GRVoiceManager * curvcmgr, const NVstring & label);
205 
206  void createStaves();
207 
208  GRMusic * getGRMusic() { return mGrMusic; }
209  int getNumVoices() const;
210 
211  void notifyAccoladeTag( const ARAccolade * inAccoladeTag );
212 
213  protected:
214 
215 #ifdef SPRINGLOG
216  ofstream springlog;
217 #endif
218  // this variable remembers, wether we are currently breaking.
219  // this is set before calling GRVoiceManager->Dobreak so that the prepare-staff-Function of GRStaffManager
220  // nows that it should copy state-information that was previously available.
221  bool mIsBreak;
223 
224  void UpdateBeginningSFF(int staffnum);
225  void ResumeOpenTags (const GRSystemSlice * lastslice, GRSystemSlice * beginslice);
226 
227  // remember the system-distance (if it is explicitly set ....)
230 
233 
243 
246 
247  // this variable holds in a list the sffs for the beginning of a line given the current state information.
248  // Whenever a clef or key changes, the sff is updated and added to the list. These values can then be used to evaluate
249  // the potential lines.
252 
255 
256  // these rods are build during BuildSPF and then saved by GRPossibleBreakPosition
257  // to be merged later through MergeSPFs
260 
263  const ARMusic * mArMusic;
264 
265 
266  SystemHash systemHash; // a hash for system-tags
267  PageHash pageHash; // a hash-table for page-tags
268  SyncHash syncHash; // this hash has all the synchronization work ...
270  int mTempSpringID; // The temporary SpringID for each Slice (especially for Tags)
271 
272  // The real SpringID ...
273  // This is incremented for the whole System that this stafmanager handles ...
275  // this remembers the mLastSpringID for the BuildSPF function.
277 
278  // The mSimpleRods are the ones, that cover just a single spring
280 
281  // mComplexRods cover more than one spring (they need to be handled differently during stretching).
283 
284  // This vector holds the springs that are handled by this staffManager
285  // They are later passed to the system(slice) ...
287 
288  // The staff-State as a vector analogous to the StaffVector
290 
291  // The SpaceForceFunction
292  // This is build a new, when a call to BuildSPF is done.
293  // It is then added to the break-state if needed ...
294  // At the end, the new spf is added to the curspf.
295 
296  // this is the SPF for the FIRST-FIT-Algorithm.
297  // Later on, the optimum-fit will be realized by having SPFs for each part between pbreaks.
299 
300  // The EventList for events that are added for synchronisation
302 
304  const ARAuto * mArAuto;
305  std::vector<const ARAccolade*> mCurAccoladeTag;
307 
308  private:
309  // the methods below are used by createStaves
310  // they have been added to structure the structure the method
311  enum { kNormalState, kNewSystem, kNewPage, kPBreak };
312  typedef struct {
313  TYPE_TIMEPOSITION timePos; // the current time position
314  TYPE_TIMEPOSITION mintp; // the smallest timeposition for the next event in any of the voices
315  // This position is maintained for forward switching ...
316  // It remembers the smallest timeposition where the is a need for a filltagmode=1
317  TYPE_TIMEPOSITION minswitchtp;
318  bool conttagmode;
319  int newline; // this is set if at least one voice has a newSystem/newPage
320  float pbreakval;
321  } TCreateStavesState;
322 
323  void checkAccidentalsCollisions();
324  void finishStaves(const TCreateStavesState& state, float beginheight);
325  bool nextTimePosition (int nvoices, bool filltagMode, TCreateStavesState& state);
326  float systemBreak (int newlineMode, float beginheight);
327  int initVoices(int cnt);
328  void applyStaffSize(GRStaff *staff, int staffNum);
329 
330  // this routine takes the current system-slice list and finds the optimum break for it.
331  // it then also creates the systems with the respective systemslices.
332  float FindOptimumBreaks(int pageorsystembreak, float beginheight = 0 );
333  GRSystemSlice * CreateBeginSlice (const GRSystemSlice * lastslice);
334  void createNewSystemRods(int startid,int endid);
335  int CheckForBarSpring(int sprid);
336 // void EndStaves(const TYPE_TIMEPOSITION & tp, int lastline = 0);
337  void handleDeletedElements();
338 
339  void MergeSPFs(GRPossibleBreakState * pbs1, GRPossibleBreakState * pbs2 = 0);
340  void BreakAtPBS(GuidoPos pbpos);
341  GRSpaceForceFunction2 * BuildSFF();
342 
343  // this routine takes care of breaking the positiontags of a new system.
344  // The routine first retrieves the lastslice of the (new, to be created) system and then manages the still open tags of the
345  // system. It saves the open tags in a list, which will then be used to resume the tags in the next line.
346  void TakeCareOfBreakAt(GRSystem * newsys);
347 };
348 
349 #endif
SubHash::grel
GRNotationElement * grel
Definition: GRStaffManager.h:67
ARMusicalVoice
The class for GUIDO sequence, list of timepositions of events of a stream.
Definition: ARMusicalVoice.h:76
GRStaffManager::addElementToSpring
void addElementToSpring(GRNotationElement *grne, int springid)
GRStaffManager::mMaxKey
GRKey * mMaxKey
Definition: GRStaffManager.h:232
GRStaffManager::prepareStaff
virtual void prepareStaff(int staff)
GRStaffManager::mLastSpringID
int mLastSpringID
Definition: GRStaffManager.h:276
GRStaffManager::GRStaffManager
GRStaffManager(GRMusic *p_grmusic, ARPageFormat *inPageFormat=0, const GuidoLayoutSettings *settings=0)
GRStaffManager::mNewLinePage
int mNewLinePage
Definition: GRStaffManager.h:235
GRStaffManager::setSystemFormat
void setSystemFormat(const ARSystemFormat *sysfrm)
SubHash::grstaff
GRStaff * grstaff
Definition: GRStaffManager.h:68
GRStaffManager::mSimpleRods
IRodList * mSimpleRods
Definition: GRStaffManager.h:279
HashEntry::data
SubHashList * data
Definition: GRStaffManager.h:89
SubHash::voice
GRVoice * voice
Definition: GRStaffManager.h:69
GRStaffManager::getGRMusic
GRMusic * getGRMusic()
Definition: GRStaffManager.h:208
GRStaffManager::getNumVoices
int getNumVoices() const
GRStaffManager::getStaff
virtual GRStaff * getStaff(int staff)
GRKey
Key notation tag.
Definition: GRKey.h:29
GRStaffManager::mComplexRods
IRodList * mComplexRods
Definition: GRStaffManager.h:282
GRPage
Graphical representation of a score page. Contains one or more instances of class GRSystem.
Definition: GRPage.h:40
GRStaffManager::deletedElements
NEPointerList * deletedElements
Definition: GRStaffManager.h:234
HashEntry::HashEntry
HashEntry()
Definition: GRStaffManager.h:84
GRStaffManager::FinishSyncSlice
int FinishSyncSlice(const TYPE_TIMEPOSITION &tp)
GRStaffManager
This class manages the staffs of a system.
Definition: GRStaffManager.h:160
Fraction
Numerator and denominator.
Definition: Fraction.h:23
GRStaffManager::firstrod
GRRod * firstrod
Definition: GRStaffManager.h:259
HashEntry::HashEntry
HashEntry(int tmp)
Definition: GRStaffManager.h:78
GRStaffManager::mGrSystem
GRSystem * mGrSystem
Definition: GRStaffManager.h:240
GRStaffManager::mSpringVector
ISpringVector * mSpringVector
Definition: GRStaffManager.h:286
GRBeginSpaceForceFunction2
GRBeginSpaceForceFunction2 is an derived version of GRSpaceForceFunction2.
Definition: GRBeginSpaceForceFunction2.h:30
GRStaffManager::AddPageTag
int AddPageTag(GRNotationElement *grel, GRStaff *grstaff, int voiceid)
GRNotationElement
parent class for all notation elements.
Definition: GRNotationElement.h:54
GRStaffManager::mVoiceMgrList
VoiceManagerList * mVoiceMgrList
Definition: GRStaffManager.h:238
GRMusic
Graphical representation of the music. It handles a list of voices and a list of pages.
Definition: GRMusic.h:41
GREvent
Graphical representation for an event (= has duration).
Definition: GREvent.h:61
GRClef
Graphial representation of a staff clef.
Definition: GRClef.h:28
GRStaffManager::evlist
vce_ev_list evlist
Definition: GRStaffManager.h:301
GRForceRodEntry::rod
GRRod * rod
Definition: GRStaffManager.h:146
GRForceRodEntry::comp
static int comp(const GRForceRodEntry *e1, const GRForceRodEntry *e2)
GRStaffManager::pblist
GRPBList * pblist
Definition: GRStaffManager.h:303
GRStaffManager::getSystemWidthCm
virtual float getSystemWidthCm()
GRRod
Used with springs and space-force functions.
Definition: GRRod.h:33
HashEntry::operator>
int operator>(const HashEntry &h) const
Definition: GRStaffManager.h:92
VoiceEvent::vce
GRVoice * vce
Definition: GRStaffManager.h:112
GRStaffManager::pageHash
PageHash pageHash
Definition: GRStaffManager.h:267
GRVoiceManager
not yet documented
Definition: GRVoiceManager.h:60
VoiceEvent
Definition: GRStaffManager.h:108
GRForceRodEntry::force
float force
Definition: GRStaffManager.h:145
GRStaffState
Keeps information about a staff.
Definition: GRStaff.h:98
GRStaffManager::mMyStaffs
VStaff * mMyStaffs
Definition: GRStaffManager.h:236
GRStaffManager::cursff
GRSpaceForceFunction2 * cursff
Definition: GRStaffManager.h:298
GRStaffManager::addRod
int addRod(GRRod *rod, bool spaceactive, bool atHead=false, int voiceID=-1)
GRForceRodEntry
Definition: GRStaffManager.h:129
GRStaff
A GRStaff represents a single line of music.
Definition: GRStaff.h:181
GRStaffManager::createStaves
void createStaves()
GRStaffManager::getRelativeEndTimePosition
TYPE_TIMEPOSITION getRelativeEndTimePosition() const
Definition: GRStaffManager.h:203
GRStaffManager::systemHash
SystemHash systemHash
Definition: GRStaffManager.h:266
GRStaffManager::beg_spr_list
sprlist * beg_spr_list
Definition: GRStaffManager.h:251
GRStaffManager::getNewLinePage
int getNewLinePage() const
GRStaffManager::mCurSysFormat
const ARSystemFormat * mCurSysFormat
Definition: GRStaffManager.h:244
SubHash::voiceID
int voiceID
Definition: GRStaffManager.h:70
KF_IPointerList
Definition: ARMusicalVoiceState.h:33
GRStaffManager::mSystemDistancePrev
float mSystemDistancePrev
Definition: GRStaffManager.h:228
GRStaffManager::mStaffStateVect
IStaffStateVector * mStaffStateVect
Definition: GRStaffManager.h:289
GRSpaceForceFunction2
This class realizes the second implementation of the space-force-function.
Definition: GRSpringForceIndex.h:99
ARSystemFormat
not yet documented
Definition: ARSystemFormat.h:45
GRStaffManager::staffBottomVector
FloatVector staffBottomVector
Definition: GRStaffManager.h:254
ARAccolade
Accolade tag to group staves into accolades.
Definition: ARAccolade.h:51
GRStaffManager::mGrMusic
GRMusic * mGrMusic
Definition: GRStaffManager.h:241
GRVoice
Graphical representation of a voice.
Definition: GRVoice.h:49
SubHash::SubHash
SubHash()
Definition: GRStaffManager.h:65
GRStaffManager::staffposvect
PositionVector staffposvect
Definition: GRStaffManager.h:237
VoiceEvent::ev
GREvent * ev
Definition: GRStaffManager.h:111
GRStaffManager::setSystemDistance
void setSystemDistance(float distance, const GRVoiceManager &p_vcmgr)
GRForceRodEntry::GRForceRodEntry
GRForceRodEntry()
Definition: GRStaffManager.h:137
GRPossibleBreakState::tp
TYPE_TIMEPOSITION tp
Definition: GRPossibleBreakState.h:129
GRStaffManager::NewPage
void NewPage(GRPage *newpage)
GRStaffManager::~GRStaffManager
virtual ~GRStaffManager()
GRStaffManager::settings
GuidoLayoutSettings settings
Definition: GRStaffManager.h:306
KR_HashTable< NVstring, HashEntry >
GRStaffManager::mCurAccoladeTag
std::vector< const ARAccolade * > mCurAccoladeTag
Definition: GRStaffManager.h:305
GRStaffManager::mTempSpringID
int mTempSpringID
Definition: GRStaffManager.h:270
GuidoLayoutSettings
Engine settings for the graphic score layout.
Definition: GUIDOEngine.h:255
GRStaffManager::mGrPage
GRPage * mGrPage
Definition: GRStaffManager.h:242
SubHash
This class combines the elements that are saved within a hash-entry for a single graphical element.
Definition: GRStaffManager.h:62
KF_IVector
Definition: GRPossibleBreakState.h:20
GRStaffManager::AddSystemTag
int AddSystemTag(GRNotationElement *grel, GRStaff *grstaff, int voiceid)
GRStaffManager::getCurrentBegSFF
GRBeginSpaceForceFunction2 * getCurrentBegSFF()
GRStaffManager::ResumeOpenTags
void ResumeOpenTags(const GRSystemSlice *lastslice, GRSystemSlice *beginslice)
ARPageFormat
not yet documented
Definition: ARPageFormat.h:52
GRStaffManager::mSystemSlices
sysslicelist * mSystemSlices
Definition: GRStaffManager.h:245
ARMusicalTag
The base class for all musical tag classes.
Definition: ARMusicalTag.h:34
NVstring
Definition: nvstring.h:21
ARAuto
Auto tag.
Definition: ARAuto.h:79
GRStaffManager::lastrod
GRRod * lastrod
Definition: GRStaffManager.h:258
GRStaffManager::getOtherGlobalStem
GRGlobalStem * getOtherGlobalStem(GRSystemSlice *psys, GRVoiceManager *curvcmgr, const NVstring &label)
GRStaffManager::voiceSpringArr
VoiceSpringIDArray voiceSpringArr
Definition: GRStaffManager.h:269
GRStaffManager::notifyAccoladeTag
void notifyAccoladeTag(const ARAccolade *inAccoladeTag)
GRStaffManager::setPageFormat
void setPageFormat(const ARPageFormat *pform)
GRStaffManager::AddGRSyncElement
int AddGRSyncElement(GRNotationElement *grel, GRStaff *grstaff, int voiceid, GRVoice *vce, GRNotationElement *sameel=0)
GRStaffManager::mGrSystemSlice
GRSystemSlice * mGrSystemSlice
Definition: GRStaffManager.h:239
GRSystemSlice
Form the basis for the optimum system-break-algorithm.
Definition: GRSystemSlice.h:55
GRStaffManager::deleteRod
int deleteRod(GRRod *rod)
GRStaffManager::mSystemSize
int mSystemSize
Definition: GRStaffManager.h:222
GRGlobalStem
Shared stem.
Definition: GRGlobalStem.h:36
GRStaffManager::mSpringID
int mSpringID
Definition: GRStaffManager.h:274
HashEntry::mSpringID
int mSpringID
Definition: GRStaffManager.h:90
ARBarFormat
the bar format tag parameter.
Definition: ARBarFormat.h:47
GRSystem
Manages a number of staffs and has a given start and end timeposition. GRSystem is the grafical repre...
Definition: GRSystem.h:52
GRStaffManager::setStaffStateTag
virtual bool setStaffStateTag(const ARMusicalTag *tag, int staffnum)
GRStaffManager::staffTopVector
FloatVector staffTopVector
Definition: GRStaffManager.h:253
GRStaffManager::relativeTimePositionOfGR
TYPE_TIMEPOSITION relativeTimePositionOfGR
Definition: GRStaffManager.h:261
GRStaffManager::mIsBreak
bool mIsBreak
Definition: GRStaffManager.h:221
KF_Vector< int >
GRStaffManager::setAutoTag
void setAutoTag(const ARAuto *p_arauto)
GRStaffManager::mMaxClef
GRClef * mMaxClef
Definition: GRStaffManager.h:231
GRStaffManager::IsAutoPageBreak
int IsAutoPageBreak() const
GRStaffManager::beg_sff_list
bsfflist * beg_sff_list
Definition: GRStaffManager.h:250
GRStaffManager::UpdateBeginningSFF
void UpdateBeginningSFF(int staffnum)
GRStaffManager::mArAuto
const ARAuto * mArAuto
Definition: GRStaffManager.h:304
GRStaffManager::mSystemDistance
float mSystemDistance
Definition: GRStaffManager.h:229
NEPointerList
Definition: NEPointerList.h:34
GRStaffManager::setBarFormat
void setBarFormat(const ARBarFormat *barfrmt, GRStaff *curstaff)
GRStaffManager::mArMusic
const ARMusic * mArMusic
Definition: GRStaffManager.h:263
GRStaffManager::getRelativeTimePositionOfGR
virtual TYPE_TIMEPOSITION getRelativeTimePositionOfGR() const
Definition: GRStaffManager.h:199
GRStaffManager::InitialSpringStretch
static float InitialSpringStretch(int start, int end, IRodList *simplerods, IRodList *complerods, ISpringVector *sprvect, std::ofstream *springlog=0)
GRStaffManager::syncHash
SyncHash syncHash
Definition: GRStaffManager.h:268
ARMusic
Translation of a GUIDO Segment into a class.
Definition: ARMusic.h:31
GRPossibleBreakState
GRPossibleBreakState saves the states of all structures that are important, if it is decided by the B...
Definition: GRPossibleBreakState.h:35
HashEntry
Definition: GRStaffManager.h:75
GRStaffManager::mDurationOfGR
TYPE_DURATION mDurationOfGR
Definition: GRStaffManager.h:262

Guido Project Copyright © 2019 Grame-CNCM