File indexing completed on 2024-05-19 16:07:13

0001 /* This file is part of the KDE project
0002  * Copyright (C) 2007 Marijn Kruisselbrink <mkruisselbrink@kde.org>
0003  *
0004  * This library is free software; you can redistribute it and/or
0005  * modify it under the terms of the GNU Library General Public
0006  * License as published by the Free Software Foundation; either
0007  * version 2 of the License, or (at your option) any later version.
0008  *
0009  * This library is distributed in the hope that it will be useful,
0010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0012  * Library General Public License for more details.
0013  *
0014  * You should have received a copy of the GNU Library General Public License
0015  * along with this library; see the file COPYING.LIB.  If not, write to
0016  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0017  * Boston, MA 02110-1301, USA.
0018  */
0019 #ifndef MUSIC_RENDERER_H
0020 #define MUSIC_RENDERER_H
0021 
0022 #include "core/Global.h"
0023 #include <QColor>
0024 #include <QPointF>
0025 
0026 class MusicStyle;
0027 class QPainter;
0028 
0029 namespace MusicCore {
0030     class Sheet;
0031     class Part;
0032     class Staff;
0033     class Voice;
0034     class VoiceElement;
0035     class StaffElement;
0036     class Clef;
0037     class KeySignature;
0038     class TimeSignature;
0039     class Chord;
0040 }
0041 
0042 class MusicRenderer {
0043 public:
0044     struct RenderState {
0045         RenderState() : clef(0) {}
0046 
0047         MusicCore::Clef* clef;
0048     };
0049 
0050     explicit MusicRenderer(MusicStyle *style);
0051 
0052     void renderSheet(QPainter& painter, MusicCore::Sheet* sheet, int firstSystem, int lastSystem);
0053     void renderPart(QPainter& painter, MusicCore::Part* part, int firstBar, int lastBar, const QColor& color = Qt::black);
0054     void renderStaff(QPainter& painter, MusicCore::Staff* staff, int firstBar, int lastBar, const QColor& color = Qt::black);
0055     void renderVoice(QPainter& painter, MusicCore::Voice* voice, int firstBar, int lastBar, const QColor& color = Qt::black);
0056     void renderElement(QPainter& painter, MusicCore::VoiceElement* element, MusicCore::Voice* voice, const QPointF& pos, RenderState& state,  const QColor& color = Qt::black);
0057     void renderStaffElement(QPainter& painter, MusicCore::StaffElement* element, const QPointF& pos, RenderState& state, const QColor& color = Qt::black);
0058 
0059     void renderClef(QPainter& painter, MusicCore::Clef* clef, const QPointF& pos, RenderState& state, const QColor& color = Qt::black, bool ignoreOwnPos = false);
0060     void renderKeySignature(QPainter& painter, MusicCore::KeySignature* keySignature, const QPointF& pos, RenderState& state, const QColor& color = Qt::black, bool ignoreOwnPos = false);
0061     void renderTimeSignature(QPainter& painter, MusicCore::TimeSignature* timeSignature, const QPointF& pos, const QColor& color = Qt::black);
0062     void renderChord(QPainter& painter, MusicCore::Chord* chord, MusicCore::Voice* voice, const QPointF& ref, const QColor& color = Qt::black);
0063     void renderRest(QPainter& painter, MusicCore::Duration duration, const QPointF& pos, const QColor& color = Qt::black);
0064     void renderNote(QPainter& painter, MusicCore::Duration duration, const QPointF& pos, qreal stemLength, const QColor& color = Qt::black);
0065     void renderAccidental(QPainter& painter, int accidentals, const QPointF& pos, const QColor& color = Qt::black);
0066 private:
0067     MusicStyle* m_style;
0068     bool m_debug;
0069 };
0070 
0071 #endif // MUSIC_RENDERER_H