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
|
|
|
|
//=============================================================================
|
|
|
|
|
|
|
|
#include "breath.h"
|
|
|
|
#include "sym.h"
|
|
|
|
#include "system.h"
|
|
|
|
#include "segment.h"
|
|
|
|
#include "measure.h"
|
|
|
|
#include "score.h"
|
2014-04-09 16:09:21 +02:00
|
|
|
#include "xml.h"
|
2019-03-24 22:19:09 +01:00
|
|
|
#include "staff.h"
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2013-05-13 18:49:17 +02:00
|
|
|
namespace Ms {
|
|
|
|
|
2016-09-19 11:28:36 +02:00
|
|
|
const std::vector<BreathType> Breath::breathList {
|
|
|
|
{ SymId::breathMarkComma, false, 0.0 },
|
|
|
|
{ SymId::breathMarkTick, false, 0.0 },
|
|
|
|
{ SymId::breathMarkSalzedo, false, 0.0 },
|
|
|
|
{ SymId::breathMarkUpbow, false, 0.0 },
|
2019-01-21 13:09:26 +01:00
|
|
|
{ SymId::caesuraCurved, true, 2.0 },
|
|
|
|
{ SymId::caesura, true, 2.0 },
|
|
|
|
{ SymId::caesuraShort, true, 2.0 },
|
|
|
|
{ SymId::caesuraThick, true, 2.0 },
|
2012-05-26 14:26:10 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// Breath
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
Breath::Breath(Score* s)
|
2018-07-04 12:41:03 +02:00
|
|
|
: Element(s, ElementFlag::MOVABLE)
|
2012-05-26 14:26:10 +02:00
|
|
|
{
|
2016-09-19 11:28:36 +02:00
|
|
|
_symId = SymId::breathMarkComma;
|
2015-01-29 22:37:39 +01:00
|
|
|
_pause = 0.0;
|
2012-05-26 14:26:10 +02:00
|
|
|
}
|
|
|
|
|
2016-09-19 11:28:36 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// isCaesura
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
bool Breath::isCaesura() const
|
|
|
|
{
|
|
|
|
for (const BreathType& bt : breathList) {
|
|
|
|
if (bt.id == _symId)
|
|
|
|
return bt.isCaesura;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// layout
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
void Breath::layout()
|
|
|
|
{
|
2019-01-17 23:13:31 +01:00
|
|
|
bool palette = (track() == -1);
|
|
|
|
if (!palette) {
|
|
|
|
if (isCaesura())
|
2019-03-29 19:53:55 +01:00
|
|
|
setPos(rxpos(), spatium());
|
2019-01-17 23:13:31 +01:00
|
|
|
else if ((score()->styleSt(Sid::MusicalSymbolFont) == "Emmentaler") && (symId() == SymId::breathMarkComma))
|
2019-03-29 19:53:55 +01:00
|
|
|
setPos(rxpos(), 0.5 * spatium());
|
2019-01-17 23:13:31 +01:00
|
|
|
else
|
2019-03-29 19:53:55 +01:00
|
|
|
setPos(rxpos(), -0.5 * spatium());
|
2019-01-17 23:13:31 +01:00
|
|
|
}
|
2016-09-19 11:28:36 +02:00
|
|
|
setbbox(symBbox(_symId));
|
2012-05-26 14:26:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// write
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
2016-11-19 11:51:21 +01:00
|
|
|
void Breath::write(XmlWriter& xml) const
|
2012-05-26 14:26:10 +02:00
|
|
|
{
|
2014-08-15 17:20:20 +02:00
|
|
|
if (!xml.canWrite(this))
|
|
|
|
return;
|
2018-09-26 12:20:00 +02:00
|
|
|
xml.stag(this);
|
2018-03-27 15:36:00 +02:00
|
|
|
writeProperty(xml, Pid::SYMBOL);
|
|
|
|
writeProperty(xml, Pid::PAUSE);
|
2012-05-26 14:26:10 +02:00
|
|
|
Element::writeProperties(xml);
|
|
|
|
xml.etag();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// read
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
2013-01-11 18:10:18 +01:00
|
|
|
void Breath::read(XmlReader& e)
|
2012-05-26 14:26:10 +02:00
|
|
|
{
|
2013-01-11 18:10:18 +01:00
|
|
|
while (e.readNextStartElement()) {
|
2015-01-29 22:37:39 +01:00
|
|
|
const QStringRef& tag(e.name());
|
2016-09-19 11:28:36 +02:00
|
|
|
if (tag == "subtype") { // obsolete
|
|
|
|
switch (e.readInt()) {
|
|
|
|
case 0:
|
|
|
|
case 1:
|
|
|
|
_symId = SymId::breathMarkComma;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
_symId = SymId::caesuraCurved;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
_symId = SymId::caesura;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (tag == "symbol")
|
|
|
|
_symId = Sym::name2id(e.readElementText());
|
2015-01-29 22:37:39 +01:00
|
|
|
else if (tag == "pause")
|
|
|
|
_pause = e.readDouble();
|
2012-05-26 14:26:10 +02:00
|
|
|
else if (!Element::readProperties(e))
|
2013-01-11 18:10:18 +01:00
|
|
|
e.unknown();
|
2012-05-26 14:26:10 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-24 22:19:09 +01:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// mag
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
qreal Breath::mag() const
|
|
|
|
{
|
|
|
|
return staff() ? staff()->mag(tick()) : 1.0;
|
|
|
|
}
|
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// draw
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
void Breath::draw(QPainter* p) const
|
|
|
|
{
|
|
|
|
p->setPen(curColor());
|
2016-09-19 11:28:36 +02:00
|
|
|
drawSymbol(_symId, p);
|
2012-05-26 14:26:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// pagePos
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
QPointF Breath::pagePos() const
|
|
|
|
{
|
|
|
|
if (parent() == 0)
|
|
|
|
return pos();
|
|
|
|
System* system = segment()->measure()->system();
|
|
|
|
qreal yp = y();
|
|
|
|
if (system)
|
|
|
|
yp += system->staff(staffIdx())->y() + system->y();
|
|
|
|
return QPointF(pageX(), yp);
|
|
|
|
}
|
|
|
|
|
2015-01-29 22:37:39 +01:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// getProperty
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
2018-03-27 15:36:00 +02:00
|
|
|
QVariant Breath::getProperty(Pid propertyId) const
|
2015-01-29 22:37:39 +01:00
|
|
|
{
|
2016-09-19 11:28:36 +02:00
|
|
|
switch (propertyId) {
|
2018-03-27 15:36:00 +02:00
|
|
|
case Pid::SYMBOL:
|
2016-09-19 13:59:57 +02:00
|
|
|
return QVariant::fromValue(_symId);
|
2018-03-27 15:36:00 +02:00
|
|
|
case Pid::PAUSE:
|
2015-01-29 22:37:39 +01:00
|
|
|
return _pause;
|
|
|
|
default:
|
|
|
|
return Element::getProperty(propertyId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// setProperty
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
2018-03-27 15:36:00 +02:00
|
|
|
bool Breath::setProperty(Pid propertyId, const QVariant& v)
|
2015-01-29 22:37:39 +01:00
|
|
|
{
|
2016-09-19 11:28:36 +02:00
|
|
|
switch (propertyId) {
|
2018-03-27 15:36:00 +02:00
|
|
|
case Pid::SYMBOL:
|
2016-09-19 13:59:57 +02:00
|
|
|
setSymId(v.value<SymId>());
|
|
|
|
break;
|
2016-09-19 11:28:36 +02:00
|
|
|
|
2018-03-27 15:36:00 +02:00
|
|
|
case Pid::PAUSE:
|
2015-01-29 22:37:39 +01:00
|
|
|
setPause(v.toDouble());
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if (!Element::setProperty(propertyId, v))
|
|
|
|
return false;
|
|
|
|
break;
|
|
|
|
}
|
2016-06-14 10:32:34 +02:00
|
|
|
triggerLayout();
|
2015-01-29 22:37:39 +01:00
|
|
|
setGenerated(false);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// propertyDefault
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
2018-03-27 15:36:00 +02:00
|
|
|
QVariant Breath::propertyDefault(Pid id) const
|
2015-01-29 22:37:39 +01:00
|
|
|
{
|
|
|
|
switch(id) {
|
2018-03-27 15:36:00 +02:00
|
|
|
case Pid::PAUSE:
|
2015-01-29 22:37:39 +01:00
|
|
|
return 0.0;
|
|
|
|
default:
|
|
|
|
return Element::propertyDefault(id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-20 22:48:34 +02:00
|
|
|
//---------------------------------------------------------
|
2017-05-12 20:16:02 +02:00
|
|
|
// nextSegmentElement
|
2014-06-20 22:48:34 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
|
2017-05-12 20:16:02 +02:00
|
|
|
Element* Breath::nextSegmentElement()
|
2014-06-20 22:48:34 +02:00
|
|
|
{
|
|
|
|
return segment()->firstInNextSegments(staffIdx());
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
2017-05-12 20:16:02 +02:00
|
|
|
// prevSegmentElement
|
2014-06-20 22:48:34 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
|
2017-05-12 20:16:02 +02:00
|
|
|
Element* Breath::prevSegmentElement()
|
2014-06-20 22:48:34 +02:00
|
|
|
{
|
|
|
|
return segment()->lastInPrevSegments(staffIdx());
|
|
|
|
}
|
2014-07-10 14:13:37 +02:00
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// accessibleInfo
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
2016-02-04 17:06:32 +01:00
|
|
|
QString Breath::accessibleInfo() const
|
2014-07-10 14:13:37 +02:00
|
|
|
{
|
2016-09-19 11:28:36 +02:00
|
|
|
return Sym::id2userName(_symId);
|
2014-07-10 14:13:37 +02:00
|
|
|
}
|
2013-05-13 18:49:17 +02:00
|
|
|
}
|
|
|
|
|