Canorus  0.7
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
/home/iurt/rpm/BUILD/canorus-0.7.R1002/src/core/muselementfactory.h
Go to the documentation of this file.
00001 
00010 #ifndef MUSELEMENTFACTORY_H_
00011 #define MUSELEMENTFACTORY_H_
00012 #include "core/barline.h"
00013 
00014 #include "core/staff.h"
00015 #include "core/muselement.h"
00016 #include "core/clef.h"
00017 #include "core/keysignature.h"
00018 #include "core/timesignature.h"
00019 #include "core/voice.h"
00020 #include "core/rest.h"
00021 #include "core/slur.h"
00022 #include "core/functionmark.h"
00023 #include "core/lyricscontext.h"
00024 #include "core/syllable.h"
00025 #include "core/mark.h"
00026 #include "core/articulation.h"
00027 #include "core/fermata.h"
00028 #include "core/tempo.h"
00029 #include "core/ritardando.h"
00030 #include "core/crescendo.h"
00031 #include "core/repeatmark.h"
00032 #include "core/fingering.h"
00033 #include "core/playablelength.h"
00034 #include "core/diatonickey.h"
00035 
00036 class CAMusElement;
00037 
00038 class CAMusElementFactory {
00039 public:
00040         CAMusElementFactory();
00041         ~CAMusElementFactory();
00042 
00043         CAMusElement *createMusElem();
00044 
00045         void removeMusElem( bool bReallyRemove = false );
00046 
00047         void configureMusElem( CAMusElement &roMusElement );
00048 
00049         inline CAMusElement *musElement() { return mpoMusElement; };
00050         inline void setMusElement( CAMusElement *elt ) { mpoMusElement = elt; }
00051 
00052         inline void cloneMusElem() { mpoMusElement = mpoMusElement->clone(); }
00053         inline void emptyMusElem() { mpoMusElement = mpoEmpty; }
00054 
00055         bool configureClef( CAStaff *staff,
00056                             CAMusElement *right );
00057 
00058         bool configureKeySignature( CAStaff *staff,
00059                                     CAMusElement *right );
00060 
00061         bool configureTimeSignature( CAStaff *staff,
00062                                      CAMusElement *right );
00063 
00064         bool configureBarline( CAStaff *staff,
00065                                CAMusElement *right );
00066 
00067         bool configureRest( CAVoice *voice,
00068                             CAMusElement *right );
00069 
00070 
00071         bool configureNote( int pitch,
00072                             CAVoice *voice,
00073                             CAMusElement *right,
00074                             bool addToChord
00075                           );
00076 
00077         static void placeAutoBar( CAPlayable* elt );
00078 
00079         bool configureTuplet( QList<CAPlayable*> listOfNotes );
00080 
00081         bool configureSlur( CAStaff *staff,
00082                             CANote *noteStart, CANote *noteEnd );
00083 
00084         bool configureMark( CAMusElement *elt );
00085 
00086         bool configureFunctionMark( CAFunctionMarkContext *fmc,
00087                                        int timeStart, int timeLength );
00088 
00089         inline CAMusElement::CAMusElementType musElementType() { return _musElementType; }
00090         void setMusElementType( CAMusElement::CAMusElementType eMEType ) { _musElementType = eMEType; }
00091 
00092         inline CAPlayableLength& playableLength() { return _playableLength; }
00093 
00094         inline void setPlayableLength( CAPlayableLength& playableLength )
00095         { _playableLength = playableLength; };
00096 
00097         void addPlayableDotted( int add, CAPlayableLength curLength );
00098 
00099         inline CANote::CAStemDirection noteStemDirection() { return _eNoteStemDirection; }
00100 
00101         inline void setNoteStemDirection( CANote::CAStemDirection eDir )
00102         { _eNoteStemDirection = eDir; }
00103 
00104         inline int  noteAccs() { return _iNoteAccs; };
00105 
00106         inline void setNoteAccs( int iNoteAccs )
00107         { _iNoteAccs = iNoteAccs; };
00108 
00109         inline void addNoteAccs( int iAdd )
00110         { if (_iNoteAccs+iAdd < 3) _iNoteAccs+= iAdd; };
00111 
00112         inline void subNoteAccs( int iSub )
00113         { if (_iNoteAccs-iSub > -3) _iNoteAccs-= iSub; };
00114 
00115         inline int diatonicKeyNumberOfAccs() { return _diatonicKeyNumberOfAccs; }
00116         inline void setDiatonicKeyNumberOfAccs(int accs) { _diatonicKeyNumberOfAccs = accs; }
00117         inline CADiatonicKey::CAGender diatonicKeyGender() { return _diatonicKeyGender; }
00118         inline void setDiatonicKeyGender( CADiatonicKey::CAGender g ) { _diatonicKeyGender = g; }
00119 
00120         inline int  noteExtraAccs() { return _iNoteExtraAccs; };
00121 
00122         inline void setNoteExtraAccs( int iNoteExtraAccs )
00123         { _iNoteExtraAccs = iNoteExtraAccs; };
00124 
00125         inline void addNoteExtraAccs( int iAdd )
00126         { _iNoteExtraAccs += iAdd; };
00127 
00128         inline void subNoteExtraAccs( int iSub )
00129         { _iNoteExtraAccs -= iSub; };
00130 
00131         inline CARest::CARestType restType() { return _eRestType; }
00132 
00133         inline void setRestType(CARest::CARestType eType)
00134         { _eRestType = eType; }
00135 
00136         inline int timeSigBeats() { return _iTimeSigBeats; }
00137         inline void setTimeSigBeats( int iTimeSigBeats )
00138         { _iTimeSigBeats = iTimeSigBeats; };
00139 
00140         inline int timeSigBeat() { return _iTimeSigBeat; }
00141         inline void setTimeSigBeat( int iTimeSigBeat )
00142         { _iTimeSigBeat = iTimeSigBeat; };
00143 
00144         inline CAClef::CAPredefinedClefType clef() { return _eClef; }
00145         inline void setClef( CAClef::CAPredefinedClefType eClefType )
00146         { _eClef = eClefType; };
00147 
00148         inline int clefOffset() { return _iClefOffset; } // readable offset interval, not internal offset
00149         inline void setClefOffset( int offset )
00150         { _iClefOffset= offset; };
00151 
00152         inline CABarline::CABarlineType barlineType() { return _eBarlineType; }
00153         inline void setBarlineType( CABarline::CABarlineType type)
00154         { _eBarlineType = type; }
00155 
00156         inline int tupletNumber() { return _tupletNumber; }
00157         inline void setTupletNumber( int number ) { _tupletNumber = number; }
00158 
00159         inline int tupletActualNumber() { return _tupletActualNumber; }
00160         inline void setTupletActualNumber( int actualNumber ) { _tupletActualNumber = actualNumber; }
00161 
00162         inline CASlur::CASlurType slurType() { return _eSlurType; }
00163         inline void setSlurType( CASlur::CASlurType type ) { _eSlurType = type; }
00164 
00165         inline CASlur::CASlurStyle slurStyle() { return _slurStyle; }
00166         inline void setSlurStyle( CASlur::CASlurStyle style ) { _slurStyle = style; }
00167 
00168         inline CAMark::CAMarkType markType() { return _markType; }
00169         inline void setMarkType( CAMark::CAMarkType t ) { _markType = t; }
00170 
00171         inline CAArticulation::CAArticulationType articulationType() { return _articulationType; }
00172         inline void setArticulationType( CAArticulation::CAArticulationType t ) { _articulationType = t; }
00173 
00174         inline CAFunctionMark::CAFunctionType fmFunction() { return _fmFunction; }
00175         inline void setFMFunction( CAFunctionMark::CAFunctionType f ) { _fmFunction = f; }
00176 
00177         inline CAFunctionMark::CAFunctionType fmChordArea() { return _fmChordArea; }
00178         inline void setFMChordArea( CAFunctionMark::CAFunctionType c ) { _fmChordArea = c; }
00179 
00180         inline CAFunctionMark::CAFunctionType fmTonicDegree() { return _fmTonicDegree; }
00181         inline void setFMTonicDegree( CAFunctionMark::CAFunctionType td ) { _fmTonicDegree = td; }
00182 
00183         inline bool isFMFunctionMinor() { return _fmFunctionMinor; }
00184         inline void setFMFunctionMinor( bool m ) { _fmFunctionMinor = m; }
00185 
00186         inline bool isFMTonicDegreeMinor() { return _fmTonicDegreeMinor; }
00187         inline void setFMTonicDegreeMinor( bool m ) { _fmTonicDegreeMinor = m; }
00188 
00189         inline bool isFMChordAreaMinor() { return _fmChordAreaMinor; }
00190         inline void setFMChordAreaMinor( bool m ) { _fmChordAreaMinor = m; }
00191 
00192         inline bool isFMEllipse() { return _fmEllipse; }
00193         inline void setFMEllipse( bool e ) { _fmEllipse = e; }
00194 
00195         inline const QString dynamicText() { return _dynamicText; }
00196         inline void setDynamicText( const QString t ) { _dynamicText = t; }
00197 
00198         inline const int dynamicVolume() { return _dynamicVolume; }
00199         inline void setDynamicVolume( const int vol ) { _dynamicVolume = vol; }
00200 
00201         inline const int instrument() { return _instrument; }
00202         inline void setInstrument( const int instrument ) { _instrument = instrument; }
00203 
00204         inline const CAFermata::CAFermataType fermataType() { return _fermataType; }
00205         inline void setFermataType( const CAFermata::CAFermataType type ) { _fermataType = type; }
00206 
00207         inline const int tempoBpm() { return _tempoBpm; }
00208         inline void setTempoBpm( const int tempoBpm ) { _tempoBpm = tempoBpm; }
00209 
00210         inline CAPlayableLength& tempoBeat() { return _tempoBeat; }
00211         inline void setTempoBeat( CAPlayableLength& length ) { _tempoBeat = length; }
00212 
00213         inline const CARitardando::CARitardandoType ritardandoType() { return _ritardandoType; }
00214         inline void setRitardandoType( CARitardando::CARitardandoType t ) { _ritardandoType = t; }
00215 
00216         inline const int crescendoFinalVolume() { return _crescendoFinalVolume; }
00217         inline void setCrescendoFinalVolume( const int v ) { _crescendoFinalVolume = v; }
00218 
00219         inline const CACrescendo::CACrescendoType crescendoType() { return _crescendoType; }
00220         inline void setCrescendoType( const CACrescendo::CACrescendoType t ) { _crescendoType = t; }
00221 
00222         inline const CARepeatMark::CARepeatMarkType repeatMarkType() { return _repeatMarkType; }
00223         inline void setRepeatMarkType( const CARepeatMark::CARepeatMarkType t ) { _repeatMarkType = t; }
00224 
00225         inline const int repeatMarkVoltaNumber() { return _repeatMarkVoltaNumber; }
00226         inline void setRepeatMarkVoltaNumber( const int n ) { _repeatMarkVoltaNumber = n; }
00227 
00228         inline const CAFingering::CAFingerNumber fingeringFinger() { return _fingeringFinger; }
00229         inline void setFingeringFinger( const CAFingering::CAFingerNumber f ) { _fingeringFinger = f; }
00230 
00231         inline const bool isFingeringOriginal() { return _fingeringOriginal; }
00232         inline void setFingeringOriginal( const int o ) { _fingeringOriginal = o; }
00233 private:
00234         CAMusElement *mpoMusElement;                    // Newly created music element itself
00235         CAMusElement *mpoEmpty;                         // An empty (dummy) element.
00236 
00238         // Element creation parameters //
00240         CAMusElement::CAMusElementType _musElementType; // Music element type
00241 
00242         // Staff music elements
00243         CAPlayableLength _playableLength; // Length of note/rest to be added
00244         CANote::CAStemDirection _eNoteStemDirection;   // Note stem direction to be inserted
00245         CASlur::CASlurType _eSlurType;                 // Slur type to be placed
00246         int _tupletNumber;                             // Tuplet number of notes
00247         int _tupletActualNumber;                       // Tuplet actual number of notes
00248         int _iPlayableDotted;                          // Number of dots to be inserted for the note/rest
00249         int _iNoteExtraAccs;                           // Extra note accidentals for new notes which user adds/removes with +/- keys
00250         int _iNoteAccs;                                // Note accidentals at specific coordinates updated regularily when in insert mode
00251         CARest::CARestType _eRestType;                 // Hidden/Normal rest
00252         int _diatonicKeyNumberOfAccs;                  // Key signature number of accidentals
00253         CADiatonicKey::CAGender _diatonicKeyGender;    // Major/Minor gender of the key signature
00254         int _iTimeSigBeats;                            // Time signature number of beats to be inserted
00255         int _iTimeSigBeat;                             // Time signature beat to be inserted
00256         CAClef::CAPredefinedClefType _eClef;           // Type of the clef to be inserted
00257         int                          _iClefOffset;     // Interval offset for the clef
00258         CABarline::CABarlineType _eBarlineType;        // Type of the barline
00259         CAMark::CAMarkType _markType;                  // Type of the mark
00260         CAArticulation::CAArticulationType _articulationType; // Type of the articulation mark
00261         CASlur::CASlurStyle _slurStyle;                // Style of the slur (solid, dotted)
00262 
00263         // Function Mark
00264         CAFunctionMark::CAFunctionType _fmFunction;    // Name of the function
00265         CAFunctionMark::CAFunctionType _fmChordArea;   // Chord area of the function
00266         CAFunctionMark::CAFunctionType _fmTonicDegree; // Tonic degree of the function
00267         bool _fmFunctionMinor;
00268         bool _fmChordAreaMinor;
00269         bool _fmTonicDegreeMinor;
00270         bool _fmEllipse;
00271 
00272         // Marks
00273         QString _dynamicText;
00274         int _dynamicVolume;
00275         int _instrument;
00276         CAFermata::CAFermataType _fermataType;
00277         CAPlayableLength _tempoBeat;
00278         int _tempoBpm;
00279         CARitardando::CARitardandoType _ritardandoType;
00280         int _crescendoFinalVolume;
00281         CACrescendo::CACrescendoType _crescendoType;
00282         CARepeatMark::CARepeatMarkType _repeatMarkType;
00283         int _repeatMarkVoltaNumber;
00284         CAFingering::CAFingerNumber _fingeringFinger;
00285         int _fingeringOriginal;
00286 };
00287 #endif // MUSELEMENTFACTORY_H_