Planeshift
Classes | Public Member Functions

Measure< MeasureElementType > Class Template Reference

A measure containing measure elements. More...

#include <pawssheetline.h>

List of all members.

Classes

class  MeasureAttributes
 Keep general attributes that can change from a measure to another like key signature, beats and tempo. More...

Public Member Functions

void AppendMeasure (Measure *measure)
 Append the given measure after this one.
void AttachMeasure (Measure *measure)
 Insert the given measure after this one and update the chord list.
bool Cut (uint divisions)
 Cut the last chords of the measures that exceeds the given number of durations.
void DeleteAllElements ()
 Delete all elements from the measure.
void DeleteChord (Chord *chord)
 Deletes the chord if it belong to this measure.
void DeleteElement (size_t n)
 Delete the element in position n.
void Draw (pawsSheetLine *pawsLine, Chord *selectedChord, int startPosition)
 Draws this measure.
void Empty ()
 Deletes all the chords in this line and keeps only an empty chord.
void Fill (uint divisions)
 Fills the measure with rests if it is incomplete.
void Fit (const MeasureAttributes *const attributes)
 Remove the elements at the end of the measures that exceeds the total duration or push a rest if there are not enough elements.
MeasureAttributes GetAttributes () const
 Get a copy of the attributes of this measure.
MeasureElementType & GetElement (size_t n)
 Get the element at position n.
const MeasureElementType & GetElement (size_t n) const
uint GetEnding ()
 Gets the number of this ending.
uint GetEndRepeat ()
 Gets the number of times this part must be repeat.
ChordGetFirstChord ()
 Returns the first chord of this measure.
ChordGetLastChord ()
 Returns the last chord of this measure.
uint GetMimimumSize (uint noteLength)
 Gets the mimimum size of this measure.
uint GetNChords ()
 Returns the number of chords in this measure.
size_t GetNElements () const
 Get the number of elements in this measure.
int GetNEndRepeat () const
 Get the number of time the repeat at the end of this measure must be performed.
uint GetSize (uint noteLength)
 Returns the measure's size.
bool GetStartRepeat ()
 Gets the start repeat state.
bool Hit (int x, Chord *&chord, bool &before)
 Check if a chord in this measure is hit.
ChordInsertChord (Chord *nearChord, bool before)
 Inserts a new empty chord before or after the given one.
void InsertElement (size_t n, const MeasureElementType &element)
 Insert a copy of the given element after element n.
bool IsEmpty () const
 Check if the measure has at least one element.
bool IsEnding () const
 Return true if this is an ending measure.
bool IsEndRepeat () const
 Return true if this measure ends a repeat section.
bool IsStartRepeat () const
 Return true if this measure starts a repeat section.
 Measure (csRef< iDocumentNode > measure, int quarterDivisions)
 Constructor.
 Measure ()
 Constructor.
 Measure (Chord *firstChord)
 Constructor.
MeasureNext ()
 Returns the next Measure.
MeasurePrev ()
 Returns the previous Measure.
void PushChord (Chord *chord)
 Pushes a chord at the end of the measure.
size_t PushElement (const MeasureElementType &element)
 Push a copy of the given element after all the elements currently in the measure.
void SetBeat (int beats, int beatType)
 Set the beat information.
void SetEnding (bool isEnding)
 Set this measure as an ending.
void SetEnding (bool isEnding)
 Sets this measure as an ending and updates all the following endings.
void SetEndRepeat (uint repeat)
 Sets the number of times this part must be repeat.
void SetFifths (int fifths)
void SetNEndRepeat (int nEndRepeat)
 Set the number of time the repeat at the end of this measure must be performed.
bool SetSize (uint size, uint noteLength)
 Sets the measure's size.
void SetStartRepeat (bool isStartRepeat)
 Set this measure to start a repeat section.
void SetStartRepeat (bool repeat)
 Sets the start repeat of this measure.
void SetTempo (int tempo)
csString ToXML (uint number, csString attributes="")
 Writes this measure as a <measure> XML node.
 ~Measure ()
 Destructor.
 ~Measure ()
 Destructor.

Detailed Description

template<typename MeasureElementType>
class Measure< MeasureElementType >

A measure containing measure elements.

Definition at line 229 of file pawssheetline.h.


