From 145364a8af6a1fec06556221e66d4b724a62fc9a Mon Sep 17 00:00:00 2001 From: tpearson Date: Mon, 1 Mar 2010 18:37:05 +0000 Subject: Added old abandoned KDE3 version of the RoseGarden MIDI tool git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/rosegarden@1097595 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- .../segment/segmentcanvas/CompositionModel.h | 179 +++++++++++++++++++++ 1 file changed, 179 insertions(+) create mode 100644 src/gui/editors/segment/segmentcanvas/CompositionModel.h (limited to 'src/gui/editors/segment/segmentcanvas/CompositionModel.h') diff --git a/src/gui/editors/segment/segmentcanvas/CompositionModel.h b/src/gui/editors/segment/segmentcanvas/CompositionModel.h new file mode 100644 index 0000000..beafc2e --- /dev/null +++ b/src/gui/editors/segment/segmentcanvas/CompositionModel.h @@ -0,0 +1,179 @@ + +/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ + +/* + Rosegarden + A MIDI and audio sequencer and musical notation editor. + + This program is Copyright 2000-2008 + Guillaume Laurent , + Chris Cannam , + Richard Bown + + The moral rights of Guillaume Laurent, Chris Cannam, and Richard + Bown to claim authorship of this work have been asserted. + + Other copyrights also apply to some parts of this work. Please + see the AUTHORS file and individual file headers for details. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. See the file + COPYING included with this distribution for more information. +*/ + +#ifndef _RG_COMPOSITIONMODEL_H_ +#define _RG_COMPOSITIONMODEL_H_ + +#include "base/Composition.h" +#include "base/Segment.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include "base/Event.h" +#include "CompositionRect.h" +#include "CompositionItem.h" + + +class RectRanges; +class CompositionItem; +class AudioPreviewDrawData; + + +namespace Rosegarden +{ + +class SnapGrid; +typedef std::vector PixmapArray; + + +class CompositionModel : public QObject, public CompositionObserver, public SegmentObserver +{ + Q_OBJECT +public: + + struct CompositionItemCompare { + bool operator()(const CompositionItem &c1, const CompositionItem &c2) const; + }; + + typedef std::vector rectlist; + typedef std::vector heightlist; + typedef std::vector rectcontainer; + typedef std::set itemcontainer; + + struct AudioPreviewDrawDataItem { + AudioPreviewDrawDataItem(PixmapArray p, QPoint bp, QRect r) : + pixmap(p), basePoint(bp), rect(r), resizeOffset(0) {}; + PixmapArray pixmap; + QPoint basePoint; + QRect rect; + + // when showing a segment that is being resized from the + // beginning, this contains the offset between the current + // rect of the segment and the resized one + int resizeOffset; + }; + + typedef std::vector AudioPreviewDrawData; + + struct RectRange { + std::pair range; + QPoint basePoint; + QColor color; + }; + + typedef std::vector RectRanges; + + class AudioPreviewData { + public: + AudioPreviewData(bool showMinima, unsigned int channels) : m_showMinima(showMinima), m_channels(channels) {}; + // ~AudioPreviewData(); + + bool showsMinima() { return m_showMinima; } + void setShowMinima(bool s) { m_showMinima = s; } + + unsigned int getChannels() { return m_channels; } + void setChannels(unsigned int c) { m_channels = c; } + + const std::vector &getValues() const { return m_values; } + void setValues(const std::vector&v) { m_values = v; } + + QRect getSegmentRect() { return m_segmentRect; } + void setSegmentRect(const QRect& r) { m_segmentRect = r; } + + protected: + std::vector m_values; + bool m_showMinima; + unsigned int m_channels; + QRect m_segmentRect; + + private: + // no copy ctor + AudioPreviewData(const AudioPreviewData&); + }; + + + virtual ~CompositionModel() {}; + + virtual unsigned int getNbRows() = 0; + virtual const rectcontainer& getRectanglesIn(const QRect& rect, + RectRanges* notationRects, AudioPreviewDrawData* audioRects) = 0; + + virtual heightlist getTrackDividersIn(const QRect& rect) = 0; + + virtual itemcontainer getItemsAt (const QPoint&) = 0; + virtual timeT getRepeatTimeAt (const QPoint&, const CompositionItem&) = 0; + + virtual SnapGrid& grid() = 0; + + virtual void setPointerPos(int xPos) = 0; + virtual void setSelected(const CompositionItem&, bool selected = true) = 0; + virtual bool isSelected(const CompositionItem&) const = 0; + virtual void setSelected(const itemcontainer&) = 0; + virtual void clearSelected() = 0; + virtual bool haveSelection() const = 0; + virtual bool haveMultipleSelection() const = 0; + virtual void signalSelection() = 0; + virtual void setSelectionRect(const QRect&) = 0; + virtual void finalizeSelectionRect() = 0; + virtual QRect getSelectionContentsRect() = 0; + virtual void signalContentChange() = 0; + + virtual void addRecordingItem(const CompositionItem&) = 0; + virtual void removeRecordingItem(const CompositionItem&) = 0; + virtual void clearRecordingItems() = 0; + virtual bool haveRecordingItems() = 0; + + enum ChangeType { ChangeMove, ChangeResizeFromStart, ChangeResizeFromEnd }; + + virtual void startChange(const CompositionItem&, ChangeType change) = 0; + virtual void startChangeSelection(ChangeType change) = 0; + virtual itemcontainer& getChangingItems() = 0; + virtual void endChange() = 0; + virtual ChangeType getChangeType() = 0; + + virtual void setLength(int width) = 0; + virtual int getLength() = 0; + +signals: + void needContentUpdate(); + void needContentUpdate(const QRect&); + void needArtifactsUpdate(); + +protected: + CompositionItem* m_currentCompositionItem; +}; + +class AudioPreviewThread; +class AudioPreviewUpdater; + + +} + +#endif -- cgit v1.2.1