MuseScore  3.4
Music composition and notation
line.h
Go to the documentation of this file.
1 //=============================================================================
2 // MuseScore
3 // Music Composition & Notation
4 //
5 // Copyright (C) 2002-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 __LINE_H__
14 #define __LINE_H__
15 
16 #include "spanner.h"
17 #include "mscore.h"
18 
19 namespace Ms {
20 
21 class SLine;
22 class System;
23 
24 //---------------------------------------------------------
25 // @@ LineSegment
32 //---------------------------------------------------------
33 
34 class LineSegment : public SpannerSegment {
35  protected:
36  virtual void editDrag(EditData&) override;
37  virtual bool edit(EditData&) override;
38  virtual QPointF gripAnchor(Grip) const override;
39  virtual void startEditDrag(EditData&) override;
40 
41  public:
44  LineSegment(const LineSegment&);
45  virtual void draw(QPainter*) const = 0;
46  SLine* line() const { return (SLine*)spanner(); }
47  virtual void spatiumChanged(qreal, qreal) override;
48  virtual void localSpatiumChanged(qreal, qreal) override;
49 
50  friend class SLine;
51  virtual void read(XmlReader&) override;
53 
54  virtual Element* propertyDelegate(Pid) override;
55 
57  int gripsCount() const override { return 3; }
58  Grip initialEditModeGrip() const override { return Grip::END; }
59  Grip defaultGrip() const override { return Grip::MIDDLE; }
60  std::vector<QPointF> gripsPositions(const EditData&) const override;
61 
62  virtual QLineF dragAnchor() const override;
63  };
64 
65 //---------------------------------------------------------
66 // @@ SLine
68 //---------------------------------------------------------
69 
70 class SLine : public Spanner {
71  qreal _lineWidth;
72  QColor _lineColor { MScore::defaultColor };
73  Qt::PenStyle _lineStyle { Qt::SolidLine };
74  qreal _dashLineLen { 5.0 };
75  qreal _dashGapLen { 5.0 };
76  bool _diagonal { false };
77 
78  protected:
79  virtual QPointF linePos(Grip, System** system) const;
80 
81  public:
83  SLine(const SLine&);
84 
85  virtual void layout() override;
86  virtual SpannerSegment* layoutSystem(System*) override;
87 
88  bool readProperties(XmlReader& node);
89  void writeProperties(XmlWriter& xml) const;
90  virtual LineSegment* createLineSegment() = 0;
91  void setLen(qreal l);
92  using Element::bbox;
93  virtual const QRectF& bbox() const override;
94 
95  virtual void write(XmlWriter&) const override;
96  virtual void read(XmlReader&) override;
97 
98  bool diagonal() const { return _diagonal; }
99  void setDiagonal(bool v) { _diagonal = v; }
100 
101  qreal lineWidth() const { return _lineWidth; }
102  QColor lineColor() const { return _lineColor; }
103  Qt::PenStyle lineStyle() const { return _lineStyle; }
104  void setLineWidth(const qreal& v) { _lineWidth = v; }
105  void setLineColor(const QColor& v) { _lineColor = v; }
106  void setLineStyle(Qt::PenStyle v) { _lineStyle = v; }
107 
108  qreal dashLineLen() const { return _dashLineLen; }
109  void setDashLineLen(qreal val) { _dashLineLen = val; }
110  qreal dashGapLen() const { return _dashGapLen; }
111  void setDashGapLen(qreal val) { _dashGapLen = val; }
112 
113  LineSegment* frontSegment() { return toLineSegment(Spanner::frontSegment()); }
114  const LineSegment* frontSegment() const { return toLineSegment(Spanner::frontSegment()); }
115  LineSegment* backSegment() { return toLineSegment(Spanner::backSegment()); }
116  const LineSegment* backSegment() const { return toLineSegment(Spanner::backSegment()); }
117  LineSegment* segmentAt(int n) { return toLineSegment(Spanner::segmentAt(n)); }
118  const LineSegment* segmentAt(int n) const { return toLineSegment(Spanner::segmentAt(n)); }
119 
120  virtual QVariant getProperty(Pid id) const override;
121  virtual bool setProperty(Pid propertyId, const QVariant&) override;
122  virtual QVariant propertyDefault(Pid id) const override;
123 
124  friend class LineSegment;
125  };
126 
127 
128 } // namespace Ms
129 #endif
130 
QColor lineColor() const
Definition: line.h:102
virtual void draw(QPainter *) const =0
const LineSegment * backSegment() const
Definition: line.h:116
virtual QLineF dragAnchor() const override
Definition: line.cpp:418
LineSegment(Score *s, ElementFlags f=ElementFlag::NOTHING)
Definition: line.h:43
void setLineStyle(Qt::PenStyle v)
Definition: line.h:106
virtual void writeProperties(XmlWriter &xml) const
Definition: element.cpp:516
Pid
Definition: property.h:62
void setDashLineLen(qreal val)
Definition: line.h:109
virtual QPointF gripAnchor(Grip) const override
Definition: line.cpp:94
Definition: xml.h:67
void setLineColor(const QColor &v)
Definition: line.h:105
virtual void editDrag(EditData &) override
Definition: line.cpp:325
virtual void localSpatiumChanged(qreal, qreal) override
Definition: line.cpp:392
virtual Element * propertyDelegate(Pid) override
Definition: line.cpp:402
Element::EditBehavior normalModeEditBehavior() const override
Definition: line.h:56
virtual bool edit(EditData &) override
Definition: line.cpp:151
parent: System
Definition: spanner.h:50
QFlags< ElementFlag > ElementFlags
Definition: element.h:101
Virtual base class for slurs, ties, lines etc.
Definition: spanner.h:136
System * system() const
Definition: spanner.h:80
SpannerSegment * segmentAt(int n)
Definition: spanner.h:211
Base class of score layout elements.
Definition: element.h:158
Grip defaultGrip() const override
Definition: line.h:59
virtual QVariant propertyDefault(Pid id) const override
Definition: spanner.cpp:162
Spanner * spanner() const
Definition: spanner.h:67
std::vector< QPointF > gripsPositions(const EditData &) const override
Definition: line.cpp:79
Virtual base class for segmented lines segments (OttavaSegment, HairpinSegment, TrillSegment...)
Definition: line.h:34
virtual void write(XmlWriter &) const
Definition: element.cpp:732
LineSegment * frontSegment()
Definition: line.h:113
virtual void startEditDrag(EditData &) override
Definition: line.cpp:136
Definition: score.h:391
qreal dashGapLen() const
Definition: line.h:110
static QColor defaultColor
Definition: mscore.h:328
SLine * line() const
Definition: line.h:46
bool readProperties(XmlReader &)
Definition: line.cpp:45
LineSegment * segmentAt(int n)
Definition: line.h:117
SpannerSegment * backSegment()
Definition: spanner.h:209
virtual Pid propertyId(const QStringRef &xmlName) const override
Definition: element.cpp:1326
virtual base class for Hairpin, Trill and TextLine
Definition: line.h:70
Grip
Definition: element.h:43
friend class SLine
Definition: line.h:50
virtual QVariant getProperty(Pid id) const override
Definition: spanner.cpp:127
LineSegment(Spanner *sp, Score *s, ElementFlags f=ElementFlag::NOTHING)
Definition: line.h:42
void setDashGapLen(qreal val)
Definition: line.h:111
virtual void spatiumChanged(qreal, qreal) override
Definition: line.cpp:382
Definition: aeolus.cpp:26
virtual const QRectF & bbox() const
Definition: element.h:257
Grip initialEditModeGrip() const override
Definition: line.h:58
Definition: xml.h:218
virtual void layout()
Definition: element.h:334
LineSegment * backSegment()
Definition: line.h:115
qreal lineWidth() const
Definition: line.h:101
virtual void read(XmlReader &) override
Definition: line.cpp:69
Definition: element.h:111
qreal _lineWidth
Definition: line.h:71
int gripsCount() const override
Definition: line.h:57
Qt::PenStyle lineStyle() const
Definition: line.h:103
qreal dashLineLen() const
Definition: line.h:108
virtual bool setProperty(Pid id, const QVariant &v) override
Definition: spanner.cpp:143
One row of measures for all instruments; a complete piece of the timeline.
Definition: system.h:79
const LineSegment * frontSegment() const
Definition: line.h:114
SpannerSegment * frontSegment()
Definition: spanner.h:207
void setLineWidth(const qreal &v)
Definition: line.h:104
EditBehavior
Definition: element.h:173
const LineSegment * segmentAt(int n) const
Definition: line.h:118
bool diagonal() const
Definition: line.h:98
void setDiagonal(bool v)
Definition: line.h:99