Canorus  0.7
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Private Attributes | List of all members
CAStaff Class Reference

Represents a staff in the sheet. More...

#include <staff.h>

Inheritance diagram for CAStaff:
Inheritance graph
[legend]

Public Member Functions

 CAStaff (const QString name, CASheet *s, int numberOfLines=5)
 
 ~CAStaff ()
 
int numberOfLines ()
 
void setNumberOfLines (int val)
 
void clear ()
 
CAStaffclone (CASheet *s)
 
int voiceCount ()
 
CAVoicevoiceAt (int i)
 
int voiceIndex (CAVoice *voice)
 
void removeVoice (CAVoice *voice)
 
QList< CAVoice * > voiceList ()
 
CAVoicevoiceByName (const QString name)
 
void addVoice (CAVoice *voice)
 
CAVoiceaddVoice ()
 
CAMusElementnext (CAMusElement *elt)
 
CAMusElementprevious (CAMusElement *elt)
 
bool remove (CAMusElement *elt, bool updateSignTimes)
 
bool remove (CAMusElement *elt)
 
int lastTimeEnd ()
 
QList< CAMusElement * > getEltByType (CAMusElement::CAMusElementType type, int startTime)
 
QList< CAPlayable * > getChord (int time)
 
bool synchronizeVoices ()
 
- Public Member Functions inherited from CAContext
 CAContext (const QString name, CASheet *s)
 
virtual ~CAContext ()
 
const QString name ()
 
void setName (const QString name)
 
CAContextType contextType ()
 
CASheetsheet ()
 
void setSheet (CASheet *sheet)
 

Private Attributes

QList< CAVoice * > _voiceList
 
int _numberOfLines
 

Additional Inherited Members

- Public Types inherited from CAContext
enum  CAContextType { Staff, FunctionMarkContext, LyricsContext }
 
- Protected Member Functions inherited from CAContext
void setContextType (CAContextType t)
 
- Protected Attributes inherited from CAContext
CASheet_sheet
 
QString _name
 
CAContextType _contextType
 

Detailed Description

Represents a staff in the sheet.

Copyright (c) 2006-2008, Matevž Jekovec, Canorus development team All Rights Reserved. See AUTHORS for a complete list of authors.

Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE.GPL for details.

This class represents usually an infinite long n-line staff where notes, rests, barlines, clefs and other music elements are placed.

CAStaff is by hierarchy part of CASheet and can include various number of CAVoice objects.

See Also
CADrawableStaff, CASheet, CAVoice

Constructor & Destructor Documentation

CAStaff::CAStaff ( const QString  name,
CASheet s,
int  numberOfLines = 5 
)

Creates a new empty staff with parent sheet s, named name and numberOfLines.

Warning
By default, no voices are created where music elements can be put. Use addVoice() to append a new voice.

References CAContext::_contextType, CAContext::_name, _numberOfLines, CAContext::name(), numberOfLines(), and CAContext::Staff.

Referenced by clone().

Here is the call graph for this function:

Here is the caller graph for this function:

CAStaff::~CAStaff ( )

References clear().

Here is the call graph for this function:

Member Function Documentation

void CAStaff::addVoice ( CAVoice voice)

Adds a voice voice to the staff and sets its parent to this staff. Call synchronizeVoices() manually to synchronize a new voice with other voices.

References _voiceList, and CAVoice::setStaff().

Referenced by CASheet::addStaff(), CAMusicXmlImport::addVoiceIfNeeded(), clone(), CAMainWin::copySelection(), CAPropertiesDialog::createDocumentFromTree(), CAMainWin::on_uiNewVoice_triggered(), CAMainWin::on_uiRemoveVoice_triggered(), CAMainWin::pasteAt(), CAMainWin::sourceViewPortCommit(), CACanorusMLImport::startElement(), and CAMidiImport::writeMidiFileEventsToScore().

Here is the call graph for this function:

Here is the caller graph for this function:

CAVoice * CAStaff::addVoice ( )

Adds an empty voice to the staff. Call synchronizeVoices() manually to synchronize a new voice with other voices.

References CAContext::name(), and voiceCount().

Here is the call graph for this function:

void CAStaff::clear ( )
virtual

Implements CAContext.

References _voiceList.

Referenced by ~CAStaff().

Here is the caller graph for this function:

CAStaff * CAStaff::clone ( CASheet s)
virtual
QList< CAPlayable * > CAStaff::getChord ( int  time)

Returns a list of notes and rests (chord) for all the voices in the staff in the given time slice time.

This is useful for determination of the harmony at certain point in time.

