2012-05-26 14:26:10 +02:00
|
|
|
//=============================================================================
|
|
|
|
// MuseScore
|
|
|
|
// Music Composition & Notation
|
|
|
|
//
|
|
|
|
// Copyright (C) 2002-2011 Werner Schweer
|
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License version 2
|
|
|
|
// as published by the Free Software Foundation and appearing in
|
|
|
|
// the file LICENCE.GPL
|
|
|
|
//=============================================================================
|
|
|
|
|
|
|
|
#ifndef __SYSTEM_H__
|
|
|
|
#define __SYSTEM_H__
|
|
|
|
|
|
|
|
/**
|
|
|
|
\file
|
2012-07-25 11:49:34 +02:00
|
|
|
Definition of classes SysStaff and System
|
2012-05-26 14:26:10 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "element.h"
|
|
|
|
#include "spatium.h"
|
2015-07-25 08:43:02 +02:00
|
|
|
#include "symbol.h"
|
2018-09-03 09:54:09 +02:00
|
|
|
#include "skyline.h"
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2013-05-13 18:49:17 +02:00
|
|
|
namespace Ms {
|
2012-05-26 14:26:10 +02:00
|
|
|
class Staff;
|
|
|
|
class StaffLines;
|
|
|
|
class Clef;
|
|
|
|
class Page;
|
|
|
|
class Bracket;
|
|
|
|
class Lyrics;
|
|
|
|
class Segment;
|
|
|
|
class MeasureBase;
|
|
|
|
class Text;
|
|
|
|
class InstrumentName;
|
|
|
|
class SpannerSegment;
|
|
|
|
class VBox;
|
2012-10-11 11:14:45 +02:00
|
|
|
class BarLine;
|
2012-05-26 14:26:10 +02:00
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// SysStaff
|
2018-09-03 09:54:09 +02:00
|
|
|
/// One staff in a System.
|
2012-05-26 14:26:10 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
class SysStaff
|
|
|
|
{
|
2016-04-19 16:56:28 +02:00
|
|
|
QRectF _bbox; // Bbox of StaffLines.
|
2018-09-03 09:54:09 +02:00
|
|
|
Skyline _skyline;
|
2016-04-19 16:56:28 +02:00
|
|
|
qreal _yOff { 0 }; // offset of top staff line within bbox
|
2020-08-07 12:25:30 +02:00
|
|
|
qreal _continuousDist { -1.0 }; // distance for continuous mode
|
2016-04-19 16:56:28 +02:00
|
|
|
bool _show { true }; // derived from Staff or false if empty
|
|
|
|
// staff is hidden
|
2012-05-26 14:26:10 +02:00
|
|
|
public:
|
2019-11-20 21:42:09 +01:00
|
|
|
//int idx { 0 };
|
2012-05-26 14:26:10 +02:00
|
|
|
QList<InstrumentName*> instrumentNames;
|
|
|
|
|
|
|
|
const QRectF& bbox() const { return _bbox; }
|
2013-01-02 09:29:17 +01:00
|
|
|
QRectF& bbox() { return _bbox; }
|
2012-05-26 14:26:10 +02:00
|
|
|
void setbbox(const QRectF& r) { _bbox = r; }
|
2016-02-16 21:21:28 +01:00
|
|
|
qreal y() const { return _bbox.y() + _yOff; }
|
|
|
|
void setYOff(qreal offset) { _yOff = offset; }
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2020-08-07 12:25:30 +02:00
|
|
|
qreal continuousDist() const { return _continuousDist; }
|
|
|
|
void setContinuousDist(qreal val) { _continuousDist = val; }
|
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
bool show() const { return _show; }
|
|
|
|
void setShow(bool v) { _show = v; }
|
2018-09-11 16:26:27 +02:00
|
|
|
|
2018-09-03 09:54:09 +02:00
|
|
|
const Skyline& skyline() const { return _skyline; }
|
|
|
|
Skyline& skyline() { return _skyline; }
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2016-04-19 16:56:28 +02:00
|
|
|
SysStaff() {}
|
2012-05-26 14:26:10 +02:00
|
|
|
~SysStaff();
|
|
|
|
};
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
2017-07-17 15:09:37 +02:00
|
|
|
// System
|
2014-05-16 13:44:32 +02:00
|
|
|
/// One row of measures for all instruments;
|
|
|
|
/// a complete piece of the timeline.
|
2012-05-26 14:26:10 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
|
2017-12-21 14:03:45 +01:00
|
|
|
class System final : public Element
|
|
|
|
{
|
2020-03-20 15:52:52 +01:00
|
|
|
SystemDivider* _systemDividerLeft { nullptr }; // to the next system
|
|
|
|
SystemDivider* _systemDividerRight { nullptr };
|
2016-02-10 13:40:34 +01:00
|
|
|
|
2016-01-04 14:48:58 +01:00
|
|
|
std::vector<MeasureBase*> ml;
|
2012-05-26 14:26:10 +02:00
|
|
|
QList<SysStaff*> _staves;
|
2012-10-12 15:36:57 +02:00
|
|
|
QList<Bracket*> _brackets;
|
2015-01-05 13:17:04 +01:00
|
|
|
QList<SpannerSegment*> _spannerSegments;
|
2012-10-12 15:36:57 +02:00
|
|
|
|
2020-03-20 15:52:52 +01:00
|
|
|
qreal _leftMargin { 0.0 }; ///< left margin for instrument name, brackets etc.
|
|
|
|
mutable bool fixedDownDistance { false };
|
|
|
|
qreal _distance { 0.0 }; // temp. variable used during layout
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2019-11-20 21:42:09 +01:00
|
|
|
int firstVisibleSysStaff() const;
|
|
|
|
int lastVisibleSysStaff() const;
|
2018-11-02 11:59:15 +01:00
|
|
|
|
2019-03-18 12:54:42 +01:00
|
|
|
int getBracketsColumnsCount();
|
|
|
|
void setBracketsXPosition(const qreal xOffset);
|
|
|
|
Bracket* createBracket(Ms::BracketItem* bi, int column, int staffIdx, QList<Ms::Bracket*>& bl, Measure* measure);
|
|
|
|
|
|
|
|
public:
|
2012-05-26 14:26:10 +02:00
|
|
|
System(Score*);
|
|
|
|
~System();
|
|
|
|
|
Create Score Tree Model
This commit adds virtual functions treeChild, treeParent and
treeChildCount to ScoreElement and implements them in most non-leaf-node
classes. An iterator is also added to ScoreElement class to iterate over
the children of any element.
In this model, Spanners, Beams and Ties are given a single parent, which
is the starting element of the spanner, beam or tie. Also, to ensure
consistency in the model, spanners, beams, and ties appear in the
children list only for their starting element. Children of spanner
elements are SpannerSegments, one for each system the spanner appears
in.
2020-06-19 19:46:59 +02:00
|
|
|
// Score Tree functions
|
|
|
|
ScoreElement* treeParent() const override;
|
|
|
|
ScoreElement* treeChild(int idx) const override;
|
|
|
|
int treeChildCount() const override;
|
|
|
|
|
2020-03-25 15:06:32 +01:00
|
|
|
System* clone() const override { return new System(*this); }
|
|
|
|
ElementType type() const override { return ElementType::SYSTEM; }
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2020-03-25 15:06:32 +01:00
|
|
|
void add(Element*) override;
|
|
|
|
void remove(Element*) override;
|
|
|
|
void change(Element* o, Element* n) override;
|
|
|
|
void write(XmlWriter&) const override;
|
|
|
|
void read(XmlReader&) override;
|
|
|
|
|
|
|
|
void scanElements(void* data, void (* func)(void*, Element*), bool all=true) override;
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2017-03-14 17:00:38 +01:00
|
|
|
void appendMeasure(MeasureBase*);
|
2018-12-20 16:53:14 +01:00
|
|
|
void removeMeasure(MeasureBase*);
|
|
|
|
void removeLastMeasure();
|
2017-03-14 17:00:38 +01:00
|
|
|
|
2016-01-04 14:48:58 +01:00
|
|
|
Page* page() const { return (Page*)parent(); }
|
|
|
|
|
2016-12-14 09:56:16 +01:00
|
|
|
void layoutSystem(qreal);
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2019-03-03 00:26:19 +01:00
|
|
|
void addBrackets(Measure* measure);
|
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
void layout2(); ///< Called after Measure layout.
|
|
|
|
void clear(); ///< Clear measure list.
|
|
|
|
|
|
|
|
QRectF bboxStaff(int staff) const { return _staves[staff]->bbox(); }
|
|
|
|
QList<SysStaff*>* staves() { return &_staves; }
|
|
|
|
const QList<SysStaff*>* staves() const { return &_staves; }
|
2013-08-30 12:46:15 +02:00
|
|
|
qreal staffYpage(int staffIdx) const;
|
2016-01-23 19:21:21 +01:00
|
|
|
qreal staffCanvasYpage(int staffIdx) const;
|
2012-05-26 14:26:10 +02:00
|
|
|
SysStaff* staff(int staffIdx) const { return _staves[staffIdx]; }
|
|
|
|
|
2016-02-10 13:40:34 +01:00
|
|
|
bool pageBreak() const;
|
2012-05-26 14:26:10 +02:00
|
|
|
|
|
|
|
SysStaff* insertStaff(int);
|
|
|
|
void removeStaff(int);
|
2019-10-22 12:56:06 +02:00
|
|
|
void adjustStavesNumber(int);
|
2012-05-26 14:26:10 +02:00
|
|
|
|
|
|
|
int y2staff(qreal y) const;
|
2020-01-29 10:38:02 +01:00
|
|
|
int searchStaff(qreal y, int preferredStaff = -1, qreal spacingFactor = 0.5) const;
|
2019-01-30 15:13:54 +01:00
|
|
|
void setInstrumentNames(bool longName, Fraction tick = { 0,1 });
|
|
|
|
Fraction snap(const Fraction& tick, const QPointF p) const;
|
|
|
|
Fraction snapNote(const Fraction& tick, const QPointF p, int staff) const;
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2016-01-04 14:48:58 +01:00
|
|
|
const std::vector<MeasureBase*>& measures() const { return ml; }
|
|
|
|
|
2012-09-05 12:14:58 +02:00
|
|
|
MeasureBase* measure(int idx) { return ml[idx]; }
|
2012-05-26 14:26:10 +02:00
|
|
|
Measure* firstMeasure() const;
|
|
|
|
Measure* lastMeasure() const;
|
2019-01-30 15:13:54 +01:00
|
|
|
Fraction endTick() const;
|
2012-05-26 14:26:10 +02:00
|
|
|
|
|
|
|
MeasureBase* nextMeasure(const MeasureBase*) const;
|
|
|
|
|
|
|
|
qreal leftMargin() const { return _leftMargin; }
|
2018-06-27 11:16:56 +02:00
|
|
|
Box* vbox() const;
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2016-02-04 11:27:47 +01:00
|
|
|
const QList<Bracket*>& brackets() const { return _brackets; }
|
2013-06-10 11:03:34 +02:00
|
|
|
|
2013-07-24 14:33:35 +02:00
|
|
|
QList<SpannerSegment*>& spannerSegments() { return _spannerSegments; }
|
|
|
|
const QList<SpannerSegment*>& spannerSegments() const { return _spannerSegments; }
|
2014-06-20 22:48:34 +02:00
|
|
|
|
2016-02-10 13:40:34 +01:00
|
|
|
SystemDivider* systemDividerLeft() const { return _systemDividerLeft; }
|
|
|
|
SystemDivider* systemDividerRight() const { return _systemDividerRight; }
|
|
|
|
|
2020-03-25 15:06:32 +01:00
|
|
|
Element* nextSegmentElement() override;
|
|
|
|
Element* prevSegmentElement() override;
|
2016-01-04 14:48:58 +01:00
|
|
|
|
|
|
|
qreal minDistance(System*) const;
|
2018-09-11 16:26:27 +02:00
|
|
|
qreal topDistance(int staffIdx, const SkylineLine&) const;
|
|
|
|
qreal bottomDistance(int staffIdx, const SkylineLine&) const;
|
2016-01-04 14:48:58 +01:00
|
|
|
qreal minTop() const;
|
|
|
|
qreal minBottom() const;
|
2019-02-23 03:55:29 +01:00
|
|
|
qreal spacerDistance(bool up) const;
|
2016-02-04 11:27:47 +01:00
|
|
|
|
|
|
|
void moveBracket(int staffIdx, int srcCol, int dstCol);
|
2016-10-12 20:06:46 +02:00
|
|
|
bool hasFixedDownDistance() const { return fixedDownDistance; }
|
2017-06-02 10:27:32 +02:00
|
|
|
int firstVisibleStaff() const;
|
2017-06-02 11:59:32 +02:00
|
|
|
int nextVisibleStaff(int) const;
|
2017-07-17 15:09:37 +02:00
|
|
|
qreal distance() const { return _distance; }
|
|
|
|
void setDistance(qreal d) { _distance = d; }
|
2020-03-07 07:32:57 +01:00
|
|
|
|
|
|
|
int firstSysStaffOfPart(const Part* part) const;
|
|
|
|
int firstVisibleSysStaffOfPart(const Part* part) const;
|
|
|
|
int lastSysStaffOfPart(const Part* part) const;
|
|
|
|
int lastVisibleSysStaffOfPart(const Part* part) const;
|
2012-05-26 14:26:10 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef QList<System*>::iterator iSystem;
|
|
|
|
typedef QList<System*>::const_iterator ciSystem;
|
2013-05-13 18:49:17 +02:00
|
|
|
} // namespace Ms
|
2012-05-26 14:26:10 +02:00
|
|
|
#endif
|