MuseScore  3.4
Music composition and notation
stem.h
Go to the documentation of this file.
1 //=============================================================================
2 // MuseScore
3 // Music Composition & Notation
4 //
5 // Copyright (C) 2010-2011 Werner Schweer
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 __STEM_H__
14 #define __STEM_H__
15 
16 #include "element.h"
17 
18 namespace Ms {
19 
20 class Chord;
21 
22 //---------------------------------------------------------
23 // @@ Stem
25 //---------------------------------------------------------
26 
27 class Stem final : public Element {
28  QLineF line; // p1 is attached to notehead
29  qreal _lineWidth;
30  qreal _userLen;
31  qreal _len { 0.0 }; // always positive
32 
33  public:
34  Stem(Score* = 0);
35  Stem &operator=(const Stem&) = delete;
36 
37  virtual Stem* clone() const override { return new Stem(*this); }
38  virtual ElementType type() const override { return ElementType::STEM; }
39  virtual void draw(QPainter*) const override;
40  virtual bool isEditable() const override { return true; }
41  virtual void layout() override;
42  virtual void spatiumChanged(qreal /*oldValue*/, qreal /*newValue*/) override;
43 
44  virtual void startEdit(EditData&) override;
45  virtual void editDrag(EditData&) override;
46  virtual void write(XmlWriter& xml) const override;
47  virtual void read(XmlReader& e) override;
48  virtual bool readProperties(XmlReader&) override;
49  virtual void reset() override;
50  virtual bool acceptDrop(EditData&) const override;
51  virtual Element* drop(EditData&) override;
52 
53  virtual QVariant getProperty(Pid propertyId) const override;
54  virtual bool setProperty(Pid propertyId, const QVariant&) override;
55  virtual QVariant propertyDefault(Pid id) const override;
56 
57  virtual int vStaffIdx() const override;
58 
59  Chord* chord() const { return toChord(parent()); }
60  bool up() const;
61 
62  qreal userLen() const { return _userLen; }
63  void setUserLen(qreal l) { _userLen = l; }
64 
65  qreal lineWidth() const { return _lineWidth; }
66  void setLineWidth(qreal w) { _lineWidth = w; }
67 
68  void setLen(qreal l);
69  qreal len() const { return _len; }
70 
71  QPointF hookPos() const;
72  qreal stemLen() const;
73  QPointF p2() const { return line.p2(); }
74 
76  int gripsCount() const override { return 1; }
77  Grip initialEditModeGrip() const override { return Grip::START; }
78  Grip defaultGrip() const override { return Grip::START; }
79  std::vector<QPointF> gripsPositions(const EditData&) const override;
80  };
81 
82 
83 } // namespace Ms
84 #endif
85 
qreal len() const
Definition: stem.h:69
void setLineWidth(qreal w)
Definition: stem.h:66
qreal stemLen() const
Definition: stem.cpp:67
Stem & operator=(const Stem &)=delete
qreal _userLen
Definition: stem.h:30
Pid
Definition: property.h:62
Definition: xml.h:67
bool up() const
Definition: stem.cpp:58
virtual void layout() override
Definition: stem.cpp:81
Graphic representation of a note stem.
Definition: stem.h:27
Grip initialEditModeGrip() const override
Definition: stem.h:77
virtual bool setProperty(Pid propertyId, const QVariant &) override
Definition: stem.cpp:354
int gripsCount() const override
Definition: stem.h:76
Base class of score layout elements.
Definition: element.h:158
Grip defaultGrip() const override
Definition: stem.h:78
virtual bool acceptDrop(EditData &) const override
Return true if this element accepts a drop at canvas relative pos of given element type and subtype...
Definition: stem.cpp:302
Element * parent() const
Definition: element.h:192
virtual Stem * clone() const override
Definition: stem.h:37
virtual void draw(QPainter *) const override
Definition: stem.cpp:148
Definition: score.h:391
EditBehavior normalModeEditBehavior() const override
Definition: stem.h:75
virtual bool readProperties(XmlReader &) override
Definition: stem.cpp:239
virtual int vStaffIdx() const override
Definition: stem.cpp:49
void setLen(qreal l)
Definition: stem.cpp:128
qreal lineWidth() const
Definition: stem.h:65
virtual QVariant getProperty(Pid propertyId) const override
Definition: stem.cpp:336
virtual Pid propertyId(const QStringRef &xmlName) const override
Definition: element.cpp:1326
Grip
Definition: element.h:43
Definition: aeolus.cpp:26
virtual void startEdit(EditData &) override
Definition: stem.cpp:267
qreal _len
Definition: stem.h:31
virtual void reset() override
Definition: stem.cpp:292
qreal userLen() const
Definition: stem.h:62
Stem(Score *=0)
Definition: stem.cpp:38
Definition: xml.h:218
QPointF hookPos() const
Definition: stem.cpp:396
virtual void editDrag(EditData &) override
Definition: stem.cpp:278
Chord * chord() const
Definition: stem.h:59
Graphic representation of a chord.
Definition: chord.h:55
qreal _lineWidth
Definition: stem.h:29
virtual bool isEditable() const override
Definition: stem.h:40
Definition: element.h:111
virtual QVariant propertyDefault(Pid id) const override
Definition: stem.cpp:377
virtual ElementType type() const override
Definition: stem.h:38
virtual void spatiumChanged(qreal, qreal) override
Definition: stem.cpp:138
ElementType
Definition: types.h:34
virtual void write(XmlWriter &xml) const override
Definition: stem.cpp:214
std::vector< QPointF > gripsPositions(const EditData &) const override
Definition: stem.cpp:258
QLineF line
Definition: stem.h:28
void setUserLen(qreal l)
Definition: stem.h:63
QPointF p2() const
Definition: stem.h:73
EditBehavior
Definition: element.h:173
virtual void read(XmlReader &e) override
Definition: stem.cpp:227
virtual Element * drop(EditData &) override
Handle a dropped element at canvas relative pos of given element type and subtype.
Definition: stem.cpp:315