annotate base/Selection.h @ 1478:8ff5505ad28d plugin-path-config

Get an expected value
author Chris Cannam
date Thu, 07 Jun 2018 16:40:28 +0100
parents 6e9615bde1f9
children c01cbe41aeb5
rev   line source
Chris@49 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@8 2
Chris@8 3 /*
Chris@52 4 Sonic Visualiser
Chris@52 5 An audio file viewer and annotation editor.
Chris@52 6 Centre for Digital Music, Queen Mary, University of London.
Chris@52 7 This file copyright 2006 Chris Cannam.
Chris@8 8
Chris@52 9 This program is free software; you can redistribute it and/or
Chris@52 10 modify it under the terms of the GNU General Public License as
Chris@52 11 published by the Free Software Foundation; either version 2 of the
Chris@52 12 License, or (at your option) any later version. See the file
Chris@52 13 COPYING included with this distribution for more information.
Chris@8 14 */
Chris@8 15
cannam@1452 16 #ifndef SV_SELECTION_H
cannam@1452 17 #define SV_SELECTION_H
Chris@8 18
Chris@8 19 #include <cstddef>
Chris@24 20 #include <set>
Chris@8 21
Chris@46 22 #include "XmlExportable.h"
Chris@1038 23 #include "BaseTypes.h"
Chris@46 24
Chris@925 25 /**
Chris@925 26 * A selection object simply represents a range in time, via start and
Chris@925 27 * end frame.
Chris@925 28 *
Chris@925 29 * The end frame is the index of the frame just *after* the end of the
Chris@925 30 * selection. For example a selection of length 10 frames starting at
Chris@925 31 * time 0 will have start frame 0 and end frame 10. This will be
Chris@925 32 * contiguous with (rather than overlapping with) a selection that
Chris@925 33 * starts at frame 10.
Chris@925 34 *
Chris@925 35 * Any selection with equal start and end frames is empty,
Chris@925 36 * representing "no selection". All empty selections are equal under
Chris@925 37 * the comparison operators. The default constructor makes an empty
Chris@925 38 * selection with start and end frames equal to zero.
Chris@925 39 */
Chris@8 40 class Selection
Chris@8 41 {
Chris@8 42 public:
Chris@8 43 Selection();
Chris@1038 44 Selection(sv_frame_t startFrame, sv_frame_t endFrame);
Chris@8 45 Selection(const Selection &);
Chris@8 46 Selection &operator=(const Selection &);
Chris@8 47 virtual ~Selection();
Chris@8 48
Chris@8 49 bool isEmpty() const;
Chris@1038 50 sv_frame_t getStartFrame() const;
Chris@1038 51 sv_frame_t getEndFrame() const;
Chris@1038 52 bool contains(sv_frame_t frame) const;
Chris@8 53
Chris@8 54 bool operator<(const Selection &) const;
Chris@8 55 bool operator==(const Selection &) const;
Chris@8 56
Chris@8 57 protected:
Chris@1038 58 sv_frame_t m_startFrame;
Chris@1038 59 sv_frame_t m_endFrame;
Chris@8 60 };
Chris@8 61
Chris@46 62 class MultiSelection : public XmlExportable
Chris@24 63 {
Chris@24 64 public:
Chris@24 65 MultiSelection();
Chris@24 66 virtual ~MultiSelection();
Chris@24 67
Chris@24 68 typedef std::set<Selection> SelectionList;
Chris@24 69
Chris@24 70 const SelectionList &getSelections() const;
Chris@24 71 void setSelection(const Selection &selection);
Chris@24 72 void addSelection(const Selection &selection);
Chris@24 73 void removeSelection(const Selection &selection);
Chris@24 74 void clearSelections();
Chris@24 75
Chris@1038 76 void getExtents(sv_frame_t &startFrame, sv_frame_t &endFrame) const;
Chris@300 77
Chris@24 78 /**
Chris@24 79 * Return the selection that contains a given frame.
Chris@24 80 * If defaultToFollowing is true, and if the frame is not in a
Chris@24 81 * selected area, return the next selection after the given frame.
Chris@24 82 * Return the empty selection if no appropriate selection is found.
Chris@24 83 */
Chris@1038 84 Selection getContainingSelection(sv_frame_t frame, bool defaultToFollowing) const;
Chris@24 85
Chris@314 86 virtual void toXml(QTextStream &stream, QString indent = "",
Chris@314 87 QString extraAttributes = "") const;
Chris@46 88
Chris@24 89 protected:
Chris@24 90 SelectionList m_selections;
Chris@24 91 };
Chris@24 92
Chris@24 93
Chris@8 94 #endif