See Also
CASheet:getChord(), CAVoice::getChord()

References CAVoice::getChord(), voiceAt(), and voiceCount().

Referenced by CAMainWin::deleteSelection(), and CASheet::getChord().

Here is the call graph for this function:

Here is the caller graph for this function:

QList< CAMusElement * > CAStaff::getEltByType ( CAMusElement::CAMusElementType  type,
int  startTime 
)

Returns a list of pointers to actual music elements which have the given startTime and are of given type. This searches the entire staff through all the voices.

See Also
CASheet::getChord()

References _voiceList.

Referenced by CALilyPondImport::findSharedElement(), and CAMidiImport::findSharedElement().

Here is the caller graph for this function:

int CAStaff::lastTimeEnd ( )

Returns the end of the last music element in the staff.

See Also
CAVoice::lastTimeEnd()

References _voiceList.

CAMusElement * CAStaff::next ( CAMusElement elt)
virtual

Returns the pointer to the element right next to the given elt in any of the voice.

See Also
next()

Implements CAContext.

References CAVoice::contains(), CAVoice::next(), voiceAt(), and voiceCount().

Referenced by CAMainWin::scoreViewPortKeyPress().

Here is the call graph for this function:

Here is the caller graph for this function:

int CAStaff::numberOfLines ( )
inline
CAMusElement * CAStaff::previous ( CAMusElement elt)
virtual

Returns the pointer to the element right before the given elt in any of the voice.

See Also
previous()

Implements CAContext.

References CAVoice::contains(), CAVoice::previous(), voiceAt(), and voiceCount().

Here is the call graph for this function:

bool CAStaff::remove ( CAMusElement elt,
bool  updateSignTimes 
)

Removes the element elt. Updates timeStarts for elements after the given element.

Also updates non-playable shared signs after the element, if updateSignTimes is True.

Eventually does the same as CAVoice::remove(), but checks for any voices present in the staff.

References CAVoice::remove(), voiceAt(), and voiceCount().

Here is the call graph for this function:

bool CAStaff::remove ( CAMusElement elt)
inlinevirtual

Implements CAContext.

void CAStaff::removeVoice ( CAVoice voice)
inline
void CAStaff::setNumberOfLines ( int  val)
inline

References _numberOfLines.

Referenced by CAPropertiesDialog::applyProperties().

Here is the caller graph for this function:

bool CAStaff::synchronizeVoices ( )

Fixes voices inconsistency: 1) If any of the voices include signs (key sigs, clefs etc.) which aren't present in all voices, add that sign to all the voices. 2) If a voice includes a sign which overlaps a playable element in other voice, insert rests until the sign is moved at the end of the overlapped chord in all voices. 3) If a voice elements are not linear (every N-th element's timeEnd should be N+1-th element's timeStart) inserts rests to achieve linearity.

Synchronizing voices is relatively slow (O(n*m) where n is number of voices and m number of elements in voice n). This was the main reason to not automate the synchronization: import filters use lots of insertions and synchronization of the voices every time a new element is inserted would considerably slow down the import filter.

Returns True, if everything was ok. False, if fixes were needed.

References CARest::composeRests(), CAVoice::musElementList(), CAVoice::synchronizeMusElements(), CAMusElement::timeEnd(), CAMusElement::timeStart(), CAVoice::updateTimes(), voiceAt(), and voiceCount().

Referenced by CAMusicXmlImport::addVoiceIfNeeded(), CACanorusMLImport::endElement(), CAMainWin::insertMusElementAt(), CAMainWin::on_uiNewVoice_triggered(), CAMainWin::on_uiPlayableLength_toggled(), CAMainWin::pasteAt(), CAMusElementFactory::placeAutoBar(), CAMusicXmlImport::readMeasure(), CAMainWin::scoreViewPortKeyPress(), and CAMainWin::sourceViewPortCommit().

Here is the call graph for this function:

Here is the caller graph for this function:

CAStaff::voiceAt ( int  i)
inline
CAVoice * CAStaff::voiceByName ( const QString  name)

Returns the first voice with the given name or Null, if such a voice doesn't exist.

References _voiceList, and CAContext::name().

Here is the call graph for this function:

CAStaff::voiceCount ( )
inline
int CAStaff::voiceIndex ( CAVoice voice)
inline

References _voiceList.

Referenced by CAMainWin::copySelection(), and CAVoice::voiceNumber().

Here is the caller graph for this function:

QList<CAVoice*> CAStaff::voiceList ( )
inline

Member Data Documentation

int CAStaff::_numberOfLines
private
QList<CAVoice *> CAStaff::_voiceList
private

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