Constructor & Destructor Documentation

template<typename MeasureElementType>
Measure< MeasureElementType >::Measure ( Chord firstChord)

Constructor.

Creates a non empty measure.

Parameters:
firstChordthe first chord of the measure.
template<typename MeasureElementType>
Measure< MeasureElementType >::Measure ( csRef< iDocumentNode >  measure,
int  quarterDivisions 
)

Constructor.

Creates a measure from a <measure> XML node.

Parameters:
measurethe <measure> XML node.
quarterDivisionsthe number of divisions in a quarter.
template<typename MeasureElementType>
Measure< MeasureElementType >::~Measure ( )

Destructor.

template<typename MeasureElementType>
Measure< MeasureElementType >::Measure ( )

Constructor.

template<typename MeasureElementType>
Measure< MeasureElementType >::~Measure ( )

Destructor.


Member Function Documentation

template<typename MeasureElementType>
void Measure< MeasureElementType >::AppendMeasure ( Measure< MeasureElementType > *  measure)

Append the given measure after this one.

This is not an insertion and the next measure is lost.

Parameters:
measurethe measure to insert.
template<typename MeasureElementType>
void Measure< MeasureElementType >::AttachMeasure ( Measure< MeasureElementType > *  measure)

Insert the given measure after this one and update the chord list.

If the given measure is already the next one it does nothing.

Parameters:
measurethe measure to insert.
template<typename MeasureElementType>
bool Measure< MeasureElementType >::Cut ( uint  divisions)

Cut the last chords of the measures that exceeds the given number of durations.

Parameters:
divisionsthe number of divisions that this measure must have.
Returns:
true if this measure is completed, false otherwise.
template<typename MeasureElementType>
void Measure< MeasureElementType >::DeleteAllElements ( ) [inline]

Delete all elements from the measure.

Definition at line 422 of file scoreelements.h.

template<typename MeasureElementType>
void Measure< MeasureElementType >::DeleteChord ( Chord chord)

Deletes the chord if it belong to this measure.

Parameters:
chordthe chord to delete.
template<typename MeasureElementType>
void Measure< MeasureElementType >::DeleteElement ( size_t  n) [inline]

Delete the element in position n.

If n is not a valid index it does nothing.

Parameters:
nThe index of the measure element.

Definition at line 417 of file scoreelements.h.

template<typename MeasureElementType>
void Measure< MeasureElementType >::Draw ( pawsSheetLine pawsLine,
Chord selectedChord,
int  startPosition 
)

Draws this measure.

Parameters:
pawsLinethe pawsSheetLine that store the font-dependent parameters.
selectedChordthe current selected chord.
startPositionthe horizontal position where the first chord must be drawn.
template<typename MeasureElementType>
void Measure< MeasureElementType >::Empty ( )

Deletes all the chords in this line and keeps only an empty chord.

template<typename MeasureElementType>
void Measure< MeasureElementType >::Fill ( uint  divisions)

Fills the measure with rests if it is incomplete.

Converts all the empty chords into rests of the same duration.

Parameters:
divisionsthe number of divisions that this measure must have.
template<typename MeasureElementType>
void Measure< MeasureElementType >::Fit ( const MeasureAttributes *const  attributes)

Remove the elements at the end of the measures that exceeds the total duration or push a rest if there are not enough elements.

The total duration is determined from the beat and beat type contained in the attributes. Attributes specified in this measure have priority. If they are undefined, the given attributes are used instead.

Parameters:
attributesAttributes of previous measures. This can be a null pointer if this measure specifies both beat and beat type. If this is not the case however, the parameter must specify at least information about beat and beat type.
template<typename MeasureElementType>
MeasureAttributes Measure< MeasureElementType >::GetAttributes ( ) const

Get a copy of the attributes of this measure.

Returns:
The attributes of this measure.
template<typename MeasureElementType>
MeasureElementType& Measure< MeasureElementType >::GetElement ( size_t  n) [inline]

Get the element at position n.

Parameters:
nThe index of the element.
Returns:
The element.

Definition at line 450 of file scoreelements.h.

template<typename MeasureElementType>
const MeasureElementType& Measure< MeasureElementType >::GetElement ( size_t  n) const [inline]

Get the element at position n.

