MuseScore  3.4
Music composition and notation
ambitus.h
Go to the documentation of this file.
1 //=============================================================================
2 // MuseScore
3 // Music Composition & Notation
4 //
5 // Copyright (C) 2002-2013 Werner Schweer and others
6 //
7 // This program is free software; you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License version 2
9 // as published by the Free Software Foundation and appearing in
10 // the file LICENCE.GPL
11 //=============================================================================
12 
13 #ifndef __AMBITUS_H__
14 #define __AMBITUS_H__
15 
16 #include "element.h"
17 #include "note.h"
18 #include "accidental.h"
19 
20 namespace Ms {
21 
22 //---------------------------------------------------------
23 // @@ Ambitus
24 //---------------------------------------------------------
25 
26 class Ambitus final : public Element {
30  bool _hasLine;
35 
36  // internally managed, to optimize layout / drawing
37  QPointF _topPos; // position of top note symbol
38  QPointF _bottomPos; // position of bottom note symbol
39  QLineF _line; // the drawn line
40 
41  void normalize();
42 
43  public:
44  Ambitus(Score* s);
45  virtual Ambitus* clone() const override { return new Ambitus(*this); }
46 
47  virtual qreal mag() const override;
48 
49  void initFrom(Ambitus* a);
50 
51  // getters and setters
52  virtual ElementType type() const override { return ElementType::AMBITUS; }
55  MScore::DirectionH direction() const { return _dir; }
56  bool hasLine() const { return _hasLine; }
57  Spatium lineWidth() const { return _lineWidth; }
58  int topOctave() const { return (_topPitch / 12) - 1; }
59  int bottomOctave() const { return (_bottomPitch / 12) - 1; }
60  int topPitch() const { return _topPitch; }
61  int bottomPitch() const { return _bottomPitch; }
62  int topTpc() const { return _topTpc; }
63  int bottomTpc() const { return _bottomTpc; }
64 
65  void setNoteHeadGroup(NoteHead::Group val) { _noteHeadGroup = val; }
66  void setNoteHeadType (NoteHead::Type val) { _noteHeadType = val; }
67  void setDirection (MScore::DirectionH val) { _dir = val; }
68  void setHasLine (bool val) { _hasLine = val; }
69  void setLineWidth (Spatium val) { _lineWidth = val; }
70  void setTopPitch (int val);
71  void setBottomPitch (int val);
72  void setTopTpc (int val);
73  void setBottomTpc (int val);
74 
75  // some utility functions
76  Segment* segment() const { return (Segment*)parent(); }
77  SymId noteHead() const;
78  qreal headWidth() const;
79  void updateRange(); // scan staff up to next section break and update range pitches
80 
81  // re-implemented virtual functions
82  virtual void draw(QPainter*) const override;
83  virtual void layout() override;
84  virtual QPointF pagePos() const override;
85  virtual void read(XmlReader&) override;
86  virtual void scanElements(void* data, void (*func)(void*, Element*), bool all=true) override;
87  virtual void setTrack(int val) override;
88  virtual void write(XmlWriter&) const override;
89  virtual bool readProperties(XmlReader&) override;
90  virtual QString accessibleInfo() const override;
91 
92  // properties
93  QVariant getProperty(Pid ) const;
94  bool setProperty(Pid propertyId, const QVariant&);
95  QVariant propertyDefault(Pid id) const;
96 
97  virtual Element* nextSegmentElement() override;
98  virtual Element* prevSegmentElement() override;
99  };
100 
101 
102 } // namespace Ms
103 #endif
104 
DirectionH
Definition: mscore.h:297
Definition of class Accidental.
virtual void read(XmlReader &) override
Definition: ambitus.cpp:222
QVariant propertyDefault(Pid id) const
Definition: ambitus.cpp:717
int topOctave() const
Definition: ambitus.h:58
virtual void scanElements(void *data, void(*func)(void *, Element *), bool all=true) override
Definition: ambitus.cpp:493
int _bottomPitch
Definition: ambitus.h:33
void setBottomPitch(int val)
Definition: ambitus.cpp:137
void setNoteHeadGroup(NoteHead::Group val)
Definition: ambitus.h:65
Pid
Definition: property.h:62
bool hasLine() const
Definition: ambitus.h:56
Definition: xml.h:67
virtual void layout() override
Definition: ambitus.cpp:290
virtual void setTrack(int val) override
Definition: ambitus.cpp:91
virtual bool readProperties(XmlReader &) override
Definition: ambitus.cpp:234
void setHasLine(bool val)
Definition: ambitus.h:68
void setTopPitch(int val)
Definition: ambitus.cpp:119
NoteHead::Group noteHeadGroup() const
Definition: ambitus.h:53
virtual qreal mag() const override
Definition: ambitus.cpp:62
virtual QString accessibleInfo() const override
Definition: ambitus.cpp:765
void updateRange()
Definition: ambitus.cpp:575
QLineF _line
Definition: ambitus.h:39
SymId
Definition: sym.h:30
Base class of score layout elements.
Definition: element.h:158
NoteHead::Type _noteHeadType
Definition: ambitus.h:28
void setDirection(MScore::DirectionH val)
Definition: ambitus.h:67
Element * parent() const
Definition: element.h:192
void setTopTpc(int val)
Definition: ambitus.cpp:162
Definition: accidental.h:65
void normalize()
Definition: ambitus.cpp:557
qreal headWidth() const
Definition: ambitus.cpp:528
Definition: score.h:391
int topTpc() const
Definition: ambitus.h:62
NoteHead::Type noteHeadType() const
Definition: ambitus.h:54
MScore::DirectionH direction() const
Definition: ambitus.h:55
int _topPitch
Definition: ambitus.h:33
SymId noteHead() const
Definition: ambitus.cpp:506
int bottomTpc() const
Definition: ambitus.h:63
virtual void write(XmlWriter &) const override
Definition: ambitus.cpp:192
int bottomOctave() const
Definition: ambitus.h:59
virtual Pid propertyId(const QStringRef &xmlName) const override
Definition: element.cpp:1326
QVariant getProperty(Pid) const
Definition: ambitus.cpp:636
Segment * segment() const
Definition: ambitus.h:76
Definition: segment.h:50
int bottomPitch() const
Definition: ambitus.h:61
Definition: aeolus.cpp:26
bool _hasLine
Definition: ambitus.h:30
Definition: spatium.h:25
Definition: xml.h:218
Spatium _lineWidth
Definition: ambitus.h:31
virtual ElementType type() const override
Definition: ambitus.h:52
virtual Ambitus * clone() const override
Definition: ambitus.h:45
virtual void draw(QPainter *) const override
Definition: ambitus.cpp:453
QPointF _topPos
Definition: ambitus.h:37
Definition of classes Note and NoteHead.
int topPitch() const
Definition: ambitus.h:60
int _topTpc
Definition: ambitus.h:34
bool setProperty(Pid propertyId, const QVariant &)
Definition: ambitus.cpp:670
MScore::DirectionH _dir
Definition: ambitus.h:29
Group
Definition: note.h:56
Accidental _bottomAccid
Definition: ambitus.h:32
void initFrom(Ambitus *a)
Definition: ambitus.cpp:71
Type
Definition: note.h:129
ElementType
Definition: types.h:34
virtual Element * prevSegmentElement() override
Definition: ambitus.cpp:756
Definition: ambitus.h:26
NoteHead::Group _noteHeadGroup
Definition: ambitus.h:27
QPointF _bottomPos
Definition: ambitus.h:38
Accidental _topAccid
Definition: ambitus.h:32
void setNoteHeadType(NoteHead::Type val)
Definition: ambitus.h:66
void setBottomTpc(int val)
Definition: ambitus.cpp:175
void setLineWidth(Spatium val)
Definition: ambitus.h:69
int _bottomTpc
Definition: ambitus.h:34
Spatium lineWidth() const
Definition: ambitus.h:57
virtual Element * nextSegmentElement() override
Definition: ambitus.cpp:747
Ambitus(Score *s)
Definition: ambitus.cpp:42
virtual QPointF pagePos() const override
position in page coordinates
Definition: ambitus.cpp:540