Canorus  0.7
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
/home/iurt/rpm/BUILD/canorus-0.7.R1002/src/export/lilypondexport.h
Go to the documentation of this file.
00001 
00008 #ifndef LILYPONDEXPORT_H_
00009 #define LILYPONDEXPORT_H_
00010 
00011 #include <QTextStream>
00012 #include <QString>
00013 
00014 #include "core/keysignature.h"
00015 #include "core/timesignature.h"
00016 #include "core/clef.h"
00017 #include "core/barline.h"
00018 #include "core/playable.h"
00019 #include "core/note.h"
00020 #include "core/rest.h"
00021 #include "core/document.h"
00022 #include "core/lyricscontext.h"
00023 #include "core/syllable.h"
00024 
00025 #include "export/export.h"
00026 
00027 class CALilyPondExport : public CAExport {
00028 public:
00029         CALilyPondExport( QTextStream *out=0 );
00030 
00032         // Polling export status //
00034         // Setter methods are private!
00035         inline CAVoice *curVoice() { return _curVoice; }
00036         inline CASheet *curSheet() { return _curSheet; }
00037         inline CAContext *curContext() { return _curContext; }
00038         inline int curContextIndex() { return _curContextIndex; }
00039         inline int curIndentLevel() { return _curIndentLevel; }
00040 
00041 private:
00042         void exportDocumentImpl(CADocument *doc);
00043         void exportSheetImpl(CASheet *sheet);
00044         void exportScoreBlock(CASheet *sheet);
00045         void exportStaffVoices(CAStaff *staff);
00046         void exportVoiceImpl(CAVoice *voice);
00047         void exportLyricsContextBlock(CALyricsContext *lc);
00048         void exportLyricsContextImpl(CALyricsContext* lc);
00049         void exportMarks( CAMusElement* );
00050         void exportPlayable( CAPlayable *elt );
00051 
00052         void writeDocumentHeader();
00053         CADiatonicPitch writeRelativeIntro();
00054         void doAnacrusisCheck(CATimeSignature *time);
00055 
00057         // Helper methods //
00059         const QString clefTypeToLilyPond( CAClef::CAClefType type, int c1, int offset );
00060         const QString diatonicKeyGenderToLilyPond( CADiatonicKey::CAGender gender);
00061         const QString playableLengthToLilyPond( CAPlayableLength length );
00062         const QString diatonicPitchToLilyPond( CADiatonicPitch p );
00063         const QString restTypeToLilyPond(CARest::CARestType type);
00064         const QString barlineTypeToLilyPond(CABarline::CABarlineType type);
00065         const QString syllableToLilyPond( CASyllable *s );
00066 
00067         inline const QString relativePitchToString(CANote* note, CADiatonicPitch prevPitch) {
00068                 return relativePitchToString( note->diatonicPitch(), prevPitch);
00069         }
00070         const QString relativePitchToString( CADiatonicPitch p, CADiatonicPitch prevPitch);
00071         void voiceVariableName( QString &name, int staffNum, int voiceNum );
00072         void spellNumbers( QString &s );
00073 
00074         QString markupString( QString );
00075         QString escapeWeirdChars( QString );
00076 
00077         void indent();
00078         inline void indentMore() { ++_curIndentLevel; }
00079         inline void indentLess() { --_curIndentLevel; }
00080 
00082         // Getter/Setter methods //
00084         inline void setCurVoice(CAVoice *voice) { _curVoice = voice; }
00085         inline void setCurSheet(CASheet *sheet) { _curSheet = sheet; }
00086         inline void setCurContext(CAContext *context) { _curContext = context; }
00087         inline void setCurContextIndex(int c) { _curContextIndex = c; }
00088         inline void setIndentLevel( int level) { _curIndentLevel = level; }
00089 
00091         // Members //
00093         QTextStream *_out;
00094         CAVoice *_curVoice;
00095         CASheet *_curSheet;
00096         CAContext *_curContext;
00097         int _curContextIndex;
00098         int _curIndentLevel;
00099 
00100         // Voice exporting current status
00101         CADiatonicPitch _lastNotePitch;
00102         CAPlayableLength _lastPlayableLength;
00103         int _curStreamTime;
00104 };
00105 
00106 #endif /* LILYPONDEXPORT_H_*/