1 /* This file is part of the KDE project 2 * Copyright (C) 2007 Marijn Kruisselbrink <mkruisselbrink@kde.org> 3 * 4 * This library is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU Library General Public 6 * License as published by the Free Software Foundation; either 7 * version 2 of the License, or (at your option) any later version. 8 * 9 * This library is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * Library General Public License for more details. 13 * 14 * You should have received a copy of the GNU Library General Public License 15 * along with this library; see the file COPYING.LIB. If not, write to 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 * Boston, MA 02110-1301, USA. 18 */ 19 #ifndef MUSIC_RENDERER_H 20 #define MUSIC_RENDERER_H 21 22 #include "core/Global.h" 23 #include <QColor> 24 #include <QPointF> 25 26 class MusicStyle; 27 class QPainter; 28 29 namespace MusicCore { 30 class Sheet; 31 class Part; 32 class Staff; 33 class Voice; 34 class VoiceElement; 35 class StaffElement; 36 class Clef; 37 class KeySignature; 38 class TimeSignature; 39 class Chord; 40 } 41 42 class MusicRenderer { 43 public: 44 struct RenderState { RenderStateRenderState45 RenderState() : clef(0) {} 46 47 MusicCore::Clef* clef; 48 }; 49 50 explicit MusicRenderer(MusicStyle *style); 51 52 void renderSheet(QPainter& painter, MusicCore::Sheet* sheet, int firstSystem, int lastSystem); 53 void renderPart(QPainter& painter, MusicCore::Part* part, int firstBar, int lastBar, const QColor& color = Qt::black); 54 void renderStaff(QPainter& painter, MusicCore::Staff* staff, int firstBar, int lastBar, const QColor& color = Qt::black); 55 void renderVoice(QPainter& painter, MusicCore::Voice* voice, int firstBar, int lastBar, const QColor& color = Qt::black); 56 void renderElement(QPainter& painter, MusicCore::VoiceElement* element, MusicCore::Voice* voice, const QPointF& pos, RenderState& state, const QColor& color = Qt::black); 57 void renderStaffElement(QPainter& painter, MusicCore::StaffElement* element, const QPointF& pos, RenderState& state, const QColor& color = Qt::black); 58 59 void renderClef(QPainter& painter, MusicCore::Clef* clef, const QPointF& pos, RenderState& state, const QColor& color = Qt::black, bool ignoreOwnPos = false); 60 void renderKeySignature(QPainter& painter, MusicCore::KeySignature* keySignature, const QPointF& pos, RenderState& state, const QColor& color = Qt::black, bool ignoreOwnPos = false); 61 void renderTimeSignature(QPainter& painter, MusicCore::TimeSignature* timeSignature, const QPointF& pos, const QColor& color = Qt::black); 62 void renderChord(QPainter& painter, MusicCore::Chord* chord, MusicCore::Voice* voice, const QPointF& ref, const QColor& color = Qt::black); 63 void renderRest(QPainter& painter, MusicCore::Duration duration, const QPointF& pos, const QColor& color = Qt::black); 64 void renderNote(QPainter& painter, MusicCore::Duration duration, const QPointF& pos, qreal stemLength, const QColor& color = Qt::black); 65 void renderAccidental(QPainter& painter, int accidentals, const QPointF& pos, const QColor& color = Qt::black); 66 private: 67 MusicStyle* m_style; 68 bool m_debug; 69 }; 70 71 #endif // MUSIC_RENDERER_H 72