Parameters:
nThe index of the element.
Returns:
The element.

Definition at line 455 of file scoreelements.h.

template<typename MeasureElementType>
uint Measure< MeasureElementType >::GetEnding ( ) [inline]

Gets the number of this ending.

Returns:
the number of the ending, 0 if this is not an ending.

Definition at line 319 of file pawssheetline.h.

template<typename MeasureElementType>
uint Measure< MeasureElementType >::GetEndRepeat ( ) [inline]

Gets the number of times this part must be repeat.

Returns:
the number of times this part must be repeat.

Definition at line 307 of file pawssheetline.h.

template<typename MeasureElementType>
Chord* Measure< MeasureElementType >::GetFirstChord ( ) [inline]

Returns the first chord of this measure.

Returns:
the first chord of this measure.

Definition at line 345 of file pawssheetline.h.

template<typename MeasureElementType>
Chord* Measure< MeasureElementType >::GetLastChord ( ) [inline]

Returns the last chord of this measure.

Returns:
the last chord of this measure.

Definition at line 351 of file pawssheetline.h.

template<typename MeasureElementType>
uint Measure< MeasureElementType >::GetMimimumSize ( uint  noteLength)

Gets the mimimum size of this measure.

Parameters:
noteLengththe length of a note.
Returns:
the mimimum size of this measure.
template<typename MeasureElementType>
uint Measure< MeasureElementType >::GetNChords ( ) [inline]

Returns the number of chords in this measure.

Returns:
the number of chords in this measure.

Definition at line 266 of file pawssheetline.h.

template<typename MeasureElementType>
size_t Measure< MeasureElementType >::GetNElements ( ) const [inline]

Get the number of elements in this measure.

Returns:
The number of elements in this measure.

Definition at line 462 of file scoreelements.h.

template<typename MeasureElementType>
int Measure< MeasureElementType >::GetNEndRepeat ( ) const [inline]

Get the number of time the repeat at the end of this measure must be performed.

Returns:
The number of time the repeat must be performed or 0 if there is not a repeat at the end of the measure.

Definition at line 470 of file scoreelements.h.

template<typename MeasureElementType>
uint Measure< MeasureElementType >::GetSize ( uint  noteLength)

Returns the measure's size.

Parameters:
noteLengththe length of a note.
Returns:
the measure's size.
template<typename MeasureElementType>
bool Measure< MeasureElementType >::GetStartRepeat ( ) [inline]

Gets the start repeat state.

Returns:
the start repeat state.

Definition at line 295 of file pawssheetline.h.

template<typename MeasureElementType>
bool Measure< MeasureElementType >::Hit ( int  x,
Chord *&  chord,
bool &  before 
)

Check if a chord in this measure is hit.

Parameters:
xthe horizontal position of the input from the beginning of the measure.
chordat the end this pointer will contains the hit chord or null if any chord has been hit.
beforeat the end this boolean will be true if the click has happened before the selected chord, false if after.
Returns:
true if a note has been hit, false otherwise.
template<typename MeasureElementType>
Chord* Measure< MeasureElementType >::InsertChord ( Chord nearChord,
bool  before 
)

Inserts a new empty chord before or after the given one.

Parameters:
nearChordthe chord near the new one.
beforetrue to insert before the given chord, false to insert it after.
Returns:
the new Chord.
template<typename MeasureElementType>
void Measure< MeasureElementType >::InsertElement ( size_t  n,
const MeasureElementType &  element 
)

Insert a copy of the given element after element n.

If n is greater than the number of elements in this measure, the element is pushed at the end.

Parameters:
nThe number of the element after which the given element must be inserted.
elementThe element to insert in the measure.
template<typename MeasureElementType>
bool Measure< MeasureElementType >::IsEmpty ( ) const [inline]

Check if the measure has at least one element.

Returns:
True if this measure does not contain elements, false otherwise.

Definition at line 486 of file scoreelements.h.

template<typename MeasureElementType>
bool Measure< MeasureElementType >::IsEnding ( ) const [inline]

Return true if this is an ending measure.

Returns:
True if this is an ending measure, false otherwise.

Definition at line 493 of file scoreelements.h.

template<typename MeasureElementType>
bool Measure< MeasureElementType >::IsEndRepeat ( ) const [inline]

Return true if this measure ends a repeat section.

Returns:
True if this is the end of a repeat section, false otherwise.

Definition at line 500 of file scoreelements.h.

template<typename MeasureElementType>
bool Measure< MeasureElementType >::IsStartRepeat ( ) const [inline]

Return true if this measure starts a repeat section.

Returns:
True if this is the start of a repeat section, false otherwise.

Definition at line 507 of file scoreelements.h.

template<typename MeasureElementType>
Measure* Measure< MeasureElementType >::Next ( ) [inline]

Returns the next Measure.

Returns:
the next Measure.

Definition at line 254 of file pawssheetline.h.

template<typename MeasureElementType>
Measure* Measure< MeasureElementType >::Prev ( ) [inline]

Returns the previous Measure.

Returns:
the previous Measure.

Definition at line 260 of file pawssheetline.h.

template<typename MeasureElementType>
void Measure< MeasureElementType >::PushChord ( Chord chord)

Pushes a chord at the end of the measure.

Parameters:
chordthe new chord.
template<typename MeasureElementType>
size_t Measure< MeasureElementType >::PushElement ( const MeasureElementType &  element) [inline]

Push a copy of the given element after all the elements currently in the measure.

Parameters:
elementThe element to push in the measure.
Returns:
The index of the pushed element.

Definition at line 515 of file scoreelements.h.

template<typename MeasureElementType>
void Measure< MeasureElementType >::SetBeat ( int  beats,
int  beatType 
)

Set the beat information.

Both beats and beatType must be defined. If only one of them is undefined, both of them will be saved as undefined.

Parameters:
beatsThe numerator of the time signature.
beatTypeThe denominator of the time signature.
template<typename MeasureElementType>
void Measure< MeasureElementType >::SetEnding ( bool  isEnding)

Set this measure as an ending.

Parameters:
isEndingTrue if this is an ending, false otherwise.
template<typename MeasureElementType>
void Measure< MeasureElementType >::SetEnding ( bool  isEnding)

Sets this measure as an ending and updates all the following endings.

Parameters:
isEndingtrue if this is an ending.
template<typename MeasureElementType>
void Measure< MeasureElementType >::SetEndRepeat ( uint  repeat) [inline]

Sets the number of times this part must be repeat.

Parameters:
repeat0 to not repeat.

Definition at line 313 of file pawssheetline.h.

template<typename MeasureElementType>
void Measure< MeasureElementType >::SetFifths ( int  fifths)

Set the key signature as the number of accidentals.

Parameters:
fifthsThe number of accidentals in the key signature. Positive for sharps, negative for flats.
template<typename MeasureElementType>
void Measure< MeasureElementType >::SetNEndRepeat ( int  nEndRepeat)

Set the number of time the repeat at the end of this measure must be performed.

Parameters:
nEndRepeatThe number of time the repeat must be performed or 0 if this measure does not end a repeat.
template<typename MeasureElementType>
bool Measure< MeasureElementType >::SetSize ( uint  size,
uint  noteLength 
)

Sets the measure's size.

Parameters:
sizethe new size of the measure.
noteLengththe length of the note with the current font.
Returns:
true if the given space is greater than the minimum space allowed.
template<typename MeasureElementType>
void Measure< MeasureElementType >::SetStartRepeat ( bool  isStartRepeat)

Set this measure to start a repeat section.

Parameters:
isEndingTrue if this is the start of a repeat section, false otherwise.
template<typename MeasureElementType>
void Measure< MeasureElementType >::SetStartRepeat ( bool  repeat) [inline]

Sets the start repeat of this measure.

Parameters:
repeattrue to start a repeat, false otherwise.

Definition at line 301 of file pawssheetline.h.

template<typename MeasureElementType>
void Measure< MeasureElementType >::SetTempo ( int  tempo)

Set the tempo.

Parameters:
tempoThe new tempo.
template<typename MeasureElementType>
csString Measure< MeasureElementType >::ToXML ( uint  number,
csString  attributes = "" 
)

Writes this measure as a <measure> XML node.

Parameters:
numberthe number of this measure.
attributesthe attributes and direction nodes.
Returns:
the <measure> XML node.

The documentation for this class was generated from the following files: